def collection_hm_children_wrt_get(self, schemaElementName=None, callsequence=None, aslist=False): set2 = self.request.GET.get("set2", "{}") # mg = self.request.GET.get("measuregroup", None) # if mg: # set2 = set2 + ", " + mg ds = self.datasource_get() cat = ds.getCatalog(self.kw["CATALOG_NAME"]) cube = self.kw["CUBE_NAME"] member = self.kw["MEMBER_UNIQUE_NAME"] + ".children" cmd="SELECT NON EMPTY %s ON COLUMNS, %s on ROWS FROM [%s]" %\ (member, set2, cube) res=cat.query(cmd) axistuple = utils.dictify(res.getAxisTuple(0)) result = [] for member in res.getAxisTuple(0): # in case someone played with MAMBER_UNIQUE_NAME #if isinstance(member, list): # member = member[0] children = int(member.DisplayInfo) & 0xffff m = {} m["CHILDREN_CARDINALITY"] = str(children) m["MEMBER_CAPTION"] = member.Caption m["MEMBER_UNIQUE_NAME"] = member.UName m["LEVEL_NUMBER"] = member.LNum m["LEVEL_UNIQUE_NAME"] = member.LName result.append(m) return result
def main(mdxfile, location, catalog, krb, username, password, spn, sslverify): p = os.path.dirname(os.path.realpath(__file__)) pyfile = os.path.join(p, os.path.splitext(mdxfile)[0] + os.path.extsep + "py") cmd = open(os.path.join(p,mdxfile)).read() p = xmla.XMLAProvider() auth = None if krb: kw = {} if spn: service, host = spn.split("@",1) kw["service"]=service kw["hostname_override"]=host if username: kw["principal"] = username auth = HTTPKerberosAuth(**kw) elif username: auth = HTTPBasicAuth(username, password) kwargs = {} log = LogRequest() kwargs["log"] = log c=p.connect(location=location, sslverify=sslverify, auth=auth, **kwargs) res=c.Execute(cmd, Catalog=catalog) x=utils.dictify(res.root, keep_none_text=True) erg=pprint.pformat(x) encodinghint="# -*- coding: utf-8" open(pyfile, "w+").write('%s\n"""\n%s\n"""\n\nresult=%s\n\nxml_response="""%s"""' % (encodinghint, cmd, erg, log.res))
def collection_hm_children_wrt_get(self, schemaElementName=None, callsequence=None, aslist=False): set2 = self.request.GET.get("set2", "{}") # mg = self.request.GET.get("measuregroup", None) # if mg: # set2 = set2 + ", " + mg ds = self.datasource_get() cat = ds.getCatalog(self.kw["CATALOG_NAME"]) cube = self.kw["CUBE_NAME"] member = self.kw["MEMBER_UNIQUE_NAME"] + ".children" cmd="SELECT NON EMPTY %s ON COLUMNS, %s on ROWS FROM [%s]" %\ (member, set2, cube) res = cat.query(cmd) axistuple = utils.dictify(res.getAxisTuple(0)) result = [] for member in res.getAxisTuple(0): # in case someone played with MAMBER_UNIQUE_NAME #if isinstance(member, list): # member = member[0] children = int(member.DisplayInfo) & 0xffff m = {} m["CHILDREN_CARDINALITY"] = str(children) m["MEMBER_CAPTION"] = member.Caption m["MEMBER_UNIQUE_NAME"] = member.UName m["LEVEL_NUMBER"] = member.LNum m["LEVEL_UNIQUE_NAME"] = member.LName result.append(m) return result
def get(self, schemaElementName=None, callsequence=None, aslist=False, altSchemaElementName=None): ds = self.datasource_get() self.kw.pop("ds_name") # if we ask for, say catalogs, but have also a fixed cube defined # we will have the variable for the CUBE in the kw. # we have to remove that or the getSchemaElements will bomb for k, v in self.fixedvalues.items(): if k not in self.neededvars[schemaElementName]: del self.kw[k] try: if oxi.IXMLASource.providedBy(ds): return utils.dictify( ds.getSchemaElements(altSchemaElementName or schemaElementName, None, aslist=aslist, more_restrictions=self.kw, generate_instance=False)) else: return self.get_iolap(ds, callsequence) except oxi.SchemaElementNotFound, e: raise _404({ "restrictions:": e.restrictions, "properties": e.properties })
def main(mdxfile, location, catalog, krb, username, password, spn, sslverify): p = os.path.dirname(os.path.realpath(__file__)) pyfile = os.path.join(p, os.path.splitext(mdxfile)[0] + os.path.extsep + "py") cmd = open(os.path.join(p, mdxfile)).read() p = xmla.XMLAProvider() auth = None if krb: kw = {} if spn: service, host = spn.split("@", 1) kw["service"] = service kw["hostname_override"] = host if username: kw["principal"] = username auth = HTTPKerberosAuth(**kw) elif username: auth = HTTPBasicAuth(username, password) kwargs = {} log = LogRequest() kwargs["log"] = log c = p.connect(location=location, sslverify=sslverify, auth=auth, **kwargs) res = c.Execute(cmd, Catalog=catalog) x = utils.dictify(res.root, keep_none_text=True) erg = pprint.pformat(x) encodinghint = "# -*- coding: utf-8" open(pyfile, "w+").write('%s\n"""\n%s\n"""\n\nresult=%s\n\nxml_response="""%s"""' % (encodinghint, cmd, erg, log.res))
def get_iolap(self, ds, callsequence): calls = callsequence calls = calls[:] calls.pop(0) # the first is the datasource, but we have that already lastobj = ds while calls: methodname, paramname = calls.pop(0) params = [] if paramname is None else [self.kw[paramname]] lastobj = getattr(lastobj, methodname)(*params) listresult = lastobj if isinstance(lastobj, list) else [lastobj] return [utils.dictify(e.getElementProperties()) for e in listresult]
def main(mdxfile, location, catalog, username, password, spn, sslverify): pyfile = os.path.splitext(mdxfile)[0] + os.path.extsep + "py" cmd = file(mdxfile).read() p = xmla.XMLAProvider() c = p.connect(location=location, username=username, password=password, spn=spn, sslverify=sslverify) res = c.Execute(cmd, Catalog=catalog) x = utils.dictify(res.root) erg = pprint.pformat(x) file(pyfile, "wb+").write('"""\n%s\n"""\n\nresult=%s\n' % (cmd, erg))
def main(mdxfile, location, catalog, username, password, spn, sslverify): pyfile = os.path.splitext(mdxfile)[0] + os.path.extsep + "py" cmd = file(mdxfile).read() p = xmla.XMLAProvider() c=p.connect(location=location, username=username, password=password, spn=spn, sslverify=sslverify) res=c.Execute(cmd, Catalog=catalog) x=utils.dictify(res.root) erg=pprint.pformat(x) file(pyfile, "wb+").write('"""\n%s\n"""\n\nresult=%s\n' % (cmd, erg))
def collection_query_post(self, schemaElementName=None, callsequence=None): r=self.request.json_body.copy() ds = self.datasource_get() cat = ds.getCatalog(self.request.matchdict["CATALOG_NAME"]) res=cat.query(r["mdx"]) axistuple = [] try: axis=0 while True: axistuple.append(res.getAxisTuple(axis)) axis += 1 except: pass prop = r.get("properties", None) slices = res.getSlice(properties=prop) uid=str(uuid.uuid4()) self.q[uid] = utils.dictify({ "axes" : axistuple, "cells" : slices, "id" : uid, "mdx" : r["mdx"] }) return self.q[uid]
def collection_query_post(self, schemaElementName=None, callsequence=None): r = self.request.json_body.copy() ds = self.datasource_get() cat = ds.getCatalog(self.request.matchdict["CATALOG_NAME"]) res = cat.query(r["mdx"]) axistuple = [] try: axis = 0 while True: axistuple.append(res.getAxisTuple(axis)) axis += 1 except: pass prop = r.get("properties", None) slices = res.getSlice(properties=prop) uid = str(uuid.uuid4()) self.q[uid] = utils.dictify({ "axes": axistuple, "cells": slices, "id": uid, "mdx": r["mdx"] }) return self.q[uid]
def get(self, schemaElementName=None, callsequence=None, aslist=False, altSchemaElementName=None): ds = self.datasource_get() self.kw.pop("ds_name") # if we ask for, say catalogs, but have also a fixed cube defined # we will have the variable for the CUBE in the kw. # we have to remove that or the getSchemaElements will bomb for k, v in self.fixedvalues.items(): if k not in self.neededvars[schemaElementName]: del self.kw[k] try: if oxi.IXMLASource.providedBy(ds): return utils.dictify(ds.getSchemaElements( altSchemaElementName or schemaElementName, None, aslist=aslist, more_restrictions=self.kw, generate_instance=False)) else: return self.get_iolap(ds, callsequence) except oxi.SchemaElementNotFound, e: raise _404({"restrictions:":e.restrictions, "properties":e.properties})