Search in sources :

Example 16 with EntityDefinition

use of org.openforis.idm.metamodel.EntityDefinition in project collect by openforis.

the class IdmDataTableBuilder method getBaseName.

@Override
protected String getBaseName() {
    EntityDefinition defn = (EntityDefinition) xform.getNodeDefinition();
    String name = defn.getAnnotation(TABLE_NAME_QNAME);
    if (name == null) {
        name = defn.getName();
    }
    return name;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition)

Example 17 with EntityDefinition

use of org.openforis.idm.metamodel.EntityDefinition in project collect by openforis.

the class DataQueryExectutorTask method createRecordsFilter.

private RecordFilter createRecordsFilter(boolean limitResults) {
    CollectSurvey survey = input.query.getSurvey();
    EntityDefinition entityDef = (EntityDefinition) survey.getSchema().getDefinitionById(input.query.getEntityDefinitionId());
    EntityDefinition rootEntityDef = entityDef.getRootEntity();
    Integer rootEntityId = rootEntityDef.getId();
    RecordFilter filter = new RecordFilter(survey);
    filter.setStep(input.step);
    filter.setRootEntityId(rootEntityId);
    if (limitResults) {
        filter.setOffset(0);
        filter.setMaxNumberOfRecords(input.maxRecords);
    }
    return filter;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordFilter(org.openforis.collect.model.RecordFilter)

Example 18 with EntityDefinition

use of org.openforis.idm.metamodel.EntityDefinition in project collect by openforis.

the class DataExportService method export.

@Transactional
public Proxy export(String rootEntityName, int stepNumber, Integer entityId, boolean includeAllAncestorAttributes, boolean includeEnumeratedEntities, boolean includeCompositeAttributeMergedColumn, boolean codeAttributeExpanded, boolean onlyOwnedRecords, String[] rootEntityKeyValues, boolean includeKMLColumnForCoordinates, boolean includeCodeItemLabelColumn, String headingSource, String languageCode, boolean includeGroupingLabels) throws IOException {
    if (dataExportProcess == null || !dataExportProcess.getStatus().isRunning()) {
        resetJobs();
        SessionState sessionState = sessionManager.getSessionState();
        CollectSurvey survey = sessionState.getActiveSurvey();
        File outputFile = File.createTempFile("collect_data_export_" + survey.getName(), ".zip");
        Step step = Step.valueOf(stepNumber);
        // prepare record filter
        Schema schema = survey.getSchema();
        EntityDefinition rootEntityDefn = schema.getRootEntityDefinition(rootEntityName);
        RecordFilter recordFilter = createRecordFilter(survey, rootEntityDefn.getId(), onlyOwnedRecords, rootEntityKeyValues);
        // filter by record step
        recordFilter.setStepGreaterOrEqual(step);
        // instantiate process
        CSVDataExportProcess process = appContext.getBean(CSVDataExportProcess.class);
        process.setOutputFile(outputFile);
        process.setRecordFilter(recordFilter);
        process.setEntityId(entityId);
        process.setAlwaysGenerateZipFile(true);
        CSVDataExportParameters config = new CSVDataExportParameters();
        config.setIncludeAllAncestorAttributes(includeAllAncestorAttributes);
        config.setIncludeEnumeratedEntities(includeEnumeratedEntities);
        config.setIncludeCompositeAttributeMergedColumn(includeCompositeAttributeMergedColumn);
        config.setIncludeKMLColumnForCoordinates(includeKMLColumnForCoordinates);
        config.setCodeAttributeExpanded(codeAttributeExpanded);
        config.setIncludeCodeItemLabelColumn(includeCodeItemLabelColumn);
        config.setHeadingSource(HeadingSource.valueOf(headingSource));
        config.setLanguageCode(languageCode);
        config.setIncludeGroupingLabels(includeGroupingLabels);
        process.setConfiguration(config);
        process.init();
        // start process
        dataExportProcess = process;
        ExecutorServiceUtil.executeInCachedPool(process);
    }
    return getCurrentJob();
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CSVDataExportProcess(org.openforis.collect.io.data.CSVDataExportProcess) Schema(org.openforis.idm.metamodel.Schema) Step(org.openforis.collect.model.CollectRecord.Step) CSVDataExportParameters(org.openforis.collect.io.data.csv.CSVDataExportParameters) CollectSurvey(org.openforis.collect.model.CollectSurvey) File(java.io.File) RecordFilter(org.openforis.collect.model.RecordFilter) Transactional(org.springframework.transaction.annotation.Transactional)

Example 19 with EntityDefinition

use of org.openforis.idm.metamodel.EntityDefinition in project collect by openforis.

the class DataService method loadRecordSummaries.

/**
 * @param rootEntityName
 * @param offset
 * @param toIndex
 * @param orderByFieldName
 * @param filter
 *
 * @return map with "count" and "records" items
 */
@Secured(USER)
public Map<String, Object> loadRecordSummaries(String rootEntityName, int offset, int maxNumberOfRows, List<RecordSummarySortField> sortFields, String[] keyValues) {
    Map<String, Object> result = new HashMap<String, Object>();
    SessionState sessionState = sessionManager.getSessionState();
    CollectSurvey activeSurvey = sessionState.getActiveSurvey();
    Schema schema = activeSurvey.getSchema();
    EntityDefinition rootEntityDefinition = schema.getRootEntityDefinition(rootEntityName);
    RecordFilter filter = new RecordFilter(activeSurvey, rootEntityDefinition.getId());
    filter.setKeyValues(keyValues);
    filter.setOffset(offset);
    filter.setMaxNumberOfRecords(maxNumberOfRows);
    // load summaries
    List<CollectRecordSummary> summaries = recordManager.loadSummaries(filter, sortFields);
    List<RecordSummaryProxy> proxies = RecordSummaryProxy.fromList(summaries, getProxyContext());
    result.put("records", proxies);
    // count total records
    int count = recordManager.countRecords(filter);
    result.put("count", count);
    return result;
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) HashMap(java.util.HashMap) Schema(org.openforis.idm.metamodel.Schema) RecordSummaryProxy(org.openforis.collect.model.proxy.RecordSummaryProxy) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CollectRecordSummary(org.openforis.collect.model.CollectRecordSummary) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordFilter(org.openforis.collect.model.RecordFilter) Secured(org.springframework.security.access.annotation.Secured)

Example 20 with EntityDefinition

use of org.openforis.idm.metamodel.EntityDefinition in project collect by openforis.

the class SpeciesService method deleteReferencingAttributes.

protected void deleteReferencingAttributes(CollectTaxonomy taxonomy) {
    List<TaxonAttributeDefinition> defns = getTaxonAttributeDefinitionsForDesignerSurvey(taxonomy.getName());
    if (!defns.isEmpty()) {
        for (TaxonAttributeDefinition defn : defns) {
            EntityDefinition parent = (EntityDefinition) defn.getParentDefinition();
            parent.removeChildDefinition(defn);
        }
        sessionManager.saveActiveDesignerSurvey();
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition)

Aggregations

EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)235 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)70 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)47 Schema (org.openforis.idm.metamodel.Schema)46 ArrayList (java.util.ArrayList)44 Test (org.junit.Test)38 Entity (org.openforis.idm.model.Entity)36 CollectRecord (org.openforis.collect.model.CollectRecord)30 CollectSurvey (org.openforis.collect.model.CollectSurvey)28 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)24 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)24 ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)19 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)18 UITab (org.openforis.collect.metamodel.ui.UITab)16 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)14 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)13 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)12 RecordFilter (org.openforis.collect.model.RecordFilter)11 SurveyObject (org.openforis.idm.metamodel.SurveyObject)10 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)9