Skip to content

Commit

Permalink
Merge pull request 'Bump goobi workflow dependency to 23.10' (#4) fro…
Browse files Browse the repository at this point in the history
…m update_goobi_dep_to_23.10 into master

Reviewed-on: https://gitea.intranda.com/goobi-workflow/goobi-plugin-opac-json/pulls/4
  • Loading branch information
rsehr committed Nov 7, 2023
2 parents 4367016 + ea93831 commit 83b9de2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions plugin/module-gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.intranda.goobi.plugins.opac</groupId>
<artifactId>json-gui</artifactId>
<version>23.08</version>
<version>23.10</version>
<properties>
<jar.name>plugin_intranda_opac_json-GUI</jar.name>
<dest.folder>/opt/digiverso/goobi/plugins/GUI/</dest.folder>
</properties>
<parent>
<groupId>de.intranda.goobi.plugins.opac</groupId>
<artifactId>json</artifactId>
<version>23.08</version>
<version>23.10</version>
</parent>
<build>
<finalName>${jar.name}</finalName>
Expand Down
4 changes: 2 additions & 2 deletions plugin/module-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.intranda.goobi.plugins.opac</groupId>
<artifactId>json-main</artifactId>
<version>23.08</version>
<version>23.10</version>
<properties>
<jar.name>plugin_intranda_opac_json</jar.name>
<dest.folder>/opt/digiverso/goobi/plugins/opac/</dest.folder>
</properties>
<parent>
<groupId>de.intranda.goobi.plugins.opac</groupId>
<artifactId>json</artifactId>
<version>23.08</version>
<version>23.10</version>
</parent>
<build>
<finalName>${jar.name}</finalName>
Expand Down
4 changes: 2 additions & 2 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.intranda.goobi.plugins.opac</groupId>
<artifactId>json</artifactId>
<version>23.08</version>
<version>23.10</version>
<packaging>pom</packaging>
<properties>
<goobi.pluginversion>1.0.1</goobi.pluginversion>
<jar.name>plugin_intranda_opac_json</jar.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<goobi.version>23.08</goobi.version>
<goobi.version>23.10</goobi.version>
</properties>
<url>http://maven.apache.org</url>
<repositories>
Expand Down
28 changes: 19 additions & 9 deletions plugin/src/main/java/de/intranda/goobi/plugins/JsonOpacPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.configuration.SubnodeConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
Expand All @@ -25,7 +27,6 @@
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.oro.text.perl.Perl5Util;
import org.goobi.interfaces.IJsonPlugin;
import org.goobi.interfaces.ISearchField;
import org.goobi.production.enums.PluginType;
Expand Down Expand Up @@ -61,20 +62,21 @@
import ugh.exceptions.IncompletePersonObjectException;
import ugh.exceptions.MetadataTypeNotAllowedException;
import ugh.fileformats.mets.MetsMods;
import ugh.fileformats.mets.MetsModsImportExport;

@PluginImplementation
@Log4j2
public class JsonOpacPlugin implements IJsonPlugin {

private Perl5Util perlUtil = new Perl5Util();
private static final long serialVersionUID = -6765019017558011325L;

@Getter
private String title = "intranda_opac_json";

@Getter
private PluginType type = PluginType.Opac;

private Config config = null;
private transient Config config = null;

private int hitcount;
protected String gattung = "Aa";
Expand Down Expand Up @@ -406,13 +408,16 @@ private void parseMetadata(Object document, DocStruct anchor, DocStruct logical,
private void addPerson(String stringValue, String identifier, PersonField pf, DocStruct anchor, DocStruct logical, Prefs prefs) {
if (StringUtils.isNotBlank(stringValue)) {
if (StringUtils.isNotBlank(pf.getValidateRegularExpression())) {
if (!perlUtil.match(pf.getValidateRegularExpression(), stringValue)) {
Pattern pattern = Pattern.compile(pf.getValidateRegularExpression());
Matcher matcher = pattern.matcher(stringValue);
if (!matcher.find()) {
return;
}
}

if (StringUtils.isNotBlank(pf.getManipulateRegularExpression())) {
stringValue = perlUtil.substitute(pf.getManipulateRegularExpression(), stringValue);
List<String> parts = MetsModsImportExport.splitRegularExpression(pf.getManipulateRegularExpression());
stringValue = stringValue.replaceAll(parts.get(0), parts.get(1));
}
if (pf.isFollowLink() && StringUtils.isNotBlank(pf.getTemplateName())) {
Config templateConfig = getConfig(pf.getTemplateName());
Expand All @@ -437,8 +442,10 @@ private void addPerson(String stringValue, String identifier, PersonField pf, Do
}

} else {
String firstname = perlUtil.substitute(pf.getFirstname(), stringValue);
String lastname = perlUtil.substitute(pf.getLastname(), stringValue);
List<String> parts = MetsModsImportExport.splitRegularExpression(pf.getManipulateRegularExpression());
String firstname = pf.getFirstname().replaceAll(parts.get(0), parts.get(1));
String lastname = pf.getLastname().replaceAll(parts.get(0), parts.get(1));

try {
Person person = new Person(prefs.getMetadataTypeByName(pf.getMetadata()));
person.setFirstname(firstname);
Expand All @@ -462,13 +469,16 @@ private void addPerson(String stringValue, String identifier, PersonField pf, Do
private void addMetadata(String stringValue, String identifier, MetadataField mf, DocStruct anchor, DocStruct logical, Prefs prefs) {
if (StringUtils.isNotBlank(stringValue)) {
if (StringUtils.isNotBlank(mf.getValidateRegularExpression())) {
if (!perlUtil.match(mf.getValidateRegularExpression(), stringValue)) {
Pattern pattern = Pattern.compile(mf.getValidateRegularExpression());
Matcher matcher = pattern.matcher(stringValue);
if (!matcher.find()) {
return;
}
}

if (StringUtils.isNotBlank(mf.getManipulateRegularExpression())) {
stringValue = perlUtil.substitute(mf.getManipulateRegularExpression(), stringValue);
List<String> parts = MetsModsImportExport.splitRegularExpression(mf.getManipulateRegularExpression());
stringValue = stringValue.replaceAll(parts.get(0), parts.get(1));
}
if (mf.isFollowLink() && StringUtils.isNotBlank(mf.getTemplateName())) {
Config templateConfig = getConfig(mf.getTemplateName());
Expand Down

0 comments on commit 83b9de2

Please sign in to comment.