use of org.openforis.collect.model.CollectRecord.Step in project collect by openforis.
the class DataService method loadRecord.
@Secured(USER)
public RecordProxy loadRecord(int id, Integer stepNumber) {
SessionState sessionState = sessionManager.getSessionState();
final CollectSurvey survey = sessionState.getActiveSurvey();
Step step = stepNumber == null ? null : Step.valueOf(stepNumber);
CollectRecord record = step == null ? recordManager.load(survey, id) : recordManager.load(survey, id, step);
sessionManager.setActiveRecord(record);
return toProxy(record);
}
use of org.openforis.collect.model.CollectRecord.Step 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.model.CollectRecord.Step 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.model.CollectRecord.Step in project collect by openforis.
the class CSVDataImportService method start.
@Secured("ROLE_ADMIN")
public DataImportStatusProxy start(String tempFileName, int parentEntityId, Step step, boolean transactional, boolean validateRecords, boolean insertNewRecords, String newRecordVersionName, boolean deleteExistingEntities) throws DataImportExeption {
if (importJob == null || !importJob.isRunning()) {
File importFile = new File(tempFileName);
SessionState sessionState = sessionManager.getSessionState();
CollectSurvey survey = sessionState.getActiveSurvey();
if (transactional) {
importJob = jobManager.createJob(TransactionalCSVDataImportJob.class);
} else {
importJob = jobManager.createJob(CSVDataImportJob.BEAN_NAME, CSVDataImportJob.class);
}
CSVDataImportSettings settings = new CSVDataImportSettings();
settings.setRecordValidationEnabled(validateRecords);
settings.setInsertNewRecords(insertNewRecords);
settings.setNewRecordVersionName(newRecordVersionName);
settings.setDeleteExistingEntities(deleteExistingEntities);
Step[] steps = step == null ? Step.values() : new Step[] { step };
CSVDataImportInput input = new CSVDataImportInput(importFile, survey, steps, parentEntityId, settings);
importJob.setInput(input);
jobManager.start(importJob);
}
return getStatus();
}
use of org.openforis.collect.model.CollectRecord.Step in project collect by openforis.
the class DataImportSummaryItemProxy method getWarnings.
@ExternalizedProperty
public List<NodeUnmarshallingErrorProxy> getWarnings() {
List<NodeUnmarshallingError> result = new ArrayList<NodeUnmarshallingError>();
Map<Step, List<NodeUnmarshallingError>> warnings = item.getWarnings();
if (warnings != null) {
Set<Step> steps = warnings.keySet();
for (Step step : steps) {
List<NodeUnmarshallingError> warningsPerStep = warnings.get(step);
result.addAll(warningsPerStep);
}
}
List<NodeUnmarshallingErrorProxy> proxies = NodeUnmarshallingErrorProxy.fromList(result);
return proxies;
}
Aggregations