use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class BackupService method getBackup.
private BackupProcess getBackup(String rootEntityName) throws Exception {
SessionState sessionState = sessionManager.getSessionState();
CollectSurvey survey = sessionState.getActiveSurvey();
Integer surveyId = survey.getId();
Map<String, BackupProcess> backupsPerSurvey = backups.get(surveyId);
if (backupsPerSurvey == null) {
backupsPerSurvey = new HashMap<String, BackupProcess>();
backups.put(surveyId, backupsPerSurvey);
}
BackupProcess backup = backupsPerSurvey.get(rootEntityName);
if (backup == null) {
int[] stepNumbers = { 1, 2, 3 };
backup = new BackupProcess(surveyManager, recordManager, dataMarshaller, backupDirectory, survey, rootEntityName, stepNumbers);
backupsPerSurvey.put(rootEntityName, backup);
}
return backup;
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class SessionManager method clearActiveRecord.
public void clearActiveRecord() {
SessionState sessionState = getSessionState();
sessionState.setActiveRecord(null);
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class SessionManager method createSessionState.
public void createSessionState(HttpSession session) {
String sessionId = session.getId();
boolean developmentMode = CollectConfiguration.isDevelopmentMode();
SessionState sessionState = new SessionState(sessionId);
if (developmentMode) {
sessionState.setUser(userManager.loadAdminUser());
// sessionState.setUser(userManager.loadByUserName("view"));
// sessionState.setUser(userManager.loadByUserName("entry"));
}
session.setAttribute(SessionState.SESSION_ATTRIBUTE_NAME, sessionState);
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class SessionManager method releaseRecord.
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);
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class RecordController method moveRecords.
@RequestMapping(value = "survey/{surveyId}/data/move/records", method = POST, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public JobProxy moveRecords(@PathVariable("surveyId") int surveyId, @RequestParam String fromStep, @RequestParam boolean promote) {
BulkRecordMoveJob job = jobManager.createJob(BulkRecordMoveJob.class);
SessionState sessionState = sessionManager.getSessionState();
User loggedUser = sessionState.getUser();
CollectSurvey survey = surveyManager.getById(surveyId);
EntityDefinition rootEntityDef = survey.getSchema().getFirstRootEntityDefinition();
job.setSurvey(survey);
job.setRootEntity(rootEntityDef.getName());
job.setPromote(promote);
job.setFromStep(Step.valueOf(fromStep));
job.setUser(loggedUser);
job.setRecordMovedCallback(new BulkRecordMoveJob.Callback() {
@Override
public void recordMoved(CollectRecord record) {
if (promote) {
publishRecordPromotedEvents(record, loggedUser.getUsername());
} else {
publishRecordDeletedEvent(record, RecordStep.valueOf(fromStep), loggedUser.getUsername());
}
}
});
jobManager.startSurveyJob(job);
return new JobProxy(job);
}
Aggregations