use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataImportService method getSummary.
@Secured(CLEANSING)
public DataImportSummaryProxy getSummary() {
if (summaryJob != null) {
DataImportSummary summary = summaryJob.getSummary();
SessionState sessionState = sessionManager.getSessionState();
Locale locale = sessionState.getLocale();
DataImportSummaryProxy proxy = new DataImportSummaryProxy(summary, locale);
return proxy;
} else {
return null;
}
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method demote.
protected void demote(Step toStep) throws RecordPersistenceException {
sessionManager.checkIsActiveRecordLocked();
SessionState sessionState = sessionManager.getSessionState();
CollectRecord record = sessionState.getActiveRecord();
Step fromStep = record.getStep();
Step exptectedFromStep = toStep.getNext();
if (exptectedFromStep != fromStep) {
throw new IllegalStateException("The active record cannot be demoted: it is not in the exptected phase: " + exptectedFromStep);
}
CollectSurvey survey = sessionState.getActiveSurvey();
String userName = sessionState.getUser().getUsername();
User user = sessionState.getUser();
Integer recordId = record.getId();
publishRecordDeletedEvent(record, fromStep.toRecordStep(), userName);
recordManager.demote(survey, recordId, record.getStep(), user);
recordManager.releaseLock(recordId);
sessionManager.clearActiveRecord();
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method createRecord.
@Secured(ENTRY)
public RecordProxy createRecord(String rootEntityName, String versionName, Step recordStep) throws RecordPersistenceException, RecordIndexException {
SessionState sessionState = sessionManager.getSessionState();
if (sessionState.isActiveRecordBeingEdited()) {
throw new MultipleEditException();
}
CollectSurvey activeSurvey = sessionState.getActiveSurvey();
User user = sessionState.getUser();
CollectRecord record = recordManager.instantiateRecord(activeSurvey, rootEntityName, user, versionName, recordStep);
NodeChangeSet changeSet = recordManager.initializeRecord(record);
List<RecordEvent> events = new EventProducer().produceFor(changeSet, user.getUsername());
sessionManager.onEvents(events);
sessionManager.setActiveRecord(record);
prepareRecordIndexing();
RecordProxy recordProxy = new RecordProxy(record, getProxyContext(), true);
return recordProxy;
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method searchAutoCompleteValues.
@Secured(USER)
public List<String> searchAutoCompleteValues(int attributeDefnId, int fieldIndex, String searchText) throws Exception {
SessionState sessionState = sessionManager.getSessionState();
CollectSurvey survey = sessionState.getActiveSurvey();
int maxResults = 10;
List<String> result = recordIndexService.search(SearchType.STARTS_WITH, survey, attributeDefnId, fieldIndex, searchText, maxResults);
return result;
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method saveActiveRecord.
@Transactional
@Secured(ENTRY_LIMITED)
public void saveActiveRecord() throws RecordPersistenceException, RecordIndexException {
sessionManager.checkIsActiveRecordLocked();
SessionState sessionState = sessionManager.getSessionState();
CollectRecord record = sessionState.getActiveRecord();
User user = sessionState.getUser();
record.setModifiedDate(new Date());
record.setModifiedBy(user);
record.setOwner(user);
String sessionId = sessionState.getSessionId();
recordManager.save(record, sessionId);
if (sessionManager.commitRecordFileChanges(record)) {
recordManager.save(record, sessionId);
}
if (isCurrentRecordIndexable()) {
recordIndexService.permanentlyIndex(record);
}
sessionEventDispatcher.recordSaved(record);
}
Aggregations