List of usage examples for org.hibernate Session get
Object get(String entityName, Serializable id);
From source file:ca.usask.gmcte.currimap.action.OutcomeManager.java
License:Open Source License
public boolean saveProgramOutcomeLink(int programId, int outcomeId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//ww w.jav a2 s . c om try { ProgramOutcome outcome = (ProgramOutcome) session.get(ProgramOutcome.class, outcomeId); Program program = (Program) session.get(Program.class, programId); LinkProgramProgramOutcome lpo = getLinkProgramOutcome(program, outcome, session); if (lpo == null) { lpo = new LinkProgramProgramOutcome(); lpo.setProgram(program); lpo.setProgramOutcome(outcome); session.save(lpo); } 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.OutcomeManager.java
License:Open Source License
public int saveCourseOfferingOutcomeLink(int courseOfferingId, String outcomeName, int outcomeId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/* w ww.j a v a 2 s . c o m*/ try { CourseOutcome outcome = new CourseOutcome(); if (outcomeId > -1) { outcome = (CourseOutcome) session.get(CourseOutcome.class, outcomeId); outcome.setName(outcomeName); session.merge(outcome); logger.debug("Saved new value [" + outcomeName + "] for id " + outcomeId); } else { outcome.setName(outcomeName); outcome.setDescription(""); session.save(outcome); } CourseOffering courseOffering = (CourseOffering) session.get(CourseOffering.class, courseOfferingId); LinkCourseOfferingOutcome lco = getLinkCourseOfferingOutcome(courseOffering, outcome, session); if (lco == null) { int existingCount = session .createQuery("FROM LinkCourseOfferingOutcome WHERE courseOffering.id=:offeringId") .setParameter("offeringId", courseOfferingId).list().size(); lco = new LinkCourseOfferingOutcome(); lco.setCourseOffering(courseOffering); lco.setCourseOutcome(outcome); lco.setDisplayIndex(existingCount + 1); session.save(lco); } session.getTransaction().commit(); return outcome.getId(); } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return -1; } }
From source file:ca.usask.gmcte.currimap.action.OutcomeManager.java
License:Open Source License
public int saveProgramOutcomeLink(int programId, String outcomeName, int programOutcomeGroupId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from ww w .j a v a 2 s. c om*/ try { ProgramOutcome outcome = new ProgramOutcome(); ProgramOutcomeGroup programOutcomeGroup = (ProgramOutcomeGroup) session.get(ProgramOutcomeGroup.class, programOutcomeGroupId); outcome.setName(outcomeName); outcome.setDescription(""); outcome.setGroup(programOutcomeGroup); session.save(outcome); Program program = (Program) session.get(Program.class, programId); LinkProgramProgramOutcome lpo = new LinkProgramProgramOutcome(); lpo.setProgram(program); lpo.setProgramOutcome(outcome); session.save(lpo); session.getTransaction().commit(); return outcome.getId(); } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return -1; } }
From source file:ca.usask.gmcte.currimap.action.OutcomeManager.java
License:Open Source License
public boolean saveProgramOutcome(String outcomeName, int programOutcomeId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();// w ww . j ava 2s.co m try { ProgramOutcome outcome = (ProgramOutcome) session.get(ProgramOutcome.class, programOutcomeId); outcome.setName(outcomeName); session.merge(outcome); 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.OutcomeManager.java
License:Open Source License
public LinkProgramProgramOutcome getLinkProgramProgramOutcomeById(int id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*ww w .j a v a2 s . co m*/ LinkProgramProgramOutcome toReturn = null; try { toReturn = (LinkProgramProgramOutcome) session.get(LinkProgramProgramOutcome.class, id); session.getTransaction().commit(); } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } } return toReturn; }
From source file:ca.usask.gmcte.currimap.action.OutcomeManager.java
License:Open Source License
public CourseOutcome getOutcomeById(int id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from w w w. j av a2 s .c om*/ CourseOutcome c = null; try { c = (CourseOutcome) session.get(CourseOutcome.class, id); session.getTransaction().commit(); } catch (Exception e) { HibernateUtil.logException(logger, e); } return c; }
From source file:ca.usask.gmcte.currimap.action.OutcomeManager.java
License:Open Source License
public LinkCourseOfferingOutcome getLinkCourseOfferingOutcomeById(int id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from ww w . j a v a 2s . com*/ LinkCourseOfferingOutcome c = null; try { c = (LinkCourseOfferingOutcome) session.get(LinkCourseOfferingOutcome.class, id); session.getTransaction().commit(); } catch (Exception e) { HibernateUtil.logException(logger, e); } return c; }
From source file:ca.usask.gmcte.currimap.action.OutcomeManager.java
License:Open Source License
public boolean addOutcomeAssessmentLink(int courseOfferingId, int outcomeId, int assessmentLinkId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//from w w w . java 2s .c o m try { LinkAssessmentCourseOutcome toSave = new LinkAssessmentCourseOutcome(); CourseOffering offering = (CourseOffering) session.get(CourseOffering.class, courseOfferingId); CourseOutcome outcome = (CourseOutcome) session.get(CourseOutcome.class, outcomeId); LinkCourseOfferingAssessment link = (LinkCourseOfferingAssessment) session .get(LinkCourseOfferingAssessment.class, assessmentLinkId); toSave.setAssessmentLink(link); toSave.setCourseOffering(offering); toSave.setOutcome(outcome); session.save(toSave); 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.OutcomeManager.java
License:Open Source License
public boolean deleteOutcomeAssessmentLink(int linkToDelete) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from w w w .j a v a 2 s .co m*/ try { LinkAssessmentCourseOutcome link = (LinkAssessmentCourseOutcome) session .get(LinkAssessmentCourseOutcome.class, linkToDelete); 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.PermissionsManager.java
License:Open Source License
public boolean saveOrganizationPermission(int organizationId, String type, String name, String first, String last) {/*from w w w . j ava 2 s . co m*/ Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); try { OrganizationAdmin p = getOrganizationAdminByNameAndType(name, type, organizationId, session); boolean existed = true; if (p == null) { p = new OrganizationAdmin(); Organization Organization = (Organization) session.get(Organization.class, organizationId); p.setOrganization(Organization); p.setName(name); p.setType(type); existed = false; if (type.equals("Userid")) p.setTypeDisplay("Persons"); else p.setTypeDisplay("Organizations"); } p.setLastName(last); p.setFirstName(first); if (existed) session.merge(p); else session.save(p); 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; } }