[virtualcommons-svn] SF.net SVN: virtualcommons:[190] mentalmodels/trunk/src/main
Status: Beta
Brought to you by:
alllee
From: <see...@us...> - 2009-07-21 00:47:56
|
Revision: 190 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=190&view=rev Author: seematalele Date: 2009-07-21 00:47:53 +0000 (Tue, 21 Jul 2009) Log Message: ----------- Changed StartupService.java - This service will create student, send first module to the client. Created AnsweringService.java which will store the student response Created RoundService.java which will retrieve the next module using Module Service and send it to the client Above services need to test using Flex GUI. Created HibernateRoundConfigDao.java and HibernateStudentResponseDao.java Modified Paths: -------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.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/java/edu/asu/commons/mme/dao/HibernateRoundConfigDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentResponseDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateRoundConfigDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateRoundConfigDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateRoundConfigDao.java 2009-07-21 00:47:53 UTC (rev 190) @@ -0,0 +1,13 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.RoundConfig; + + +public class HibernateRoundConfigDao extends HibernateDao<RoundConfig> { + + public HibernateRoundConfigDao() + { + super(RoundConfig.class); + } + +} Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentResponseDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentResponseDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentResponseDao.java 2009-07-21 00:47:53 UTC (rev 190) @@ -0,0 +1,11 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.StudentResponse; + +public class HibernateStudentResponseDao extends HibernateDao<StudentResponse> { + public HibernateStudentResponseDao() + { + super(StudentResponse.class); + } + +} Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java 2009-07-21 00:47:53 UTC (rev 190) @@ -0,0 +1,38 @@ +package edu.asu.commons.mme.service; + +import java.util.List; + +import edu.asu.commons.mme.dao.HibernateStudentDao; +import edu.asu.commons.mme.dao.HibernateStudentResponseDao; +import edu.asu.commons.mme.entity.Student; +import edu.asu.commons.mme.entity.StudentResponse; + +public class AnsweringService extends Service.Base<StudentResponse, HibernateStudentResponseDao> { + + private HibernateStudentResponseDao studentResponseDao; + private HibernateStudentDao studentDao; + + + StudentResponse studentResponse; + Student student; + + public void saveQuestion(List<StudentResponse> studentResponses) + { + for(int i = 0; i < studentResponses.size(); i++ ) + { + StudentResponse clientStudentResponse = new StudentResponse(); + clientStudentResponse = (StudentResponse) studentResponses.get(i); + + studentResponse = new StudentResponse(); + studentResponse.setQuestion(clientStudentResponse.getQuestion()); + studentResponse.setResponse(clientStudentResponse.getResponse()); + studentResponse.setStudent(clientStudentResponse.getStudent()); + save(studentResponse); + } + } + + public void setStudentDao(HibernateStudentDao studentDao) { + this.studentDao = studentDao; + } + +} Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java 2009-07-21 00:47:53 UTC (rev 190) @@ -0,0 +1,20 @@ +package edu.asu.commons.mme.service; + +import edu.asu.commons.mme.dao.HibernateRoundConfigDao; +import edu.asu.commons.mme.entity.Module; +import edu.asu.commons.mme.entity.RoundConfig; + +public class RoundService extends Service.Base<RoundConfig, HibernateRoundConfigDao> { + + private ModuleService moduleService; + + public void setModuleService(ModuleService moduleService) { + this.moduleService = moduleService; + } + + public Module getNextModule(int sequenceNo) + { + return moduleService.getModule(sequenceNo); + } + +} 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-07-20 19:34:32 UTC (rev 189) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java 2009-07-21 00:47:53 UTC (rev 190) @@ -4,9 +4,13 @@ import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; +import edu.asu.commons.mme.entity.Module; + public class StartupService implements ApplicationListener { private QuestionCreatorService questionCreatorService; + private StudentService studentService; + private ModuleService moduleService; private volatile boolean alreadyInitialized; @@ -14,6 +18,7 @@ public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ContextRefreshedEvent && ! alreadyInitialized) { //questionCreatorService.createQuestions(); + alreadyInitialized = true; } @@ -22,7 +27,24 @@ public void setQuestionCreatorService(QuestionCreatorService questionCreatorService) { this.questionCreatorService = questionCreatorService; } + + public void setStudentService(StudentService studentService) { + this.studentService = studentService; + } + + public Long createStudent(Integer birthYear, String semester,String gender,String major) { + + return studentService.createStudent(birthYear, semester, gender, major); + } - + public Module getFirstModule() + { + studentService.formGroups(); + return moduleService.getModule(1); + } + public void setModuleService(ModuleService moduleService) { + this.moduleService = moduleService; + } + } 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-07-20 19:34:32 UTC (rev 189) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StudentService.java 2009-07-21 00:47:53 UTC (rev 190) @@ -28,16 +28,39 @@ // System.out.println("Ethnicity " + semester); // System.out.println("Gender " + gender); // System.out.println("Major " + major); + Student student = new Student(); - student.setBirthYear(birthYear); student.setSemester(semester); student.setGender(Gender.valueOf(gender)); student.setMajor(major); save(student); getLogger().debug("Student id is: " + student.getId()); - students.add(student); + if(!checkStudentAlreadyExists(student)) + { + students.add(student); + } + else + return 0L; + return student.getId(); } + public boolean checkStudentAlreadyExists(Student student) + { + for(int i = 0; i < students.size(); i++) + { + if(students.get(i).equals(student)){ + return true; + } + } + return false; + } + + + public void formGroups() + { + //write an algorithm to form groups + } + } Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-07-20 19:34:32 UTC (rev 189) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-07-21 00:47:53 UTC (rev 190) @@ -34,6 +34,10 @@ <property name='sessionFactory' ref='sessionFactory'/> </bean> + <bean id='roundConfigDao' class='edu.asu.commons.mme.dao.HibernateRoundConfigDao'> + <property name='sessionFactory' ref='sessionFactory'/> + </bean> + <bean id='moduleDao' class="edu.asu.commons.mme.dao.HibernateModuleDao"> <property name='sessionFactory' ref='sessionFactory'/> </bean> @@ -60,9 +64,25 @@ <property name='sessionFactory' ref='sessionFactory'/> </bean> + <bean id='studentResponseDao' class='edu.asu.commons.mme.dao.HibernateStudentResponseDao'> + <property name='sessionFactory' ref='sessionFactory'/> + </bean> <!-- spring managed service layer --> +<bean id='roundService' class='edu.asu.commons.mme.service.RoundService'> + <property name='dao' ref='roundConfigDao'/> + <property name='moduleService' ref='moduleService'/> + + </bean> + + + <bean id='answeringService' class='edu.asu.commons.mme.service.AnsweringService'> + <property name='dao' ref='studentResponseDao'/> + <property name='studentDao' ref='studentDao'/> + + </bean> + <bean id='questionCreatorService' class='edu.asu.commons.mme.service.QuestionCreatorService'> <property name='dao' ref='questionDao'/> <property name='blockDao' ref='blockDao'/> @@ -74,6 +94,7 @@ <bean id='startupService' class='edu.asu.commons.mme.service.StartupService'> <property name='questionCreatorService' ref='questionCreatorService'/> + <property name='studentService' ref='studentService'/> </bean> <bean id='studentService' class='edu.asu.commons.mme.service.StudentService'> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |