[gee-svn] SF.net SVN: gabel: [156] trunk/gee/war/WEB-INF/classes
Status: Alpha
Brought to you by:
alllee
|
From: <al...@us...> - 2006-03-09 06:16:03
|
Revision: 156 Author: alllee Date: 2006-03-08 22:15:53 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=156&view=rev Log Message: ----------- adding services and DAOs for consent forms and experiment configuration, minor hygiene on ExperimentConfigurationEntity. 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/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/war/WEB-INF/classes/log4j.properties Added 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/ExperimentConfigurationService.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-09 05:27:32 UTC (rev 155) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-03-09 06:15:53 UTC (rev 156) @@ -52,7 +52,7 @@ } if ( isRunning() ) { throw new UnsupportedOperationException("AbstractExperiment does " + - "not support hot-reconfiguration yet"); + "not support reconfiguration while running yet"); } this.configuration = configuration; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-09 05:27:32 UTC (rev 155) +++ trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-03-09 06:15:53 UTC (rev 156) @@ -24,7 +24,8 @@ @Table(name="consent_form") public class ConsentForm { - private int id = -1; + // are longs overkill? + private Long id = Long.valueOf(-1); private String description; private String deception; @@ -38,10 +39,10 @@ private Date irbDateApproved; @Id @GeneratedValue - public int getId() { + public Long getId() { return id; } - public void setId(int id) { + public void setId(Long id) { this.id = id; } public String getBenefits() { Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-09 05:27:32 UTC (rev 155) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfigurationEntity.java 2006-03-09 06:15:53 UTC (rev 156) @@ -19,8 +19,11 @@ /** * $Id$ * - * Helps specific ExperimentConfiguration-S read in their configuration data - * from a variety of sources. + * 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 @@ -37,7 +40,7 @@ private final static String DEFAULT_SERVER_ADDRESS = "groups.psych.indiana.edu"; // persistent fields - private long id = -1; + private Long id = Long.valueOf(-1); private String description; private String experimentName; private String clientJarName; @@ -46,17 +49,21 @@ private int serverPort; private String serverName; private boolean triggeredExperiment; - // transient fields + // transient fields (vaguely remember reading somewhere that it's better + // to place these on the accessor methods instead, figure out if this is + // the case) + @Transient private InetSocketAddress serverAddress; + @Transient private T currentParameters; - private @Transient Iterator<T> parametersIterator; + @Transient + private Iterator<T> parametersIterator; public ExperimentConfigurationEntity(String serverName, int port) { setServerName(serverName); setServerPort(port); } - @Transient public synchronized InetSocketAddress getServerAddress() { // FIXME: return configuration address instead? if (serverAddress == null) { @@ -75,11 +82,11 @@ } @Id @GeneratedValue - public long getId() { + public Long getId() { return id; } - public void setId(long id) { + public void setId(Long id) { this.id = id; } @@ -108,8 +115,7 @@ this.triggeredExperiment = triggeredExperiment; } - @ManyToOne(targetEntity=ConsentForm.class) - @JoinColumn(name="consent_id") + @ManyToOne public ConsentForm getConsentForm() { return consentForm; } @@ -125,7 +131,6 @@ currentParameters = parametersIterator.next(); } - @Transient public synchronized T getCurrentParameters() { List<T> allParameters = getAllParameters(); if (currentParameters == null) { 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-09 05:27:32 UTC (rev 155) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-03-09 06:15:53 UTC (rev 156) @@ -64,6 +64,8 @@ private boolean roundRunning; + // FIXME: instead, need to find configurations from + // ExperimentConfigurationDao, yes? public ForagerExperiment(ForagerConfiguration configuration) { addEventProcessors(); getLogger().debug("Creating a new ForagerExperiment with configuration: " + configuration); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-09 05:27:32 UTC (rev 155) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-03-09 06:15:53 UTC (rev 156) @@ -23,7 +23,7 @@ private ForagerAgentConfiguration agentConfiguration; private ForagerConfiguration configuration; - private long id = -1; + private Long id = Long.valueOf(-1L); private String name; private int foodSpoilDuration; private double foodRate; @@ -37,11 +37,11 @@ private String specialInstructions; @Id @GeneratedValue - public long getId() { + public Long getId() { return id; } - public void setId(long id) { + public void setId(Long id) { this.id = id; } Added: trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java 2006-03-09 06:15:53 UTC (rev 156) @@ -0,0 +1,27 @@ +package edu.indiana.psych.gee.service; + +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + +import edu.indiana.psych.gee.ConsentForm; + +/** + * $Id: Exp $ + * + * Hibernate data access object for consent forms. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision: $ + */ + +public class ConsentFormDao extends HibernateDaoSupport { + + + public ConsentForm find(Integer id) { + return (ConsentForm) getHibernateTemplate().get(ConsentForm.class, id); + } + + public void update(ConsentForm consentForm) { + getHibernateTemplate().saveOrUpdate(consentForm); + } + +} Added: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java 2006-03-09 06:15:53 UTC (rev 156) @@ -0,0 +1,28 @@ +package edu.indiana.psych.gee.service; + +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + +import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentConfigurationEntity; + +/** + * $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 ExperimentConfigurationDao extends HibernateDaoSupport { + + public <E extends ExperimentConfigurationEntity> E find(Class<E> configurationClass, Integer id) { + return configurationClass.cast(getHibernateTemplate().get(configurationClass, id)); + } + + public void update(ExperimentConfiguration configuration) { + getHibernateTemplate().saveOrUpdate(configuration); + } + +} Added: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-03-09 06:15:53 UTC (rev 156) @@ -0,0 +1,41 @@ +package edu.indiana.psych.gee.service; + +import java.io.InputStream; + +import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentConfigurationEntity; + +/** + * $Id: Exp $ + * + * Handles requests for manipulating experiment configurations, this includes + * database and flat file persistence, uploading new experiment + * configurations, and other editing, etc. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision: $ + */ + +public class ExperimentConfigurationService { + + private ExperimentConfigurationDao experimentConfigurationDao; + + public <E extends ExperimentConfiguration> E load(Class<E> configurationClass, InputStream stream) { + + return null; + } + + public <E extends ExperimentConfigurationEntity> E find(Class<E> configurationClass, Integer id) { + return experimentConfigurationDao.find(configurationClass, id); + } + + + public void update(ExperimentConfiguration configuration) { + experimentConfigurationDao.update(configuration); + } + + public void setExperimentConfigurationDao(ExperimentConfigurationDao experimentConfigurationDao) { + this.experimentConfigurationDao = experimentConfigurationDao; + } + +} Modified: trunk/gee/war/WEB-INF/classes/log4j.properties =================================================================== --- trunk/gee/war/WEB-INF/classes/log4j.properties 2006-03-09 05:27:32 UTC (rev 155) +++ trunk/gee/war/WEB-INF/classes/log4j.properties 2006-03-09 06:15:53 UTC (rev 156) @@ -7,6 +7,9 @@ # Spring Stuff log4j.logger.org.springframework=INFO +# turn off introspection crap from freemarker beans +log4j.logger.freemarker.beans=WARN + # commons digester crap log4j.logger.org.apache.commons.digester=ERROR log4j.logger.org.hibernate=DEBUG This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |