Skip to content

Commit

Permalink
extended the plugin for magazines
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenHankiewicz committed May 14, 2024
1 parent 26821fd commit 13b66bd
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 54 deletions.
23 changes: 12 additions & 11 deletions install/plugin_intranda_export_adm_bsme.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<config_plugin>

<!-- directory where to export to -->
<targetDirectory>/opt/digiverso/viewer/hotfolder/</targetDirectory>
<!-- directories where to export to -->
<targetDirectoryMagazines>/opt/digiverso/viewer/hotfolderMagazines/</targetDirectoryMagazines>
<targetDirectoryNewspapers>/opt/digiverso/viewer/hotfolderNewspapers/</targetDirectoryNewspapers>

<!-- main viewer url -->
<viewerUrl>https://adm.goobi.cloud/viewer/</viewerUrl>>
Expand All @@ -11,16 +12,15 @@
- $(meta.CatalogIDDigital)
- $(meta.topstruct.TitleDocMain)
- $(process.Template) -->
<rightsToUse>$(process.rightsToUse)</rightsToUse>
<rightsDetails>$(process.rightsDetails)</rightsDetails>
<source>$(process.source)</source>
<mediaType>$(process.mediaType)</mediaType>
<mediaGroup>$(process.mediaGroup)</mediaGroup>
<sourceOrganisation>$(process.sourceOrganisation)</sourceOrganisation>
<frequency>$(process.frequency)</frequency>
<technicalNotes>$(process.technicalNotes)</technicalNotes>
<rightsToUse>$(template.Rights to Use)</rightsToUse>
<rightsDetails>$(template.Rights Details)</rightsDetails>
<source>Goobi</source>
<mediaType>$(template.Media Type)</mediaType>
<mediaGroup>$(template.Media Group)</mediaGroup>
<sourceOrganisation>$(template.Source Organization)</sourceOrganisation>
<frequency>$(template.Issue Frequency)</frequency>


<!-- mets parameter -->
<!-- if a field is empty or missing, project configuration is used -->
<metsUrl addFileExtension="true">https://adm.goobi.cloud/viewer/sourcefile?id=</metsUrl>
Expand Down Expand Up @@ -53,6 +53,7 @@
<purl>_purl</purl>
<identifier>CatalogIDDigital</identifier>
<issueDate>DateIssued</issueDate>
<dateOfOrigin>DateOfOrigin</dateOfOrigin>
<yearDate>CurrentNoSorting</yearDate>
<titleLabel>TitleDocMain</titleLabel>
<modsTitle>MainTitle</modsTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.nio.file.Paths;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import de.sub.goobi.helper.StorageProvider;
import ugh.dl.DocStruct;
import ugh.dl.Metadata;
Expand Down Expand Up @@ -43,6 +45,33 @@ public static String getMetdata(DocStruct ds, String field) {
return "";
}

/**
* extremely simple translation method to convert German issue labes into pseudo english labels
*
* @param value
* @return
*/
public static String getTranslatedIssueLabels(String value) {
String copy = value;
copy = copy.replace("Ausgabe vom", "");
copy = copy.replace("Issue from", "");
return copy;
}

/**
* get English part of a metadata that is separated from Arabic part
*
* @param value
* @return
*/
public static String getEnglishPartOfString(String value) {
String copy = value.replace("–", "-");
if (copy.contains("-")) {
copy = StringUtils.substringAfter(copy, "-").trim();
}
return copy;
}

