gee-svn Mailing List for Group Experiments Environment
Status: Alpha
Brought to you by:
alllee
You can subscribe to this list here.
2006 |
Jan
|
Feb
(14) |
Mar
(47) |
Apr
(4) |
May
(14) |
Jun
(10) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
---|
From: <zr...@us...> - 2006-12-14 22:21:24
|
Revision: 199 http://svn.sourceforge.net/gabel/?rev=199&view=rev Author: zrilak Date: 2006-12-14 14:21:24 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Removed Paths: ------------- gabel/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zr...@us...> - 2006-12-14 22:00:14
|
Revision: 198 http://svn.sourceforge.net/gabel/?rev=198&view=rev Author: zrilak Date: 2006-12-14 14:00:13 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Added Paths: ----------- gabel/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-06-20 23:53:44
|
Revision: 197 Author: alllee Date: 2006-06-20 16:53:41 -0700 (Tue, 20 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=197&view=rev Log Message: ----------- adding a measly test & referencing jakarta commons BeanUtils within the eclipse .classpath Modified Paths: -------------- trunk/gee/.classpath Added Paths: ----------- trunk/gee/src/test/edu/indiana/psych/gee/event/ trunk/gee/src/test/edu/indiana/psych/gee/event/EventChannelTester.java Modified: trunk/gee/.classpath =================================================================== --- trunk/gee/.classpath 2006-06-20 06:44:52 UTC (rev 196) +++ trunk/gee/.classpath 2006-06-20 23:53:41 UTC (rev 197) @@ -16,5 +16,6 @@ <classpathentry kind="lib" path="war/WEB-INF/lib/hibernate-annotations.jar"/> <classpathentry kind="lib" path="war/WEB-INF/lib/spring.jar"/> <classpathentry kind="lib" path="war/WEB-INF/lib/spring-hibernate3.jar"/> + <classpathentry kind="lib" path="war/WEB-INF/lib/commons-beanutils-core.jar"/> <classpathentry kind="output" path="build"/> </classpath> Added: trunk/gee/src/test/edu/indiana/psych/gee/event/EventChannelTester.java =================================================================== --- trunk/gee/src/test/edu/indiana/psych/gee/event/EventChannelTester.java (rev 0) +++ trunk/gee/src/test/edu/indiana/psych/gee/event/EventChannelTester.java 2006-06-20 23:53:41 UTC (rev 197) @@ -0,0 +1,56 @@ +package edu.indiana.psych.gee.event; + +import edu.indiana.psych.gee.agent.AgentIdentifier; +import junit.framework.TestCase; + +/** + * $Id$ + * + * Exercises the event channel. + * + * @author <a href='ano...@gm...'>Allen Lee</a> + * @version $Revision$ + */ + +public class EventChannelTester extends TestCase { + + private EventChannel channel; + private Event event; + private final Object notifier = new Object(); + + public void setUp() { + channel = new EventChannel(); + } + + public void testEventProcessors() { + channel.add(new EventTypeProcessor<BeginExperimentRequest>(BeginExperimentRequest.class) { + public void handle(BeginExperimentRequest event) { + synchronized (notifier) { + setEvent(event); + notifier.notifyAll(); + } + } + }); + synchronized (notifier) { + channel.handle(new BeginExperimentRequest(new AgentIdentifier())); + try { + notifier.wait(); + } + catch (InterruptedException e) {} + assertNotNull(event); + } + } + + private void setEvent(Event event) { + this.event = event; + } + + public void testSingleton() { + assertEquals(EventChannel.getInstance(), EventChannel.getInstance()); + assertFalse(EventChannel.getInstance().equals(new EventChannel())); + assertFalse(EventChannel.getInstance().equals(channel)); + assertFalse(channel.equals(new EventChannel())); + assertEquals(EventChannel.getInstance(), EventChannel.getInstance()); + } + +} Property changes on: trunk/gee/src/test/edu/indiana/psych/gee/event/EventChannelTester.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-06-20 06:45:02
|
Revision: 196 Author: alllee Date: 2006-06-19 23:44:52 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=196&view=rev Log Message: ----------- adding default forager consent form bean to application context. 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/bean/ConsentForm.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java trunk/gee/war/WEB-INF/applicationContext.xml trunk/gee/war/WEB-INF/classes/webwork.properties trunk/gee/war/WEB-INF/classes/xwork.xml trunk/gee/war/consent.jsp trunk/gee/war/index.jsp Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.properties Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-06-20 06:44:52 UTC (rev 196) @@ -8,6 +8,7 @@ import edu.indiana.psych.gee.event.EventChannel; import edu.indiana.psych.gee.net.DispatcherFactory; import edu.indiana.psych.gee.net.ServerDispatcher; +import edu.indiana.psych.gee.service.ConsentFormService; import edu.indiana.psych.gee.service.ExperimentConfigurationService; import edu.indiana.psych.gee.service.ExperimentService; import edu.indiana.psych.gee.time.Duration; @@ -33,6 +34,7 @@ private ExperimentService experimentService; private ExperimentConfigurationService configurationService; + private ConsentFormService consentFormService; private C configuration; // private ExperimentRoundParameters currentParameters; @@ -134,8 +136,8 @@ } public String toString() { - return String.format("[ %s ] experiment [ %s ] running on port %d", - super.toString(), getName(), getServerPort()); + return String.format("[ %s ] experiment [ %s:%s ] running on port %d", + super.toString(), getName(), getIdentifier(), getServerPort()); } @@ -215,6 +217,10 @@ this.configurationService = configurationService; } + public void setConsentFormService(ConsentFormService consentFormService) { + this.consentFormService = consentFormService; + } + public void setDefaultConfiguration(C defaultConfiguration) { if (defaultConfiguration == null) { throw new IllegalArgumentException("Cannot set default configuration to null."); @@ -222,11 +228,17 @@ ExperimentConfiguration configuration = configurationService.find(defaultConfiguration.getClass(), defaultConfiguration.getExperimentIdentifier()); if (configuration == null) { this.defaultConfiguration = defaultConfiguration; + consentFormService.persist(defaultConfiguration.getConsentForm()); configurationService.persist(defaultConfiguration); } else { this.defaultConfiguration = (C) configuration; } + if (configuration == null) { + configuration = defaultConfiguration; + } + + } Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-06-20 06:44:52 UTC (rev 196) @@ -24,6 +24,11 @@ // no consent form available for this experiment.. just start? getLogger().warn("XXX: No consent form available for this experiment: " + getExperiment()); } + getLogger().warn("XXX: configuration: " + getExperiment().getConfiguration()); + getLogger().warn("XXX: configuration's consent: " + getExperiment().getConfiguration().getConsentForm()); + getLogger().warn("XXX: consent form: " + consentForm); + getLogger().warn("XXX: consent form date approved: " + consentForm.getIrbDateApproved()); + getLogger().warn("XXX: consent form date expires: " + consentForm.getIrbDateApprovalExpires()); return INPUT; } @@ -45,10 +50,14 @@ return consentForm; } - public void setExperimentIdentifier(String experimentName) { - this.experimentIdentifier = experimentName; + public String getExperimentIdentifier() { + return experimentIdentifier; } + public void setExperimentIdentifier(String experimentIdentifier) { + this.experimentIdentifier = experimentIdentifier; + } + public Participant getParticipant() { return participant; } Deleted: trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.properties =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.properties 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.properties 2006-06-20 06:44:52 UTC (rev 196) @@ -1,2 +0,0 @@ -approval.date = Approval Date: {0, date, MMMMMMMMM dd, yyyy} -approval.expiration.date = Expires: {0, date, MMMMMMMMM dd, yyyy} Modified: trunk/gee/src/java/edu/indiana/psych/gee/bean/ConsentForm.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/ConsentForm.java 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/ConsentForm.java 2006-06-20 06:44:52 UTC (rev 196) @@ -91,11 +91,6 @@ } @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; } @@ -103,17 +98,6 @@ 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; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-06-20 06:44:52 UTC (rev 196) @@ -1,6 +1,8 @@ package edu.indiana.psych.gee.forager; import java.awt.Dimension; +import java.io.IOException; +import java.io.InputStream; import java.util.Collections; import java.util.List; import java.util.Properties; Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-06-20 06:44:52 UTC (rev 196) @@ -21,7 +21,6 @@ public class ExperimentConfigurationService { private ExperimentConfigurationDao experimentConfigurationDao; -// private ConsentFormDao consentFormDao; public <E extends ExperimentConfiguration> List<E> findAll(Class<E> configurationClass) { @@ -62,8 +61,4 @@ this.experimentConfigurationDao = experimentConfigurationDao; } -// public void setConsentFormDao(ConsentFormDao consentFormDao) { -// this.consentFormDao = consentFormDao; -// } - } Modified: trunk/gee/war/WEB-INF/applicationContext.xml =================================================================== --- trunk/gee/war/WEB-INF/applicationContext.xml 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/war/WEB-INF/applicationContext.xml 2006-06-20 06:44:52 UTC (rev 196) @@ -35,7 +35,6 @@ <property name="password" value="${db.password}"/> </bean> - <!-- hibernate beans, session factory and transaction manager --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="/WEB-INF/hibernate.cfg.xml"/> @@ -60,6 +59,9 @@ <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- application layer beans --> + <bean id="consentFormService" class="edu.indiana.psych.gee.service.ConsentFormService"> + <property name='consentFormDao' ref='consentFormDao'/> + </bean> <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"/> @@ -72,6 +74,7 @@ <property name="description" value="The Forager web experiment explores how individuals allocate themselves in a world with scarce resources via an always-available applet."/> <property name='clientJarName' value='forager-client.jar'/> <property name='clientMainClass' value='edu.indiana.psych.gee.forager.client.ForagerApplet'/> + <property name='consentForm' ref='foragerConsentForm'/> </bean> <bean id="defaultForagerExperimentConfiguration" class="edu.indiana.psych.gee.forager.ForagerConfiguration"> <constructor-arg value="groups.psych.indiana.edu"/> @@ -82,15 +85,65 @@ <property name='clientJarName' value='forager-client.jar'/> <property name='clientMainClass' value='edu.indiana.psych.gee.forager.client.ForagerApplet'/> <property name='triggeredExperiment' value='true'/> + <property name='consentForm' ref='foragerConsentForm'/> </bean> <bean id="forager-web" class="edu.indiana.psych.gee.forager.ForagerExperiment"> <property name="configurationService" ref='configurationService'/> + <property name="consentFormService" ref='consentFormService'/> <property name="defaultConfiguration" ref="defaultForagerWebConfiguration"/> <property name="experimentService" ref="experimentService"/> </bean> <bean id="forager-experiment" class="edu.indiana.psych.gee.forager.ForagerExperiment"> <property name="configurationService" ref='configurationService'/> + <property name="consentFormService" ref='consentFormService'/> <property name="defaultConfiguration" ref="defaultForagerExperimentConfiguration"/> <property name="experimentService" ref="experimentService"/> </bean> + <bean id='foragerConsentForm' class='edu.indiana.psych.gee.bean.ConsentForm'> + <property name='studyNumber' value='#04-9064'/> + <property name='description' value='You are invited to participate in a + research study, entitled Group Behavior. The purpose of the study is to + investigate how people think, act, and make decisions in groups. You will + be given a full debriefing at the end of the experiment. Each of the + experiments will take 5-10 minutes to complete. The particular + instructions for an experiment will be displayed on the computer screen. + During the experiment, you will be interacting with a group of humans or + artificial intelligence agents. You will see the choices they make, and + they will see your choices.'/> + <property name='deception' value='No deception is used in this study.'/> + <property name='confidentiality' value='The information in the study + records will be kept confidential. Data will be made available only to + persons conducting the study. No reference will be made in verbal or + written form which could link your name to the study. Your name is not + recorded with your data.'/> + <property name='compensation' value='There is no monetary compensation for + participating in this study.'/> + <property name='risks' value='There are no anticipated risks associated + with the experiments.'/> + <property name='benefits' value='Society benefits from this research + because an understanding of how groups behave can help us to predict the + behaviors of complex organizations and develop technologies that promote + the efficient and accurate flow of information within groups. You benefit + from this experience because you learn something about how group + psychology experiments are designed and conducted, what issues are of + interest to cognitive scientists, and what kinds of group behaviors emerge + when individuals try to reach their goals in an environment that consists + largely of other individuals. In addition, many people find the + experiments to be fun and intriguing. At the end of the experiment, you + will be shown your own performance compared to the average performance of + others in your group, a debriefing that describes what the experiment was + about, and links to related research.'/> + <property name='participation' value='Your participation in this study is + purely voluntary. You may decline to participate. If you decide to + participate, you may withdraw from the study at any time without penalty + or loss of benefits. If you withdraw from the study prior to the + completion of your session your data will not be saved.'/> + <property name='irbDateApproved' ref='consentFormDate'/> + </bean> + <bean id='consentFormDate' factory-bean='dateFormatter' factory-method='parse'> + <constructor-arg><value>10/26/2005</value></constructor-arg> + </bean> + <bean id="dateFormatter" class="java.text.SimpleDateFormat"> + <constructor-arg><value>MM/dd/yyyy</value></constructor-arg> + </bean> </beans> Modified: trunk/gee/war/WEB-INF/classes/webwork.properties =================================================================== --- trunk/gee/war/WEB-INF/classes/webwork.properties 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/war/WEB-INF/classes/webwork.properties 2006-06-20 06:44:52 UTC (rev 196) @@ -1,3 +1,4 @@ webwork.objectFactory=spring webwork.devMode=true webwork.ui.theme=ajax +webwork.custom.i18n.resources=format.properties Modified: trunk/gee/war/WEB-INF/classes/xwork.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/xwork.xml 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/war/WEB-INF/classes/xwork.xml 2006-06-20 06:44:52 UTC (rev 196) @@ -51,5 +51,4 @@ </package> <include file="gee-ajax.xml"/> <include file="gee-admin.xml"/> - <include file="gee-csan.xml"/> </xwork> Modified: trunk/gee/war/consent.jsp =================================================================== --- trunk/gee/war/consent.jsp 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/war/consent.jsp 2006-06-20 06:44:52 UTC (rev 196) @@ -1,5 +1,5 @@ <head> -<title> Consent Form for ${experimentName}</title> +<title>Consent Form for ${experimentIdentifier}</title> <#assign commitDate="$Date$"> <#assign lastModified=commitDate?word_list[1]> <meta name="lastModifiedDate" content="${commitDate}"/> @@ -8,7 +8,7 @@ <TABLE BGCOLOR="#A4B5C5" CELLPADDING="4" CELLSPACING="0" WIDTH="100%" BORDER="0"> <TR> <TD WIDTH="100%"> - <H3>${experimentName} consent form</H3> + <H3>${experimentIdentifier} consent form</H3> </TD> <TD ALIGN="right" VALIGN="top" BGCOLOR="#A4B5C5" WIDTH="70%" style="white-space: nowrap;"> <b>Study #04-9064</b><br/> @@ -20,7 +20,7 @@ <TABLE CELLPADDING="4" CELLSPACING="2" BORDER="0"> <TR> <TD> - <B>${experimentName}</B><BR> + <B>${experimentIdentifier}</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> @@ -64,6 +64,9 @@ <B>Contact</B><BR> + <#if consentForm.contact?exists> + ${consentForm.contact} + <#else> <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> @@ -104,6 +107,7 @@ </TD></TR> </TABLE> </TD></TR></TABLE> + </#if> <P> <B>Participation</B><BR> @@ -129,19 +133,23 @@ <@ww.select label="Age" name="participant.age" required="true" list=["Under 18", "18-24", "25-36", "37-55", "Over 55"]/> <@ww.textfield label="Name" name="participant.name" required="true" /> - <@ww.hidden name="experimentName"/> + <@ww.hidden name="experimentIdentifier"/> <@ww.submit/> </@ww.form> <hr /> <small> -IRB Approved -<br/> -<@ww.text name="approval.date"> - <@ww.param value="'consentForm.irbDateApproved'"/> -</@ww.text> -<br/> -<@ww.text name="approval.expiration.date"> - <@ww.param value="'consentForm.irbDateApprovalExpires'"/> -</@ww.text> +<table border=1 cellspacing=1 cellpadding=4 style='border-style:outset;'> +<thead> +<th style='border-style:none;'>IRB Approved</td><td style='border-style:none;'> </td> +</thead> +<tr> +<td style='border-style:none;'>Approval Date:</td> +<td style='border-style:none;'>${consentForm.irbDateApproved?date}</td> +</tr> +<tr> +<td style='border-style:none;'>Expires:</td> +<td style='border-style:none;'>${consentForm.irbDateApprovalExpires?date}</td> +</tr> +</table> </small> Modified: trunk/gee/war/index.jsp =================================================================== --- trunk/gee/war/index.jsp 2006-06-19 21:52:04 UTC (rev 195) +++ trunk/gee/war/index.jsp 2006-06-20 06:44:52 UTC (rev 196) @@ -76,10 +76,10 @@ <!-- emit developers dynamically? --> <UL> <LI><A HREF="http://cognitrn.psych.indiana.edu/rgoldsto/rob.html">Rob Goldstone - Director</A> - <LI>Andy Jones - Developer / Researcher - <LI><a href="http://www.cs.indiana.edu/~alllee">Allen Lee - Lead Programmer / "Researcher"</a> - <LI>Zoran Rilak - Developer / Researcher - <LI>Michael Roberts - Developer / Researcher + <LI>Andy Jones + <LI><a href="http://www.cs.indiana.edu/~alllee">Allen Lee</a> + <LI>Zoran Rilak + <LI>Michael Roberts </UL> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-06-19 21:52:08
|
Revision: 195 Author: alllee Date: 2006-06-19 14:52:04 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=195&view=rev Log Message: ----------- new logo without the clock Modified Paths: -------------- trunk/gee/war/images/forager-v2/forager-logo.gif Modified: trunk/gee/war/images/forager-v2/forager-logo.gif =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-06-19 21:44:27
|
Revision: 194 Author: alllee Date: 2006-06-19 14:44:19 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=194&view=rev Log Message: ----------- time left label gif Added Paths: ----------- trunk/gee/war/images/forager-v2/time-left-label.gif Added: trunk/gee/war/images/forager-v2/time-left-label.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/time-left-label.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-06-19 18:58:25
|
Revision: 193 Author: alllee Date: 2006-06-19 11:58:20 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=193&view=rev Log Message: ----------- food eaten logo to go on the sidebar Added Paths: ----------- trunk/gee/war/images/forager-v2/food-eaten-logo.gif Added: trunk/gee/war/images/forager-v2/food-eaten-logo.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/food-eaten-logo.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-06-19 18:16:21
|
Revision: 192 Author: alllee Date: 2006-06-19 11:16:15 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=192&view=rev Log Message: ----------- adding forager logo Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java Added Paths: ----------- trunk/gee/war/images/forager-v2/forager-logo.gif Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-06-18 23:55:29 UTC (rev 191) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-06-19 18:16:15 UTC (rev 192) @@ -478,6 +478,8 @@ new ClassPathXmlApplicationContext("applicationContext.xml"); ForagerExperiment experiment = (ForagerExperiment) appContext.getBean("forager-web"); + ForagerConfiguration configuration = experiment.getConfiguration(); + // FIXME: hack for now.. experiment.start(); } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-06-18 23:55:29 UTC (rev 191) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-06-19 18:16:15 UTC (rev 192) @@ -13,6 +13,9 @@ import javax.persistence.Table; import javax.persistence.Transient; +import org.apache.commons.beanutils.BeanUtils; +import org.springframework.core.io.ClassPathResource; + import edu.indiana.psych.gee.ExperimentRoundParameters; import edu.indiana.psych.gee.time.Duration; @@ -36,6 +39,29 @@ private int maximumSeparation; private String specialInstructions; + public static ForagerExperimentParameters load(String resource) { + try { + return load(new ClassPathResource(resource).getInputStream()); + } + catch (IOException e) { + e.printStackTrace(); + return null; + } + } + public static ForagerExperimentParameters load(InputStream stream) { + ForagerExperimentParameters parameters = new ForagerExperimentParameters(); + Properties properties = new Properties(); + try { + properties.load(stream); + BeanUtils.populate(parameters, properties); + } + catch (Exception e) { + e.printStackTrace(); + return null; + } + return parameters; + } + @Id @GeneratedValue public Long getId() { return id; @@ -55,7 +81,6 @@ this.configuration = configuration; } - public int getMinimumParticipantsForNoBots() { return minimumParticipantsForNoBots; } @@ -83,7 +108,6 @@ @Transient public Dimension getBoardSize() { - // TODO Auto-generated method stub return new Dimension(getBoardWidth(), getBoardHeight()); } @@ -95,6 +119,7 @@ return participantsRequiredForSave; } + // FIXME: figure out how to map Visibility to a table..? @Transient public Visibility getSubjectVisibility() { return Visibility.FULL; Added: trunk/gee/war/images/forager-v2/forager-logo.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/forager-logo.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-06-18 23:55:34
|
Revision: 191 Author: alllee Date: 2006-06-18 16:55:29 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=191&view=rev Log Message: ----------- adding jakarta commons pooling and beanutils dependencies. Modified Paths: -------------- trunk/gee/build.xml trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java Added Paths: ----------- trunk/gee/war/WEB-INF/lib/commons-beanutils-core.jar trunk/gee/war/WEB-INF/lib/commons-pool.jar Modified: trunk/gee/build.xml =================================================================== --- trunk/gee/build.xml 2006-06-18 22:56:07 UTC (rev 190) +++ trunk/gee/build.xml 2006-06-18 23:55:29 UTC (rev 191) @@ -39,6 +39,7 @@ <fileset dir="${web.lib.dir}"> <include name="**/*.jar" /> </fileset> + <pathelement location='${war.dir}'/> <pathelement location="${build.classes.dir}" /> <pathelement location="${test.build.dir}"/> </path> @@ -68,8 +69,16 @@ </fileset> </copy> <copy file='${web.inf}/classes/log4j.properties' todir='${build.classes.dir}' /> + <copy file='${web.inf}/applicationContext.xml' todir='${build.classes.dir}'/> </target> + <target name='forager-server' depends='compile'> + <java classname='edu.indiana.psych.gee.forager.ForagerExperiment' + classpathref='build.classpath' + fork='yes' /> + </target> + + <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="build.classpath"/> <target name="init-db" depends="compile"> <mkdir dir='${generated.dir}'/> Modified: trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java 2006-06-18 22:56:07 UTC (rev 190) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java 2006-06-18 23:55:29 UTC (rev 191) @@ -124,6 +124,7 @@ } // advances the parameters iterator or resets it. + @Transient public void updateCurrentParameters() { if (parametersIterator == null || ! parametersIterator.hasNext()) { parametersIterator = getAllParameters().iterator(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-06-18 22:56:07 UTC (rev 190) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-06-18 23:55:29 UTC (rev 191) @@ -31,8 +31,7 @@ private List<ForagerExperimentParameters> allParameters; - public ForagerConfiguration() { - } + public ForagerConfiguration() { } public ForagerConfiguration(String serverName, int port) { super(serverName, port); Added: trunk/gee/war/WEB-INF/lib/commons-beanutils-core.jar =================================================================== (Binary files differ) Property changes on: trunk/gee/war/WEB-INF/lib/commons-beanutils-core.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/WEB-INF/lib/commons-pool.jar =================================================================== (Binary files differ) Property changes on: trunk/gee/war/WEB-INF/lib/commons-pool.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream 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:56:12
|
Revision: 190 Author: alllee Date: 2006-06-18 15:56:07 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=190&view=rev Log Message: ----------- minor javadoc hygiene + rudimentary main method for ForagerExperiment. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/event/BeginExperimentRequest.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/GridView.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/BeginExperimentRequest.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/BeginExperimentRequest.java 2006-06-18 22:51:45 UTC (rev 189) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/BeginExperimentRequest.java 2006-06-18 22:56:07 UTC (rev 190) @@ -7,8 +7,8 @@ /** * $Id$ * - * Used by the facilitator to signal the ForagerServer that we are done - * collecting clients and ready to start the next experiment. + * Used by the facilitator to signal that we are done collecting clients and + * ready to start the next experiment. * * * @author Allen Lee Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-06-18 22:51:45 UTC (rev 189) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-06-18 22:56:07 UTC (rev 190) @@ -10,6 +10,8 @@ import java.util.Set; import java.util.SortedSet; +import org.springframework.context.support.ClassPathXmlApplicationContext; + import edu.indiana.psych.gee.AbstractExperiment; import edu.indiana.psych.gee.Identifier; import edu.indiana.psych.gee.agent.Agent; @@ -26,7 +28,6 @@ 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; @@ -313,7 +314,7 @@ currentRoundDuration = parameters.getRoundDuration().start(); foragerGameState = new ForagerServerGameState(getEventChannel(), parameters); // foragerGameState.setBoardSize(currentExperimentConfiguration); - persister = new ForagerPersister(parameters); + persister = new ForagerPersister(getEventChannel(), parameters); // loop through once and populate the ForagerGameState so that each // and every participant has an initial starting position. for (Identifier id: currentParticipantHeadings.keySet()) { @@ -472,4 +473,12 @@ persister.clear(); } + public static void main(String[] args) { + ClassPathXmlApplicationContext appContext = + new ClassPathXmlApplicationContext("applicationContext.xml"); + ForagerExperiment experiment = + (ForagerExperiment) appContext.getBean("forager-web"); + experiment.start(); + } + } 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 22:51:45 UTC (rev 189) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/GridView.java 2006-06-18 22:56:07 UTC (rev 190) @@ -71,7 +71,6 @@ // XXX: images still aren't fully loaded. When you actually invoke // drawImage on these images, make sure to pass this in so that when the // 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-v2/") }); foodImage1 = toolkit.getImage(imageLoader.findResource("grass-1.gif")); 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. |
From: <al...@us...> - 2006-06-18 18:34:54
|
Revision: 188 Author: alllee Date: 2006-06-18 11:34:40 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=188&view=rev Log Message: ----------- * adding new forager images * NioDispatcher's connect() now blocks until it receives an Identifier from the server it's connecting to. * some more refactoring. Modified Paths: -------------- trunk/gee/lib/junit.jar 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/Event.java trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.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/forager/DebriefingAssistant.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.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/event/ClientUpdateEvent.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/Worker.java trunk/gee/src/java/edu/indiana/psych/gee/net/WorkerPool.java trunk/gee/war/WEB-INF/classes/xwork.xml trunk/gee/war/index.jsp Added Paths: ----------- trunk/gee/src/test/edu/indiana/psych/gee/net/NioDispatcherTester.java trunk/gee/war/WEB-INF/lib/dwr.jar trunk/gee/war/images/forager-v2/ trunk/gee/war/images/forager-v2/bot-back.gif trunk/gee/war/images/forager-v2/bot-front.gif trunk/gee/war/images/forager-v2/bot-side-left.gif trunk/gee/war/images/forager-v2/bot-side-right.gif trunk/gee/war/images/forager-v2/grass-1.gif trunk/gee/war/images/forager-v2/grass-2.gif trunk/gee/war/images/forager-v2/grass-3.gif trunk/gee/war/images/forager-v2/grass-4.gif trunk/gee/war/images/forager-v2/others-back.gif trunk/gee/war/images/forager-v2/others-front.gif trunk/gee/war/images/forager-v2/others-side-left.gif trunk/gee/war/images/forager-v2/others-side-right.gif trunk/gee/war/images/forager-v2/you-back.gif trunk/gee/war/images/forager-v2/you-front.gif trunk/gee/war/images/forager-v2/you-side-left.gif trunk/gee/war/images/forager-v2/you-side-right.gif Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/net/event/ServerAssignedIdentifierEvent.java trunk/gee/src/test/edu/indiana/psych/gee/net/SocketIdentifierTester.java Modified: trunk/gee/lib/junit.jar =================================================================== (Binary files differ) Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractEvent.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractEvent.java 2006-06-18 18:34:40 UTC (rev 188) @@ -43,7 +43,7 @@ /** * Returns the event's identifier */ - public Identifier id() { + public Identifier getId() { return id; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractPersistableEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractPersistableEvent.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/AbstractPersistableEvent.java 2006-06-18 18:34:40 UTC (rev 188) @@ -42,7 +42,6 @@ // ordinal to help impose a total ordering across all persistable events. int comparison = compare(getCreationTime(), e.getCreationTime()); if (comparison == 0) { - // this may cause problems with overflow if that should ever happen. return compare(ordinal, e.ordinal); } return comparison; Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/Event.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/Event.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/Event.java 2006-06-18 18:34:40 UTC (rev 188) @@ -15,7 +15,7 @@ */ public interface Event extends Serializable { - public Identifier id(); + public Identifier getId(); // FIXME: use TimePoints instead. public long getCreationTime(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventChannel.java 2006-06-18 18:34:40 UTC (rev 188) @@ -1,6 +1,7 @@ package edu.indiana.psych.gee.event; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -17,21 +18,17 @@ private final static EventChannel INSTANCE = new EventChannel(); - /** - * EventDispatcher helper class manages the EventChannel's EventGenerator - * duties (subscribe/unsubscribe) as well as dispatching requests. It - * installs new EventHandlers, removes extant EventHandlers, and propagates - * events generated by the pool or passed in via the handle(Event event) - * method. - */ - private final EventDispatcher assistant = new EventDispatcher(); + private final Map<EventHandler, EventConstraint> eventListeners = + new HashMap<EventHandler, EventConstraint>(); + // Maps a 'module' owner to a list of event processors (which encapsulate both EventHandling + // and an EventConstraint). private final Map<Object, List<EventProcessor>> owners = new HashMap<Object, List<EventProcessor>>(); /** * Provides access to a singleton version of the EventChannel. - * @return + * @return the EventChannel singleton */ public static EventChannel getInstance() { return INSTANCE; @@ -39,160 +36,162 @@ /** * Adds an event to the EventChannel which then propagates the event to - * all interested subscribers. + * all interested subscribers. EventHandler.handle(Event) is invoked in a separate + * thread of execution. * - * @param event The event to add to the Pool. + * @param event The event to distribute via this EventChannel. */ - public synchronized void handle(Event event) { - assistant.dispatch(event); + public void handle(final Event event) { + synchronized (eventListeners) { + for (final Map.Entry<EventHandler, EventConstraint> entry : eventListeners.entrySet()) { + if (entry.getValue().accepts(event)) { + new Thread() { + public void run() { + entry.getKey().handle(event); + } + }.start(); + } + } + } } - + /** * An EventTypeProcessor is a convenience type for subscribing to the pool and * provides localized event handling for a given constraint. * @param processor */ - public synchronized void add(EventProcessor processor) { + public void add(EventProcessor processor) { subscribe(processor, processor); } - + /** * An EventTypeProcessor is a convenience type for subscribing to the pool and * provides localized event handling for a given constraint. * @param processor */ - public synchronized void add(Object owner, EventProcessor processor) { + public void add(Object owner, EventProcessor processor) { getEventProcessorsFor(owner).add(processor); } - - @SuppressWarnings("serial") + private List<EventProcessor> getEventProcessorsFor(Object owner) { - List<EventProcessor> processors = owners.get(owner); - if (processors == null) { - // overrides the add method to auto-subscribe the EventProcessor - // with this EventChannel. Should probably override all other - // add/insert methods in the future. - processors = new ArrayList<EventProcessor>() { - public boolean add(EventProcessor processor) { - subscribe(processor, processor); - return super.add(processor); - } - }; - owners.put(owner, processors); + synchronized (owners) { + List<EventProcessor> processors = owners.get(owner); + if (processors == null) { + processors = new EventProcessorList(); + owners.put(owner, processors); + } + return processors; } - return processors; + } - + public List<EventProcessor> register(Object owner) { return getEventProcessorsFor(owner); } - - public synchronized void unregister(Object owner) { - List<EventProcessor> processors = owners.remove(owner); + + public void unregister(Object owner) { + List<EventProcessor> processors = null; + synchronized (owners) { + processors = owners.remove(owner); + } if (processors != null) { for (EventProcessor processor: processors) { unsubscribe(processor); } } } - - public synchronized void remove(Object owner) { + + public void remove(Object owner) { unregister(owner); } /** - * Informs the pool that the given handler should receive all Events added - * to the Pool satisfying the given EventConstraint. + * The given handler will receive all Events received by this EventChannel + * accept()-ed by the given EventConstraint. * * @param handler The EventHandler to subscribe. * @param constraint The constraint with which to filter events. */ - public synchronized void subscribe(EventHandler handler, EventConstraint constraint) { + public void subscribe(EventHandler handler, EventConstraint constraint) { if (handler == this) { throw new IllegalArgumentException( "Cannot subscribe the event channel to itself."); } - assistant.put(handler, constraint); + synchronized (eventListeners) { + eventListeners.put(handler, constraint); + } } - - public synchronized void subscribe(EventHandler handler) { - subscribe(handler, EventConstraint.NONE); + + public void subscribe(EventHandler handler) { + subscribe(handler, EventConstraint.NONE); } /** - * Unsubscribes an EventHandler. + * Unsubscribes an EventHandler from this EventChannel, stopping it from receiving any + * events from this EventChannel. * * @param handler The EventHandler to unsubscribe. - * - * @throws KnownspaceException */ - public synchronized void unsubscribe(EventHandler handler) { - assistant.remove(handler); + public void unsubscribe(EventHandler handler) { + synchronized (eventListeners) { + eventListeners.remove(handler); + } } - + /** - * Extract this class to top level if it turns out to be useful in more contexts. - * - * @see mud.engine.EventGenerator + * $Id$ + * + * FIXME: this class should support automatic subscription/unsubscription with all methods that + * add/remove to this List. Right now only the basic add/remove methods are supported. */ - private static class EventDispatcher { - private final Map<EventHandler, EventConstraint> eventListeners; - - /** - * Create a new EventDispatcher. - */ - protected EventDispatcher() { - eventListeners = new HashMap<EventHandler, EventConstraint>(); + private class EventProcessorList extends ArrayList<EventProcessor> { + private static final long serialVersionUID = -4756601346604320046L; + @Override + public boolean add(EventProcessor processor) { + subscribe(processor, processor); + return super.add(processor); } - - /** - * 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. - */ - protected synchronized void put(EventHandler handler, EventConstraint constraint) { - eventListeners.put(handler, constraint); + @Override + public void add(int index, EventProcessor processor) { + subscribe(processor, processor); + super.add(index, processor); } - - /** - * Removes an EventHandler and its associated constraint. This method - * provides access for removing EventHandlers. It should be used - * within the EventGenerator's unsubscribe() method. - * - * @param handler The EventHandler to remove. - */ - protected synchronized void remove(EventHandler handler) { - eventListeners.remove(handler); + @Override + public boolean addAll(Collection<? extends EventProcessor> c) { + for (EventProcessor processor: c) { + subscribe(processor, processor); + } + return super.addAll(c); } - - /** - * Fires the given event to all interested EventHandlers. This method - * provides a way for Events to be sent to all EventHandlers subscribed - * 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); - } + @Override + public boolean addAll(int index, Collection<? extends EventProcessor> c) { + for (EventProcessor processor: c) { + subscribe(processor, processor); } - /* - for (Iterator handlers = eventListeners.keySet().iterator(); handlers.hasNext(); ) { - final EventHandler handler = (EventHandler) handlers.next(); - final EventConstraint constraint = eventListeners.get(handler); - if ( constraint.accepts(event) ) { - handler.handle(event); + return super.addAll(index, c); + } + @Override + public EventProcessor remove(int index) { + EventProcessor removed = super.remove(index); + unsubscribe(removed); + return removed; + } + @Override + public boolean remove(Object o) { + if (o instanceof EventProcessor) { + unsubscribe((EventProcessor) o); + } + return super.remove(o); + } + @Override + public boolean removeAll(Collection<?> c) { + for (Object o: c) { + if (o instanceof EventProcessor) { + unsubscribe((EventProcessor) o); } } - */ + return super.removeAll(c); } - + } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventProcessor.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventProcessor.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventProcessor.java 2006-06-18 18:34:40 UTC (rev 188) @@ -4,7 +4,9 @@ /** * $Id$ * - * Support class for processing events by type. + * Support interface for processing events, encapsulating both an EventHandler and an EventConstraint + * in the same class/type. + * * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision$ Modified: trunk/gee/src/java/edu/indiana/psych/gee/event/EventTypeProcessor.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/event/EventTypeProcessor.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/event/EventTypeProcessor.java 2006-06-18 18:34:40 UTC (rev 188) @@ -4,7 +4,8 @@ /** * $Id$ * - * Generified version of EventTypeProcessor. + * An EventTypeProcessor encapsulates both an EventHandler and an EventInstanceofConstraint + * within the same class for convenience sake. * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision$ @@ -12,7 +13,7 @@ public abstract class EventTypeProcessor<E extends Event> implements EventProcessor<E> { - private final EventConstraint constraint; + private final EventInstanceofConstraint constraint; /** * FIXME: find a way to get around having to specify the type of the class @@ -29,5 +30,4 @@ public boolean accepts(Event event) { return constraint.accepts(event); } - } Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/DebriefingAssistant.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/DebriefingAssistant.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/DebriefingAssistant.java 2006-06-18 18:34:40 UTC (rev 188) @@ -50,7 +50,7 @@ List<EventProcessor> processors = channel.register(this); processors.add(new EventTypeProcessor<PersistableEvent>(PersistableEvent.class) { public boolean accepts(Event event) { - return super.accepts(event) && ! (event.id() instanceof AgentIdentifier); + return super.accepts(event) && ! (event.getId() instanceof AgentIdentifier); } public void handle(PersistableEvent event) { if (event instanceof FoodAddedEvent) { @@ -62,7 +62,7 @@ else { // otherwise, associate it with the actions of the given client // only. - TreeSet<PersistableEvent> actions = clientActions.get(event.id()); + TreeSet<PersistableEvent> actions = clientActions.get(event.getId()); if (actions == null) { // FIXME: should assert that there are no actions ONLY for bot // identifiers. 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-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperiment.java 2006-06-18 18:34:40 UTC (rev 188) @@ -92,9 +92,9 @@ processors.add(new EventTypeProcessor<ClientReadyEvent>(ClientReadyEvent.class) { public void handle(ClientReadyEvent event) { synchronized (queuedParticipants) { - if ( queuedParticipants.remove(event.id()) ) { - readyToJoinParticipants.add(event.id()); - sendRegistrationEvent(event.id()); + if ( queuedParticipants.remove(event.getId()) ) { + readyToJoinParticipants.add(event.getId()); + sendRegistrationEvent(event.getId()); } } } @@ -102,7 +102,7 @@ processors.add(new EventTypeProcessor<ClientUpdateEvent>(ClientUpdateEvent.class) { public void handle(ClientUpdateEvent event) { synchronized (currentParticipantHeadings) { - currentParticipantHeadings.put(event.id(), event.getDirection()); + currentParticipantHeadings.put(event.getId(), event.getDirection()); } } }); @@ -110,9 +110,9 @@ processors.add(new EventTypeProcessor<ConnectionEvent>(ConnectionEvent.class) { public void handle(ConnectionEvent event) { synchronized (queuedParticipants) { - queuedParticipants.add(event.id()); + queuedParticipants.add(event.getId()); } - sendRegistrationEvent(event.id()); + sendRegistrationEvent(event.getId()); } }); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java 2006-06-18 18:34:40 UTC (rev 188) @@ -95,11 +95,11 @@ // the ForagerServerGameState. if (event instanceof AddClientEvent) { AddClientEvent addClientEvent = (AddClientEvent) event; - addClient(addClientEvent.id(), addClientEvent.getPosition()); + addClient(addClientEvent.getId(), addClientEvent.getPosition()); } else if (event instanceof MovementEvent) { MovementEvent movementEvent = (MovementEvent) event; - moveClient(movementEvent.id(), movementEvent.getDirection()); + moveClient(movementEvent.getId(), movementEvent.getDirection()); } else if (event instanceof FoodAddedEvent) { FoodAddedEvent foodAddedEvent = (FoodAddedEvent) event; 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-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClient.java 2006-06-18 18:34:40 UTC (rev 188) @@ -96,12 +96,12 @@ // FIXME: should state change should happen in a consistent way // by a consistent class? state = READY; - if (event.id().equals(id)) { + if (event.getId().equals(id)) { dispatcher.transmit(event); } else { error("Invalid client id ready, expected [" + id + "] actual [" - + event.id() + "]"); + + event.getId() + "]"); } } }); @@ -294,7 +294,7 @@ private ClientMessageQueueHandler(EventChannel channel) { channel.add(new EventTypeProcessor<ClientUpdateEvent>(ClientUpdateEvent.class) { public void handle(ClientUpdateEvent event) { - assert event.id().equals(ForagerClient.this.id); + assert event.getId().equals(ForagerClient.this.id); if (ForagerClient.this.state != RUNNING) { info("game is currently not running, ignoring: " + event + " state: " + ForagerClient.this.state); return; 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-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerClientGameState.java 2006-06-18 18:34:40 UTC (rev 188) @@ -74,7 +74,7 @@ clientState.setPosition(point); } if (event.didConsumeFood()) { - ClientState clientState = clients.get(event.id()); + ClientState clientState = clients.get(event.getId()); clientState.incrementFoodEaten(); // FIXME: drop an event into the event channel to signal the ForagerGameWindow // instead of doing this. 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-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/client/ForagerGameWindow.java 2006-06-18 18:34:40 UTC (rev 188) @@ -160,7 +160,7 @@ // reading through the debriefing! } setSpecialInstructions(event.toString()); - clientIdentifier = event.id(); + clientIdentifier = event.getId(); } private synchronized void setSpecialInstructions(String specialInstructions) { Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientUpdateEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientUpdateEvent.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/event/ClientUpdateEvent.java 2006-06-18 18:34:40 UTC (rev 188) @@ -32,6 +32,6 @@ } public String toString() { - return "Client update: " + id() + "\n\tDirection: " + direction; + return "Client update: " + getId() + "\n\tDirection: " + direction; } } 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-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/AbstractServerDispatcher.java 2006-06-18 18:34:40 UTC (rev 188) @@ -37,8 +37,8 @@ super(channel); channel.add(this, new EventTypeProcessor<DisconnectionRequest>(DisconnectionRequest.class) { public void handle(DisconnectionRequest request) { - logger.warn("disconnecting: " + request.id(), request.getException()); - disconnectedClients.add( request.id() ); + logger.warn("disconnecting: " + request.getId(), request.getException()); + disconnectedClients.add( request.getId() ); } }); } @@ -68,7 +68,6 @@ port, listeningPort)); return; } - listening = true; listeningPort = port; dispatcherThread = createDispatcherThread(); dispatcherThread.start(); @@ -93,7 +92,7 @@ } private Thread createDispatcherThread() { - return new Thread(new Runnable() { + return new Thread() { /** * Template method controlling the flow of execution for this Dispatcher. * Subclasses should implement bind(int port) and processIncomingConnections() @@ -104,6 +103,7 @@ logger.debug(getClass() + " listening on port:" + port); try { bind(port); + listening = true; while ( listening ) { processIncomingConnections(); // disconnect any pending disconnected clients and so on. @@ -116,9 +116,13 @@ shutdown(); } } - }); + }; } + public boolean isListening() { + return listening; + } + private void performConnectionMaintenance() { for (Iterator<Identifier> iter = disconnectedClients.iterator(); iter.hasNext(); ) { Identifier id = iter.next(); 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-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/ClientSocketDispatcher.java 2006-06-18 18:34:40 UTC (rev 188) @@ -10,22 +10,13 @@ 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$ * - * FIXME: Confused class hierarchy needs some work. Both ClientSocketDispatcher - * and ServerSocketDispatcher have common code for reading and transmitting - * Events across the network that should live somewhere common. Perhaps this is - * the case for SocketDispatcherWorker being its bona fide class. - * across the network - where should this live? The AbstractServerDispatcher - * has additional helper methods that it can use. + * The client dispatcher only implements the connecting part of the network business. * - * Perhaps this is a sign that we should be using composition instead of - * inheritance. * - * - * + * * @author Allen Lee * @version $Revision$ */ @@ -37,7 +28,7 @@ super(channel); channel.add(new EventTypeProcessor<DisconnectionRequest>(DisconnectionRequest.class) { public void handle(DisconnectionRequest event) { - disconnect(event.id()); + disconnect(event.getId()); } }); } @@ -58,11 +49,11 @@ // block while we wait for the ServerSocketDispatcher to assign an // Identifier to us. Event event = SocketDispatcherWorker.readEvent(socket); - assert event instanceof ServerAssignedIdentifierEvent; - Identifier id = event.id(); + assert event instanceof ConnectionEvent; + Identifier id = event.getId(); worker = new SocketDispatcherWorker(this, id, socket); worker.start(); - getLocalEventHandler().handle(new ConnectionEvent(event.id())); + getLocalEventHandler().handle((ConnectionEvent) event); return id; } catch (IOException e) { 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-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/NioDispatcher.java 2006-06-18 18:34:40 UTC (rev 188) @@ -3,6 +3,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetSocketAddress; @@ -16,15 +17,11 @@ 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 edu.indiana.psych.gee.net.event.ConnectionEvent; import edu.indiana.psych.gee.net.event.DisconnectionEvent; -import edu.indiana.psych.gee.net.event.ServerAssignedIdentifierEvent; /** * $Id$ @@ -32,6 +29,8 @@ * This class manages network connections via the java.nio package and can be * used by both clients and servers. Network connection descriptors (Identifiers) * are used to uniformly refer to the individual connections across the network. + * The NioDispatcher is both a client and a server dispatcher, allowing p2p + * connections. * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision$ @@ -40,7 +39,7 @@ private final static int READ_BUFFER_SIZE = 8192; - private final static int INT_SIZE = 4; + private final static int BYTES_PER_INT = 4; private ServerSocketChannel server; @@ -56,7 +55,8 @@ // SocketChannel. // bidirectional map of Identifier <-> SocketChannel - private final BidiMap connections = new DualHashBidiMap(); + private final Map<Identifier, SocketChannel> connections = + new HashMap<Identifier, SocketChannel>(); // maps Identifiers of clients that are in the process of // sending an Object across the stream but only got there halfway private Map<Identifier, PendingDataBuffer> pendingClients = @@ -70,6 +70,13 @@ initWorkerPool(workerPoolSize); } + /** + * package private to enforce access via the DispatcherFactory. + */ + NioDispatcher(EventChannel channel) { + this(channel, 10); + } + private void initWorkerPool(int size) { // XXX: special case worker pool of size 1 to just be a single Worker. if (size > 1) { @@ -84,6 +91,7 @@ worker = new NioDispatcherWorker(); } } + public boolean isConnected(Identifier id) { return true; } @@ -95,11 +103,12 @@ public Identifier connect(InetSocketAddress address) { try { SocketChannel connection = SocketChannel.open(address); - connection.configureBlocking(false); +// 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 // Identifiers used on the Server side. - Identifier id = new SocketIdentifier(connection.socket()); addMapping(id, connection); return id; } @@ -110,17 +119,29 @@ } } + private Identifier readConnectionEvent(SocketChannel connection) throws IOException { + connection.configureBlocking(true); + InputStream in = connection.socket().getInputStream(); + // read past the int header + in.read(); in.read(); in.read(); in.read(); + ObjectInputStream ois = new ObjectInputStream(in); + try { + ConnectionEvent event = (ConnectionEvent) ois.readObject(); + return event.getId(); + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + private void addMapping(Identifier id, SocketChannel channel) { connections.put(id, channel); } private SocketChannel getConnection(Identifier id) { - return (SocketChannel) connections.get(id); + return connections.get(id); } - - private Identifier getIdentifier(Object channel) { - return (Identifier) connections.getKey(channel); - } public void disconnect(Identifier id) { SocketChannel channel = getConnection(id); @@ -149,7 +170,7 @@ } catch (IOException e) { e.printStackTrace(); - requestDisconnection(event.id(), e); + requestDisconnection(event.getId(), e); } // FIXME: improve exception handling. throw new RuntimeException("Unable to convert event into raw byte data: " + event); @@ -178,11 +199,11 @@ public void transmit(Event event) { try { byte[] data = marshal(event); - write(event.id(), data); + write(event.getId(), data); } catch (IOException e) { e.printStackTrace(); - requestDisconnection(event.id(), e); + requestDisconnection(event.getId(), e); } } @@ -198,21 +219,23 @@ disconnect(id); throw new IllegalArgumentException("Attempting to write with an Identifier that doesn't exist: " + id); } - final int objectSize = data.length; - // FIXME: could be a performance bottle-neck in the future, allocation - // can be expensive. - // allocate enough space for the object and the int header, which is - // defined by the language spec to be 32-bits (4 bytes). See if - // there's a way to dynamically/reliably determine the size of an int - // in Java, i.e., equivalent to sizeof operator in C. Then again, - // maybe Java will never change from having 32-bit ints. - ByteBuffer buffer = ByteBuffer.allocate(objectSize + INT_SIZE); - // int header specifying how big the object is is needed so that the - // other side can know how much data to expect to read. - buffer.putInt(objectSize); - buffer.put(data); - buffer.clear(); - channel.write(buffer); + synchronized (channel) { + final int objectSize = data.length; + // FIXME: could be a performance bottle-neck in the future, allocation + // can be expensive. + // allocate enough space for the object and the int header, which is + // defined by the language spec to be 32-bits (4 bytes). See if + // there's a way to dynamically/reliably determine the size of an int + // in Java, i.e., equivalent to sizeof operator in C. Then again, + // maybe Java will never change from having 32-bit ints. + ByteBuffer buffer = ByteBuffer.allocate(objectSize + BYTES_PER_INT); + // int header specifying how big the object is is needed so that the + // other side can know how much data to expect to read. + buffer.putInt(objectSize); + buffer.put(data); + buffer.clear(); + channel.write(buffer); + } } /** @@ -229,8 +252,9 @@ // something larger than the set READ_BUFFER_SIZE? We have to // deal with chunking that up. SocketChannel channel = (SocketChannel) key.channel(); - Identifier id = getIdentifier(channel); + Identifier id = getIdentifier(key); + // clear out the original buffer. buffer.clear(); channel.read(buffer); buffer.flip(); @@ -255,10 +279,14 @@ } catch (IOException e) { e.printStackTrace(); - requestDisconnection(getIdentifier(key.channel()), e); + requestDisconnection(getIdentifier(key), e); } } + private Identifier getIdentifier(SelectionKey key) { + return (Identifier) key.attachment(); + } + // XXX: assumes that pendingClients has been locked private void handleRequest(Identifier id, ByteBuffer buffer) { // get the size of the Object so we know how much data we expect to @@ -354,18 +382,22 @@ } protected void processIncomingConnections() throws IOException { - SocketChannel incoming = server.accept(); + final SocketChannel incoming = server.accept(); getLogger().debug("incoming connection: " + incoming); - // this takes care of the case where server is configured to non-block - if (incoming != null) { - incoming.configureBlocking(false); - Identifier id = new SocketIdentifier(incoming.socket()); - // write the identifier to the client - addMapping(id, incoming); - worker.process(incoming); - transmit(new ServerAssignedIdentifierEvent(id)); - getLocalEventHandler().handle(new ConnectionEvent(id)); - } + new Thread() { + public void run() { + Identifier id = worker.process(incoming); + System.err.println("generated id" + id); + addMapping(id, incoming); + // send the newly generated Identifier to the client dispatcher, + // which should be blocked, waiting for it. + ConnectionEvent connectionEvent = new ConnectionEvent(id); + transmit(connectionEvent); + // notify any interested parties that a new connection has been + // made with the given Identifier. + getLocalEventHandler().handle(connectionEvent); + } + }.start(); } private class NioDispatcherWorker implements Worker<SocketChannel> { @@ -395,11 +427,25 @@ return selector.keys().size(); } - public void process(SocketChannel o) { + /** + * Adds the incoming socket channel to the queue of channels to be registered + * and then blocks the currently executing thread. This call will block until + * the incoming SocketChannel has successfully registered with the Selector. + */ + + public Identifier process(SocketChannel incoming) { synchronized (channels) { - channels.add(o); + channels.add(incoming); } - selector.wakeup(); + synchronized (incoming) { + selector.wakeup(); + try { + incoming.wait(); + } catch (InterruptedException e) {} + } + Identifier id = new SocketIdentifier(incoming.socket()); + incoming.keyFor(selector).attach(id); + return id; } public void remove(SocketChannel channel) { @@ -428,7 +474,6 @@ StringBuilder msg = new StringBuilder(); msg.append(this + " has " + selector.keys().size() + " channels\n"); for (SocketChannel channel : channels) { -// SocketChannel channel = (SocketChannel) iter.next(); msg.append(" "); msg.append(channel.toString()); msg.append('\n'); @@ -461,7 +506,7 @@ } public void run() { - // assumesthat we don't need to worry about + // assumes that we don't need to worry about // multiple threads starting this, otherwise we need to lock // on the test-and-set here. if (running) return; @@ -483,13 +528,17 @@ e.printStackTrace(); continue; } + finally { + synchronized (incoming) { + incoming.notifyAll(); + } + } } } // handle incoming data. try { if ( selector.select() >= 0 ) { - for (Iterator<SelectionKey> iterator = selector.selectedKeys().iterator(); - iterator.hasNext(); ) + for (Iterator<SelectionKey> iterator = selector.selectedKeys().iterator(); iterator.hasNext(); ) { SelectionKey key = iterator.next(); NioDispatcher.this.readData(key, buffer); 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-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/ServerSocketDispatcher.java 2006-06-18 18:34:40 UTC (rev 188) @@ -11,7 +11,6 @@ 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$ @@ -58,7 +57,7 @@ } public void transmit(Event event) { - Identifier id = event.id(); + Identifier id = event.getId(); if (id == null || id == Identifier.NULL) { // transmit to all connected clients if the target identifier is // not specified. @@ -93,11 +92,12 @@ Identifier id = new SocketIdentifier(incoming); // FIXME: consider pooling socket connections SocketDispatcherWorker worker = new SocketDispatcherWorker(this, id, incoming); - // immediately write a ServerAssignedIdentifierEvent to the incoming connection. - worker.write(new ServerAssignedIdentifierEvent(id)); + // immediately write a ConnectionEvent to the incoming connection. + ConnectionEvent event = new ConnectionEvent(id); + worker.write(event); workers.put(id, worker); worker.start(); - getLocalEventHandler().handle(new ConnectionEvent(id)); + getLocalEventHandler().handle(event); } protected void cleanup() { Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/Worker.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/Worker.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/Worker.java 2006-06-18 18:34:40 UTC (rev 188) @@ -1,5 +1,7 @@ package edu.indiana.psych.gee.net; +import edu.indiana.psych.gee.Identifier; + // import java.nio.channels.SocketChannel; /** @@ -12,7 +14,7 @@ * @version $Revision$ */ public interface Worker<T> extends Runnable, Comparable { - public void process(T object); + public Identifier process(T object); public int numberOfJobs(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/net/WorkerPool.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/WorkerPool.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/WorkerPool.java 2006-06-18 18:34:40 UTC (rev 188) @@ -5,11 +5,15 @@ import java.util.Map; import java.util.TreeSet; +import edu.indiana.psych.gee.Identifier; + /** * $Id$ * - * Pooled implementation for worker threads. The WorkerPool is a composite of - * the Worker. + * Very basic pooled implementation for worker threads. The WorkerPool is a composite of + * the Worker. + * + * FIXME: should just use Java 1.5 thread pools, i.e., ThreadPoolExecutor * * @author <a href='mailto:al...@cs...'>Allen Lee</a> * @version $Revision$ @@ -69,7 +73,7 @@ } } - public synchronized void process(T object) { + public synchronized Identifier process(T object) { Worker<T> worker = workers.first(); // this should always grab the first worker out. if (growable) { @@ -78,8 +82,8 @@ workers.add(worker); } } - worker.process(object); objectToWorkerMap.put(object, worker); + return worker.process(object); } public void report() { Deleted: trunk/gee/src/java/edu/indiana/psych/gee/net/event/ServerAssignedIdentifierEvent.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/event/ServerAssignedIdentifierEvent.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/event/ServerAssignedIdentifierEvent.java 2006-06-18 18:34:40 UTC (rev 188) @@ -1,23 +0,0 @@ -package edu.indiana.psych.gee.net.event; - -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); - } -} Added: trunk/gee/src/test/edu/indiana/psych/gee/net/NioDispatcherTester.java =================================================================== --- trunk/gee/src/test/edu/indiana/psych/gee/net/NioDispatcherTester.java (rev 0) +++ trunk/gee/src/test/edu/indiana/psych/gee/net/NioDispatcherTester.java 2006-06-18 18:34:40 UTC (rev 188) @@ -0,0 +1,68 @@ +package edu.indiana.psych.gee.net; + +import junit.framework.TestCase; +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.ConnectionEvent; + +/** + * $Id$ + * + * @author <a href='ano...@gm...'>Allen Lee</a> + * @version $Revision$ + */ + +public class NioDispatcherTester extends TestCase { + + private final static int DEFAULT_PORT = 16237; + + private NioDispatcher serverDispatcher; + private NioDispatcher clientDispatcher; + private EventChannel serverEventChannel; + private EventChannel clientEventChannel; + + private final Object notifier = new Object(); + private Identifier id; + + @Override + public void setUp() { + serverEventChannel = new EventChannel(); + clientEventChannel = new EventChannel(); + serverDispatcher = new NioDispatcher(serverEventChannel); + clientDispatcher = new NioDispatcher(clientEventChannel, 1); + } + + public void testConnect() throws Exception { + serverEventChannel.add(new EventTypeProcessor<ConnectionEvent>(ConnectionEvent.class) { + public void handle(ConnectionEvent event) { + synchronized (notifier) { + setIdentifier(event.getId()); + assertNotNull(event.getId()); + notifier.notifyAll(); + } + } + }); + serverDispatcher.listen(DEFAULT_PORT); + while (! serverDispatcher.isListening()) { + Thread.sleep(100); + } + synchronized (notifier) { + final Identifier clientId = connect(); + assertNotNull(clientId); + notifier.wait(); + assertEquals(clientId, id); + assertNotNull(id); + } + } + + private void setIdentifier(Identifier id) { + this.id = id; + } + + private Identifier connect() { + return clientDispatcher.connect("localhost", DEFAULT_PORT); + } + +} + Property changes on: trunk/gee/src/test/edu/indiana/psych/gee/net/NioDispatcherTester.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id Deleted: trunk/gee/src/test/edu/indiana/psych/gee/net/SocketIdentifierTester.java =================================================================== --- trunk/gee/src/test/edu/indiana/psych/gee/net/SocketIdentifierTester.java 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/src/test/edu/indiana/psych/gee/net/SocketIdentifierTester.java 2006-06-18 18:34:40 UTC (rev 188) @@ -1,85 +0,0 @@ -package edu.indiana.psych.gee.net; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.Stack; - -import junit.framework.TestCase; - -/** - * $Id$ - * - * - * Exercises SocketIdentifier semantics. - * - * - * - * @author Team - * @version $Revision$ - */ -public class SocketIdentifierTester extends TestCase { - - private final static InetSocketAddress SERVER_SOCKET_ADDRESS = new InetSocketAddress(23732); - private ServerSocket serverSocket; - private Thread serverThread; - private Stack<Socket> acceptedSockets = new Stack<Socket>(); - - public SocketIdentifierTester(String name) { - super(name); - } - - public void setUp() throws IOException { - serverSocket = new ServerSocket(23732); - serverThread = new Thread() { - public void run() { - try { - while (serverThread != null) { - acceptedSockets.push(serverSocket.accept()); - } - } - catch (IOException e) { - throw new RuntimeException(e); - } - finally { - try { - serverSocket.close(); - } - catch (IOException e) { - throw new RuntimeException(e); - } - serverThread = null; - } - } - }; - serverThread.start(); - } - - public void tearDown() { - serverThread = null; - } - - public void testCollectionability() throws Exception { - Socket socket = new Socket(); - socket.connect(SERVER_SOCKET_ADDRESS); - SocketIdentifier localSocketIdentifier = new SocketIdentifier(socket); - SocketIdentifier remoteSocketIdentifier = new SocketIdentifier(acceptedSockets.pop()); - assertEquals("local socket identifier should .equals remote socket identifier", - remoteSocketIdentifier, localSocketIdentifier); - assertEquals("local socket identifier should .equals itself socket identifier", - localSocketIdentifier, localSocketIdentifier); - assertEquals(new SocketIdentifier(socket), localSocketIdentifier); - assertEquals(new SocketIdentifier(socket), remoteSocketIdentifier); - assertEquals("local and remote identifiers should hash the same", - localSocketIdentifier.hashCode(), - remoteSocketIdentifier.hashCode()); - socket = new Socket(); - socket.connect(SERVER_SOCKET_ADDRESS); - assertFalse(new SocketIdentifier(socket).equals(localSocketIdentifier)); - - assertFalse(new SocketIdentifier(socket).hashCode() == localSocketIdentifier.hashCode()); - - } - -} Modified: trunk/gee/war/WEB-INF/classes/xwork.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/xwork.xml 2006-05-31 23:57:30 UTC (rev 187) +++ trunk/gee/war/WEB-INF/classes/xwork.xml 2006-06-18 18:34:40 UTC (rev 188) @@ -51,4 +51,5 @@ </package> <include file="gee-ajax.xml"/> <include file="gee-admin.xml"/> + <include file="gee-csan.xml"/> </xwork> Added: trunk/gee/war/WEB-INF/lib/dwr.jar =================================================================== (Binary files differ) Property changes on: trunk/gee/war/WEB-INF/lib/dwr.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/bot-back.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/bot-back.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/bot-front.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/bot-front.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/bot-side-left.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/bot-side-left.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/bot-side-right.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/bot-side-right.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/grass-1.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/grass-1.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/grass-2.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/grass-2.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/grass-3.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/grass-3.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/grass-4.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/grass-4.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/others-back.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/others-back.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/others-front.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/others-front.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/others-side-left.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/others-side-left.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/others-side-right.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/others-side-right.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/you-back.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/you-back.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/you-front.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/you-front.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/you-side-left.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/forager-v2/you-side-left.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/gee/war/images/forager-v2/you-side-right.gif =================================================================== (Binary files differ) Property changes on: trunk/gee/war/ima... [truncated message content] |
From: <al...@us...> - 2006-05-31 23:57:33
|
Revision: 187 Author: alllee Date: 2006-05-31 16:57:30 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=187&view=rev Log Message: ----------- experiment configurations now editable from the web, now to add experiment parameters into the mix. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java trunk/gee/war/WEB-INF/classes/gee-admin.xml Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java 2006-05-31 22:53:54 UTC (rev 186) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java 2006-05-31 23:57:30 UTC (rev 187) @@ -1,5 +1,7 @@ package edu.indiana.psych.gee.action; +import com.opensymphony.xwork.Preparable; + import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentRoundParameters; @@ -13,16 +15,19 @@ */ @SuppressWarnings("serial") -public class ManageExperimentConfiguration extends GeeAction { +public class ManageExperimentConfiguration extends GeeAction implements Preparable { private ExperimentConfiguration<? extends ExperimentRoundParameters> configuration; - private String configurationId; + private Long configurationId; private String configurationClass; + public void prepare() { + configuration = findConfiguration(getConfigurationId()); + } + public String save() { if (configuration == null) { - configuration = findConfiguration(getConfigurationId()); getLogger().warn("Trying to save a null configuration, ignoring.."); return INPUT; } @@ -52,12 +57,22 @@ public ExperimentConfiguration<? extends ExperimentRoundParameters> getConfiguration() { return configuration; } + + /* + public void setConfiguration(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration) { + this.configuration = configuration; + } + */ public Long getConfigurationId() { - return Long.valueOf(configurationId); + return configurationId; } + + public void setConfigurationClass(String configurationClass) { + this.configurationClass = configurationClass; + } - public void setConfigurationId(String configurationId) { + public void setConfigurationId(Long configurationId) { this.configurationId = configurationId; } @@ -70,16 +85,12 @@ try { return Class.forName(configurationClass); } - catch (ClassNotFoundException e) { + catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); - getLogger().error("Could not find class:" + configurationClass); + getLogger().error("Unable to load class:" + configurationClass); return null; } } - public void setConfigurationClass(String configurationClass) { - this.configurationClass = configurationClass; - } - -} + } Modified: trunk/gee/war/WEB-INF/classes/gee-admin.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-05-31 22:53:54 UTC (rev 186) +++ trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-05-31 23:57:30 UTC (rev 187) @@ -17,7 +17,8 @@ <result name="input" type="freemarker">configureExperiment.jsp</result> </action> <action name="configuration" class="edu.indiana.psych.gee.action.ManageExperimentConfiguration"> - <result name="success" type="freemarker">listExperimentConfigurations.jsp</result> + <interceptor-ref name="paramsPrepareParamsStack"/> + <result name="success" type="freemarker">configureExperiment.jsp</result> <result name="input" type="freemarker">configureExperiment.jsp</result> </action> </package> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-05-31 22:54:04
|
Revision: 186 Author: alllee Date: 2006-05-31 15:53:54 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=186&view=rev Log Message: ----------- default experiment configurations are now persisted/loaded from the DB when AbstractExperiment is being instantiated. 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/action/ManageExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java trunk/gee/war/WEB-INF/applicationContext.xml trunk/gee/war/WEB-INF/classes/gee-admin.xml trunk/gee/war/WEB-INF/classes/xwork.xml trunk/gee/war/admin/configureExperiment.jsp trunk/gee/war/admin/listExperiments.jsp trunk/gee/war/css/gee.css trunk/gee/war/index.jsp trunk/gee/war/template.jsp Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-05-31 22:53:54 UTC (rev 186) @@ -32,9 +32,8 @@ private boolean running; private ExperimentService experimentService; -// private ExperimentConfigurationService configurationService; + private ExperimentConfigurationService configurationService; - private String name; private C configuration; // private ExperimentRoundParameters currentParameters; @@ -64,11 +63,6 @@ return defaultConfiguration; } - public void setDefaultConfiguration(C defaultConfiguration) { - this.defaultConfiguration = defaultConfiguration; - } - - public synchronized void start() throws ExperimentLifecycleException { if ( isRunning() ) { getLogger().warn("Ignoring request to START an already running experiment."); @@ -94,6 +88,9 @@ } public int getServerPort() { + if (configuration == null) { + return -1; + } return getConfiguration().getServerPort(); } @@ -107,12 +104,16 @@ } public String getName() { - if (name == null) { - name = getConfiguration().getExperimentName(); + if (configuration == null) { + return super.toString(); } - return name; + return getConfiguration().getExperimentName(); } + public String getIdentifier() { + return getConfiguration().getExperimentIdentifier(); + } + public boolean equals(Object object) { return (this == object) || ((object instanceof Experiment) && ((Experiment) object).getName().equals(getName())); @@ -187,7 +188,6 @@ protected abstract StateMachine getStateMachine(); - private Thread createExperimentServerThread() { return new Thread(new Runnable() { public void run() { @@ -211,6 +211,22 @@ } public void setConfigurationService(ExperimentConfigurationService configurationService) { -// this.configurationService = configurationService; + this.configurationService = configurationService; } + + public void setDefaultConfiguration(C defaultConfiguration) { + if (defaultConfiguration == null) { + throw new IllegalArgumentException("Cannot set default configuration to null."); + } + ExperimentConfiguration configuration = configurationService.find(defaultConfiguration.getClass(), defaultConfiguration.getExperimentIdentifier()); + if (configuration == null) { + this.defaultConfiguration = defaultConfiguration; + configurationService.persist(defaultConfiguration); + } + else { + this.defaultConfiguration = (C) configuration; + } + } + + } Modified: trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/Experiment.java 2006-05-31 22:53:54 UTC (rev 186) @@ -31,6 +31,9 @@ public String getName() { return "null"; } + public String getIdentifier() { + return "null"; + } public ConsentForm getConsentForm() { return null; } @@ -61,6 +64,7 @@ public String getDescription(); public String getName(); + public String getIdentifier(); public ConsentForm getConsentForm(); Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java 2006-05-31 22:53:54 UTC (rev 186) @@ -23,7 +23,7 @@ private Set<Experiment> experiments; - private String experimentName; + private String experimentIdentifier; private ExperimentConfiguration configuration; @@ -37,32 +37,18 @@ } public String start() { - getLogger().debug("Starting: " + experimentName); + getLogger().debug("Starting: " + experimentIdentifier); getExperiment().start(); return NONE; } - public String status() { - getLogger().debug("Retrieving status for: " + experimentName); - return SUCCESS; - } - public String stop() { Experiment experiment = getExperiment(); - getLogger().debug("Stopping: " + experimentName + ": " + experiment); + getLogger().debug("Stopping: " + experimentIdentifier + ": " + experiment); experiment.stop(); return NONE; } - public String listExperiments() { - return SUCCESS; - } - - public String createExperiment() { - - return SUCCESS; - } - public ExperimentConfiguration getConfiguration() { return getExperiment().getConfiguration(); } @@ -79,11 +65,11 @@ } public Experiment getExperiment() { - return getExperimentService().find(experimentName); + return getExperimentService().find(experimentIdentifier); } - public void setExperimentName(String experimentName) { - this.experimentName = experimentName; + public void setExperimentIdentifier(String experimentName) { + this.experimentIdentifier = experimentName; } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java 2006-05-31 22:53:54 UTC (rev 186) @@ -15,22 +15,71 @@ @SuppressWarnings("serial") public class ManageExperimentConfiguration extends GeeAction { + private ExperimentConfiguration<? extends ExperimentRoundParameters> configuration; + private String configurationId; + private String configurationClass; public String save() { + if (configuration == null) { + configuration = findConfiguration(getConfigurationId()); + getLogger().warn("Trying to save a null configuration, ignoring.."); + return INPUT; + } getConfigurationService().persist(configuration); return SUCCESS; } + public String add() { + configuration = findConfiguration(-1L); + return INPUT; + } + + public String edit() { + configuration = findConfiguration(getConfigurationId()); + return INPUT; + } + + public String addParameters() { + return INPUT; + } + public String delete() { getConfigurationService().delete(configuration); return SUCCESS; } + public ExperimentConfiguration<? extends ExperimentRoundParameters> getConfiguration() { + return configuration; + } + + public Long getConfigurationId() { + return Long.valueOf(configurationId); + } + public void setConfigurationId(String configurationId) { + this.configurationId = configurationId; + } + + private ExperimentConfiguration<? extends ExperimentRoundParameters> findConfiguration(Long configurationId) { + return getConfigurationService().find(getConfigurationClass(), configurationId); + } + + private Class getConfigurationClass() { + // TODO Auto-generated method stub + try { + return Class.forName(configurationClass); + } + catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + getLogger().error("Could not find class:" + configurationClass); + return null; + } + } - public void setConfiguration(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration) { - this.configuration = configuration; + public void setConfigurationClass(String configurationClass) { + this.configurationClass = configurationClass; } } 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-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-05-31 22:53:54 UTC (rev 186) @@ -14,11 +14,11 @@ @SuppressWarnings("serial") public class StartExperiment extends GeeAction { - private String experimentName; + private String experimentIdentifier; private Participant participant; private ConsentForm consentForm; - public String prepare() { + public String consent() { consentForm = getExperiment().getConsentForm(); if (consentForm == null) { // no consent form available for this experiment.. just start? @@ -28,7 +28,7 @@ } public String start() { - if ( getExperimentService().start(experimentName) ) { + if ( getExperimentService().start(experimentIdentifier) ) { return SUCCESS; } else { @@ -38,21 +38,17 @@ } public Experiment getExperiment() { - return getExperimentService().find(experimentName); + return getExperimentService().find(experimentIdentifier); } public ConsentForm getConsentForm() { return consentForm; } - public String getExperimentName() { - return experimentName; + public void setExperimentIdentifier(String experimentName) { + this.experimentIdentifier = experimentName; } - public void setExperimentName(String experimentName) { - this.experimentName = experimentName; - } - public Participant getParticipant() { return participant; } Modified: trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java 2006-05-31 22:53:54 UTC (rev 186) @@ -5,6 +5,8 @@ import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentRoundParameters; +import java.util.List; + /** * $Id$ * @@ -22,6 +24,8 @@ public <E extends ExperimentConfiguration> E find(final Class<E> configurationClass, final String experimentName); + public <E extends ExperimentConfiguration> List<E> findAll(Class<E> configurationClass); + public void persist(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration); public void delete(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration); Modified: trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java 2006-05-31 22:53:54 UTC (rev 186) @@ -5,6 +5,7 @@ import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.Session; +import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Restrictions; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; @@ -12,6 +13,8 @@ import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentRoundParameters; +import java.util.List; + /** * $Id: Exp $ * @@ -26,16 +29,31 @@ private final Log logger = LogFactory.getLog(getClass()); + public <E extends ExperimentConfiguration> List<E> findAll(Class<E> configurationClass) { + return (List<E>) getHibernateTemplate().findByCriteria( DetachedCriteria.forClass(configurationClass) ); + } + public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Long id) { + if (id == -1L) { + try { + return configurationClass.newInstance(); + } + catch (Exception e) { + e.printStackTrace(); + String errorMessage = "Unable to instantiate instance of: " + configurationClass; + logger.error(errorMessage); + throw new IllegalArgumentException(errorMessage, e); + } + } return configurationClass.cast(getHibernateTemplate().get(configurationClass, id)); } - public <E extends ExperimentConfiguration> E find(final Class<E> configurationClass, final String experimentName) { + public <E extends ExperimentConfiguration> E find(final Class<E> configurationClass, final String experimentIdentifier) { return configurationClass.cast( getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Criteria criteria = session.createCriteria(configurationClass); - criteria.add(Restrictions.eq("experimentName", experimentName)); + criteria.add(Restrictions.eq("experimentIdentifier", experimentIdentifier)); return criteria.uniqueResult(); } })); Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerExperimentParameters.java 2006-05-31 22:53:54 UTC (rev 186) @@ -9,7 +9,6 @@ import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Transient; Modified: trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerServerGameState.java 2006-05-31 22:53:54 UTC (rev 186) @@ -25,7 +25,7 @@ /** * $Id$ * - * The ForagerServerGameState is the data model needed on the server side. + * Represents the server side data model. * * * @author Allen Lee 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-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-05-31 22:53:54 UTC (rev 186) @@ -1,9 +1,12 @@ package edu.indiana.psych.gee.service; + import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentRoundParameters; import edu.indiana.psych.gee.dao.ExperimentConfigurationDao; +import java.util.List; + /** * $Id: Exp $ * @@ -21,9 +24,15 @@ // private ConsentFormDao consentFormDao; + public <E extends ExperimentConfiguration> List<E> findAll(Class<E> configurationClass) { + return experimentConfigurationDao.findAll(configurationClass); + } public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Long id) { - return experimentConfigurationDao.find(configurationClass, id); + if (configurationClass == null) { + return null; + } + return experimentConfigurationDao.find(configurationClass, id); } /* FIXME: figure out if it is even possible to support this sort of @@ -37,8 +46,8 @@ } */ - public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, String experimentName) { - return experimentConfigurationDao.find(configurationClass, experimentName); + public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, String experimentIdentifier) { + return experimentConfigurationDao.find(configurationClass, experimentIdentifier); } public void persist(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration) { 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-27 22:58:09 UTC (rev 185) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentService.java 2006-05-31 22:53:54 UTC (rev 186) @@ -21,32 +21,24 @@ public class ExperimentService { @SuppressWarnings("serial") - private final Map<String, Experiment> allExperiments = - new HashMap<String, Experiment>() { - public Experiment get(String key) { - if (key == null) { - return Experiment.NULL; - } - return super.get(key); - } - }; + private final Map<String, Experiment> allExperiments = new HashMap<String, Experiment>(); private final Log logger = LogFactory.getLog(getClass()); - public boolean start(String experimentName) { - find(experimentName).start(); - return available(experimentName); + public boolean start(String experimentIdentifier) { + find(experimentIdentifier).start(); + return available(experimentIdentifier); } - public boolean available(String experimentName) { - return allExperiments.containsKey(experimentName); + public boolean available(String experimentIdentifier) { + return allExperiments.containsKey(experimentIdentifier); } public void add(Experiment experiment) { if (experiment == null) { throw new IllegalArgumentException("Trying to add a null experiment to the experiment service"); } - allExperiments.put(experiment.getName(), experiment); + allExperiments.put(experiment.getIdentifier(), experiment); } public void remove(Experiment experiment) { @@ -54,13 +46,13 @@ logger.warn("Trying to remove a null experiment from ExperimentService - ignoring"); return; } - if ( allExperiments.remove(experiment.getName()) == null ) { + if ( allExperiments.remove(experiment.getIdentifier()) == null ) { logger.warn("Tried to remove " + experiment + " which doesn't exist in ExperimentService"); } } - public Experiment find(String name) { - Experiment experiment = allExperiments.get(name); + public Experiment find(String experimentIdentifier) { + Experiment experiment = allExperiments.get(experimentIdentifier); if (experiment == null) { return Experiment.NULL; } Modified: trunk/gee/war/WEB-INF/applicationContext.xml =================================================================== --- trunk/gee/war/WEB-INF/applicationContext.xml 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/war/WEB-INF/applicationContext.xml 2006-05-31 22:53:54 UTC (rev 186) @@ -67,7 +67,8 @@ <bean id="defaultForagerWebConfiguration" class="edu.indiana.psych.gee.forager.ForagerConfiguration"> <constructor-arg value="groups.psych.indiana.edu"/> <constructor-arg type="int"><value>26000</value></constructor-arg> - <property name="experimentName" value="forager-web"/> + <property name="experimentName" value="forager"/> + <property name="experimentIdentifier" value="forager-web"/> <property name="description" value="The Forager web experiment explores how individuals allocate themselves in a world with scarce resources via an always-available applet."/> <property name='clientJarName' value='forager-client.jar'/> <property name='clientMainClass' value='edu.indiana.psych.gee.forager.client.ForagerApplet'/> @@ -75,20 +76,21 @@ <bean id="defaultForagerExperimentConfiguration" class="edu.indiana.psych.gee.forager.ForagerConfiguration"> <constructor-arg value="groups.psych.indiana.edu"/> <constructor-arg type="int"><value>26001</value></constructor-arg> - <property name="experimentName" value="forager-experiment"/> + <property name="experimentName" value="forager"/> + <property name="experimentIdentifier" value="forager-experiment"/> <property name="description" value="The in-house Forager experiment explores how individuals allocate themselves in a world with scarce resources under a facilitator's guidance in controlled settings."/> <property name='clientJarName' value='forager-client.jar'/> <property name='clientMainClass' value='edu.indiana.psych.gee.forager.client.ForagerApplet'/> <property name='triggeredExperiment' value='true'/> </bean> <bean id="forager-web" class="edu.indiana.psych.gee.forager.ForagerExperiment"> + <property name="configurationService" ref='configurationService'/> <property name="defaultConfiguration" ref="defaultForagerWebConfiguration"/> - <property name="configurationService" ref='configurationService'/> <property name="experimentService" ref="experimentService"/> </bean> <bean id="forager-experiment" class="edu.indiana.psych.gee.forager.ForagerExperiment"> + <property name="configurationService" ref='configurationService'/> <property name="defaultConfiguration" ref="defaultForagerExperimentConfiguration"/> - <property name="configurationService" ref='configurationService'/> <property name="experimentService" ref="experimentService"/> </bean> </beans> Modified: trunk/gee/war/WEB-INF/classes/gee-admin.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-05-31 22:53:54 UTC (rev 186) @@ -8,9 +8,9 @@ admin package o' actions and urls. define the login filter here? --> <package name="admin" extends="default" namespace="/admin"> - <action name="index" class="edu.indiana.psych.gee.action.ManageExperiment" method="authenticate"> + <action name="index" class="edu.indiana.psych.gee.action.ManageExperiment"> <result name="success" type="freemarker">listExperiments.jsp</result> - <result name="error">error.jsp</result> + <result name="error">/error.jsp</result> </action> <action name="experiment" class="edu.indiana.psych.gee.action.ManageExperiment"> <result name="success" type="freemarker">listExperiments.jsp</result> Modified: trunk/gee/war/WEB-INF/classes/xwork.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/xwork.xml 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/war/WEB-INF/classes/xwork.xml 2006-05-31 22:53:54 UTC (rev 186) @@ -43,9 +43,8 @@ <result type="freemarker">startExperiment.jsp</result> <result name="input" type="freemarker">consent.jsp</result> </action> - <action name="consent" class="edu.indiana.psych.gee.action.StartExperiment" method="prepare"> + <action name="consent" class="edu.indiana.psych.gee.action.StartExperiment" method="consent"> <!-- FIXME: do not use a validating stack here --> - <interceptor-ref name="basicStack"/> <result type="freemarker">consent.jsp</result> <result name="input" type="freemarker">consent.jsp</result> </action> Modified: trunk/gee/war/admin/configureExperiment.jsp =================================================================== --- trunk/gee/war/admin/configureExperiment.jsp 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/war/admin/configureExperiment.jsp 2006-05-31 22:53:54 UTC (rev 186) @@ -6,10 +6,12 @@ <p> Configuring the <span class="highlight">${configuration.experimentName}</span> experiment: </p> -<@ww.form action="updateExperimentConfiguration"> - <@ww.hidden name="experimentName" value="${configuration.experimentName}"/> +<@ww.form action="configuration!save.action" method="post"> + <@ww.hidden name="configurationClass" value="${configuration.class.name}"/> + <@ww.hidden name="configurationId" value="${configuration.id}"/> <@ww.textfield size=40 label="Server port" name="configuration.serverPort"/> <@ww.textfield size=40 label="Experiment name" name="configuration.experimentName"/> + <@ww.textfield size=40 label="Experiment id" name="configuration.experimentIdentifier"/> <@ww.textfield size=40 label="Server name" name="configuration.serverName"/> <@ww.textarea cols=37 rows=6 label="Description" name="configuration.description"/> <@ww.checkbox label="Triggered?" name="configuration.triggeredExperiment"/> @@ -25,13 +27,16 @@ <#else> <h3> <div id="Error"> -No experiment parameters associated with ${configuration.experimentName}, please add some! +No experiment parameters associated with ${configuration.experimentName}, + <a href='javascript:void(0)' onclick='toggle("addExperimentParametersDiv")'>add some?</a>. </div> </h3> </#if> <hr/> -<@ww.form action="addExperimentParameters" method="POST" enctype="multipart/form-data"> +<div id="addExperimentParametersDiv" style="display:none;"> +<@ww.form action="configuration!addParameters.action" method="POST" enctype="multipart/form-data"> <@ww.file label="Add experiment parameters from file: " name="'experimentParametersFile'"/> <@ww.submit value="Load"/> </@ww.form> +</div> </body> Modified: trunk/gee/war/admin/listExperiments.jsp =================================================================== --- trunk/gee/war/admin/listExperiments.jsp 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/war/admin/listExperiments.jsp 2006-05-31 22:53:54 UTC (rev 186) @@ -9,7 +9,7 @@ (not implemented yet). <table> <tr> - <th>Name</th> + <th>Name/Identifier</th> <th>Description</th> <th>Status</th> <th>Action</th> @@ -20,18 +20,18 @@ <#else> <tr class="displayeven"> </#if> - <td width="10%"><span class='highlight'>${name}</span></td> + <td width="10%"><span class='highlight'>${name} / ${identifier}</span></td> <td width="50%">${description}</td> <td width="15%"> ${running?string("running", "not running")} </td> <td width="25%"> ( - <a href="experiment!start.action?experimentName=${name}">Start<a> + <a href="experiment!start.action?experimentIdentifier=${identifier}">Start<a> | - <a href='experiment!stop.action?experimentName=${name}'>Stop<a> + <a href='experiment!stop.action?experimentIdentifier=${identifier}'>Stop<a> | - <a href='experiment!configure.action?experimentName=${name}'>Edit</a> + <a href='experiment!configure.action?experimentIdentifier=${identifier}'>Edit</a> ) </td> </tr> Modified: trunk/gee/war/css/gee.css =================================================================== --- trunk/gee/war/css/gee.css 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/war/css/gee.css 2006-05-31 22:53:54 UTC (rev 186) @@ -73,7 +73,7 @@ } th { - background: #C96; + background: #A4B5C5; border-left: 1px solid #EB8; border-right: 1px solid #B74; border-top: 1px solid #EB8; Modified: trunk/gee/war/index.jsp =================================================================== --- trunk/gee/war/index.jsp 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/war/index.jsp 2006-05-31 22:53:54 UTC (rev 186) @@ -57,12 +57,13 @@ <tr class="displayeven"> </#if> <td style="white-space: nowrap;"> - <a href='consent.action?experimentName=${name}'> - <span class="highlight">[ ${name} ]</span> - </a> + <#assign url='consent.action?experimentIdentifier=${identifier}'> + <@ww.a href='${url}'> + <span class="highlight">[ ${identifier} ]</span> + </@ww.a> </td> <td>${description}</td> - <td><a href='consent.action?experimentName=${name}'><i>start</i></a></td> + <td><@ww.a href='${url}'><i>start</i></@ww.a></td> </tr> </@ww.iterator> </tbody> Modified: trunk/gee/war/template.jsp =================================================================== --- trunk/gee/war/template.jsp 2006-05-27 22:58:09 UTC (rev 185) +++ trunk/gee/war/template.jsp 2006-05-31 22:53:54 UTC (rev 186) @@ -9,6 +9,16 @@ <LINK REL="stylesheet" HREF="/gee/css/gee.css" TYPE="text/css" /> <title><decorator:title default="Group Experiments Environment" /></title> <decorator:head /> +<script> + function $(id) { + return document.getElementById(id); + } + function toggle(id) { + var display = $(id).style.display; + $(id).style.display = + (display == "block") ? "none" : "block"; + } +</script> </head> <body> <div id="Content"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-05-25 00:11:00
|
Revision: 184 Author: alllee Date: 2006-05-24 17:10:55 -0700 (Wed, 24 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=184&view=rev Log Message: ----------- adding notion of a experiment Identifer to ExperimentConfiguration, and fixing errors in xwork configuration. Still grinding away on editing experiment configurations via the web. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java trunk/gee/war/WEB-INF/classes/gee-admin.xml Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-05-24 18:17:59 UTC (rev 183) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-05-25 00:10:55 UTC (rev 184) @@ -27,8 +27,22 @@ public String getServerName(); public void setServerName(String serverName); + /** + * Returns a user friendly name for the experiment. This can be duplicated for several + * experiment instances (e.g., forager or social choice experiments have a variety of potential names). + * @return + */ public String getExperimentName(); public void setExperimentName(String experimentName); + + /** + * Returns a unique String name/identifier for the experiment configured by this ExperimentConfiguration object, + * e.g., forager-experiment, forager-web. + * + * @return a unique String identifier for this Experiment. + */ + public String getExperimentIdentifier(); + public void setExperimentIdentifier(String experimentIdentifier); public int getServerPort(); public void setServerPort(int serverPort); Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java 2006-05-24 18:17:59 UTC (rev 183) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java 2006-05-25 00:10:55 UTC (rev 184) @@ -23,22 +23,17 @@ private Set<Experiment> experiments; - private Experiment experiment; private String experimentName; private ExperimentConfiguration configuration; public String authenticate() { - return SUCCESS; } public String configure() { - for (ExperimentRoundParameters parameter: getAllParameters()) { - getLogger().warn("XXX: Returning: " + parameter); - } - // load experiment and various pieces of configuration information? - return SUCCESS; + configuration = getExperiment().getConfiguration(); + return INPUT; } public String start() { @@ -84,12 +79,11 @@ } public Experiment getExperiment() { - return experiment; + return getExperimentService().find(experimentName); } public void setExperimentName(String experimentName) { this.experimentName = experimentName; - this.experiment = getExperimentService().find(experimentName); } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java 2006-05-24 18:17:59 UTC (rev 183) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java 2006-05-25 00:10:55 UTC (rev 184) @@ -4,6 +4,7 @@ import java.util.Iterator; import java.util.List; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @@ -46,6 +47,7 @@ private Long id = Long.valueOf(-1); private String description; private String experimentName; + private String experimentIdentifier; private String clientJarName; private String clientMainClass; private ConsentForm consentForm; @@ -171,6 +173,7 @@ this.description = description; } + @Column(nullable=false) public String getExperimentName() { return experimentName; } @@ -191,4 +194,13 @@ public Duration getDelayBetweenRounds() { return Duration.create(30); } + + @Column(nullable=false, unique=true) + public String getExperimentIdentifier() { + return experimentIdentifier; + } + + public void setExperimentIdentifier(String experimentIdentifier) { + this.experimentIdentifier = experimentIdentifier; + } } Modified: trunk/gee/war/WEB-INF/classes/gee-admin.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-05-24 18:17:59 UTC (rev 183) +++ trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-05-25 00:10:55 UTC (rev 184) @@ -8,14 +8,17 @@ admin package o' actions and urls. define the login filter here? --> <package name="admin" extends="default" namespace="/admin"> - - <action name="index" class="edu.indiana.psych.gee.action.AuthenticateAction" method="authenticate"> + <action name="index" class="edu.indiana.psych.gee.action.ManageExperiment" method="authenticate"> <result name="success" type="freemarker">listExperiments.jsp</result> <result name="error">error.jsp</result> </action> <action name="experiment" class="edu.indiana.psych.gee.action.ManageExperiment"> <result name="success" type="freemarker">listExperiments.jsp</result> - <result name="input">configureExperiment.jsp</result> + <result name="input" type="freemarker">configureExperiment.jsp</result> </action> + <action name="configuration" class="edu.indiana.psych.gee.action.ManageExperimentConfiguration"> + <result name="success" type="freemarker">listExperimentConfigurations.jsp</result> + <result name="input" type="freemarker">configureExperiment.jsp</result> + </action> </package> </xwork> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-05-24 18:18:26
|
Revision: 183 Author: alllee Date: 2006-05-24 11:17:59 -0700 (Wed, 24 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=183&view=rev Log Message: ----------- adding Sessions, AuthenticationTokens, GeeAdministrators to the admin portion of the webapp. Still refining the ExperimentConfiguration fiasco, need to make a concrete page that lets you create/edit/delete experiment configurations and consent forms soon. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java trunk/gee/war/WEB-INF/applicationContext.xml trunk/gee/war/WEB-INF/classes/gee-admin.xml trunk/gee/war/WEB-INF/classes/webwork.properties trunk/gee/war/admin/listExperiments.jsp trunk/gee/war/ajax/status.ajax trunk/gee/war/includes/header.jsp Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java trunk/gee/src/java/edu/indiana/psych/gee/bean/AuthenticationToken.java trunk/gee/src/java/edu/indiana/psych/gee/bean/GeeAdministrator.java trunk/gee/src/java/edu/indiana/psych/gee/session/ trunk/gee/src/java/edu/indiana/psych/gee/session/SessionData.java trunk/gee/src/java/edu/indiana/psych/gee/session/SessionDataAware.java Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java Modified: trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/src/java/edu/indiana/psych/gee/AbstractExperiment.java 2006-05-24 18:17:59 UTC (rev 183) @@ -1,7 +1,5 @@ package edu.indiana.psych.gee; -import java.util.List; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -10,8 +8,8 @@ import edu.indiana.psych.gee.event.EventChannel; import edu.indiana.psych.gee.net.DispatcherFactory; import edu.indiana.psych.gee.net.ServerDispatcher; +import edu.indiana.psych.gee.service.ExperimentConfigurationService; import edu.indiana.psych.gee.service.ExperimentService; -import edu.indiana.psych.gee.service.ExperimentConfigurationService; import edu.indiana.psych.gee.time.Duration; /** @@ -38,8 +36,10 @@ private String name; private C configuration; - private ExperimentRoundParameters currentParameters; +// private ExperimentRoundParameters currentParameters; + private C defaultConfiguration; + public AbstractExperiment() { channel = new EventChannel(); dispatcher = DispatcherFactory.getInstance().createServerDispatcher(channel); @@ -59,6 +59,15 @@ } this.configuration = configuration; } + + public C getDefaultConfiguration() { + return defaultConfiguration; + } + + public void setDefaultConfiguration(C defaultConfiguration) { + this.defaultConfiguration = defaultConfiguration; + } + public synchronized void start() throws ExperimentLifecycleException { if ( isRunning() ) { @@ -143,20 +152,8 @@ // XXX: not using Iterators here because that'd impose // call-only-once semantics unless we jumped more hoops public String getNextRoundInstructions() { - if (currentParameters == null) { - currentParameters = configuration.getCurrentParameters(); - if (currentParameters == null) { - // FIXME: allow the user to specify configuration here instead - // of throwing an exception. - throw new ExperimentLifecycleException("No experimental rounds have been configured."); - } - return currentParameters.getSpecialInstructions(); - } - // need a non-mutating way to access the special instructions on deck. - List<ExperimentRoundParameters> allParameters = configuration.getAllParameters(); - int nextIndex = (allParameters.indexOf(currentParameters) + 1) % allParameters.size(); -// nextIndex = nextIndex % allParameters.size(); - return allParameters.get(nextIndex).getSpecialInstructions(); + return configuration.getNextRoundInstructions(); + } public void setExperimentService(ExperimentService experimentService) { @@ -164,6 +161,15 @@ this.experimentService.remove(this); } this.experimentService = experimentService; + if (configuration == null) { + configuration = getDefaultConfiguration(); + if (configuration == null) { + // no default configuration available either.. don't add this experiment to the + // experiment service! + getLogger().warn("No configurations available for: " + this); + return; + } + } experimentService.add(this); } @@ -203,4 +209,8 @@ } }); } + + public void setConfigurationService(ExperimentConfigurationService configurationService) { +// this.configurationService = configurationService; + } } Modified: trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/src/java/edu/indiana/psych/gee/ExperimentConfiguration.java 2006-05-24 18:17:59 UTC (rev 183) @@ -9,13 +9,16 @@ /** * $Id: Exp $ * - * + * All GEE experiment configurations should follow this contract. * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision: $ */ public interface ExperimentConfiguration<T extends ExperimentRoundParameters> { + + public Long getId(); + public void setId(Long id); public List<T> getAllParameters(); public void setAllParameters(List<T> allParameters); @@ -37,6 +40,8 @@ public String getDescription(); public void setDescription(String description); + + public String getNextRoundInstructions(); public boolean isTriggeredExperiment(); public void setTriggeredExperiment(boolean triggered); @@ -44,7 +49,3 @@ public InetSocketAddress getServerAddress(); } -/* - * $Log: $ - */ - Deleted: trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java 2006-05-24 18:17:59 UTC (rev 183) @@ -1,95 +0,0 @@ -package edu.indiana.psych.gee.action; - -import java.util.List; -import java.util.Set; - -import edu.indiana.psych.gee.Experiment; -import edu.indiana.psych.gee.ExperimentConfiguration; -import edu.indiana.psych.gee.ExperimentRoundParameters; - -/** - * $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$ - */ - -@SuppressWarnings("serial") -public class AdminAction extends GeeAction { - - - private Set<Experiment> experiments; - private Experiment experiment; - private String experimentName; - - private ExperimentConfiguration configuration; - - public String authenticate() { - - return SUCCESS; - } - - public String configure() { - for (ExperimentRoundParameters parameter: getAllParameters()) { - getLogger().warn("XXX: Returning: " + parameter); - } - // load experiment and various pieces of configuration information? - return SUCCESS; - } - - public String start() { - getLogger().debug("Starting: " + experimentName); - getExperiment().start(); - return SUCCESS; - } - - public String status() { - getLogger().debug("Retrieving status for: " + experimentName); - return SUCCESS; - } - - public String stop() { - Experiment experiment = getExperiment(); - getLogger().debug("Stopping: " + experimentName + ": " + experiment); - experiment.stop(); - return SUCCESS; - } - - public String listExperiments() { - return SUCCESS; - } - - public String createExperiment() { - - return SUCCESS; - } - - public ExperimentConfiguration getConfiguration() { - return getExperiment().getConfiguration(); - } - - public List<? extends ExperimentRoundParameters> getAllParameters() { - return getConfiguration().getAllParameters(); - } - - public Set<Experiment> getExperiments() { - if (experiments == null || experiments.isEmpty()) { - experiments = getExperimentService().getAllExperiments(); - } - return experiments; - } - - public Experiment getExperiment() { - return experiment; - } - - public void setExperimentName(String experimentName) { - this.experimentName = experimentName; - this.experiment = getExperimentService().find(experimentName); - } - -} Copied: trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java (from rev 182, trunk/gee/src/java/edu/indiana/psych/gee/action/AdminAction.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperiment.java 2006-05-24 18:17:59 UTC (rev 183) @@ -0,0 +1,95 @@ +package edu.indiana.psych.gee.action; + +import java.util.List; +import java.util.Set; + +import edu.indiana.psych.gee.Experiment; +import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentRoundParameters; + +/** + * $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$ + */ + +@SuppressWarnings("serial") +public class ManageExperiment extends GeeAction { + + + private Set<Experiment> experiments; + private Experiment experiment; + private String experimentName; + + private ExperimentConfiguration configuration; + + public String authenticate() { + + return SUCCESS; + } + + public String configure() { + for (ExperimentRoundParameters parameter: getAllParameters()) { + getLogger().warn("XXX: Returning: " + parameter); + } + // load experiment and various pieces of configuration information? + return SUCCESS; + } + + public String start() { + getLogger().debug("Starting: " + experimentName); + getExperiment().start(); + return NONE; + } + + public String status() { + getLogger().debug("Retrieving status for: " + experimentName); + return SUCCESS; + } + + public String stop() { + Experiment experiment = getExperiment(); + getLogger().debug("Stopping: " + experimentName + ": " + experiment); + experiment.stop(); + return NONE; + } + + public String listExperiments() { + return SUCCESS; + } + + public String createExperiment() { + + return SUCCESS; + } + + public ExperimentConfiguration getConfiguration() { + return getExperiment().getConfiguration(); + } + + public List<? extends ExperimentRoundParameters> getAllParameters() { + return getConfiguration().getAllParameters(); + } + + public Set<Experiment> getExperiments() { + if (experiments == null || experiments.isEmpty()) { + experiments = getExperimentService().getAllExperiments(); + } + return experiments; + } + + public Experiment getExperiment() { + return experiment; + } + + public void setExperimentName(String experimentName) { + this.experimentName = experimentName; + this.experiment = getExperimentService().find(experimentName); + } + +} Added: trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java 2006-05-24 18:17:59 UTC (rev 183) @@ -0,0 +1,36 @@ +package edu.indiana.psych.gee.action; + +import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentRoundParameters; + +/** + * $Id$ + * + * WebWork Action used to manage experiment configurations. + * + * @author <a href='ano...@gm...'>Allen Lee</a> + * @version $Revision$ + */ + +@SuppressWarnings("serial") +public class ManageExperimentConfiguration extends GeeAction { + + private ExperimentConfiguration<? extends ExperimentRoundParameters> configuration; + + public String save() { + getConfigurationService().persist(configuration); + return SUCCESS; + } + + public String delete() { + getConfigurationService().delete(configuration); + return SUCCESS; + } + + + + public void setConfiguration(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration) { + this.configuration = configuration; + } + +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/action/ManageExperimentConfiguration.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id Added: trunk/gee/src/java/edu/indiana/psych/gee/bean/AuthenticationToken.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/AuthenticationToken.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/AuthenticationToken.java 2006-05-24 18:17:59 UTC (rev 183) @@ -0,0 +1,78 @@ +package edu.indiana.psych.gee.bean; + +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +/** + * $Id$ + * + * A persistent token used to mark all data submitted by a given user. + * + * @author <a href='ano...@gm...'>Allen Lee</a> + * @version $Revision$ + */ + +@Entity +@Table(name = "gee_administrator_sessions") +public class AuthenticationToken { + + public final static AuthenticationToken INVALID = new AuthenticationToken(); + + private Long id = Long.valueOf(-1); + + private GeeAdministrator geeAdministrator; + + private Date creationTime; + + public static AuthenticationToken create(GeeAdministrator user) { + if (user == null) { + throw new IllegalArgumentException( + "Attempt to create an AuthenticationToken with a null User."); + } + AuthenticationToken token = new AuthenticationToken(); + token.setGeeAdministrator(user); + token.setCreationTime(new Date()); + return token; + } + + @Temporal(TemporalType.TIMESTAMP) + public Date getCreationTime() { + return creationTime; + } + + public void setCreationTime(Date date) { + this.creationTime = date; + } + + @Id + @GeneratedValue + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @ManyToOne + public GeeAdministrator getGeeAdministrator() { + return geeAdministrator; + } + + public void setGeeAdministrator(GeeAdministrator user) { + this.geeAdministrator = user; + } + + @Transient + public boolean isValid() { + return this != INVALID && geeAdministrator != null; + } +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/bean/AuthenticationToken.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id Modified: trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/ExperimentConfigurationEntity.java 2006-05-24 18:17:59 UTC (rev 183) @@ -13,6 +13,8 @@ import javax.persistence.Table; import javax.persistence.Transient; +import org.hibernate.annotations.Proxy; + import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.ExperimentLifecycleException; import edu.indiana.psych.gee.ExperimentRoundParameters; @@ -33,6 +35,7 @@ @Entity @Inheritance(strategy=InheritanceType.JOINED) @Table(name="experiment_configuration") +@Proxy(proxyClass=ExperimentConfiguration.class) public abstract class ExperimentConfigurationEntity<T extends ExperimentRoundParameters> implements ExperimentConfiguration<T> { @@ -137,6 +140,20 @@ } return currentParameters; } + + @Transient + public synchronized String getNextRoundInstructions() { + if (currentParameters == null) { + return getAllParameters().get(0).getSpecialInstructions(); + } + return currentParameters.getSpecialInstructions(); + } +// need a non-mutating way to access the special instructions on deck. +// List<ExperimentRoundParameters> allParameters = configuration.getAllParameters(); +// int nextIndex = (allParameters.indexOf(currentParameters) + 1) % allParameters.size(); +// nextIndex = nextIndex % allParameters.size(); +// return allParameters.get(nextIndex).getSpecialInstructions(); +// } public String getClientJarName() { return clientJarName; Added: trunk/gee/src/java/edu/indiana/psych/gee/bean/GeeAdministrator.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/GeeAdministrator.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/GeeAdministrator.java 2006-05-24 18:17:59 UTC (rev 183) @@ -0,0 +1,159 @@ +package edu.indiana.psych.gee.bean; + +import java.util.Date; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +/** + * $Id$ + * + * Represents an gee administrator that has the ability to perform any operation under the + * admin namespace. At the moment this includes start/stop experiments, modify + * experiment configuration information. + * + * @author <a href='ano...@gm...'>Allen Lee</a> + * @version $Revision$ + */ + +@Entity +@Table(name = "gee_administrator") +public class GeeAdministrator { + + @Id + @GeneratedValue + private Long id = Long.valueOf(-1); + + @Temporal(TemporalType.TIMESTAMP) + @Column(nullable = false) + private Date dateCreated; + + @Column(nullable = false) + private String firstName; + + @Column(nullable = false) + private String lastName; + + private String middleInitial; + + @Column(nullable = false) + private String emailAddress; + + @Column(nullable = false) + private String institution; + + @Column(nullable = false, unique = true) + private String username; + + @OneToMany(mappedBy = "geeAdministrator") + private Set<AuthenticationToken> userSessions; + private String password; + private transient String passwordConfirmation; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + @Transient + public String getFullName() { + return String.format("%s %s. %s", firstName, middleInitial, + lastName, username); + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getInstitution() { + return institution; + } + + public void setInstitution(String institution) { + this.institution = institution; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getMiddleInitial() { + return middleInitial; + } + + public void setMiddleInitial(String middleInitial) { + this.middleInitial = middleInitial; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Date getDateCreated() { + return dateCreated; + } + + public void setDateCreated(Date dateCreated) { + this.dateCreated = dateCreated; + } + + public String getPasswordConfirmation() { + return passwordConfirmation; + } + + public void setPasswordConfirmation(String passwordConfirmation) { + this.passwordConfirmation = passwordConfirmation; + } + + public Set<AuthenticationToken> getUserSessions() { + return userSessions; + } + + public void setUserSessions(Set<AuthenticationToken> userSessions) { + this.userSessions = userSessions; + } + + public String toString() { + return getFullName(); + } + +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/bean/GeeAdministrator.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id Modified: trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/src/java/edu/indiana/psych/gee/dao/ExperimentConfigurationDao.java 2006-05-24 18:17:59 UTC (rev 183) @@ -3,6 +3,7 @@ import org.springframework.transaction.annotation.Transactional; import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentRoundParameters; /** * $Id$ @@ -17,10 +18,12 @@ @Transactional public interface ExperimentConfigurationDao { - public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Integer id); + public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Long id); public <E extends ExperimentConfiguration> E find(final Class<E> configurationClass, final String experimentName); - public void persist(ExperimentConfiguration configuration); + public void persist(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration); + + public void delete(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration); } Modified: trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/src/java/edu/indiana/psych/gee/dao/HibernateExperimentConfigurationDao.java 2006-05-24 18:17:59 UTC (rev 183) @@ -10,6 +10,7 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentRoundParameters; /** * $Id: Exp $ @@ -25,7 +26,7 @@ private final Log logger = LogFactory.getLog(getClass()); - public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Integer id) { + public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Long id) { return configurationClass.cast(getHibernateTemplate().get(configurationClass, id)); } @@ -33,7 +34,6 @@ 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(); @@ -41,8 +41,12 @@ })); } - public void persist(ExperimentConfiguration configuration) { - getHibernateTemplate().saveOrUpdate(configuration); + public void persist(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration) { + getHibernateTemplate().saveOrUpdate(configuration); } + public void delete(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration) { + getHibernateTemplate().delete(configuration); + } + } 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-19 00:48:18 UTC (rev 182) +++ trunk/gee/src/java/edu/indiana/psych/gee/forager/ForagerConfiguration.java 2006-05-24 18:17:59 UTC (rev 183) @@ -8,8 +8,10 @@ import javax.persistence.OneToMany; import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; -import javax.persistence.Transient; +import org.hibernate.annotations.Proxy; + +import edu.indiana.psych.gee.ExperimentConfiguration; import edu.indiana.psych.gee.bean.ExperimentConfigurationEntity; /** @@ -24,11 +26,11 @@ @Entity @PrimaryKeyJoinColumn(name="experiment_configuration_id") @Table(name="forager_configuration") +@Proxy(proxyClass=ExperimentConfiguration.class) public class ForagerConfiguration extends ExperimentConfigurationEntity<ForagerExperimentParameters> { private List<ForagerExperimentParameters> allParameters; - public ForagerConfiguration() { } 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-19 00:48:18 UTC (rev 182) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-05-24 18:17:59 UTC (rev 183) @@ -1,6 +1,7 @@ package edu.indiana.psych.gee.service; import edu.indiana.psych.gee.ExperimentConfiguration; +import edu.indiana.psych.gee.ExperimentRoundParameters; import edu.indiana.psych.gee.dao.ExperimentConfigurationDao; /** @@ -18,8 +19,10 @@ private ExperimentConfigurationDao experimentConfigurationDao; // private ConsentFormDao consentFormDao; + - public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Integer id) { + + public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Long id) { return experimentConfigurationDao.find(configurationClass, id); } @@ -38,9 +41,13 @@ return experimentConfigurationDao.find(configurationClass, experimentName); } - public void persist(ExperimentConfiguration configuration) { + public void persist(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration) { experimentConfigurationDao.persist(configuration); } + + public void delete(ExperimentConfiguration<? extends ExperimentRoundParameters> configuration) { + experimentConfigurationDao.delete(configuration); + } public void setExperimentConfigurationDao(ExperimentConfigurationDao experimentConfigurationDao) { this.experimentConfigurationDao = experimentConfigurationDao; Added: trunk/gee/src/java/edu/indiana/psych/gee/session/SessionData.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/session/SessionData.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/session/SessionData.java 2006-05-24 18:17:59 UTC (rev 183) @@ -0,0 +1,40 @@ +package edu.indiana.psych.gee.session; + +import edu.indiana.psych.gee.bean.AuthenticationToken; +import edu.indiana.psych.gee.bean.GeeAdministrator; + +/** + * $Id$ + * + * This class maintains all necessary state for a given session with a User. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision$ + */ + +public class SessionData { + + private AuthenticationToken authenticationToken; + + public GeeAdministrator getUser() { + return (isAuthenticated()) + ? authenticationToken.getGeeAdministrator() + : null; + } + + public AuthenticationToken getAuthenticationToken() { + return authenticationToken; + } + + public void clearAuthenticationToken() { + authenticationToken = null; + } + + public void setAuthenticationToken(AuthenticationToken token) { + this.authenticationToken = token; + } + + public boolean isAuthenticated() { + return authenticationToken != null && authenticationToken.isValid(); + } +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/session/SessionData.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id Added: trunk/gee/src/java/edu/indiana/psych/gee/session/SessionDataAware.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/session/SessionDataAware.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/session/SessionDataAware.java 2006-05-24 18:17:59 UTC (rev 183) @@ -0,0 +1,39 @@ +package edu.indiana.psych.gee.session; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * $Id$ + * + * This interface marks all classes that should be given a piece of SessionData. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision$ + */ + +public interface SessionDataAware { + + public void setSessionData(SessionData data); + + + public static abstract class Base implements SessionDataAware { + private Log logger = LogFactory.getLog(getClass()); + private SessionData data; + public void setSessionData(SessionData data) { + this.data = data; + } + public SessionData getSessionData() { + return data; + } + protected Log getLogger() { + return logger; + } + } + +} + + +/* + * $Log: $ + */ Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/session/SessionDataAware.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id Modified: trunk/gee/war/WEB-INF/applicationContext.xml =================================================================== --- trunk/gee/war/WEB-INF/applicationContext.xml 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/war/WEB-INF/applicationContext.xml 2006-05-24 18:17:59 UTC (rev 183) @@ -82,13 +82,13 @@ <property name='triggeredExperiment' value='true'/> </bean> <bean id="forager-web" class="edu.indiana.psych.gee.forager.ForagerExperiment"> - <constructor-arg ref="defaultForagerWebConfiguration"/> - <constructor-arg ref="configurationService"/> + <property name="defaultConfiguration" ref="defaultForagerWebConfiguration"/> + <property name="configurationService" ref='configurationService'/> <property name="experimentService" ref="experimentService"/> </bean> <bean id="forager-experiment" class="edu.indiana.psych.gee.forager.ForagerExperiment"> - <constructor-arg ref="defaultForagerExperimentConfiguration"/> - <constructor-arg ref="configurationService"/> + <property name="defaultConfiguration" ref="defaultForagerExperimentConfiguration"/> + <property name="configurationService" ref='configurationService'/> <property name="experimentService" ref="experimentService"/> </bean> </beans> Modified: trunk/gee/war/WEB-INF/classes/gee-admin.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/war/WEB-INF/classes/gee-admin.xml 2006-05-24 18:17:59 UTC (rev 183) @@ -8,30 +8,14 @@ admin package o' actions and urls. define the login filter here? --> <package name="admin" extends="default" namespace="/admin"> - <action name="index" class="edu.indiana.psych.gee.action.AdminAction" method="authenticate"> + + <action name="index" class="edu.indiana.psych.gee.action.AuthenticateAction" method="authenticate"> <result name="success" type="freemarker">listExperiments.jsp</result> <result name="error">error.jsp</result> </action> - <action name="configure" class="edu.indiana.psych.gee.action.AdminAction" method="configure"> - <result name="success" type="freemarker">configureExperiment.jsp</result> - </action> - <action name="list" class="edu.indiana.psych.gee.action.AdminAction" method="listExperiments"> + <action name="experiment" class="edu.indiana.psych.gee.action.ManageExperiment"> <result name="success" type="freemarker">listExperiments.jsp</result> - <result name="error">error.jsp</result> + <result name="input">configureExperiment.jsp</result> </action> - <action name="create" class="edu.indiana.psych.gee.action.AdminAction" method="createExperiment"> - <result name="success" type="redirect">listExperiments.jsp</result> - <result name="input">createExperiment.jsp</result> - </action> - <action name="start" class="edu.indiana.psych.gee.action.AdminAction" method="start"> - <result name="success" type="freemarker">listExperiments.jsp</result> - </action> - <action name="stop" class="edu.indiana.psych.gee.action.AdminAction" method="stop"> - <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> </xwork> Modified: trunk/gee/war/WEB-INF/classes/webwork.properties =================================================================== --- trunk/gee/war/WEB-INF/classes/webwork.properties 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/war/WEB-INF/classes/webwork.properties 2006-05-24 18:17:59 UTC (rev 183) @@ -1,4 +1,3 @@ webwork.objectFactory=spring webwork.devMode=true - webwork.ui.theme=ajax Modified: trunk/gee/war/admin/listExperiments.jsp =================================================================== --- trunk/gee/war/admin/listExperiments.jsp 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/war/admin/listExperiments.jsp 2006-05-24 18:17:59 UTC (rev 183) @@ -1,6 +1,5 @@ <head> <meta name="lastModifiedDate" content="$Date$"/> -<@ww.head theme="ajax"/> <title>Experiment Statuses</title> </head> <body> @@ -24,22 +23,15 @@ <td width="10%"><span class='highlight'>${name}</span></td> <td width="50%">${description}</td> <td width="15%"> - <@ww.div id="status" href="/ajax/status.action?experimentName=${name}" listenTopics="start, stop"> - ${running?string("running", "not running")} - </@ww.div> + ${running?string("running", "not running")} </td> <td width="25%"> ( - <@ww.a id="start" href="start.action?experimentName=${name}" notifyTopics="start"> - Start - </@ww.a> + <a href="experiment!start.action?experimentName=${name}">Start<a> | - <@ww.a id="stop" href='stop.action?experimentName=${name}' notifyTopics="stop" > - Stop - </@ww.a> + <a href='experiment!stop.action?experimentName=${name}'>Stop<a> | - <a href='<@ww.url action="configure" experimentName="${name}" />'> - Edit</a> + <a href='experiment!configure.action?experimentName=${name}'>Edit</a> ) </td> </tr> Modified: trunk/gee/war/ajax/status.ajax =================================================================== --- trunk/gee/war/ajax/status.ajax 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/war/ajax/status.ajax 2006-05-24 18:17:59 UTC (rev 183) @@ -1 +1 @@ -<font color='brown'>${experiment.running?string("running", "not running")}</font> +<font color="blue">${experiment.running?string("running", "not running")}</font> Modified: trunk/gee/war/includes/header.jsp =================================================================== --- trunk/gee/war/includes/header.jsp 2006-05-19 00:48:18 UTC (rev 182) +++ trunk/gee/war/includes/header.jsp 2006-05-24 18:17:59 UTC (rev 183) @@ -1,12 +1,4 @@ <%@ taglib prefix="ww" uri="webwork" %> -<head> -<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> -</script> -<script type="text/javascript"> -_uacct = "UA-321755-2"; -urchinTracker(); -</script> -</head> <TABLE BGCOLOR="#A4B5C5" CELLPADDING="4" CELLSPACING="0" WIDTH="100%" BORDER="0"> <TR> <TD><img src='images/gee.png'/><b>Group Experiments Environment</b></td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
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-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 out = new ObjectOutputStream(socket.getOutputStream()); + out.writeObject(event); + out.flush(); + } // XXX: don't close() the stream. It closes the wrapped Socket // output stream and essentially fubars the socket. } @@ -92,8 +95,8 @@ return (Event) in.readObject(); } - public Event readEvent() throws IOException, ClassNotFoundException { - return readEvent(socket); + public synchronized Event readEvent() throws IOException, ClassNotFoundException { + return SocketDispatcherWorker.readEvent(socket); } public Socket getSocket() { Copied: trunk/gee/src/java/edu/indiana/psych/gee/net/event/ClientReadyEvent.java (from rev 179, trunk/gee/src/java/edu/indiana/psych/gee/net/ClientReadyEvent.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/event/ClientReadyEvent.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/event/ClientReadyEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -0,0 +1,24 @@ +package edu.indiana.psych.gee.net.event; + +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); + } + +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/net/event/ClientReadyEvent.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: trunk/gee/src/java/edu/indiana/psych/gee/net/event/ConnectionEvent.java (from rev 179, trunk/gee/src/java/edu/indiana/psych/gee/net/ConnectionEvent.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/event/ConnectionEvent.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/event/ConnectionEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -0,0 +1,23 @@ +package edu.indiana.psych.gee.net.event; + +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); + } +} + Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/net/event/ConnectionEvent.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionEvent.java (from rev 179, trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionEvent.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionEvent.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -0,0 +1,23 @@ +package edu.indiana.psych.gee.net.event; + +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); + } +} + Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionEvent.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionRequest.java (from rev 179, trunk/gee/src/java/edu/indiana/psych/gee/net/DisconnectionRequest.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionRequest.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionRequest.java 2006-05-18 05:18:18 UTC (rev 180) @@ -0,0 +1,32 @@ +package edu.indiana.psych.gee.net.event; + +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; + } +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/net/event/DisconnectionRequest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: trunk/gee/src/java/edu/indiana/psych/gee/net/event/ExperimentUpdateEvent.java (from rev 179, trunk/gee/src/java/edu/indiana/psych/gee/net/ExperimentUpdateEvent.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/event/ExperimentUpdateEvent.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/event/ExperimentUpdateEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -0,0 +1,16 @@ +package edu.indiana.psych.gee.net.event; + +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 { + +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/net/event/ExperimentUpdateEvent.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: trunk/gee/src/java/edu/indiana/psych/gee/net/event/ServerAssignedIdentifierEvent.java (from rev 179, trunk/gee/src/java/edu/indiana/psych/gee/net/ServerAssignedIdentifierEvent.java) =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/net/event/ServerAssignedIdentifierEvent.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/net/event/ServerAssignedIdentifierEvent.java 2006-05-18 05:18:18 UTC (rev 180) @@ -0,0 +1,23 @@ +package edu.indiana.psych.gee.net.event; + +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); + } +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/net/event/ServerAssignedIdentifierEvent.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormDao.java 2006-05-18 05:18:18 UTC (rev 180) @@ -2,7 +2,7 @@ import org.springframework.transaction.annotation.Transactional; -import edu.indiana.psych.gee.ConsentForm; +import edu.indiana.psych.gee.bean.ConsentForm; /** * $Id: Exp$ 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-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ConsentFormService.java 2006-05-18 05:18:18 UTC (rev 180) @@ -2,7 +2,7 @@ import java.util.List; -import edu.indiana.psych.gee.ConsentForm; +import edu.indiana.psych.gee.bean.ConsentForm; /** * $Id: Exp $ 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-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-05-18 05:18:18 UTC (rev 180) @@ -20,11 +20,6 @@ private ExperimentConfigurationDao experimentConfigurationDao; private ConsentFormDao consentFormDao; - public <E extends ExperimentConfiguration> E load(Class<E> configurationClass, InputStream stream) { - - return null; - } - public <E extends ExperimentConfiguration> E find(Class<E> configurationClass, Integer id) { return experimentConfigurationDao.find(configurationClass, id); } Modified: trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java 2006-05-17 23:11:47 UTC (rev 179) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java 2006-05-18 05:18:18 UTC (rev 180) @@ -2,7 +2,7 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport; -import edu.indiana.psych.gee.ConsentForm; +import edu.indiana.psych.gee.bean.ConsentForm; /** * $Id$ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-05-17 23:11:51
|
Revision: 179 Author: alllee Date: 2006-05-17 16:11:47 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=179&view=rev Log Message: ----------- adding very simple participant validation Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/bean/Participant-validation.xml Added: trunk/gee/src/java/edu/indiana/psych/gee/bean/Participant-validation.xml =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/bean/Participant-validation.xml (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/bean/Participant-validation.xml 2006-05-17 23:11:47 UTC (rev 179) @@ -0,0 +1,19 @@ +<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" +"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<!-- +vim:sts=2:sw=2: +--> +<validators> + <field name="name"> + <field-validator type="requiredstring"> + <message>Please enter your name.</message> + </field-validator> + </field> + <field name="age"> + <field-validator type="fieldexpression"> + <param name="expression">age neq "Under 18"</param> + <message>You must be over 18 to participate.</message> + </field-validator> + </field> +</validators> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-05-17 23:11:08
|
Revision: 178 Author: alllee Date: 2006-05-17 16:10:56 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=178&view=rev Log Message: ----------- converted consent.jsp to freemarker, improving validation and overall webwork usage. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment-validation.xml trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java trunk/gee/war/WEB-INF/classes/xwork.xml trunk/gee/war/consent.jsp trunk/gee/war/css/gee.css trunk/gee/war/includes/header.jsp trunk/gee/war/index.jsp trunk/gee/war/template.jsp Added Paths: ----------- trunk/gee/war/images/gee.png Modified: trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-05-17 22:29:35 UTC (rev 177) +++ trunk/gee/src/java/edu/indiana/psych/gee/ConsentForm.java 2006-05-17 23:10:56 UTC (rev 178) @@ -27,6 +27,7 @@ // are longs overkill? private Long id = Long.valueOf(-1); + private String studyNumber; private String description; private String deception; private String confidentiality; Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment-validation.xml =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment-validation.xml 2006-05-17 22:29:35 UTC (rev 177) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment-validation.xml 2006-05-17 23:10:56 UTC (rev 178) @@ -4,43 +4,10 @@ vim:sts=2:sw=2: --> <validators> - <field name="participantName"> - <field-validator type="requiredstring"> - <message>Please enter a name.</message> + <field name="participant"> + <field-validator type="visitor"> + <message/> </field-validator> </field> - <field name="participantAge"> - <field-validator type="int"> - <param name="min">18</param> - <message>You must be 18 or older.</message> - </field-validator> - </field> - - <!-- other sample validators. - <field name="bar2"> - <field-validator type="regex"> - <param name="regex">[0-9],[0-9]</param> - <message>The value of bar2 must be in the format "x, y", where x and y are between 0 and 9</message> - </field-validator> - </field> - <field name="date"> - <field-validator type="date"> - <param name="min">12/22/2002</param> - <param name="max">12/25/2002</param> - <message>The date must be between 12-22-2002 and 12-25-2002.</message> - </field-validator> - </field> - <field name="foo"> - <field-validator type="int"> - <param name="min">0</param> - <param name="max">100</param> - <message key="foo.range">Could not find foo.range!</message> - </field-validator> - </field> - <validator type="expression"> - <param name="expression"<foo < bar</param> - <message>Foo must be greater than Bar. Foo = ${foo}, Bar = ${bar}.</message> - </validator> - --> </validators> 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 22:29:35 UTC (rev 177) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-05-17 23:10:56 UTC (rev 178) @@ -2,6 +2,7 @@ import edu.indiana.psych.gee.ConsentForm; import edu.indiana.psych.gee.Experiment; +import edu.indiana.psych.gee.bean.Participant; /** * $Id$ @@ -14,14 +15,16 @@ public class StartExperiment extends GeeAction { private String experimentName; - - private int participantAge; - private String participantName; + private Participant participant; private ConsentForm consentForm; - private String message; public String prepare() { - return SUCCESS; + 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()); + } + return INPUT; } public String start() { @@ -34,18 +37,11 @@ } } - public String getMessage() { - return message; - } - public Experiment getExperiment() { return getExperimentService().find(experimentName); } public ConsentForm getConsentForm() { - if (consentForm == null) { - consentForm = getExperiment().getConsentForm(); - } return consentForm; } @@ -57,20 +53,12 @@ this.experimentName = experimentName; } - public void setParticipantAge(int participantAge) { - this.participantAge = participantAge; + public Participant getParticipant() { + return participant; } - public int getParticipantAge() { - return participantAge; + public void setParticipant(Participant participant) { + this.participant = participant; } - public void setParticipantName(String participantName) { - this.participantName = participantName; - } - - public String getParticipantName() { - return participantName; - } - } Modified: trunk/gee/war/WEB-INF/classes/xwork.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/xwork.xml 2006-05-17 22:29:35 UTC (rev 177) +++ trunk/gee/war/WEB-INF/classes/xwork.xml 2006-05-17 23:10:56 UTC (rev 178) @@ -37,17 +37,17 @@ <default-interceptor-ref name="geeDefaultStack"/> <!-- the start page lists all available experiments --> <action name="index" class="edu.indiana.psych.gee.action.ListExperiments"> - <result name="success" type="freemarker">index.jsp</result> + <result type="freemarker">index.jsp</result> </action> <action name="start" class="edu.indiana.psych.gee.action.StartExperiment" method="start"> - <result name="success" type="freemarker">startExperiment.jsp</result> - <result name="input">consent.jsp</result> + <result type="freemarker">startExperiment.jsp</result> + <result name="input" type="freemarker">consent.jsp</result> </action> <action name="consent" class="edu.indiana.psych.gee.action.StartExperiment" method="prepare"> <!-- FIXME: do not use a validating stack here --> <interceptor-ref name="basicStack"/> - <result name="success">consent.jsp</result> - <result name="input">consent.jsp</result> + <result type="freemarker">consent.jsp</result> + <result name="input" type="freemarker">consent.jsp</result> </action> </package> <include file="gee-ajax.xml"/> Modified: trunk/gee/war/consent.jsp =================================================================== --- trunk/gee/war/consent.jsp 2006-05-17 22:29:35 UTC (rev 177) +++ trunk/gee/war/consent.jsp 2006-05-17 23:10:56 UTC (rev 178) @@ -1,23 +1,18 @@ -<%@ taglib prefix="ww" uri="webwork" %> <head> -<title> Consent Form for [ <ww:property value="experimentName"/> ]</title> - <% - String commitDate = "$Date$"; - java.util.StringTokenizer toke = new java.util.StringTokenizer(commitDate, " "); - toke.nextToken(); - String lastModifiedDate = toke.nextToken(); - %> -<meta name="lastModifiedDate" content="<%= commitDate %>"/> +<title> Consent Form for ${experimentName}</title> +<#assign commitDate="$Date$"> +<#assign lastModified=commitDate?word_list[1]> +<meta name="lastModifiedDate" content="${commitDate}"/> </head> <TABLE BGCOLOR="#A4B5C5" CELLPADDING="4" CELLSPACING="0" WIDTH="100%" BORDER="0"> <TR> <TD WIDTH="100%"> - <H3><ww:property value="experimentName"/> consent form</H3> + <H3>${experimentName} consent form</H3> </TD> <TD ALIGN="right" VALIGN="top" BGCOLOR="#A4B5C5" WIDTH="70%" style="white-space: nowrap;"> <b>Study #04-9064</b><br/> - <small>Last Modified: <%= lastModifiedDate %></small> + <small>Last Modified: ${lastModified}</small> </TD> </TR> </TABLE> @@ -25,8 +20,7 @@ <TABLE CELLPADDING="4" CELLSPACING="2" BORDER="0"> <TR> <TD> - - <B>Forager</B><BR> + <B>${experimentName} consent form</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> @@ -131,24 +125,23 @@ <p style="font-weight: bolder; background-color: #FFE303;">I have read and understand the information presented above. I agree to participate in this study.</p> -<ww:form method="post" validate="true" action='start'> - <ww:select label="Age" name="participantAge" required="true" - list="#{'17':'Under 18', '18':'18-24', '25':'25-36', '37':'37-55', '55':'Over 55'}" - value="'18'"/> - <ww:textfield label="Name" name="participantName" required="true" /> - <ww:hidden name="experimentName"/> - <ww:submit/> -</ww:form> +<@ww.form method="post" action='start' validate='true'> + <@ww.select label="Age" name="participant.age" required="true" + list=["Under 18", "18-24", "25-36", "37-55", "Over 55"]/> + <@ww.textfield label="Name" name="participant.name" required="true" /> + <@ww.hidden name="experimentName"/> + <@ww.submit/> +</@ww.form> <hr /> <small> IRB Approved <br/> -<ww:text name="approval.date"> - <ww:param name="value" value="%{consentForm.irbDateApproved}"/> -</ww:text> +<@ww.text name="approval.date"> + <@ww.param name="value" value="%{consentForm.irbDateApproved}"/> +</@ww.text> <br/> -<ww:text name="approval.expiration.date"> - <ww:param name="value" value="%{consentForm.irbDateApprovalExpires}"/> -</ww:text> +<@ww.text name="approval.expiration.date"> + <@ww.param name="value" value="%{consentForm.irbDateApprovalExpires}"/> +</@ww.text> </small> Modified: trunk/gee/war/css/gee.css =================================================================== --- trunk/gee/war/css/gee.css 2006-05-17 22:29:35 UTC (rev 177) +++ trunk/gee/war/css/gee.css 2006-05-17 23:10:56 UTC (rev 178) @@ -5,6 +5,12 @@ font-family: helvetica, arial, sans-serif; } +.frame { margin: 5px 20px 5px 20px; font-size: 90%; } +.frame .content { margin: 0px; } + +.note { border: solid 1px #7099C5; background-color: #f0f0ff; } +.note .label { background-color: #7099C5; color: #ffffff; } + #Error { color: #802A2A; font-weight: bold; Added: trunk/gee/war/images/gee.png =================================================================== (Binary files differ) Property changes on: trunk/gee/war/images/gee.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/gee/war/includes/header.jsp =================================================================== --- trunk/gee/war/includes/header.jsp 2006-05-17 22:29:35 UTC (rev 177) +++ trunk/gee/war/includes/header.jsp 2006-05-17 23:10:56 UTC (rev 178) @@ -1 +1,23 @@ +<%@ taglib prefix="ww" uri="webwork" %> +<head> +<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> +</script> +<script type="text/javascript"> +_uacct = "UA-321755-2"; +urchinTracker(); +</script> +</head> +<TABLE BGCOLOR="#A4B5C5" CELLPADDING="4" CELLSPACING="0" WIDTH="100%" BORDER="0"> + <TR> + <TD><img src='images/gee.png'/><b>Group Experiments Environment</b></td> + </TR> +</TABLE> +<div class="frame note"> +<div class="label">Note</div> +<div class="content"> +This web application is still under development and may not function properly. +Please visit <a href='http://groups.psych.indiana.edu'>http://groups.psych.indiana.edu</a> to +try our experiments. Thanks! +</div> +</div> Modified: trunk/gee/war/index.jsp =================================================================== --- trunk/gee/war/index.jsp 2006-05-17 22:29:35 UTC (rev 177) +++ trunk/gee/war/index.jsp 2006-05-17 23:10:56 UTC (rev 178) @@ -2,16 +2,6 @@ <meta name="lastModifiedDate" content="$Date$"/> </head> -<TABLE BGCOLOR="#A4B5C5" CELLPADDING="4" CELLSPACING="0" WIDTH="100%" BORDER="0"> - <TR> - <TD WIDTH="100%"> - <H3>Group Experiments Environment</H3> - </TD> - <td> </td> - </TR><TR> - <td colspan="2"> </td> - </TR> -</TABLE> <I><center>Welcome to the Group Experiments Environment (GEE) project!</center></I> <hr/> <P> Modified: trunk/gee/war/template.jsp =================================================================== --- trunk/gee/war/template.jsp 2006-05-17 22:29:35 UTC (rev 177) +++ trunk/gee/war/template.jsp 2006-05-17 23:10:56 UTC (rev 178) @@ -11,8 +11,8 @@ <decorator:head /> </head> <body> + <div id="Content"> <%@ include file="/includes/header.jsp" %> - <div id="Content"> <decorator:body /> <%@ include file="/includes/footer.jsp" %> 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-17 00:06:29
|
Revision: 176 Author: alllee Date: 2006-05-16 17:06:26 -0700 (Tue, 16 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=176&view=rev Log Message: ----------- ping pong Added Paths: ----------- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java 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-05-17 00:06:26 UTC (rev 176) @@ -0,0 +1,26 @@ +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); + +} Property changes on: trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationDao.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id Added: trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java (rev 0) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/HibernateConsentFormDao.java 2006-05-17 00:06:26 UTC (rev 176) @@ -0,0 +1,26 @@ +package edu.indiana.psych.gee.service; + +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + +import edu.indiana.psych.gee.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/service/HibernateConsentFormDao.java ___________________________________________________________________ Name: svn:keywords + Date Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-05-17 00:06:17
|
Revision: 175 Author: alllee Date: 2006-05-16 17:06:07 -0700 (Tue, 16 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=175&view=rev Log Message: ----------- making the webapp deployable again, fixing Spring wiring. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java trunk/gee/war/WEB-INF/applicationContext.xml 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-17 00:00:59 UTC (rev 174) +++ trunk/gee/src/java/edu/indiana/psych/gee/service/ExperimentConfigurationService.java 2006-05-17 00:06:07 UTC (rev 175) @@ -17,7 +17,7 @@ public class ExperimentConfigurationService { - private HibernateExperimentConfigurationDao experimentConfigurationDao; + private ExperimentConfigurationDao experimentConfigurationDao; private ConsentFormDao consentFormDao; public <E extends ExperimentConfiguration> E load(Class<E> configurationClass, InputStream stream) { @@ -48,7 +48,7 @@ experimentConfigurationDao.persist(configuration); } - public void setExperimentConfigurationDao(HibernateExperimentConfigurationDao experimentConfigurationDao) { + public void setExperimentConfigurationDao(ExperimentConfigurationDao experimentConfigurationDao) { this.experimentConfigurationDao = experimentConfigurationDao; } Modified: trunk/gee/war/WEB-INF/applicationContext.xml =================================================================== --- trunk/gee/war/WEB-INF/applicationContext.xml 2006-05-17 00:00:59 UTC (rev 174) +++ trunk/gee/war/WEB-INF/applicationContext.xml 2006-05-17 00:06:07 UTC (rev 175) @@ -53,7 +53,7 @@ <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- persistence layer daos--> - <bean id="experimentConfigurationDao" class="edu.indiana.psych.gee.service.ExperimentConfigurationDao"> + <bean id="experimentConfigurationDao" class="edu.indiana.psych.gee.service.HibernateExperimentConfigurationDao"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="consentFormDao" class="edu.indiana.psych.gee.service.HibernateConsentFormDao"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-05-17 00:01:11
|
Revision: 174 Author: alllee Date: 2006-05-16 17:00:59 -0700 (Tue, 16 May 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=174&view=rev Log Message: ----------- spring's hibernate3 support has been factored into this jar. Added Paths: ----------- trunk/gee/war/WEB-INF/lib/spring-hibernate3.jar Added: trunk/gee/war/WEB-INF/lib/spring-hibernate3.jar =================================================================== (Binary files differ) Property changes on: trunk/gee/war/WEB-INF/lib/spring-hibernate3.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |