Search in sources :

Example 1 with CollectAnnotations

use of org.openforis.collect.metamodel.CollectAnnotations in project collect by openforis.

the class CollectSurveyIdmlBinder method onUnmarshallingComplete.

@Override
protected void onUnmarshallingComplete(Survey survey) {
    super.onUnmarshallingComplete(survey);
    CollectSurvey collectSurvey = (CollectSurvey) survey;
    CollectAnnotations annotations = collectSurvey.getAnnotations();
    collectSurvey.setTarget(annotations.getSurveyTarget());
    collectSurvey.setCollectVersion(annotations.getCollectVersion());
    if (collectSurvey.getUIOptions() != null) {
        try {
            UIConfiguration uiConfiguration = new UIOptionsMigrator().migrateToUIConfiguration(collectSurvey.getUIOptions());
            collectSurvey.setUIConfiguration(uiConfiguration);
        } catch (UIOptionsMigrationException e) {
            log.error("Error generating UI model for survey " + collectSurvey.getUri() + ": " + e.getMessage());
        } catch (Exception e) {
            log.error("Error generating UI model for survey " + collectSurvey.getUri() + ": " + e.getMessage(), e);
        }
    }
}
Also used : UIOptionsMigrator(org.openforis.collect.metamodel.ui.UIOptionsMigrator) UIConfiguration(org.openforis.collect.metamodel.ui.UIConfiguration) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey) IOException(java.io.IOException) SurveyImportException(org.openforis.collect.persistence.SurveyImportException) UIOptionsMigrationException(org.openforis.collect.metamodel.ui.UIOptionsMigrator.UIOptionsMigrationException) UIOptionsMigrationException(org.openforis.collect.metamodel.ui.UIOptionsMigrator.UIOptionsMigrationException)

Example 2 with CollectAnnotations

use of org.openforis.collect.metamodel.CollectAnnotations in project collect by openforis.

the class RelationalSchemaGenerator method addDataObjects.

/**
 * Recursively creates and adds tables and columns
 *
 * @param rs
 * @param parentTable
 * @param defn
 * @throws CollectRdbException
 */
private void addDataObjects(RelationalSchema rs, DataTable table, NodeDefinition defn, Path relativePath) throws CollectRdbException {
    if (defn instanceof EntityDefinition) {
        if (defn.isMultiple()) {
            // Create table for multiple entity
            table = createDataTable(rs, table, defn, relativePath);
            rs.addTable(table);
        } else {
            // just keep a reference
            rs.assignAncestorTable((EntityDefinition) defn);
        }
        // Add child tables and columns
        EntityDefinition entityDefn = (EntityDefinition) defn;
        for (NodeDefinition child : entityDefn.getChildDefinitions()) {
            Path childPath;
            if (defn.isMultiple()) {
                childPath = Path.relative(child.getName());
            } else {
                childPath = relativePath.appendElement(child.getName());
            }
            addDataObjects(rs, table, child, childPath);
        }
    } else if (defn instanceof AttributeDefinition) {
        AttributeDefinition attrDefn = (AttributeDefinition) defn;
        CollectSurvey survey = (CollectSurvey) defn.getSurvey();
        CollectAnnotations annotations = survey.getAnnotations();
        // do not include if it's a calculated attribute and it has not to be included in data export
        if (!attrDefn.isCalculated() || annotations.isIncludedInDataExport(defn)) {
            if (defn.isMultiple()) {
                // Create table for multiple attributes
                table = createDataTable(rs, table, defn, relativePath);
                rs.addTable(table);
                relativePath = Path.relative(".");
            }
            // Add columns for attributes in entity tables or attribute tables
            addDataColumns(rs, table, (AttributeDefinition) defn, relativePath);
        }
    }
}
Also used : Path(org.openforis.idm.path.Path) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) NumericAttributeDefinition(org.openforis.idm.metamodel.NumericAttributeDefinition) DateAttributeDefinition(org.openforis.idm.metamodel.DateAttributeDefinition) NumberAttributeDefinition(org.openforis.idm.metamodel.NumberAttributeDefinition) TimeAttributeDefinition(org.openforis.idm.metamodel.TimeAttributeDefinition) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 3 with CollectAnnotations

use of org.openforis.collect.metamodel.CollectAnnotations in project collect by openforis.

the class SurveyMainInfoFormObject method saveTo.

