[gee-svn] SF.net SVN: gabel: [164] trunk/gee/src/java/edu/indiana/psych/gee
Status: Alpha
Brought to you by:
alllee
|
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. |