[virtualcommons-svn] SF.net SVN: virtualcommons:[283] mentalmodels/trunk
Status: Beta
Brought to you by:
alllee
From: <see...@us...> - 2009-09-28 22:57:37
|
Revision: 283 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=283&view=rev Author: seematalele Date: 2009-09-28 22:57:24 +0000 (Mon, 28 Sep 2009) Log Message: ----------- Created GameConfig.java entity which is a meta data for game configuration. Game.java will use one of the GameConfig.java configuration for conducting the game. Changed the FisheryExperimentCore.mxml so that each participant will receive blocks for that particular game. I have manually added entries in the database in GameConfig and gameroundConfig table. Created the GameConfig.as and change the actionscript classes according to the schema (entities in the java side). Modified Paths: -------------- mentalmodels/trunk/flex/src/StartGame.mxml mentalmodels/trunk/flex/src/actionscript/Game.as mentalmodels/trunk/flex/src/actionscript/Location.as mentalmodels/trunk/flex/src/actionscript/Student.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.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/GameRound.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.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/ModuleService.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/classes/log4j.properties mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/GameConfig.as mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateGameConfigDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameConfig.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Instructor.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameConfigService.java Removed Paths: ------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/RoundLocation.java Modified: mentalmodels/trunk/flex/src/StartGame.mxml =================================================================== --- mentalmodels/trunk/flex/src/StartGame.mxml 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/flex/src/StartGame.mxml 2009-09-28 22:57:24 UTC (rev 283) @@ -109,13 +109,9 @@ var gameObject:Game = new Game(); gameObject.money = stpMoney.value; - gameObject.description = txtDescription.text; - gameObject.numberOfRounds = 2; - gameObject.maxDays = 30; - gameObject.maxFishHarvest = 100; + gameObject.gameCode = txtDescription.text; gameObject.timestamp = new Date(); - gameObject.title = "test Game Title"; - + startupService.createGame(gameObject); /* var message:AsyncMessage = new AsyncMessage(); message.body = "got gameObject" + gameObject.description; @@ -146,7 +142,7 @@ if(event.result != null) { - var description:String = (event.result as Game).description; + var description:String = (event.result as Game).gameCode; btnStartGame.enabled = true; game = event.result as Game; txtGameID.text = description; Modified: mentalmodels/trunk/flex/src/actionscript/Game.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Game.as 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/flex/src/actionscript/Game.as 2009-09-28 22:57:24 UTC (rev 283) @@ -1,21 +1,15 @@ package actionscript { - import mx.collections.ArrayCollection; - [Bindable] [RemoteClass(alias="edu.asu.commons.mme.entity.Game")] public class Game { public var id:Number; - public var numberOfRounds:int; - public var numberOfLocations:int; - public var maxDays:int; - public var maxFishHarvest:int; - public var timestamp:Date; - public var title:String; - public var description:String; + public var gameConfig:GameConfig; + public var timestamp:Date; + public var gameCode:String; public var money:Number; - public var imageLocation:String; - public var rounds:ArrayCollection; + public var currentRound:Round; + public var currentBlock:Block; } } \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/GameConfig.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/GameConfig.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/GameConfig.as 2009-09-28 22:57:24 UTC (rev 283) @@ -0,0 +1,19 @@ +package actionscript +{ + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.GameConfig")] + public class GameConfig + { + public var id:Number; + public var numberOfRounds:int; + public var numberOfLocations:int; + public var maxDays:int; + public var maxFishHarvest:int; + public var timestamp:Date; + public var title:String; + public var description:String; + public var money:Number; + public var imageLocation:String; + + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/Location.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Location.as 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/flex/src/actionscript/Location.as 2009-09-28 22:57:24 UTC (rev 283) @@ -1,6 +1,5 @@ package actionscript { - import mx.collections.ArrayCollection; [Bindable] [RemoteClass(alias="edu.asu.commons.mme.entity.Location")] @@ -11,6 +10,9 @@ public var maxCapacity:int; public var growthRate:Number; public var initialPopulation:int; - public var roundLocations:ArrayCollection; + public var currentPopulation:Number; + public var fishLeaving:Number; + public var fishReturned:Number; + public var gameConfig:GameConfig; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/Student.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Student.as 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/flex/src/actionscript/Student.as 2009-09-28 22:57:24 UTC (rev 283) @@ -16,6 +16,7 @@ public var timestamp:Date; public var gender:String; public var gameCode:String; + public var game:Game; /** * input: Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-09-28 22:57:24 UTC (rev 283) @@ -68,7 +68,7 @@ </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/messagebroker/streamingamf"/> --> @@ -405,6 +405,7 @@ } else { + consumer.subtopic = studentObject.gameCode; consumer.subscribe(); //Alert.show("GameCode is '" + studentObject.gameCode + "'"); //Alert.show("subscribed to destination: " + consumer.destination); Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-09-28 22:57:24 UTC (rev 283) @@ -292,6 +292,26 @@ -- 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, + `gameCode` varchar(255) NOT NULL, + `money` double DEFAULT NULL, + `timestamp` datetime NOT NULL, + `current_block_id` bigint(20) DEFAULT NULL, + `current_round_id` bigint(20) DEFAULT NULL, + `gameConfig_id` bigint(20) NOT NULL, + PRIMARY KEY (`id`), + KEY `FK304BF2F1265AC7` (`current_block_id`), + KEY `FK304BF219A3AF27` (`current_round_id`), + KEY `FK304BF25E134D93` (`gameConfig_id`), + CONSTRAINT `FK304BF25E134D93` FOREIGN KEY (`gameConfig_id`) REFERENCES `game_config` (`id`), + CONSTRAINT `FK304BF219A3AF27` FOREIGN KEY (`current_round_id`) REFERENCES `round_config` (`id`), + CONSTRAINT `FK304BF2F1265AC7` FOREIGN KEY (`current_block_id`) REFERENCES `block` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `game` @@ -299,16 +319,69 @@ LOCK TABLES `game` WRITE; /*!40000 ALTER TABLE `game` DISABLE KEYS */; -INSERT INTO `game` VALUES (1,'First game','island.jpg',30,5,0,4,4,'2009-07-19 17:30:35','Mental Model Experiment',3,2),(2,'dell2','null',30,100,0.01,0,2,'2009-08-21 14:58:14','test Game Title',1,1); /*!40000 ALTER TABLE `game` ENABLE KEYS */; UNLOCK TABLES; -- +-- Table structure for table `game_config` +-- + +DROP TABLE IF EXISTS `game_config`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `game_config` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `description` longtext NOT NULL, + `image_location` varchar(255) DEFAULT NULL, + `max_days` int(11) NOT NULL, + `max_fish_harvest` int(11) NOT NULL, + `no_of_locations` int(11) NOT NULL, + `timestamp` datetime NOT NULL, + `title` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `game_config` +-- + +LOCK TABLES `game_config` WRITE; +/*!40000 ALTER TABLE `game_config` DISABLE KEYS */; +INSERT INTO `game_config` VALUES (1,'Mental Model Experiment',NULL,30,5,4,'2009-09-28 11:26:14','E-Fishery'); +/*!40000 ALTER TABLE `game_config` ENABLE KEYS */; +UNLOCK TABLES; + +-- -- 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` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `sequence_no` int(11) NOT NULL, + `gameConfig_id` bigint(20) NOT NULL, + `round_id` bigint(20) NOT NULL, + PRIMARY KEY (`id`), + KEY `FKA0C2A405E134D93` (`gameConfig_id`), + KEY `FKA0C2A4047CF2321` (`round_id`), + CONSTRAINT `FKA0C2A4047CF2321` FOREIGN KEY (`round_id`) REFERENCES `round_config` (`id`), + CONSTRAINT `FKA0C2A405E134D93` FOREIGN KEY (`gameConfig_id`) REFERENCES `game_config` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 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 */; +INSERT INTO `game_round_config` VALUES (1,1,1,1),(2,2,1,2),(3,3,1,3),(4,4,1,4); +/*!40000 ALTER TABLE `game_round_config` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `grp` -- @@ -361,8 +434,35 @@ -- Table structure for table `location` -- +DROP TABLE IF EXISTS `location`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `location` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `current_population` double DEFAULT NULL, + `fish_leaving` double DEFAULT NULL, + `fish_return` double DEFAULT NULL, + `growth_rate` double NOT NULL, + `initial_population` double NOT NULL, + `location_name` varchar(255) NOT NULL, + `max_capacity` double NOT NULL, + `gameConfig_id` bigint(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `FK714F9FB55E134D93` (`gameConfig_id`), + CONSTRAINT `FK714F9FB55E134D93` FOREIGN KEY (`gameConfig_id`) REFERENCES `game_config` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; -- +-- Dumping data for table `location` +-- + +LOCK TABLES `location` WRITE; +/*!40000 ALTER TABLE `location` DISABLE KEYS */; +/*!40000 ALTER TABLE `location` ENABLE KEYS */; +UNLOCK TABLES; + +-- -- Table structure for table `module` -- @@ -534,6 +634,15 @@ -- 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', + 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` @@ -541,16 +650,14 @@ LOCK TABLES `round_config` WRITE; /*!40000 ALTER TABLE `round_config` DISABLE KEYS */; -INSERT INTO `round_config` VALUES (1,0,1),(2,0,2),(3,1,3),(4,0,4); +INSERT INTO `round_config` VALUES (1,0),(2,0),(3,1),(4,0); /*!40000 ALTER TABLE `round_config` ENABLE KEYS */; UNLOCK TABLES; -- --- Table structure for table `round_config_location` +-- Table structure for table `student` -- - - DROP TABLE IF EXISTS `student`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -742,4 +849,4 @@ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2009-09-04 0:47:19 +-- Dump completed on 2009-09-28 18:29:10 Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateGameConfigDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateGameConfigDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateGameConfigDao.java 2009-09-28 22:57:24 UTC (rev 283) @@ -0,0 +1,12 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.GameConfig; + +public class HibernateGameConfigDao extends HibernateDao<GameConfig> { + + public HibernateGameConfigDao() + { + super(GameConfig.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-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Game.java 2009-09-28 22:57:24 UTC (rev 283) @@ -2,17 +2,13 @@ import java.io.Serializable; import java.sql.Timestamp; -import java.util.List; 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.ManyToOne; -import javax.persistence.OneToMany; import javax.persistence.Table; @Entity @@ -25,37 +21,19 @@ @GeneratedValue private Long id; - @Column(name="no_of_rounds",nullable = false) - private Integer numberOfRounds; + @ManyToOne + @JoinColumn(nullable = false) + private GameConfig gameConfig; - @Column(name="no_of_locations",nullable = false) - private Integer numberOfLocations; - - @Column(name="max_days",nullable = false) - private Integer maxDays; - - @Column(name="max_fish_harvest",nullable = false) - private Integer maxFishHarvest; - @Column(nullable=false) private Timestamp timestamp; @Column(nullable=false) - private String title; + private String gameCode; - @Lob - private String description; - @Column(scale=2) private Double money; - @Column(name="image_location") - private String imageLocation; - - // FIXME: should this be many-to-many instead? - @OneToMany(mappedBy = "game") - private List<GameRound> gameRounds; - @ManyToOne @JoinColumn(name="current_round_id", nullable=true) private Round currentRound; @@ -64,10 +42,6 @@ @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; } @@ -75,18 +49,6 @@ return id; } - public void setTitle(String title) { - this.title = title; - } - public String getTitle() { - return title; - } - public void setDescription(String description) { - this.description = description; - } - public String getDescription() { - return description; - } public void setMoney(Double money) { this.money = money; } @@ -94,49 +56,12 @@ return money; } - /*public void setRoundconfig(List<Round> roundconfig) { - this.rounds = roundconfig; - } - public List<Round> getRoundconfig() { - return rounds; - }*/ public void setTimestamp(Timestamp timestamp) { this.timestamp = timestamp; } public Timestamp getTimestamp() { return timestamp; } - public Integer getNumberOfRounds() { - return numberOfRounds; - } - public void setNumberOfRounds(Integer numberOfRounds) { - this.numberOfRounds = numberOfRounds; - } - public Integer getNumberOfLocations() { - return numberOfLocations; - } - public void setNumberOfLocations(Integer numberOfLocations) { - this.numberOfLocations = numberOfLocations; - } - public Integer getMaxDays() { - return maxDays; - } - public void setMaxDays(Integer maxDays) { - this.maxDays = maxDays; - } - public Integer getMaxFishHarvest() { - return maxFishHarvest; - } - public void setMaxFishHarvest(Integer maxFishHarvest) { - this.maxFishHarvest = maxFishHarvest; - } - public String getImageLocation() { - return imageLocation; - } - public void setImageLocation(String imageLocation) { - this.imageLocation = imageLocation; - } - public void setCurrentRound(Round currentRound) { this.currentRound = currentRound; } @@ -149,17 +74,17 @@ public Block getCurrentBlock() { return currentBlock; } - public void setLocations(List<Location> locations) { - this.locations = locations; + public void setGameConfig(GameConfig gameConfig) { + this.gameConfig = gameConfig; } - public List<Location> getLocations() { - return locations; + public GameConfig getGameConfig() { + return gameConfig; } - public void setGameRounds(List<GameRound> gameRounds) { - this.gameRounds = gameRounds; + public void setGameCode(String gameCode) { + this.gameCode = gameCode; } - public List<GameRound> getGameRounds() { - return gameRounds; + public String getGameCode() { + return gameCode; } } Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameConfig.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameConfig.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameConfig.java 2009-09-28 22:57:24 UTC (rev 283) @@ -0,0 +1,120 @@ +package edu.asu.commons.mme.entity; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +@Entity +@Table(name="game_config") +public class GameConfig implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = -5758994275900963337L; + + @Id + @GeneratedValue + private Long id; + + @Column(nullable=false) + private String title; + + @Lob + @Column(nullable=false) + private String description; + + @Column(name="no_of_locations",nullable = false) + private Integer numberOfLocations; + + @Column(name="max_days",nullable = false) + private Integer maxDays; + + @Column(name="max_fish_harvest",nullable = false) + private Integer maxFishHarvest; + + @Column(nullable=false) + private Timestamp timestamp; + + @Column(name="image_location") + private String imageLocation; + + // FIXME: should this be many-to-many instead? +/* @OneToMany(mappedBy = "gameConfig") + private List<GameRound> gameRounds;*/ + + @OneToMany(mappedBy = "gameConfig") + private List<Location> locations; + + + public void setId(Long id) { + this.id = id; + } + public Long getId() { + return id; + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = timestamp; + } + public Timestamp getTimestamp() { + return timestamp; + } + public Integer getNumberOfLocations() { + return numberOfLocations; + } + public void setNumberOfLocations(Integer numberOfLocations) { + this.numberOfLocations = numberOfLocations; + } + public Integer getMaxDays() { + return maxDays; + } + public void setMaxDays(Integer maxDays) { + this.maxDays = maxDays; + } + public Integer getMaxFishHarvest() { + return maxFishHarvest; + } + public void setMaxFishHarvest(Integer maxFishHarvest) { + this.maxFishHarvest = maxFishHarvest; + } + public String getImageLocation() { + return imageLocation; + } + public void setImageLocation(String imageLocation) { + this.imageLocation = imageLocation; + } + 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; + }*/ + public void setTitle(String title) { + this.title = title; + } + public String getTitle() { + return title; + } + public void setDescription(String description) { + this.description = description; + } + public String getDescription() { + return description; + } +} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameRound.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameRound.java 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/GameRound.java 2009-09-28 22:57:24 UTC (rev 283) @@ -2,11 +2,13 @@ import java.io.Serializable; +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.OrderBy; import javax.persistence.Table; @Entity @@ -24,11 +26,15 @@ @ManyToOne @JoinColumn(nullable=false) + @OrderBy("seqNo") private Round round; @ManyToOne @JoinColumn(nullable=false) - private Game game; + private GameConfig gameConfig; + + @Column(name="sequence_no",nullable=false) + private Integer seqNo; public void setId(Long id) { this.id = id; @@ -46,12 +52,20 @@ return round; } - public void setGame(Game game) { - this.game = game; + public void setGameConfig(GameConfig gameConfig) { + this.gameConfig = gameConfig; } - public Game getGame() { - return game; + public GameConfig getGameConfig() { + return gameConfig; } + public void setSeqNo(Integer seqNo) { + this.seqNo = seqNo; + } + + public Integer getSeqNo() { + return seqNo; + } + } Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Instructor.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Instructor.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Instructor.java 2009-09-28 22:57:24 UTC (rev 283) @@ -0,0 +1,55 @@ +package edu.asu.commons.mme.entity; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "instructor") +public class Instructor implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 612372011522490955L; + + @Id + @GeneratedValue + private Long id; + + @Column + private String fname; + + @Column + private String lname; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setFname(String fname) { + this.fname = fname; + } + + public String getFname() { + return fname; + } + + public void setLname(String lname) { + this.lname = lname; + } + + public String getLname() { + return lname; + } + + +} 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-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Location.java 2009-09-28 22:57:24 UTC (rev 283) @@ -1,14 +1,12 @@ package edu.asu.commons.mme.entity; 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.ManyToOne; -import javax.persistence.OneToMany; import javax.persistence.Table; @Entity @@ -21,32 +19,29 @@ @GeneratedValue private Long id; -/* @OneToMany(mappedBy = "location") - private List<RoundLocation> roundLocations;*/ - @Column(nullable=false,name="location_name") private String locationName; - @Column(nullable=false,name="max_capacity") + @Column(nullable=false,name="max_capacity", scale=2) private Double maxCapacity; @Column(nullable=false,name="growth_rate", scale=2) private Double growthRate; - @Column(nullable=false,name="initial_population") + @Column(nullable=false,name="initial_population", scale=2) private Double initialPopulation; - @Column(name="current_population") + @Column(name="current_population", scale=2) private Double currentPopulation; - @Column(name="fish_leaving") + @Column(name="fish_leaving", scale=2) private Double fishLeaving; - @Column(name="fish_return") + @Column(name="fish_return", scale=2) private Double fishReturned; @ManyToOne - private Game game; + private GameConfig gameConfig; public void setId(Long id) { this.id = id; @@ -87,13 +82,6 @@ public Double getCurrentPopulation() { return currentPopulation; } - /*public void setRoundLocations(List<RoundLocation> roundLocations) { - this.roundLocations = roundLocations; - } - public List<RoundLocation> getRoundLocations() { - return roundLocations; - }*/ - public void setFishLeaving(Double fishLeaving) { this.fishLeaving = fishLeaving; } @@ -110,12 +98,12 @@ return fishReturned; } - public void setGame(Game game) { - this.game = game; + public void setGameConfig(GameConfig gameConfig) { + this.gameConfig = gameConfig; } - public Game getGame() { - return game; + public GameConfig getGameConfig() { + return gameConfig; } } 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-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Round.java 2009-09-28 22:57:24 UTC (rev 283) @@ -21,35 +21,20 @@ @GeneratedValue private Long id; - @Column(name="round_no",nullable=false) - private Integer roundNo; - - @OneToMany(mappedBy = "round") - private List<GameRound> gameRounds; + /*@OneToMany(mappedBy = "round") + private List<GameRound> gameRounds;*/ @Column(name="communication_flag",nullable=false,columnDefinition="Boolean default false") private boolean communicationFlag; - /*@ManyToOne - private ModuleRoundConfig round_config;*/ - - - /*@OneToMany(mappedBy = "round") - private List<RoundLocation> roundLocations; - */ public void setId(Long id) { this.id = id; } public Long getId() { return id; } - public void setRoundNo(Integer roundNo) { - this.roundNo = roundNo; - } - public Integer getRoundNo() { - return roundNo; - } + public void setCommunicationFlag(boolean communication_flag) { this.communicationFlag = communication_flag; } @@ -62,14 +47,14 @@ public List<RoundLocation> getRoundLocations() { return roundLocations; }*/ - public void setGameRounds(List<GameRound> gameRounds) { + /*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; } Deleted: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/RoundLocation.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/RoundLocation.java 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/RoundLocation.java 2009-09-28 22:57:24 UTC (rev 283) @@ -1,57 +0,0 @@ -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="round_config_location") -public class RoundLocation implements Serializable { - - /** - * - */ - private static final long serialVersionUID = -3215898164475817212L; - - @Id - @GeneratedValue - private Long id; - - @ManyToOne - @JoinColumn(nullable=false) - private Round round; - - @ManyToOne - @JoinColumn(nullable=false) - private Location location; - - 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 setLocation(Location location) { - this.location = location; - } - - public Location getLocation() { - return location; - } - -} Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameConfigService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameConfigService.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/GameConfigService.java 2009-09-28 22:57:24 UTC (rev 283) @@ -0,0 +1,11 @@ +package edu.asu.commons.mme.service; + +import edu.asu.commons.mme.dao.HibernateGameConfigDao; +import edu.asu.commons.mme.entity.GameConfig; + +public class GameConfigService extends Service.Base<GameConfig, HibernateGameConfigDao>{ + + + + +} 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-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/LocationService.java 2009-09-28 22:57:24 UTC (rev 283) @@ -8,6 +8,7 @@ import edu.asu.commons.mme.dao.HibernateLocationDao; import edu.asu.commons.mme.entity.Game; +import edu.asu.commons.mme.entity.GameConfig; import edu.asu.commons.mme.entity.Location; import edu.asu.commons.mme.entity.Round; @@ -27,26 +28,27 @@ initLocation = locations.get(i); 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()); + Hibernate.initialize(location.getGameConfig()); + for(Location loc:location.getGameConfig().getLocations()) + { + Hibernate.initialize(loc); + + } + //getLogger().debug("the game rounds for round objects are : " + game.getCurrentRound().getGameRounds().get(0)); } 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++) @@ -59,51 +61,58 @@ return location; } //FIXME: For the pilot experiment locations are set manually but in future might want to take inputs from user - public void setAllLocations(Game game) + public List<Location> setAllLocations(GameConfig gameConfig) { - Location harbor = new Location(); - harbor.setLocationName("Harbor"); - harbor.setCurrentPopulation(0.0); - harbor.setGrowthRate(0.0); - harbor.setInitialPopulation(0.0); - harbor.setMaxCapacity(0.0); - harbor.setGame(game); - getDao().save(harbor); + List<Location> locations = new ArrayList<Location>(); + try{ + Location harbor = new Location(); + harbor.setLocationName("Harbor"); + harbor.setCurrentPopulation(0.0); + harbor.setGrowthRate(0.0); + harbor.setInitialPopulation(0.0); + harbor.setMaxCapacity(0.0); + harbor.setGameConfig(gameConfig); + getDao().save(harbor); + getLogger().info("Saved Location "+harbor.getLocationName()+" with id " + harbor.getId()); + locations.add(harbor); + + Location bay1 = new Location(); + bay1.setLocationName("Bay1"); + bay1.setCurrentPopulation(5.0); + bay1.setInitialPopulation(5.0); + bay1.setGrowthRate(0.5); + bay1.setMaxCapacity(10.0); + bay1.setGameConfig(gameConfig); + getDao().save(bay1); + getLogger().info("Saved Location " + bay1.getLocationName() +" with id "+ bay1.getId()); + locations.add(bay1); + + Location bay2 = new Location(); + bay2.setLocationName("Bay2"); + bay2.setCurrentPopulation(10.0); + bay2.setInitialPopulation(10.0); + bay2.setGrowthRate(0.15); + bay2.setMaxCapacity(20.0); + bay2.setGameConfig(gameConfig); + getDao().save(bay2); + getLogger().info("Saved Location " + bay2.getLocationName() +" with id "+ bay2.getId()); + locations.add(bay2); + + Location bay3 = new Location(); + bay3.setLocationName("Bay3"); + bay3.setCurrentPopulation(15.0); + bay3.setInitialPopulation(15.0); + bay3.setGrowthRate(0.05); + bay3.setMaxCapacity(30.0); + bay3.setGameConfig(gameConfig); + getDao().save(bay3); + getLogger().info("Saved Location " + bay3.getLocationName() +" with id "+ bay3.getId()); + locations.add(bay3); + }catch(Exception e) + { + e.printStackTrace(); + } - getLogger().info("Saved Location "+harbor.getLocationName()+" with id " + harbor.getId()); - - Location bay1 = new Location(); - bay1.setLocationName("Bay1"); - bay1.setCurrentPopulation(5.0); - bay1.setInitialPopulation(5.0); - bay1.setGrowthRate(0.5); - bay1.setMaxCapacity(10.0); - bay1.setGame(game); - getDao().save(bay1); - - getLogger().info("Saved Location " + bay1.getLocationName() +" with id "+ bay1.getId()); - - Location bay2 = new Location(); - bay2.setLocationName("Bay2"); - bay2.setCurrentPopulation(10.0); - bay2.setInitialPopulation(10.0); - bay2.setGrowthRate(0.15); - bay2.setMaxCapacity(20.0); - bay2.setGame(game); - getDao().save(bay2); - - getLogger().info("Saved Location " + bay2.getLocationName() +" with id "+ bay2.getId()); - - Location bay3 = new Location(); - bay3.setLocationName("Bay3"); - bay3.setCurrentPopulation(15.0); - bay3.setInitialPopulation(15.0); - bay3.setGrowthRate(0.05); - bay3.setMaxCapacity(30.0); - bay3.setGame(game); - getDao().save(bay3); - - getLogger().info("Saved Location " + bay3.getLocationName() +" with id "+ bay3.getId()); - + return locations; } } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-09-28 22:57:24 UTC (rev 283) @@ -29,9 +29,7 @@ private boolean startGame = true; private Round currentRound; private int blockSeqNo; - private Block currentBlock; - public void test() { getLogger().debug("test to check if module service is working...." ); @@ -120,7 +118,7 @@ return null; } - 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); @@ -129,7 +127,7 @@ else return game.getCurrentRound().getRoundNo(); - } + }*/ private boolean isModuleFinished(Module module) { // TODO Auto-generated method stub @@ -219,9 +217,6 @@ } - - - public void setCurrentModule(Module currentModule) { this.currentModule = currentModule; } 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-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java 2009-09-28 22:57:24 UTC (rev 283) @@ -10,6 +10,7 @@ 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; @@ -20,15 +21,14 @@ 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.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> { @@ -38,110 +38,131 @@ private HibernateGameDao gameDao; private HibernateModuleRoundConfigDao moduleRoundDao; private HibernateGameRoundDao gameRoundDao; + private HibernateGameConfigDao gameConfigDao; private LocationService locationService; - //private Module currentModule; - //private boolean startGame = true; - //private Round currentRound; - //private Block currentBlock; - private int blockSeqNo; - private boolean gameFinished; public RoundService() { - /*setCurrentGame(null); - setCurrentBlock(null); - setCurrentModule(null); - setCurrentModuleRoundConfig(null); - setCurrentRound(null);*/ 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.getDescription()); + getLogger().debug("game came from flex is : " + game.getGameCode()); Game newGame = new Game(); //currentGame = game; try { - newGame.setDescription(game.getDescription()); - newGame.setMaxDays(game.getMaxDays()); - newGame.setMaxFishHarvest(game.getMaxFishHarvest()); + newGame.setGameCode(game.getGameCode()); newGame.setMoney(game.getMoney()); - newGame.setNumberOfRounds(game.getNumberOfRounds()); - newGame.setNumberOfLocations(game.getNumberOfLocations()); newGame.setTimestamp(game.getTimestamp()); - newGame.setTitle(game.getTitle()); - newGame.setImageLocation("null"); + + //FIXME: Currently using default GameConfiguration whose id is 1 + GameConfig gameConfig = gameConfigDao.find(1L); + newGame.setGameConfig(gameConfig); getGameDao().save(newGame); - String str = newGame.getDescription()+newGame.getId(); + String str = newGame.getGameCode()+newGame.getId(); - if(getGameDao().findAllByProperty("description", str).size() != 0) + if(getGameDao().findAllByProperty("gameCode", str).size() != 0) { //getLogger().debug("in if loop "); newGame = null; } else { - newGame.setDescription(str); + newGame.setGameCode(str); getGameDao().save(newGame); getLogger().info("Created the game: " + newGame.getId()); - initializeGameRounds(newGame); - initializeLocations(newGame); + initializeLocations(gameConfig); initializeGame(newGame); } }catch(Exception e) { e.printStackTrace(); } - getLogger().debug("current game from flex is: " + newGame.getDescription()); + getLogger().debug("current game from flex is: " + newGame.getId()); return newGame; } - private void initializeGameRounds(Game 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.setGame(newGame); + gameRound.setGameConfig(gameConfig); gameRound.setRound(round); gameRoundDao.save(gameRound); gameRounds.add(gameRound); } - newGame.setGameRounds(gameRounds); - getGameDao().save(newGame); + getGameConfigDao().save(gameConfig); } - private void initializeLocations(Game newGame) + private void initializeLocations(GameConfig gameConfig) { - locationService.setAllLocations(newGame); - newGame.setLocations(locationService.getAllLocations()); - getGameDao().save(newGame); + gameConfig.setLocations(locationService.setAllLocations(gameConfig)); + getGameConfigDao().save(gameConfig); } public void initializeGame(Game game) { // TODO Auto-generated method stub - Hibernate.initialize(game); - Hibernate.initialize(game.getCurrentBlock()); - Hibernate.initialize(game.getCurrentRound()); - // Hibernate.initialize(game.getLocations()); + try{ + Hibernate.initialize(game); + Hibernate.initialize(game.getCurrentBlock()); + + + GameConfig gameconfig = game.getGameConfig(); + Hibernate.initialize(gameconfig); + + for(Location location:gameconfig.getLocations()) + { + Hibernate.initialize(location); - for(GameRound gameRound :game.getGameRounds()){ - Hibernate.initialize(gameRound); - //Hibernate.initialize(gameRound.getGame()); - initializeRound(gameRound.getRound()); + } + + 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(); } - for(Location location :game.getLocations()){ - locationService.initializeLocation(location); - } + //Hibernate.initialize(gameconfig.getGameRounds()); + + } - public Module getNextModule(int sequenceNo) { return getModule(sequenceNo); @@ -171,13 +192,18 @@ //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().info("Current Round is null... "); + getLogger().info("Current block is null... "); + getLogger().info("Starting of the game...." + game.getGameCode()); - getLogger().debug("Starting of the game...." + game.getDescription()); - currentRound = getNextRound(null); + 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 @@ -202,9 +228,15 @@ else { //set the next round - currentRound = getNextRound(game.getCurrentRound()); + 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); } } @@ -214,7 +246,11 @@ //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); } @@ -292,32 +328,52 @@ } - private Round getNextRound(Round currentRound) { + 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) { - returnRound = getDao().findByProperty("roundNo", 1); - //returnRound = currentRound; - //initializeRound(returnRound); + //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 { - getLogger().debug("current round no is: " + currentRound.getRoundNo()); - List<Round> rounds = getDao().findAll(); - for(int i = 0; i < rounds.size(); i++) + Map<String, Object> variables = new HashMap<String, Object>(); + variables.put("gameConfig",gameConfig); + variables.put("round", currentRound); + gameRounds = getGameRoundDao().findByEqCriteria(variables); + if(gameRounds.size() == 1) { - getLogger().debug("in for loop round no is: " + rounds.get(i).getRoundNo()); - if(currentRound.getRoundNo() < rounds.get(i).getRoundNo()) + int currentSeqNo = gameRounds.get(0).getSeqNo(); + gameRounds = getGameRoundDao().findAll(); + for(int i = 0; i < gameRounds.size(); i++) { - returnRound = rounds.get(i); - break; - //getLogger().debug("currentround object is "+ rounds.get(i).getId()); + 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 "); + } } - getLogger().debug("currentround object is "+ returnRound.getId()); return returnRound; } @@ -332,6 +388,7 @@ } + @SuppressWarnings("unused") private void initializeCurrentBlock(Block block) { Hibernate.initialize(block); @@ -432,23 +489,35 @@ }*/ public boolean isGameFinished(Game game) { - List<GameRound> gameRounds = game.getGameRounds(); + GameConfig gameConfig = game.getGameConfig(); + List<GameRound> gameRounds = getGameRoundDao().findAllByProperty("gameConfig",game.getGameConfig()); boolean flag = false; - if(game.getCurrentRound().getRoundNo() == gameRounds.get(gameRounds.size() - 1).getRound().getRoundNo()) + 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) { - flag = true; - } - else - { - for(GameRound gameRound:gameRounds) + int currentSeqNo = gameRounds.get(0).getSeqNo(); + gameRounds.clear(); + gameRounds = getGameRoundDao().findAllByProperty("gameConfig", gameConfig); + + if(currentSeqNo == gameRounds.get(gameRounds.size() - 1).getSeqNo()) { - if(game.getCurrentRound().getRoundNo() < game.getCurrentRound().getRoundNo()) + flag = true; + } + else + { + for(GameRound gameRound:gameRounds) { - flag = false; + if(currentSeqNo < gameRound.getSeqNo()) + { + flag = false; + } } + } - } return flag; } @@ -626,25 +695,6 @@ return currentRound; }*/ - private void initializeRound(Round round) { - // TODO Auto-generated method stub - Hibernate.initialize(round); - - //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()); - } - public void setGameDao(HibernateGameDao gameDao) { this.gameDao = gameDao; } @@ -673,7 +723,6 @@ return blockDao; } public void setGameFinished(boolean gameFinished) { - this.gameFinished = gameFinished; } @@ -686,9 +735,9 @@ return locationService; } - public String getDescription(Game game) { + public String getGameCode(Game game) { // TODO Auto-generated method stub - return game.getDescription(); + return game.getGameCode(); } public void setGameRoundDao(HibernateGameRoundDao gameRoundDao) { @@ -698,4 +747,12 @@ public HibernateGameRoundDao getGameRoundDao() { return gameRoundDao; } + + public void setGameConfigDao(HibernateGameConfigDao gameConfigDao) { + this.gameConfigDao = gameConfigDao; + } + + public HibernateGameConfigDao getGameConfigDao() { + return gameConfigDao; + } } 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-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartGame.java 2009-09-28 22:57:24 UTC (rev 283) @@ -36,18 +36,7 @@ public Student createStudent(Student student) { - // 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())) - { - student.setGame(game); - studentReturn = new Student(); - studentReturn = studentService.createStudent(student); - //System.out.println("student Return info: " + studentReturn.getGameCode()); - } - return studentReturn; + return studentService.createStudent(student); } public Game createGame(Game game) @@ -91,7 +80,7 @@ while (i<17) { i++; - String msgDestination = roundService.getDescription(game); + String msgDestination = roundService.getGameCode(newGameState); //Push the first block to the clients AsyncMessage msg = new AsyncMessage(); 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-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java 2009-09-28 22:57:24 UTC (rev 283) @@ -29,7 +29,18 @@ public Student createStudent(Student student) { - return getStartGame().createStudent(student); + //Game game = student.getGame(); + Student studentReturn = null; + //System.out.println("game description: " + game.getDescription() + " student game code is: " + student.getGameCode()); + for(StartGame startGame:currentGames) + { + if(startGame.getGame().getGameCode().equals(student.getGameCode())) + { + student.setGame(startGame.getGame()); + studentReturn = startGame.createStudent(student); + } + } + return studentReturn; } public Game createGame(Game game) @@ -54,6 +65,7 @@ { e.printStackTrace(); } + getStartGame().getRoundService().initializeGame(newGame); return newGame; } Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-09-28 22:57:24 UTC (rev 283) @@ -97,6 +97,10 @@ <property name='sessionFactory' ref='sessionFactory'/> </bean> + <bean id='gameConfigDao' class='edu.asu.commons.mme.dao.HibernateGameConfigDao'> + <property name='sessionFactory' ref='sessionFactory'/> + </bean> + <bean id='moduleRoundDao' class='edu.asu.commons.mme.dao.HibernateModuleRoundConfigDao'> <property name='sessionFactory' ref='sessionFactory'/> </bean> @@ -116,6 +120,7 @@ <property name='dao' ref='roundConfigDao'/> <property name='moduleDao' ref='moduleDao'/> <property name='gameDao' ref='gameDao' /> + <property name='gameConfigDao' ref='gameConfigDao' /> <property name='moduleRoundDao' ref='moduleRoundDao' /> <property name='locationService' ref='locationService'/> <property name='gameRoundDao' ref='gameRoundDao'/> Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/classes/log4j.properties =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/classes/log4j.properties 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/classes/log4j.properties 2009-09-28 22:57:24 UTC (rev 283) @@ -12,5 +12,5 @@ log4j.logger.edu.asu.commons=DEBUG #log4j.logger.org.springframework=DEBUG -log4j.logger.org.springframework=ERROR +log4j.logger.org.springframework=DEBUG log4j.logger.org.hibernate=ERROR Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml 2009-09-28 22:53:16 UTC (rev 282) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml 2009-09-28 22:57:24 UTC (rev 283) @@ -7,8 +7,10 @@ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> + <mapping class='edu.asu.commons.mme.entity.GameConfig'/> <mapping class='edu.asu.commons.mme.entity.Game'/> - <mapping class='edu.asu.commons.mme.entity.Round'/> + <mapping class='edu.asu.commons.mme.entity.Round'/> + <mapping class='edu.asu.commons.mme.entity.GameRound'/> <mapping class='edu.asu.commons.mme.entity.Location'/> <!-- <mapping class='edu.asu.commons.mme.entity.RoundLocation'/> @@ -17,8 +19,8 @@ <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. |