} else {
nature = QuerySerializationConstants.FIELD_NATURE_ATTRIBUTE;
}
} else if (field.isCalculatedField()){
CalculatedSelectField calculatedSelectField = (CalculatedSelectField)field;
fieldJSON.put(QuerySerializationConstants.FIELD_TYPE, field.CALCULATED_FIELD);
JSONObject fieldClaculationDescriptor = new JSONObject();
fieldClaculationDescriptor.put(QuerySerializationConstants.FIELD_TYPE, calculatedSelectField.getType());
fieldClaculationDescriptor.put(QuerySerializationConstants.FIELD_EXPRESSION, calculatedSelectField.getExpression());
fieldJSON.put(QuerySerializationConstants.FIELD_ID, fieldClaculationDescriptor);
fieldJSON.put(QuerySerializationConstants.FIELD_ICON_CLS, "calculation");
nature = QuerySerializationConstants.FIELD_NATURE_POST_LINE_CALCULATED;
} else if (field.isInLineCalculatedField()) {
InLineCalculatedSelectField calculatedSelectField = (InLineCalculatedSelectField)field;
fieldJSON.put(QuerySerializationConstants.FIELD_TYPE, field.IN_LINE_CALCULATED_FIELD);
JSONObject fieldClaculationDescriptor = new JSONObject();
fieldClaculationDescriptor.put(QuerySerializationConstants.FIELD_ALIAS, calculatedSelectField.getAlias());
fieldClaculationDescriptor.put(QuerySerializationConstants.FIELD_TYPE, calculatedSelectField.getType());
fieldClaculationDescriptor.put(QuerySerializationConstants.FIELD_EXPRESSION, calculatedSelectField.getExpression());
fieldJSON.put(QuerySerializationConstants.FIELD_ID, fieldClaculationDescriptor);
fieldJSON.put(QuerySerializationConstants.FIELD_LONG_DESCRIPTION, calculatedSelectField.getExpression());
if ( calculatedSelectField.isGroupByField() ) {
fieldJSON.put(QuerySerializationConstants.FIELD_GROUP, "true");
} else {
fieldJSON.put(QuerySerializationConstants.FIELD_GROUP, "");
}
fieldJSON.put(QuerySerializationConstants.FIELD_AGGREGATION_FUNCTION, calculatedSelectField.getFunction().getName());
fieldJSON.put(QuerySerializationConstants.FIELD_ORDER, calculatedSelectField.getOrderType());
//fieldJSON.put(SerializationConstants.FIELD_GROUP, "");
fieldJSON.put(QuerySerializationConstants.FIELD_ORDER, "");
//fieldJSON.put(SerializationConstants.FIELD_AGGREGATION_FUNCTION, "");
fieldJSON.put(QuerySerializationConstants.FIELD_ICON_CLS, "calculation");
/*
* We should understand if the calculated field is an attribute (i.e. a composition of attributes)
* or a measure (i.e. a composition of measures).
* The easiest way to understand this it to see if it is a grouping field.
* TODO manage queries without any aggregation and grouping.
* At the time being this information is used only in crosstab definition, and crosstab base query SHOULD
* make aggregation.
*/
if ( calculatedSelectField.isGroupByField() ) {
nature = QuerySerializationConstants.FIELD_NATURE_ATTRIBUTE;
} else {
nature = QuerySerializationConstants.FIELD_NATURE_MEASURE;
}