Skip to content

Commit bffdbce

Browse files
committed
migrate propertyName restriction from string to list
Signed-off-by: dbulahov <[email protected]>
1 parent 2c38704 commit bffdbce

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

client/soapmessage/src/main/java/org/eclipse/daanse/xmla/client/soapmessage/DiscoverConsumers.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
import org.slf4j.LoggerFactory;
7676

7777
import java.util.function.Consumer;
78-
import java.util.stream.Collectors;
7978

8079
import static org.eclipse.daanse.xmla.api.discover.discover.datasources.DiscoverDataSourcesRestrictions.RESTRICTIONS_AUTHENTICATION_MODE;
8180
import static org.eclipse.daanse.xmla.api.discover.discover.datasources.DiscoverDataSourcesRestrictions.RESTRICTIONS_DATA_SOURCE_DESCRIPTION;
@@ -200,7 +199,8 @@
200199

201200
public class DiscoverConsumers {
202201

203-
private static final Logger LOGGER = LoggerFactory.getLogger(DiscoverConsumers.class);
202+
private static final String VALUE = "Value";
203+
private static final Logger LOGGER = LoggerFactory.getLogger(DiscoverConsumers.class);
204204
private static final String NS_URI = "urn:schemas-microsoft-com:xml-analysis";
205205

206206
private DiscoverConsumers() {
@@ -675,8 +675,10 @@ static Consumer<SOAPMessage> createDiscoverPropertiesRequestConsumer(DiscoverPro
675675
SOAPElement restrictionList = discover.addChildElement(RESTRICTIONS).addChildElement(RESTRICTION_LIST);
676676

677677
if (dr.propertyName().size() > 0) {
678-
String joinedStr = dr.propertyName().stream().collect(Collectors.joining("\n", "", ""));
679-
addChildElement(restrictionList, RESTRICTIONS_PROPERTY_NAME, joinedStr);
678+
SOAPElement el = addChildElement(restrictionList, RESTRICTIONS_PROPERTY_NAME);
679+
for (String propName : dr.propertyName()) {
680+
addChildElement(el, VALUE, propName);
681+
}
680682
}
681683

682684
SOAPElement propertyList = discover.addChildElement(PROPERTIES).addChildElement(PROPERTY_LIST);

client/soapmessage/src/main/java/org/eclipse/daanse/xmla/client/soapmessage/SoapUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2832,7 +2832,7 @@ static void addChildElement(SOAPElement element, String childElementName, String
28322832
}
28332833
}
28342834

2835-
private static SOAPElement addChildElement(SOAPElement element, String childElementName) {
2835+
static SOAPElement addChildElement(SOAPElement element, String childElementName) {
28362836
try {
28372837
return element.addChildElement(childElementName);
28382838
} catch (SOAPException e) {

server/adapter.soapmessage/src/main/java/org/eclipse/daanse/xmla/server/adapter/soapmessage/Convert.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@
1919
import java.time.Duration;
2020
import java.time.Instant;
2121
import java.util.ArrayList;
22-
import java.util.Arrays;
2322
import java.util.HashMap;
2423
import java.util.Iterator;
2524
import java.util.List;
2625
import java.util.Map;
2726
import java.util.Optional;
2827

29-
import jakarta.xml.soap.SOAPHeader;
30-
import org.eclipse.daanse.xmla.api.common.enums.ActionTypeEnum;
3128
import org.eclipse.daanse.xmla.api.common.enums.AuthenticationModeEnum;
3229
import org.eclipse.daanse.xmla.api.common.enums.ColumnOlapTypeEnum;
3330
import org.eclipse.daanse.xmla.api.common.enums.CoordinateTypeEnum;
@@ -114,13 +111,12 @@ private Convert() {
114111
}
115112

116113
public static DiscoverPropertiesRestrictionsR discoverPropertiesRestrictions(SOAPElement restriction) {
117-
Map<String, String> m = getMapValuesByTag(restriction, RESTRICTION_LIST);
118-
String propertyName = m.get(PROPERTY_NAME);
119-
if (propertyName != null) {
120-
String[] properties = propertyName.split("\\n");
121-
return new DiscoverPropertiesRestrictionsR(Arrays.stream(properties).map(s -> s.trim()).filter(s -> s.length() > 0).toList());
114+
NodeList nodeList = restriction.getElementsByTagName(RESTRICTION_LIST);
115+
List<String> pnList = new ArrayList<>();
116+
if (nodeList != null && nodeList.getLength() > 0 && nodeList.item(0) instanceof SOAPElement sEl) {
117+
pnList = getValuesByTag(sEl, PROPERTY_NAME);
122118
}
123-
return new DiscoverPropertiesRestrictionsR(List.of());
119+
return new DiscoverPropertiesRestrictionsR(pnList);
124120
}
125121

126122
public static PropertiesR propertiestoProperties(SOAPElement propertiesElement) {
@@ -7456,6 +7452,27 @@ private static Map<String, String> getMapValuesByTag(SOAPElement el, String tagN
74567452
return Map.of();
74577453
}
74587454

7455+
private static List<String> getValuesByTag(SOAPElement el, String tagName) {
7456+
NodeList nodeList = el.getElementsByTagName(tagName);
7457+
7458+
if (nodeList != null && nodeList.getLength() > 0) {
7459+
return getValues(nodeList.item(0).getChildNodes());
7460+
}
7461+
return List.of();
7462+
}
7463+
7464+
private static List<String> getValues(NodeList nl) {
7465+
List<String> result = new ArrayList<>();
7466+
for (int i = 0; i < nl.getLength(); i++) {
7467+
org.w3c.dom.Node n = nl.item(i);
7468+
String val = n.getTextContent().trim();
7469+
if (val.length() > 0) {
7470+
result.add(val);
7471+
}
7472+
}
7473+
return result;
7474+
}
7475+
74597476
private static Map<String, String> getMapValues(NodeList nl) {
74607477
Map<String, String> result = new HashMap<>();
74617478
for (int i = 0; i < nl.getLength(); i++) {

0 commit comments

Comments
 (0)