[virtualcommons-svn] SF.net SVN: virtualcommons:[263] mentalmodels/trunk
Status: Beta
Brought to you by:
alllee
From: <see...@us...> - 2009-08-19 01:26:19
|
Revision: 263 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=263&view=rev Author: seematalele Date: 2009-08-19 01:26:13 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Written code for executing Day by day decision but it is not complete. Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/LocationService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java Modified: mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as 2009-08-18 23:19:35 UTC (rev 262) +++ mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as 2009-08-19 01:26:13 UTC (rev 263) @@ -14,7 +14,8 @@ public var threshold:Number; public var location:Location; public var repeatedDecisions:Boolean; - public var dayOutput:ArrayCollection; + public var student:Student; + public var round:Round; public var roundConfig:actionscript.Round; } } \ No newline at end of file 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-08-18 23:19:35 UTC (rev 262) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/DayByDayDecisionsService.java 2009-08-19 01:26:13 UTC (rev 263) @@ -6,13 +6,17 @@ import org.springframework.transaction.annotation.Transactional; import edu.asu.commons.mme.dao.HibernateDayByDayDecisionsDao; +import edu.asu.commons.mme.dao.HibernateLocationDao; import edu.asu.commons.mme.entity.DayByDayDecisions; -import edu.asu.commons.mme.entity.Question; -import edu.asu.commons.mme.entity.Student; +import edu.asu.commons.mme.entity.Location; @Transactional public class DayByDayDecisionsService extends Service.Base<DayByDayDecisions, HibernateDayByDayDecisionsDao> { + LocationService locationService; + + + private List<DayByDayDecisions> studentDecisions = new ArrayList<DayByDayDecisions>(); public void setStudentDecisions(List<DayByDayDecisions> studentDecisions) { @@ -43,12 +47,53 @@ } } - public void executeStrategy() + public void allocateStudentForEachBay() { + DayByDayDecisions studentDecision = new DayByDayDecisions(); + List<DayByDayDecisions> bay1 = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay2 = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> bay3 = new ArrayList<DayByDayDecisions>(); + List<DayByDayDecisions> harbor = new ArrayList<DayByDayDecisions>(); + + for(int i = 0; i < studentDecisions.size(); i++) + { + studentDecision = studentDecisions.get(i); + if(studentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay1")) + { + bay1.add(studentDecision); + } + else if(studentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay2")) + { + bay2.add(studentDecision); + } + else if(studentDecision.getLocation().getLocationName().equalsIgnoreCase("Bay3")) + { + bay3.add(studentDecision); + } + else if(studentDecision.getLocation().getLocationName().equalsIgnoreCase("Harbor")) + { + harbor.add(studentDecision); + } + } + executeStrategy(bay1,"Bay1"); + executeStrategy(bay2,"Bay2"); + executeStrategy(bay3,"Bay3"); + executeStrategy(harbor,"Harbor"); } + public void executeStrategy(List<DayByDayDecisions> bay,String locationName) + { + Location location = locationService.getLocation(locationName); + + } + public LocationService getLocationService() { + return locationService; + } + + public void setLocationService(LocationService locationService) { + this.locationService = locationService; + } - } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/LocationService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/LocationService.java 2009-08-18 23:19:35 UTC (rev 262) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/LocationService.java 2009-08-19 01:26:13 UTC (rev 263) @@ -51,5 +51,21 @@ } return locations; } + + public Location getLocation(String locationName) + { + // TODO Auto-generated method stub + List<Location>locations = getAllLocations(); + Location location =new Location(); + + for(int i=0; i<locations.size(); i++) + { + if(locations.get(i).getLocationName().equalsIgnoreCase(locationName)) + { + location = locations.get(i); + } + } + return location; + } } Modified: 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-08-18 23:19:35 UTC (rev 262) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java 2009-08-19 01:26:13 UTC (rev 263) @@ -60,18 +60,26 @@ currentGame = new Game(); currentGame = game; getGameDao().save(currentGame); - currentGame.setDescription(currentGame.getDescription()+currentGame.getId()); - getGameDao().save(currentGame); - setCurrentGame(currentGame); - initializeCurrentGame(); + String str = currentGame.getDescription()+currentGame.getId(); + if(getGameDao().findAllByProperty("description", str) !=null) + { + setCurrentGame(null); + } + else + { + currentGame.setDescription(str); + getGameDao().save(currentGame); + setCurrentGame(currentGame); + initializeGame(currentGame); + } return getCurrentGame(); } - private void initializeCurrentGame() { + private void initializeGame(Game game) { // TODO Auto-generated method stub - Hibernate.initialize(currentGame); - Hibernate.initialize(currentGame.getCurrentBlock()); - Hibernate.initialize(currentGame.getCurrentRound()); - Iterator<Round> rounds = currentGame.getRounds().iterator(); + Hibernate.initialize(game); + Hibernate.initialize(game.getCurrentBlock()); + Hibernate.initialize(game.getCurrentRound()); + Iterator<Round> rounds = game.getRounds().iterator(); while(rounds.hasNext()) { initializeRound(rounds.next()); @@ -83,7 +91,6 @@ return getModule(sequenceNo); } - public void test() { getLogger().debug("test to check if module service is working...." ); @@ -267,10 +274,6 @@ return false; } - - - - public HibernateModuleDao getModuleDao() { return moduleDao; } @@ -373,11 +376,11 @@ 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(game.getCurrentRound() == null) + //Game game = gameDao.find(1L); + if(getCurrentGame().getCurrentRound() == null) return 0; else - return game.getCurrentRound().getRoundNo(); + return getCurrentGame().getCurrentRound().getRoundNo(); } @@ -418,7 +421,6 @@ private void saveGameState(Block currentBlock) { - //FIXME: Game id 1 is hard coded but needs to make it dynamic Game game = gameDao.find(1L); game.setCurrentBlock(currentBlock); @@ -426,14 +428,12 @@ gameDao.save(game); } - public Integer getTimerforBlock(Block block) { return block.getDuration(); } - private void initializeModule(Module module) { // TODO Auto-generated method stub @@ -514,8 +514,9 @@ Iterator <Game> games = currentRound.getGame().iterator(); while(games.hasNext()) { - Hibernate.initialize(games.next()); + initializeGame(games.next()); + } List<Location> roundlocations = currentRound.getLocations(); Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java 2009-08-18 23:19:35 UTC (rev 262) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java 2009-08-19 01:26:13 UTC (rev 263) @@ -38,7 +38,6 @@ public void assignGroups() { - MessageBroker msgBroker = MessageBroker.getMessageBroker(null); String clientID = UUIDUtils.createUUID(); AsyncMessage msg = new AsyncMessage(); @@ -52,7 +51,7 @@ msg.setBody(students); System.out.println("Message broker is: "+ msgBroker); System.out.println("Students size is: " + students.size()); - + msgBroker.routeMessageToService(msg, null); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |