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