// field nature can me "measure" or "attribute"
String nature = null;
if (field.isDataMartField()) {
DataMartSelectField dataMartSelectField = (DataMartSelectField)field;
fieldJSON.put(QuerySerializationConstants.FIELD_TYPE, field.DATAMART_FIELD);
fieldUniqueName = dataMartSelectField.getUniqueName();
datamartField = dataSource.getModelStructure().getField( fieldUniqueName );
Assert.assertNotNull(datamartField, "A filed named [" + fieldUniqueName + "] does not exist in the datamart model");
fieldJSON.put(QuerySerializationConstants.FIELD_ID, datamartField.getUniqueName());
// localize entity name
label = null;
if(datamartLabels != null) {
label = datamartLabels.getProperty(datamartField.getParent(), "label");
}
label = StringUtilities.isEmpty(label)? datamartField.getParent().getName(): label;
fieldJSON.put(QuerySerializationConstants.FIELD_ENTITY, label);
// localize field name
label = null;
if(datamartLabels != null) {
label = datamartLabels.getProperty(datamartField, "label");
}
label = StringUtilities.isEmpty(label)? datamartField.getName(): label;
fieldJSON.put(QuerySerializationConstants.FIELD_NAME, label);
longDescription = getFieldLongDescription(datamartField, datamartLabels);
fieldJSON.put(QuerySerializationConstants.FIELD_LONG_DESCRIPTION, longDescription);
if( dataMartSelectField.isGroupByField() ) {
fieldJSON.put(QuerySerializationConstants.FIELD_GROUP, "true");
} else {
fieldJSON.put(QuerySerializationConstants.FIELD_GROUP, "");
}
fieldJSON.put(QuerySerializationConstants.FIELD_ORDER, dataMartSelectField.getOrderType());
fieldJSON.put(QuerySerializationConstants.FIELD_AGGREGATION_FUNCTION, dataMartSelectField.getFunction().getName());
//DatamartProperties datamartProperties = dataSource.getDataMartProperties();
String iconCls = datamartField.getPropertyAsString("type");
fieldJSON.put(QuerySerializationConstants.FIELD_ICON_CLS, iconCls);
// if an aggregation function is defined or if the field is declared as "measure" into property file,
// then it is a measure, elsewhere it is an attribute
if (
(dataMartSelectField.getFunction() != null
&& !dataMartSelectField.getFunction().equals(AggregationFunctions.NONE_FUNCTION))
|| iconCls.equals("measure")) {
nature = QuerySerializationConstants.FIELD_NATURE_MEASURE;
} else {
nature = QuerySerializationConstants.FIELD_NATURE_ATTRIBUTE;
}