Search in sources :

Example 1 with EntityPositionIdentifierDefinition

use of org.openforis.collect.io.data.DataLine.EntityPositionIdentifierDefinition in project collect by openforis.

the class DataCSVReader method getExpectedAncestorKeyColumnNames.

private List<String> getExpectedAncestorKeyColumnNames() {
    List<EntityIdentifierDefinition> entityIdentifierDefns = getAncestorIdentifiers();
    // validate ancestor key columns
    Schema schema = parentEntityDefinition.getSchema();
    List<String> expectedEntityKeyColumns = new ArrayList<String>();
    for (EntityIdentifierDefinition identifier : entityIdentifierDefns) {
        int defnId = identifier.getEntityDefinitionId();
        EntityDefinition defn = (EntityDefinition) schema.getDefinitionById(defnId);
        if (identifier instanceof EntityPositionIdentifierDefinition) {
            String expectedColName = getPositionColumnName(defn);
            expectedEntityKeyColumns.add(expectedColName);
        } else if (identifier instanceof SingleEntityIdentifierDefinition) {
        // skip
        } else {
            List<AttributeDefinition> keyDefns = defn.getKeyAttributeDefinitions();
            for (AttributeDefinition keyDefn : keyDefns) {
                List<String> expectedColNames = getKeyAttributeColumnNames(parentEntityDefinition, keyDefn);
                expectedEntityKeyColumns.addAll(expectedColNames);
            }
        }
    }
    return expectedEntityKeyColumns;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) SingleEntityIdentifierDefinition(org.openforis.collect.io.data.DataLine.SingleEntityIdentifierDefinition) Schema(org.openforis.idm.metamodel.Schema) ArrayList(java.util.ArrayList) EntityPositionIdentifierDefinition(org.openforis.collect.io.data.DataLine.EntityPositionIdentifierDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) ArrayList(java.util.ArrayList) List(java.util.List) SingleEntityIdentifierDefinition(org.openforis.collect.io.data.DataLine.SingleEntityIdentifierDefinition) EntityIdentifierDefinition(org.openforis.collect.io.data.DataLine.EntityIdentifierDefinition)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 EntityIdentifierDefinition (org.openforis.collect.io.data.DataLine.EntityIdentifierDefinition)1 EntityPositionIdentifierDefinition (org.openforis.collect.io.data.DataLine.EntityPositionIdentifierDefinition)1 SingleEntityIdentifierDefinition (org.openforis.collect.io.data.DataLine.SingleEntityIdentifierDefinition)1 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1 Schema (org.openforis.idm.metamodel.Schema)1