|
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.
|