Search in sources :

Example 21 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class ModelService method isActiveSurveyRecordsLocked.

public boolean isActiveSurveyRecordsLocked() {
    CollectSurvey survey = sessionManager.getActiveSurvey();
    boolean result = survey != null && survey.isPublished() && surveyManager.isRecordValidationInProgress(survey.getId());
    return result;
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 22 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class RDBReportingRepositories method process.

@Override
public void process(final RecordTransaction recordTransaction) {
    final RelationalSchema rdbSchema = getRelatedRelationalSchema(recordTransaction);
    final CollectSurvey survey = (CollectSurvey) rdbSchema.getSurvey();
    RecordStep step = recordTransaction.getRecordStep();
    withConnection(survey.getName(), step, new Callback() {

        public void execute(Connection connection) {
            RDBUpdater rdbUpdater = createRDBUpdater(rdbSchema, connection);
            for (RecordEvent recordEvent : recordTransaction.getEvents()) {
                EventHandler handler = new EventHandler(recordEvent, rdbSchema, survey, rdbUpdater);
                handler.handle();
            }
        }
    });
}
Also used : RecordStep(org.openforis.collect.event.RecordStep) Connection(java.sql.Connection) RecordEvent(org.openforis.collect.event.RecordEvent) CollectSurvey(org.openforis.collect.model.CollectSurvey) RelationalSchema(org.openforis.collect.relational.model.RelationalSchema)

Example 23 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class RDBReportingRepositories method initializeSchemaDefinitions.

private void initializeSchemaDefinitions() {
    List<CollectSurvey> surveys = surveyManager.getAll();
    for (CollectSurvey survey : surveys) {
        initializeRelationalSchemaDefinition(survey);
        initializeMondrianSchemaDefinition(survey, survey.getDefaultLanguage());
    }
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 24 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey 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 25 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class CodeListImportService method start.

@Secured("ROLE_ADMIN")
public CodeListImportStatusProxy start(int codeListId, String tempFileName, CSVFileOptions fileOptions, boolean overwriteData) throws DataImportExeption {
    if (importProcess == null || !importProcess.getStatus().isRunning()) {
        File importFile = new File(tempFileName);
        SessionStatus designerSessionStatus = sessionManager.getDesignerSessionStatus();
        CollectSurvey survey = designerSessionStatus.getSurvey();
        String langCode = designerSessionStatus.getCurrentLanguageCode();
        CodeList codeList = survey.getCodeListById(codeListId);
        importProcess = new CodeListImportProcess(codeListManager, codeList, langCode, importFile, fileOptions, overwriteData);
        importProcess.init();
        CodeListImportStatus status = importProcess.getStatus();
        if (status != null && !importProcess.getStatus().isError()) {
            startProcessThread();
        }
    }
    return getStatus();
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) SessionStatus(org.openforis.collect.designer.session.SessionStatus) CodeListImportStatus(org.openforis.collect.manager.codelistimport.CodeListImportStatus) CollectSurvey(org.openforis.collect.model.CollectSurvey) File(java.io.File) CodeListImportProcess(org.openforis.collect.manager.codelistimport.CodeListImportProcess) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

CollectSurvey (org.openforis.collect.model.CollectSurvey)329 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)53 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)40 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)38 CollectRecord (org.openforis.collect.model.CollectRecord)30 RecordFilter (org.openforis.collect.model.RecordFilter)27 Transactional (org.springframework.transaction.annotation.Transactional)26 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)25 ArrayList (java.util.ArrayList)23 File (java.io.File)21 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)21 Secured (org.springframework.security.access.annotation.Secured)20 User (org.openforis.collect.model.User)19 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)19 SessionState (org.openforis.collect.web.session.SessionState)18 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)17 Test (org.junit.Test)16 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)15 CodeList (org.openforis.idm.metamodel.CodeList)15 Schema (org.openforis.idm.metamodel.Schema)15