List of usage examples for org.jdom2 Element getAttributeValue
public String getAttributeValue(final String attname)
This returns the attribute value for the attribute with the given name and within no namespace, null if there is no such attribute, and the empty string if the attribute value is empty.
From source file:de.smartics.maven.plugin.jboss.modules.parser.AbstractModuleClusionAdderV2.java
License:Apache License
public void addClusions(final Element matchElement) { if (matchElement != null) { final List<Element> clusionElements = matchElement.getChildren(elementId, NS); for (final Element clusionElement : clusionElements) { final String name = clusionElement.getAttributeValue("module"); final ModuleClusion clusion = new ModuleClusion(name); add(clusion);//from w ww.j a v a 2s . c o m } } }
From source file:de.smartics.maven.plugin.jboss.modules.parser.ModulesDescriptorBuilder.java
License:Apache License
private void parseModule(final Element moduleElement) { builder = new ModuleDescriptor.Builder(); final String moduleName = moduleElement.getAttributeValue("name"); final String slot = moduleElement.getAttributeValue("slot"); builder.withName(moduleName);//from w ww. j a va 2 s . c o m builder.withSlot(slot); parseDirectives(moduleElement.getChild("directives", NS)); parseMatch(moduleElement.getChild("match", NS)); parseApplyToDependencies(moduleElement.getChild("apply-to-dependencies", NS)); parseApplyToModule(moduleElement.getChild("apply-to-module", NS)); final ModuleDescriptor descriptor = builder.build(); modulesDescriptor.addDescriptor(descriptor); }
From source file:de.smartics.maven.plugin.jboss.modules.parser.ModulesDescriptorBuilder.java
License:Apache License
private void handleChild(final ApplyToModule.Builder mBuilder, final XMLOutputter outputter, final Element child) { final String elementName = child.getName(); if ("dependencies".equals(elementName)) { handleDependencies(mBuilder, outputter, child); } else if ("properties".equals(elementName)) { for (final Element propertyElement : child.getChildren("property", ModuleXmlBuilder.NS)) { final String name = propertyElement.getAttributeValue("name"); final String fragment = outputter.outputString(propertyElement); mBuilder.addPropertyXml(name, fragment); }//ww w . ja v a 2 s . c om } else if ("exports".equals(elementName)) { final String fragment = outputter.outputString(child); mBuilder.withExportsXml(fragment); } else if ("main-class".equals(elementName)) { final String fragment = outputter.outputString(child); mBuilder.withMainClassXml(fragment); } else if ("resource-root".equals(elementName)) { final String fragment = outputter.outputString(child); mBuilder.addResourceRootXml(fragment); } else { // TODO warn or add to end? } }
From source file:de.smartics.maven.plugin.jboss.modules.parser.ModulesDescriptorBuilder.java
License:Apache License
private void handleDependencies(final ApplyToModule.Builder mBuilder, final XMLOutputter outputter, final Element child) { int nonModuleCounter = 0; for (final Element childElement : child.getChildren()) { final String childElementName = childElement.getName(); final String name; if ("module".equals(childElementName)) { name = childElement.getAttributeValue("name"); } else {/*from w w w . ja v a2 s. co m*/ // i.e. system, maybe others. nonModuleCounter++; name = "non-module@" + nonModuleCounter; } final String fragment = outputter.outputString(childElement); mBuilder.addDependencyXml(name, fragment); } }
From source file:de.smartics.maven.plugin.jboss.modules.parser.ModulesDescriptorBuilderV2.java
License:Apache License
private void parseModule(final Element moduleElement) { builder = new ModuleDescriptor.Builder(); final String moduleName = moduleElement.getAttributeValue("name"); final String slot = moduleElement.getAttributeValue("slot"); builder.withName(moduleName);/*w ww . java2 s .c om*/ builder.withSlot(slot); parseDirectives(moduleElement); parseMatch(moduleElement); parseApplyToDependencies(moduleElement); parseApplyToModule(moduleElement); final ModuleDescriptor descriptor = builder.build(); modulesDescriptor.addDescriptor(descriptor); }
From source file:de.smartics.maven.plugin.jboss.modules.parser.ModulesDescriptorBuilderV2.java
License:Apache License
private void parseDirectives(final Element directivesElement) { if (directivesElement == null) { return;/*from w ww . j ava 2 s . co m*/ } final Directives.Builder builder = new Directives.Builder(); final String skip = directivesElement.getAttributeValue("skip"); builder.withSkip(skip); final String inheritSlot = directivesElement.getAttributeValue("inherit-slot"); builder.withInheritSlot(inheritSlot); final Directives directives = builder.build(); this.builder.with(directives); }
From source file:de.smartics.maven.plugin.jboss.modules.parser.ModulesDescriptorBuilderV2.java
License:Apache License
private void parseApply(final Builder builder, final Element dependenciesElement) { if (dependenciesElement == null) { return;/*from www .j a v a2 s. co m*/ } final String slot = dependenciesElement.getAttributeValue("slot"); final String skip = dependenciesElement.getAttributeValue("skip"); final String export = dependenciesElement.getAttributeValue("export"); final String services = dependenciesElement.getAttributeValue("services"); final String optional = dependenciesElement.getAttributeValue("optional"); builder.withSlot(slot); builder.withSkip(skip); builder.withExport(export); builder.withServices(services); builder.withOptional(optional); final XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat()); final Element importElement = dependenciesElement.getChild("imports", NS); if (importElement != null) { adjustNamespaces(importElement); final String imports = outputter.outputString(importElement); builder.withImportsXml(imports); } final Element exportElement = dependenciesElement.getChild("exports", NS); if (exportElement != null) { adjustNamespaces(exportElement); final String exports = outputter.outputString(exportElement); builder.withExportsXml(exports); } }
From source file:de.sub.goobi.config.DigitalCollections.java
License:Open Source License
public static String getDefaultDigitalCollectionForProcess(Process process) throws JDOMException, IOException { String filename = ConfigurationHelper.getInstance().getConfigurationFolder() + "goobi_digitalCollections.xml"; if (!Files.exists(Paths.get(filename))) { throw new FileNotFoundException("File not found: " + filename); }//from w w w . ja v a2 s . c o m String firstCollection = ""; /* Datei einlesen und Root ermitteln */ SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(filename); Element root = doc.getRootElement(); /* alle Projekte durchlaufen */ List<Element> projekte = root.getChildren(); for (Iterator<Element> iter = projekte.iterator(); iter.hasNext();) { Element projekt = iter.next(); List<Element> projektnamen = projekt.getChildren("name"); for (Iterator<Element> iterator = projektnamen.iterator(); iterator.hasNext();) { Element projektname = iterator.next(); /* * wenn der Projektname aufgefhrt wird, dann alle Digitalen Collectionen in die Liste */ if (projektname.getText().equalsIgnoreCase(process.getProjekt().getTitel())) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); String collectionName = col.getText(); String defaultCollection = col.getAttributeValue("default"); if (defaultCollection.equalsIgnoreCase("true")) { return collectionName; } if (StringUtils.isBlank(firstCollection)) { firstCollection = collectionName; } } } } } return firstCollection; }
From source file:de.sub.goobi.forms.MassImportForm.java
License:Open Source License
/** * generate a list with all possible collections for given project *//*from w w w . ja v a 2 s . c om*/ private void initializePossibleDigitalCollections() { this.possibleDigitalCollection = new ArrayList<>(); ArrayList<String> defaultCollections = new ArrayList<>(); String filename = this.help.getGoobiConfigDirectory() + "goobi_digitalCollections.xml"; if (!StorageProvider.getInstance().isFileExists(Paths.get(filename))) { Helper.setFehlerMeldung("File not found: ", filename); return; } this.digitalCollections = new ArrayList<>(); try { /* Datei einlesen und Root ermitteln */ SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(filename); Element root = doc.getRootElement(); /* alle Projekte durchlaufen */ List<Element> projekte = root.getChildren(); for (Iterator<Element> iter = projekte.iterator(); iter.hasNext();) { Element projekt = iter.next(); // collect default collections if (projekt.getName().equals("default")) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); if (col.getAttribute("default") != null && col.getAttributeValue("default").equalsIgnoreCase("true")) { digitalCollections.add(col.getText()); } defaultCollections.add(col.getText()); } } else { // run through the projects List<Element> projektnamen = projekt.getChildren("name"); for (Iterator<Element> iterator = projektnamen.iterator(); iterator.hasNext();) { Element projektname = iterator.next(); // all all collections to list if (projektname.getText().equalsIgnoreCase(this.template.getProjekt().getTitel())) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); if (col.getAttribute("default") != null && col.getAttributeValue("default").equalsIgnoreCase("true")) { digitalCollections.add(col.getText()); } this.possibleDigitalCollection.add(col.getText()); } } } } } } catch (JDOMException e1) { log.error("error while parsing digital collections", e1); Helper.setFehlerMeldung("Error while parsing digital collections", e1); } catch (IOException e1) { log.error("error while parsing digital collections", e1); Helper.setFehlerMeldung("Error while parsing digital collections", e1); } if (this.possibleDigitalCollection.size() == 0) { this.possibleDigitalCollection = defaultCollections; } }
From source file:de.sub.goobi.forms.ProzesskopieForm.java
License:Open Source License
private void initializePossibleDigitalCollections() { this.possibleDigitalCollection = new ArrayList<>(); ArrayList<String> defaultCollections = new ArrayList<>(); String filename = this.help.getGoobiConfigDirectory() + "goobi_digitalCollections.xml"; if (!StorageProvider.getInstance().isFileExists(Paths.get(filename))) { Helper.setFehlerMeldung("File not found: ", filename); return;/*from w w w. j av a2 s . com*/ } this.digitalCollections = new ArrayList<>(); try { /* Datei einlesen und Root ermitteln */ SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(filename); Element root = doc.getRootElement(); /* alle Projekte durchlaufen */ List<Element> projekte = root.getChildren(); for (Iterator<Element> iter = projekte.iterator(); iter.hasNext();) { Element projekt = iter.next(); // collect default collections if (projekt.getName().equals("default")) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); if (col.getAttribute("default") != null && col.getAttributeValue("default").equalsIgnoreCase("true")) { digitalCollections.add(col.getText()); } defaultCollections.add(col.getText()); } } else { // run through the projects List<Element> projektnamen = projekt.getChildren("name"); for (Iterator<Element> iterator = projektnamen.iterator(); iterator.hasNext();) { Element projektname = iterator.next(); // all all collections to list if (projektname.getText().equalsIgnoreCase(this.prozessKopie.getProjekt().getTitel())) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); if (col.getAttribute("default") != null && col.getAttributeValue("default").equalsIgnoreCase("true")) { digitalCollections.add(col.getText()); } this.possibleDigitalCollection.add(col.getText()); } } } } } } catch (JDOMException e1) { logger.error("error while parsing digital collections", e1); Helper.setFehlerMeldung("Error while parsing digital collections", e1); } catch (IOException e1) { logger.error("error while parsing digital collections", e1); Helper.setFehlerMeldung("Error while parsing digital collections", e1); } if (this.possibleDigitalCollection.size() == 0) { this.possibleDigitalCollection = defaultCollections; } // if only one collection is possible take it directly if (isSingleChoiceCollection()) { this.digitalCollections.add(getDigitalCollectionIfSingleChoice()); } }