Example #1
0
 public void releaseRecord() throws RecordUnlockedException {
   checkIsActiveRecordLocked();
   SessionState sessionState = getSessionState();
   CollectRecord activeRecord = sessionState.getActiveRecord();
   if (activeRecord != null && activeRecord.getId() != null) {
     recordManager.releaseLock(activeRecord.getId());
   }
   sessionState.setActiveRecord(null);
 }
Example #2
0
 public SessionState getSessionState() {
   SessionState sessionState = null;
   try {
     sessionState = (SessionState) getSessionAttribute(SessionState.SESSION_ATTRIBUTE_NAME);
   } catch (IllegalStateException e) {
     throw new InvalidSessionException();
   }
   if (sessionState.getUser() == null) {
     sessionState.setUser(loadAuthenticatedUser());
   }
   return sessionState;
 }
Example #3
0
 public void saveActiveDesignerSurvey() {
   try {
     SessionState sessionState = getSessionState();
     CollectSurvey survey = getActiveDesignerSurvey();
     boolean activeSurveyWork = sessionState.isActiveSurveyWork();
     if (activeSurveyWork) {
       surveyManager.save(survey);
     } else {
       throw new IllegalArgumentException("Active designer survey should be a 'work' survey");
     }
   } catch (SurveyStoreException e) {
     LOG.error("Error updating taxonomy related attributes.", e);
   }
 }
Example #4
0
 public void checkIsActiveRecordLocked() throws RecordUnlockedException {
   SessionState sessionState = getSessionState();
   CollectRecord record = sessionState.getActiveRecord();
   if (record == null) {
     throw new RecordUnlockedException();
   } else if (record.getId() != null) {
     User user = sessionState.getUser();
     String lockId = sessionState.getSessionId();
     try {
       recordManager.checkIsLocked(record.getId(), user, lockId);
       sessionState.keepActiveRecordAlive();
     } catch (RecordUnlockedException e) {
       clearActiveRecord();
       throw e;
     }
   }
 }
Example #5
0
 @Secured("ROLE_ADMIN")
 public DataImportStateProxy startSummaryCreation(boolean overwriteAll) throws DataImportExeption {
   if (dataImportProcess == null || !dataImportProcess.isRunning()) {
     SessionState sessionState = sessionManager.getSessionState();
     File userImportFolder = new File(importDirectory, sessionState.getSessionId());
     packagedFile = new File(userImportFolder, FILE_NAME);
     List<User> usersList = userManager.loadAll();
     HashMap<String, User> users = new HashMap<String, User>();
     for (User user : usersList) {
       users.put(user.getName(), user);
     }
     dataImportProcess =
         new DataImportProcess(
             surveyManager, recordManager, recordDao, users, packagedFile, overwriteAll);
     dataImportProcess.prepareToStartSummaryCreation();
     ExecutorServiceUtil.executeInCachedPool(dataImportProcess);
   }
   DataImportState state = dataImportProcess.getState();
   DataImportStateProxy proxy = new DataImportStateProxy(state);
   return proxy;
 }
Example #6
0
 public void setActiveSurvey(CollectSurvey survey) {
   SessionState sessionState = getSessionState();
   sessionState.setActiveSurvey(survey);
 }
Example #7
0
 public void setActiveRecord(CollectRecord record) {
   SessionState sessionState = getSessionState();
   sessionState.setActiveRecord(record);
   sessionState.keepActiveRecordAlive();
 }
Example #8
0
 public CollectSurvey getActiveSurvey() {
   SessionState sessionState = getSessionState();
   return sessionState.getActiveSurvey();
 }
Example #9
0
 public CollectRecord getActiveRecord() {
   SessionState sessionState = getSessionState();
   return sessionState.getActiveRecord();
 }
Example #10
0
 public void setLocale(String string) {
   Locale locale = LocaleUtils.toLocale(string);
   SessionState sessionState = getSessionState();
   sessionState.setLocale(locale);
 }
Example #11
0
 public void clearActiveRecord() {
   SessionState sessionState = getSessionState();
   sessionState.setActiveRecord(null);
 }