[virtualcommons-svn] SF.net SVN: virtualcommons:[108] mentalmodels/trunk
Status: Beta
Brought to you by:
alllee
From: <see...@us...> - 2009-04-18 02:36:32
|
Revision: 108 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=108&view=rev Author: seematalele Date: 2009-04-18 02:36:30 +0000 (Sat, 18 Apr 2009) Log Message: ----------- written code in StudentService and HibernateStudentDao. Tested it but getting error if I make class as transactional. Otherwise it does not give any error. Modified Paths: -------------- mentalmodels/trunk/flex/src/MME.mxml mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml mentalmodels/trunk/flex/src/actionscript/RoundConfig.as mentalmodels/trunk/pom.xml mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Gender.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StudentService.java mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml Added Paths: ----------- mentalmodels/trunk/src/main/webapp/FisheryExperiment.html mentalmodels/trunk/src/main/webapp/FisheryExperiment.swf Modified: mentalmodels/trunk/flex/src/MME.mxml =================================================================== --- mentalmodels/trunk/flex/src/MME.mxml 2009-04-18 00:59:30 UTC (rev 107) +++ mentalmodels/trunk/flex/src/MME.mxml 2009-04-18 02:36:30 UTC (rev 108) @@ -9,6 +9,9 @@ <![CDATA[ import mx.collections.ArrayCollection; import actionscript.RoundConfig; + import mx.controls.Alert; + import mx.rpc.events.ResultEvent; + import mx.rpc.events.FaultEvent; // request config data from server private var rndConfig:RoundConfig = getConfig(); @@ -22,6 +25,47 @@ new ArrayCollection([5, 10, 15])); } + [Bindable] public var outputresp : Boolean; + private function resultHandler(event:ResultEvent):void + { + outputresp = event.result as Boolean; + } + + private function faultHandler(event:FaultEvent):void + { + Alert.show(event.fault.faultDetail); + } + + /*private function getData():void + { + outputresp = ss.getStudentFname(); + + }*/ + + private function save():void + { + + changeState(); + /*Alert.show("In save() function"); + Alert.show("year of birth is " + socio_demographic_information1.txtipYOB.text); + Alert.show(socio_demographic_information1.txtipMajor.text); + Alert.show(socio_demographic_information1.study.selectedValue.toString());*/ + //Alert.show(socio_demographic_information1.female.selected?'Correct Answer!':'Wrong Answer', 'Result'); + if(ss.createStudent(socio_demographic_information1.txtipYOB.text, socio_demographic_information1.txtipMajor.text,"Female",socio_demographic_information1.study.selectedValue.toString())) + { + Alert.show("Record is sucessfully added!"); + } + else + Alert.show("Record is NOT sucessfully added!"); + + } + + private function changeState():void + { + this.currentState = 'forecasting'; + } + + ]]> </mx:Script> @@ -45,7 +89,7 @@ </ns1:Socio_Demographic_Information> <mx:HBox x="42" width="100%" height="10%" verticalAlign="bottom" horizontalAlign="center" bottom="5" id="hbox1"> - <mx:Button label="Submit" id="btnSubmit_Socio_Demographic_Info" click="currentState='forecasting'" fontSize="12"/> + <mx:Button label="Submit" id="btnSubmit_Socio_Demographic_Info" click="save()" fontSize="12"/> </mx:HBox> </mx:Canvas> <mx:HBox width="100%" id="hboxfooter" horizontalAlign="center" verticalAlign="bottom"> @@ -56,4 +100,5 @@ </mx:HBox> </mx:VBox> </mx:Canvas> + <mx:RemoteObject id="ss" destination="studentservice" fault="faultHandler(event)" result="resultHandler(event)"/> </mx:Application> Modified: mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml =================================================================== --- mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml 2009-04-18 00:59:30 UTC (rev 107) +++ mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml 2009-04-18 02:36:30 UTC (rev 108) @@ -7,18 +7,21 @@ <mx:FormHeading label="Socio DemographicInformation " id="frmheadingSocioDemographicInfo" fontSize="24" textAlign="left" themeColor="#1200FF" color="#186BE8" width="5%" height="10%"/> <mx:FormItem id="frmitemStudy" horizontalAlign="left" fontSize="14" required="true"> <mx:Label text="What year are you in your study?"/> - <mx:RadioButton id="freshman" groupName="study"> + <mx:RadioButtonGroup id="study"/> + <mx:RadioButton id="freshman" groupName="{study}"> <mx:label>Freshman</mx:label> </mx:RadioButton> - <mx:RadioButton id="sophomore" groupName="study"> + <mx:RadioButton id="sophomore" groupName="{study}"> <mx:label>Sophomore</mx:label> </mx:RadioButton> - <mx:RadioButton id="junior" groupName="study"> + <mx:RadioButton id="junior" groupName="{study}"> <mx:label>Junior</mx:label> </mx:RadioButton> - <mx:RadioButton id="senior" groupName="study"> + <mx:RadioButton id="senior" groupName="{study}"> <mx:label>Senior</mx:label> </mx:RadioButton> + + </mx:FormItem> <mx:FormItem label="What is your major?" id="frmitemMajor" horizontalAlign="left" fontSize="14" required="true"> @@ -28,6 +31,7 @@ <mx:TextInput id="txtipYOB" maxChars="4"/> </mx:FormItem> <mx:FormItem label="Gender" id="frmitemGender" horizontalAlign="left" fontSize="14" required="true"> + <mx:RadioButtonGroup id="gender"/> <mx:RadioButton id="male" groupName="gender"> <mx:label>Male</mx:label> </mx:RadioButton> Modified: mentalmodels/trunk/flex/src/actionscript/RoundConfig.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/RoundConfig.as 2009-04-18 00:59:30 UTC (rev 107) +++ mentalmodels/trunk/flex/src/actionscript/RoundConfig.as 2009-04-18 02:36:30 UTC (rev 108) @@ -2,6 +2,7 @@ { import mx.collections.ArrayCollection; + public class RoundConfig { private var number:Number; // what round is it? Modified: mentalmodels/trunk/pom.xml =================================================================== --- mentalmodels/trunk/pom.xml 2009-04-18 00:59:30 UTC (rev 107) +++ mentalmodels/trunk/pom.xml 2009-04-18 02:36:30 UTC (rev 108) @@ -131,6 +131,7 @@ <artifactId>xalan</artifactId> <version>2.7.1</version> </dependency> + </dependencies> <build> <finalName>mme</finalName> @@ -150,6 +151,10 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> + <configuration> + <server>myserver</server> + </configuration> + </plugin> <plugin> <groupId>org.mortbay.jetty</groupId> Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentDao.java 2009-04-18 00:59:30 UTC (rev 107) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentDao.java 2009-04-18 02:36:30 UTC (rev 108) @@ -1,5 +1,13 @@ package edu.asu.commons.mme.dao; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.springframework.transaction.annotation.Transactional; + +import edu.asu.commons.mme.entity.GameConfig; +import edu.asu.commons.mme.entity.Gender; +import edu.asu.commons.mme.entity.Group; import edu.asu.commons.mme.entity.Student; /** @@ -11,10 +19,84 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ +@Transactional public class HibernateStudentDao extends HibernateDao<Student> { + + private static Integer groupNo=0; + private static Integer studentNo=0; + private SessionFactory sessionFactory; public HibernateStudentDao() { super(Student.class); } + + public SessionFactory getSessionFactory() { + return super.getSessionFactory(); + } + public void setSessionFactory(SessionFactory sessionFactory) { + this.sessionFactory = sessionFactory; + } + public static void setGroupNo(Integer groupNo) { + HibernateStudentDao.groupNo = groupNo; + } + + public static Integer getGroupNo() { + return groupNo; + } + + public static void setStudentNo(Integer studentNo) { + HibernateStudentDao.studentNo = studentNo; + } + + public static Integer getStudentNo() { + return studentNo; + } + + public Long createStudent(Integer birthyear, String ethnicity, String gender,String major) + { + Student newstudent = null; + try{ + sessionFactory = this.getSessionFactory(); + Session session = + sessionFactory.getCurrentSession(); + Transaction tx = session.beginTransaction(); + //generateGroups(); + studentNo = getStudentNo() + 1; + newstudent = new Student(); + //newstudent.setGroup(newgroup); + newstudent.setBirthYear(birthyear); + newstudent.setEthnicity(ethnicity); + if(gender.equals(Gender.F)) + newstudent.setGender(Gender.F); + else + newstudent.setGender(Gender.M); + newstudent.setMajor(major); + newstudent.setStudentNo(studentNo); + session.save(newstudent); + tx.commit(); + + } + catch(Exception e) + { + logger.error("Can not create student."); + + } + finally{ + sessionFactory.close(); + } + return newstudent.getId(); + + } + + + + + + + + + + + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Gender.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Gender.java 2009-04-18 00:59:30 UTC (rev 107) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Gender.java 2009-04-18 02:36:30 UTC (rev 108) @@ -1,5 +1,5 @@ package edu.asu.commons.mme.entity; public enum Gender { -FEMALE, MALE +F, M } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java 2009-04-18 00:59:30 UTC (rev 107) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Student.java 2009-04-18 02:36:30 UTC (rev 108) @@ -21,7 +21,6 @@ private Long id; @ManyToOne - @JoinColumn(nullable=false) private Group group; @Column(name="student_no",nullable = false) Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StudentService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StudentService.java 2009-04-18 00:59:30 UTC (rev 107) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StudentService.java 2009-04-18 02:36:30 UTC (rev 108) @@ -1,7 +1,16 @@ package edu.asu.commons.mme.service; +import org.apache.log4j.Logger; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.springframework.transaction.annotation.Transactional; + import edu.asu.commons.mme.dao.HibernateStudentDao; +import edu.asu.commons.mme.entity.GameConfig; +import edu.asu.commons.mme.entity.Gender; import edu.asu.commons.mme.entity.Student; +import edu.asu.commons.mme.entity.Group; /** * @@ -11,6 +20,33 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Rev$ */ + + public class StudentService extends Service.Base<Student, HibernateStudentDao> { + Student newstudent; + Group newgroup; + + + private static Integer groupNo; + private static Integer studentNo; + + public boolean createGroup() + { + return false; + } + + public Long createStudent(Integer birthYear, String ethnicity,String gender,String major) + { + //createGroup(); + System.out.println("Birthyear" + birthYear); + System.out.println("Ethnicity" + ethnicity); + System.out.println("Gender" + gender); + System.out.println("Major" + major); + + this.getDao().createStudent(birthYear, ethnicity, gender, major); + return newstudent.getId(); + + } + } Added: mentalmodels/trunk/src/main/webapp/FisheryExperiment.html =================================================================== --- mentalmodels/trunk/src/main/webapp/FisheryExperiment.html (rev 0) +++ mentalmodels/trunk/src/main/webapp/FisheryExperiment.html 2009-04-18 02:36:30 UTC (rev 108) @@ -0,0 +1,121 @@ +<!-- saved from url=(0014)about:internet --> +<html lang="en"> + +<!-- +Smart developers always View Source. + +This application was built using Adobe Flex, an open source framework +for building rich Internet applications that get delivered via the +Flash Player or to desktops via Adobe AIR. + +Learn more about Flex at http://flex.org +// --> + +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + +<!-- BEGIN Browser History required section --> +<link rel="stylesheet" type="text/css" href="history/history.css" /> +<!-- END Browser History required section --> + +<title></title> +<script src="AC_OETags.js" language="javascript"></script> + +<!-- BEGIN Browser History required section --> +<script src="history/history.js" language="javascript"></script> +<!-- END Browser History required section --> + +<style> +body { margin: 0px; overflow:hidden } +</style> +<script language="JavaScript" type="text/javascript"> +<!-- +// ----------------------------------------------------------------------------- +// Globals +// Major version of Flash required +var requiredMajorVersion = 9; +// Minor version of Flash required +var requiredMinorVersion = 0; +// Minor version of Flash required +var requiredRevision = 124; +// ----------------------------------------------------------------------------- +// --> +</script> +</head> + +<body scroll="no"> +<script language="JavaScript" type="text/javascript"> +<!-- +// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65) +var hasProductInstall = DetectFlashVer(6, 0, 65); + +// Version check based upon the values defined in globals +var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); + +if ( hasProductInstall && !hasRequestedVersion ) { + // DO NOT MODIFY THE FOLLOWING FOUR LINES + // Location visited after installation is complete if installation is required + var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn"; + var MMredirectURL = window.location; + document.title = document.title.slice(0, 47) + " - Flash Player Installation"; + var MMdoctitle = document.title; + + AC_FL_RunContent( + "src", "playerProductInstall", + "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"", + "width", "760", + "height", "510", + "align", "middle", + "id", "FisheryExperiment", + "quality", "high", + "bgcolor", "#869ca7", + "name", "FisheryExperiment", + "allowScriptAccess","sameDomain", + "type", "application/x-shockwave-flash", + "pluginspage", "http://www.adobe.com/go/getflashplayer" + ); +} else if (hasRequestedVersion) { + // if we've detected an acceptable version + // embed the Flash Content SWF when all tests are passed + AC_FL_RunContent( + "src", "FisheryExperiment", + "width", "760", + "height", "510", + "align", "middle", + "id", "FisheryExperiment", + "quality", "high", + "bgcolor", "#869ca7", + "name", "FisheryExperiment", + "allowScriptAccess","sameDomain", + "type", "application/x-shockwave-flash", + "pluginspage", "http://www.adobe.com/go/getflashplayer" + ); + } else { // flash is too old or we can't detect the plugin + var alternateContent = 'Alternate HTML content should be placed here. ' + + 'This content requires the Adobe Flash Player. ' + + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>'; + document.write(alternateContent); // insert non-flash content + } +// --> +</script> +<noscript> + <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" + id="FisheryExperiment" width="760" height="510" + codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> + <param name="movie" value="FisheryExperiment.swf" /> + <param name="quality" value="high" /> + <param name="bgcolor" value="#869ca7" /> + <param name="allowScriptAccess" value="sameDomain" /> + <embed src="FisheryExperiment.swf" quality="high" bgcolor="#869ca7" + width="760" height="510" name="FisheryExperiment" align="middle" + play="true" + loop="false" + quality="high" + allowScriptAccess="sameDomain" + type="application/x-shockwave-flash" + pluginspage="http://www.adobe.com/go/getflashplayer"> + </embed> + </object> +</noscript> +</body> +</html> Added: mentalmodels/trunk/src/main/webapp/FisheryExperiment.swf =================================================================== (Binary files differ) Property changes on: mentalmodels/trunk/src/main/webapp/FisheryExperiment.swf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-04-18 00:59:30 UTC (rev 107) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-04-18 02:36:30 UTC (rev 108) @@ -12,6 +12,7 @@ xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop @@ -23,7 +24,8 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> -<!-- Flex related information started --> + +<!-- Flex related information started --> <flex:message-broker > </flex:message-broker> @@ -71,6 +73,6 @@ <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- XXX: don't need proxy-target-class if services are interfaces instead --> - <tx:annotation-driven proxy-target-class='true'/> + <tx:annotation-driven proxy-target-class="true"/> </beans> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |