Search in sources :

Example 86 with AttributeDefinition

use of org.openforis.idm.metamodel.AttributeDefinition in project collect by openforis.

the class CSVWriterDataQueryResultItemProcessor method writeCSVHeader.

private void writeCSVHeader() {
    List<String> headers = new ArrayList<String>();
    EntityDefinition rootEntity = query.getEntityDefinition().getRootEntity();
    List<AttributeDefinition> keyAttributeDefinitions = rootEntity.getKeyAttributeDefinitions();
    for (AttributeDefinition def : keyAttributeDefinitions) {
        String keyLabel = def.getLabel(Type.INSTANCE);
        if (StringUtils.isBlank(keyLabel)) {
            keyLabel = def.getName();
        }
        headers.add(keyLabel);
    }
    headers.add("Path");
    AttributeDefinition attrDef = (AttributeDefinition) query.getSchema().getDefinitionById(query.getAttributeDefinitionId());
    headers.addAll(extractFieldHeaders(attrDef));
    csvWriter.writeHeaders(headers);
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) ArrayList(java.util.ArrayList) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Example 87 with AttributeDefinition

use of org.openforis.idm.metamodel.AttributeDefinition in project collect by openforis.

the class DataQueryResultItem method getAttributeDefinition.

public AttributeDefinition getAttributeDefinition() {
    Schema schema = query.getSchema();
    AttributeDefinition def = (AttributeDefinition) schema.getDefinitionById(query.getAttributeDefinitionId());
    return def;
}
Also used : Schema(org.openforis.idm.metamodel.Schema) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Example 88 with AttributeDefinition

use of org.openforis.idm.metamodel.AttributeDefinition in project collect by openforis.

the class DataQueryResultItem method extractAttributeValue.

public Value extractAttributeValue() {
    AttributeDefinition def = getAttributeDefinition();
    Value val = new JSONValueParser().parseValue(def, value);
    return val;
}
Also used : JSONValueParser(org.openforis.collect.datacleansing.json.JSONValueParser) Value(org.openforis.idm.model.Value) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Example 89 with AttributeDefinition

use of org.openforis.idm.metamodel.AttributeDefinition in project collect by openforis.

the class DataTable method getDataColumn.

public DataColumn getDataColumn(FieldDefinition<?> fieldDefinition) {
    AttributeDefinition attributeDefinition = (AttributeDefinition) fieldDefinition.getParentDefinition();
    List<DataColumn> attributeDataColumns = getDataColumns(attributeDefinition);
    String fieldDefinitionName = fieldDefinition.getName();
    for (DataColumn column : attributeDataColumns) {
        NodeDefinition columnNodeDefn = column.getNodeDefinition();
        if (columnNodeDefn instanceof FieldDefinition && columnNodeDefn.getName().equals(fieldDefinitionName)) {
            return column;
        }
    }
    return null;
}
Also used : FieldDefinition(org.openforis.idm.metamodel.FieldDefinition) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition)

Example 90 with AttributeDefinition

use of org.openforis.idm.metamodel.AttributeDefinition in project collect by openforis.

the class DataTable method getDataColumns.

public List<DataColumn> getDataColumns(AttributeDefinition attributeDefinition) {
    List<DataColumn> result = new ArrayList<DataColumn>();
    int attributeDefinitionId = attributeDefinition.getId();
    for (Column<?> column : getColumns()) {
        if (column instanceof DataColumn) {
            DataColumn dataCol = (DataColumn) column;
            AttributeDefinition columnAttrDefn = dataCol.getAttributeDefinition();
            if (columnAttrDefn.getId() == attributeDefinitionId && !(dataCol instanceof CodeValueFKColumn)) {
                result.add(dataCol);
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition)

Aggregations

AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)107 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)47 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)37 ArrayList (java.util.ArrayList)33 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)27 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)21 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)20 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)18 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)18 CollectSurvey (org.openforis.collect.model.CollectSurvey)17 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)16 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)16 TextAttributeDefinition (org.openforis.idm.metamodel.TextAttributeDefinition)12 TimeAttributeDefinition (org.openforis.idm.metamodel.TimeAttributeDefinition)12 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)11 Schema (org.openforis.idm.metamodel.Schema)10 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)9 Entity (org.openforis.idm.model.Entity)9 Value (org.openforis.idm.model.Value)9 RangeAttributeDefinition (org.openforis.idm.metamodel.RangeAttributeDefinition)8