Skip to content

Commit

Permalink
Solve checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
markusweigelt committed Oct 11, 2023
1 parent e56b722 commit 1ebde37
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,32 @@

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 java.util.Objects;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.inject.Named;
import java.util.Objects;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.kitodo.production.services.ServiceManager;


@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 ServiceManager.getOcrdWorkflowService().getOcrdWorkflow(value);
}
return null;
}

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if(Objects.nonNull(value) && value instanceof Pair) {
if (Objects.nonNull(value) && value instanceof Pair) {
return (String) ((Pair) value).getKey();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ public Pair getOcrdWorkflow() {
*/
public void setOcrdWorkflow(Pair ocrdWorkflow) {
String ocrdWorkflowId = StringUtils.EMPTY;
if(Objects.nonNull(ocrdWorkflow)) {
if (Objects.nonNull(ocrdWorkflow)) {
ocrdWorkflowId = ocrdWorkflow.getKey().toString();
}
process.setOcrdWorkflowId(ocrdWorkflowId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public Pair getOcrdWorkflow() {
*/
public void setOcrdWorkflow(Pair ocrdWorkflow) {
String ocrdWorkflowId = StringUtils.EMPTY;
if(Objects.nonNull(ocrdWorkflow)) {
if (Objects.nonNull(ocrdWorkflow)) {
ocrdWorkflowId = ocrdWorkflow.getKey().toString();
}
template.setOcrdWorkflowId(ocrdWorkflowId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ private enum MetadataLevel {
* be replaced.
*/
private static final Pattern VARIABLE_FINDER_REGEX = Pattern.compile(
"(\\$?)\\((?:(prefs|processid|processtitle|projectid|" + "stepid|stepname|generatorsource|generatorsourcepath|ocrdworkflowid)|" + "(?:(meta|process|product|template)\\.(?:(firstchild|topstruct)\\.)?([^)]+)|" + "(?:(filename|basename|relativepath))))\\)");

"(\\$?)\\((?:(prefs|processid|processtitle|projectid|stepid|stepname|generatorsource|generatorsourcepath|ocrdworkflowid)|"
+ "(?:(meta|process|product|template)\\.(?:(firstchild|topstruct)\\.)?([^)]+)|"
+ "(?:(filename|basename|relativepath))))\\)");
/**
* The map is filled with replacement instructions that are required for
* backwards compatibility with version 2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@

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.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kitodo.config.ConfigCore;
import org.kitodo.config.enums.ParameterCore;

import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitOption;
Expand All @@ -30,6 +22,14 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kitodo.config.ConfigCore;
import org.kitodo.config.enums.ParameterCore;

public class OcrdWorkflowService {

private static final Logger logger = LogManager.getLogger(OcrdWorkflowService.class);
Expand Down Expand Up @@ -83,8 +83,8 @@ public List<Pair> getOcrdWorkflows() {
/**
* Get an OCR-D workflow by identifier.
*
* @param ocrdWorkflowId
* @return
* @param ocrdWorkflowId The OCR-D workflow identifier
* @return The OCR-D workflow
*/
public Pair getOcrdWorkflow(String ocrdWorkflowId) {
if (StringUtils.isNotEmpty(ocrdWorkflowId)) {
Expand Down

0 comments on commit 1ebde37

Please sign in to comment.