List of usage examples for org.hibernate Session get
Object get(String entityName, Serializable id);
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean updateLinkCourseOfferingAssessment(int id, int assessmentId, double weight, int whenId, String criterionExists, double criterionLevel, String criterionSubmitted, String criterionCompleted, String[] additionQuestionResponses, String additionalInfo) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();// w w w. j a v a2s .c o m try { LinkCourseOfferingAssessment o = (LinkCourseOfferingAssessment) session .get(LinkCourseOfferingAssessment.class, id); deleteExistingAdditionalAssessmentOptions(o, session); createNewAdditionalAssessmentOptions(o, additionQuestionResponses, session); AssessmentTimeOption when = (AssessmentTimeOption) session.get(AssessmentTimeOption.class, whenId); Assessment assessment = (Assessment) session.get(Assessment.class, assessmentId); o.setWhen(when); o.setWeight(weight); o.setAdditionalInfo(additionalInfo); o.setCriterionExists(criterionExists); o.setCriterionLevel(criterionLevel); o.setCriterionCompleted(criterionCompleted); o.setCriterionSubmitted(criterionSubmitted); o.setAssessment(assessment); session.merge(o); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
private void createNewAdditionalAssessmentOptions(LinkCourseOfferingAssessment link, String[] additionQuestionResponses, Session session) { for (String answer : additionQuestionResponses) { AssessmentFeedbackOption questionOption = (AssessmentFeedbackOption) session .get(AssessmentFeedbackOption.class, Integer.parseInt(answer)); LinkCourseAssessmentFeedbackOption newLink = new LinkCourseAssessmentFeedbackOption(); newLink.setLinkCourseOfferingAssessment(link); newLink.setOption(questionOption); session.save(newLink);/*ww w . j a v a 2s. c o m*/ } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean saveLinkCourseOfferingTeachingMethod(int courseOfferingId, int teachingMethod, int howLongId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//w w w . j a v a 2 s .c om try { LinkCourseOfferingTeachingMethod o = new LinkCourseOfferingTeachingMethod(); CourseOffering c = (CourseOffering) session.get(CourseOffering.class, courseOfferingId); TeachingMethod tm = (TeachingMethod) session.get(TeachingMethod.class, teachingMethod); TeachingMethodPortionOption howLong = (TeachingMethodPortionOption) session .get(TeachingMethodPortionOption.class, howLongId); o.setCourseOffering(c); o.setHowLong(howLong); o.setTeachingMethod(tm); session.save(o); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean saveLinkCourseOfferingAssessment(int courseOfferingId, int assessmentId, double weight, int whenId, String criterionExists, double criterionLevel, String criterionSubmitted, String criterionCompleted, String[] additionQuestionResponses, String additionalInfo) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//from w w w.ja v a 2 s. com try { LinkCourseOfferingAssessment o = new LinkCourseOfferingAssessment(); CourseOffering c = (CourseOffering) session.get(CourseOffering.class, courseOfferingId); Assessment a = (Assessment) session.get(Assessment.class, assessmentId); AssessmentTimeOption when = (AssessmentTimeOption) session.get(AssessmentTimeOption.class, whenId); o.setCourseOffering(c); o.setAssessment(a); o.setWhen(when); o.setWeight(weight); o.setCriterionExists(criterionExists); o.setCriterionLevel(criterionLevel); o.setAdditionalInfo(additionalInfo); o.setCriterionCompleted(criterionCompleted); o.setCriterionSubmitted(criterionSubmitted); session.save(o); this.createNewAdditionalAssessmentOptions(o, additionQuestionResponses, session); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
private CourseOffering getCourseOfferingById(int id, Session session) { return (CourseOffering) session.get(CourseOffering.class, id); }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public Course getCourseById(int id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/* ww w .j a va 2 s .c o m*/ Course c = null; try { c = (Course) session.get(Course.class, id); session.getTransaction().commit(); } catch (Exception e) { HibernateUtil.logException(logger, e); } return c; }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean addOrganizationToCourse(int organizationId, int courseId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();// w w w.j a va2s .c om try { Organization o = (Organization) session.get(Organization.class, organizationId); Course course = (Course) session.get(Course.class, courseId); LinkCourseOrganization newLink = new LinkCourseOrganization(); newLink.setCourse(course); newLink.setOrganization(o); session.save(newLink); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean addInstructorToCourseOffering(String userid, int courseOfferingId, String first, String last) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from www . j a v a 2 s .c om*/ try { Instructor inst = getInstructorByUserid(userid, session); if (inst == null) { inst = new Instructor(); inst.setUserid(userid); } inst.setFirstName(first); inst.setLastName(last); CourseOffering courseOffering = (CourseOffering) session.get(CourseOffering.class, courseOfferingId); LinkCourseOfferingInstructor newLink = new LinkCourseOfferingInstructor(); newLink.setCourseOffering(courseOffering); newLink.setInstructor(inst); session.save(newLink); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean removeOrganizationFromCourse(int linkId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from ww w .ja va2 s. c o m*/ try { LinkCourseOrganization link = (LinkCourseOrganization) session.get(LinkCourseOrganization.class, linkId); session.delete(link); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean removeInstructorFromCourseOffering(int linkId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();// w ww .jav a 2s. c om try { LinkCourseOfferingInstructor link = (LinkCourseOfferingInstructor) session .get(LinkCourseOfferingInstructor.class, linkId); session.delete(link); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }