Search in sources :

Example 11 with CollectAnnotations

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

the class CollectSurvey method getExtendedDataFields.

/**
 * Goes though the attributes on the survey finding those that are marked as coming "From CSV" meaning that the popup-up will not show the attributes and they will be kept as hidden inputs
 * @param survey
 * @return The list of attributes that are marked as coming "From CSV" or that are key attributes
 */
public List<AttributeDefinition> getExtendedDataFields() {
    final CollectAnnotations annotations = getAnnotations();
    final List<AttributeDefinition> fromCsvAttributes = new ArrayList<AttributeDefinition>();
    getSchema().traverse(new NodeDefinitionVisitor() {

        public void visit(NodeDefinition def) {
            if (def instanceof AttributeDefinition) {
                AttributeDefinition attrDef = (AttributeDefinition) def;
                if (annotations.isFromCollectEarthCSV(attrDef) && !attrDef.isKey()) {
                    fromCsvAttributes.add(attrDef);
                }
            }
        }
    });
    return fromCsvAttributes;
}
Also used : ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) NodeDefinitionVisitor(org.openforis.idm.metamodel.NodeDefinitionVisitor)

Example 12 with CollectAnnotations

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

the class CoordinateAttributeDefinitionFormObject method saveTo.

@Override
public void saveTo(T dest, String languageCode) {
    super.saveTo(dest, languageCode);
    saveFieldOrderValue(dest);
    dest.setFieldLabel(CoordinateAttributeDefinition.X_FIELD_NAME, languageCode, xFieldLabel);
    dest.setFieldLabel(CoordinateAttributeDefinition.Y_FIELD_NAME, languageCode, yFieldLabel);
    dest.setFieldLabel(CoordinateAttributeDefinition.SRS_FIELD_NAME, languageCode, srsFieldLabel);
    CollectAnnotations annotations = ((CollectSurvey) dest.getSurvey()).getAnnotations();
    annotations.setAllowOnlyDeviceCoordinate(dest, allowOnlyDeviceCoordinate);
    annotations.setShowSrsField(dest, showSrsField);
}
Also used : CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 13 with CollectAnnotations

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

the class CoordinateAttributeDefinitionFormObject method loadFrom.

@Override
public void loadFrom(T source, String languageCode) {
    super.loadFrom(source, languageCode);
    loadFieldsOrderValue(source);
    xFieldLabel = source.getFieldLabel(CoordinateAttributeDefinition.X_FIELD_NAME, languageCode);
    yFieldLabel = source.getFieldLabel(CoordinateAttributeDefinition.Y_FIELD_NAME, languageCode);
    srsFieldLabel = source.getFieldLabel(CoordinateAttributeDefinition.SRS_FIELD_NAME, languageCode);
    CollectAnnotations annotations = ((CollectSurvey) source.getSurvey()).getAnnotations();
    allowOnlyDeviceCoordinate = annotations.isAllowOnlyDeviceCoordinate(source);
    showSrsField = annotations.isShowSrsField(source);
}
Also used : CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 14 with CollectAnnotations

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

the class FileAttributeDefinitionFormObject method saveTo.

@Override
public void saveTo(T dest, String languageCode) {
    super.saveTo(dest, languageCode);
    dest.setMaxSize(convertToBytes(maxSize));
    dest.removeAllExtensions();
    CollectAnnotations annotations = ((CollectSurvey) dest.getSurvey()).getAnnotations();
    annotations.setFileType(dest, FileType.valueOf(fileType));
}
Also used : CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 15 with CollectAnnotations

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

the class AttributeDefinitionFormObject method loadFrom.

@Override
public void loadFrom(T source, String languageCode) {
    super.loadFrom(source, languageCode);
    key = source.isKey();
    attributeDefaults = new ArrayList<AttributeDefault>(source.getAttributeDefaults());
    CollectSurvey survey = (CollectSurvey) source.getSurvey();
    CollectAnnotations annotations = survey.getAnnotations();
    phaseToApplyDefaultValue = annotations.getPhaseToApplyDefaultValue(source).name();
    editable = annotations.isEditable(source);
    measurement = annotations.isMeasurementAttribute(source);
    showInMapBalloon = annotations.isShowInMapBalloon(source);
    checks = new ArrayList<Check<?>>(source.getChecks());
    UIOptions uiOptions = getUIOptions(source);
    visibleFields = uiOptions.getVisibleFields(source);
    if (source.getReferencedAttribute() != null) {
        referencedAttributePath = source.getReferencedAttribute().getPath();
    }
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) AttributeDefault(org.openforis.idm.metamodel.AttributeDefault) Check(org.openforis.idm.metamodel.validation.Check) 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