use of com.google.cloud.dialogflow.v2beta1.Document in project goobi-workflow by intranda.
the class ProzesskopieForm method initializePossibleDigitalCollections.
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.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) {
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;
}
if (isSingleChoiceCollection()) {
this.digitalCollections.add(getDigitalCollectionIfSingleChoice());
}
}
use of com.google.cloud.dialogflow.v2beta1.Document in project goobi-workflow by intranda.
the class HelperSchritte method extractAuthorityMetadata.
public static void extractAuthorityMetadata(Path metadataFile, Map<String, List<String>> metadataPairs) {
XPathFactory xFactory = XPathFactory.instance();
XPathExpression<Element> authorityMetaXpath = xFactory.compile("//mets:xmlData/mods:mods/mods:extension/goobi:goobi/goobi:metadata[goobi:authorityValue]", Filters.element(), null, mods, mets, goobiNamespace);
SAXBuilder builder = new SAXBuilder();
Document doc;
try {
doc = builder.build(metadataFile.toString());
} catch (JDOMException | IOException e1) {
return;
}
for (Element meta : authorityMetaXpath.evaluate(doc)) {
String name = meta.getAttributeValue("name");
if (name == null) {
continue;
} else {
String key = name + "_authority";
List<String> values = metadataPairs.get(key);
if (values == null) {
values = new ArrayList<>();
metadataPairs.put(key, values);
}
values.add(meta.getChildText("authorityValue", goobiNamespace));
}
}
}
use of com.google.cloud.dialogflow.v2beta1.Document in project goobi-workflow by intranda.
the class PluginInstaller method parsePlugin.
private static PluginInstallInfo parsePlugin(Path pluginFolder) throws JDOMException, IOException {
// TODO: error checking...
Document pluginPomDocument = parsePomXml(pluginFolder, "pom.xml");
String name = extractPluginName(pluginPomDocument, pluginFolder);
String type = extractPluginTypeFromName(name);
String pluginVersion = pluginVersionXpath.evaluateFirst(pluginPomDocument).getTextTrim();
Element goobiVersionEle = goobiVersionXpath.evaluateFirst(pluginPomDocument);
if (goobiVersionEle == null) {
goobiVersionEle = secondGoobiVersionXpath.evaluateFirst(pluginPomDocument);
}
String goobiVersion = goobiVersionEle.getTextTrim();
List<PluginVersion> versions = Collections.singletonList(new PluginVersion(null, null, goobiVersion, goobiVersion, pluginVersion));
return new PluginInstallInfo(0, name, type, null, null, versions);
}
use of com.google.cloud.dialogflow.v2beta1.Document in project goobi-workflow by intranda.
the class PluginInstaller method parsePomXml.
private static Document parsePomXml(Path pluginFolder, String pomFilePath) throws JDOMException, IOException {
SAXBuilder saxBuilder = new SAXBuilder();
Path pomPath = pluginFolder.resolve(pomFilePath);
Document pluginPomDocument = saxBuilder.build(pomPath.toFile());
return pluginPomDocument;
}
use of com.google.cloud.dialogflow.v2beta1.Document in project goobi-workflow by intranda.
the class XsltPreparatorDocket method startExport.
/**
* This method exports the production metadata as xml to a given stream.
*
* @param process the process to export
* @param os the OutputStream to write the contents to
* @throws IOException
* @throws ExportFileException
*/
@Override
public void startExport(Process process, OutputStream os, String xslt) throws IOException {
try {
Document doc = createDocument(process, true, true);
XMLOutputter outp = new XMLOutputter();
outp.setFormat(Format.getPrettyFormat());
outp.output(doc, os);
os.close();
} catch (Exception e) {
throw new IOException(e);
}
}
Aggregations