Skip to content
Snippets Groups Projects
Commit 7c16fed9 authored by OZG-Cloud Team's avatar OZG-Cloud Team
Browse files

OZG-5808 Xdomea: Simplify xpath expression for xmlcode

parent 17018bd7
No related branches found
No related tags found
No related merge requests found
...@@ -22,28 +22,15 @@ import de.ozgcloud.eingang.common.formdata.IncomingFile; ...@@ -22,28 +22,15 @@ import de.ozgcloud.eingang.common.formdata.IncomingFile;
public class XdomeaXMLValueReader { public class XdomeaXMLValueReader {
private static final String DATEINAME_NODE_QUERY_STRING = "//Hauptobjekt//Dateiname"; private static final String DATEINAME_NODE_QUERY_STRING = "//Hauptobjekt//Dateiname";
private static final XPathExpression DATEINAME_NODE_QUERY = compileXPathExpression(DATEINAME_NODE_QUERY_STRING); // Interpret XML-Attachments as representations
// XML filetype code: 030 (see https://www.xrepository.de/details/urn:xoev-de:xdomea:codeliste:dateiformat)
// Query für XML-Dateien in Anlagen private static final String DATEINAME_NODE_FOR_XML_ANHANG_QUERY_STRING = "//Anlage//Format/Name[contains(., '030')]/..//Dateiname";
// Siehe auch https://www.xrepository.de/details/urn:xoev-de:xdomea:kosit:standard:xdomea private static final XPathExpression DATEINAME_NODE_QUERY = compileXPathExpression(
// und https://www.xrepository.de/details/urn:xoev-de:xdomea:codeliste:dateiformat DATEINAME_NODE_QUERY_STRING + "|" + DATEINAME_NODE_FOR_XML_ANHANG_QUERY_STRING);
public static final String ANLAGE_NODE_QUERY_DFOERDER = "//Anlage//Format/Name[@listURI='urn:xoev-de:xdomea:codeliste:dateiformat']/code[.='030']/../..//Dateiname";
public static final String ANLAGE_NODE_QUERY_AFM = "//Anlage//Format/Name[substring(., 1, 3)='030']/..//Dateiname";
public static final String ANLAGE_NODE_QUERY_STRING = ANLAGE_NODE_QUERY_DFOERDER + " | " + ANLAGE_NODE_QUERY_AFM;
private static final XPathExpression ANLAGE_NODE_QUERY = compileXPathExpression(ANLAGE_NODE_QUERY_STRING);
public List<String> readRepresentationFileNames(IncomingFile xdomeaXMLFile) { public List<String> readRepresentationFileNames(IncomingFile xdomeaXMLFile) {
var parsedXML = XMLHelper.parseDocument(xdomeaXMLFile).getDocumentElement(); var parsedXML = XMLHelper.parseDocument(xdomeaXMLFile).getDocumentElement();
return Stream.concat( return getTextsFromNodes(queryDateinameNodeList(parsedXML)).toList();
getTextsFromNodes(
queryDateinameNodeList(
parsedXML
)),
getTextsFromNodes(
queryAnlageNodeList(
parsedXML
))
).toList();
} }
private NodeList queryDateinameNodeList(Element contextElement) { private NodeList queryDateinameNodeList(Element contextElement) {
...@@ -58,18 +45,6 @@ public class XdomeaXMLValueReader { ...@@ -58,18 +45,6 @@ public class XdomeaXMLValueReader {
} }
} }
private NodeList queryAnlageNodeList(Element contextElement) {
try {
return (NodeList) ANLAGE_NODE_QUERY
.evaluate(
contextElement,
XPathConstants.NODESET
);
} catch (XPathExpressionException e) {
throw new TechnicalException("Failed to execute xpath search!", e);
}
}
private Stream<String> getTextsFromNodes(NodeList nodeList) { private Stream<String> getTextsFromNodes(NodeList nodeList) {
return streamNodeList(nodeList) return streamNodeList(nodeList)
.map(Node::getTextContent) .map(Node::getTextContent)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment