ISO19139SchemaPlugin extends SchemaPlugin implements
    AssociatedResourcesSchemaPlugin,
    MultilingualSchemaPlugin,
    ExportablePlugin,
    ISOPlugin,
    LinkAwareSchemaPlugin { public static List<String> getLanguages(Element md) { List<String> languages = new ArrayList<>(); try { String mainLanguage = getMainLanguage(md); if (mainLanguage.length() > 0) { languages.add(mainLanguage); } List<Attribute> locales = (List<Attribute>) Xml.selectNodes(md, "gmd:locale@codeListValue", ISO19139SchemaPlugin.allNamespaces.asList()); if (locales != null) { locales.stream() .map(Attribute::getValue) .filter(Objects::nonNull) .filter(l -> !l.equalsIgnoreCase(mainLanguage)) .forEach(l -> languages.add(l)); }; } catch (JDOMException e) { } return languages; } ISO19139SchemaPlugin(); Set<AssociatedResource> getAssociatedResourcesUUIDs(Element metadata); @Override Set<String> getAssociatedParentUUIDs(Element metadata); Set<String> getAssociatedDatasetUUIDs(Element metadata); Set<String> getAssociatedFeatureCatalogueUUIDs(Element metadata); Set<String> getAssociatedSourceUUIDs(Element metadata); @Override List<Element> getTranslationForElement(Element element, String languageIdentifier); @Override void addTranslationToElement(Element element, String languageIdentifier, String value); @Override Element removeTranslationFromElement(Element element, List<String> langs); @Override String getBasicTypeCharacterStringName(); @Override Element createBasicTypeCharacterString(); @Override Element addOperatesOn(Element serviceRecord,
                                 Map<String, String> layers,
                                 String serviceType,
                                 String baseUrl); @Override List<Extent> getExtents(Element record); @Override Map<String, Namespace> getCswTypeNames(); @Override Map<String, String> getExportFormats(); @Override Element processElement(Element el,
                                  String attributeRef,
                                  String parsedAttributeName,
                                  String attributeValue); static List<String> getLanguages(Element md); RawLinkPatternStreamer<L, M> createLinkStreamer(ILinkBuilder<L, M> linkbuilder); static final String IDENTIFIER; static ImmutableSet<Namespace> allNamespaces; }
@Test public void mainLanguageGcoCharString() throws URISyntaxException, JDOMException, NoSuchFileException { Element input = Xml.loadFile(Paths.get(ISO19139SchemaPluginTest.class.getClassLoader().getResource("schema/iso19139/languages/main_charstring.xml").toURI())); List<String> languages = ISO19139SchemaPlugin.getLanguages(input); assertArrayEquals(new String[] {"ger", "fre", "ita"}, languages.toArray()); }
@Test public void noMainLanguageGcoCharString() throws URISyntaxException, JDOMException, NoSuchFileException { Element input = Xml.loadFile(Paths.get(ISO19139SchemaPluginTest.class.getClassLoader().getResource("schema/iso19139/languages/main_charstring.xml").toURI())); ((List<Element>) Xml.selectNodes(input, ". List<String> languages = ISO19139SchemaPlugin.getLanguages(input); assertArrayEquals(new String[] {"fre", "ita", "ger"}, languages.toArray()); }
@Test public void noLocales() throws URISyntaxException, JDOMException, NoSuchFileException { Element input = Xml.loadFile(Paths.get(ISO19139SchemaPluginTest.class.getClassLoader().getResource("schema/iso19139/languages/main_charstring.xml").toURI())); ((List<Element>) Xml.selectNodes(input, ". List<String> languages = ISO19139SchemaPlugin.getLanguages(input); assertArrayEquals(new String[] {"ger"}, languages.toArray()); }
@Test public void noLocalesnoMain() throws URISyntaxException, JDOMException, NoSuchFileException { Element input = Xml.loadFile(Paths.get(ISO19139SchemaPluginTest.class.getClassLoader().getResource("schema/iso19139/languages/main_charstring.xml").toURI())); ((List<Element>) Xml.selectNodes(input, ". ((List<Element>) Xml.selectNodes(input, ". List<String> languages = ISO19139SchemaPlugin.getLanguages(input); assertArrayEquals(new String[] {}, languages.toArray()); }
@Test public void mainEncodedWithCodelist() throws URISyntaxException, JDOMException, NoSuchFileException { Element input = Xml.loadFile(Paths.get(ISO19139SchemaPluginTest.class.getClassLoader().getResource("schema/iso19139/languages/main_code.xml").toURI())); List<String> languages = ISO19139SchemaPlugin.getLanguages(input); assertArrayEquals(new String[] {"roh", "fre", "ita", "ger"}, languages.toArray()); }