Skip to content

Commit

Permalink
feat: take account new document guarantee category
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien committed Jan 29, 2024
1 parent a3e9641 commit 1892d41
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected boolean modelMatches(PDPage page, PageExtractorModel model) throws IOE
}
@Override
public boolean shouldTryToApply(File file) {
return (file.getDocument().getDocumentCategory() == DocumentCategory.IDENTIFICATION
return (file.getDocument().getDocumentCategory() == DocumentCategory.GUARANTEE_PROVIDER_CERTIFICATE
&& file.getDocument().getDocumentSubCategory() == OTHER_GUARANTEE
&& MediaType.APPLICATION_PDF_VALUE.equalsIgnoreCase(file.getStorageFile().getContentType()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected boolean modelMatches(PDPage page, PageExtractorModel model) throws IOE

@Override
public boolean shouldTryToApply(File file) {
return (file.getDocument().getDocumentCategory() == DocumentCategory.IDENTIFICATION
return (file.getDocument().getDocumentCategory() == DocumentCategory.GUARANTEE_PROVIDER_CERTIFICATE
&& file.getDocument().getDocumentSubCategory() == OTHER_GUARANTEE
&& MediaType.APPLICATION_PDF_VALUE.equalsIgnoreCase(file.getStorageFile().getContentType()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.extern.slf4j.Slf4j;
import net.sourceforge.tess4j.ITessAPI;
import net.sourceforge.tess4j.Tesseract;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

import java.awt.*;
Expand All @@ -18,6 +19,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static fr.dossierfacile.common.enums.DocumentSubCategory.OTHER_GUARANTEE;
import static fr.dossierfacile.common.enums.DocumentSubCategory.VISALE;

/**
Expand All @@ -26,6 +28,7 @@
@Service
@Slf4j
@RequiredArgsConstructor
@Order(3)
public class GuaranteeVisaleParser extends AbstractSinglePageImageOcrParser<GuaranteeProviderFile> implements FileParser<GuaranteeProviderFile> {
static final Zones ZONES = new Zones(
new Rectangle(120, 150, 370, 30),
Expand Down Expand Up @@ -101,8 +104,9 @@ public GuaranteeProviderFile parse(BufferedImage image) {

@Override
public boolean shouldTryToApply(File file) {
return (file.getDocument().getDocumentCategory() == DocumentCategory.IDENTIFICATION
&& file.getDocument().getDocumentSubCategory() == VISALE);
return (file.getDocument().getDocumentCategory() == DocumentCategory.GUARANTEE_PROVIDER_CERTIFICATE
&& (file.getDocument().getDocumentSubCategory() == VISALE
|| file.getDocument().getDocumentSubCategory() == OTHER_GUARANTEE));// TODO currently there is not way to selection VISALE subcategory on UI
}

public record Zones(Rectangle zoneTitle, Rectangle zoneIdentification, Rectangle zoneValidityDate) {
Expand Down

0 comments on commit 1892d41

Please sign in to comment.