Skip to content

Commit

Permalink
Metadata editor / Support add embedded multilingual / Simplify XPath …
Browse files Browse the repository at this point in the history
…and sonarlint.
  • Loading branch information
fxprunayre committed Dec 9, 2024
1 parent fa44961 commit 3d7a65c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,23 +588,13 @@ public boolean duplicateElementsForMultilingual() {
@Override
public List<String> getMetadataLanguages(Element metadata) {
try {
Xml.selectNodes(metadata, ".//mdb:defaultLocale/lan:PT_Locale/@id", allNamespaces.asList())
return Xml.selectNodes(metadata, ".//*[name() = 'mdb:defaultLocale' or name() = 'mdb:otherLocale']/lan:PT_Locale/@id", allNamespaces.asList())
.stream()
.filter(node -> node instanceof Attribute)
.filter(Attribute.class::isInstance)
.map(node -> ((Attribute)node).getValue())
.filter(s -> s != null && !s.isBlank())
.filter(Objects::nonNull)
.collect(Collectors.toList()).addAll(
Xml.selectNodes(metadata, ".//mdb:otherLocale/lan:PT_Locale/@id", allNamespaces.asList())
.stream()
.filter(node -> node instanceof Attribute)
.map(node -> ((Attribute)node).getValue())
.filter(s -> s != null && !s.isBlank())
.filter(Objects::nonNull)
.collect(Collectors.toList())
);
} catch (JDOMException e) {
e.printStackTrace();
.collect(Collectors.toList());
} catch (JDOMException ignored) {
}
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,11 @@ public List<String> getMetadataLanguages(Element metadata) {
try {
return Xml.selectNodes(metadata, ".//gmd:locale/gmd:PT_Locale/@id", allNamespaces.asList())
.stream()
.filter(node -> node instanceof Attribute)
.filter(Attribute.class::isInstance)
.map(node -> ((Attribute)node).getValue())
.filter(s -> s != null && !s.isBlank())
.filter(Objects::nonNull)
.collect(Collectors.toList());
} catch (JDOMException e) {
e.printStackTrace();
} catch (JDOMException ignored) {
}
return Collections.emptyList();
}
Expand Down

0 comments on commit 3d7a65c

Please sign in to comment.