Commit 04472a0d authored by mouadh's avatar mouadh

xmlwitch

parent af02a983
......@@ -311,56 +311,103 @@ class XmlaDiscoverTools():
if request.Restrictions.RestrictionList.SchemaName == "MDSCHEMA_HIERARCHIES" and \
request.Properties.PropertyList.Catalog is not None:
self.change_catalogue(request.Properties.PropertyList.Catalog)
return etree.fromstring("""
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
""" + discover_schema_rowsets_xsd + """
<row>
<SchemaName>MDSCHEMA_HIERARCHIES</SchemaName>
<SchemaGuid>C8B522DA-5CF3-11CE-ADE5-00AA0044773D</SchemaGuid>
<Restrictions>
<Name>CATALOG_NAME</Name>
<Type>string</Type>
</Restrictions>
<Restrictions>
<Name>SCHEMA_NAME</Name>
<Type>string</Type>
</Restrictions>
<Restrictions>
<Name>CUBE_NAME</Name>
<Type>string</Type>
</Restrictions>
<Restrictions>
<Name>DIMENSION_UNIQUE_NAME</Name>
<Type>string</Type>
</Restrictions>
<Restrictions>
<Name>HIERARCHY_NAME</Name>
<Type>string</Type>
</Restrictions>
<Restrictions>
<Name>HIERARCHY_UNIQUE_NAME</Name>
<Type>string</Type>
</Restrictions>
<Restrictions>
<Name>HIERARCHY_ORIGIN</Name>
<Type>unsignedShort</Type>
</Restrictions>
<Restrictions>
<Name>CUBE_SOURCE</Name>
<Type>unsignedShort</Type>
</Restrictions>
<Restrictions>
<Name>HIERARCHY_VISIBILITY</Name>
<Type>unsignedShort</Type>
</Restrictions>
<RestrictionsMask>511</RestrictionsMask>
</row>
</root>
</return>
""")
restriction_names = ['CATALOG_NAME',
'SCHEMA_NAME',
'CUBE_NAME',
'DIMENSION_UNIQUE_NAME',
'HIERARCHY_NAME',
'HIERARCHY_UNIQUE_NAME',
'HIERARCHY_ORIGIN',
'CUBE_SOURCE',
'HIERARCHY_VISIBILITY']
restriction_types = ['string',
'string',
'string',
'string',
'string',
'string',
'unsignedShort',
'unsignedShort',
'unsignedShort']
xml = xmlwitch.Builder()
with xml.root(str(discover_schema_rowsets_xsd), xmlns="urn:schemas-microsoft-com:xml-analysis:rowset",
**{'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance'}):
for idx, restriction in enumerate(restriction_names):
with xml.row:
xml.SchemaName('MDSCHEMA_HIERARCHIES')
xml.SchemaGuid('C8B522DA-5CF3-11CE-ADE5-00AA0044773D')
with xml.Restrictions:
xml.Name(restriction)
xml.Type(restriction_types[idx])
# todo fix this
# xml.RestrictionsMask('511')
html_parser = HTMLParser.HTMLParser()
xml = html_parser.unescape(str(xml))
return """
<return>
{0}
</return>
""".format(xml)
# return etree.fromstring("""
# <return>
# <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
# xmlns:xsd="http://www.w3.org/2001/XMLSchema"
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
# """ + discover_schema_rowsets_xsd + """
# <row>
# <SchemaName>MDSCHEMA_HIERARCHIES</SchemaName>
# <SchemaGuid>C8B522DA-5CF3-11CE-ADE5-00AA0044773D</SchemaGuid>
# <Restrictions>
# <Name>CATALOG_NAME</Name>
# <Type>string</Type>
# </Restrictions>
# <Restrictions>
# <Name>SCHEMA_NAME</Name>
# <Type>string</Type>
# </Restrictions>
# <Restrictions>
# <Name>CUBE_NAME</Name>
# <Type>string</Type>
# </Restrictions>
# <Restrictions>
# <Name>DIMENSION_UNIQUE_NAME</Name>
# <Type>string</Type>
# </Restrictions>
# <Restrictions>
# <Name>HIERARCHY_NAME</Name>
# <Type>string</Type>
# </Restrictions>
# <Restrictions>
# <Name>HIERARCHY_UNIQUE_NAME</Name>
# <Type>string</Type>
# </Restrictions>
# <Restrictions>
# <Name>HIERARCHY_ORIGIN</Name>
# <Type>unsignedShort</Type>
# </Restrictions>
# <Restrictions>
# <Name>CUBE_SOURCE</Name>
# <Type>unsignedShort</Type>
# </Restrictions>
# <Restrictions>
# <Name>HIERARCHY_VISIBILITY</Name>
# <Type>unsignedShort</Type>
# </Restrictions>
# <RestrictionsMask>511</RestrictionsMask>
# </row>
# </root>
# </return>
# """)
if request.Restrictions.RestrictionList.SchemaName == 'MDSCHEMA_MEASURES' and \
request.Properties.PropertyList.Catalog is not None:
self.change_catalogue(request.Properties.PropertyList.Catalog)
......
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