[gee-svn] SF.net SVN: gabel: [168] trunk/gee/war/WEB-INF
Status: Alpha
Brought to you by:
alllee
|
From: <al...@us...> - 2006-03-23 06:44:06
|
Revision: 168 Author: alllee Date: 2006-03-22 22:43:54 -0800 (Wed, 22 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=168&view=rev Log Message: ----------- adding ExperimentConfiguration interface back into the mix now that I sort of understand how to use WW to automagically populate form parameters for instances of ExperimentConfiguration - use the Preparable interface for that. Still have some residual problems though... of course. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/action/GeeAction.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/war/WEB-INF/classes/gee-admin.xml trunk/gee/war/WEB-INF/classes/xwork.xml trunk/gee/war/WEB-INF/hibernate.cfg.xml trunk/gee/war/WEB-INF/sitemesh.xml Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java Deleted: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-23 05:38:49 UTC (rev 167) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-03-23 06:43:54 UTC (rev 168) @@ -1,188 +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.OneToMany; -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. - * - * - * @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"; - - // 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 ExperimentConfiguration() { - this(DEFAULT_SERVER_HOST_NAME, -1); - } - - public ExperimentConfiguration(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); - } -} Added: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.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-23 06:43:54 UTC (rev 168) @@ -0,0 +1,47 @@ +package edu.indiana.psych.gee; + +import java.util.List; +import java.net.InetSocketAddress; + +import edu.indiana.psych.gee.time.Duration; + +/** + * $Id: Exp $ + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision: $ + */ + +public interface ExperimentConfiguration<T extends ExperimentRoundParameters> { + + public List<T> getAllParameters(); + public void setAllParameters(List<T> allParameters); + public T getCurrentParameters(); + + public String getServerName(); + public void setServerName(String serverName); + + public String getExperimentName(); + public void setExperimentName(String experimentName); + + public int getServerPort(); + public void setServerPort(int serverPort); + + public ConsentForm getConsentForm(); + public void setConsentForm(ConsentForm consentForm); + + public Duration getDelayBetweenRounds(); + + public String getDescription(); + public void setDescription(String description); + + public boolean isTriggeredExperiment(); + public void setTriggeredExperiment(boolean triggered); + + public InetSocketAddress getServerAddress(); + +} +/* + * $Log: $ + */ + Copied: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java (from rev 166, trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-23 06:43:54 UTC (rev 168) @@ -0,0 +1,191 @@ +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.OneToMany; +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. + * + * + * @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/GeeAction.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/GeeAction.java 2006-03-23 05:38:49 UTC (rev 167) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/GeeAction.java 2006-03-23 06:43:54 UTC (rev 168) @@ -6,6 +6,7 @@ import com.opensymphony.xwork.ActionSupport; import edu.indiana.psych.gee.service.ExperimentService; +import edu.indiana.psych.gee.service.ExperimentConfigurationService; /** * $Id$ @@ -22,16 +23,26 @@ private final Log logger = LogFactory.getLog(getClass()); private ExperimentService experimentService; + private ExperimentConfigurationService configurationService; protected Log getLogger() { return logger; } - + protected ExperimentService getExperimentService() { return experimentService; } + protected ExperimentConfigurationService getConfigurationService() { + return configurationService; + } + public void setExperimentService(ExperimentService experimentService) { this.experimentService = experimentService; } + + public void setConfigurationService(ExperimentConfigurationService configurationService) { + this.configurationService = configurationService; + } + } 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-23 05:38:49 UTC (rev 167) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/UpdateExperimentConfiguration.java 2006-03-23 06:43:54 UTC (rev 168) @@ -2,6 +2,8 @@ import java.util.List; +import com.opensymphony.xwork.Preparable; + import edu.indiana.psych.gee.Experiment; import edu.indiana.psych.gee.ExperimentRoundParameters; import edu.indiana.psych.gee.ExperimentConfiguration; @@ -10,11 +12,13 @@ /** * $Id: Exp $ * + * WW action handling changes made to experiment configurations. + * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision: $ */ -public class UpdateExperimentConfiguration extends GeeAction { +public class UpdateExperimentConfiguration extends GeeAction implements Preparable { private String experimentName; @@ -22,26 +26,26 @@ public String execute() { getLogger().debug("XXX: updating experiment configuration: " + configuration); + getConfigurationService().persist(configuration); return SUCCESS; } + public void prepare() throws Exception { + this.configuration = getExperimentService().find(experimentName).getConfiguration(); + } + public ExperimentConfiguration getConfiguration() { return configuration; } - public List<? extends ExperimentRoundParameters> getAllParameters() { - getLogger().warn("XXX: Returning: " + configuration.getAllParameters()); - return configuration.getAllParameters(); - } - + /* public void setConfiguration(ExperimentConfiguration configuration) { this.configuration = configuration; } + */ public void setExperimentName(String experimentName) { getLogger().warn("XXX: setting experiment name: " + 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-23 05:38:49 UTC (rev 167) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-03-23 06:43:54 UTC (rev 168) @@ -10,7 +10,7 @@ import javax.persistence.Table; import javax.persistence.Transient; -import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentConfigurationEntity; /** * $Id$ @@ -24,7 +24,7 @@ @Entity @PrimaryKeyJoinColumn(name="experiment_configuration_id") @Table(name="forager_configuration") -public class ForagerConfiguration extends ExperimentConfiguration<ForagerExperimentParameters> { +public class ForagerConfiguration extends ExperimentConfigurationEntity<ForagerExperimentParameters> { private List<ForagerExperimentParameters> allParameters; Modified: trunk/gee/war/WEB-INF/classes/gee-admin.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-03-23 05:38:49 UTC (rev 167) +++ trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-03-23 06:43:54 UTC (rev 168) @@ -30,6 +30,7 @@ <result name="success" type="freemarker">listExperiments.jsp</result> </action> <action name="updateExperimentConfiguration" class="edu.indiana.psych.gee.action.UpdateExperimentConfiguration"> + <interceptor-ref name="prepareStack"/> <result name="success" type="freemarker">configureExperiment.jsp</result> </action> </package> Modified: trunk/gee/war/WEB-INF/classes/xwork.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/xwork.xml 2006-03-23 05:38:49 UTC (rev 167) +++ trunk/gee/war/WEB-INF/classes/xwork.xml 2006-03-23 06:43:54 UTC (rev 168) @@ -5,30 +5,35 @@ <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.1.dtd"> <xwork> <include file="webwork-default.xml"/> - <package name="default" extends="webwork-default"> <interceptors> - <interceptor-stack name="geeDefaultStack"> - <interceptor-ref name="exception"/> + <interceptor-stack name="prepareStack"> + <interceptor-ref name="params"/> + <interceptor-ref name="prepare"/> + <interceptor-ref name="exception"/> + <interceptor-ref name="servlet-config"/> + <interceptor-ref name="params"/> + </interceptor-stack> + <interceptor-stack name="geeDefaultStack"> + <interceptor-ref name="exception"/> <!-- <interceptor-ref name="alias"/> --> - <interceptor-ref name="servlet-config"/> - <interceptor-ref name="prepare"/> + <interceptor-ref name="servlet-config"/> + <interceptor-ref name="prepare"/> <!-- <interceptor-ref name="i18n"/> --> - <interceptor-ref name="chain"/> + <interceptor-ref name="chain"/> <!-- <interceptor-ref name="model-driven"/> --> <!-- <interceptor-ref name="fileUpload"/> --> - <interceptor-ref name="static-params"/> - <interceptor-ref name="params"/> - <interceptor-ref name="conversionError"/> - <interceptor-ref name="validation"> - <param name="excludeMethods">input,back,cancel</param> - </interceptor-ref> - <interceptor-ref name="workflow"> - <param name="excludeMethods">input,back,cancel</param> - </interceptor-ref> - </interceptor-stack> - </interceptors> - +<!-- <interceptor-ref name="static-params"/> --> + <interceptor-ref name="params"/> + <interceptor-ref name="conversionError"/> + <interceptor-ref name="validation"> + <param name="excludeMethods">input,back,cancel</param> + </interceptor-ref> + <interceptor-ref name="workflow"> + <param name="excludeMethods">input,back,cancel</param> + </interceptor-ref> + </interceptor-stack> + </interceptors> <default-interceptor-ref name="geeDefaultStack"/> <!-- the start page lists all available experiments --> <action name="index" class="edu.indiana.psych.gee.action.ListExperiments"> @@ -45,8 +50,6 @@ <result name="input">consent.jsp</result> </action> </package> - <include file="gee-ajax.xml"/> <include file="gee-admin.xml"/> - </xwork> Modified: trunk/gee/war/WEB-INF/hibernate.cfg.xml =================================================================== --- trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-03-23 05:38:49 UTC (rev 167) +++ trunk/gee/war/WEB-INF/hibernate.cfg.xml 2006-03-23 06:43:54 UTC (rev 168) @@ -9,7 +9,7 @@ <session-factory> <mapping package="edu.indiana.psych.gee"/> <mapping class="edu.indiana.psych.gee.ConsentForm"/> - <mapping class="edu.indiana.psych.gee.ExperimentConfiguration"/> + <mapping class="edu.indiana.psych.gee.ExperimentConfigurationEntity"/> <mapping package="edu.indiana.psych.gee.forager"/> <mapping class="edu.indiana.psych.gee.forager.ForagerAgentConfiguration"/> <mapping class="edu.indiana.psych.gee.forager.ForagerConfiguration"/> Modified: trunk/gee/war/WEB-INF/sitemesh.xml =================================================================== --- trunk/gee/war/WEB-INF/sitemesh.xml 2006-03-23 05:38:49 UTC (rev 167) +++ trunk/gee/war/WEB-INF/sitemesh.xml 2006-03-23 06:43:54 UTC (rev 168) @@ -3,21 +3,15 @@ vim:sts=2:sw=2: --> <sitemesh> - <property name="decorators.file" value="/WEB-INF/decorators.xml" /> - <excludes file="${decorators.file}" /> - - <page-parsers> - <parser content-type="text/html" - class="com.opensymphony.module.sitemesh.parser.FastPageParser" /> - <parser content-type="text/html;charset=ISO-8859-1" - class="com.opensymphony.module.sitemesh.parser.FastPageParser" /> - </page-parsers> - - <decorator-mappers> - <mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper"> - <param name="config" value="${decorators.file}" /> - </mapper> - </decorator-mappers> + <property name="decorators.file" value="/WEB-INF/decorators.xml"/> + <excludes file="${decorators.file}"/> + <page-parsers> + <parser content-type="text/html" class="com.opensymphony.module.sitemesh.parser.FastPageParser"/> + <parser content-type="text/html;charset=ISO-8859-1" class="com.opensymphony.module.sitemesh.parser.FastPageParser"/> + </page-parsers> + <decorator-mappers> + <mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper"> + <param name="config" value="${decorators.file}"/> + </mapper> + </decorator-mappers> </sitemesh> - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |