Thread: [gee-svn] SF.net SVN: gabel: [131] trunk/gee/src/java/edu/indiana/psych/gee
Status: Alpha
Brought to you by:
alllee
|
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 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-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. - * - * Revisio... [truncated message content] |
|
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 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-11 23:07:25
|
Revision: 164 Author: alllee Date: 2006-03-11 15:07:17 -0800 (Sat, 11 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=164&view=rev Log Message: ----------- about to replace ExperimentConfiguration with ExperimentConfigurationEntity since we're having trouble getting WW to write to ExperimentConfiguration as an interface. Modified Paths: -------------- 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/ExperimentRoundParameters.java trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java trunk/gee/src/java/edu/indiana/psych/gee/action/UpdateExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-11 23:07:17 UTC (rev 164) @@ -47,6 +47,7 @@ C persistedConfiguration = configurationService.find(configurationClass, defaultConfiguration.getExperimentName()); if (persistedConfiguration == null) { setConfiguration(defaultConfiguration); + configurationService.persist(defaultConfiguration); } else { setConfiguration(persistedConfiguration); Deleted: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-11 23:07:17 UTC (rev 164) @@ -1,60 +0,0 @@ -package edu.indiana.psych.gee; - -import java.net.InetSocketAddress; -import java.util.List; - -import edu.indiana.psych.gee.time.Duration; - -/** - * $Id$ - * - * Global configuration parameters for a given Experiment server instance. - * - * @author <a href='al...@cs...'>Allen Lee</a> - * @version $Revision$ - */ - -public interface ExperimentConfiguration<P extends ExperimentRoundParameters> { - - - /** - * Returns the port that the experiment server with this configuration is - * listening. A convenience method for getServerAddress().getPort(); - * - * @return - */ - public int getServerPort(); - public void setServerPort(int serverPort); - - /** - * Returns the fully qualified InetSocketAddress (hostname and port) on - * the server with this configuration is running. - * @return - */ - public InetSocketAddress getServerAddress(); - - public boolean isTriggeredExperiment(); - public void setTriggeredExperiment(boolean triggeredExperiment); - - public List<P> getAllParameters(); - - public P getCurrentParameters(); - - public String getDescription(); - public void setDescription(String description); - - public String getExperimentName(); - public void setExperimentName(String experimentName); - - public String getClientJarName(); - public void setClientJarName(String clientJarName); - - public String getClientMainClass(); - public void setClientMainClass(String clientMainClass); - - public ConsentForm getConsentForm(); - public void setConsentForm(ConsentForm consentForm); - - public Duration getDelayBetweenRounds(); - -} Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-11 23:07:17 UTC (rev 164) @@ -14,7 +14,7 @@ import javax.persistence.Table; import javax.persistence.Transient; -import org.hibernate.annotations.Proxy; +import edu.indiana.psych.gee.time.Duration; /** * $Id$ @@ -33,12 +33,12 @@ @Entity @Inheritance(strategy=InheritanceType.JOINED) @Table(name="experiment_configuration") -@Proxy(proxyClass=ExperimentConfiguration.class) -public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> -implements ExperimentConfiguration<T> { - - private final static String DEFAULT_SERVER_ADDRESS = "groups.psych.indiana.edu"; - +public class ExperimentConfiguration<T extends ExperimentRoundParameters> { + + // this should be a configurable property.. + private final static String DEFAULT_SERVER_HOST_NAME = "groups.psych.indiana.edu"; + + private List<ForagerExperimentParameters> allParameters; // persistent fields private Long id = Long.valueOf(-1); private String description; @@ -55,6 +55,10 @@ private transient InetSocketAddress serverAddress; private transient T currentParameters; private transient Iterator<T> parametersIterator; + + public ExperimentConfigurationEntity() { + this(DEFAULT_SERVER_HOST_NAME, -1); + } public ExperimentConfigurationEntity(String serverName, int port) { setServerName(serverName); @@ -68,17 +72,12 @@ serverAddress = new InetSocketAddress(serverName, getServerPort()); if (serverAddress.isUnresolved()) { // default should be specified via config file. - serverAddress = new InetSocketAddress(getDefaultServerAddress(), getServerPort()); + serverAddress = new InetSocketAddress(DEFAULT_SERVER_HOST_NAME, getServerPort()); } } return serverAddress; } - public static String getDefaultServerAddress() { - // be configurable. - return DEFAULT_SERVER_ADDRESS; - } - @Id @GeneratedValue public Long getId() { return id; @@ -141,6 +140,26 @@ return currentParameters; } + @OneToMany(mappedBy="configuration") + @JoinColumn(name="configuration_id") + public List<ForagerExperimentParameters> getAllParameters() { + return allParameters; + } + + public void setAllParameters(List<ForagerExperimentParameters> allParameters) { + this.allParameters = allParameters; + } + + /* + public List<T> getAllParameters() { + throw new UnsupportedOperationException("Subclasses must override getAllParameters."); + } + + public void setAllParameters(List<T> allParameters) { + throw new UnsupportedOperationException("Subclasses must override setAllParameters."); + } + */ + public String getClientJarName() { return clientJarName; } @@ -172,4 +191,9 @@ public void setClientMainClass(String clientMainClass) { this.clientMainClass = clientMainClass; } + + @Transient + public Duration getDelayBetweenRounds() { + return Duration.create(30); + } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java 2006-03-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentRoundParameters.java 2006-03-11 23:07:17 UTC (rev 164) @@ -22,6 +22,7 @@ public Dimension getBoardSize(); public T getConfiguration(); + public void setConfiguration(T configuration); public Duration getRoundDuration(); 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-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java 2006-03-11 23:07:17 UTC (rev 164) @@ -33,7 +33,6 @@ public String configure() { // load experiment and various pieces of configuration information? - this.configuration = getExperiment().getConfiguration(); return SUCCESS; } @@ -64,6 +63,10 @@ return SUCCESS; } + public ExperimentConfiguration getConfiguration() { + return getExperiment().getConfiguration(); + } + public Set<Experiment> getExperiments() { if (experiments == null || experiments.isEmpty()) { experiments = getExperimentService().getAllExperiments(); @@ -71,19 +74,13 @@ return experiments; } - public ExperimentConfiguration getConfiguration() { - return configuration; - } - public Experiment getExperiment() { - if (experiment == null) { - experiment = getExperimentService().find(experimentName); - } return experiment; } public void setExperimentName(String experimentName) { this.experimentName = experimentName; + this.experiment = getExperimentService().find(experimentName); } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/UpdateExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/UpdateExperimentConfiguration.java 2006-03-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/UpdateExperimentConfiguration.java 2006-03-11 23:07:17 UTC (rev 164) @@ -1,6 +1,8 @@ package edu.indiana.psych.gee.action; -import edu.indiana.psych.gee.ExperimentConfigurationEntity; +import edu.indiana.psych.gee.Experiment; +import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.service.ExperimentService; /** * $Id: Exp $ @@ -11,18 +13,22 @@ public class UpdateExperimentConfiguration extends GeeAction { - private ExperimentConfigurationEntity configuration; + private String experimentName; + private ExperimentConfiguration configuration; + public String execute() { getLogger().debug("XXX: updating experiment configuration: " + configuration); return SUCCESS; } - public ExperimentConfigurationEntity getConfiguration() { + public ExperimentConfiguration getConfiguration() { return configuration; } - public void setConfiguration(ExperimentConfigurationEntity configuration) { - this.configuration = configuration; + public void setExperimentName(String experimentName) { + this.experimentName = experimentName; + this.configuration = getExperimentService().find(experimentName).getConfiguration(); + } } 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-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-11 23:07:17 UTC (rev 164) @@ -13,7 +13,6 @@ import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentConfigurationEntity; -import edu.indiana.psych.gee.time.Duration; /** * $Id$ @@ -30,25 +29,12 @@ @Proxy(proxyClass=ExperimentConfiguration.class) public class ForagerConfiguration extends ExperimentConfigurationEntity<ForagerExperimentParameters> { - private List<ForagerExperimentParameters> allParameters; + public ForagerConfiguration() { + } public ForagerConfiguration(String serverName, int port) { super(serverName, port); } - @Transient - public Duration getDelayBetweenRounds() { - return Duration.create(30); - } - - @OneToMany(mappedBy="configuration") - @JoinColumn(name="configuration_id") - public List<ForagerExperimentParameters> getAllParameters() { - return allParameters; - } - - public void setAllParameters(List<ForagerExperimentParameters> allParameters) { - this.allParameters = allParameters; - } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java 2006-03-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java 2006-03-11 23:07:17 UTC (rev 164) @@ -20,7 +20,7 @@ return (ConsentForm) getHibernateTemplate().get(ConsentForm.class, id); } - public void update(ConsentForm consentForm) { + public void persist(ConsentForm consentForm) { getHibernateTemplate().saveOrUpdate(consentForm); } Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java 2006-03-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java 2006-03-11 23:07:17 UTC (rev 164) @@ -22,8 +22,8 @@ return null; } - public void update(ConsentForm consentForm) { - consentFormDao.update(consentForm); + public void persist(ConsentForm consentForm) { + consentFormDao.persist(consentForm); } public void setConsentFormDao(ConsentFormDao consentFormDao) { Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java 2006-03-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java 2006-03-11 23:07:17 UTC (rev 164) @@ -37,7 +37,7 @@ })); } - public void update(ExperimentConfiguration configuration) { + public void persist(ExperimentConfiguration configuration) { getHibernateTemplate().saveOrUpdate(configuration); } Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-03-11 05:53:54 UTC (rev 163) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-03-11 23:07:17 UTC (rev 164) @@ -45,8 +45,8 @@ return experimentConfigurationDao.find(configurationClass, experimentName); } - public void update(ExperimentConfiguration configuration) { - experimentConfigurationDao.update(configuration); + public void persist(ExperimentConfiguration configuration) { + experimentConfigurationDao.persist(configuration); } public void setExperimentConfigurationDao(ExperimentConfigurationDao experimentConfigurationDao) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <al...@us...> - 2006-03-11 23:08:15
|
Revision: 165 Author: alllee Date: 2006-03-11 15:08:12 -0800 (Sat, 11 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=165&view=rev Log Message: ----------- replacing ExperimentConfiguration interface with a bean class (used to be ExperimentConfigurationEntity) to ease integration with WW. Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java Copied: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java (from rev 164, trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-11 23:08:12 UTC (rev 165) @@ -0,0 +1,199 @@ +package edu.indiana.psych.gee; + +import java.net.InetSocketAddress; +import java.util.Iterator; +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.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Transient; + +import edu.indiana.psych.gee.time.Duration; + +/** + * $Id$ + * + * Provides hibernate object/relational annotations for fields common to most + * ExperimentConfigurations, things like consent forms, experiment names, and + * a Collection of ExperimentRoundParameters. If you don't want to store your + * configuration information in a database, subclass + * ExperimentConfigurationFile instead (which isn't written yet ;-). + * + * + * @author Allen Lee + * @version $Revision$ + */ + +@Entity +@Inheritance(strategy=InheritanceType.JOINED) +@Table(name="experiment_configuration") +public class ExperimentConfiguration<T extends ExperimentRoundParameters> { + + // this should be a configurable property.. + private final static String DEFAULT_SERVER_HOST_NAME = "groups.psych.indiana.edu"; + + private List<ForagerExperimentParameters> allParameters; + // persistent fields + private Long id = Long.valueOf(-1); + private String description; + private String experimentName; + private String clientJarName; + private String clientMainClass; + private int worldHeight; + private int worldWidth; + private ConsentForm consentForm; + private int serverPort; + private String serverName; + private boolean triggeredExperiment; + // generated transient fields, no need to persist. + private transient InetSocketAddress serverAddress; + private transient T currentParameters; + private transient Iterator<T> parametersIterator; + + public ExperimentConfigurationEntity() { + this(DEFAULT_SERVER_HOST_NAME, -1); + } + + public ExperimentConfigurationEntity(String serverName, int port) { + setServerName(serverName); + setServerPort(port); + } + + @Transient + 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(DEFAULT_SERVER_HOST_NAME, getServerPort()); + } + } + return serverAddress; + } + + @Id @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public int getServerPort() { + 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 triggeredExperiment; + } + + public void setTriggeredExperiment(boolean triggeredExperiment) { + this.triggeredExperiment = triggeredExperiment; + } + + @ManyToOne + public ConsentForm getConsentForm() { + return consentForm; + } + public void setConsentForm(ConsentForm consentForm) { + 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(); + if (currentParameters == null) { + if (allParameters.isEmpty()) { + throw new ExperimentLifecycleException("No experiment round parameters available for : " + getExperimentName()); + } + currentParameters = allParameters.get(0); + } + return currentParameters; + } + + @OneToMany(mappedBy="configuration") + @JoinColumn(name="configuration_id") + public List<ForagerExperimentParameters> getAllParameters() { + return allParameters; + } + + public void setAllParameters(List<ForagerExperimentParameters> allParameters) { + this.allParameters = allParameters; + } + + /* + public List<T> getAllParameters() { + throw new UnsupportedOperationException("Subclasses must override getAllParameters."); + } + + public void setAllParameters(List<T> allParameters) { + throw new UnsupportedOperationException("Subclasses must override setAllParameters."); + } + */ + + 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; + } + + public String getClientMainClass() { + return clientMainClass; + } + + public void setClientMainClass(String clientMainClass) { + this.clientMainClass = clientMainClass; + } + + @Transient + public Duration getDelayBetweenRounds() { + return Duration.create(30); + } +} Deleted: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-11 23:07:17 UTC (rev 164) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-11 23:08:12 UTC (rev 165) @@ -1,199 +0,0 @@ -package edu.indiana.psych.gee; - -import java.net.InetSocketAddress; -import java.util.Iterator; -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.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Transient; - -import edu.indiana.psych.gee.time.Duration; - -/** - * $Id$ - * - * Provides hibernate object/relational annotations for fields common to most - * ExperimentConfigurations, things like consent forms, experiment names, and - * a Collection of ExperimentRoundParameters. If you don't want to store your - * configuration information in a database, subclass - * ExperimentConfigurationFile instead (which isn't written yet ;-). - * - * - * @author Allen Lee - * @version $Revision$ - */ - -@Entity -@Inheritance(strategy=InheritanceType.JOINED) -@Table(name="experiment_configuration") -public class ExperimentConfiguration<T extends ExperimentRoundParameters> { - - // this should be a configurable property.. - private final static String DEFAULT_SERVER_HOST_NAME = "groups.psych.indiana.edu"; - - private List<ForagerExperimentParameters> allParameters; - // persistent fields - private Long id = Long.valueOf(-1); - private String description; - private String experimentName; - private String clientJarName; - private String clientMainClass; - private int worldHeight; - private int worldWidth; - private ConsentForm consentForm; - private int serverPort; - private String serverName; - private boolean triggeredExperiment; - // generated transient fields, no need to persist. - private transient InetSocketAddress serverAddress; - private transient T currentParameters; - private transient Iterator<T> parametersIterator; - - public ExperimentConfigurationEntity() { - this(DEFAULT_SERVER_HOST_NAME, -1); - } - - public ExperimentConfigurationEntity(String serverName, int port) { - setServerName(serverName); - setServerPort(port); - } - - @Transient - 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(DEFAULT_SERVER_HOST_NAME, getServerPort()); - } - } - return serverAddress; - } - - @Id @GeneratedValue - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public int getServerPort() { - 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 triggeredExperiment; - } - - public void setTriggeredExperiment(boolean triggeredExperiment) { - this.triggeredExperiment = triggeredExperiment; - } - - @ManyToOne - public ConsentForm getConsentForm() { - return consentForm; - } - public void setConsentForm(ConsentForm consentForm) { - 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(); - if (currentParameters == null) { - if (allParameters.isEmpty()) { - throw new ExperimentLifecycleException("No experiment round parameters available for : " + getExperimentName()); - } - currentParameters = allParameters.get(0); - } - return currentParameters; - } - - @OneToMany(mappedBy="configuration") - @JoinColumn(name="configuration_id") - public List<ForagerExperimentParameters> getAllParameters() { - return allParameters; - } - - public void setAllParameters(List<ForagerExperimentParameters> allParameters) { - this.allParameters = allParameters; - } - - /* - public List<T> getAllParameters() { - throw new UnsupportedOperationException("Subclasses must override getAllParameters."); - } - - public void setAllParameters(List<T> allParameters) { - throw new UnsupportedOperationException("Subclasses must override setAllParameters."); - } - */ - - 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; - } - - public String getClientMainClass() { - return clientMainClass; - } - - public void setClientMainClass(String clientMainClass) { - this.clientMainClass = clientMainClass; - } - - @Transient - public Duration getDelayBetweenRounds() { - return Duration.create(30); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <al...@us...> - 2006-05-17 22:29:40
|
Revision: 177 Author: alllee Date: 2006-05-17 15:29:35 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=177&view=rev Log Message: ----------- Simple participant persistent bean Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/bean/ trunk/gee/src/java/edu/indiana/psych/gee/bean/Participant.java Added: trunk/gee/src/java/edu/indiana/psych/gee/bean/Participant.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/Participant.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/Participant.java 2006-05-17 22:29:35 UTC (rev 177) @@ -0,0 +1,57 @@ +package edu.indiana.psych.gee.bean; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * $Id: Exp $ + * + * Persistent bean representing a participant. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision: $ + */ + +@Entity +@Table(name="participant") +public class Participant { + + private Long id; + + private String age; + private String name; + private String experimentName; + + @Id @GeneratedValue + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public String getAge() { + return age; + } + public void setAge(String age) { + this.age = age; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getExperimentName() { + return experimentName; + } + public void setExperimentName(String experimentName) { + this.experimentName = experimentName; + } + + + + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <al...@us...> - 2006-05-18 05:18:39
|
Revision: 180 Author: alllee Date: 2006-05-17 22:18:18 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=180&view=rev Log Message: ----------- some relatively major package restructuring, and removing Identifier.NULL's confused equals method (Object.equals() pointer equality is sufficient). 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/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/Identifier.java trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/event/EndRoundEvent.java trunk/gee/src/java/edu/indiana/psych/gee/event/RoundStartedEvent.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClient.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerGameWindow.java trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.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/ClientSocketDispatcher.java trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.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/service/ConsentFormDao.java trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/bean/ConsentForm.java trunk/gee/src/java/edu/indiana/psych/gee/net/event/ trunk/gee/src/java/edu/indiana/psych/gee/net/event/ClientReadyEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/event/ConnectionEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionRequest.java trunk/gee/src/java/edu/indiana/psych/gee/net/event/ExperimentUpdateEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/event/ServerAssignedIdentifierEvent.java Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java trunk/gee/src/java/edu/indiana/psych/gee/net/ClientReadyEvent.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/ExperimentUpdateEvent.java trunk/gee/src/java/edu/indiana/psych/gee/net/ServerAssignedIdentifierEvent.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-05-18 05:18:18 UTC (rev 180) @@ -5,6 +5,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import edu.indiana.psych.gee.bean.ConsentForm; import edu.indiana.psych.gee.event.Event; import edu.indiana.psych.gee.event.EventChannel; import edu.indiana.psych.gee.net.DispatcherFactory; @@ -33,7 +34,7 @@ private boolean running; private ExperimentService experimentService; - private ExperimentConfigurationService configurationService; +// private ExperimentConfigurationService configurationService; private String name; private C configuration; Deleted: trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-05-18 05:18:18 UTC (rev 180) @@ -1,130 +0,0 @@ -package edu.indiana.psych.gee; - -import java.util.Calendar; -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; - -/** - * $Id$ - * - * Persistent bean representing a consent form. - * - * @author <a href='al...@cs...'>Allen Lee</a> - * @version $Revision$ - */ - -@Entity -@Table(name="consent_form") -public class ConsentForm { - - // are longs overkill? - private Long id = Long.valueOf(-1); - - private String studyNumber; - private String description; - private String deception; - private String confidentiality; - private String compensation; - private String risks; - private String benefits; - private String contact; - private String participation; - - private Date irbDateApproved; - - @Id @GeneratedValue - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - public String getBenefits() { - return benefits; - } - public void setBenefits(String benefits) { - this.benefits = benefits; - } - public String getCompensation() { - return compensation; - } - public void setCompensation(String compensation) { - this.compensation = compensation; - } - public String getConfidentiality() { - return confidentiality; - } - public void setConfidentiality(String confidentiality) { - this.confidentiality = confidentiality; - } - public String getContact() { - return contact; - } - public void setContact(String contact) { - this.contact = contact; - } - public String getDeception() { - return deception; - } - public void setDeception(String deception) { - this.deception = deception; - } - public String getDescription() { - return description; - } - 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(); - calendar.set(2005, 9, 26); - irbDateApproved = calendar.getTime(); - } - return irbDateApproved; - } - - public void setIrbDateApproved(Date irbDateApproved) { - this.irbDateApproved = irbDateApproved; - } - - // FIXME: atrocity - private boolean isToday(Date date) { - Calendar now = Calendar.getInstance(); - now.setTime(new Date()); - Calendar then = Calendar.getInstance(); - then.setTime(date); - return (now.get(Calendar.MONTH) == then.get(Calendar.MONTH) - && now.get(Calendar.YEAR) == then.get(Calendar.YEAR) - && now.get(Calendar.DAY_OF_MONTH) == then.get(Calendar.DAY_OF_MONTH)); - } - - public String getParticipation() { - return participation; - } - public void setParticipation(String participation) { - this.participation = participation; - } - public String getRisks() { - return risks; - } - public void setRisks(String risks) { - this.risks = risks; - } - -} Modified: trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java 2006-05-18 05:18:18 UTC (rev 180) @@ -3,6 +3,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import edu.indiana.psych.gee.bean.ConsentForm; import edu.indiana.psych.gee.net.Dispatcher; /** Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-05-18 05:18:18 UTC (rev 180) @@ -3,10 +3,13 @@ import java.util.List; import java.net.InetSocketAddress; +import edu.indiana.psych.gee.bean.ConsentForm; import edu.indiana.psych.gee.time.Duration; /** * $Id: Exp $ + * + * * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision: $ Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-05-18 05:18:18 UTC (rev 180) @@ -9,12 +9,11 @@ import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; -import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; +import edu.indiana.psych.gee.bean.ConsentForm; import edu.indiana.psych.gee.time.Duration; /** Modified: trunk/gee/src/java/edu/indiana/psych/gee/Identifier.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/Identifier.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/Identifier.java 2006-05-18 05:18:18 UTC (rev 180) @@ -18,9 +18,5 @@ public String toString() { return "[ <NULL Identifier> ]"; } - - public boolean equals(Object object) { - return (this == object) || ((object instanceof Identifier) && object.toString().equals(toString())); - } }; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-05-18 05:18:18 UTC (rev 180) @@ -1,7 +1,7 @@ package edu.indiana.psych.gee.action; -import edu.indiana.psych.gee.ConsentForm; import edu.indiana.psych.gee.Experiment; +import edu.indiana.psych.gee.bean.ConsentForm; import edu.indiana.psych.gee.bean.Participant; /** Copied: trunk/gee/src/java/edu/indiana/psych/gee/bean/ConsentForm.java (from rev 179, trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/ConsentForm.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/ConsentForm.java 2006-05-18 05:18:18 UTC (rev 180) @@ -0,0 +1,136 @@ +package edu.indiana.psych.gee.bean; + +import java.util.Calendar; +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +/** + * $Id$ + * + * Persistent bean representing a consent form. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision$ + */ + +@Entity +@Table(name="consent_form") +public class ConsentForm { + + // are longs overkill? + private Long id = Long.valueOf(-1); + + private String studyNumber; + private String description; + private String deception; + private String confidentiality; + private String compensation; + private String risks; + private String benefits; + private String contact; + private String participation; + + private Date irbDateApproved; + + @Id @GeneratedValue + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public String getBenefits() { + return benefits; + } + public void setBenefits(String benefits) { + this.benefits = benefits; + } + public String getCompensation() { + return compensation; + } + public void setCompensation(String compensation) { + this.compensation = compensation; + } + public String getConfidentiality() { + return confidentiality; + } + public void setConfidentiality(String confidentiality) { + this.confidentiality = confidentiality; + } + public String getContact() { + return contact; + } + public void setContact(String contact) { + this.contact = contact; + } + public String getDeception() { + return deception; + } + public void setDeception(String deception) { + this.deception = deception; + } + public String getDescription() { + return description; + } + 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(); + calendar.set(2005, 9, 26); + irbDateApproved = calendar.getTime(); + } + return irbDateApproved; + } + + public void setIrbDateApproved(Date irbDateApproved) { + this.irbDateApproved = irbDateApproved; + } + + // FIXME: atrocity + private boolean isToday(Date date) { + Calendar now = Calendar.getInstance(); + now.setTime(new Date()); + Calendar then = Calendar.getInstance(); + then.setTime(date); + return (now.get(Calendar.MONTH) == then.get(Calendar.MONTH) + && now.get(Calendar.YEAR) == then.get(Calendar.YEAR) + && now.get(Calendar.DAY_OF_MONTH) == then.get(Calendar.DAY_OF_MONTH)); + } + + public String getParticipation() { + return participation; + } + public void setParticipation(String participation) { + this.participation = participation; + } + public String getRisks() { + return risks; + } + public void setRisks(String risks) { + this.risks = risks; + } + public String getStudyNumber() { + return studyNumber; + } + public void setStudyNumber(String studyNumber) { + this.studyNumber = studyNumber; + } + +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/bean/ConsentForm.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EndRoundEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EndRoundEvent.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EndRoundEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -3,7 +3,7 @@ import java.util.SortedSet; import edu.indiana.psych.gee.Identifier; -import edu.indiana.psych.gee.net.ExperimentUpdateEvent; +import edu.indiana.psych.gee.net.event.ExperimentUpdateEvent; import edu.indiana.psych.gee.time.Duration; /** Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/RoundStartedEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/RoundStartedEvent.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/RoundStartedEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -3,7 +3,7 @@ import edu.indiana.psych.gee.ExperimentRoundParameters; import edu.indiana.psych.gee.Identifier; -import edu.indiana.psych.gee.net.ExperimentUpdateEvent; +import edu.indiana.psych.gee.net.event.ExperimentUpdateEvent; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-05-18 05:18:18 UTC (rev 180) @@ -23,9 +23,9 @@ import edu.indiana.psych.gee.forager.ForagerAgentFactory.ForagerAgent; import edu.indiana.psych.gee.forager.event.ClientPositionUpdateEvent; import edu.indiana.psych.gee.forager.event.ClientUpdateEvent; -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.net.event.ClientReadyEvent; +import edu.indiana.psych.gee.net.event.ConnectionEvent; import edu.indiana.psych.gee.service.ExperimentConfigurationService; import edu.indiana.psych.gee.time.Duration; import edu.indiana.psych.gee.util.GeeUtils; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClient.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClient.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClient.java 2006-05-18 05:18:18 UTC (rev 180) @@ -22,10 +22,10 @@ import edu.indiana.psych.gee.forager.event.ClientUpdateEvent; import edu.indiana.psych.gee.forager.event.StartExperimentRoundRequest; import edu.indiana.psych.gee.net.ClientDispatcher; -import edu.indiana.psych.gee.net.ClientReadyEvent; -import edu.indiana.psych.gee.net.DisconnectionEvent; import edu.indiana.psych.gee.net.DispatcherFactory; -import edu.indiana.psych.gee.net.ExperimentUpdateEvent; +import edu.indiana.psych.gee.net.event.ClientReadyEvent; +import edu.indiana.psych.gee.net.event.DisconnectionEvent; +import edu.indiana.psych.gee.net.event.ExperimentUpdateEvent; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerGameWindow.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerGameWindow.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerGameWindow.java 2006-05-18 05:18:18 UTC (rev 180) @@ -37,7 +37,7 @@ import edu.indiana.psych.gee.forager.Direction; import edu.indiana.psych.gee.forager.event.ClientUpdateEvent; import edu.indiana.psych.gee.forager.event.StartExperimentRoundRequest; -import edu.indiana.psych.gee.net.ClientReadyEvent; +import edu.indiana.psych.gee.net.event.ClientReadyEvent; 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-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientPositionUpdateEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -6,7 +6,7 @@ import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.event.AbstractEvent; -import edu.indiana.psych.gee.net.ExperimentUpdateEvent; +import edu.indiana.psych.gee.net.event.ExperimentUpdateEvent; Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/AbstractDispatcher.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/AbstractDispatcher.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/AbstractDispatcher.java 2006-05-18 05:18:18 UTC (rev 180) @@ -5,6 +5,7 @@ import edu.indiana.psych.gee.event.Event; import edu.indiana.psych.gee.event.EventChannel; import edu.indiana.psych.gee.event.EventHandler; +import edu.indiana.psych.gee.net.event.DisconnectionRequest; /** * $Id$ Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/AbstractServerDispatcher.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/AbstractServerDispatcher.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/AbstractServerDispatcher.java 2006-05-18 05:18:18 UTC (rev 180) @@ -11,6 +11,7 @@ import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.event.EventChannel; import edu.indiana.psych.gee.event.EventTypeProcessor; +import edu.indiana.psych.gee.net.event.DisconnectionRequest; /** * $Id$ Deleted: trunk/gee/src/java/edu/indiana/psych/gee/net/ClientReadyEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/ClientReadyEvent.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/ClientReadyEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -1,24 +0,0 @@ -package edu.indiana.psych.gee.net; - -import edu.indiana.psych.gee.Identifier; -import edu.indiana.psych.gee.event.AbstractEvent; - - -/** - * $Id$ - * - * This Event signifies that the ForagerClient is ready and willing to - * join the game whenever the next one starts. - * - * @author Allen Lee - * @version $Revision$ - */ -public class ClientReadyEvent extends AbstractEvent { - - private static final long serialVersionUID = -3226895587981309363L; - - public ClientReadyEvent(Identifier id) { - super(id); - } - -} Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/ClientSocketDispatcher.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/ClientSocketDispatcher.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/ClientSocketDispatcher.java 2006-05-18 05:18:18 UTC (rev 180) @@ -8,6 +8,9 @@ import edu.indiana.psych.gee.event.Event; import edu.indiana.psych.gee.event.EventChannel; import edu.indiana.psych.gee.event.EventTypeProcessor; +import edu.indiana.psych.gee.net.event.ConnectionEvent; +import edu.indiana.psych.gee.net.event.DisconnectionRequest; +import edu.indiana.psych.gee.net.event.ServerAssignedIdentifierEvent; /** * $Id$ Deleted: trunk/gee/src/java/edu/indiana/psych/gee/net/ConnectionEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/ConnectionEvent.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/ConnectionEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -1,23 +0,0 @@ -package edu.indiana.psych.gee.net; - -import edu.indiana.psych.gee.Identifier; -import edu.indiana.psych.gee.event.AbstractEvent; - -/** - * $Id$ - * - * Used to signify that a successful connection was made. - * - * @author Allen Lee - * @version $Revision$ - */ - -public class ConnectionEvent extends AbstractEvent { - - private static final long serialVersionUID = -7374984013354707218L; - - public ConnectionEvent(Identifier id) { - super(id); - } -} - Deleted: trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionEvent.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -1,23 +0,0 @@ -package edu.indiana.psych.gee.net; - -import edu.indiana.psych.gee.Identifier; -import edu.indiana.psych.gee.event.AbstractEvent; - -/** - * $Id$ - * - * Signifies that a disconnection happened for the given id. - * - * - * @author Allen Lee - * @version $Revision$ - */ -public class DisconnectionEvent extends AbstractEvent { - - private static final long serialVersionUID = 1116488025527784177L; - - public DisconnectionEvent(Identifier id) { - super(id); - } -} - Deleted: trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionRequest.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionRequest.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionRequest.java 2006-05-18 05:18:18 UTC (rev 180) @@ -1,32 +0,0 @@ -package edu.indiana.psych.gee.net; - -import edu.indiana.psych.gee.Identifier; -import edu.indiana.psych.gee.event.AbstractEvent; - -/** - * $Id$ - * - * Signifies that a disconnection should happen for the given identifier. - * - * @author Allen Lee - * @version $Revision$ - */ -public class DisconnectionRequest extends AbstractEvent { - - private static final long serialVersionUID = 8135584626891675116L; - - private final Exception exception; - - public DisconnectionRequest(Identifier id) { - this(id, null); - } - - public DisconnectionRequest(Identifier id, Exception exception) { - super(id); - this.exception = exception; - } - - public Exception getException() { - return exception; - } -} Deleted: trunk/gee/src/java/edu/indiana/psych/gee/net/ExperimentUpdateEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/ExperimentUpdateEvent.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/ExperimentUpdateEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -1,16 +0,0 @@ -package edu.indiana.psych.gee.net; - -import edu.indiana.psych.gee.event.Event; - - -/** - * $Id$ - * - * Marker interface for events originating from an Experiment server. - * - * @author <a href='al...@cs...'>Allen Lee</a> - * @version $Revision$ - */ -public interface ExperimentUpdateEvent extends Event { - -} Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java 2006-05-18 05:18:18 UTC (rev 180) @@ -22,6 +22,9 @@ import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.event.Event; import edu.indiana.psych.gee.event.EventChannel; +import edu.indiana.psych.gee.net.event.ConnectionEvent; +import edu.indiana.psych.gee.net.event.DisconnectionEvent; +import edu.indiana.psych.gee.net.event.ServerAssignedIdentifierEvent; /** * $Id$ Deleted: trunk/gee/src/java/edu/indiana/psych/gee/net/ServerAssignedIdentifierEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/ServerAssignedIdentifierEvent.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/ServerAssignedIdentifierEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -1,23 +0,0 @@ -package edu.indiana.psych.gee.net; - -import edu.indiana.psych.gee.Identifier; -import edu.indiana.psych.gee.event.AbstractEvent; - -/** - * $Id$ - * - * Used to inform the client of the server assigned Identifier. - * - * - * @author Allen Lee - * @version $Revision$ - */ -public class ServerAssignedIdentifierEvent extends AbstractEvent -implements ExperimentUpdateEvent { - - private static final long serialVersionUID = -2258127108062718367L; - - public ServerAssignedIdentifierEvent(Identifier id) { - super(id); - } -} Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/ServerSocketDispatcher.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/ServerSocketDispatcher.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/ServerSocketDispatcher.java 2006-05-18 05:18:18 UTC (rev 180) @@ -9,6 +9,9 @@ import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.event.Event; import edu.indiana.psych.gee.event.EventChannel; +import edu.indiana.psych.gee.net.event.ConnectionEvent; +import edu.indiana.psych.gee.net.event.DisconnectionEvent; +import edu.indiana.psych.gee.net.event.ServerAssignedIdentifierEvent; /** * $Id$ Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/SocketDispatcherWorker.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/SocketDispatcherWorker.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/SocketDispatcherWorker.java 2006-05-18 05:18:18 UTC (rev 180) @@ -8,6 +8,7 @@ import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.event.Event; +import edu.indiana.psych.gee.net.event.DisconnectionRequest; /** * $Id$ @@ -66,9 +67,11 @@ public void write(Event event) { try { // FIXME: consider caching the object output stream? - ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream()); - out.writeObject(event); - out.flush(); + synchronized (socket) { + ObjectOutputStream o... [truncated message content] |
|
From: <al...@us...> - 2006-05-18 05:44:06
|
Revision: 181 Author: alllee Date: 2006-05-17 22:43:53 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=181&view=rev Log Message: ----------- package refactoring, adding a dao subpackage. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/dao/ trunk/gee/src/java/edu/indiana/psych/gee/dao/ConsentFormDao.java trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateConsentFormDao.java trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateExperimentConfigurationDao.java Copied: trunk/gee/src/java/edu/indiana/psych/gee/dao/ConsentFormDao.java (from rev 180, trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/dao/ConsentFormDao.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/dao/ConsentFormDao.java 2006-05-18 05:43:53 UTC (rev 181) @@ -0,0 +1,23 @@ +package edu.indiana.psych.gee.dao; + +import org.springframework.transaction.annotation.Transactional; + +import edu.indiana.psych.gee.bean.ConsentForm; + +/** + * $Id: Exp$ + * + * Data access object for consent forms. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision: $ + */ + +@Transactional +public interface ConsentFormDao { + + public ConsentForm find(Integer id); + + public void persist(ConsentForm consentForm); + +} Copied: trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java (from rev 179, trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java 2006-05-18 05:43:53 UTC (rev 181) @@ -0,0 +1,26 @@ +package edu.indiana.psych.gee.dao; + +import org.springframework.transaction.annotation.Transactional; + +import edu.indiana.psych.gee.ExperimentConfiguration; + +/** + * $Id$ + * + * Data access object for persisting experiment configurations, should also + * take care of experiment round parameters. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision$ + */ + +@Transactional +public interface ExperimentConfigurationDao { + + public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Integer id); + + public <E extends ExperimentConfiguration> E find(final Class<E> configurationClass, final String experimentName); + + public void persist(ExperimentConfiguration configuration); + +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id Copied: trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateConsentFormDao.java (from rev 180, trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateConsentFormDao.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateConsentFormDao.java 2006-05-18 05:43:53 UTC (rev 181) @@ -0,0 +1,26 @@ +package edu.indiana.psych.gee.dao; + +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + +import edu.indiana.psych.gee.bean.ConsentForm; + +/** + * $Id$ + * + * Hibernate data access object for consent forms. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision$ + */ + +public class HibernateConsentFormDao extends HibernateDaoSupport implements ConsentFormDao { + + public ConsentForm find(Integer id) { + return (ConsentForm) getHibernateTemplate().get(ConsentForm.class, id); + } + + public void persist(ConsentForm consentForm) { + getHibernateTemplate().saveOrUpdate(consentForm); + } + +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateConsentFormDao.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id Copied: trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java (from rev 179, trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateExperimentConfigurationDao.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java 2006-05-18 05:43:53 UTC (rev 181) @@ -0,0 +1,48 @@ +package edu.indiana.psych.gee.dao; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.hibernate.Criteria; +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.criterion.Restrictions; +import org.springframework.orm.hibernate3.HibernateCallback; +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + +import edu.indiana.psych.gee.ExperimentConfiguration; + +/** + * $Id: Exp $ + * + * Data access object for persisting experiment configurations, should also + * take care of experiment round parameters. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision: $ + */ + +public class HibernateExperimentConfigurationDao extends HibernateDaoSupport implements ExperimentConfigurationDao { + + private final Log logger = LogFactory.getLog(getClass()); + + public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Integer id) { + return configurationClass.cast(getHibernateTemplate().get(configurationClass, id)); + } + + public <E extends ExperimentConfiguration> E find(final Class<E> configurationClass, final String experimentName) { + return configurationClass.cast( + getHibernateTemplate().execute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + logger.warn("doInHibernate session is: " + session.hashCode()); + Criteria criteria = session.createCriteria(configurationClass); + criteria.add(Restrictions.eq("experimentName", experimentName)); + return criteria.uniqueResult(); + } + })); + } + + public void persist(ExperimentConfiguration configuration) { + getHibernateTemplate().saveOrUpdate(configuration); + } + +} Deleted: trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java 2006-05-18 05:18:18 UTC (rev 180) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java 2006-05-18 05:43:53 UTC (rev 181) @@ -1,23 +0,0 @@ -package edu.indiana.psych.gee.service; - -import org.springframework.transaction.annotation.Transactional; - -import edu.indiana.psych.gee.bean.ConsentForm; - -/** - * $Id: Exp$ - * - * Data access object for consent forms. - * - * @author <a href='al...@cs...'>Allen Lee</a> - * @version $Revision: $ - */ - -@Transactional -public interface ConsentFormDao { - - public ConsentForm find(Integer id); - - public void persist(ConsentForm consentForm); - -} Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java 2006-05-18 05:18:18 UTC (rev 180) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java 2006-05-18 05:43:53 UTC (rev 181) @@ -3,6 +3,7 @@ import java.util.List; import edu.indiana.psych.gee.bean.ConsentForm; +import edu.indiana.psych.gee.dao.ConsentFormDao; /** * $Id: Exp $ Deleted: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java 2006-05-18 05:18:18 UTC (rev 180) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java 2006-05-18 05:43:53 UTC (rev 181) @@ -1,26 +0,0 @@ -package edu.indiana.psych.gee.service; - -import org.springframework.transaction.annotation.Transactional; - -import edu.indiana.psych.gee.ExperimentConfiguration; - -/** - * $Id$ - * - * Data access object for persisting experiment configurations, should also - * take care of experiment round parameters. - * - * @author <a href='al...@cs...'>Allen Lee</a> - * @version $Revision$ - */ - -@Transactional -public interface ExperimentConfigurationDao { - - public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Integer id); - - public <E extends ExperimentConfiguration> E find(final Class<E> configurationClass, final String experimentName); - - public void persist(ExperimentConfiguration configuration); - -} Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-05-18 05:18:18 UTC (rev 180) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-05-18 05:43:53 UTC (rev 181) @@ -1,8 +1,7 @@ package edu.indiana.psych.gee.service; -import java.io.InputStream; - import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.dao.ExperimentConfigurationDao; /** * $Id: Exp $ @@ -18,7 +17,7 @@ public class ExperimentConfigurationService { private ExperimentConfigurationDao experimentConfigurationDao; - private ConsentFormDao consentFormDao; +// private ConsentFormDao consentFormDao; public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Integer id) { return experimentConfigurationDao.find(configurationClass, id); @@ -47,8 +46,8 @@ this.experimentConfigurationDao = experimentConfigurationDao; } - public void setConsentFormDao(ConsentFormDao consentFormDao) { - this.consentFormDao = consentFormDao; - } +// public void setConsentFormDao(ConsentFormDao consentFormDao) { +// this.consentFormDao = consentFormDao; +// } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java 2006-05-18 05:18:18 UTC (rev 180) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java 2006-05-18 05:43:53 UTC (rev 181) @@ -20,6 +20,7 @@ */ public class ExperimentService { + @SuppressWarnings("serial") private final Map<String, Experiment> allExperiments = new HashMap<String, Experiment>() { public Experiment get(String key) { Deleted: trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java 2006-05-18 05:18:18 UTC (rev 180) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java 2006-05-18 05:43:53 UTC (rev 181) @@ -1,26 +0,0 @@ -package edu.indiana.psych.gee.service; - -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -import edu.indiana.psych.gee.bean.ConsentForm; - -/** - * $Id$ - * - * Hibernate data access object for consent forms. - * - * @author <a href='al...@cs...'>Allen Lee</a> - * @version $Revision$ - */ - -public class HibernateConsentFormDao extends HibernateDaoSupport implements ConsentFormDao { - - public ConsentForm find(Integer id) { - return (ConsentForm) getHibernateTemplate().get(ConsentForm.class, id); - } - - public void persist(ConsentForm consentForm) { - getHibernateTemplate().saveOrUpdate(consentForm); - } - -} Deleted: trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateExperimentConfigurationDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateExperimentConfigurationDao.java 2006-05-18 05:18:18 UTC (rev 180) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateExperimentConfigurationDao.java 2006-05-18 05:43:53 UTC (rev 181) @@ -1,48 +0,0 @@ -package edu.indiana.psych.gee.service; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.criterion.Restrictions; -import org.springframework.orm.hibernate3.HibernateCallback; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -import edu.indiana.psych.gee.ExperimentConfiguration; - -/** - * $Id: Exp $ - * - * Data access object for persisting experiment configurations, should also - * take care of experiment round parameters. - * - * @author <a href='al...@cs...'>Allen Lee</a> - * @version $Revision: $ - */ - -public class HibernateExperimentConfigurationDao extends HibernateDaoSupport implements ExperimentConfigurationDao { - - private final Log logger = LogFactory.getLog(getClass()); - - public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Integer id) { - return configurationClass.cast(getHibernateTemplate().get(configurationClass, id)); - } - - public <E extends ExperimentConfiguration> E find(final Class<E> configurationClass, final String experimentName) { - return configurationClass.cast( - getHibernateTemplate().execute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - logger.warn("doInHibernate session is: " + session.hashCode()); - Criteria criteria = session.createCriteria(configurationClass); - criteria.add(Restrictions.eq("experimentName", experimentName)); - return criteria.uniqueResult(); - } - })); - } - - public void persist(ExperimentConfiguration configuration) { - getHibernateTemplate().saveOrUpdate(configuration); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <al...@us...> - 2006-06-18 22:51:50
|
Revision: 189 Author: alllee Date: 2006-06-18 15:51:45 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=189&view=rev Log Message: ----------- adding new subject/self/food images to GridView, still need to hook in extra directions.. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/GridView.java trunk/gee/src/java/edu/indiana/psych/gee/forager/client/DebriefingView.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/SubjectView.java trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-06-18 18:34:40 UTC (rev 188) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-06-18 22:51:45 UTC (rev 189) @@ -85,6 +85,7 @@ else { getLogger().warn("Ignoring spurious request to STOP: " + toString()); } + getEventChannel().remove(this); } public int getServerPort() { Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/GridView.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/GridView.java 2006-06-18 18:34:40 UTC (rev 188) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/GridView.java 2006-06-18 22:51:45 UTC (rev 189) @@ -32,9 +32,15 @@ * so that the scaling calculation does not have to be performed * for each paint. */ - protected Image foodImage, subjectImage, selfImage, botImage; + private Image foodImage1, foodImage2, foodImage3, foodImage4; + private Image subjectDownImage, subjectUpImage, subjectLeftImage, subjectRightImage; + private Image selfDownImage, selfUpImage, selfLeftImage, selfRightImage; + private Image botDownImage, botUpImage, botLeftImage, botRightImage; - protected Image scaledFoodImage, scaledSubjectImage, scaledSelfImage, scaledBotImage; + protected Image scaledFoodImage1, scaledFoodImage2, scaledFoodImage3, scaledFoodImage4; + protected Image scaledSubjectDownImage, scaledSubjectUpImage, scaledSubjectLeftImage, scaledSubjectRightImage; + protected Image scaledSelfDownImage, scaledSelfUpImage, scaledSelfLeftImage, scaledSelfRightImage; + protected Image scaledBotDownImage, scaledBotUpImage, scaledBotLeftImage, scaledBotRightImage; /** * Use these for the dimensions when drawing. @@ -67,20 +73,23 @@ // imageUpdate callback is invoked a repaint happens. URL location = null; try { - URLClassLoader imageLoader = URLClassLoader.newInstance(new URL[] { new URL("http", "groups.psych.indiana.edu", "/gee/images/forager/") }); - if (foodImage == null) { - System.out.println("URL is: " + imageLoader.findResource("gem-food.gif")); - foodImage = toolkit.getImage(imageLoader.findResource("gem-food.gif")); - } - if (selfImage == null) { - selfImage = toolkit.getImage(imageLoader.findResource("gem-self.gif")); - } - if (subjectImage == null) { - subjectImage = toolkit.getImage(imageLoader.findResource("gem-red.gif")); - } - if (botImage == null) { - botImage = toolkit.getImage(imageLoader.findResource("gem-gray.gif")); - } + URLClassLoader imageLoader = URLClassLoader.newInstance(new URL[] { new URL("http", "groups.psych.indiana.edu", "/gee/images/forager-v2/") }); + foodImage1 = toolkit.getImage(imageLoader.findResource("grass-1.gif")); + foodImage2 = toolkit.getImage(imageLoader.findResource("grass-2.gif")); + foodImage3 = toolkit.getImage(imageLoader.findResource("grass-3.gif")); + foodImage4 = toolkit.getImage(imageLoader.findResource("grass-4.gif")); + selfDownImage = toolkit.getImage(imageLoader.findResource("you-front.gif")); + selfUpImage = toolkit.getImage(imageLoader.findResource("you-back.gif")); + selfLeftImage = toolkit.getImage(imageLoader.findResource("you-side-left.gif")); + selfRightImage = toolkit.getImage(imageLoader.findResource("you-side-right.gif")); + subjectDownImage = toolkit.getImage(imageLoader.findResource("others-front.gif")); + subjectUpImage = toolkit.getImage(imageLoader.findResource("others-back.gif")); + subjectLeftImage = toolkit.getImage(imageLoader.findResource("others-side-left.gif")); + subjectRightImage = toolkit.getImage(imageLoader.findResource("others-side-right.gif")); + botDownImage = toolkit.getImage(imageLoader.findResource("bot-front.gif")); + botUpImage = toolkit.getImage(imageLoader.findResource("bot-back.gif")); + botLeftImage = toolkit.getImage(imageLoader.findResource("bot-side-left.gif")); + botRightImage = toolkit.getImage(imageLoader.findResource("bot-side-right.gif")); } catch (Exception e) { throw new RuntimeException(e); @@ -88,19 +97,32 @@ } - /** - * Sets dw, and dh, xoffset, and yoffset - * Uses the screenSize as given in the constructor - * along with the current board size. - * Expects the following variables to have been set already: - * 1. the screenSize - * 2. the boardSize - * 3. the images - */ - public void setup(ExperimentRoundParameters parameters) { + private void loadScaledImages() { + int cellWidth = (int) dw; + int cellHeight = (int) dh; + scaledFoodImage1 = foodImage1.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledFoodImage2 = foodImage2.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledFoodImage3 = foodImage3.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledFoodImage4 = foodImage4.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledSubjectDownImage = subjectDownImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledSubjectUpImage = subjectUpImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledSubjectLeftImage = subjectLeftImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledSubjectRightImage = subjectRightImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledSelfDownImage = selfDownImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledSelfUpImage = selfUpImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledSelfLeftImage = selfLeftImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledSelfRightImage = selfRightImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledBotDownImage = botDownImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledBotUpImage = botUpImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledBotLeftImage = botLeftImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + scaledBotRightImage = botRightImage.getScaledInstance(cellWidth, cellHeight, Image.SCALE_FAST); + + } + + private void setScreenSize(Dimension screenSize) { + this.screenSize = screenSize; int availableWidth = (int) screenSize.getWidth(); int availableHeight = (int) screenSize.getHeight(); - setBoardSize(parameters.getBoardSize()); // stretch board to the max dw = (availableWidth / boardSize.getWidth()); @@ -113,16 +135,28 @@ yoffset = (int) Math.floor((availableHeight - (dh * boardSize.getHeight())) / 2); // get scaled instances of the originals - scaledFoodImage = foodImage.getScaledInstance((int) dw, (int) dh, Image.SCALE_FAST); - scaledSubjectImage = subjectImage.getScaledInstance((int) dw, (int) dh, - Image.SCALE_FAST); - scaledSelfImage = selfImage.getScaledInstance((int) dw, (int) dh, Image.SCALE_FAST); - scaledBotImage = botImage.getScaledInstance((int) dw, (int) dh, Image.SCALE_FAST); + loadScaledImages(); // make sure we've got enough room setSize(availableWidth, availableHeight); } + + /** + * Sets dw, and dh, xoffset, and yoffset + * Uses the screenSize as given in the constructor + * along with the current board size. + * Expects the following variables to have been set already: + * 1. the screenSize + * 2. the boardSize + * 3. the images + */ + public void setup(ExperimentRoundParameters parameters) { + setBoardSize(parameters.getBoardSize()); + setScreenSize(screenSize); + + } + private void setBoardSize(Dimension boardSize) { this.boardSize = boardSize; setBackground(Color.BLACK); @@ -131,8 +165,7 @@ } public Dimension getBoardSize() { - // defensive copy to protect for-some-reason public instance vars. - return new Dimension(boardSize); + return boardSize; } @@ -164,23 +197,16 @@ paintCollection(collection, graphics2D, image, null); } - protected void paintCollection(Collection collection, + protected void paintCollection(Collection<Point> collection, Graphics2D graphics2D, Image image, ImageObserver observer) { synchronized (collection) { int width = (int) dw; int height = (int) dh; - for (Iterator iter = collection.iterator(); iter.hasNext(); ) { - Point point = (Point) iter.next(); + for (Point point : collection) { int x = scaleX(point.x); int y = scaleY(point.y); - if (image == null) { - graphics2D.setColor(Color.GREEN); - graphics2D.fillOval(x, y, width, height); - } - else { - graphics2D.drawImage(image, x, y, observer); - } + graphics2D.drawImage(image, x, y, observer); } } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/client/DebriefingView.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/client/DebriefingView.java 2006-06-18 18:34:40 UTC (rev 188) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/DebriefingView.java 2006-06-18 22:51:45 UTC (rev 189) @@ -76,7 +76,7 @@ } protected void paintFood(Graphics2D g) { - paintCollection(foodPositionsMap.keySet(), g, scaledFoodImage, this); + paintCollection(foodPositionsMap.keySet(), g, scaledFoodImage1, this); } protected void paintSubjects(Graphics2D g) { Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClient.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClient.java 2006-06-18 18:34:40 UTC (rev 188) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClient.java 2006-06-18 22:51:45 UTC (rev 189) @@ -180,6 +180,7 @@ } public void shutdown() { + disconnect(); channel.unregister(this); channel.unregister(messageQueueHandler); } 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-06-18 18:34:40 UTC (rev 188) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java 2006-06-18 22:51:45 UTC (rev 189) @@ -27,9 +27,9 @@ public ForagerClientGameState(EventChannel channel) { super(channel); - channel.add(new EventTypeProcessor(RoundStartedEvent.class) { - public void handle(Event event) { - initialize( (RoundStartedEvent) event); + channel.add(new EventTypeProcessor<RoundStartedEvent>(RoundStartedEvent.class) { + public void handle(RoundStartedEvent event) { + initialize(event); } }); } 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-06-18 18:34:40 UTC (rev 188) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/SubjectView.java 2006-06-18 22:51:45 UTC (rev 189) @@ -40,7 +40,7 @@ private Identifier clientId; // Map<Point, Duration> - private Map foodEaten = new HashMap(); + private Map<Point, Duration> foodEaten = new HashMap<Point, Duration>(); private Visibility subjectVisibility; private Visibility foodVisibility; @@ -84,7 +84,7 @@ // visible radius of the current player, or don't show any food. if (foodVisibility.isFull()) { // render all food - paintCollection(state.getFoodPositions(), graphics2D, scaledFoodImage); + paintCollection(state.getFoodPositions(), graphics2D, scaledFoodImage1); } else if (foodVisibility.isPartial()) { // render food conditionally based on whether or not it lies within @@ -103,10 +103,8 @@ * @param graphics2D */ protected void paintFoodEaten(Graphics2D graphics2D) { - int width = (int) dw; - int height = (int) dh; - int offset = 0; synchronized (foodEaten) { + Image foodImage = null; for (Iterator iter = foodEaten.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); @@ -122,32 +120,29 @@ // for a crude animation of food shrinking over time we have an // offset associated with time intervals that we subtract from // the width and height of the food image. - if (elapsedTime < 500L) { - offset = 0; + if (elapsedTime < 400L) { + foodImage = scaledFoodImage1; } - else if (elapsedTime < 1000L) { - offset = 2; + else if (elapsedTime < 800L) { + foodImage = scaledFoodImage2; } - else if (elapsedTime < 1500L) { - offset = 4; + else if (elapsedTime < 1200L) { + foodImage = scaledFoodImage3; } + else if (elapsedTime < 1600L) { + foodImage = scaledFoodImage4; + } // food pellets shrink over time - paintFoodPellet(point, graphics2D, width - offset, height - offset); + paintFoodPellet(point, graphics2D, foodImage); } } } - private void paintFoodPellet(Point point, Graphics2D graphics2D, int width, int height) { + private void paintFoodPellet(Point point, Graphics2D graphics2D, Image image) { int x = scaleX(point.x); int y = scaleY(point.y); - if (scaledFoodImage == null) { - graphics2D.setColor(Color.GREEN); - graphics2D.fillOval(x, y, width, height); - } - else { - graphics2D.drawImage(scaledFoodImage, x, y, width, height, null); - } + graphics2D.drawImage(image, x, y, (int) dw, (int) dh, null); } // FIXME: performance bottleneck, drawImage seems to take a lot of time. @@ -188,15 +183,17 @@ // graphics2D.drawImage(scaledSelfImage, scaleX(selfLocation.x), scaleY(selfLocation.y), null); } + // FIXME: add additional images for up/left/right/etc depending on the + // client direction.. private Image getImageFor(Identifier id) { if ( state.isBot(id) ) { - return scaledBotImage; + return scaledBotDownImage; } else if (id.equals(clientId)) { - return scaledSelfImage; + return scaledSelfDownImage; } else { - return scaledSubjectImage; + return scaledSubjectDownImage; } } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java 2006-06-18 18:34:40 UTC (rev 188) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java 2006-06-18 22:51:45 UTC (rev 189) @@ -104,7 +104,6 @@ try { SocketChannel connection = SocketChannel.open(address); // block until we've read the socket identifier from server. - System.err.println("connection: " + connection); Identifier id = readConnectionEvent(connection); worker.process(connection); // XXX: we return an Identifier that's .equals() with the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |