forked from kitodo/kitodo-production
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of OCR-D workflow implementaiton
- Loading branch information
1 parent
e107408
commit c7e3aac
Showing
7 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...t/src/main/resources/db/migration/V2_125__Add_authority_and_fields_for_ocrd_workflows.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- | ||
-- (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 authority to assign OCR-D workflow in template or process details | ||
INSERT IGNORE INTO authority (title) VALUES ('assignOcrdWorkflow_clientAssignable'); | ||
|
||
-- Add column of OCR-D workflow identifier | ||
ALTER TABLE template ADD ocrd_workflow_id varchar(255) DEFAULT NULL; |
44 changes: 44 additions & 0 deletions
44
Kitodo/src/main/java/org/kitodo/production/converter/OcrdWorkflowConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* (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 org.apache.commons.lang3.StringUtils; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.kitodo.production.services.ServiceManager; | ||
|
||
import javax.faces.component.UIComponent; | ||
import javax.faces.context.FacesContext; | ||
import javax.faces.convert.Converter; | ||
import javax.inject.Named; | ||
import java.util.Objects; | ||
|
||
@Named | ||
public class OcrdWorkflowConverter extends BeanConverter implements Converter { | ||
|
||
@Override | ||
public Object getAsObject(FacesContext context, UIComponent component, String value) { | ||
if (StringUtils.isNotEmpty(value)) { | ||
return ServiceManager.getOcrdWorkflowService().getOcrdWorkflows().stream().filter(pair -> pair.getKey().equals(value)) | ||
.findFirst().get(); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getAsString(FacesContext context, UIComponent component, Object value) { | ||
if(Objects.nonNull(value) && value instanceof Pair) { | ||
return (String) ((Pair) value).getKey(); | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Kitodo/src/main/java/org/kitodo/production/services/ocr/OcrdWorkflowService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.production.services.ocr; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.commons.lang3.tuple.ImmutablePair; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.kitodo.production.services.ServiceManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class OcrdWorkflowService { | ||
|
||
private static volatile OcrdWorkflowService instance = null; | ||
|
||
/** | ||
* Return singleton variable of type OcrdWorkflowService. | ||
* | ||
* @return unique instance of OcrdWorkflowService | ||
*/ | ||
public static OcrdWorkflowService getInstance() { | ||
OcrdWorkflowService localReference = instance; | ||
if (Objects.isNull(localReference)) { | ||
synchronized (OcrdWorkflowService.class) { | ||
localReference = instance; | ||
if (Objects.isNull(localReference)) { | ||
localReference = new OcrdWorkflowService(); | ||
instance = localReference; | ||
} | ||
} | ||
} | ||
return localReference; | ||
} | ||
|
||
/** | ||
* Get OCR-D workflows - available means that ... | ||
* | ||
* @return list of OCR-D workflows objects | ||
*/ | ||
public List<Pair> getOcrdWorkflows() { | ||
List workflows = new ArrayList(); | ||
workflows.add(new ImmutablePair<>("1", "One")); | ||
workflows.add(new ImmutablePair<>("2", "Two")); | ||
workflows.add(new ImmutablePair<>("3", "Tree")); | ||
return workflows; | ||
} | ||
|
||
public Pair getOcrdWorkflow(String ocrdWorkflowId) { | ||
if (StringUtils.isNotEmpty(ocrdWorkflowId)) { | ||
return getOcrdWorkflows().stream().filter(pair -> pair.getKey().equals(ocrdWorkflowId)).findFirst().get(); | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters