[virtualcommons-svn] SF.net SVN: virtualcommons:[281] mentalmodels/trunk
Status: Beta
Brought to you by:
alllee
From: <see...@us...> - 2009-09-24 19:16:50
|
Revision: 281 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=281&view=rev Author: seematalele Date: 2009-09-24 19:16:41 +0000 (Thu, 24 Sep 2009) Log Message: ----------- Can create multiple games. Tested it by creating and starting 2 games at different times Made changes in the startGame.mxml Changed the schema of mme Modified Paths: -------------- mentalmodels/trunk/flex/src/StartGame.mxml mentalmodels/trunk/src/main/db/init-mme.sql mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Game.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/ModuleRoundConfig.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Round.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/StartGame.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.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/HibernateGameRoundDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameRound.java Modified: mentalmodels/trunk/flex/src/StartGame.mxml =================================================================== --- mentalmodels/trunk/flex/src/StartGame.mxml 2009-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/flex/src/StartGame.mxml 2009-09-24 19:16:41 UTC (rev 281) @@ -33,7 +33,7 @@ <mx:method name="startGame"/> </mx:RemoteObject> - <mx:Consumer id="consumer" destination="chat" message="messageHandler(event)" fault="faultMsgHandler(event)" channelSet="{cs}" /> + <mx:Consumer id="consumer" destination="mme" message="messageHandler(event)" fault="faultMsgHandler(event)" channelSet="{cs}" /> <mx:ChannelSet id="cs"> <!--<mx:StreamingAMFChannel url="http://localhost:8080/mme/messagebroker/streamingamf"/>--> @@ -64,6 +64,7 @@ [Bindable]private var pageNum:int = 0; public var currentBlock:Block = null; + public var game:Game = null; public function init():void { @@ -120,8 +121,8 @@ message.body = "got gameObject" + gameObject.description; producer.send(message); Alert.show("message is send"); */ - consumer.subscribe(); - Alert.show("subscribed to destination: " + consumer.destination); + + } public function start():void @@ -130,7 +131,7 @@ /*consumer.subscribe(); Alert.show("subscribed to destination: " + consumer.destination);*/ - startupService.startGame(); + startupService.startGame(game); //consumer.subtopic = "hello3"; } @@ -144,8 +145,14 @@ { if(event.result != null) { - txtGameID.text = (event.result as Game).description; + + var description:String = (event.result as Game).description; btnStartGame.enabled = true; + game = event.result as Game; + txtGameID.text = description; + consumer.subtopic = description; + consumer.subscribe(); + Alert.show("subscribed to destination: " + consumer.destination); } else { @@ -161,15 +168,14 @@ { //Alert.show("message from server came.."); var block:actionscript.Block = event.message.body as actionscript.Block; - Alert.show("String came from server is: " + block.id + " " + block.description); + //Alert.show("String came from server is: " + block.id + " " + block.description); - - /* if(currentBlock == null) + if(block == null) { Alert.show("Game is over!!"); } else - Alert.show("Block from server is : " + currentBlock.description); */ + Alert.show("Block from server is : " + block.description); } ]]> Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2009-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-09-24 19:16:41 UTC (rev 281) @@ -292,29 +292,6 @@ -- Table structure for table `game` -- -DROP TABLE IF EXISTS `game`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `game` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `description` longtext, - `image_location` varchar(255) DEFAULT NULL, - `max_days` int(11) NOT NULL, - `max_fish_harvest` int(11) NOT NULL, - `money` double DEFAULT NULL, - `no_of_locations` int(11) NOT NULL, - `no_of_rounds` int(11) NOT NULL, - `timestamp` datetime NOT NULL, - `title` varchar(255) NOT NULL, - `current_block_id` bigint(20) DEFAULT NULL, - `current_round_id` bigint(20) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `FK304BF2F1265AC7` (`current_block_id`), - KEY `FK304BF219A3AF27` (`current_round_id`), - CONSTRAINT `FK304BF219A3AF27` FOREIGN KEY (`current_round_id`) REFERENCES `round_config` (`id`), - CONSTRAINT `FK304BF2F1265AC7` FOREIGN KEY (`current_block_id`) REFERENCES `block` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `game` @@ -330,29 +307,8 @@ -- Table structure for table `game_round_config` -- -DROP TABLE IF EXISTS `game_round_config`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `game_round_config` ( - `game_id` bigint(20) NOT NULL, - `rounds_id` bigint(20) NOT NULL, - UNIQUE KEY `rounds_id` (`rounds_id`), - KEY `FKA0C2A407AC42F73` (`game_id`), - KEY `FKA0C2A40479268AA` (`rounds_id`), - CONSTRAINT `FKA0C2A40479268AA` FOREIGN KEY (`rounds_id`) REFERENCES `round_config` (`id`), - CONSTRAINT `FKA0C2A407AC42F73` FOREIGN KEY (`game_id`) REFERENCES `game` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `game_round_config` --- -LOCK TABLES `game_round_config` WRITE; -/*!40000 ALTER TABLE `game_round_config` DISABLE KEYS */; -/*!40000 ALTER TABLE `game_round_config` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `grp` -- @@ -578,16 +534,6 @@ -- Table structure for table `round_config` -- -DROP TABLE IF EXISTS `round_config`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `round_config` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `communication_flag` tinyint(1) NOT NULL DEFAULT '0', - `round_no` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `round_config` @@ -603,34 +549,8 @@ -- Table structure for table `round_config_location` -- -DROP TABLE IF EXISTS `round_config_location`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `round_config_location` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `location_id` bigint(20) NOT NULL, - `round_id` bigint(20) NOT NULL, - PRIMARY KEY (`id`), - KEY `FKC67B0361224FD013` (`location_id`), - KEY `FKC67B036147CF2321` (`round_id`), - CONSTRAINT `FKC67B036147CF2321` FOREIGN KEY (`round_id`) REFERENCES `round_config` (`id`), - CONSTRAINT `FKC67B0361224FD013` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `round_config_location` --- -LOCK TABLES `round_config_location` WRITE; -/*!40000 ALTER TABLE `round_config_location` DISABLE KEYS */; -/*!40000 ALTER TABLE `round_config_location` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `student` --- - DROP TABLE IF EXISTS `student`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateGameRoundDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateGameRoundDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateGameRoundDao.java 2009-09-24 19:16:41 UTC (rev 281) @@ -0,0 +1,11 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.GameRound; + +public class HibernateGameRoundDao extends HibernateDao<GameRound>{ + + public HibernateGameRoundDao() + { + super(GameRound.class); + } +} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Game.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Game.java 2009-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Game.java 2009-09-24 19:16:41 UTC (rev 281) @@ -6,16 +6,15 @@ import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.Lob; -import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.Table; -import org.hibernate.annotations.CollectionOfElements; - @Entity @Table(name="game") public class Game implements Serializable { @@ -54,9 +53,8 @@ private String imageLocation; // FIXME: should this be many-to-many instead? - @ManyToMany - @CollectionOfElements - private List<Round> rounds; + @OneToMany(mappedBy = "game") + private List<GameRound> gameRounds; @ManyToOne @JoinColumn(name="current_round_id", nullable=true) @@ -66,6 +64,9 @@ @JoinColumn(name="current_block_id", nullable=true) private Block currentBlock; + @OneToMany(mappedBy = "game") + private List<Location> locations; + public void setId(Long id) { this.id = id; @@ -135,12 +136,7 @@ public void setImageLocation(String imageLocation) { this.imageLocation = imageLocation; } - public List<Round> getRounds() { - return rounds; - } - public void setRounds(List<Round> rounds) { - this.rounds = rounds; - } + public void setCurrentRound(Round currentRound) { this.currentRound = currentRound; } @@ -153,7 +149,18 @@ public Block getCurrentBlock() { return currentBlock; } - - + public void setLocations(List<Location> locations) { + this.locations = locations; + } + public List<Location> getLocations() { + return locations; + } + public void setGameRounds(List<GameRound> gameRounds) { + this.gameRounds = gameRounds; + } + public List<GameRound> getGameRounds() { + return gameRounds; + } + } Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameRound.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameRound.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameRound.java 2009-09-24 19:16:41 UTC (rev 281) @@ -0,0 +1,57 @@ +package edu.asu.commons.mme.entity; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "game_round_config") +public class GameRound implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = -2918858356542877284L; + + @Id + @GeneratedValue + private Long id; + + @ManyToOne + @JoinColumn(nullable=false) + private Round round; + + @ManyToOne + @JoinColumn(nullable=false) + private Game game; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setRound(Round round) { + this.round = round; + } + + public Round getRound() { + return round; + } + + public void setGame(Game game) { + this.game = game; + } + + public Game getGame() { + return game; + } + +} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java 2009-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java 2009-09-24 19:16:41 UTC (rev 281) @@ -21,8 +21,8 @@ @GeneratedValue private Long id; - @OneToMany(mappedBy = "location") - private List<RoundLocation> roundLocations; +/* @OneToMany(mappedBy = "location") + private List<RoundLocation> roundLocations;*/ @Column(nullable=false,name="location_name") private String locationName; @@ -87,12 +87,12 @@ public Double getCurrentPopulation() { return currentPopulation; } - public void setRoundLocations(List<RoundLocation> roundLocations) { + /*public void setRoundLocations(List<RoundLocation> roundLocations) { this.roundLocations = roundLocations; } public List<RoundLocation> getRoundLocations() { return roundLocations; - } + }*/ public void setFishLeaving(Double fishLeaving) { this.fishLeaving = fishLeaving; Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/ModuleRoundConfig.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/ModuleRoundConfig.java 2009-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/ModuleRoundConfig.java 2009-09-24 19:16:41 UTC (rev 281) @@ -8,6 +8,7 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OrderBy; import javax.persistence.Table; @@ -33,6 +34,7 @@ @ManyToOne @JoinColumn(nullable = false) + @OrderBy("sequenceNo") private Round round; public void setSequenceNo(Integer sequenceNo) { Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Round.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Round.java 2009-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Round.java 2009-09-24 19:16:41 UTC (rev 281) @@ -24,9 +24,8 @@ @Column(name="round_no",nullable=false) private Integer roundNo; - /*@ManyToMany - @CollectionOfElements - private List<Game> game;*/ + @OneToMany(mappedBy = "round") + private List<GameRound> gameRounds; @Column(name="communication_flag",nullable=false,columnDefinition="Boolean default false") private boolean communicationFlag; @@ -35,9 +34,9 @@ private ModuleRoundConfig round_config;*/ - @OneToMany(mappedBy = "round") + /*@OneToMany(mappedBy = "round") private List<RoundLocation> roundLocations; - + */ public void setId(Long id) { this.id = id; } @@ -57,13 +56,20 @@ public boolean getCommunicationFlag() { return communicationFlag; } - public void setRoundLocations(List<RoundLocation> roundLocations) { + /*public void setRoundLocations(List<RoundLocation> roundLocations) { this.roundLocations = roundLocations; } public List<RoundLocation> getRoundLocations() { return roundLocations; + }*/ + public void setGameRounds(List<GameRound> gameRounds) { + this.gameRounds = gameRounds; } + public List<GameRound> getGameRounds() { + return gameRounds; + } + /*public void setRound_config(ModuleRoundConfig round_config) { this.round_config = round_config; } 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-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/LocationService.java 2009-09-24 19:16:41 UTC (rev 281) @@ -9,6 +9,7 @@ import edu.asu.commons.mme.dao.HibernateLocationDao; import edu.asu.commons.mme.entity.Game; import edu.asu.commons.mme.entity.Location; +import edu.asu.commons.mme.entity.Round; @Transactional public class LocationService extends Service.Base<Location, HibernateLocationDao>{ @@ -24,13 +25,24 @@ for(int i = 0; i < locations.size(); i++) { initLocation = locations.get(i); - Hibernate.initialize(initLocation); - Hibernate.initialize(initLocation.getRoundLocations()); - + initializeLocation(initLocation); } return locations; } + public void initializeLocation(Location location) { + // TODO Auto-generated method stub + Hibernate.initialize(location); + //Hibernate.initialize(location.getRoundLocations()); + Game game = location.getGame(); + Hibernate.initialize(game); + Hibernate.initialize(game); + Hibernate.initialize(game.getCurrentBlock()); + Hibernate.initialize(game.getCurrentRound()); + Hibernate.initialize(game.getGameRounds()); + Hibernate.initialize(game.getLocations()); + } + public Location getLocation(String locationName) { // TODO Auto-generated method stub @@ -94,5 +106,4 @@ getLogger().info("Saved Location " + bay3.getLocationName() +" with id "+ bay3.getId()); } - } 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-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java 2009-09-24 19:16:41 UTC (rev 281) @@ -1,14 +1,17 @@ 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.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; @@ -17,12 +20,15 @@ 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.GameRound; import edu.asu.commons.mme.entity.InformationWindow; +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.entity.RoundLocation; @Transactional public class RoundService extends Service.Base<Round, HibernateRoundConfigDao> { @@ -31,85 +37,109 @@ private HibernateBlockDao blockDao; private HibernateGameDao gameDao; private HibernateModuleRoundConfigDao moduleRoundDao; + private HibernateGameRoundDao gameRoundDao; private LocationService locationService; - - private Module currentModule; + + //private Module currentModule; //private boolean startGame = true; - private Round currentRound; - private Block currentBlock; - private List<Game> currentGames; + //private Round currentRound; + //private Block currentBlock; private int blockSeqNo; - private ModuleRoundConfig currentModuleRoundConfig; - - private boolean gameFinished; public RoundService() { - setCurrentGame(null); + /*setCurrentGame(null); setCurrentBlock(null); setCurrentModule(null); setCurrentModuleRoundConfig(null); - setCurrentRound(null); + setCurrentRound(null);*/ setBlockSeqNo(0); setGameFinished(false); } public Game createGame(Game game) { + getLogger().debug("game came from flex is : " + game.getDescription()); + Game newGame = new Game(); //currentGame = game; - newGame.setDescription(game.getDescription()); - newGame.setMaxDays(game.getMaxDays()); - newGame.setMaxFishHarvest(game.getMaxFishHarvest()); - newGame.setMoney(game.getMoney()); - newGame.setNumberOfRounds(game.getNumberOfRounds()); - newGame.setNumberOfLocations(game.getNumberOfLocations()); - newGame.setTimestamp(game.getTimestamp()); - newGame.setTitle(game.getTitle()); - newGame.setImageLocation("null"); - -// currentGame.setro// - getGameDao().save(newGame); - String str = newGame.getDescription()+newGame.getId(); - - if(getGameDao().findAllByProperty("description", str).size() != 0) + try { - getLogger().debug("in if loop "); - newGame = null; - setCurrentGame(newGame); - } - else + newGame.setDescription(game.getDescription()); + newGame.setMaxDays(game.getMaxDays()); + newGame.setMaxFishHarvest(game.getMaxFishHarvest()); + newGame.setMoney(game.getMoney()); + newGame.setNumberOfRounds(game.getNumberOfRounds()); + newGame.setNumberOfLocations(game.getNumberOfLocations()); + newGame.setTimestamp(game.getTimestamp()); + newGame.setTitle(game.getTitle()); + newGame.setImageLocation("null"); + getGameDao().save(newGame); + String str = newGame.getDescription()+newGame.getId(); + + if(getGameDao().findAllByProperty("description", str).size() != 0) + { + //getLogger().debug("in if loop "); + newGame = null; + } + else + { + newGame.setDescription(str); + getGameDao().save(newGame); + getLogger().info("Created the game: " + newGame.getId()); + initializeGameRounds(newGame); + initializeLocations(newGame); + initializeGame(newGame); + } + }catch(Exception e) { - newGame.setDescription(str); - getGameDao().save(newGame); - setCurrentGame(newGame); - - //initializeGame(newGame); - getLogger().info("Created the game: " + newGame.getId()); - initializeLocations(newGame); + e.printStackTrace(); } getLogger().debug("current game from flex is: " + newGame.getDescription()); return newGame; } - + + private void initializeGameRounds(Game newGame) { + // TODO Auto-generated method stub + List<GameRound> gameRounds = new ArrayList<GameRound>(); + + for(Round round:getDao().findAll()) + { + GameRound gameRound = new GameRound(); + gameRound.setGame(newGame); + gameRound.setRound(round); + gameRoundDao.save(gameRound); + gameRounds.add(gameRound); + } + newGame.setGameRounds(gameRounds); + getGameDao().save(newGame); + } + private void initializeLocations(Game newGame) { locationService.setAllLocations(newGame); + newGame.setLocations(locationService.getAllLocations()); + getGameDao().save(newGame); } - private void initializeGame(Game game) { + public void initializeGame(Game game) { // TODO Auto-generated method stub Hibernate.initialize(game); Hibernate.initialize(game.getCurrentBlock()); Hibernate.initialize(game.getCurrentRound()); - /*Iterator<Round> rounds = game.getRounds().iterator(); - while(rounds.hasNext()) - { - initializeRound(rounds.next()); - }*/ + // Hibernate.initialize(game.getLocations()); + + for(GameRound gameRound :game.getGameRounds()){ + Hibernate.initialize(gameRound); + //Hibernate.initialize(gameRound.getGame()); + initializeRound(gameRound.getRound()); + } + for(Location location :game.getLocations()){ + locationService.initializeLocation(location); + } } public Module getNextModule(int sequenceNo) @@ -130,82 +160,107 @@ *4) Find out the current block number *5) Return the next block */ - - public Block getBlock() + + public Game getBlock(Game game) { - //getLogger().debug("in getBlock "); - //setCurrentModuleRoundConfig(currentModuleRoundConfig); - //find out the current module number - if(currentModuleRoundConfig == null){ - currentModuleRoundConfig = new ModuleRoundConfig(); - if(currentRound == null) - { - setNextRound(); - setModuleForCurrentRound(0); - if(currentBlock == null) - { - setCurrentBlock(new Block()); - currentBlock = getBlock(1); - } - } + 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().debug("Current Round is null... "); + getLogger().debug("Current block is null... "); + + getLogger().debug("Starting of the game...." + game.getDescription()); + currentRound = getNextRound(null); + currentModuleRoundConfig = getModuleRoundConfig(0, currentRound); + Module currentModule = getModuleForCurrentRound(currentModuleRoundConfig); + currentBlock = getBlock(currentModule,1); } else { - if(isCurrentModuleFinished()) + 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"); - if(isCurrentRoundFinished()) + //currentModuleRoundConfig = game.getCurrentRound(). + if(isCurrentRoundFinished(game)) { getLogger().debug("current round is finished"); - if(isGameFinished()) + if(isGameFinished(game)) { + getLogger().debug("Game is finished..." + game.getId()); return null; } else { //set the next round - setNextRound(); - setModuleForCurrentRound(0); - if(currentBlock == null) - { - setCurrentBlock(new Block()); - currentBlock = getBlock(1); - } + currentRound = getNextRound(game.getCurrentRound()); + currentModuleRoundConfig = getModuleRoundConfig(0, currentRound); + Module currentModule = getModuleForCurrentRound(currentModuleRoundConfig); + currentBlock = getBlock(currentModule,1); } } else { getLogger().debug("current round is not finished"); - setModuleForCurrentRound(getCurrentModuleRoundConfig().getSequenceNo()); - if(currentBlock == null) - { - setCurrentBlock(new Block()); - currentBlock = getBlock(1); - } + //currentRound = getNextRound(game.getCurrentRound()); + + currentModuleRoundConfig = getModuleRoundConfig(getPreviousModuleConfigSequenceNo(game), currentRound); + Module currentModule = getModuleForCurrentRound(currentModuleRoundConfig); + currentBlock = getBlock(currentModule,1); + } } else { //get the next block in the module - getLogger().debug("currentmodule is " + currentModule.getId()); - setNextBlock(); - getLogger().debug(currentBlock.getDescription()); + //getLogger().debug("currentmodule is " + game.getCurrentBlock().getModule().getId()); + currentBlock = getNextBlock(game.getCurrentBlock()); + getLogger().debug("the next block for the game is: " + game.getCurrentBlock().getDescription()); } } - saveGameState(currentBlock); - getLogger().debug("question group sizes is : " + currentBlock.getQuestionGroups().size()); - initializeCurrentBlock(currentBlock); - getLogger().debug("Module is " + currentModule.getId() + "Block sent to the server is: " + getCurrentBlock().getDescription()); - return getCurrentBlock(); + 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 void setModuleForCurrentRound(int prevSeqNo) { + 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); @@ -214,94 +269,59 @@ if(moduleRoundConfigs.get(i).getSequenceNo() > prevSeqNo) { currentModuleRoundConfig = moduleRoundConfigs.get(i); - setCurrentModuleRoundConfig(currentModuleRoundConfig); - setCurrentModule(moduleRoundConfigs.get(i).getModule()); - getLogger().debug("current module is: " + getCurrentModule().getDescription()); - setCurrentBlock(null); 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 void setNextRound() { + + private Round getNextRound(Round currentRound) { // TODO Auto-generated method stub + Round returnRound = null; if(currentRound == null) { - currentRound = new Round(); - currentRound = getDao().findByProperty("roundNo", 1); - setCurrentRound(currentRound); - initializeRound(currentRound); + returnRound = getDao().findByProperty("roundNo", 1); + //returnRound = currentRound; + //initializeRound(returnRound); } else { + getLogger().debug("current round no is: " + currentRound.getRoundNo()); List<Round> rounds = getDao().findAll(); for(int i = 0; i < rounds.size(); i++) { + getLogger().debug("in for loop round no is: " + rounds.get(i).getRoundNo()); if(currentRound.getRoundNo() < rounds.get(i).getRoundNo()) { - setCurrentRound(rounds.get(i)); + returnRound = rounds.get(i); break; + //getLogger().debug("currentround object is "+ rounds.get(i).getId()); } } } - getLogger().debug("currentround object is "+ currentRound.getId()); + getLogger().debug("currentround object is "+ returnRound.getId()); + return returnRound; } - - private boolean isCurrentRoundFinished() { - // TODO Auto-generated method stub - List<ModuleRoundConfig> moduleRoundConfigs = new ArrayList<ModuleRoundConfig> (); - moduleRoundConfigs = moduleRoundDao.findAllByProperty("round",currentRound); - - if(currentModuleRoundConfig == null) - { - getLogger().debug("currentModuleRoundConfig is null"); - return true; - } - else - { - if(moduleRoundConfigs.size() == 1) - { - return true; - - } - else - { - getLogger().debug("check condition is "+ moduleRoundConfigs.get(moduleRoundConfigs.size() - 1).getSequenceNo()); - int seqNo = moduleRoundConfigs.get(moduleRoundConfigs.size() - 1).getSequenceNo(); - if((currentModuleRoundConfig.getSequenceNo()) == seqNo) - { - getLogger().debug("flag return is true"); - return 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(i).getSequenceNo()) - { - return false; - } - } - } - } - } - - return false; - } - public HibernateModuleDao getModuleDao() { return moduleDao; } @@ -339,25 +359,25 @@ Module module = block.getModule(); Hibernate.initialize(module); - initializeModule(currentModule); + initializeModule(module); } - private void setNextBlock() { + private Block getNextBlock(Block currentBlock) { // TODO Auto-generated method stub List<Block> blocks = new ArrayList<Block>(); - blocks = getCurrentModule().getBlocks(); - + blocks = currentBlock.getModule().getBlocks(); + Block returnBlock = null; for(int i = 0; i < blocks.size(); i++) { if(currentBlock.getSequenceNo() < blocks.get(i).getSequenceNo()) { - setCurrentBlock(blocks.get(i)); + returnBlock = blocks.get(i); break; } - } + return returnBlock; } @@ -373,7 +393,7 @@ return module; } - public Block getBlock(int seqNo) + public Block getBlock(Module currentModule, int seqNo) { //Module module = new Module(); // module = currentModule; @@ -390,7 +410,7 @@ return block; } - private void setRound(int roundNo) { + /* private void setRound(int roundNo) { // TODO Auto-generated method stub currentRound = new Round(); @@ -399,9 +419,9 @@ getLogger().debug("currentround object is "+ currentRound.getId()); setCurrentRound(currentRound); - } + }*/ - private int getCurrentRoundNo() { + /*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); @@ -410,51 +430,134 @@ else return getCurrentGame().getCurrentRound().getRoundNo(); + }*/ + public boolean isGameFinished(Game game) { + List<GameRound> gameRounds = game.getGameRounds(); + boolean flag = false; + + if(game.getCurrentRound().getRoundNo() == gameRounds.get(gameRounds.size() - 1).getRound().getRoundNo()) + { + flag = true; + } + else + { + for(GameRound gameRound:gameRounds) + { + if(game.getCurrentRound().getRoundNo() < game.getCurrentRound().getRoundNo()) + { + flag = false; + } + } + + } + return flag; } - private boolean isCurrentModuleFinished() { + 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(currentModule == null) + if(currentBlock == null) { - return true; + flag = true; } else { - blocks = getCurrentModule().getBlocks(); + 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: " + getCurrentModule().getId()); - + getLogger().debug("no of blocks " + blocks.size() +"for module id: " + currentModule.getId()); + //if module contains only one block if(blocks.size() == 1) - return true; + flag = true; else { for(int i = 0; i < blocks.size(); i++) { - if(currentBlock.getSequenceNo() == blocks.get(blocks.size() - 1).getSequenceNo()) - return true; + flag = true; if(currentBlock.getSequenceNo() < blocks.get(i).getSequenceNo()) { - return false; + flag = false; } } } } - return false; + return flag; } + private Game saveGameState(Block currentBlock, Round currentRound, Game game) { - private void saveGameState(Block currentBlock) { - //FIXME: Game id 1 is hard coded but needs to make it dynamic - //Game game = gameDao.find(1L); - - currentGame.setCurrentBlock(currentBlock); - currentGame.setCurrentRound(currentRound); - gameDao.save(currentGame); + 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().getId()); + newGame.setCurrentBlock(currentBlock); + newGame.setCurrentRound(currentRound); + gameDao.save(newGame); + getLogger().info("The game state is saved. The current block : " + newGame.getCurrentBlock().getId() + "while the current Round is: " + newGame.getCurrentRound().getId()); + return newGame; } public Integer getTimerforBlock(Block block) @@ -502,49 +605,43 @@ } } - public Block getCurrentBlock() { + /*public Block getCurrentBlock() { //FIXEME: game id 1 is hard coded, it should be dynamic -// Game game = gameDao.find(1L); + // Game game = gameDao.find(1L); Block block = new Block(); block = currentGame.getCurrentBlock(); // Hibernate.initialize(block); return block; - } + }*/ - public void setCurrentModule(Module currentModule) { - this.currentModule = currentModule; - } - public Module getCurrentModule() { - return currentModule; - } - - public void setCurrentRound(Round currentRound) { - this.currentRound = currentRound; - } - - public Round getCurrentRound() { + /*public Round getCurrentRound() { getLogger().debug("in get current round funciton"); - /*Round round = currentGame.getCurrentRound(); + Round round = currentGame.getCurrentRound(); //Round round = getDao().find(getCurrentRound().getId()); - - initializeRound(round);*/ + + initializeRound(round); getLogger().debug("round no is " + currentRound.getRoundNo() + " " + currentRound.getId()); return currentRound; - } + }*/ private void initializeRound(Round round) { // TODO Auto-generated method stub Hibernate.initialize(round); - - Hibernate.initialize(round.getRoundLocations()); + //Hibernate.initialize(round.getRoundLocations()); + /*for (RoundLocation roundLocation: round.getRoundLocations()) { Hibernate.initialize(roundLocation); //hibernateroundLocation.getLocation(); }*/ - + for (GameRound gameRound: round.getGameRounds()) { + Hibernate.initialize(gameRound); + //hibernateroundLocation.getLocation(); + } + + //Hibernate.initialize(currentRound.getLocations()); } @@ -575,46 +672,12 @@ public HibernateBlockDao getBlockDao() { return blockDao; } - - public void setModuleRoundConfig(ModuleRoundConfig moduleRoundConfig) { - this.currentModuleRoundConfig = moduleRoundConfig; - } - - public ModuleRoundConfig getModuleRoundConfig() { - return currentModuleRoundConfig; - } - public void setGameFinished(boolean gameFinished) { this.gameFinished = gameFinished; } - public boolean isGameFinished() { - if(getCurrentGame().getCurrentRound().getRoundNo() < currentRound.getRoundNo()) - { - gameFinished = true; - } - return false; - } - public void setCurrentBlock(Block currentBlock) { - this.currentBlock = currentBlock; - } - public ModuleRoundConfig getCurrentModuleRoundConfig() { - return currentModuleRoundConfig; - } - - public void setCurrentModuleRoundConfig( - ModuleRoundConfig currentModuleRoundConfig) { - this.currentModuleRoundConfig = currentModuleRoundConfig; - } - public void setCurrentGame(Game game) { - this.currentGame = game; - } - public Game getCurrentGame() { - return currentGame; - } - public void setLocationService(LocationService locationService) { this.locationService = locationService; } @@ -623,11 +686,16 @@ return locationService; } - public void setCurrentGames(List<Game> currentGames) { - this.currentGames = currentGames; + public String getDescription(Game game) { + // TODO Auto-generated method stub + return game.getDescription(); } - public List<Game> getCurrentGames() { - return currentGames; + public void setGameRoundDao(HibernateGameRoundDao gameRoundDao) { + this.gameRoundDao = gameRoundDao; } + + public HibernateGameRoundDao getGameRoundDao() { + return gameRoundDao; + } } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java 2009-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java 2009-09-24 19:16:41 UTC (rev 281) @@ -11,7 +11,7 @@ import flex.messaging.util.UUIDUtils; -public class StartGame extends Thread { +public class StartGame implements Runnable { private static Logger logger = Logger.getLogger(StartGame.class); private boolean running; @@ -20,19 +20,24 @@ private DayByDayDecisionsService dayBydayDecisionService; private StudentService studentService; private ModuleRoundConfig currentModuleRoundConfig; - + private Game game; + public StartGame() { - System.out.println("module service object is "); + //System.out.println("module service object is "); /*moduleService.test(); moduleService.setStartModule(true);*/ + /*setRoundService(new RoundService()); + setLocationService(new LocationService()); + */ setRunning(true); + } - + public Student createStudent(Student student) { -// Game game = new Game(); - Game game = roundService.getCurrentGame(); + // Game game = new Game(); + Game game = student.getGame(); Student studentReturn = null; //System.out.println("game description: " + game.getDescription() + " student game code is: " + student.getGameCode()); if(game.getDescription().equals(student.getGameCode())) @@ -44,13 +49,21 @@ } return studentReturn; } - + public Game createGame(Game game) { - System.out.println("game came from flex is: " + game.getDescription()); - return roundService.createGame(game); + //System.out.println("game came from flex is: " + game.getDescription()); + game = roundService.createGame(game); + System.out.println("game object return from round service is: " + game); + if(game != null) + { + setGame(game); + } + //roundService.initializeGame(game); + return game; + } - + public List<Student> assignGroups() { return studentService.assignGroups(); @@ -67,31 +80,43 @@ */ public void run() { - Block block = new Block(); + Game newGameState = null; + Block block = null; //roundService.test(); - MessageBroker msgBroker = MessageBroker.getMessageBroker("_messageBroker"); String clientID = UUIDUtils.createUUID(); + newGameState = game; int i=0; - while (i<5) { + while (i<17) { i++; - String msgDestination = roundService.getCurrentGame().getDescription(); + String msgDestination = roundService.getDescription(game); //Push the first block to the clients AsyncMessage msg = new AsyncMessage(); - msg.setDestination("chat"); - //msg.setHeader("DSSubtopic", "hello3"); + + msg.setDestination("mme"); + msg.setHeader("DSSubtopic", msgDestination); msg.setClientId(clientID); msg.setMessageId(UUIDUtils.createUUID()); msg.setTimestamp(System.currentTimeMillis()); - block = roundService.getBlock(); - msg.setBody(block); + + newGameState = roundService.getBlock(game); + setGame(newGameState); + if(newGameState == null) + { + msg.setBody(null); + } + else + { + block = newGameState.getCurrentBlock(); + msg.setBody(block); + } msgBroker.routeMessageToService(msg, null); logger.debug("message is sent to the client: " + msg); - - /* if(block.getDescription().equalsIgnoreCase("Day-by-day decisions game")) + + /* if(block.getDescription().equalsIgnoreCase("Day-by-day decisions game")) { //start day by day decision //getDayBydayDecisionService(). @@ -107,22 +132,18 @@ //start the timer for the block sent try { //for testing purpose 5000 is given as an argument - Thread.sleep(20000); + Thread.sleep(10000); if(block == null) { running = false; } } catch (InterruptedException e) { } - - } - } - + private boolean isGameOver() { // TODO Auto-generated method stub - return false; } @@ -166,5 +187,12 @@ this.studentService = studentService; } + public void setGame(Game game) { + this.game = game; + } + + public Game getGame() { + return game; + } } 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-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java 2009-09-24 19:16:41 UTC (rev 281) @@ -21,6 +21,7 @@ //private QuestionCreatorService questionCreatorService; private StartGame startGame; private ApplicationContext ctx; + private ArrayList<StartGame> currentGames; /*public void setQuestionCreatorService(QuestionCreatorService questionCreatorService) { this.questionCreatorService = questionCreatorService; @@ -33,11 +34,27 @@ public Game createGame(Game game) { - if(getStartGame() == null) + Game newGame = null; + try { setStartGame(); + newGame = getStartGame().createGame(game); + if(newGame != null) + { + System.out.println("new Game is: " + newGame); + if(currentGames == null) + { + currentGames = new ArrayList<StartGame>(); + } + System.out.println("startGame is: " + startGame); + System.out.println("current games are: " + currentGames); + currentGames.add(startGame); + } + }catch(Exception e ) + { + e.printStackTrace(); } - return startGame.createGame(game); + return newGame; } public void assignGroups() @@ -57,19 +74,34 @@ System.out.println("Students size is: " + students.size()); msgBroker.routeMessageToService(msg, null); - } - public void startGame() + public void startGame(Game game) { //push assign groups to all the students //assignGroups(); //start the game - this.startGame.run(); + System.out.println("Game came from client is to start: " + game.getId() + "size of currentGame is " + currentGames.size()); + try + { + for(int i = 0; i < currentGames.size(); i++) + { + System.out.println("game in for loop is: " + currentGames.get(i).getGame().getId()); + + if(currentGames.get(i).getGame().getId().equals(game.getId())) + { + System.out.println("Game is found"); + currentGames.get(i).run(); + } + } + }catch(Exception e) + { + e.printStackTrace(); + } } - public void stop() { + public void stop(Game game) { startGame.setRunning(false); startGame = null; } @@ -83,10 +115,8 @@ public void setStartGame() { try{ - if (startGame == null) { - this.startGame = (StartGame)ctx.getBean("startGame"); - - } + this.startGame = (StartGame)ctx.getBean("startGame"); + System.out.println("startGame is: " + startGame); }catch(Exception e) { System.out.println(e.getStackTrace()); @@ -94,7 +124,6 @@ } public StartGame getStartGame() { - return startGame; } } Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-09-24 19:16:41 UTC (rev 281) @@ -100,6 +100,10 @@ <bean id='moduleRoundDao' class='edu.asu.commons.mme.dao.HibernateModuleRoundConfigDao'> <property name='sessionFactory' ref='sessionFactory'/> </bean> + + <bean id='gameRoundDao' class='edu.asu.commons.mme.dao.HibernateGameRoundDao'> + <property name='sessionFactory' ref='sessionFactory'/> + </bean> <!-- spring managed service layer --> @@ -114,7 +118,7 @@ <property name='gameDao' ref='gameDao' /> <property name='moduleRoundDao' ref='moduleRoundDao' /> <property name='locationService' ref='locationService'/> - <!-- <property name='blockDao' ref='blockDao'/> --> + <property name='gameRoundDao' ref='gameRoundDao'/> </bean> @@ -161,7 +165,7 @@ <property name="startModule" value="Testing String."/> </bean> --> - <bean id="startGame" class="edu.asu.commons.mme.service.StartGame"> + <bean id="startGame" class="edu.asu.commons.mme.service.StartGame" scope = "prototype"> <property name='roundService' ref='roundService'/> <property name='locationService' ref='locationService'/> <property name='studentService' ref='studentService'/> @@ -184,7 +188,7 @@ <!-- Expose services for Flex/BlazeDS messaging --> <flex:message-destination id="chat" /> - <flex:message-destination id="mme" /> + <flex:message-destination id="mme" allow-subtopics="true" subtopic-separator="." /> <!-- Flex related information ended--> <bean id="mmeDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml 2009-09-16 21:14:48 UTC (rev 280) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml 2009-09-24 19:16:41 UTC (rev 281) @@ -10,12 +10,15 @@ <mapping class='edu.asu.commons.mme.entity.Game'/> <mapping class='edu.asu.commons.mme.entity.Round'/> <mapping class='edu.asu.commons.mme.entity.Location'/> + <!-- <mapping class='edu.asu.commons.mme.entity.RoundLocation'/> + --> + <mapping class='edu.asu.commons.mme.entity.Communication'/> <mapping class='edu.asu.commons.mme.entity.Group'/> <mapping class='edu.asu.commons.mme.entity.Student'/> + <mapping class='edu.asu.commons.mme.entity.GameRound'/> - <mapping class='edu.asu.commons.mme.entity.StudentRoundConfig'/> <mapping class='edu.asu.commons.mme.entity.StudentStrategy'/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |