Skip to content

Commit

Permalink
select barcode / image name detection in ui
Browse files Browse the repository at this point in the history
  • Loading branch information
rsehr committed Feb 23, 2024
1 parent a7a34d4 commit 292d51a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 9 deletions.
54 changes: 51 additions & 3 deletions plugin/GUI/META-INF/resources/uii/plugin_workflow_massupload.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@

<composite:implementation>

<style>
.select-insertmode {
margin-top: 5px;
margin-bottom: 10px;
width: 100%;
}


.select-insertmode input[type="radio"] {
margin-right: 5px;
}

table.select-insertmode label {
font-family: "Goobi2_regular",sans-serif;
font-size: 1rem;
}
.select-insertmode label {
display: inline-block;
margin: 0;
padding: 2px 0 0 5px;
font-weight: normal;
}

</style>

<h:outputText styleClass="alert alert-danger d-block" value="#{msgs.noAccessAllowed} Plugin_Goobi_Massupload"
rendered="#{!LoginForm.hasRole('Plugin_Goobi_Massupload')}"/>

Expand All @@ -29,9 +54,29 @@
title="#{msgs[NavigationForm.workflowPlugin.title]}">

<div class="row" style="padding:15px;">

<h:form
id="insertMode"
prependId="false">
<div class="col-sm-8">
<strong><h:outputText value="#{msgs.plugin_massupload_insertMode}:" /></strong>
<h:selectOneRadio
value="#{NavigationForm.workflowPlugin.insertMode}"
styleClass="table__radio select-insertmode">
<f:selectItems
var="selection"
value="#{NavigationForm.workflowPlugin.insertModes}"
itemLabel="#{msgs[selection]}"
itemValue="#{selection}" />

<f:ajax />
</h:selectOneRadio>
</div>
</h:form>
<!-- UPLOAD AREA -->
<div class="col-sm-6" >



<div class="draganddroparea" >
<h:form id="uploadform" prependId="false" >
<p:fileUpload listener="#{NavigationForm.workflowPlugin.uploadFile}" id="upload" auto="true"
Expand All @@ -57,6 +102,9 @@
<!-- ACTION AREA -->
<div class="col-sm-6">
<h:form id="actionarea">



<p:remoteCommand name="sortFiles" actionListener="#{NavigationForm.workflowPlugin.sortFiles}" update="actionarea, uploadBox:actionform"/>

<h:panelGroup rendered="#{NavigationForm.workflowPlugin.uploadedFiles.size() > 0}">
Expand All @@ -75,7 +123,7 @@

<button
title="#{msgs.plugin_massupload_analyzeBarcodes}"
jsf:rendered="#{NavigationForm.workflowPlugin.useBarcodes and not NavigationForm.workflowPlugin.showInsertButton and not NavigationForm.workflowPlugin.analyzingBarcodes}"
jsf:rendered="#{NavigationForm.workflowPlugin.insertMode=='plugin_massupload_insertmode_barcode' and not NavigationForm.workflowPlugin.showInsertButton and not NavigationForm.workflowPlugin.analyzingBarcodes}"
jsf:action="#{NavigationForm.workflowPlugin.assignProcessesWithBarcodeInfo}"
styleClass="btn btn-blank float-end">
<i class="fa fa-qrcode"/>
Expand All @@ -99,7 +147,7 @@
</h:commandLink>

<h:commandLink id="plugin_massupload_hiddenAjaxRefresh"
rendered="#{true or NavigationForm.workflowPlugin.useBarcodes and NavigationForm.workflowPlugin.analyzingBarcodes}">
rendered="#{true or NavigationForm.workflowPlugin.insertMode=='plugin_massupload_insertmode_barcode' and NavigationForm.workflowPlugin.analyzingBarcodes}">
<f:ajax render="uploadFilesTableForm @form" />
</h:commandLink>

Expand Down
16 changes: 10 additions & 6 deletions plugin/src/de/intranda/goobi/plugins/MassUploadPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,15 @@ public class MassUploadPlugin implements IWorkflowPlugin, IPlugin {
private HashSet<Integer> stepIDs = new HashSet<>();
private transient List<MassUploadedProcess> finishedInserts = new ArrayList<>();
private boolean copyImagesViaGoobiScript = false;
private boolean useBarcodes = false;
private transient ExecutorService barcodePool;
private volatile boolean analyzingBarcodes = false;
private boolean currentlyInserting;
private boolean hideInsertButtonAfterClick = false;

private boolean useBarcodesDefault = false;
private String[] insertModes = { "plugin_massupload_insertmode_imageName", "plugin_massupload_insertmode_barcode" };
private String insertMode = "plugin_massupload_insertmode_imageName";

/**
* Constructor
*/
Expand All @@ -111,10 +114,11 @@ public MassUploadPlugin() {
filenameSeparator = config.getString("filename-separator", "_").toLowerCase();
stepTitles = Arrays.asList(config.getStringArray("allowed-step"));
copyImagesViaGoobiScript = config.getBoolean("copy-images-using-goobiscript", false);
useBarcodes = config.getBoolean("use-barcodes", false);
boolean useBarcodes = config.getBoolean("use-barcodes", false);
if (useBarcodes) {
barcodePool = Executors.newFixedThreadPool(2);
insertMode = "plugin_massupload_insertmode_barcode";
}
barcodePool = Executors.newFixedThreadPool(2);
processTitleMatchType = config.getString("match-type", "contains");

}
Expand Down Expand Up @@ -169,7 +173,7 @@ public void sortFiles() {
String currentBarcode = "";
Map<String, List<Process>> searchCache = new HashMap<>();
this.uploadedFiles.sort(Comparator.comparing(MassUploadedFile::getFilename));
if (useBarcodes) {
if ("plugin_massupload_insertmode_barcode".equals(insertMode)) {
for (MassUploadedFile muf : this.uploadedFiles) {
try {
if (!muf.isCheckedForBarcode()) {
Expand Down Expand Up @@ -214,7 +218,7 @@ private void saveFileTemporary(String fileName, InputStream in) throws IOExcepti
}
out.flush();
MassUploadedFile muf = new MassUploadedFile(file, fileName);
if (useBarcodes) {
if ("plugin_massupload_insertmode_barcode".equals(insertMode)) {
Callable<String> readBarcodeTask = () -> readBarcode(muf.getFile(), BarcodeFormat.CODE_128);
Future<String> futureBarcode = this.barcodePool.submit(readBarcodeTask);
String barcodeInfo = null;
Expand Down Expand Up @@ -258,7 +262,7 @@ public void readFilesFromUserHomeFolder() {
for (Path file : files) {
if (!Files.isDirectory(file) && !".DS_Store".equals(file.getFileName().toString())) {
MassUploadedFile muf = new MassUploadedFile(file.toFile(), file.getFileName().toString());
if (!useBarcodes) {
if ("plugin_massupload_insertmode_barcode".equals(insertMode)) {
assignProcessByFilename(muf, searchCache);
}
uploadedFiles.add(muf);
Expand Down

0 comments on commit 292d51a

Please sign in to comment.