public ThinQuery convertQuery(@NotNull String xml) throws Exception {
if (StringUtils.isNotBlank(xml) && xml.trim().startsWith("<?xml")) {
QueryDeserializer qd = new QueryDeserializer();
SaikuCube scube = qd.getFakeCube(xml);
OlapConnection con = olapDiscoverService.getNativeConnection(scube.getConnection());
IQuery query = qd.unparse(xml, con);
if (QueryType.QM.equals(query.getType())) {
OlapQuery qr = (OlapQuery) query;
Query sQ = QueryConverter.convertQuery(qr.getQuery());
SaikuCube converted = ObjectUtil.convert(scube.getConnection(), sQ.getCube());
return Thin.convert(sQ, converted);
} else {
SaikuCube converted = ObjectUtil.convert(scube.getConnection(), olapDiscoverService.getNativeCube(scube));
return new ThinQuery(query.getName(), converted, query.getMdx());
}
}
return null;
}