Commit 79f5c215 authored by mouadh's avatar mouadh

format

parent 7e36a6be
...@@ -974,34 +974,40 @@ class XmlaDiscoverTools(): ...@@ -974,34 +974,40 @@ class XmlaDiscoverTools():
mdschema_hierarchies_xsd, mdschema_hierarchies_xsd,
xmlns="urn:schemas-microsoft-com:xml-analysis:rowset", xmlns="urn:schemas-microsoft-com:xml-analysis:rowset",
**{ **{
'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema', 'xmlns:xsd':
'http://www.w3.org/2001/XMLSchema',
'xmlns:xsi': 'xmlns:xsi':
'http://www.w3.org/2001/XMLSchema-instance' 'http://www.w3.org/2001/XMLSchema-instance'
}): }):
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
# french caracteres # french caracteres
# TODO encode dataframe # TODO encode dataframe
if type(df.iloc[0][0]) == unicode: if type(df.iloc[0][0]) == unicode:
column_attribut = df.iloc[0][0].encode('utf-8', column_attribut = df.iloc[0][0].encode(
'replace') 'utf-8', 'replace')
else: else:
column_attribut = df.iloc[0][0] column_attribut = df.iloc[0][0]
with xml.row: with xml.row:
xml.CATALOG_NAME(self.selected_catalogue) xml.CATALOG_NAME(self.selected_catalogue)
xml.CUBE_NAME(self.selected_catalogue) xml.CUBE_NAME(self.selected_catalogue)
xml.DIMENSION_UNIQUE_NAME('[' + table_name + ']') xml.DIMENSION_UNIQUE_NAME('[' + table_name +
']')
xml.HIERARCHY_NAME(table_name) xml.HIERARCHY_NAME(table_name)
xml.HIERARCHY_UNIQUE_NAME('[{0}].[{0}]'.format(table_name)) xml.HIERARCHY_UNIQUE_NAME(
'[{0}].[{0}]'.format(table_name))
xml.HIERARCHY_CAPTION(table_name) xml.HIERARCHY_CAPTION(table_name)
xml.DIMENSION_TYPE('3') xml.DIMENSION_TYPE('3')
xml.HIERARCHY_CARDINALITY('6') xml.HIERARCHY_CARDINALITY('6')
xml.DEFAULT_MEMBER('[{0}].[{0}].[{1}].[{2}]'.format(table_name, xml.DEFAULT_MEMBER(
df.columns[0], column_attribut)) '[{0}].[{0}].[{1}].[{2}]'.format(
table_name, df.columns[
0], column_attribut))
xml.STRUCTURE('0') xml.STRUCTURE('0')
xml.IS_VIRTUAL('false') xml.IS_VIRTUAL('false')
xml.IS_READWRITE('false') xml.IS_READWRITE('false')
...@@ -1022,7 +1028,8 @@ class XmlaDiscoverTools(): ...@@ -1022,7 +1028,8 @@ class XmlaDiscoverTools():
xml.HIERARCHY_CAPTION('Measures') xml.HIERARCHY_CAPTION('Measures')
xml.DIMENSION_TYPE('2') xml.DIMENSION_TYPE('2')
xml.HIERARCHY_CARDINALITY('0') xml.HIERARCHY_CARDINALITY('0')
xml.DEFAULT_MEMBER('[Measures].[{0}]'.format(self.executer.measures[0])) xml.DEFAULT_MEMBER('[Measures].[{0}]'.format(
self.executer.measures[0]))
xml.STRUCTURE('0') xml.STRUCTURE('0')
xml.IS_VIRTUAL('false') xml.IS_VIRTUAL('false')
xml.IS_READWRITE('false') xml.IS_READWRITE('false')
...@@ -1058,17 +1065,20 @@ class XmlaDiscoverTools(): ...@@ -1058,17 +1065,20 @@ class XmlaDiscoverTools():
'http://www.w3.org/2001/XMLSchema-instance' 'http://www.w3.org/2001/XMLSchema-instance'
}): }):
for tables in self.executer.get_all_tables_names(ignore_fact=True): for tables in self.executer.get_all_tables_names(
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:
with xml.row: with xml.row:
xml.CATALOG_NAME(self.selected_catalogue) xml.CATALOG_NAME(self.selected_catalogue)
xml.CUBE_NAME(self.selected_catalogue) xml.CUBE_NAME(self.selected_catalogue)
xml.DIMENSION_UNIQUE_NAME('['+tables+']') xml.DIMENSION_UNIQUE_NAME('[' + tables + ']')
xml.HIERARCHY_UNIQUE_NAME('[{0}].[{0}]'.format(tables)) xml.HIERARCHY_UNIQUE_NAME(
'[{0}].[{0}]'.format(tables))
xml.LEVEL_NAME(str(col)) xml.LEVEL_NAME(str(col))
xml.LEVEL_UNIQUE_NAME('[{0}].[{0}].[{1}]'.format(tables, col)) xml.LEVEL_UNIQUE_NAME(
'[{0}].[{0}].[{1}]'.format(tables, col))
xml.LEVEL_CAPTION(str(col)) xml.LEVEL_CAPTION(str(col))
xml.LEVEL_NUMBER(str(l_nb)) xml.LEVEL_NUMBER(str(l_nb))
xml.LEVEL_CARDINALITY('0') xml.LEVEL_CARDINALITY('0')
...@@ -1149,7 +1159,8 @@ class XmlaDiscoverTools(): ...@@ -1149,7 +1159,8 @@ class XmlaDiscoverTools():
'xmlns:xsi': 'xmlns:xsi':
'http://www.w3.org/2001/XMLSchema-instance' 'http://www.w3.org/2001/XMLSchema-instance'
}): }):
for tables in self.executer.get_all_tables_names(ignore_fact=True): for tables in self.executer.get_all_tables_names(
ignore_fact=True):
with xml.row: with xml.row:
xml.CATALOG_NAME(self.selected_catalogue) xml.CATALOG_NAME(self.selected_catalogue)
xml.CUBE_NAME(self.selected_catalogue) xml.CUBE_NAME(self.selected_catalogue)
...@@ -1159,25 +1170,33 @@ class XmlaDiscoverTools(): ...@@ -1159,25 +1170,33 @@ class XmlaDiscoverTools():
xml.DIMENSION_CARDINALITY('MANY') xml.DIMENSION_CARDINALITY('MANY')
xml.DIMENSION_IS_VISIBLE('true') xml.DIMENSION_IS_VISIBLE('true')
xml.DIMENSION_IS_FACT_DIMENSION('false') xml.DIMENSION_IS_FACT_DIMENSION('false')
xml.DIMENSION_GRANULARITY('[{0}].[{0}]'.format(tables)) xml.DIMENSION_GRANULARITY(
'[{0}].[{0}]'.format(tables))
html_parser = HTMLParser.HTMLParser() html_parser = HTMLParser.HTMLParser()
xml = html_parser.unescape(str(xml)) xml = html_parser.unescape(str(xml))
return xml return xml
def discover_mdschema_properties_response(self, request): def discover_mdschema_properties_response(self, request):
xml = xmlwitch.Builder() xml = xmlwitch.Builder()
if request.Restrictions.RestrictionList.PROPERTY_TYPE == 2 and \ if request.Restrictions.RestrictionList.PROPERTY_TYPE == 2 and \
request.Properties.PropertyList.Catalog is not None: request.Properties.PropertyList.Catalog is not None:
properties_names = ['FONT_FLAGS', 'LANGUAGE', 'style', 'ACTION_TYPE', 'FONT_SIZE', 'FORMAT_STRING', properties_names = [
'className', 'UPDATEABLE', 'BACK_COLOR', 'CELL_ORDINAL', 'FONT_NAME', 'VALUE', 'FONT_FLAGS', 'LANGUAGE', 'style', 'ACTION_TYPE', 'FONT_SIZE',
'FORMATTED_VALUE', 'FORE_COLOR'] 'FORMAT_STRING', 'className', 'UPDATEABLE', 'BACK_COLOR',
properties_captions = ['FONT_FLAGS', 'LANGUAGE', 'style', 'ACTION_TYPE', 'FONT_SIZE', 'FORMAT_STRING', 'CELL_ORDINAL', 'FONT_NAME', 'VALUE', 'FORMATTED_VALUE',
'className', 'UPDATEABLE', 'BACK_COLOR', 'CELL_ORDINAL', 'FONT_NAME', 'VALUE', 'FORE_COLOR'
'FORMATTED_VALUE', 'FORE_COLOR'] ]
properties_datas = ['3', '19', '130', '19', '18', '130', '130', '19', '19', '19', '130', '12', '130', '19'] properties_captions = [
'FONT_FLAGS', 'LANGUAGE', 'style', 'ACTION_TYPE', 'FONT_SIZE',
'FORMAT_STRING', 'className', 'UPDATEABLE', 'BACK_COLOR',
'CELL_ORDINAL', 'FONT_NAME', 'VALUE', 'FORMATTED_VALUE',
'FORE_COLOR'
]
properties_datas = [
'3', '19', '130', '19', '18', '130', '130', '19', '19', '19',
'130', '12', '130', '19'
]
self.change_catalogue(request.Properties.PropertyList.Catalog) self.change_catalogue(request.Properties.PropertyList.Catalog)
...@@ -1190,7 +1209,7 @@ class XmlaDiscoverTools(): ...@@ -1190,7 +1209,7 @@ class XmlaDiscoverTools():
'xmlns:xsi': 'xmlns:xsi':
'http://www.w3.org/2001/XMLSchema-instance' 'http://www.w3.org/2001/XMLSchema-instance'
}): }):
for idx,prop_name in enumerate(properties_names): for idx, prop_name in enumerate(properties_names):
with xml.row: with xml.row:
xml.CATALOG_NAME(self.selected_catalogue) xml.CATALOG_NAME(self.selected_catalogue)
xml.PROPERTY_TYPE('2') xml.PROPERTY_TYPE('2')
...@@ -1217,7 +1236,6 @@ class XmlaDiscoverTools(): ...@@ -1217,7 +1236,6 @@ class XmlaDiscoverTools():
xml = html_parser.unescape(str(xml)) xml = html_parser.unescape(str(xml))
return xml return xml
def discover_mdschema_members_response(self, request): def discover_mdschema_members_response(self, request):
# Enumeration of hierarchies in all dimensions # Enumeration of hierarchies in all dimensions
if request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue and \ if request.Restrictions.RestrictionList.CUBE_NAME == self.selected_catalogue and \
...@@ -1248,12 +1266,15 @@ class XmlaDiscoverTools(): ...@@ -1248,12 +1266,15 @@ class XmlaDiscoverTools():
xml.CATALOG_NAME(self.selected_catalogue) xml.CATALOG_NAME(self.selected_catalogue)
xml.CUBE_NAME(self.selected_catalogue) xml.CUBE_NAME(self.selected_catalogue)
xml.DIMENSION_UNIQUE_NAME(separed_tuple[0]) xml.DIMENSION_UNIQUE_NAME(separed_tuple[0])
xml.HIERARCHY_UNIQUE_NAME('{0}.{0}'.format(separed_tuple[0])) xml.HIERARCHY_UNIQUE_NAME(
'{0}.{0}'.format(separed_tuple[0]))
xml.LEVEL_UNIQUE_NAME(joined) xml.LEVEL_UNIQUE_NAME(joined)
xml.LEVEL_NUMBER('0') xml.LEVEL_NUMBER('0')
xml.MEMBER_ORDINAL('0') xml.MEMBER_ORDINAL('0')
xml.MEMBER_NAME(last_attribut) xml.MEMBER_NAME(last_attribut)
xml.MEMBER_UNIQUE_NAME(request.Restrictions.RestrictionList.MEMBER_UNIQUE_NAME) xml.MEMBER_UNIQUE_NAME(
request.Restrictions.RestrictionList.
MEMBER_UNIQUE_NAME)
xml.MEMBER_TYPE('1') xml.MEMBER_TYPE('1')
xml.MEMBER_CAPTION(last_attribut) xml.MEMBER_CAPTION(last_attribut)
xml.CHILDREN_CARDINALITY('1') xml.CHILDREN_CARDINALITY('1')
......
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