@Override
public void saveTo(CollectSurvey dest, String languageCode) {
    dest.setName(name);
    dest.setDescription(languageCode, description);
    dest.setProjectName(languageCode, projectName);
    dest.setPublished(published);
    CollectAnnotations annotations = dest.getAnnotations();
    annotations.setCollectEarthPlotArea(fromListitemValueToDouble(collectEarthPlotArea));
    annotations.setCollectEarthSamplePoints(Integer.parseInt(collectEarthSamplePoints));
    annotations.setBingMapsKey(bingMapsKey);
    annotations.setBingMapsEnabled(openBingMaps);
    annotations.setYandexMapsEnabled(openYandexMaps);
    annotations.setStreetViewEnabled(openStreetView);
    annotations.setGEECodeEditorEnabled(openGEECodeEditor);
    annotations.setGEEExplorerEnabled(openGEEExplorer);
    annotations.setKeyChangeAllowed(keyChangeAllowed);
}
Also used : CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations)

Example 4 with CollectAnnotations

use of org.openforis.collect.metamodel.CollectAnnotations in project collect by openforis.

the class SurveyMainInfoFormObject method loadFrom.

@Override
public void loadFrom(CollectSurvey source, String languageCode) {
    name = source.getName();
    description = source.getDescription(languageCode);
    published = source.isPublished();
    projectName = source.getProjectName(languageCode);
    defaultProjectName = source.getProjectName();
    defaultDescription = source.getDescription();
    CollectAnnotations annotations = source.getAnnotations();
    collectEarthPlotArea = toListitemValue(annotations.getCollectEarthPlotArea());
    collectEarthSamplePoints = String.valueOf(annotations.getCollectEarthSamplePoints());
    bingMapsKey = annotations.getBingMapsKey();
    openBingMaps = annotations.isBingMapsEnabled();
    openYandexMaps = annotations.isYandexMapsEnabled();
    openStreetView = annotations.isStreetViewEnabled();
    openGEEExplorer = annotations.isGEEExplorerEnabled();
    openGEECodeEditor = annotations.isGEECodeEditorEnabled();
    keyChangeAllowed = annotations.isKeyChangeAllowed();
}
Also used : CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations)

Example 5 with CollectAnnotations

use of org.openforis.collect.metamodel.CollectAnnotations in project collect by openforis.

the class TaxonAttributeDefinitionFormObject method saveTo.

@Override
public void saveTo(TaxonAttributeDefinition dest, String languageCode) {
    super.saveTo(dest, languageCode);
    dest.setTaxonomy(taxonomy);
    dest.setHighestTaxonRank(TaxonRank.fromName(highestRank));
    dest.setQualifiers(qualifiers);
    dest.setFieldLabel(CODE_FIELD_NAME, languageCode, codeFieldLabel);
    dest.setFieldLabel(SCIENTIFIC_NAME_FIELD_NAME, languageCode, scientificNameFieldLabel);
    dest.setFieldLabel(VERNACULAR_NAME_FIELD_NAME, languageCode, vernacularNameFieldLabel);
    dest.setFieldLabel(LANGUAGE_CODE_FIELD_NAME, languageCode, languageCodeFieldLabel);
    dest.setFieldLabel(LANGUAGE_VARIETY_FIELD_NAME, languageCode, languageVarietyFieldLabel);
    dest.setFieldLabel(FAMILY_CODE_FIELD_NAME, languageCode, familyCodeFieldLabel);
    dest.setFieldLabel(FAMILY_SCIENTIFIC_NAME_FIELD_NAME, languageCode, familyNameFieldLabel);
    CollectSurvey survey = (CollectSurvey) dest.getSurvey();
    CollectAnnotations annotations = survey.getAnnotations();
    annotations.setShowFamily(dest, showFamily);
    annotations.setIncludeUniqueVernacularName(dest, includeUniqueVernacularName);
    annotations.setAllowUnlisted(dest, allowUnlisted);
}
Also used : CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Aggregations

CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)32 CollectSurvey (org.openforis.collect.model.CollectSurvey)21 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)11 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)9 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)7 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)7 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)6 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)6 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)5 TextAttributeDefinition (org.openforis.idm.metamodel.TextAttributeDefinition)5 ArrayList (java.util.ArrayList)4 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)4 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)4 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)4 TimeAttributeDefinition (org.openforis.idm.metamodel.TimeAttributeDefinition)4 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)3 NodeDefinitionVisitor (org.openforis.idm.metamodel.NodeDefinitionVisitor)3 RangeAttributeDefinition (org.openforis.idm.metamodel.RangeAttributeDefinition)3 TextInput (org.openforis.collect.metamodel.CollectAnnotations.TextInput)2 UIConfiguration (org.openforis.collect.metamodel.ui.UIConfiguration)2