List of usage examples for org.hibernate CacheMode IGNORE
CacheMode IGNORE
To view the source code for org.hibernate CacheMode IGNORE.
Click Source Link
From source file:org.unitime.timetable.onlinesectioning.custom.purdue.PurdueBatchSolverValidator.java
License:Apache License
@Override public void save() throws Exception { iProgress.setStatus("Validating solution ..."); List<Protocol> protocols = new ArrayList<Protocol>(); protocols.add(Protocol.HTTP);/*from w w w . ja va 2 s . c om*/ protocols.add(Protocol.HTTPS); iClient = new Client(protocols); iCSV.setHeader(new CSVField[] { new CSVField("PUID"), new CSVField("Name"), new CSVField("Course"), new CSVField("CRN"), new CSVField("Code"), new CSVField("Message") }); org.hibernate.Session hibSession = null; Transaction tx = null; try { hibSession = SessionDAO.getInstance().getSession(); hibSession.setCacheMode(CacheMode.IGNORE); hibSession.setFlushMode(FlushMode.MANUAL); tx = hibSession.beginTransaction(); Session session = Session.getSessionUsingInitiativeYearTerm(iInitiative, iYear, iTerm); if (session == null) throw new Exception("Session " + iInitiative + " " + iTerm + iYear + " not found!"); ApplicationProperties.setSessionId(session.getUniqueId()); iSession = new AcademicSessionInfo(session); validate(session, hibSession); hibSession.flush(); tx.commit(); tx = null; } catch (Exception e) { iProgress.fatal("Unable to validate, reason: " + e.getMessage(), e); sLog.error(e.getMessage(), e); if (tx != null) tx.rollback(); } finally { if (hibSession != null && hibSession.isOpen()) hibSession.close(); try { iClient.stop(); } catch (Exception e) { sLog.error(e.getMessage(), e); } } }
From source file:org.unitime.timetable.onlinesectioning.custom.purdue.XEBatchSolverSaver.java
License:Apache License
@Override public void save() throws Exception { iProgress.setStatus("Saving solution ..."); List<Protocol> protocols = new ArrayList<Protocol>(); protocols.add(Protocol.HTTP);//from ww w .j a v a 2s . c o m protocols.add(Protocol.HTTPS); iClient = new Client(protocols); iCSV.setHeader(new CSVField[] { new CSVField("PUID"), new CSVField("Name"), new CSVField("Course"), new CSVField("CRN"), new CSVField("Request"), new CSVField("Status"), new CSVField("Message"), new CSVField("Used Override") }); org.hibernate.Session hibSession = null; Transaction tx = null; try { hibSession = SessionDAO.getInstance().getSession(); hibSession.setCacheMode(CacheMode.IGNORE); hibSession.setFlushMode(FlushMode.MANUAL); tx = hibSession.beginTransaction(); Session session = Session.getSessionUsingInitiativeYearTerm(iInitiative, iYear, iTerm); if (session == null) throw new Exception("Session " + iInitiative + " " + iTerm + iYear + " not found!"); ApplicationProperties.setSessionId(session.getUniqueId()); iSession = new AcademicSessionInfo(session); save(session, hibSession); if (!iUpdatedStudents.isEmpty() && CustomStudentEnrollmentHolder.isCanRequestUpdates()) { CustomStudentEnrollmentHolder.getProvider().requestUpdate((OnlineSectioningServer) getSolver(), new OnlineSectioningHelper(hibSession, getUser()), iUpdatedStudents); } hibSession.flush(); tx.commit(); tx = null; } catch (Exception e) { iProgress.fatal("Unable to save , reason: " + e.getMessage(), e); sLog.error(e.getMessage(), e); if (tx != null) tx.rollback(); } finally { if (hibSession != null && hibSession.isOpen()) hibSession.close(); try { iClient.stop(); } catch (Exception e) { sLog.error(e.getMessage(), e); } } }
From source file:org.unitime.timetable.onlinesectioning.OnlineSectioningLogger.java
License:Open Source License
public void run() { sLog.info("Online Sectioning Logger is up."); try {//from w ww . j a va 2 s . c om iActive = true; while (true) { try { sleep(60000); } catch (InterruptedException e) { } List<OnlineSectioningLog.Action> actionsToSave = null; synchronized (iActions) { if (!iActions.isEmpty()) { actionsToSave = new ArrayList<OnlineSectioningLog.Action>(iActions); iActions.clear(); } } try { if (actionsToSave != null) { sLog.debug("Persisting " + actionsToSave.size() + " actions..."); if (iLogLimit > 0 && actionsToSave.size() >= iLogLimit) sLog.warn("The limit of " + iLogLimit + " unpersisted log messages was reached, some messages have been dropped."); org.hibernate.Session hibSession = OnlineSectioningLogDAO.getInstance().createNewSession(); hibSession.setCacheMode(CacheMode.IGNORE); try { Hashtable<Long, Session> sessions = new Hashtable<Long, Session>(); for (OnlineSectioningLog.Action q : actionsToSave) { org.unitime.timetable.model.OnlineSectioningLog log = new org.unitime.timetable.model.OnlineSectioningLog(); log.setAction(q.toByteArray()); log.setOperation(q.getOperation()); String studentExternalId = (q.getStudent().hasExternalId() ? q.getStudent().getExternalId() : null); if (studentExternalId == null || studentExternalId.isEmpty()) { Student student = StudentDAO.getInstance().get(q.getStudent().getUniqueId(), hibSession); if (student == null) continue; studentExternalId = student.getExternalUniqueId(); } log.setStudent(studentExternalId); log.setTimeStamp(new Date(q.getStartTime())); if (q.hasResult()) log.setResult(q.getResult().getNumber()); if (q.hasUser() && q.getUser().hasExternalId()) log.setUser(q.getUser().getExternalId()); Long sessionId = q.getSession().getUniqueId(); Session session = sessions.get(sessionId); if (session == null) { session = SessionDAO.getInstance().get(sessionId, hibSession); sessions.put(sessionId, session); } log.setSession(session); hibSession.save(log); } hibSession.flush(); } finally { hibSession.close(); } } } catch (Throwable t) { sLog.warn("Failed to save " + actionsToSave.size() + " log actions: " + t.getMessage(), t); } if (!iActive) break; } } catch (Throwable t) { sLog.error("Online Sectioning Logger failed: " + t.getMessage(), t); } finally { iActive = false; if (iOut != null) { iOut.flush(); iOut.close(); } } sLog.info("Online Sectioning Logger is down."); }
From source file:org.unitime.timetable.onlinesectioning.server.AbstractServer.java
License:Open Source License
@Override public <E> E execute(OnlineSectioningAction<E> action, OnlineSectioningLog.Entity user) throws SectioningException { long c0 = OnlineSectioningHelper.getCpuTime(); String cacheMode = getConfig().getProperty(action.name() + ".CacheMode", getConfig().getProperty("CacheMode")); OnlineSectioningHelper h = new OnlineSectioningHelper(user, cacheMode != null ? CacheMode.valueOf(cacheMode) : action instanceof HasCacheMode ? ((HasCacheMode) action).getCacheMode() : CacheMode.IGNORE); try {// w w w .ja va2s. com setCurrentHelper(h); h.addMessageHandler( new OnlineSectioningHelper.DefaultMessageLogger(LogFactory.getLog(action.getClass().getName() + "." + action.name() + "[" + getAcademicSession().toCompactString() + "]"))); h.addAction(action, getAcademicSession()); E ret = action.execute(this, h); if (h.getAction() != null && !h.getAction().hasResult()) { if (ret == null) h.getAction().setResult(OnlineSectioningLog.Action.ResultType.NULL); else if (ret instanceof Boolean) h.getAction().setResult((Boolean) ret ? OnlineSectioningLog.Action.ResultType.TRUE : OnlineSectioningLog.Action.ResultType.FALSE); else h.getAction().setResult(OnlineSectioningLog.Action.ResultType.SUCCESS); } return ret; } catch (Exception e) { if (e instanceof SectioningException) { if (e.getCause() == null) { h.info("Execution failed: " + e.getMessage()); } else { h.warn("Execution failed: " + e.getMessage(), e.getCause()); } } else { h.error("Execution failed: " + e.getMessage(), e); } if (h.getAction() != null) { h.getAction().setResult(OnlineSectioningLog.Action.ResultType.FAILURE); if (e.getCause() != null && e instanceof SectioningException) h.getAction() .addMessage(OnlineSectioningLog.Message.newBuilder() .setLevel(OnlineSectioningLog.Message.Level.FATAL) .setText(e.getCause().getClass().getName() + ": " + e.getCause().getMessage())); else h.getAction() .addMessage(OnlineSectioningLog.Message.newBuilder() .setLevel(OnlineSectioningLog.Message.Level.FATAL) .setText(e.getMessage() == null ? "null" : e.getMessage())); } if (e instanceof SectioningException) throw (SectioningException) e; throw new SectioningException(MSG.exceptionUnknown(e.getMessage()), e); } finally { if (h.getAction() != null) { h.getAction().setEndTime(System.currentTimeMillis()) .setCpuTime(OnlineSectioningHelper.getCpuTime() - c0); if ((!h.getAction().hasStudent() || !h.getAction().getStudent().hasExternalId()) && user != null && user.hasExternalId() && user.hasType() && user.getType() == OnlineSectioningLog.Entity.EntityType.STUDENT) { if (h.getAction().hasStudent()) { h.getAction().getStudentBuilder().setExternalId(user.getExternalId()); } else { h.getAction().setStudent( OnlineSectioningLog.Entity.newBuilder().setExternalId(user.getExternalId())); } } } if (iLog.isDebugEnabled()) iLog.debug("Executed: " + h.getLog() + " (" + h.getLog().toByteArray().length + " bytes)"); OnlineSectioningLogger.getInstance().record(h.getLog()); releaseCurrentHelper(); } }
From source file:org.unitime.timetable.onlinesectioning.updates.CheckOfferingAction.java
License:Open Source License
@Override public CacheMode getCacheMode() { return CacheMode.IGNORE; }
From source file:org.unitime.timetable.solver.exam.ExamDatabaseLoader.java
License:Open Source License
public void load() throws Exception { iProgress.setStatus("Loading input data ..."); org.hibernate.Session hibSession = new ExamDAO().getSession(); hibSession.setCacheMode(CacheMode.IGNORE); Transaction tx = null;//www. j a v a2s.c o m try { tx = hibSession.beginTransaction(); TravelTime.populateTravelTimes(getModel().getDistanceMetric(), iSessionId, hibSession); loadPeriods(); loadRooms(); RoomAvailabilityInterface availability = null; if (SolverServerImplementation.getInstance() != null) availability = SolverServerImplementation.getInstance().getRoomAvailability(); else availability = RoomAvailability.getInstance(); if (availability != null) loadRoomAvailability(availability); loadExams(); loadStudents(); loadDistributions(); ExamType type = ExamTypeDAO.getInstance().get(iExamTypeId, hibSession); if (ApplicationProperty.ExaminationConsiderEventConflicts.isTrue(type.getReference())) loadAvailabilitiesFromEvents(); if (ApplicationProperty.ExaminationCreateSameRoomConstraints.isTrue(type.getReference())) makeupSameRoomConstraints(); getModel().init(); getModel().clearAssignmentContexts(getAssignment()); checkConsistency(); assignInitial(); tx.commit(); } catch (Exception e) { iProgress.fatal("Unable to load examination problem, reason: " + e.getMessage(), e); if (tx != null) tx.rollback(); throw e; } finally { // here we need to close the session since this code may run in a separate thread if (hibSession != null && hibSession.isOpen()) hibSession.close(); } }
From source file:org.unitime.timetable.solver.exam.ExamDatabaseSaver.java
License:Open Source License
public void save() { iProgress.setStatus("Saving solution ..."); org.hibernate.Session hibSession = new ExamDAO().getSession(); hibSession.setCacheMode(CacheMode.IGNORE); Transaction tx = null;/*from ww w. j av a2 s . co m*/ try { tx = hibSession.beginTransaction(); saveSolution(hibSession); tx.commit(); iProgress.setPhase("Refreshing solution ...", 1); try { if (SolverServerImplementation.getInstance() != null) SolverServerImplementation.getInstance().refreshExamSolution(iSessionId, iExamTypeId); iProgress.incProgress(); } catch (Exception e) { iProgress.warn("Unable to refresh solution, reason:" + e.getMessage(), e); } } catch (Exception e) { if (tx != null) tx.rollback(); iProgress.fatal("Unable to save a solution, reason: " + e.getMessage(), e); } finally { // here we need to close the session since this code may run in a separate thread if (hibSession != null && hibSession.isOpen()) hibSession.close(); } }
From source file:org.unitime.timetable.solver.instructor.InstructorSchedulingDatabaseLoader.java
License:Apache License
public void load() throws Exception { ApplicationProperties.setSessionId(iSessionId); org.hibernate.Session hibSession = null; Transaction tx = null;//ww w . ja v a 2s . c o m try { hibSession = TimetableManagerDAO.getInstance().createNewSession(); hibSession.setCacheMode(CacheMode.IGNORE); hibSession.setFlushMode(FlushMode.COMMIT); tx = hibSession.beginTransaction(); load(hibSession); tx.commit(); } catch (Exception e) { iProgress.fatal("Unable to load input data, reason: " + e.getMessage(), e); tx.rollback(); } finally { // here we need to close the session since this code may run in a separate thread if (hibSession != null && hibSession.isOpen()) hibSession.close(); } }
From source file:org.unitime.timetable.solver.instructor.InstructorSchedulingDatabaseSaver.java
License:Apache License
@Override public void save() throws Exception { ApplicationProperties.setSessionId(iSessionId); iProgress.setStatus("Saving solution ..."); org.hibernate.Session hibSession = new _RootDAO().getSession(); hibSession.setCacheMode(CacheMode.IGNORE); Transaction tx = null;/*w ww . j a v a 2 s . c o m*/ try { tx = hibSession.beginTransaction(); saveSolution(hibSession); tx.commit(); if (!iUpdatedConfigs.isEmpty()) { String className = ApplicationProperty.ExternalActionInstrOfferingConfigAssignInstructors.value(); if (className != null && className.trim().length() > 0) { ExternalInstrOfferingConfigAssignInstructorsAction assignAction = (ExternalInstrOfferingConfigAssignInstructorsAction) (Class .forName(className).newInstance()); iProgress.setPhase("Performing external actions ...", iUpdatedConfigs.size()); for (InstrOfferingConfig ioc : iUpdatedConfigs) { iProgress.incProgress(); assignAction.performExternalInstrOfferingConfigAssignInstructorsAction(ioc, hibSession); } } } if (!iUpdatedOfferings.isEmpty()) { String className = ApplicationProperty.ExternalActionCourseOfferingEdit.value(); if (className != null && className.trim().length() > 0) { ExternalCourseOfferingEditAction editAction = (ExternalCourseOfferingEditAction) (Class .forName(className).newInstance()); iProgress.setPhase("Performing external actions ...", iUpdatedOfferings.size()); for (InstructionalOffering io : iUpdatedOfferings) { iProgress.incProgress(); editAction.performExternalCourseOfferingEditAction(io, hibSession); } } } iProgress.setPhase("Refreshing solution ...", 1); try { if (SolverServerImplementation.getInstance() != null) SolverServerImplementation.getInstance().refreshInstructorSolution(iSolverGroupId); iProgress.incProgress(); } catch (Exception e) { iProgress.warn("Unable to refresh solution, reason:" + e.getMessage(), e); } if (!iUpdatedOfferings.isEmpty() || !iUpdatedConfigs.isEmpty()) { Session session = SessionDAO.getInstance().get(iSessionId, hibSession); if (!session.getStatusType().isTestSession() && (session.getStatusType().canOnlineSectionStudents() || session.getStatusType().canSectionAssistStudents())) { Set<Long> offeringIds = new HashSet<Long>(); for (InstructionalOffering io : iUpdatedOfferings) offeringIds.add(io.getUniqueId()); for (InstrOfferingConfig config : iUpdatedConfigs) offeringIds.add(config.getInstructionalOffering().getUniqueId()); StudentSectioningQueue.offeringChanged(hibSession, null, iSessionId, offeringIds); hibSession.flush(); } } } catch (Exception e) { if (tx != null) tx.rollback(); iProgress.fatal("Unable to save a solution, reason: " + e.getMessage(), e); } finally { // here we need to close the session since this code may run in a separate thread if (hibSession != null && hibSession.isOpen()) hibSession.close(); } }
From source file:org.unitime.timetable.solver.studentsct.StudentSectioningDatabaseLoader.java
License:Open Source License
public void load() { iProgress.setStatus("Loading input data ..."); org.hibernate.Session hibSession = null; Transaction tx = null;//from w w w.j a v a2s. c o m try { hibSession = SessionDAO.getInstance().getSession(); hibSession.setCacheMode(CacheMode.IGNORE); hibSession.setFlushMode(FlushMode.MANUAL); tx = hibSession.beginTransaction(); Session session = null; if (iSessionId != null) { session = SessionDAO.getInstance().get(iSessionId); if (session != null) { iYear = session.getAcademicYear(); iTerm = session.getAcademicTerm(); iInitiative = session.getAcademicInitiative(); getModel().getProperties().setProperty("Data.Year", iYear); getModel().getProperties().setProperty("Data.Term", iTerm); getModel().getProperties().setProperty("Data.Initiative", iInitiative); } } else { session = Session.getSessionUsingInitiativeYearTerm(iInitiative, iYear, iTerm); if (session != null) { iSessionId = session.getUniqueId(); getModel().getProperties().setProperty("General.SessionId", String.valueOf(iSessionId)); } } if (session == null) throw new Exception("Session " + iInitiative + " " + iTerm + iYear + " not found!"); iProgress.info("Loading data for " + iInitiative + " " + iTerm + iYear + "..."); if (getModel().getDistanceConflict() != null) TravelTime.populateTravelTimes(getModel().getDistanceConflict().getDistanceMetric(), iSessionId, hibSession); load(session, hibSession); tx.commit(); } catch (Exception e) { iProgress.fatal("Unable to load sectioning problem, reason: " + e.getMessage(), e); sLog.error(e.getMessage(), e); tx.rollback(); } finally { // here we need to close the session since this code may run in a separate thread if (hibSession != null && hibSession.isOpen()) hibSession.close(); } }