Search in sources :

Example 1 with AbstractValue

use of org.openforis.idm.model.AbstractValue in project collect by openforis.

the class CSVDataImportProcess method setRecordKeys.

private void setRecordKeys(DataLine line, CollectRecord record) {
    EntityDefinition rootEntityDefn = record.getRootEntity().getDefinition();
    Value[] recordKeyValues = line.getRecordKeyValues(rootEntityDefn);
    List<AttributeDefinition> keyAttributeDefinitions = rootEntityDefn.getKeyAttributeDefinitions();
    for (int i = 0; i < keyAttributeDefinitions.size(); i++) {
        AttributeDefinition keyDefn = keyAttributeDefinitions.get(i);
        // for record key attributes, absolute path must be equal to relative path
        Attribute<?, ?> keyAttr = record.findNodeByPath(keyDefn.getPath());
        Value keyVal = recordKeyValues[i];
        setValueInField(keyAttr, keyDefn.getMainFieldName(), ((AbstractValue) keyVal).toInternalString(), line.getLineNumber(), null);
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) AbstractValue(org.openforis.idm.model.AbstractValue) Value(org.openforis.idm.model.Value) NumericAttributeDefinition(org.openforis.idm.metamodel.NumericAttributeDefinition) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) NumberAttributeDefinition(org.openforis.idm.metamodel.NumberAttributeDefinition)

Aggregations

AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)1 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)1 AbstractValue (org.openforis.idm.model.AbstractValue)1 Value (org.openforis.idm.model.Value)1