예제 #1
0
파일: pyramid.py 프로젝트: RogerWebb/olap
    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
예제 #2
0
파일: writeresult.py 프로젝트: may-day/olap
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))
예제 #3
0
파일: pyramid.py 프로젝트: yildizib/olap
    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
예제 #4
0
파일: pyramid.py 프로젝트: yildizib/olap
    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
            })
예제 #5
0
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))
예제 #6
0
파일: pyramid.py 프로젝트: RogerWebb/olap
 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]
예제 #7
0
파일: pyramid.py 프로젝트: yildizib/olap
 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]
예제 #8
0
파일: writeresult.py 프로젝트: vmalic/olap
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))
예제 #9
0
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))
예제 #10
0
파일: pyramid.py 프로젝트: RogerWebb/olap
 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]
예제 #11
0
파일: pyramid.py 프로젝트: yildizib/olap
 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]
예제 #12
0
파일: pyramid.py 프로젝트: RogerWebb/olap
    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})