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
8ea06bc8
Commit
8ea06bc8
authored
Jul 24, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmlwitch
parent
8c647126
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
120 deletions
+62
-120
olapy/core/services/xmla_execute_tools.py
olapy/core/services/xmla_execute_tools.py
+62
-120
No files found.
olapy/core/services/xmla_execute_tools.py
View file @
8ea06bc8
...
@@ -89,7 +89,7 @@ class XmlaExecuteTools():
...
@@ -89,7 +89,7 @@ class XmlaExecuteTools():
:param splited_df:
:param splited_df:
:return:
:return:
"""
"""
# axis0 = ""
xml
=
xmlwitch
.
Builder
()
xml
=
xmlwitch
.
Builder
()
# only measure selected
# only measure selected
if
mdx_execution_result
[
'columns_desc'
][
mdx_query_axis
].
keys
()
==
[
if
mdx_execution_result
[
'columns_desc'
][
mdx_query_axis
].
keys
()
==
[
...
@@ -130,8 +130,10 @@ class XmlaExecuteTools():
...
@@ -130,8 +130,10 @@ class XmlaExecuteTools():
]
]
first_att
=
3
first_att
=
3
if
tuples
:
with
xml
.
Axis
(
name
=
axis
):
with
xml
.
Tuples
:
for
tupls
in
itertools
.
chain
(
*
tuples
):
for
tupls
in
itertools
.
chain
(
*
tuples
):
# axis0 += "<Tuple>\n"
with
xml
.
Tuple
:
with
xml
.
Tuple
:
if
tupls
[
0
][
1
]
in
self
.
executer
.
measures
and
len
(
if
tupls
[
0
][
1
]
in
self
.
executer
.
measures
and
len
(
self
.
executer
.
selected_measures
)
>
1
:
self
.
executer
.
selected_measures
)
>
1
:
...
@@ -143,20 +145,7 @@ class XmlaExecuteTools():
...
@@ -143,20 +145,7 @@ class XmlaExecuteTools():
xml
.
DisplayInfo
(
'0'
)
xml
.
DisplayInfo
(
'0'
)
xml
.
HIERARCHY_UNIQUE_NAME
(
'[Measures]'
)
xml
.
HIERARCHY_UNIQUE_NAME
(
'[Measures]'
)
# axis0 += """
# <Member Hierarchy="[Measures]">
# <UName>[Measures].[{0}]</UName>
# <Caption>{0}</Caption>
# <LName>[Measures]</LName>
# <LNum>0</LNum>
# <DisplayInfo>0</DisplayInfo>
# <HIERARCHY_UNIQUE_NAME>[Measures]</HIERARCHY_UNIQUE_NAME>
# </Member>
# """.format(tupls[0][1])
if
tupls
[
0
][
-
1
]
in
self
.
executer
.
measures
:
if
tupls
[
0
][
-
1
]
in
self
.
executer
.
measures
:
# tocom
# axis0 += "</Tuple>\n"
continue
continue
for
tupl
in
tupls
:
for
tupl
in
tupls
:
...
@@ -174,9 +163,11 @@ class XmlaExecuteTools():
...
@@ -174,9 +163,11 @@ class XmlaExecuteTools():
with
xml
.
Member
(
Hierarchy
=
"[{0}].[{0}]"
.
format
(
tuple_without_minus_1
[
0
])):
with
xml
.
Member
(
Hierarchy
=
"[{0}].[{0}]"
.
format
(
tuple_without_minus_1
[
0
])):
xml
.
UName
(
'[{0}].[{0}].[{1}].{2}'
.
format
(
tuple_without_minus_1
[
0
],
xml
.
UName
(
'[{0}].[{0}].[{1}].{2}'
.
format
(
tuple_without_minus_1
[
0
],
splited_df
[
tuple_without_minus_1
[
splited_df
[
tuple_without_minus_1
[
0
]].
columns
[
len
(
tuple_without_minus_1
)
-
first_att
],
0
]].
columns
[
len
(
tuple_without_minus_1
)
-
first_att
],
'.'
.
join
([
'['
+
str
(
i
)
+
']'
for
i
in
'.'
.
join
([
'['
+
str
(
i
)
+
']'
for
i
in
tuple_without_minus_1
[
first_att
-
1
:]
tuple_without_minus_1
[
first_att
-
1
:]
])))
])))
xml
.
Caption
(
'{0}'
.
format
(
tuple_without_minus_1
[
-
1
]))
xml
.
Caption
(
'{0}'
.
format
(
tuple_without_minus_1
[
-
1
]))
xml
.
LName
(
'[{0}].[{0}].[{1}]'
.
format
(
xml
.
LName
(
'[{0}].[{0}].[{1}]'
.
format
(
...
@@ -185,21 +176,7 @@ class XmlaExecuteTools():
...
@@ -185,21 +176,7 @@ class XmlaExecuteTools():
xml
.
LNum
(
'{0}'
.
format
(
len
(
tuple_without_minus_1
)
-
first_att
))
xml
.
LNum
(
'{0}'
.
format
(
len
(
tuple_without_minus_1
)
-
first_att
))
xml
.
DisplayInfo
(
'131076'
)
xml
.
DisplayInfo
(
'131076'
)
# axis0 += """
# PARENT_UNIQUE_NAME must be before HIERARCHY_UNIQUE_NAME (todo change it in xsd)
# <Member Hierarchy="[{0}].[{0}]">
# <UName>[{0}].[{0}].[{1}].{2}</UName>
# <Caption>{3}</Caption>
# <LName>[{0}].[{0}].[{1}]</LName>
# <LNum>{4}</LNum>
# <DisplayInfo>131076</DisplayInfo>""".format(
# tuple_without_minus_1[0], splited_df[tuple_without_minus_1[
# 0]].columns[len(tuple_without_minus_1) - first_att],
# '.'.join([
# '[' + str(i) + ']'
# for i in tuple_without_minus_1[first_att - 1:]
# ]), tuple_without_minus_1[-1],
# len(tuple_without_minus_1) - first_att)
# PARENT_UNIQUE_NAME must be before HIERARCHY_UNIQUE_NAME
if
len
(
tuple_without_minus_1
[
first_att
-
1
:])
>
1
:
if
len
(
tuple_without_minus_1
[
first_att
-
1
:])
>
1
:
xml
.
PARENT_UNIQUE_NAME
(
'[{0}].[{0}].[{1}].{2}'
.
format
(
xml
.
PARENT_UNIQUE_NAME
(
'[{0}].[{0}].[{1}].{2}'
.
format
(
tuple_without_minus_1
[
0
],
tuple_without_minus_1
[
0
],
...
@@ -208,44 +185,9 @@ class XmlaExecuteTools():
...
@@ -208,44 +185,9 @@ class XmlaExecuteTools():
'['
+
str
(
i
)
+
']'
'['
+
str
(
i
)
+
']'
for
i
in
tuple_without_minus_1
[
first_att
-
1
:
-
1
]
for
i
in
tuple_without_minus_1
[
first_att
-
1
:
-
1
]
])))
])))
# axis0 += """
# <PARENT_UNIQUE_NAME>[{0}].[{0}].[{1}].{2}</PARENT_UNIQUE_NAME>""".format(
# tuple_without_minus_1[0],
# splited_df[tuple_without_minus_1[0]].columns[0],
# '.'.join([
# '[' + str(i) + ']'
# for i in tuple_without_minus_1[first_att - 1:-1]
# ]))
xml
.
HIERARCHY_UNIQUE_NAME
(
'[{0}].[{0}]'
.
format
(
tuple_without_minus_1
[
0
]))
xml
.
HIERARCHY_UNIQUE_NAME
(
'[{0}].[{0}]'
.
format
(
tuple_without_minus_1
[
0
]))
# axis0 += """
# <HIERARCHY_UNIQUE_NAME>[{0}].[{0}]</HIERARCHY_UNIQUE_NAME>
# </Member>
# """.format(tuple_without_minus_1[0])
# axis0 += "</Tuple>\n"
print
(
xml
)
print
(
type
(
xml
))
print
(
str
(
xml
)
==
''
)
if
str
(
xml
)
!=
''
:
xml
=
"""
<Axis name="{0}">
<Tuples>
{1}
</Tuples>
</Axis>
"""
.
format
(
axis
,
str
(
xml
))
# if axis0:
# axis0 = """
# <Axis name="{0}">
# <Tuples>
# {1}
# </Tuples>
# </Axis>
# """.format(axis, axis0)
print
(
xml
)
return
str
(
xml
)
return
str
(
xml
)
def
generate_xs0
(
self
,
mdx_execution_result
):
def
generate_xs0
(
self
,
mdx_execution_result
):
...
...
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