use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method promote.
protected void promote(Step to) throws RecordPersistenceException, RecordPromoteException {
sessionManager.checkIsActiveRecordLocked();
SessionState sessionState = sessionManager.getSessionState();
CollectRecord record = sessionState.getActiveRecord();
String userName = sessionState.getUser().getUsername();
Step currentStep = record.getStep();
Step exptectedStep = to.getPrevious();
if (exptectedStep == currentStep) {
User user = sessionState.getUser();
sessionEventDispatcher.recordSaved(record);
recordManager.promote(record, user);
publishRecordPromotedEvents(record, userName);
recordManager.releaseLock(record.getId());
sessionManager.clearActiveRecord();
if (isCurrentRecordIndexable()) {
recordIndexService.permanentlyIndex(record);
}
} else {
throw new IllegalStateException("The active record cannot be submitted: it is not in the exptected phase: " + exptectedStep);
}
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method getCurrentLocale.
protected Locale getCurrentLocale() {
SessionState sessionState = getSessionState();
Locale locale = sessionState.getLocale();
return locale;
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method checkoutRecord.
@Secured(ENTRY_LIMITED)
public RecordProxy checkoutRecord(int id, Integer stepNumber, boolean forceUnlock) throws RecordPersistenceException, RecordIndexException {
SessionState sessionState = sessionManager.getSessionState();
if (sessionState.isActiveRecordBeingEdited()) {
throw new MultipleEditException();
}
final CollectSurvey survey = sessionState.getActiveSurvey();
User user = sessionState.getUser();
Step step = stepNumber == null ? null : Step.valueOf(stepNumber);
CollectRecord record = step == null ? recordManager.checkout(survey, user, id, sessionState.getSessionId(), forceUnlock) : recordManager.checkout(survey, user, id, step, sessionState.getSessionId(), forceUnlock);
sessionManager.setActiveRecord(record);
prepareRecordIndexing();
return toProxy(record);
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method moveNode.
@Secured(ENTRY_LIMITED)
public void moveNode(int nodeId, int index) {
SessionState sessionState = sessionManager.getSessionState();
CollectRecord record = sessionState.getActiveRecord();
recordManager.moveNode(record, nodeId, index);
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method deleteRecord.
@Transactional
@Secured(ENTRY)
public void deleteRecord(int id) throws RecordPersistenceException {
SessionState sessionState = sessionManager.getSessionState();
CollectSurvey survey = sessionState.getActiveSurvey();
String userName = sessionState.getUser().getUsername();
CollectRecord record = recordManager.load(survey, id);
if (record.getStep() != Step.ENTRY) {
throw new IllegalStateException("Cannot delete a record not in ENTRY phase");
}
fileManager.deleteAllFiles(record);
recordManager.delete(id);
publishRecordDeletedEvent(record, record.getStep().toRecordStep(), userName);
}
Aggregations