gee-svn Mailing List for Group Experiments Environment (Page 3)
Status: Alpha
Brought to you by:
alllee
You can subscribe to this list here.
2006 |
Jan
|
Feb
(14) |
Mar
(47) |
Apr
(4) |
May
(14) |
Jun
(10) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
---|
From: <al...@us...> - 2006-03-05 18:16:27
|
Revision: 148 Author: alllee Date: 2006-03-05 10:16:20 -0800 (Sun, 05 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=148&view=rev Log Message: ----------- mindless hygiene, removing unused constructors, using Point2D's distance function instead of manually writing out the Cartesian distance formula. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java trunk/gee/src/java/edu/indiana/psych/gee/forager/Visibility.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java 2006-03-05 07:59:51 UTC (rev 147) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java 2006-03-05 18:16:20 UTC (rev 148) @@ -7,6 +7,9 @@ import java.util.List; import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import edu.indiana.psych.gee.agent.Agent; import edu.indiana.psych.gee.agent.AgentFactory; import edu.indiana.psych.gee.agent.AgentIdentifier; @@ -14,6 +17,8 @@ class ForagerAgentFactory implements AgentFactory<ForagerExperimentParameters> { + private final static Log logger = LogFactory.getLog(ForagerAgentFactory.class); + public ForagerAgent create(ForagerExperimentParameters parameters) { Visibility visibility = parameters.getFoodVisibility(); // FIXME: add support for partial visibility here. @@ -59,16 +64,6 @@ return new Point(x, y); } - private int clamp(double value, int start, int end) { - if (value >= end) { - return end - 1; - } - else if (value < start) { - return start; - } - return (int) Math.floor(value); - } - // FIXME: optimization hotspot // should be able to just iterate through the food // positions and tell if it belongs to a quadrant through straight-up @@ -106,7 +101,7 @@ Point gridGoal = null; if (new Double(total).isNaN()) { // if total is way big, pick random grid goal - System.out.println("VisibleFoodAgent: total was NaN"); + logger.debug("total was NaN, picking randomly"); int newx = (int) Math.floor(Math.random() * grid_x); int newy = (int) Math.floor(Math.random() * grid_y); gridGoal = new Point(newx, newy); @@ -135,7 +130,7 @@ newy += (gridGoal.getY() * gridsize_y); setCurrentGoal(new Point(newx, newy)); - // System.out.println("next goal set at: x: " + newx + " y: " + newy); + logger.debug("next goal set at: x: " + newx + " y: " + newy); } public Direction move() { @@ -151,8 +146,9 @@ for (Point currentPoint : pieces) { // cartesian distance between the current piece of food and // this agent's current location. - current = Math.sqrt(Math.pow(currentPoint.x - location.x, 2) + - Math.pow(currentPoint.y - location.y, 2)); + current = location.distance(currentPoint); +// Math.sqrt(Math.pow(currentPoint.x - location.x, 2) + +// Math.pow(currentPoint.y - location.y, 2)); if (current < closest || closest == -1) { closestPoint = currentPoint; closest = current; @@ -209,7 +205,7 @@ Point gridGoal = null; if (new Double(total).isNaN()) { // if total is way big, pick random grid goal - System.out.println("InvisibleFoodAgent: total was NaN"); + logger.debug("total was NaN, picking randomly"); int newx = (int) Math.floor(Math.random() * grid_x); int newy = (int) Math.floor(Math.random() * grid_y); gridGoal = new Point(newx, newy); @@ -237,7 +233,7 @@ newy += (gridGoal.getY() * gridsize_y); setCurrentGoal(new Point(newx, newy)); - // System.out.println("next goal set at: x: " + newx + " y: " + newy); + logger.debug("next goal set at: x: " + newx + " y: " + newy); } @@ -297,7 +293,7 @@ this.config = experimentConfiguration; // are agents visible - this.visibleAgents = ! experimentConfiguration.getSubjectVisibility().isZeroVisibility(); + this.visibleAgents = ! experimentConfiguration.getSubjectVisibility().isZero(); // find how out big grid we have board_x = experimentConfiguration.getBoardSize().width; @@ -337,7 +333,7 @@ int posx = (int) Math.floor((double) location.x / (double) gridsize_x); int posy = (int) Math.floor((double) location.y / (double) gridsize_y); - if (event.wasFoodConsumed()) { + if (event.didConsumeFood()) { Qgrid[posx][posy] += foodReward; } else { Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/Visibility.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/Visibility.java 2006-03-05 07:59:51 UTC (rev 147) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/Visibility.java 2006-03-05 18:16:20 UTC (rev 148) @@ -57,7 +57,7 @@ * * @return */ - public boolean isZeroVisibility() { + public boolean isZero() { return this == ZERO; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java 2006-03-05 07:59:51 UTC (rev 147) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java 2006-03-05 18:16:20 UTC (rev 148) @@ -73,7 +73,7 @@ } clientState.setPosition(point); } - if (event.wasFoodConsumed()) { + if (event.didConsumeFood()) { ClientState clientState = clients.get(event.id()); clientState.incrementFoodEaten(); // FIXME: drop an event into the event channel to signal the ForagerGameWindow Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java 2006-03-05 07:59:51 UTC (rev 147) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java 2006-03-05 18:16:20 UTC (rev 148) @@ -1,7 +1,6 @@ package edu.indiana.psych.gee.forager.event; import java.awt.Point; -import java.util.Collections; import java.util.Map; import java.util.Set; @@ -15,7 +14,7 @@ * $Id$ * * Maintains a Map of all clients and their locations (denoted by - * java.awt.Point-S). If the foodEaten point is null, then no food was + * java.awt.Point-S). If the didConsumeFood point is null, then no food was * consumed by the client identified by this Event's Identifier. * * Can also maintain a list of food positions, if the food is visible @@ -29,28 +28,29 @@ private static final long serialVersionUID = -128693557750400520L; private final Map<Identifier, Point> clientPositions; private final Set<Point> foodPositions; - private final boolean foodEaten; + private final boolean didConsumeFood; // private int numberOfBytes; - public ClientPositionUpdateEvent(Identifier clientId, Map<Identifier, Point> positions) { - this(clientId, false, positions); - } +// public ClientPositionUpdateEvent(Identifier clientId, Map<Identifier, Point> positions) { +// this(clientId, false, positions); +// } +// +// public ClientPositionUpdateEvent(Identifier clientId, boolean didConsumeFood, Map<Identifier, Point> positions) { +// // FIXME: use Collections.EMPTY_SET instead of null? +// this(clientId, didConsumeFood, positions, null); +// } - public ClientPositionUpdateEvent(Identifier clientId, boolean foodEaten, Map<Identifier, Point> positions) { - this(clientId, foodEaten, positions, Collections.EMPTY_SET); - } - - public ClientPositionUpdateEvent(Identifier clientId, boolean foodEaten, Map<Identifier, Point> positions, Set<Point> foodPositions) { + public ClientPositionUpdateEvent(Identifier clientId, boolean didConsumeFood, Map<Identifier, Point> positions, Set<Point> foodPositions) { super(clientId); - this.foodEaten = foodEaten; + this.didConsumeFood = didConsumeFood; this.clientPositions = positions; this.foodPositions = foodPositions; //this.numberOfBytes = GeeUtils.getNumberOfBytes(this); } - public boolean wasFoodConsumed() { - return foodEaten; + public boolean didConsumeFood() { + return didConsumeFood; } public Map<Identifier, Point> getClientPositions() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. <ano...@gm...> - 2006-03-05 17:01:38
|
Is this mailing list borked? On 3/4/06, al...@us... <al...@us...> wrote: > > Revision: 138 > Author: alllee > Date: 2006-03-04 11:10:37 -0800 (Sat, 04 Mar 2006) > ViewCVS: http://svn.sourceforge.net/gabel/?rev=3D138&view=3Drev > > Log Message: > ----------- > webapp now starts up again at least. > > Modified Paths: > -------------- > trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java > > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntit= y.java > > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.j= ava > > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.ja= va > > trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration= .java > > trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentPar= ameters.java > trunk/gee/war/startExperiment.jsp > > Added Paths: > ----------- > trunk/gee/war/WEB-INF/lib/asm.jar > Modified: trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-0= 4 > 18:55:18 UTC (rev 137) > +++ trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-0= 4 > 19:10:37 UTC (rev 138) > @@ -7,6 +7,7 @@ > import javax.persistence.GeneratedValue; > import javax.persistence.Id; > import javax.persistence.Table; > +import javax.persistence.*; > > /** > * $Id$ > @@ -77,12 +78,14 @@ > public void setDescription(String description) { > this.description =3D description; > } > + @Transient > public Date getIrbDateApprovalExpires() { > Calendar calendar =3D Calendar.getInstance(); > calendar.setTime(getIrbDateApproved()); > calendar.add(Calendar.DAY_OF_MONTH, 364); > return calendar.getTime(); > } > + @Temporal(TemporalType.DATE) > public Date getIrbDateApproved() { > if (irbDateApproved =3D=3D null || isToday(irbDateApproved)) { > Calendar calendar =3D Calendar.getInstance(); > @@ -91,6 +94,11 @@ > } > return irbDateApproved; > } > + > + public void setIrbDateApproved(Date irbDateApproved) { > + this.irbDateApproved =3D irbDateApproved; > + } > + > // FIXME: atrocity > private boolean isToday(Date date) { > Calendar now =3D Calendar.getInstance(); > @@ -101,9 +109,7 @@ > && now.get(Calendar.YEAR) =3D=3D then.get(Calendar.YEAR) > && now.get(Calendar.DAY_OF_MONTH) =3D=3D then.get( > Calendar.DAY_OF_MONTH)); > } > - public void setIrbDateApproved(Date irbDateApproved) { > - this.irbDateApproved =3D irbDateApproved; > - } > + > public String getParticipation() { > return participation; > } > > Modified: > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.ja= va > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.ja= va > 2006-03-04 18:55:18 UTC (rev 137) > +++ > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.ja= va > 2006-03-04 19:10:37 UTC (rev 138) > @@ -3,6 +3,7 @@ > import java.net.InetSocketAddress; > import java.util.List; > > +import javax.persistence.Entity; > import javax.persistence.GeneratedValue; > import javax.persistence.Id; > import javax.persistence.Inheritance; > @@ -23,6 +24,7 @@ > * @version $Revision$ > */ > > +@Entity > @Table(name=3D"experiment_configuration") > @Inheritance(strategy=3DInheritanceType.JOINED) > public abstract class ExperimentConfigurationEntity<T extends > ExperimentRoundParameters> > @@ -35,6 +37,7 @@ > private String description; > private String experimentName; > private String clientJarName; > + private String clientMainClass; > > > private ForagerExperimentParameters currentParameters; > @@ -149,6 +152,14 @@ > public void setExperimentName(String experimentName) { > this.experimentName =3D experimentName; > } > + > + public String getClientMainClass() { > + return clientMainClass; > + } > + > + public void setClientMainClass(String clientMainClass) { > + this.clientMainClass =3D clientMainClass; > + } > } > > > > Modified: > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java = 2006-03-04 > 18:55:18 UTC (rev 137) > +++ > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java = 2006-03-04 > 19:10:37 UTC (rev 138) > @@ -6,6 +6,7 @@ > import javax.persistence.Inheritance; > import javax.persistence.InheritanceType; > import javax.persistence.Table; > +import javax.persistence.*; > > /** > * $Id: Exp$ > @@ -19,11 +20,12 @@ > @Entity > @Table(name=3D"experiment_parameters") > @Inheritance(strategy=3DInheritanceType.JOINED) > -public abstract class ExperimentParametersEntity implements > ExperimentRoundParameters { > +public abstract class ExperimentParametersEntity<T extends > ExperimentConfiguration> > +implements ExperimentRoundParameters { > > private long id =3D -1; > > - private ExperimentConfiguration configuration; > + private T configuration; > > @Id @GeneratedValue > public long getId() { > @@ -34,11 +36,13 @@ > this.id =3D id; > } > > - public ExperimentConfiguration getConfiguration() { > + @ManyToOne(targetEntity=3DExperimentConfigurationEntity.class) > + @JoinColumn(name=3D"configuration_id", nullable=3Dfalse) > + public T getConfiguration() { > return configuration; > } > > - public void setConfiguration(ExperimentConfiguration configuration) = { > + public void setConfiguration(T configuration) { > this.configuration =3D configuration; > } > > > Modified: > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java > 2006-03-04 18:55:18 UTC (rev 137) > +++ > trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java > 2006-03-04 19:10:37 UTC (rev 138) > @@ -15,13 +15,13 @@ > * @version $Revision$ > */ > > -public interface ExperimentRoundParameters { > +public interface ExperimentRoundParameters<T extends > ExperimentConfiguration> { > > public String getSpecialInstructions(); > > public Dimension getBoardSize(); > > - public ExperimentConfiguration getConfiguration(); > + public T getConfiguration(); > > public Duration getRoundDuration(); > > > Modified: > trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.jav= a > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- > trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.jav= a 2006-03-04 > 18:55:18 UTC (rev 137) > +++ > trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.jav= a 2006-03-04 > 19:10:37 UTC (rev 138) > @@ -28,7 +28,6 @@ > @Table(name=3D"forager_configuration") > public class ForagerConfiguration extends > ExperimentConfigurationEntity<ForagerExperimentParameters> { > > - > public ForagerConfiguration(String serverName, int port) { > super(serverName, port); > } > @@ -38,9 +37,10 @@ > return "forager-client.jar"; > } > > - public String getClientClass() { > + public String getClientMainClass() { > return ForagerApplet.class.getName(); > } > + > public String getExperimentName() { > return "forager"; > } > > Modified: > trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParamet= ers.java > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- > trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParamet= ers.java > 2006-03-04 18:55:18 UTC (rev 137) > +++ > trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParamet= ers.java > 2006-03-04 19:10:37 UTC (rev 138) > @@ -27,7 +27,7 @@ > @PrimaryKeyJoinColumn(name=3D"forager_parameters_id") > @Proxy(proxyClass=3DExperimentRoundParameters.class) > @Table(name=3D"forager_parameters") > -public class ForagerExperimentParameters extends > ExperimentParametersEntity { > +public class ForagerExperimentParameters extends > ExperimentParametersEntity<ForagerConfiguration> { > > > private ForagerAgentConfiguration agentConfiguration; > @@ -102,12 +102,7 @@ > return Duration.create(240); > } > > - @ManyToOne(targetEntity=3DForagerConfiguration.class) > - @JoinColumn(name=3D"configuration_id", nullable=3Dfalse) > - public ForagerConfiguration getConfiguration() { > - return (ForagerConfiguration) super.getConfiguration(); > - } > - > + > @Transient > public List getAllFoodRegions() { > return Collections.EMPTY_LIST; > > Added: trunk/gee/war/WEB-INF/lib/asm.jar > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > (Binary files differ) > > > Property changes on: trunk/gee/war/WEB-INF/lib/asm.jar > ___________________________________________________________________ > Name: svn:mime-type > + application/octet-stream > > Modified: trunk/gee/war/startExperiment.jsp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- trunk/gee/war/startExperiment.jsp 2006-03-04 18:55:18 UTC (rev 137) > +++ trunk/gee/war/startExperiment.jsp 2006-03-04 19:10:37 UTC (rev 138) > @@ -15,7 +15,7 @@ > > > <!-- FIXME: make width/height configurable later? --> > - <applet code=3D'<ww:property value=3D"experiment.configuration.clientC= lass"/>' > width=3D"600" height=3D"600" > + <applet code=3D'<ww:property value=3D" > experiment.configuration.clientMainClass"/>' width=3D"600" height=3D"600" > archive=3D'<ww:property value=3D" > experiment.configuration.clientJarName"/>'> > <param name=3D'experiment-hostname' value=3D"<ww:property value=3D' > experiment.configuration.serverAddress.hostName'/>" /> > <param name=3D'experiment-port' value=3D"<ww:property value=3D' > experiment.serverPort'/>" /> > > > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Gabel-svn mailing list > Gab...@li... > https://lists.sourceforge.net/lists/listinfo/gabel-svn > |
From: <al...@us...> - 2006-03-05 08:00:00
|
Revision: 147 Author: alllee Date: 2006-03-04 23:59:51 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=147&view=rev Log Message: ----------- mindless hygiene. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerGameState.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-05 07:40:40 UTC (rev 146) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-05 07:59:51 UTC (rev 147) @@ -1,6 +1,5 @@ package edu.indiana.psych.gee; -import java.util.Iterator; import java.util.List; import org.apache.commons.logging.Log; @@ -16,12 +15,14 @@ /** * $Id$ * - * Abstract base class for Experiments, providing convenience methods. + * Abstract base class for Experiments, providing convenience methods for + * obtaining an ExperimentConfiguration of the appropriate type, registering + * with an ExperimentService specified via Spring, * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision$ */ -public abstract class AbstractExperiment<T extends ExperimentConfiguration> implements Experiment<T> { +public abstract class AbstractExperiment<C extends ExperimentConfiguration> implements Experiment<C> { private final Log logger = LogFactory.getLog(getClass()); private final EventChannel channel; @@ -33,7 +34,7 @@ private ExperimentService service; private String name; - private T configuration; + private C configuration; private ExperimentRoundParameters currentParameters; public AbstractExperiment() { @@ -41,11 +42,11 @@ dispatcher = DispatcherFactory.getInstance().createServerDispatcher(channel); } - public T getConfiguration() { + public C getConfiguration() { return configuration; } - public void setConfiguration(T configuration) { + public void setConfiguration(C configuration) { if (configuration == null) { throw new IllegalArgumentException("Invalid configuration"); } @@ -88,16 +89,7 @@ return getConfiguration().getConsentForm(); } - public boolean isFull() { - // TODO Auto-generated method stub - return false; - } - public String toString() { - return String.format("[ %s ] experiment [ %s ] running on port %d", - super.toString(), getName(), getServerPort()); - } - public String getDescription() { return getConfiguration().getDescription(); } @@ -122,6 +114,17 @@ return running; } + public boolean isFull() { + // TODO Auto-generated method stub + return false; + } + + public String toString() { + return String.format("[ %s ] experiment [ %s ] running on port %d", + super.toString(), getName(), getServerPort()); + } + + /** * Returns the special instructions to be used for the next available * round. If this is the first time this method has been called when the @@ -167,7 +170,7 @@ } protected Duration getDelayBetweenRounds() { - return configuration.getDelayBetweenRounds(); + return getConfiguration().getDelayBetweenRounds(); } protected EventChannel getEventChannel() { Modified: trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java 2006-03-05 07:40:40 UTC (rev 146) +++ trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java 2006-03-05 07:59:51 UTC (rev 147) @@ -12,7 +12,7 @@ * @version $Revision$ */ -public interface Experiment<T extends ExperimentConfiguration> { +public interface Experiment<C extends ExperimentConfiguration> { public static final Experiment NULL = new Experiment() { private final Log logger = LogFactory.getLog(getClass()); @@ -67,8 +67,8 @@ public boolean isFull(); public boolean isRunning(); - public T getConfiguration(); - public void setConfiguration(T configuration); + public C getConfiguration(); + public void setConfiguration(C configuration); // interface State { // public final static State WAITING = new State() { Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-05 07:40:40 UTC (rev 146) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-05 07:59:51 UTC (rev 147) @@ -14,7 +14,7 @@ * @version $Revision$ */ -public interface ExperimentConfiguration<T extends ExperimentRoundParameters> { +public interface ExperimentConfiguration<P extends ExperimentRoundParameters> { /** @@ -34,9 +34,9 @@ public boolean isTriggeredExperiment(); - public List<T> getAllParameters(); + public List<P> getAllParameters(); - public T getCurrentParameters(); + public P getCurrentParameters(); public String getDescription(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 07:40:40 UTC (rev 146) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 07:59:51 UTC (rev 147) @@ -2,17 +2,12 @@ import java.util.List; -import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; import javax.persistence.OneToMany; -import javax.persistence.OrderBy; import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; import javax.persistence.Transient; -import javax.persistence.*; import org.hibernate.annotations.Proxy; @@ -41,6 +36,10 @@ super(serverName, port); } + public static ForagerConfiguration getDefaultConfiguration() { + return new ForagerConfiguration("groups.psych.indiana.edu", 25000); + } + @Transient public Duration getDelayBetweenRounds() { return Duration.create(30); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-05 07:40:40 UTC (rev 146) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-05 07:59:51 UTC (rev 147) @@ -26,7 +26,6 @@ import edu.indiana.psych.gee.net.ClientReadyEvent; import edu.indiana.psych.gee.net.ConnectionEvent; import edu.indiana.psych.gee.net.Dispatcher; -import edu.indiana.psych.gee.service.ExperimentService; import edu.indiana.psych.gee.time.Duration; import edu.indiana.psych.gee.util.GeeUtils; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerGameState.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerGameState.java 2006-03-05 07:40:40 UTC (rev 146) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerGameState.java 2006-03-05 07:59:51 UTC (rev 147) @@ -2,7 +2,6 @@ import java.awt.Point; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import edu.indiana.psych.gee.Identifier; @@ -30,7 +29,8 @@ // Map<Identifier, ClientState> used to maintain the set of // currently connected clients, their positions and other useful // information. - protected final Map clients = new HashMap(); + protected final Map<Identifier, ClientState> clients = + new HashMap<Identifier, ClientState>(); protected ForagerGameState(EventChannel channel) { this.channel = channel; @@ -62,30 +62,27 @@ } /** - * Returns a Map<Identifier, Point> representing the latest client - * positions. + * Returns a Map associating client Identifiers and Point locations + * representing the latest client positions. */ - public synchronized Map getClientPositions() { - Map positions = new HashMap(); - for (Iterator iter = clients.values().iterator(); iter.hasNext(); ) { - ClientState clientState = (ClientState) iter.next(); + public synchronized Map<Identifier, Point> getClientPositions() { + Map<Identifier, Point> positions = new HashMap<Identifier, Point>(); + for (ClientState clientState : clients.values()) { positions.put(clientState.id(), clientState.getPosition()); } return positions; } public String toString() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); int clientId = 0; - synchronized (clients) { - for (Iterator iterator = clients.values().iterator(); iterator.hasNext(); ) { - ClientState state = (ClientState) iterator.next(); + for (ClientState state : clients.values()) { Point position = state.getPosition(); buffer.append(state.getFoodEaten()).append(' '); buffer.append(position.x).append(' ').append(position.y).append(' '); buffer.append(state.getFoodEaten()).append(' '); - clientId++; + buffer.append(clientId++); } } @@ -95,16 +92,16 @@ // now we just need to associate a brightness-over-time with a particular // client. public int getFoodEatenFor(Identifier id) { - ClientState state = (ClientState) clients.get(id); + ClientState state = clients.get(id); if (state == null) { - // FIXME: perhaps we should just return 0 instead. + // FIXME: perhaps we should just return 0 instead? throw new IllegalArgumentException("no client state available for: " + id); } return state.getFoodEaten(); } public boolean hasClientEaten(Identifier id) { - ClientState clientState = (ClientState) clients.get(id); + ClientState clientState = clients.get(id); if (clientState == null) { error("asked if client [" + id + "] ate, but this client doesn't exist."); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java 2006-03-05 07:40:40 UTC (rev 146) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java 2006-03-05 07:59:51 UTC (rev 147) @@ -3,7 +3,6 @@ import java.awt.Point; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -24,7 +23,7 @@ public class ForagerClientGameState extends ForagerGameState { - private Set foodPositions = new HashSet(); + private Set<Point> foodPositions = new HashSet<Point>(); public ForagerClientGameState(EventChannel channel) { super(channel); @@ -38,18 +37,17 @@ /** * Returns a Set<Point> containing the positions of food pellets. */ - public synchronized Set getFoodPositions() { + public synchronized Set<Point> getFoodPositions() { return Collections.unmodifiableSet(foodPositions); } public synchronized void initialize(RoundStartedEvent event) { clear(); // Map<Identifier, Point> - Map positions = event.getInitialData(); - for (Iterator iter = positions.entrySet().iterator(); iter.hasNext(); ) { - Map.Entry entry = (Map.Entry) iter.next(); - Identifier id = (Identifier) entry.getKey(); - Point point = (Point) entry.getValue(); + Map<Identifier, Point> positions = event.getInitialData(); + for (Map.Entry<Identifier, Point> entry : positions.entrySet()) { + Identifier id = entry.getKey(); + Point point = entry.getValue(); addClient(id, point); } } @@ -61,25 +59,22 @@ */ public synchronized void update(ClientPositionUpdateEvent event, ForagerGameWindow window) { // incoming client positions are Map<Identifier, Point> - Map clientPositions = event.getClientPositions(); + Map<Identifier, Point> clientPositions = event.getClientPositions(); // incoming foodPositions is just a Set of Points (which is all the // client needs to know) foodPositions = event.getFoodPositions(); // update all client positions. - for (Iterator iterator = clientPositions.entrySet().iterator(); - iterator.hasNext(); ) - { - Map.Entry entry = (Map.Entry) iterator.next(); - Identifier id = (Identifier) entry.getKey(); - Point point = (Point) entry.getValue(); - ClientState clientState = (ClientState) clients.get(id); + for (Map.Entry<Identifier, Point> entry : clientPositions.entrySet()) { + Identifier id = entry.getKey(); + Point point = entry.getValue(); + ClientState clientState = clients.get(id); if (clientState == null) { throw new IllegalStateException("clients didn't contain id: " + id); } clientState.setPosition(point); } if (event.wasFoodConsumed()) { - ClientState clientState = (ClientState) clients.get(event.id()); + ClientState clientState = clients.get(event.id()); clientState.incrementFoodEaten(); // FIXME: drop an event into the event channel to signal the ForagerGameWindow // instead of doing this. @@ -87,6 +82,7 @@ } // double bytesPerSecond = getBytesPerSecond(event.getNumberOfBytes(), event.getCreationTime()); window.update(); + clientPositions.clear(); } // private double getBytesPerSecond(int numberOfBytes, long creationTime) { Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java 2006-03-05 07:40:40 UTC (rev 146) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java 2006-03-05 07:59:51 UTC (rev 147) @@ -20,7 +20,6 @@ * * Can also maintain a list of food positions, if the food is visible * - * @author Andy Jones * @author Allen Lee * @version $Revision$ */ @@ -28,22 +27,21 @@ implements ExperimentUpdateEvent { private static final long serialVersionUID = -128693557750400520L; - // Map<Identifier, Point> - private final Map clientPositions; - private final Set foodPositions; + private final Map<Identifier, Point> clientPositions; + private final Set<Point> foodPositions; private final boolean foodEaten; // private int numberOfBytes; - public ClientPositionUpdateEvent(Identifier clientId, Map positions) { + public ClientPositionUpdateEvent(Identifier clientId, Map<Identifier, Point> positions) { this(clientId, false, positions); } - public ClientPositionUpdateEvent(Identifier clientId, boolean foodEaten, Map positions) { + public ClientPositionUpdateEvent(Identifier clientId, boolean foodEaten, Map<Identifier, Point> positions) { this(clientId, foodEaten, positions, Collections.EMPTY_SET); } - public ClientPositionUpdateEvent(Identifier clientId, boolean foodEaten, Map positions, Set foodPositions) { + public ClientPositionUpdateEvent(Identifier clientId, boolean foodEaten, Map<Identifier, Point> positions, Set<Point> foodPositions) { super(clientId); this.foodEaten = foodEaten; this.clientPositions = positions; @@ -55,11 +53,11 @@ return foodEaten; } - public Map getClientPositions() { + public Map<Identifier, Point> getClientPositions() { return clientPositions; } - public Set getFoodPositions() { + public Set<Point> getFoodPositions() { return foodPositions; } @@ -72,7 +70,7 @@ } public Point getClientPosition(Identifier id) { - return (Point) clientPositions.get(id); + return clientPositions.get(id); } Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java 2006-03-05 07:40:40 UTC (rev 146) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java 2006-03-05 07:59:51 UTC (rev 147) @@ -9,8 +9,6 @@ import org.apache.commons.logging.LogFactory; import edu.indiana.psych.gee.Experiment; -import edu.indiana.psych.gee.forager.ForagerConfiguration; -import edu.indiana.psych.gee.forager.ForagerExperiment; /** * $Id$ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-05 07:40:47
|
Revision: 146 Author: alllee Date: 2006-03-04 23:40:40 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=146&view=rev Log Message: ----------- using spring to manage more of our objects. AbstractExperiment now gets the ExperimentService injected into it via Spring, when it receives the ExperimentService it adds itself to the ExperimentService. This means that actual experiments must be listed as beans in applicationContext.xml now. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java trunk/gee/war/WEB-INF/applicationContext.xml Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-05 06:47:09 UTC (rev 145) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-05 07:40:40 UTC (rev 146) @@ -10,6 +10,7 @@ import edu.indiana.psych.gee.event.EventChannel; import edu.indiana.psych.gee.net.DispatcherFactory; import edu.indiana.psych.gee.net.ServerDispatcher; +import edu.indiana.psych.gee.service.ExperimentService; import edu.indiana.psych.gee.time.Duration; /** @@ -28,7 +29,10 @@ private Thread serverThread; private boolean running; + + private ExperimentService service; + private String name; private T configuration; private ExperimentRoundParameters currentParameters; @@ -99,7 +103,10 @@ } public String getName() { - return getConfiguration().getExperimentName(); + if (name == null) { + name = getConfiguration().getExperimentName(); + } + return name; } public boolean equals(Object object) { @@ -145,6 +152,14 @@ // nextIndex = nextIndex % allParameters.size(); return allParameters.get(nextIndex).getSpecialInstructions(); } + + public void setExperimentService(ExperimentService service) { + if (this.service != null) { + this.service.remove(this); + } + this.service = service; + service.add(this); + } protected void transmit(Event event) { Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 06:47:09 UTC (rev 145) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 07:40:40 UTC (rev 146) @@ -41,10 +41,6 @@ super(serverName, port); } - public static ForagerConfiguration getDefaultConfiguration() { - return new ForagerConfiguration(getDefaultServerAddress(), 25000); - } - @Transient public Duration getDelayBetweenRounds() { return Duration.create(30); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-05 06:47:09 UTC (rev 145) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-05 07:40:40 UTC (rev 146) @@ -26,6 +26,7 @@ import edu.indiana.psych.gee.net.ClientReadyEvent; import edu.indiana.psych.gee.net.ConnectionEvent; import edu.indiana.psych.gee.net.Dispatcher; +import edu.indiana.psych.gee.service.ExperimentService; import edu.indiana.psych.gee.time.Duration; import edu.indiana.psych.gee.util.GeeUtils; @@ -65,9 +66,9 @@ private boolean roundRunning; public ForagerExperiment(ForagerConfiguration configuration) { + addEventProcessors(); getLogger().debug("Creating a new ForagerExperiment with configuration: " + configuration); setConfiguration(configuration); - addEventProcessors(); this.delayBetweenRounds = configuration.getDelayBetweenRounds(); } Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java 2006-03-05 06:47:09 UTC (rev 145) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java 2006-03-05 07:40:40 UTC (rev 146) @@ -22,23 +22,18 @@ */ public class ExperimentService { - private final static Map<String, Experiment> allExperiments = - new HashMap<String, Experiment>(); + private final Map<String, Experiment> allExperiments = + new HashMap<String, Experiment>() { + public Experiment get(String key) { + if (key == null) { + return Experiment.NULL; + } + return super.get(key); + } + }; private final Log logger = LogFactory.getLog(getClass()); - public ExperimentService() { - logger.debug("instantiating ExperimentService : " + this); - synchronized (ExperimentService.class) { - if ( allExperiments.isEmpty() ) { - allExperiments.put(null, Experiment.NULL); - // FIXME: use ioc to grab a default forager configuration. - add(new ForagerExperiment(ForagerConfiguration.getDefaultConfiguration())); - // add(new SocialChoiceExperiment()); - } - } - } - public boolean start(String experimentName) { find(experimentName).start(); return available(experimentName); @@ -55,6 +50,16 @@ allExperiments.put(experiment.getName(), experiment); } + public void remove(Experiment experiment) { + if (experiment == null) { + logger.warn("Trying to remove a null experiment from ExperimentService - ignoring"); + return; + } + if ( allExperiments.remove(experiment.getName()) == null ) { + logger.warn("Tried to remove " + experiment + " which doesn't exist in ExperimentService"); + } + } + public Experiment find(String name) { Experiment experiment = allExperiments.get(name); if (experiment == null) { Modified: trunk/gee/war/WEB-INF/applicationContext.xml =================================================================== --- trunk/gee/war/WEB-INF/applicationContext.xml 2006-03-05 06:47:09 UTC (rev 145) +++ trunk/gee/war/WEB-INF/applicationContext.xml 2006-03-05 07:40:40 UTC (rev 146) @@ -4,6 +4,7 @@ --> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans default-autowire="autodetect"> + <!-- persistence layer beans --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="/WEB-INF/jdbc.properties"/> @@ -28,5 +29,20 @@ <ref bean="mysqlDataSource"/> </property> </bean> + <!-- application layer beans --> <bean id="experimentService" class="edu.indiana.psych.gee.service.ExperimentService"/> + <bean id="defaultForagerConfiguration" class="edu.indiana.psych.gee.forager.ForagerConfiguration"> + <constructor-arg value="groups.psych.indiana.edu"/> + <constructor-arg type="int"><value>26000</value></constructor-arg> + <property name="experimentName" value="forager"/> + <property name="description" + value="The Forager experiment explores how individuals allocate themselves + in a world with scarce resources"/> + <property name='clientJarName' value='forager-client.jar'/> + <property name='clientMainClass' value='edu.indiana.psych.gee.forager.ForagerApplet'/> + </bean> + <bean id="forager-web" class="edu.indiana.psych.gee.forager.ForagerExperiment"> + <constructor-arg ref="defaultForagerConfiguration"/> + <property name="experimentService" ref="experimentService"/> + </bean> </beans> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-05 06:47:12
|
Revision: 145 Author: alllee Date: 2006-03-04 22:47:09 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=145&view=rev Log Message: ----------- amazingly, object mapping seems to have worked. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java 2006-03-05 06:39:06 UTC (rev 144) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java 2006-03-05 06:47:09 UTC (rev 145) @@ -6,6 +6,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; +import javax.persistence.Transient; import org.hibernate.annotations.Proxy; @@ -49,6 +50,7 @@ return movementPenalty; } + @Transient public Properties getProperties() { return properties; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-05 06:39:06 UTC (rev 144) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-05 06:47:09 UTC (rev 145) @@ -13,14 +13,11 @@ import javax.persistence.Table; import javax.persistence.Transient; -import org.hibernate.annotations.Proxy; - import edu.indiana.psych.gee.ExperimentRoundParameters; import edu.indiana.psych.gee.time.Duration; @Entity @Table(name="forager_parameter") -@Proxy(proxyClass=ExperimentRoundParameters.class) public class ForagerExperimentParameters implements ExperimentRoundParameters<ForagerConfiguration> { private ForagerAgentConfiguration agentConfiguration; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-05 06:39:14
|
Revision: 144 Author: alllee Date: 2006-03-04 22:39:06 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=144&view=rev Log Message: ----------- speeding up deployment by skipping the war step, experimenting with different mapping strategies, could be a bug in hibernate annotations. Modified Paths: -------------- trunk/gee/build.xml trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/war/WEB-INF/applicationContext.xml trunk/gee/war/WEB-INF/hibernate.cfg.xml Modified: trunk/gee/build.xml =================================================================== --- trunk/gee/build.xml 2006-03-05 05:17:09 UTC (rev 143) +++ trunk/gee/build.xml 2006-03-05 06:39:06 UTC (rev 144) @@ -8,6 +8,7 @@ <property file='build.properties'/> <property name='build.dir' value='build'/> + <property name='build.classes.dir' value='${build.dir}/classes'/> <property name='src.dir' value='src'/> <property name='java.src.dir' value='${src.dir}/java'/> <property name='test.src.dir' value='${src.dir}/test'/> @@ -28,19 +29,20 @@ <!-- XXX: deployment type, for production use gee, for others use gee-dev --> <property name='webapp.name' value='gee'/> - <property name='webapp.deploy.dir' value='${tomcat.webapps.dir}/${webapp.name}'/> + <property name='webapp.deploy.dir' value='${build.dir}/${webapp.name}'/> <path id="build.classpath"> <pathelement location="." /> <fileset dir="${web.lib.dir}"> <include name="**/*.jar" /> </fileset> - <pathelement location="${build.dir}" /> + <pathelement location="${build.classes.dir}" /> <pathelement location="${test.build.dir}"/> </path> <target name="prepare"> <mkdir dir="${build.dir}"/> + <mkdir dir='${build.classes.dir}'/> </target> <target name='clean'> @@ -50,19 +52,19 @@ <!-- compilation tasks --> <target name='compile' depends='prepare'> <javac srcdir='${java.src.dir}' - destdir='${build.dir}' + destdir='${build.classes.dir}' debug='on' deprecation='on' > <classpath refid='build.classpath' /> </javac> - <copy todir='${build.dir}'> + <copy todir='${build.classes.dir}'> <fileset dir='${java.src.dir}'> <include name='**/*.xml'/> <include name='**/*.properties'/> </fileset> </copy> - <copy file='${web.inf}/classes/log4j.properties' todir='${build.dir}' /> + <copy file='${web.inf}/classes/log4j.properties' todir='${build.classes.dir}' /> </target> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="build.classpath"/> @@ -71,7 +73,7 @@ <echo message="You must have valid database connection information within build.properties for this task to succeed."/> <hibernatetool destdir="${generated.dir}"> <classpath> - <path location="${build.dir}"/> + <path location="${build.classes.dir}"/> </classpath> <!-- annotated class/packages are specified in the hibernate.cfg.xml --> <annotationconfiguration propertyFile="build.properties" configurationfile="${web.inf}/hibernate.cfg.xml"/> @@ -83,7 +85,7 @@ <!-- compilation tasks --> <target name='compile-forager-client' depends='prepare'> <javac srcdir="${java.src.dir}" - destdir='${build.dir}' + destdir='${build.classes.dir}' debug='on' deprecation='on' target="1.5" @@ -123,28 +125,49 @@ </junit> </target> + + <target name='deploy'> + <antcall target='webapp'/> + </target> + + <target name='webapp' depends='compile'> + <mkdir dir='${webapp.deploy.dir}'/> + <copy todir='${webapp.deploy.dir}'> + <fileset dir='war'/> + </copy> + <copy todir='${webapp.deploy.dir}/WEB-INF/classes'> + <fileset dir='${build.classes.dir}'/> + </copy> + <antcall target='post-deploy'/> + </target> + <!-- archive creation tasks --> <target name='war' depends='compile'> <war destfile='${war.file}' webxml='${web.inf}/web.xml' excludes='**Tester.class'> <fileset dir='war'/> - <classes dir='${build.dir}'/> + <classes dir='${build.classes.dir}'/> </war> </target> <!-- deployment tasks --> - <target name='deploy' depends='war'> + <target name='deploy-war' depends='war'> <unwar src='${war.file}' dest='${webapp.deploy.dir}' /> + <antcall target='post-deploy'/> + </target> + + <target name='post-deploy'> <chmod dir='${webapp.deploy.dir}' perm='664' type='file' includes='**'/> <chmod dir='${webapp.deploy.dir}' perm='755' type='dir' includes='**'/> </target> + <target name='forager-client-jar' depends='compile-forager-client'> <jar destfile='forager-client.jar'> <manifest> <attribute name="Main-Class" value="edu.indiana.psych.gee.forager.client.ForagerApplet"/> </manifest> - <fileset dir='${build.dir}'> + <fileset dir='${build.classes.dir}'> <exclude name='edu/indiana/psych/gee/event/generics/**'/> <exclude name='edu/indiana/psych/gee/action/**'/> <exclude name='edu/indiana/psych/gee/service/**'/> @@ -188,58 +211,3 @@ </target> </project> - -<!-- -$Log$ -Revision 1.11 2006/02/03 08:02:49 alllee -forager experiment almost back up again, some last minute debugging left to -do after some sleep. - - TODO: AbstractEvent is getting instantiated with a Null ID for some - reasonon the client side via ClientReadyEvent it appears. - -Revision 1.10 2006/02/02 22:04:59 alllee -- log4j logging requires additional commons-logging.properties indirection and - the log4j jar (naturally) -- adding missing pieces to validation, they need to exist in the classpath. - Ant task to compile now copies over relevant .xml and .properties files over - to the build directory. xwork.xml also needs an 'input' result for the - validated action. May need to make the validation happen as - PrepareConsentForm-validation.xml, still working out the details. - -Revision 1.9 2006/02/01 18:12:23 alllee -consent form approval date and expiration date are now being used by -the getConsent.jsp view. Still monkeying with validation. Going to have to -do some serious package refactoring here in a little bit to separate the 1.4 -compliant stuff from the webapp stuff that can leverage 1.5 pieces. - -Revision 1.8 2006/01/13 07:40:10 alllee -starting to display experiment metadata through the page. still need to fill -in the link to actually start and begin participating in an experiment. - -Revision 1.7 2006/01/07 06:47:27 alllee -hygiene commit, using BidiMap from Jakarta Commons in place of maintaining two -maps in the NioDispatcher. - -Revision 1.6 2005/12/26 20:06:43 alllee -adding the rest of the jar dependencies needed by the web framework. Will -probably use built-in hypersonic sql java db unless it seems like an actual DB -is necessary (still need to change that dependency in the spring -applicationContext.xml file) - -Revision 1.5 2005/12/22 06:44:20 alllee -skeletal classes for the refactored webapp experiment framework. - -Revision 1.4 2005/12/21 23:41:34 alllee -adding deployment and war creation targets to ant. - -Revision 1.3 2005/12/21 21:47:25 alllee -adding ant task to build web components and stubbed out XWork actions. - -Revision 1.2 2005/12/21 20:48:40 alllee -removing forrest website. - -Revision 1.1 2004/07/13 06:19:53 alllee -buildfile for forrest website. ---> - Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-05 05:17:09 UTC (rev 143) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-05 06:39:06 UTC (rev 144) @@ -30,9 +30,7 @@ private boolean running; private T configuration; - private List<ExperimentRoundParameters> allParameters; private ExperimentRoundParameters currentParameters; - private Iterator<ExperimentRoundParameters> parametersIterator; public AbstractExperiment() { channel = new EventChannel(); @@ -52,7 +50,6 @@ "not support hot-reconfiguration yet"); } this.configuration = configuration; - allParameters = configuration.getAllParameters(); } public synchronized void start() throws ExperimentLifecycleException { @@ -80,7 +77,7 @@ } public int getServerPort() { - return configuration.getServerPort(); + return getConfiguration().getServerPort(); } public ConsentForm getConsentForm() { @@ -98,11 +95,11 @@ } public String getDescription() { - return configuration.getDescription(); + return getConfiguration().getDescription(); } public String getName() { - return configuration.getExperimentName(); + return getConfiguration().getExperimentName(); } public boolean equals(Object object) { @@ -134,7 +131,7 @@ // call-only-once semantics unless we jumped more hoops public String getNextRoundInstructions() { if (currentParameters == null) { - currentParameters = allParameters.get(0); + currentParameters = configuration.getCurrentParameters(); if (currentParameters == null) { // FIXME: allow the user to specify configuration here instead // of throwing an exception. @@ -142,22 +139,14 @@ } return currentParameters.getSpecialInstructions(); } + // need a non-mutating way to access the special instructions on deck. + List<ExperimentRoundParameters> allParameters = configuration.getAllParameters(); int nextIndex = (allParameters.indexOf(currentParameters) + 1) % allParameters.size(); // nextIndex = nextIndex % allParameters.size(); return allParameters.get(nextIndex).getSpecialInstructions(); } - protected void updateCurrentParameters() { - if (! parametersIterator.hasNext()) { - parametersIterator = allParameters.iterator(); - } - currentParameters = parametersIterator.next(); - } - protected ExperimentRoundParameters getCurrentParameters() { - return currentParameters; - } - protected void transmit(Event event) { dispatcher.transmit(event); } @@ -170,10 +159,6 @@ return channel; } - protected List<ExperimentRoundParameters> getAllParameters() { - return allParameters; - } - protected abstract StateMachine getStateMachine(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-05 05:17:09 UTC (rev 143) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-05 06:39:06 UTC (rev 144) @@ -1,6 +1,7 @@ package edu.indiana.psych.gee; import java.net.InetSocketAddress; +import java.util.Iterator; import java.util.List; import javax.persistence.Entity; @@ -42,12 +43,13 @@ private String clientJarName; private String clientMainClass; private ConsentForm consentForm; - private T currentParameters; private int serverPort; private String serverName; private boolean triggeredExperiment; // transient fields private InetSocketAddress serverAddress; + private T currentParameters; + private @Transient Iterator<T> parametersIterator; public ExperimentConfigurationEntity(String serverName, int port) { setServerName(serverName); @@ -115,6 +117,14 @@ this.consentForm = consentForm; } + // advances the parameters iterator or resets it. + public void updateCurrentParameters() { + if (parametersIterator == null || ! parametersIterator.hasNext()) { + parametersIterator = getAllParameters().iterator(); + } + currentParameters = parametersIterator.next(); + } + @Transient public synchronized T getCurrentParameters() { List<T> allParameters = getAllParameters(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 05:17:09 UTC (rev 143) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 06:39:06 UTC (rev 144) @@ -8,9 +8,11 @@ import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; import javax.persistence.OneToMany; +import javax.persistence.OrderBy; import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; import javax.persistence.Transient; +import javax.persistence.*; import org.hibernate.annotations.Proxy; @@ -28,8 +30,6 @@ * @version $Revision$ */ @Entity -@Inheritance(strategy=InheritanceType.JOINED) -@DiscriminatorValue("forager") @PrimaryKeyJoinColumn(name="experiment_configuration_id") @Table(name="forager_configuration") @Proxy(proxyClass=ExperimentConfiguration.class) @@ -41,21 +41,6 @@ super(serverName, port); } - /* - // FIXME: replace hard coded names with configuration. - public String getClientJarName() { - return "forager-client.jar"; - } - - public String getClientMainClass() { - return ForagerApplet.class.getName(); - } - - public String getDescription() { - return "The Forager experiment explores how participants allocate themselves in a world with scarce resources."; - } - */ - public static ForagerConfiguration getDefaultConfiguration() { return new ForagerConfiguration(getDefaultServerAddress(), 25000); } @@ -65,7 +50,7 @@ return Duration.create(30); } - @OneToMany(targetEntity=ForagerExperimentParameters.class) + @OneToMany(mappedBy="configuration") @JoinColumn(name="configuration_id") public List<ForagerExperimentParameters> getAllParameters() { return allParameters; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-05 05:17:09 UTC (rev 143) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-05 06:39:06 UTC (rev 144) @@ -121,9 +121,6 @@ } - protected ForagerExperimentParameters getCurrentParameters() { - return (ForagerExperimentParameters) super.getCurrentParameters(); - } /** * Processes all the clients message queues. */ @@ -306,13 +303,12 @@ return; } // initialize per-round objects. + getConfiguration().updateCurrentParameters(); + ForagerExperimentParameters parameters = getCurrentParameters(); // FIXME: move this configuration into its own method or // something. - updateCurrentParameters(); debriefingAssistant = new DebriefingAssistant(getEventChannel(), currentParticipantHeadings.keySet()); - - addAgents(getCurrentParameters()); - ForagerExperimentParameters parameters = getCurrentParameters(); + addAgents(parameters); currentRoundDuration = parameters.getRoundDuration().start(); foragerGameState = new ForagerServerGameState(getEventChannel(), parameters); // foragerGameState.setBoardSize(currentExperimentConfiguration); @@ -340,7 +336,7 @@ for (Identifier id : currentParticipantHeadings.keySet()) { RoundStartedEvent event = new RoundStartedEvent(id, - getCurrentParameters(), + parameters, foragerGameState.getClientPositions()); transmit(event); } @@ -422,6 +418,10 @@ state = ForagerState.WAITING; } } + + private ForagerExperimentParameters getCurrentParameters() { + return getConfiguration().getCurrentParameters(); + } private void saveExperiment() { if (persister == null) { Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-05 05:17:09 UTC (rev 143) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-05 06:39:06 UTC (rev 144) @@ -19,9 +19,9 @@ import edu.indiana.psych.gee.time.Duration; @Entity -@Table(name="forager_parameters") +@Table(name="forager_parameter") @Proxy(proxyClass=ExperimentRoundParameters.class) -public class ForagerExperimentParameters implements ExperimentRoundParameters { +public class ForagerExperimentParameters implements ExperimentRoundParameters<ForagerConfiguration> { private ForagerAgentConfiguration agentConfiguration; private ForagerConfiguration configuration; @@ -37,13 +37,8 @@ private int minimumSeparation; private int maximumSeparation; private String specialInstructions; - private long id = -1; - public ForagerExperimentParameters(ForagerConfiguration configuration) { - setConfiguration(configuration); - } - @Id @GeneratedValue public long getId() { return id; @@ -53,7 +48,7 @@ this.id = id; } - @ManyToOne(targetEntity=ForagerConfiguration.class) + @ManyToOne @JoinColumn(name="configuration_id", nullable=false) public ForagerConfiguration getConfiguration() { return configuration; Modified: trunk/gee/war/WEB-INF/applicationContext.xml =================================================================== --- trunk/gee/war/WEB-INF/applicationContext.xml 2006-03-05 05:17:09 UTC (rev 143) +++ trunk/gee/war/WEB-INF/applicationContext.xml 2006-03-05 06:39:06 UTC (rev 144) @@ -15,7 +15,7 @@ <property name="password" value="${geedb.password}"/> </bean> <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> - <property name="configLocation" value="WEB-INF/hibernate-session-factory-config.xml"/> + <property name="configLocation" value="WEB-INF/hibernate.cfg.xml"/> <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/> <property name="hibernateProperties"> <props> Modified: trunk/gee/war/WEB-INF/hibernate.cfg.xml =================================================================== --- trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-03-05 05:17:09 UTC (rev 143) +++ trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-03-05 06:39:06 UTC (rev 144) @@ -11,8 +11,9 @@ <mapping class="edu.indiana.psych.gee.ConsentForm"/> <mapping class="edu.indiana.psych.gee.ExperimentConfigurationEntity"/> <mapping package="edu.indiana.psych.gee.forager"/> + <mapping class="edu.indiana.psych.gee.forager.ForagerAgentConfiguration"/> + <mapping class="edu.indiana.psych.gee.forager.ForagerConfiguration"/> <mapping class="edu.indiana.psych.gee.forager.ForagerExperimentParameters"/> - <mapping class="edu.indiana.psych.gee.forager.ForagerConfiguration"/> </session-factory> </hibernate-configuration> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-05 05:17:18
|
Revision: 143 Author: alllee Date: 2006-03-04 21:17:09 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=143&view=rev Log Message: ----------- mapping ForagerAgentConfiguration and more properties from ForagerExperimentParameters. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-05 04:55:19 UTC (rev 142) +++ trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-05 05:17:09 UTC (rev 143) @@ -7,7 +7,9 @@ import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; -import javax.persistence.*; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; /** * $Id$ Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-05 04:55:19 UTC (rev 142) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-05 05:17:09 UTC (rev 143) @@ -3,9 +3,6 @@ import java.net.InetSocketAddress; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import edu.indiana.psych.gee.time.Duration; /** Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-05 04:55:19 UTC (rev 142) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-05 05:17:09 UTC (rev 143) @@ -34,21 +34,20 @@ implements ExperimentConfiguration<T> { private final static String DEFAULT_SERVER_ADDRESS = "groups.psych.indiana.edu"; - + + // persistent fields private long id = -1; - private String description; private String experimentName; private String clientJarName; private String clientMainClass; private ConsentForm consentForm; - - private T currentParameters; - private InetSocketAddress serverAddress; private int serverPort; private String serverName; private boolean triggeredExperiment; + // transient fields + private InetSocketAddress serverAddress; public ExperimentConfigurationEntity(String serverName, int port) { setServerName(serverName); Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-05 04:55:19 UTC (rev 142) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-05 05:17:09 UTC (rev 143) @@ -1,12 +1,7 @@ package edu.indiana.psych.gee; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; import javax.persistence.Table; -import javax.persistence.*; /** * $Id: Exp$ @@ -17,8 +12,15 @@ * @version $Revision: $ */ +@Entity +@Table(name="experiment_parameters") public abstract class ExperimentParametersEntity<T extends ExperimentConfiguration> implements ExperimentRoundParameters { + private long id = -1; + + + + } Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java 2006-03-05 04:55:19 UTC (rev 142) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java 2006-03-05 05:17:09 UTC (rev 143) @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -137,21 +136,21 @@ * @see mud.engine.EventGenerator */ private static class EventDispatcher { - /** - * Map<EventHandler, EventConstraint > - */ - private final Map eventListeners; + private final Map<EventHandler, EventConstraint> eventListeners; /** * Create a new EventDispatcher. */ protected EventDispatcher() { - eventListeners = new HashMap(); + eventListeners = new HashMap<EventHandler, EventConstraint>(); } /** - * This method allows EventGenerators to add an EventHandler and EventConstraint. - * This should be used within the EventGenerator's subscribe() method. + * Associates a constraint with a given handler; whenever an Event passes + * through the EventChannel the constraint is applied to the event. If + * successful, the Event is passed to the EventHandler, otherwise it's + * skipped. Currently only supports 1-1 mappings between constraints + * and handlers. * * @param handler EventHandler to subscribe. * @param constraint EventConstraint to filter with. @@ -174,23 +173,26 @@ /** * Fires the given event to all interested EventHandlers. This method * provides a way for Events to be sent to all EventHandlers subscribed - * for them. This method should be used in an EventGenerator whenever an - * event needs to be fired. + * for them. * * @param event The event to fire. */ protected synchronized void dispatch(final Event event) { + for (Map.Entry<EventHandler, EventConstraint> entry : eventListeners.entrySet()) { + if (entry.getValue().accepts(event)) { + entry.getKey().handle(event); + } + } + /* for (Iterator handlers = eventListeners.keySet().iterator(); handlers.hasNext(); ) { final EventHandler handler = (EventHandler) handlers.next(); - final EventConstraint constraint = getConstraintFor(handler); + final EventConstraint constraint = eventListeners.get(handler); if ( constraint.accepts(event) ) { handler.handle(event); } } + */ } - private EventConstraint getConstraintFor(EventHandler handler) { - return (EventConstraint) eventListeners.get(handler); - } } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java 2006-03-05 04:55:19 UTC (rev 142) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java 2006-03-05 05:17:09 UTC (rev 143) @@ -3,6 +3,8 @@ import java.util.Properties; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.Proxy; @@ -15,30 +17,36 @@ public class ForagerAgentConfiguration implements AgentConfiguration { private static final long serialVersionUID = -6259298886681245586L; - - private final ForagerConfiguration foragerConfiguration; - - /** - * @param configuration - */ - ForagerAgentConfiguration(ForagerConfiguration configuration) { - foragerConfiguration = configuration; + + private long id = -1; + + private int foodReward = 200; + private int expectedFoodReward = 500; + private int luceK = 100; + private int movementPenalty = 2; + private float movementRate = 0.5f; + private Properties properties; + + @Id @GeneratedValue + public long getId() { + return id; } + + public void setId(long id) { + this.id = id; + } - - Properties properties; - public int getFoodReward() { - return 200; + return foodReward; } public int getExpectedFoodReward() { - return 500; + return expectedFoodReward; } public int getLuceK() { - return 100; + return luceK; } public int getMovementPenalty() { - return 2; + return movementPenalty; } public Properties getProperties() { @@ -46,6 +54,26 @@ } public float getMovementRate() { - return 0.5f; + return movementRate; } + + public void setExpectedFoodReward(int expectedFoodReward) { + this.expectedFoodReward = expectedFoodReward; + } + + public void setFoodReward(int foodReward) { + this.foodReward = foodReward; + } + + public void setLuceK(int luceK) { + this.luceK = luceK; + } + + public void setMovementPenalty(int movementPenalty) { + this.movementPenalty = movementPenalty; + } + + public void setMovementRate(float movementRate) { + this.movementRate = movementRate; + } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 04:55:19 UTC (rev 142) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 05:17:09 UTC (rev 143) @@ -16,13 +16,12 @@ import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentConfigurationEntity; -import edu.indiana.psych.gee.forager.client.ForagerApplet; import edu.indiana.psych.gee.time.Duration; /** * $Id$ * - * Configuration for the forager experiment. + * Persistent configuration for the forager experiment. * * * @author <a href='al...@cs...'>Allen Lee</a> @@ -52,9 +51,6 @@ return ForagerApplet.class.getName(); } - public String getExperimentName() { - return "forager"; - } public String getDescription() { return "The Forager experiment explores how participants allocate themselves in a world with scarce resources."; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-05 04:55:19 UTC (rev 142) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-05 05:17:09 UTC (rev 143) @@ -11,7 +11,6 @@ import java.util.SortedSet; import edu.indiana.psych.gee.AbstractExperiment; -import edu.indiana.psych.gee.ConsentForm; import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.agent.Agent; import edu.indiana.psych.gee.event.AbortExperimentRequest; @@ -185,7 +184,7 @@ */ private void addAgents(ForagerExperimentParameters configuration) { int numberOfParticipants = currentParticipantHeadings.size(); - int minimumParticipants = configuration.getMinimumParticipants(); + int minimumParticipants = configuration.getMinimumParticipantsForNoBots(); getLogger().debug(String.format("Need [%d] participants - have [%d]", minimumParticipants, numberOfParticipants)); if (numberOfParticipants < minimumParticipants) { @@ -237,11 +236,7 @@ } enum ForagerState implements State { WAITING, ROUND_IN_PROGRESS } - - private void foo() { - timeToNextRound = delayBetweenRounds.plus(currentRoundDuration.getDelta()).start(); - } - + private class ForagerStateMachine implements StateMachine { private ForagerState state; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-05 04:55:19 UTC (rev 142) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-05 05:17:09 UTC (rev 143) @@ -6,6 +6,8 @@ import java.util.Properties; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; @@ -13,7 +15,6 @@ import org.hibernate.annotations.Proxy; -import edu.indiana.psych.gee.ExperimentParametersEntity; import edu.indiana.psych.gee.ExperimentRoundParameters; import edu.indiana.psych.gee.time.Duration; @@ -28,6 +29,14 @@ private String name; private int foodSpoilDuration; private double foodRate; + private int minimumParticipantsForNoBots; + private int participantsRequiredForSave; + private int numberOfBots; + private int boardWidth; + private int boardHeight; + private int minimumSeparation; + private int maximumSeparation; + private String specialInstructions; private long id = -1; @@ -55,49 +64,43 @@ } - public int getMinimumParticipants() { - // FIXME: replace with configuration value. - return 5; + public int getMinimumParticipantsForNoBots() { + return minimumParticipantsForNoBots; } public int getNumberOfBots() { - return 5; + return numberOfBots; } public int getMinimumSeparation() { - // FIXME: use actual configuration parameters. - return 5; + return minimumSeparation; } public int getMaximumSeparation() { - // FIXME: use actual configuration parameters. - return 25; + return maximumSeparation; } public String getSpecialInstructions() { - // TODO Auto-generated method stub - return "Very special instructions"; + return specialInstructions; } @Transient public Properties getProperties() { - // TODO Auto-generated method stub return new Properties(); } @Transient public Dimension getBoardSize() { // TODO Auto-generated method stub - return new Dimension(600, 600); + return new Dimension(getBoardWidth(), getBoardHeight()); } public boolean shouldPersist(int numberOfParticipants) { - return (numberOfParticipants >= getNumberOfParticipantsRequiredForSave()); + return (numberOfParticipants >= getParticipantsRequiredForSave()); } - private int getNumberOfParticipantsRequiredForSave() { - // FIXME: remove stub default value. - return 5; + public int getParticipantsRequiredForSave() { + return participantsRequiredForSave; } @Transient @@ -145,8 +148,54 @@ this.foodRate = foodRate; } + @ManyToOne(targetEntity=ForagerAgentConfiguration.class) + @JoinColumn(name="agent_configuration_id") public ForagerAgentConfiguration getAgentConfiguration() { return agentConfiguration; } + + public int getBoardHeight() { + return boardHeight; + } + + public void setBoardHeight(int boardHeight) { + this.boardHeight = boardHeight; + } + + public int getBoardWidth() { + return boardWidth; + } + + public void setBoardWidth(int boardWidth) { + this.boardWidth = boardWidth; + } + + public void setAgentConfiguration(ForagerAgentConfiguration agentConfiguration) { + this.agentConfiguration = agentConfiguration; + } + + public void setMaximumSeparation(int maximumSeparation) { + this.maximumSeparation = maximumSeparation; + } + + public void setMinimumParticipantsForNoBots(int minimumParticipantsForNoBots) { + this.minimumParticipantsForNoBots = minimumParticipantsForNoBots; + } + + public void setMinimumSeparation(int minimumSeparation) { + this.minimumSeparation = minimumSeparation; + } + + public void setNumberOfBots(int numberOfBots) { + this.numberOfBots = numberOfBots; + } + + public void setSpecialInstructions(String specialInstructions) { + this.specialInstructions = specialInstructions; + } + + public void setParticipantsRequiredForSave(int participantsRequiredForSave) { + this.participantsRequiredForSave = participantsRequiredForSave; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-05 04:55:24
|
Revision: 142 Author: alllee Date: 2006-03-04 20:55:19 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=142&view=rev Log Message: ----------- trying to fix the mapping relationship between forager configuration and forager experiment parameters. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/war/WEB-INF/hibernate.cfg.xml Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-05 04:40:28 UTC (rev 141) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-05 04:55:19 UTC (rev 142) @@ -13,6 +13,7 @@ import javax.persistence.Table; import javax.persistence.Transient; +import org.hibernate.annotations.Proxy; /** * $Id$ @@ -26,8 +27,9 @@ */ @Entity +@Inheritance(strategy=InheritanceType.JOINED) @Table(name="experiment_configuration") -@Inheritance(strategy=InheritanceType.JOINED) +@Proxy(proxyClass=ExperimentConfiguration.class) public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> implements ExperimentConfiguration<T> { Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 04:40:28 UTC (rev 141) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-05 04:55:19 UTC (rev 142) @@ -12,6 +12,9 @@ import javax.persistence.Table; import javax.persistence.Transient; +import org.hibernate.annotations.Proxy; + +import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentConfigurationEntity; import edu.indiana.psych.gee.forager.client.ForagerApplet; import edu.indiana.psych.gee.time.Duration; @@ -30,6 +33,7 @@ @DiscriminatorValue("forager") @PrimaryKeyJoinColumn(name="experiment_configuration_id") @Table(name="forager_configuration") +@Proxy(proxyClass=ExperimentConfiguration.class) public class ForagerConfiguration extends ExperimentConfigurationEntity<ForagerExperimentParameters> { private List<ForagerExperimentParameters> allParameters; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-05 04:40:28 UTC (rev 141) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-05 04:55:19 UTC (rev 142) @@ -5,16 +5,11 @@ import java.util.List; import java.util.Properties; -import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; import javax.persistence.Transient; -import javax.persistence.*; import org.hibernate.annotations.Proxy; @@ -23,14 +18,10 @@ import edu.indiana.psych.gee.time.Duration; @Entity -@Inheritance(strategy=InheritanceType.JOINED) -@DiscriminatorValue("forager") -@PrimaryKeyJoinColumn(name="forager_parameters_id") -@Proxy(proxyClass=ExperimentRoundParameters.class) @Table(name="forager_parameters") +@Proxy(proxyClass=ExperimentRoundParameters.class) public class ForagerExperimentParameters implements ExperimentRoundParameters { - private ForagerAgentConfiguration agentConfiguration; private ForagerConfiguration configuration; @@ -40,7 +31,7 @@ private long id = -1; - ForagerExperimentParameters(ForagerConfiguration configuration) { + public ForagerExperimentParameters(ForagerConfiguration configuration) { setConfiguration(configuration); } Modified: trunk/gee/war/WEB-INF/hibernate.cfg.xml =================================================================== --- trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-03-05 04:40:28 UTC (rev 141) +++ trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-03-05 04:55:19 UTC (rev 142) @@ -9,7 +9,7 @@ <session-factory> <mapping package="edu.indiana.psych.gee"/> <mapping class="edu.indiana.psych.gee.ConsentForm"/> - <mapping class="edu.indiana.psych.gee.ExperimentParametersEntity"/> + <mapping class="edu.indiana.psych.gee.ExperimentConfigurationEntity"/> <mapping package="edu.indiana.psych.gee.forager"/> <mapping class="edu.indiana.psych.gee.forager.ForagerExperimentParameters"/> <mapping class="edu.indiana.psych.gee.forager.ForagerConfiguration"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-05 04:41:05
|
Revision: 141 Author: alllee Date: 2006-03-04 20:40:28 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=141&view=rev Log Message: ----------- removed $Log$ changelogs and improving persistence mappings for ConsentForm and ForagerConfiguration/ForagerExperimentParameters Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentLifecycleException.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java trunk/gee/src/java/edu/indiana/psych/gee/Identifier.java trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java trunk/gee/src/java/edu/indiana/psych/gee/action/CreateExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/action/GeeAction.java trunk/gee/src/java/edu/indiana/psych/gee/action/ListExperiments.java trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/agent/Agent.java trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentFactory.java trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentIdentifier.java trunk/gee/src/java/edu/indiana/psych/gee/event/AbortExperimentRequest.java trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractPersistableEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/BeginExperimentRequest.java trunk/gee/src/java/edu/indiana/psych/gee/event/ClientErrorMessageEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/EndRoundEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/Event.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventConstraint.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventGenerator.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventHandler.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventInstanceofConstraint.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventProcessor.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventTypeProcessor.java trunk/gee/src/java/edu/indiana/psych/gee/event/OpenBrowserEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/OrEventConstraint.java trunk/gee/src/java/edu/indiana/psych/gee/event/PersistableEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/RegistrationEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/RoundStartedEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/generics/EventTypeProcessor.java trunk/gee/src/java/edu/indiana/psych/gee/forager/DebriefingAssistant.java trunk/gee/src/java/edu/indiana/psych/gee/forager/Direction.java trunk/gee/src/java/edu/indiana/psych/gee/forager/Food.java trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodDispenser.java trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodRegion.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerGameState.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerPersister.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java trunk/gee/src/java/edu/indiana/psych/gee/forager/GridView.java trunk/gee/src/java/edu/indiana/psych/gee/forager/Visibility.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/DebriefingView.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerApplet.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClient.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerGameWindow.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/SubjectView.java trunk/gee/src/java/edu/indiana/psych/gee/forager/event/AddClientEvent.java trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientUpdateEvent.java trunk/gee/src/java/edu/indiana/psych/gee/forager/event/FoodAddedEvent.java trunk/gee/src/java/edu/indiana/psych/gee/forager/event/MovementEvent.java trunk/gee/src/java/edu/indiana/psych/gee/forager/event/StartExperimentRoundRequest.java trunk/gee/src/java/edu/indiana/psych/gee/net/AbstractDispatcher.java trunk/gee/src/java/edu/indiana/psych/gee/net/AbstractServerDispatcher.java trunk/gee/src/java/edu/indiana/psych/gee/net/ClientDispatcher.java trunk/gee/src/java/edu/indiana/psych/gee/net/ClientSocketDispatcher.java trunk/gee/src/java/edu/indiana/psych/gee/net/ConnectionEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionRequest.java trunk/gee/src/java/edu/indiana/psych/gee/net/Dispatcher.java trunk/gee/src/java/edu/indiana/psych/gee/net/DispatcherFactory.java trunk/gee/src/java/edu/indiana/psych/gee/net/ExperimentUpdateEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java trunk/gee/src/java/edu/indiana/psych/gee/net/ServerAssignedIdentifierEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/ServerDispatcher.java trunk/gee/src/java/edu/indiana/psych/gee/net/ServerSocketDispatcher.java trunk/gee/src/java/edu/indiana/psych/gee/net/SocketDispatcherWorker.java trunk/gee/src/java/edu/indiana/psych/gee/net/SocketIdentifier.java trunk/gee/src/java/edu/indiana/psych/gee/net/Worker.java trunk/gee/src/java/edu/indiana/psych/gee/net/WorkerFactory.java trunk/gee/src/java/edu/indiana/psych/gee/net/WorkerPool.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java trunk/gee/src/java/edu/indiana/psych/gee/time/Duration.java trunk/gee/src/java/edu/indiana/psych/gee/time/TimePoint.java trunk/gee/src/java/edu/indiana/psych/gee/util/GeeUtils.java trunk/gee/src/test/edu/indiana/psych/gee/net/SocketIdentifierTester.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-05 04:40:28 UTC (rev 141) @@ -20,7 +20,7 @@ * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision$ */ -public abstract class AbstractExperiment implements Experiment { +public abstract class AbstractExperiment<T extends ExperimentConfiguration> implements Experiment<T> { private final Log logger = LogFactory.getLog(getClass()); private final EventChannel channel; @@ -29,7 +29,7 @@ private Thread serverThread; private boolean running; - private ExperimentConfiguration configuration; + private T configuration; private List<ExperimentRoundParameters> allParameters; private ExperimentRoundParameters currentParameters; private Iterator<ExperimentRoundParameters> parametersIterator; @@ -39,11 +39,11 @@ dispatcher = DispatcherFactory.getInstance().createServerDispatcher(channel); } - public ExperimentConfiguration getConfiguration() { + public T getConfiguration() { return configuration; } - public void setConfiguration(ExperimentConfiguration configuration) { + public void setConfiguration(T configuration) { if (configuration == null) { throw new IllegalArgumentException("Invalid configuration"); } @@ -82,7 +82,11 @@ public int getServerPort() { return configuration.getServerPort(); } - + + public ConsentForm getConsentForm() { + return getConfiguration().getConsentForm(); + } + public boolean isFull() { // TODO Auto-generated method stub return false; @@ -94,17 +98,11 @@ } public String getDescription() { - if (configuration != null) { - return configuration.getDescription(); - } - return "No description specified."; + return configuration.getDescription(); } public String getName() { - if (configuration != null) { - return configuration.getExperimentName(); - } - return "No experiment name specified."; + return configuration.getExperimentName(); } public boolean equals(Object object) { @@ -201,84 +199,3 @@ }); } } - - -/* - * $Log$ - * Revision 1.17 2006/02/24 06:05:19 alllee - * whackamoling remaining bugs. Needed to synchronize access to - * AbstractServerDispatcher's shutdown method. Added lots of spurious debugging - * output, to be removed soon. - * - * TODO: persistent experiment configuration and reloading. - * - * Revision 1.16 2006/02/23 19:45:00 alllee - * making experimentRunning a bean property. - * - * Revision 1.15 2006/02/23 18:12:21 alllee - * wiring up pages and actions for experiment configuration (via the - * AdminAction) in an effort to understand why the ForagerExperiment is not - * listed as 'running'. - * - * Revision 1.14 2006/02/06 05:33:38 alllee - * Fully adopting Java 1.5 for the client side as well as the server side and generifying more client-dependent classes. - * - * Revision 1.13 2006/02/06 04:58:48 alllee - * removing connection handling code from this base class - i think it makes more sense to just let the custom subclasses handle all connection related functionality like queuing participants vs. adding them in right away, etc. - * - * Revision 1.12 2006/02/04 06:43:40 alllee - * adding more functionality to ForagerExperiment, still need to work out experiment timing details. - * - * Revision 1.11 2006/02/03 21:42:56 alllee - * * changing log levels to DEBUG for mo better diagnostics on the server side. - * * minor presentation changes to CSS, white background behind the content. - * * client/server connection successfully happening, hang issue was resolved by - * removing the spurious dispatcher.listen() from within setConfiguration(). - * * changing ForagerExperiment port to 25000 for no apparent reason. - * - * TODO: finish wiring up the state machine inside the ForagerExperiment. iron - * out details of how to stop an experiment from listening on a port when - * redeploying, currently have to restart the tomcat container to successfully - * stop the experiment and load in the new experiment code bound to the port. - * - * Revision 1.10 2006/02/03 21:28:28 alllee - * removing dispatcher.listen() from calls to setConfiguration, think this is why the server is starting 'prematurely'. - * - * Revision 1.9 2006/01/17 08:34:53 alllee - * adding more presentation layer functionality, dynamic consent form is all set, - * but still need to hook in validation for the name. - * - * Revision 1.8 2006/01/16 07:51:23 alllee - * refining: - * - the EventProcessor abstraction, trying to keep them simple. - * - the threading and event processing model employed by the experiment and its supporting classes, mostly ironing out the responsibilities of the Dispatcher and the Experiment and figuring out what to put where. - * - Duration now has 'canonical' durations (cached, prototype durations ostensibly used to spit out durations with a set start/end time). - * - * Revision 1.7 2006/01/15 00:17:09 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - * Revision 1.6 2006/01/13 09:30:54 alllee - * almost have experiments running - the StartExperiment action has all the - * information it needs and can start the experiment, but the startExperiment - * page is failing because forager-client.jar isn't there. Next step - make - * forager-client.jar there. - * - * Revision 1.5 2006/01/13 07:40:12 alllee - * starting to display experiment metadata through the page. still need to fill - * in the link to actually start and begin participating in an experiment. - * - * Revision 1.4 2006/01/12 04:14:00 alllee - * switching to presentation layer development for some time to get a better feel for what needs to be done with respect to experiment configuration. - * - * Revision 1.3 2006/01/06 21:52:10 alllee - * instead of sprinkling System.currentTimeMillis() everywhere delegating to AbstractExperiment's getCurrentTime() which will switch to System.currentTimeNanos() at some unspecified time in the future. - * - * Revision 1.2 2006/01/06 08:35:27 alllee - * ironing out more of the webapp framework, still highly dysunfunctional/volatile. - * - * Revision 1.1 2006/01/04 05:54:15 alllee - * Adding skeletal support for experiment configuration. - * - ExperimentConfiguration represent the global configuration for a given Experiment server instance, mostly network parameters (hostname/port, etc.) but also some experiment parameters like should-wait-for-facilitator-signal. - * - ExperimentRoundParameters represent per-experimental-round configuration, experiment parameters that affect a single round of a given experiment. - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-05 04:40:28 UTC (rev 141) @@ -124,22 +124,3 @@ } } - - -/* - * $Log$ - * Revision 1.3 2006/02/01 18:12:23 alllee - * consent form approval date and expiration date are now being used by - * the getConsent.jsp view. Still monkeying with validation. Going to have to - * do some serious package refactoring here in a little bit to separate the 1.4 - * compliant stuff from the webapp stuff that can leverage 1.5 pieces. - * - * Revision 1.2 2006/01/17 02:51:40 alllee - * adding Action to load the consent form for the given experiment. - * - * Revision 1.1 2006/01/04 05:54:15 alllee - * Adding skeletal support for experiment configuration. - * - ExperimentConfiguration represent the global configuration for a given Experiment server instance, mostly network parameters (hostname/port, etc.) but also some experiment parameters like should-wait-for-facilitator-signal. - * - ExperimentRoundParameters represent per-experimental-round configuration, experiment parameters that affect a single round of a given experiment. - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java 2006-03-05 04:40:28 UTC (rev 141) @@ -12,7 +12,7 @@ * @version $Revision$ */ -public interface Experiment { +public interface Experiment<T extends ExperimentConfiguration> { public static final Experiment NULL = new Experiment() { private final Log logger = LogFactory.getLog(getClass()); @@ -67,8 +67,8 @@ public boolean isFull(); public boolean isRunning(); - public ExperimentConfiguration getConfiguration(); - public void setConfiguration(ExperimentConfiguration configuration); + public T getConfiguration(); + public void setConfiguration(T configuration); // interface State { // public final static State WAITING = new State() { @@ -96,36 +96,3 @@ } } - -/* - * $Log$ - * Revision 1.7 2006/01/17 08:34:53 alllee - * adding more presentation layer functionality, dynamic consent form is all set, - * but still need to hook in validation for the name. - * - * Revision 1.6 2006/01/13 09:30:54 alllee - * almost have experiments running - the StartExperiment action has all the - * information it needs and can start the experiment, but the startExperiment - * page is failing because forager-client.jar isn't there. Next step - make - * forager-client.jar there. - * - * Revision 1.5 2006/01/13 07:40:12 alllee - * starting to display experiment metadata through the page. still need to fill - * in the link to actually start and begin participating in an experiment. - * - * Revision 1.4 2006/01/12 04:14:00 alllee - * switching to presentation layer development for some time to get a better feel for what needs to be done with respect to experiment configuration. - * - * Revision 1.3 2006/01/06 08:35:27 alllee - * ironing out more of the webapp framework, still highly dysunfunctional/volatile. - * - * Revision 1.2 2006/01/04 05:54:15 alllee - * Adding skeletal support for experiment configuration. - * - ExperimentConfiguration represent the global configuration for a given Experiment server instance, mostly network parameters (hostname/port, etc.) but also some experiment parameters like should-wait-for-facilitator-signal. - * - ExperimentRoundParameters represent per-experimental-round configuration, experiment parameters that affect a single round of a given experiment. - * - * Revision 1.1 2005/12/22 06:44:20 alllee - * skeletal classes for the refactored webapp experiment framework. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-05 04:40:28 UTC (rev 141) @@ -3,6 +3,9 @@ import java.net.InetSocketAddress; import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import edu.indiana.psych.gee.time.Duration; /** @@ -15,6 +18,7 @@ */ public interface ExperimentConfiguration<T extends ExperimentRoundParameters> { + /** * Returns the port that the experiment server with this configuration is @@ -35,7 +39,7 @@ public List<T> getAllParameters(); - public ExperimentRoundParameters getCurrentParameters(); + public T getCurrentParameters(); public String getDescription(); @@ -43,45 +47,8 @@ public String getClientJarName(); + public ConsentForm getConsentForm(); + public Duration getDelayBetweenRounds(); } - - -/* - * $Log$ - * Revision 1.8 2006/02/24 06:05:19 alllee - * whackamoling remaining bugs. Needed to synchronize access to - * AbstractServerDispatcher's shutdown method. Added lots of spurious debugging - * output, to be removed soon. - * - * TODO: persistent experiment configuration and reloading. - * - * Revision 1.7 2006/01/16 07:51:23 alllee - * refining: - * - the EventProcessor abstraction, trying to keep them simple. - * - the threading and event processing model employed by the experiment and its supporting classes, mostly ironing out the responsibilities of the Dispatcher and the Experiment and figuring out what to put where. - * - Duration now has 'canonical' durations (cached, prototype durations ostensibly used to spit out durations with a set start/end time). - * - * Revision 1.6 2006/01/15 00:17:09 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - * Revision 1.5 2006/01/13 09:30:54 alllee - * almost have experiments running - the StartExperiment action has all the - * information it needs and can start the experiment, but the startExperiment - * page is failing because forager-client.jar isn't there. Next step - make - * forager-client.jar there. - * - * Revision 1.4 2006/01/13 07:40:12 alllee - * starting to display experiment metadata through the page. still need to fill - * in the link to actually start and begin participating in an experiment. - * - * Revision 1.3 2006/01/06 08:35:27 alllee - * ironing out more of the webapp framework, still highly dysunfunctional/volatile. - * - * Revision 1.2 2006/01/04 05:54:15 alllee - * Adding skeletal support for experiment configuration. - * - ExperimentConfiguration represent the global configuration for a given Experiment server instance, mostly network parameters (hostname/port, etc.) but also some experiment parameters like should-wait-for-facilitator-signal. - * - ExperimentRoundParameters represent per-experimental-round configuration, experiment parameters that affect a single round of a given experiment. - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-05 04:40:28 UTC (rev 141) @@ -8,10 +8,11 @@ import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Transient; -import edu.indiana.psych.gee.forager.ForagerExperimentParameters; /** * $Id$ @@ -28,7 +29,7 @@ @Table(name="experiment_configuration") @Inheritance(strategy=InheritanceType.JOINED) public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> -implements ExperimentConfiguration { +implements ExperimentConfiguration<T> { private final static String DEFAULT_SERVER_ADDRESS = "groups.psych.indiana.edu"; @@ -38,11 +39,10 @@ private String experimentName; private String clientJarName; private String clientMainClass; + private ConsentForm consentForm; - private ForagerExperimentParameters currentParameters; -// private List<T> allParameters; - private List<ForagerExperimentParameters> allParameters; + private T currentParameters; private InetSocketAddress serverAddress; private int serverPort; private String serverName; @@ -105,21 +105,18 @@ this.triggeredExperiment = triggeredExperiment; } - -// @OneToMany(targetEntity=ExperimentParametersEntity.class) -// @OneToMany(targetEntity=ForagerExperimentParameters.class) - // @JoinColumn(name="configuration_id") - @Transient - public List<ForagerExperimentParameters> getAllParameters() { - return allParameters; + @ManyToOne(targetEntity=ConsentForm.class) + @JoinColumn(name="consent_id") + public ConsentForm getConsentForm() { + return consentForm; } - - public void setAllParameters(List<ForagerExperimentParameters> allParameters) { - this.allParameters = allParameters; + public void setConsentForm(ConsentForm consentForm) { + this.consentForm = consentForm; } - + @Transient - public synchronized ForagerExperimentParameters getCurrentParameters() { + public synchronized T getCurrentParameters() { + List<T> allParameters = getAllParameters(); if (currentParameters == null) { if (allParameters.isEmpty()) { throw new ExperimentLifecycleException("No experiment round parameters available for : " + getExperimentName()); @@ -161,24 +158,3 @@ this.clientMainClass = clientMainClass; } } - - -/* - * $Log$ - * Revision 1.4 2006/01/15 00:17:09 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - * Revision 1.3 2006/01/14 03:23:06 alllee - * beating out Configuration's implementation - more to come soon from the - * Eclipse side. - * - * Revision 1.2 2006/01/13 09:30:54 alllee - * almost have experiments running - the StartExperiment action has all the - * information it needs and can start the experiment, but the startExperiment - * page is failing because forager-client.jar isn't there. Next step - make - * forager-client.jar there. - * - * Revision 1.1 2006/01/12 04:14:00 alllee - * switching to presentation layer development for some time to get a better feel for what needs to be done with respect to experiment configuration. - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentLifecycleException.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentLifecycleException.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentLifecycleException.java 2006-03-05 04:40:28 UTC (rev 141) @@ -26,13 +26,3 @@ } } -/* - * $Log$ - * Revision 1.2 2006/01/12 04:14:00 alllee - * switching to presentation layer development for some time to get a better feel for what needs to be done with respect to experiment configuration. - * - * Revision 1.1 2005/12/22 06:44:20 alllee - * skeletal classes for the refactored webapp experiment framework. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java 2006-03-05 04:40:28 UTC (rev 141) @@ -30,30 +30,3 @@ public AgentConfiguration getAgentConfiguration(); } -/* - * $Log$ - * Revision 1.5 2006/02/04 06:43:40 alllee - * adding more functionality to ForagerExperiment, still need to work out experiment timing details. - * - * Revision 1.4 2006/01/16 07:51:23 alllee - * refining: - * - the EventProcessor abstraction, trying to keep them simple. - * - the threading and event processing model employed by the experiment and its supporting classes, mostly ironing out the responsibilities of the Dispatcher and the Experiment and figuring out what to put where. - * - Duration now has 'canonical' durations (cached, prototype durations ostensibly used to spit out durations with a set start/end time). - * - * Revision 1.3 2006/01/15 00:17:09 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - * Revision 1.2 2006/01/12 04:14:00 alllee - * switching to presentation layer development for some time to get a better feel for what needs to be done with respect to experiment configuration. - * - * Revision 1.1 2006/01/04 05:54:15 alllee - * Adding skeletal support for experiment configuration. - * - ExperimentConfiguration represent the global configuration for a given Experiment server instance, mostly network parameters (hostname/port, etc.) but also some experiment parameters like should-wait-for-facilitator-signal. - * - ExperimentRoundParameters represent per-experimental-round configuration, experiment parameters that affect a single round of a given experiment. - * - * Revision 1.1 2005/12/22 06:44:20 alllee - * skeletal classes for the refactored webapp experiment framework. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/Identifier.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/Identifier.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/Identifier.java 2006-03-05 04:40:28 UTC (rev 141) @@ -24,10 +24,3 @@ } }; } - -/* - * $Log$ - * Revision 1.1 2006/01/06 08:35:27 alllee - * ironing out more of the webapp framework, still highly dysunfunctional/volatile. - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java 2006-03-05 04:40:28 UTC (rev 141) @@ -7,6 +7,10 @@ /** * $Id$ * + * Allows the user to administer experiments. Administrative actions include + * configuring, starting and stopping experiments as well as attaching to + * experiments as a bystander and viewing experiment statuses. + * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision$ */ @@ -70,20 +74,3 @@ } } -/* - * $Log$ - * Revision 1.3 2006/02/24 06:05:20 alllee - * whackamoling remaining bugs. Needed to synchronize access to - * AbstractServerDispatcher's shutdown method. Added lots of spurious debugging - * output, to be removed soon. - * - * TODO: persistent experiment configuration and reloading. - * - * Revision 1.2 2006/02/23 21:12:32 alllee - * extracting WebWork/xwork dependency to GeeAction base class. Currently supplies a logger and an ExperimentService (set by Spring) to subclasses. - * - * Revision 1.1 2006/02/23 19:49:33 alllee - * trying a new kind of Action with multiple methods mapped to action URLs. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/CreateExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/CreateExperiment.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/CreateExperiment.java 2006-03-05 04:40:28 UTC (rev 141) @@ -18,27 +18,3 @@ } -/* - * $Log$ - * Revision 1.4 2006/02/23 21:12:32 alllee - * extracting WebWork/xwork dependency to GeeAction base class. Currently supplies a logger and an ExperimentService (set by Spring) to subclasses. - * - * Revision 1.3 2006/02/23 18:12:22 alllee - * wiring up pages and actions for experiment configuration (via the - * AdminAction) in an effort to understand why the ForagerExperiment is not - * listed as 'running'. - * - * Revision 1.2 2006/01/17 02:51:40 alllee - * adding Action to load the consent form for the given experiment. - * - * Revision 1.1 2005/12/21 20:58:49 alllee - * - staying with the model of keeping necessary jar and config files in the - * source tree at the same location where they are going to be in the deployed - * war. For the purposes of this project at least this makes the knowledge of - * where these files live implicit, as opposed to keeping them all in a - * top-level src/conf or lib directory and then encoding the knowledge of where - * to place them in the build.xml target logic. - * - adding first stubby Actions and some basic jars needed for webwork. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/GeeAction.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/GeeAction.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/GeeAction.java 2006-03-05 04:40:28 UTC (rev 141) @@ -10,7 +10,7 @@ /** * $Id$ * - * Base class for all Gee Actions, provides a logger and an event channel. + * Base class for all Gee Actions, provides a Logger and ExperimentService. * * * @author <a href='al...@cs...'>Allen Lee</a> @@ -35,11 +35,3 @@ this.experimentService = experimentService; } } - - -/* - * $Log$ - * Revision 1.1 2006/02/23 21:12:32 alllee - * extracting WebWork/xwork dependency to GeeAction base class. Currently supplies a logger and an ExperimentService (set by Spring) to subclasses. - * - */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/ListExperiments.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/ListExperiments.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/ListExperiments.java 2006-03-05 04:40:28 UTC (rev 141) @@ -8,6 +8,8 @@ /** * $Id$ * + * Loads all available experiments into a bean property. + * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision$ */ @@ -30,31 +32,3 @@ } -/* - * $Log$ - * Revision 1.6 2006/02/23 21:12:32 alllee - * extracting WebWork/xwork dependency to GeeAction base class. Currently supplies a logger and an ExperimentService (set by Spring) to subclasses. - * - * Revision 1.5 2006/01/17 02:51:40 alllee - * adding Action to load the consent form for the given experiment. - * - * Revision 1.4 2006/01/13 07:40:12 alllee - * starting to display experiment metadata through the page. still need to fill - * in the link to actually start and begin participating in an experiment. - * - * Revision 1.3 2006/01/12 20:23:48 alllee - * presentation layer inching closer towards completeness. Getting webworks tags - * hooked up with the jsps. The stack is a really nice implicit way to pass - * values around from Action to Page. Unfortunately documentation for the - * project is pretty poor, hopefully the struts integration will improve this. - * - * Revision 1.2 2006/01/04 05:54:17 alllee - * Adding skeletal support for experiment configuration. - * - ExperimentConfiguration represent the global configuration for a given Experiment server instance, mostly network parameters (hostname/port, etc.) but also some experiment parameters like should-wait-for-facilitator-signal. - * - ExperimentRoundParameters represent per-experimental-round configuration, experiment parameters that affect a single round of a given experiment. - * - * Revision 1.1 2005/12/21 21:47:27 alllee - * adding ant task to build web components and stubbed out XWork actions. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-03-05 04:40:28 UTC (rev 141) @@ -74,47 +74,3 @@ } } -/* - * $Log$ - * Revision 1.9 2006/02/23 21:12:32 alllee - * extracting WebWork/xwork dependency to GeeAction base class. Currently supplies a logger and an ExperimentService (set by Spring) to subclasses. - * - * Revision 1.8 2006/02/03 21:28:28 alllee - * removing dispatcher.listen() from calls to setConfiguration, think this is why the server is starting 'prematurely'. - * - * Revision 1.7 2006/02/03 08:02:49 alllee - * forager experiment almost back up again, some last minute debugging left to - * do after some sleep. - * - * TODO: AbstractEvent is getting instantiated with a Null ID for some - * reasonon the client side via ClientReadyEvent it appears. - * - * Revision 1.6 2006/02/03 00:22:47 alllee - * fixing validation up some more. StartExperiment needs accessors for its - * validated fields in order for the validation to work. - * - * Revision 1.5 2006/01/17 08:34:54 alllee - * adding more presentation layer functionality, dynamic consent form is all set, - * but still need to hook in validation for the name. - * - * Revision 1.4 2006/01/14 00:36:00 alllee - * adding a brief client message if StartExperiments fails. That class is not an - * optimal place to store those kind of messages, forces recompilation in order - * to change the message. Lift to a configuration later, there should be a - * webwork way to store messages. - * - * Revision 1.3 2006/01/13 09:30:54 alllee - * almost have experiments running - the StartExperiment action has all the - * information it needs and can start the experiment, but the startExperiment - * page is failing because forager-client.jar isn't there. Next step - make - * forager-client.jar there. - * - * Revision 1.2 2006/01/13 07:40:12 alllee - * starting to display experiment metadata through the page. still need to fill - * in the link to actually start and begin participating in an experiment. - * - * Revision 1.1 2005/12/21 21:47:27 alllee - * adding ant task to build web components and stubbed out XWork actions. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/agent/Agent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/agent/Agent.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/agent/Agent.java 2006-03-05 04:40:28 UTC (rev 141) @@ -22,13 +22,3 @@ public interface Agent { public AgentIdentifier id(); } - - - -/* - * $Log$ - * Revision 1.1 2006/02/04 06:37:58 alllee - * adding base agent package support. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentConfiguration.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentConfiguration.java 2006-03-05 04:40:28 UTC (rev 141) @@ -24,11 +24,3 @@ public Properties getProperties(); } - - -/* - * $Log$ - * Revision 1.1 2006/02/04 06:37:58 alllee - * adding base agent package support. - * - */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentFactory.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentFactory.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentFactory.java 2006-03-05 04:40:28 UTC (rev 141) @@ -17,11 +17,3 @@ public Agent create(P parameters); } - -/* - * $Log$ - * Revision 1.1 2006/02/04 06:37:58 alllee - * adding base agent package support. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentIdentifier.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentIdentifier.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/agent/AgentIdentifier.java 2006-03-05 04:40:28 UTC (rev 141) @@ -17,9 +17,6 @@ private static AgentIdentifier lastIdentifier = null; - // FIXME: may want to have a static int ordinal for imposing order? - // Actually we can simulate that easily by inserting into an - // OrderedSet and having a comparator compare creationTime and id. private final long creationTime = System.currentTimeMillis(); private long id = 0; @@ -61,14 +58,3 @@ } } - - -/* - * $Log$ - * Revision 1.1 2006/02/04 06:37:58 alllee - * adding base agent package support. - * - * Revision 1.1 2006/01/15 00:17:09 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/AbortExperimentRequest.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/AbortExperimentRequest.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/AbortExperimentRequest.java 2006-03-05 04:40:28 UTC (rev 141) @@ -28,10 +28,3 @@ } } -/* - * $Log$ - * Revision 1.1 2006/01/15 00:17:08 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractEvent.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractEvent.java 2006-03-05 04:40:28 UTC (rev 141) @@ -58,13 +58,3 @@ return creationTime; } } -/* - * $Log$ - * Revision 1.2 2006/02/04 23:08:02 alllee - * mindless hygiene + comment fixes. Still fixing ForagerExperiment, folding over functionality from ForagerServer and refactoring as I go. - * - * Revision 1.1 2006/01/06 08:36:02 alllee - * transferred the core event subsystem into the webapp framework. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractPersistableEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractPersistableEvent.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractPersistableEvent.java 2006-03-05 04:40:28 UTC (rev 141) @@ -40,22 +40,16 @@ // System.currentTimeMillis() is not fine-grained enough to distinguish // between two Event creation times occasionally, hence the use of the // ordinal to help impose a total ordering across all persistable events. - long diff = (getCreationTime() - e.getCreationTime()); - if ( diff == 0 ) { + int comparison = compare(getCreationTime(), e.getCreationTime()); + if (comparison == 0) { // this may cause problems with overflow if that should ever happen. - diff = ordinal - e.ordinal; - return (diff > 0) ? 1 : (diff == 0) ? 0 : -1; + return compare(ordinal, e.ordinal); } - return (diff > 0) ? 1 : -1; + return comparison; } + + private int compare(long a, long b) { + return (a > b) ? 1 : (a == b) ? 0 : -1; + } } -/* - * $Log$ - * Revision 1.2 2006/02/04 23:08:02 alllee - * mindless hygiene + comment fixes. Still fixing ForagerExperiment, folding over functionality from ForagerServer and refactoring as I go. - * - * Revision 1.1 2006/01/15 00:17:08 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/BeginExperimentRequest.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/BeginExperimentRequest.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/BeginExperimentRequest.java 2006-03-05 04:40:28 UTC (rev 141) @@ -28,16 +28,3 @@ } } -/* - * $Log$ - * Revision 1.2 2006/02/04 23:08:02 alllee - * mindless hygiene + comment fixes. Still fixing ForagerExperiment, folding over functionality from ForagerServer and refactoring as I go. - * - * Revision 1.1 2006/02/04 06:43:40 alllee - * adding more functionality to ForagerExperiment, still need to work out experiment timing details. - * - * Revision 1.1 2006/01/15 00:17:08 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/ClientErrorMessageEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/ClientErrorMessageEvent.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/ClientErrorMessageEvent.java 2006-03-05 04:40:28 UTC (rev 141) @@ -36,16 +36,3 @@ } - -/* - * $Log$ - * Revision 1.1 2006/01/15 00:17:08 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - * Revision 1.2 2005/09/22 03:19:23 alllee - * adding serialVersionUID to all serializable classes. - * - * Revision 1.1 2004/12/05 05:51:54 alllee - * event to convey error messages to the ForagerApplet and ForagerClient - * - */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EndRoundEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EndRoundEvent.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EndRoundEvent.java 2006-03-05 04:40:28 UTC (rev 141) @@ -46,61 +46,3 @@ } } -/** - * $Log$ - * Revision 1.2 2006/01/16 07:51:23 alllee - * refining: - * - the EventProcessor abstraction, trying to keep them simple. - * - the threading and event processing model employed by the experiment and its supporting classes, mostly ironing out the responsibilities of the Dispatcher and the Experiment and figuring out what to put where. - * - Duration now has 'canonical' durations (cached, prototype durations ostensibly used to spit out durations with a set start/end time). - * - * Revision 1.1 2006/01/15 00:17:08 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - * Revision 1.9 2005/09/22 03:19:23 alllee - * adding serialVersionUID to all serializable classes. - * - * Revision 1.8 2004/11/22 07:55:32 alllee - * Switched back to SocketDispatcher - NioDispatcher seems to be causing problems - * once again, the debriefings aren't getting sent properly for some reason. - * SIGH. - * - anal-retentively turned ServerUpdateEvent into a marker interface instead of - * an abstract class - * - working on ForagerClient, ForagerGameWindow, ForagerServer, trying to get - * the fuckers to display properly. Unfortunately, the timeLeftLabel is still - * fubared. Swing is such a train wreck. I'd love to move this whole thing to - * the Eclipse SWT so I can half-ass learn yet another GUI toolkit. - * - * Revision 1.7 2004/10/05 20:52:39 alllee - * - refixed compareTo in PersistableEvent; compareTo is NOT equals() or - * hashCode(). It's only used for determining a total ordering on events - * within a Collection for instance. - * - adding a Set of PersistableEvents to the EndRoundEvent so that the client - * can reconstruct a graphical debriefing view. - * - * Revision 1.6 2004/08/30 20:52:37 alllee - * - trying to get the full debriefing up on the server side. Curiouser and - * curiouser; when you don't move at all during the experiment, the full - * debriefing pops up, but if you do move during the experiment, it doesn't. - * Could it be related to the persister somehow? Will probably need to use a - * standalone client to better debug this problem, but the last time I checked - * it didn't even occur on the standalone client... grrr. - * - * Revision 1.5 2004/07/29 13:54:31 andjones - * .Fixed persister to write research results to file - * .client now gets debriefing from server (with minimal stats) - * .bug fixes - * - * Revision 1.4 2004/07/29 12:54:23 andjones - * OHhhhh yea - * - * Revision 1.3 2004/07/29 06:35:25 andjones - * Getting the client closer to looking sweeeeet - * - * Revision 1.2 2004/07/12 03:42:25 alllee - * events refactoring, finalizing remote messaging protocol. - * - * Revision 1.1 2004/07/12 01:57:55 andjones - * Yea, these may help us spank it... - ADJ - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/Event.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/Event.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/Event.java 2006-03-05 04:40:28 UTC (rev 141) @@ -20,16 +20,3 @@ public long getCreationTime(); } - - - -/* - * $Log$ - * Revision 1.2 2006/01/17 02:19:08 alllee - * adding food dispenser, fixing logic in ForagerPersister, and propagating the introduction of Durations into the configuration levels and food-type classes. - * - * Revision 1.1 2006/01/06 08:36:02 alllee - * transferred the core event subsystem into the webapp framework. - * - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java 2006-03-05 04:40:28 UTC (rev 141) @@ -194,38 +194,3 @@ } } } - -/* - * $Log$ - * Revision 1.8 2006/02/06 05:57:31 alllee - * for want of curried procedures, you can now 'register' with the EventChannel - * and get a List of event processors that, if you add to it directly, subscribes - * your newly added event processor to the EventChannel. - * - * Revision 1.7 2006/02/06 05:52:33 alllee - * complexifying EventChannel some more to make it easier to attach/detach anonymous event processors that still get cleaned up appropriately by associating them with owners who manage them. - * - * Revision 1.6 2006/02/06 04:59:10 alllee - * mindless hygiene - * - * Revision 1.5 2006/02/04 06:43:40 alllee - * adding more functionality to ForagerExperiment, still need to work out experiment timing details. - * - * Revision 1.4 2006/01/16 23:57:33 alllee - * EventProcessors are now EventConstraints as well to better support constraint chaining - an explicit way of doing it outside of superclass chaining would be nice in addition. Hopefully it doesn't become too confusing. - * - * Mindless hygiene of other classes, almost to the point where we can test running experiments in the webapp. - * - * Revision 1.3 2006/01/16 07:51:23 alllee - * refining: - * - the EventProcessor abstraction, trying to keep them simple. - * - the threading and event processing model employed by the experiment and its supporting classes, mostly ironing out the responsibilities of the Dispatcher and the Experiment and figuring out what to put where. - * - Duration now has 'canonical' durations (cached, prototype durations ostensibly used to spit out durations with a set start/end time). - * - * Revision 1.2 2006/01/15 00:17:08 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - * Revision 1.1 2006/01/06 08:36:02 alllee - * transferred the core event subsystem into the webapp framework. - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventConstraint.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventConstraint.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventConstraint.java 2006-03-05 04:40:28 UTC (rev 141) @@ -24,16 +24,3 @@ */ public boolean accepts(Event event); } -/* - * $Log$ - * Revision 1.1 2006/01/06 08:36:02 alllee - * transferred the core event subsystem into the webapp framework. - * - * Revision 1.1 2004/05/11 02:15:57 alllee - * The beginnings of a messaging framework for GABEL. It's intended use is only - * on the server side, though extension to a remote messaging framework is also - * possible by making Events Serializable, and creating RemoteEventHandler, - * RemoveEventGenerator interfaces. The focal point is the EventChannel, which - * is a mediator, dispatching Events to EventHandlers interested in those Events. - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventGenerator.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventGenerator.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventGenerator.java 2006-03-05 04:40:28 UTC (rev 141) @@ -29,12 +29,3 @@ */ public void unsubscribe(EventHandler handler); } - -/* - * $Log$ - * Revision 1.2 2006/01/16 22:47:31 alllee - * ClientSocketDispatcher now emits a ConnectionEvent into the client's local event channel upon a successful connect(). - * - * Revision 1.1 2006/01/06 08:36:02 alllee - * transferred the core event subsystem into the webapp framework. - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventHandler.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventHandler.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventHandler.java 2006-03-05 04:40:28 UTC (rev 141) @@ -17,11 +17,3 @@ */ public void handle(Event event); } - -/* - * $Log$ - * Revision 1.1 2006/01/06 08:36:02 alllee - * transferred the core event subsystem into the webapp framework. - * - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventInstanceofConstraint.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventInstanceofConstraint.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventInstanceofConstraint.java 2006-03-05 04:40:28 UTC (rev 141) @@ -49,18 +49,3 @@ return target.isInstance(defendant); } } - -/* - * $Log$ - * Revision 1.1 2006/01/06 08:36:02 alllee - * transferred the core event subsystem into the webapp framework. - * - * Revision 1.1 2004/05/11 02:15:57 alllee - * The beginnings of a messaging framework for GABEL. It's intended use is only - * on the server side, though extension to a remote messaging framework is also - * possible by making Events Serializable, and creating RemoteEventHandler, - * RemoveEventGenerator interfaces. The focal point is the EventChannel, which - * is a mediator, dispatching Events to EventHandlers interested in those Events. - * - * - */ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventProcessor.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventProcessor.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventProcessor.java 2006-03-05 04:40:28 UTC (rev 141) @@ -13,22 +13,3 @@ public interface EventProcessor extends EventHandler, EventConstraint { } - - -/* - * $Log$ - * Revision 1.3 2006/01/16 23:57:32 alllee - * EventProcessors are now EventConstraints as well to better support constraint chaining - an explicit way of doing it outside of superclass chaining would be nice in addition. Hopefully it doesn't become too confusing. - * - * Mindless hygiene of other classes, almost to the point where we can test running experiments in the webapp. - * - * Revision 1.2 2006/01/16 07:51:23 alllee - * refining: - * - the EventProcessor abstraction, trying to keep them simple. - * - the threading and event processing model employed by the experiment and its supporting classes, mostly ironing out the responsibilities of the Dispatcher and the Experiment and figuring out what to put where. - * - Duration now has 'canonical' durations (cached, prototype durations ostensibly used to spit out durations with a set start/end time). - * - * Revision 1.1 2006/01/15 00:17:08 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventTypeProcessor.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventTypeProcessor.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventTypeProcessor.java 2006-03-05 04:40:28 UTC (rev 141) @@ -20,22 +20,3 @@ return constraint.accepts(event); } } - - -/* - * $Log$ - * Revision 1.2 2006/01/16 23:57:32 alllee - * EventProcessors are now EventConstraints as well to better support constraint chaining - an explicit way of doing it outside of superclass chaining would be nice in addition. Hopefully it doesn't become too confusing. - * - * Mindless hygiene of other classes, almost to the point where we can test running experiments in the webapp. - * - * Revision 1.1 2006/01/16 07:51:23 alllee - * refining: - * - the EventProcessor abstraction, trying to keep them simple. - * - the threading and event processing model employed by the experiment and its supporting classes, mostly ironing out the responsibilities of the Dispatcher and the Experiment and figuring out what to put where. - * - Duration now has 'canonical' durations (cached, prototype durations ostensibly used to spit out durations with a set start/end time). - * - * Revision 1.1 2006/01/15 00:17:08 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/OpenBrowserEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/OpenBrowserEvent.java 2006-03-05 01:18:24 UTC (rev 140) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/OpenB... [truncated message content] |
From: <al...@us...> - 2006-03-05 01:18:28
|
Revision: 140 Author: alllee Date: 2006-03-04 17:18:24 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=140&view=rev Log Message: ----------- it'll be easier to maintain this if we don't have to worry about auto-committing this file with user/pass info. Rename to jdbc.properties with the appropriate information at deployment time. Added Paths: ----------- trunk/gee/war/WEB-INF/jdbc.properties.example Removed Paths: ------------- trunk/gee/war/WEB-INF/jdbc.properties Deleted: trunk/gee/war/WEB-INF/jdbc.properties =================================================================== --- trunk/gee/war/WEB-INF/jdbc.properties 2006-03-04 21:02:42 UTC (rev 139) +++ trunk/gee/war/WEB-INF/jdbc.properties 2006-03-05 01:18:24 UTC (rev 140) @@ -1,7 +0,0 @@ -# replace these with custom database user/pass -# the database name -geedb.name=gee -# a username with privileges to admin experiments -geedb.user=dummy-user -# admin's db password -geedb.password=dummy-password Copied: trunk/gee/war/WEB-INF/jdbc.properties.example (from rev 137, trunk/gee/war/WEB-INF/jdbc.properties) =================================================================== --- trunk/gee/war/WEB-INF/jdbc.properties.example (rev 0) +++ trunk/gee/war/WEB-INF/jdbc.properties.example 2006-03-05 01:18:24 UTC (rev 140) @@ -0,0 +1,7 @@ +# replace these with custom database user/pass +# the database name +geedb.name=gee +# a username with privileges to admin experiments +geedb.user=dummy-user +# admin's db password +geedb.password=dummy-password This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 21:02:50
|
Revision: 139 Author: alllee Date: 2006-03-04 13:02:42 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=139&view=rev Log Message: ----------- schema generation now works from ant init-db task, still needs more tweaking though. Modified Paths: -------------- trunk/gee/build.xml trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/war/WEB-INF/applicationContext.xml Added Paths: ----------- trunk/gee/war/WEB-INF/lib/mysql-connector-java-3.1.12-bin.jar Modified: trunk/gee/build.xml =================================================================== --- trunk/gee/build.xml 2006-03-04 19:10:37 UTC (rev 138) +++ trunk/gee/build.xml 2006-03-04 21:02:42 UTC (rev 139) @@ -8,8 +8,10 @@ <property file='build.properties'/> <property name='build.dir' value='build'/> - <property name='src.dir' value='src/java'/> - <property name='test.src.dir' value='test'/> + <property name='src.dir' value='src'/> + <property name='java.src.dir' value='${src.dir}/java'/> + <property name='test.src.dir' value='${src.dir}/test'/> + <property name='generated.dir' value='${src.dir}/generated'/> <property name='test.build.dir' value='build/test'/> <property name='test.results.dir' value='test-results'/> <property name='war.dir' value='war'/> @@ -19,7 +21,7 @@ <property name='war.file' value='gee.war'/> <!-- tomcat properties --> -<!-- FIXME: should try to grab tomcat.home from environment first TOMCAT_HOME --> +<!-- FIXME: should try to grab tomcat.home from environment first? --> <property name='tomcat.home' value='/usr/local/tomcat'/> <property name='tomcat.lib.dir' value='${tomcat.home}/server/lib'/> <property name='tomcat.webapps.dir' value='${tomcat.home}/webapps'/> @@ -47,7 +49,7 @@ <!-- compilation tasks --> <target name='compile' depends='prepare'> - <javac srcdir='${src.dir}' + <javac srcdir='${java.src.dir}' destdir='${build.dir}' debug='on' deprecation='on' @@ -55,16 +57,18 @@ <classpath refid='build.classpath' /> </javac> <copy todir='${build.dir}'> - <fileset dir='${src.dir}'> + <fileset dir='${java.src.dir}'> <include name='**/*.xml'/> <include name='**/*.properties'/> </fileset> </copy> + <copy file='${web.inf}/classes/log4j.properties' todir='${build.dir}' /> </target> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="build.classpath"/> <target name="init-db" depends="compile"> - <echo message="You must have a build.properties file with valid database connection information for this task to succeed."/> + <mkdir dir='${generated.dir}'/> + <echo message="You must have valid database connection information within build.properties for this task to succeed."/> <hibernatetool destdir="${generated.dir}"> <classpath> <path location="${build.dir}"/> @@ -78,7 +82,7 @@ <!-- compilation tasks --> <target name='compile-forager-client' depends='prepare'> - <javac srcdir="${src.dir}" + <javac srcdir="${java.src.dir}" destdir='${build.dir}' debug='on' deprecation='on' Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 19:10:37 UTC (rev 138) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 21:02:42 UTC (rev 139) @@ -17,34 +17,8 @@ * @version $Revision: $ */ -@Entity -@Table(name="experiment_parameters") -@Inheritance(strategy=InheritanceType.JOINED) public abstract class ExperimentParametersEntity<T extends ExperimentConfiguration> implements ExperimentRoundParameters { - private long id = -1; - private T configuration; - - @Id @GeneratedValue - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - @ManyToOne(targetEntity=ExperimentConfigurationEntity.class) - @JoinColumn(name="configuration_id", nullable=false) - public T getConfiguration() { - return configuration; - } - - public void setConfiguration(T configuration) { - this.configuration = configuration; - } - - } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 19:10:37 UTC (rev 138) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 21:02:42 UTC (rev 139) @@ -14,6 +14,7 @@ import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; import javax.persistence.Transient; +import javax.persistence.*; import org.hibernate.annotations.Proxy; @@ -27,21 +28,43 @@ @PrimaryKeyJoinColumn(name="forager_parameters_id") @Proxy(proxyClass=ExperimentRoundParameters.class) @Table(name="forager_parameters") -public class ForagerExperimentParameters extends ExperimentParametersEntity<ForagerConfiguration> { +public class ForagerExperimentParameters implements ExperimentRoundParameters { private ForagerAgentConfiguration agentConfiguration; + private ForagerConfiguration configuration; private String name; private int foodSpoilDuration; private double foodRate; - + private long id = -1; + + ForagerExperimentParameters(ForagerConfiguration configuration) { setConfiguration(configuration); } + @Id @GeneratedValue + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne(targetEntity=ForagerConfiguration.class) + @JoinColumn(name="configuration_id", nullable=false) + public ForagerConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration(ForagerConfiguration configuration) { + this.configuration = configuration; + } + public int getMinimumParticipants() { // FIXME: replace with configuration value. return 5; Modified: trunk/gee/war/WEB-INF/applicationContext.xml =================================================================== --- trunk/gee/war/WEB-INF/applicationContext.xml 2006-03-04 19:10:37 UTC (rev 138) +++ trunk/gee/war/WEB-INF/applicationContext.xml 2006-03-04 21:02:42 UTC (rev 139) @@ -10,7 +10,7 @@ </bean> <bean id="mysqlDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> - <property name="url" value="jdbc:mysql://localhost/${geedb.name}"/> + <property name="url" value="jdbc:mysql://localhost:3306/${geedb.name}"/> <property name="username" value="${geedb.user}"/> <property name="password" value="${geedb.password}"/> </bean> Added: trunk/gee/war/WEB-INF/lib/mysql-connector-java-3.1.12-bin.jar =================================================================== (Binary files differ) Property changes on: trunk/gee/war/WEB-INF/lib/mysql-connector-java-3.1.12-bin.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 19:10:45
|
Revision: 138 Author: alllee Date: 2006-03-04 11:10:37 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=138&view=rev Log Message: ----------- webapp now starts up again at least. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/war/startExperiment.jsp Added Paths: ----------- trunk/gee/war/WEB-INF/lib/asm.jar Modified: trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-04 18:55:18 UTC (rev 137) +++ trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-04 19:10:37 UTC (rev 138) @@ -7,6 +7,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; +import javax.persistence.*; /** * $Id$ @@ -77,12 +78,14 @@ public void setDescription(String description) { this.description = description; } + @Transient public Date getIrbDateApprovalExpires() { Calendar calendar = Calendar.getInstance(); calendar.setTime(getIrbDateApproved()); calendar.add(Calendar.DAY_OF_MONTH, 364); return calendar.getTime(); } + @Temporal(TemporalType.DATE) public Date getIrbDateApproved() { if (irbDateApproved == null || isToday(irbDateApproved)) { Calendar calendar = Calendar.getInstance(); @@ -91,6 +94,11 @@ } return irbDateApproved; } + + public void setIrbDateApproved(Date irbDateApproved) { + this.irbDateApproved = irbDateApproved; + } + // FIXME: atrocity private boolean isToday(Date date) { Calendar now = Calendar.getInstance(); @@ -101,9 +109,7 @@ && now.get(Calendar.YEAR) == then.get(Calendar.YEAR) && now.get(Calendar.DAY_OF_MONTH) == then.get(Calendar.DAY_OF_MONTH)); } - public void setIrbDateApproved(Date irbDateApproved) { - this.irbDateApproved = irbDateApproved; - } + public String getParticipation() { return participation; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-04 18:55:18 UTC (rev 137) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-04 19:10:37 UTC (rev 138) @@ -3,6 +3,7 @@ import java.net.InetSocketAddress; import java.util.List; +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Inheritance; @@ -23,6 +24,7 @@ * @version $Revision$ */ +@Entity @Table(name="experiment_configuration") @Inheritance(strategy=InheritanceType.JOINED) public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> @@ -35,6 +37,7 @@ private String description; private String experimentName; private String clientJarName; + private String clientMainClass; private ForagerExperimentParameters currentParameters; @@ -149,6 +152,14 @@ public void setExperimentName(String experimentName) { this.experimentName = experimentName; } + + public String getClientMainClass() { + return clientMainClass; + } + + public void setClientMainClass(String clientMainClass) { + this.clientMainClass = clientMainClass; + } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 18:55:18 UTC (rev 137) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 19:10:37 UTC (rev 138) @@ -6,6 +6,7 @@ import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.Table; +import javax.persistence.*; /** * $Id: Exp$ @@ -19,11 +20,12 @@ @Entity @Table(name="experiment_parameters") @Inheritance(strategy=InheritanceType.JOINED) -public abstract class ExperimentParametersEntity implements ExperimentRoundParameters { +public abstract class ExperimentParametersEntity<T extends ExperimentConfiguration> +implements ExperimentRoundParameters { private long id = -1; - private ExperimentConfiguration configuration; + private T configuration; @Id @GeneratedValue public long getId() { @@ -34,11 +36,13 @@ this.id = id; } - public ExperimentConfiguration getConfiguration() { + @ManyToOne(targetEntity=ExperimentConfigurationEntity.class) + @JoinColumn(name="configuration_id", nullable=false) + public T getConfiguration() { return configuration; } - public void setConfiguration(ExperimentConfiguration configuration) { + public void setConfiguration(T configuration) { this.configuration = configuration; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java 2006-03-04 18:55:18 UTC (rev 137) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java 2006-03-04 19:10:37 UTC (rev 138) @@ -15,13 +15,13 @@ * @version $Revision$ */ -public interface ExperimentRoundParameters { +public interface ExperimentRoundParameters<T extends ExperimentConfiguration> { public String getSpecialInstructions(); public Dimension getBoardSize(); - public ExperimentConfiguration getConfiguration(); + public T getConfiguration(); public Duration getRoundDuration(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-04 18:55:18 UTC (rev 137) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-04 19:10:37 UTC (rev 138) @@ -28,7 +28,6 @@ @Table(name="forager_configuration") public class ForagerConfiguration extends ExperimentConfigurationEntity<ForagerExperimentParameters> { - public ForagerConfiguration(String serverName, int port) { super(serverName, port); } @@ -38,9 +37,10 @@ return "forager-client.jar"; } - public String getClientClass() { + public String getClientMainClass() { return ForagerApplet.class.getName(); } + public String getExperimentName() { return "forager"; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 18:55:18 UTC (rev 137) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 19:10:37 UTC (rev 138) @@ -27,7 +27,7 @@ @PrimaryKeyJoinColumn(name="forager_parameters_id") @Proxy(proxyClass=ExperimentRoundParameters.class) @Table(name="forager_parameters") -public class ForagerExperimentParameters extends ExperimentParametersEntity { +public class ForagerExperimentParameters extends ExperimentParametersEntity<ForagerConfiguration> { private ForagerAgentConfiguration agentConfiguration; @@ -102,12 +102,7 @@ return Duration.create(240); } - @ManyToOne(targetEntity=ForagerConfiguration.class) - @JoinColumn(name="configuration_id", nullable=false) - public ForagerConfiguration getConfiguration() { - return (ForagerConfiguration) super.getConfiguration(); - } - + @Transient public List getAllFoodRegions() { return Collections.EMPTY_LIST; Added: trunk/gee/war/WEB-INF/lib/asm.jar =================================================================== (Binary files differ) Property changes on: trunk/gee/war/WEB-INF/lib/asm.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/gee/war/startExperiment.jsp =================================================================== --- trunk/gee/war/startExperiment.jsp 2006-03-04 18:55:18 UTC (rev 137) +++ trunk/gee/war/startExperiment.jsp 2006-03-04 19:10:37 UTC (rev 138) @@ -15,7 +15,7 @@ <!-- FIXME: make width/height configurable later? --> - <applet code='<ww:property value="experiment.configuration.clientClass"/>' width="600" height="600" + <applet code='<ww:property value="experiment.configuration.clientMainClass"/>' width="600" height="600" archive='<ww:property value="experiment.configuration.clientJarName"/>'> <param name='experiment-hostname' value="<ww:property value='experiment.configuration.serverAddress.hostName'/>" /> <param name='experiment-port' value="<ww:property value='experiment.serverPort'/>" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 18:55:31
|
Revision: 137 Author: alllee Date: 2006-03-04 10:55:18 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=137&view=rev Log Message: ----------- cleaning imports, added getters/setters to ExperimentConfigurationEntity for server name, client jar name, experiment name, and description. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java trunk/gee/src/java/edu/indiana/psych/gee/event/generics/EventTypeProcessor.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-04 18:50:24 UTC (rev 136) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-04 18:55:18 UTC (rev 137) @@ -1,6 +1,5 @@ package edu.indiana.psych.gee; -import java.io.File; import java.net.InetSocketAddress; import java.util.List; Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-04 18:50:24 UTC (rev 136) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-04 18:55:18 UTC (rev 137) @@ -1,22 +1,16 @@ package edu.indiana.psych.gee; -import java.io.File; import java.net.InetSocketAddress; -import java.util.ArrayList; import java.util.List; -import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; -import javax.persistence.JoinColumn; -import javax.persistence.MappedSuperclass; -import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; -import edu.indiana.psych.gee.forager.*; +import edu.indiana.psych.gee.forager.ForagerExperimentParameters; /** * $Id$ @@ -29,7 +23,6 @@ * @version $Revision$ */ -@Entity @Table(name="experiment_configuration") @Inheritance(strategy=InheritanceType.JOINED) public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> @@ -132,6 +125,30 @@ } return currentParameters; } + + public String getClientJarName() { + return clientJarName; + } + + public void setClientJarName(String clientJarName) { + this.clientJarName = clientJarName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getExperimentName() { + return experimentName; + } + + public void setExperimentName(String experimentName) { + this.experimentName = experimentName; + } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 18:50:24 UTC (rev 136) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 18:55:18 UTC (rev 137) @@ -5,9 +5,7 @@ import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; -import javax.persistence.MappedSuperclass; import javax.persistence.Table; -import javax.persistence.Transient; /** * $Id: Exp$ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/generics/EventTypeProcessor.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/generics/EventTypeProcessor.java 2006-03-04 18:50:24 UTC (rev 136) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/generics/EventTypeProcessor.java 2006-03-04 18:55:18 UTC (rev 137) @@ -4,7 +4,6 @@ import edu.indiana.psych.gee.event.EventConstraint; import edu.indiana.psych.gee.event.EventInstanceofConstraint; import edu.indiana.psych.gee.event.EventProcessor; -import edu.indiana.psych.gee.net.ConnectionEvent; /** * $Id$ Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java 2006-03-04 18:50:24 UTC (rev 136) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java 2006-03-04 18:55:18 UTC (rev 137) @@ -3,7 +3,6 @@ import java.awt.Point; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-04 18:50:24 UTC (rev 136) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-04 18:55:18 UTC (rev 137) @@ -2,8 +2,6 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.PrimaryKeyJoinColumn; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 18:50:24 UTC (rev 136) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 18:55:18 UTC (rev 137) @@ -7,20 +7,16 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.JoinColumn; -import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; -import javax.persistence.ManyToOne; import javax.persistence.Transient; import org.hibernate.annotations.Proxy; -import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentParametersEntity; import edu.indiana.psych.gee.ExperimentRoundParameters; import edu.indiana.psych.gee.time.Duration; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java 2006-03-04 18:50:24 UTC (rev 136) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java 2006-03-04 18:55:18 UTC (rev 137) @@ -5,7 +5,6 @@ import java.util.Map; import java.util.Set; - import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.event.AbstractEvent; import edu.indiana.psych.gee.net.ExperimentUpdateEvent; @@ -82,9 +81,4 @@ // } } -/** - * $Log$ - * Revision 1.1 2006/01/15 00:17:09 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - */ + Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java 2006-03-04 18:50:24 UTC (rev 136) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java 2006-03-04 18:55:18 UTC (rev 137) @@ -16,13 +16,13 @@ import java.util.LinkedList; import java.util.Map; +import org.apache.commons.collections.BidiMap; +import org.apache.commons.collections.bidimap.DualHashBidiMap; + import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.event.Event; import edu.indiana.psych.gee.event.EventChannel; -import org.apache.commons.collections.BidiMap; -import org.apache.commons.collections.bidimap.DualHashBidiMap; - /** * $Id$ * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 18:50:31
|
Revision: 136 Author: alllee Date: 2006-03-04 10:50:24 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=136&view=rev Log Message: ----------- fixing persistent classes. Having problems mapping generic classes the way I want to - I'd like to make it easy to subclass ExperimentConfigurationEntity as a generic class and get a lot of default behavior for free by parameterizing the superclass with the particular ExperimentRoundParameters type that your specific ExperimentConfiguration will use and maintain a collection of. That way each subclass wouldn't have to reimplement getAllParameters() to return the specific a specifically-typed Collection that you want, instead the framework provides all that for you. Unfortunately this may not be possible.. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/war/WEB-INF/hibernate.cfg.xml Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-04 07:38:23 UTC (rev 135) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-04 18:50:24 UTC (rev 136) @@ -52,7 +52,7 @@ "not support hot-reconfiguration yet"); } this.configuration = configuration; - allParameters = configuration.getAllExperimentRoundParameters(); + allParameters = configuration.getAllParameters(); } public synchronized void start() throws ExperimentLifecycleException { Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-04 07:38:23 UTC (rev 135) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-04 18:50:24 UTC (rev 136) @@ -34,15 +34,8 @@ public boolean isTriggeredExperiment(); - /** - * Returns the directory containing all experiment configuration files for - * the Experiment with this ExperimentConfiguration. - * @return - */ - public File getExperimentConfigurationDirectory(); + public List<T> getAllParameters(); - public List<T> getAllExperimentRoundParameters(); - public ExperimentRoundParameters getCurrentParameters(); public String getDescription(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-04 07:38:23 UTC (rev 135) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-04 18:50:24 UTC (rev 136) @@ -6,10 +6,18 @@ import java.util.List; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; import javax.persistence.MappedSuperclass; import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Transient; +import edu.indiana.psych.gee.forager.*; + /** * $Id$ * @@ -22,23 +30,34 @@ */ @Entity -@MappedSuperclass +@Table(name="experiment_configuration") +@Inheritance(strategy=InheritanceType.JOINED) public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> implements ExperimentConfiguration { private final static String DEFAULT_SERVER_ADDRESS = "groups.psych.indiana.edu"; + + private long id = -1; + + private String description; + private String experimentName; + private String clientJarName; - private T currentParameters; - private final List<T> allParameters = new ArrayList<T>(); + + private ForagerExperimentParameters currentParameters; +// private List<T> allParameters; + private List<ForagerExperimentParameters> allParameters; private InetSocketAddress serverAddress; - private int port; + private int serverPort; private String serverName; + private boolean triggeredExperiment; public ExperimentConfigurationEntity(String serverName, int port) { - this.serverName = serverName; - this.port = port; + setServerName(serverName); + setServerPort(port); } + @Transient public synchronized InetSocketAddress getServerAddress() { // FIXME: return configuration address instead? if (serverAddress == null) { @@ -55,28 +74,56 @@ // be configurable. return DEFAULT_SERVER_ADDRESS; } + + @Id @GeneratedValue + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } public int getServerPort() { - return port; + return serverPort; } + + public void setServerPort(int serverPort) { + this.serverPort = serverPort; + } + + public String getServerName() { + return serverName; + } + public void setServerName(String serverName) { + this.serverName = serverName; + } + public boolean isTriggeredExperiment() { // TODO Auto-generated method stub - return false; + return triggeredExperiment; } - public File getExperimentConfigurationDirectory() { - // TODO Auto-generated method stub - return null; - } + public void setTriggeredExperiment(boolean triggeredExperiment) { + this.triggeredExperiment = triggeredExperiment; + } - @OneToMany(targetEntity=ExperimentParametersEntity.class) - @JoinColumn(name="configuration_id") - public List<T> getAllExperimentRoundParameters() { + +// @OneToMany(targetEntity=ExperimentParametersEntity.class) +// @OneToMany(targetEntity=ForagerExperimentParameters.class) + // @JoinColumn(name="configuration_id") + @Transient + public List<ForagerExperimentParameters> getAllParameters() { return allParameters; } + + public void setAllParameters(List<ForagerExperimentParameters> allParameters) { + this.allParameters = allParameters; + } - public synchronized T getCurrentParameters() { + @Transient + public synchronized ForagerExperimentParameters getCurrentParameters() { if (currentParameters == null) { if (allParameters.isEmpty()) { throw new ExperimentLifecycleException("No experiment round parameters available for : " + getExperimentName()); Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 07:38:23 UTC (rev 135) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 18:50:24 UTC (rev 136) @@ -1,9 +1,13 @@ package edu.indiana.psych.gee; import javax.persistence.Entity; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; import javax.persistence.MappedSuperclass; +import javax.persistence.Table; +import javax.persistence.Transient; /** * $Id: Exp$ @@ -15,13 +19,23 @@ */ @Entity -@MappedSuperclass +@Table(name="experiment_parameters") +@Inheritance(strategy=InheritanceType.JOINED) public abstract class ExperimentParametersEntity implements ExperimentRoundParameters { + private long id = -1; + private ExperimentConfiguration configuration; - @ManyToOne(targetEntity=ExperimentConfigurationEntity.class) - @JoinColumn(name="configuration_id", nullable=false) + @Id @GeneratedValue + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + public ExperimentConfiguration getConfiguration() { return configuration; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-04 07:38:23 UTC (rev 135) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-04 18:50:24 UTC (rev 136) @@ -1,9 +1,14 @@ package edu.indiana.psych.gee.forager; +import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; +import javax.persistence.Transient; import edu.indiana.psych.gee.ExperimentConfigurationEntity; import edu.indiana.psych.gee.forager.client.ForagerApplet; @@ -19,12 +24,13 @@ * @version $Revision$ */ @Entity +@Inheritance(strategy=InheritanceType.JOINED) +@DiscriminatorValue("forager") +@PrimaryKeyJoinColumn(name="forager_configuration_id") @Table(name="forager_configuration") public class ForagerConfiguration extends ExperimentConfigurationEntity<ForagerExperimentParameters> { + - - private long id = -1; - public ForagerConfiguration(String serverName, int port) { super(serverName, port); } @@ -48,21 +54,10 @@ return new ForagerConfiguration(getDefaultServerAddress(), 25000); } + @Transient public Duration getDelayBetweenRounds() { return Duration.create(30); } - - @Id @GeneratedValue - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - - } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 07:38:23 UTC (rev 135) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 18:50:24 UTC (rev 136) @@ -5,10 +5,17 @@ import java.util.List; import java.util.Properties; +import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.JoinColumn; import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.ManyToOne; +import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; +import javax.persistence.ManyToOne; import javax.persistence.Transient; import org.hibernate.annotations.Proxy; @@ -19,32 +26,26 @@ import edu.indiana.psych.gee.time.Duration; @Entity +@Inheritance(strategy=InheritanceType.JOINED) +@DiscriminatorValue("forager") +@PrimaryKeyJoinColumn(name="forager_parameters_id") +@Proxy(proxyClass=ExperimentRoundParameters.class) @Table(name="forager_parameters") -@Proxy(proxyClass=ExperimentRoundParameters.class) public class ForagerExperimentParameters extends ExperimentParametersEntity { - private final ForagerConfiguration foragerConfiguration; + private ForagerAgentConfiguration agentConfiguration; - /** - * @param configuration - */ + private String name; + private int foodSpoilDuration; + private double foodRate; + + ForagerExperimentParameters(ForagerConfiguration configuration) { - foragerConfiguration = configuration; + setConfiguration(configuration); } - long id = -1; - String name; - int foodSpoilDuration; - double foodRate; - ForagerAgentConfiguration agentConfiguration; - - @Id @GeneratedValue - public long getId() { - return id; - } - public int getMinimumParticipants() { // FIXME: replace with configuration value. return 5; @@ -69,11 +70,13 @@ return "Very special instructions"; } + @Transient public Properties getProperties() { // TODO Auto-generated method stub return new Properties(); } + @Transient public Dimension getBoardSize() { // TODO Auto-generated method stub return new Dimension(600, 600); @@ -88,20 +91,25 @@ return 5; } + @Transient public Visibility getSubjectVisibility() { return Visibility.FULL; } + @Transient public Visibility getFoodVisibility() { return Visibility.FULL; } + @Transient public Duration getRoundDuration() { return Duration.create(240); } - public ExperimentConfiguration getConfiguration() { - return foragerConfiguration; + @ManyToOne(targetEntity=ForagerConfiguration.class) + @JoinColumn(name="configuration_id", nullable=false) + public ForagerConfiguration getConfiguration() { + return (ForagerConfiguration) super.getConfiguration(); } @Transient @@ -117,10 +125,6 @@ this.name = name; } - public void setId(long id) { - this.id = id; - } - public int getFoodSpoilDuration() { return foodSpoilDuration; } Modified: trunk/gee/war/WEB-INF/hibernate.cfg.xml =================================================================== --- trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-03-04 07:38:23 UTC (rev 135) +++ trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-03-04 18:50:24 UTC (rev 136) @@ -9,7 +9,9 @@ <session-factory> <mapping package="edu.indiana.psych.gee"/> <mapping class="edu.indiana.psych.gee.ConsentForm"/> + <mapping class="edu.indiana.psych.gee.ExperimentParametersEntity"/> <mapping package="edu.indiana.psych.gee.forager"/> + <mapping class="edu.indiana.psych.gee.forager.ForagerExperimentParameters"/> <mapping class="edu.indiana.psych.gee.forager.ForagerConfiguration"/> </session-factory> </hibernate-configuration> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 07:38:27
|
Revision: 135 Author: alllee Date: 2006-03-03 23:38:23 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=135&view=rev Log Message: ----------- provides hibernate annotation configuration Added Paths: ----------- trunk/gee/war/WEB-INF/lib/hibernate-tools.jar Added: trunk/gee/war/WEB-INF/lib/hibernate-tools.jar =================================================================== (Binary files differ) Property changes on: trunk/gee/war/WEB-INF/lib/hibernate-tools.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 07:38:08
|
Revision: 134 Author: alllee Date: 2006-03-03 23:38:04 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=134&view=rev Log Message: ----------- should be in war/WEB-INF/lib instead Removed Paths: ------------- trunk/gee/lib/hibernate-tools.jar Deleted: trunk/gee/lib/hibernate-tools.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 07:37:16
|
Revision: 133 Author: alllee Date: 2006-03-03 23:37:12 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=133&view=rev Log Message: ----------- adding ant task for automatic db schema generation via hibernate Modified Paths: -------------- trunk/gee/build.xml Added Paths: ----------- trunk/gee/lib/hibernate-tools.jar Modified: trunk/gee/build.xml =================================================================== --- trunk/gee/build.xml 2006-03-04 07:01:38 UTC (rev 132) +++ trunk/gee/build.xml 2006-03-04 07:37:12 UTC (rev 133) @@ -14,7 +14,8 @@ <property name='test.results.dir' value='test-results'/> <property name='war.dir' value='war'/> <property name='web.inf' value='${war.dir}/WEB-INF'/> - <property name='lib.dir' value='${web.inf}/lib'/> + <property name='lib.dir' value='lib'/> + <property name='web.lib.dir' value='${web.inf}/lib'/> <property name='war.file' value='gee.war'/> <!-- tomcat properties --> @@ -27,9 +28,9 @@ <property name='webapp.name' value='gee'/> <property name='webapp.deploy.dir' value='${tomcat.webapps.dir}/${webapp.name}'/> - <path id="webapp.classpath"> + <path id="build.classpath"> <pathelement location="." /> - <fileset dir="${lib.dir}"> + <fileset dir="${web.lib.dir}"> <include name="**/*.jar" /> </fileset> <pathelement location="${build.dir}" /> @@ -51,7 +52,7 @@ debug='on' deprecation='on' > - <classpath refid='webapp.classpath' /> + <classpath refid='build.classpath' /> </javac> <copy todir='${build.dir}'> <fileset dir='${src.dir}'> @@ -61,6 +62,20 @@ </copy> </target> + <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="build.classpath"/> + <target name="init-db" depends="compile"> + <echo message="You must have a build.properties file with valid database connection information for this task to succeed."/> + <hibernatetool destdir="${generated.dir}"> + <classpath> + <path location="${build.dir}"/> + </classpath> +<!-- annotated class/packages are specified in the hibernate.cfg.xml --> + <annotationconfiguration propertyFile="build.properties" configurationfile="${web.inf}/hibernate.cfg.xml"/> + <hbm2ddl export="true" drop="true" outputfilename="gee.sql"/> + </hibernatetool> + </target> + + <!-- compilation tasks --> <target name='compile-forager-client' depends='prepare'> <javac srcdir="${src.dir}" @@ -69,7 +84,7 @@ deprecation='on' target="1.5" > - <classpath refid='webapp.classpath' /> + <classpath refid='build.classpath' /> <exclude name='edu/indiana/psych/gee/event/generics/**'/> <exclude name='edu/indiana/psych/gee/action/**'/> <exclude name='edu/indiana/psych/gee/service/**'/> @@ -84,7 +99,7 @@ source="1.5" debug="on"> <!-- <compilerarg value='-Xlint:unchecked'/> --> - <classpath refid="webapp.classpath" /> + <classpath refid="build.classpath" /> </javac> </target> @@ -93,7 +108,7 @@ <delete dir="${test.results.dir}"/> <mkdir dir="${test.results.dir}"/> <junit fork="yes" haltonfailure="yes" printsummary="yes"> - <classpath refid="webapp.classpath" /> + <classpath refid="build.classpath" /> <batchtest todir="${test.results.dir}" > <formatter usefile="no" type="plain" /> <formatter type="xml" /> Added: trunk/gee/lib/hibernate-tools.jar =================================================================== (Binary files differ) Property changes on: trunk/gee/lib/hibernate-tools.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 07:01:40
|
Revision: 132 Author: alllee Date: 2006-03-03 23:01:38 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=132&view=rev Log Message: ----------- convention > overly-verbose names Added Paths: ----------- trunk/gee/war/WEB-INF/hibernate.cfg.xml Removed Paths: ------------- trunk/gee/war/WEB-INF/hibernate-session-factory-config.xml Deleted: trunk/gee/war/WEB-INF/hibernate-session-factory-config.xml =================================================================== --- trunk/gee/war/WEB-INF/hibernate-session-factory-config.xml 2006-03-04 04:18:13 UTC (rev 131) +++ trunk/gee/war/WEB-INF/hibernate-session-factory-config.xml 2006-03-04 07:01:38 UTC (rev 132) @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<!-- -vim:sts=2:sw=2: ---> -<!DOCTYPE hibernate-configuration PUBLIC - "-//Hibernate/Hibernate Configuration DTD 3.0//EN" - "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd "> -<hibernate-configuration> - <session-factory> - <mapping package="edu.indiana.psych.gee"/> - <mapping class="edu.indiana.psych.gee.ConsentForm"/> - <mapping package="edu.indiana.psych.gee.forager"/> - <mapping class="edu.indiana.psych.gee.forager.ForagerConfiguration"/> - </session-factory> -</hibernate-configuration> - Copied: trunk/gee/war/WEB-INF/hibernate.cfg.xml (from rev 130, trunk/gee/war/WEB-INF/hibernate-session-factory-config.xml) =================================================================== --- trunk/gee/war/WEB-INF/hibernate.cfg.xml (rev 0) +++ trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-03-04 07:01:38 UTC (rev 132) @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<!-- +vim:sts=2:sw=2: +--> +<!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd "> +<hibernate-configuration> + <session-factory> + <mapping package="edu.indiana.psych.gee"/> + <mapping class="edu.indiana.psych.gee.ConsentForm"/> + <mapping package="edu.indiana.psych.gee.forager"/> + <mapping class="edu.indiana.psych.gee.forager.ForagerConfiguration"/> + </session-factory> +</hibernate-configuration> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 04:18:16
|
Revision: 131 Author: alllee Date: 2006-03-03 20:18:13 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=131&view=rev Log Message: ----------- removing spurious Log keywords, svn doesn't support it. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 03:33:07 UTC (rev 130) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 04:18:13 UTC (rev 131) @@ -32,8 +32,3 @@ } - - -/* - * $Log: $ - */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java 2006-03-04 03:33:07 UTC (rev 130) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java 2006-03-04 04:18:13 UTC (rev 131) @@ -49,7 +49,3 @@ return 0.5f; } } - -/* - * $Log: $ - */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 03:33:07 UTC (rev 130) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 04:18:13 UTC (rev 131) @@ -9,6 +9,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; +import javax.persistence.Transient; import org.hibernate.annotations.Proxy; @@ -103,6 +104,7 @@ return foragerConfiguration; } + @Transient public List getAllFoodRegions() { return Collections.EMPTY_LIST; } @@ -140,7 +142,3 @@ } } - -/* - * $Log: $ - */ \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 03:33:14
|
Revision: 130 Author: alllee Date: 2006-03-03 19:33:07 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=130&view=rev Log Message: ----------- renamed ExperimentConfigurationSupport -> ExperimentConfigurationEntity to more accurately reflect its purpose. Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java Copied: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java (from rev 126, trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationSupport.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-04 03:33:07 UTC (rev 130) @@ -0,0 +1,109 @@ +package edu.indiana.psych.gee; + +import java.io.File; +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.MappedSuperclass; +import javax.persistence.OneToMany; + +/** + * $Id$ + * + * Helps specific ExperimentConfiguration-S read in their configuration data + * from a variety of sources. + * + * + * @author Allen Lee + * @version $Revision$ + */ + +@Entity +@MappedSuperclass +public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> +implements ExperimentConfiguration { + + private final static String DEFAULT_SERVER_ADDRESS = "groups.psych.indiana.edu"; + + private T currentParameters; + private final List<T> allParameters = new ArrayList<T>(); + private InetSocketAddress serverAddress; + private int port; + private String serverName; + + public ExperimentConfigurationEntity(String serverName, int port) { + this.serverName = serverName; + this.port = port; + } + + public synchronized InetSocketAddress getServerAddress() { + // FIXME: return configuration address instead? + if (serverAddress == null) { + serverAddress = new InetSocketAddress(serverName, getServerPort()); + if (serverAddress.isUnresolved()) { + // default should be specified via config file. + serverAddress = new InetSocketAddress(getDefaultServerAddress(), getServerPort()); + } + } + return serverAddress; + } + + public static String getDefaultServerAddress() { + // be configurable. + return DEFAULT_SERVER_ADDRESS; + } + + public int getServerPort() { + return port; + } + + public boolean isTriggeredExperiment() { + // TODO Auto-generated method stub + return false; + } + + public File getExperimentConfigurationDirectory() { + // TODO Auto-generated method stub + return null; + } + + @OneToMany(targetEntity=ExperimentParametersEntity.class) + @JoinColumn(name="configuration_id") + public List<T> getAllExperimentRoundParameters() { + return allParameters; + } + + public synchronized T getCurrentParameters() { + if (currentParameters == null) { + if (allParameters.isEmpty()) { + throw new ExperimentLifecycleException("No experiment round parameters available for : " + getExperimentName()); + } + currentParameters = allParameters.get(0); + } + return currentParameters; + } +} + + +/* + * $Log$ + * Revision 1.4 2006/01/15 00:17:09 alllee + * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. + * + * Revision 1.3 2006/01/14 03:23:06 alllee + * beating out Configuration's implementation - more to come soon from the + * Eclipse side. + * + * Revision 1.2 2006/01/13 09:30:54 alllee + * almost have experiments running - the StartExperiment action has all the + * information it needs and can start the experiment, but the startExperiment + * page is failing because forager-client.jar isn't there. Next step - make + * forager-client.jar there. + * + * Revision 1.1 2006/01/12 04:14:00 alllee + * switching to presentation layer development for some time to get a better feel for what needs to be done with respect to experiment configuration. + * + */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 03:30:09
|
Revision: 129 Author: alllee Date: 2006-03-03 19:30:00 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=129&view=rev Log Message: ----------- Working out object relational mapping for experiment configurations. The current idea which will hopefully work is to use abstract classes as the @Entity objects and have concrete subclasses of those Entity classes. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-04 03:29:20 UTC (rev 128) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-04 03:30:00 UTC (rev 129) @@ -5,7 +5,7 @@ import javax.persistence.Id; import javax.persistence.Table; -import edu.indiana.psych.gee.ExperimentConfigurationSupport; +import edu.indiana.psych.gee.ExperimentConfigurationEntity; import edu.indiana.psych.gee.forager.client.ForagerApplet; import edu.indiana.psych.gee.time.Duration; @@ -20,7 +20,7 @@ */ @Entity @Table(name="forager_configuration") -public class ForagerConfiguration extends ExperimentConfigurationSupport<ForagerExperimentParameters> { +public class ForagerConfiguration extends ExperimentConfigurationEntity<ForagerExperimentParameters> { private long id = -1; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 03:29:20 UTC (rev 128) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-04 03:30:00 UTC (rev 129) @@ -13,14 +13,15 @@ import org.hibernate.annotations.Proxy; import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentParametersEntity; import edu.indiana.psych.gee.ExperimentRoundParameters; import edu.indiana.psych.gee.time.Duration; @Entity @Table(name="forager_parameters") @Proxy(proxyClass=ExperimentRoundParameters.class) -public class ForagerExperimentParameters -implements ExperimentRoundParameters { +public class ForagerExperimentParameters extends ExperimentParametersEntity { + private final ForagerConfiguration foragerConfiguration; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 03:29:23
|
Revision: 128 Author: alllee Date: 2006-03-03 19:29:20 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=128&view=rev Log Message: ----------- Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java Added: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentParametersEntity.java 2006-03-04 03:29:20 UTC (rev 128) @@ -0,0 +1,39 @@ +package edu.indiana.psych.gee; + +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.MappedSuperclass; + +/** + * $Id: Exp$ + * + * + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision: $ + */ + +@Entity +@MappedSuperclass +public abstract class ExperimentParametersEntity implements ExperimentRoundParameters { + + private ExperimentConfiguration configuration; + + @ManyToOne(targetEntity=ExperimentConfigurationEntity.class) + @JoinColumn(name="configuration_id", nullable=false) + public ExperimentConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration(ExperimentConfiguration configuration) { + this.configuration = configuration; + } + + +} + + +/* + * $Log: $ + */ \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-04 03:28:49
|
Revision: 127 Author: alllee Date: 2006-03-03 19:28:46 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=127&view=rev Log Message: ----------- Working out object relational mapping for experiment configurations. The current idea which will hoepfully work is to use abstract classes as the @Entity objects and have concrete subclasses of those Entity classes. Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationSupport.java Deleted: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationSupport.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationSupport.java 2006-03-01 17:05:55 UTC (rev 126) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationSupport.java 2006-03-04 03:28:46 UTC (rev 127) @@ -1,103 +0,0 @@ -package edu.indiana.psych.gee; - -import java.io.File; -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.List; - -import javax.persistence.MappedSuperclass; - -/** - * $Id$ - * - * Helps specific ExperimentConfiguration-S read in their configuration data - * from a variety of sources. - * - * - * @author Allen Lee - * @version $Revision$ - */ - -@MappedSuperclass -public abstract class ExperimentConfigurationSupport<T extends ExperimentRoundParameters> -implements ExperimentConfiguration { - - private final static String DEFAULT_SERVER_ADDRESS = "groups.psych.indiana.edu"; - - private T currentParameters; - private final List<T> allParameters = new ArrayList<T>(); - private InetSocketAddress serverAddress; - private int port; - private String serverName; - - public ExperimentConfigurationSupport(String serverName, int port) { - this.serverName = serverName; - this.port = port; - } - - public synchronized InetSocketAddress getServerAddress() { - // FIXME: return configuration address instead? - if (serverAddress == null) { - serverAddress = new InetSocketAddress(serverName, getServerPort()); - if (serverAddress.isUnresolved()) { - // default should be specified via config file. - serverAddress = new InetSocketAddress(getDefaultServerAddress(), getServerPort()); - } - } - return serverAddress; - } - - public static String getDefaultServerAddress() { - // be configurable. - return DEFAULT_SERVER_ADDRESS; - } - - public int getServerPort() { - return port; - } - - public boolean isTriggeredExperiment() { - // TODO Auto-generated method stub - return false; - } - - public File getExperimentConfigurationDirectory() { - // TODO Auto-generated method stub - return null; - } - - public List<T> getAllExperimentRoundParameters() { - return allParameters; - } - - public synchronized T getCurrentParameters() { - if (currentParameters == null) { - if (allParameters.isEmpty()) { - throw new ExperimentLifecycleException("No experiment round parameters available for : " + getExperimentName()); - } - currentParameters = allParameters.get(0); - } - return currentParameters; - } -} - - -/* - * $Log$ - * Revision 1.4 2006/01/15 00:17:09 alllee - * huge commit to commemorate compilability, but not fully working code. Using the notion of time intervals inspird by the http://timeandmoney.sourceforge.net project to improve the handling of durations and points in time when an experiment is supposed to start and stop. Ported over almost all of the functionality needed to run the forager experiment inside the webapp framework. - * - * Revision 1.3 2006/01/14 03:23:06 alllee - * beating out Configuration's implementation - more to come soon from the - * Eclipse side. - * - * Revision 1.2 2006/01/13 09:30:54 alllee - * almost have experiments running - the StartExperiment action has all the - * information it needs and can start the experiment, but the startExperiment - * page is failing because forager-client.jar isn't there. Next step - make - * forager-client.jar there. - * - * Revision 1.1 2006/01/12 04:14:00 alllee - * switching to presentation layer development for some time to get a better feel for what needs to be done with respect to experiment configuration. - * - */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-01 17:06:03
|
Revision: 126 Author: alllee Date: 2006-03-01 09:05:55 -0800 (Wed, 01 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=126&view=rev Log Message: ----------- * adding cglib to WEB-INF lib directory to keep hibernate happy * moving <ww:head theme="ajax"> into the classes that need it only. Modified Paths: -------------- trunk/gee/war/admin/listExperiments.jsp trunk/gee/war/template.jsp Added Paths: ----------- trunk/gee/war/WEB-INF/lib/cglib.jar Added: trunk/gee/war/WEB-INF/lib/cglib.jar =================================================================== (Binary files differ) Property changes on: trunk/gee/war/WEB-INF/lib/cglib.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/gee/war/admin/listExperiments.jsp =================================================================== --- trunk/gee/war/admin/listExperiments.jsp 2006-03-01 05:14:24 UTC (rev 125) +++ trunk/gee/war/admin/listExperiments.jsp 2006-03-01 17:05:55 UTC (rev 126) @@ -1,5 +1,6 @@ <head> <meta name="lastModifiedDate" content="$Date$"/> +<@ww.head theme="ajax"/> <title>Experiment Statuses</title> </head> <body> Modified: trunk/gee/war/template.jsp =================================================================== --- trunk/gee/war/template.jsp 2006-03-01 05:14:24 UTC (rev 125) +++ trunk/gee/war/template.jsp 2006-03-01 17:05:55 UTC (rev 126) @@ -1,13 +1,11 @@ <!-- vim:sts=2:sw=2: --> -<%@ taglib prefix="ww" uri="webwork" %> <%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %> <%@ include file="/includes/cache.jsp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> - <ww:head theme="ajax"/> <LINK REL="stylesheet" HREF="/gee/css/gee.css" TYPE="text/css" /> <title><decorator:title default="Group Experiments Environment" /></title> <decorator:head /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-03-01 05:14:38
|
Revision: 125 Author: alllee Date: 2006-02-28 21:14:24 -0800 (Tue, 28 Feb 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=125&view=rev Log Message: ----------- extracting ForagerExperimentParameters from ForagerConfiguration, hibernate needs it to be a bona-fide class in order to map it properly. Modified Paths: -------------- trunk/gee/.classpath trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationSupport.java trunk/gee/src/java/edu/indiana/psych/gee/event/ClientErrorMessageEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java trunk/gee/src/java/edu/indiana/psych/gee/forager/DebriefingAssistant.java trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodDispenser.java trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodRegion.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerPersister.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/SubjectView.java Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java Modified: trunk/gee/.classpath =================================================================== --- trunk/gee/.classpath 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/.classpath 2006-03-01 05:14:24 UTC (rev 125) @@ -11,7 +11,8 @@ <classpathentry kind="lib" path="war/WEB-INF/lib/webwork.jar"/> <classpathentry kind="lib" path="war/WEB-INF/lib/xwork.jar"/> <classpathentry kind="lib" path="war/WEB-INF/lib/rife-continuations.jar"/> + <classpathentry kind="lib" path="war/WEB-INF/lib/commons-collections.jar"/> + <classpathentry kind="lib" path="war/WEB-INF/lib/hibernate3.jar"/> <classpathentry kind="lib" path="war/WEB-INF/lib/hibernate-annotations.jar"/> - <classpathentry kind="lib" path="war/WEB-INF/lib/commons-collections.jar"/> <classpathentry kind="output" path="build"/> </classpath> Modified: trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-01 05:14:24 UTC (rev 125) @@ -4,7 +4,7 @@ import java.util.Date; import javax.persistence.Entity; -import javax.persistence.GeneratorType; +import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; @@ -34,7 +34,7 @@ private Date irbDateApproved; - @Id(generate=GeneratorType.AUTO) + @Id @GeneratedValue public int getId() { return id; } @@ -91,6 +91,7 @@ } return irbDateApproved; } + // FIXME: atrocity private boolean isToday(Date date) { Calendar now = Calendar.getInstance(); now.setTime(new Date()); Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-01 05:14:24 UTC (rev 125) @@ -15,7 +15,7 @@ * @version $Revision$ */ -public interface ExperimentConfiguration { +public interface ExperimentConfiguration<T extends ExperimentRoundParameters> { /** * Returns the port that the experiment server with this configuration is @@ -41,7 +41,7 @@ */ public File getExperimentConfigurationDirectory(); - public List<ExperimentRoundParameters> getAllExperimentRoundParameters(); + public List<T> getAllExperimentRoundParameters(); public ExperimentRoundParameters getCurrentParameters(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationSupport.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationSupport.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationSupport.java 2006-03-01 05:14:24 UTC (rev 125) @@ -1,12 +1,12 @@ package edu.indiana.psych.gee; import java.io.File; -import java.net.InetAddress; import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.List; -import java.util.Properties; +import javax.persistence.MappedSuperclass; + /** * $Id$ * @@ -18,14 +18,14 @@ * @version $Revision$ */ -public abstract class ExperimentConfigurationSupport +@MappedSuperclass +public abstract class ExperimentConfigurationSupport<T extends ExperimentRoundParameters> implements ExperimentConfiguration { private final static String DEFAULT_SERVER_ADDRESS = "groups.psych.indiana.edu"; - private ExperimentRoundParameters currentParameters; - private final List<ExperimentRoundParameters> allParameters = - new ArrayList<ExperimentRoundParameters>(); + private T currentParameters; + private final List<T> allParameters = new ArrayList<T>(); private InetSocketAddress serverAddress; private int port; private String serverName; @@ -66,11 +66,11 @@ return null; } - public List<ExperimentRoundParameters> getAllExperimentRoundParameters() { + public List<T> getAllExperimentRoundParameters() { return allParameters; } - public synchronized ExperimentRoundParameters getCurrentParameters() { + public synchronized T getCurrentParameters() { if (currentParameters == null) { if (allParameters.isEmpty()) { throw new ExperimentLifecycleException("No experiment round parameters available for : " + getExperimentName()); Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/ClientErrorMessageEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/ClientErrorMessageEvent.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/ClientErrorMessageEvent.java 2006-03-01 05:14:24 UTC (rev 125) @@ -30,6 +30,10 @@ this.exception = exception; } + public Exception getException() { + return exception; + } + } Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java 2006-03-01 05:14:24 UTC (rev 125) @@ -66,6 +66,7 @@ getEventProcessorsFor(owner).add(processor); } + @SuppressWarnings("serial") private List<EventProcessor> getEventProcessorsFor(Object owner) { List<EventProcessor> processors = owners.get(owner); if (processors == null) { @@ -87,7 +88,7 @@ return getEventProcessorsFor(owner); } - public synchronized void remove(Object owner) { + public synchronized void unregister(Object owner) { List<EventProcessor> processors = owners.remove(owner); if (processors != null) { for (EventProcessor processor: processors) { @@ -95,6 +96,10 @@ } } } + + public synchronized void remove(Object owner) { + unregister(owner); + } /** * Informs the pool that the given handler should receive all Events added Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/DebriefingAssistant.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/DebriefingAssistant.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/DebriefingAssistant.java 2006-03-01 05:14:24 UTC (rev 125) @@ -1,7 +1,7 @@ package edu.indiana.psych.gee.forager; -import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedSet; @@ -11,6 +11,7 @@ import edu.indiana.psych.gee.agent.AgentIdentifier; import edu.indiana.psych.gee.event.Event; import edu.indiana.psych.gee.event.EventChannel; +import edu.indiana.psych.gee.event.EventProcessor; import edu.indiana.psych.gee.event.PersistableEvent; import edu.indiana.psych.gee.event.generics.EventTypeProcessor; import edu.indiana.psych.gee.forager.event.FoodAddedEvent; @@ -34,16 +35,20 @@ private final Map<Identifier, TreeSet<PersistableEvent>> clientActions = new HashMap<Identifier, TreeSet<PersistableEvent>>(); + private final EventChannel channel; + DebriefingAssistant(EventChannel channel, Set<Identifier> identifiers) { for (Identifier id : identifiers) { clientActions.put(id, new TreeSet<PersistableEvent>()); } + this.channel = channel; // EventConstraint noBotEventsConstraint = new EventConstraint() { // public boolean accepts(Event event) { // return ! (event.id() instanceof AgentIdentifier); // } // }; - channel.add(new EventTypeProcessor<PersistableEvent>(PersistableEvent.class) { + List<EventProcessor> processors = channel.register(this); + processors.add(new EventTypeProcessor<PersistableEvent>(PersistableEvent.class) { public boolean accepts(Event event) { return super.accepts(event) && ! (event.id() instanceof AgentIdentifier); } @@ -79,6 +84,7 @@ public synchronized void clear() { clientActions.clear(); + channel.remove(this); } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodDispenser.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodDispenser.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodDispenser.java 2006-03-01 05:14:24 UTC (rev 125) @@ -8,7 +8,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import edu.indiana.psych.gee.forager.ForagerConfiguration.ForagerExperimentParameters; import edu.indiana.psych.gee.time.Duration; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodRegion.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodRegion.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/FoodRegion.java 2006-03-01 05:14:24 UTC (rev 125) @@ -10,7 +10,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import edu.indiana.psych.gee.forager.ForagerConfiguration.ForagerExperimentParameters; /** * $Id$ Added: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentConfiguration.java 2006-03-01 05:14:24 UTC (rev 125) @@ -0,0 +1,55 @@ +package edu.indiana.psych.gee.forager; + +import java.util.Properties; + +import javax.persistence.Entity; +import javax.persistence.Table; + +import org.hibernate.annotations.Proxy; + +import edu.indiana.psych.gee.agent.AgentConfiguration; + +@Entity +@Table(name="agent_configuration") +@Proxy(proxyClass=AgentConfiguration.class) +public class ForagerAgentConfiguration implements AgentConfiguration { + + private static final long serialVersionUID = -6259298886681245586L; + + private final ForagerConfiguration foragerConfiguration; + + /** + * @param configuration + */ + ForagerAgentConfiguration(ForagerConfiguration configuration) { + foragerConfiguration = configuration; + } + + + Properties properties; + + public int getFoodReward() { + return 200; + } + public int getExpectedFoodReward() { + return 500; + } + public int getLuceK() { + return 100; + } + public int getMovementPenalty() { + return 2; + } + + public Properties getProperties() { + return properties; + } + + public float getMovementRate() { + return 0.5f; + } +} + +/* + * $Log: $ + */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerAgentFactory.java 2006-03-01 05:14:24 UTC (rev 125) @@ -13,9 +13,9 @@ import edu.indiana.psych.gee.agent.AgentIdentifier; import edu.indiana.psych.gee.forager.event.ClientPositionUpdateEvent; -class ForagerAgentFactory implements AgentFactory<ForagerConfiguration.ForagerExperimentParameters> { +class ForagerAgentFactory implements AgentFactory<ForagerExperimentParameters> { - public ForagerAgent create(ForagerConfiguration.ForagerExperimentParameters parameters) { + public ForagerAgent create(ForagerExperimentParameters parameters) { Visibility visibility = parameters.getFoodVisibility(); // FIXME: add support for partial visibility here. if (visibility == Visibility.ZERO) { @@ -31,7 +31,7 @@ */ private static class VisibleFoodAgent extends ForagerAgent { - public VisibleFoodAgent(ForagerConfiguration.ForagerExperimentParameters e) { + public VisibleFoodAgent(ForagerExperimentParameters e) { super(e); } @@ -181,7 +181,7 @@ */ private static class InvisibleFoodAgent extends ForagerAgent { - public InvisibleFoodAgent(ForagerConfiguration.ForagerExperimentParameters e) { + public InvisibleFoodAgent(ForagerExperimentParameters e) { super(e); } @@ -262,7 +262,7 @@ protected Set<Point> food; protected ClientPositionUpdateEvent currentState; - protected ForagerConfiguration.ForagerExperimentParameters config; + protected ForagerExperimentParameters config; // Algorithm Parameters -------------- protected double[][] Qgrid; @@ -294,7 +294,7 @@ protected int gridsize_y = 0; // begin code ------------------------ - public ForagerAgent(ForagerConfiguration.ForagerExperimentParameters experimentConfiguration) { + public ForagerAgent(ForagerExperimentParameters experimentConfiguration) { this.config = experimentConfiguration; // are agents visible Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-01 05:14:24 UTC (rev 125) @@ -1,21 +1,11 @@ package edu.indiana.psych.gee.forager; -import java.awt.Dimension; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - import javax.persistence.Entity; -import javax.persistence.GeneratorType; +import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; -import org.hibernate.annotations.Proxy; - -import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentConfigurationSupport; -import edu.indiana.psych.gee.ExperimentRoundParameters; -import edu.indiana.psych.gee.agent.AgentConfiguration; import edu.indiana.psych.gee.forager.client.ForagerApplet; import edu.indiana.psych.gee.time.Duration; @@ -28,8 +18,13 @@ * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision$ */ -public class ForagerConfiguration extends ExperimentConfigurationSupport { +@Entity +@Table(name="forager_configuration") +public class ForagerConfiguration extends ExperimentConfigurationSupport<ForagerExperimentParameters> { + + private long id = -1; + public ForagerConfiguration(String serverName, int port) { super(serverName, port); } @@ -53,157 +48,17 @@ return new ForagerConfiguration(getDefaultServerAddress(), 25000); } - public ForagerExperimentParameters getCurrentParameters() { - return (ForagerExperimentParameters) super.getCurrentParameters(); - } - public Duration getDelayBetweenRounds() { return Duration.create(30); } - - @Entity - @Table(name="parameters") - @Proxy(proxyClass=ExperimentRoundParameters.class) - public class ForagerExperimentParameters - implements ExperimentRoundParameters { - - private long id = -1; - private String name; - private int foodSpoilDuration; - private double foodRate; - - private ForagerAgentConfiguration agentConfiguration; - - @Id(generate=GeneratorType.AUTO) - public long getId() { - return id; - } - - public int getMinimumParticipants() { - // FIXME: replace with configuration value. - return 5; - } - - public int getNumberOfBots() { - return 5; - } - - public int getMinimumSeparation() { - // FIXME: use actual configuration parameters. - return 5; - } - - public int getMaximumSeparation() { - // FIXME: use actual configuration parameters. - return 25; - } - public String getSpecialInstructions() { - // TODO Auto-generated method stub - return "Very special instructions"; - } - - public Properties getProperties() { - // TODO Auto-generated method stub - return new Properties(); - } - - public Dimension getBoardSize() { - // TODO Auto-generated method stub - return new Dimension(600, 600); - } - - public boolean shouldPersist(int numberOfParticipants) { - return (numberOfParticipants >= getNumberOfParticipantsRequiredForSave()); - } - - private int getNumberOfParticipantsRequiredForSave() { - // FIXME: remove stub default value. - return 5; - } - - public Visibility getSubjectVisibility() { - return Visibility.FULL; - } - - public Visibility getFoodVisibility() { - return Visibility.FULL; - } - - public Duration getRoundDuration() { - return Duration.create(240); - } - - public ExperimentConfiguration getConfiguration() { - return ForagerConfiguration.this; - } - - public List getAllFoodRegions() { - return Collections.EMPTY_LIST; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public void setId(long id) { - this.id = id; - } - - public int getFoodSpoilDuration() { - return foodSpoilDuration; - } - - public void setFoodSpoilDuration(int foodSpoilDuration) { - this.foodSpoilDuration = foodSpoilDuration; - } - - public double getFoodRate() { - return foodRate; - } - - public void setFoodRate(double foodRate) { - this.foodRate = foodRate; - } - - public ForagerAgentConfiguration getAgentConfiguration() { - return agentConfiguration; - } - + @Id @GeneratedValue + public long getId() { + return id; } - - @Entity - @Table(name="agent_configuration") - @Proxy(proxyClass=AgentConfiguration.class) - public class ForagerAgentConfiguration implements AgentConfiguration { - private static final long serialVersionUID = -6259298886681245586L; - private Properties properties; - - public int getFoodReward() { - return 200; - } - public int getExpectedFoodReward() { - return 500; - } - public int getLuceK() { - return 100; - } - public int getMovementPenalty() { - return 2; - } - - public Properties getProperties() { - return properties; - } - - public float getMovementRate() { - return 0.5f; - } + public void setId(long id) { + this.id = id; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-01 05:14:24 UTC (rev 125) @@ -23,7 +23,6 @@ import edu.indiana.psych.gee.event.RoundStartedEvent; import edu.indiana.psych.gee.event.generics.EventTypeProcessor; import edu.indiana.psych.gee.forager.ForagerAgentFactory.ForagerAgent; -import edu.indiana.psych.gee.forager.ForagerConfiguration.ForagerExperimentParameters; import edu.indiana.psych.gee.forager.event.ClientPositionUpdateEvent; import edu.indiana.psych.gee.forager.event.ClientUpdateEvent; import edu.indiana.psych.gee.net.ClientReadyEvent; Added: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-01 05:14:24 UTC (rev 125) @@ -0,0 +1,145 @@ +package edu.indiana.psych.gee.forager; + +import java.awt.Dimension; +import java.util.Collections; +import java.util.List; +import java.util.Properties; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.hibernate.annotations.Proxy; + +import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentRoundParameters; +import edu.indiana.psych.gee.time.Duration; + +@Entity +@Table(name="forager_parameters") +@Proxy(proxyClass=ExperimentRoundParameters.class) +public class ForagerExperimentParameters +implements ExperimentRoundParameters { + + private final ForagerConfiguration foragerConfiguration; + + /** + * @param configuration + */ + ForagerExperimentParameters(ForagerConfiguration configuration) { + foragerConfiguration = configuration; + } + + long id = -1; + String name; + int foodSpoilDuration; + double foodRate; + + ForagerAgentConfiguration agentConfiguration; + + @Id @GeneratedValue + public long getId() { + return id; + } + + public int getMinimumParticipants() { + // FIXME: replace with configuration value. + return 5; + } + + public int getNumberOfBots() { + return 5; + } + + public int getMinimumSeparation() { + // FIXME: use actual configuration parameters. + return 5; + } + + public int getMaximumSeparation() { + // FIXME: use actual configuration parameters. + return 25; + } + + public String getSpecialInstructions() { + // TODO Auto-generated method stub + return "Very special instructions"; + } + + public Properties getProperties() { + // TODO Auto-generated method stub + return new Properties(); + } + + public Dimension getBoardSize() { + // TODO Auto-generated method stub + return new Dimension(600, 600); + } + + public boolean shouldPersist(int numberOfParticipants) { + return (numberOfParticipants >= getNumberOfParticipantsRequiredForSave()); + } + + private int getNumberOfParticipantsRequiredForSave() { + // FIXME: remove stub default value. + return 5; + } + + public Visibility getSubjectVisibility() { + return Visibility.FULL; + } + + public Visibility getFoodVisibility() { + return Visibility.FULL; + } + + public Duration getRoundDuration() { + return Duration.create(240); + } + + public ExperimentConfiguration getConfiguration() { + return foragerConfiguration; + } + + public List getAllFoodRegions() { + return Collections.EMPTY_LIST; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public void setId(long id) { + this.id = id; + } + + public int getFoodSpoilDuration() { + return foodSpoilDuration; + } + + public void setFoodSpoilDuration(int foodSpoilDuration) { + this.foodSpoilDuration = foodSpoilDuration; + } + + public double getFoodRate() { + return foodRate; + } + + public void setFoodRate(double foodRate) { + this.foodRate = foodRate; + } + + public ForagerAgentConfiguration getAgentConfiguration() { + return agentConfiguration; + } + +} + +/* + * $Log: $ + */ \ No newline at end of file Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerPersister.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerPersister.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerPersister.java 2006-03-01 05:14:24 UTC (rev 125) @@ -23,8 +23,6 @@ import edu.indiana.psych.gee.event.EventHandler; import edu.indiana.psych.gee.event.EventInstanceofConstraint; import edu.indiana.psych.gee.event.PersistableEvent; -import edu.indiana.psych.gee.event.generics.EventTypeProcessor; -import edu.indiana.psych.gee.forager.ForagerConfiguration.ForagerExperimentParameters; import edu.indiana.psych.gee.forager.event.AddClientEvent; /** Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java 2006-03-01 05:14:24 UTC (rev 125) @@ -15,7 +15,6 @@ import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.event.EventChannel; import edu.indiana.psych.gee.event.PersistableEvent; -import edu.indiana.psych.gee.forager.ForagerConfiguration.ForagerExperimentParameters; import edu.indiana.psych.gee.forager.event.AddClientEvent; import edu.indiana.psych.gee.forager.event.FoodAddedEvent; import edu.indiana.psych.gee.forager.event.MovementEvent; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/client/SubjectView.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/client/SubjectView.java 2006-03-01 04:47:42 UTC (rev 124) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/SubjectView.java 2006-03-01 05:14:24 UTC (rev 125) @@ -14,9 +14,9 @@ import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.forager.ForagerConfiguration; +import edu.indiana.psych.gee.forager.ForagerExperimentParameters; import edu.indiana.psych.gee.forager.GridView; import edu.indiana.psych.gee.forager.Visibility; -import edu.indiana.psych.gee.forager.ForagerConfiguration.ForagerExperimentParameters; import edu.indiana.psych.gee.time.Duration; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |