Compare commits

...
Author SHA1 Message Date
deiflaender 06b2b964bd DEV: Added fonts 2020-11-17 14:28:55 +01:00
deiflaender 44d365ca84 Fixed positions 2020-11-17 13:56:55 +01:00
5 changed files with 64 additions and 38 deletions
@@ -7,3 +7,12 @@ ENV PLATFORM_JAR ${PLATFORM_JAR}
ENV USES_ELASTICSEARCH false
COPY ["${PLATFORM_JAR}", "/"]
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
wget cabextract xfonts-utils fonts-liberation \
&& rm -rf /var/lib/apt/lists/*
RUN curl http://ftp.br.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.7_all.deb -o /tmp/ttf-mscorefonts-installer_3.7_all.deb \
&& dpkg -i /tmp/ttf-mscorefonts-installer_3.7_all.deb \
&& rm /tmp/ttf-mscorefonts-installer_3.7_all.deb \
@@ -56,7 +56,18 @@ public class RedactionController implements RedactionResource {
return convert(flatDocument, classifiedDoc.getPages().size(), classifiedDoc.getRedactionLogEntities());
}
return convert(pdDocument, classifiedDoc.getPages().size(), classifiedDoc.getRedactionLogEntities());
RedactionResult result = convert(pdDocument, classifiedDoc.getPages().size(), classifiedDoc.getRedactionLogEntities());
result.getRedactionLog().getRedactionLogEntry().forEach(entry -> {
entry.getPositions().forEach(pos -> {
if(pos.getPage() == 28 && entry.getValue().equals("Shults")){
System.out.println(entry);
}
});
});
return result;
} catch (IOException e) {
throw new RedactionException(e);
@@ -210,7 +210,7 @@ public class TextPositionSequence implements CharSequence {
.getYDirAdj() + 2;
}
return new Rectangle(new Point(posXInit, posYInit), posXEnd - posXInit, posYEnd - posYInit + height, page);
return new Rectangle(new Point(posXInit - 0.00001f, posYInit), posXEnd - posXInit , posYEnd - posYInit + height, page);
}
@@ -14,17 +14,15 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.kie.api.KieServices;
@@ -40,21 +38,16 @@ import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.junit4.SpringRunner;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.configuration.v1.api.model.Colors;
import com.iqser.red.service.configuration.v1.api.model.DictionaryResponse;
import com.iqser.red.service.configuration.v1.api.model.RulesResponse;
import com.iqser.red.service.configuration.v1.api.model.TypeResponse;
import com.iqser.red.service.configuration.v1.api.model.TypeResult;
import com.iqser.red.service.redaction.v1.model.Comment;
import com.iqser.red.service.redaction.v1.model.IdRemoval;
import com.iqser.red.service.redaction.v1.model.ManualRedactionEntry;
import com.iqser.red.service.redaction.v1.model.ManualRedactions;
import com.iqser.red.service.redaction.v1.model.Point;
import com.iqser.red.service.redaction.v1.model.Rectangle;
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
import com.iqser.red.service.redaction.v1.model.RedactionRequest;
import com.iqser.red.service.redaction.v1.model.RedactionResult;
import com.iqser.red.service.redaction.v1.model.Status;
import com.iqser.red.service.redaction.v1.server.client.DictionaryClient;
import com.iqser.red.service.redaction.v1.server.client.RulesClient;
import com.iqser.red.service.redaction.v1.server.controller.RedactionController;
@@ -342,41 +335,49 @@ public class RedactionIntegrationTest {
System.out.println("numberOfPages: " + result.getNumberOfPages());
}
@Autowired
private ObjectMapper objectMapper;
@Ignore
@Test
public void testManualRedaction() throws IOException {
ClassPathResource redactionLogResource = new ClassPathResource("files/ManualRedactions.json");
ManualRedactions manualRedactions = objectMapper.readValue(redactionLogResource.getInputStream(), ManualRedactions.class);
System.out.println("testManualRedaction");
long start = System.currentTimeMillis();
ClassPathResource pdfFileResource = new ClassPathResource("files/Minimal Examples/Single Table.pdf");
ClassPathResource pdfFileResource = new ClassPathResource("files/21 Chlorothalonil RAR 11 Volume 3CA B 9 August 2017.pdf");
ManualRedactions manualRedactions = new ManualRedactions();
// ManualRedactions manualRedactions = new ManualRedactions();
//
// String manualAddId = UUID.randomUUID().toString();
//
// Comment comment = Comment.builder()
// .date(OffsetDateTime.now())
// .user("TEST_USER")
// .text("This is a comment test")
// .build();
// manualRedactions.setIdsToRemove(Set.of(IdRemoval.builder()
// .id("0836727c3508a0b2ea271da69c04cc2f")
// .status(Status.REQUESTED)
// .build()));
//
// manualRedactions.getComments().put("e5be0f1d941bbb92a068e198648d06c4", List.of(comment));
// manualRedactions.getComments().put("0836727c3508a0b2ea271da69c04cc2f", List.of(comment));
// manualRedactions.getComments().put(manualAddId, List.of(comment));
//
// ManualRedactionEntry manualRedactionEntry = new ManualRedactionEntry();
// manualRedactionEntry.setId(manualAddId);
// manualRedactionEntry.setStatus(Status.REQUESTED);
// manualRedactionEntry.setType("name");
// manualRedactionEntry.setValue("O'Loughlin C.K.");
// manualRedactionEntry.setReason("Manual Redaction");
// manualRedactionEntry.setPositions(List.of(new Rectangle(new Point(375.61096f, 241.282f), 7.648041f, 43.72262f, 1), new Rectangle(new Point(384.83517f, 241.282f), 7.648041f, 17.043358f, 1)));
String manualAddId = UUID.randomUUID().toString();
Comment comment = Comment.builder()
.date(OffsetDateTime.now())
.user("TEST_USER")
.text("This is a comment test")
.build();
manualRedactions.setIdsToRemove(Set.of(IdRemoval.builder()
.id("0836727c3508a0b2ea271da69c04cc2f")
.status(Status.REQUESTED)
.build()));
manualRedactions.getComments().put("e5be0f1d941bbb92a068e198648d06c4", List.of(comment));
manualRedactions.getComments().put("0836727c3508a0b2ea271da69c04cc2f", List.of(comment));
manualRedactions.getComments().put(manualAddId, List.of(comment));
ManualRedactionEntry manualRedactionEntry = new ManualRedactionEntry();
manualRedactionEntry.setId(manualAddId);
manualRedactionEntry.setStatus(Status.REQUESTED);
manualRedactionEntry.setType("name");
manualRedactionEntry.setValue("O'Loughlin C.K.");
manualRedactionEntry.setReason("Manual Redaction");
manualRedactionEntry.setPositions(List.of(new Rectangle(new Point(375.61096f, 241.282f), 7.648041f, 43.72262f, 1), new Rectangle(new Point(384.83517f, 241.282f), 7.648041f, 17.043358f, 1)));
manualRedactions.getEntriesToAdd().add(manualRedactionEntry);
// manualRedactions.getEntriesToAdd().add(manualRedactionEntry);
RedactionRequest request = RedactionRequest.builder()
.document(IOUtils.toByteArray(pdfFileResource.getInputStream()))
@@ -388,6 +389,11 @@ public class RedactionIntegrationTest {
try (FileOutputStream fileOutputStream = new FileOutputStream("/tmp/Redacted.pdf")) {
fileOutputStream.write(result.getDocument());
}
try (FileOutputStream fileOutputStream = new FileOutputStream("/tmp/logX.txt")) {
fileOutputStream.write(objectMapper.writeValueAsBytes(result.getRedactionLog()));
}
long end = System.currentTimeMillis();
System.out.println("duration: " + (end - start));