Commit 3484de7e authored by mouadh's avatar mouadh

format

parent c43be567
...@@ -7,19 +7,14 @@ import uuid ...@@ -7,19 +7,14 @@ import uuid
from lxml import etree from lxml import etree
from ..mdx.executor.execute import MdxEngine from ..mdx.executor.execute import MdxEngine
from .xmla_discover_xsds import (dbschema_catalogs_xsd, dbschema_tables_xsd, from .xmla_discover_xsds import (
discover_datasources_xsd, dbschema_catalogs_xsd, dbschema_tables_xsd, discover_datasources_xsd,
discover_literals_xsd, discover_literals_xsd, discover_preperties_xsd,
discover_preperties_xsd, discover_schema_rowsets_xsd, mdschema_cubes_xsd, mdschema_dimensions_xsd,
discover_schema_rowsets_xsd, mdschema_hierarchies_xsd, mdschema_kpis_xsd, mdschema_levels_xsd,
mdschema_cubes_xsd, mdschema_dimensions_xsd, mdschema_measures_xsd, mdschema_measuresgroups_dimensions_xsd,
mdschema_hierarchies_xsd, mdschema_kpis_xsd, mdschema_measuresgroups_xsd, mdschema_members_xsd,
mdschema_levels_xsd, mdschema_measures_xsd, mdschema_properties_properties_xsd, mdschema_sets_xsd)
mdschema_measuresgroups_dimensions_xsd,
mdschema_measuresgroups_xsd,
mdschema_members_xsd,
mdschema_properties_properties_xsd,
mdschema_sets_xsd)
# TODO clean # TODO clean
...@@ -78,7 +73,6 @@ class XmlaDiscoverTools(): ...@@ -78,7 +73,6 @@ class XmlaDiscoverTools():
</return>""") </return>""")
def discover_properties_response(self, request): def discover_properties_response(self, request):
def get_props(xsd, PropertyName, PropertyDescription, PropertyType, def get_props(xsd, PropertyName, PropertyDescription, PropertyType,
PropertyAccessType, IsRequired, Value): PropertyAccessType, IsRequired, Value):
return etree.fromstring(""" return etree.fromstring("""
...@@ -120,15 +114,15 @@ class XmlaDiscoverTools(): ...@@ -120,15 +114,15 @@ class XmlaDiscoverTools():
elif request.Restrictions.RestrictionList.PropertyName == 'MdpropMdxSubqueries': elif request.Restrictions.RestrictionList.PropertyName == 'MdpropMdxSubqueries':
if 'Unspecified' in request.Properties.PropertyList.Catalog: if 'Unspecified' in request.Properties.PropertyList.Catalog:
return get_props(discover_preperties_xsd, 'MdpropMdxSubqueries', return get_props(discover_preperties_xsd,
'MdpropMdxSubqueries', 'int', 'Read', 'false', 'MdpropMdxSubqueries', 'MdpropMdxSubqueries',
'15') 'int', 'Read', 'false', '15')
if request.Properties.PropertyList.Catalog is not None: if request.Properties.PropertyList.Catalog is not None:
self.change_catalogue(request.Properties.PropertyList.Catalog) self.change_catalogue(request.Properties.PropertyList.Catalog)
return get_props(discover_preperties_xsd, 'MdpropMdxSubqueries', return get_props(discover_preperties_xsd,
'MdpropMdxSubqueries', 'int', 'Read', 'false', 'MdpropMdxSubqueries', 'MdpropMdxSubqueries',
'15') 'int', 'Read', 'false', '15')
elif request.Restrictions.RestrictionList.PropertyName == 'MdpropMdxDrillFunctions': elif request.Restrictions.RestrictionList.PropertyName == 'MdpropMdxDrillFunctions':
if 'Unspecified' in request.Properties.PropertyList.Catalog: if 'Unspecified' in request.Properties.PropertyList.Catalog:
...@@ -167,8 +161,8 @@ class XmlaDiscoverTools(): ...@@ -167,8 +161,8 @@ class XmlaDiscoverTools():
def discover_schema_rowsets_response(self, request): def discover_schema_rowsets_response(self, request):
if request.Restrictions.RestrictionList.SchemaName == "MDSCHEMA_HIERARCHIES" and \ if request.Restrictions.RestrictionList.SchemaName == "MDSCHEMA_HIERARCHIES" 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)
return etree.fromstring(""" return etree.fromstring("""
<return> <return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset" <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
...@@ -220,8 +214,8 @@ class XmlaDiscoverTools(): ...@@ -220,8 +214,8 @@ class XmlaDiscoverTools():
""") """)
if request.Restrictions.RestrictionList.SchemaName == 'MDSCHEMA_MEASURES' and \ if request.Restrictions.RestrictionList.SchemaName == 'MDSCHEMA_MEASURES' 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)
return etree.fromstring(""" return etree.fromstring("""
<return> <return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset" <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
...@@ -1810,8 +1804,8 @@ class XmlaDiscoverTools(): ...@@ -1810,8 +1804,8 @@ class XmlaDiscoverTools():
<MEASURE_UNQUALIFIED_CAPTION>{2}</MEASURE_UNQUALIFIED_CAPTION> <MEASURE_UNQUALIFIED_CAPTION>{2}</MEASURE_UNQUALIFIED_CAPTION>
<MEASUREGROUP_NAME>default</MEASUREGROUP_NAME> <MEASUREGROUP_NAME>default</MEASUREGROUP_NAME>
</row> </row>
""".format(self.selected_catalogue, """.format(self.selected_catalogue, self.selected_catalogue,
self.selected_catalogue, mes) mes)
return etree.fromstring(""" return etree.fromstring("""
<return> <return>
...@@ -1918,7 +1912,7 @@ class XmlaDiscoverTools(): ...@@ -1918,7 +1912,7 @@ class XmlaDiscoverTools():
<INSTANCE_SELECTION>0</INSTANCE_SELECTION> <INSTANCE_SELECTION>0</INSTANCE_SELECTION>
</row> </row>
""".format(self.selected_catalogue, table_name, """.format(self.selected_catalogue, table_name,
df.columns[0], df.iloc[0][0]) df.columns[0], df.iloc[0][0])
rows += """ rows += """
<row> <row>
...@@ -1942,8 +1936,7 @@ class XmlaDiscoverTools(): ...@@ -1942,8 +1936,7 @@ class XmlaDiscoverTools():
<HIERARCHY_ORIGIN>1</HIERARCHY_ORIGIN> <HIERARCHY_ORIGIN>1</HIERARCHY_ORIGIN>
<INSTANCE_SELECTION>0</INSTANCE_SELECTION> <INSTANCE_SELECTION>0</INSTANCE_SELECTION>
</row> </row>
""".format(self.selected_catalogue, """.format(self.selected_catalogue, self.executer.measures[0])
self.executer.measures[0])
return etree.fromstring(""" return etree.fromstring("""
<return> <return>
...@@ -1984,7 +1977,7 @@ class XmlaDiscoverTools(): ...@@ -1984,7 +1977,7 @@ class XmlaDiscoverTools():
<INSTANCE_SELECTION>0</INSTANCE_SELECTION> <INSTANCE_SELECTION>0</INSTANCE_SELECTION>
</row> </row>
""".format(self.selected_catalogue, table_name, """.format(self.selected_catalogue, table_name,
df.columns[0], df.iloc[0][0]) df.columns[0], df.iloc[0][0])
rows += """ rows += """
<row> <row>
...@@ -2008,7 +2001,7 @@ class XmlaDiscoverTools(): ...@@ -2008,7 +2001,7 @@ class XmlaDiscoverTools():
<HIERARCHY_ORIGIN>1</HIERARCHY_ORIGIN> <HIERARCHY_ORIGIN>1</HIERARCHY_ORIGIN>
<INSTANCE_SELECTION>0</INSTANCE_SELECTION> <INSTANCE_SELECTION>0</INSTANCE_SELECTION>
</row>""".format(self.selected_catalogue, </row>""".format(self.selected_catalogue,
self.executer.measures[0]) self.executer.measures[0])
return etree.fromstring(""" return etree.fromstring("""
<return> <return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset" <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
...@@ -2027,8 +2020,7 @@ class XmlaDiscoverTools(): ...@@ -2027,8 +2020,7 @@ class XmlaDiscoverTools():
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( for tables in self.executer.get_all_tables_names(ignore_fact=True):
ignore_fact=True):
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 += """
...@@ -2050,8 +2042,7 @@ class XmlaDiscoverTools(): ...@@ -2050,8 +2042,7 @@ class XmlaDiscoverTools():
<LEVEL_KEY_CARDINALITY>1</LEVEL_KEY_CARDINALITY> <LEVEL_KEY_CARDINALITY>1</LEVEL_KEY_CARDINALITY>
<LEVEL_ORIGIN>2</LEVEL_ORIGIN> <LEVEL_ORIGIN>2</LEVEL_ORIGIN>
</row> </row>
""".format(self.selected_catalogue, tables, col, """.format(self.selected_catalogue, tables, col, l_nb)
l_nb)
l_nb += 1 l_nb += 1
rows += """ rows += """
...@@ -2114,8 +2105,7 @@ class XmlaDiscoverTools(): ...@@ -2114,8 +2105,7 @@ class XmlaDiscoverTools():
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( for tables in self.executer.get_all_tables_names(ignore_fact=True):
ignore_fact=True):
rows += """ rows += """
<row> <row>
<CATALOG_NAME>{0}</CATALOG_NAME> <CATALOG_NAME>{0}</CATALOG_NAME>
...@@ -2254,7 +2244,7 @@ class XmlaDiscoverTools(): ...@@ -2254,7 +2244,7 @@ class XmlaDiscoverTools():
</root> </root>
</return> </return>
""".format(self.selected_catalogue, """.format(self.selected_catalogue,
mdschema_properties_properties_xsd)) mdschema_properties_properties_xsd))
elif request.Restrictions.RestrictionList.PROPERTY_TYPE == 1: elif request.Restrictions.RestrictionList.PROPERTY_TYPE == 1:
return etree.fromstring(""" return etree.fromstring("""
...@@ -2282,8 +2272,7 @@ class XmlaDiscoverTools(): ...@@ -2282,8 +2272,7 @@ class XmlaDiscoverTools():
# joined -> [Product].[Product].[Company] # joined -> [Product].[Product].[Company]
last_attribut = ''.join(att for att in separed_tuple[-1] last_attribut = ''.join(att for att in separed_tuple[-1]
if att not in '[]').replace('&', if att not in '[]').replace('&', '&amp;')
'&amp;')
return etree.fromstring(""" return etree.fromstring("""
<return> <return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset" <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
...@@ -2311,6 +2300,6 @@ class XmlaDiscoverTools(): ...@@ -2311,6 +2300,6 @@ class XmlaDiscoverTools():
</row> </row>
</root> </root>
</return> </return>
""".format(self.selected_catalogue, separed_tuple[ """.format(
0], joined, request. self.selected_catalogue, separed_tuple[0], joined,
Restrictions.RestrictionList.MEMBER_UNIQUE_NAME)) request.Restrictions.RestrictionList.MEMBER_UNIQUE_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