String queryName = queryElement.getAttributeValue("name");
String cubeName = queryElement.getAttributeValue(CUBE);
if (!StringUtils.isNotBlank(cubeName)) {
throw new QueryParseException("Cube for query not defined");
}
String connectionName = queryElement.getAttributeValue(CONNECTION);
String catalogName = queryElement.getAttributeValue(CATALOG);
String schemaName = queryElement.getAttributeValue(SCHEMA);
try {
Element qmElement = queryElement.getChild("QueryModel");
if (qmElement != null) {
qm = createEmptyQuery(queryName, catalogName, schemaName, cubeName);
manipulateQuery(qmElement);
SaikuCube cube =
new SaikuCube(connectionName, cubeName, qm.getCube().getName(), qm.getCube().getCaption(), catalogName,
schemaName);
IQuery q = new OlapQuery(qm, connection, cube, false);
setTotals(q, queryElement);
Properties p = getProperties(queryElement);
q.setProperties(p);
return q;
} else {
throw new OlapException("Can't find child <QueryModel>");
}
} catch (OlapException e) {
throw new QueryParseException(e.getMessage(), e);
}
} else {
throw new QueryParseException(
"Cannot parse Query Model: Query node not found and/or more than 1 Query node found");
}
}