Thread: [virtualcommons-svn] SF.net SVN: virtualcommons:[348] mentalmodels/trunk (Page 3)
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-10-29 22:39:06
|
Revision: 348 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=348&view=rev Author: kjonas Date: 2009-10-29 22:38:51 +0000 (Thu, 29 Oct 2009) Log Message: ----------- Modified the code for creating new locations to try and accommodate the changes to Location class that Seema made. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf mentalmodels/trunk/src/main/webapp/StartGame.swf mentalmodels/trunk/src/main/webapp/test.swf Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -297,7 +297,7 @@ str += ">\n"; } selectCurrentWindows( tempArray ); - Alert.show(str,"Information Windows:"); +// Alert.show(str,"Information Windows:"); } } Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-10-29 22:38:51 UTC (rev 348) @@ -32,9 +32,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -32,9 +32,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -38,9 +38,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -19,9 +19,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -41,9 +41,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -43,9 +43,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -38,9 +38,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -18,9 +18,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -11,9 +11,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-10-29 21:26:06 UTC (rev 347) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-10-29 22:38:51 UTC (rev 348) @@ -53,9 +53,7 @@ private function newLocation(maxCapacity:Number,growth:Number):Location { var newLoc:Location = new Location(); - newLoc.maxCapacity = maxCapacity; newLoc.growthRate = growth; - newLoc.initialPopulation = maxCapacity / 2.0; return newLoc; } Modified: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/StartGame.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/test.swf =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-10-29 23:15:46
|
Revision: 349 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=349&view=rev Author: kjonas Date: 2009-10-29 23:15:38 +0000 (Thu, 29 Oct 2009) Log Message: ----------- Trying to code the passing of the list of locations so that it can be passed later in the experiment if something goes wrong (with small delay only) Modified Paths: -------------- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf mentalmodels/trunk/src/main/webapp/StartGame.swf mentalmodels/trunk/src/main/webapp/test.swf Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-10-29 22:38:51 UTC (rev 348) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-10-29 23:15:38 UTC (rev 349) @@ -17,7 +17,7 @@ <mx:State name="instructionsLoad"> <mx:AddChild relativeTo="{content}"> <comp:InstructionPage id="instructions" initialize="gotoInstructions()" x="0" y="0" - preinitialize="instructions.locations=locations"/> + preinitialize="instructions.setLocations(locations)"/> </mx:AddChild> </mx:State> @@ -422,7 +422,12 @@ { if(event.result is ArrayCollection) { + Alert.show(""+(event.result as ArrayCollection).length,"locations received"); locations = event.result as ArrayCollection; + if(instructions != null) + { + instructions.setLocations(locations); + } } } private function strategyResultHandler(event:ResultEvent):void Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-10-29 22:38:51 UTC (rev 348) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-10-29 23:15:38 UTC (rev 349) @@ -222,6 +222,15 @@ return block; } + public function setLocations(newLocations:ArrayCollection):void + { + locations = newLocations; + if(pageDisplay != null) + { + pageDisplay.locations = newLocations; + } + } + ]]> </mx:Script> Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-10-29 22:38:51 UTC (rev 348) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-10-29 23:15:38 UTC (rev 349) @@ -143,7 +143,7 @@ { assignGroups(game); getLogger().debug("system has assigned groups. "); - //pushBlock(game); + pushBlock(game); flag = true; } else Modified: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/StartGame.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/test.swf =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-11-20 18:22:01
|
Revision: 373 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=373&view=rev Author: seematalele Date: 2009-11-20 18:21:53 +0000 (Fri, 20 Nov 2009) Log Message: ----------- 1)Re factored code. Removed some unwanted java service files. Changed the applicationContext.xml also. 2)Changed the entities in Server side, so changed the actionscript class files too. 3)Written Strategy Execution algorithm for non repeated decisions and also for repeated decisions. But for Repeated decisions, checking of suspend condition needs to be done. 3)Testing (successfully) - Non repeated decisions. Repeated conditions WITHOUT suspend condition. Game object is sent to the client (instead of pushing block, pushing the game state). DayByDayDecisions 4)Next Tasks - Execute repeated decisions with suspend condition. Test DayByDayDecisions and StrategyExecution with client GUI. Create communication Component and configure and write code for chatting also. Modified Paths: -------------- mentalmodels/trunk/flex/src/StartGame.mxml mentalmodels/trunk/flex/src/actionscript/DayByDayDecisions.as mentalmodels/trunk/flex/src/actionscript/Round.as mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml mentalmodels/trunk/src/main/db/init-mme.sql mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/SuspendRepetition.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml Added Paths: ----------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateSuspendRepetitionDao.java Removed Paths: ------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/Feed.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java Modified: mentalmodels/trunk/flex/src/StartGame.mxml =================================================================== --- mentalmodels/trunk/flex/src/StartGame.mxml 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/StartGame.mxml 2009-11-20 18:21:53 UTC (rev 373) @@ -161,7 +161,7 @@ private function messageHandler(event:MessageEvent):void { //Alert.show("message from server came.."); - if(event.message.body as actionscript.Block) + /* if(event.message.body as actionscript.Block) { var block:actionscript.Block = event.message.body as actionscript.Block; //Alert.show("String came from server is: " + block.id + " " + block.description); @@ -176,8 +176,31 @@ else if(event.message.body as ArrayCollection) { Alert.show("something else "); + } */ + if(event.message.body as actionscript.Game) + { + var game:actionscript.Game = event.message.body as actionscript.Game; + //Alert.show("String came from server is: " + block.id + " " + block.description); + + if(game == null) + { + Alert.show("Game is over!!"); + } + else + Alert.show("Block from server is : " + game.currentBlock.description); } + else if(event.message.body as ArrayCollection) + { + Alert.show("something else "); + } + else if(event.message.body as int) + { + Alert.show((event.message.body as int).toString()); + } + + + } ]]> Modified: mentalmodels/trunk/flex/src/actionscript/DayByDayDecisions.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DayByDayDecisions.as 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/actionscript/DayByDayDecisions.as 2009-11-20 18:21:53 UTC (rev 373) @@ -12,6 +12,6 @@ public var earnings:Number; public var money:Number; public var student:actionscript.Student; - public var otherStudents:ArrayCollection; + public var studentStrategy:StudentStrategy; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/Round.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Round.as 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/actionscript/Round.as 2009-11-20 18:21:53 UTC (rev 373) @@ -8,9 +8,6 @@ public class Round { public var id:Number; - public var roundNo:int; - public var game:Game; public var communicationFlag:Boolean; - public var roundLocations:ArrayCollection; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as 2009-11-20 18:21:53 UTC (rev 373) @@ -13,7 +13,9 @@ public var days:int; public var threshold:Number; public var location:Location; - public var repeatedDecisions:Boolean; + public var repeatedDecision:Boolean; public var round:actionscript.Round; + public var dayBydayDecisions:ArrayCollection; + public var repeatedDecisionNo:int; } } Modified: mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as 2009-11-20 18:21:53 UTC (rev 373) @@ -6,9 +6,9 @@ public class SuspendRepetition { public var id:Number; - public var roundConfig:Round; - public var student:Student; + public var round:Round; + public var student:actionscript.Student; public var daysInHarbor:int; - public var fishingThreshold:Number; + public var threshold:Number; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-11-20 18:21:53 UTC (rev 373) @@ -136,7 +136,7 @@ tempObject.round = notRepeated.round; tempObject.allocationSeqNo = i; - tempObject.repeatedDecisions = false; + tempObject.repeatedDecision = false; array.addItem(tempObject); } @@ -150,7 +150,7 @@ tempObject.round = repeated.round; tempObject.allocationSeqNo = i+notRepeatedArray.length; - tempObject.repeatedDecisions = true; + tempObject.repeatedDecision = true; array.addItem(tempObject); } Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-11-20 18:21:53 UTC (rev 373) @@ -218,11 +218,14 @@ `earnings` double DEFAULT NULL, `location_id` bigint(20) NOT NULL, `student_id` bigint(20) NOT NULL, + `studentStrategy_id` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`), KEY `FK5B92B164224FD013` (`location_id`), KEY `FK5B92B164992B5A41` (`student_id`), - CONSTRAINT `FK5B92B164992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`), - CONSTRAINT `FK5B92B164224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`) + KEY `FK5B92B164A4A1AE81` (`studentStrategy_id`), + CONSTRAINT `FK5B92B164A4A1AE81` FOREIGN KEY (`studentStrategy_id`) REFERENCES `student_strategy` (`id`), + CONSTRAINT `FK5B92B164224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`), + CONSTRAINT `FK5B92B164992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -396,13 +399,16 @@ `fish_return` double DEFAULT NULL, `initial_population` double NOT NULL, `max_capacity` double NOT NULL, + `dayByDayDecsion_id` bigint(20) DEFAULT NULL, `group_id` bigint(20) NOT NULL, `location_id` bigint(20) NOT NULL, PRIMARY KEY (`id`), KEY `FKCFF7B975224FD013` (`location_id`), KEY `FKCFF7B97565663181` (`group_id`), - CONSTRAINT `FKCFF7B97565663181` FOREIGN KEY (`group_id`) REFERENCES `grp` (`id`), - CONSTRAINT `FKCFF7B975224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`) + KEY `FKCFF7B975A4684961` (`dayByDayDecsion_id`), + CONSTRAINT `FKCFF7B975A4684961` FOREIGN KEY (`dayByDayDecsion_id`) REFERENCES `day_by_day_decision` (`id`), + CONSTRAINT `FKCFF7B975224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`), + CONSTRAINT `FKCFF7B97565663181` FOREIGN KEY (`group_id`) REFERENCES `grp` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -813,7 +819,8 @@ `id` bigint(20) NOT NULL AUTO_INCREMENT, `allocation_sequence_no` int(11) NOT NULL, `days` int(11) NOT NULL, - `repeated_decisions` tinyint(1) NOT NULL, + `repeated_decision` tinyint(1) NOT NULL, + `repeated_decision_no` int(11) DEFAULT NULL, `threshold` double NOT NULL, `location_id` bigint(20) NOT NULL, `round_id` bigint(20) NOT NULL, @@ -847,14 +854,14 @@ CREATE TABLE `suspend_repetition` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `days_in_harbor` int(11) NOT NULL, - `fishing_threshold` float NOT NULL, - `roundConfig_id` bigint(20) NOT NULL, + `threshold` float NOT NULL, + `round_id` bigint(20) NOT NULL, `student_id` bigint(20) NOT NULL, PRIMARY KEY (`id`), - KEY `FKFBDC454297B31F` (`roundConfig_id`), + KEY `FKFBDC45447CF2321` (`round_id`), KEY `FKFBDC454992B5A41` (`student_id`), CONSTRAINT `FKFBDC454992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`), - CONSTRAINT `FKFBDC454297B31F` FOREIGN KEY (`roundConfig_id`) REFERENCES `round_config` (`id`) + CONSTRAINT `FKFBDC45447CF2321` FOREIGN KEY (`round_id`) REFERENCES `round_config` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -876,4 +883,4 @@ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2009-11-12 22:20:40 +-- Dump completed on 2009-11-20 18:10:50 Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateSuspendRepetitionDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateSuspendRepetitionDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateSuspendRepetitionDao.java 2009-11-20 18:21:53 UTC (rev 373) @@ -0,0 +1,11 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.SuspendRepetition; + +public class HibernateSuspendRepetitionDao extends HibernateDao<SuspendRepetition> { + + public HibernateSuspendRepetitionDao() + { + super(SuspendRepetition.class); + } +} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayByDayDecisions.java 2009-11-20 18:21:53 UTC (rev 373) @@ -36,6 +36,9 @@ @Column private Double earnings; + @ManyToOne + @JoinColumn(nullable=true) + private StudentStrategy studentStrategy; /*@OneToMany(mappedBy = "dayByDayDecision") @CollectionOfElements(fetch = FetchType.EAGER) private List<DayByDayOtherStudentDecisions> dayByDayOtherStudentDecisions;*/ @@ -80,6 +83,14 @@ return earnings; } + public void setStudentStrategy(StudentStrategy studentStrategy) { + this.studentStrategy = studentStrategy; + } + + public StudentStrategy getStudentStrategy() { + return studentStrategy; + } + /*public void setDayByDayOtherStudentDecisions( List<DayByDayOtherStudentDecisions> dayByDayOtherStudentDecisions) { this.dayByDayOtherStudentDecisions = dayByDayOtherStudentDecisions; Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GroupLocation.java 2009-11-20 18:21:53 UTC (rev 373) @@ -46,6 +46,11 @@ @Column(nullable=false,name="initial_population") private Double initialPopulation; + @ManyToOne + @JoinColumn(nullable=true) + private DayByDayDecisions dayByDayDecsion; + + public void setId(Long id) { this.id = id; } @@ -110,4 +115,12 @@ return initialPopulation; } + public void setDayByDayDecsion(DayByDayDecisions dayByDayDecsion) { + this.dayByDayDecsion = dayByDayDecsion; + } + + public DayByDayDecisions getDayByDayDecsion() { + return dayByDayDecsion; + } + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java 2009-11-20 18:21:53 UTC (rev 373) @@ -38,8 +38,6 @@ private String semester; - - @Column private Double money; Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java 2009-11-20 18:21:53 UTC (rev 373) @@ -2,17 +2,21 @@ import java.io.Serializable; - +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.Table; +import org.hibernate.annotations.CollectionOfElements; +import edu.asu.commons.mme.entity.DayByDayDecisions; + @Entity @Table(name="student_strategy") @@ -45,9 +49,20 @@ @JoinColumn(nullable=false) public Location location; - @Column (name="repeated_decisions",columnDefinition="Boolean", nullable=false) - public boolean repeatedDecisions; + @Column (name="repeated_decision",columnDefinition="Boolean", nullable=false) + public boolean repeatedDecision; + @Column (name="repeated_decision_no") + public Integer repeatedDecisionNo; + + public Integer getRepeatedDecisionNo() { + return repeatedDecisionNo; + } + + public void setRepeatedDecisionNo(Integer repeatedDecisionNo) { + this.repeatedDecisionNo = repeatedDecisionNo; + } + public void setId(Long id) { this.id = id; } @@ -80,12 +95,12 @@ return threshold; } - public void setRepeatedDecisions(boolean repeatedDecisions) { - this.repeatedDecisions = repeatedDecisions; + public void setRepeatedDecision(boolean repeatedDecision) { + this.repeatedDecision = repeatedDecision; } - public boolean isRepeatedDecisions() { - return repeatedDecisions; + public boolean isRepeatedDecision() { + return repeatedDecision; } public void setRound(Round round) { @@ -111,7 +126,13 @@ public Student getStudent() { return student; } - - - + + /*public void setDayBydayDecisions(List<DayByDayDecisions> dayBydayDecisions) { + this.dayBydayDecisions = dayBydayDecisions; + } + + public List<DayByDayDecisions> getDayBydayDecisions() { + return dayBydayDecisions; + }*/ + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/SuspendRepetition.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/SuspendRepetition.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/SuspendRepetition.java 2009-11-20 18:21:53 UTC (rev 373) @@ -33,8 +33,8 @@ @Column(name="days_in_harbor",nullable=false) private Integer daysInHarbor; - @Column(name="fishing_threshold",nullable=false) - private Float fishingThreshold; + @Column(name="threshold",nullable=false) + private Float threshold; public void setId(Long id) { this.id = id; @@ -52,28 +52,28 @@ return daysInHarbor; } - public void setFishingThreshold(Float fishingThreshold) { - this.fishingThreshold = fishingThreshold; + public void setStudent(Student student) { + this.student = student; } - public Float getFishingThreshold() { - return fishingThreshold; + public Student getStudent() { + return student; } - public void setRoundConfig(Round roundconfig) { - this.round = roundconfig; + public void setThreshold(Float threshold) { + this.threshold = threshold; } - public Round getRoundConfig() { - return round; + public Float getThreshold() { + return threshold; } - public void setStudent(Student student) { - this.student = student; + public void setRound(Round round) { + this.round = round; } - public Student getStudent() { - return student; + public Round getRound() { + return round; } } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java 2009-11-20 18:21:53 UTC (rev 373) @@ -1,32 +1,44 @@ package edu.asu.commons.mme.service; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; + + +import org.hibernate.Query; + import org.springframework.transaction.annotation.Transactional; import edu.asu.commons.mme.dao.HibernateDayByDayDecisionsDao; import edu.asu.commons.mme.dao.HibernateStudentResponseDao; import edu.asu.commons.mme.dao.HibernateStudentStrategyDao; +import edu.asu.commons.mme.dao.HibernateSuspendRepetitionDao; import edu.asu.commons.mme.entity.DayByDayDecisions; import edu.asu.commons.mme.entity.Student; import edu.asu.commons.mme.entity.StudentResponse; import edu.asu.commons.mme.entity.StudentStrategy; +import edu.asu.commons.mme.entity.SuspendRepetition; @Transactional public class AnsweringService extends Service.Base<StudentResponse, HibernateStudentResponseDao> { - - + + //private HibernateStudentDao studentDao; private HibernateStudentStrategyDao studentStrategyDao; //private HibernateDayByDayDecisionsDao dayByDayDecisionsDao; -// private DayByDayDecisionsService dayByDayDecisionsService; + // private DayByDayDecisionsService dayByDayDecisionsService; private ModuleService moduleService; private HibernateDayByDayDecisionsDao dayByDayDecisionsDao; - + private HibernateSuspendRepetitionDao suspendRepetitionDao; + StudentResponse studentResponse; StudentStrategy studentStrategy; Student student; - + + public static final String getLastDay = "SELECT max(d.dayNumber) FROM DayByDayDecisions d " + + "where d.student=:student"; + /** * This method is for Psychometric, Categorical and text question types. * @param studentResponses @@ -34,48 +46,91 @@ public void saveQuestion(List<StudentResponse> studentResponses) { StudentResponse clientStudentResponse = new StudentResponse(); - for(int i = 0; i < studentResponses.size(); i++ ) - { - clientStudentResponse = (StudentResponse) studentResponses.get(i); - getLogger().debug("Question is: " + clientStudentResponse.getQuestion()); - getLogger().debug("Response is: " + clientStudentResponse.getResponse()); - getLogger().debug("Student is: " + clientStudentResponse.getStudent()); - studentResponse = new StudentResponse(); - studentResponse.setQuestion(clientStudentResponse.getQuestion()); - studentResponse.setResponse(clientStudentResponse.getResponse()); - studentResponse.setStudent(clientStudentResponse.getStudent()); + for(int i = 0; i < studentResponses.size(); i++ ) + { + clientStudentResponse = (StudentResponse) studentResponses.get(i); + getLogger().debug("Question is: " + clientStudentResponse.getQuestion()); + getLogger().debug("Response is: " + clientStudentResponse.getResponse()); + getLogger().debug("Student is: " + clientStudentResponse.getStudent()); + studentResponse = new StudentResponse(); + studentResponse.setQuestion(clientStudentResponse.getQuestion()); + studentResponse.setResponse(clientStudentResponse.getResponse()); + studentResponse.setStudent(clientStudentResponse.getStudent()); - getDao().save(studentResponse); - } - + getDao().save(studentResponse); + } + } - + /** * this method is for saving strategies of students. * @param studentStrategies */ - + public void saveSuspendRepetition(SuspendRepetition suspendRepetition) + { + SuspendRepetition suspendDecision = new SuspendRepetition(); + suspendDecision.setDaysInHarbor(suspendRepetition.getDaysInHarbor()); + suspendDecision.setThreshold(suspendRepetition.getThreshold()); + suspendDecision.setStudent(suspendRepetition.getStudent()); + suspendDecision.setRound(suspendRepetition.getRound()); + suspendRepetitionDao.save(suspendDecision); + } public void saveStrategy(List<StudentStrategy> studentStrategies) { - StudentStrategy clientStudentStrategy = new StudentStrategy(); - for(int i = 0; i < studentStrategies.size(); i++ ) - { - clientStudentStrategy = (StudentStrategy) studentStrategies.get(i); - studentStrategy = new StudentStrategy(); - studentStrategy.setLocation(clientStudentStrategy.getLocation()); - studentStrategy.setAllocationSeqNo(clientStudentStrategy.getAllocationSeqNo()); - studentStrategy.setDays(clientStudentStrategy.getDays()); - studentStrategy.setRepeatedDecisions(clientStudentStrategy.isRepeatedDecisions()); - studentStrategy.setRound(clientStudentStrategy.getRound()); - studentStrategy.setStudent(clientStudentStrategy.getStudent()); - studentStrategy.setThreshold(clientStudentStrategy.getThreshold()); - getStudentStrategyDao().save(studentStrategy); - } + try{ + StudentStrategy clientStudentStrategy = null; + Integer lastDayNo = 0; + for(int i = 0; i < studentStrategies.size(); i++ ) + { + clientStudentStrategy = (StudentStrategy) studentStrategies.get(i); + if(clientStudentStrategy.getDays() != 0) + { + studentStrategy = new StudentStrategy(); + studentStrategy.setLocation(clientStudentStrategy.getLocation()); + studentStrategy.setAllocationSeqNo(clientStudentStrategy.getAllocationSeqNo()); + studentStrategy.setDays(clientStudentStrategy.getDays()); + studentStrategy.setRepeatedDecision(clientStudentStrategy.isRepeatedDecision()); + studentStrategy.setRound(clientStudentStrategy.getRound()); + studentStrategy.setStudent(clientStudentStrategy.getStudent()); + studentStrategy.setThreshold(clientStudentStrategy.getThreshold()); + studentStrategy.setRepeatedDecisionNo(clientStudentStrategy.getRepeatedDecisionNo()); + getStudentStrategyDao().save(studentStrategy); + + Query getLastDayForStudent = getStudentStrategyDao().getCurrentSession().createQuery(getLastDay); + getLastDayForStudent.setEntity("student", studentStrategy.getStudent()); + Iterator<?> lastdayIterator = getLastDayForStudent.list().iterator(); + getLogger().debug("Days are : " + studentStrategy.getDays()); + + while(lastdayIterator.hasNext()) + { + lastDayNo = (Integer) lastdayIterator.next(); + getLogger().debug("Last day Number is : " + lastDayNo); + if(lastDayNo == null) + { + lastDayNo = 0; + } + + } + //get previous day number + for(int dayNo = lastDayNo+1,counter=0; counter < studentStrategy.getDays(); dayNo++,counter++) + { + DayByDayDecisions decision = new DayByDayDecisions(); + decision.setLocation(studentStrategy.getLocation()); + decision.setStudent(studentStrategy.getStudent()); + decision.setDayNumber(dayNo); + decision.setStudentStrategy(studentStrategy); + dayByDayDecisionsDao.save(decision); + getLogger().debug("Student is : " + studentStrategy.getStudent().getId()); + } + } + } + }catch(Exception e) + { + e.printStackTrace(); + } } - - - - + + /*public void setDayByDayDecisionsDao(HibernateDayByDayDecisionsDao dayByDayDecisionsDao) { this.dayByDayDecisionsDao = dayByDayDecisionsDao; }*/ @@ -112,4 +167,12 @@ return dayByDayDecisionsDao; } + public void setSuspendRepetitionDao(HibernateSuspendRepetitionDao suspendRepetitionDao) { + this.suspendRepetitionDao = suspendRepetitionDao; + } + + public HibernateSuspendRepetitionDao getSuspendRepetitionDao() { + return suspendRepetitionDao; + } + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-11-20 18:21:53 UTC (rev 373) @@ -9,6 +9,7 @@ import org.hibernate.Query; import org.springframework.transaction.annotation.Transactional; + import edu.asu.commons.mme.dao.HibernateDayByDayDecisionsDao; import edu.asu.commons.mme.dao.HibernateDayByDayOtherStudentDecisionsDao; import edu.asu.commons.mme.dao.HibernateGameDao; @@ -91,12 +92,19 @@ static final String groupsWithinGame = "select distinct student.group from Student student where student.game =:current_game_id "; static final String studentDecisionsForGame = "SELECT d FROM DayByDayDecisions d, Student s where s.game =:game and s=d.student"; static final String getgroupLocation = "SELECT g FROM GroupLocation g where g.group =:group and g.location =:location"; - static final String getStudentStrategy = "SELECT ss FROM StudentStrategy ss,Student s where s.game =: game and s=d.student"; + //static final String getStudentStrategy = "SELECT ss FROM StudentStrategy ss,Student s where s.game =: game and s=d.student and ss.repeatedDecisions =: repeated_decisions"; + static final String getStudentDayByDayDecisionsFromStrategy = "SELECT dbd FROM DayByDayDecisions dbd,StudentStrategy ss,Student s " + + " where s.game =:game and s=ss.student and " + + " dbd.studentStrategy=ss and " + + " ss.repeatedDecision=:repeated_decisions"; + + static final String checkSuspendCondition=""; public void setGameDao(HibernateGameDao gameDao) { this.gameDao = gameDao; } + public void setLocationDao(HibernateLocationDao locationDao) { this.locationDao = locationDao; } @@ -178,9 +186,10 @@ studentDecisions.add(decision); getLogger().info("student decision is: " + decision.getId() + "location number: " + decision.getLocation().getLocationName()); } + executeStrategy(studentDecisions, game, false); //find out different groups in the game - Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); + /*Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); queryforGroups.setLong("current_game_id", game.getId()); Iterator groups = queryforGroups.list().iterator(); @@ -195,7 +204,7 @@ * find out the population for every bay */ - getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); + /*getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); while(groups.hasNext()) { Group currentGroup = (Group) groups.next(); @@ -234,14 +243,12 @@ calculateHarvest(bay2Students,"Bay2",currentGroup,game); calculateHarvest(bay3Students,"Bay3",currentGroup,game); calculateNewPopulation(currentGroup); - } + }*/ }catch(Exception e) { e.printStackTrace(); } - - } //FIXME: max_fish_capacity is hard coded to 5 but actually this value should get from game object @@ -441,43 +448,77 @@ { e.printStackTrace(); } - } - /*public void executeStrategy(Game game) + public void executeStrategy(Game game) { //get student Strategies - List<StudentStrategy> studentStrategies = new ArrayList<StudentStrategy>(); + List<DayByDayDecisions> studentDecisions = new ArrayList<DayByDayDecisions>(); + boolean repeatedDecisions = false; + //execute non repeated decisions first + try + { + Query studentStrategiesWithNonRepeatedDecisions = getDao().getCurrentSession().createQuery(getStudentDayByDayDecisionsFromStrategy); - Query studentStrategiesQuery = studentStrategyDao.getCurrentSession().createQuery(getStudentStrategy); + studentStrategiesWithNonRepeatedDecisions.setEntity("game", game); + studentStrategiesWithNonRepeatedDecisions.setBoolean("repeated_decisions", repeatedDecisions); - studentStrategiesQuery.setEntity("game", game); + Iterator studentStrategyNonRepeatedIterator = studentStrategiesWithNonRepeatedDecisions.list().iterator(); - Iterator studentStrategyIterator = studentStrategiesQuery.list().iterator(); - try - { - while(studentStrategyIterator.hasNext()) + while(studentStrategyNonRepeatedIterator.hasNext()) { - StudentStrategy strategy = (StudentStrategy)studentStrategyIterator.next(); - for(int i = 0; i < strategy.getDays();i++) - studentStrategies.add(strategy); + DayByDayDecisions dayByDayDecision = (DayByDayDecisions)studentStrategyNonRepeatedIterator.next(); + studentDecisions.add(dayByDayDecision); } - Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); + executeStrategy(studentDecisions, game, repeatedDecisions); + - queryforGroups.setLong("current_game_id", game.getId()); - Iterator groups = queryforGroups.list().iterator(); - List<GroupLocation> groupLocations = new ArrayList<GroupLocation>(); - List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); - List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); - List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); - List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); - /** For every group find out the groupLocations objects. - * find out the student decisions for current group. - * Separate the students for each bay - * find out the population for every bay - */ + //execute repeated decisions + repeatedDecisions = true; + Query studentStrategiesQueryWithRepeatedDecisions = getDao().getCurrentSession().createQuery(getStudentDayByDayDecisionsFromStrategy); - /* getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); + studentStrategiesQueryWithRepeatedDecisions.setEntity("game", game); + studentStrategiesQueryWithRepeatedDecisions.setBoolean("repeated_decisions",repeatedDecisions); + + Iterator studentStrategyRepeatedIterator = studentStrategiesQueryWithRepeatedDecisions.list().iterator(); + + while(studentStrategyRepeatedIterator.hasNext()) + { + DayByDayDecisions dayByDayDecision = (DayByDayDecisions)studentStrategyRepeatedIterator.next(); + studentDecisions.add(dayByDayDecision); + } + executeStrategy(studentDecisions, game, repeatedDecisions); + + }catch(Exception e) + { + e.printStackTrace(); + } + + } + + + public void executeStrategy(List<DayByDayDecisions> studentDecisions, Game game, boolean repeatedDecisions) + { + Query queryforGroups = studentDao.getCurrentSession().createQuery(groupsWithinGame); + + queryforGroups.setLong("current_game_id", game.getId()); + Iterator groups = queryforGroups.list().iterator(); + List<GroupLocation> groupLocations = new ArrayList<GroupLocation>(); + List<DayByDayDecisions> bay1Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay2Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay3Students = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> harborStudents = new ArrayList<DayByDayDecisions>(); + /** For every group find out the groupLocations objects. + * find out the student decisions for current group. + * Separate the students for each bay + * find out the population for every bay + */ + + getLogger().debug("number of groups in the game are: " + queryforGroups.list().size()); + Game currentGame = gameDao.find(game.getId()); + + for(int dayCounter = 0; dayCounter < currentGame.getGameConfig().getMaxDays(); dayCounter++ ) + { while(groups.hasNext()) { Group currentGroup = (Group) groups.next(); @@ -488,12 +529,26 @@ //List<StudentDayByDayDecisions> studentDecisionForCurrentGroup = new ArrayList<DayByDayDecisions>(); for(DayByDayDecisions tempStudentDecision:studentDecisions) { - + if(tempStudentDecision.getStudent().getGroup().getId() == currentGroup.getId()) { - //studentDecisionForCurrentGroup.add(tempStudentDecision); - if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + /** + * Check suspend condition for repeated decisions before putting allocating a student to any location + * + */ + if(repeatedDecisions) { + tempStudentDecision.getStudentStrategy().getThreshold(); + } + + + + if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) + { + harborStudents.add(tempStudentDecision); + } + else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + { bay1Students.add(tempStudentDecision); } else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay2")) @@ -504,26 +559,19 @@ { bay3Students.add(tempStudentDecision); } - else if(tempStudentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) - { - harborStudents.add(tempStudentDecision); - } - } } + calculateHarvest(bay1Students,"Bay1",currentGroup,game); calculateHarvest(bay2Students,"Bay2",currentGroup,game); calculateHarvest(bay3Students,"Bay3",currentGroup,game); calculateNewPopulation(currentGroup); + } - }catch(Exception e) - { - e.printStackTrace(); } + } - }*/ - public void setStudentStrategyDao(HibernateStudentStrategyDao studentStrategyDao) { this.studentStrategyDao = studentStrategyDao; } Deleted: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/Feed.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/Feed.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/Feed.java 2009-11-20 18:21:53 UTC (rev 373) @@ -1,62 +0,0 @@ -package edu.asu.commons.mme.service; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -public class Feed implements ApplicationContextAware{ - - public static void main(String args[]) { - Feed feed = new Feed(); - feed.start(); - } - - private StartGame thread; - private ApplicationContext ctx; - - public Feed() { - } - - public void start() { - - try{ - if (thread == null) { - thread = (StartGame)ctx.getBean("startGame"); - thread.run(); - } - }catch(Exception e) - { - System.out.println(e.getStackTrace()); - } - } - - public void stop() { - thread.setRunning(false); - thread = null; - } - - @Override - public void setApplicationContext(ApplicationContext context) - throws BeansException { - // TODO Auto-generated method stub - this.ctx = context; - - } - - /*@Override - public Object invoke(Message msg) { - // TODO Auto-generated method stub - if(msg.getBody().equals("New")){ - System.out.println("Adapter received new"); - return "This is a message from invoke method"; - }else{ - System.out.println("Adapter sending message"); - AsyncMessage newMessage = (AsyncMessage)msg; - MessageService msgService = (MessageService)getDestination().getService(); - msgService.pushMessageToClients(newMessage, true); - } - return null; - - }*/ - -} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameService.java 2009-11-20 18:21:53 UTC (rev 373) @@ -58,7 +58,6 @@ private int blockSeqNo; - private RoundService roundService; MessageHandler msgHandler; @@ -383,8 +382,6 @@ groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); - groupLocationDao.save(groupLocation); - getLogger().info("group location is created and id is: " + groupLocation.getId()); } if(location.getLocationName().equalsIgnoreCase("bay2")) { @@ -400,8 +397,6 @@ groupLocation.setFishReturned(0.0); getLogger().info("initiali population set is: " + initCapacity); - groupLocationDao.save(groupLocation); - getLogger().info("group location is created and id is: " + groupLocation.getId()); } if(location.getLocationName().equalsIgnoreCase("bay3")) { @@ -417,8 +412,6 @@ groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); - groupLocationDao.save(groupLocation); - getLogger().info("group location is created and id is: " + groupLocation.getId()); } if(location.getLocationName().equalsIgnoreCase("harbor")) { @@ -434,9 +427,11 @@ groupLocation.setFishLeaving(0.0); groupLocation.setFishReturned(0.0); - groupLocationDao.save(groupLocation); - getLogger().info("group location is created and id is: " + groupLocation.getId()); } + groupLocation.setDayByDayDecsion(null); + groupLocationDao.save(groupLocation); + getLogger().info("group location is created and id is: " + groupLocation.getId()); + } } @@ -1183,15 +1178,6 @@ } - public void setRoundService(RoundService roundService) { - this.roundService = roundService; - } - - - public RoundService getRoundService() { - return roundService; - } - public void setGroupLocationDao(HibernateGroupLocationDao groupLocationDao) { this.groupLocationDao = groupLocationDao; } Deleted: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java 2009-11-20 01:39:54 UTC (rev 372) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java 2009-11-20 18:21:53 UTC (rev 373) @@ -1,828 +0,0 @@ -package edu.asu.commons.mme.service; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.hibernate.Hibernate; -import org.springframework.transaction.annotation.Transactional; - -import edu.asu.commons.mme.dao.HibernateBlockDao; -import edu.asu.commons.mme.dao.HibernateGameConfigDao; -import edu.asu.commons.mme.dao.HibernateGameDao; -import edu.asu.commons.mme.dao.HibernateGameRoundDao; -import edu.asu.commons.mme.dao.HibernateModuleDao; -import edu.asu.commons.mme.dao.HibernateModuleRoundConfigDao; -import edu.asu.commons.mme.dao.HibernateRoundConfigDao; -import edu.asu.commons.mme.entity.Block; -import edu.asu.commons.mme.entity.BlockInformationWindow; -import edu.asu.commons.mme.entity.CategoricalOption; -import edu.asu.commons.mme.entity.CategoricalQuestion; -import edu.asu.commons.mme.entity.Game; -import edu.asu.commons.mme.entity.GameConfig; -import edu.asu.commons.mme.entity.GameRound; -import edu.asu.commons.mme.entity.Location; -import edu.asu.commons.mme.entity.Module; -import edu.asu.commons.mme.entity.ModuleRoundConfig; -import edu.asu.commons.mme.entity.Question; -import edu.asu.commons.mme.entity.QuestionGroup; -import edu.asu.commons.mme.entity.Round; -import edu.asu.commons.mme.utility.MessageHandler; - -@Transactional -public class RoundService extends Service.Base<Round, HibernateRoundConfigDao>{ - - private HibernateModuleDao moduleDao; - private HibernateBlockDao blockDao; - private HibernateGameDao gameDao; - private HibernateModuleRoundConfigDao moduleRoundDao; - private HibernateGameRoundDao gameRoundDao; - private HibernateGameConfigDao gameConfigDao; - - private LocationService locationService; - - private int blockSeqNo; - - private Game game; - - public Game getGame() { - return game; - } - - public void setGame(Game game) { - this.game = game; - } - - public RoundService() - { - setBlockSeqNo(0); - setGameFinished(false); - } - - public GameConfig createGameConfig(GameConfig gameConfig) - { - GameConfig newGameConfig = null; - try{ - newGameConfig = new GameConfig(); - newGameConfig.setImageLocation(null); - newGameConfig.setTimestamp(gameConfig.getTimestamp()); - newGameConfig.setMaxDays(gameConfig.getMaxDays()); - newGameConfig.setMaxFishHarvest(gameConfig.getMaxFishHarvest()); - newGameConfig.setNumberOfLocations(gameConfig.getNumberOfLocations()); - getGameConfigDao().save(newGameConfig); - initializeGameRounds(newGameConfig); - initializeLocations(newGameConfig); - - }catch(Exception e) - { - e.printStackTrace(); - } - return newGameConfig; - } - - - public Game createGame(Game game) - { - getLogger().debug("game came from flex is : " + game.getGameCode()); - - Game newGame = new Game(); - //currentGame = game; - try - { - newGame.setGameCode(game.getGameCode()); - newGame.setMoney(game.getMoney()); - newGame.setTimestamp(game.getTimestamp()); - - //FIXME: Currently using default GameConfiguration whose id is 1 - GameConfig gameConfig = gameConfigDao.find(1L); - newGame.setGameConfig(gameConfig); - getGameDao().save(newGame); - String str = newGame.getGameCode()+newGame.getId(); - - if(getGameDao().findAllByProperty("gameCode", str).size() != 0) - { - //getLogger().debug("in if loop "); - newGame = null; - } - else - { - newGame.setGameCode(str); - getGameDao().save(newGame); - getLogger().info("Created the game: " + newGame.getId()); - initializeLocations(gameConfig); - initializeGame(newGame); - } - }catch(Exception e) - { - e.printStackTrace(); - } - getLogger().debug("current game from flex is: " + newGame.getId()); - return newGame; - } - - private void initializeGameRounds(GameConfig gameConfig) { - // TODO Auto-generated method stub - List<GameRound> gameRounds = new ArrayList<GameRound>(); - for(Round round:getDao().findAll()) - { - GameRound gameRound = new GameRound(); - gameRound.setGameConfig(gameConfig); - gameRound.setRound(round); - gameRoundDao.save(gameRound); - gameRounds.add(gameRound); - } - getGameConfigDao().save(gameConfig); - } - - private void initializeLocations(GameConfig gameConfig) - { - //gameConfig.setLocations(locationService.setAllLocations(gameConfig)); - getGameConfigDao().save(gameConfig); - } - - public void initializeGame(Game game) { - // TODO Auto-generated method stub - try{ - Hibernate.initialize(game); - Hibernate.initialize(game.getCurrentBlock()); - - - GameConfig gameconfig = game.getGameConfig(); - Hibernate.initialize(gameconfig); - - /*for(Location location:gameconfig.getLocations()) - { - Hibernate.initialize(location); - - }*/ - - Round round = game.getCurrentRound(); - Hibernate.initialize(round); - /*for(GameRound gameRound:round.getGameRounds()) - { - getLogger().debug("gameround in initializing round is " + gameRound.getId()); - Hibernate.initialize(gameRound); - }*/ - - }catch(Exception e ) - { - e.printStackTrace(); - } - //Hibernate.initialize(gameconfig.getGameRounds()); - - - } - public Module getNextModule(int sequenceNo) - { - return getModule(sequenceNo); - } - - public void test() - { - getLogger().debug("test to check if module service is working...." ); - } - - /* - *1) Check if the current module round config is null, this object keeps track of which round - * and which module in that round is going on - *2) Find out the current module number - *3) check if it is finished, if yes find out the current round number - *4) Find out the current block number - *5) Return the next block - */ - - public Game getBlock(Game game) - { - - ModuleRoundConfig currentModuleRoundConfig; - Block currentBlock = null; - Round currentRound = null; - - //check if it is a start of the game - if(game.getCurrentRound() == null && game.getCurrentBlock() == null ) - { - getLogger().info("Current Round is null... "); - getLogger().info("Current block is null... "); - getLogger().info("Starting of the game...." + game.getGameCode()); - - currentRound = getNextRound(game); - getLogger().info("Next Round object is "+ currentRound.getId()); - - currentModuleRoundConfig = getModuleRoundConfig(0, currentRound); - getLogger().info("Next ModuleRound Config object is "+ currentModuleRoundConfig.getId()); - - Module currentModule = getModuleForCurrentRound(currentModuleRoundConfig); - getLogger().info("Next Module object is "+ currentModule.getId()); - currentBlock = getBlock(currentModule,1); - } - else - { - getLogger().debug("Current Round is : " + game.getCurrentRound().getId()); - getLogger().debug("Current block is : " + game.getCurrentBlock().getId()); - currentBlock = game.getCurrentBlock(); - currentRound = game.getCurrentRound(); - if(isModuleFinished(game.getCurrentBlock())) - { - getLogger().debug("current module is finished"); - - //currentModuleRoundConfig = game.getCurrentRound(). - if(isCurrentRoundFinished(game)) - { - getLogger().debug("current round is finished"); - if(isGameFinished(game)) - { - getLogger().debug("Game is finished..." + game.getId()); - return null; - } - else - { - //set the next round - currentRound = getNextRound(game); - getLogger().info("Next Round object is "+ currentRound.getId()); - - currentModuleRoundConfig = getModuleRoundConfig(0, currentRound); - getLogger().info("Next ModuleRound Config object is "+ currentModuleRoundConfig.getId()); - - Module currentModule = getModuleForCurrentRound(currentModuleRoundConfig); - getLogger().info("Next Module object is "+ currentModule.getId()); - - currentBlock = getBlock(currentModule,1); - } - } - else - { - getLogger().debug("current round is not finished"); - //currentRound = getNextRound(game.getCurrentRound()); - - currentModuleRoundConfig = getModuleRoundConfig(getPreviousModuleConfigSequenceNo(game), currentRound); - getLogger().info("Next ModuleRound Config object is "+ currentModuleRoundConfig.getId()); - - Module currentModule = getModuleForCurrentRound(currentModuleRoundConfig); - getLogger().info("Next Module object is "+ currentModule.getId()); - - currentBlock = getBlock(currentModule,1); - - } - } - else - { - //get the next block in the module - //getLogger().debug("currentmodule is " + game.getCurrentBlock().getModule().getId()); - currentBlock = getNextBlock(game.getCurrentBlock()); - getLogger().debug("the next block for the game is: " + game.getCurrentBlock().getDescription()); - } - } - - Game newGame = saveGameState(currentBlock,currentRound,game); - getLogger().debug("question group sizes is : " + newGame.getCurrentBlock().getQuestionGroups().size()); - //initializeCurrentBlock(newGame.getCurrentBlock()); - initializeGame(newGame); - getLogger().debug("Module is " + newGame.getCurrentBlock().getModule().getId() + "Block sent to the server is: " + currentBlock.getDescription()); - return newGame; - } - - private int getPreviousModuleConfigSequenceNo(Game game) { - // TODO Auto-generated method stub - List<ModuleRoundConfig> moduleRoundConfigs = new ArrayList<ModuleRoundConfig> (); - ModuleRoundConfig currentModuleRoundConfig = null; - - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("module",game.getCurrentBlock().getModule()); - variables.put("round", game.getCurrentRound()); - moduleRoundConfigs = moduleRoundDao.findByEqCriteria(variables); - if(moduleRoundConfigs.size() == 1) - { - currentModuleRoundConfig = moduleRoundConfigs.get(0); - moduleRoundConfigs.clear(); - } - getLogger().debug("the prev Sequence no is : " + currentModuleRoundConfig.getSequenceNo()); - if(currentModuleRoundConfig != null) - return currentModuleRoundConfig.getSequenceNo(); - return 0; - } - - private ModuleRoundConfig getModuleRoundConfig(int prevSeqNo, Round currentRound) { - // TODO Auto-generated method stub - //int prevSeqNo = 0; - List<ModuleRoundConfig> moduleRoundConfigs = new ArrayList<ModuleRoundConfig> (); - ModuleRoundConfig currentModuleRoundConfig = null; - try - { - moduleRoundConfigs = moduleRoundDao.findAllByProperty("round",currentRound); - for(int i = 0; i < moduleRoundConfigs.size(); i++) - { - if(moduleRoundConfigs.get(i).getSequenceNo() > prevSeqNo) - { - currentModuleRoundConfig = moduleRoundConfigs.get(i); - break; - - /*setCurrentModule(moduleRoundConfigs.get(i).getModule()); - getLogger().debug("current module is: " + getCurrentModule().getDescription()); - currentBlock = null; - break;*/ - } - } - }catch(Exception e) - { - e.printStackTrace(); - } - return currentModuleRoundConfig; - - } - - private Module getModuleForCurrentRound(ModuleRoundConfig moduleRoundConfig) { - // TODO Auto-generated method stub - //getLogger().debug("current module is: " + getCurrentModule().getDescription()); - return moduleRoundConfig.getModule(); - } - - - private Round getNextRound(Game game) { - // TODO Auto-generated method stub - - Round returnRound = null; - Round currentRound = game.getCurrentRound(); - GameConfig gameConfig = game.getGameConfig(); - List<GameRound> gameRounds = new ArrayList<GameRound>(); - if(currentRound == null) - { - //get the first round - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("gameConfig",gameConfig); - variables.put("seqNo", 1); - getGameRoundDao().findByEqCriteria(variables); - gameRounds = gameRoundDao.findByEqCriteria(variables); - if(gameRounds.size() == 1) - { - returnRound = gameRounds.get(0).getRound(); - gameRounds.clear(); - } - } - else - { - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("gameConfig",gameConfig); - variables.put("round", currentRound); - gameRounds = getGameRoundDao().findByEqCriteria(variables); - if(gameRounds.size() == 1) - { - int currentSeqNo = gameRounds.get(0).getSeqNo(); - gameRounds = getGameRoundDao().findAll(); - for(int i = 0; i < gameRounds.size(); i++) - { - if(currentSeqNo < gameRounds.get(i).getSeqNo()) - { - returnRound = gameRounds.get(i).getRound(); - break; - //getLogger().debug("currentround object is "+ rounds.get(i).getId()); - } - } - } - else - { - getLogger().error("Error Occured.. Game Config is associated with multiple Rounds "); - } - } - - return returnRound; - } - - public HibernateModuleDao getModuleDao() { - return moduleDao; - } - - - public void setModuleDao(HibernateModuleDao moduleDao) { - this.moduleDao = moduleDao; - } - - - @SuppressWarnings("unused") - private void initializeCurrentBlock(Block block) { - - Hibernate.initialize(block); - Iterator<QuestionGroup> iteratorquestionGrp = block.getQuestionGroups().iterator(); - { - while(iteratorquestionGrp.hasNext()) - { - QuestionGroup questionGroup = iteratorquestionGrp.next(); - Hibernate.initialize(questionGroup); - // getLogger().debug(questionGroup.getDescription()); - List<Question> questions = questionGroup.getQuestions(); - - for(int j = 0; j < questions.size(); j++) - { - Hibernate.initialize(questions.get(j)); - if(questions.get(j).getClass().getName().equalsIgnoreCase("edu.asu.commons.mme.entity.CategoricalQuestion")) - { - CategoricalQuestion categoricalQ = (CategoricalQuestion)questions.get(j); - Iterator<CategoricalOption> categoricalOption = categoricalQ.getCategoricalOptions().iterator(); - Hibernate.initialize(categoricalOption); - } - } - } - } - - Module module = block.getModule(); - Hibernate.initialize(module); - initializeModule(module); - - } - - - private Block getNextBlock(Block currentBlock) { - // TODO Auto-generated method stub - List<Block> blocks = new ArrayList<Block>(); - blocks = currentBlock.getModule().getBlocks(); - Block returnBlock = null; - for(int i = 0; i < blocks.size(); i++) - { - if(currentBlock.getSequenceNo() < blocks.get(i).getSequenceNo()) - { - returnBlock = blocks.get(i); - break; - } - } - return returnBlock; - - } - - public Module getModule(int moduleNumber) - { - // Enter the sequence number in new Integer(Sequence number of module u want to fetch) - - Module module = moduleDao.findByProperty("sequenceNo", moduleNumber); - Hibernate.initialize(module); - getLogger().debug("Module object is " + module.getDescription()); - initializeModule(module); - - return module; - } - - public Block getBlock(Module currentModule, int seqNo) - { - //Module module = new Module(); - // module = currentModule; - Block block = new Block(); - for(int i = 0; i < currentModule.getBlocks().size(); i++) - { - block = currentModule.getBlocks().get(i); - if(block.getSequenceNo() == seqNo) - { - return block; - } - } - - return block; - } - - /* private void setRound(int roundNo) { - // TODO Auto-generated method stub - currentRound = new Round(); - - currentRound = getDao().findByProperty("roundNo", roundNo); - //Hibernate.initialize(currentRound); - getLogger().debug("currentround object is "+ currentRound.getId()); - setCurrentRound(currentRound); - - }*/ - - /*private int getCurrentRoundNo() { - // TODO Auto-generated method stub - //FIXME: Game id 1 is hard coded but needs to make it dynamic - //Game game = gameDao.find(1L); - if(getCurrentGame().getCurrentRound() == null) - return 0; - else - return getCurrentGame().getCurrentRound().getRoundNo(); - - }*/ - public boolean isGameFinished(Game game) { - GameConfig gameConfig = game.getGameConfig(); - List<GameRound> gameRounds = getGameRoundDao().findAllByProperty("gameConfig",game.getGameConfig()); - boolean flag = false; - - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("gameConfig",gameConfig); - variables.put("round", game.getCurrentRound()); - gameRounds = getGameRoundDao().findByEqCriteria(variables); - if(gameRounds.size() == 1) - { - int currentSeqNo = gameRounds.get(0).getSeqNo(); - gameRounds.clear(); - gameRounds = getGameRoundDao().findAllByProperty("gameConfig", gameConfig); - - if(currentSeqNo == gameRounds.get(gameRounds.size() - 1).getSeqNo()) - { - flag = true; - } - else - { - for(GameRound gameRound:gameRounds) - { - if(currentSeqNo < gameRound.getSeqNo()) - { - flag = false; - } - } - - } - } - return flag; - } - - private boolean isCurrentRoundFinished(Game game) { - boolean flag = false; - List<ModuleRoundConfig> moduleRoundConfigs = new ArrayList<ModuleRoundConfig> (); - Round currentRound = game.getCurrentRound(); - Module currentModule = game.getCurrentBlock().getModule(); - - ModuleRoundConfig currentModuleRoundConfig = new ModuleRoundConfig(); - - Map<String, Object> variables = new HashMap<String, Object>(); - variables.put("module",currentModule); - variables.put("round", currentRound); - moduleRoundConfigs = moduleRoundDao.findByEqCriteria(variables); - if(moduleRoundConfigs.size() == 1) - { - currentModuleRoundConfig = moduleRoundConfigs.get(0); - moduleRoundConfigs.clear(); - } - moduleRoundConfigs = moduleRoundDao.findAllByProperty("round",currentRound); - getLogger().debug("the module round configs size is: " + moduleRoundConfigs.size()); - //check if it contains only one module, if yes then round is over - if(moduleRoundConfigs.size() == 1) - { - flag = true; - } - else - { - getLogger().debug("module round config is "+ moduleRoundConfigs.get(moduleRoundConfigs.size() - 1).getSequenceNo()); - int seqNo = moduleRoundConfigs.get(moduleRoundConfigs.size() - 1).getSequenceNo(); - if((currentModuleRoundConfig.getSequenceNo()) == seqNo) - { - flag = true; - } - else - { - for(int i = 0; i < moduleRoundConfigs.size(); i++) - { - // getLogger().debug("moduleroundconfig seq no is" + moduleRoundConfigs.get(i).getSequenceNo()); - getLogger().debug("Current seq no is" + currentModuleRoundConfig.getSequenceNo() +"and the moduleroundconfig is "+ moduleRoundConfigs.get(i).getSequenceNo()); - - if(currentModuleRoundConfig.getSequenceNo() == moduleRoundConfigs.get(moduleRoundConfigs.size() - 1).getSequenceNo()) - flag = true; - if(currentModuleRoundConfig.getSequenceNo() < moduleRoundConfigs.get(i).getSequenceNo()) - { - flag = false; - } - } - } - } - return flag; - } - - - private boolean isModuleFinished(Block currentBlock) { - // TODO Auto-generated method stub - boolean flag = false; - - List<Block> blocks = new ArrayList<Block>(); - getLogger().debug("in iscurrentmodulefinished"); - if(currentBlock == null) - { - flag = true; - } - else - { - Module currentModule = currentBlock.getModule(); - //getBlocks() return blocks in order of sequence number - blocks = currentModule.getBlocks(); - //select max(b.sequence_no) from block b where b.module_id=2; - getLogger().debug("no of blocks " + blocks.size() +"for module id: " + currentModule.getId()); - //if module contains only one block - if(blocks.size() == 1) - flag = true; - else - { - for(int i = 0; i < blocks.size(); i++) - { - if(currentBlock.getSequenceNo() == blocks.get(blocks.size() - 1).getSequenceNo()) - flag = true; - if(currentBlock.getSequenceNo() < blocks.get(i).getSequenceNo()) - { - flag = false; - } - - } - } - } - return flag; - } - - private Game saveGameState(Block currentBlock, Round currentRound, Game game) { - - //FIXME: Game id 1 is hard coded but needs to make it dynamic - getLogger().info(" Game id to SAVE is: " + game.getId()); - Game newGame = null; - newGame = gameDao.find(game.getId()); - getLogger().info("The current block is: " + currentBlock.getId() + " while the current Round is: " + currentRound.getId()); - if(newGame.getCurrentBlock() == null && newGame.getCurrentRound()==null) - getLogger().info("BEFORE GAME SAVE: The current block NULL while the current Round is NULL"); - else - getLogger().info("BEFORE GAME SAVE: The current block is: " + newGame.getCurrentBlock().getId() + " while the current Round is: " + newGame.getCurrentRound().ge... [truncated message content] |
From: <kj...@us...> - 2010-01-15 21:23:13
|
Revision: 434 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=434&view=rev Author: kjonas Date: 2010-01-15 21:23:07 +0000 (Fri, 15 Jan 2010) Log Message: ----------- updated swf files Modified Paths: -------------- mentalmodels/trunk/pom.xml mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.html mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf mentalmodels/trunk/src/main/webapp/InitialiseDatabase.html mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf mentalmodels/trunk/src/main/webapp/StartGame.html mentalmodels/trunk/src/main/webapp/StartGame.swf Modified: mentalmodels/trunk/pom.xml =================================================================== --- mentalmodels/trunk/pom.xml 2010-01-15 21:20:31 UTC (rev 433) +++ mentalmodels/trunk/pom.xml 2010-01-15 21:23:07 UTC (rev 434) @@ -56,6 +56,11 @@ <version>2.5.6</version> </dependency> <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <version>2.5.6.SEC01</version> +</dependency> + <dependency> <groupId>org.springframework.flex</groupId> <artifactId>spring-flex</artifactId> <version>1.0.0.RC2</version> Modified: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.html =================================================================== --- mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.html 2010-01-15 21:20:31 UTC (rev 433) +++ mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.html 2010-01-15 21:23:07 UTC (rev 434) @@ -28,15 +28,6 @@ <style> body { margin: 0px; overflow:hidden } </style> - -<script language="JavaScript"> - window.onbeforeunload = confirmExit; - function confirmExit() - { - return "If you are connected to the server, you will be disconnected if the page closes. Students in the experiment will be removed if the window closes."; - } -</script> - <script language="JavaScript" type="text/javascript"> <!-- // ----------------------------------------------------------------------------- @@ -53,12 +44,8 @@ </head> <body scroll="no"> - <script language="JavaScript" type="text/javascript"> <!-- - -var clientIP = '<!--#echo var="REMOTE_ADDR"-->'; - // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65) var hasProductInstall = DetectFlashVer(6, 0, 65); @@ -70,12 +57,12 @@ // Location visited after installation is complete if installation is required var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn"; var MMredirectURL = window.location; - document.title = document.title.slice(0, 47) + " - Flash Player Installation"; - var MMdoctitle = document.title; + document.title = document.title.slice(0, 47) + " - Flash Player Installation"; + var MMdoctitle = document.title; AC_FL_RunContent( "src", "playerProductInstall", - "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+'&ip=test'+clientIP+"", + "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"", "width", "100%", "height", "100%", "align", "middle", @@ -95,30 +82,27 @@ "width", "100%", "height", "100%", "align", "middle", - "valign", "middle", "id", "FisheryExperimentShell", "quality", "high", "bgcolor", "#869ca7", "name", "FisheryExperimentShell", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", - "pluginspage", "http://www.adobe.com/go/getflashplayer", - "FlashVars", "ip=test"+clientIP+"" + "pluginspage", "http://www.adobe.com/go/getflashplayer" ); -} else { // flash is too old or we can't detect the plugin - var alternateContent = 'Alternate HTML content should be placed here. ' - + 'This content requires the Adobe Flash Player. ' - + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>'; - document.write(alternateContent); // insert non-flash content + } else { // flash is too old or we can't detect the plugin + var alternateContent = 'Alternate HTML content should be placed here. ' + + 'This content requires the Adobe Flash Player. ' + + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>'; + document.write(alternateContent); // insert non-flash content } // --> </script> <noscript> - <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" + <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="FisheryExperimentShell" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> <param name="movie" value="FisheryExperimentShell.swf" /> - <PARAM NAME=FlashVars VALUE="ip=test${clientIP}"> <param name="quality" value="high" /> <param name="bgcolor" value="#869ca7" /> <param name="allowScriptAccess" value="sameDomain" /> Modified: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/InitialiseDatabase.html =================================================================== --- mentalmodels/trunk/src/main/webapp/InitialiseDatabase.html 2010-01-15 21:20:31 UTC (rev 433) +++ mentalmodels/trunk/src/main/webapp/InitialiseDatabase.html 2010-01-15 21:23:07 UTC (rev 434) @@ -28,15 +28,6 @@ <style> body { margin: 0px; overflow:hidden } </style> - -<script language="JavaScript"> - window.onbeforeunload = confirmExit; - function confirmExit() - { - return "If you are connected to the server, you will be disconnected if the page closes. Students in the experiment will be removed if the window closes."; - } -</script> - <script language="JavaScript" type="text/javascript"> <!-- // ----------------------------------------------------------------------------- @@ -53,12 +44,8 @@ </head> <body scroll="no"> - <script language="JavaScript" type="text/javascript"> <!-- - -var clientIP = '<!--#echo var="REMOTE_ADDR"-->'; - // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65) var hasProductInstall = DetectFlashVer(6, 0, 65); @@ -70,12 +57,12 @@ // Location visited after installation is complete if installation is required var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn"; var MMredirectURL = window.location; - document.title = document.title.slice(0, 47) + " - Flash Player Installation"; - var MMdoctitle = document.title; + document.title = document.title.slice(0, 47) + " - Flash Player Installation"; + var MMdoctitle = document.title; AC_FL_RunContent( "src", "playerProductInstall", - "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+'&ip=test'+clientIP+"", + "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"", "width", "100%", "height", "100%", "align", "middle", @@ -95,30 +82,27 @@ "width", "100%", "height", "100%", "align", "middle", - "valign", "middle", "id", "InitialiseDatabase", "quality", "high", "bgcolor", "#869ca7", "name", "InitialiseDatabase", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", - "pluginspage", "http://www.adobe.com/go/getflashplayer", - "FlashVars", "ip=test"+clientIP+"" + "pluginspage", "http://www.adobe.com/go/getflashplayer" ); -} else { // flash is too old or we can't detect the plugin - var alternateContent = 'Alternate HTML content should be placed here. ' - + 'This content requires the Adobe Flash Player. ' - + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>'; - document.write(alternateContent); // insert non-flash content + } else { // flash is too old or we can't detect the plugin + var alternateContent = 'Alternate HTML content should be placed here. ' + + 'This content requires the Adobe Flash Player. ' + + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>'; + document.write(alternateContent); // insert non-flash content } // --> </script> <noscript> - <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" + <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="InitialiseDatabase" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> <param name="movie" value="InitialiseDatabase.swf" /> - <PARAM NAME=FlashVars VALUE="ip=test${clientIP}"> <param name="quality" value="high" /> <param name="bgcolor" value="#869ca7" /> <param name="allowScriptAccess" value="sameDomain" /> Modified: mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/StartGame.html =================================================================== --- mentalmodels/trunk/src/main/webapp/StartGame.html 2010-01-15 21:20:31 UTC (rev 433) +++ mentalmodels/trunk/src/main/webapp/StartGame.html 2010-01-15 21:23:07 UTC (rev 434) @@ -28,15 +28,6 @@ <style> body { margin: 0px; overflow:hidden } </style> - -<script language="JavaScript"> - window.onbeforeunload = confirmExit; - function confirmExit() - { - return "If you are connected to the server, you will be disconnected if the page closes. Students in the experiment will be removed if the window closes."; - } -</script> - <script language="JavaScript" type="text/javascript"> <!-- // ----------------------------------------------------------------------------- @@ -53,12 +44,8 @@ </head> <body scroll="no"> - <script language="JavaScript" type="text/javascript"> <!-- - -var clientIP = '<!--#echo var="REMOTE_ADDR"-->'; - // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65) var hasProductInstall = DetectFlashVer(6, 0, 65); @@ -70,12 +57,12 @@ // Location visited after installation is complete if installation is required var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn"; var MMredirectURL = window.location; - document.title = document.title.slice(0, 47) + " - Flash Player Installation"; - var MMdoctitle = document.title; + document.title = document.title.slice(0, 47) + " - Flash Player Installation"; + var MMdoctitle = document.title; AC_FL_RunContent( "src", "playerProductInstall", - "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+'&ip=test'+clientIP+"", + "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"", "width", "100%", "height", "100%", "align", "middle", @@ -95,30 +82,27 @@ "width", "100%", "height", "100%", "align", "middle", - "valign", "middle", "id", "StartGame", "quality", "high", "bgcolor", "#869ca7", "name", "StartGame", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", - "pluginspage", "http://www.adobe.com/go/getflashplayer", - "FlashVars", "ip=test"+clientIP+"" + "pluginspage", "http://www.adobe.com/go/getflashplayer" ); -} else { // flash is too old or we can't detect the plugin - var alternateContent = 'Alternate HTML content should be placed here. ' - + 'This content requires the Adobe Flash Player. ' - + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>'; - document.write(alternateContent); // insert non-flash content + } else { // flash is too old or we can't detect the plugin + var alternateContent = 'Alternate HTML content should be placed here. ' + + 'This content requires the Adobe Flash Player. ' + + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>'; + document.write(alternateContent); // insert non-flash content } // --> </script> <noscript> - <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" + <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="StartGame" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> <param name="movie" value="StartGame.swf" /> - <PARAM NAME=FlashVars VALUE="ip=test${clientIP}"> <param name="quality" value="high" /> <param name="bgcolor" value="#869ca7" /> <param name="allowScriptAccess" value="sameDomain" /> Modified: mentalmodels/trunk/src/main/webapp/StartGame.swf =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |