Commit 81e47334 authored by Jérome Perrin's avatar Jérome Perrin

discover: support a few more restriction lists in queries

parent 12434484
...@@ -1730,7 +1730,7 @@ class XmlaDiscoverTools(): ...@@ -1730,7 +1730,7 @@ class XmlaDiscoverTools():
""".format(_catalogues)) """.format(_catalogues))
def discover_mdschema_cubes_response(self, request): def discover_mdschema_cubes_response(self, request):
if request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue \ if request.Restrictions.RestrictionList and request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue \
and request.Properties.PropertyList.Catalog is not None: and request.Properties.PropertyList.Catalog is not None:
self.change_catalogue(request.Properties.PropertyList.Catalog) self.change_catalogue(request.Properties.PropertyList.Catalog)
if request.Restrictions.RestrictionList.CATALOG_NAME == self.selected_catalogue: if request.Restrictions.RestrictionList.CATALOG_NAME == self.selected_catalogue:
...@@ -1822,8 +1822,8 @@ class XmlaDiscoverTools(): ...@@ -1822,8 +1822,8 @@ class XmlaDiscoverTools():
def discover_mdschema_measures__response(self, request): def discover_mdschema_measures__response(self, request):
measures = "" measures = ""
if request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue and \ if request.Restrictions.RestrictionList and\
request.Restrictions.RestrictionList.MEASURE_VISIBILITY == 3 and\ request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue and \
request.Properties.PropertyList.Catalog is not None: request.Properties.PropertyList.Catalog is not None:
self.change_catalogue(request.Properties.PropertyList.Catalog) self.change_catalogue(request.Properties.PropertyList.Catalog)
...@@ -1859,8 +1859,9 @@ class XmlaDiscoverTools(): ...@@ -1859,8 +1859,9 @@ class XmlaDiscoverTools():
""".format(measures)) """.format(measures))
def discover_mdschema_dimensions_response(self, request): def discover_mdschema_dimensions_response(self, request):
if request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue and\ if request.Restrictions.RestrictionList and (\
request.Restrictions.RestrictionList.CATALOG_NAME == self.selected_catalogue and \ request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue or\
request.Restrictions.RestrictionList.CATALOG_NAME == self.selected_catalogue) and \
request.Properties.PropertyList.Catalog is not None: request.Properties.PropertyList.Catalog is not None:
self.change_catalogue(request.Properties.PropertyList.Catalog) self.change_catalogue(request.Properties.PropertyList.Catalog)
...@@ -1920,11 +1921,14 @@ class XmlaDiscoverTools(): ...@@ -1920,11 +1921,14 @@ class XmlaDiscoverTools():
request.Properties.PropertyList.Catalog is not None: request.Properties.PropertyList.Catalog is not None:
self.change_catalogue(request.Properties.PropertyList.Catalog) self.change_catalogue(request.Properties.PropertyList.Catalog)
if request.Restrictions.RestrictionList.HIERARCHY_VISIBILITY == 3: if 1: # XXX request.Restrictions.RestrictionList.HIERARCHY_VISIBILITY == 3:
rows = "" rows = ""
for table_name, df in self.executer.tables_loaded.items(): for table_name, df in self.executer.tables_loaded.items():
if table_name == self.executer.facts: if table_name == self.executer.facts:
continue continue
if request.Restrictions.RestrictionList.DIMENSION_UNIQUE_NAME and \
request.Restrictions.RestrictionList.DIMENSION_UNIQUE_NAME != '[{}]'.format(table_name):
continue
# french caracteres # french caracteres
# TODO encode dataframe # TODO encode dataframe
...@@ -1959,7 +1963,9 @@ class XmlaDiscoverTools(): ...@@ -1959,7 +1963,9 @@ class XmlaDiscoverTools():
""".format(self.selected_catalogue, table_name, """.format(self.selected_catalogue, table_name,
df.columns[0], column_attribut) df.columns[0], column_attribut)
rows += """ if (not request.Restrictions.RestrictionList.DIMENSION_UNIQUE_NAME) or \
request.Restrictions.RestrictionList.DIMENSION_UNIQUE_NAME == '[Measures]':
rows += """
<row> <row>
<CATALOG_NAME>{0}</CATALOG_NAME> <CATALOG_NAME>{0}</CATALOG_NAME>
<CUBE_NAME>{0}</CUBE_NAME> <CUBE_NAME>{0}</CUBE_NAME>
...@@ -2068,13 +2074,16 @@ class XmlaDiscoverTools(): ...@@ -2068,13 +2074,16 @@ class XmlaDiscoverTools():
def discover_mdschema_levels__response(self, request): def discover_mdschema_levels__response(self, request):
# TODO fix levels in the same table (with xml file maybe) !!!!!!!!! # TODO fix levels in the same table (with xml file maybe) !!!!!!!!!
if request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue and \ if (request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue or \
request.Restrictions.RestrictionList.CATALOG_NAME == self.selected_catalogue and \ request.Restrictions.RestrictionList.CATALOG_NAME == self.selected_catalogue ) and \
request.Properties.PropertyList.Catalog is not None: request.Properties.PropertyList.Catalog is not None:
self.change_catalogue(request.Properties.PropertyList.Catalog) self.change_catalogue(request.Properties.PropertyList.Catalog)
rows = "" rows = ""
for tables in self.executer.get_all_tables_names(ignore_fact=True): for tables in self.executer.get_all_tables_names(ignore_fact=True):
if request.Restrictions.RestrictionList.DIMENSION_UNIQUE_NAME and (
request.Restrictions.RestrictionList.DIMENSION_UNIQUE_NAME != '[{}]'.format(tables)):
continue
l_nb = 0 l_nb = 0
for col in self.executer.tables_loaded[tables].columns: for col in self.executer.tables_loaded[tables].columns:
rows += """ rows += """
...@@ -2099,7 +2108,9 @@ class XmlaDiscoverTools(): ...@@ -2099,7 +2108,9 @@ class XmlaDiscoverTools():
""".format(self.selected_catalogue, tables, col, l_nb) """.format(self.selected_catalogue, tables, col, l_nb)
l_nb += 1 l_nb += 1
rows += """ if not request.Restrictions.RestrictionList.DIMENSION_UNIQUE_NAME or (
request.Restrictions.RestrictionList.DIMENSION_UNIQUE_NAME == '[Measures]'):
rows += """
<row> <row>
<CATALOG_NAME>{0}</CATALOG_NAME> <CATALOG_NAME>{0}</CATALOG_NAME>
<CUBE_NAME>{0}</CUBE_NAME> <CUBE_NAME>{0}</CUBE_NAME>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment