Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
olapy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
olapy
Commits
c43be567
Commit
c43be567
authored
May 03, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid consecutive if-statements
parent
d9973b89
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
501 additions
and
494 deletions
+501
-494
olapy/core/services/xmla_discover_tools.py
olapy/core/services/xmla_discover_tools.py
+501
-494
No files found.
olapy/core/services/xmla_discover_tools.py
View file @
c43be567
...
...
@@ -1520,8 +1520,9 @@ class XmlaDiscoverTools():
"""
)
def
discover_literals_response
(
self
,
request
):
if
request
.
Properties
.
PropertyList
.
Content
==
'SchemaData'
:
if
request
.
Properties
.
PropertyList
.
Format
==
'Tabular'
:
if
request
.
Properties
.
PropertyList
.
Content
==
'SchemaData'
\
and
request
.
Properties
.
PropertyList
.
Format
==
'Tabular'
:
return
etree
.
fromstring
(
"""
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
...
...
@@ -1645,8 +1646,9 @@ class XmlaDiscoverTools():
"""
)
def
discover_mdschema_sets_response
(
self
,
request
):
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
\
and
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
return
etree
.
fromstring
(
"""
<return>
...
...
@@ -1659,8 +1661,9 @@ class XmlaDiscoverTools():
"""
)
def
discover_mdschema_kpis_response
(
self
,
request
):
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
\
and
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
return
etree
.
fromstring
(
"""
<return>
...
...
@@ -1693,8 +1696,8 @@ class XmlaDiscoverTools():
"""
.
format
(
_catalogues
))
def
discover_mdschema_cubes_response
(
self
,
request
):
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
\
and
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
if
request
.
Restrictions
.
RestrictionList
.
CATALOG_NAME
==
self
.
selected_catalogue
:
return
etree
.
fromstring
(
"""
...
...
@@ -1785,11 +1788,11 @@ class XmlaDiscoverTools():
def
discover_mdschema_measures__response
(
self
,
request
):
measures
=
""
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Restrictions
.
RestrictionList
.
MEASURE_VISIBILITY
==
3
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
and
\
request
.
Restrictions
.
RestrictionList
.
MEASURE_VISIBILITY
==
3
and
\
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
for
mes
in
self
.
executer
.
measures
:
measures
+=
"""
<row>
...
...
@@ -1809,6 +1812,7 @@ class XmlaDiscoverTools():
</row>
"""
.
format
(
self
.
selected_catalogue
,
self
.
selected_catalogue
,
mes
)
return
etree
.
fromstring
(
"""
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
...
...
@@ -1821,21 +1825,19 @@ class XmlaDiscoverTools():
"""
.
format
(
measures
))
def
discover_mdschema_dimensions_response
(
self
,
request
):
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Restrictions
.
RestrictionList
.
CATALOG_NAME
==
self
.
selected_catalogue
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
and
\
request
.
Restrictions
.
RestrictionList
.
CATALOG_NAME
==
self
.
selected_catalogue
and
\
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
rows
=
""
ord
=
1
for
tables
in
self
.
executer
.
get_all_tables_names
(
ignore_fact
=
True
):
for
tables
in
self
.
executer
.
get_all_tables_names
(
ignore_fact
=
True
):
# TODO in another idea, change this
# TO CHANGE NAME DISPLAY THAT EXISTS IN CONFIG FILE
if
MdxEngine
.
dimension_display_name
!=
[]:
if
tables
in
MdxEngine
.
dimension_display_name
:
if
MdxEngine
.
dimension_display_name
!=
[]
and
tables
in
MdxEngine
.
dimension_display_name
:
continue
rows
+=
"""
<row>
...
...
@@ -1884,13 +1886,13 @@ class XmlaDiscoverTools():
def
discover_mdschema_hierarchies_response
(
self
,
request
):
# Enumeration of hierarchies in all dimensions
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
and
\
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
if
request
.
Restrictions
.
RestrictionList
.
HIERARCHY_VISIBILITY
==
3
:
rows
=
""
for
table_name
,
df
in
self
.
executer
.
tables_loaded
.
items
():
# column = XmlaProvider.executer.get_columns_to_index(tables, 1, 0)[0]
if
table_name
==
self
.
executer
.
facts
:
continue
rows
+=
"""
...
...
@@ -1917,7 +1919,6 @@ class XmlaDiscoverTools():
</row>
"""
.
format
(
self
.
selected_catalogue
,
table_name
,
df
.
columns
[
0
],
df
.
iloc
[
0
][
0
])
# self.executer.get_attribute_column_rm_id(tables, column, 0))
rows
+=
"""
<row>
...
...
@@ -1954,6 +1955,7 @@ class XmlaDiscoverTools():
</root>
</return>
"""
.
format
(
rows
))
if
request
.
Restrictions
.
RestrictionList
.
CATALOG_NAME
==
self
.
selected_catalogue
:
rows
=
""
for
table_name
,
df
in
self
.
executer
.
tables_loaded
.
items
():
...
...
@@ -2019,11 +2021,11 @@ class XmlaDiscoverTools():
def
discover_mdschema_levels__response
(
self
,
request
):
# TODO fix levels in the same table (with xml file maybe) !!!!!!!!!
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Restrictions
.
RestrictionList
.
CATALOG_NAME
==
self
.
selected_catalogue
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
and
\
request
.
Restrictions
.
RestrictionList
.
CATALOG_NAME
==
self
.
selected_catalogue
and
\
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
rows
=
""
for
tables
in
self
.
executer
.
get_all_tables_names
(
ignore_fact
=
True
):
...
...
@@ -2084,8 +2086,9 @@ class XmlaDiscoverTools():
</return>"""
.
format
(
rows
))
def
discover_mdschema_measuresgroups_response
(
self
,
request
):
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
and
\
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
return
etree
.
fromstring
(
"""
<return>
...
...
@@ -2106,8 +2109,9 @@ class XmlaDiscoverTools():
"""
.
format
(
self
.
selected_catalogue
))
def
discover_mdschema_measuresgroups_dimensions_response
(
self
,
request
):
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
and
\
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
rows
=
""
for
tables
in
self
.
executer
.
get_all_tables_names
(
...
...
@@ -2138,8 +2142,10 @@ class XmlaDiscoverTools():
"""
.
format
(
rows
))
def
discover_mdschema_properties_response
(
self
,
request
):
if
request
.
Restrictions
.
RestrictionList
.
PROPERTY_TYPE
==
2
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
if
request
.
Restrictions
.
RestrictionList
.
PROPERTY_TYPE
==
2
and
\
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
return
etree
.
fromstring
(
"""
<return>
...
...
@@ -2249,6 +2255,7 @@ class XmlaDiscoverTools():
</return>
"""
.
format
(
self
.
selected_catalogue
,
mdschema_properties_properties_xsd
))
elif
request
.
Restrictions
.
RestrictionList
.
PROPERTY_TYPE
==
1
:
return
etree
.
fromstring
(
"""
<return>
...
...
@@ -2262,10 +2269,11 @@ class XmlaDiscoverTools():
def
discover_mdschema_members_response
(
self
,
request
):
# Enumeration of hierarchies in all dimensions
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
if
request
.
Restrictions
.
RestrictionList
.
CUBE_NAME
==
self
.
selected_catalogue
and
\
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
and
\
request
.
Restrictions
.
RestrictionList
.
TREE_OP
==
8
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
if
request
.
Restrictions
.
RestrictionList
.
TREE_OP
==
8
:
separed_tuple
=
request
.
Restrictions
.
RestrictionList
.
MEMBER_UNIQUE_NAME
.
split
(
"."
)
joined
=
"."
.
join
(
separed_tuple
[:
-
1
])
...
...
@@ -2293,8 +2301,7 @@ class XmlaDiscoverTools():
<MEMBER_NAME>"""
+
last_attribut
+
"""</MEMBER_NAME>
<MEMBER_UNIQUE_NAME>{3}</MEMBER_UNIQUE_NAME>
<MEMBER_TYPE>1</MEMBER_TYPE>
<MEMBER_CAPTION>"""
+
last_attribut
+
"""</MEMBER_CAPTION>
<MEMBER_CAPTION>"""
+
last_attribut
+
"""</MEMBER_CAPTION>
<CHILDREN_CARDINALITY>1</CHILDREN_CARDINALITY>
<PARENT_LEVEL>0</PARENT_LEVEL>
<PARENT_COUNT>0</PARENT_COUNT>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment