Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import org.slf4j.LoggerFactory;

import java.util.function.Consumer;
import java.util.stream.Collectors;

import static org.eclipse.daanse.xmla.api.discover.discover.datasources.DiscoverDataSourcesRestrictions.RESTRICTIONS_AUTHENTICATION_MODE;
import static org.eclipse.daanse.xmla.api.discover.discover.datasources.DiscoverDataSourcesRestrictions.RESTRICTIONS_DATA_SOURCE_DESCRIPTION;
Expand Down Expand Up @@ -200,7 +199,8 @@

public class DiscoverConsumers {

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

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

if (dr.propertyName().size() > 0) {
String joinedStr = dr.propertyName().stream().collect(Collectors.joining("\n", "", ""));
addChildElement(restrictionList, RESTRICTIONS_PROPERTY_NAME, joinedStr);
SOAPElement el = addChildElement(restrictionList, RESTRICTIONS_PROPERTY_NAME);
for (String propName : dr.propertyName()) {
addChildElement(el, VALUE, propName);
}
}

SOAPElement propertyList = discover.addChildElement(PROPERTIES).addChildElement(PROPERTY_LIST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2832,7 +2832,7 @@ static void addChildElement(SOAPElement element, String childElementName, String
}
}

private static SOAPElement addChildElement(SOAPElement element, String childElementName) {
static SOAPElement addChildElement(SOAPElement element, String childElementName) {
try {
return element.addChildElement(childElementName);
} catch (SOAPException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import jakarta.xml.soap.SOAPHeader;
import org.eclipse.daanse.xmla.api.common.enums.ActionTypeEnum;
import org.eclipse.daanse.xmla.api.common.enums.AuthenticationModeEnum;
import org.eclipse.daanse.xmla.api.common.enums.ColumnOlapTypeEnum;
import org.eclipse.daanse.xmla.api.common.enums.CoordinateTypeEnum;
Expand Down Expand Up @@ -114,13 +111,12 @@ private Convert() {
}

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

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

private static List<String> getValuesByTag(SOAPElement el, String tagName) {
NodeList nodeList = el.getElementsByTagName(tagName);

if (nodeList != null && nodeList.getLength() > 0) {
return getValues(nodeList.item(0).getChildNodes());
}
return List.of();
}

private static List<String> getValues(NodeList nl) {
List<String> result = new ArrayList<>();
for (int i = 0; i < nl.getLength(); i++) {
org.w3c.dom.Node n = nl.item(i);
String val = n.getTextContent().trim();
if (val.length() > 0) {
result.add(val);
}
}
return result;
}

private static Map<String, String> getMapValues(NodeList nl) {
Map<String, String> result = new HashMap<>();
for (int i = 0; i < nl.getLength(); i++) {
Expand Down
Loading