* import properties from layoutparser
* add logging-commons
This commit is contained in:
parent
e744c488ef
commit
33ec43e15e
@ -11,18 +11,17 @@ plugins {
|
|||||||
|
|
||||||
description = "redaction-service-server-v1"
|
description = "redaction-service-server-v1"
|
||||||
|
|
||||||
extra["layoutparserVersion"] = "0.8.0"
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":redaction-service-api-v1"))
|
implementation(project(":redaction-service-api-v1"))
|
||||||
implementation("com.iqser.red.service:persistence-service-internal-api-v1:RED-6725")
|
implementation("com.iqser.red.service:persistence-service-internal-api-v1:RED-6725-3")
|
||||||
implementation("com.knecon.fforesight:layoutparser-service-internal-api:0.16.0")
|
implementation("com.knecon.fforesight:layoutparser-service-internal-api:0.17.0")
|
||||||
|
|
||||||
implementation("com.iqser.red.commons:spring-commons:2.1.0") { exclude(group = "org.springframework.boot", module = "spring-boot-starter-log4j2") }
|
implementation("com.iqser.red.commons:spring-commons:2.1.0") { exclude(group = "org.springframework.boot", module = "spring-boot-starter-log4j2") }
|
||||||
implementation("com.iqser.red.commons:metric-commons:2.1.0") { exclude(group = "org.springframework.boot", module = "spring-boot-starter-log4j2") }
|
implementation("com.iqser.red.commons:metric-commons:2.1.0") { exclude(group = "org.springframework.boot", module = "spring-boot-starter-log4j2") }
|
||||||
|
|
||||||
implementation("com.iqser.red.commons:dictionary-merge-commons:1.3.0")
|
implementation("com.iqser.red.commons:dictionary-merge-commons:1.3.0")
|
||||||
implementation("com.iqser.red.commons:storage-commons:2.1.0")
|
implementation("com.iqser.red.commons:storage-commons:2.1.0")
|
||||||
|
implementation("com.iqser.red.commons:logging-commons:2.3.0")
|
||||||
implementation("com.knecon.fforesight:tenant-commons:0.10.0")
|
implementation("com.knecon.fforesight:tenant-commons:0.10.0")
|
||||||
|
|
||||||
implementation("org.springframework.boot:spring-boot-starter-aop:3.0.4")
|
implementation("org.springframework.boot:spring-boot-starter-aop:3.0.4")
|
||||||
@ -37,13 +36,14 @@ dependencies {
|
|||||||
|
|
||||||
implementation("org.locationtech.jts:jts-core:1.19.0")
|
implementation("org.locationtech.jts:jts-core:1.19.0")
|
||||||
|
|
||||||
|
implementation("org.springframework.cloud:spring-cloud-starter-openfeign:4.0.1")
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-amqp:3.0.4")
|
||||||
|
|
||||||
testImplementation("org.apache.pdfbox:pdfbox:3.0.0-alpha2")
|
testImplementation("org.apache.pdfbox:pdfbox:3.0.0-alpha2")
|
||||||
testImplementation("org.apache.pdfbox:pdfbox-tools:3.0.0-alpha2")
|
testImplementation("org.apache.pdfbox:pdfbox-tools:3.0.0-alpha2")
|
||||||
|
|
||||||
implementation("org.springframework.cloud:spring-cloud-starter-openfeign:4.0.1")
|
|
||||||
implementation("org.springframework.boot:spring-boot-starter-amqp:3.0.4")
|
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4")
|
testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4")
|
||||||
testImplementation("com.knecon.fforesight:layoutparser-service-processor:0.16.0") { exclude(group = "com.iqser.red.service", module = "persistence-service-shared-api-v1") }
|
testImplementation("com.knecon.fforesight:layoutparser-service-processor:0.17.0") { exclude(group = "com.iqser.red.service", module = "persistence-service-shared-api-v1") }
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
|
|||||||
@ -1,109 +1,51 @@
|
|||||||
package com.iqser.red.service.redaction.v1.server.document.data.mapper;
|
package com.iqser.red.service.redaction.v1.server.document.data.mapper;
|
||||||
|
|
||||||
import static java.lang.String.format;
|
|
||||||
|
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.iqser.red.service.redaction.v1.server.document.graph.nodes.Image;
|
import com.iqser.red.service.redaction.v1.server.document.graph.nodes.Image;
|
||||||
import com.iqser.red.service.redaction.v1.server.document.graph.nodes.TableCell;
|
|
||||||
import com.iqser.red.service.redaction.v1.server.document.graph.nodes.ImageType;
|
import com.iqser.red.service.redaction.v1.server.document.graph.nodes.ImageType;
|
||||||
import com.iqser.red.service.redaction.v1.server.document.graph.nodes.Table;
|
import com.iqser.red.service.redaction.v1.server.document.graph.nodes.Table;
|
||||||
|
import com.iqser.red.service.redaction.v1.server.document.graph.nodes.TableCell;
|
||||||
|
import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructure;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.experimental.FieldDefaults;
|
import lombok.experimental.FieldDefaults;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
|
||||||
public class PropertiesMapper {
|
public class PropertiesMapper {
|
||||||
|
|
||||||
String imageType = "imageType";
|
|
||||||
private final String transparency = "transparency";
|
|
||||||
private final String position = "position";
|
|
||||||
String id = "id";
|
|
||||||
String row = "row";
|
|
||||||
String col = "col";
|
|
||||||
String header = "header";
|
|
||||||
String bBox = "bBox";
|
|
||||||
String numberOfRows = "numberOfRows";
|
|
||||||
String numberOfCols = "numberOfCols";
|
|
||||||
|
|
||||||
|
|
||||||
public Map<String, String> buildImageProperties(Image image) {
|
|
||||||
|
|
||||||
Map<String, String> properties = new HashMap<>();
|
|
||||||
properties.put(imageType, image.getImageType().toString());
|
|
||||||
properties.put(transparency, String.valueOf(image.isTransparent()));
|
|
||||||
properties.put(position, toString(image.getPosition()));
|
|
||||||
properties.put(id, image.getId());
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String toString(Rectangle2D rectangle2D) {
|
|
||||||
|
|
||||||
return format("%f,%f,%f,%f", rectangle2D.getX(), rectangle2D.getY(), rectangle2D.getWidth(), rectangle2D.getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Map<String, String> buildTableCellProperties(TableCell tableCell) {
|
|
||||||
|
|
||||||
Map<String, String> properties = new HashMap<>();
|
|
||||||
properties.put(row, String.valueOf(tableCell.getRow()));
|
|
||||||
properties.put(col, String.valueOf(tableCell.getCol()));
|
|
||||||
properties.put(header, String.valueOf(tableCell.isHeader()));
|
|
||||||
|
|
||||||
if (tableCell.getPages().size() > 1 || tableCell.getBBox().keySet().size() > 1) {
|
|
||||||
throw new IllegalArgumentException("TableCell can only occur on a single page!");
|
|
||||||
}
|
|
||||||
String bBoxString = toString(tableCell.getBBox().get(tableCell.getPages().stream().findFirst().get()));
|
|
||||||
properties.put(bBox, bBoxString);
|
|
||||||
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Map<String, String> buildTableProperties(Table table) {
|
|
||||||
|
|
||||||
Map<String, String> properties = new HashMap<>();
|
|
||||||
properties.put(numberOfRows, String.valueOf(table.getNumberOfRows()));
|
|
||||||
properties.put(numberOfCols, String.valueOf(table.getNumberOfCols()));
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void parseImageProperties(Map<String, String> properties, Image.ImageBuilder builder) {
|
public void parseImageProperties(Map<String, String> properties, Image.ImageBuilder builder) {
|
||||||
|
|
||||||
builder.imageType(ImageType.fromString(properties.get(imageType)));
|
builder.imageType(ImageType.fromString(properties.get(DocumentStructure.ImageProperties.IMAGE_TYPE)));
|
||||||
builder.transparent(Boolean.parseBoolean(properties.get(transparency)));
|
builder.transparent(Boolean.parseBoolean(properties.get(DocumentStructure.ImageProperties.TRANSPARENT)));
|
||||||
builder.position(parseRectangle2D(properties.get(position)));
|
builder.position(parseRectangle2D(properties.get(DocumentStructure.ImageProperties.POSITION)));
|
||||||
builder.id(properties.get(id));
|
builder.id(properties.get(DocumentStructure.ImageProperties.ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void parseTableCellProperties(Map<String, String> properties, TableCell.TableCellBuilder builder) {
|
public void parseTableCellProperties(Map<String, String> properties, TableCell.TableCellBuilder builder) {
|
||||||
|
|
||||||
builder.row(Integer.parseInt(properties.get(row)));
|
builder.row(Integer.parseInt(properties.get(DocumentStructure.TableCellProperties.ROW)));
|
||||||
builder.col(Integer.parseInt(properties.get(col)));
|
builder.col(Integer.parseInt(properties.get(DocumentStructure.TableCellProperties.COL)));
|
||||||
builder.header(Boolean.parseBoolean(properties.get(header)));
|
builder.header(Boolean.parseBoolean(properties.get(DocumentStructure.TableCellProperties.HEADER)));
|
||||||
builder.bBox(parseRectangle2D(properties.get(bBox)));
|
builder.bBox(parseRectangle2D(properties.get(DocumentStructure.TableCellProperties.B_BOX)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void parseTableProperties(Map<String, String> properties, Table.TableBuilder builder) {
|
public void parseTableProperties(Map<String, String> properties, Table.TableBuilder builder) {
|
||||||
|
|
||||||
builder.numberOfRows(Integer.parseInt(properties.get(numberOfRows)));
|
builder.numberOfRows(Integer.parseInt(properties.get(DocumentStructure.TableProperties.NUMBER_OF_ROWS)));
|
||||||
builder.numberOfCols(Integer.parseInt(properties.get(numberOfCols)));
|
builder.numberOfCols(Integer.parseInt(properties.get(DocumentStructure.TableProperties.NUMBER_OF_COLS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Rectangle2D parseRectangle2D(String bBox) {
|
private Rectangle2D parseRectangle2D(String bBox) {
|
||||||
|
|
||||||
List<Float> floats = Arrays.stream(bBox.split(",")).map(Float::parseFloat).toList();
|
List<Float> floats = Arrays.stream(bBox.split(DocumentStructure.RECTANGLE_DELIMITER)).map(Float::parseFloat).toList();
|
||||||
return new Rectangle2D.Float(floats.get(0), floats.get(1), floats.get(2), floats.get(3));
|
return new Rectangle2D.Float(floats.get(0), floats.get(1), floats.get(2), floats.get(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user