Search in sources :

Example 6 with Step

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);
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) CollectRecord(org.openforis.collect.model.CollectRecord) RecordStep(org.openforis.collect.event.RecordStep) Step(org.openforis.collect.model.CollectRecord.Step) CollectSurvey(org.openforis.collect.model.CollectSurvey) Secured(org.springframework.security.access.annotation.Secured)

Example 7 with Step

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);
    }
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) CollectRecord(org.openforis.collect.model.CollectRecord) User(org.openforis.collect.model.User) RecordStep(org.openforis.collect.event.RecordStep) Step(org.openforis.collect.model.CollectRecord.Step)

Example 8 with Step

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);
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) CollectRecord(org.openforis.collect.model.CollectRecord) User(org.openforis.collect.model.User) MultipleEditException(org.openforis.collect.persistence.MultipleEditException) RecordStep(org.openforis.collect.event.RecordStep) Step(org.openforis.collect.model.CollectRecord.Step) CollectSurvey(org.openforis.collect.model.CollectSurvey) Secured(org.springframework.security.access.annotation.Secured)

Example 9 with Step

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();
}
Also used : TransactionalCSVDataImportJob(org.openforis.collect.io.data.TransactionalCSVDataImportJob) CSVDataImportJob(org.openforis.collect.io.data.CSVDataImportJob) SessionState(org.openforis.collect.web.session.SessionState) CSVDataImportInput(org.openforis.collect.io.data.CSVDataImportJob.CSVDataImportInput) Step(org.openforis.collect.model.CollectRecord.Step) CollectSurvey(org.openforis.collect.model.CollectSurvey) TransactionalCSVDataImportJob(org.openforis.collect.io.data.TransactionalCSVDataImportJob) CSVDataImportSettings(org.openforis.collect.io.data.csv.CSVDataImportSettings) File(java.io.File) Secured(org.springframework.security.access.annotation.Secured)

Example 10 with Step

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;
}
Also used : NodeUnmarshallingError(org.openforis.collect.persistence.xml.NodeUnmarshallingError) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Step(org.openforis.collect.model.CollectRecord.Step) ExternalizedProperty(org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)

Aggregations

Step (org.openforis.collect.model.CollectRecord.Step)49 CollectRecord (org.openforis.collect.model.CollectRecord)24 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)21 CollectSurvey (org.openforis.collect.model.CollectSurvey)11 ArrayList (java.util.ArrayList)9 RecordStep (org.openforis.collect.event.RecordStep)8 SessionState (org.openforis.collect.web.session.SessionState)8 StepSummary (org.openforis.collect.model.CollectRecordSummary.StepSummary)7 IOException (java.io.IOException)5 RecordFilter (org.openforis.collect.model.RecordFilter)5 NodeUnmarshallingError (org.openforis.collect.persistence.xml.NodeUnmarshallingError)5 MainStep (org.openforis.collect.io.data.DataImportState.MainStep)4 SubStep (org.openforis.collect.io.data.DataImportState.SubStep)4 User (org.openforis.collect.model.User)4 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)4 Schema (org.openforis.idm.metamodel.Schema)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Secured (org.springframework.security.access.annotation.Secured)3