-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OCR-D Workflow integration #5697
Changes from 51 commits
3a5aaa6
4672dd1
8d6809a
54f0d93
de02bb5
c041fc3
35637f0
b59203a
df3b6f5
6ae0344
805637a
c737e71
a227bbd
922ae8e
464b861
c450ad3
ff53014
18ff2d8
7055ef3
7380441
b57a3f2
319727e
bfd037e
3b23eb9
305bb06
d3e53ca
980cfa0
0a3ca19
8197c62
ac4883e
5a22270
138c740
525091e
28ae981
7f78c38
73f39e3
980c322
abf063f
8790fff
7e7ab3a
2ec1b19
64203e0
3f76202
2127a97
3a736ef
ec84969
b1de092
db660b4
23944ba
6686042
90b63e6
2cb746c
540ed9d
0c7f4f6
2fc9af5
5cb74c5
20c3d4e
d39a62a
17cbade
d57cd7b
10d03b9
651d710
01d275d
347f6ee
8e389d4
67e5ecc
453ab22
ecbae9e
ffc58d1
e76a770
aa4ac13
42480ff
93f6aa9
08c746f
587aa3e
5a90f0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* This file is part of the Kitodo project. | ||
* | ||
* It is licensed under GNU General Public License version 3 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* GPL3-License.txt file that was distributed with this source code. | ||
*/ | ||
|
||
package org.kitodo.data.database.beans; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.ForeignKey; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
|
||
@Entity | ||
@Table(name = "ocrworkflow") | ||
public class OCRWorkflow extends BaseBean { | ||
|
||
@Column(name = "title") | ||
private String title; | ||
|
||
@Column(name = "file") | ||
private String file; | ||
|
||
@Column(name = "active") | ||
private Boolean active = true; | ||
markusweigelt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@ManyToOne | ||
@JoinColumn(name = "client_id", foreignKey = @ForeignKey(name = "FK_ocrworkflow_client_id")) | ||
private Client client; | ||
|
||
public String getTitle() { | ||
return this.title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getFile() { | ||
return this.file; | ||
} | ||
|
||
public void setFile(String file) { | ||
this.file = file; | ||
} | ||
|
||
/** | ||
* Check if ocr workflow is active. | ||
* | ||
* @return true or false | ||
*/ | ||
public Boolean isActive() { | ||
if (Objects.isNull(this.active)) { | ||
markusweigelt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.active = true; | ||
} | ||
return this.active; | ||
} | ||
|
||
/** | ||
* Set ruleset as active. | ||
markusweigelt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* @param active as boolean | ||
*/ | ||
public void setActive(boolean active) { | ||
this.active = active; | ||
} | ||
|
||
|
||
/** | ||
* Get client. | ||
* | ||
* @return Client object | ||
*/ | ||
public Client getClient() { | ||
return this.client; | ||
} | ||
|
||
/** | ||
* Set client. | ||
* | ||
* @param client | ||
* as Client object | ||
*/ | ||
public void setClient(Client client) { | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object object) { | ||
if (this == object) { | ||
return true; | ||
} | ||
|
||
if (object instanceof OCRWorkflow) { | ||
OCRWorkflow ruleset = (OCRWorkflow) object; | ||
markusweigelt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return Objects.equals(this.getId(), ruleset.getId()); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(title, file, active); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,10 @@ public class Process extends BaseTemplateBean { | |
@JoinColumn(name = "docket_id", foreignKey = @ForeignKey(name = "FK_process_docket_id")) | ||
private Docket docket; | ||
|
||
@ManyToOne | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add corresponding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have such a corresponding relationship for similar examples, for example Ruleset or Docket and we don't need this relationship atm. If the relationship is needed then we should add it later and provide an appropriate migration script. I want to customize the data structure only for the cases which are really needed. @solth What do you mean? |
||
@JoinColumn(name = "ocr_workflow_id", foreignKey = @ForeignKey(name = "FK_process_ocr_workflow_id")) | ||
private OCRWorkflow ocrWorkflow; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "project_id", foreignKey = @ForeignKey(name = "FK_process_project_id")) | ||
private Project project; | ||
|
@@ -289,6 +293,25 @@ public void setDocket(Docket docket) { | |
this.docket = docket; | ||
} | ||
|
||
/** | ||
* Get ocr workflow. | ||
* | ||
* @return value of ocr workflow | ||
*/ | ||
public OCRWorkflow getOcrWorkflow() { | ||
return ocrWorkflow; | ||
} | ||
|
||
/** | ||
* Set ocr workflow. | ||
* | ||
* @param ocrWorkflow | ||
* as Workflow object | ||
*/ | ||
public void setOcrWorkflow(OCRWorkflow ocrWorkflow) { | ||
this.ocrWorkflow = ocrWorkflow; | ||
} | ||
|
||
/** | ||
* Get template. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* This file is part of the Kitodo project. | ||
* | ||
* It is licensed under GNU General Public License version 3 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* GPL3-License.txt file that was distributed with this source code. | ||
*/ | ||
|
||
package org.kitodo.data.database.persistence; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.kitodo.data.database.beans.OCRWorkflow; | ||
import org.kitodo.data.database.exceptions.DAOException; | ||
|
||
public class OCRWorkflowDAO extends BaseDAO<OCRWorkflow> { | ||
|
||
@Override | ||
public OCRWorkflow getById(Integer id) throws DAOException { | ||
OCRWorkflow ocrWorkflow = retrieveObject(OCRWorkflow.class, id); | ||
if (Objects.isNull(ocrWorkflow)) { | ||
throw new DAOException("Object cannot be found in database"); | ||
} | ||
return ocrWorkflow; | ||
} | ||
|
||
@Override | ||
public List<OCRWorkflow> getAll() throws DAOException { | ||
return retrieveAllObjects(OCRWorkflow.class); | ||
} | ||
|
||
@Override | ||
public List<OCRWorkflow> getAll(int offset, int size) throws DAOException { | ||
return retrieveObjects("FROM OCRWorkflow ORDER BY id ASC", offset, size); | ||
} | ||
|
||
@Override | ||
public List<OCRWorkflow> getAllNotIndexed(int offset, int size) throws DAOException { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void remove(Integer ocrWorkflowId) throws DAOException { | ||
removeObject(OCRWorkflow.class, ocrWorkflowId); | ||
} | ||
|
||
/** | ||
* Get available ocr workflows - available means that ocr workflow has status active and is | ||
* assigned to client with given id. | ||
* | ||
* @param clientId | ||
* id of client to which searched ocr workflows should be assigned | ||
* @return list of available ocr workflow objects | ||
*/ | ||
public List<OCRWorkflow> getAvailableOCRWorkflows(int clientId) { | ||
return getByQuery( | ||
"SELECT w FROM OCRWorkflow AS w INNER JOIN w.client AS c WITH c.id = :clientId", | ||
Collections.singletonMap("clientId", clientId)); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- | ||
-- (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
-- | ||
-- This file is part of the Kitodo project. | ||
-- | ||
-- It is licensed under GNU General Public License version 3 or later. | ||
-- | ||
-- For the full copyright and license information, please read the | ||
-- GPL3-License.txt file that was distributed with this source code. | ||
-- | ||
|
||
-- Add authorities to manage ocr workflows | ||
INSERT IGNORE INTO authority (title) VALUES ('addOCRWorkflow_clientAssignable'); | ||
INSERT IGNORE INTO authority (title) VALUES ('editOCRWorkflow_clientAssignable'); | ||
INSERT IGNORE INTO authority (title) VALUES ('deleteOCRWorkflow_clientAssignable'); | ||
INSERT IGNORE INTO authority (title) VALUES ('viewOCRWorkflow_clientAssignable'); | ||
|
||
-- Add table "ocrworkflow" | ||
CREATE TABLE IF NOT EXISTS ocrworkflow ( | ||
id INT(10) NOT NULL AUTO_INCREMENT, | ||
title varchar(255) NOT NULL, | ||
file varchar(255) NOT NULL, | ||
active tinyint(1) DEFAULT NULL, | ||
markusweigelt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
client_id INT(10) NOT NULL, | ||
PRIMARY KEY(id) | ||
) DEFAULT CHARACTER SET = utf8mb4 | ||
COLLATE utf8mb4_unicode_ci; | ||
|
||
-- Add column related to ocr workflow to process table | ||
ALTER TABLE process ADD ocr_workflow_id INT(11) DEFAULT NULL; | ||
|
||
-- Add foreign key | ||
ALTER TABLE process add constraint `FK_process_ocr_workflow_id` | ||
foreign key (ocr_workflow_id) REFERENCES ocrworkflow(id); | ||
|
||
-- Add column related to ocr workflow to template table | ||
ALTER TABLE template ADD ocr_workflow_id INT(11) DEFAULT NULL; | ||
|
||
-- Add foreign key | ||
ALTER TABLE template add constraint `FK_template_ocr_workflow_id` | ||
foreign key (ocr_workflow_id) REFERENCES ocrworkflow(id); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* This file is part of the Kitodo project. | ||
* | ||
* It is licensed under GNU General Public License version 3 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* GPL3-License.txt file that was distributed with this source code. | ||
*/ | ||
|
||
package org.kitodo.production.converter; | ||
|
||
import javax.faces.component.UIComponent; | ||
import javax.faces.context.FacesContext; | ||
import javax.faces.convert.Converter; | ||
import javax.inject.Named; | ||
|
||
import org.kitodo.production.services.ServiceManager; | ||
|
||
@Named | ||
public class OCRWorkflowConverter extends BeanConverter implements Converter { | ||
|
||
@Override | ||
public Object getAsObject(FacesContext context, UIComponent component, String value) { | ||
return getAsObject(ServiceManager.getOCRWorkflowService(), value); | ||
} | ||
|
||
@Override | ||
public String getAsString(FacesContext context, UIComponent component, Object value) { | ||
return getAsString(value, "ocrWorkflow"); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The term workflow is already in use in Production with a different meaning. Maybe we can find a not-yet-used name for this class, like OCR configuration (
OcrConfig
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That ambiguity is well known and oft discussed. So far, I have never seen a good counter proposal. OCR configuration gets closest indeed – I could live with that.
Within ocrd_kitodo documentation, though, we decided to use workflow and always disambiguate between (organisational) Kitodo Workflow and (technical) OCR Workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the term
OCR Configuration
misleading. It reminds me of the configuration to an OCR server or a more general configuration. What is withOCR Processing
,OCR Recipe
or directlyOCR Profile
. I thinkOCR Profile
sounds good for me! It may contain a workflow field and can be linked to a later profile implementation in the monitor.In addition, we would have to document well that the workflows in the OCR-D environment are meant with this term, but that is the case with all terms i think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, configuration may not be so good after all. Yes, OCR profile would also be acceptable, if properly explained/documented, as indeed would have to be done in any case.