Skip to content

Commit

Permalink
Merge pull request 'Bump goobi workflow dependency to 23.10' (#6) fro…
Browse files Browse the repository at this point in the history
  • Loading branch information
rsehr committed Nov 7, 2023
2 parents 8c01621 + 3ea98e2 commit 5132f4c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 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.workflow</groupId>
<artifactId>fileUploadProcessCreation-gui</artifactId>
<version>23.08</version>
<version>23.10</version>
<properties>
<jar.name>plugin_intranda_workflow_fileUploadProcessCreation-GUI</jar.name>
<dest.folder>/opt/digiverso/goobi/plugins/GUI/</dest.folder>
</properties>
<parent>
<groupId>de.intranda.goobi.plugins.workflow</groupId>
<artifactId>fileUploadProcessCreation</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.workflow</groupId>
<artifactId>fileUploadProcessCreation-main</artifactId>
<version>23.08</version>
<version>23.10</version>
<properties>
<jar.name>plugin_intranda_workflow_fileUploadProcessCreation</jar.name>
<dest.folder>/opt/digiverso/goobi/plugins/workflow/</dest.folder>
</properties>
<parent>
<groupId>de.intranda.goobi.plugins.workflow</groupId>
<artifactId>fileUploadProcessCreation</artifactId>
<version>23.08</version>
<version>23.10</version>
</parent>
<build>
<finalName>${jar.name}</finalName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<metadataDocumentType>Monograph</metadataDocumentType>

<!-- define a naming schema for the file names to be matched for the process creation -->
<namingSchema>/.*(BA_\\d+[_-](\\d+)).*\\.jpg/</namingSchema>
<namingSchema>.*(BA_\\d+[_-](\\d+)).*\\.jpg</namingSchema>

</config_plugin>
4 changes: 2 additions & 2 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.intranda.goobi.plugins.workflow</groupId>
<artifactId>fileUploadProcessCreation</artifactId>
<version>23.08</version>
<version>23.10</version>
<packaging>pom</packaging>
<properties>
<goobi.version>23.08</goobi.version>
<goobi.version>23.10</goobi.version>
</properties>
<distributionManagement>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.configuration.XMLConfiguration;
import org.apache.oro.text.perl.Perl5Util;
import org.goobi.beans.Process;
import org.goobi.beans.Step;
import org.goobi.beans.User;
Expand Down Expand Up @@ -58,13 +59,15 @@
@Data
public class FileUploadProcessCreationWorkflowPlugin implements IWorkflowPlugin, IPlugin {

private static final long serialVersionUID = -2750139629101527562L;

private String allowedTypes;

private List<MassUploadedFile> uploadedFiles = new ArrayList<>();
private transient List<MassUploadedFile> uploadedFiles = new ArrayList<>();
private User user;
private File tempFolder;

private Map<String, List<MassUploadedFile>> processFilenameMap = new HashMap<>();
private transient Map<String, List<MassUploadedFile>> processFilenameMap = new HashMap<>();
private Map<String, Boolean> processTitleChecks = new HashMap<>();

private String processTemplateName;
Expand All @@ -73,7 +76,6 @@ public class FileUploadProcessCreationWorkflowPlugin implements IWorkflowPlugin,

private String metadataDocumentType;
private String namingSchema;
private Perl5Util perlUtil = new Perl5Util();

@Override
public String getGui() {
Expand Down Expand Up @@ -286,7 +288,7 @@ public void startInserting() {
// check if automatic steps must be executed

for (Step s : newProcess.getSchritte()) {
if (s.getBearbeitungsstatusEnum().equals(StepStatus.OPEN) && s.isTypAutomatisch()) {
if (StepStatus.OPEN.equals(s.getBearbeitungsstatusEnum()) && s.isTypAutomatisch()) {
ScriptThreadWithoutHibernate myThread = new ScriptThreadWithoutHibernate(s);
myThread.start();
}
Expand All @@ -307,8 +309,10 @@ private void assignProcessToFile(MassUploadedFile uploadedFile, Map<String, List
// get the relevant part of the file name

String processTitle = null;
if (perlUtil.match(namingSchema, uploadedFile.getFilename())) {
processTitle = perlUtil.group(1);
Pattern pattern = Pattern.compile(namingSchema);
Matcher matcher = pattern.matcher(uploadedFile.getFilename());
if (matcher.matches()) {
processTitle = matcher.group(1);
} else {
uploadedFile.setStatusmessage(Helper.getTranslation("plugin_workflow_fileUploadPCWrongFilename"));
uploadedFile.setStatus(MassUploadedFileStatus.ERROR);
Expand All @@ -325,7 +329,7 @@ private void assignProcessToFile(MassUploadedFile uploadedFile, Map<String, List
}
}

if (processTitleChecks.get(processTitle)) {
if (processTitleChecks.get(processTitle).booleanValue()) {
uploadedFile.setStatusmessage(Helper.getTranslation("plugin_workflow_fileUploadPCProcessExists", processTitle));
uploadedFile.setStatus(MassUploadedFileStatus.ERROR);
} else {
Expand Down Expand Up @@ -369,9 +373,7 @@ private void assignProcessToFile(MassUploadedFile uploadedFile, Map<String, List
}

public boolean getShowInsertButton() {
boolean showInsertButton =
this.uploadedFiles.size() > 0 && this.uploadedFiles.stream().allMatch(muf -> muf.getStatus() != MassUploadedFileStatus.UNKNWON);
return showInsertButton;
return !uploadedFiles.isEmpty() && this.uploadedFiles.stream().allMatch(muf -> muf.getStatus() != MassUploadedFileStatus.UNKNWON);
}

public boolean isShowInsertButton() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.oro.text.perl.Perl5Util;
import org.junit.Test;

public class FileUploadProcessCreationWorkflowPluginTest {


@Test public void testRegularExpression () {
@Test
public void testRegularExpression() {
List<String> test = new ArrayList<>();
test.add("abc.jpg");
test.add("Stadtarchiv Crowdsourcing 06. Post BA_1991_336112.jpg");
Expand All @@ -18,13 +19,14 @@ public class FileUploadProcessCreationWorkflowPluginTest {
test.add("BA_1988_26870.jpg");
test.add("Stadtarchiv Crowdsourcing 06. Post BA_1991_336113.jpg");

Perl5Util perlUtil = new Perl5Util();

Pattern pattern = Pattern.compile("(.*)_(\\d+)\\.jpg");
for (String s : test) {
if (perlUtil.match("/(.*)_(\\d+)\\.jpg/", s)) {
Matcher matcher = pattern.matcher(s);
if (matcher.matches()) {

System.out.println("match");
System.out.println(perlUtil.group(1));
System.out.println(perlUtil.group(2));
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
}
// Matcher m =pattern.matcher(s);
// System.out.println(m.group());
Expand Down

0 comments on commit 5132f4c

Please sign in to comment.