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);
}
}
}
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);
}
}
}
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);
}
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();
}
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);
}
Aggregations