[gee-svn] SF.net SVN: gabel: [182] trunk/gee/war
Status: Alpha
Brought to you by:
alllee
|
From: <al...@us...> - 2006-05-19 00:48:24
|
Revision: 182 Author: alllee Date: 2006-05-18 17:48:18 -0700 (Thu, 18 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=182&view=rev Log Message: ----------- fixing hibernate mapping file to reflect the movement of persistent beans into the edu.indiana.psych.gee.bean package. Heavy refactoring about to take place in ForagerExperiment/AbstractExperiment Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.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/war/WEB-INF/applicationContext.xml trunk/gee/war/WEB-INF/hibernate.cfg.xml trunk/gee/war/consent.jsp Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-05-18 05:43:53 UTC (rev 181) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-05-19 00:48:18 UTC (rev 182) @@ -45,22 +45,6 @@ dispatcher = DispatcherFactory.getInstance().createServerDispatcher(channel); } - public AbstractExperiment(Class<C> configurationClass, C defaultConfiguration, - ExperimentConfigurationService configurationService) { - this(); - // FIXME: alas, this doesn't seem to be easy to do it the way I'd like - // to, i.e., - // C persistedConfiguration = configurationService.find(defaultConfiguration); - C persistedConfiguration = configurationService.find(configurationClass, defaultConfiguration.getExperimentName()); - if (persistedConfiguration == null) { - setConfiguration(defaultConfiguration); - configurationService.persist(defaultConfiguration); - } - else { - setConfiguration(persistedConfiguration); - } - } - public C getConfiguration() { return configuration; } Deleted: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-05-18 05:43:53 UTC (rev 181) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-05-19 00:48:18 UTC (rev 182) @@ -1,190 +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.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Transient; - -import edu.indiana.psych.gee.bean.ConsentForm; -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. - * - * - * @author Allen Lee - * @version $Revision$ - */ - -@Entity -@Inheritance(strategy=InheritanceType.JOINED) -@Table(name="experiment_configuration") -public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> -implements ExperimentConfiguration<T> { - - // this should be a configurable property.. - private final static String DEFAULT_SERVER_HOST_NAME = "groups.psych.indiana.edu"; - - // 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; - } - - - /* - @Transient - public List<T> getAllParameters() { - throw new UnsupportedOperationException("Subclasses must override getAllParameters."); - } - - @Transient - 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); - } -} 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-18 05:43:53 UTC (rev 181) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-05-19 00:48:18 UTC (rev 182) @@ -22,7 +22,7 @@ consentForm = getExperiment().getConsentForm(); if (consentForm == null) { // no consent form available for this experiment.. just start? - getLogger().warn("No consent form available for this experiment: " + getExperiment()); + getLogger().warn("XXX: No consent form available for this experiment: " + getExperiment()); } return INPUT; } Copied: trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java (from rev 181, trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java 2006-05-19 00:48:18 UTC (rev 182) @@ -0,0 +1,177 @@ +package edu.indiana.psych.gee.bean; + +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.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Transient; + +import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentLifecycleException; +import edu.indiana.psych.gee.ExperimentRoundParameters; +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. + * + * + * @author Allen Lee + * @version $Revision$ + */ + +@Entity +@Inheritance(strategy=InheritanceType.JOINED) +@Table(name="experiment_configuration") +public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> +implements ExperimentConfiguration<T> { + + // this should be a configurable property.. + private final static String DEFAULT_SERVER_HOST_NAME = "groups.psych.indiana.edu"; + + // persistent fields + private Long id = Long.valueOf(-1); + private String description; + private String experimentName; + private String clientJarName; + private String clientMainClass; + 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; + } + + 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); + } +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-05-18 05:43:53 UTC (rev 181) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-05-19 00:48:18 UTC (rev 182) @@ -10,7 +10,7 @@ import javax.persistence.Table; import javax.persistence.Transient; -import edu.indiana.psych.gee.ExperimentConfigurationEntity; +import edu.indiana.psych.gee.bean.ExperimentConfigurationEntity; /** * $Id$ Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-05-18 05:43:53 UTC (rev 181) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-05-19 00:48:18 UTC (rev 182) @@ -64,13 +64,8 @@ private boolean roundRunning; - // FIXME: instead, need to find configurations from - // ExperimentConfigurationDao, yes? - public ForagerExperiment(ForagerConfiguration defaultConfiguration, - ExperimentConfigurationService configurationService) { - super(ForagerConfiguration.class, defaultConfiguration, configurationService); + public ForagerExperiment() { addEventProcessors(); - getLogger().debug("Creating a new ForagerExperiment with configuration: " + defaultConfiguration); } private void sendRegistrationEvent(Collection<Identifier> identifiers) { Modified: trunk/gee/war/WEB-INF/applicationContext.xml =================================================================== --- trunk/gee/war/WEB-INF/applicationContext.xml 2006-05-18 05:43:53 UTC (rev 181) +++ trunk/gee/war/WEB-INF/applicationContext.xml 2006-05-19 00:48:18 UTC (rev 182) @@ -53,17 +53,16 @@ <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- persistence layer daos--> - <bean id="experimentConfigurationDao" class="edu.indiana.psych.gee.service.HibernateExperimentConfigurationDao"> + <bean id="experimentConfigurationDao" class="edu.indiana.psych.gee.dao.HibernateExperimentConfigurationDao"> <property name="sessionFactory" ref="sessionFactory"/> </bean> - <bean id="consentFormDao" class="edu.indiana.psych.gee.service.HibernateConsentFormDao"> + <bean id="consentFormDao" class="edu.indiana.psych.gee.dao.HibernateConsentFormDao"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- application layer beans --> <bean id="experimentService" class="edu.indiana.psych.gee.service.ExperimentService"/> <bean id="configurationService" class="edu.indiana.psych.gee.service.ExperimentConfigurationService"> <property name="experimentConfigurationDao" ref="experimentConfigurationDao"/> - <property name="consentFormDao" ref="consentFormDao"/> </bean> <bean id="defaultForagerWebConfiguration" class="edu.indiana.psych.gee.forager.ForagerConfiguration"> <constructor-arg value="groups.psych.indiana.edu"/> Modified: trunk/gee/war/WEB-INF/hibernate.cfg.xml =================================================================== --- trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-05-18 05:43:53 UTC (rev 181) +++ trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-05-19 00:48:18 UTC (rev 182) @@ -7,9 +7,10 @@ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd "> <hibernate-configuration> <session-factory> - <mapping package="edu.indiana.psych.gee"/> - <mapping class="edu.indiana.psych.gee.ConsentForm"/> - <mapping class="edu.indiana.psych.gee.ExperimentConfigurationEntity"/> + <mapping package="edu.indiana.psych.gee.bean"/> + <mapping class="edu.indiana.psych.gee.bean.ConsentForm"/> + <mapping class="edu.indiana.psych.gee.bean.ExperimentConfigurationEntity"/> + <mapping class="edu.indiana.psych.gee.bean.Participant"/> <mapping package="edu.indiana.psych.gee.forager"/> <mapping class="edu.indiana.psych.gee.forager.ForagerAgentConfiguration"/> <mapping class="edu.indiana.psych.gee.forager.ForagerConfiguration"/> Modified: trunk/gee/war/consent.jsp =================================================================== --- trunk/gee/war/consent.jsp 2006-05-18 05:43:53 UTC (rev 181) +++ trunk/gee/war/consent.jsp 2006-05-19 00:48:18 UTC (rev 182) @@ -20,7 +20,7 @@ <TABLE CELLPADDING="4" CELLSPACING="2" BORDER="0"> <TR> <TD> - <B>${experimentName} consent form</B><BR> + <B>${experimentName}</B><BR> <TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%"> <TR><TD WIDTH="100%" BGCOLOR="#A4B5C5" HEIGHT="5"><IMG SRC="/images/blank.gif" WIDTH="1" HEIGHT="1"></TD></TR> </TABLE> @@ -137,11 +137,11 @@ IRB Approved <br/> <@ww.text name="approval.date"> - <@ww.param name="value" value="%{consentForm.irbDateApproved}"/> + <@ww.param value="'consentForm.irbDateApproved'"/> </@ww.text> <br/> <@ww.text name="approval.expiration.date"> - <@ww.param name="value" value="%{consentForm.irbDateApprovalExpires}"/> + <@ww.param value="'consentForm.irbDateApprovalExpires'"/> </@ww.text> </small> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |