}
private DataStoreMetaData getDataStoreMeta(Query query) {
DataStoreMetaData dataStoreMeta;
ISelectField queryFiled;
FieldMetadata dataStoreFieldMeta;
dataStoreMeta = new DataStoreMetaData();
Iterator fieldsIterator = query.getSelectFields(true).iterator();
while(fieldsIterator.hasNext()) {
queryFiled = (ISelectField)fieldsIterator.next();
dataStoreFieldMeta = new FieldMetadata();
dataStoreFieldMeta.setAlias( queryFiled.getAlias() );
if(queryFiled.isDataMartField()) {
DataMartSelectField dataMartSelectField = (DataMartSelectField) queryFiled;
dataStoreFieldMeta.setName( ((DataMartSelectField)queryFiled).getUniqueName() );
dataStoreFieldMeta.setProperty("calculated", new Boolean(false));
dataStoreFieldMeta.setProperty("uniqueName", dataMartSelectField.getUniqueName());
dataStoreFieldMeta.setType(Object.class);
String format = dataMartSelectField.getPattern();
if (format != null && !format.trim().equals("")) {
dataStoreFieldMeta.setProperty("format", format);
}
} else if(queryFiled.isCalculatedField()){
CalculatedSelectField claculatedQueryField = (CalculatedSelectField)queryFiled;
dataStoreFieldMeta.setName(claculatedQueryField.getAlias());
dataStoreFieldMeta.setProperty("calculated", new Boolean(true));
// FIXME also calculated field must have uniquename for uniformity
dataStoreFieldMeta.setProperty("uniqueName", claculatedQueryField.getAlias());
DataSetVariable variable = new DataSetVariable(claculatedQueryField.getAlias(), claculatedQueryField.getType(), claculatedQueryField.getExpression());
dataStoreFieldMeta.setProperty("variable", variable);
dataStoreFieldMeta.setType( variable.getTypeClass() );
} else if(queryFiled.isInLineCalculatedField()){
InLineCalculatedSelectField claculatedQueryField = (InLineCalculatedSelectField)queryFiled;
dataStoreFieldMeta.setName(claculatedQueryField.getAlias());
dataStoreFieldMeta.setProperty("calculated", new Boolean(false));
// FIXME also calculated field must have uniquename for uniformity
dataStoreFieldMeta.setProperty("uniqueName", claculatedQueryField.getAlias());
DataSetVariable variable = new DataSetVariable(claculatedQueryField.getAlias(), claculatedQueryField.getType(), claculatedQueryField.getExpression());
dataStoreFieldMeta.setProperty("variable", variable);
dataStoreFieldMeta.setType( variable.getTypeClass() );
}
dataStoreFieldMeta.setProperty("visible", new Boolean(queryFiled.isVisible()));
dataStoreMeta.addFiedMeta(dataStoreFieldMeta);
}
return dataStoreMeta;