diff --git a/server/adapter.soapmessage/src/main/java/org/eclipse/daanse/xmla/server/adapter/soapmessage/Convert.java b/server/adapter.soapmessage/src/main/java/org/eclipse/daanse/xmla/server/adapter/soapmessage/Convert.java index fb4caae..ca3f129 100644 --- a/server/adapter.soapmessage/src/main/java/org/eclipse/daanse/xmla/server/adapter/soapmessage/Convert.java +++ b/server/adapter.soapmessage/src/main/java/org/eclipse/daanse/xmla/server/adapter/soapmessage/Convert.java @@ -189,7 +189,7 @@ private static PropertiesR propertyListToProperties(SOAPElement propertyList) { } public static MdSchemaFunctionsRestrictionsR discoverMdSchemaFunctionsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaFunctionsRestrictionsR( Optional.ofNullable(m.get(FUNCTION_NAME)), Optional.ofNullable(OriginEnum.fromValue(m.get(ORIGIN))), @@ -200,7 +200,7 @@ public static MdSchemaFunctionsRestrictionsR discoverMdSchemaFunctionsRestrictio public static MdSchemaDimensionsRestrictionsR discoverMdSchemaDimensionsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaDimensionsRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), @@ -213,7 +213,7 @@ public static MdSchemaDimensionsRestrictionsR discoverMdSchemaDimensionsRestrict } public static MdSchemaCubesRestrictionsR discoverMdSchemaCubesRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaCubesRestrictionsR(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CUBE_NAME)), @@ -223,7 +223,7 @@ public static MdSchemaCubesRestrictionsR discoverMdSchemaCubesRestrictions(SOAPE } public static MdSchemaMeasureGroupsRestrictionsR discoverMdSchemaMeasureGroups(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaMeasureGroupsRestrictionsR(Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CUBE_NAME)), @@ -232,7 +232,7 @@ public static MdSchemaMeasureGroupsRestrictionsR discoverMdSchemaMeasureGroups(S } public static MdSchemaKpisRestrictionsR discoverMdSchemaKpisRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaKpisRestrictionsR(Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CUBE_NAME)), @@ -242,7 +242,7 @@ public static MdSchemaKpisRestrictionsR discoverMdSchemaKpisRestrictions(SOAPEle } public static MdSchemaSetsRestrictionsR discoverMdSchemaSetsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaSetsRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), @@ -256,7 +256,7 @@ public static MdSchemaSetsRestrictionsR discoverMdSchemaSetsRestrictions(SOAPEle } public static MdSchemaPropertiesRestrictionsR discoverMdSchemaPropertiesRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaPropertiesRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), @@ -275,7 +275,7 @@ public static MdSchemaPropertiesRestrictionsR discoverMdSchemaPropertiesRestrict } public static MdSchemaMembersRestrictionsR discoverMdSchemaMembersRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaMembersRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), @@ -294,7 +294,7 @@ public static MdSchemaMembersRestrictionsR discoverMdSchemaMembersRestrictions(S } public static MdSchemaMeasuresRestrictionsR discoverMdSchemaMeasuresRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaMeasuresRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), @@ -310,7 +310,7 @@ public static MdSchemaMeasuresRestrictionsR discoverMdSchemaMeasuresRestrictions public static MdSchemaMeasureGroupDimensionsRestrictionsR discoverMdSchemaMeasureGroupDimensionsRestrictions( SOAPElement restriction ) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaMeasureGroupDimensionsRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), @@ -322,7 +322,7 @@ public static MdSchemaMeasureGroupDimensionsRestrictionsR discoverMdSchemaMeasur } public static MdSchemaLevelsRestrictionsR discoverMdSchemaLevelsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaLevelsRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), @@ -340,7 +340,7 @@ public static MdSchemaLevelsRestrictionsR discoverMdSchemaLevelsRestrictions(SOA } public static MdSchemaHierarchiesRestrictionsR discoverMdSchemaHierarchiesRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaHierarchiesRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), @@ -356,7 +356,7 @@ public static MdSchemaHierarchiesRestrictionsR discoverMdSchemaHierarchiesRestri public static DbSchemaTablesInfoRestrictionsR discoverDbSchemaTablesInfo(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DbSchemaTablesInfoRestrictionsR( Optional.ofNullable(m.get(TABLE_CATALOG)), Optional.ofNullable(m.get(TABLE_SCHEMA)), @@ -366,7 +366,7 @@ public static DbSchemaTablesInfoRestrictionsR discoverDbSchemaTablesInfo(SOAPEle } public static DbSchemaSourceTablesRestrictionsR discoverDbSchemaSourceTablesRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DbSchemaSourceTablesRestrictionsR( Optional.ofNullable(m.get(TABLE_CATALOG)), Optional.ofNullable(m.get(TABLE_SCHEMA)), @@ -376,7 +376,7 @@ public static DbSchemaSourceTablesRestrictionsR discoverDbSchemaSourceTablesRest } public static DbSchemaSchemataRestrictionsR discoverDbSchemaSchemataRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DbSchemaSchemataRestrictionsR( m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME), m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME), @@ -385,7 +385,7 @@ public static DbSchemaSchemataRestrictionsR discoverDbSchemaSchemataRestrictions } public static DbSchemaProviderTypesRestrictionsR discoverDbSchemaProviderTypesRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DbSchemaProviderTypesRestrictionsR( Optional.ofNullable(LevelDbTypeEnum.fromValue(m.get(DATA_TYPE))), Optional.ofNullable(Boolean.valueOf(m.get(BEST_MATCH))) @@ -393,7 +393,7 @@ public static DbSchemaProviderTypesRestrictionsR discoverDbSchemaProviderTypesRe } public static DbSchemaColumnsRestrictionsR discoverDbSchemaColumnsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DbSchemaColumnsRestrictionsR( Optional.ofNullable(m.get(TABLE_CATALOG)), Optional.ofNullable(m.get(TABLE_SCHEMA)), @@ -404,7 +404,7 @@ public static DbSchemaColumnsRestrictionsR discoverDbSchemaColumnsRestrictions(S } public static DiscoverXmlMetaDataRestrictionsR discoverDiscoverXmlMetaDataRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DiscoverXmlMetaDataRestrictionsR( Optional.ofNullable(m.get(OBJECT_TYPE)), Optional.ofNullable(m.get(DATABASE_ID)), @@ -433,7 +433,7 @@ public static DiscoverXmlMetaDataRestrictionsR discoverDiscoverXmlMetaDataRestri } public static DiscoverDataSourcesRestrictionsR discoverDiscoverDataSourcesRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DiscoverDataSourcesRestrictionsR( m.get(DATA_SOURCE_NAME), Optional.ofNullable(m.get(DATA_SOURCE_DESCRIPTION)), @@ -446,42 +446,42 @@ public static DiscoverDataSourcesRestrictionsR discoverDiscoverDataSourcesRestri } public static DbSchemaCatalogsRestrictionsR discoverDbSchemaCatalogsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DbSchemaCatalogsRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)) ); } public static DiscoverSchemaRowsetsRestrictionsR discoverSchemaRowsetsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DiscoverSchemaRowsetsRestrictionsR( Optional.ofNullable(m.get(SCHEMA_NAME_LOW)) ); } public static DiscoverEnumeratorsRestrictionsR discoverDiscoverEnumerators(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DiscoverEnumeratorsRestrictionsR( Optional.ofNullable(m.get(ENUM_NAME)) ); } public static DiscoverKeywordsRestrictionsR discoverKeywordsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DiscoverKeywordsRestrictionsR( Optional.ofNullable(m.get(KEYWORD)) ); } public static DiscoverLiteralsRestrictionsR discoverLiteralsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DiscoverLiteralsRestrictionsR( Optional.ofNullable(m.get(LITERAL_NAME)) ); } public static DbSchemaTablesRestrictionsR discoverDbSchemaTablesRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new DbSchemaTablesRestrictionsR( Optional.ofNullable(m.get(TABLE_CATALOG)), Optional.ofNullable(m.get(TABLE_SCHEMA)), @@ -492,7 +492,7 @@ public static DbSchemaTablesRestrictionsR discoverDbSchemaTablesRestrictions(SOA public static MdSchemaActionsRestrictionsR discoverMdSchemaActionsRestrictions(SOAPElement restriction) { - Map m = getMapValuesByTag(restriction, RESTRICTION_LIST); + Map m = getRestrictionMap(restriction); return new MdSchemaActionsRestrictionsR( Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.CATALOG_NAME)), Optional.ofNullable(m.get(Constants.ROWSET.ROW_PROPERTY.SCHEMA_NAME)), @@ -7478,14 +7478,32 @@ private static AggregationDesignAttribute getAggregationDesignAttribute(NodeList return new AggregationDesignAttributeR(attributeID, Optional.ofNullable(estimatedCount)); } - private static Map getMapValuesByTag(SOAPElement el, String tagName) { - NodeList nodeList = el.getElementsByTagName(tagName); - if (nodeList != null && nodeList.getLength() > 0) { - return getMapValues(nodeList.item(0).getChildNodes()); + private static Map getRestrictionMap(SOAPElement el) { + Iterator nodeIterator = el.getChildElements(); + while (nodeIterator.hasNext()) { + Node node = nodeIterator.next(); + if (node instanceof SOAPElement restrictions + && Constants.MSXMLA.QN_RESTRICTION_LIST.equals(restrictions.getElementQName())) { + return restrictionValues(restrictions); + } + } return Map.of(); } + private static Map restrictionValues(SOAPElement restrictionList) { + Map result = new HashMap<>(); + Iterator nodeIteratorRestrictionList = restrictionList.getChildElements(); + while (nodeIteratorRestrictionList.hasNext()) { + Node n = nodeIteratorRestrictionList.next(); + if (n instanceof SOAPElement restrictionListElement) { + String name = restrictionListElement.getLocalName(); + result.put(name, restrictionListElement.getTextContent()); + } + } + return result; + } + private static List getValuesByTag(SOAPElement el, String tagName) { NodeList nodeList = el.getElementsByTagName(tagName);