/**
* get the language from metadata
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.tree.xpath.XPathExpressionEngine;
import org.goobi.beans.JournalEntry;
import org.goobi.beans.Process;
import org.jdom2.Document;
import org.jdom2.Element;
Expand Down Expand Up @@ -69,7 +70,7 @@ public MagazineExporter(XMLConfiguration config, Process process, Prefs prefs, D
this.prefs = prefs;
this.dd = dd;
viewerUrl = config.getString("viewerUrl", "https://viewer.goobi.io");
targetFolder = config.getString("targetDirectory", "/opt/digiverso/goobi/output/");
targetFolder = config.getString("targetDirectoryMagazines", "/opt/digiverso/goobi/output/");
}

/**
Expand Down Expand Up @@ -111,29 +112,41 @@ public boolean startExport() {
String mediaType = vr.replace(config.getString("/mediaType"));
String mediaGroup = vr.replace(config.getString("/mediaGroup"));
String sourceOrganisation = vr.replace(config.getString("/sourceOrganisation"));
String technicalNotes = vr.replace(config.getString("/technicalNotes"));

volume.addContent(new Element("Rights_to_Use").setText(rightsToUse));
volume.addContent(new Element("Right_Details").setText(rightsDetails));
volume.addContent(new Element("Media_Source").setText(source));
volume.addContent(new Element("Media_type").setText(mediaType));
volume.addContent(new Element("Media_Group").setText(mediaGroup));
volume.addContent(new Element("Publication_ID").setText(volumeId));
// not needed anymore
// volume.addContent(new Element("Publication_ID").setText(volumeId));
volume.addContent(new Element("Publication_Name")
.setText(AdmBsmeExportHelper.getMetdata(anchor, config.getString("/metadata/titleLabel"))));
volume.addContent(new Element("Language")
.setText(AdmBsmeExportHelper.getLanguageFullname(anchor, config.getString("/metadata/DocLanguage"))));
.setText(AdmBsmeExportHelper.getLanguageFullname(anchor, config.getString("/metadata/language"))));
volume.addContent(
new Element("Source_Organization").setText(sourceOrganisation));
volume.addContent(new Element("Technical_Notes").setText(technicalNotes));

// add all journal entries as technical notes
if (process.getJournal() != null) {
Element technicalNotes = new Element("Technical_Notes");
for (JournalEntry je : process.getJournal()) {
technicalNotes.addContent(new Element("Entry").setAttribute("date", je.getFormattedCreationDate())
.setAttribute("type", je.getType().getTitle())
.setText(je.getFormattedContent()));
}
volume.addContent(technicalNotes);
} else {
volume.addContent(new Element("Technical_Notes").setText("- no entry available -"));
}

// add issue information
Element issue = new Element("issueInfo");
volume.addContent(issue);
issue.addContent(
new Element("issueNumber").setText(AdmBsmeExportHelper.getMetdata(topStruct, config.getString("/metadata/issueNumber"))));
issue.addContent(new Element("issueID").setText(volumeId));
issue.addContent(new Element("issueDate").setText(AdmBsmeExportHelper.getMetdata(topStruct, config.getString("/metadata/issueDate"))));
issue.addContent(new Element("issueDate").setText(AdmBsmeExportHelper.getMetdata(topStruct, config.getString("/metadata/dateOfOrigin"))));
issue.addContent(new Element("Open_In_Viewer").setText(viewerUrl + volumeId));
volume.addContent(new Element("Barcode").setText(volumeId));
issue.addContent(new Element("issueFile").setText(volumeId + ".pdf").setAttribute("Format", "application/pdf"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.tree.xpath.XPathExpressionEngine;
import org.goobi.beans.JournalEntry;
import org.goobi.beans.Process;
import org.jdom2.Document;
import org.jdom2.Element;
Expand Down Expand Up @@ -73,7 +74,7 @@ public NewspaperExporter(XMLConfiguration config, Process process, Prefs prefs,
this.prefs = prefs;
this.dd = dd;
viewerUrl = config.getString("viewerUrl", "https://viewer.goobi.io");
targetFolder = config.getString("targetDirectory", "/opt/digiverso/goobi/output/");
targetFolder = config.getString("targetDirectoryNewspapers", "/opt/digiverso/goobi/output/");
pdfIssues = new ArrayList<>();
}

Expand Down Expand Up @@ -121,21 +122,34 @@ public boolean startExport() {
String mediaGroup = vr.replace(config.getString("/mediaGroup"));
String sourceOrganisation = vr.replace(config.getString("/sourceOrganisation"));
String frequency = vr.replace(config.getString("/frequency"));
String technicalNotes = vr.replace(config.getString("/technicalNotes"));

volume.addContent(new Element("Rights_to_Use").setText(rightsToUse));
volume.addContent(new Element("Right_Details").setText(rightsDetails));
volume.addContent(new Element("Media_Source").setText(source));
volume.addContent(new Element("Media_type").setText(mediaType));
volume.addContent(new Element("Media_Group").setText(mediaGroup));
volume.addContent(new Element("Publication_ID").setText(volumeId));
// not needed anymore
// volume.addContent(new Element("Publication_ID").setText(volumeId));
volume.addContent(new Element("Publication_Name")
.setText(AdmBsmeExportHelper.getMetdata(anchor, config.getString("/metadata/titleLabel"))));
volume.addContent(new Element("Language")
.setText(AdmBsmeExportHelper.getLanguageFullname(topStruct, config.getString("/metadata/DocLanguage"))));
.setText(AdmBsmeExportHelper.getLanguageFullname(topStruct, config.getString("/metadata/language"))));
volume.addContent(
new Element("Source_Organization").setText(sourceOrganisation));
volume.addContent(new Element("Technical_Notes").setText(technicalNotes));

// add all journal entries as technical notes
if (process.getJournal() != null) {
Element technicalNotes = new Element("Technical_Notes");
for (JournalEntry je : process.getJournal()) {
technicalNotes.addContent(new Element("Entry").setAttribute("date", je.getFormattedCreationDate())
.setAttribute("type", je.getType().getTitle())
.setText(je.getFormattedContent()));
}
volume.addContent(technicalNotes);
} else {
volume.addContent(new Element("Technical_Notes").setText("- no entry available -"));
}

volume.addContent(new Element("Barcode").setText(volumeId));
volume.addContent(new Element("MetadataMetsFile").setText(volumeId + ".xml").setAttribute("Format", "application/xml"));

Expand All @@ -146,6 +160,16 @@ public boolean startExport() {
new Element("issueNumber").setText(AdmBsmeExportHelper.getMetdata(ds, config.getString("/metadata/issueNumber"))));
issue.addContent(new Element("issueID").setText(volumeId + "-" + simpleDate));
issue.addContent(new Element("issueFrequency").setText(frequency));

// get the anchor title and leave the english part of the title
String issueTitlePrefix = AdmBsmeExportHelper.getMetdata(anchor, config.getString("/metadata/titleLabel"));
issueTitlePrefix = AdmBsmeExportHelper.getEnglishPartOfString(issueTitlePrefix);
// get the issue title
String issueTitle =
AdmBsmeExportHelper.getTranslatedIssueLabels(AdmBsmeExportHelper.getMetdata(ds, config.getString("/metadata/titleLabel")));
// put prefix and title together
issue.addContent(new Element("issueTitle").setText(issueTitlePrefix + issueTitle));

issue.addContent(new Element("issueDate").setText(AdmBsmeExportHelper.getMetdata(ds, config.getString("/metadata/issueDate"))));
issue.addContent(new Element("Open_In_Viewer").setText(viewerUrl + volumeId + "-" + simpleDate));
issue.addContent(new Element("issueFile").setText(volumeId + "-" + simpleDate + ".pdf").setAttribute("Format", "application/pdf"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public NewspaperMetsCreator(XMLConfiguration config, Process process, Prefs pref
this.prefs = prefs;
this.dd = dd;
this.fileMap = fileMap;
targetFolder = config.getString("targetDirectory", "/opt/digiverso/goobi/output/");
targetFolder = config.getString("targetDirectoryNewspapers", "/opt/digiverso/goobi/output/");
vr = new VariableReplacer(dd, prefs, process, null);
}

Expand Down Expand Up @@ -309,13 +309,18 @@ public boolean exportMetsFile() throws IOException, WriteException, PreferencesE
issueIdentifier = md.getValue();
}
if (md.getType().getName().equals(labelType.getName())) {
// add the anchor label as prefix in front of each issue
String englishNewspaperName = getEnglishPartOfString(titleLabel);
md.setValue(englishNewspaperName + " " + getTranslatedIssueLabels(md.getValue()));

// EITHER: add the anchor label as prefix in front of each issue
String englishNewspaperName = AdmBsmeExportHelper.getEnglishPartOfString(titleLabel);
md.setValue(englishNewspaperName + " " + AdmBsmeExportHelper.getTranslatedIssueLabels(md.getValue()));

// OR: use original title (incl. arabic font)
// md.setValue(titleLabel + " " + getTranslatedIssueLabels(md.getValue()));

issueLabel = md.getValue();
}
if (md.getType().getName().equals(mainTitleType.getName())) {
md.setValue(getTranslatedIssueLabels(md.getValue()));
md.setValue(AdmBsmeExportHelper.getTranslatedIssueLabels(md.getValue()));
issueTitle = md.getValue();
}
if (md.getType().getName().equals(issueNumberType.getName())) {
Expand Down Expand Up @@ -918,33 +923,6 @@ private static String padIdString(int logId) {
return strId;
}

/**
* extremely simple translation method to convert German issue labes into pseudo english labels
*
* @param value
* @return
*/
private static String getTranslatedIssueLabels(String value) {
String copy = value;
copy = copy.replace("Ausgabe vom", "");
copy = copy.replace("Issue from", "");
return copy;
}

/**
* get English part of a metadata that is separated from Arabic part
*
* @param value
* @return
*/
private static String getEnglishPartOfString(String value) {
String copy = value.replace("–", "-");
if (copy.contains("-")) {
copy = StringUtils.substringAfter(copy, "-").trim();
}
return copy;
}

/**
* simple comparator for volumes
*/
Expand Down

0 comments on commit 13b66bd

Please sign in to comment.