You can subscribe to this list here.
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2011 |
Jan
(7) |
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
(6) |
Jul
(21) |
Aug
(2) |
Sep
(36) |
Oct
(63) |
Nov
(82) |
Dec
|
| 2012 |
Jan
|
Feb
(14) |
Mar
(26) |
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
(1) |
Oct
(5) |
Nov
(16) |
Dec
|
| 2013 |
Jan
(1) |
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(6) |
Aug
(16) |
Sep
(7) |
Oct
(6) |
Nov
(19) |
Dec
(1) |
|
From: <da...@us...> - 2013-12-10 10:27:32
|
Revision: 347
http://sourceforge.net/p/advance-project/code/347
Author: dalmaso
Date: 2013-12-10 10:27:28 +0000 (Tue, 10 Dec 2013)
Log Message:
-----------
Sync with online version
Modified Paths:
--------------
advance-et/trunk/nbproject/build-impl.xml
advance-et/trunk/nbproject/genfiles.properties
advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/LoginServlet.java
advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/UploadXmlServlet.java
advance-et/trunk/web/WEB-INF/web.xml
advance-et/trunk/web/css/editFile.css
advance-et/trunk/web/css/fileList.css
advance-et/trunk/web/css/general.css
advance-et/trunk/web/js/editFile.js
advance-et/trunk/web/js/fileList.js
advance-et/trunk/web/pages/editFile.jsp
advance-et/trunk/web/pages/fileList.jsp
advance-et/trunk/web/pages/viewFile.jsp
Added Paths:
-----------
advance-et/trunk/ncaabracket.js
advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/DestroySessionServlet.java
advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/ServletContextListener.java
advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/SessionServletListener.java
advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/UserNameListManager.java
Modified: advance-et/trunk/nbproject/build-impl.xml
===================================================================
--- advance-et/trunk/nbproject/build-impl.xml 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/nbproject/build-impl.xml 2013-12-10 10:27:28 UTC (rev 347)
@@ -407,6 +407,11 @@
</and>
</condition>
</target>
+ <target name="-init-test-properties">
+ <property name="test.binaryincludes" value="<nothing>"/>
+ <property name="test.binarytestincludes" value=""/>
+ <property name="test.binaryexcludes" value=""/>
+ </target>
<target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/web-project/2">
<attribute default="${includes}" name="includes"/>
@@ -429,7 +434,7 @@
</sequential>
</macrodef>
</target>
- <target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
+ <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/web-project/2">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@@ -443,6 +448,9 @@
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
+ <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
+ <filename name="${test.binarytestincludes}"/>
+ </fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@@ -569,7 +577,7 @@
</sequential>
</macrodef>
</target>
- <target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
+ <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/web-project/2">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
@@ -583,6 +591,9 @@
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
+ <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
+ <filename name="${test.binarytestincludes}"/>
+ </fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@@ -835,11 +846,11 @@
pre NB7.2 profiling section; consider it deprecated
-->
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
- <target name="-profile-pre-init">
+ <target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
- <target name="-profile-post-init">
+ <target if="profiler.info.jvmargs.agent" name="-profile-post-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
@@ -887,7 +898,7 @@
<target if="has.persistence.xml" name="-copy-persistence-xml">
<mkdir dir="${build.web.dir}/WEB-INF/classes/META-INF"/>
<copy todir="${build.web.dir}/WEB-INF/classes/META-INF">
- <fileset dir="${persistence.xml.dir}" includes="persistence.xml"/>
+ <fileset dir="${persistence.xml.dir}" includes="persistence.xml orm.xml"/>
</copy>
</target>
<target name="-post-compile">
@@ -1227,7 +1238,7 @@
<jvmarg value="${profiler.j2ee.agentID}"/>
</nbstartprofiledserver>
</target>
- <target if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">
+ <target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
<nbprofiledirect>
<classpath>
Modified: advance-et/trunk/nbproject/genfiles.properties
===================================================================
--- advance-et/trunk/nbproject/genfiles.properties 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/nbproject/genfiles.properties 2013-12-10 10:27:28 UTC (rev 347)
@@ -4,5 +4,5 @@
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=363c97b5
-nbproject/build-impl.xml.script.CRC32=1c824f86
-nbproject/build-impl.xml.stylesheet.CRC32=b7883b1f@1.36.1.1
+nbproject/build-impl.xml.script.CRC32=c3a39748
+nbproject/build-impl.xml.stylesheet.CRC32=5459df51@1.43.0.1
Added: advance-et/trunk/ncaabracket.js
===================================================================
--- advance-et/trunk/ncaabracket.js (rev 0)
+++ advance-et/trunk/ncaabracket.js 2013-12-10 10:27:28 UTC (rev 347)
@@ -0,0 +1,412 @@
+var r = 320;
+
+var svg = d3.select("#chart").append("svg")
+ .attr("width", r*4)
+ .attr("height", r*3.2)
+ .style("background","#fff")
+ .append("g")
+ .attr("transform", "translate(" + r*2 + "," + (r*1.6) + ")")
+
+svg.append("text").attr("class","region")
+ .text("MIDWEST")
+ .attr("x", r*1.5)
+ .attr("y", r*1)
+ .attr("text-anchor","middle");
+
+svg.append("text").attr("class","region")
+ .text("SOUTH")
+ .attr("x", -r*1.5)
+ .attr("y", -r*1)
+ .attr("text-anchor","middle");
+
+svg.append("text").attr("class","region")
+ .text("EAST")
+ .attr("x", r*1.5)
+ .attr("y", -r*1)
+ .attr("text-anchor","middle");
+
+svg.append("text")
+ .text("WEST").attr("class","region")
+ .attr("x", -r*1.5)
+ .attr("y", r*1)
+ .attr("text-anchor","middle");
+
+function Team(name) {
+ this.name = name;
+ this.seed = 0;
+ this.region = 0;
+ this.probs = []; // prob of making it to each game
+ this.stillin = 1; // is team still in tournament?
+}
+
+function Game(num, flag) {
+ this.name = num;
+ this.region = 0;
+ this.teams = []; // possible teams playing in this game
+ this.prevGames = []; // parent games
+ this.played = flag; // has the game been played?
+}
+
+function isDefined(element, index, array) {
+ return (element != undefined);
+}
+
+function hasValue(element, index, array) {
+ if (element > 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+// recursively create the tree structure so D3 can display it correctly
+function travelTree(onegame) {
+ //document.write(onegame.name);
+ var returnArray = [];
+ var h;
+ // figure out all the child games first
+ if (onegame.prevGames.length > 0) {
+ onegame.prevGames.forEach(function (g) {
+ //document.write("-->");
+ h = new Object();
+ h.name = g.name;
+ h.children = travelTree(g);
+ h.teams = g.teams;
+ h.region = g.region;
+ h.played = g.played;
+ returnArray.push(h);
+ });
+ }
+ // in the first round, some games are not symmetric, so need to allow
+ // for specifying a team as a child
+ if (onegame.prevGames.length < 2) {
+ onegame.teams.forEach(function (t){
+ if (t.probs[onegame.name] >0) {
+ var skipThis = false;
+ if (onegame.prevGames.length == 1) {
+ onegame.prevGames[0].teams.forEach(function (t2) {
+ if (t2.name == t.name) {
+ skipThis = true;
+ }
+ });
+ }
+ if (!skipThis) {
+ h = new Object();
+ h.name = t.name;
+ h.children = [];
+ h.stillin = t.stillin;
+ h.probs = t.probs;
+ h.seed = t.seed;
+ h.region = t.region;
+ returnArray.push(h);
+ }
+ }
+ })
+ }
+ return returnArray;
+
+}
+
+
+function parseCSV(onerow, rowindex) {
+ if (rowindex == 0){
+ // first row has all the teams
+ onerow.forEach(function(oneteam, teamindex){
+ if (teamindex > 0) { // ignore entry one
+ allTeams.push(new Team(oneteam));
+ }
+ });
+ } else if (rowindex == 1) {
+ // second row is each team's seed
+ onerow.forEach(function (oneseed, teamindex) {
+ if (teamindex > 0) { // ignore entry one
+ allTeams[teamindex-1].seed = oneseed;
+ }
+ });
+ } else if (rowindex == 2) {
+ // second row is each team's regions
+ onerow.forEach(function (oneregion, teamindex) {
+ if (teamindex > 0) { // ignore entry one
+ allTeams[teamindex-1].region = oneregion;
+ }
+ });
+ } else if (rowindex == 3) {
+ // third row indicates if a team is still in the tournament
+ onerow.forEach(function (oneflag, teamindex) {
+ if (teamindex > 0) { // ignore entry one
+ allTeams[teamindex-1].stillin = oneflag;
+ }
+ });
+ } else {
+ realrowindex = rowindex-4;
+ // all other rows are games
+ onerow.forEach(function(oneprob, teamindex) {
+
+ if (teamindex == 0) { // first entry is the played flag
+ allGames.push(new Game(realrowindex, oneprob));
+ } else {
+ var thisTeam = allTeams[teamindex-1];
+ var thisGame = allGames[allGames.length-1];
+ if (oneprob > 0) {
+ thisGame.teams.push(thisTeam);
+ // find this game's ancestors
+ var lastGame = thisTeam.probs.map(hasValue).lastIndexOf(1);
+ if (lastGame > -1) {
+ if (thisGame.prevGames.length == 0) {
+ thisGame.prevGames.push(allGames[lastGame]);
+ } else {
+ var addThis = true;
+ thisGame.prevGames.forEach(function (g) {
+ if (allGames[lastGame] == g) {
+ addThis = false;
+ }
+ });
+ if (addThis) {
+ thisGame.prevGames.push(allGames[lastGame]);
+ }
+
+ }
+ }
+ }
+ thisTeam.probs[realrowindex] = oneprob;
+ }
+ });
+ }
+}
+
+function padWithSpace(num) {
+ if (num < 10) {
+ return " " + num.toString();
+ } else {
+ return num.toString();
+ }
+}
+
+// for debugging purposes
+function printTree(node) {
+ if (node.children.length > 0) {
+ document.writeln(" { name = " + node.name + ",");
+ document.write(" childen (" + node.children.length + ") = [<br> ");
+ node.children.forEach(function (c) {
+ printTree(c);
+ document.write(",");
+ });
+ document.write("] } <br>");
+ } else {
+ document.writeln("{ name = " + node.name + "}");
+ }
+
+}
+
+function teamover(t) {
+ d3.select(this).selectAll("text")
+ .transition().duration(100).attr("fill","#000");
+
+ svg.selectAll("g.futuregame").select("circle")
+ .transition().duration(100)
+ .attr("r",5) // this is in case you roll from one team to next w/o activating teamout
+ .style("fill","#ccc").style("stroke","#ccc");
+
+ t.probs.forEach(function (p, gameindex) {
+ if (p>0) {
+ if (allGames[gameindex].played==0) {
+ svg.selectAll("g.g"+gameindex).select("circle")
+ .transition().duration(100)
+ .attr("r",10)
+ .style("fill","#99c").style("stroke","#000");
+ svg.selectAll("g.g"+gameindex).append("text")
+ .text((Math.round(p*1000)/10)+"%")
+ .attr("class", "prob")
+ .attr("x", 0)
+ .attr("y", -15)
+ .attr("text-anchor", "middle")
+ .attr("transform", function(z) {return "rotate(" + (90-z.x) + ")"; })
+ .attr("fill","#11f")
+ .attr("font-size","0.9em");
+ }
+ }
+ })
+
+}
+function teamout(t,i){
+ d3.select(this).selectAll("text")
+ .transition().duration(100).attr("fill","#aaa");
+
+ svg.selectAll("g.futuregame").select("circle")
+ .transition().duration(100)
+ .attr("r",5)
+ .style("fill","#99c").style("stroke","#99c");
+
+ t.probs.forEach(function (p, gameindex) {
+ if (p>0) {
+ svg.selectAll("g.g"+gameindex).select("text.prob").remove();
+
+ }
+ });
+
+}
+
+function gameover(d, i) {
+ svg.selectAll("g.futuregame").select("circle")
+ .transition().duration(100)
+ .attr("r",5) // this is in case you roll from one team to next w/o activating teamout
+ .style("fill","#ccc").style("stroke","#ccc");
+
+ d3.select(this)
+ .transition().duration(100)
+ .attr("r",10)
+ .style("stroke", "black").style("stroke-width", "2px");
+
+ d.teams.forEach(function (t) {
+ if (t.stillin==1) {
+ var nameText = svg.selectAll("g."+t.name.toLowerCase().replace(/\W/g,"_"))
+ .selectAll("text")
+ .transition().duration(100).attr("fill", "#000");
+ svg.selectAll("g."+t.name.toLowerCase().replace(/\W/g,"_"))
+ .append("text")
+ .attr("class", "prob")
+ .text((Math.round(t.probs[d.name]*1000)/10)+"%")
+ .attr("x", function(d) { return d.x < 180 ? 10 : -10; })
+ .attr("y",10)
+ .attr("text-anchor", function(z) { return z.x < 180 ? "end" : "start"; })
+ .attr("transform", function(z) { return z.x < 180 ? null : "rotate(180)"; })
+ .attr("fill","#11f")
+ .attr("font-size","0.9em");
+ }
+ });
+}
+
+function gameout(d, i) {
+ svg.selectAll("g.futuregame").select("circle")
+ .transition().duration(100)
+ .attr("r",5)
+ .style("fill","#99c").style("stroke","#99c");
+
+ d3.select(this)
+ .transition().duration(100)
+ .attr("r",5)
+ .style("stroke", "#99c").style("stroke-width", "2px");
+
+ d.teams.forEach(function (t) {
+ if (t.stillin ==1) {
+ svg.selectAll("g."+t.name.toLowerCase().replace(/\W/g,"_"))
+ .selectAll("text")
+ .transition().duration(100).attr("fill", "#aaa");
+ svg.selectAll("g."+t.name.toLowerCase().replace(/\W/g,"_"))
+ .select("text.prob").remove();
+ }
+ });
+}
+
+
+// START MAIN JS STUFF
+//
+// these will hold the teams/games as they are being parsed from CSV
+var allTeams = [];
+var allGames = [];
+
+// read in CSV file and parse each row
+d3.text("bracket.csv", function(data) {
+
+ // save the CSV data as objects in allTeams and allGames
+ var rows = d3.csv.parseRows(data);
+ rows.forEach(parseCSV);
+
+ // generate tree structure from the data that was read in
+ var finalgame = allGames[allGames.length-1];
+ var gameTree = new Object();
+ gameTree.name = finalgame.name;
+ gameTree.children = travelTree(finalgame);
+ gameTree.teams = allTeams;
+ gameTree.played = finalgame.played;
+
+ // time to visualize!
+ var tree = d3.layout.tree()
+ .size([360, r])
+ .separation(function(a, b) {
+ if (a.region != b.region) {
+ return 1;
+ } else {
+ return (a.parent == b.parent ? 3 : 3) / a.depth;
+ }
+ });
+
+ var diagonal = d3.svg.diagonal.radial()
+ .projection(function(d) { return [d.y+5, d.x / 180 * Math.PI]; });
+
+ var nodes = tree.nodes(gameTree);
+ var links = tree.links(nodes);
+
+ var drawlink = svg.selectAll("path.link")
+ .data(links)
+ .enter()
+ .append("path")
+ .attr("class", "link")
+ .attr("d", diagonal);
+
+ var drawnode = svg.selectAll("g.node")
+ .data(nodes)
+ .enter().append("g")
+ .attr("class","node")
+ .attr("transform", function(d) { return "rotate(" + (d.x-90) + ")translate(" + d.y + ")"; })
+
+ var playedGameNodes = drawnode.filter(function (d) {
+ return ((typeof(d.name) == "number") && (d.played==1));
+ });
+
+ var futureGameNodes = drawnode.filter(function (d) {
+ return ((typeof(d.name) == "number") && (d.played==0));
+ });
+
+ var teamInNodes = drawnode.filter(function (d) {
+ return ((typeof(d.name) == "string") && (d.stillin==1));
+ });
+
+ var teamOutNodes = drawnode.filter(function (d) {
+ return ((typeof(d.name) == "string") && (d.stillin==0));
+ });
+
+ var teamNodes = drawnode.filter(function (d) {
+ return (typeof(d.name) == "string");
+ });
+
+ playedGameNodes.attr("class", function(d) {return "node playedgame g" + d.name;})
+ .append("circle").attr("r",3)
+ .style("stroke", "#ccc").style("stroke-width", "2px")
+ .style("fill", "#fff");
+
+ futureGameNodes.attr("class", function(d) {return "node futuregame g" + d.name;})
+ .append("circle").attr("r",5)
+ .style("stroke", "#99c").style("stroke-width", "2px")
+ .style("fill", "#99c")
+ .on("mouseover", gameover)
+ .on("mouseout", gameout);
+
+ teamNodes
+ .attr("class", function (d) { return "node team " + d.name.toLowerCase().replace(/\W/g,"_"); })
+ .append("text")
+ .attr("x", function(d) { return d.x < 180 ? 40 : -40; })
+ .attr("y", 10)
+ .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
+ .attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
+ .text(function(d) { return d.name; });
+
+ teamNodes
+ .append("text")
+ .attr("x", function(d) { return d.x < 180 ? 25 : -25; })
+ .attr("y", 10)
+ .attr("text-anchor", "middle")
+ .attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
+ .text(function(d) { return d.seed; });
+
+ teamInNodes.selectAll("text")
+ .attr("fill", "#aaa");
+
+ teamOutNodes.selectAll("text")
+ .attr("fill", "#ddd").style("text-decoration","none");
+
+ teamInNodes
+ .on("mouseover", teamover)
+ .on("mouseout", teamout);
+
+});
Property changes on: advance-et/trunk/ncaabracket.js
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/DestroySessionServlet.java
===================================================================
--- advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/DestroySessionServlet.java (rev 0)
+++ advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/DestroySessionServlet.java 2013-12-10 10:27:28 UTC (rev 347)
@@ -0,0 +1,76 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.ttsnetwork.elicitationtool;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author farago
+ */
+public class DestroySessionServlet extends HttpServlet {
+
+ /**
+ * Processes requests for both HTTP
+ * <code>GET</code> and
+ * <code>POST</code> methods.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void processRequest(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ request.getSession().invalidate();
+ }
+
+ // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
+ /**
+ * Handles the HTTP
+ * <code>GET</code> method.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Handles the HTTP
+ * <code>POST</code> method.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Returns a short description of the servlet.
+ *
+ * @return a String containing servlet description
+ */
+ @Override
+ public String getServletInfo() {
+ return "Short description";
+ }// </editor-fold>
+}
Property changes on: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/DestroySessionServlet.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/LoginServlet.java
===================================================================
--- advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/LoginServlet.java 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/LoginServlet.java 2013-12-10 10:27:28 UTC (rev 347)
@@ -85,7 +85,14 @@
}
if (userBean != null) {
+
+ UserNameListManager userNameListManager = ((UserNameListManager) getServletContext().getAttribute("userNameListManager"));
+
+ if (!userNameListManager.userNameExists(userBean.getName())) {
+ userNameListManager.addUserName(userBean.getName());
request.getSession().setAttribute("userBean", userBean);
+ }
+
}
} catch (JDOMException ex) {
Added: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/ServletContextListener.java
===================================================================
--- advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/ServletContextListener.java (rev 0)
+++ advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/ServletContextListener.java 2013-12-10 10:27:28 UTC (rev 347)
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.ttsnetwork.elicitationtool;
+
+import javax.servlet.ServletContextEvent;
+
+/**
+ * Web application lifecycle listener.
+ *
+ * @author farago
+ */
+public class ServletContextListener implements javax.servlet.ServletContextListener {
+
+ public void contextInitialized(ServletContextEvent sce) {
+ sce.getServletContext().setAttribute("userNameListManager", new UserNameListManager());
+ }
+
+ public void contextDestroyed(ServletContextEvent sce) {
+ sce.getServletContext().removeAttribute("userNameListManager");
+ }
+}
Property changes on: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/ServletContextListener.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/SessionServletListener.java
===================================================================
--- advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/SessionServletListener.java (rev 0)
+++ advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/SessionServletListener.java 2013-12-10 10:27:28 UTC (rev 347)
@@ -0,0 +1,32 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.ttsnetwork.elicitationtool;
+
+import java.util.Collection;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+/**
+ * Web application lifecycle listener.
+ *
+ * @author farago
+ */
+public class SessionServletListener implements HttpSessionListener {
+
+ public void sessionCreated(HttpSessionEvent se) {
+
+ }
+
+ public void sessionDestroyed(HttpSessionEvent se) {
+ String userName = ((UserBean) se.getSession().getAttribute("userBean")).getName();
+ Collection<FileItem> files = FileManager.getInstance().getFiles();
+ for (FileItem fileItem : files) {
+ if(fileItem.getUser()!= null && fileItem.getUser().equals(userName)) {
+ fileItem.setUser(null);
+ }
+ }
+ ((UserNameListManager)se.getSession().getServletContext().getAttribute("userNameListManager")).removeUserName(userName);
+ }
+}
Property changes on: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/SessionServletListener.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/UploadXmlServlet.java
===================================================================
--- advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/UploadXmlServlet.java 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/UploadXmlServlet.java 2013-12-10 10:27:28 UTC (rev 347)
@@ -84,7 +84,7 @@
validateXml(doc, validationErrorMessages);
// System.out.println("Error messages: " + validationErrorMessages);
- if (validationErrorMessages.isEmpty()) {
+// if (validationErrorMessages.isEmpty()) {
FileWriter writer = new FileWriter(xml);
new XMLOutputter(Format.getPrettyFormat()).output(doc, writer);
writer.close();
@@ -95,17 +95,17 @@
+ "id=\"success-message\">"
+ item.getName() + "</p>");
FileManager.getInstance().add(xml);
- } else {
+// } else {
+//
+// StringBuilder sb = new StringBuilder();
+// for (String s : validationErrorMessages) {
+// sb.append(s).append("\n");
+// }
+// errorMessage = sb.toString();
+//
+// }
- StringBuilder sb = new StringBuilder();
- for (String s : validationErrorMessages) {
- sb.append(s).append("\n");
- }
- errorMessage = sb.toString();
- }
-
-
} else {
errorMessage = getErrorMessage(5); //Name already exists
}
Added: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/UserNameListManager.java
===================================================================
--- advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/UserNameListManager.java (rev 0)
+++ advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/UserNameListManager.java 2013-12-10 10:27:28 UTC (rev 347)
@@ -0,0 +1,32 @@
+package com.ttsnetwork.elicitationtool;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author farago
+ */
+public class UserNameListManager {
+
+ public static ArrayList<String> userNameList = new ArrayList<String>();
+//private static UserManager instance = new UserManager();
+
+ /*
+ * public UserManager getInstance(){ return instance; }
+ */
+ public ArrayList<String> getUserList() {
+ return userNameList;
+ }
+
+ public void addUserName(String userName) {
+ userNameList.add(userName);
+ }
+
+ public void removeUserName(String userName) {
+ userNameList.remove(userName);
+ }
+
+ public boolean userNameExists(String userName) {
+ return userNameList.contains(userName);
+ }
+}
Property changes on: advance-et/trunk/src/java/com/ttsnetwork/elicitationtool/UserNameListManager.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: advance-et/trunk/web/WEB-INF/web.xml
===================================================================
--- advance-et/trunk/web/WEB-INF/web.xml 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/web/WEB-INF/web.xml 2013-12-10 10:27:28 UTC (rev 347)
@@ -65,6 +65,14 @@
<filter-name>LoginFilter</filter-name>
<url-pattern>/doc/*</url-pattern>
</filter-mapping>
+ <listener>
+ <description>HttpSessionListener</description>
+ <listener-class>com.ttsnetwork.elicitationtool.SessionServletListener</listener-class>
+ </listener>
+ <listener>
+ <description>ServletContextListener</description>
+ <listener-class>com.ttsnetwork.elicitationtool.ServletContextListener</listener-class>
+ </listener>
<servlet>
<servlet-name>SaveXmlServlet</servlet-name>
<servlet-class>com.ttsnetwork.elicitationtool.SaveXmlServlet</servlet-class>
@@ -123,6 +131,10 @@
<servlet-name>GetFileListServlet</servlet-name>
<servlet-class>com.ttsnetwork.elicitationtool.GetFileListServlet</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>DestroySessionServlet</servlet-name>
+ <servlet-class>com.ttsnetwork.elicitationtool.DestroySessionServlet</servlet-class>
+ </servlet>
<servlet-mapping>
<servlet-name>SaveXmlServlet</servlet-name>
<url-pattern>*.saveXml</url-pattern>
@@ -163,10 +175,12 @@
<servlet-name>GetFileListServlet</servlet-name>
<url-pattern>*.getFileList</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>DestroySessionServlet</servlet-name>
+ <url-pattern>*.destroySession</url-pattern>
+ </servlet-mapping>
<session-config>
- <session-timeout>
- 30
- </session-timeout>
+ <session-timeout>15</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
Modified: advance-et/trunk/web/css/editFile.css
===================================================================
--- advance-et/trunk/web/css/editFile.css 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/web/css/editFile.css 2013-12-10 10:27:28 UTC (rev 347)
@@ -1,3 +1,8 @@
+body{
+ margin: 15px auto;
+ padding: 0 !important;
+}
+
#wrapper{min-width: 60em;}
#page-header{border-bottom: 1px solid #808080;}
@@ -7,7 +12,7 @@
#content .container, #content #separator{
float: left; height: 100%; margin: 0; padding: 0;}
#content .container#tree-container{width: 36.46%; /* 350px */}
-#content .container#node-editor-container{width: 61.98%; /* 595px */}
+#content .container#node-editor-container{width: 61.97%; /* 595px */}
#content #separator{
width: 1.5625%; /* 15px */
border-width: 0px 1px; border-style: solid; border-color: #808080;
@@ -164,49 +169,52 @@
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px){
html, body{
- /*width: 100%;*/ min-width: 100%; max-width: none; min-height: 100%;
+ width: 100%; min-width: 100%; max-width: none; min-height: 100%;
margin: 0; padding: 0;
- -webkit-text-size-adjust: none;}
+ -webkit-text-size-adjust: none;
+ }
#wrapper{
position: relative;
- /*min-width: 100%;*/ width: 100%; min-height: 100%;
+ width: 100%; height: 100%; max-width: 100%;
margin: 0; padding: 0;
box-shadow: none;
}
- #page-header #logo-2{display: none;}
+ #content{
+ height: 83%;
+ }
- #node-editor-toolbar button{font-size: 1.8em;}
+ #content .container{
+ height: 100%;
}
-/* WVGA */
-@media only screen
-and (max-device-width : 800px) {
- html, body{
- /*width: 100%;*/ min-width: 100%; max-width: none; min-height: 100%;
- margin: 0; padding: 0;
- -webkit-text-size-adjust: none;}
-
- #wrapper{
- /* position: relative;*/
- /*min-width: 100%;*/ width: 100%; min-height: 100%;
- margin: 0; padding: 0;
- box-shadow: none;
+ #content .container #tree{
+ height: 90.2%;
+ padding-bottom: 1em;
}
- #content{height: 100%; min-height: 100%; background-color: red;}
+ #page-header #logo-2{display: none;}
- .toolbar{position: absolute; bottom: 2%;}
#content .container .toolbar#tree-toolbar{
- width: 36.46%;
+ position: static;
}
- #content #node-editor-toolbar{width: 61.98%;}
- #separator{background-color: yellowgreen;}
+ #node-editor-toolbar button{font-size: 1.8em;}
- #page-header #logo-2{display: none;}
+ #footer{
+ position: static;
+ }
+}
- #node-editor-toolbar button{font-size: 1.8em;}
+@media only screen and (min-device-width: 768px) and (max-device-width: 1024px)
+and (orientation:landscape){
+ #page-header, #footer{
+ height: auto;
+ }
+
+ #content{height: 48.5em;}
+ #content .container #tree{height: 83%;}
+ #content .container #node-editor{height: 90%;}
}
/* SMARTPHONES */
@@ -221,30 +229,34 @@
#wrapper{
position: relative;
- /*min-width: 100%;*/ width: 100%; min-height: 100%;
+ /*min-width: 100%;*/ width: 100%; min-height: 100%; max-width: 100%;
margin: 0; padding: 0;
box-shadow: none;
}
+ #content, #separator{
+ min-height: 48.5em; height: auto;
+ }
+
+ #content .container{
+ height: 48.5em;
+ }
+
+ #content .container #tree, #content .container #node-editor{
+ min-height: 40.5em;
+ padding-bottom: 1em;
+ }
+
#page-header #logo-2{display: none;}
+ #content .container .toolbar#tree-toolbar{
+ position: static;
+ }
#node-editor-toolbar button{font-size: 1.8em;}
- /*
- #content{min-height: 100%; height: auto; overflow: auto;}
-
- #content .container#node-editor-container, #content #separator{display: none;}
- #content .container#tree-container{
- float: left; width: 100%;}
-
- #tree-container #tree, #node-editor-container #node-editor{
- background-image: none; padding-bottom: 18.5%;}
- #tree-container .toolbar#tree-toolbar,
- #node-editor-container .toolbar#node-editor-toolbar{
- position: absolute; bottom: 0.8em;}
-
- #footer p{font-size: 0.8em;}
- #footer p a{text-decoration: none;}*/
+ #footer{
+ position: static;
+ }
}
/* QVGA */
@@ -252,33 +264,38 @@
and (max-device-width : 240px) {
html, body{
- width: 100%; min-width: 100%; max-width: none; min-height: 100%;
+ /*width: 100%;*/ min-width: 100%; max-width: none; min-height: 100%;
margin: 0; padding: 0;
-webkit-text-size-adjust: none;}
#wrapper{
position: relative;
- min-width: 100%; width: 100%; min-height: 100%; height: auto;
+ /*min-width: 100%;*/ width: 100%; min-height: 100%;
margin: 0; padding: 0;
box-shadow: none;
- background: url(../images/editor_bg.png);}
+ }
- #page-header #logo-2{display: none;}
- /*
+ #content{
+ min-height: 48.5em; height: auto;
+ }
- #content{min-height: 100%; height: auto; overflow: auto;}
+ #content .container{
+ height: auto;
+ }
- #content .container#node-editor-container,
- #content #separator{display: none;}
- #content .container#tree-container{
- position: absolute; top: 0; left: 0;
- float: none; width: 100%; min-height: 100%;}
+ #content .container #tree{
+ min-height: 40.5em; height: auto;
+ padding-bottom: 1em;
+ }
- #tree-container #tree{background-image: none; padding-bottom: 18%;}
- #tree-container #tree-toolbar{position: absolute; bottom: 0.8em;}
+ #page-header #logo-2{display: none;}
- #node-editor #jxgbox{width: 100%; height: 100%; background-color: #fff;}
+ #content .container .toolbar#tree-toolbar{
+ position: static;
+ }
+ #node-editor-toolbar button{font-size: 1.8em;}
- #footer p{font-size: 0.8em;}
- #footer p a{text-decoration: none;}*/
+ #footer{
+ position: static;
+ }
}
\ No newline at end of file
Modified: advance-et/trunk/web/css/fileList.css
===================================================================
--- advance-et/trunk/web/css/fileList.css 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/web/css/fileList.css 2013-12-10 10:27:28 UTC (rev 347)
@@ -124,14 +124,13 @@
#page-header .logo#logo-1 img{width: 98%;}
#page-header #logo-2{display: none;}
- #content #page-title p{font-size: 2em;}
#content .toolbar form button{font-size: 2em;}
#footer p a{text-decoration: none;}
}
/* WVGA */
-@media only screen
+/*@media only screen
and (max-device-width : 800px) {
html, body{
width: 100%; min-width: 100%; max-width: 100%; min-height: 100%;
@@ -143,7 +142,7 @@
box-shadow: none;}
#content .toolbar{position: absolute; bottom: 2%;}
-}
+}*/
/* SMARTPHONES */
@media only screen
@@ -162,10 +161,17 @@
#page-header .logo#logo-1 img{width: 98%;}
#page-header #logo-2{display: none;}
- #content #page-title p{font-size: 2em;}
+ #content{
+ background-color: red;
+ }
+ #content .page-title p #title{padding-top: 0.5em; font-size: 1.6em;}
+ #content .toolbar{position: absolute; bottom: 3%;}
#content .toolbar form button{font-size: 1.2em;}
- #footer p a{text-decoration: none;}
+ #footer p{font-size: 0.8em;}
+ #footer p a{
+ text-decoration: none;
+ }
#upload-box{left: 5%; top: 30%; width: 90%;}
}
Modified: advance-et/trunk/web/css/general.css
===================================================================
--- advance-et/trunk/web/css/general.css 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/web/css/general.css 2013-12-10 10:27:28 UTC (rev 347)
@@ -42,7 +42,8 @@
margin: 0 auto;
box-shadow: 0 0 5px #000;
background-color: yellowgreen;
- background-color: #e0e0e0;}
+ background-color: #e0e0e0;
+}
#page-header{
height: 13.34%;
Modified: advance-et/trunk/web/js/editFile.js
===================================================================
--- advance-et/trunk/web/js/editFile.js 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/web/js/editFile.js 2013-12-10 10:27:28 UTC (rev 347)
@@ -74,10 +74,30 @@
if(typeOfContent === 'graph'){
if(confirm('Do you want to record MI?')){
$('#node-editor-toolbar button.record-values').click();
+ }else{
+ if(isValidContent()){
+
+ if(typeOfGraph == 2 && areTabsUnchecked()){
+ return false;
+ }else{
+ switchNode();
+ }
+
+ }
}
}else if(typeOfContent === 'slider'){
if(confirm('Do you want to record RI?')){
$('#node-editor-toolbar button.record-values').click();
+ }else{
+ if(isValidContent()){
+
+ if(typeOfGraph == 2 && areTabsUnchecked()){
+ return false;
+ }else{
+ switchNode();
+ }
+
+ }
}
}
}else{
@@ -696,7 +716,7 @@
*/
var isValidContent = function(){
var isValid = false;
- var message = 'Data cannot be saved.';
+ var message = 'Data are not valid.';
if(typeOfContent === 'graph' && typeOfGraph > 0 && typeOfGraph < 3){
var isValidMaxY = false;
var isValidMinY = true;
@@ -903,10 +923,13 @@
var valueMG = node.attr('value-mg');
if(values == 'integer'){
- if(genericType == 'g'){
+ // if(genericType == 'g'){
+ // typeOfGraph = 1; // value-mg="((-20 1)(0 0.2)(5 0))"
+ // }else
+ if(genericType == 'gd'){
+ typeOfGraph = 2; //value-mg="(([tab1] ((-20 1)(0 0.2)(5 0))) (([tab2] ((-20 1)(0 0.2)(5 0)))"
+ }else{
typeOfGraph = 1; // value-mg="((-20 1)(0 0.2)(5 0))"
- }else if(genericType == 'gd'){
- typeOfGraph = 2; //value-mg="(([tab1] ((-20 1)(0 0.2)(5 0))) (([tab2] ((-20 1)(0 0.2)(5 0)))"
}
}else if(values == 'nominal'){
typeOfGraph = 3; // value-mg="(none 0) (a-few 0.2) (moderate-number 0.3) (quite-a-lot 0.6) (many 0.9) (loads 1))"
@@ -995,14 +1018,12 @@
}
}
-/**
-*
-*/
-var getCoordinates = function(valueMG, coordinatesArray){
/*
- * Thanks to Ben Nadel & Giovanni Dal Maso
+ * Thanks to Ben Nadel http://www.bennadel.com/blog/1742-Using-Regular-Expressions-In-Javascript-A-General-Overview-.htm
+ * & Giovanni Dal Maso
* Create an array of point coordinates from the XML node's values
*/
+var getCoordinates = function(valueMG, coordinatesArray){
var pattern = /\(([-+]?[0-9]*\.?[0-9]+) ([-+]?[0-9]*\.?[0-9]+)\)/g;
while ((matches = pattern.exec(valueMG))){
var x = Number(matches[1]);
@@ -1117,7 +1138,6 @@
// Sets the node editor header text and insert it into the DOM
pageTitle = nodeEditor.prev();
- // pageTitle.children('p').text(node.attr('label').charAt(0).toUpperCase() + node.attr('label').slice(1, 49));
nodeEditor.empty().removeClass('padded').height('83%'); //Remove elements from nodeEditor
Modified: advance-et/trunk/web/js/fileList.js
===================================================================
--- advance-et/trunk/web/js/fileList.js 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/web/js/fileList.js 2013-12-10 10:27:28 UTC (rev 347)
@@ -203,7 +203,6 @@
type: 'post',
dataType: 'xml',
error: function(jqXHR, textStatus, errorThrown){
- alert('Si è verificato un\'errore');
},
success: function(data, textStatus, jqXHR){
var xml = $(data);
@@ -214,12 +213,12 @@
$.each(xml.find('file'), function(){
var file = $(this);
- console.log(file.attr('user'));
var user = $.trim(file.attr('user'));
+ var newElement;
if(user !== undefined && user !== null && user.length > 0){
- var newElement = $('<div>' + file.attr('filename') + '</div>').append($('<img>').attr('src', '../images/locked.png')).append($('<span>').text(user + ' is editing'));
+ newElement = $('<div>' + file.attr('filename') + '</div>').append($('<img>').attr('src', '../images/locked.png')).append($('<span>').text(user + ' is editing'));
}else{
- var newElement = $('<a>').attr('href', '#').text(file.attr('filename'));
+ newElement = $('<a>').attr('href', '#').text(file.attr('filename'));
}
newElement.addClass('file');
temporaryContainer.append(liElement.clone().append(newElement));
Modified: advance-et/trunk/web/pages/editFile.jsp
===================================================================
--- advance-et/trunk/web/pages/editFile.jsp 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/web/pages/editFile.jsp 2013-12-10 10:27:28 UTC (rev 347)
@@ -14,13 +14,11 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <%-- <meta name="viewport" content="target-densitydpi=device-dpi, user-scalable=no, initial-scale=1.0, width=device-width" /> --%>
-
+ <!--<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width" />-->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<script type="text/javascript" src="../js/editFile.js"></script>
-<!-- <link rel="stylesheet" type="text/css" href="../css/jquery-ui-1.8.18.custom.css">-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="../css/jquery-ui-1.9.0.custom.min.css">
<link rel="stylesheet" type="text/css" href="../css/general.css">
Modified: advance-et/trunk/web/pages/fileList.jsp
===================================================================
--- advance-et/trunk/web/pages/fileList.jsp 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/web/pages/fileList.jsp 2013-12-10 10:27:28 UTC (rev 347)
@@ -58,10 +58,10 @@
<c:forEach var="fileItem" items="${pageScope.fileList}">
<li>
<c:choose>
- <c:when test="${fileItem.user == userBean.name || fileItem.user == null}">
+ <c:when test="${fileItem.user == null}">
<a href="#" class="file">${fileItem.filename}</a>
</c:when>
- <c:when test="${fileItem.user != null}">
+ <c:otherwise>
<div class="file" title="File is under editing">
${fileItem.filename}
<img src="../images/locked.png">
@@ -69,7 +69,7 @@
${fileItem.user} is editing
</span>
</div>
- </c:when>
+ </c:otherwise>
</c:choose>
</li>
</c:forEach>
Modified: advance-et/trunk/web/pages/viewFile.jsp
===================================================================
--- advance-et/trunk/web/pages/viewFile.jsp 2013-11-20 12:07:21 UTC (rev 346)
+++ advance-et/trunk/web/pages/viewFile.jsp 2013-12-10 10:27:28 UTC (rev 347)
@@ -10,7 +10,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta name="viewport" content="target-densitydpi=device-dpi, user-scalable=yes, initial-scale=1.0, width=device-width" />
+ <!--<meta name="viewport" content="target-densitydpi=device-dpi, user-scalable=yes, initial-scale=1.0, width=device-width" />-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/viewFile.css">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-20 12:07:25
|
Revision: 346
http://sourceforge.net/p/advance-project/code/346
Author: csirobi
Date: 2013-11-20 12:07:21 +0000 (Wed, 20 Nov 2013)
Log Message:
-----------
L2: null-check for the warehouse pair
Modified Paths:
--------------
advance-live-reporter-os/WebContent/css/warehouse-header.css
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java
Modified: advance-live-reporter-os/WebContent/css/warehouse-header.css
===================================================================
--- advance-live-reporter-os/WebContent/css/warehouse-header.css 2013-11-19 20:44:33 UTC (rev 345)
+++ advance-live-reporter-os/WebContent/css/warehouse-header.css 2013-11-20 12:07:21 UTC (rev 346)
@@ -116,8 +116,6 @@
width: 100%;
height: 100%;
table-layout : fixed;
- overflow : hidden;
- white-space : nowrap;
}
div.warehouse-menu .updown-width tr,
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java 2013-11-19 20:44:33 UTC (rev 345)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java 2013-11-20 12:07:21 UTC (rev 346)
@@ -58,6 +58,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Strings;
+
/**
* Data provider for the warehouse summary and detail views.
* @author karnokd, 2013.04.29.
@@ -385,6 +387,7 @@
serviceToSnip.get(ServiceLevel.PRIORITY).addAll(Arrays.asList(WarehouseServiceLevel.PRIORITY_SPECIAL));
serviceToSnip.get(ServiceLevel.SPECIAL).addAll(Arrays.asList(WarehouseServiceLevel.PRIORITY_SPECIAL));
+ Warehouse wh = MasterDB.warehouse(hubId, warehouse);
for (ConsignmentSummary cs : consignmentStatus.valueCollection()) {
double cscreated = 0;
@@ -400,14 +403,16 @@
cscreated = cs.floorspace(ItemStatus.CREATED);
EnumMap<WarehouseServiceLevel, Aggregates> perLevel = out.get(cs.deliveryDepot);
-
- for (WarehouseServiceLevel s : serviceToSnip.get(cs.level)) {
- perLevel.get(s).created += cscreated;
- perLevel.get(s).scanned += csscanned;
- perLevel.get(s).declared += csdeclared;
- perLevel.get(s).athub += csathub;
- perLevel.get(s).lefthub += cslefthub;
- }
+
+ if(Strings.isNullOrEmpty(wh.pair) == false) {
+ for (WarehouseServiceLevel s : serviceToSnip.get(cs.level)) {
+ perLevel.get(s).created += cscreated;
+ perLevel.get(s).scanned += csscanned;
+ perLevel.get(s).declared += csdeclared;
+ perLevel.get(s).athub += csathub;
+ perLevel.get(s).lefthub += cslefthub;
+ }
+ }
}
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-19 20:44:35
|
Revision: 345
http://sourceforge.net/p/advance-project/code/345
Author: csirobi
Date: 2013-11-19 20:44:33 +0000 (Tue, 19 Nov 2013)
Log Message:
-----------
Layer 2: api fixed
Modified Paths:
--------------
advance-live-reporter-os/WebContent/api-warehouse-l2.jsp
Modified: advance-live-reporter-os/WebContent/api-warehouse-l2.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-l2.jsp 2013-11-19 11:45:16 UTC (rev 344)
+++ advance-live-reporter-os/WebContent/api-warehouse-l2.jsp 2013-11-19 20:44:33 UTC (rev 345)
@@ -37,8 +37,8 @@
Map<L2DisplaySide, List<L2StorageRawData>> storageRawMap = warehouseSwitch.getL2StorageRawMap();
WarehouseSummary.warehouseDetails(storageRawMap, warehouseSwitch.hubId(),
new DateTime(hubDepotSwitch.getDateTime()), warehouseSwitch.getWarehouse(),
- HubDepotDataCache.get(session.getServletContext()));
-
+ warehouseSwitch.getWarehouseType(), HubDepotDataCache.get(session.getServletContext()));
+
result = L2Chart.getJSONtoChart(warehouseSwitch, storageRawMap);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-11-19 11:45:19
|
Revision: 344
http://sourceforge.net/p/advance-project/code/344
Author: akarnokd
Date: 2013-11-19 11:45:16 +0000 (Tue, 19 Nov 2013)
Log Message:
-----------
Fixed layout-map related bug: not showing warehouse contents in various view settings.
Modified Paths:
--------------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageRawData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java 2013-11-18 17:42:07 UTC (rev 343)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java 2013-11-19 11:45:16 UTC (rev 344)
@@ -180,7 +180,8 @@
case NOW_AT_HUB:
// for STANDARD & PRIORITY
for (WarehouseServiceLevel wsl : L2StorageChartData.USED_SERVICES) {
- double x = storageRaw.items.get(wsl).get(ItemStatus.AT_HUB).normalValue.doubleValue();
+ BarData bd = storageRaw.items.get(wsl).get(ItemStatus.AT_HUB);
+ double x = bd.normalValue.doubleValue();
weightInput.put(wsl, x);
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageRawData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageRawData.java 2013-11-18 17:42:07 UTC (rev 343)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageRawData.java 2013-11-19 11:45:16 UTC (rev 344)
@@ -90,4 +90,13 @@
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "L2StorageRawData [warehouse=" + warehouse + ", type=" + type
+ + ", side=" + side + ", id=" + id + "]";
+ }
+
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java 2013-11-18 17:42:07 UTC (rev 343)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java 2013-11-19 11:45:16 UTC (rev 344)
@@ -284,11 +284,23 @@
TLongObjectMap<EnumMap<ServiceLevel, TLongSet>> out1 = cache.getItemsInWarehouse(hubId, s.warehouse, when);
warehouseTypeMap.put(WarehouseType.A, out1);
whs.add(Pair.of(s.warehouse, WarehouseType.A));
+ // extract all item ids
+ for (EnumMap<ServiceLevel, TLongSet> m1 : out1.valueCollection()) {
+ for (TLongSet m2 : m1.values()) {
+ itemIds.addAll(m2);
+ }
+ }
if (s.pair != null) {
TLongObjectMap<EnumMap<ServiceLevel, TLongSet>> out2 = cache.getItemsInWarehouse(hubId, s.pair, when);
warehouseTypeMap.put(WarehouseType.B, out2);
whs.add(Pair.of(s.pair, WarehouseType.B));
+ // extract all item ids
+ for (EnumMap<ServiceLevel, TLongSet> m1 : out2.valueCollection()) {
+ for (TLongSet m2 : m1.values()) {
+ itemIds.addAll(m2);
+ }
+ }
} else {
warehouseTypeMap.put(WarehouseType.B, new TLongObjectHashMap<EnumMap<ServiceLevel, TLongSet>>());
}
@@ -306,12 +318,6 @@
levelTypeDepotCapacity.get(sn).get(wh.second).adjustOrPutValue((short)b.depot, b.capacity, b.capacity);
}
}
- // extract all item ids
- for (EnumMap<ServiceLevel, TLongSet> m1 : out1.valueCollection()) {
- for (TLongSet m2 : m1.values()) {
- itemIds.addAll(m2);
- }
- }
}
break;
}
@@ -410,17 +416,16 @@
* @param hubId the hub id
* @param when the current time
* @param warehouse the current warehouse name
+ * @param wtype the warehouse type.
* @param cache the data cache
*/
public static void warehouseDetails(
Map<L2DisplaySide, List<L2StorageRawData>> storageRawMap,
- long hubId, ReadableDateTime when, String warehouse,
+ long hubId, ReadableDateTime when, String warehouse, WarehouseType wtype,
HubDepotDataCache cache) {
final EnumMap<WarehouseServiceLevel, TObjectDoubleMap<WarehouseType>> levelTypeSum = new EnumMap<>(WarehouseServiceLevel.class);
EnumMap<WarehouseServiceLevel, EnumMap<WarehouseType, TLongIntMap>> levelTypeDepotCapacity = new EnumMap<>(WarehouseServiceLevel.class);
-
-
final EnumMap<WarehouseServiceLevel, EnumMap<WarehouseType, TLongDoubleMap>> levelTypeDepotSum = new EnumMap<>(WarehouseServiceLevel.class);
TLongObjectMap<EnumMap<WarehouseServiceLevel, Aggregates>> depotLevelAggregates = new TLongObjectHashMap<>();
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-18 17:42:07 UTC (rev 343)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-19 11:45:16 UTC (rev 344)
@@ -393,7 +393,8 @@
break;
case B:
if (wh.pair != null) {
- storageInfoList = warehouseLayoutMap.get(wh.pair).get(WarehouseSide.values()[displaySide.ordinal()]);
+ Map<WarehouseSide, List<StorageAreaInfo>> map = warehouseLayoutMap.get(wh.pair);
+ storageInfoList = map.get(WarehouseSide.values()[displaySide.ordinal()]);
} else {
storageInfoList = new ArrayList<>();
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java 2013-11-18 17:42:07 UTC (rev 343)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java 2013-11-19 11:45:16 UTC (rev 344)
@@ -440,6 +440,7 @@
}
}
mergeInto(list, b.depot, b.capacity, WarehouseType.A, sl, b.index);
+ mergeInto(list, b.depot, b.capacity, WarehouseType.B, sl, b.index);
}
}
for (Map<WarehouseSide, List<StorageAreaInfo>> m : result.values()) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-18 17:42:11
|
Revision: 343
http://sourceforge.net/p/advance-project/code/343
Author: csirobi
Date: 2013-11-18 17:42:07 +0000 (Mon, 18 Nov 2013)
Log Message:
-----------
Layer 1-3: clear the "set actual date"
Modified Paths:
--------------
advance-live-reporter-os/WebContent/api-warehouse-l1.jsp
advance-live-reporter-os/WebContent/api-warehouse-l2.jsp
advance-live-reporter-os/WebContent/api-warehouse-l3.jsp
advance-live-reporter-os/WebContent/css/warehouse-header.css
Modified: advance-live-reporter-os/WebContent/api-warehouse-l1.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-l1.jsp 2013-11-15 12:26:41 UTC (rev 342)
+++ advance-live-reporter-os/WebContent/api-warehouse-l1.jsp 2013-11-18 17:42:07 UTC (rev 343)
@@ -25,7 +25,6 @@
try
{
HubDepotSwitch hubDepotSwitch = new HubDepotSwitch(user.hub, user.name);
- hubDepotSwitch.setDateTime(new Date());
WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
warehouseSwitch.setWarehouse(request.getParameter("warehouse_name"));
Modified: advance-live-reporter-os/WebContent/api-warehouse-l2.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-l2.jsp 2013-11-15 12:26:41 UTC (rev 342)
+++ advance-live-reporter-os/WebContent/api-warehouse-l2.jsp 2013-11-18 17:42:07 UTC (rev 343)
@@ -28,7 +28,6 @@
try
{
HubDepotSwitch hubDepotSwitch = new HubDepotSwitch(user.hub, user.name);
- hubDepotSwitch.setDateTime(new Date());
WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
warehouseSwitch.setWarehouse(request.getParameter("warehouse_name"));
@@ -39,9 +38,9 @@
WarehouseSummary.warehouseDetails(storageRawMap, warehouseSwitch.hubId(),
new DateTime(hubDepotSwitch.getDateTime()), warehouseSwitch.getWarehouse(),
HubDepotDataCache.get(session.getServletContext()));
-
- result = L2Chart.getJSONtoChart(warehouseSwitch, storageRawMap);
+ result = L2Chart.getJSONtoChart(warehouseSwitch, storageRawMap);
+
}
catch(IllegalArgumentException e)
{
Modified: advance-live-reporter-os/WebContent/api-warehouse-l3.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-l3.jsp 2013-11-15 12:26:41 UTC (rev 342)
+++ advance-live-reporter-os/WebContent/api-warehouse-l3.jsp 2013-11-18 17:42:07 UTC (rev 343)
@@ -27,7 +27,6 @@
try
{
HubDepotSwitch hubDepotSwitch = new HubDepotSwitch(user.hub, user.name);
- hubDepotSwitch.setDateTime(new Date());
WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
warehouseSwitch.setWarehouse(request.getParameter("warehouse_name"));
Modified: advance-live-reporter-os/WebContent/css/warehouse-header.css
===================================================================
--- advance-live-reporter-os/WebContent/css/warehouse-header.css 2013-11-15 12:26:41 UTC (rev 342)
+++ advance-live-reporter-os/WebContent/css/warehouse-header.css 2013-11-18 17:42:07 UTC (rev 343)
@@ -115,6 +115,9 @@
border-collapse: collapse;
width: 100%;
height: 100%;
+ table-layout : fixed;
+ overflow : hidden;
+ white-space : nowrap;
}
div.warehouse-menu .updown-width tr,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-11-15 12:26:46
|
Revision: 342
http://sourceforge.net/p/advance-project/code/342
Author: akarnokd
Date: 2013-11-15 12:26:41 +0000 (Fri, 15 Nov 2013)
Log Message:
-----------
Updated referenced libraries
Modified Paths:
--------------
flow-editor/trunk/Advance Core Module/nbproject/genfiles.properties
flow-editor/trunk/Advance Core Module/nbproject/project.xml
flow-editor/trunk/Advance Core Module/release/modules/ext/advance-core.jar
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/BlockRegistryDataObject.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/OperationsPaletteTopComponent.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/TreeBrowserTopComponent.form
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/TreeBrowserTopComponent.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ConstAddAction.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ConstEditAction.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/EditSupport.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/EditType.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog.form
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog2.form
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog2.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/diagram/FlowScene.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/diagram/WidgetBuilder.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/model/ConstantBlock.java
flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/model/FlowDescription.java
flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/DownloadFlowAction.java
flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/EngineController.java
flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/VerifyFlowAction.java
flow-editor/trunk/nbproject/genfiles.properties
flow-editor/trunk/nbproject/platform.xml
Added Paths:
-----------
flow-editor/trunk/Advance Core Module/release/modules/ext/akarnokd_tools.jar
Modified: flow-editor/trunk/Advance Core Module/nbproject/genfiles.properties
===================================================================
--- flow-editor/trunk/Advance Core Module/nbproject/genfiles.properties 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Advance Core Module/nbproject/genfiles.properties 2013-11-15 12:26:41 UTC (rev 342)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=32fb5e26
+build.xml.data.CRC32=e240a4b8
build.xml.script.CRC32=68c8db74
-build.xml.stylesheet.CRC32=a56c6a5b@2.50.1
+build.xml.stylesheet.CRC32=a56c6a5b@2.62.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=32fb5e26
+nbproject/build-impl.xml.data.CRC32=e240a4b8
nbproject/build-impl.xml.script.CRC32=e7aa4969
-nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1
+nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.62.1
Modified: flow-editor/trunk/Advance Core Module/nbproject/project.xml
===================================================================
--- flow-editor/trunk/Advance Core Module/nbproject/project.xml 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Advance Core Module/nbproject/project.xml 2013-11-15 12:26:41 UTC (rev 342)
@@ -107,7 +107,6 @@
<package>eu.advance.logistics.flow.engine.test</package>
<package>eu.advance.logistics.flow.engine.typesystem</package>
<package>eu.advance.logistics.flow.engine.util</package>
- <package>eu.advance.logistics.flow.engine.xml</package>
<package>eu.advance.logistics.prediction.support</package>
<package>eu.advance.logistics.prediction.support.attributes</package>
<package>eu.advance.logistics.prediction.support.collections</package>
@@ -125,6 +124,18 @@
<package>hu.akarnokd.reactive4java.test</package>
<package>hu.akarnokd.reactive4java.test.old</package>
<package>hu.akarnokd.reactive4java.util</package>
+ <package>hu.akarnokd.utils</package>
+ <package>hu.akarnokd.utils.collection</package>
+ <package>hu.akarnokd.utils.concurrent</package>
+ <package>hu.akarnokd.utils.crypto</package>
+ <package>hu.akarnokd.utils.database</package>
+ <package>hu.akarnokd.utils.io</package>
+ <package>hu.akarnokd.utils.lang</package>
+ <package>hu.akarnokd.utils.math</package>
+ <package>hu.akarnokd.utils.mix</package>
+ <package>hu.akarnokd.utils.sequence</package>
+ <package>hu.akarnokd.utils.trove</package>
+ <package>hu.akarnokd.utils.xml</package>
<package>javax.annotation</package>
<package>javax.annotation.concurrent</package>
<package>javax.annotation.meta</package>
@@ -484,6 +495,10 @@
<runtime-relative-path>ext/j2ssh-0.2.9.jar</runtime-relative-path>
<binary-origin>release/modules/ext/j2ssh-0.2.9.jar</binary-origin>
</class-path-extension>
+ <class-path-extension>
+ <runtime-relative-path>ext/akarnokd_tools.jar</runtime-relative-path>
+ <binary-origin>release/modules/ext/akarnokd_tools.jar</binary-origin>
+ </class-path-extension>
</data>
</configuration>
</project>
Modified: flow-editor/trunk/Advance Core Module/release/modules/ext/advance-core.jar
===================================================================
(Binary files differ)
Added: flow-editor/trunk/Advance Core Module/release/modules/ext/akarnokd_tools.jar
===================================================================
(Binary files differ)
Index: flow-editor/trunk/Advance Core Module/release/modules/ext/akarnokd_tools.jar
===================================================================
--- flow-editor/trunk/Advance Core Module/release/modules/ext/akarnokd_tools.jar 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Advance Core Module/release/modules/ext/akarnokd_tools.jar 2013-11-15 12:26:41 UTC (rev 342)
Property changes on: flow-editor/trunk/Advance Core Module/release/modules/ext/akarnokd_tools.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/BlockRegistryDataObject.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/BlockRegistryDataObject.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/BlockRegistryDataObject.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -43,7 +43,7 @@
import com.google.common.io.Closeables;
import eu.advance.logistics.flow.engine.model.fd.AdvanceBlockDescription;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
public class BlockRegistryDataObject extends MultiDataObject {
/** */
@@ -86,9 +86,9 @@
}
public static void read(InputStream in) {
- XElement root = null;
+ XNElement root = null;
try {
- root = XElement.parseXML(in);
+ root = XNElement.parseXML(in);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
} finally {
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/OperationsPaletteTopComponent.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/OperationsPaletteTopComponent.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/OperationsPaletteTopComponent.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -44,7 +44,7 @@
import eu.advance.logistics.flow.editor.palette.PaletteRootChildren;
import eu.advance.logistics.flow.editor.util.Util;
import eu.advance.logistics.flow.engine.runtime.BlockRegistryEntry;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionListener;
@@ -141,7 +141,7 @@
Node n = nodes[0];
if (n instanceof BlockNode) {
BlockNode bn = (BlockNode)n;
- blockTip.setText("<html><p>" + XElement.sanitize(bn.blockDesc()) + "</p></html>");
+ blockTip.setText("<html><p>" + XNElement.sanitize(bn.blockDesc()) + "</p></html>");
blockTip.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
blockTip.setVisible(true);
return;
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/TreeBrowserTopComponent.form
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/TreeBrowserTopComponent.form 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/TreeBrowserTopComponent.form 2013-11-15 12:26:41 UTC (rev 342)
@@ -1,4 +1,4 @@
-<?xml version="1.1" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.4" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/TreeBrowserTopComponent.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/TreeBrowserTopComponent.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/TreeBrowserTopComponent.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -38,7 +38,7 @@
import eu.advance.logistics.flow.editor.tree.FlowDescriptionNode;
import eu.advance.logistics.flow.editor.tree.SimpleBlockNode;
import eu.advance.logistics.flow.editor.util.Util;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
@@ -116,7 +116,7 @@
Node n = nodes[0];
if (n instanceof SimpleBlockNode) {
SimpleBlockNode bn = (SimpleBlockNode)n;
- blockTip.setText("<html><p>" + XElement.sanitize(bn.getBlock().getTooltip()) + "</p></html>");
+ blockTip.setText("<html><p>" + XNElement.sanitize(bn.getBlock().getTooltip()) + "</p></html>");
blockTip.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
blockTip.setVisible(true);
return;
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ConstAddAction.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ConstAddAction.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ConstAddAction.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -23,7 +23,6 @@
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
-import java.net.URI;
import javax.swing.AbstractAction;
@@ -41,12 +40,12 @@
import eu.advance.logistics.flow.editor.undo.CompositeEdit;
import eu.advance.logistics.flow.editor.undo.ConstantBlockAdded;
import eu.advance.logistics.flow.editor.undo.UndoRedoSupport;
-import eu.advance.logistics.flow.engine.block.AdvanceData;
+import eu.advance.logistics.flow.engine.AdvanceData;
import eu.advance.logistics.flow.engine.inference.TypeKind;
import eu.advance.logistics.flow.engine.model.fd.AdvanceBlockParameterDescription;
import eu.advance.logistics.flow.engine.model.fd.AdvanceConstantBlock;
import eu.advance.logistics.flow.engine.model.fd.AdvanceType;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
import java.net.URISyntaxException;
import org.openide.util.Exceptions;
@@ -128,7 +127,7 @@
}
}
try {
- AdvanceType at = c.getAdvanecType();
+ AdvanceType at = c.getAdvanceType();
if (c.type != null) {
c.type = BlockRegistry.getInstance().resolveSchema(at.typeURI);
}
@@ -140,7 +139,7 @@
return c;
}
} else {
- c.value = new XElement(at.typeURI.getSchemeSpecificPart());
+ c.value = new XNElement(at.typeURI.getSchemeSpecificPart());
c.value.content = "";
c.value.content = EditSupport.edit(c.value.content, at.typeURI);
return c.value.content != null ? c : null;
@@ -151,7 +150,7 @@
return null;
}
public static String convertToXml(AdvanceConstantBlock c) {
- XElement temp = new XElement("constant");
+ XNElement temp = new XNElement("constant");
c.save(temp);
return temp.toString();
}
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ConstEditAction.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ConstEditAction.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ConstEditAction.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -30,10 +30,10 @@
import eu.advance.logistics.flow.editor.model.ConstantBlock;
import eu.advance.logistics.flow.editor.undo.ConstantBlockChanged;
import eu.advance.logistics.flow.editor.undo.UndoRedoSupport;
-import eu.advance.logistics.flow.engine.block.AdvanceData;
+import eu.advance.logistics.flow.engine.AdvanceData;
import eu.advance.logistics.flow.engine.model.fd.AdvanceConstantBlock;
import eu.advance.logistics.flow.engine.model.fd.AdvanceType;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
import java.net.URISyntaxException;
import org.openide.util.Exceptions;
@@ -58,9 +58,9 @@
AdvanceConstantBlock newConstant;
AdvanceConstantBlock currentConstant = target.getConstant();
try {
- AdvanceType at = currentConstant.getAdvanecType();
+ AdvanceType at = currentConstant.getAdvanceType();
if (AdvanceData.TYPE.equals(at.typeURI)) {
- XElement value = EditType.edit(currentConstant.value);
+ XNElement value = EditType.edit(currentConstant.value);
if (value == null) {
return;
}
@@ -88,7 +88,7 @@
private static AdvanceConstantBlock clone(AdvanceConstantBlock source) {
AdvanceConstantBlock cloned = new AdvanceConstantBlock();
- XElement temp = new XElement("constant");
+ XNElement temp = new XNElement("constant");
source.save(temp);
cloned.load(temp);
return cloned;
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/EditSupport.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/EditSupport.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/EditSupport.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -1,6 +1,6 @@
package eu.advance.logistics.flow.editor.actions;
-import eu.advance.logistics.flow.engine.block.AdvanceData;
+import eu.advance.logistics.flow.engine.AdvanceData;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.lang.reflect.InvocationTargetException;
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/EditType.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/EditType.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/EditType.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -5,7 +5,7 @@
package eu.advance.logistics.flow.editor.actions;
import com.google.common.collect.Lists;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.util.List;
@@ -26,7 +26,7 @@
* @param value the initial type value.
* @return the advance:type element
*/
- public static XElement edit(XElement value) {
+ public static XNElement edit(XNElement value) {
String title = "Type<T>";
JPanel panel = new JPanel();
@@ -54,7 +54,7 @@
* @param s the string to convert, if empty, null is returned
* @return the XElement representing the type
*/
- public static XElement toXML(String s) {
+ public static XNElement toXML(String s) {
if (s.isEmpty()) {
return null;
}
@@ -74,7 +74,7 @@
tokens.add(b.toString());
}
// uri[<uri[<...>][,uri[<...>]]>]
- XElement result = new XElement("type");
+ XNElement result = new XNElement("type");
result.set("type", tokens.get(0));
if (tokens.size() > 3 && tokens.get(1).equals("<")) {
@@ -82,10 +82,10 @@
}
return result;
}
- static void parseURIList(XElement argsFor, List<String> tokens) {
+ static void parseURIList(XNElement argsFor, List<String> tokens) {
int i = 0;
do {
- XElement out = argsFor.add("type-argument");
+ XNElement out = argsFor.add("type-argument");
out.set(tokens.get(i));
if (tokens.size() > i + 1) {
final String tok = tokens.get(i + 1);
@@ -106,14 +106,14 @@
* @param type the type to convert
* @return the string representation
*/
- public static String fromXML(XElement type) {
+ public static String fromXML(XNElement type) {
StringBuilder b = new StringBuilder();
b.append(type.get("type"));
if (type.hasChildren()) {
b.append("<");
int i = 0;
- for (XElement c : type.childrenWithName("type-argument")) {
+ for (XNElement c : type.childrenWithName("type-argument")) {
if (i > 0) {
b.append(", ");
}
@@ -130,7 +130,7 @@
* @param value the type.xsd definition of a type structure
* @return the associated type, e.g., if value is advance:string, the result is advance:type<advance:string>
*/
- public static String createTypeConstructor(XElement value) {
+ public static String createTypeConstructor(XNElement value) {
return "advance:type<" + EditType.fromXML(value) + ">";
}
}
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog.form
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog.form 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog.form 2013-11-15 12:26:41 UTC (rev 342)
@@ -1,4 +1,4 @@
-<?xml version="1.1" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<NonVisualComponents>
@@ -10,6 +10,7 @@
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -30,7 +30,7 @@
import eu.advance.logistics.flow.editor.BlockRegistry;
import eu.advance.logistics.flow.engine.model.fd.AdvanceBlockParameterDescription;
import eu.advance.logistics.flow.engine.model.fd.AdvanceType;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
/**
*
@@ -82,7 +82,7 @@
paramDesc.displayName = jTextField1.getText();
paramDesc.documentation = jTextPane1.getText();
paramDesc.type = type;
- XElement temp = new XElement(tag);
+ XNElement temp = new XNElement(tag);
paramDesc.save(temp);
customTypeText.setText(temp.toString());
} else {
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog2.form
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog2.form 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog2.form 2013-11-15 12:26:41 UTC (rev 342)
@@ -1,4 +1,4 @@
-<?xml version="1.1" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
@@ -6,6 +6,7 @@
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog2.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog2.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/actions/ParameterDescriptionDialog2.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -32,7 +32,7 @@
import org.openide.windows.WindowManager;
import eu.advance.logistics.flow.engine.model.fd.AdvanceBlockParameterDescription;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
/**
*
@@ -98,7 +98,7 @@
}
private String convertToText(AdvanceBlockParameterDescription d) {
- XElement temp = new XElement(tag);
+ XNElement temp = new XNElement(tag);
d.save(temp);
return temp.toString();
}
@@ -138,7 +138,7 @@
private AdvanceBlockParameterDescription createFromText(String xml) {
if (xml != null && xml.length() > 0) {
try {
- XElement temp = XElement.parseXML(new StringReader(xml));
+ XNElement temp = XNElement.parseXML(new StringReader(xml));
AdvanceBlockParameterDescription d = new AdvanceBlockParameterDescription();
d.load(temp);
return d;
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/diagram/FlowScene.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/diagram/FlowScene.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/diagram/FlowScene.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -71,7 +71,7 @@
import eu.advance.logistics.flow.editor.undo.BindRemoved;
import eu.advance.logistics.flow.editor.undo.BlockRenamed;
import eu.advance.logistics.flow.editor.undo.UndoRedoSupport;
-import eu.advance.logistics.flow.engine.block.AdvanceData;
+import eu.advance.logistics.flow.engine.AdvanceData;
import eu.advance.logistics.flow.engine.model.fd.AdvanceType;
/**
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/diagram/WidgetBuilder.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/diagram/WidgetBuilder.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/diagram/WidgetBuilder.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -47,7 +47,7 @@
import eu.advance.logistics.flow.editor.model.SimpleBlock;
import eu.advance.logistics.flow.editor.undo.CompositeEdit;
import eu.advance.logistics.flow.engine.model.fd.AdvanceBlockParameterDescription;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
/**
*
@@ -171,7 +171,7 @@
AdvanceBlockParameterDescription d = param.getDescription();
StringBuilder sb = new StringBuilder();
sb.append("<html>");
- sb.append(XElement.sanitize(param.getDescription().type.toString())).append("<br>");
+ sb.append(XNElement.sanitize(param.getDescription().type.toString())).append("<br>");
if (d.displayName != null) {
sb.append("<b>").append(d.displayName).append("</b><br>");
}
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/model/ConstantBlock.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/model/ConstantBlock.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/model/ConstantBlock.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -22,7 +22,7 @@
import eu.advance.logistics.flow.engine.model.fd.AdvanceBlockParameterDescription;
import eu.advance.logistics.flow.engine.model.fd.AdvanceConstantBlock;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
/**
* <b>ConstantBlock</b>
@@ -98,7 +98,7 @@
}
private static AdvanceConstantBlock clone(AdvanceConstantBlock src) {
- XElement temp = new XElement("temp");
+ XNElement temp = new XNElement("temp");
src.save(temp);
AdvanceConstantBlock cloned = new AdvanceConstantBlock();
cloned.load(temp);
Modified: flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/model/FlowDescription.java
===================================================================
--- flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/model/FlowDescription.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/Flow Editor Module/src/eu/advance/logistics/flow/editor/model/FlowDescription.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -35,7 +35,7 @@
import eu.advance.logistics.flow.engine.compiler.AdvanceCompilationResult;
import eu.advance.logistics.flow.engine.model.fd.AdvanceCompositeBlock;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
/**
*
@@ -92,7 +92,7 @@
}
public static void save(OutputStream s, AdvanceCompositeBlock compositeBlock) throws IOException {
- XElement root = AdvanceCompositeBlock.serializeFlow(compositeBlock);
+ XNElement root = AdvanceCompositeBlock.serializeFlow(compositeBlock);
BufferedWriter out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(s));
@@ -114,11 +114,11 @@
}
public static AdvanceCompositeBlock load(InputStream s) throws IOException {
- XElement root = null;
+ XNElement root = null;
InputStream in = null;
try {
in = new BufferedInputStream(s);
- root = XElement.parseXML(in);
+ root = XNElement.parseXML(in);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
} finally {
Modified: flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/DownloadFlowAction.java
===================================================================
--- flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/DownloadFlowAction.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/DownloadFlowAction.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -53,7 +53,7 @@
import eu.advance.logistics.flow.engine.api.ds.AdvanceRealm;
import eu.advance.logistics.flow.engine.api.ds.AdvanceUserRealmRights;
import eu.advance.logistics.flow.engine.model.fd.AdvanceCompositeBlock;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
//@ActionID(category = "RemoteFlowEngine",
//id = "eu.advance.logistics.flow.engine.controlcenter.DownloadFlowAction")
@@ -118,7 +118,7 @@
AdvanceCompositeBlock flow = null;
try {
Commons.fixRights(engine, realm, AdvanceUserRealmRights.READ);
- XElement root = engine.datastore().queryFlow(realm.name);
+ XNElement root = engine.datastore().queryFlow(realm.name);
if (root != null) {
flow = AdvanceCompositeBlock.parseFlow(root);
} else {
Modified: flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/EngineController.java
===================================================================
--- flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/EngineController.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/EngineController.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -40,7 +40,7 @@
import eu.advance.logistics.flow.engine.api.ds.AdvanceLoginType;
import eu.advance.logistics.flow.engine.api.impl.HttpRemoteEngineControl;
import eu.advance.logistics.flow.engine.test.BasicLocalEngine;
-import eu.advance.logistics.flow.engine.util.KeystoreManager;
+import hu.akarnokd.utils.crypto.KeystoreManager;
/**
*
Modified: flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/VerifyFlowAction.java
===================================================================
--- flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/VerifyFlowAction.java 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/FlowEngineCC/src/eu/advance/logistics/flow/engine/controlcenter/VerifyFlowAction.java 2013-11-15 12:26:41 UTC (rev 342)
@@ -46,7 +46,7 @@
import eu.advance.logistics.flow.engine.compiler.AdvanceCompilationResult;
import eu.advance.logistics.flow.engine.model.fd.AdvanceCompositeBlock;
import eu.advance.logistics.flow.engine.test.BasicLocalEngine;
-import eu.advance.logistics.flow.engine.xml.XElement;
+import hu.akarnokd.utils.xml.XNElement;
@ActionID(category = "RemoteFlowEngine",
id = "eu.advance.logistics.flow.engine.controlcenter.VerifyFlowAction")
@@ -125,7 +125,7 @@
CCDebugRow dr = new CCDebugRow();
dr.watch = new CCWatchSettings();
dr.timestamp = new Date();
- XElement e = new XElement("advance-compilation-result");
+ XNElement e = new XNElement("advance-compilation-result");
result.save(e);
dr.value = Option.some(e);
dr.watch.block = "";
Modified: flow-editor/trunk/nbproject/genfiles.properties
===================================================================
--- flow-editor/trunk/nbproject/genfiles.properties 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/nbproject/genfiles.properties 2013-11-15 12:26:41 UTC (rev 342)
@@ -7,5 +7,5 @@
nbproject/build-impl.xml.script.CRC32=f0745599
nbproject/build-impl.xml.stylesheet.CRC32=0f381476@2.47.1
nbproject/platform.xml.data.CRC32=9b3166a5
-nbproject/platform.xml.script.CRC32=db9e1f43
-nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.50.1
+nbproject/platform.xml.script.CRC32=6dcbd131
+nbproject/platform.xml.stylesheet.CRC32=4e1f53d4@2.62.1
Modified: flow-editor/trunk/nbproject/platform.xml
===================================================================
--- flow-editor/trunk/nbproject/platform.xml 2013-11-15 12:00:43 UTC (rev 341)
+++ flow-editor/trunk/nbproject/platform.xml 2013-11-15 12:26:41 UTC (rev 342)
@@ -17,7 +17,7 @@
</pathconvert>
<property name="disabled.modules" value=""/>
<pathconvert property="module.includes" pathsep="">
- <mapper type="glob" from="${basedir}${file.separator}*" to="(?!\Q*\E)"/>
+ <mapper type="glob" from="${basedir}${file.separator}*" to="(?!^\Q*\E$)"/>
<path>
<filelist files="${disabled.modules}" dir="."/>
</path>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-11-15 12:00:46
|
Revision: 341
http://sourceforge.net/p/advance-project/code/341
Author: akarnokd
Date: 2013-11-15 12:00:43 +0000 (Fri, 15 Nov 2013)
Log Message:
-----------
Updated libraries
Modified Paths:
--------------
advance-live-reporter-os/WebContent/WEB-INF/lib/akarnokd_tools.jar
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/DuringDayData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
Added Paths:
-----------
advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-1.0.jar
advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-api-1.0.jar
Removed Paths:
-------------
advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine.jar
Added: advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-1.0.jar
===================================================================
(Binary files differ)
Index: advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-1.0.jar
===================================================================
--- advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-1.0.jar 2013-11-15 11:50:36 UTC (rev 340)
+++ advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-1.0.jar 2013-11-15 12:00:43 UTC (rev 341)
Property changes on: advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-1.0.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-api-1.0.jar
===================================================================
(Binary files differ)
Index: advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-api-1.0.jar
===================================================================
--- advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-api-1.0.jar 2013-11-15 11:50:36 UTC (rev 340)
+++ advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-api-1.0.jar 2013-11-15 12:00:43 UTC (rev 341)
Property changes on: advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine-api-1.0.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Deleted: advance-live-reporter-os/WebContent/WEB-INF/lib/advance-flow-engine.jar
===================================================================
(Binary files differ)
Modified: advance-live-reporter-os/WebContent/WEB-INF/lib/akarnokd_tools.jar
===================================================================
(Binary files differ)
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java 2013-11-15 11:50:36 UTC (rev 340)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java 2013-11-15 12:00:43 UTC (rev 341)
@@ -20,6 +20,8 @@
*/
package eu.advance.logistics.live.reporter.charts;
+import hu.akarnokd.utils.xml.XElement;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumSet;
@@ -30,7 +32,6 @@
import javax.xml.stream.XMLStreamException;
-import eu.advance.logistics.flow.engine.xml.XElement;
import eu.advance.logistics.live.reporter.model.ItemStatus;
/**
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/DuringDayData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/DuringDayData.java 2013-11-15 11:50:36 UTC (rev 340)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/DuringDayData.java 2013-11-15 12:00:43 UTC (rev 341)
@@ -25,6 +25,7 @@
import hu.akarnokd.utils.collection.AggregatorHashMap4;
import hu.akarnokd.utils.collection.AggregatorMap1;
import hu.akarnokd.utils.collection.AggregatorMap4;
+import hu.akarnokd.utils.xml.XElement;
import java.io.IOException;
import java.util.ArrayList;
@@ -39,7 +40,6 @@
import com.google.common.collect.Iterables;
-import eu.advance.logistics.flow.engine.xml.XElement;
import eu.advance.logistics.live.reporter.model.ChartView;
import eu.advance.logistics.live.reporter.model.DuringAmountStatus;
import eu.advance.logistics.live.reporter.model.ServiceLevel;
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-15 11:50:36 UTC (rev 340)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-15 12:00:43 UTC (rev 341)
@@ -50,21 +50,21 @@
private WarehouseOption l2warehouseOption;
/** The storage area order. */
private StorageAreaOrder storageOrder;
-
+
/** Level 3 warehouse display mode option. */
private WarehouseOption l3warehouseOption;
/** Level 3 selected storage area ID. */
private long l3SelectedStorageId;
- /** Level 3 warehouse name. */
- private String l3warehouse;
-
+ /** Level 3 warehouse name. */
+ private String l3warehouse;
+
/** The hub id. */
private final long hubId;
/** The user. */
private final String user;
- /** The map of warehouse pairs. */
- private final Map<String, String> warehousePairMap;
-
+ /** The map of warehouse pairs. */
+ private final Map<String, String> warehousePairMap;
+
/**
* Constructor.
* @param hubId the hub
@@ -73,138 +73,131 @@
*/
public WarehouseSwitch(long hubId, String user) {
this.hubId = hubId;
- this.user = user;
- this.warehousePairMap = this.createWarehousePairMap();
- this.warehouse = this.getFirstWarehousePairTop();
-
- this.l2warehouseOption = WarehouseOption.A;
+ this.user = user;
+ this.warehousePairMap = this.createWarehousePairMap();
+ this.warehouse = this.getFirstWarehousePairTop();
+
+ this.l2warehouseOption = WarehouseOption.A;
this.storageOrder = StorageAreaOrder.PHYSICAL;
this.l3warehouseOption = WarehouseOption.LEFT;
this.l3SelectedStorageId = 0;
this.l3warehouse = this.warehouse;
}
-
+
/**
* Creates map for the warehouse pairs.
* @return map of the warehouse pairs
*/
- private Map<String, String> createWarehousePairMap()
- {
- Map<String, String> wPair = new LinkedHashMap<>();
- List<Warehouse> list = MasterDB.warehouses(this.hubId);
-
- if(list.isEmpty() == false)
- {
- for(Warehouse item: list)
- {
- if( (wPair.containsKey(item.warehouse) == false) && (wPair.containsValue(item.warehouse) == false))
- {
- String pair = Strings.isNullOrEmpty(item.pair) ? "" : item.pair;
- wPair.put(item.warehouse, pair);
- }
- }
- }
-
- return wPair;
+ private Map<String, String> createWarehousePairMap() {
+ Map<String, String> wPair = new LinkedHashMap<>();
+ List<Warehouse> list = MasterDB.warehouses(this.hubId);
+
+ if (list.isEmpty() == false) {
+ for (Warehouse item: list) {
+ if ((wPair.containsKey(item.warehouse) == false) && (wPair.containsValue(item.warehouse) == false)) {
+ String pair = Strings.isNullOrEmpty(item.pair) ? "" : item.pair;
+ wPair.put(item.warehouse, pair);
+ }
+ }
+ }
+
+ return wPair;
}
-
+
/**
* Returns the map of the warehouse pairs.
* @return the map of the warehouse pairs
*/
- public Map<String, String> getWarehousePairMap()
- {
- return this.warehousePairMap;
+ public Map<String, String> getWarehousePairMap() {
+ return this.warehousePairMap;
}
-
+
/**
* Returns the pair of the warehouse.
* @return the pair of the warehouse
*/
- public String getPair()
- {
- String res = "";
-
- if(warehousePairMap.containsKey(this.warehouse))
- {
- res = warehousePairMap.get(this.warehouse);
- }
- else if(warehousePairMap.containsValue(this.warehouse))
- {
- for(String keyItem : warehousePairMap.keySet())
- {
- if(warehousePairMap.get(keyItem).equals(this.warehouse))
- {
- res = keyItem;
- }
- }
- }
-
- return res;
+ public String getPair() {
+ String res = "";
+
+ if (warehousePairMap.containsKey(this.warehouse)) {
+ res = warehousePairMap.get(this.warehouse);
+ }
+ else if(warehousePairMap.containsValue(this.warehouse))
+ {
+ for(String keyItem : warehousePairMap.keySet())
+ {
+ if(warehousePairMap.get(keyItem).equals(this.warehouse))
+ {
+ res = keyItem;
+ }
+ }
+ }
+
+ return res;
}
-
+
/**
* Returns the top member of the first warehouse pair to initialize the warehouse.
* @return the top member of the first warehouse pair
*/
public String getFirstWarehousePairTop()
{
- String res = "";
- if(this.warehousePairMap.isEmpty() == false)
- {
- res = this.warehousePairMap.keySet().iterator().next();
- }
-
- return res;
+ String res = "";
+ if(this.warehousePairMap.isEmpty() == false)
+ {
+ res = this.warehousePairMap.keySet().iterator().next();
+ }
+
+ return res;
}
-
+
/**
* Returns the top member of the actual warehouse pair.
* @return the top member of the actual warehouse pair
*/
public String getWarehousePairTop()
{
- String res = "";
-
- if(warehousePairMap.containsKey(this.warehouse))
- {
- res = this.warehouse;
- }
- else if(warehousePairMap.containsValue(this.warehouse))
- {
- for(String keyItem : warehousePairMap.keySet())
- {
- if(warehousePairMap.get(keyItem).equals(this.warehouse))
- {
- res = keyItem;
- }
- }
- }
-
- return res;
+ String res = "";
+
+ if(warehousePairMap.containsKey(this.warehouse))
+ {
+ res = this.warehouse;
+ }
+ else if(warehousePairMap.containsValue(this.warehouse))
+ {
+ for(String keyItem : warehousePairMap.keySet())
+ {
+ if(warehousePairMap.get(keyItem).equals(this.warehouse))
+ {
+ res = keyItem;
+ }
+ }
+ }
+
+ return res;
}
-
- /**
- * Returns the bottom member of the actual warehouse pair.
- * @return the bottom member of the actual warehouse pair
- */
+
+ /**
+ * Returns the bottom member of the actual warehouse pair.
+ * @return the bottom member of the actual warehouse pair
+ */
public String getWarehousePairBottom()
{
- String res = "";
-
- if(this.warehousePairMap.containsKey(this.warehouse))
- {
- res = this.warehousePairMap.get(this.warehouse);
- }
- else if(this.warehousePairMap.containsValue(this.warehouse))
- {
- res = this.warehouse;
- }
-
- return res;
+ String res = "";
+
+ if(this.warehousePairMap.containsKey(this.warehouse))
+ {
+ res = this.warehousePairMap.get(this.warehouse);
+ }
+ else if(this.warehousePairMap.containsValue(this.warehouse))
+ {
+ res = this.warehouse;
+ }
+
+ return res;
}
-
+
/**
* Returns the hub of this warehouse.
* @return the hub id
@@ -212,16 +205,16 @@
public long hubId() {
return hubId;
}
-
+
/**
* Sets the actual warehosue.
* @param warehouse the actual warehosue
*/
public void setWarehouse(String warehouse)
{
- this.warehouse = warehouse;
+ this.warehouse = warehouse;
}
-
+
/**
* Set the level 2 warehouse option.
* @param option the option
@@ -251,16 +244,16 @@
public void setL3SelectedStorageId(long storageId) {
this.l3SelectedStorageId = storageId;
}
-
+
/**
* Sets the level 3 warehouse.
* @param warehouse the level 3 warehouse
*/
public void setL3Warehouse(String warehouse)
{
- this.l3warehouse = warehouse;
+ this.l3warehouse = warehouse;
}
-
+
/**
* @return the warehouse
*/
@@ -362,16 +355,16 @@
public long getL3SelectedStorageId() {
return this.l3SelectedStorageId;
}
-
+
/**
* Returns the Level 3 warehouse.
* @return the Level 3 warehouse
*/
public String getL3Warehouse()
{
- return this.l3warehouse;
+ return this.l3warehouse;
}
-
+
/**
* Returns the default floorspace scale.
* @return the default floorspace scale
@@ -387,9 +380,9 @@
Map<L2DisplaySide, List<L2StorageRawData>> result = new LinkedHashMap<L2DisplaySide, List<L2StorageRawData>>();
Map<String, Map<WarehouseSide, List<StorageAreaInfo>>> warehouseLayoutMap = MasterDB.getWarehouseLayoutMap(hubId);
-
+
Warehouse wh = MasterDB.warehouse(hubId, warehouse);
-
+
for (L2DisplaySide displaySide : L2DisplaySide.values()) {
List<StorageAreaInfo> storageInfoList;
@@ -418,29 +411,29 @@
switch(sOption) {
case A:
{
- storageRaw.warehouse = warehouse;
- storageRaw.type = getWarehouseType();
- storageRaw.side = WarehouseSide.values()[displaySide.ordinal()];
- break;
+ storageRaw.warehouse = warehouse;
+ storageRaw.type = getWarehouseType();
+ storageRaw.side = WarehouseSide.values()[displaySide.ordinal()];
+ break;
}
case B:
{
- storageRaw.warehouse = wh.pair;
- storageRaw.type = getWarehouseType();
- storageRaw.side = WarehouseSide.values()[displaySide.ordinal()];
- break;
+ storageRaw.warehouse = wh.pair;
+ storageRaw.type = getWarehouseType();
+ storageRaw.side = WarehouseSide.values()[displaySide.ordinal()];
+ break;
}
case LEFT:
case RIGHT:
{
- storageRaw.warehouse = (displaySide == L2DisplaySide.LEFT) ? warehouse : wh.pair;
- storageRaw.type = WarehouseType.values()[displaySide.ordinal()];
- storageRaw.side = getL2WarehouseSide();
- break;
+ storageRaw.warehouse = (displaySide == L2DisplaySide.LEFT) ? warehouse : wh.pair;
+ storageRaw.type = WarehouseType.values()[displaySide.ordinal()];
+ storageRaw.side = getL2WarehouseSide();
+ break;
}
default:
}
-
+
storageRaw.id = storageInfoItem.id;
for (WarehouseType st : WarehouseType.values()) {
@@ -468,7 +461,7 @@
List<L3DepotStorageData> result = new ArrayList<L3DepotStorageData>();
Map<String, Map<WarehouseSide, List<StorageAreaInfo>>> warehouseLayoutMap = MasterDB.getWarehouseLayoutMap(hubId);
-
+
List<StorageAreaInfo> storageInfoList = warehouseLayoutMap.get(l3warehouse).get(getL3WarehouseSide());
for (StorageAreaInfo storageInfoItem : storageInfoList) {
HubDepotInfo depotInfo = MasterDB.getDepotSummaryValueMaxes(hubId, storageInfoItem.id, user);
@@ -506,7 +499,7 @@
long result = 0;
Map<String, Map<WarehouseSide, List<StorageAreaInfo>>> warehouseLayoutMap = MasterDB.getWarehouseLayoutMap(hubId);
-
+
// If the storageId from the request is real..
if (storageId != 0) {
List<StorageAreaInfo> prevStorageInfoList = warehouseLayoutMap.get(l3warehouse).get(prevWarehouseSide);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-11-15 11:50:40
|
Revision: 340
http://sourceforge.net/p/advance-project/code/340
Author: akarnokd
Date: 2013-11-15 11:50:36 +0000 (Fri, 15 Nov 2013)
Log Message:
-----------
Updated version number.
Modified Paths:
--------------
advance/src/eu/advance/logistics/flow/engine/AdvanceFlowEngine.java
Modified: advance/src/eu/advance/logistics/flow/engine/AdvanceFlowEngine.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/AdvanceFlowEngine.java 2013-11-13 15:04:09 UTC (rev 339)
+++ advance/src/eu/advance/logistics/flow/engine/AdvanceFlowEngine.java 2013-11-15 11:50:36 UTC (rev 340)
@@ -88,7 +88,7 @@
/** The logger. */
protected static final Logger LOG = LoggerFactory.getLogger(AdvanceFlowEngine.class);
/** The version of the flow engine. */
- public static final String VERSION = "0.16.288";
+ public static final String VERSION = "1.0.000";
/** The configuration. */
private AdvanceEngineConfig config;
/** The basic server. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-13 15:04:12
|
Revision: 339
http://sourceforge.net/p/advance-project/code/339
Author: csirobi
Date: 2013-11-13 15:04:09 +0000 (Wed, 13 Nov 2013)
Log Message:
-----------
Warehouse empty map handling.
Modified Paths:
--------------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-13 14:28:02 UTC (rev 338)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-13 15:04:09 UTC (rev 339)
@@ -145,12 +145,18 @@
}
/**
- * Returns the top member of the first warehouse pair.
+ * Returns the top member of the first warehouse pair to initialize the warehouse.
* @return the top member of the first warehouse pair
*/
public String getFirstWarehousePairTop()
{
- return this.warehousePairMap.keySet().iterator().next();
+ String res = "";
+ if(this.warehousePairMap.isEmpty() == false)
+ {
+ res = this.warehousePairMap.keySet().iterator().next();
+ }
+
+ return res;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-13 14:28:05
|
Revision: 338
http://sourceforge.net/p/advance-project/code/338
Author: csirobi
Date: 2013-11-13 14:28:02 +0000 (Wed, 13 Nov 2013)
Log Message:
-----------
L2 raw data minor changes
Modified Paths:
--------------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageChartData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageRawData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageChartData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageChartData.java 2013-11-13 13:36:02 UTC (rev 337)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageChartData.java 2013-11-13 14:28:02 UTC (rev 338)
@@ -40,12 +40,12 @@
/** HashMap for background color of chart. */
public final Map<L2TimeState, BgColor> bgColor;
- /**Time states which are used in this class.*/
+ /**Time states which are used in this level.*/
public static final L2TimeState[] USED_BAR_TIME = {
L2TimeState.NOW_AT_HUB,
L2TimeState.COMING_UP
};
- /**Warehouse services which are used in this class.*/
+ /**Warehouse services which are used in this level.*/
public static final WarehouseServiceLevel[] USED_SERVICES = {
WarehouseServiceLevel.STANDARD,
WarehouseServiceLevel.PRIORITY_SPECIAL
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageRawData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageRawData.java 2013-11-13 13:36:02 UTC (rev 337)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageRawData.java 2013-11-13 14:28:02 UTC (rev 338)
@@ -43,9 +43,22 @@
/** Storage area capacity based on the warehouse type and the warehouse service level. */
public final Map<WarehouseType, Map<WarehouseServiceLevel, Double>> storageCapacityMap;
-
/** HashMap for items. */
public final Map<WarehouseServiceLevel, Map<ItemStatus, BarData>> items;
+
+ /**Warehouse services which are used in this level.*/
+ public static final WarehouseServiceLevel[] USED_SERVICES = {
+ WarehouseServiceLevel.STANDARD,
+ WarehouseServiceLevel.PRIORITY_SPECIAL
+ };
+ /**Item statuses which are used in this level.*/
+ public static final ItemStatus[] USED_ITEMS = {
+ ItemStatus.AT_HUB,
+ ItemStatus.DECLARED,
+ ItemStatus.SCANNED,
+ ItemStatus.CREATED
+ };
+
/**
* Constructor.
*/
@@ -55,34 +68,13 @@
}
/**
- * Get that warehouse service levels which are used in this class: STANDARD, PRIORITY_SPECIAL.
- * @return EnumSet of the used warehouse service levels
- */
- public static EnumSet<WarehouseServiceLevel> getUsedServices() {
- EnumSet<WarehouseServiceLevel> result = EnumSet.of(WarehouseServiceLevel.STANDARD, WarehouseServiceLevel.PRIORITY_SPECIAL);
- return result;
- }
-
- /**
- * Get that item statuses which are used in this class.
- * @return EnumSet of the used items statuses
- */
- public static EnumSet<ItemStatus> getUsedItemStatus() {
- EnumSet<ItemStatus> result = EnumSet.of(ItemStatus.AT_HUB,
- ItemStatus.DECLARED,
- ItemStatus.SCANNED,
- ItemStatus.CREATED);
- return result;
- }
-
- /**
* Normalize items data based on the floorspace capacity of the storage.
*/
public void normalizeByCap() {
BarData bd;
double capacity;
- for (WarehouseServiceLevel sKey : L2StorageRawData.getUsedServices()) {
+ for (WarehouseServiceLevel sKey : L2StorageRawData.USED_SERVICES) {
// For at_hub: count the warehouse type + warehouse snip specific capacity.
bd = this.items.get(sKey).get(ItemStatus.AT_HUB);
capacity = this.storageCapacityMap.get(this.type).get(sKey);
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java 2013-11-13 13:36:02 UTC (rev 337)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java 2013-11-13 14:28:02 UTC (rev 338)
@@ -433,11 +433,11 @@
EnumMap<WarehouseServiceLevel, Aggregates> forDepot = depotLevelAggregates.get((short)storageRawItem.id);
// Fill the concrete storageRawItem
- for (WarehouseServiceLevel sKey : L2StorageRawData.getUsedServices()) {
+ for (WarehouseServiceLevel sKey : L2StorageRawData.USED_SERVICES) {
Aggregates a = forDepot.get(sKey);
Map<ItemStatus, BarData> items = new LinkedHashMap<ItemStatus, BarData>();
- for (ItemStatus pKey : L2StorageRawData.getUsedItemStatus()) {
+ for (ItemStatus pKey : L2StorageRawData.USED_ITEMS) {
if (pKey == ItemStatus.AT_HUB) {
double v = getInStorageFloorspace(levelTypeDepotSum, storageRawItem.type, storageRawItem.id, sKey);
items.put(pKey, new BarData(v));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-13 13:36:05
|
Revision: 337
http://sourceforge.net/p/advance-project/code/337
Author: csirobi
Date: 2013-11-13 13:36:02 +0000 (Wed, 13 Nov 2013)
Log Message:
-----------
L2: "direction" tag of json minor changes
Modified Paths:
--------------
advance-live-reporter-os/WebContent/warehouse-header.jspf
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java
Modified: advance-live-reporter-os/WebContent/warehouse-header.jspf
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-11-11 18:37:11 UTC (rev 336)
+++ advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-11-13 13:36:02 UTC (rev 337)
@@ -32,6 +32,7 @@
String whName = ObjectUtils.nvl(request.getParameter("warehouse_name"), warehouseSwitch.getFirstWarehousePairTop());
String whOption = ObjectUtils.nvl(request.getParameter("warehouse_option"), "A");
String stOrder = ObjectUtils.nvl(request.getParameter("storage_order"), "PHYSICAL");
+ //Real values are set by l2_l3 form at the l2 jsp page.
String whL3Option = ObjectUtils.nvl(request.getParameter("warehouse_l3_option"), "LEFT");
String whL3StId = ObjectUtils.nvl(request.getParameter("warehouse_l3_storage_id"), "0");
String whL3Name = ObjectUtils.nvl(request.getParameter("warehouse_l3_name"), warehouseSwitch.getFirstWarehousePairTop());
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java 2013-11-11 18:37:11 UTC (rev 336)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java 2013-11-13 13:36:02 UTC (rev 337)
@@ -194,36 +194,19 @@
for (L2DisplaySide dsKey : L2DisplaySide.values()) {
JSONObject dsRecord = new JSONObject();
switch (ws.getL2WarehouseOption()) {
- case A:
- {
- dsRecord.put("align", WarehouseSide.values()[dsKey.ordinal()].name().toLowerCase());
- dsRecord.put("warehouseName", ws.getWarehouse());
- dsRecord.put("warehouseInfo", ws.getWarehouseType().name());
- break;
- }
+ case A:
case B:
- {
dsRecord.put("align", WarehouseSide.values()[dsKey.ordinal()].name().toLowerCase());
- dsRecord.put("warehouseName", ws.getPair());
dsRecord.put("warehouseInfo", ws.getWarehouseType().name());
break;
- }
case LEFT:
- {
dsRecord.put("align", WarehouseSide.LEFT.toString().toLowerCase());
- String wh = (dsKey == L2DisplaySide.LEFT) ? ws.getWarehouse() : ws.getPair();
- dsRecord.put("warehouseName", wh);
dsRecord.put("warehouseInfo", WarehouseType.values()[dsKey.ordinal()].name());
break;
- }
case RIGHT:
- {
dsRecord.put("align", WarehouseSide.RIGHT.toString().toLowerCase());
- String wh = (dsKey == L2DisplaySide.LEFT) ? ws.getWarehouse() : ws.getPair();
- dsRecord.put("warehouseName", wh);
dsRecord.put("warehouseInfo", WarehouseType.values()[dsKey.ordinal()].name());
break;
- }
default:
}
dsRecord.put("at_hub", L2TimeState.NOW_AT_HUB.getMessage());
@@ -245,24 +228,18 @@
{
String res = "";
- switch(ws.getL2WarehouseOption())
- {
+ switch(ws.getL2WarehouseOption()) {
case A:
- {
res = ws.getWarehouse();
break;
- }
case B:
- {
res = ws.getPair();
break;
- }
case LEFT:
case RIGHT:
- {
res = (ds == L2DisplaySide.LEFT) ? ws.getWarehouse() : ws.getPair();
break;
- }
+ default:
}
return res;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-11 18:37:14
|
Revision: 336
http://sourceforge.net/p/advance-project/code/336
Author: csirobi
Date: 2013-11-11 18:37:11 +0000 (Mon, 11 Nov 2013)
Log Message:
-----------
Warehouse minor changes
Modified Paths:
--------------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageChartData.java
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java 2013-11-11 17:52:02 UTC (rev 335)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/ChartProcess.java 2013-11-11 18:37:11 UTC (rev 336)
@@ -132,12 +132,12 @@
HashMap<L2TimeState, Double> maxInput = new LinkedHashMap<L2TimeState, Double>();
// I.) For NOW_AT_HUB & COMING_UP
- for (L2TimeState timeState : L2StorageChartData.getUsedBarTime()) {
+ for (L2TimeState timeState : L2StorageChartData.USED_BAR_TIME) {
// 1.) Count bar length...
Map<WarehouseServiceLevel, L2StorageChartData.BarLength> lengthMap = new LinkedHashMap<>();
Map<WarehouseServiceLevel, Double> weightInput = ChartProcess.getWeightInput(timeState, storageRaw);
//.. for STANDARD & PRIORITY
- for (WarehouseServiceLevel wsl : L2StorageChartData.getUsedServices()) {
+ for (WarehouseServiceLevel wsl : L2StorageChartData.USED_SERVICES) {
L2StorageChartData.BarLength barLength = new L2StorageChartData.BarLength();
barLength.setLength(ChartProcess.countBarLength(timeState, weightInput.get(wsl).doubleValue()));
lengthMap.put(wsl, barLength);
@@ -166,7 +166,7 @@
//
/**
- * Count weighted input for barLength(), maximum() at STANDARD & PRIORITY.
+ * Count weighted input for barLength(), maximum() at STANDARD & PRIORITY at level 2.
* @param timeState the time state
* @param storageRaw the raw data
* @return the state map
@@ -178,14 +178,14 @@
switch(timeState) {
case NOW_AT_HUB:
// for STANDARD & PRIORITY
- for (WarehouseServiceLevel wsl : L2StorageChartData.getUsedServices()) {
+ for (WarehouseServiceLevel wsl : L2StorageChartData.USED_SERVICES) {
double x = storageRaw.items.get(wsl).get(ItemStatus.AT_HUB).normalValue.doubleValue();
weightInput.put(wsl, x);
}
break;
case COMING_UP:
- for (WarehouseServiceLevel wsl : L2StorageChartData.getUsedServices()) {
+ for (WarehouseServiceLevel wsl : L2StorageChartData.USED_SERVICES) {
double m = ChartProcess.PW_VALUES.get(timeState).wm
* storageRaw.items.get(wsl).get(ItemStatus.DECLARED).normalValue.doubleValue();
double s = ChartProcess.PW_VALUES.get(timeState).ws
@@ -205,7 +205,7 @@
/**
- * Count the maximum value of weighted input map.
+ * Count the maximum value of weighted input map for level 2 and 3.
* @param weightInput the weight map
* @return maximum
*/
@@ -218,7 +218,7 @@
}
/**
- * Count bar length.
+ * Count bar length for level 2.
* @param timeState the time state
* @param x the X coordinate
* @return the bar length
@@ -230,7 +230,7 @@
}
/**
- * Count bar color.
+ * Count bar color for level 2.
* @param timeState time state
* @param x value
* @return list of color components
@@ -284,7 +284,7 @@
depotStorageData.relFullness = (wX0SA + wX0SB + wX1);
}
/**
- * Get weight input.
+ * Count the weight input for level 3.
* @param timeState the time state
* @param type the warehouse type
* @param depotStorageData the data
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java 2013-11-11 17:52:02 UTC (rev 335)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java 2013-11-11 18:37:11 UTC (rev 336)
@@ -289,7 +289,7 @@
storageRecord.put("id", storageChart.id);
storageRecord.put("overColor", storageChart.bgColor.get(L2TimeState.OVERALL).getColor());
- for (L2TimeState timeState : L2StorageChartData.getUsedBarTime()) {
+ for (L2TimeState timeState : L2StorageChartData.USED_BAR_TIME) {
JSONObject timeRecord = new JSONObject();
timeRecord.put("standardNormal", storageChart.barLength.get(timeState).get(WarehouseServiceLevel.STANDARD).getLength().toPlainString());
timeRecord.put("priorityNormal", storageChart.barLength.get(timeState).get(WarehouseServiceLevel.PRIORITY_SPECIAL).getLength().toPlainString());
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageChartData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageChartData.java 2013-11-11 17:52:02 UTC (rev 335)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2StorageChartData.java 2013-11-11 18:37:11 UTC (rev 336)
@@ -20,7 +20,6 @@
*/
package eu.advance.logistics.live.reporter.charts;
-import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -40,6 +39,18 @@
public final Map<L2TimeState, Map<WarehouseServiceLevel, BarLength>> barLength;
/** HashMap for background color of chart. */
public final Map<L2TimeState, BgColor> bgColor;
+
+ /**Time states which are used in this class.*/
+ public static final L2TimeState[] USED_BAR_TIME = {
+ L2TimeState.NOW_AT_HUB,
+ L2TimeState.COMING_UP
+ };
+ /**Warehouse services which are used in this class.*/
+ public static final WarehouseServiceLevel[] USED_SERVICES = {
+ WarehouseServiceLevel.STANDARD,
+ WarehouseServiceLevel.PRIORITY_SPECIAL
+ };
+
/**
* Constructor, initializes the fields.
*/
@@ -49,24 +60,6 @@
}
/**
- * Get that time states which are used in this class: NOW_AT_HUB, COMING_UP.
- * @return EnumSet of the used time states
- */
- public static EnumSet<L2TimeState> getUsedBarTime() {
- EnumSet<L2TimeState> result = EnumSet.of(L2TimeState.NOW_AT_HUB, L2TimeState.COMING_UP);
- return result;
- }
-
- /**
- * Get that warehouse services which are used in this class.
- * @return EnumSet of the used warehouse service levels
- */
- public static EnumSet<WarehouseServiceLevel> getUsedServices() {
- EnumSet<WarehouseServiceLevel> result = EnumSet.of(WarehouseServiceLevel.STANDARD, WarehouseServiceLevel.PRIORITY_SPECIAL);
- return result;
- }
-
- /**
* BarLength inner helper class for storing the bar length.
* @author csirobi
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-11 17:52:04
|
Revision: 335
http://sourceforge.net/p/advance-project/code/335
Author: csirobi
Date: 2013-11-11 17:52:02 +0000 (Mon, 11 Nov 2013)
Log Message:
-----------
Warehouse minor changes
Modified Paths:
--------------
advance-live-reporter-os/WebContent/api-warehouse-l3.jsp
advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3WarehouseMode.java
Modified: advance-live-reporter-os/WebContent/api-warehouse-l3.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-l3.jsp 2013-11-11 17:35:15 UTC (rev 334)
+++ advance-live-reporter-os/WebContent/api-warehouse-l3.jsp 2013-11-11 17:52:02 UTC (rev 335)
@@ -44,7 +44,7 @@
warehouseSwitch.setL3SelectedStorageId(Integer.parseInt(request.getParameter("warehouse_l3_storage_id")));
break;
}
- case L3OPTION:
+ case OPTION:
{
int atStorageId = Integer.parseInt(request.getParameter("warehouse_l3_storage_id"));
Modified: advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js
===================================================================
--- advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js 2013-11-11 17:35:15 UTC (rev 334)
+++ advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js 2013-11-11 17:52:02 UTC (rev 335)
@@ -37,8 +37,8 @@
$.warehousemenu("init", "l3");
mySelf.active = $.warehousemenu("getActiveMenu");
- mySelf.handlerForL3Option();
- mySelf.handlerForOrder();
+ mySelf.handlerFor("option");
+ mySelf.handlerFor("order");
mySelf.refreshPage();
$(window).on("orientationchange", function()
@@ -58,30 +58,18 @@
},
- handlerForL3Option : function()
+ handlerFor : function(group)
{
var mySelf = this;
- var cl = "click.option";
+ var cl = "click." + group;
- $("#hand_option").on(cl, function(event)
+ $("#hand_" + group).on(cl, function(event)
{
- mySelf.active.option = event.active;
- mySelf.callChart("l3option");
+ mySelf.active[group] = event.active;
+ mySelf.callChart(group);
});
},
- handlerForOrder : function()
- {
- var mySelf = this;
- var cl = "click.order";
-
- $("#hand_order").on(cl, function(event)
- {
- mySelf.active.order = event.active;
- mySelf.callChart("order");
- });
- },
-
refreshPage : function()
{
var mySelf = this;
@@ -94,10 +82,11 @@
{
var mySelf = this;
var s = mySelf.active.warehouse;
+ var l3o = mySelf.active.option.split("_");
var r = mySelf.active.order.split("_");
- var l3o = mySelf.active.option.split("_");
var storageId = 0;
var l3Warehouse = $('input[id="warehouse_l3_name"]').val();
+
if(modeType == "init")
{
@@ -115,8 +104,8 @@
data : {
mode : modeType,
warehouse_name : s,
+ warehouse_l3_option : l3o[1],
storage_order : r[1],
- warehouse_l3_option : l3o[1],
warehouse_l3_storage_id : storageId,
warehouse_l3_name : l3Warehouse
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3WarehouseMode.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3WarehouseMode.java 2013-11-11 17:35:15 UTC (rev 334)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3WarehouseMode.java 2013-11-11 17:52:02 UTC (rev 335)
@@ -30,8 +30,8 @@
INIT,
/** Orientation. */
ORIENT,
- /** Layer 3 option. */
- L3OPTION,
+ /** Option. */
+ OPTION,
/** Order. */
ORDER;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-11 17:35:18
|
Revision: 334
http://sourceforge.net/p/advance-project/code/334
Author: csirobi
Date: 2013-11-11 17:35:15 +0000 (Mon, 11 Nov 2013)
Log Message:
-----------
SL2 and SL3: modified based on the BL
Modified Paths:
--------------
advance-live-reporter-os/WebContent/api-warehouse-l3.jsp
advance-live-reporter-os/WebContent/js/charts/warehouse-l2-chart.js
advance-live-reporter-os/WebContent/js/pages/warehouse-l2-page.js
advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js
advance-live-reporter-os/WebContent/warehouse-header.jspf
advance-live-reporter-os/WebContent/warehouse-l2.jsp
advance-live-reporter-os/WebContent/warehouse-l3.jsp
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3Chart.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3DepotStorageData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3WarehouseMode.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
Modified: advance-live-reporter-os/WebContent/api-warehouse-l3.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-l3.jsp 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/WebContent/api-warehouse-l3.jsp 2013-11-11 17:35:15 UTC (rev 334)
@@ -31,8 +31,9 @@
WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
warehouseSwitch.setWarehouse(request.getParameter("warehouse_name"));
+ warehouseSwitch.setStorageAreaOrder(request.getParameter("storage_order"));
warehouseSwitch.setL3WarehouseOption(request.getParameter("warehouse_l3_option"));
- warehouseSwitch.setStorageAreaOrder(request.getParameter("storage_order"));
+ warehouseSwitch.setL3Warehouse(request.getParameter("warehouse_l3_name"));
switch(L3WarehouseMode.valueOf(request.getParameter("mode").toUpperCase()))
{
@@ -43,7 +44,7 @@
warehouseSwitch.setL3SelectedStorageId(Integer.parseInt(request.getParameter("warehouse_l3_storage_id")));
break;
}
- case OPTION:
+ case L3OPTION:
{
int atStorageId = Integer.parseInt(request.getParameter("warehouse_l3_storage_id"));
Modified: advance-live-reporter-os/WebContent/js/charts/warehouse-l2-chart.js
===================================================================
--- advance-live-reporter-os/WebContent/js/charts/warehouse-l2-chart.js 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/WebContent/js/charts/warehouse-l2-chart.js 2013-11-11 17:35:15 UTC (rev 334)
@@ -151,6 +151,7 @@
var rect = $(event.target);
$("#" + settings.handSilentRect).triggerHandler({
type : "click.silent",
+ displayed_wh : rect.attr("displayed_wh"),
storage_id : rect.attr("storage_id"),
storage_info: rect.attr("storage_info")
});
@@ -301,6 +302,7 @@
myRect.setAttributeNS(null, "y", zeroY);
myRect.setAttributeNS(null, "width", columnInfo.width.circle + columnInfo.width.text);
myRect.setAttributeNS(null, "height", columnInfo.height);
+ myRect.setAttribute("displayed_wh", storageData.displayedWarehouse);
myRect.setAttribute("storage_info", storageData.warehouseLayout);
myRect.setAttribute("storage_id", storageData.id);
document.getElementById(appendId).appendChild(myRect);
Modified: advance-live-reporter-os/WebContent/js/pages/warehouse-l2-page.js
===================================================================
--- advance-live-reporter-os/WebContent/js/pages/warehouse-l2-page.js 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/WebContent/js/pages/warehouse-l2-page.js 2013-11-11 17:35:15 UTC (rev 334)
@@ -94,8 +94,9 @@
$('#l2_l3_form input[name="warehouse_name"]').val(s);
$('#l2_l3_form input[name="warehouse_option"]').val(o[1]);
$('#l2_l3_form input[name="storage_order"]').val(r[1]);
- $('#l2_l3_form input[name="warehouse_l3_option"]').val(l3o[2]);
+ $('#l2_l3_form input[name="warehouse_l3_option"]').val(l3o[1]);
$('#l2_l3_form input[name="warehouse_l3_storage_id"]').val(event.storage_id);
+ $('#l2_l3_form input[name="warehouse_l3_name"]').val(event.displayed_wh);
$("#l2_l3_form").submit();
});
Modified: advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js
===================================================================
--- advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js 2013-11-11 17:35:15 UTC (rev 334)
@@ -37,8 +37,8 @@
$.warehousemenu("init", "l3");
mySelf.active = $.warehousemenu("getActiveMenu");
- mySelf.handlerFor("option");
- mySelf.handlerFor("order");
+ mySelf.handlerForL3Option();
+ mySelf.handlerForOrder();
mySelf.refreshPage();
$(window).on("orientationchange", function()
@@ -58,18 +58,30 @@
},
- handlerFor : function(group)
+ handlerForL3Option : function()
{
var mySelf = this;
- var cl = "click." + group;
+ var cl = "click.option";
- $("#hand_" + group).on(cl, function(event)
+ $("#hand_option").on(cl, function(event)
{
- mySelf.active[group] = event.active;
- mySelf.callChart(group);
+ mySelf.active.option = event.active;
+ mySelf.callChart("l3option");
});
},
+ handlerForOrder : function()
+ {
+ var mySelf = this;
+ var cl = "click.order";
+
+ $("#hand_order").on(cl, function(event)
+ {
+ mySelf.active.order = event.active;
+ mySelf.callChart("order");
+ });
+ },
+
refreshPage : function()
{
var mySelf = this;
@@ -82,9 +94,10 @@
{
var mySelf = this;
var s = mySelf.active.warehouse;
- var o = mySelf.active.option.split("_");
var r = mySelf.active.order.split("_");
+ var l3o = mySelf.active.option.split("_");
var storageId = 0;
+ var l3Warehouse = $('input[id="warehouse_l3_name"]').val();
if(modeType == "init")
{
@@ -102,9 +115,10 @@
data : {
mode : modeType,
warehouse_name : s,
- warehouse_l3_option : o[1],
storage_order : r[1],
- warehouse_l3_storage_id : storageId
+ warehouse_l3_option : l3o[1],
+ warehouse_l3_storage_id : storageId,
+ warehouse_l3_name : l3Warehouse
}
});
}
Modified: advance-live-reporter-os/WebContent/warehouse-header.jspf
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-11-11 17:35:15 UTC (rev 334)
@@ -34,12 +34,14 @@
String stOrder = ObjectUtils.nvl(request.getParameter("storage_order"), "PHYSICAL");
String whL3Option = ObjectUtils.nvl(request.getParameter("warehouse_l3_option"), "LEFT");
String whL3StId = ObjectUtils.nvl(request.getParameter("warehouse_l3_storage_id"), "0");
+ String whL3Name = ObjectUtils.nvl(request.getParameter("warehouse_l3_name"), warehouseSwitch.getFirstWarehousePairTop());
warehouseSwitch.setWarehouse(whName);
warehouseSwitch.setL2WarehouseOption(whOption);
warehouseSwitch.setStorageAreaOrder(stOrder);
warehouseSwitch.setL3WarehouseOption(whL3Option);
warehouseSwitch.setL3SelectedStorageId(Long.parseLong(whL3StId));
+ warehouseSwitch.setL3Warehouse(whL3Name);
}
catch(IllegalArgumentException e)
{
@@ -433,7 +435,6 @@
getActiveMenu : function()
{
var active = {};
-
active.warehouse = $('td[id^="warehouse_"].active').text();
active.option = $('td[id^="option_"].active').attr("id");
active.order = $('td[id^="order_"].active').attr("id");
@@ -499,8 +500,6 @@
if (method === "init")
op[method](param);
else if (method === "getActiveMenu")
- return op[method]();
- else if (method === "showErrorMessage")
return op[method](param);
};
Modified: advance-live-reporter-os/WebContent/warehouse-l2.jsp
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-l2.jsp 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/WebContent/warehouse-l2.jsp 2013-11-11 17:35:15 UTC (rev 334)
@@ -34,6 +34,7 @@
<input type="hidden" name="storage_order" value="">
<input type="hidden" name="warehouse_l3_option" value="">
<input type="hidden" name="warehouse_l3_storage_id" value="">
+ <input type="hidden" name="warehouse_l3_name" value="">
</form>
</center>
</body>
Modified: advance-live-reporter-os/WebContent/warehouse-l3.jsp
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-l3.jsp 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/WebContent/warehouse-l3.jsp 2013-11-11 17:35:15 UTC (rev 334)
@@ -27,6 +27,7 @@
<div id="k2"></div>
<input id="warehouse_l3_storage_id" type="hidden" name="warehouse_l3_storage_id" value="<%= warehouseSwitch.getL3SelectedStorageId()%>">
+ <input id="warehouse_l3_name" type="hidden" name="warehouse_l3_name" value="<%= warehouseSwitch.getL3Warehouse()%>">
</center>
</body>
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L2Chart.java 2013-11-11 17:35:15 UTC (rev 334)
@@ -113,7 +113,7 @@
JSONObject result = new JSONObject();
result.put("direction", L2Chart.createDirectionJSON(ws));
for (L2DisplaySide dsKey : L2DisplaySide.values()) {
- result.put(dsKey.getInfo(), L2Chart.createDisplaySideJSON(storageRawMap.get(dsKey), storageChartMap.get(dsKey)));
+ result.put(dsKey.getInfo(), L2Chart.createDisplaySideJSON(L2Chart.getDisplayedWarehouse(dsKey, ws), storageRawMap.get(dsKey), storageChartMap.get(dsKey)));
}
return result;
@@ -195,18 +195,35 @@
JSONObject dsRecord = new JSONObject();
switch (ws.getL2WarehouseOption()) {
case A:
+ {
+ dsRecord.put("align", WarehouseSide.values()[dsKey.ordinal()].name().toLowerCase());
+ dsRecord.put("warehouseName", ws.getWarehouse());
+ dsRecord.put("warehouseInfo", ws.getWarehouseType().name());
+ break;
+ }
case B:
- dsRecord.put("align", WarehouseSide.values()[dsKey.ordinal()].name().toLowerCase());
- dsRecord.put("warehouseInfo", ws.getWarehouse() + ws.getWarehouseType().name());
- break;
+ {
+ dsRecord.put("align", WarehouseSide.values()[dsKey.ordinal()].name().toLowerCase());
+ dsRecord.put("warehouseName", ws.getPair());
+ dsRecord.put("warehouseInfo", ws.getWarehouseType().name());
+ break;
+ }
case LEFT:
- dsRecord.put("align", WarehouseSide.LEFT.toString().toLowerCase());
- dsRecord.put("warehouseInfo", ws.getWarehouse() + WarehouseType.values()[dsKey.ordinal()].name());
- break;
+ {
+ dsRecord.put("align", WarehouseSide.LEFT.toString().toLowerCase());
+ String wh = (dsKey == L2DisplaySide.LEFT) ? ws.getWarehouse() : ws.getPair();
+ dsRecord.put("warehouseName", wh);
+ dsRecord.put("warehouseInfo", WarehouseType.values()[dsKey.ordinal()].name());
+ break;
+ }
case RIGHT:
- dsRecord.put("align", WarehouseSide.RIGHT.toString().toLowerCase());
- dsRecord.put("warehouseInfo", ws.getWarehouse() + WarehouseType.values()[dsKey.ordinal()].name());
- break;
+ {
+ dsRecord.put("align", WarehouseSide.RIGHT.toString().toLowerCase());
+ String wh = (dsKey == L2DisplaySide.LEFT) ? ws.getWarehouse() : ws.getPair();
+ dsRecord.put("warehouseName", wh);
+ dsRecord.put("warehouseInfo", WarehouseType.values()[dsKey.ordinal()].name());
+ break;
+ }
default:
}
dsRecord.put("at_hub", L2TimeState.NOW_AT_HUB.getMessage());
@@ -219,14 +236,46 @@
}
/**
+ * Returns the displayed warehouse based on the display side and the warehouse switch.
+ * @param ds the dislay side
+ * @param ws the warehouse switch
+ * @return the displayed warehouse
+ */
+ private static String getDisplayedWarehouse(L2DisplaySide ds, WarehouseSwitch ws)
+ {
+ String res = "";
+
+ switch(ws.getL2WarehouseOption())
+ {
+ case A:
+ {
+ res = ws.getWarehouse();
+ break;
+ }
+ case B:
+ {
+ res = ws.getPair();
+ break;
+ }
+ case LEFT:
+ case RIGHT:
+ {
+ res = (ds == L2DisplaySide.LEFT) ? ws.getWarehouse() : ws.getPair();
+ break;
+ }
+ }
+
+ return res;
+ }
+
+ /**
* Create a display side JSON array.
* @param storageRawList the raw list
* @param storageChartList the storage chart
* @return the JSON array
*/
- private static JSONArray createDisplaySideJSON(
- List<L2StorageRawData> storageRawList,
- List<L2StorageChartData> storageChartList) {
+ private static JSONArray createDisplaySideJSON(String displayedWarehouse, List<L2StorageRawData> storageRawList, List<L2StorageChartData> storageChartList)
+ {
JSONArray result = new JSONArray();
int i = 0;
@@ -234,7 +283,8 @@
JSONObject storageRecord = new JSONObject();
L2StorageRawData storageRaw = storageRawList.get(i);
- String ss = storageRaw.warehouse + "_" + storageRaw.type + "_" + storageRaw.side.name();
+ storageRecord.put("displayedWarehouse", displayedWarehouse);
+ String ss = storageRaw.type + "_" + storageRaw.side.name();
storageRecord.put("warehouseLayout", ss.toLowerCase());
storageRecord.put("id", storageChart.id);
storageRecord.put("overColor", storageChart.bgColor.get(L2TimeState.OVERALL).getColor());
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3Chart.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3Chart.java 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3Chart.java 2013-11-11 17:35:15 UTC (rev 334)
@@ -112,6 +112,7 @@
private static JSONObject createStatusJSON(WarehouseSwitch ws) {
JSONObject result = new JSONObject();
+ result.put("displayedWarehouse", ws.getL3Warehouse());
result.put("jumpStorageId", ws.getL3SelectedStorageId());
JSONArray inner = new JSONArray();
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3DepotStorageData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3DepotStorageData.java 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3DepotStorageData.java 2013-11-11 17:35:15 UTC (rev 334)
@@ -33,7 +33,7 @@
*/
public class L3DepotStorageData {
- /** Name of the warehouse. */
+ /** Name of the layer 3 warehouse. */
public String warehouse;
/** Side of the warehouse. */
public WarehouseSide side;
@@ -67,7 +67,7 @@
* @param warehouseSwitch the warehouse switch
*/
public L3DepotStorageData(WarehouseSwitch warehouseSwitch) {
- this.warehouse = warehouseSwitch.getWarehouse();
+ this.warehouse = warehouseSwitch.getL3Warehouse();
this.side = warehouseSwitch.getL3WarehouseSide();
this.storageCapacityMap = new HashMap<>();
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3WarehouseMode.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3WarehouseMode.java 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3WarehouseMode.java 2013-11-11 17:35:15 UTC (rev 334)
@@ -30,8 +30,8 @@
INIT,
/** Orientation. */
ORIENT,
- /** Option. */
- OPTION,
+ /** Layer 3 option. */
+ L3OPTION,
/** Order. */
ORDER;
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-08 17:43:48 UTC (rev 333)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-11 17:35:15 UTC (rev 334)
@@ -50,10 +50,13 @@
private WarehouseOption l2warehouseOption;
/** The storage area order. */
private StorageAreaOrder storageOrder;
+
/** Level 3 warehouse display mode option. */
private WarehouseOption l3warehouseOption;
/** Level 3 selected storage area ID. */
private long l3SelectedStorageId;
+ /** Level 3 warehouse name. */
+ private String l3warehouse;
/** The hub id. */
private final long hubId;
@@ -79,6 +82,7 @@
this.l3warehouseOption = WarehouseOption.LEFT;
this.l3SelectedStorageId = 0;
+ this.l3warehouse = this.warehouse;
}
/**
@@ -88,7 +92,7 @@
private Map<String, String> createWarehousePairMap()
{
Map<String, String> wPair = new LinkedHashMap<>();
- List<Warehouse> list = MasterDB.warehouses(1);
+ List<Warehouse> list = MasterDB.warehouses(this.hubId);
if(list.isEmpty() == false)
{
@@ -115,6 +119,32 @@
}
/**
+ * Returns the pair of the warehouse.
+ * @return the pair of the warehouse
+ */
+ public String getPair()
+ {
+ String res = "";
+
+ if(warehousePairMap.containsKey(this.warehouse))
+ {
+ res = warehousePairMap.get(this.warehouse);
+ }
+ else if(warehousePairMap.containsValue(this.warehouse))
+ {
+ for(String keyItem : warehousePairMap.keySet())
+ {
+ if(warehousePairMap.get(keyItem).equals(this.warehouse))
+ {
+ res = keyItem;
+ }
+ }
+ }
+
+ return res;
+ }
+
+ /**
* Returns the top member of the first warehouse pair.
* @return the top member of the first warehouse pair
*/
@@ -215,7 +245,17 @@
public void setL3SelectedStorageId(long storageId) {
this.l3SelectedStorageId = storageId;
}
+
/**
+ * Sets the level 3 warehouse.
+ * @param warehouse the level 3 warehouse
+ */
+ public void setL3Warehouse(String warehouse)
+ {
+ this.l3warehouse = warehouse;
+ }
+
+ /**
* @return the warehouse
*/
public String getWarehouse() {
@@ -316,7 +356,17 @@
public long getL3SelectedStorageId() {
return this.l3SelectedStorageId;
}
+
/**
+ * Returns the Level 3 warehouse.
+ * @return the Level 3 warehouse
+ */
+ public String getL3Warehouse()
+ {
+ return this.l3warehouse;
+ }
+
+ /**
* Returns the default floorspace scale.
* @return the default floorspace scale
*/
@@ -358,22 +408,33 @@
for (StorageAreaInfo storageInfoItem : storageInfoList) {
L2StorageRawData storageRaw = new L2StorageRawData();
- storageRaw.warehouse = warehouse;
switch(sOption) {
case A:
+ {
+ storageRaw.warehouse = warehouse;
+ storageRaw.type = getWarehouseType();
+ storageRaw.side = WarehouseSide.values()[displaySide.ordinal()];
+ break;
+ }
case B:
- storageRaw.type = getWarehouseType();
- storageRaw.side = WarehouseSide.values()[displaySide.ordinal()];
- break;
+ {
+ storageRaw.warehouse = wh.pair;
+ storageRaw.type = getWarehouseType();
+ storageRaw.side = WarehouseSide.values()[displaySide.ordinal()];
+ break;
+ }
case LEFT:
- case RIGHT:
- storageRaw.type = WarehouseType.values()[displaySide.ordinal()];
- storageRaw.side = getL2WarehouseSide();
- break;
+ case RIGHT:
+ {
+ storageRaw.warehouse = (displaySide == L2DisplaySide.LEFT) ? warehouse : wh.pair;
+ storageRaw.type = WarehouseType.values()[displaySide.ordinal()];
+ storageRaw.side = getL2WarehouseSide();
+ break;
+ }
default:
}
-
+
storageRaw.id = storageInfoItem.id;
for (WarehouseType st : WarehouseType.values()) {
@@ -402,7 +463,7 @@
Map<String, Map<WarehouseSide, List<StorageAreaInfo>>> warehouseLayoutMap = MasterDB.getWarehouseLayoutMap(hubId);
- List<StorageAreaInfo> storageInfoList = warehouseLayoutMap.get(warehouse).get(getL3WarehouseSide());
+ List<StorageAreaInfo> storageInfoList = warehouseLayoutMap.get(l3warehouse).get(getL3WarehouseSide());
for (StorageAreaInfo storageInfoItem : storageInfoList) {
HubDepotInfo depotInfo = MasterDB.getDepotSummaryValueMaxes(hubId, storageInfoItem.id, user);
if (depotInfo != null) {
@@ -439,10 +500,10 @@
long result = 0;
Map<String, Map<WarehouseSide, List<StorageAreaInfo>>> warehouseLayoutMap = MasterDB.getWarehouseLayoutMap(hubId);
-
+
// If the storageId from the request is real..
if (storageId != 0) {
- List<StorageAreaInfo> prevStorageInfoList = warehouseLayoutMap.get(warehouse).get(prevWarehouseSide);
+ List<StorageAreaInfo> prevStorageInfoList = warehouseLayoutMap.get(l3warehouse).get(prevWarehouseSide);
int ordinal = -1;
// Find the ordinal of this storageId
@@ -454,7 +515,7 @@
// If the storageId is found, get the opposite storageId from the actual side
if (ordinal > -1) {
- List<StorageAreaInfo> actualStorageInfoList = warehouseLayoutMap.get(warehouse).get(getL3WarehouseSide());
+ List<StorageAreaInfo> actualStorageInfoList = warehouseLayoutMap.get(l3warehouse).get(getL3WarehouseSide());
// If the size of this actual side is less than the previous one..
if (actualStorageInfoList.size() < ordinal) {
result = actualStorageInfoList.get(actualStorageInfoList.size() - 1).id;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-08 17:43:50
|
Revision: 333
http://sourceforge.net/p/advance-project/code/333
Author: csirobi
Date: 2013-11-08 17:43:48 +0000 (Fri, 08 Nov 2013)
Log Message:
-----------
Warehouse minor changes
Modified Paths:
--------------
advance-live-reporter-os/WebContent/warehouse-header.jspf
Added Paths:
-----------
advance-live-reporter-os/WebContent/api-warehouse-updown.jsp
Removed Paths:
-------------
advance-live-reporter-os/WebContent/api-updown-wh.jsp
Deleted: advance-live-reporter-os/WebContent/api-updown-wh.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-updown-wh.jsp 2013-11-08 17:37:04 UTC (rev 332)
+++ advance-live-reporter-os/WebContent/api-updown-wh.jsp 2013-11-08 17:43:48 UTC (rev 333)
@@ -1,69 +0,0 @@
-<%@page import="net.sf.json.JSONArray"%>
-<%@page import="hu.akarnokd.utils.lang.*"%>
-<%@page import="java.util.Date"%>
-<%@page import="eu.advance.logistics.live.reporter.charts.WarehouseSwitch"%>
-<%@page import="eu.advance.logistics.live.reporter.charts.HubDepotSwitch"%>
-<%@page import="eu.advance.logistics.live.reporter.charts.ErrorType"%>
-<%@page import="eu.advance.logistics.live.reporter.model.User"%>
-<%@page import="net.sf.json.JSONObject"%>
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
-<%
- response.setContentType("application/json");
- JSONObject result = new JSONObject();
-
- User user = null;
- synchronized(session)
- {
- user = (User) session.getAttribute("USER");
- }
- if(user == null)
- {
- JSONObject errType = new JSONObject();
- errType.put(ErrorType.TIME_OUT.name().toLowerCase(), ErrorType.TIME_OUT.getMessage());
- result.put("error", errType);
- } else
- {
- try
- {
- HubDepotSwitch hubDepotSwitch = new HubDepotSwitch(user.hub, user.name);
- hubDepotSwitch.setDateTime(new Date());
-
- WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
- String whName = ObjectUtils.nvl(request.getParameter("warehouse_name"), warehouseSwitch.getFirstWarehousePairTop());
- warehouseSwitch.setWarehouse(whName);
-
- int i = 0, pos = 0;
- String whTop = warehouseSwitch.getWarehousePairTop();
- JSONArray dataArr = new JSONArray();
- JSONObject o;
- for(String keyItem : warehouseSwitch.getWarehousePairMap().keySet())
- {
- if(keyItem.equals(whTop))
- {
- pos = i;
- }
- i++;
-
- o = new JSONObject();
- o.put("top", keyItem);
- o.put("bottom", warehouseSwitch.getWarehousePairMap().get(keyItem));
- dataArr.add(o);
- }
-
- result.put("size", warehouseSwitch.getWarehousePairMap().size());
- result.put("position", pos);
- result.put("dataList", dataArr);
-
-
- } catch (IllegalArgumentException e)
- {
- JSONObject errType = new JSONObject();
- errType.put(ErrorType.ENUM_CODE_ILLEGAL_FORMAT.name().toLowerCase(), ErrorType.ENUM_CODE_ILLEGAL_FORMAT.getMessage());
- result.put("error", errType);
- }
-
- }
-
- out.print(result.toString());
-%>
\ No newline at end of file
Copied: advance-live-reporter-os/WebContent/api-warehouse-updown.jsp (from rev 332, advance-live-reporter-os/WebContent/api-updown-wh.jsp)
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-updown.jsp (rev 0)
+++ advance-live-reporter-os/WebContent/api-warehouse-updown.jsp 2013-11-08 17:43:48 UTC (rev 333)
@@ -0,0 +1,69 @@
+<%@page import="net.sf.json.JSONArray"%>
+<%@page import="hu.akarnokd.utils.lang.*"%>
+<%@page import="java.util.Date"%>
+<%@page import="eu.advance.logistics.live.reporter.charts.WarehouseSwitch"%>
+<%@page import="eu.advance.logistics.live.reporter.charts.HubDepotSwitch"%>
+<%@page import="eu.advance.logistics.live.reporter.charts.ErrorType"%>
+<%@page import="eu.advance.logistics.live.reporter.model.User"%>
+<%@page import="net.sf.json.JSONObject"%>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<%
+ response.setContentType("application/json");
+ JSONObject result = new JSONObject();
+
+ User user = null;
+ synchronized(session)
+ {
+ user = (User) session.getAttribute("USER");
+ }
+ if(user == null)
+ {
+ JSONObject errType = new JSONObject();
+ errType.put(ErrorType.TIME_OUT.name().toLowerCase(), ErrorType.TIME_OUT.getMessage());
+ result.put("error", errType);
+ } else
+ {
+ try
+ {
+ HubDepotSwitch hubDepotSwitch = new HubDepotSwitch(user.hub, user.name);
+ hubDepotSwitch.setDateTime(new Date());
+
+ WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
+ String whName = ObjectUtils.nvl(request.getParameter("warehouse_name"), warehouseSwitch.getFirstWarehousePairTop());
+ warehouseSwitch.setWarehouse(whName);
+
+ int i = 0, pos = 0;
+ String whTop = warehouseSwitch.getWarehousePairTop();
+ JSONArray dataArr = new JSONArray();
+ JSONObject o;
+ for(String keyItem : warehouseSwitch.getWarehousePairMap().keySet())
+ {
+ if(keyItem.equals(whTop))
+ {
+ pos = i;
+ }
+ i++;
+
+ o = new JSONObject();
+ o.put("top", keyItem);
+ o.put("bottom", warehouseSwitch.getWarehousePairMap().get(keyItem));
+ dataArr.add(o);
+ }
+
+ result.put("size", warehouseSwitch.getWarehousePairMap().size());
+ result.put("position", pos);
+ result.put("dataList", dataArr);
+
+
+ } catch (IllegalArgumentException e)
+ {
+ JSONObject errType = new JSONObject();
+ errType.put(ErrorType.ENUM_CODE_ILLEGAL_FORMAT.name().toLowerCase(), ErrorType.ENUM_CODE_ILLEGAL_FORMAT.getMessage());
+ result.put("error", errType);
+ }
+
+ }
+
+ out.print(result.toString());
+%>
\ No newline at end of file
Modified: advance-live-reporter-os/WebContent/warehouse-header.jspf
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-11-08 17:37:04 UTC (rev 332)
+++ advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-11-08 17:43:48 UTC (rev 333)
@@ -286,7 +286,7 @@
var pos = 0;
$.ajax({
- url : "api-updown-wh.jsp",
+ url : "api-warehouse-updown.jsp",
type : "POST",
data : {
warehouse_name : mySelf.active.warehouse
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-08 17:37:07
|
Revision: 332
http://sourceforge.net/p/advance-project/code/332
Author: csirobi
Date: 2013-11-08 17:37:04 +0000 (Fri, 08 Nov 2013)
Log Message:
-----------
SL1: warehouse up-down selector
SL1, SL3: order of item statuses
Modified Paths:
--------------
advance-live-reporter-os/WebContent/css/warehouse-header.css
advance-live-reporter-os/WebContent/warehouse-header.jspf
advance-live-reporter-os/WebContent/warehouse-l1.jsp
advance-live-reporter-os/WebContent/warehouse-l2.jsp
advance-live-reporter-os/WebContent/warehouse-l3.jsp
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1Chart.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3Chart.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3DepotStorageData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java
Added Paths:
-----------
advance-live-reporter-os/WebContent/api-updown-wh.jsp
advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-down.png
advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-up.png
Added: advance-live-reporter-os/WebContent/api-updown-wh.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-updown-wh.jsp (rev 0)
+++ advance-live-reporter-os/WebContent/api-updown-wh.jsp 2013-11-08 17:37:04 UTC (rev 332)
@@ -0,0 +1,69 @@
+<%@page import="net.sf.json.JSONArray"%>
+<%@page import="hu.akarnokd.utils.lang.*"%>
+<%@page import="java.util.Date"%>
+<%@page import="eu.advance.logistics.live.reporter.charts.WarehouseSwitch"%>
+<%@page import="eu.advance.logistics.live.reporter.charts.HubDepotSwitch"%>
+<%@page import="eu.advance.logistics.live.reporter.charts.ErrorType"%>
+<%@page import="eu.advance.logistics.live.reporter.model.User"%>
+<%@page import="net.sf.json.JSONObject"%>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<%
+ response.setContentType("application/json");
+ JSONObject result = new JSONObject();
+
+ User user = null;
+ synchronized(session)
+ {
+ user = (User) session.getAttribute("USER");
+ }
+ if(user == null)
+ {
+ JSONObject errType = new JSONObject();
+ errType.put(ErrorType.TIME_OUT.name().toLowerCase(), ErrorType.TIME_OUT.getMessage());
+ result.put("error", errType);
+ } else
+ {
+ try
+ {
+ HubDepotSwitch hubDepotSwitch = new HubDepotSwitch(user.hub, user.name);
+ hubDepotSwitch.setDateTime(new Date());
+
+ WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
+ String whName = ObjectUtils.nvl(request.getParameter("warehouse_name"), warehouseSwitch.getFirstWarehousePairTop());
+ warehouseSwitch.setWarehouse(whName);
+
+ int i = 0, pos = 0;
+ String whTop = warehouseSwitch.getWarehousePairTop();
+ JSONArray dataArr = new JSONArray();
+ JSONObject o;
+ for(String keyItem : warehouseSwitch.getWarehousePairMap().keySet())
+ {
+ if(keyItem.equals(whTop))
+ {
+ pos = i;
+ }
+ i++;
+
+ o = new JSONObject();
+ o.put("top", keyItem);
+ o.put("bottom", warehouseSwitch.getWarehousePairMap().get(keyItem));
+ dataArr.add(o);
+ }
+
+ result.put("size", warehouseSwitch.getWarehousePairMap().size());
+ result.put("position", pos);
+ result.put("dataList", dataArr);
+
+
+ } catch (IllegalArgumentException e)
+ {
+ JSONObject errType = new JSONObject();
+ errType.put(ErrorType.ENUM_CODE_ILLEGAL_FORMAT.name().toLowerCase(), ErrorType.ENUM_CODE_ILLEGAL_FORMAT.getMessage());
+ result.put("error", errType);
+ }
+
+ }
+
+ out.print(result.toString());
+%>
\ No newline at end of file
Modified: advance-live-reporter-os/WebContent/css/warehouse-header.css
===================================================================
--- advance-live-reporter-os/WebContent/css/warehouse-header.css 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/WebContent/css/warehouse-header.css 2013-11-08 17:37:04 UTC (rev 332)
@@ -68,7 +68,7 @@
right: 0px;
margin: 0px 12px 0px 0px;
height: 145px;
- width: 481px;
+ width: 540px;
}
div.warehouse-menu div.option-inner {
@@ -79,21 +79,35 @@
height: 100%;
}
+div.warehouse-menu td.updown-up{
+ background: url("../images/warehouse/warehouse-sel-up.png") no-repeat center center;
+}
+
+div.warehouse-menu td.updown-down{
+ background: url("../images/warehouse/warehouse-sel-down.png") no-repeat center center;
+}
+
+div.warehouse-menu .updown-width {
+ margin: 0px auto;
+ width: 40px;
+}
+
div.warehouse-menu .warehouse-width {
- margin: 0px auto;
+ margin: 0px 0px 0px 7px;
width: 160px;
}
div.warehouse-menu .option-width {
- margin: 0px 0px 0px 10px;
+ margin: 0px 0px 0px 7px;
width: 200px;
}
div.warehouse-menu .order-width {
- margin: 0px 0px 0px 10px;
+ margin: 0px 0px 0px 7px;
width: 100px;
}
+div.warehouse-menu .updown-width table,
div.warehouse-menu .warehouse-width table,
div.warehouse-menu .option-width table,
div.warehouse-menu .order-width table {
@@ -103,6 +117,7 @@
height: 100%;
}
+div.warehouse-menu .updown-width tr,
div.warehouse-menu .warehouse-width tr,
div.warehouse-menu .option-width tr {
color: #000000;
@@ -118,8 +133,10 @@
height: 33%%;
}
+div.warehouse-menu .updown-width td,
div.warehouse-menu .warehouse-width td,
-div.warehouse-menu .option-width td {
+div.warehouse-menu .option-width td,
+div.warehouse-menu .order-width td {
border: 1px solid #388C00;
font-size: 20px;
font-weight: bold;
@@ -129,16 +146,6 @@
vertical-align: middle;
}
-div.warehouse-menu .order-width td {
- border: 1px solid #388C00;
- font-size: 32px;
- font-weight: bold;
- padding: 0px;
- margin: 0px;
- text-align:center;
- vertical-align: middle;
-}
-
div.warehouse-menu td.inactive {
background-color: #FFFFFF;
color : #388C00;
Added: advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-down.png
===================================================================
(Binary files differ)
Index: advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-down.png
===================================================================
--- advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-down.png 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-down.png 2013-11-08 17:37:04 UTC (rev 332)
Property changes on: advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-down.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-up.png
===================================================================
(Binary files differ)
Index: advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-up.png
===================================================================
--- advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-up.png 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-up.png 2013-11-08 17:37:04 UTC (rev 332)
Property changes on: advance-live-reporter-os/WebContent/images/warehouse/warehouse-sel-up.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: advance-live-reporter-os/WebContent/warehouse-header.jspf
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-11-08 17:37:04 UTC (rev 332)
@@ -33,7 +33,6 @@
String whOption = ObjectUtils.nvl(request.getParameter("warehouse_option"), "A");
String stOrder = ObjectUtils.nvl(request.getParameter("storage_order"), "PHYSICAL");
String whL3Option = ObjectUtils.nvl(request.getParameter("warehouse_l3_option"), "LEFT");
-
String whL3StId = ObjectUtils.nvl(request.getParameter("warehouse_l3_storage_id"), "0");
warehouseSwitch.setWarehouse(whName);
@@ -41,17 +40,6 @@
warehouseSwitch.setStorageAreaOrder(stOrder);
warehouseSwitch.setL3WarehouseOption(whL3Option);
warehouseSwitch.setL3SelectedStorageId(Long.parseLong(whL3StId));
-
-
- /*
- warehouseSwitch.setL2WarehouseOption(request.getParameter("warehouse_option"));
- warehouseSwitch.setStorageAreaOrder(request.getParameter("storage_order"));
- warehouseSwitch.setL3WarehouseOption(request.getParameter("warehouse_l3_option"));
- if (request.getParameter("warehouse_l3_storage_id") != null) {
- warehouseSwitch.setL3SelectedStorageId(Long.parseLong(request.getParameter("warehouse_l3_storage_id")));
- }
- */
-
}
catch(IllegalArgumentException e)
{
@@ -90,6 +78,16 @@
<div id="hand_option"></div>
<div id="hand_order"></div>
+ <div id="updown_warehouse" class="option-inner updown-width">
+ <table>
+ <tr>
+ <td id="updown_up" class="inactive updown-up"></td>
+ </tr>
+ <tr>
+ <td id="updown_down" class="inactive updown-down"></td>
+ </tr>
+ </table>
+ </div>
<div id="selector_warehouse" class="option-inner warehouse-width">
<table>
<tr>
@@ -176,6 +174,7 @@
mySelf.setUpDown("warehouse-down", "warehouse-l2.jsp");
mySelf.setWarehouseMenu();
+ mySelf.upDownWarehouseHandler();
mySelf.buttonWarehouseHandler();
$("#selector_option").hide();
@@ -268,9 +267,8 @@
{
var mySelf = this;
var active = mySelf.active;
- var ss = 'td[id^="warehouse_"]';
- $(ss).toggleClass(mySelf.actClass, false);
+ $('td[id^="warehouse_"]').toggleClass(mySelf.actClass, false);
if($('td[id="warehouse_top"]').text() == active.warehouse)
{
$('td[id="warehouse_top"]').toggleClass(mySelf.actClass);
@@ -281,6 +279,74 @@
}
},
+ // Get the warehouse pair and set the click handler
+ upDownWarehouseHandler : function()
+ {
+ var mySelf = this;
+ var pos = 0;
+
+ $.ajax({
+ url : "api-updown-wh.jsp",
+ type : "POST",
+ data : {
+ warehouse_name : mySelf.active.warehouse
+ },
+ dataType : "json",
+ success : function(result)
+ {
+ if ((result.size !== undefined) &&
+ (result.position !== undefined) &&
+ (result.dataList !== undefined))
+ {
+ pos = result.position * 1.0;
+
+ $("td#updown_up").on("click", function(event)
+ {
+ pos = ( pos == 0) ? result.size - 1 : pos - 1;
+ mySelf.upDownSetWarehouse(pos, result);
+ });
+
+ $("td#updown_down").on("click", function(event)
+ {
+ pos = ( pos == result.size - 1) ? 0 : pos + 1;
+ mySelf.upDownSetWarehouse(pos, result);
+ });
+
+ } else if (result.error !== undefined)
+ {
+ var v = "";
+ $.each(result.error, function(key, value){ v = value; });
+ $("div.error-msgbox p#error_msg").html(v);
+ $("body").addClass("show-error");
+ }
+ }
+ });
+
+ },
+
+ // Set the active warehouse based on up-down button
+ upDownSetWarehouse : function(pos, result)
+ {
+ var mySelf = this;
+
+ $("td#warehouse_top").text(result.dataList[pos].top);
+ $("td#warehouse_bottom").text(result.dataList[pos].bottom);
+
+ if( $('td[id^="warehouse_"].active').text() === "")
+ {
+ $('td[id^="warehouse_"]').toggleClass(mySelf.actClass, false);
+ $("td#warehouse_top").toggleClass(mySelf.actClass);
+ }
+
+ var actValue = $('td[id^="warehouse_"].active').text();
+ $("#hand_warehouse").triggerHandler(
+ {
+ type : "click.warehouse",
+ active : actValue,
+ });
+
+ },
+
// Warehouse button group handler
buttonWarehouseHandler : function()
{
@@ -291,7 +357,8 @@
{
var isChanged = true;
- if ($("#" + event.target.id).hasClass(mySelf.actClass) == false)
+ if (($("#" + event.target.id).hasClass(mySelf.actClass) == false) &&
+ ($("#" + event.target.id).text() !== ""))
{
$(ss).toggleClass(mySelf.actClass, false);
$("#" + event.target.id).toggleClass(mySelf.actClass);
@@ -302,11 +369,10 @@
if (isChanged)
{
- var t = "click.warehouse";
var actValue = $('td[id="' + event.target.id + '"]').text();
$("#hand_warehouse").triggerHandler({
- type : t,
+ type : "click.warehouse",
active : actValue,
});
}
@@ -422,46 +488,6 @@
}
return active;
- },
-
- // Error message dialog box
- showErrorMessage : function(param)
- {
- var defaultMsg = "There seems to be a problem with the server.<br/>Please try again later.";
- $("div.warehouse-menu div#dialog_general").dialog(
- {
- autoOpen: true,
- modal: true,
- width: 300,
- height: 200,
- resizable: false,
-
- open : function(event, ui)
- {
- if(param !== undefined)
- {
- $("div#dialog_general p#general_message").html("");
- $("div#dialog_general p#general_message").html(param);
- }
- else
- {
- $("div#dialog_general p#general_message").html("");
- $("div#dialog_general p#general_message").html(defaultMsg);
- }
- },
- buttons:
- {
- Ok: function()
- {
- $( this ).dialog( "close" );
- }
- },
- close : function()
- {
- $(location).attr("href", "logout.jsp");
- }
- });
-
}
};
Modified: advance-live-reporter-os/WebContent/warehouse-l1.jsp
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-l1.jsp 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/WebContent/warehouse-l1.jsp 2013-11-08 17:37:04 UTC (rev 332)
@@ -14,7 +14,6 @@
<script src="js/lib/jquery-1.8.1.js" type="text/javascript"></script>
-<script src="js/lib/jquery-ui-1.10.3.js" type="text/javascript"></script>
<script src="js/charts/warehouse-l1-chart.js" type="text/javascript"></script>
<script src="js/pages/warehouse-l1-page.js" type="text/javascript"></script>
Modified: advance-live-reporter-os/WebContent/warehouse-l2.jsp
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-l2.jsp 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/WebContent/warehouse-l2.jsp 2013-11-08 17:37:04 UTC (rev 332)
@@ -14,7 +14,6 @@
<script src="js/lib/jquery-1.8.1.js" type="text/javascript"></script>
-<script src="js/lib/jquery-ui-1.10.3.js" type="text/javascript"></script>
<script src="js/charts/warehouse-l2-chart.js" type="text/javascript"></script>
<script src="js/pages/warehouse-l2-page.js" type="text/javascript"></script>
Modified: advance-live-reporter-os/WebContent/warehouse-l3.jsp
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-l3.jsp 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/WebContent/warehouse-l3.jsp 2013-11-08 17:37:04 UTC (rev 332)
@@ -14,7 +14,6 @@
<script src="js/lib/jquery-1.8.1.js" type="text/javascript"></script>
-<script src="js/lib/jquery-ui-1.10.3.js" type="text/javascript"></script>
<script src="js/charts/warehouse-l3-chart.js" type="text/javascript"></script>
<script src="js/pages/warehouse-l3-page.js" type="text/javascript"></script>
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1Chart.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1Chart.java 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1Chart.java 2013-11-08 17:37:04 UTC (rev 332)
@@ -69,13 +69,11 @@
JSONObject result = new JSONObject();
JSONArray inner = new JSONArray();
- int ordinal = 0;
- for (ItemStatus keyItem : L1OverallData.getDisplayItems()) {
- JSONObject statusRecord = new JSONObject();
+ for (ItemStatus keyItem : L1OverallData.DISPLAY_ITEMS) {
+ JSONObject statusRecord = new JSONObject();
statusRecord.put("info", keyItem.getInfo());
statusRecord.put("message", keyItem.getMessage());
- inner.add(ordinal, statusRecord);
- ordinal++;
+ inner.add(statusRecord);
}
result.put("overall", inner);
@@ -84,7 +82,7 @@
JSONObject statusRecord = new JSONObject();
statusRecord.put("info", keyItem.name().toLowerCase());
statusRecord.put("message", keyItem.getMessage());
- inner.add(keyItem.ordinal(), statusRecord);
+ inner.add(statusRecord);
}
result.put("athub", inner);
@@ -138,7 +136,7 @@
// Generate for Overall
innerArr = new JSONArray();
- for (ItemStatus pKey: L1OverallData.getDisplayItems()) {
+ for (ItemStatus pKey: L1OverallData.DISPLAY_ITEMS) {
itemRec = new JSONObject();
itemRec.put("info", pKey.getInfo());
itemRec.put("value", overData.items.get(sKey).get(pKey).value.toPlainString());
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java 2013-11-08 17:37:04 UTC (rev 332)
@@ -20,7 +20,6 @@
*/
package eu.advance.logistics.live.reporter.charts;
-import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -37,6 +36,16 @@
public int busAsUsSc;
/** HashMap for items. */
public final Map<WarehouseServiceLevel, Map<ItemStatus, BarData>> items;
+ /**item statuses which are displayed in the UI.*/
+ public static final ItemStatus[] DISPLAY_ITEMS = {
+ ItemStatus.LEFT_HUB_TODAY,
+ ItemStatus.AT_HUB,
+ ItemStatus.DECLARED,
+ ItemStatus.SCANNED,
+ ItemStatus.CREATED
+ };
+
+
/**
* Constructor, initializes the fields.
* @param warehouseSwitch the warehouse switch
@@ -48,20 +57,6 @@
}
/**
- * Get that item statuses which are displayed in the UI.
- * @return EnumSet of the used item statuses
- */
- public static EnumSet<ItemStatus> getDisplayItems() {
- EnumSet<ItemStatus> result = EnumSet.of(ItemStatus.LEFT_HUB_TODAY,
- ItemStatus.AT_HUB,
- ItemStatus.DECLARED,
- ItemStatus.SCANNED,
- ItemStatus.CREATED);
-
- return result;
- }
-
- /**
* Normalize value of items based on total coordinate.
* @param coord the coordinates
*/
@@ -84,7 +79,7 @@
public void checkBaus() {
GraphDecimal value = new GraphDecimal(0);
- for (ItemStatus pKey : L1OverallData.getDisplayItems()) {
+ for (ItemStatus pKey : L1OverallData.DISPLAY_ITEMS) {
value = value.add(new GraphDecimal(this.items.get(WarehouseServiceLevel.ALL).get(pKey).value));
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3Chart.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3Chart.java 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3Chart.java 2013-11-08 17:37:04 UTC (rev 332)
@@ -115,7 +115,7 @@
result.put("jumpStorageId", ws.getL3SelectedStorageId());
JSONArray inner = new JSONArray();
- for (ItemStatus keyItem : L3DepotStorageData.displayedPStatus()) {
+ for (ItemStatus keyItem : L3DepotStorageData.DISPLAY_FUTURE_STATUS) {
JSONObject statusRecord = new JSONObject();
statusRecord.put("info", keyItem.getInfo());
statusRecord.put("message", keyItem.getMessage());
@@ -179,7 +179,7 @@
// Generate for Future
innerArr = new JSONArray();
- for (ItemStatus pKey: L3DepotStorageData.displayedPStatus()) {
+ for (ItemStatus pKey: L3DepotStorageData.DISPLAY_FUTURE_STATUS) {
itemRec = new JSONObject();
itemRec.put("info", pKey.getInfo());
itemRec.put("value", data.futureItems.get(sKey).get(pKey).value.toPlainString());
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3DepotStorageData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3DepotStorageData.java 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L3DepotStorageData.java 2013-11-08 17:37:04 UTC (rev 332)
@@ -54,6 +54,14 @@
public final Map<WarehouseServiceLevel, Map<ItemStatus, BarData>> futureItems;
/** HashMap for at hub items separate to A and B warehouse. */
public final Map<WarehouseServiceLevel, Map<WarehouseType, BarData>> atHubItems;
+
+ /**Future item statuses which are displayed.*/
+ public static final ItemStatus[] DISPLAY_FUTURE_STATUS = {
+ ItemStatus.DECLARED,
+ ItemStatus.SCANNED,
+ ItemStatus.CREATED
+ };
+
/**
* Constructor.
* @param warehouseSwitch the warehouse switch
@@ -69,31 +77,6 @@
}
/**
- * Get that future item statuses which are used in this class.
- * @return EnumSet of the used item statuses
- */
- public static EnumSet<ItemStatus> getFuturePStatus() {
- EnumSet<ItemStatus> result = EnumSet.of(ItemStatus.DECLARED,
- ItemStatus.SCANNED,
- ItemStatus.CREATED,
- ItemStatus.PREDICTED);
-
- return result;
- }
-
- /**
- * Get that future item statuses which are displayed by change request.
- * @return EnumSet of the used item statuses
- */
- public static EnumSet<ItemStatus> displayedPStatus() {
- EnumSet<ItemStatus> result = EnumSet.of(ItemStatus.DECLARED,
- ItemStatus.SCANNED,
- ItemStatus.CREATED);
-
- return result;
- }
-
- /**
* Returns the combined capacity of storage (A + B).
* @return the capacity value
*/
@@ -128,7 +111,7 @@
for (WarehouseServiceLevel sKey : WarehouseServiceLevel.values()) {
// For future items: count the warehouse type + warehouse service level specific capacity.
capacity = new GraphDecimal(this.getStorageCapacity(EnumSet.of(WarehouseType.A, WarehouseType.B), sKey));
- for (ItemStatus pKey : L3DepotStorageData.displayedPStatus()) {
+ for (ItemStatus pKey : L3DepotStorageData.DISPLAY_FUTURE_STATUS) {
this.futureItems.get(sKey).get(pKey).normalizeWarehouseL3(capacity, coord.normalScale);
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-08 17:37:04 UTC (rev 332)
@@ -28,6 +28,8 @@
import java.util.List;
import java.util.Map;
+import com.google.common.base.Strings;
+
import eu.advance.logistics.live.reporter.db.MasterDB;
import eu.advance.logistics.live.reporter.model.HubDepotInfo;
import eu.advance.logistics.live.reporter.model.UOM;
@@ -69,7 +71,7 @@
public WarehouseSwitch(long hubId, String user) {
this.hubId = hubId;
this.user = user;
- this.warehousePairMap = this.getWarehousePairMap();
+ this.warehousePairMap = this.createWarehousePairMap();
this.warehouse = this.getFirstWarehousePairTop();
this.l2warehouseOption = WarehouseOption.A;
@@ -79,7 +81,11 @@
this.l3SelectedStorageId = 0;
}
- private Map<String, String> getWarehousePairMap()
+ /**
+ * Creates map for the warehouse pairs.
+ * @return map of the warehouse pairs
+ */
+ private Map<String, String> createWarehousePairMap()
{
Map<String, String> wPair = new LinkedHashMap<>();
List<Warehouse> list = MasterDB.warehouses(1);
@@ -90,7 +96,8 @@
{
if( (wPair.containsKey(item.warehouse) == false) && (wPair.containsValue(item.warehouse) == false))
{
- wPair.put(item.warehouse, item.pair);
+ String pair = Strings.isNullOrEmpty(item.pair) ? "" : item.pair;
+ wPair.put(item.warehouse, pair);
}
}
}
@@ -98,11 +105,28 @@
return wPair;
}
+ /**
+ * Returns the map of the warehouse pairs.
+ * @return the map of the warehouse pairs
+ */
+ public Map<String, String> getWarehousePairMap()
+ {
+ return this.warehousePairMap;
+ }
+
+ /**
+ * Returns the top member of the first warehouse pair.
+ * @return the top member of the first warehouse pair
+ */
public String getFirstWarehousePairTop()
{
return this.warehousePairMap.keySet().iterator().next();
}
+ /**
+ * Returns the top member of the actual warehouse pair.
+ * @return the top member of the actual warehouse pair
+ */
public String getWarehousePairTop()
{
String res = "";
@@ -125,6 +149,10 @@
return res;
}
+ /**
+ * Returns the bottom member of the actual warehouse pair.
+ * @return the bottom member of the actual warehouse pair
+ */
public String getWarehousePairBottom()
{
String res = "";
@@ -149,6 +177,10 @@
return hubId;
}
+ /**
+ * Sets the actual warehosue.
+ * @param warehouse the actual warehosue
+ */
public void setWarehouse(String warehouse)
{
this.warehouse = warehouse;
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java 2013-11-07 20:00:42 UTC (rev 331)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java 2013-11-08 17:37:04 UTC (rev 332)
@@ -486,10 +486,6 @@
for (WarehouseType stype : WarehouseType.values()) {
Map<WarehouseSide, Double> sd = new LinkedHashMap<>();
String key = snKey.toString() + stype.toString();
-
- // FIXME somehow!
- System.out.println("X3 " + key);
-
result.put(key, sd);
for (WarehouseSide ssKey : WarehouseSide.values()) {
double count = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-11-07 20:00:44
|
Revision: 331
http://sourceforge.net/p/advance-project/code/331
Author: akarnokd
Date: 2013-11-07 20:00:42 +0000 (Thu, 07 Nov 2013)
Log Message:
-----------
Updated tool library.
Modified Paths:
--------------
Advance-API/lib/akarnokd_tools.jar
Modified: Advance-API/lib/akarnokd_tools.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-11-07 20:00:20
|
Revision: 330
http://sourceforge.net/p/advance-project/code/330
Author: akarnokd
Date: 2013-11-07 20:00:16 +0000 (Thu, 07 Nov 2013)
Log Message:
-----------
Updated tool library.
Modified Paths:
--------------
advance/lib/akarnokd_tools.jar
advance/src/eu/advance/logistics/flow/engine/AdvanceBlock.java
advance/src/eu/advance/logistics/flow/engine/AdvanceEngineConfig.java
advance/src/eu/advance/logistics/flow/engine/AdvancePoolCreator.java
advance/src/eu/advance/logistics/flow/engine/AdvancePools.java
advance/src/eu/advance/logistics/flow/engine/JDBCDataStore.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCDelete.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCDeleteAll.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCInsert.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCInsertAll.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQuery.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQueryAll.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQueryOption.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCThrottledBatchQuery.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCThrottledQuery.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCUpdate.java
advance/src/eu/advance/logistics/flow/engine/block/db/JDBCUpdateAll.java
advance/src/eu/advance/logistics/flow/engine/block/file/ConsignmentMMSource.java
advance/src/eu/advance/logistics/flow/engine/block/file/LocalDirList.java
advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoad.java
advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoadAll.java
advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoadXML.java
advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileMove.java
advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileMoveAll.java
advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileSave.java
advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileSaveAll.java
advance/src/eu/advance/logistics/flow/engine/block/prediction/ConsignmentGet.java
advance/src/eu/advance/logistics/flow/engine/block/prediction/DuringDayModelReader.java
advance/src/eu/advance/logistics/flow/engine/block/prediction/DuringDayModelWriter.java
advance/src/eu/advance/logistics/flow/engine/block/prediction/SelectedAttributesProviderImpl.java
advance/src/eu/advance/logistics/flow/engine/cc/CCValueDialog.java
advance/src/eu/advance/logistics/flow/engine/comm/ChangeNotification.java
advance/src/eu/advance/logistics/flow/engine/comm/EmailPoolManager.java
advance/src/eu/advance/logistics/flow/engine/comm/FTPPoolManager.java
advance/src/eu/advance/logistics/flow/engine/comm/JDBCPoolManager.java
advance/src/eu/advance/logistics/flow/engine/comm/JMSPoolManager.java
advance/src/eu/advance/logistics/flow/engine/comm/LocalPoolManager.java
advance/src/eu/advance/logistics/flow/engine/comm/SOAPPoolManager.java
advance/src/eu/advance/logistics/flow/engine/comm/WebPoolManager.java
advance/src/eu/advance/logistics/flow/engine/test/JDBCDataStoreTest.java
Removed Paths:
-------------
advance/src/eu/advance/logistics/flow/engine/api/BoundedPool.java
advance/src/eu/advance/logistics/flow/engine/api/Pool.java
advance/src/eu/advance/logistics/flow/engine/api/PoolManager.java
advance/src/eu/advance/logistics/flow/engine/api/UnlimitedPool.java
Modified: advance/lib/akarnokd_tools.jar
===================================================================
(Binary files differ)
Modified: advance/src/eu/advance/logistics/flow/engine/AdvanceBlock.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/AdvanceBlock.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/AdvanceBlock.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,10 +21,10 @@
package eu.advance.logistics.flow.engine;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.model.fd.AdvanceType;
import eu.advance.logistics.flow.engine.runtime.Block;
Modified: advance/src/eu/advance/logistics/flow/engine/AdvanceEngineConfig.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/AdvanceEngineConfig.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/AdvanceEngineConfig.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -25,6 +25,7 @@
import hu.akarnokd.reactive4java.scheduler.DefaultScheduler;
import hu.akarnokd.reactive4java.util.Closeables;
import hu.akarnokd.utils.crypto.KeystoreManager;
+import hu.akarnokd.utils.pool.BoundedPool;
import hu.akarnokd.utils.xml.XNElement;
import java.io.Closeable;
@@ -50,7 +51,6 @@
import com.google.common.collect.Maps;
import edu.umd.cs.findbugs.annotations.NonNull;
-import eu.advance.logistics.flow.engine.api.BoundedPool;
import eu.advance.logistics.flow.engine.api.ds.AdvanceCreateModifyInfo;
import eu.advance.logistics.flow.engine.api.ds.AdvanceDataStore;
import eu.advance.logistics.flow.engine.api.ds.AdvanceJDBCDataSource;
Modified: advance/src/eu/advance/logistics/flow/engine/AdvancePoolCreator.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/AdvancePoolCreator.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/AdvancePoolCreator.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,13 +21,14 @@
package eu.advance.logistics.flow.engine;
+import hu.akarnokd.reactive4java.base.Func2;
+import hu.akarnokd.reactive4java.base.Option;
+import hu.akarnokd.utils.pool.BoundedPool;
+import hu.akarnokd.utils.pool.Pool;
+import hu.akarnokd.utils.pool.UnlimitedPool;
+
import java.io.File;
-import hu.akarnokd.reactive4java.base.Func2;
-import hu.akarnokd.reactive4java.base.Option;
-import eu.advance.logistics.flow.engine.api.BoundedPool;
-import eu.advance.logistics.flow.engine.api.Pool;
-import eu.advance.logistics.flow.engine.api.UnlimitedPool;
import eu.advance.logistics.flow.engine.api.ds.AdvanceDataStore;
import eu.advance.logistics.flow.engine.api.ds.AdvanceEmailBox;
import eu.advance.logistics.flow.engine.api.ds.AdvanceFTPDataSource;
Modified: advance/src/eu/advance/logistics/flow/engine/AdvancePools.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/AdvancePools.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/AdvancePools.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,20 +22,18 @@
package eu.advance.logistics.flow.engine;
import hu.akarnokd.reactive4java.base.Func2;
+import hu.akarnokd.reactive4java.base.MultiIOException;
import hu.akarnokd.reactive4java.base.Option;
+import hu.akarnokd.utils.pool.Pool;
import java.io.Closeable;
import java.io.IOException;
-import java.util.List;
import java.util.Map;
-import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
-import eu.advance.logistics.flow.engine.api.Pool;
-import eu.advance.logistics.flow.engine.api.core.MultiIOException;
/**
* A common pool for various communication pools.
@@ -93,21 +91,21 @@
}
@Override
public void close() throws IOException {
- List<IOException> exc = Lists.newArrayList();
+ MultiIOException exc = null;
synchronized (pools) {
for (Map<String, Pool<?>> e : pools.values()) {
for (Pool<?> p : e.values()) {
try {
p.close();
} catch (IOException ex) {
- exc.add(ex);
+ exc = MultiIOException.createOrAdd(exc, ex);
}
}
}
pools.clear();
}
- if (!exc.isEmpty()) {
- throw new MultiIOException(exc);
+ if (exc != null) {
+ throw exc;
}
}
}
Modified: advance/src/eu/advance/logistics/flow/engine/JDBCDataStore.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/JDBCDataStore.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/JDBCDataStore.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -27,6 +27,7 @@
import hu.akarnokd.utils.database.SQLInvoke;
import hu.akarnokd.utils.database.SQLResult;
import hu.akarnokd.utils.mix.XNUtils;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.sequence.SequenceUtils;
import hu.akarnokd.utils.xml.XNElement;
@@ -47,7 +48,6 @@
import com.google.common.collect.Sets;
import edu.umd.cs.findbugs.annotations.NonNull;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.api.core.AdvanceControlException;
import eu.advance.logistics.flow.engine.api.ds.AdvanceDataStore;
import eu.advance.logistics.flow.engine.api.ds.AdvanceDataStoreUpdate;
Deleted: advance/src/eu/advance/logistics/flow/engine/api/BoundedPool.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/api/BoundedPool.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/api/BoundedPool.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -1,116 +0,0 @@
-/*
- * Copyright 2010-2013 The Advance EU 7th Framework project consortium
- *
- * This file is part of Advance.
- *
- * Advance is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Advance is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Advance. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-package eu.advance.logistics.flow.engine.api;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import javax.annotation.concurrent.GuardedBy;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
-import eu.advance.logistics.flow.engine.api.core.MultiIOException;
-
-
-/**
- * A bounded object pool.
- * @author akarnokd, 2011.10.06.
- * @param <T> the pooled object type
- */
-public class BoundedPool<T> implements Pool<T> {
- /** The available pool of objects. */
- protected final BlockingQueue<T> objects;
- /** The storage of all created objects. */
- @GuardedBy("allObjects")
- protected final Set<T> allObjects = Sets.newHashSet();
- /** The target pool size. */
- protected final int poolSize;
- /** The manager of the pool objects. */
- protected final PoolManager<T> manager;
- /**
- * Creates a pool with the given size.
- * @param poolSize the pool size
- * @param manager the pool manager
- */
- public BoundedPool(int poolSize,
- PoolManager<T> manager) {
- this.poolSize = poolSize;
- this.manager = manager;
-
- objects = new LinkedBlockingQueue<T>(poolSize);
- }
- @Override
- public T get() throws Exception {
- synchronized (allObjects) {
- if (allObjects.size() < poolSize) {
- T obj = manager.create();
- allObjects.add(obj);
- return obj;
- }
- }
- T obj = objects.take();
- if (manager.verify(obj)) {
- return obj;
- }
- // create a new one instead
- synchronized (allObjects) {
- allObjects.remove(obj);
- obj = manager.create();
- allObjects.add(obj);
- return obj;
- }
- }
- /**
- * Return a pool object.
- * @param obj the object to return
- */
- @Override
- public void put(T obj) {
- synchronized (allObjects) {
- if (!allObjects.contains(obj)) {
- throw new IllegalArgumentException("obj is not managed by this pool");
- }
- }
- objects.add(obj);
- }
- @Override
- public void close() throws IOException {
- List<Exception> exc = Lists.newArrayList();
- synchronized (allObjects) {
- for (T obj : allObjects) {
- try {
- manager.close(obj);
- } catch (Exception ex) {
- exc.add(ex);
- }
- }
- allObjects.clear();
- }
- if (exc.size() > 0) {
- throw new MultiIOException(exc);
- }
- }
-}
Deleted: advance/src/eu/advance/logistics/flow/engine/api/Pool.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/api/Pool.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/api/Pool.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -1,47 +0,0 @@
-/*
- * Copyright 2010-2013 The Advance EU 7th Framework project consortium
- *
- * This file is part of Advance.
- *
- * Advance is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Advance is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Advance. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-package eu.advance.logistics.flow.engine.api;
-
-import java.io.Closeable;
-
-import edu.umd.cs.findbugs.annotations.NonNull;
-
-
-/**
- * Represents a generic pooling object which supplies and takes back objects.
- * @author akarnokd, 2011.10.05.
- * @param <T> the pooled object type
- */
-public interface Pool<T> extends Closeable {
- /**
- * Retrieve an object from the pool.
- * @return the object retrieved
- * @throws Exception if the object could not be supplied
- */
- @NonNull
- T get() throws Exception;
- /**
- * Return an object to the pool.
- * @param obj the object to return
- */
- void put(@NonNull T obj);
-}
Deleted: advance/src/eu/advance/logistics/flow/engine/api/PoolManager.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/api/PoolManager.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/api/PoolManager.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -1,52 +0,0 @@
-/*
- * Copyright 2010-2013 The Advance EU 7th Framework project consortium
- *
- * This file is part of Advance.
- *
- * Advance is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Advance is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Advance. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-package eu.advance.logistics.flow.engine.api;
-
-import edu.umd.cs.findbugs.annotations.NonNull;
-
-/**
- * The pool manager interface for creating, verifying and closing objects.
- * @author akarnokd, 2011-10-05
- * @param <T> the object type
- */
-public interface PoolManager<T> {
- /**
- * Creates a new object of type T.
- * @return the object
- * @throws Exception if the object could not be created
- */
- @NonNull
- T create() throws Exception;
- /**
- * Verify the validity of the given object.
- * @param obj the object to verify
- * @return true if the object is valid
- * @throws Exception if the verification failure indicates a permanent error
- */
- boolean verify(T obj) throws Exception;
- /**
- * Close the specified object.
- * @param obj the object to close
- * @throws Exception to aggregate exceptions
- */
- void close(T obj) throws Exception;
-}
\ No newline at end of file
Deleted: advance/src/eu/advance/logistics/flow/engine/api/UnlimitedPool.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/api/UnlimitedPool.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/api/UnlimitedPool.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -1,66 +0,0 @@
-/*
- * Copyright 2010-2013 The Advance EU 7th Framework project consortium
- *
- * This file is part of Advance.
- *
- * Advance is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Advance is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Advance. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-package eu.advance.logistics.flow.engine.api;
-
-import java.io.IOException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A pool manager which may return an unlimited amount of objects.
- * <p>The pool doesn't keep track of the returned objects.</p>
- * @author akarnokd, 2011.10.06.
- * @param <T> the pooled object type
- */
-public class UnlimitedPool<T> implements Pool<T> {
- /** The logger. */
- protected static final Logger LOG = LoggerFactory.getLogger(UnlimitedPool.class);
- /** The pool manager object. */
- protected final PoolManager<T> manager;
- /**
- * Constructor. Initializes the pool manager.
- * @param manager the pool manager
- */
- public UnlimitedPool(PoolManager<T> manager) {
- this.manager = manager;
- }
- @Override
- public void close() throws IOException {
- // NO op
- }
-
- @Override
- public T get() throws Exception {
- return manager.create();
- }
-
- @Override
- public void put(T obj) {
- try {
- manager.close(obj);
- } catch (Exception ex) {
- LOG.error(ex.toString(), ex);
- }
- }
-
-}
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCDelete.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCDelete.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCDelete.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,6 +21,7 @@
package eu.advance.logistics.flow.engine.block.db;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -32,7 +33,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCDeleteAll.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCDeleteAll.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCDeleteAll.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,6 +21,7 @@
package eu.advance.logistics.flow.engine.block.db;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -33,7 +34,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCInsert.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCInsert.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCInsert.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,6 +21,7 @@
package eu.advance.logistics.flow.engine.block.db;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -34,7 +35,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCInsertAll.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCInsertAll.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCInsertAll.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -20,6 +20,7 @@
*/
package eu.advance.logistics.flow.engine.block.db;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -36,7 +37,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQuery.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQuery.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQuery.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -24,6 +24,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -35,7 +36,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQueryAll.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQueryAll.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQueryAll.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -24,6 +24,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -38,7 +39,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQueryOption.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQueryOption.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCQueryOption.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -23,6 +23,7 @@
import hu.akarnokd.reactive4java.base.Action1;
import hu.akarnokd.reactive4java.base.Observer;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -36,7 +37,6 @@
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
import eu.advance.logistics.flow.engine.AdvanceData;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCThrottledBatchQuery.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCThrottledBatchQuery.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCThrottledBatchQuery.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -24,6 +24,7 @@
import hu.akarnokd.reactive4java.base.Action1;
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.scheduler.SingleLaneExecutor;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -39,7 +40,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
import eu.advance.logistics.flow.engine.runtime.ConstantPort;
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCThrottledQuery.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCThrottledQuery.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCThrottledQuery.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -24,6 +24,7 @@
import hu.akarnokd.reactive4java.base.Action1;
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.scheduler.SingleLaneExecutor;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -36,7 +37,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
import eu.advance.logistics.flow.engine.runtime.ConstantPort;
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCUpdate.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCUpdate.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCUpdate.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -20,6 +20,7 @@
*/
package eu.advance.logistics.flow.engine.block.db;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -32,7 +33,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/db/JDBCUpdateAll.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/db/JDBCUpdateAll.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/db/JDBCUpdateAll.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,6 +21,7 @@
package eu.advance.logistics.flow.engine.block.db;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -33,7 +34,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/file/ConsignmentMMSource.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/file/ConsignmentMMSource.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/file/ConsignmentMMSource.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -23,6 +23,7 @@
import hu.akarnokd.reactive4java.base.Action1;
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.util.Closeables;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.io.File;
@@ -44,7 +45,6 @@
import eu.advance.logistics.flow.engine.AdvanceBlock;
import eu.advance.logistics.flow.engine.AdvanceData;
import eu.advance.logistics.flow.engine.AdvanceRuntimeContext;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
import eu.advance.logistics.flow.engine.runtime.BlockSettings;
import eu.advance.logistics.flow.engine.runtime.ConstantPort;
Modified: advance/src/eu/advance/logistics/flow/engine/block/file/LocalDirList.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/file/LocalDirList.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/file/LocalDirList.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -23,6 +23,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.util.List;
@@ -33,7 +34,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.FileInfo;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
Modified: advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoad.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoad.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoad.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,6 +22,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.nio.charset.Charset;
@@ -32,7 +33,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoadAll.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoadAll.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoadAll.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,6 +22,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.util.Collections;
@@ -31,7 +32,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoadXML.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoadXML.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileLoadXML.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,12 +22,12 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import eu.advance.logistics.annotations.Block;
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileMove.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileMove.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileMove.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,6 +22,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import com.google.common.io.Files;
@@ -30,7 +31,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileMoveAll.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileMoveAll.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileMoveAll.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,6 +22,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.util.Map;
@@ -32,7 +33,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileSave.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileSave.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileSave.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,6 +22,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.nio.charset.Charset;
@@ -33,7 +34,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileSaveAll.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileSaveAll.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/file/LocalFileSaveAll.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,6 +22,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.util.Map;
@@ -31,7 +32,6 @@
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/prediction/ConsignmentGet.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/prediction/ConsignmentGet.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/prediction/ConsignmentGet.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -23,6 +23,7 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
import hu.akarnokd.utils.database.DB;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.sql.PreparedStatement;
@@ -40,7 +41,6 @@
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
import eu.advance.logistics.flow.engine.AdvanceRuntimeContext;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.JDBCConnection;
import eu.advance.logistics.flow.engine.runtime.BlockSettings;
Modified: advance/src/eu/advance/logistics/flow/engine/block/prediction/DuringDayModelReader.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/prediction/DuringDayModelReader.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/prediction/DuringDayModelReader.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -20,12 +20,12 @@
*/
package eu.advance.logistics.flow.engine.block.prediction;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import eu.advance.logistics.annotations.Block;
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.annotations.Output;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/prediction/DuringDayModelWriter.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/prediction/DuringDayModelWriter.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/prediction/DuringDayModelWriter.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,11 +22,11 @@
import hu.akarnokd.reactive4java.base.Observer;
import hu.akarnokd.reactive4java.reactive.Reactive;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import eu.advance.logistics.annotations.Block;
import eu.advance.logistics.annotations.Input;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/block/prediction/SelectedAttributesProviderImpl.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/block/prediction/SelectedAttributesProviderImpl.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/block/prediction/SelectedAttributesProviderImpl.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -20,6 +20,7 @@
*/
package eu.advance.logistics.flow.engine.block.prediction;
+import hu.akarnokd.utils.pool.Pool;
import hu.akarnokd.utils.xml.XNElement;
import java.util.HashMap;
@@ -28,7 +29,6 @@
import java.util.logging.Logger;
import eu.advance.logistics.flow.engine.AdvanceBlock;
-import eu.advance.logistics.flow.engine.api.Pool;
import eu.advance.logistics.flow.engine.comm.LocalConnection;
import eu.advance.logistics.flow.engine.runtime.DataResolver;
import eu.advance.logistics.prediction.support.attributes.SelectedAttribute;
Modified: advance/src/eu/advance/logistics/flow/engine/cc/CCValueDialog.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/cc/CCValueDialog.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/cc/CCValueDialog.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -24,6 +24,7 @@
import hu.akarnokd.reactive4java.base.Action0;
import hu.akarnokd.reactive4java.base.Action1;
import hu.akarnokd.reactive4java.base.Option;
+import hu.akarnokd.utils.xml.XNAppender;
import hu.akarnokd.utils.xml.XNElement;
import hu.akarnokd.utils.xml.XNElement.XAttributeName;
import hu.akarnokd.utils.xml.XNElement.XRepresentationRecord;
@@ -278,9 +279,20 @@
}
final XNElement e = (XNElement)o;
- StringBuilder b = new StringBuilder();
- e.toStringRep("", new HashMap<String, String>(), b, new Action1<XRepresentationRecord>() {
+ final StringBuilder b = new StringBuilder();
+ e.toStringRep("", new HashMap<String, String>(),
+ new XNAppender() {
@Override
+ public XNAppender append(Object o) {
+ b.append(o);
+ return this;
+ }
+ @Override
+ public int length() {
+ return b.length();
+ }
+ }, new Action1<XRepresentationRecord>() {
+ @Override
public void invoke(XRepresentationRecord value) {
switch (value.state) {
case START_ELEMENT:
Modified: advance/src/eu/advance/logistics/flow/engine/comm/ChangeNotification.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/comm/ChangeNotification.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/comm/ChangeNotification.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -23,6 +23,7 @@
import hu.akarnokd.reactive4java.base.Scheduler;
import hu.akarnokd.reactive4java.util.DefaultObservable;
+import hu.akarnokd.utils.pool.Pool;
import java.io.Closeable;
import java.io.IOException;
@@ -36,8 +37,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import eu.advance.logistics.flow.engine.api.Pool;
-
/**
* A poll based local or remote file change notifier.
* Clients should register to this class as observers and they will receive the list
Modified: advance/src/eu/advance/logistics/flow/engine/comm/EmailPoolManager.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/comm/EmailPoolManager.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/comm/EmailPoolManager.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,7 +21,7 @@
package eu.advance.logistics.flow.engine.comm;
-import eu.advance.logistics.flow.engine.api.PoolManager;
+import hu.akarnokd.utils.pool.PoolManager;
import eu.advance.logistics.flow.engine.api.ds.AdvanceDataStore;
import eu.advance.logistics.flow.engine.api.ds.AdvanceEmailBox;
Modified: advance/src/eu/advance/logistics/flow/engine/comm/FTPPoolManager.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/comm/FTPPoolManager.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/comm/FTPPoolManager.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -23,6 +23,7 @@
import hu.akarnokd.utils.crypto.KeystoreFault;
import hu.akarnokd.utils.crypto.KeystoreManager;
+import hu.akarnokd.utils.pool.PoolManager;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -58,7 +59,6 @@
import com.sshtools.j2ssh.transport.publickey.SshPublicKey;
import edu.umd.cs.findbugs.annotations.NonNull;
-import eu.advance.logistics.flow.engine.api.PoolManager;
import eu.advance.logistics.flow.engine.api.core.AdvanceControlException;
import eu.advance.logistics.flow.engine.api.ds.AdvanceDataStore;
import eu.advance.logistics.flow.engine.api.ds.AdvanceFTPDataSource;
Modified: advance/src/eu/advance/logistics/flow/engine/comm/JDBCPoolManager.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/comm/JDBCPoolManager.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/comm/JDBCPoolManager.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -22,6 +22,7 @@
package eu.advance.logistics.flow.engine.comm;
import hu.akarnokd.utils.database.DB;
+import hu.akarnokd.utils.pool.PoolManager;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -32,7 +33,6 @@
import org.slf4j.LoggerFactory;
import edu.umd.cs.findbugs.annotations.NonNull;
-import eu.advance.logistics.flow.engine.api.PoolManager;
import eu.advance.logistics.flow.engine.api.ds.AdvanceJDBCDataSource;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/comm/JMSPoolManager.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/comm/JMSPoolManager.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/comm/JMSPoolManager.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,8 +21,11 @@
package eu.advance.logistics.flow.engine.comm;
+import hu.akarnokd.reactive4java.base.MultiIOException;
+import hu.akarnokd.utils.pool.PoolManager;
+
+import java.io.IOException;
import java.util.Hashtable;
-import java.util.List;
import javax.jms.JMSException;
import javax.jms.Queue;
@@ -39,11 +42,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.Lists;
-
import edu.umd.cs.findbugs.annotations.NonNull;
-import eu.advance.logistics.flow.engine.api.PoolManager;
-import eu.advance.logistics.flow.engine.api.core.MultiIOException;
import eu.advance.logistics.flow.engine.api.ds.AdvanceJMSEndpoint;
@@ -113,24 +112,24 @@
@Override
public void close(JMSConnection obj) throws Exception {
- List<Throwable> lst = Lists.newArrayList();
+ MultiIOException exc = null;
try {
obj.session().close();
} catch (JMSException ex) {
- lst.add(ex);
+ exc = MultiIOException.createOrAdd(exc, new IOException(ex));
}
try {
obj.connection().close();
} catch (JMSException ex) {
- lst.add(ex);
+ exc = MultiIOException.createOrAdd(exc, new IOException(ex));
}
try {
obj.context().close();
} catch (NamingException ex) {
- lst.add(ex);
+ exc = MultiIOException.createOrAdd(exc, new IOException(ex));
}
- if (!lst.isEmpty()) {
- throw new MultiIOException(lst);
+ if (exc != null) {
+ throw exc;
}
}
/**
Modified: advance/src/eu/advance/logistics/flow/engine/comm/LocalPoolManager.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/comm/LocalPoolManager.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/comm/LocalPoolManager.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,7 +21,7 @@
package eu.advance.logistics.flow.engine.comm;
-import eu.advance.logistics.flow.engine.api.PoolManager;
+import hu.akarnokd.utils.pool.PoolManager;
import eu.advance.logistics.flow.engine.api.ds.AdvanceLocalFileDataSource;
/**
Modified: advance/src/eu/advance/logistics/flow/engine/comm/SOAPPoolManager.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/comm/SOAPPoolManager.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/comm/SOAPPoolManager.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,7 +21,7 @@
package eu.advance.logistics.flow.engine.comm;
-import eu.advance.logistics.flow.engine.api.PoolManager;
+import hu.akarnokd.utils.pool.PoolManager;
import eu.advance.logistics.flow.engine.api.ds.AdvanceDataStore;
import eu.advance.logistics.flow.engine.api.ds.AdvanceSOAPEndpoint;
Modified: advance/src/eu/advance/logistics/flow/engine/comm/WebPoolManager.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/comm/WebPoolManager.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/comm/WebPoolManager.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,7 +21,7 @@
package eu.advance.logistics.flow.engine.comm;
-import eu.advance.logistics.flow.engine.api.PoolManager;
+import hu.akarnokd.utils.pool.PoolManager;
import eu.advance.logistics.flow.engine.api.ds.AdvanceDataStore;
import eu.advance.logistics.flow.engine.api.ds.AdvanceWebDataSource;
Modified: advance/src/eu/advance/logistics/flow/engine/test/JDBCDataStoreTest.java
===================================================================
--- advance/src/eu/advance/logistics/flow/engine/test/JDBCDataStoreTest.java 2013-11-07 19:46:55 UTC (rev 329)
+++ advance/src/eu/advance/logistics/flow/engine/test/JDBCDataStoreTest.java 2013-11-07 20:00:16 UTC (rev 330)
@@ -21,6 +21,7 @@
package eu.advance.logistics.flow.engine.test;
+import hu.akarnokd.utils.pool.BoundedPool;
import hu.akarnokd.utils.xml.XNElement;
import java.io.IOException;
@@ -28,7 +29,6 @@
import java.util.Map;
import eu.advance.logistics.flow.engine.JDBCDataStore;
-import eu.advance.logistics.flow.engine.api.BoundedPool;
import eu.advance.logistics.flow.engine.api.core.AdvanceControlException;
import eu.advance.logistics.flow.engine.api.ds.AdvanceJDBCDataSource;
import eu.advance.logistics.flow.engine.api.ds.AdvanceNotificationGroupType;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-11-07 19:46:58
|
Revision: 329
http://sourceforge.net/p/advance-project/code/329
Author: akarnokd
Date: 2013-11-07 19:46:55 +0000 (Thu, 07 Nov 2013)
Log Message:
-----------
Updated helper lib
Modified Paths:
--------------
Advance-API/lib/akarnokd_tools.jar
Removed Paths:
-------------
Advance-API/src/eu/advance/logistics/flow/engine/api/core/MultiIOException.java
Modified: Advance-API/lib/akarnokd_tools.jar
===================================================================
(Binary files differ)
Deleted: Advance-API/src/eu/advance/logistics/flow/engine/api/core/MultiIOException.java
===================================================================
--- Advance-API/src/eu/advance/logistics/flow/engine/api/core/MultiIOException.java 2013-11-06 19:53:45 UTC (rev 328)
+++ Advance-API/src/eu/advance/logistics/flow/engine/api/core/MultiIOException.java 2013-11-07 19:46:55 UTC (rev 329)
@@ -1,84 +0,0 @@
-/*
- * Copyright 2010-2013 The Advance EU 7th Framework project consortium
- *
- * This file is part of Advance.
- *
- * Advance is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Advance is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Advance. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-package eu.advance.logistics.flow.engine.api.core;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.util.Collections;
-import java.util.List;
-
-import com.google.common.collect.Lists;
-
-/**
- * An exception which wraps many other exception under a common IOException-type.
- * @author akarnokd, 2011.10.05.
- */
-public class MultiIOException extends IOException {
- /** */
- private static final long serialVersionUID = 1406886722299385700L;
- /** The list of exceptions. */
- protected final List<Throwable> exceptions;
- /**
- * Create a MultiIOException with the given sequence of wrapped exceptions.
- * @param exceptions the sequence of exceptions
- */
- public MultiIOException(Iterable<? extends Throwable> exceptions) {
- this.exceptions = Lists.newArrayList(exceptions);
- }
- @Override
- public String getLocalizedMessage() {
- StringBuilder b = new StringBuilder();
- for (Throwable t : exceptions) {
- if (b.length() > 0) {
- b.append(", ");
- }
- b.append(t);
- }
- return b.toString();
- }
- @Override
- public void printStackTrace() {
- super.printStackTrace();
- for (Throwable t : exceptions) {
- t.printStackTrace();
- }
- }
- @Override
- public void printStackTrace(PrintStream s) {
- super.printStackTrace(s);
- for (Throwable t : exceptions) {
- t.printStackTrace(s);
- }
- }
- @Override
- public void printStackTrace(PrintWriter s) {
- super.printStackTrace(s);
- for (Throwable t : exceptions) {
- t.printStackTrace(s);
- }
- }
- /** @return the unmodifiable list of wrapped exceptions. */
- public List<Throwable> getExceptions() {
- return Collections.unmodifiableList(exceptions);
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-11-06 19:53:49
|
Revision: 328
http://sourceforge.net/p/advance-project/code/328
Author: csirobi
Date: 2013-11-06 19:53:45 +0000 (Wed, 06 Nov 2013)
Log Message:
-----------
Shed layout: bug fixing to start out
Modified Paths:
--------------
advance-live-reporter-os/WebContent/api-warehouse-l1.jsp
advance-live-reporter-os/WebContent/api-warehouse-l2.jsp
advance-live-reporter-os/WebContent/api-warehouse-l3.jsp
advance-live-reporter-os/WebContent/css/warehouse-header.css
advance-live-reporter-os/WebContent/js/pages/warehouse-l1-page.js
advance-live-reporter-os/WebContent/js/pages/warehouse-l2-page.js
advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js
advance-live-reporter-os/WebContent/warehouse-header.jspf
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1Chart.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java
Added Paths:
-----------
advance-live-reporter-os/src/l2params.xml
advance-live-reporter-os/src/l2params.xsd
Modified: advance-live-reporter-os/WebContent/api-warehouse-l1.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-l1.jsp 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/WebContent/api-warehouse-l1.jsp 2013-11-06 19:53:45 UTC (rev 328)
@@ -27,7 +27,8 @@
HubDepotSwitch hubDepotSwitch = new HubDepotSwitch(user.hub, user.name);
hubDepotSwitch.setDateTime(new Date());
- WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, request.getParameter("warehouse_name"), user.name);
+ WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
+ warehouseSwitch.setWarehouse(request.getParameter("warehouse_name"));
L1OverallData overallData = new L1OverallData(warehouseSwitch);
L1AtHubData atHubData = new L1AtHubData(warehouseSwitch);
Modified: advance-live-reporter-os/WebContent/api-warehouse-l2.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-l2.jsp 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/WebContent/api-warehouse-l2.jsp 2013-11-06 19:53:45 UTC (rev 328)
@@ -30,7 +30,8 @@
HubDepotSwitch hubDepotSwitch = new HubDepotSwitch(user.hub, user.name);
hubDepotSwitch.setDateTime(new Date());
- WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, request.getParameter("warehouse_name"), user.name);
+ WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
+ warehouseSwitch.setWarehouse(request.getParameter("warehouse_name"));
warehouseSwitch.setL2WarehouseOption(request.getParameter("warehouse_option"));
warehouseSwitch.setStorageAreaOrder(request.getParameter("storage_order"));
Modified: advance-live-reporter-os/WebContent/api-warehouse-l3.jsp
===================================================================
--- advance-live-reporter-os/WebContent/api-warehouse-l3.jsp 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/WebContent/api-warehouse-l3.jsp 2013-11-06 19:53:45 UTC (rev 328)
@@ -29,7 +29,8 @@
HubDepotSwitch hubDepotSwitch = new HubDepotSwitch(user.hub, user.name);
hubDepotSwitch.setDateTime(new Date());
- WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, request.getParameter("warehouse_name"), user.name);
+ WarehouseSwitch warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
+ warehouseSwitch.setWarehouse(request.getParameter("warehouse_name"));
warehouseSwitch.setL3WarehouseOption(request.getParameter("warehouse_l3_option"));
warehouseSwitch.setStorageAreaOrder(request.getParameter("storage_order"));
Modified: advance-live-reporter-os/WebContent/css/warehouse-header.css
===================================================================
--- advance-live-reporter-os/WebContent/css/warehouse-header.css 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/WebContent/css/warehouse-header.css 2013-11-06 19:53:45 UTC (rev 328)
@@ -121,7 +121,7 @@
div.warehouse-menu .warehouse-width td,
div.warehouse-menu .option-width td {
border: 1px solid #388C00;
- font-size: 52px;
+ font-size: 20px;
font-weight: bold;
padding: 0px;
margin: 0px;
Modified: advance-live-reporter-os/WebContent/js/pages/warehouse-l1-page.js
===================================================================
--- advance-live-reporter-os/WebContent/js/pages/warehouse-l1-page.js 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/WebContent/js/pages/warehouse-l1-page.js 2013-11-06 19:53:45 UTC (rev 328)
@@ -78,13 +78,13 @@
callChart : function()
{
var mySelf = this;
- var s = mySelf.active.warehouse.split("_");
+ var s = mySelf.active.warehouse;
$("div#k2").warehousel1chart("clearBar");
$("div#k2").warehousel1chart("warehouseL1Bar", {
url : "api-warehouse-l1.jsp",
data : {
- warehouse_name : s[1]
+ warehouse_name : s
}
});
}
Modified: advance-live-reporter-os/WebContent/js/pages/warehouse-l2-page.js
===================================================================
--- advance-live-reporter-os/WebContent/js/pages/warehouse-l2-page.js 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/WebContent/js/pages/warehouse-l2-page.js 2013-11-06 19:53:45 UTC (rev 328)
@@ -86,12 +86,12 @@
$("#hand_silent_rect").on("click.silent", function(event)
{
- var s = mySelf.active.warehouse.split("_");
+ var s = mySelf.active.warehouse;
var o = mySelf.active.option.split("_");
var r = mySelf.active.order.split("_");
var l3o = event.storage_info.split("_");
- $('#l2_l3_form input[name="warehouse_name"]').val(s[1]);
+ $('#l2_l3_form input[name="warehouse_name"]').val(s);
$('#l2_l3_form input[name="warehouse_option"]').val(o[1]);
$('#l2_l3_form input[name="storage_order"]').val(r[1]);
$('#l2_l3_form input[name="warehouse_l3_option"]').val(l3o[2]);
@@ -105,7 +105,7 @@
callChart : function()
{
var mySelf = this;
- var s = mySelf.active.warehouse.split("_");
+ var s = mySelf.active.warehouse;
var o = mySelf.active.option.split("_");
var r = mySelf.active.order.split("_");
@@ -113,7 +113,7 @@
$("div#k2").warehousel2chart("warehouseL2Bar", {
url : "api-warehouse-l2.jsp",
data : {
- warehouse_name : s[1],
+ warehouse_name : s,
warehouse_option : o[1],
storage_order : r[1]
},
Modified: advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js
===================================================================
--- advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/WebContent/js/pages/warehouse-l3-page.js 2013-11-06 19:53:45 UTC (rev 328)
@@ -81,7 +81,7 @@
callChart : function(modeType)
{
var mySelf = this;
- var s = mySelf.active.warehouse.split("_");
+ var s = mySelf.active.warehouse;
var o = mySelf.active.option.split("_");
var r = mySelf.active.order.split("_");
var storageId = 0;
@@ -101,10 +101,10 @@
url : "api-warehouse-l3.jsp",
data : {
mode : modeType,
- warehouse_name : s[1],
+ warehouse_name : s,
warehouse_l3_option : o[1],
storage_order : r[1],
- warehouse_l3_storage_id : storageId
+ warehouse_l3_storage_id : storageId
}
});
}
Modified: advance-live-reporter-os/WebContent/warehouse-header.jspf
===================================================================
--- advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/WebContent/warehouse-header.jspf 2013-11-06 19:53:45 UTC (rev 328)
@@ -1,3 +1,4 @@
+<%@page import="hu.akarnokd.utils.lang.*"%>
<%@page import="java.util.Date"%>
<%@page import="eu.advance.logistics.live.reporter.charts.*"%>
<%@page import="eu.advance.logistics.live.reporter.model.*"%>
@@ -3,5 +4,4 @@
<%
User user = null;
-HubDepotSwitch hubDepotSwitch = null;
WarehouseSwitch warehouseSwitch = null;
@@ -23,17 +23,35 @@
else
{
warehouseSwitch = (WarehouseSwitch)request.getAttribute("WAREHOUSE_SWITCH");
- if (warehouseSwitch == null ) {
- try {
- if (request.getParameter("warehouse_name") != null) {
- warehouseSwitch = new WarehouseSwitch(user.hub, request.getParameter("warehouse_name"), user.name);
- warehouseSwitch.setL2WarehouseOption(request.getParameter("warehouse_option"));
- warehouseSwitch.setStorageAreaOrder(request.getParameter("storage_order"));
- warehouseSwitch.setL3WarehouseOption(request.getParameter("warehouse_l3_option"));
- if (request.getParameter("warehouse_l3_storage_id") != null) {
- warehouseSwitch.setL3SelectedStorageId(Long.parseLong(request.getParameter("warehouse_l3_storage_id")));
- }
- }
+ if (warehouseSwitch == null )
+ {
+ try
+ {
+ warehouseSwitch = new WarehouseSwitch(user.hub, user.name);
+
+ String whName = ObjectUtils.nvl(request.getParameter("warehouse_name"), warehouseSwitch.getFirstWarehousePairTop());
+ String whOption = ObjectUtils.nvl(request.getParameter("warehouse_option"), "A");
+ String stOrder = ObjectUtils.nvl(request.getParameter("storage_order"), "PHYSICAL");
+ String whL3Option = ObjectUtils.nvl(request.getParameter("warehouse_l3_option"), "LEFT");
+
+ String whL3StId = ObjectUtils.nvl(request.getParameter("warehouse_l3_storage_id"), "0");
+
+ warehouseSwitch.setWarehouse(whName);
+ warehouseSwitch.setL2WarehouseOption(whOption);
+ warehouseSwitch.setStorageAreaOrder(stOrder);
+ warehouseSwitch.setL3WarehouseOption(whL3Option);
+ warehouseSwitch.setL3SelectedStorageId(Long.parseLong(whL3StId));
+
+
+ /*
+ warehouseSwitch.setL2WarehouseOption(request.getParameter("warehouse_option"));
+ warehouseSwitch.setStorageAreaOrder(request.getParameter("storage_order"));
+ warehouseSwitch.setL3WarehouseOption(request.getParameter("warehouse_l3_option"));
+ if (request.getParameter("warehouse_l3_storage_id") != null) {
+ warehouseSwitch.setL3SelectedStorageId(Long.parseLong(request.getParameter("warehouse_l3_storage_id")));
+ }
+ */
+
}
catch(IllegalArgumentException e)
{
@@ -61,10 +79,10 @@
<div id="warehouse-up-down" class="warehouse-up-down"></div>
<form id="warehouse_form" method="post" action="" accept-charset="UTF-8">
- <input type="hidden" name="warehouse_name" value=""> <input
- type="hidden" name="warehouse_option" value=""> <input
- type="hidden" name="storage_order" value=""> <input
- type="hidden" name="warehouse_l3_option" value="">
+ <input type="hidden" name="warehouse_name" value="">
+ <input type="hidden" name="warehouse_option" value="">
+ <input type="hidden" name="storage_order" value="">
+ <input type="hidden" name="warehouse_l3_option" value="">
</form>
</div>
<div class="option-container">
@@ -75,10 +93,10 @@
<div id="selector_warehouse" class="option-inner warehouse-width">
<table>
<tr>
- <td id="warehouse_1" class="inactive">1</td>
+ <td id="warehouse_top" class="inactive"><%= warehouseSwitch.getWarehousePairTop()%></td>
</tr>
<tr>
- <td id="warehouse_2" class="inactive">2</td>
+ <td id="warehouse_bottom" class="inactive"><%= warehouseSwitch.getWarehousePairBottom()%></td>
</tr>
</table>
</div>
@@ -148,7 +166,7 @@
var mySelf = this;
mySelf.atPage = param;
- mySelf.active.warehouse = "warehouse_<%= warehouseSwitch.getWarehouse().toLowerCase()%>";
+ mySelf.active.warehouse = "<%= warehouseSwitch.getWarehouse()%>";
mySelf.active.option = "option_<%= warehouseSwitch.getL2WarehouseOption().name().toLowerCase()%>";
mySelf.active.order = "order_<%= warehouseSwitch.getStorageOrder().name().toLowerCase()%>";
mySelf.active.l3option = "option_<%= warehouseSwitch.getL3WarehouseOption().name().toLowerCase()%>";
@@ -157,8 +175,9 @@
{
mySelf.setUpDown("warehouse-down", "warehouse-l2.jsp");
- mySelf.setInitMenu("warehouse");
- mySelf.buttonGroupHandler("warehouse");
+ mySelf.setWarehouseMenu();
+ mySelf.buttonWarehouseHandler();
+
$("#selector_option").hide();
$("#selector_order").hide();
}
@@ -166,7 +185,7 @@
{
mySelf.setUpDown("warehouse-up", "warehouse-l1.jsp");
- mySelf.setInitMenu("warehouse");
+ mySelf.setWarehouseMenu();
mySelf.setInitMenu("option");
mySelf.buttonGroupHandler("option");
@@ -177,7 +196,7 @@
{
mySelf.setUpDown("warehouse-up", "warehouse-l2.jsp");
- mySelf.setInitMenu("warehouse");
+ mySelf.setWarehouseMenu();
mySelf.setInitMenu("option", "l3");
mySelf.buttonGroupHandler("option");
@@ -235,7 +254,7 @@
var active = mySelf.getAllEnumMenu();
$("#warehouse_form").attr("action", actionURL);
- $('#warehouse_form input[name="warehouse_name"]').val(active.warehouse);
+ $('#warehouse_form input[name="warehouse_name"]').val(active.warehouse);
$('#warehouse_form input[name="warehouse_option"]').val(active.option);
$('#warehouse_form input[name="storage_order"]').val(active.order);
$('#warehouse_form input[name="warehouse_l3_option"]').val(active.l3option);
@@ -244,6 +263,58 @@
});
},
+ // Set the warehouse menu based on mySelf.active
+ setWarehouseMenu : function()
+ {
+ var mySelf = this;
+ var active = mySelf.active;
+ var ss = 'td[id^="warehouse_"]';
+
+ $(ss).toggleClass(mySelf.actClass, false);
+ if($('td[id="warehouse_top"]').text() == active.warehouse)
+ {
+ $('td[id="warehouse_top"]').toggleClass(mySelf.actClass);
+ }
+ else if($('td[id="warehouse_bottom"]').text() == active.warehouse)
+ {
+ $('td[id="warehouse_bottom"]').toggleClass(mySelf.actClass);
+ }
+ },
+
+ // Warehouse button group handler
+ buttonWarehouseHandler : function()
+ {
+ var mySelf = this;
+ var ss = 'td[id^="warehouse_"]';
+
+ $(ss).on("click", function(event)
+ {
+ var isChanged = true;
+
+ if ($("#" + event.target.id).hasClass(mySelf.actClass) == false)
+ {
+ $(ss).toggleClass(mySelf.actClass, false);
+ $("#" + event.target.id).toggleClass(mySelf.actClass);
+ } else
+ {
+ isChanged = false;
+ }
+
+ if (isChanged)
+ {
+ var t = "click.warehouse";
+ var actValue = $('td[id="' + event.target.id + '"]').text();
+
+ $("#hand_warehouse").triggerHandler({
+ type : t,
+ active : actValue,
+ });
+ }
+
+ });
+
+ },
+
// Set the switchboard menu based on the mySelf.active and the level
setInitMenu : function(group, level)
{
@@ -297,7 +368,7 @@
{
var active = {};
- active.warehouse = $('td[id^="warehouse_"].active').attr("id");
+ active.warehouse = $('td[id^="warehouse_"].active').text();
active.option = $('td[id^="option_"].active').attr("id");
active.order = $('td[id^="order_"].active').attr("id");
@@ -312,8 +383,7 @@
if(mySelf.atPage == "l1")
{
- var s = $('td[id^="warehouse_"].active').attr("id").split("_");
- active.warehouse = s[1];
+ active.warehouse = $('td[id^="warehouse_"].active').text();
var o = mySelf.active.option.split("_");
active.option = o[1];
@@ -326,8 +396,7 @@
}
else if(mySelf.atPage == "l2")
{
- var s = $('td[id^="warehouse_"].active').attr("id").split("_");
- active.warehouse = s[1];
+ active.warehouse = $('td[id^="warehouse_"].active').text();
var o = $('td[id^="option_"].active').attr("id").split("_");
active.option = o[1];
@@ -340,8 +409,7 @@
}
else if(mySelf.atPage == "l3")
{
- var s = $('td[id^="warehouse_"].active').attr("id").split("_");
- active.warehouse = s[1];
+ active.warehouse = $('td[id^="warehouse_"].active').text();
var o = mySelf.active.option.split("_");
active.option = o[1];
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1Chart.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1Chart.java 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1Chart.java 2013-11-06 19:53:45 UTC (rev 328)
@@ -69,11 +69,13 @@
JSONObject result = new JSONObject();
JSONArray inner = new JSONArray();
+ int ordinal = 0;
for (ItemStatus keyItem : L1OverallData.getDisplayItems()) {
JSONObject statusRecord = new JSONObject();
statusRecord.put("info", keyItem.getInfo());
statusRecord.put("message", keyItem.getMessage());
- inner.add(keyItem.ordinal(), statusRecord);
+ inner.add(ordinal, statusRecord);
+ ordinal++;
}
result.put("overall", inner);
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java 2013-11-06 19:53:45 UTC (rev 328)
@@ -84,7 +84,7 @@
public void checkBaus() {
GraphDecimal value = new GraphDecimal(0);
- for (ItemStatus pKey : ItemStatus.values()) {
+ for (ItemStatus pKey : L1OverallData.getDisplayItems()) {
value = value.add(new GraphDecimal(this.items.get(WarehouseServiceLevel.ALL).get(pKey).value));
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSummary.java 2013-11-06 19:53:45 UTC (rev 328)
@@ -168,7 +168,9 @@
double d = 0;
for (WarehouseSide sKey : WarehouseSide.values()) {
- d += warehouseCapacityMap.get(warehouse).get(sKey);
+ // FIXME somehow!
+ d += warehouseCapacityMap.get(warehouse + WarehouseType.A).get(sKey);
+ d += warehouseCapacityMap.get(warehouse + WarehouseType.B).get(sKey);
}
return d;
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/WarehouseSwitch.java 2013-11-06 19:53:45 UTC (rev 328)
@@ -52,26 +52,95 @@
private WarehouseOption l3warehouseOption;
/** Level 3 selected storage area ID. */
private long l3SelectedStorageId;
+
/** The hub id. */
private final long hubId;
/** The user. */
private final String user;
+ /** The map of warehouse pairs. */
+ private final Map<String, String> warehousePairMap;
+
/**
* Constructor.
* @param hubId the hub
* @param warehouse the starting warehouse
* @param user the user name
*/
- public WarehouseSwitch(long hubId, String warehouse, String user) {
+ public WarehouseSwitch(long hubId, String user) {
this.hubId = hubId;
- this.warehouse = warehouse;
- this.user = user;
- this.l2warehouseOption = WarehouseOption.A;
+ this.user = user;
+ this.warehousePairMap = this.getWarehousePairMap();
+ this.warehouse = this.getFirstWarehousePairTop();
+
+ this.l2warehouseOption = WarehouseOption.A;
this.storageOrder = StorageAreaOrder.PHYSICAL;
this.l3warehouseOption = WarehouseOption.LEFT;
this.l3SelectedStorageId = 0;
}
+
+ private Map<String, String> getWarehousePairMap()
+ {
+ Map<String, String> wPair = new LinkedHashMap<>();
+ List<Warehouse> list = MasterDB.warehouses(1);
+
+ if(list.isEmpty() == false)
+ {
+ for(Warehouse item: list)
+ {
+ if( (wPair.containsKey(item.warehouse) == false) && (wPair.containsValue(item.warehouse) == false))
+ {
+ wPair.put(item.warehouse, item.pair);
+ }
+ }
+ }
+
+ return wPair;
+ }
+
+ public String getFirstWarehousePairTop()
+ {
+ return this.warehousePairMap.keySet().iterator().next();
+ }
+
+ public String getWarehousePairTop()
+ {
+ String res = "";
+
+ if(warehousePairMap.containsKey(this.warehouse))
+ {
+ res = this.warehouse;
+ }
+ else if(warehousePairMap.containsValue(this.warehouse))
+ {
+ for(String keyItem : warehousePairMap.keySet())
+ {
+ if(warehousePairMap.get(keyItem).equals(this.warehouse))
+ {
+ res = keyItem;
+ }
+ }
+ }
+
+ return res;
+ }
+
+ public String getWarehousePairBottom()
+ {
+ String res = "";
+
+ if(this.warehousePairMap.containsKey(this.warehouse))
+ {
+ res = this.warehousePairMap.get(this.warehouse);
+ }
+ else if(this.warehousePairMap.containsValue(this.warehouse))
+ {
+ res = this.warehouse;
+ }
+
+ return res;
+ }
+
/**
* Returns the hub of this warehouse.
* @return the hub id
@@ -79,6 +148,12 @@
public long hubId() {
return hubId;
}
+
+ public void setWarehouse(String warehouse)
+ {
+ this.warehouse = warehouse;
+ }
+
/**
* Set the level 2 warehouse option.
* @param option the option
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java 2013-10-07 11:57:44 UTC (rev 327)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/MasterDB.java 2013-11-06 19:53:45 UTC (rev 328)
@@ -398,6 +398,7 @@
map.put(sd, new ArrayList<StorageAreaInfo>());
}
}
+
TLongObjectMap<StorageSide> depotSide = new TLongObjectHashMap<>();
for (Warehouse wh : warehouses) {
String sn = wh.warehouse;
@@ -446,6 +447,7 @@
Collections.sort(l);
}
}
+
return result;
}
/**
@@ -484,6 +486,10 @@
for (WarehouseType stype : WarehouseType.values()) {
Map<WarehouseSide, Double> sd = new LinkedHashMap<>();
String key = snKey.toString() + stype.toString();
+
+ // FIXME somehow!
+ System.out.println("X3 " + key);
+
result.put(key, sd);
for (WarehouseSide ssKey : WarehouseSide.values()) {
double count = 0;
@@ -494,6 +500,7 @@
}
}
}
+
return result;
}
}
Added: advance-live-reporter-os/src/l2params.xml
===================================================================
--- advance-live-reporter-os/src/l2params.xml (rev 0)
+++ advance-live-reporter-os/src/l2params.xml 2013-11-06 19:53:45 UTC (rev 328)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<paramWeight xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="l2params.xsd">
+ <timeState id="now_at_hub">
+ <tau>0.85</tau>
+ <lambda>0.85</lambda>
+ <delta>1.2</delta>
+ </timeState>
+ <timeState id="coming_up">
+ <tau>0.85</tau>
+ <lambda>0.85</lambda>
+ <delta>1.2</delta>
+ <wm>0.6</wm>
+ <ws>0.3</ws>
+ <we>0.1</we>
+ </timeState>
+ <timeState id="overall">
+ <lambda>0.85</lambda>
+ <delta>1.2</delta>
+ <wn>0.75</wn>
+ <wp>0.25</wp>
+ </timeState>
+</paramWeight>
Added: advance-live-reporter-os/src/l2params.xsd
===================================================================
--- advance-live-reporter-os/src/l2params.xsd (rev 0)
+++ advance-live-reporter-os/src/l2params.xsd 2013-11-06 19:53:45 UTC (rev 328)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="paramWeight">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="timeState" maxOccurs="unbounded" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:float" name="tau" minOccurs="0"/>
+ <xs:element type="xs:float" name="lambda"/>
+ <xs:element type="xs:float" name="delta"/>
+ <xs:element type="xs:float" name="wm" minOccurs="0"/>
+ <xs:element type="xs:float" name="ws" minOccurs="0"/>
+ <xs:element type="xs:float" name="we" minOccurs="0"/>
+ <xs:element type="xs:float" name="wn" minOccurs="0"/>
+ <xs:element type="xs:float" name="wp" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="id" use="optional"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cs...@us...> - 2013-10-07 11:57:48
|
Revision: 327
http://sourceforge.net/p/advance-project/code/327
Author: csirobi
Date: 2013-10-07 11:57:44 +0000 (Mon, 07 Oct 2013)
Log Message:
-----------
HubDepot: summary chart fix
Modified Paths:
--------------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/SumChart.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/SumData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/ServiceLevel.java
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/SumChart.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/SumChart.java 2013-10-07 07:39:21 UTC (rev 326)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/SumChart.java 2013-10-07 11:57:44 UTC (rev 327)
@@ -71,6 +71,24 @@
return result;
}
+ /** The relevant service levels. */
+ private static final ServiceLevel[] SERVICE_LEVELS = {
+ ServiceLevel.ALL,
+ ServiceLevel.STANDARD,
+ ServiceLevel.PRIORITY,
+ ServiceLevel.SPECIAL
+ };
+
+ /** The relevant item statuses. */
+ private static final ItemStatus[] ITEM_STATUSES = {
+ ItemStatus.LEFT_HUB_TODAY,
+ ItemStatus.AT_HUB,
+ ItemStatus.DECLARED,
+ ItemStatus.SCANNED,
+ ItemStatus.CREATED,
+ ItemStatus.PREDICTED
+ };
+
/**
* Create the direction JSON object.
* @param sumData the data source
@@ -116,7 +134,7 @@
switch(sumData.type) {
case HUB:
JSONArray tickArray = new JSONArray();
- for (ServiceLevel sKey : ServiceLevel.values()) {
+ for (ServiceLevel sKey : SERVICE_LEVELS) {
tickArray.add(((HubCoord)coord).noOfTotalTick.get(sKey).toPlainString());
}
result.put("noOfTotalTick", tickArray);
@@ -135,16 +153,7 @@
return result;
}
- /** The relevant item statuses. */
- private static final ItemStatus[] ITEM_STATUSES = {
- ItemStatus.CREATED,
- ItemStatus.SCANNED,
- ItemStatus.DECLARED,
- ItemStatus.AT_HUB,
- ItemStatus.LEFT_HUB_TODAY,
- ItemStatus.PREDICTED
- };
-
+
/**
* Create the status JSON array.
* @return the created JSON array
@@ -162,6 +171,7 @@
return resultArray;
}
+
/**
* Create the bars JSON array.
* @param coord the coordinate object
@@ -176,7 +186,7 @@
JSONArray orientRec;
EnumSet<OrientStatus> orientKeys = bar.getOrientKeys();
- for (ServiceLevel uKey: ServiceLevel.values()) {
+ for (ServiceLevel uKey: SERVICE_LEVELS) {
typeRec = new JSONObject();
typeRec.put("unit", uKey.getMessage());
typeRec.put("name", bar.name);
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/SumData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/SumData.java 2013-10-07 07:39:21 UTC (rev 326)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/SumData.java 2013-10-07 11:57:44 UTC (rev 327)
@@ -124,10 +124,12 @@
*/
public void checkBaus() {
GraphDecimal value = new GraphDecimal(0);
+ // Widest range case: login at hub and selected any depot.
+ ItemStatus[] statuses = {ItemStatus.AT_HUB, ItemStatus.DECLARED, ItemStatus.SCANNED, ItemStatus.CREATED, ItemStatus.PREDICTED};
for (OrientStatus oKey : this.getOrientKeys()) {
- GraphDecimal inner = new GraphDecimal(0);
- for (ItemStatus pKey : ItemStatus.values()) {
+ GraphDecimal inner = this.maxLeftHub(true);
+ for (ItemStatus pKey : statuses) {
BarData bd = this.items.get(ServiceLevel.ALL).get(oKey).get(pKey);
if (bd != null) {
inner = inner.add(new GraphDecimal(bd.value));
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/ServiceLevel.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/ServiceLevel.java 2013-10-07 07:39:21 UTC (rev 326)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/ServiceLevel.java 2013-10-07 11:57:44 UTC (rev 327)
@@ -29,7 +29,7 @@
STANDARD("Standard"),
/** Priority level. */
PRIORITY("Priority"),
- /** Special levle. */
+ /** Special level. */
SPECIAL("Special"),
/** Used by the screens to indicate aggregation. */
ALL("All services");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-10-07 07:39:25
|
Revision: 326
http://sourceforge.net/p/advance-project/code/326
Author: akarnokd
Date: 2013-10-07 07:39:21 +0000 (Mon, 07 Oct 2013)
Log Message:
-----------
Added Arx native task.
Modified Paths:
--------------
advance-live-reporter-os/src/crontab.xml
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/PredictionDB.java
Added Paths:
-----------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/cron/
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/cron/ArxRunnerTask.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/cron/package-info.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/TimedValue.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxCoefficients.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxConfig.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxKMeans.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxLearner.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxModel.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxTimedValueAggregator.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/package-info.java
Modified: advance-live-reporter-os/src/crontab.xml
===================================================================
--- advance-live-reporter-os/src/crontab.xml 2013-10-04 12:16:01 UTC (rev 325)
+++ advance-live-reporter-os/src/crontab.xml 2013-10-07 07:39:21 UTC (rev 326)
@@ -1,14 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<crontab>
-<!--
<task id='ARXRunner' months='*' days='*' weekdays='1' hours='0' minutes='0'
- class='eu.advance.logistics.live.reporter.prediction.arx.ARXRunnerTask'>
+ class='eu.advance.logistics.live.reporter.cron.ArxRunnerTask'>
+ <param name="model-order" value="10"/>
<param name='days' value='365'/>
<param name='use-blacklist' value='true'/>
<param name='hub' value='1'/>
<param name='shift-start' value='5'/>
<param name='horizon' value='3'/>
</task>
+<!--
<task id='MLLearner' months='*' days='*' weekdays='1' hours='0' minutes='0'
class='eu.advance.logistics.live.reporter.prediction.ml.MLLearnerTask'>
<param name='days' value='365'/>
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/cron/ArxRunnerTask.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/cron/ArxRunnerTask.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/cron/ArxRunnerTask.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package eu.advance.logistics.live.reporter.cron;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.joda.time.DateMidnight;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import eu.advance.logistics.live.reporter.db.MasterDB;
+import eu.advance.logistics.live.reporter.db.PredictionDB;
+import eu.advance.logistics.live.reporter.model.ArxPrediction;
+import eu.advance.logistics.live.reporter.model.ArxPredictionKey;
+import eu.advance.logistics.live.reporter.model.CrontabTask;
+import eu.advance.logistics.live.reporter.model.CrontabTaskSettings;
+import eu.advance.logistics.live.reporter.model.TimedValue;
+import eu.advance.logistics.live.reporter.prediction.arx.ArxCoefficients;
+import eu.advance.logistics.live.reporter.prediction.arx.ArxConfig;
+import eu.advance.logistics.live.reporter.prediction.arx.ArxLearner;
+import gnu.trove.map.TObjectDoubleMap;
+import gnu.trove.map.hash.TObjectDoubleHashMap;
+import gnu.trove.procedure.TObjectDoubleProcedure;
+
+/**
+ * Executes the learning and prediction for the ARX model.
+ * @author karnokd, 2013.05.27.
+ */
+public class ArxRunnerTask implements CrontabTask {
+ /** The logger. */
+ protected static final Logger LOGGER = LoggerFactory.getLogger(ArxRunnerTask.class);
+ @Override
+ public void execute(CrontabTaskSettings settings) throws Exception {
+ final long hub = settings.parameters.getLong("hub");
+ final int historyDays = settings.parameters.getInt("days");
+ final int horizon = settings.parameters.getInt("horizon");
+ final int shiftStartHour = settings.parameters.getInt("shift-start");
+ final boolean blacklist = settings.parameters.getBoolean("use-blacklist");
+
+ DateMidnight start = settings.lastCheck.toDateMidnight();
+ DateMidnight end = start.plusDays(1);
+
+ PredictionDB.deleteARXPredictions(hub, null, start.toDateTime(), end.toDateTime());
+ DateMidnight window = start.minusDays(historyDays);
+ final ArxConfig config = new ArxConfig();
+ if (blacklist) {
+ config.holidays.addAll(MasterDB.holidays());
+ config.ignoreWeekends = true;
+ } else {
+ config.ignoreWeekends = false;
+ }
+
+ config.horizon = horizon;
+ config.modelOrder = settings.parameters.getInt("model-order", config.modelOrder);
+
+ final Map<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> inbound = new HashMap<>();
+ final Map<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> outbound = new HashMap<>();
+
+ Set<ArxPredictionKey> inboundSum = new HashSet<>();
+ Set<ArxPredictionKey> outboundSum = new HashSet<>();
+
+ inbound.entrySet();
+ outbound.entrySet();
+
+ LOGGER.debug("Loading manifests for date range " + window + " to " + end);
+
+ PredictionDB.dailyManifests(hub, window, end, shiftStartHour, inbound, outbound);
+
+ aggregateForHub(hub, inbound, outbound, inboundSum, outboundSum);
+
+ ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
+
+ while (start.compareTo(end) <= 0) {
+ final DateMidnight fstart = start;
+ final DateMidnight fwindow = window;
+ exec.execute(new Runnable() {
+ @Override
+ public void run() {
+ LOGGER.debug("Starting day " + fstart);
+ final List<ArxPrediction> ps = new ArrayList<>();
+ for (final Map.Entry<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> e : inbound.entrySet()) {
+ ps.addAll(calculate(fstart, fwindow, hub, horizon, config, e, true));
+ }
+ for (final Map.Entry<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> e : outbound.entrySet()) {
+ ps.addAll(calculate(fstart, fwindow, hub, horizon, config, e, false));
+ }
+ LOGGER.debug("Saving day " + fstart + " with " + ps.size() + " entries");
+ PredictionDB.saveARXPredictions(ps);
+ }
+ });
+
+ start = start.plusDays(1);
+ window = start.minusDays(historyDays);
+ }
+ exec.shutdown();
+ exec.awaitTermination(6, TimeUnit.HOURS);
+ }
+ /**
+ * Aggregates the inbound and outbound manifests to a hub level.
+ * @param hub the hub id used as negative key
+ * @param inbound the inbound map
+ * @param outbound the outbound map
+ * @param inboundSum the inbound sum keys
+ * @param outboundSum the outbound sum keys
+ */
+ public static void aggregateForHub(
+ long hub,
+ final Map<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> inbound,
+ final Map<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> outbound,
+ Set<ArxPredictionKey> inboundSum, Set<ArxPredictionKey> outboundSum) {
+ for (ArxPredictionKey k : new ArrayList<>(inbound.keySet())) {
+ ArxPredictionKey sumKey = new ArxPredictionKey(k.serviceLevel, k.unit, -hub);
+ inbound.put(sumKey, new TObjectDoubleHashMap<DateMidnight>());
+ inboundSum.add(sumKey);
+ }
+ for (Map.Entry<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> e : inbound.entrySet()) {
+ ArxPredictionKey sumKey = new ArxPredictionKey(e.getKey().serviceLevel, e.getKey().unit, -hub);
+ final TObjectDoubleMap<DateMidnight> sum = inbound.get(sumKey);
+
+ e.getValue().forEachEntry(new TObjectDoubleProcedure<DateMidnight>() {
+ @Override
+ public boolean execute(DateMidnight a, double b) {
+ sum.adjustOrPutValue(a, b, b);
+ return true;
+ }
+ });
+ }
+ for (ArxPredictionKey k : new ArrayList<>(outbound.keySet())) {
+ ArxPredictionKey sumKey = new ArxPredictionKey(k.serviceLevel, k.unit, -hub);
+ outbound.put(sumKey, new TObjectDoubleHashMap<DateMidnight>());
+ outboundSum.add(sumKey);
+ }
+ for (Map.Entry<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> e : outbound.entrySet()) {
+ ArxPredictionKey sumKey = new ArxPredictionKey(e.getKey().serviceLevel, e.getKey().unit, -hub);
+ final TObjectDoubleMap<DateMidnight> sum = outbound.get(sumKey);
+
+ e.getValue().forEachEntry(new TObjectDoubleProcedure<DateMidnight>() {
+ @Override
+ public boolean execute(DateMidnight a, double b) {
+ sum.adjustOrPutValue(a, b, b);
+ return true;
+ }
+ });
+ }
+ }
+ /**
+ * Calculate the prediction for the given time window and other configuration.
+ * @param start the target day to start predicting for
+ * @param window the window start for learning
+ * @param hub the target hub
+ * @param horizon the number of days to predict
+ * @param config the learning configuration
+ * @param e the time series for a particular model
+ * @param inbound is this the inbound record?
+ * @return the predicted values
+ */
+ public static List<ArxPrediction> calculate(DateMidnight start, DateMidnight window,
+ long hub, int horizon, ArxConfig config,
+ Map.Entry<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> e, boolean inbound) {
+
+ ArxPredictionKey key = e.getKey();
+
+ final List<TimedValue> values = new ArrayList<>(256);
+
+ final DateMidnight fwindow = window;
+ final DateMidnight fstart = start;
+
+ // create the subset of dates
+ e.getValue().forEachEntry(new TObjectDoubleProcedure<DateMidnight>() {
+ @Override
+ public boolean execute(DateMidnight a, double b) {
+ if (a.compareTo(fwindow) >= 0 && a.compareTo(fstart) < 0) {
+ values.add(new TimedValue(a, b));
+ }
+ return true;
+ }
+ });
+ // ensure the time data ends at start - 1 days
+ values.add(new TimedValue(fstart.minusDays(1), 0));
+
+ ArxCoefficients coeff = ArxLearner.learn(values, config);
+ List<TimedValue> forecasts = ArxLearner.predict(config, coeff, values, horizon);
+
+ List<ArxPrediction> ps = new ArrayList<>();
+ for (TimedValue tv : forecasts) {
+ ArxPrediction p = new ArxPrediction();
+ p.hub = hub;
+ p.depot = key.depot;
+ p.dayRun = start.toDateTime();
+ p.inbound = inbound;
+ p.service = key.serviceLevel;
+ p.unit = key.unit;
+ p.dayPredict = tv.day;
+ p.value = tv.value;
+ ps.add(p);
+ }
+ return ps;
+ }
+
+}
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/cron/package-info.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/cron/package-info.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/cron/package-info.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+/**
+ * Crontab tasks package.
+ * @author karnokd, 2013.10.07.
+ *
+ */
+package eu.advance.logistics.live.reporter.cron;
\ No newline at end of file
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/PredictionDB.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/PredictionDB.java 2013-10-04 12:16:01 UTC (rev 325)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/PredictionDB.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -20,10 +20,17 @@
*/
package eu.advance.logistics.live.reporter.db;
+import gnu.trove.TLongCollection;
+import gnu.trove.map.TLongObjectMap;
+import gnu.trove.map.TObjectDoubleMap;
+import gnu.trove.map.hash.TLongObjectHashMap;
+import gnu.trove.map.hash.TObjectDoubleHashMap;
import hu.akarnokd.utils.database.DB;
import hu.akarnokd.utils.database.SQLInvoke;
+import hu.akarnokd.utils.trove.TroveUtils;
import java.io.IOException;
+import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -37,9 +44,13 @@
import org.joda.time.DateMidnight;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
+import org.joda.time.ReadableDateTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import eu.advance.logistics.live.reporter.model.ArxPrediction;
import eu.advance.logistics.live.reporter.model.ArxPredictionKey;
+import eu.advance.logistics.live.reporter.model.Consignment;
import eu.advance.logistics.live.reporter.model.ServiceLevel;
import eu.advance.logistics.live.reporter.model.UOM;
@@ -48,6 +59,8 @@
* @author karnokd, 2013.09.24.
*/
public final class PredictionDB {
+ /** The logger. */
+ private static final Logger LOG = LoggerFactory.getLogger(PredictionDB.class);
/** Database class. */
private PredictionDB() { }
/**
@@ -138,4 +151,167 @@
}
}
+ /**
+ * Delete the ARX predictions based on the given settings.
+ * @param hub the target hub
+ * @param depot the target depot if not null
+ * @param from the start of the prediction date, if not null, inclusive
+ * @param to the end of the prediction date, if not null, exclusive
+ */
+ public static void deleteARXPredictions(long hub, @Nullable Long depot,
+ @Nullable ReadableDateTime from, @Nullable ReadableDateTime to) {
+ try (DB db = DB.connect()) {
+ StringBuilder sql = new StringBuilder();
+ List<Object> params = new ArrayList<>();
+
+ sql.append("DELETE FROM arx_predictions WHERE hub = ? ");
+ params.add(hub);
+ if (depot != null) {
+ sql.append("AND depot = ? ");
+ params.add(depot);
+ }
+ if (from != null) {
+ sql.append("AND day_predict >= ? ");
+ params.add(from);
+ }
+ if (to != null) {
+ sql.append("AND day_predict < ? ");
+ params.add(to);
+ }
+
+ db.update(sql, params);
+ db.commit();
+ } catch (IOException | SQLException ex) {
+ ex.printStackTrace();
+ }
+ }
+ /**
+ * Returns the daily manifests for a given time range, grouped by
+ * service level, depot.
+ * @param hub the target hub
+ * @param start the start date, used for entered
+ * @param end the end date, used for entered
+ * @param shiftStartHour the shift start hour
+ * @param inbound the map of inbound manifested values from depots
+ * @param outbound the map of outbound manifested values to depots
+ */
+ public static void dailyManifests(
+ final long hub,
+ final ReadableDateTime start,
+ final ReadableDateTime end,
+ final int shiftStartHour,
+ final Map<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> inbound,
+ final Map<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> outbound) {
+ try (DB db = DB.connect()) {
+ StringBuilder sql = new StringBuilder();
+ sql
+ .append("SELECT ")
+ .append("id, declared, collection_depot, delivery_depot, service_level ")
+ .append("FROM ")
+ .append("consignments ")
+ .append("WHERE ")
+ .append("hub = ? ")
+ .append("AND created >= ? AND created < ? ")
+ .append("AND declared IS NOT NULL ");
+
+ final TLongObjectMap<Consignment> cs = new TLongObjectHashMap<>();
+
+ db.queryReadOnly(sql, new SQLInvoke() {
+ @Override
+ public void invoke(ResultSet t) throws SQLException {
+ Consignment c = new Consignment();
+ c.id = t.getLong(1);
+ c.declared = DB.getDateTime(t, 2);
+ c.collectionDepot = t.getLong(3);
+ c.deliveryDepot = t.getLong(4);
+ c.service = ServiceLevel.values()[t.getInt(5)];
+
+ cs.put(c.id, c);
+ }
+ }, hub, start, end);
+
+ for (TLongCollection ci : TroveUtils.split(cs.keySet(), 1000)) {
+ sql.setLength(0);
+ sql.append("SELECT ")
+ .append(" consignment_id, width, height, length ")
+ .append("FROM ")
+ .append("items ")
+ .append("WHERE ")
+ .append("consignment_id IN (");
+ TroveUtils.join(ci, ",", sql);
+ sql.append(")");
+
+ db.queryReadOnly(sql, new SQLInvoke() {
+ @Override
+ public void invoke(ResultSet t) throws SQLException {
+ Consignment c = cs.get(t.getLong(1));
+
+ double w = t.getDouble(2);
+ double h = t.getDouble(3);
+ double l = t.getDouble(4);
+
+ double f = w * l;
+ double p = w * l * h;
+
+ DateMidnight dm = c.declared.toDateMidnight();
+ if (c.declared.getHourOfDay() < shiftStartHour) {
+ dm = dm.minusDays(1);
+ }
+
+ add(true, c.service, UOM.ITEMCOUNT, c.collectionDepot, dm, 1);
+ add(false, c.service, UOM.ITEMCOUNT, c.deliveryDepot, dm, 1);
+
+ add(true, c.service, UOM.PRICEUNIT, c.collectionDepot, dm, p);
+ add(false, c.service, UOM.PRICEUNIT, c.deliveryDepot, dm, p);
+
+ add(true, c.service, UOM.FLOORSPACE, c.collectionDepot, dm, f);
+ add(false, c.service, UOM.FLOORSPACE, c.deliveryDepot, dm, f);
+
+ }
+ /**
+ * Add an entry to the maps.
+ * @param in inbound?
+ * @param service service level
+ * @param uom unit of measure
+ * @param depot depot
+ * @param dm day
+ * @param value value
+ */
+ void add(boolean in, ServiceLevel service, UOM uom, long depot, DateMidnight dm, double value) {
+ Map<ArxPredictionKey, TObjectDoubleMap<DateMidnight>> map = in ? inbound : outbound;
+ ArxPredictionKey key = new ArxPredictionKey(service, uom, depot);
+ TObjectDoubleMap<DateMidnight> m1 = map.get(key);
+ if (m1 == null) {
+ m1 = new TObjectDoubleHashMap<>();
+ map.put(key, m1);
+ }
+
+ m1.adjustOrPutValue(dm, value, value);
+ }
+ });
+ }
+
+ } catch (IOException | SQLException ex) {
+ LOG.error(ex.toString(), ex);
+ }
+ }
+ /**
+ * Save the ARX prediction records.
+ * @param predictions the predictions
+ */
+ public static void saveARXPredictions(List<ArxPrediction> predictions) {
+ try (DB db = DB.connect()) {
+ try (PreparedStatement pstmt = db.prepare(
+ "INSERT INTO arx_predictions VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
+ for (ArxPrediction p : predictions) {
+ DB.setParams(pstmt, p.hub, p.depot, p.dayRun, p.dayPredict, p.service.ordinal(), p.inbound, p.unit.ordinal(), p.value, Double.class);
+ pstmt.addBatch();
+ }
+ pstmt.executeBatch();
+ db.commit();
+ }
+ } catch (IOException | SQLException ex) {
+ ex.printStackTrace();
+ }
+ }
}
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/TimedValue.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/TimedValue.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/TimedValue.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package eu.advance.logistics.live.reporter.model;
+
+import org.joda.time.DateMidnight;
+
+/**
+ * A date and value record.
+ * @author karnokd, 2013.05.03.
+ */
+public class TimedValue {
+ /** The day. */
+ public final DateMidnight day;
+ /** The value. */
+ public final double value;
+ /**
+ * Constructor, sets the fields.
+ * @param day the day
+ * @param value the value
+ */
+ public TimedValue(DateMidnight day, double value) {
+ this.day = day;
+ this.value = value;
+ }
+ @Override
+ public String toString() {
+ return "{ " + day + ", " + value + " }";
+ }
+}
\ No newline at end of file
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxCoefficients.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxCoefficients.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxCoefficients.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.prediction.arx;
+
+import gnu.trove.list.TDoubleList;
+import gnu.trove.list.array.TDoubleArrayList;
+
+/**
+ * The learning result.
+ * @author karnokd, 2013.05.03.
+ */
+public class ArxCoefficients {
+ /** The model coefficients. */
+ public final TDoubleList modelCoefficients = new TDoubleArrayList();
+ /** The external coefficients. */
+ public final TDoubleList externalCoefficients = new TDoubleArrayList();
+ @Override
+ public String toString() {
+ return "{\r\n" + modelCoefficients + ",\r\n" + externalCoefficients + "\r\n}";
+ }
+}
\ No newline at end of file
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxConfig.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxConfig.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxConfig.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package eu.advance.logistics.live.reporter.prediction.arx;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.joda.time.DateMidnight;
+
+/**
+ * The configuration for the ARX learning.
+ * @author karnokd, 2013.05.03.
+ */
+public class ArxConfig {
+ /** The number of days to consider. */
+ public int modelOrder = 10;
+ /** Number of clusters. */
+ public int clusterCount = 1;
+ /** Maximum iteration. */
+ public int maxIterations = 10;
+ /** Length of validation horizon. */
+ public int horizon = 5;
+ /** Normalize values? */
+ public boolean normalize = true;
+ /** Percentage between train and test set. */
+ public double split = 0.75;
+ /** The set of holidays to ignore. */
+ public final Set<DateMidnight> holidays = new HashSet<>();
+ /** Ignore weekend data? */
+ public boolean ignoreWeekends = true;
+}
\ No newline at end of file
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxKMeans.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxKMeans.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxKMeans.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -0,0 +1,505 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package eu.advance.logistics.live.reporter.prediction.arx;
+
+import hu.akarnokd.reactive4java.base.Func2;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.google.common.collect.Lists;
+
+/**
+ * K-means algorithm for classifying and predicting multiple time series.
+ * @author gneu, 2012.02.10.
+ */
+public class ArxKMeans {
+ /** Number of clusters. */
+ protected int clusterCount;
+ /** Number of external factors. */
+ protected int m;
+ /** Number of AR parameters. */
+ protected int p;
+ /** Maximal number of iterations. */
+ protected int maxIter;
+ /** Whether to use normalization. */
+ protected boolean normalized;
+ /** Function to return the external effects at time {@code t}.*/
+ protected Func2<Integer, Integer, Double> u;
+ /** The set of K ARX Models. */
+ protected ArxModel[] allModels;
+ /** All data. */
+ protected double[][] allData;
+ /** Training data. */
+ protected double[][] trainData;
+ /** Test data. */
+ protected double[][] testData;
+ /** Training data estimates. */
+ protected double[][] trainDataEst;
+ /** Test data estimates. */
+ protected double[][] testDataEst;
+ /** L1 error on the train set. */
+ protected double l1train;
+ /** L1 error on the test set. */
+ protected double l1test;
+ /** L2 error on the train set. */
+ protected double l2train;
+ /** L2 error on the test set. */
+ protected double l2test;
+ /** Array indicating classes for each time series. */
+ protected int[] classes;
+ /** Sets of time series belonging to each cluster. (i.e, [cluster #] == series index */
+ protected List<Set<Integer>> classSet;
+ /** Number of time series. */
+ protected int numSeries;
+ /** Length of individual training time series. */
+ protected int numTraining;
+ /** Normalization coefficients for each time series. */
+ protected double[] trainMean;
+ /** Horizon for measuring accuracy. */
+ protected int horizon;
+ /** Where to split the provided data into train and test datasets. */
+ protected int split;
+ /** Skip the clustering and compute only an ARX model? */
+ protected boolean directARX = true;
+ /**
+ * Initialize.
+ * @param allData all available data
+ * @param split the split count, if between 1 and the number of columns in allData, 0 for no split
+ * @param p the model order
+ * @param m the number of external factors
+ * @param cluserCount the number of ARX models
+ * @param maxIter the maximal number of iterations for K-means
+ * @param normalized whether to use normalization
+ * @param horizon the prediction horizon
+ * @param u the function that represents external factors
+ */
+ public ArxKMeans(
+ double[][] allData,
+ int split,
+ int p,
+ int m,
+ int cluserCount,
+ int maxIter,
+ boolean normalized,
+ int horizon,
+ Func2<Integer, Integer, Double> u) {
+ this.allData = allData;
+ this.split = split;
+ this.p = p;
+ this.m = m;
+ this.clusterCount = cluserCount;
+ this.maxIter = maxIter;
+ this.normalized = normalized;
+ this.horizon = horizon;
+ this.u = u;
+ this.numSeries = allData.length;
+
+ if (split > 0) {
+ int len = allData[0].length;
+ trainData = new double[numSeries][split];
+ testData = new double[numSeries][len - split];
+ for (int n = 0; n < numSeries; n++) {
+ System.arraycopy(allData[n], 0, trainData[n], 0, split);
+ System.arraycopy(allData[n], split, testData[n], 0, allData[0].length - split);
+ }
+ } else {
+ trainData = allData.clone();
+ testData = allData.clone();
+ }
+
+ this.numTraining = trainData[0].length;
+ this.classes = new int[numSeries];
+ this.trainMean = new double[numSeries];
+ this.trainDataEst = new double[numSeries][];
+ this.testDataEst = new double[numSeries][];
+ this.classSet = Lists.newArrayList();;
+ for (int k = 0; k < cluserCount; k++) {
+ classSet.add(new HashSet<Integer>());
+ }
+ }
+
+
+ /**
+ * Set all data.
+ * @param allData the data to set
+ */
+ public void setAllData(double[][] allData) {
+ int len = allData[0].length;
+ trainData = new double[numSeries][split];
+ testData = new double[numSeries][len - split];
+ for (int n = 0; n < numSeries; n++) {
+ System.arraycopy(allData[n], 0, trainData[n], 0, split);
+ System.arraycopy(allData[n], split, testData[n], 0, len - split);
+ }
+ this.allData = allData.clone();
+ }
+
+ /**
+ * Set train-test split.
+ * @param split where to split the data in two
+ */
+ public void setSplit(int split) {
+ this.split = split;
+ }
+
+
+
+// /**
+// * Set the function returning external factors.
+// * @param u the function to set
+// */
+// public void setU(Func2<Integer, Integer, Double> u) {
+// this.u = u;
+// for (int k = 0; k < clusterCount; k++) {
+// allModels[k].u = u;
+// }
+// }
+
+
+ /**
+ * Set the training data.
+ * @param trainData the training data to set
+ */
+ public void setTrainData(double[][] trainData) {
+ this.trainData = trainData.clone();
+ }
+
+ /**
+ * Set the test data.
+ * @param testData the test data
+ */
+ public void setTestData(double[][] testData) {
+ this.testData = testData.clone();
+ }
+
+ /** @return the predictions for the test window */
+ public double[][] getPredictions() {
+ return testDataEst;
+ }
+
+ /** @return the L1 error of the predictions on the test window */
+ public double getL1TestError() {
+ return l1test;
+ }
+
+ /** @return the L2 error of the predictions on the test window */
+ public double getL2TestError() {
+ return l2test;
+ }
+
+ /** @return the L1 error of the predictions on the train window*/
+ public double getL1TrainError() {
+ return l1train;
+ }
+
+ /** @return the L2 error of the predictions on the train window*/
+ public double getL2TrainError() {
+ return l2train;
+ }
+ /**
+ * Returns the average L2 error between two sets of time series.
+ * @param data the original set of time series
+ * @param dataEst the estimated set of time series
+ * @return the l2 error
+ */
+ public static double l2Error(double[][] data, double[][] dataEst) {
+ double err = 0.0;
+ int nonzeroes = 0;
+ for (int n = 0; n < data.length; n++) {
+ for (int t = 0; t < data[n].length; t++) {
+ double d = data[n][t];
+ double dE = dataEst[n][t];
+ if (d > 0.0 && dE != -1.0) {
+ err += (d - dE) * (d - dE);
+ nonzeroes++;
+ }
+ }
+ }
+ if (nonzeroes > 0) {
+ return err / nonzeroes;
+ }
+ return 0.0;
+ }
+
+ /**
+ * Returns the average L2 error between two time series.
+ * @param data the original time series
+ * @param dataEst the estimated time series
+ * @return the average L2 error
+ */
+ protected static double l2Error(double[] data, double[] dataEst) {
+ double err = 0.0;
+ int nonzeroes = 0;
+ for (int t = 0; t < data.length; t++) {
+ double d = data[t];
+ double dE = dataEst[t];
+ if (d > 0.0 && dE != -1.0) {
+ err += (d - dE) * (d - dE);
+ nonzeroes++;
+ }
+ }
+ if (nonzeroes > 0) {
+ return err / nonzeroes;
+ }
+ return 0.0;
+ }
+
+ /**
+ * Returns the average L1 error between two sets of time series.
+ * @param data the original set of time series
+ * @param dataEst the estimated set of time series
+ * @return the average L1 error
+ */
+ public static double l1Error(double[][] data, double[][] dataEst) {
+ double err = 0.0;
+ int nonzeroes = 0;
+ for (int n = 0; n < data.length; n++) {
+ for (int t = 0; t < data[n].length; t++) {
+ double d = data[n][t];
+ double dE = dataEst[n][t];
+ if (d > 0.0 && dE != -1.0) {
+ err += Math.abs(d - dE);
+ nonzeroes++;
+ }
+ }
+ }
+ if (nonzeroes > 0) {
+ return err / nonzeroes;
+ }
+ return 0.0;
+ }
+
+ /**
+ * Returns the average L1 error between two time series.
+ * @param data the original time series
+ * @param dataEst the estimated time series
+ * @return the average L2 error
+ */
+ protected static double l1Error(double[] data, double[] dataEst) {
+ double err = 0.0;
+ int nonzeroes = 0;
+ for (int t = 0; t < data.length; t++) {
+ double d = data[t];
+ double dE = dataEst[t];
+ if (d > 0.0 && dE != -1.0) {
+ err += Math.abs(d - dE);
+ nonzeroes++;
+ }
+ }
+ if (nonzeroes > 0) {
+ return err / nonzeroes;
+ }
+ return 0.0;
+ }
+
+ /**
+ * Classifies time series into one of K clusters.
+ * @return if the clusers have changed
+ */
+ protected boolean classify() {
+ boolean changed = false;
+ int bestK = 0;
+ double[] trainEst = null;
+ for (int n = 0; n < numSeries; n++) {
+ double bestErr = Double.POSITIVE_INFINITY;
+ for (int k = 0; k < clusterCount; k++) {
+ // this could be slightly improved if we also pass some initializing values to the function
+ // though the expected improvement is negligible if p<<T, which should be the case
+ double[] dummy = allModels[k].estimate(trainData[n], null, trainMean[n]);
+ double err = l2Error(trainData[n], dummy);
+ //System.out.println(k + ": " + err);
+ if (err <= bestErr) {
+ bestK = k;
+ bestErr = err;
+ trainEst = dummy.clone();
+ }
+ }
+
+ if (classes[n] != bestK) {
+ classSet.get(classes[n]).remove(n);
+ classes[n] = bestK;
+ changed = true;
+ }
+
+ classSet.get(bestK).add(n);
+ trainDataEst[n] = trainEst;
+ }
+ //for (int k=0; k<K; k++)
+ // System.out.print(classSet[k].size() + " ");
+ //System.out.println();
+ return changed;
+ }
+
+ /**
+ * Updates parameters belonging to each cluster.
+ */
+ protected void update() {
+ for (int k = 0; k < clusterCount; k++) {
+ //System.out.println(k + ": " + Arrays.toString(allModels[k].uCoeffs));
+ // concatenate training time series
+ if (classSet.get(k).isEmpty()) {
+ //int index = (int) Math.floor(Math.random()*N);
+ //allModels[k] = new ArxModel(trainData[index], p, m, u);
+ //allModels[k].solveMSE();
+ continue;
+ }
+ double[] longTrainingSeries = new double[classSet.get(k).size() * numTraining];
+ double[][] trainingSet = new double[classSet.get(k).size()][numTraining];
+ int h = 0;
+ for (int n : classSet.get(k)) {
+ for (int t = 0; t < numTraining; t++) {
+ double tt = trainData[n][t] / trainMean[n];
+ trainingSet[h][t] = tt;
+ longTrainingSeries[h * numTraining + t] = tt;
+ }
+ h++;
+ }
+ // solve for new parameter values
+ //allModels[k].setNumSeries(classSet[k].size());
+ //allModels[k].setObservations(longTrainingSeries);
+ //allModels[k].solveMSE(); // simple and dirty
+ allModels[k].solveMSE(trainingSet); // somewhat more difficult, but overall superior performance
+ //System.out.println(k + ": " + Arrays.toString(allModels[k].arCoeffs));
+ }
+ }
+
+ /**
+ * Runs K-means clustering.
+ */
+ public void solve() {
+ // normalizes data by the mean of the training data if requested
+ if (normalized) {
+ for (int n = 0; n < numSeries; n++) {
+ double trainM = 0.0;
+ for (int t = 0; t < numTraining; t++) {
+ trainM += trainData[n][t] / numTraining;
+ }
+ trainMean[n] = trainM > 0 ? trainM : 1.0;
+ }
+ } else {
+ for (int n = 0; n < numSeries; n++) {
+ trainMean[n] = 1.0;
+ }
+ }
+
+ // initialize if needed
+ if (allModels == null) {
+ if (clusterCount >= numSeries) {
+ clusterCount = numSeries;
+ }
+ allModels = new ArxModel[clusterCount];
+ for (int k = 0; k < clusterCount; k++) {
+ int index = (int) Math.floor(Math.random() * numSeries);
+ if (clusterCount >= numSeries) {
+ index = k;
+ }
+ allModels[k] = new ArxModel(trainData[index], p, m, u);
+ allModels[k].solveMSE();
+ classSet.get(k).add(index);
+ classes[index] = k;
+ }
+ }
+
+ if (!directARX) {
+ boolean changed = true;
+
+ for (int iter = 0; (iter < maxIter) && (changed); iter++) {
+ changed = clusterCount < numSeries ? classify() : false;
+
+ update();
+ }
+ }
+
+ predict(0);
+ }
+ /**
+ * Run the prediction.
+ * @param lookahead the lookahead days
+ * @return the estimated data
+ */
+ public double[][] predict(int lookahead) {
+ // compute estimates for the test section of each time series
+ for (int n = 0; n < numSeries; n++) {
+ int k = classes[n];
+ int subRangeStart = numTraining - p - horizon;
+ int subRangeSize = numTraining;
+// double[] initValues = Arrays.copyOfRange(trainData[n], subRangeStart, subRangeSize);
+ // fix if there isn't enough data to cover p + horizon
+ double[] initValues = new double[p + horizon];
+ for (int i = subRangeStart; i < subRangeSize; i++) {
+ if (i >= 0) {
+ initValues[i - subRangeStart] = trainData[n][i];
+ }
+ }
+ double[][] estimates = allModels[k].estimate(testData[n], initValues, trainMean[n], horizon, split);
+ testDataEst[n] = estimates[lookahead];
+
+ //double[] initValues = Arrays.copyOfRange(trainData[n], T-p, T);
+ //testDataEst[n]= allModels[k].estimate(testData[n], initValues, trainMean[n]);
+ trainDataEst[n] = allModels[k].estimate(trainData[n], null, trainMean[n]);
+ }
+
+ l2train = l2Error(trainData, trainDataEst);
+ l1train = l1Error(trainData, trainDataEst);
+ l2test = l2Error(testData, testDataEst);
+ l1test = l1Error(testData, testDataEst);
+
+ return testDataEst;
+ }
+ /** @return the models. */
+ public List<ArxModel> models() {
+ return Arrays.asList(allModels);
+ }
+ /**
+ * @return the learned class index for each row of the input data
+ */
+ public int[] getClasses() {
+ return classes.clone();
+ }
+ /**
+ * Returns the set of input row indexes for the given cluser index.
+ * @param clusterIndex the cluster index
+ * @return the set of row indexes
+ */
+ public Set<Integer> getTimeseriesRowsForCluster(int clusterIndex) {
+ return classSet.get(clusterIndex);
+ }
+ /**
+ * Split data into trainset and test set.
+ * @param split where to split the data in two
+ * */
+ public void split(int split) {
+ int len = allData[0].length;
+ split = Math.min(len, split);
+ trainData = new double[numSeries][split];
+ testData = new double[numSeries][len - split];
+ for (int n = 0; n < numSeries; n++) {
+ System.arraycopy(allData[n], 0, trainData[n], 0, split);
+ System.arraycopy(allData[n], split, testData[n], 0, len - split);
+ }
+ this.split = split;
+ }
+
+}
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxLearner.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxLearner.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxLearner.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package eu.advance.logistics.live.reporter.prediction.arx;
+
+import eu.advance.logistics.live.reporter.model.TimedValue;
+import hu.akarnokd.reactive4java.base.Func2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.joda.time.DateMidnight;
+
+/**
+ * The ARX learner routine.
+ * @author karnokd, 2013.05.03.
+ */
+public final class ArxLearner {
+ /** Utility class. */
+ private ArxLearner() { }
+ /**
+ * Learn the given time series.
+ * @param timeSeries the time value group sequence
+ * @param config the learning configuration
+ * @return the learnt model coefficients
+ */
+ public static ArxCoefficients learn(Iterable<? extends TimedValue> timeSeries, ArxConfig config) {
+ final ArxTimedValueAggregator series = new ArxTimedValueAggregator(
+ config.holidays, config.ignoreWeekends);
+ series.addAll(timeSeries);
+ series.build();
+ series.addForecastDays(1);
+
+ int minSamples = (int)Math.ceil((1 + config.split) * config.modelOrder);
+ int m = 5;
+ if (series.dayOfWeek.size() >= minSamples) {
+ ArxKMeans kMeans = new ArxKMeans(
+ series.timeSeriesMatrix,
+ (int)(series.dayOfWeek.size() * config.split),
+ config.modelOrder,
+ m,
+ 1, // model count
+ config.maxIterations,
+ config.normalize,
+ config.horizon,
+ new Func2<Integer, Integer, Double>() {
+ @Override
+ public Double invoke(Integer param1, Integer param2) {
+ return series.dayOfWeek.get(param1) == param2.intValue() ? 1d : 0d;
+ }
+ }
+ );
+ kMeans.solve();
+ ArxCoefficients result = new ArxCoefficients();
+ for (ArxModel md : kMeans.models()) {
+ result.modelCoefficients.addAll(md.getArCoefficients());
+ result.externalCoefficients.addAll(md.getUCoefficients());
+ }
+ return result;
+ }
+ return new ArxCoefficients();
+ }
+ /**
+ * Calculate a prediction by using the given coefficients, time series
+ * and horizon length.
+ * @param config the learning configuration
+ * @param coeffs the coefficients
+ * @param timeSeries the time series
+ * @param horizon the horizon after the time series ends
+ * @return the predicted values paired by the day and value
+ */
+ public static List<TimedValue> predict(
+ ArxConfig config,
+ ArxCoefficients coeffs,
+ Iterable<? extends TimedValue> timeSeries,
+ int horizon) {
+ final ArxTimedValueAggregator series = new ArxTimedValueAggregator(config.holidays, config.ignoreWeekends);
+ series.addAll(timeSeries);
+ series.build();
+
+ // extend day of week info by the horizon
+ List<DateMidnight> horizonDays = series.addForecastDays(horizon);
+
+ // create arx model
+ ArxModel arxModel = new ArxModel(
+ new double[0],
+ coeffs.modelCoefficients.size(),
+ coeffs.externalCoefficients.size(),
+ new Func2<Integer, Integer, Double>() {
+ @Override
+ public Double invoke(Integer param1, Integer param2) {
+ return series.dayOfWeek.get(param1) == param2.intValue() ? 1d : 0d;
+ }
+ });
+
+ // setup coefficients
+ int i = 0;
+ for (double ac : coeffs.modelCoefficients.toArray()) {
+ arxModel.setArCoefficient(i, ac);
+ i++;
+ }
+ i = 0;
+ for (double uc : coeffs.externalCoefficients.toArray()) {
+ arxModel.setUCoefficient(i, uc);
+ i++;
+ }
+
+ // calculte forecasts
+ double[] values = arxModel.forecastAll(series.timeSeriesMatrix[0], horizon);
+
+ List<TimedValue> result = new ArrayList<>();
+ i = 0;
+ for (double v : values) {
+ result.add(new TimedValue(horizonDays.get(i), v));
+ i++;
+ }
+ return result;
+ }
+}
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxModel.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxModel.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxModel.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -0,0 +1,422 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package eu.advance.logistics.live.reporter.prediction.arx;
+
+import hu.akarnokd.reactive4java.base.Func2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.apache.commons.math3.linear.MatrixUtils;
+import org.apache.commons.math3.linear.RealMatrix;
+import org.apache.commons.math3.linear.SingularValueDecomposition;
+
+import eu.advance.logistics.flow.engine.block.prediction.ObservationModel;
+
+/**
+ * Autoregressive model with exogenous effects.
+ * @author karnokd, 2012.02.01.
+ */
+public class ArxModel extends ObservationModel {
+ /** The external factor count. */
+ protected int m;
+ /** Function to return the external effects at time {@code t}. */
+ protected Func2<Integer, Integer, Double> u;
+ /** The order of the Ar model. */
+ protected int p;
+ /** The autoregression part coefficients. */
+ protected double[] arCoeffs;
+ /** The external factors coefficeints. */
+ protected double[] uCoeffs;
+ /** The number of time series in the training set. */
+ protected int numSeries;
+ /** The set of time series used for training. */
+ protected double[][] trainingSet;
+ /**
+ * Initialize the model.
+ * @param x the array of observations [n]
+ * @param p the model order
+ * @param m the number of additional effects
+ * @param u Function to return the external effects at time {@code t}
+ */
+ public ArxModel(
+ double[] x,
+ int p,
+ int m,
+ Func2<Integer, Integer, Double> u) {
+ super(x);
+ trainingSet = new double[1][];
+ trainingSet[0] = Arrays.copyOf(x, x.length);
+ this.p = p;
+ this.m = m;
+ this.u = u;
+ this.numSeries = 1;
+ arCoeffs = new double[p];
+ uCoeffs = new double[m];
+ }
+
+ /**
+ * Solve the model and find the coefficients by using the Mean Square Error estimation algorithm.
+ */
+ public void solveMSE() {
+ int n = this.observations.length;
+
+ if (n < p) {
+ Arrays.fill(arCoeffs, 0.0);
+ Arrays.fill(uCoeffs, 0.0);
+ return;
+ }
+
+ RealMatrix am = MatrixUtils.createRealMatrix(n - p, p + m);
+ RealMatrix atm = MatrixUtils.createRealMatrix(p + m, n - p);
+
+ double[] x = this.observations;
+
+ for (int i = 0; i < n - p; i++) {
+ for (int j = 0; j < p; j++) {
+ double xt = x[i - 1 + p - j];
+ am.setEntry(i, j, xt);
+ atm.setEntry(j, i, xt);
+ }
+ for (int j = p; j < p + m; j++) {
+ double ut = u.invoke(i + p, j - p); // check if % indeed works
+ am.setEntry(i, j, ut);
+ atm.setEntry(j, i, ut);
+ }
+ }
+
+ // theta = pinv(a'a) * a' * x
+
+ RealMatrix atmam = atm.multiply(am);
+
+ RealMatrix atmamInv = new SingularValueDecomposition(atmam).getSolver().getInverse();
+
+ RealMatrix atmamInvAtm = atmamInv.multiply(atm);
+
+ RealMatrix xv = MatrixUtils.createColumnRealMatrix(Arrays.copyOfRange(x, p, n));
+
+ RealMatrix theta = atmamInvAtm.multiply(xv);
+
+ double[] thetav = theta.getColumn(0);
+
+ arCoeffs = new double[p];
+ uCoeffs = new double[m];
+
+ System.arraycopy(thetav, 0, arCoeffs, 0, p);
+ System.arraycopy(thetav, p, uCoeffs, 0, m);
+ }
+
+ /**
+ * Solve the model and find the coefficients by using the Mean Square Error estimation algorithm.
+ * @param trainData the training data.
+ */
+ public void solveMSE(double[][] trainData) {
+ int numGroups = trainData.length;
+ int numTimes = trainData[0].length;
+
+ double[][] at = new double[p + m][numGroups * numTimes];
+ ArrayList<Double> xList = new ArrayList<Double>();
+ int curr = 0;
+ for (int n = 0; n < numGroups; n++) {
+ ArrayList<Double> yList = new ArrayList<Double>();
+ ArrayList<Integer> tList = new ArrayList<Integer>();
+ for (int t = 0; t < numTimes; t++) {
+ double entry = trainData[n][t];
+ if (entry > 0.0) {
+ yList.add(entry);
+ if (yList.size() > p) {
+ xList.add(entry);
+ tList.add(t);
+ }
+ }
+ }
+
+ Object[] yv = yList.toArray();
+ Object[] tv = tList.toArray();
+
+ int yl = yv.length;
+
+ for (int i = 0; i < yl - p; i++) {
+ curr++;
+ for (int j = 0; j < p; j++) {
+ double yt = (Double)yv[i + p - 1 - j];
+ at[j][curr] = yt;
+ }
+ for (int j = p; j < p + m; j++) {
+ double ut = u.invoke(((Integer)tv[i]), j - p);
+ at[j][curr] = ut;
+ }
+ }
+ }
+
+ if (curr == 0) {
+ arCoeffs = new double[p];
+ uCoeffs = new double[m];
+ Arrays.fill(arCoeffs, 0.0);
+ Arrays.fill(uCoeffs, 0.0);
+ return;
+ }
+
+ double[][] atmPrep = new double[m + p][curr];
+ for (int n = 0; n < (m + p); n++) {
+ atmPrep[n] = Arrays.copyOf(at[n], curr);
+ }
+
+ RealMatrix atm = MatrixUtils.createRealMatrix(atmPrep);
+ RealMatrix am = atm.transpose();
+
+ // theta = pinv(a'a) * a' * x
+
+ RealMatrix atmam = atm.multiply(am);
+
+ RealMatrix atmamInv = new SingularValueDecomposition(atmam).getSolver().getInverse();
+
+ RealMatrix atmamInvAtm = atmamInv.multiply(atm);
+
+ RealMatrix xv = MatrixUtils.createRealMatrix(xList.size(), 1);
+ for (int i = 0; i < xList.size(); i++) {
+ xv.setEntry(i, 0, xList.get(i));
+ }
+
+ RealMatrix theta = atmamInvAtm.multiply(xv);
+
+ double[] thetav = theta.getColumn(0);
+
+ arCoeffs = new double[p];
+ uCoeffs = new double[m];
+
+ System.arraycopy(thetav, 0, arCoeffs, 0, p);
+ System.arraycopy(thetav, p, uCoeffs, 0, m);
+ }
+ /**
+ * @return the autoregression's coefficients [p]
+ */
+ public double[] getArCoefficients() {
+ return arCoeffs.clone();
+ }
+ /** @return the external effect's coefficients [m]. */
+ public double[] getUCoefficients() {
+ return uCoeffs.clone();
+ }
+ /** @return the order of the autoregressive model. */
+ public int getP() {
+ return p;
+ }
+ /** @return the external effects count. */
+ public int getM() {
+ return m;
+ }
+ /**
+ * Compute the forecast for the next h time values.
+ * @param h the time horizon, h > 0
+ * @return the forecast values [h]
+ */
+ public double[] forecastAll(int h) {
+ return forecastAll(this.observations, h);
+ }
+ /**
+ * Compute the forecast for the next h time values.
+ * @param x the samples
+ * @param h the time horizon, h > 0
+ * @return the forecast values [h]
+ */
+ public double[] forecastAll(double[] x, int h) {
+ double[] xf = new double[h];
+
+ int n = x.length;
+
+ for (int t = n; t < n + h; t++) {
+ double sum = 0d;
+ for (int i = 0; i < p; i++) {
+
+ double o = 0d;
+ if (t - i - 1 < n) {
+ o = x[t - i - 1];
+ } else {
+ o = xf[t - n - 1 - i];
+ }
+
+ sum += arCoeffs[i] * o;
+ }
+ double sumu = 0d;
+ for (int i = 0; i < m; i++) {
+ sumu += uCoeffs[i] * u.invoke(t, i);
+ }
+ xf[t - n] = sum + sumu;
+ }
+
+ return xf;
+ }
+
+ /**
+ * Estimates data based on parameters computed for normalized data.
+ * @param data the time series to estimate
+ * @param initValues the initial values
+ * @param scale the scale of the unnormalized time series
+ * @param horizon the lookahead horizon
+ * @param offset ?
+ * @return the estimated values for each group
+ */
+ public double[][] estimate(
+ double[] data,
+ double[] initValues, double scale, int horizon, int offset) {
+ int numTime = data.length;
+ int iT = initValues.length;
+
+ double[] fullData = new double[numTime + iT];
+ System.arraycopy(initValues, 0, fullData, 0, iT);
+ System.arraycopy(data, 0, fullData, iT, numTime);
+
+ ArrayList<Integer> tList = new ArrayList<Integer>();
+
+ for (int t = 0; t < numTime; t++) {
+ if (data[t] > 0.0) {
+ tList.add(t);
+ }
+ }
+
+ int filteredTimes = tList.size();
+
+ double[][] predictedData = new double[horizon][numTime];
+ double[][] initValuesEst = new double[horizon][horizon];
+
+ for (int h = 0; h < horizon; h++) {
+ for (int j = h; j < horizon; j++) {
+ double initPred = 0.0;
+ int hh = Math.min(h, p);
+ for (int i = hh; i < p; i++) {
+ initPred += initValues[p + j - i - 1] * arCoeffs[i];
+ }
+ for (int i = 0; i < hh; i++) {
+ initPred += initValuesEst[j - i - 1][i] * arCoeffs[i];
+ }
+ initValuesEst[j][h] = initPred;
+ }
+ }
+
+ for (int h = 0; h < horizon; h++) {
+ int ph = Math.min(p + h, filteredTimes);
+ for (int t = 0; t < ph; t++) {
+ double prediction = 0.0;
+ int hh = Math.min(h, p);
+ for (int i = hh; i < p; i++) {
+ prediction +=
+ (t - i - 1 < 0)
+ ? initValues[p + horizon + t - i - 1] * arCoeffs[i]
+ : data[tList.get(t - i - 1)] * arCoeffs[i];
+ }
+ for (int i = 0; i < hh; i++) {
+ prediction += (t - i - 1 < 0)
+ ? initValuesEst[horizon + t - i - 1][i] * arCoeffs[i]
+ : predictedData[i][tList.get(t - i - 1)] * arCoeffs[i];
+ }
+ for (int i = 0; i < m; i++) {
+ prediction += scale * uCoeffs[i] * u.invoke(tList.get(t) + offset, i);
+ }
+ predictedData[h][tList.get(t)] = prediction;
+ }
+ for (int t = ph; t < filteredTimes; t++) {
+ double prediction = 0.0;
+ int hh = Math.min(h, p);
+ for (int i = hh; i < p; i++) {
+ prediction += data[tList.get(t - i - 1)] * arCoeffs[i];
+ }
+ for (int i = 0; i < hh; i++) {
+ prediction += predictedData[i][tList.get(t - i - 1)] * arCoeffs[i];
+ }
+ for (int i = 0; i < m; i++) {
+ prediction += scale * uCoeffs[i] * u.invoke(tList.get(t) + offset, i);
+ }
+ predictedData[h][tList.get(t)] = prediction;
+ }
+ }
+ return predictedData;
+ }
+
+ /**
+ * Estimates data based on parameters computed for normalized data.
+ * @param data the time series to estimate
+ * @param initValues the initial values
+ * @param scale the scale of the unnormalized time series
+ * @return the estimates
+ */
+ public double[] estimate(double[] data, double[] initValues, double scale) {
+ int numTimes = data.length;
+ double[] predictedData = new double[numTimes];
+ int pp = Math.min(p, numTimes);
+ if (initValues == null) {
+ for (int t = 0; t < pp; t++) {
+ predictedData[t] = -1.0;
+ }
+ } else {
+ for (int t = 0; t < pp; t++) {
+ double prediction = 0.0;
+ for (int i = 0; i < p; i++) {
+ prediction +=
+ (t - i - 1 < 0)
+ ? initValues[p + t - i - 1] * arCoeffs[i]
+ : data[t - i - 1] * arCoeffs[i];
+ }
+ for (int i = 0; i < m; i++) {
+ prediction += scale * uCoeffs[i] * u.invoke(t, i);
+ }
+ predictedData[t] = prediction;
+ }
+ }
+ for (int t = pp; t < numTimes; t++) {
+ double prediction = 0.0;
+ for (int i = 0; i < p; i++) {
+ prediction += data[t - i - 1] * arCoeffs[i];
+ }
+ for (int i = 0; i < m; i++) {
+ prediction += scale * uCoeffs[i] * u.invoke(t, i);
+ }
+ predictedData[t] = prediction;
+ }
+ return predictedData;
+ }
+
+ @Override
+ public int paramCount() {
+ return m + p;
+ }
+ @Override
+ public double logLikelihood() {
+ throw new UnsupportedOperationException();
+ }
+ /**
+ * Sets the autoregression model coefficient.
+ * @param index the index < p
+ * @param value the value
+ */
+ public void setArCoefficient(int index, double value) {
+ arCoeffs[index] = value;
+ }
+ /**
+ * Sets the autoregression exogenous model coefficient.
+ * @param index the index, < m
+ * @param value the value
+ */
+ public void setUCoefficient(int index, double value) {
+ uCoeffs[index] = value;
+ }
+}
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxTimedValueAggregator.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxTimedValueAggregator.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/prediction/arx/ArxTimedValueAggregator.java 2013-10-07 07:39:21 UTC (rev 326)
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.prediction.arx;
+
+import eu.advance.logistics.live.reporter.model.TimedValue;
+import gnu.trove.list.TIntList;
+import gnu.trove.list.array.TIntArrayList;
+import gnu.trove.map.TObjectDoubleMap;
+import gnu.trove.map.hash.TObjectDoubleHashMap;
+
+import java.util.ArrayList;
+import java.util.List;
+import jav...
[truncated message content] |
|
From: <aka...@us...> - 2013-10-04 12:16:05
|
Revision: 325
http://sourceforge.net/p/advance-project/code/325
Author: akarnokd
Date: 2013-10-04 12:16:01 +0000 (Fri, 04 Oct 2013)
Log Message:
-----------
Updated demo data generator.
Modified Paths:
--------------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/VehicleAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/WarehouseAgent.java
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java 2013-10-03 14:03:54 UTC (rev 324)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java 2013-10-04 12:16:01 UTC (rev 325)
@@ -36,6 +36,8 @@
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.LocalTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
@@ -56,6 +58,8 @@
*
*/
public class ConsignmentCreator {
+ /** The logger. */
+ private static final Logger LOG = LoggerFactory.getLogger(ConsignmentCreator.class);
/** The database connection. */
DB db;
/** Field. */
@@ -227,6 +231,9 @@
}
env.consignmentsEnd();
env.eventLoop();
+ if (env.hasUnporcessed()) {
+ LOG.error("Items remained!");
+ }
db.commit();
}
/**
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java 2013-10-03 14:03:54 UTC (rev 324)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java 2013-10-04 12:16:01 UTC (rev 325)
@@ -36,12 +36,17 @@
import java.awt.Point;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
+import java.util.Set;
import org.joda.time.DateTime;
+import org.joda.time.Seconds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,6 +69,18 @@
private final TLongObjectMap<HubAgent> hubAgents = new TLongObjectHashMap<>();
/** The event sequence. */
private final PriorityQueue<Pair<DateTime, Action0>> events = new PriorityQueue<>(256, new CompareFirst());
+ /** Time to load one item. */
+ public static final int LOAD_SECONDS = 10;
+ /** Time to unload one item. */
+ public static final int UNLOAD_SECONDS = 10;
+ /** Max wait in seconds in case of an empty hub/depot. */
+ public static final int MAX_LOAD_WAIT = 60 * 60;
+ /** The idle wait in seconds. */
+ public static final int IDLE_WAIT = 5 * 60;
+ /** Indication that no further consignments will be created. */
+ public boolean endOfConsignments;
+ /** Consignments not introduced yet. */
+ public final Set<ConsItem> pendingConsignments = new HashSet<>();
/**
* Constructor.
* @param db the database
@@ -120,11 +137,11 @@
WarehouseAgent wa = new WarehouseAgent();
wa.hub = wh.hub;
- wa.warehouse = wh.warehouse;
+ wa.id = wh.warehouse;
ha.warehouses.add(wa);
- warehouseAgents.put(wa.warehouse, wa);
+ warehouseAgents.put(wa.id, wa);
}
}
/**
@@ -163,7 +180,6 @@
VehicleAgent va = new VehicleAgent();
va.id = v.vehicleId;
- va.depotId = v.depot;
va.depot = da;
va.capacity = v.capacity;
@@ -285,14 +301,14 @@
ItemEventType iet = onto ? ItemEventType.SOURCE_SCAN : ItemEventType.DESTINATION_SCAN;
event(item.id, item.consignmentId, when, iet);
try {
- ScanType st = onto ? ScanType.SOURCE : ScanType.DESTINATION;
+ int st = (onto ? ScanType.SOURCE : ScanType.DESTINATION).ordinal();
db.update("INSERT IGNORE INTO scans VALUES (?, ?, ?, ?, ?, ?)",
- item.consignmentId, item.id, st.ordinal(),
- va.depot, when, va.id
+ item.consignmentId, item.id, st,
+ va.depot.id, when, va.id
);
db.update("INSERT IGNORE INTO scans_history VALUES (?, ?, ?, ?, ?, ?)",
- item.consignmentId, item.id, st.ordinal(),
- va.depot, when, va.id
+ item.consignmentId, item.id, st,
+ va.depot.id, when, va.id
);
} catch (SQLException ex) {
throw new RuntimeException(ex);
@@ -312,7 +328,7 @@
db.update("UPDATE consignments_history SET declared = ? WHERE id = ? ", when, ci.consignmentId);
- db.update("INSERT INGORE INTO vehicle_declared VALUES (?, ?, ?)", va.id, when, ci.externalId);
+ db.update("INSERT IGNORE INTO vehicle_declared VALUES (?, ?, ?)", va.id, when, ci.externalId);
}
} catch (SQLException ex) {
throw new RuntimeException(ex);
@@ -330,10 +346,10 @@
event(ci.id, ci.consignmentId, when, enter ? ItemEventType.HUB_ARRIVE : ItemEventType.HUB_LEAVE);
}
if (enter) {
- va.sessionId = va.hub + "_" + when.toString("yyyyMMdd'_'HHmmss") + "_" + va.id;
+ va.sessionId = va.hub.id + "_" + when.toString("yyyyMMdd'_'HHmmss") + "_" + va.id;
db.update("INSERT IGNORE INTO vehicle_sessions VALUES (?, ?, ?, ?, ?)",
- va.sessionId, va.id, va.hub, when, DateTime.class);
+ va.sessionId, va.id, va.hub.id, when, DateTime.class);
} else {
db.update("UPDATE vehicle_sessions SET leave_timestamp = ? WHERE session_id = ? ", when, va.sessionId);
}
@@ -351,18 +367,19 @@
public void warehouseEnterLeave(VehicleAgent va, DateTime when, boolean enter) {
try {
long scanId = db.insertAuto("INSERT INTO vehicle_scan (session_id, scan_timestamp, warehouse, entry) VALUES (?, ?, ?, ?)",
- va.sessionId, when, va.warehouse, enter);
+ va.sessionId, when, va.warehouse.id, enter);
for (ConsItem ci : va.contents) {
event(ci.id, ci.consignmentId, when, enter ? ItemEventType.WAREHOUSE_ENTER : ItemEventType.WAREHOUSE_LEAVE);
+ int st = (enter ? ScanType.WAREHOUSE_ENTER : ScanType.WAREHOUSE_LEAVE).ordinal();
db.update("INSERT IGNORE INTO scans VALUES (?, ?, ?, ?, ?, ?)",
- ci.consignmentId, ci.id, enter ? ScanType.WAREHOUSE_ENTER : ScanType.WAREHOUSE_LEAVE,
- va.hub + " " + va.warehouse, when, va.id);
+ ci.consignmentId, ci.id, st,
+ va.hub.id + " " + va.warehouse.id, when, va.id);
db.update("INSERT IGNORE INTO scans_history VALUES (?, ?, ?, ?, ?, ?)",
- ci.consignmentId, ci.id, enter ? ScanType.WAREHOUSE_ENTER : ScanType.WAREHOUSE_LEAVE,
- va.hub + " " + va.warehouse, when, va.id);
+ ci.consignmentId, ci.id, st,
+ va.hub.id + " " + va.warehouse.id, when, va.id);
db.update("INSERT IGNORE INTO vehicle_items VALUES (?, ?)", scanId, ci.externalId);
}
@@ -382,13 +399,14 @@
try {
event(ci.id, ci.consignmentId, when, onto ? ItemEventType.SCAN_ON : ItemEventType.SCAN_OFF);
+ int st = (onto ? ScanType.WAREHOUSE_MANUAL_LOAD : ScanType.WAREHOUSE_MANUAL_UNLOAD).ordinal();
db.update("INSERT IGNORE INTO scans VALUES (?, ?, ?, ?, ?, ?)",
- ci.consignmentId, ci.id, onto ? ScanType.WAREHOUSE_MANUAL_LOAD : ScanType.WAREHOUSE_MANUAL_UNLOAD,
- va.hub + " " + va.warehouse, when, va.id);
+ ci.consignmentId, ci.id, st,
+ va.hub.id + " " + va.warehouse.id, when, va.id);
db.update("INSERT IGNORE INTO scans_history VALUES (?, ?, ?, ?, ?, ?)",
- ci.consignmentId, ci.id, onto ? ScanType.WAREHOUSE_MANUAL_LOAD : ScanType.WAREHOUSE_MANUAL_UNLOAD,
- va.hub + " " + va.warehouse, when, va.id);
+ ci.consignmentId, ci.id, st,
+ va.hub.id + " " + va.warehouse.id, when, va.id);
} catch (SQLException ex) {
throw new RuntimeException(ex);
@@ -400,21 +418,21 @@
* @param item the item
*/
public void newItem(final ConsItem item) {
- DepotAgent da = depotAgents.get(item.consignment.collectionDepot);
- da.toDeliver.add(item);
- DateTime when = item.consignment.created;
- event(item.id, item.consignmentId, when, ItemEventType.CREATED);
-
- if (!da.onSite.isEmpty()) {
- VehicleAgent va = Collections.max(da.onSite, VehicleAgent.CAPACITY_CONTENTS);
- va.hubId = item.consignment.hub;
- va.contents.add(item);
- depotScanVehicle(va, item, when, true);
-
- if (va.isFull()) {
- leaveForHub(va, when);
+ pendingConsignments.add(item);
+ final DateTime when = item.consignment.created;
+ add(when, new Action0() {
+ @Override
+ public void invoke() {
+ pendingConsignments.remove(item);
+ final DepotAgent da = depotAgents.get(item.consignment.collectionDepot);
+ da.toDeliver.add(item);
+ event(item.id, item.consignmentId, when, ItemEventType.CREATED);
+ if (!da.onSite.isEmpty()) {
+ VehicleAgent va = Collections.max(da.onSite, VehicleAgent.CAPACITY_CONTENTS);
+ dispatchDepotVehicle(va, when);
+ }
}
- }
+ });
}
/**
* Leave for the hub.
@@ -422,9 +440,12 @@
* @param when the current time
*/
public void leaveForHub(final VehicleAgent va, DateTime when) {
+ LOG.info(va.id + " DEPOT " + va.depot.id + " LEAVE [" + va.contents.size() + "] @ " + when.toString("yyyy-MM-dd HH:mm:ss"));
+ declare(va, when);
va.atDepot = false;
+ va.waiting = null;
va.depot.onSite.remove(va);
- final DateTime arrive = depotHubTravel(when, va.depotId, va.hubId);
+ final DateTime arrive = depotHubTravel(when, va.depot.id, va.hubId);
add(arrive, new Action0() {
@Override
public void invoke() {
@@ -438,20 +459,21 @@
* @param when the current time
*/
public void enterHub(VehicleAgent va, DateTime when) {
+ LOG.info(va.id + " HUB ENTER [" + va.contents.size() + "] @ " + when.toString("yyyy-MM-dd HH:mm:ss"));
va.atHub = true;
va.hub = hubAgents.get(va.hubId);
va.hub.onSite.add(va);
hubVehicleEnterLeave(va, when, true);
- dispatchVehicle(va, when);
+ dispatchHubVehicle(va, when);
}
/**
* Dispatch a vehicle based on its contents.
* @param va the vehicle
* @param when the current time
*/
- public void dispatchVehicle(final VehicleAgent va, final DateTime when) {
+ public void dispatchHubVehicle(final VehicleAgent va, final DateTime when) {
if (va.sourceContent()) {
WarehouseAgent wa = findUnloadWarehouse(va);
if (wa != null) {
@@ -459,23 +481,174 @@
unload(va, when);
} else {
// try again later
- final DateTime next = when.plusMinutes(1);
- add(next, new Action0() {
- @Override
- public void invoke() {
- dispatchVehicle(va, next);
- }
- });
+ final DateTime next = when.plusSeconds(IDLE_WAIT);
+ dispatchHubWait(va, next);
}
} else
- if (va.destinationContent()) {
-
+ if (va.destinationContent() && va.isFull()) {
+ leaveHub(va, when);
} else
- if (va.isEmpty()) {
-
+ if (va.destinationContent() || va.isEmpty()) {
+ WarehouseAgent wa = findLoadWarehouse(va);
+ if (wa != null) {
+ enterWarehouse(va, wa, when);
+ load(va, when, true);
+ } else {
+ if (va.waiting == null) {
+ va.waiting = when;
+ }
+ if (Seconds.secondsBetween(va.waiting, when).getSeconds() > MAX_LOAD_WAIT) {
+ va.waiting = null;
+ leaveHub(va, when);
+ } else {
+ final DateTime next = when.plusSeconds(IDLE_WAIT);
+ dispatchHubWait(va, next);
+ }
+ }
}
}
/**
+ * Leave the hub.
+ * @param va the vehicle
+ * @param when the current time
+ */
+ public void leaveHub(final VehicleAgent va, final DateTime when) {
+ LOG.info(va.id + " HUB LEAVE [" + va.contents.size() + "] @ " + when.toString("yyyy-MM-dd HH:mm:ss"));
+ hubVehicleEnterLeave(va, when, false);
+
+ final DateTime depotArrive = depotHubTravel(when, va.depot.id, va.hub.id);
+
+ va.hub.onSite.remove(va);
+
+ va.hub = null;
+ va.atHub = false;
+ va.sessionId = null;
+
+ add(depotArrive, new Action0() {
+ @Override
+ public void invoke() {
+ depotArrive(va, depotArrive);
+ }
+ });
+ }
+ /**
+ * Vehicle arrived at a depot.
+ * @param va the vehicle
+ * @param when the time
+ */
+ public void depotArrive(VehicleAgent va, DateTime when) {
+ LOG.info(va.id + " DEPOT " + va.depot.id + " ENTER [" + va.contents.size() + "] @ " + when.toString("yyyy-MM-dd HH:mm:ss"));
+ va.atDepot = true;
+ va.depot.onSite.add(va);
+
+ for (ConsItem ci : va.contents) {
+ depotScanVehicle(va, ci, when, false);
+ }
+ va.contents.clear();
+
+ dispatchDepotVehicle(va, when);
+ }
+ /**
+ * Dispatch the depot vehicle.
+ * @param va the vehicle
+ * @param when the current time
+ */
+ public void dispatchDepotVehicle(final VehicleAgent va, DateTime when) {
+ if (!va.atDepot) {
+ return;
+ } else
+ if (va.isFull()) {
+ leaveForHub(va, when);
+ } else
+ if (!va.depot.toDeliver.isEmpty()) {
+ int limit = va.limit();
+ for (ConsItem ci : new ArrayList<>(va.depot.toDeliver)) {
+ if (limit > 0) {
+ va.hubId = ci.consignment.hub;
+ va.contents.add(ci);
+ va.depot.toDeliver.remove(ci);
+ depotScanVehicle(va, ci, when, true);
+ limit--;
+ }
+ }
+ final DateTime wait = when.plusSeconds(LOAD_SECONDS);
+ dispatchDepotWait(va, wait);
+ } else
+ if (itemsForDepotExist(va.depot.id) || va.sourceContent()) {
+ if (va.waiting == null) {
+ va.waiting = when;
+ }
+ if (endOfConsignments || Seconds.secondsBetween(va.waiting, when).getSeconds() > MAX_LOAD_WAIT) {
+ leaveForHub(va, when);
+ } else {
+ final DateTime wait = when.plusSeconds(IDLE_WAIT);
+ dispatchDepotWait(va, wait);
+ }
+ } else
+ if (!endOfConsignments) {
+ final DateTime wait = when.plusSeconds(IDLE_WAIT);
+ dispatchDepotWait(va, wait);
+ }
+ }
+ /**
+ * Wait for some time and run a dispatch in the depot.
+ * @param va the vehicle
+ * @param wait the time to wait
+ */
+ protected void dispatchDepotWait(final VehicleAgent va, final DateTime wait) {
+ add(wait, new Action0() {
+ @Override
+ public void invoke() {
+ dispatchDepotVehicle(va, wait);
+ }
+ });
+ }
+ /**
+ * Check if other depots, in-transit vehicles or the hub contains items for the target depot.
+ * @param depot the target depot
+ * @return true if items need to be fetched from hub
+ */
+ public boolean itemsForDepotExist(long depot) {
+ for (ConsItem ci : pendingConsignments) {
+ if (ci.consignment.deliveryDepot == depot) {
+ return true;
+ }
+ }
+ for (DepotAgent da : depotAgents.valueCollection()) {
+ for (ConsItem ci : da.toDeliver) {
+ if (ci.consignment.deliveryDepot == depot) {
+ return true;
+ }
+ }
+ }
+ for (VehicleAgent va : vehicleAgents.values()) {
+ for (ConsItem ci : va.contents) {
+ if (ci.consignment.deliveryDepot == depot) {
+ return true;
+ }
+ }
+ }
+ for (WarehouseAgent wa : warehouseAgents.values()) {
+ if (wa.storageAreas.containsKey(depot)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ /**
+ * Wait until the given time and dispatch the vehicle again.
+ * @param va the vehicle
+ * @param next the wait end time
+ */
+ protected void dispatchHubWait(final VehicleAgent va, final DateTime next) {
+ add(next, new Action0() {
+ @Override
+ public void invoke() {
+ dispatchHubVehicle(va, next);
+ }
+ });
+ }
+ /**
* Enter the warehouse.
* @param va the vehicle
* @param wa the warehouse
@@ -487,6 +660,7 @@
wa.vehicles.add(va);
warehouseEnterLeave(va, when, true);
+ LOG.debug(va.id + " WAREHOUSE " + wa.id + " ENTER [" + va.contents.size() + "] @ " + when.toString("yyyy-MM-dd HH:mm:ss"));
}
/**
* Schedule the unloading of items.
@@ -509,7 +683,7 @@
}
});
- first = first.plusSeconds(10);
+ first = first.plusSeconds(UNLOAD_SECONDS);
}
}
final DateTime dt = first;
@@ -526,9 +700,65 @@
* @param dt the current time
*/
public void unloadComplete(final VehicleAgent va, DateTime dt) {
-
+ if (!va.sourceContent() && va.warehouse.storageAreas.containsKey(va.depot.id)) {
+ load(va, dt, false);
+ } else {
+ leaveWarehouse(va, dt);
+ }
}
/**
+ * Leave the warehouse.
+ * @param va the vehicle
+ * @param when the time
+ */
+ protected void leaveWarehouse(final VehicleAgent va, DateTime when) {
+ final DateTime leave = when.plusSeconds(va.position.leaveTime);
+ add(leave, new Action0() {
+ @Override
+ public void invoke() {
+ LOG.debug(va.id + " WAREHOUSE " + va.warehouse.id + " LEAVE [" + va.contents.size() + "] @ " + leave.toString("yyyy-MM-dd HH:mm:ss"));
+ warehouseEnterLeave(va, leave, false);
+
+ va.warehouse.vehicles.remove(va);
+ va.warehouse = null;
+ va.position = null;
+
+ dispatchHubVehicle(va, leave);
+ }
+ });
+ }
+ /**
+ * Load onto the vehicle.
+ * @param va the vehicle
+ * @param when the current time
+ * @param waitEnter wait for vehicle enter?
+ */
+ public void load(final VehicleAgent va, DateTime when, boolean waitEnter) {
+ DateTime dt = when;
+ if (waitEnter) {
+ dt = dt.plusSeconds(va.position.enterTime);
+ }
+ Collection<ConsItem> cs = va.warehouse.storageAreas.get(va.depot.id);
+ int limit = va.limit();
+ if (limit == 0 || cs.isEmpty()) {
+ leaveWarehouse(va, dt);
+ } else {
+ final ConsItem ci = cs.iterator().next();
+ if (va.warehouse.storageAreas.remove(va.depot.id, ci)) {
+ dt = dt.plusSeconds(LOAD_SECONDS);
+ final DateTime fdt = dt;
+ add(dt, new Action0() {
+ @Override
+ public void invoke() {
+ warehouseItemScan(va, ci, fdt, true);
+ va.contents.add(ci);
+ load(va, fdt, false);
+ }
+ });
+ }
+ }
+ }
+ /**
* Find a warehouse which can accept most of the contents of the vehicle.
* @param va the vehicle
* @return the best warehouse, null if all are occupied
@@ -559,9 +789,54 @@
return wres;
}
/**
+ * Find a warehouse with the most content.
+ * @param va the vehicle
+ * @return the warehouse or null if no item can be found
+ */
+ public WarehouseAgent findLoadWarehouse(VehicleAgent va) {
+ WarehouseAgent result = null;
+ int fill = 0;
+ for (WarehouseAgent wa : va.hub.warehouses) {
+ if (wa.vehicles.size() < wa.positions.size()) {
+ int cnt = wa.storageAreas.get(va.depot.id).size();
+ if (cnt > 0 && (result == null || cnt > fill)) {
+ fill = cnt;
+ result = wa;
+ }
+ }
+ }
+ return result;
+ }
+ /**
* Indicate that no more consignments will be created.
*/
public void consignmentsEnd() {
- // TODO
+ endOfConsignments = true;
}
+ /**
+ * Check if unprocessed items remained.
+ * @return true if unprocessed items remained
+ */
+ public boolean hasUnporcessed() {
+ boolean r = false;
+ for (WarehouseAgent wa : warehouseAgents.values()) {
+ if (!wa.storageAreas.isEmpty()) {
+ LOG.warn(wa.id + ": " + wa.storageAreas.size());
+ r = true;
+ }
+ }
+ for (DepotAgent da : depotAgents.valueCollection()) {
+ if (!da.toDeliver.isEmpty()) {
+ LOG.warn(da.id + ": " + da.toDeliver.size());
+ r = true;
+ }
+ }
+ for (VehicleAgent va : vehicleAgents.values()) {
+ if (!va.isEmpty()) {
+ LOG.warn(va.id + ": " + va.contents.size());
+ r = true;
+ }
+ }
+ return r;
+ }
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/VehicleAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/VehicleAgent.java 2013-10-03 14:03:54 UTC (rev 324)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/VehicleAgent.java 2013-10-04 12:16:01 UTC (rev 325)
@@ -24,6 +24,8 @@
import java.util.Comparator;
import java.util.List;
+import org.joda.time.DateTime;
+
import eu.advance.logistics.live.reporter.model.LorryPosition;
/**
@@ -33,8 +35,6 @@
public class VehicleAgent {
/** The id. */
public String id;
- /** The owner/target depot. */
- public long depotId;
/** The owner depot. */
public DepotAgent depot;
/** The vehicle capacity. */
@@ -53,6 +53,8 @@
public boolean atHub;
/** Vehicle is at a depot. */
public boolean atDepot = true;
+ /** The time when entered into a waiting state. */
+ public DateTime waiting;
/** The contents. */
public final List<ConsItem> contents = new ArrayList<>();
/** Capacity comparator. */
@@ -68,7 +70,7 @@
public int compare(VehicleAgent o1, VehicleAgent o2) {
int c = Integer.compare(o1.capacity, o2.capacity);
if (c == 0) {
- c = Integer.compare(o1.contents.size(), o2.contents.size());
+ c = Integer.compare(o2.contents.size(), o1.contents.size());
}
return c;
}
@@ -93,7 +95,7 @@
*/
public boolean sourceContent() {
for (ConsItem ci : contents) {
- if (ci.consignment.collectionDepot == depotId) {
+ if (ci.consignment.collectionDepot == depot.id) {
return true;
}
}
@@ -105,10 +107,17 @@
*/
public boolean destinationContent() {
for (ConsItem ci : contents) {
- if (ci.consignment.deliveryDepot == depotId) {
+ if (ci.consignment.deliveryDepot == depot.id) {
return true;
}
}
return false;
}
+ /**
+ * The number of items that can be loaded onto the vehicle.
+ * @return the load limit
+ */
+ public int limit() {
+ return capacity - contents.size();
+ }
}
\ No newline at end of file
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/WarehouseAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/WarehouseAgent.java 2013-10-03 14:03:54 UTC (rev 324)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/WarehouseAgent.java 2013-10-04 12:16:01 UTC (rev 325)
@@ -38,7 +38,7 @@
/** The hub. */
public long hub;
/** The warehouse. */
- public String warehouse;
+ public String id;
/** The depots and the current contents. */
public final Multimap<Long, ConsItem> storageAreas = HashMultimap.create();
/** The target depots maintained by the warehouse. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-10-03 14:03:57
|
Revision: 324
http://sourceforge.net/p/advance-project/code/324
Author: akarnokd
Date: 2013-10-03 14:03:54 +0000 (Thu, 03 Oct 2013)
Log Message:
-----------
Reworking demo data generator.
Modified Paths:
--------------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/Aggregates.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/HubCoord.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/ConsignmentDB.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Demo.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/DepotAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/HubAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/VehicleAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/WarehouseAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/ScanType.java
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/Aggregates.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/Aggregates.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/Aggregates.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -47,11 +47,11 @@
@NonNull
public LinkedHashMap<ItemStatus, BarData> create() {
LinkedHashMap<ItemStatus, BarData> p = new LinkedHashMap<>();
- p.put(ItemStatus.LEFT_HUB, new BarData(lefthub));
+ p.put(ItemStatus.LEFT_HUB_TODAY, new BarData(lefthub));
+ p.put(ItemStatus.CREATED, new BarData(created));
+ p.put(ItemStatus.SCANNED, new BarData(scanned));
+ p.put(ItemStatus.DECLARED, new BarData(declared));
p.put(ItemStatus.AT_HUB, new BarData(athub));
- p.put(ItemStatus.DECLARED, new BarData(declared));
- p.put(ItemStatus.SCANNED, new BarData(scanned));
- p.put(ItemStatus.CREATED, new BarData(created));
p.put(ItemStatus.PREDICTED, new BarData(predicted));
return p;
}
@@ -69,7 +69,8 @@
case CREATED:
value = created;
break;
- case LEFT_HUB:
+// case LEFT_HUB:
+ case LEFT_HUB_TODAY:
value = lefthub;
break;
case DECLARED:
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/HubCoord.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/HubCoord.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/HubCoord.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -58,7 +58,7 @@
private void setNoOfTotalTick(ServiceLevel snip, SumData sumData) {
// Count: (totalCoord - sumData.maxLeftHub() + leftHub) DIV (tickUnit * scale)
int total = super.totalCoord.subtract(sumData.maxLeftHub(true))
- .add(sumData.items.get(snip).get(OrientStatus.SINGLE).get(ItemStatus.LEFT_HUB).value).intValue();
+ .add(sumData.items.get(snip).get(OrientStatus.SINGLE).get(ItemStatus.LEFT_HUB_TODAY).value).intValue();
int tickScale = super.getTickScale().intValue();
this.noOfTotalTick.put(snip, new GraphDecimal((total / tickScale)));
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/charts/L1OverallData.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -52,7 +52,7 @@
* @return EnumSet of the used item statuses
*/
public static EnumSet<ItemStatus> getDisplayItems() {
- EnumSet<ItemStatus> result = EnumSet.of(ItemStatus.LEFT_HUB,
+ EnumSet<ItemStatus> result = EnumSet.of(ItemStatus.LEFT_HUB_TODAY,
ItemStatus.AT_HUB,
ItemStatus.DECLARED,
ItemStatus.SCANNED,
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/ConsignmentDB.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/ConsignmentDB.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/ConsignmentDB.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -483,7 +483,7 @@
for (TLongCollection ids : TroveUtils.split(consMap.keySet(), 1000)) {
sql.setLength(0);
- sql.append("SELECT consingment_id, width, height, length FROM items ")
+ sql.append("SELECT consignment_id, width, height, length FROM items ")
.append("WHERE consignment_id IN (");
TroveUtils.join(ids, ",", sql);
sql.append(")");
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -207,8 +207,8 @@
* @throws SQLException ingored
*/
public void run() throws SQLException {
- DateMidnight startDay = new DateMidnight(2013, 7, 1);
- DateMidnight endDay = new DateMidnight(2013, 12, 31);
+ DateMidnight startDay = new DateMidnight(2013, 9, 30);
+ DateMidnight endDay = new DateMidnight(2013, 9, 30);
DateMidnight day = startDay;
@@ -218,20 +218,14 @@
if (dow != DateTimeConstants.SATURDAY && dow != DateTimeConstants.SUNDAY) {
System.out.printf("Day: %s%n", day);
List<Cons> cons = generate(day);
- DateTime max = saveCons(cons);
+ saveCons(cons);
db.commit();
-
- if (max != null) {
- env.consignmentsEnd(max);
- }
}
}
day = day.plusDays(1);
-
- env.eventLoop();
- db.commit();
}
+ env.consignmentsEnd();
env.eventLoop();
db.commit();
}
@@ -243,11 +237,12 @@
*/
List<Cons> generate(DateMidnight day) throws SQLException {
List<Cons> r = new ArrayList<>();
- LocalTime lt = new LocalTime(7, 0);
+ int lt = new LocalTime(7, 0).getMillisOfDay() / 1000;
int dy = day.getDayOfYear();
int dm = day.getDayOfMonth();
int dw = day.getDayOfWeek();
int k = 0;
+ int seconds = 0;
for (Postcode pc : postcodes) {
if (pc.id % 5 != dw - 1) {
int nf = 0;
@@ -273,7 +268,7 @@
Cons cs = new Cons();
r.add(cs);
cs.id = ++consId;
- cs.created = day.toDateTime().withTime(lt.getHourOfDay(), lt.getMinuteOfHour(), lt.getSecondOfMinute(), lt.getMillisOfSecond());
+ cs.created = day.toDateTime().plusSeconds(lt + seconds);
cs.itemCount = nf + nh + nq;
cs.collectionPostcode = pc.id;
cs.collectionDepot = postcodeClosestDepot.get(pc.id).id;
@@ -282,7 +277,7 @@
cs.deliveryDepot = postcodeClosestDepot.get(dpc.id).id;
cs.externalId = "C" + cs.id;
- int sli = ((dm + k) % 30);
+ int sli = ((dm + k) % 29);
if (sli == 0) {
cs.service = ServiceLevel.SPECIAL;
} else
@@ -305,6 +300,7 @@
ConsItem item = new ConsItem();
item.consignment = cs;
item.id = ++itemId;
+ item.consignmentId = cs.id;
item.length = 1;
item.width = 1;
item.height = 1;
@@ -315,6 +311,7 @@
ConsItem item = new ConsItem();
item.consignment = cs;
item.id = ++itemId;
+ item.consignmentId = cs.id;
item.length = 1;
item.width = 1;
item.height = 0.5;
@@ -325,6 +322,7 @@
ConsItem item = new ConsItem();
item.consignment = cs;
item.id = ++itemId;
+ item.consignmentId = cs.id;
item.length = 1;
item.width = 1;
item.height = 0.25;
@@ -338,8 +336,9 @@
}
-
- lt = lt.plusSeconds(15);
+ seconds = (seconds + 20);
+
+
k++;
}
return r;
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Demo.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Demo.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Demo.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -63,7 +63,7 @@
*/
private static void createMaster(DB db) throws SQLException {
// create hubs
- int nHubs = 2;
+ int nHubs = 1;
for (int i = 1; i <= nHubs; i++) {
db.update("INSERT IGNORE INTO hubs VALUES (?, ?, ?, ?)", i, "Hub " + i, 1000, 1000);
}
@@ -73,7 +73,7 @@
for (int i = 1; i <= nDepots; i++) {
db.update("INSERT IGNORE INTO depots VALUES (?, ?) ", i, "Depot " + i);
- int nVehicles = (int)Math.ceil(5d * i / nDepots);
+ int nVehicles = 1 + (int)Math.ceil(5d * i / nDepots);
for (int j = 1; j <= nVehicles; j++) {
db.update("INSERT IGNORE INTO vehicles VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
@@ -96,7 +96,7 @@
db.update("INSERT IGNORE INTO warehouses VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
i, "Warehouse " + wi, x, y, 60, 100, 0, rnd.nextInt(5) + 5, "Warehouse " + (wi % 2 == 0 ? wi - 1 : wi + 1));
- int sa = (nDepots / 2) * ((j - 1) / 2);
+ int sa = ((j - 1) / 2) * (nDepots / 2);
for (int k = 0; k < nDepots / 2; k++) {
db.update("INSERT IGNORE INTO storage_areas VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
i, "Warehouse " + wi, k % 2, k / 2, sa + k + 1, 20, 1.5, 0, 30
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/DepotAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/DepotAgent.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/DepotAgent.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -21,13 +21,8 @@
package eu.advance.logistics.live.reporter.demo;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.joda.time.DateTime;
-
-import eu.advance.logistics.live.reporter.model.ItemEventType;
-
/**
* A depot manager "agent".
* @author karnokd, 2013.10.01.
@@ -42,54 +37,4 @@
public final List<VehicleAgent> vehicles = new ArrayList<>();
/** The vehicles on site. */
public final List<VehicleAgent> onSite = new ArrayList<>();
- /** The environment. */
- private EnvironmentAgent env;
- /**
- * Constructor, sets the environment.
- * @param env the environment
- */
- public DepotAgent(EnvironmentAgent env) {
- this.env = env;
- }
- /**
- * Item arrived from the collection postcode.
- * @param now the current time
- * @param item the item
- */
- public void itemArrived(DateTime now, ConsItem item) {
- toDeliver.add(item);
- checkLoadVehicle(now);
- }
- /**
- * Vehicle arrived at the depot.
- * @param now the arrival time
- * @param va the vehicle
- */
- public void vehicleArrived(DateTime now, VehicleAgent va) {
- for (ConsItem item : va.contents) {
- env.event(item.id, item.consignmentId, now, ItemEventType.DESTINATION_SCAN);
- }
- va.contents.clear();
- va.targetHub = null;
- va.atDepot = true;
- onSite.add(va);
- checkLoadVehicle(now);
- }
- /**
- * Check if vehicles can be loaded.
- * @param now the current time
- */
- public void checkLoadVehicle(DateTime now) {
- if (!onSite.isEmpty()) {
- for (ConsItem ci : new ArrayList<>(toDeliver)) {
- List<VehicleAgent> vas = new ArrayList<>(onSite);
- Collections.sort(vas, VehicleAgent.CAPACITY);
- for (VehicleAgent va : vas) {
- if (va.tryLoadInDepot(now, ci)) {
- toDeliver.remove(ci);
- }
- }
- }
- }
- }
}
\ No newline at end of file
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -36,17 +36,22 @@
import java.awt.Point;
import java.sql.SQLException;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import org.joda.time.DateTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The base environment for the agents.
* @author karnokd, 2013.10.02.
*/
public class EnvironmentAgent {
+ /** The log. */
+ private static final Logger LOG = LoggerFactory.getLogger(EnvironmentAgent.class);
/** The database connection. */
protected final DB db;
/** The map of depots. */
@@ -70,9 +75,18 @@
* The event loop.
*/
public void eventLoop() {
+ int i = 1;
while (!events.isEmpty()) {
Pair<DateTime, Action0> e = events.remove();
e.second.invoke();
+ if (i % 1000 == 0) {
+ try {
+ db.commit();
+ } catch (SQLException ex) {
+ LOG.error(ex.toString(), ex);
+ }
+ }
+ i++;
}
}
/**
@@ -90,7 +104,7 @@
public void setHubs(Iterable<Hub> hubs) {
hubAgents.clear();
for (Hub h : hubs) {
- HubAgent ha = new HubAgent(this);
+ HubAgent ha = new HubAgent();
ha.id = h.id;
hubAgents.put(ha.id, ha);
}
@@ -104,7 +118,7 @@
for (Warehouse wh : warehouses) {
HubAgent ha = hubAgents.get(wh.hub);
- WarehouseAgent wa = new WarehouseAgent(this);
+ WarehouseAgent wa = new WarehouseAgent();
wa.hub = wh.hub;
wa.warehouse = wh.warehouse;
@@ -131,7 +145,7 @@
public void setDepots(Iterable<Depot> depots) {
depotAgents.clear();
for (Depot d : depots) {
- DepotAgent da = new DepotAgent(this);
+ DepotAgent da = new DepotAgent();
da.id = d.id;
depotAgents.put(da.id, da);
@@ -147,9 +161,10 @@
for (Vehicle v : vehicles) {
DepotAgent da = depotAgents.get(v.depot);
- VehicleAgent va = new VehicleAgent(this);
+ VehicleAgent va = new VehicleAgent();
va.id = v.vehicleId;
- va.depot = v.depot;
+ va.depotId = v.depot;
+ va.depot = da;
va.capacity = v.capacity;
da.onSite.add(va);
@@ -169,20 +184,6 @@
}
}
/**
- * Stores an event for a particulare item.
- * @param itemId the item identifier
- * @param consignmentId the parent consignment id
- * @param timestamp the event timestamp
- * @param event the event
- */
- public void event(long itemId, long consignmentId, DateTime timestamp, ItemEventType event) {
- try {
- db.update("INSERT INGORE INTO events VALUES (?, ?, ?, ?)", itemId, consignmentId, timestamp, event.ordinal());
- } catch (SQLException ex) {
- throw new RuntimeException(ex);
- }
- }
- /**
* Returns the depot position.
* @param depot the depot
* @return the
@@ -259,120 +260,308 @@
return now.plusSeconds((int)d);
}
/**
- * Add a new item.
- * @param item the item
+ * Stores an event for a particulare item.
+ * @param itemId the item identifier
+ * @param consignmentId the parent consignment id
+ * @param timestamp the event timestamp
+ * @param event the event
*/
- public void newItem(final ConsItem item) {
-
- event(item.id, item.consignmentId, item.consignment.created, ItemEventType.CREATED);
-
- final DateTime depotArrive = postcodeDepotTravel(item.consignment.created, item.consignment.collectionPostcode, item.consignment.collectionDepot);
-
- final DepotAgent da = depotAgents.get(item.consignment.collectionDepot);
-
- add(depotArrive, new Action0() {
- @Override
- public void invoke() {
- da.itemArrived(depotArrive, item);
- }
- });
+ public void event(long itemId, long consignmentId, DateTime timestamp, ItemEventType event) {
+ try {
+ db.update("INSERT IGNORE INTO `events` VALUES (?, ?, ?, ?)",
+ consignmentId, itemId, timestamp, event.ordinal());
+ } catch (SQLException ex) {
+ throw new RuntimeException(ex);
+ }
}
/**
- * Register a collection scan.
- * @param vehicleId the vehicle identifier
- * @param when the scan time
- * @param item the item
+ * Record a scan onto vehicle event in the database tables.
+ * @param va the vehicle agent
+ * @param item the consignment item
+ * @param when the current time
+ * @param onto scan onto the vehicle
*/
- public void collectionScan(String vehicleId, DateTime when, ConsItem item) {
- event(item.id, item.consignmentId, when, ItemEventType.SOURCE_SCAN);
-
+ public void depotScanVehicle(VehicleAgent va, ConsItem item, DateTime when, boolean onto) {
+ ItemEventType iet = onto ? ItemEventType.SOURCE_SCAN : ItemEventType.DESTINATION_SCAN;
+ event(item.id, item.consignmentId, when, iet);
try {
- db.update("INSERT IGNORE INTO scans VALUES (?, ?, ?, ?, ?, ?, ?)",
- item.consignmentId, item.id, ScanType.SOURCE.ordinal(),
- item.consignment.collectionDepot, true, when, vehicleId);
-
- db.update("INSERT IGNORE INTO scans_history VALUES (?, ?, ?, ?, ?, ?, ?)",
- item.consignmentId, item.id, ScanType.SOURCE.ordinal(),
- item.consignment.collectionDepot, true, when, vehicleId);
+ ScanType st = onto ? ScanType.SOURCE : ScanType.DESTINATION;
+ db.update("INSERT IGNORE INTO scans VALUES (?, ?, ?, ?, ?, ?)",
+ item.consignmentId, item.id, st.ordinal(),
+ va.depot, when, va.id
+ );
+ db.update("INSERT IGNORE INTO scans_history VALUES (?, ?, ?, ?, ?, ?)",
+ item.consignmentId, item.id, st.ordinal(),
+ va.depot, when, va.id
+ );
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
}
/**
- * Declare a pallet on a vehicle.
- * @param vehicleId the vehicle identifier
- * @param when the time of the declaration
- * @param externalItemId the item identifier
+ * Declare the contents of the entire vehicle.
+ * @param va the vehicle
+ * @param when the current time
*/
- public void declare(String vehicleId, DateTime when, String externalItemId) {
- int iidx = externalItemId.indexOf("I");
- long consId = Long.parseLong(externalItemId.substring(1, iidx));
-// long itemId = Long.parseLong(externalItemId.substring(iidx + 1));
-
+ public void declare(VehicleAgent va, DateTime when) {
try {
- db.update("INSERT IGNORE INTO vehicle_declared VALUES (?, ?, ?)", vehicleId, when, externalItemId);
- db.update("UPDATE consignments SET declared = ? WHERE id = ?", when, consId);
- db.update("UPDATE consignments_history SET declared = ? WHERE id = ?", when, consId);
+ for (ConsItem ci : va.contents) {
+ event(ci.id, ci.consignmentId, when, ItemEventType.DECLARED);
+
+ db.update("UPDATE consignments SET declared = ? WHERE id = ? ", when, ci.consignmentId);
+
+ db.update("UPDATE consignments_history SET declared = ? WHERE id = ? ", when, ci.consignmentId);
+
+ db.update("INSERT INGORE INTO vehicle_declared VALUES (?, ?, ?)", va.id, when, ci.externalId);
+ }
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
}
/**
- * Vehicle arrived at hub.
- * @param now the current time
- * @param hub the hub
+ * Record a vehicle enter-leave the hub.
* @param va the vehicle
+ * @param when the current time
+ * @param enter enter?
*/
- public void hubArrive(final DateTime now, final long hub, final VehicleAgent va) {
- va.sessionId = hub + "_" + now.toString("yyyyMMdd'_'HHmmss") + "_" + va.id;
- va.atHub = true;
-
- for (ConsItem ci : va.contents) {
- event(ci.id, ci.consignmentId, now, ItemEventType.HUB_ARRIVE);
+ public void hubVehicleEnterLeave(VehicleAgent va, DateTime when, boolean enter) {
+ try {
+ for (ConsItem ci : va.contents) {
+ event(ci.id, ci.consignmentId, when, enter ? ItemEventType.HUB_ARRIVE : ItemEventType.HUB_LEAVE);
+ }
+ if (enter) {
+ va.sessionId = va.hub + "_" + when.toString("yyyyMMdd'_'HHmmss") + "_" + va.id;
+
+ db.update("INSERT IGNORE INTO vehicle_sessions VALUES (?, ?, ?, ?, ?)",
+ va.sessionId, va.id, va.hub, when, DateTime.class);
+ } else {
+ db.update("UPDATE vehicle_sessions SET leave_timestamp = ? WHERE session_id = ? ", when, va.sessionId);
+ }
+
+ } catch (SQLException ex) {
+ throw new RuntimeException(ex);
}
-
- HubAgent ha = hubAgents.get(va.targetHub);
- ha.vehiclesOnSite.add(va);
- ha.loadUnload(now);
}
/**
- * Register the contents of the vehicle entering/leaving its warehouse.
+ * Record a vehicle enter/leave a warehouse.
* @param va the vehicle
- * @param now the current time
+ * @param when the current time
* @param enter is enter?
*/
- public void warehouseScan(VehicleAgent va, DateTime now, boolean enter) {
+ public void warehouseEnterLeave(VehicleAgent va, DateTime when, boolean enter) {
try {
- long sid = db.insertAuto("INSERT INTO vehicle_scan (session_id, scan_timestamp, warehouse, entry) VALUES (?, ?, ?, ?)",
- va.sessionId, now, va.warehouse, enter
- );
+ long scanId = db.insertAuto("INSERT INTO vehicle_scan (session_id, scan_timestamp, warehouse, entry) VALUES (?, ?, ?, ?)",
+ va.sessionId, when, va.warehouse, enter);
+
for (ConsItem ci : va.contents) {
- event(ci.id, ci.consignmentId, now, ItemEventType.WAREHOUSE_ENTER);
- db.update("INSERT INTO vehicle_items VALUES (?, ?) ", sid, ci.externalId);
+ event(ci.id, ci.consignmentId, when, enter ? ItemEventType.WAREHOUSE_ENTER : ItemEventType.WAREHOUSE_LEAVE);
- ScanType st = enter ? ScanType.WAREHOUSE_ENTER : ScanType.WAREHOUSE_LEAVE;
-
db.update("INSERT IGNORE INTO scans VALUES (?, ?, ?, ?, ?, ?)",
- ci.consignmentId, ci.id, st,
- va.targetHub + " " + va.warehouse, now, va.id);
+ ci.consignmentId, ci.id, enter ? ScanType.WAREHOUSE_ENTER : ScanType.WAREHOUSE_LEAVE,
+ va.hub + " " + va.warehouse, when, va.id);
db.update("INSERT IGNORE INTO scans_history VALUES (?, ?, ?, ?, ?, ?)",
- ci.consignmentId, ci.id, st,
- va.targetHub + " " + va.warehouse, now, va.id);
-
+ ci.consignmentId, ci.id, enter ? ScanType.WAREHOUSE_ENTER : ScanType.WAREHOUSE_LEAVE,
+ va.hub + " " + va.warehouse, when, va.id);
+
+ db.update("INSERT IGNORE INTO vehicle_items VALUES (?, ?)", scanId, ci.externalId);
}
+
} catch (SQLException ex) {
throw new RuntimeException(ex);
+ }
+ }
+ /**
+ * Record the scan of the item onto/off a vehicle.
+ * @param va the vehicle
+ * @param ci the item
+ * @param when the current time
+ * @param onto the direction
+ */
+ public void warehouseItemScan(VehicleAgent va, ConsItem ci, DateTime when, boolean onto) {
+ try {
+ event(ci.id, ci.consignmentId, when, onto ? ItemEventType.SCAN_ON : ItemEventType.SCAN_OFF);
+
+ db.update("INSERT IGNORE INTO scans VALUES (?, ?, ?, ?, ?, ?)",
+ ci.consignmentId, ci.id, onto ? ScanType.WAREHOUSE_MANUAL_LOAD : ScanType.WAREHOUSE_MANUAL_UNLOAD,
+ va.hub + " " + va.warehouse, when, va.id);
+
+ db.update("INSERT IGNORE INTO scans_history VALUES (?, ?, ?, ?, ?, ?)",
+ ci.consignmentId, ci.id, onto ? ScanType.WAREHOUSE_MANUAL_LOAD : ScanType.WAREHOUSE_MANUAL_UNLOAD,
+ va.hub + " " + va.warehouse, when, va.id);
+
+ } catch (SQLException ex) {
+ throw new RuntimeException(ex);
+ }
+
+ }
+ /**
+ * Add a new item.
+ * @param item the item
+ */
+ public void newItem(final ConsItem item) {
+ DepotAgent da = depotAgents.get(item.consignment.collectionDepot);
+ da.toDeliver.add(item);
+ DateTime when = item.consignment.created;
+ event(item.id, item.consignmentId, when, ItemEventType.CREATED);
+
+ if (!da.onSite.isEmpty()) {
+ VehicleAgent va = Collections.max(da.onSite, VehicleAgent.CAPACITY_CONTENTS);
+ va.hubId = item.consignment.hub;
+ va.contents.add(item);
+ depotScanVehicle(va, item, when, true);
+
+ if (va.isFull()) {
+ leaveForHub(va, when);
+ }
}
}
/**
- * Indicate that no more consignments will appear on the given day.
- * @param now the current time
+ * Leave for the hub.
+ * @param va the vehicle
+ * @param when the current time
*/
- public void consignmentsEnd(DateTime now) {
- // TODO
- for (DepotAgent da : depotAgents.valueCollection()) {
+ public void leaveForHub(final VehicleAgent va, DateTime when) {
+ va.atDepot = false;
+ va.depot.onSite.remove(va);
+ final DateTime arrive = depotHubTravel(when, va.depotId, va.hubId);
+ add(arrive, new Action0() {
+ @Override
+ public void invoke() {
+ enterHub(va, arrive);
+ }
+ });
+ }
+ /**
+ * Enter the hub.
+ * @param va the vehicle.
+ * @param when the current time
+ */
+ public void enterHub(VehicleAgent va, DateTime when) {
+ va.atHub = true;
+ va.hub = hubAgents.get(va.hubId);
+ va.hub.onSite.add(va);
+
+ hubVehicleEnterLeave(va, when, true);
+
+ dispatchVehicle(va, when);
+ }
+ /**
+ * Dispatch a vehicle based on its contents.
+ * @param va the vehicle
+ * @param when the current time
+ */
+ public void dispatchVehicle(final VehicleAgent va, final DateTime when) {
+ if (va.sourceContent()) {
+ WarehouseAgent wa = findUnloadWarehouse(va);
+ if (wa != null) {
+ enterWarehouse(va, wa, when);
+ unload(va, when);
+ } else {
+ // try again later
+ final DateTime next = when.plusMinutes(1);
+ add(next, new Action0() {
+ @Override
+ public void invoke() {
+ dispatchVehicle(va, next);
+ }
+ });
+ }
+ } else
+ if (va.destinationContent()) {
+ } else
+ if (va.isEmpty()) {
+
}
}
+ /**
+ * Enter the warehouse.
+ * @param va the vehicle
+ * @param wa the warehouse
+ * @param when the current time
+ */
+ public void enterWarehouse(VehicleAgent va, WarehouseAgent wa, DateTime when) {
+ va.warehouse = wa;
+ va.position = wa.freeSlot();
+ wa.vehicles.add(va);
+
+ warehouseEnterLeave(va, when, true);
+ }
+ /**
+ * Schedule the unloading of items.
+ * @param va the vehicle
+ * @param when current time
+ */
+ public void unload(final VehicleAgent va, DateTime when) {
+ DateTime first = when.plusSeconds(va.position.enterTime);
+ for (final ConsItem ci : va.contents) {
+ if (va.warehouse.depots.contains(ci.consignment.deliveryDepot)) {
+
+ final DateTime dt = first;
+ add(first, new Action0() {
+ @Override
+ public void invoke() {
+ va.warehouse.storageAreas.put(ci.consignment.deliveryDepot, ci);
+ va.contents.remove(ci);
+
+ warehouseItemScan(va, ci, dt, false);
+ }
+ });
+
+ first = first.plusSeconds(10);
+ }
+ }
+ final DateTime dt = first;
+ add(first, new Action0() {
+ @Override
+ public void invoke() {
+ unloadComplete(va, dt);
+ }
+ });
+ }
+ /**
+ * Called when the vehicle was unloaded successfully.
+ * @param va the vehicle
+ * @param dt the current time
+ */
+ public void unloadComplete(final VehicleAgent va, DateTime dt) {
+
+ }
+ /**
+ * Find a warehouse which can accept most of the contents of the vehicle.
+ * @param va the vehicle
+ * @return the best warehouse, null if all are occupied
+ */
+ public WarehouseAgent findUnloadWarehouse(VehicleAgent va) {
+
+ WarehouseAgent wres = null;
+ int bestWres = 0;
+
+ for (WarehouseAgent wa : va.hub.warehouses) {
+ if (wa.vehicles.size() < wa.positions.size()) {
+ int contentThere = 0;
+ int contentVa = 0;
+ for (ConsItem ci : va.contents) {
+ contentThere += wa.storageAreas.get(ci.consignment.deliveryDepot).size();
+ contentVa += wa.depots.contains(ci.consignment.deliveryDepot) ? 1 : 0;
+ }
+
+ if (contentVa > 0) {
+ if (wres == null || bestWres > contentThere) {
+ wres = wa;
+ bestWres = contentThere;
+ }
+ }
+ }
+ }
+
+ return wres;
+ }
+ /**
+ * Indicate that no more consignments will be created.
+ */
+ public void consignmentsEnd() {
+ // TODO
+ }
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/HubAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/HubAgent.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/HubAgent.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -23,8 +23,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.joda.time.DateTime;
-
/**
* The hub agent.
* @author karnokd, 2013.10.01.
@@ -33,33 +31,7 @@
/** Identifier. */
public long id;
/** List of vehicles on site. */
- public final List<VehicleAgent> vehiclesOnSite = new ArrayList<>();
+ public final List<VehicleAgent> onSite = new ArrayList<>();
/** List of vehicles. */
public final List<WarehouseAgent> warehouses = new ArrayList<>();
- /** The environment. */
- private EnvironmentAgent env;
- /**
- * Constructor, sets the environment.
- * @param env the environment
- */
- public HubAgent(EnvironmentAgent env) {
- this.env = env;
- }
- /**
- * Schedule the loading and unloading vehicles.
- * @param now the current time
- */
- public void loadUnload(DateTime now) {
- for (VehicleAgent va : vehiclesOnSite) {
- if (va.warehouse == null) {
- if (va.needsUnload()) {
- for (WarehouseAgent wa : warehouses) {
- if (wa.tryEnter(now, va)) {
-
- }
- }
- }
- }
- }
- }
}
\ No newline at end of file
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/VehicleAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/VehicleAgent.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/VehicleAgent.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -20,16 +20,12 @@
*/
package eu.advance.logistics.live.reporter.demo;
-import hu.akarnokd.reactive4java.base.Action0;
-
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
-import org.joda.time.DateTime;
+import eu.advance.logistics.live.reporter.model.LorryPosition;
-import eu.advance.logistics.live.reporter.model.ItemEventType;
-
/**
* A vehicle delivering items to and from hub.
* @author karnokd, 2013.10.01.
@@ -38,17 +34,21 @@
/** The id. */
public String id;
/** The owner/target depot. */
- public long depot;
+ public long depotId;
+ /** The owner depot. */
+ public DepotAgent depot;
/** The vehicle capacity. */
public int capacity;
/** The target hub, if moving towards it. */
- public Long targetHub;
+ public Long hubId;
+ /** The hub where the vehicle is at. */
+ public HubAgent hub;
/** The session identifier. */
public String sessionId;
/** In a warehouse if not null. */
- public String warehouse;
+ public WarehouseAgent warehouse;
/** In a lorry position if not null. */
- public Integer position;
+ public LorryPosition position;
/** Vehicle is at a hub. */
public boolean atHub;
/** Vehicle is at a depot. */
@@ -62,77 +62,50 @@
return Integer.compare(o1.capacity, o2.capacity);
}
};
- /** The environment. */
- private EnvironmentAgent env;
+ /** Capacity comparator. */
+ public static final Comparator<VehicleAgent> CAPACITY_CONTENTS = new Comparator<VehicleAgent>() {
+ @Override
+ public int compare(VehicleAgent o1, VehicleAgent o2) {
+ int c = Integer.compare(o1.capacity, o2.capacity);
+ if (c == 0) {
+ c = Integer.compare(o1.contents.size(), o2.contents.size());
+ }
+ return c;
+ }
+ };
/**
- * Constructor, sets the environment.
- * @param env the environment
+ * Check if the vehicle is full.
+ * @return true if vehicle is full
*/
- public VehicleAgent(EnvironmentAgent env) {
- this.env = env;
+ public boolean isFull() {
+ return contents.size() >= capacity;
}
/**
- * Try loading a consignment item into the vehicle at the depot.
- * @param now the current time
- * @param item the item to load
- * @return true if loaded successfully
+ * Check if vehicle is empty.
+ * @return true if empty
*/
- public boolean tryLoadInDepot(DateTime now, ConsItem item) {
- if (atDepot) {
- if (targetHub == null) {
- targetHub = item.consignment.hub;
- add(now, item);
- if (contents.size() >= capacity) {
- departToHub(now);
- }
- return true;
- } else
- if (targetHub == item.consignment.hub) {
- if (contents.size() < capacity) {
- add(now, item);
- if (contents.size() >= capacity) {
- departToHub(now);
- }
- return true;
- }
- }
- }
- return false;
+ public boolean isEmpty() {
+ return contents.isEmpty();
}
/**
- * Depart the vehicle towards the hub.
- * @param now the time
+ * Check if the vehicle contains items from the source depot.
+ * @return true if source content is present
*/
- public void departToHub(DateTime now) {
- atDepot = false;
+ public boolean sourceContent() {
for (ConsItem ci : contents) {
- env.event(ci.id, ci.consignmentId, now, ItemEventType.DECLARED);
- env.declare(id, now, ci.externalId);
+ if (ci.consignment.collectionDepot == depotId) {
+ return true;
+ }
}
- final DateTime hubArrive = env.depotHubTravel(now, depot, targetHub);
- env.add(hubArrive, new Action0() {
- @Override
- public void invoke() {
- env.hubArrive(hubArrive, targetHub, VehicleAgent.this);
- }
- });
+ return false;
}
/**
- * Add a consignment item.
- * @param now the current time
- * @param item the item to add
+ * Check if the vehicle contains items for the destination depot.
+ * @return true if destination content is present
*/
- public void add(DateTime now, ConsItem item) {
- contents.add(item);
- env.collectionScan(id, now, item);
- }
- /**
- * Check if the vehicle contains items from the collection depot.
- * @return true if contains items from collection depot
- */
- public boolean needsUnload() {
+ public boolean destinationContent() {
for (ConsItem ci : contents) {
- if (ci.consignment.collectionDepot == depot) {
+ if (ci.consignment.deliveryDepot == depotId) {
return true;
}
}
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/WarehouseAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/WarehouseAgent.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/WarehouseAgent.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -20,17 +20,13 @@
*/
package eu.advance.logistics.live.reporter.demo;
-import eu.advance.logistics.live.reporter.model.ItemEventType;
import eu.advance.logistics.live.reporter.model.LorryPosition;
import gnu.trove.set.TLongSet;
import gnu.trove.set.hash.TLongHashSet;
-import hu.akarnokd.reactive4java.base.Action0;
import java.util.ArrayList;
import java.util.List;
-import org.joda.time.DateTime;
-
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
@@ -51,86 +47,20 @@
public final List<VehicleAgent> vehicles = new ArrayList<>();
/** The lorry positions. */
public final List<LorryPosition> positions = new ArrayList<>();
- /** The environment. */
- private EnvironmentAgent env;
/**
- * Constructor, sets the environment.
- * @param env the environment
+ * Locates the first free vehicle slot.
+ * @return the vehicle slot or null if full
*/
- public WarehouseAgent(EnvironmentAgent env) {
- this.env = env;
- }
- /**
- * Try entering a warehouse.
- * @param now the current time
- * @param va the warehouse agent
- * @return true if enter was successful
- */
- public boolean tryEnter(DateTime now, VehicleAgent va) {
- if (positions.size() > vehicles.size()) {
- for (ConsItem ci : va.contents) {
- if (depots.contains(ci.consignment.deliveryDepot)) {
- enter(now, va);
- return true;
- }
- }
+ public LorryPosition freeSlot() {
+ List<LorryPosition> candidates = new ArrayList<>(positions);
+
+ for (VehicleAgent va : vehicles) {
+ candidates.remove(va.position);
}
- return false;
- }
- /**
- * Enter a vehicle into a free position and schedule the unload.
- * @param now the current time
- * @param va the vehicle
- */
- public void enter(DateTime now, final VehicleAgent va) {
- va.warehouse = warehouse;
- List<LorryPosition> lps = new ArrayList<LorryPosition>(positions);
- for (VehicleAgent va0 : vehicles) {
- for (int i = lps.size() - 1; i >= 0; i--) {
- LorryPosition lp = lps.get(i);
- if (lp.index == va0.position) {
- lps.remove(i);
- }
- }
+
+ if (candidates.isEmpty()) {
+ return null;
}
- vehicles.add(va);
- va.position = lps.get(0).index;
- DateTime unload = now.plusSeconds(lps.get(0).enterTime);
-
- env.warehouseScan(va, now, true);
-
- for (final ConsItem ci : va.contents) {
- final DateTime funload = unload;
- if (depots.contains(ci.consignment.deliveryDepot)) {
- env.add(unload, new Action0() {
- @Override
- public void invoke() {
- env.event(ci.id, ci.consignmentId, funload, ItemEventType.SCAN_OFF);
- storageAreas.put(ci.consignment.deliveryDepot, ci);
- va.contents.remove(ci);
- }
- });
- }
- unload = unload.plusSeconds(15);
- }
- final DateTime endUnload = unload;
- env.add(endUnload, new Action0() {
- @Override
- public void invoke() {
- checkLoad(endUnload, va);
- }
- });
+ return candidates.get(0);
}
- /**
- * Check if there is something to load onto the vehicle in the warehouse.
- * @param now the current time
- * @param va the vehicle
- */
- public void checkLoad(DateTime now, VehicleAgent va) {
- if (va.contents.isEmpty()) {
- if (depots.contains(va.depot)) {
- // TODO continue
- }
- }
- }
}
\ No newline at end of file
Modified: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/ScanType.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/ScanType.java 2013-10-02 13:57:00 UTC (rev 323)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/ScanType.java 2013-10-03 14:03:54 UTC (rev 324)
@@ -27,12 +27,12 @@
public enum ScanType {
/** Scan at the collection depot. */
SOURCE,
- /** Manual scan at the hub off a vehicle. */
- HUB_MANUAL_UNLOAD,
- /** Manual scan at the hub onto a vehicle. */
- HUB_MANUAL_LOAD,
/** Automatic warehouse scan on enter. */
WAREHOUSE_ENTER,
+ /** Manual scan at the warehouse off a vehicle. */
+ WAREHOUSE_MANUAL_UNLOAD,
+ /** Manual scan at the warehouse onto a vehicle. */
+ WAREHOUSE_MANUAL_LOAD,
/** Automatic warehouse scan on leave. */
WAREHOUSE_LEAVE,
/** Scan at the delivery depot. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aka...@us...> - 2013-10-02 13:57:03
|
Revision: 323
http://sourceforge.net/p/advance-project/code/323
Author: akarnokd
Date: 2013-10-02 13:57:00 +0000 (Wed, 02 Oct 2013)
Log Message:
-----------
Demo refactor and more things implemented
Modified Paths:
--------------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/model/LorryPosition.java
Added Paths:
-----------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/CompareFirst.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Cons.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsItem.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Demo.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/DepotAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/HubAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/VehicleAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/WarehouseAgent.java
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/package-info.java
Removed Paths:
-------------
advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/Demo.java
Deleted: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/Demo.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/Demo.java 2013-10-01 16:15:09 UTC (rev 322)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/Demo.java 2013-10-02 13:57:00 UTC (rev 323)
@@ -1,624 +0,0 @@
-/*
- * Copyright 2010-2013 The Advance EU 7th Framework project consortium
- *
- * This file is part of Advance.
- *
- * Advance is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Advance is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Advance. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-package eu.advance.logistics.live.reporter.db;
-
-import gnu.trove.map.TLongObjectMap;
-import gnu.trove.map.hash.TLongObjectHashMap;
-import hu.akarnokd.utils.crypto.BCrypt;
-import hu.akarnokd.utils.database.DB;
-import hu.akarnokd.utils.sequence.SequenceUtils;
-
-import java.awt.Point;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
-import org.joda.time.DateMidnight;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeConstants;
-import org.joda.time.LocalTime;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-
-import eu.advance.logistics.live.reporter.model.Consignment;
-import eu.advance.logistics.live.reporter.model.Depot;
-import eu.advance.logistics.live.reporter.model.Hub;
-import eu.advance.logistics.live.reporter.model.Item;
-import eu.advance.logistics.live.reporter.model.ItemEventType;
-import eu.advance.logistics.live.reporter.model.Postcode;
-import eu.advance.logistics.live.reporter.model.ServiceLevel;
-import eu.advance.logistics.live.reporter.model.StorageArea;
-import eu.advance.logistics.live.reporter.model.UserView;
-import eu.advance.logistics.live.reporter.model.Vehicle;
-import eu.advance.logistics.live.reporter.model.Warehouse;
-
-/**
- * Prepares the database with demo data.
- * @author karnokd, 2013.09.24.
- */
-public final class Demo {
- /** Demo. */
- private Demo() { }
- /**
- * The demo program.
- * @param args no arguments
- * @throws Exception ignored
- */
- public static void main(String[] args) throws Exception {
- try (DB db = DB.connect()) {
- createMaster(db);
-
- db.commit();
-
- ConsignmentCreator cc = new ConsignmentCreator(db);
- cc.init();
- cc.run();
- cc.done();
-
- db.commit();
- }
- }
- /**
- * Create the basic hubs and depots.
- * @param db the database connection
- * @throws SQLException on error
- */
- private static void createMaster(DB db) throws SQLException {
- // create hubs
- int nHubs = 2;
- for (int i = 1; i <= nHubs; i++) {
- db.update("INSERT IGNORE INTO hubs VALUES (?, ?, ?, ?)", i, "Hub " + i, 1000, 1000);
- }
-
- // create depots
- int nDepots = 20;
- for (int i = 1; i <= nDepots; i++) {
- db.update("INSERT IGNORE INTO depots VALUES (?, ?) ", i, "Depot " + i);
-
- int nVehicles = (int)Math.ceil(5d * i / nDepots);
-
- for (int j = 1; j <= nVehicles; j++) {
- db.update("INSERT IGNORE INTO vehicles VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
- "D" + i + "V" + j, i, Integer.class, Integer.class, 50, 4, 4, 15, 4000
- );
- }
- }
-
- // create warehouses per hub
- int nWarehouses = 4;
- int nLorryPositions = 4;
-
- Random rnd = new Random(0);
-
- for (int i = 1; i <= nHubs; i++) {
- for (int j = 1; j <= nWarehouses; j++) {
- int x = 500 + (j % 2 == 1 ? -100 : 100);
- int y = 500 + (j % 2 == 1 ? -150 : 150);
- int wi = ((i - 1) * nWarehouses + j);
- db.update("INSERT IGNORE INTO warehouses VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
- i, "Warehouse " + wi, x, y, 60, 100, 0, rnd.nextInt(5) + 5, "Warehouse " + (wi % 2 == 0 ? wi - 1 : wi + 1));
-
- int sa = (nDepots / 2) * ((j - 1) / 2);
- for (int k = 0; k < nDepots / 2; k++) {
- db.update("INSERT IGNORE INTO storage_areas VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
- i, "Warehouse " + wi, k % 2, k / 2, sa + k + 1, 20, 1.5, 0, 30
- );
- }
- for (int k = 0; k < nLorryPositions; k++) {
- int lx = k % 2 == 0 ? 23 : 32;
- int ly = k / 2 == 0 ? 10 : 60;
-
- int et = k / 2 == 0 ? 15 : 30;
- int lt = k / 2 == 0 ? 30 : 15;
-
- db.update("INSERT IGNORE INTO lorry_positions VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ",
- i, "Warehouse " + wi, k, lx, ly, 5, 20, et, lt);
- }
- }
- }
-
-
- // create hub, warehouse and depot users
- for (int i = 1; i <= nHubs; i++) {
- db.update("INSERT IGNORE INTO users (name, hub, depot, admin, default_view, password) VALUES (?, ?, ?, ?, ?, ?)",
- "admin" + i, 1, Long.class, true, UserView.HUB.ordinal(), BCrypt.hashpw("admin" + i, BCrypt.gensalt()));
-
- db.update("INSERT IGNORE INTO users (name, hub, depot, admin, default_view, password) VALUES (?, ?, ?, ?, ?, ?)",
- "hub" + i, 1, Long.class, false, UserView.HUB.ordinal(), BCrypt.hashpw("hub" + i, BCrypt.gensalt()));
-
- db.update("INSERT IGNORE INTO users (name, hub, depot, admin, default_view, password) VALUES (?, ?, ?, ?, ?, ?)",
- "warehouse" + i, 1, Long.class, true, UserView.WAREHOUSE.ordinal(), BCrypt.hashpw("warehouse" + i, BCrypt.gensalt()));
- }
-
- for (int i = 1; i <= nDepots; i++) {
- db.update("INSERT IGNORE INTO users (name, hub, depot, admin, default_view, password) VALUES (?, ?, ?, ?, ?, ?)",
- "depot" + i, 1, i, false, UserView.HUB.ordinal(), BCrypt.hashpw("depot" + i, BCrypt.gensalt()));
- }
-
-
- // create holidays
- int nStartYear = 2013;
- int nEndYear = 2020;
- for (int y = nStartYear; y <= nEndYear; y++) {
- db.update("INSERT IGNORE INTO holidays VALUES (?)", new DateMidnight(y, 1, 1));
- db.update("INSERT IGNORE INTO holidays VALUES (?)", new DateMidnight(y, 12, 25));
- db.update("INSERT IGNORE INTO holidays VALUES (?)", new DateMidnight(y, 12, 26));
- db.update("INSERT IGNORE INTO holidays VALUES (?)", new DateMidnight(y, 12, 31));
- }
-
- int nPostcodes = 2000;
- for (int i = 0; i < nPostcodes; i++) {
- String pcg = "X" + (char)('A' + (i / 100));
-
- String pc = String.format("%s%02d", pcg, i % 100);
-
- db.update("INSERT IGNORE INTO postcodes VALUES (?, ?, ?) ",
- i + 1, pc, pcg);
- }
- }
- /**
- * Returns the position of a postcode.
- * @param postcode the postcode in form 'XA00'
- * @return the position
- */
- static Point postcodeLocation(String postcode) {
- int c = postcode.charAt(1) - 'A';
- int n = Integer.parseInt(postcode.substring(2));
-
- return new Point(n, c * 3);
- }
- /**
- * Returns the depot position.
- * @param depot the depot
- * @return the
- */
- static Point depotLocation(long depot) {
- int x = (int)(16 + 16 * ((depot - 1) % 5));
- int y = (int)(10 + 10 * ((depot - 1) / 5));
-
- return new Point(x, y);
- }
- /**
- * Returns the position of the hub.
- * @param hub the hub id
- * @return the position
- */
- static Point hubLocation(long hub) {
- return new Point((int)(hub * 33), 30);
- }
- /**
- * The consignment item with back-reference to the consignment itself.
- * @author karnokd, 2013.10.01.
- */
- static class ConsItem extends Item {
- /** The parent consignment. */
- public Cons consignment;
- }
- /** The created consignment. */
- static class Cons extends Consignment {
- /** The consignment items. */
- public final List<ConsItem> items = new ArrayList<>();
- }
- /**
- * The base agent class.
- * @author karnokd, 2013.10.01.
- */
- static class BaseAgent {
- /** The database connection. */
- DB db;
- /**
- * Set the database connection.
- * @param db the database connection
- */
- public void setDb(DB db) {
- this.db = db;
- }
- }
- /**
- * A depot manager "agent".
- * @author karnokd, 2013.10.01.
- *
- */
- static class DepotAgent extends BaseAgent {
- /** Depot identifier. */
- public long id;
- /** The items to deliver. */
- public final List<ConsItem> toDelivery = new ArrayList<>();
- /** The items to dispatch. */
- public final List<ConsItem> toDispatch = new ArrayList<>();
- /** The list of vehicles. */
- public final List<VehicleAgent> vehicles = new ArrayList<>();
-
- }
- /**
- * A vehicle delivering items to and from hub.
- * @author karnokd, 2013.10.01.
- */
- static class VehicleAgent extends BaseAgent {
- /** The id. */
- public String id;
- /** The owner/target depot. */
- public long depot;
- /** The vehicle capacity. */
- public int capacity;
- /** The target hub, if moving towards it. */
- public Long targetHub;
- /** The session identifier. */
- public String sessionId;
- /** In a warehouse if not null. */
- public String warehouse;
- /** In a lorry position if not null. */
- public Integer position;
- /** The contents. */
- public final List<ConsItem> contents = new ArrayList<>();
- }
- /**
- * The hub agent.
- * @author karnokd, 2013.10.01.
- */
- static class HubAgent extends BaseAgent {
- /** Identifier. */
- public long id;
- /** List of vehicles on site. */
- public final List<VehicleAgent> vehiclesOnSite = new ArrayList<>();
- /** List of vehicles. */
- public final List<WarehouseAgent> warehouses = new ArrayList<>();
- }
- /**
- * A warehouse managing items.
- * @author karnokd, 2013.10.01.
- */
- static class WarehouseAgent extends BaseAgent {
- /** The hub. */
- public long hub;
- /** The warehouse. */
- public String warehouse;
- /** The depots and the current contents. */
- public final Multimap<Long, ConsItem> storageAreas = HashMultimap.create();
- /** List of vehicles on site. */
- public final List<VehicleAgent> vehicles = new ArrayList<>();
- }
- /**
- * Consignment creator.
- * @author karnokd, 2013.10.01.
- *
- */
- static class ConsignmentCreator {
- /** The database connection. */
- DB db;
- /** Field. */
- private List<Postcode> postcodes;
- /** Field. */
- private TLongObjectMap<Postcode> postcodeMap;
- /** Field. */
- private List<Vehicle> vehicles;
- /** Field. */
- private Multimap<Long, Vehicle> depotVehicles;
- /** Field. */
- private List<Hub> hubs;
- /** Field. */
- private TLongObjectMap<Hub> hubMap;
- /** Field. */
- private List<Depot> depots;
- /** Field. */
- private TLongObjectMap<Depot> depotMap;
- /** Field. */
- private Set<DateMidnight> holidays;
- /** Field. */
- private List<Warehouse> warehouses;
- /** Field. */
- private Multimap<Long, Warehouse> warehouseMap;
- /** Field. */
- private List<StorageArea> storages;
- /** Field. */
- private Multimap<String, StorageArea> areas;
- /** Field. */
- private TLongObjectMap<Depot> postcodeClosestDepot;
- /** Field. */
- private TLongObjectMap<Hub> depotClosestHub;
- /** The running consignment id. */
- private long consId;
- /** The running item ids. */
- private long itemId;
- /** The map of depots. */
- private final TLongObjectMap<DepotAgent> depotAgents = new TLongObjectHashMap<>();
- /** The map of vehicles. */
- private final TLongObjectMap<VehicleAgent> vehicleAgents = new TLongObjectHashMap<>();
- /** The map of warehouses. */
- private final Map<String, WarehouseAgent> warehouseAgents = new HashMap<>();
- /** The map of hub agents. */
- private final TLongObjectMap<HubAgent> hubAgents = new TLongObjectHashMap<>();
- /**
- * Constructor, sets the database connection.
- * @param db the database connection
- */
- public ConsignmentCreator(DB db) {
- this.db = db;
- }
- /**
- * Initializes the environment.
- * @throws SQLException ignored
- */
- public void init() throws SQLException {
- postcodes = db.queryReadOnly("SELECT * FROM postcodes", Postcode.SELECT);
- postcodeMap = new TLongObjectHashMap<>();
- for (Postcode p : postcodes) {
- postcodeMap.put(p.id, p);
- }
-
- vehicles = db.queryReadOnly("SELECT * FROM vehicles", Vehicle.SELECT);
- depotVehicles = HashMultimap.create();
- for (Vehicle v : vehicles) {
- depotVehicles.put(v.depot, v);
- }
-
- hubs = db.queryReadOnly("SELECT * FROM hubs", Hub.SELECT);
- hubMap = new TLongObjectHashMap<>();
- for (Hub h : hubs) {
- hubMap.put(h.id, h);
- }
-
- depots = db.queryReadOnly("SELECT * FROM depots", Depot.SELECT);
- depotMap = new TLongObjectHashMap<>();
- for (Depot d : depots) {
- depotMap.put(d.id, d);
- }
-
- holidays = new HashSet<>();
- db.queryReadOnly("SELECT holiday FROM holidays", SequenceUtils.into(holidays, DB.SELECT_DATEMIDNIGHT));
-
- warehouses = db.queryReadOnly("SELECT * FROM warehouses", Warehouse.SELECT);
- warehouseMap = HashMultimap.create();
- for (Warehouse w : warehouses) {
- warehouseMap.put(w.hub, w);
- }
-
- storages = db.queryReadOnly("SELECT * FROM storage_areas", StorageArea.SELECT);
- areas = HashMultimap.create();
- for (StorageArea s : storages) {
- areas.put(s.warehouse, s);
- }
-
- postcodeClosestDepot = new TLongObjectHashMap<>();
- for (Postcode pc : postcodes) {
- double dist = 0d;
- Depot dmin = null;
- Point pcp = postcodeLocation(pc.code);
- for (Depot d : depots) {
- Point dd = depotLocation(d.id);
- double dist1 = dd.distance(pcp);
-
- if (dmin == null || dist > dist1) {
- dmin = d;
- dist = dist1;
- }
- }
- postcodeClosestDepot.put(pc.id, dmin);
- }
-
- depotClosestHub = new TLongObjectHashMap<>();
- for (Depot d : depots) {
- Hub hmin = null;
- double dist = 0d;
- Point dd = depotLocation(d.id);
- for (Hub h : hubs) {
- Point hp = hubLocation(h.id);
- double dist1 = hp.distance(dd);
- if (hmin == null || dist > dist1) {
- hmin = h;
- dist = dist1;
- }
- }
- depotClosestHub.put(d.id, hmin);
- }
-
- }
- /**
- * Generate.
- * @throws SQLException ingored
- */
- public void run() throws SQLException {
- DateMidnight startDay = new DateMidnight(2013, 7, 1);
- DateMidnight endDay = new DateMidnight(2013, 12, 31);
-
- DateMidnight day = startDay;
-
- while (day.compareTo(endDay) <= 0) {
- if (!holidays.contains(day)) {
- int dow = day.getDayOfWeek();
- if (dow != DateTimeConstants.SATURDAY && dow != DateTimeConstants.SUNDAY) {
- System.out.printf("Day: %s%n", day);
- List<Cons> cons = generate(day);
- saveCons(cons);
-
- db.commit();
- }
- }
-
- day = day.plusDays(1);
- }
- }
- /**
- * Generate a day.
- * @param day the day
- * @throws SQLException ignored
- * @return the generated consignments
- */
- List<Cons> generate(DateMidnight day) throws SQLException {
- List<Cons> r = new ArrayList<>();
- LocalTime lt = new LocalTime(7, 0);
- int dy = day.getDayOfYear();
- int dm = day.getDayOfMonth();
- int dw = day.getDayOfWeek();
- int k = 0;
- for (Postcode pc : postcodes) {
- if (pc.id % 5 != dw - 1) {
- int nf = 0;
- int nh = 0;
- int nq = 0;
- switch ((int)(pc.id % 3)) {
- case 0:
- nf = 1;
- break;
- case 1:
- nh = 1;
- nf = dy % 2 == 0 ? 1 : 0;
- nq = dy % 2 != 0 ? 1 : 0;
- break;
- case 2:
- nh = 2;
- break;
- default:
- }
-
- Postcode dpc = postcodes.get((k + postcodes.size() / 3) % postcodes.size());
-
- Cons cs = new Cons();
- r.add(cs);
- cs.id = ++consId;
- cs.created = day.toDateTime().withTime(lt.getHourOfDay(), lt.getMinuteOfHour(), lt.getSecondOfMinute(), lt.getMillisOfSecond());
- cs.itemCount = nf + nh + nq;
- cs.collectionPostcode = pc.id;
- cs.collectionDepot = postcodeClosestDepot.get(pc.id).id;
- cs.hub = depotClosestHub.get(cs.collectionDepot).id;
- cs.deliveryPostcode = dpc.id;
- cs.deliveryDepot = postcodeClosestDepot.get(dpc.id).id;
-
- int sli = ((dm + k) % 30);
- if (sli == 0) {
- cs.service = ServiceLevel.SPECIAL;
- } else
- if (sli < 5) {
- cs.service = ServiceLevel.STANDARD;
- } else
- if (sli < 9) {
- cs.service = ServiceLevel.PRIORITY;
- } else
- if (sli < 18) {
- cs.service = ServiceLevel.STANDARD;
- } else
- if (sli < 22) {
- cs.service = ServiceLevel.PRIORITY;
- } else {
- cs.service = ServiceLevel.STANDARD;
- }
-
- for (int i = 0; i < nf; i++) {
- ConsItem item = new ConsItem();
- item.consignment = cs;
- item.id = ++itemId;
- item.length = 1;
- item.width = 1;
- item.height = 1;
- cs.items.add(item);
- }
- for (int i = 0; i < nh; i++) {
- ConsItem item = new ConsItem();
- item.consignment = cs;
- item.id = ++itemId;
- item.length = 1;
- item.width = 1;
- item.height = 0.5;
- cs.items.add(item);
- }
- for (int i = 0; i < nq; i++) {
- ConsItem item = new ConsItem();
- item.consignment = cs;
- item.id = ++itemId;
- item.length = 1;
- item.width = 1;
- item.height = 0.25;
- cs.items.add(item);
- }
- }
-
- lt = lt.plusSeconds(15);
- k++;
- }
- return r;
- }
- /**
- * Save the consignments and items.
- * @param seq the sequence
- * @throws SQLException on error
- */
- void saveCons(Iterable<Cons> seq) throws SQLException {
- for (Cons cs : seq) {
- db.update("INSERT IGNORE INTO consignments VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
- cs.id, cs.created, DateTime.class,
- cs.hub, cs.collectionDepot, cs.collectionPostcode,
- cs.deliveryDepot, cs.deliveryPostcode,
- cs.service.ordinal(), cs.itemCount, String.class);
-
- db.update("INSERT IGNORE INTO consignments_history VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
- cs.id, cs.created, DateTime.class,
- cs.hub, cs.collectionDepot, cs.collectionPostcode,
- cs.deliveryDepot, cs.deliveryPostcode,
- cs.service.ordinal(), cs.itemCount, String.class);
-
- for (Item item : cs.items) {
- db.update("INSERT IGNORE INTO items VALUES (?, ?, ?, ?, ?, ?) ",
- item.id, cs.id, String.class, item.width, item.height, item.length);
- db.update("INSERT IGNORE INTO items_history VALUES (?, ?, ?, ?, ?, ?) ",
- item.id, cs.id, String.class, item.width, item.height, item.length);
-
- db.update("INSERT IGNORE INTO events VALUES (?, ?, ?, ?)",
- item.id, cs.id, cs.created, ItemEventType.CREATED.ordinal());
- }
- }
- }
- /**
- * Returns the distance between a postcode and a depot.
- * @param postcode the postcode
- * @param depot the depot
- * @return the distance
- */
- public double postcodeDepotDistance(long postcode, long depot) {
- Point pc = postcodeLocation(postcodeMap.get(postcode).code);
- Point pd = depotLocation(depot);
- return pc.distance(pd);
- }
- /**
- * The distance between a hub and depot.
- * @param depot the depot
- * @param hub the hub
- * @return the distance
- */
- public double depotHubDistance(long depot, long hub) {
- Point pd = depotLocation(depot);
- Point ph = hubLocation(hub);
- return pd.distance(ph);
- }
- /**
- * Complete.
- * @throws SQLException ignored
- */
- public void done() throws SQLException {
-
- }
- }
-}
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/CompareFirst.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/CompareFirst.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/CompareFirst.java 2013-10-02 13:57:00 UTC (rev 323)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.demo;
+
+import hu.akarnokd.reactive4java.base.Pair;
+
+import java.util.Comparator;
+
+import org.joda.time.DateTime;
+
+/**
+ * Compare the first element of a pair.
+ * @author karnokd, 2013.10.02.
+ */
+public class CompareFirst implements Comparator<Pair<DateTime, ?>> {
+ @Override
+ public int compare(Pair<DateTime, ?> o1, Pair<DateTime, ?> o2) {
+ return o1.first.compareTo(o2.first);
+ }
+}
\ No newline at end of file
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Cons.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Cons.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Cons.java 2013-10-02 13:57:00 UTC (rev 323)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.demo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.advance.logistics.live.reporter.model.Consignment;
+
+/** The created consignment. */
+public class Cons extends Consignment {
+ /** The consignment items. */
+ public final List<ConsItem> items = new ArrayList<>();
+}
\ No newline at end of file
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsItem.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsItem.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsItem.java 2013-10-02 13:57:00 UTC (rev 323)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.demo;
+
+import eu.advance.logistics.live.reporter.model.Item;
+
+/**
+ * The consignment item with back-reference to the consignment itself.
+ * @author karnokd, 2013.10.01.
+ */
+public class ConsItem extends Item {
+ /** The parent consignment. */
+ public Cons consignment;
+}
\ No newline at end of file
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/ConsignmentCreator.java 2013-10-02 13:57:00 UTC (rev 323)
@@ -0,0 +1,387 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.demo;
+
+import gnu.trove.map.TLongObjectMap;
+import gnu.trove.map.hash.TLongObjectHashMap;
+import hu.akarnokd.utils.database.DB;
+import hu.akarnokd.utils.sequence.SequenceUtils;
+
+import java.awt.Point;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.joda.time.DateMidnight;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeConstants;
+import org.joda.time.LocalTime;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+
+import eu.advance.logistics.live.reporter.model.Depot;
+import eu.advance.logistics.live.reporter.model.Hub;
+import eu.advance.logistics.live.reporter.model.Item;
+import eu.advance.logistics.live.reporter.model.LorryPosition;
+import eu.advance.logistics.live.reporter.model.Postcode;
+import eu.advance.logistics.live.reporter.model.ServiceLevel;
+import eu.advance.logistics.live.reporter.model.StorageArea;
+import eu.advance.logistics.live.reporter.model.Vehicle;
+import eu.advance.logistics.live.reporter.model.Warehouse;
+
+/**
+ * Consignment creator.
+ * @author karnokd, 2013.10.01.
+ *
+ */
+public class ConsignmentCreator {
+ /** The database connection. */
+ DB db;
+ /** Field. */
+ private List<Postcode> postcodes;
+ /** Field. */
+ private TLongObjectMap<Postcode> postcodeMap;
+ /** Field. */
+ private List<Vehicle> vehicles;
+ /** Field. */
+ private Multimap<Long, Vehicle> depotVehicles;
+ /** Field. */
+ private List<Hub> hubs;
+ /** Field. */
+ private TLongObjectMap<Hub> hubMap;
+ /** Field. */
+ private List<Depot> depots;
+ /** Field. */
+ private TLongObjectMap<Depot> depotMap;
+ /** Field. */
+ private Set<DateMidnight> holidays;
+ /** Field. */
+ private List<Warehouse> warehouses;
+ /** Field. */
+ private Multimap<Long, Warehouse> warehouseMap;
+ /** Field. */
+ private List<StorageArea> storages;
+ /** Field. */
+ private Multimap<String, StorageArea> areas;
+ /** Field. */
+ private TLongObjectMap<Depot> postcodeClosestDepot;
+ /** Field. */
+ private TLongObjectMap<Hub> depotClosestHub;
+ /** The running consignment id. */
+ private long consId;
+ /** The running item ids. */
+ private long itemId;
+ /** The environment agent. */
+ private EnvironmentAgent env;
+ /**
+ * Constructor, sets the database connection.
+ * @param db the database connection
+ */
+ public ConsignmentCreator(DB db) {
+ this.db = db;
+ }
+ /**
+ * Returns the position of a postcode.
+ * @param postcode the postcode in form 'XA00'
+ * @return the position
+ */
+ static Point postcodeLocation(String postcode) {
+ int c = postcode.charAt(1) - 'A';
+ int n = Integer.parseInt(postcode.substring(2));
+
+ return new Point(n, c * 3);
+ }
+ /**
+ * Initializes the environment.
+ * @throws SQLException ignored
+ */
+ public void init() throws SQLException {
+ postcodes = db.queryReadOnly("SELECT * FROM postcodes", Postcode.SELECT);
+ postcodeMap = new TLongObjectHashMap<>();
+ for (Postcode p : postcodes) {
+ postcodeMap.put(p.id, p);
+ }
+
+ vehicles = db.queryReadOnly("SELECT * FROM vehicles", Vehicle.SELECT);
+ depotVehicles = HashMultimap.create();
+ for (Vehicle v : vehicles) {
+ depotVehicles.put(v.depot, v);
+ }
+
+ hubs = db.queryReadOnly("SELECT * FROM hubs", Hub.SELECT);
+ hubMap = new TLongObjectHashMap<>();
+ for (Hub h : hubs) {
+ hubMap.put(h.id, h);
+ }
+
+ depots = db.queryReadOnly("SELECT * FROM depots", Depot.SELECT);
+ depotMap = new TLongObjectHashMap<>();
+ for (Depot d : depots) {
+ depotMap.put(d.id, d);
+ }
+
+ holidays = new HashSet<>();
+ db.queryReadOnly("SELECT holiday FROM holidays", SequenceUtils.into(holidays, DB.SELECT_DATEMIDNIGHT));
+
+ warehouses = db.queryReadOnly("SELECT * FROM warehouses", Warehouse.SELECT);
+ warehouseMap = HashMultimap.create();
+ for (Warehouse w : warehouses) {
+ warehouseMap.put(w.hub, w);
+ }
+
+ storages = db.queryReadOnly("SELECT * FROM storage_areas", StorageArea.SELECT);
+ areas = HashMultimap.create();
+ for (StorageArea s : storages) {
+ areas.put(s.warehouse, s);
+ }
+
+ postcodeClosestDepot = new TLongObjectHashMap<>();
+ for (Postcode pc : postcodes) {
+ double dist = 0d;
+ Depot dmin = null;
+ Point pcp = postcodeLocation(pc.code);
+ for (Depot d : depots) {
+ Point dd = EnvironmentAgent.depotLocation(d.id);
+ double dist1 = dd.distance(pcp);
+
+ if (dmin == null || dist > dist1) {
+ dmin = d;
+ dist = dist1;
+ }
+ }
+ postcodeClosestDepot.put(pc.id, dmin);
+ }
+
+ depotClosestHub = new TLongObjectHashMap<>();
+ for (Depot d : depots) {
+ Hub hmin = null;
+ double dist = 0d;
+ Point dd = EnvironmentAgent.depotLocation(d.id);
+ for (Hub h : hubs) {
+ Point hp = EnvironmentAgent.hubLocation(h.id);
+ double dist1 = hp.distance(dd);
+ if (hmin == null || dist > dist1) {
+ hmin = h;
+ dist = dist1;
+ }
+ }
+ depotClosestHub.put(d.id, hmin);
+ }
+
+ List<LorryPosition> lorryPositions = db.queryReadOnly("SELECT * FROM lorry_positions", LorryPosition.SELECT);
+
+ // ----------------------------------------------------------
+
+ env = new EnvironmentAgent(db);
+ env.setHubs(hubs);
+ env.setWarehouses(warehouses);
+ env.setStorageAreas(storages);
+ env.setDepots(depots);
+ env.setVehicles(vehicles);
+ env.setLorryPositions(lorryPositions);
+
+ }
+ /**
+ * Generate.
+ * @throws SQLException ingored
+ */
+ public void run() throws SQLException {
+ DateMidnight startDay = new DateMidnight(2013, 7, 1);
+ DateMidnight endDay = new DateMidnight(2013, 12, 31);
+
+ DateMidnight day = startDay;
+
+ while (day.compareTo(endDay) <= 0) {
+ if (!holidays.contains(day)) {
+ int dow = day.getDayOfWeek();
+ if (dow != DateTimeConstants.SATURDAY && dow != DateTimeConstants.SUNDAY) {
+ System.out.printf("Day: %s%n", day);
+ List<Cons> cons = generate(day);
+ DateTime max = saveCons(cons);
+ db.commit();
+
+ if (max != null) {
+ env.consignmentsEnd(max);
+ }
+ }
+ }
+
+ day = day.plusDays(1);
+
+ env.eventLoop();
+ db.commit();
+ }
+ env.eventLoop();
+ db.commit();
+ }
+ /**
+ * Generate a day.
+ * @param day the day
+ * @throws SQLException ignored
+ * @return the generated consignments
+ */
+ List<Cons> generate(DateMidnight day) throws SQLException {
+ List<Cons> r = new ArrayList<>();
+ LocalTime lt = new LocalTime(7, 0);
+ int dy = day.getDayOfYear();
+ int dm = day.getDayOfMonth();
+ int dw = day.getDayOfWeek();
+ int k = 0;
+ for (Postcode pc : postcodes) {
+ if (pc.id % 5 != dw - 1) {
+ int nf = 0;
+ int nh = 0;
+ int nq = 0;
+ switch ((int)(pc.id % 3)) {
+ case 0:
+ nf = 1;
+ break;
+ case 1:
+ nh = 1;
+ nf = dy % 2 == 0 ? 1 : 0;
+ nq = dy % 2 != 0 ? 1 : 0;
+ break;
+ case 2:
+ nh = 2;
+ break;
+ default:
+ }
+
+ Postcode dpc = postcodes.get((k + postcodes.size() / 3) % postcodes.size());
+
+ Cons cs = new Cons();
+ r.add(cs);
+ cs.id = ++consId;
+ cs.created = day.toDateTime().withTime(lt.getHourOfDay(), lt.getMinuteOfHour(), lt.getSecondOfMinute(), lt.getMillisOfSecond());
+ cs.itemCount = nf + nh + nq;
+ cs.collectionPostcode = pc.id;
+ cs.collectionDepot = postcodeClosestDepot.get(pc.id).id;
+ cs.hub = depotClosestHub.get(cs.collectionDepot).id;
+ cs.deliveryPostcode = dpc.id;
+ cs.deliveryDepot = postcodeClosestDepot.get(dpc.id).id;
+ cs.externalId = "C" + cs.id;
+
+ int sli = ((dm + k) % 30);
+ if (sli == 0) {
+ cs.service = ServiceLevel.SPECIAL;
+ } else
+ if (sli < 5) {
+ cs.service = ServiceLevel.STANDARD;
+ } else
+ if (sli < 9) {
+ cs.service = ServiceLevel.PRIORITY;
+ } else
+ if (sli < 18) {
+ cs.service = ServiceLevel.STANDARD;
+ } else
+ if (sli < 22) {
+ cs.service = ServiceLevel.PRIORITY;
+ } else {
+ cs.service = ServiceLevel.STANDARD;
+ }
+
+ for (int i = 0; i < nf; i++) {
+ ConsItem item = new ConsItem();
+ item.consignment = cs;
+ item.id = ++itemId;
+ item.length = 1;
+ item.width = 1;
+ item.height = 1;
+ item.externalId = cs.externalId + "I" + item.id;
+ cs.items.add(item);
+ }
+ for (int i = 0; i < nh; i++) {
+ ConsItem item = new ConsItem();
+ item.consignment = cs;
+ item.id = ++itemId;
+ item.length = 1;
+ item.width = 1;
+ item.height = 0.5;
+ item.externalId = cs.externalId + "I" + item.id;
+ cs.items.add(item);
+ }
+ for (int i = 0; i < nq; i++) {
+ ConsItem item = new ConsItem();
+ item.consignment = cs;
+ item.id = ++itemId;
+ item.length = 1;
+ item.width = 1;
+ item.height = 0.25;
+ item.externalId = cs.externalId + "I" + item.id;
+ cs.items.add(item);
+ }
+
+ for (ConsItem ci : cs.items) {
+ env.newItem(ci);
+ }
+ }
+
+
+
+ lt = lt.plusSeconds(15);
+ k++;
+ }
+ return r;
+ }
+ /**
+ * Save the consignments and items.
+ * @param seq the sequence
+ * @return the latest creation timestamp
+ * @throws SQLException on error
+ */
+ DateTime saveCons(Iterable<Cons> seq) throws SQLException {
+ DateTime max = null;
+ for (Cons cs : seq) {
+ db.update("INSERT IGNORE INTO consignments VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ cs.id, cs.created, DateTime.class,
+ cs.hub, cs.collectionDepot, cs.collectionPostcode,
+ cs.deliveryDepot, cs.deliveryPostcode,
+ cs.service.ordinal(), cs.itemCount, cs.externalId);
+
+ db.update("INSERT IGNORE INTO consignments_history VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ cs.id, cs.created, DateTime.class,
+ cs.hub, cs.collectionDepot, cs.collectionPostcode,
+ cs.deliveryDepot, cs.deliveryPostcode,
+ cs.service.ordinal(), cs.itemCount, cs.externalId);
+
+ for (Item item : cs.items) {
+ db.update("INSERT IGNORE INTO items VALUES (?, ?, ?, ?, ?, ?) ",
+ item.id, cs.id, item.externalId, item.width, item.height, item.length);
+ db.update("INSERT IGNORE INTO items_history VALUES (?, ?, ?, ?, ?, ?) ",
+ item.id, cs.id, item.externalId, item.width, item.height, item.length);
+ }
+ if (max == null || max.compareTo(cs.created) < 0) {
+ max = cs.created;
+ }
+ }
+ return max;
+ }
+ /**
+ * Complete.
+ * @throws SQLException ignored
+ */
+ public void done() throws SQLException {
+
+ }
+}
\ No newline at end of file
Copied: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Demo.java (from rev 322, advance-live-reporter-os/src/eu/advance/logistics/live/reporter/db/Demo.java)
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Demo.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/Demo.java 2013-10-02 13:57:00 UTC (rev 323)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.demo;
+
+import hu.akarnokd.utils.crypto.BCrypt;
+import hu.akarnokd.utils.database.DB;
+
+import java.sql.SQLException;
+import java.util.Random;
+
+import org.joda.time.DateMidnight;
+
+import eu.advance.logistics.live.reporter.model.UserView;
+
+/**
+ * Prepares the database with demo data.
+ * @author karnokd, 2013.09.24.
+ */
+public final class Demo {
+ /** Demo. */
+ private Demo() { }
+ /**
+ * The demo program.
+ * @param args no arguments
+ * @throws Exception ignored
+ */
+ public static void main(String[] args) throws Exception {
+ try (DB db = DB.connect()) {
+ createMaster(db);
+
+ db.commit();
+
+ ConsignmentCreator cc = new ConsignmentCreator(db);
+ cc.init();
+ cc.run();
+ cc.done();
+
+ db.commit();
+ }
+ }
+ /**
+ * Create the basic hubs and depots.
+ * @param db the database connection
+ * @throws SQLException on error
+ */
+ private static void createMaster(DB db) throws SQLException {
+ // create hubs
+ int nHubs = 2;
+ for (int i = 1; i <= nHubs; i++) {
+ db.update("INSERT IGNORE INTO hubs VALUES (?, ?, ?, ?)", i, "Hub " + i, 1000, 1000);
+ }
+
+ // create depots
+ int nDepots = 20;
+ for (int i = 1; i <= nDepots; i++) {
+ db.update("INSERT IGNORE INTO depots VALUES (?, ?) ", i, "Depot " + i);
+
+ int nVehicles = (int)Math.ceil(5d * i / nDepots);
+
+ for (int j = 1; j <= nVehicles; j++) {
+ db.update("INSERT IGNORE INTO vehicles VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ "D" + i + "V" + j, i, Integer.class, Integer.class, 50, 4, 4, 15, 4000
+ );
+ }
+ }
+
+ // create warehouses per hub
+ int nWarehouses = 4;
+ int nLorryPositions = 4;
+
+ Random rnd = new Random(0);
+
+ for (int i = 1; i <= nHubs; i++) {
+ for (int j = 1; j <= nWarehouses; j++) {
+ int x = 500 + (j % 2 == 1 ? -100 : 100);
+ int y = 500 + (j % 2 == 1 ? -150 : 150);
+ int wi = ((i - 1) * nWarehouses + j);
+ db.update("INSERT IGNORE INTO warehouses VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ i, "Warehouse " + wi, x, y, 60, 100, 0, rnd.nextInt(5) + 5, "Warehouse " + (wi % 2 == 0 ? wi - 1 : wi + 1));
+
+ int sa = (nDepots / 2) * ((j - 1) / 2);
+ for (int k = 0; k < nDepots / 2; k++) {
+ db.update("INSERT IGNORE INTO storage_areas VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ i, "Warehouse " + wi, k % 2, k / 2, sa + k + 1, 20, 1.5, 0, 30
+ );
+ }
+ for (int k = 0; k < nLorryPositions; k++) {
+ int lx = k % 2 == 0 ? 23 : 32;
+ int ly = k / 2 == 0 ? 10 : 60;
+
+ int et = k / 2 == 0 ? 15 : 30;
+ int lt = k / 2 == 0 ? 30 : 15;
+
+ db.update("INSERT IGNORE INTO lorry_positions VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ",
+ i, "Warehouse " + wi, k, lx, ly, 5, 20, et, lt);
+ }
+ }
+ }
+
+
+ // create hub, warehouse and depot users
+ for (int i = 1; i <= nHubs; i++) {
+ db.update("INSERT IGNORE INTO users (name, hub, depot, admin, default_view, password) VALUES (?, ?, ?, ?, ?, ?)",
+ "admin" + i, 1, Long.class, true, UserView.HUB.ordinal(), BCrypt.hashpw("admin" + i, BCrypt.gensalt()));
+
+ db.update("INSERT IGNORE INTO users (name, hub, depot, admin, default_view, password) VALUES (?, ?, ?, ?, ?, ?)",
+ "hub" + i, 1, Long.class, false, UserView.HUB.ordinal(), BCrypt.hashpw("hub" + i, BCrypt.gensalt()));
+
+ db.update("INSERT IGNORE INTO users (name, hub, depot, admin, default_view, password) VALUES (?, ?, ?, ?, ?, ?)",
+ "warehouse" + i, 1, Long.class, true, UserView.WAREHOUSE.ordinal(), BCrypt.hashpw("warehouse" + i, BCrypt.gensalt()));
+ }
+
+ for (int i = 1; i <= nDepots; i++) {
+ db.update("INSERT IGNORE INTO users (name, hub, depot, admin, default_view, password) VALUES (?, ?, ?, ?, ?, ?)",
+ "depot" + i, 1, i, false, UserView.HUB.ordinal(), BCrypt.hashpw("depot" + i, BCrypt.gensalt()));
+ }
+
+
+ // create holidays
+ int nStartYear = 2013;
+ int nEndYear = 2020;
+ for (int y = nStartYear; y <= nEndYear; y++) {
+ db.update("INSERT IGNORE INTO holidays VALUES (?)", new DateMidnight(y, 1, 1));
+ db.update("INSERT IGNORE INTO holidays VALUES (?)", new DateMidnight(y, 12, 25));
+ db.update("INSERT IGNORE INTO holidays VALUES (?)", new DateMidnight(y, 12, 26));
+ db.update("INSERT IGNORE INTO holidays VALUES (?)", new DateMidnight(y, 12, 31));
+ }
+
+ int nPostcodes = 2000;
+ for (int i = 0; i < nPostcodes; i++) {
+ String pcg = "X" + (char)('A' + (i / 100));
+
+ String pc = String.format("%s%02d", pcg, i % 100);
+
+ db.update("INSERT IGNORE INTO postcodes VALUES (?, ?, ?) ",
+ i + 1, pc, pcg);
+ }
+ }
+}
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/DepotAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/DepotAgent.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/DepotAgent.java 2013-10-02 13:57:00 UTC (rev 323)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.demo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.joda.time.DateTime;
+
+import eu.advance.logistics.live.reporter.model.ItemEventType;
+
+/**
+ * A depot manager "agent".
+ * @author karnokd, 2013.10.01.
+ *
+ */
+public class DepotAgent {
+ /** Depot identifier. */
+ public long id;
+ /** The items to deliver. */
+ public final List<ConsItem> toDeliver = new ArrayList<>();
+ /** The list of own vehicles. */
+ public final List<VehicleAgent> vehicles = new ArrayList<>();
+ /** The vehicles on site. */
+ public final List<VehicleAgent> onSite = new ArrayList<>();
+ /** The environment. */
+ private EnvironmentAgent env;
+ /**
+ * Constructor, sets the environment.
+ * @param env the environment
+ */
+ public DepotAgent(EnvironmentAgent env) {
+ this.env = env;
+ }
+ /**
+ * Item arrived from the collection postcode.
+ * @param now the current time
+ * @param item the item
+ */
+ public void itemArrived(DateTime now, ConsItem item) {
+ toDeliver.add(item);
+ checkLoadVehicle(now);
+ }
+ /**
+ * Vehicle arrived at the depot.
+ * @param now the arrival time
+ * @param va the vehicle
+ */
+ public void vehicleArrived(DateTime now, VehicleAgent va) {
+ for (ConsItem item : va.contents) {
+ env.event(item.id, item.consignmentId, now, ItemEventType.DESTINATION_SCAN);
+ }
+ va.contents.clear();
+ va.targetHub = null;
+ va.atDepot = true;
+ onSite.add(va);
+ checkLoadVehicle(now);
+ }
+ /**
+ * Check if vehicles can be loaded.
+ * @param now the current time
+ */
+ public void checkLoadVehicle(DateTime now) {
+ if (!onSite.isEmpty()) {
+ for (ConsItem ci : new ArrayList<>(toDeliver)) {
+ List<VehicleAgent> vas = new ArrayList<>(onSite);
+ Collections.sort(vas, VehicleAgent.CAPACITY);
+ for (VehicleAgent va : vas) {
+ if (va.tryLoadInDepot(now, ci)) {
+ toDeliver.remove(ci);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/EnvironmentAgent.java 2013-10-02 13:57:00 UTC (rev 323)
@@ -0,0 +1,378 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.demo;
+
+import eu.advance.logistics.live.reporter.model.Depot;
+import eu.advance.logistics.live.reporter.model.Hub;
+import eu.advance.logistics.live.reporter.model.ItemEventType;
+import eu.advance.logistics.live.reporter.model.LorryPosition;
+import eu.advance.logistics.live.reporter.model.ScanType;
+import eu.advance.logistics.live.reporter.model.StorageArea;
+import eu.advance.logistics.live.reporter.model.Vehicle;
+import eu.advance.logistics.live.reporter.model.Warehouse;
+import gnu.trove.map.TLongObjectMap;
+import gnu.trove.map.hash.TLongObjectHashMap;
+import hu.akarnokd.reactive4java.base.Action0;
+import hu.akarnokd.reactive4java.base.Pair;
+import hu.akarnokd.utils.database.DB;
+
+import java.awt.Point;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.PriorityQueue;
+
+import org.joda.time.DateTime;
+
+/**
+ * The base environment for the agents.
+ * @author karnokd, 2013.10.02.
+ */
+public class EnvironmentAgent {
+ /** The database connection. */
+ protected final DB db;
+ /** The map of depots. */
+ private final TLongObjectMap<DepotAgent> depotAgents = new TLongObjectHashMap<>();
+ /** The map of vehicles. */
+ private final Map<String, VehicleAgent> vehicleAgents = new HashMap<>();
+ /** The map of warehouses. */
+ private final Map<String, WarehouseAgent> warehouseAgents = new HashMap<>();
+ /** The map of hub agents. */
+ private final TLongObjectMap<HubAgent> hubAgents = new TLongObjectHashMap<>();
+ /** The event sequence. */
+ private final PriorityQueue<Pair<DateTime, Action0>> events = new PriorityQueue<>(256, new CompareFirst());
+ /**
+ * Constructor.
+ * @param db the database
+ */
+ public EnvironmentAgent(DB db) {
+ this.db = db;
+ }
+ /**
+ * The event loop.
+ */
+ public void eventLoop() {
+ while (!events.isEmpty()) {
+ Pair<DateTime, Action0> e = events.remove();
+ e.second.invoke();
+ }
+ }
+ /**
+ * Add a new event to the queue.
+ * @param timestamp the timestamp
+ * @param action the action
+ */
+ public void add(DateTime timestamp, Action0 action) {
+ events.add(Pair.of(timestamp, action));
+ }
+ /**
+ * Create hub agents.
+ * @param hubs the sequence of hubs
+ */
+ public void setHubs(Iterable<Hub> hubs) {
+ hubAgents.clear();
+ for (Hub h : hubs) {
+ HubAgent ha = new HubAgent(this);
+ ha.id = h.id;
+ hubAgents.put(ha.id, ha);
+ }
+ }
+ /**
+ * Create warehouse agents for hubs.
+ * @param warehouses the warehouses
+ */
+ public void setWarehouses(Iterable<Warehouse> warehouses) {
+ warehouseAgents.clear();
+ for (Warehouse wh : warehouses) {
+ HubAgent ha = hubAgents.get(wh.hub);
+
+ WarehouseAgent wa = new WarehouseAgent(this);
+ wa.hub = wh.hub;
+ wa.warehouse = wh.warehouse;
+
+ ha.warehouses.add(wa);
+
+ warehouseAgents.put(wa.warehouse, wa);
+ }
+ }
+ /**
+ * Set the storage areas insode warehouses.
+ * @param storages the storage areas
+ */
+ public void setStorageAreas(Iterable<StorageArea> storages) {
+ for (StorageArea sa : storages) {
+ WarehouseAgent wa = warehouseAgents.get(sa.warehouse);
+
+ wa.depots.add(sa.depot);
+ }
+ }
+ /**
+ * Create the depot agents.
+ * @param depots the depots
+ */
+ public void setDepots(Iterable<Depot> depots) {
+ depotAgents.clear();
+ for (Depot d : depots) {
+ DepotAgent da = new DepotAgent(this);
+ da.id = d.id;
+
+ depotAgents.put(da.id, da);
+ }
+
+ }
+ /**
+ * Create the vehicle agents.
+ * @param vehicles the vehicle
+ */
+ public void setVehicles(Iterable<Vehicle> vehicles) {
+ vehicleAgents.clear();
+ for (Vehicle v : vehicles) {
+ DepotAgent da = depotAgents.get(v.depot);
+
+ VehicleAgent va = new VehicleAgent(this);
+ va.id = v.vehicleId;
+ va.depot = v.depot;
+ va.capacity = v.capacity;
+
+ da.onSite.add(va);
+ da.vehicles.add(va);
+
+ vehicleAgents.put(va.id, va);
+ }
+ }
+ /**
+ * Set the lorry positions in warehouses.
+ * @param lorryPositions the lorry position sequence
+ */
+ public void setLorryPositions(Iterable<LorryPosition> lorryPositions) {
+ for (LorryPosition lp : lorryPositions) {
+ WarehouseAgent wa = warehouseAgents.get(lp.warehouse);
+ wa.positions.add(lp);
+ }
+ }
+ /**
+ * Stores an event for a particulare item.
+ * @param itemId the item identifier
+ * @param consignmentId the parent consignment id
+ * @param timestamp the event timestamp
+ * @param event the event
+ */
+ public void event(long itemId, long consignmentId, DateTime timestamp, ItemEventType event) {
+ try {
+ db.update("INSERT INGORE INTO events VALUES (?, ?, ?, ?)", itemId, consignmentId, timestamp, event.ordinal());
+ } catch (SQLException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ /**
+ * Returns the depot position.
+ * @param depot the depot
+ * @return the
+ */
+ static Point depotLocation(long depot) {
+ int x = (int)(16 + 16 * ((depot - 1) % 5));
+ int y = (int)(10 + 10 * ((depot - 1) / 5));
+
+ return new Point(x, y);
+ }
+ /**
+ * Returns the position of the hub.
+ * @param hub the hub id
+ * @return the position
+ */
+ static Point hubLocation(long hub) {
+ return new Point((int)(hub * 33), 30);
+ }
+ /**
+ * Returns the position of a postcode.
+ * @param postcode the postcode in form 'XA00'
+ * @return the position
+ */
+ static Point postcodeLocation(long postcode) {
+ int c = (int)((postcode - 1) / 100);
+ int n = (int)((postcode - 1) % 100);
+
+ return new Point(n, c * 3);
+ }
+ /**
+ * Returns the distance between a postcode and a depot.
+ * @param postcode the postcode
+ * @param depot the depot
+ * @return the distance
+ */
+ public double postcodeDepotDistance(long postcode, long depot) {
+ Point pc = postcodeLocation(postcode);
+ Point pd = depotLocation(depot);
+ return pc.distance(pd);
+ }
+ /**
+ * The distance between a hub and depot.
+ * @param depot the depot
+ * @param hub the hub
+ * @return the distance
+ */
+ public double depotHubDistance(long depot, long hub) {
+ Point pd = depotLocation(depot);
+ Point ph = hubLocation(hub);
+ return pd.distance(ph);
+ }
+ /**
+ * Computes the arrival time of an item travelling from the postcode to the depot.
+ * @param now the current time
+ * @param postcode the postcode
+ * @param depot the depot
+ * @return the arrival time
+ */
+ public DateTime postcodeDepotTravel(DateTime now, long postcode, long depot) {
+ double d = postcodeDepotDistance(postcode, depot) * 60 * 1.5;
+
+ return now.plusSeconds((int)d);
+ }
+ /**
+ * Computes the arrival time of a vehicle, from depot to hub.
+ * @param now the current time
+ * @param depot the depot
+ * @param hub the hub
+ * @return the arrival time
+ */
+ public DateTime depotHubTravel(DateTime now, long depot, long hub) {
+ double d = depotHubDistance(depot, hub) * 60 * 1.5;
+
+ return now.plusSeconds((int)d);
+ }
+ /**
+ * Add a new item.
+ * @param item the item
+ */
+ public void newItem(final ConsItem item) {
+
+ event(item.id, item.consignmentId, item.consignment.created, ItemEventType.CREATED);
+
+ final DateTime depotArrive = postcodeDepotTravel(item.consignment.created, item.consignment.collectionPostcode, item.consignment.collectionDepot);
+
+ final DepotAgent da = depotAgents.get(item.consignment.collectionDepot);
+
+ add(depotArrive, new Action0() {
+ @Override
+ public void invoke() {
+ da.itemArrived(depotArrive, item);
+ }
+ });
+ }
+ /**
+ * Register a collection scan.
+ * @param vehicleId the vehicle identifier
+ * @param when the scan time
+ * @param item the item
+ */
+ public void collectionScan(String vehicleId, DateTime when, ConsItem item) {
+ event(item.id, item.consignmentId, when, ItemEventType.SOURCE_SCAN);
+
+ try {
+ db.update("INSERT IGNORE INTO scans VALUES (?, ?, ?, ?, ?, ?, ?)",
+ item.consignmentId, item.id, ScanType.SOURCE.ordinal(),
+ item.consignment.collectionDepot, true, when, vehicleId);
+
+ db.update("INSERT IGNORE INTO scans_history VALUES (?, ?, ?, ?, ?, ?, ?)",
+ item.consignmentId, item.id, ScanType.SOURCE.ordinal(),
+ item.consignment.collectionDepot, true, when, vehicleId);
+ } catch (SQLException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ /**
+ * Declare a pallet on a vehicle.
+ * @param vehicleId the vehicle identifier
+ * @param when the time of the declaration
+ * @param externalItemId the item identifier
+ */
+ public void declare(String vehicleId, DateTime when, String externalItemId) {
+ int iidx = externalItemId.indexOf("I");
+ long consId = Long.parseLong(externalItemId.substring(1, iidx));
+// long itemId = Long.parseLong(externalItemId.substring(iidx + 1));
+
+ try {
+ db.update("INSERT IGNORE INTO vehicle_declared VALUES (?, ?, ?)", vehicleId, when, externalItemId);
+ db.update("UPDATE consignments SET declared = ? WHERE id = ?", when, consId);
+ db.update("UPDATE consignments_history SET declared = ? WHERE id = ?", when, consId);
+ } catch (SQLException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ /**
+ * Vehicle arrived at hub.
+ * @param now the current time
+ * @param hub the hub
+ * @param va the vehicle
+ */
+ public void hubArrive(final DateTime now, final long hub, final VehicleAgent va) {
+ va.sessionId = hub + "_" + now.toString("yyyyMMdd'_'HHmmss") + "_" + va.id;
+ va.atHub = true;
+
+ for (ConsItem ci : va.contents) {
+ event(ci.id, ci.consignmentId, now, ItemEventType.HUB_ARRIVE);
+ }
+
+ HubAgent ha = hubAgents.get(va.targetHub);
+ ha.vehiclesOnSite.add(va);
+ ha.loadUnload(now);
+ }
+ /**
+ * Register the contents of the vehicle entering/leaving its warehouse.
+ * @param va the vehicle
+ * @param now the current time
+ * @param enter is enter?
+ */
+ public void warehouseScan(VehicleAgent va, DateTime now, boolean enter) {
+ try {
+ long sid = db.insertAuto("INSERT INTO vehicle_scan (session_id, scan_timestamp, warehouse, entry) VALUES (?, ?, ?, ?)",
+ va.sessionId, now, va.warehouse, enter
+ );
+ for (ConsItem ci : va.contents) {
+ event(ci.id, ci.consignmentId, now, ItemEventType.WAREHOUSE_ENTER);
+ db.update("INSERT INTO vehicle_items VALUES (?, ?) ", sid, ci.externalId);
+
+ ScanType st = enter ? ScanType.WAREHOUSE_ENTER : ScanType.WAREHOUSE_LEAVE;
+
+ db.update("INSERT IGNORE INTO scans VALUES (?, ?, ?, ?, ?, ?)",
+ ci.consignmentId, ci.id, st,
+ va.targetHub + " " + va.warehouse, now, va.id);
+
+ db.update("INSERT IGNORE INTO scans_history VALUES (?, ?, ?, ?, ?, ?)",
+ ci.consignmentId, ci.id, st,
+ va.targetHub + " " + va.warehouse, now, va.id);
+
+ }
+ } catch (SQLException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ /**
+ * Indicate that no more consignments will appear on the given day.
+ * @param now the current time
+ */
+ public void consignmentsEnd(DateTime now) {
+ // TODO
+ for (DepotAgent da : depotAgents.valueCollection()) {
+
+ }
+ }
+}
Added: advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/HubAgent.java
===================================================================
--- advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/HubAgent.java (rev 0)
+++ advance-live-reporter-os/src/eu/advance/logistics/live/reporter/demo/HubAgent.java 2013-10-02 13:57:00 UTC (rev 323)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2010-2013 The Advance EU 7th Framework project consortium
+ *
+ * This file is part of Advance.
+ *
+ * Advance is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Advance is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Advance. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+package eu.advance.logistics.live.reporter.demo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.joda.time.DateTime;
+
+/**
+ * The hub agent.
+ * @author karnokd, 2013.10.01.
+ */
+publi...
[truncated message content] |