RED-5232: Reformatted whole project with new style
This commit is contained in:
parent
2a933fb2d7
commit
e60a312cb6
@ -1,4 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ public class PlanSpec {
|
||||
|
||||
private static final String SERVICE_KEY = SERVICE_NAME.toUpperCase().replaceAll("-", "");
|
||||
|
||||
|
||||
/**
|
||||
* Run main to publish plan on Bamboo
|
||||
*/
|
||||
@ -58,9 +59,15 @@ public class PlanSpec {
|
||||
bambooServer.publish(secPlanPermission);
|
||||
}
|
||||
|
||||
|
||||
private PlanPermissions createPlanPermission(PlanIdentifier planIdentifier) {
|
||||
Permissions permission = new Permissions()
|
||||
.userPermissions("atlbamboo", PermissionType.EDIT, PermissionType.VIEW, PermissionType.ADMIN, PermissionType.CLONE, PermissionType.BUILD)
|
||||
|
||||
Permissions permission = new Permissions().userPermissions("atlbamboo",
|
||||
PermissionType.EDIT,
|
||||
PermissionType.VIEW,
|
||||
PermissionType.ADMIN,
|
||||
PermissionType.CLONE,
|
||||
PermissionType.BUILD)
|
||||
.groupPermissions("development", PermissionType.EDIT, PermissionType.VIEW, PermissionType.CLONE, PermissionType.BUILD)
|
||||
.groupPermissions("devplant", PermissionType.EDIT, PermissionType.VIEW, PermissionType.CLONE, PermissionType.BUILD)
|
||||
.loggedInUserPermissions(PermissionType.VIEW)
|
||||
@ -68,104 +75,52 @@ public class PlanSpec {
|
||||
return new PlanPermissions(planIdentifier.getProjectKey(), planIdentifier.getPlanKey()).permissions(permission);
|
||||
}
|
||||
|
||||
|
||||
private Project project() {
|
||||
return new Project()
|
||||
.name("RED")
|
||||
.key(new BambooKey("RED"));
|
||||
|
||||
return new Project().name("RED").key(new BambooKey("RED"));
|
||||
}
|
||||
|
||||
|
||||
public Plan createPlan() {
|
||||
return new Plan(
|
||||
project(),
|
||||
SERVICE_NAME, new BambooKey(SERVICE_KEY))
|
||||
.description("Plan created from (enter repository url of your plan)")
|
||||
|
||||
return new Plan(project(), SERVICE_NAME, new BambooKey(SERVICE_KEY)).description("Plan created from (enter repository url of your plan)")
|
||||
.variables(new Variable("maven_add_param", ""))
|
||||
.stages(new Stage("Default Stage")
|
||||
.jobs(new Job("Default Job",
|
||||
new BambooKey("JOB1"))
|
||||
.tasks(
|
||||
new ScriptTask()
|
||||
.description("Clean")
|
||||
.inlineBody("#!/bin/bash\n" +
|
||||
"set -e\n" +
|
||||
"rm -rf ./*"),
|
||||
new VcsCheckoutTask()
|
||||
.description("Checkout Default Repository")
|
||||
.cleanCheckout(true)
|
||||
.checkoutItems(new CheckoutItem().defaultRepository()),
|
||||
new ScriptTask()
|
||||
.description("Build")
|
||||
.location(Location.FILE)
|
||||
.fileFromPath("bamboo-specs/src/main/resources/scripts/build-java.sh")
|
||||
.argument(SERVICE_NAME),
|
||||
createJUnitParserTask()
|
||||
.description("Resultparser")
|
||||
.resultDirectories("**/test-reports/*.xml, **/target/surefire-reports/*.xml, **/target/failsafe-reports/*.xml")
|
||||
.enabled(true),
|
||||
new InjectVariablesTask()
|
||||
.description("Inject git Tag")
|
||||
.path("git.tag")
|
||||
.namespace("g")
|
||||
.scope(InjectVariablesScope.LOCAL),
|
||||
new VcsTagTask()
|
||||
.description("${bamboo.g.gitTag}")
|
||||
.tagName("${bamboo.g.gitTag}")
|
||||
.defaultRepository())
|
||||
.dockerConfiguration(
|
||||
new DockerConfiguration()
|
||||
.image("nexus.iqser.com:5001/infra/maven:3.8.4-openjdk-17-slim")
|
||||
.volume("/etc/maven/settings.xml", "/usr/share/maven/conf/settings.xml")
|
||||
.volume("/var/run/docker.sock", "/var/run/docker.sock")
|
||||
)
|
||||
)
|
||||
)
|
||||
.stages(new Stage("Default Stage").jobs(new Job("Default Job", new BambooKey("JOB1")).tasks(new ScriptTask().description("Clean")
|
||||
.inlineBody("#!/bin/bash\n" + "set -e\n" + "rm -rf ./*"),
|
||||
new VcsCheckoutTask().description("Checkout Default Repository").cleanCheckout(true).checkoutItems(new CheckoutItem().defaultRepository()),
|
||||
new ScriptTask().description("Build").location(Location.FILE).fileFromPath("bamboo-specs/src/main/resources/scripts/build-java.sh").argument(SERVICE_NAME),
|
||||
createJUnitParserTask().description("Resultparser")
|
||||
.resultDirectories("**/test-reports/*.xml, **/target/surefire-reports/*.xml, **/target/failsafe-reports/*.xml")
|
||||
.enabled(true),
|
||||
new InjectVariablesTask().description("Inject git Tag").path("git.tag").namespace("g").scope(InjectVariablesScope.LOCAL),
|
||||
new VcsTagTask().description("${bamboo.g.gitTag}").tagName("${bamboo.g.gitTag}").defaultRepository())
|
||||
.dockerConfiguration(new DockerConfiguration().image("nexus.iqser.com:5001/infra/maven:3.8.4-openjdk-17-slim")
|
||||
.volume("/etc/maven/settings.xml", "/usr/share/maven/conf/settings.xml")
|
||||
.volume("/var/run/docker.sock", "/var/run/docker.sock"))))
|
||||
.linkedRepositories("RED / " + SERVICE_NAME)
|
||||
|
||||
.triggers(new BitbucketServerTrigger())
|
||||
.planBranchManagement(new PlanBranchManagement()
|
||||
.createForVcsBranch()
|
||||
.delete(new BranchCleanup()
|
||||
.whenInactiveInRepositoryAfterDays(14))
|
||||
.planBranchManagement(new PlanBranchManagement().createForVcsBranch()
|
||||
.delete(new BranchCleanup().whenInactiveInRepositoryAfterDays(14))
|
||||
.notificationForCommitters());
|
||||
}
|
||||
|
||||
|
||||
public Plan createSecBuild() {
|
||||
return new Plan(
|
||||
project(),
|
||||
SERVICE_NAME + "-Sec", new BambooKey(SERVICE_KEY + "SEC"))
|
||||
.description("Security Analysis Plan")
|
||||
.stages(new Stage("Default Stage")
|
||||
.jobs(new Job("Default Job",
|
||||
new BambooKey("JOB1"))
|
||||
.tasks(
|
||||
new ScriptTask()
|
||||
.description("Clean")
|
||||
.inlineBody("#!/bin/bash\n" +
|
||||
"set -e\n" +
|
||||
"rm -rf ./*"),
|
||||
new VcsCheckoutTask()
|
||||
.description("Checkout Default Repository")
|
||||
.cleanCheckout(true)
|
||||
.checkoutItems(new CheckoutItem().defaultRepository()),
|
||||
new ScriptTask()
|
||||
.description("Sonar")
|
||||
.location(Location.FILE)
|
||||
.fileFromPath("bamboo-specs/src/main/resources/scripts/sonar-java.sh")
|
||||
.argument(SERVICE_NAME))
|
||||
.dockerConfiguration(
|
||||
new DockerConfiguration()
|
||||
.image("nexus.iqser.com:5001/infra/maven:3.8.4-openjdk-17-slim")
|
||||
.volume("/etc/maven/settings.xml", "/usr/share/maven/conf/settings.xml")
|
||||
.dockerRunArguments("--net=host")
|
||||
.volume("/var/run/docker.sock", "/var/run/docker.sock")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return new Plan(project(), SERVICE_NAME + "-Sec", new BambooKey(SERVICE_KEY + "SEC")).description("Security Analysis Plan")
|
||||
.stages(new Stage("Default Stage").jobs(new Job("Default Job", new BambooKey("JOB1")).tasks(new ScriptTask().description("Clean")
|
||||
.inlineBody("#!/bin/bash\n" + "set -e\n" + "rm -rf ./*"),
|
||||
new VcsCheckoutTask().description("Checkout Default Repository").cleanCheckout(true).checkoutItems(new CheckoutItem().defaultRepository()),
|
||||
new ScriptTask().description("Sonar").location(Location.FILE).fileFromPath("bamboo-specs/src/main/resources/scripts/sonar-java.sh").argument(SERVICE_NAME))
|
||||
.dockerConfiguration(new DockerConfiguration().image("nexus.iqser.com:5001/infra/maven:3.8.4-openjdk-17-slim")
|
||||
.volume("/etc/maven/settings.xml", "/usr/share/maven/conf/settings.xml")
|
||||
.dockerRunArguments("--net=host")
|
||||
.volume("/var/run/docker.sock", "/var/run/docker.sock"))))
|
||||
.linkedRepositories("RED / " + SERVICE_NAME)
|
||||
.triggers(
|
||||
new ScheduledTrigger()
|
||||
.scheduleOnceDaily(LocalTime.of(23, 00)))
|
||||
.planBranchManagement(new PlanBranchManagement()
|
||||
.createForVcsBranchMatching("release.*")
|
||||
.notificationForCommitters());
|
||||
}
|
||||
.triggers(new ScheduledTrigger().scheduleOnceDaily(LocalTime.of(23, 00)))
|
||||
.planBranchManagement(new PlanBranchManagement().createForVcsBranchMatching("release.*").notificationForCommitters());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package buildjob;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.atlassian.bamboo.specs.api.builders.plan.Plan;
|
||||
|
||||
4
pom.xml
4
pom.xml
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.iqser.red</groupId>
|
||||
<artifactId>platform-docker-dependency</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<relativePath />
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<groupId>com.iqser.red</groupId>
|
||||
<artifactId>platform-dependency</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<relativePath />
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.iqser.red.service</groupId>
|
||||
@ -48,7 +48,7 @@
|
||||
<groupId>org.sonarsource.scanner.maven</groupId>
|
||||
<artifactId>sonar-maven-plugin</artifactId>
|
||||
<version>3.9.0.2155</version>
|
||||
</plugin>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.owasp</groupId>
|
||||
<artifactId>dependency-check-maven</artifactId>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
package com.iqser.red.service.redaction.report.v1.api.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.iqser.red.service.redaction.report.v1.api.model;
|
||||
|
||||
import com.dslplatform.json.CompiledJson;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.iqser.red.service.redaction.report.v1.api.resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PlaceholderResource {
|
||||
|
||||
String PLACEHOLDERS_PATH = "/placeholders";
|
||||
@ -17,11 +17,12 @@ public interface PlaceholderResource {
|
||||
String REPORT_TEMPLATE_ID_PATH_VARIABLE = "/report-template-id/{" + REPORT_TEMPLATE_ID + "}";
|
||||
String PLACEHOLDER_PATH_VARIABLE = "/placeholder/{" + PLACEHOLDER + "}";
|
||||
|
||||
|
||||
@GetMapping(value = PLACEHOLDERS_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<String> getPlaceholders();
|
||||
|
||||
|
||||
@GetMapping(value = PLACEHOLDERS_PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + REPORT_TEMPLATE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<String> getPlaceholdersOfTemplate(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId,
|
||||
@PathVariable(REPORT_TEMPLATE_ID) String reportTemplateId);
|
||||
List<String> getPlaceholdersOfTemplate(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId, @PathVariable(REPORT_TEMPLATE_ID) String reportTemplateId);
|
||||
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ public interface RSSResource {
|
||||
|
||||
|
||||
@GetMapping(value = RSS_PATH + DOSSIER_ID_PATH_VARIABLE, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
|
||||
RSSResponse getRSS(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@RequestParam(value = "fileId", required = false) String fileId);
|
||||
RSSResponse getRSS(@PathVariable(DOSSIER_ID) String dossierId, @RequestParam(value = "fileId", required = false) String fileId);
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
package com.iqser.red.service.redaction.report.v1.api.resource;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.common.JSONPrimitive;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.ReportTemplate;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.common.JSONPrimitive;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.ReportTemplate;
|
||||
|
||||
public interface ReportTemplateResource {
|
||||
|
||||
@ -17,8 +18,8 @@ public interface ReportTemplateResource {
|
||||
|
||||
String DOSSIER_TEMPLATE_ID_PATH_VARIABLE = "/dossier-template-id/{" + DOSSIER_TEMPLATE_ID + "}";
|
||||
|
||||
|
||||
@PostMapping(value = REPORT_TEMPLATE_PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<ReportTemplate> getReportTemplatesByPlaceholder(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId,
|
||||
@RequestBody JSONPrimitive<String> placeholder);
|
||||
List<ReportTemplate> getReportTemplatesByPlaceholder(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId, @RequestBody JSONPrimitive<String> placeholder);
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
package com.iqser.red.service.redaction.report.v1.api.resource;
|
||||
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StatusReportResponse;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StatusReportResponse;
|
||||
|
||||
public interface StatusReportResource {
|
||||
|
||||
String STATUS_REPORT = "/statusReport";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server;
|
||||
|
||||
import com.iqser.red.commons.spring.DefaultWebMvcConfiguration;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration;
|
||||
import com.iqser.red.service.redaction.report.v1.server.settings.ReportTemplateSettings;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@ -15,6 +10,11 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
import com.iqser.red.commons.spring.DefaultWebMvcConfiguration;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration;
|
||||
import com.iqser.red.service.redaction.report.v1.server.settings.ReportTemplateSettings;
|
||||
|
||||
import io.micrometer.core.aop.TimedAspect;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
|
||||
@ -35,8 +35,10 @@ public class Application {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public TimedAspect timedAspect(MeterRegistry registry) {
|
||||
|
||||
return new TimedAspect(registry);
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.client;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.DossierAttributesResource;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
@FeignClient(name = "DossierAttributesResource", url = "${persistence-service.url}")
|
||||
public interface DossierAttributesClient extends DossierAttributesResource {
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.client;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.DossierAttributesConfigResource;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.DossierAttributesConfigResource;
|
||||
|
||||
@FeignClient(name = "DossierAttributesConfigResource", url = "${persistence-service.url}")
|
||||
public interface DossierAttributesConfigClient extends DossierAttributesConfigResource {
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.client;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.DossierResource;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.DossierResource;
|
||||
|
||||
@FeignClient(name = "DossierResource", url = "${persistence-service.url}")
|
||||
public interface DossierClient extends DossierResource {
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.client;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.FileAttributesConfigResource;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.FileAttributesConfigResource;
|
||||
|
||||
@FeignClient(name = "FileAttributesResource", url = "${persistence-service.url}")
|
||||
public interface FileAttributesConfigClient extends FileAttributesConfigResource {
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.client;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.StatusResource;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.StatusResource;
|
||||
|
||||
@FeignClient(name = "StatusResource", url = "${persistence-service.url}")
|
||||
public interface FileStatusClient extends StatusResource {
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.client;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.RedactionLogResource;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.RedactionLogResource;
|
||||
|
||||
@FeignClient(name = "RedactionLogResource", url = "${persistence-service.url}")
|
||||
public interface RedactionLogClient extends RedactionLogResource {
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.client;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.ReportTemplateResource;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.ReportTemplateResource;
|
||||
|
||||
@FeignClient(name = "ReportTemplateResource", url = "${persistence-service.url}")
|
||||
public interface ReportTemplateClient extends ReportTemplateResource {
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.configuration;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.core.QueueBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class MessagingConfiguration {
|
||||
@ -39,10 +40,7 @@ public class MessagingConfiguration {
|
||||
@Bean
|
||||
public Queue reportResultQueue() {
|
||||
|
||||
return QueueBuilder.durable(REPORT_RESULT_QUEUE)
|
||||
.withArgument("x-dead-letter-exchange", "")
|
||||
.withArgument("x-dead-letter-routing-key", REPORT_RESULT_DLQ)
|
||||
.build();
|
||||
return QueueBuilder.durable(REPORT_RESULT_QUEUE).withArgument("x-dead-letter-exchange", "").withArgument("x-dead-letter-routing-key", REPORT_RESULT_DLQ).build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.controller;
|
||||
|
||||
import com.iqser.red.service.redaction.report.v1.api.resource.PlaceholderResource;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.iqser.red.service.redaction.report.v1.api.resource.PlaceholderResource;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@ -17,15 +19,16 @@ public class PlaceholderController implements PlaceholderResource {
|
||||
|
||||
private final PlaceholderService placeholderService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getPlaceholders() {
|
||||
|
||||
return placeholderService.getGeneralPlaceholders();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getPlaceholdersOfTemplate(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId,
|
||||
@PathVariable(REPORT_TEMPLATE_ID) String reportTemplateId) {
|
||||
public List<String> getPlaceholdersOfTemplate(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId, @PathVariable(REPORT_TEMPLATE_ID) String reportTemplateId) {
|
||||
|
||||
return new ArrayList<>(placeholderService.getPlaceholdersOfTemplate(dossierTemplateId, reportTemplateId));
|
||||
}
|
||||
|
||||
@ -17,8 +17,7 @@ public class RSSController implements RSSResource {
|
||||
private final RSSService rSSService;
|
||||
|
||||
|
||||
public RSSResponse getRSS(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@RequestParam(value = "fileId", required = false) String fileId) {
|
||||
public RSSResponse getRSS(@PathVariable(DOSSIER_ID) String dossierId, @RequestParam(value = "fileId", required = false) String fileId) {
|
||||
|
||||
return rSSService.getRSS(dossierId, fileId);
|
||||
}
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.common.JSONPrimitive;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.ReportTemplate;
|
||||
import com.iqser.red.service.redaction.report.v1.api.resource.ReportTemplateResource;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@ -19,10 +21,11 @@ public class ReportTemplateController implements ReportTemplateResource {
|
||||
|
||||
private final PlaceholderService placeholderService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<ReportTemplate> getReportTemplatesByPlaceholder(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId,
|
||||
@RequestBody JSONPrimitive<String> placeholder) {
|
||||
public List<ReportTemplate> getReportTemplatesByPlaceholder(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId, @RequestBody JSONPrimitive<String> placeholder) {
|
||||
|
||||
return placeholderService.getReportTemplatesByPlaceholder(dossierTemplateId, placeholder.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,21 +1,22 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StatusReportResponse;
|
||||
import com.iqser.red.service.redaction.report.v1.api.resource.StatusReportResource;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.StatusReportGenerationService;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class StatusReportController implements StatusReportResource {
|
||||
|
||||
|
||||
private final StatusReportGenerationService statusReportGenerationService;
|
||||
private final DossierClient dossierClient;
|
||||
|
||||
@ -23,7 +24,7 @@ public class StatusReportController implements StatusReportResource {
|
||||
@Override
|
||||
public StatusReportResponse generateStatusReport(@PathVariable(DOSSIER_ID) String dossierId) {
|
||||
|
||||
Dossier dossier = dossierClient.getDossierById(dossierId, true,false);
|
||||
Dossier dossier = dossierClient.getDossierById(dossierId, true, false);
|
||||
byte[] report = statusReportGenerationService.generateReport(dossier);
|
||||
return new StatusReportResponse(report, dossier.getDossierName() + ".xlsx");
|
||||
}
|
||||
|
||||
@ -8,6 +8,8 @@ import lombok.Data;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class ColoredText {
|
||||
|
||||
private String text;
|
||||
private String color;
|
||||
|
||||
}
|
||||
|
||||
@ -10,4 +10,5 @@ public class ExcelCell {
|
||||
private Cell cell;
|
||||
private int columnWidth;
|
||||
private int rowHeights;
|
||||
|
||||
}
|
||||
|
||||
@ -29,5 +29,4 @@ public class ExcelModel {
|
||||
private boolean placeholderInFirstRow;
|
||||
private boolean firstRowWritten;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ import lombok.Data;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ImagePlaceholder {
|
||||
|
||||
private String placeholder;
|
||||
private byte[] image;
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.model;
|
||||
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MultiFileWorkbook {
|
||||
|
||||
@ -13,4 +13,5 @@ public class PlaceHolderFunctions {
|
||||
|
||||
private Map<Integer, Function<PlaceholderInput, String>> functionPerPlaceHolder;
|
||||
private Set<String> foundPlaceHolder;
|
||||
|
||||
}
|
||||
|
||||
@ -74,10 +74,15 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@RequiredArgsConstructor
|
||||
public class ExcelReportGenerationService {
|
||||
|
||||
|
||||
@Timed("redactmanager_generateExcelReport")
|
||||
public void generateExcelReport(List<ReportRedactionEntry> reportEntries, PlaceholderModel placeholderModel, String reportTemplateName, SXSSFWorkbook workbook,
|
||||
String dossierName, FileModel fileModel, ExcelModel excelModel, boolean isLastFile) {
|
||||
public void generateExcelReport(List<ReportRedactionEntry> reportEntries,
|
||||
PlaceholderModel placeholderModel,
|
||||
String reportTemplateName,
|
||||
SXSSFWorkbook workbook,
|
||||
String dossierName,
|
||||
FileModel fileModel,
|
||||
ExcelModel excelModel,
|
||||
boolean isLastFile) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@ -91,25 +96,43 @@ public class ExcelReportGenerationService {
|
||||
sheet.setColumnWidth(columnWidthEntry.getKey(), columnWidthEntry.getValue());
|
||||
}
|
||||
|
||||
addRows(workbook, sheet, excelModel.getCellsToCopyBeforeRedactionPlaceholderRow(), excelModel.isHasRssPlaceHolders() ? excelModel.getWrittenRows()
|
||||
.size() : 0, placeholderModel, dossierName, fileModel.getFilename(), excelModel);
|
||||
addRows(workbook,
|
||||
sheet,
|
||||
excelModel.getCellsToCopyBeforeRedactionPlaceholderRow(),
|
||||
excelModel.isHasRssPlaceHolders() ? excelModel.getWrittenRows().size() : 0,
|
||||
placeholderModel,
|
||||
dossierName,
|
||||
fileModel.getFilename(),
|
||||
excelModel);
|
||||
|
||||
if(!excelModel.isHasRssPlaceHolders()) {
|
||||
if (!excelModel.isHasRssPlaceHolders()) {
|
||||
excelModel.setRowsBeforeRedactionEntryRowsAdded(true);
|
||||
}
|
||||
}
|
||||
|
||||
if(!excelModel.isHasRssPlaceHolders()) {
|
||||
if (!excelModel.isHasRssPlaceHolders()) {
|
||||
addRedactionEntryRows(sheet, reportEntries, fileModel.getFilename(), excelModel, placeholderModel);
|
||||
}
|
||||
|
||||
if (isLastFile) {
|
||||
addRows(workbook, sheet, excelModel.getCellsToCopyAfterRedactionPlaceholderRow(), excelModel.getWrittenRows()
|
||||
.size(), placeholderModel, dossierName, fileModel.getFilename(), excelModel);
|
||||
addRows(workbook,
|
||||
sheet,
|
||||
excelModel.getCellsToCopyAfterRedactionPlaceholderRow(),
|
||||
excelModel.getWrittenRows().size(),
|
||||
placeholderModel,
|
||||
dossierName,
|
||||
fileModel.getFilename(),
|
||||
excelModel);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Report Generation took: {} for file with id {}, pageCount: {}, redactionLogEntryCount: {}, reportName: {}, className: {}", System.currentTimeMillis() - start, fileModel.getId(), fileModel.getNumberOfPages(), reportEntries.size(), reportTemplateName, getClass().getSimpleName());
|
||||
log.info("Report Generation took: {} for file with id {}, pageCount: {}, redactionLogEntryCount: {}, reportName: {}, className: {}",
|
||||
System.currentTimeMillis() - start,
|
||||
fileModel.getId(),
|
||||
fileModel.getNumberOfPages(),
|
||||
reportEntries.size(),
|
||||
reportTemplateName,
|
||||
getClass().getSimpleName());
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -119,15 +142,21 @@ public class ExcelReportGenerationService {
|
||||
|
||||
@SneakyThrows
|
||||
@Timed("redactmanager_excel-addRows")
|
||||
private void addRows(SXSSFWorkbook workbook, Sheet sheet, Map<CellIdentifier, Cell> copiedCells, int numberOfRowsToShift, PlaceholderModel placeholderModel, String dossierName,
|
||||
String filename, ExcelModel excelModel) {
|
||||
private void addRows(SXSSFWorkbook workbook,
|
||||
Sheet sheet,
|
||||
Map<CellIdentifier, Cell> copiedCells,
|
||||
int numberOfRowsToShift,
|
||||
PlaceholderModel placeholderModel,
|
||||
String dossierName,
|
||||
String filename,
|
||||
ExcelModel excelModel) {
|
||||
|
||||
Set<Integer> createdCopyRows = new HashSet<>();
|
||||
|
||||
int skipRows = excelModel.isHasRssPlaceHolders() && excelModel.isFirstRowWritten() && !excelModel.isPlaceholderInFirstRow() ? 1 : 0;
|
||||
for (Map.Entry<CellIdentifier, Cell> cellsToCopyEntry : copiedCells.entrySet()) {
|
||||
|
||||
if(excelModel.isHasRssPlaceHolders() && cellsToCopyEntry.getKey().getRowIndex() == 0 && excelModel.isFirstRowWritten() && !excelModel.isPlaceholderInFirstRow()){
|
||||
if (excelModel.isHasRssPlaceHolders() && cellsToCopyEntry.getKey().getRowIndex() == 0 && excelModel.isFirstRowWritten() && !excelModel.isPlaceholderInFirstRow()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -190,11 +219,11 @@ public class ExcelReportGenerationService {
|
||||
columnWidths.put(i, columnWidth);
|
||||
String cellStringValue = cell.getStringCellValue();
|
||||
|
||||
if(j == 0 && cellStringValue.contains("{{")){
|
||||
if (j == 0 && cellStringValue.contains("{{")) {
|
||||
placeholderInFirstRow = true;
|
||||
}
|
||||
|
||||
if(cellStringValue.contains(RSS_PLACEHOLDER_BASE)){
|
||||
if (cellStringValue.contains(RSS_PLACEHOLDER_BASE)) {
|
||||
hasRssPlaceHolders = true;
|
||||
}
|
||||
|
||||
@ -221,7 +250,16 @@ public class ExcelReportGenerationService {
|
||||
}
|
||||
|
||||
log.debug("Calculate Placeholder Cells took: {}", System.currentTimeMillis() - start);
|
||||
return new ExcelModel(placeholderCellPos, placeholderRow, columnWidths, cellsToCopyBeforePlaceholderRow, cellsToCopyAfterPlaceholderRow, new ArrayList<>(), false, hasRssPlaceHolders, placeholderInFirstRow, false);
|
||||
return new ExcelModel(placeholderCellPos,
|
||||
placeholderRow,
|
||||
columnWidths,
|
||||
cellsToCopyBeforePlaceholderRow,
|
||||
cellsToCopyAfterPlaceholderRow,
|
||||
new ArrayList<>(),
|
||||
false,
|
||||
hasRssPlaceHolders,
|
||||
placeholderInFirstRow,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +289,12 @@ public class ExcelReportGenerationService {
|
||||
|
||||
private boolean containsRedactionPlaceholder(String text) {
|
||||
|
||||
return text.startsWith(DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE) || text.startsWith(FILE_ATTRIBUTE_PLACEHOLDER_BASE) || text.contains(FILE_NAME_PLACEHOLDER) || text.contains(PAGE_PLACEHOLDER) || text.contains(PARAGRAPH_PLACEHOLDER) || text.contains(JUSTIFICATION_PLACEHOLDER) || text.contains(EXCERPT_PLACEHOLDER) || text.contains(JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || text.contains(JUSTIFICATION_REASON_PLACEHOLDER) || text.contains(REDACTION_VALUE_PLACEHOLDER) || text.contains(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER) || text.contains(JUSTIFICATION_TEXT_PLACEHOLDER) || text.contains(SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER) || text.contains(SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER) || text.contains(REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER);
|
||||
return text.startsWith(DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE) || text.startsWith(FILE_ATTRIBUTE_PLACEHOLDER_BASE) || text.contains(FILE_NAME_PLACEHOLDER) || text.contains(
|
||||
PAGE_PLACEHOLDER) || text.contains(PARAGRAPH_PLACEHOLDER) || text.contains(JUSTIFICATION_PLACEHOLDER) || text.contains(EXCERPT_PLACEHOLDER) || text.contains(
|
||||
JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || text.contains(JUSTIFICATION_REASON_PLACEHOLDER) || text.contains(REDACTION_VALUE_PLACEHOLDER) || text.contains(
|
||||
JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER) || text.contains(JUSTIFICATION_TEXT_PLACEHOLDER) || text.contains(
|
||||
SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER) || text.contains(SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER) || text.contains(
|
||||
REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER);
|
||||
}
|
||||
|
||||
|
||||
@ -318,8 +361,9 @@ public class ExcelReportGenerationService {
|
||||
if (cell.getStringCellValue().contains(imagePlaceholder.getPlaceholder())) {
|
||||
try (ByteArrayInputStream is = new ByteArrayInputStream(imagePlaceholder.getImage())) {
|
||||
|
||||
double factor = calculateScale(is, PixelUtil.widthUnits2Pixel((short) sheet.getColumnWidth(cell.getColumnIndex())), PixelUtil.heightUnits2Pixel(cell.getRow()
|
||||
.getHeight()));
|
||||
double factor = calculateScale(is,
|
||||
PixelUtil.widthUnits2Pixel((short) sheet.getColumnWidth(cell.getColumnIndex())),
|
||||
PixelUtil.heightUnits2Pixel(cell.getRow().getHeight()));
|
||||
is.reset();
|
||||
|
||||
int pictureIdx = workbook.addPicture(is.readAllBytes(), SXSSFWorkbook.PICTURE_TYPE_JPEG);
|
||||
|
||||
@ -62,8 +62,8 @@ public class GeneratePlaceholderService {
|
||||
|
||||
if (dossierAttribute.getValue() != null) {
|
||||
if (dossierAttribute.getValue().startsWith("data:")) {
|
||||
imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder()
|
||||
.decode(dossierAttribute.getValue().split(",")[1])));
|
||||
imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(),
|
||||
Base64.getDecoder().decode(dossierAttribute.getValue().split(",")[1])));
|
||||
} else {
|
||||
imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder().decode(dossierAttribute.getValue())));
|
||||
}
|
||||
@ -115,10 +115,17 @@ public class GeneratePlaceholderService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Set<String> getDefaultPlaceholders() {
|
||||
|
||||
return new HashSet<>(Set.of(FILE_NAME_PLACEHOLDER, FORMAT_DATE_ISO_PLACEHOLDER, FORMAT_DATE_GER_PLACEHOLDER, FORMAT_DATE_ENG_PLACEHOLDER, FORMAT_TIME_ISO_PLACEHOLDER, DOSSIER_NAME_PLACEHOLDER, IUCLID_FUNCTION_PLACEHOLDER, SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER, SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER));
|
||||
return new HashSet<>(Set.of(FILE_NAME_PLACEHOLDER,
|
||||
FORMAT_DATE_ISO_PLACEHOLDER,
|
||||
FORMAT_DATE_GER_PLACEHOLDER,
|
||||
FORMAT_DATE_ENG_PLACEHOLDER,
|
||||
FORMAT_TIME_ISO_PLACEHOLDER,
|
||||
DOSSIER_NAME_PLACEHOLDER,
|
||||
IUCLID_FUNCTION_PLACEHOLDER,
|
||||
SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER,
|
||||
SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -77,7 +77,23 @@ public class PlaceholderService {
|
||||
|
||||
public List<String> getGeneralPlaceholders() {
|
||||
|
||||
return List.of(FILE_NAME_PLACEHOLDER, PAGE_PLACEHOLDER, PARAGRAPH_PLACEHOLDER, JUSTIFICATION_PLACEHOLDER, EXCERPT_PLACEHOLDER, FORMAT_DATE_ISO_PLACEHOLDER, FORMAT_DATE_GER_PLACEHOLDER, FORMAT_DATE_ENG_PLACEHOLDER, FORMAT_TIME_ISO_PLACEHOLDER, DOSSIER_NAME_PLACEHOLDER, IUCLID_FUNCTION_PLACEHOLDER, REDACTION_VALUE_PLACEHOLDER, JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER, JUSTIFICATION_TEXT_PLACEHOLDER, SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER, SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER, REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER);
|
||||
return List.of(FILE_NAME_PLACEHOLDER,
|
||||
PAGE_PLACEHOLDER,
|
||||
PARAGRAPH_PLACEHOLDER,
|
||||
JUSTIFICATION_PLACEHOLDER,
|
||||
EXCERPT_PLACEHOLDER,
|
||||
FORMAT_DATE_ISO_PLACEHOLDER,
|
||||
FORMAT_DATE_GER_PLACEHOLDER,
|
||||
FORMAT_DATE_ENG_PLACEHOLDER,
|
||||
FORMAT_TIME_ISO_PLACEHOLDER,
|
||||
DOSSIER_NAME_PLACEHOLDER,
|
||||
IUCLID_FUNCTION_PLACEHOLDER,
|
||||
REDACTION_VALUE_PLACEHOLDER,
|
||||
JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER,
|
||||
JUSTIFICATION_TEXT_PLACEHOLDER,
|
||||
SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER,
|
||||
SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER,
|
||||
REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -14,14 +14,10 @@ import java.util.stream.Collectors;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileModel;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.rss.RSSFileResponse;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.rss.RSSResponse;
|
||||
import com.iqser.red.service.redaction.report.v1.api.resource.RSSResource;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.RedactionLogClient;
|
||||
import com.iqser.red.service.redaction.v1.model.ChangeType;
|
||||
@ -43,12 +39,74 @@ public class RSSService {
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
guidelineMapping.put("Acute Dermal Toxicity", Set.of("OECD 402", "OECD Test Guideline 402", "OECD Guidelines for the Testing of Chemicals No. 402", "OECD Guidelines for Testing of Chemicals, Procedure 402", "OPPTS 870.1200", "OPPTS Guideline Number 870.1200", "EPA 870.1200"));
|
||||
guidelineMapping.put("Acute inhalation toxicity", Set.of("OECD 403", "OECD Test Guideline 403", "OECD Guidelines for the Testing of Chemicals No. 403", "OECD Guidelines for Testing of Chemicals, Procedure 403", "OECD 436", "OECD Test Guideline 436", "OECD Guidelines for the Testing of Chemicals No. 436", "OECD Guidelines for Testing of Chemicals, Procedure 436", "OPPTS 870.1300", "OPPTS Guideline Number 870.1300", "EPA 870.1300"));
|
||||
guidelineMapping.put("Acute oral toxicity", Set.of("OECD 425", "OECD Test Guideline 425", "OECD Guidelines for the Testing of Chemicals No. 425", "OECD Guidelines for Testing of Chemicals, Procedure 425", "OECD 423", "OECD Test Guideline 423", "OECD Guidelines for the Testing of Chemicals No. 423", "OECD Guidelines for Testing of Chemicals, Procedure 423", "OPPTS 870.1100", "OPPTS Guideline Number 870.1100", "EPA 870.1100"));
|
||||
guidelineMapping.put("Eye irritation", Set.of("OECD 437", "OECD Test Guideline 437", "OECD Guidelines for the Testing of Chemicals No. 437", "OECD Guidelines for Testing of Chemicals, Procedure 437", "OECD 405", "OECD Test Guideline 405", "OECD Guidelines for the Testing of Chemicals No. 405", "OECD Guidelines for Testing of Chemicals, Procedure 405", "OPPTS 870.2400", "OPPTS Guideline Number 870.2400", "EPA 870.2400"));
|
||||
guidelineMapping.put("Skin irritation", Set.of("OECD 404", "OECD Test Guideline 404", "OECD Guidelines for the Testing of Chemicals No. 404", "OECD Guidelines for Testing of Chemicals, Procedure 404", "OECD 439", "OECD Test Guideline 439", "OECD Guidelines for the Testing of Chemicals No. 439", "OECD Guidelines for Testing of Chemicals, Procedure 439", "OPPTS 870.2500", "OPPTS Guideline Number 870.2500", "EPA 870.2500"));
|
||||
guidelineMapping.put("Skin sentitization", Set.of("OECD 406", "OECD Test Guideline 406", "OECD Guidelines for the Testing of Chemicals No. 406", "OECD Guidelines for Testing of Chemicals, Procedure 406", "OECD 429", "OECD Test Guideline 429", "OECD Guidelines for the Testing of Chemicals No. 429", "OECD Guidelines for Testing of Chemicals, Procedure 429", "OPPTS 870.2600", "OPPTS Guideline Number 870.2600", "EPA 870.2600"));
|
||||
guidelineMapping.put("Acute Dermal Toxicity",
|
||||
Set.of("OECD 402",
|
||||
"OECD Test Guideline 402",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 402",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 402",
|
||||
"OPPTS 870.1200",
|
||||
"OPPTS Guideline Number 870.1200",
|
||||
"EPA 870.1200"));
|
||||
guidelineMapping.put("Acute inhalation toxicity",
|
||||
Set.of("OECD 403",
|
||||
"OECD Test Guideline 403",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 403",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 403",
|
||||
"OECD 436",
|
||||
"OECD Test Guideline 436",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 436",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 436",
|
||||
"OPPTS 870.1300",
|
||||
"OPPTS Guideline Number 870.1300",
|
||||
"EPA 870.1300"));
|
||||
guidelineMapping.put("Acute oral toxicity",
|
||||
Set.of("OECD 425",
|
||||
"OECD Test Guideline 425",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 425",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 425",
|
||||
"OECD 423",
|
||||
"OECD Test Guideline 423",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 423",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 423",
|
||||
"OPPTS 870.1100",
|
||||
"OPPTS Guideline Number 870.1100",
|
||||
"EPA 870.1100"));
|
||||
guidelineMapping.put("Eye irritation",
|
||||
Set.of("OECD 437",
|
||||
"OECD Test Guideline 437",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 437",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 437",
|
||||
"OECD 405",
|
||||
"OECD Test Guideline 405",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 405",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 405",
|
||||
"OPPTS 870.2400",
|
||||
"OPPTS Guideline Number 870.2400",
|
||||
"EPA 870.2400"));
|
||||
guidelineMapping.put("Skin irritation",
|
||||
Set.of("OECD 404",
|
||||
"OECD Test Guideline 404",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 404",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 404",
|
||||
"OECD 439",
|
||||
"OECD Test Guideline 439",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 439",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 439",
|
||||
"OPPTS 870.2500",
|
||||
"OPPTS Guideline Number 870.2500",
|
||||
"EPA 870.2500"));
|
||||
guidelineMapping.put("Skin sentitization",
|
||||
Set.of("OECD 406",
|
||||
"OECD Test Guideline 406",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 406",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 406",
|
||||
"OECD 429",
|
||||
"OECD Test Guideline 429",
|
||||
"OECD Guidelines for the Testing of Chemicals No. 429",
|
||||
"OECD Guidelines for Testing of Chemicals, Procedure 429",
|
||||
"OPPTS 870.2600",
|
||||
"OPPTS Guideline Number 870.2600",
|
||||
"EPA 870.2600"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,23 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
|
||||
import com.iqser.red.service.redaction.v1.model.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
|
||||
import com.iqser.red.service.redaction.v1.model.ManualRedactionType;
|
||||
import com.iqser.red.service.redaction.v1.model.Rectangle;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLogLegalBasis;
|
||||
|
||||
@Service
|
||||
public class RedactionLogConverterService {
|
||||
@ -52,16 +61,24 @@ public class RedactionLogConverterService {
|
||||
|
||||
if (pages.isEmpty() || !pages.contains(position.getPage())) {
|
||||
pages.add(position.getPage());
|
||||
reportEntries.add(new ReportRedactionEntry(position.getPage(), position.getTopLeft().getX(), position.getTopLeft()
|
||||
.getY(), getSection(entry, position), checkTextForNull(entry.getLegalBasis()) + " " + legalBasisMappings.stream()
|
||||
.filter(lbm -> lbm.getReason().equalsIgnoreCase(entry.getLegalBasis()))
|
||||
.findAny()
|
||||
.map(RedactionLogLegalBasis::getDescription)
|
||||
.orElse(""), entry.getLegalBasis(), legalBasisMappings.stream()
|
||||
.filter(lbm -> lbm.getReason().equalsIgnoreCase(entry.getLegalBasis()))
|
||||
.findAny()
|
||||
.map(RedactionLogLegalBasis::getDescription)
|
||||
.orElse(""), checkTextForNull(entry.getTextBefore()) + entry.getValue() + checkTextForNull(entry.getTextAfter()), entry.getValue(), mapOfEntityDisplayName.get(entry.getType())));
|
||||
reportEntries.add(new ReportRedactionEntry(position.getPage(),
|
||||
position.getTopLeft().getX(),
|
||||
position.getTopLeft().getY(),
|
||||
getSection(entry, position),
|
||||
checkTextForNull(entry.getLegalBasis()) + " " + legalBasisMappings.stream()
|
||||
.filter(lbm -> lbm.getReason().equalsIgnoreCase(entry.getLegalBasis()))
|
||||
.findAny()
|
||||
.map(RedactionLogLegalBasis::getDescription)
|
||||
.orElse(""),
|
||||
entry.getLegalBasis(),
|
||||
legalBasisMappings.stream()
|
||||
.filter(lbm -> lbm.getReason().equalsIgnoreCase(entry.getLegalBasis()))
|
||||
.findAny()
|
||||
.map(RedactionLogLegalBasis::getDescription)
|
||||
.orElse(""),
|
||||
checkTextForNull(entry.getTextBefore()) + entry.getValue() + checkTextForNull(entry.getTextAfter()),
|
||||
entry.getValue(),
|
||||
mapOfEntityDisplayName.get(entry.getType())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.ReportTemplate;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileModel;
|
||||
@ -7,7 +21,11 @@ import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.ty
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportRequestMessage;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportType;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.*;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DictionaryClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.RedactionLogClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.ReportTemplateClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.MultiFileDocument;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.MultiFileWorkbook;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.PlaceholderModel;
|
||||
@ -16,19 +34,11 @@ import com.iqser.red.service.redaction.report.v1.server.settings.ReportTemplateS
|
||||
import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageService;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
||||
import com.iqser.red.storage.commons.exception.StorageObjectDoesNotExist;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
@Slf4j
|
||||
@ -49,6 +59,7 @@ public class ReportGenerationService {
|
||||
private final ReportTemplateSettings reportTemplateSettings;
|
||||
private final RSSService rSSService;
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@Timed("redactmanager_generateReports")
|
||||
public String generateReports(ReportRequestMessage reportMessage) {
|
||||
@ -72,7 +83,10 @@ public class ReportGenerationService {
|
||||
for (Sheet sheet : readWorkbook) {
|
||||
writeWorkbook.createSheet(sheet.getSheetName());
|
||||
}
|
||||
MultiFileWorkbook multiFileWorkbook = new MultiFileWorkbook(readWorkbook, writeWorkbook, templateId, reportTemplate.getFileName(),
|
||||
MultiFileWorkbook multiFileWorkbook = new MultiFileWorkbook(readWorkbook,
|
||||
writeWorkbook,
|
||||
templateId,
|
||||
reportTemplate.getFileName(),
|
||||
excelTemplateReportGenerationService.calculateExcelModel(readWorkbook.getSheetAt(0)));
|
||||
multiFileWorkbookReportTemplates.add(multiFileWorkbook);
|
||||
} catch (IOException e) {
|
||||
@ -103,21 +117,26 @@ public class ReportGenerationService {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
var fileStatus = fileStatusClient.getFileStatus(reportMessage.getDossierId(), reportMessage.getFileIds()
|
||||
.get(j));
|
||||
var fileStatus = fileStatusClient.getFileStatus(reportMessage.getDossierId(), reportMessage.getFileIds().get(j));
|
||||
|
||||
generatePlaceholderService.resolveFileAttributeValues(fileStatus, placeholderModel);
|
||||
|
||||
List<ReportRedactionEntry> reportEntries = getReportEntries(reportMessage.getDossierId(), reportMessage.getFileIds()
|
||||
.get(j), fileStatus.isExcluded());
|
||||
List<ReportRedactionEntry> reportEntries = getReportEntries(reportMessage.getDossierId(), reportMessage.getFileIds().get(j), fileStatus.isExcluded());
|
||||
|
||||
var isLastFile = j == reportMessage.getFileIds().size() - 1;
|
||||
|
||||
for (MultiFileWorkbook multiFileWorkbook : multiFileWorkbookReportTemplates) {
|
||||
if(multiFileWorkbook.getExcelModel().isHasRssPlaceHolders()){
|
||||
if (multiFileWorkbook.getExcelModel().isHasRssPlaceHolders()) {
|
||||
generatePlaceholderService.resolveRssValues(fileStatus, placeholderModel);
|
||||
}
|
||||
excelTemplateReportGenerationService.generateExcelReport(reportEntries, placeholderModel, multiFileWorkbook.getTemplateName(), multiFileWorkbook.getWriteWorkbook(), dossier.getDossierName(), fileStatus, multiFileWorkbook.getExcelModel(), isLastFile);
|
||||
excelTemplateReportGenerationService.generateExcelReport(reportEntries,
|
||||
placeholderModel,
|
||||
multiFileWorkbook.getTemplateName(),
|
||||
multiFileWorkbook.getWriteWorkbook(),
|
||||
dossier.getDossierName(),
|
||||
fileStatus,
|
||||
multiFileWorkbook.getExcelModel(),
|
||||
isLastFile);
|
||||
}
|
||||
|
||||
for (MultiFileDocument multiFileDocument : multiFileDocumentReportTemplates) {
|
||||
@ -127,7 +146,11 @@ public class ReportGenerationService {
|
||||
wordReportGenerationService.removePlaceholdersRow(wordReportGenerationService.getRedactionTable(multiFileDocument.getDocument()));
|
||||
byte[] wordDoc = wordReportGenerationService.toByteArray(multiFileDocument.getDocument());
|
||||
String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), wordDoc);
|
||||
storedFileInformation.add(new StoredFileInformation(null, storageId, ReportType.WORD_TEMPLATE_MULTI_FILE, multiFileDocument.getTemplateId(), multiFileDocument.getDocumentPartNr()));
|
||||
storedFileInformation.add(new StoredFileInformation(null,
|
||||
storageId,
|
||||
ReportType.WORD_TEMPLATE_MULTI_FILE,
|
||||
multiFileDocument.getTemplateId(),
|
||||
multiFileDocument.getDocumentPartNr()));
|
||||
multiFileDocument.setDocumentPartNr(multiFileDocument.getDocumentPartNr() + 1);
|
||||
|
||||
try (ByteArrayInputStream is = new ByteArrayInputStream(multiFileDocument.getTemplateAsBytes())) {
|
||||
@ -136,18 +159,29 @@ public class ReportGenerationService {
|
||||
multiFileDocument.setNumberOfChars(0);
|
||||
}
|
||||
}
|
||||
numberOfChars = wordReportGenerationService.generateWordReport(reportEntries, placeholderModel, multiFileDocument.getTemplateName(), multiFileDocument.getDocument(), fileStatus, dossier, isLastFile ? isLastFile : multiFileDocument.getNumberOfChars() + numberOfChars >= reportTemplateSettings.getMultiFileChunkSize());
|
||||
numberOfChars = wordReportGenerationService.generateWordReport(reportEntries,
|
||||
placeholderModel,
|
||||
multiFileDocument.getTemplateName(),
|
||||
multiFileDocument.getDocument(),
|
||||
fileStatus,
|
||||
dossier,
|
||||
isLastFile ? isLastFile : multiFileDocument.getNumberOfChars() + numberOfChars >= reportTemplateSettings.getMultiFileChunkSize());
|
||||
multiFileDocument.setNumberOfChars(multiFileDocument.getNumberOfChars() + numberOfChars);
|
||||
}
|
||||
|
||||
for (ReportTemplate reportTemplate : singleFilesTemplates) {
|
||||
|
||||
storedFileInformation.add(createReportFromTemplate(dossier, fileStatus, placeholderModel, reportTemplate.getFileName(), reportMessage.getDownloadId(), reportEntries, reportTemplate));
|
||||
storedFileInformation.add(createReportFromTemplate(dossier,
|
||||
fileStatus,
|
||||
placeholderModel,
|
||||
reportTemplate.getFileName(),
|
||||
reportMessage.getDownloadId(),
|
||||
reportEntries,
|
||||
reportTemplate));
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("Successfully processed {}/{} fileIds for downloadId {}, took {}", i, reportMessage.getFileIds()
|
||||
.size(), reportMessage.getDownloadId(), end - start);
|
||||
log.info("Successfully processed {}/{} fileIds for downloadId {}, took {}", i, reportMessage.getFileIds().size(), reportMessage.getDownloadId(), end - start);
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -160,16 +194,23 @@ public class ReportGenerationService {
|
||||
for (MultiFileDocument multiFileDocument : multiFileDocumentReportTemplates) {
|
||||
byte[] template = wordReportGenerationService.toByteArray(multiFileDocument.getDocument());
|
||||
String storageId = reportStorageService.storeObject(reportMessage.getDownloadId(), template);
|
||||
storedFileInformation.add(new StoredFileInformation(null, storageId, ReportType.WORD_TEMPLATE_MULTI_FILE, multiFileDocument.getTemplateId(), multiFileDocument.getDocumentPartNr()));
|
||||
storedFileInformation.add(new StoredFileInformation(null,
|
||||
storageId,
|
||||
ReportType.WORD_TEMPLATE_MULTI_FILE,
|
||||
multiFileDocument.getTemplateId(),
|
||||
multiFileDocument.getDocumentPartNr()));
|
||||
}
|
||||
|
||||
return reportStorageService.storeReportInformation(reportMessage.getDownloadId(), storedFileInformation);
|
||||
}
|
||||
|
||||
|
||||
private StoredFileInformation createReportFromTemplate(Dossier dossier, FileModel fileStatus,
|
||||
PlaceholderModel placeholderModel, String templateName,
|
||||
String downloadId, List<ReportRedactionEntry> reportEntries,
|
||||
private StoredFileInformation createReportFromTemplate(Dossier dossier,
|
||||
FileModel fileStatus,
|
||||
PlaceholderModel placeholderModel,
|
||||
String templateName,
|
||||
String downloadId,
|
||||
List<ReportRedactionEntry> reportEntries,
|
||||
ReportTemplate reportTemplate) {
|
||||
|
||||
if (reportTemplate.getFileName().endsWith(".xlsx")) {
|
||||
@ -181,11 +222,18 @@ public class ReportGenerationService {
|
||||
writeWorkbook.createSheet(sheet.getSheetName());
|
||||
}
|
||||
var excelModel = excelTemplateReportGenerationService.calculateExcelModel(readWorkbook.getSheetAt(0));
|
||||
if(excelModel.isHasRssPlaceHolders()){
|
||||
if (excelModel.isHasRssPlaceHolders()) {
|
||||
generatePlaceholderService.resolveRssValues(fileStatus, placeholderModel);
|
||||
}
|
||||
|
||||
excelTemplateReportGenerationService.generateExcelReport(reportEntries, placeholderModel, templateName, writeWorkbook, dossier.getDossierName(), fileStatus, excelModel, true);
|
||||
excelTemplateReportGenerationService.generateExcelReport(reportEntries,
|
||||
placeholderModel,
|
||||
templateName,
|
||||
writeWorkbook,
|
||||
dossier.getDossierName(),
|
||||
fileStatus,
|
||||
excelModel,
|
||||
true);
|
||||
byte[] template = excelTemplateReportGenerationService.toByteArray(writeWorkbook);
|
||||
String storageId = reportStorageService.storeObject(downloadId, template);
|
||||
return new StoredFileInformation(fileStatus.getId(), storageId, ReportType.EXCEL_TEMPLATE_SINGLE_FILE, reportTemplate.getTemplateId(), 0);
|
||||
@ -232,8 +280,7 @@ public class ReportGenerationService {
|
||||
|
||||
List<Type> typeList = new ArrayList<>();
|
||||
typeList.addAll(dictionaryClient.getAllTypesForDossier(dossierId, false));
|
||||
typeList.addAll(dictionaryClient.getAllTypesForDossierTemplate(dossierClient.getDossierById(dossierId, true, false)
|
||||
.getDossierTemplateId(), false));
|
||||
typeList.addAll(dictionaryClient.getAllTypesForDossierTemplate(dossierClient.getDossierById(dossierId, true, false).getDossierTemplateId(), false));
|
||||
|
||||
Map<String, String> mapOfEntityDisplayName = new HashMap<>();
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ public class ReportMessageReceiver {
|
||||
ReportRequestMessage reportMessage = objectMapper.readValue(message.getBody(), ReportRequestMessage.class);
|
||||
|
||||
// This prevents from endless retries oom errors.
|
||||
if(message.getMessageProperties().isRedelivered()){
|
||||
if (message.getMessageProperties().isRedelivered()) {
|
||||
throw new AmqpRejectAndDontRequeueException(String.format("Error during last processing of request with downloadId: %s, do not retry.", reportMessage.getDownloadId()));
|
||||
}
|
||||
|
||||
@ -55,10 +55,12 @@ public class ReportMessageReceiver {
|
||||
private void addToReportResultQueue(String userId, String downloadId, String reportFileInformationStorageId, int priority) {
|
||||
|
||||
try {
|
||||
rabbitTemplate.convertAndSend(REPORT_RESULT_QUEUE, objectMapper.writeValueAsString(new ReportResultMessage(userId, downloadId, reportFileInformationStorageId)), message -> {
|
||||
message.getMessageProperties().setPriority(priority);
|
||||
return message;
|
||||
});
|
||||
rabbitTemplate.convertAndSend(REPORT_RESULT_QUEUE,
|
||||
objectMapper.writeValueAsString(new ReportResultMessage(userId, downloadId, reportFileInformationStorageId)),
|
||||
message -> {
|
||||
message.getMessageProperties().setPriority(priority);
|
||||
return message;
|
||||
});
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@ -82,8 +82,13 @@ public class WordReportGenerationService {
|
||||
|
||||
|
||||
@Timed("redactmanager_generateWordReport")
|
||||
public int generateWordReport(List<ReportRedactionEntry> reportEntries, PlaceholderModel placeholderModel, String reportTemplateName, XWPFDocument doc, FileModel fileModel,
|
||||
Dossier dossier, boolean isLastFile) {
|
||||
public int generateWordReport(List<ReportRedactionEntry> reportEntries,
|
||||
PlaceholderModel placeholderModel,
|
||||
String reportTemplateName,
|
||||
XWPFDocument doc,
|
||||
FileModel fileModel,
|
||||
Dossier dossier,
|
||||
boolean isLastFile) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@ -107,8 +112,13 @@ public class WordReportGenerationService {
|
||||
removePlaceholdersRow(table);
|
||||
}
|
||||
|
||||
log.info("Report Generation took: {} for file with id {}, pageCount: {}, redactionLogEntryCount: {}, reportName: {}, className: {}", System.currentTimeMillis() - start,
|
||||
fileModel.getId(), fileModel.getNumberOfPages(), reportEntries.size(), reportTemplateName, getClass().getSimpleName());
|
||||
log.info("Report Generation took: {} for file with id {}, pageCount: {}, redactionLogEntryCount: {}, reportName: {}, className: {}",
|
||||
System.currentTimeMillis() - start,
|
||||
fileModel.getId(),
|
||||
fileModel.getNumberOfPages(),
|
||||
reportEntries.size(),
|
||||
reportTemplateName,
|
||||
getClass().getSimpleName());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage() + " in file: " + fileModel.getFilename());
|
||||
@ -149,7 +159,10 @@ public class WordReportGenerationService {
|
||||
}
|
||||
|
||||
|
||||
private String getPlaceholderValue(String placeholder, String dossierName, String filename, PlaceholderModel placeholderModel,
|
||||
private String getPlaceholderValue(String placeholder,
|
||||
String dossierName,
|
||||
String filename,
|
||||
PlaceholderModel placeholderModel,
|
||||
List<ReportRedactionEntry> reportRedactionEntries) {
|
||||
|
||||
if (placeholder.equals(FORMAT_DATE_ISO_PLACEHOLDER)) {
|
||||
@ -210,7 +223,11 @@ public class WordReportGenerationService {
|
||||
|
||||
|
||||
@Timed("redactmanager_word-replaceTextPlaceholders")
|
||||
public int replaceTextPlaceholders(XWPFDocument doc, PlaceholderModel placeholderModel, String dossierName, String fileName, XWPFTable tableToSkip,
|
||||
public int replaceTextPlaceholders(XWPFDocument doc,
|
||||
PlaceholderModel placeholderModel,
|
||||
String dossierName,
|
||||
String fileName,
|
||||
XWPFTable tableToSkip,
|
||||
List<ReportRedactionEntry> reportRedactionEntries) {
|
||||
|
||||
int sumOfChars = 0;
|
||||
@ -296,10 +313,10 @@ public class WordReportGenerationService {
|
||||
|
||||
for (XWPFTable tbl : doc.getTables()) {
|
||||
String tblText = tbl.getText();
|
||||
if (tblText.contains(PAGE_PLACEHOLDER) || tblText.contains(PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_PLACEHOLDER) || tblText.contains(
|
||||
EXCERPT_PLACEHOLDER) || tblText.contains(JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_REASON_PLACEHOLDER) || tblText.contains(
|
||||
JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER) || tblText.contains(JUSTIFICATION_TEXT_PLACEHOLDER) || tblText.contains(
|
||||
SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER) || tblText.contains(SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER)) {
|
||||
if (tblText.contains(PAGE_PLACEHOLDER) || tblText.contains(PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_PLACEHOLDER) || tblText.contains(EXCERPT_PLACEHOLDER) || tblText.contains(
|
||||
JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_REASON_PLACEHOLDER) || tblText.contains(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER) || tblText.contains(
|
||||
JUSTIFICATION_TEXT_PLACEHOLDER) || tblText.contains(SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER) || tblText.contains(
|
||||
SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER)) {
|
||||
return tbl;
|
||||
}
|
||||
}
|
||||
@ -341,7 +358,10 @@ public class WordReportGenerationService {
|
||||
|
||||
|
||||
@Timed("redactmanager_word-addRedactionEntryRows")
|
||||
private int addRedactionEntryRows(XWPFTable table, List<ReportRedactionEntry> reportEntries, String filename, PlaceholderModel placeholderModel,
|
||||
private int addRedactionEntryRows(XWPFTable table,
|
||||
List<ReportRedactionEntry> reportEntries,
|
||||
String filename,
|
||||
PlaceholderModel placeholderModel,
|
||||
PlaceHolderFunctions placeHolderFunctions) {
|
||||
|
||||
int sumOfChars = 0;
|
||||
@ -527,7 +547,8 @@ public class WordReportGenerationService {
|
||||
|
||||
|
||||
protected int approxNumberOfChars(Optional<ReportRedactionEntry> firstReportEntry, String filename) {
|
||||
if(firstReportEntry.isPresent()) {
|
||||
|
||||
if (firstReportEntry.isPresent()) {
|
||||
int sumOfChars = 0;
|
||||
|
||||
sumOfChars += filename.length();
|
||||
|
||||
@ -1,23 +1,26 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.storage;
|
||||
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
|
||||
import com.iqser.red.storage.commons.service.StorageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
|
||||
import com.iqser.red.storage.commons.service.StorageService;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ReportStorageService {
|
||||
|
||||
private final StorageService storageService;
|
||||
|
||||
|
||||
public String storeObject(String downloadId, byte[] data) {
|
||||
|
||||
String storageId = StorageIdUtils.getStorageId(downloadId, UUID.randomUUID().toString());
|
||||
@ -36,6 +39,7 @@ public class ReportStorageService {
|
||||
|
||||
|
||||
public byte[] getReportTemplate(String storageId) {
|
||||
|
||||
try {
|
||||
return IOUtils.toByteArray(storageService.getObject(storageId).getInputStream());
|
||||
} catch (IOException e) {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.utils;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class ResourceLoader {
|
||||
|
||||
@ -21,4 +21,5 @@ public class ResourceLoader {
|
||||
throw new IllegalArgumentException("could not load classpath resource: " + classpathPath, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,22 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.DossierAttributeConfig;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.ReportTemplate;
|
||||
@ -11,22 +28,6 @@ import com.iqser.red.service.redaction.report.v1.server.client.ReportTemplateCli
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService;
|
||||
import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageService;
|
||||
import com.iqser.red.storage.commons.service.StorageService;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@ -53,6 +54,7 @@ public class PlaceholderTest {
|
||||
@MockBean
|
||||
private FileAttributesConfigClient fileAttributesClient;
|
||||
|
||||
|
||||
@Test
|
||||
public void testGeneralPlaceholders() {
|
||||
|
||||
@ -64,6 +66,7 @@ public class PlaceholderTest {
|
||||
Assert.assertEquals(placeholders.size(), 17);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetReportTemplates() throws IOException {
|
||||
|
||||
@ -78,20 +81,62 @@ public class PlaceholderTest {
|
||||
ClassPathResource templateResource2 = new ClassPathResource("templates/" + storageId2);
|
||||
when(reportStorageService.getReportTemplate(storageId2)).thenReturn(IOUtils.toByteArray(templateResource2.getInputStream()));
|
||||
|
||||
when(reportTemplateClient.getAvailableReportTemplates(dossierTemplateId)).thenReturn(List.of(
|
||||
ReportTemplate.builder().storageId(storageId).build(),
|
||||
when(reportTemplateClient.getAvailableReportTemplates(dossierTemplateId)).thenReturn(List.of(ReportTemplate.builder().storageId(storageId).build(),
|
||||
ReportTemplate.builder().storageId(storageId2).build()));
|
||||
|
||||
DossierAttributeConfig dossierAttributeConfig = new DossierAttributeConfig("id", "Active Substance", true, "{{dossier.attribute.ActiveSubstance}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig2 = new DossierAttributeConfig("id2", "Rapporteur Member State", false, "{{dossier.attribute.RapporteurMemberState}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig3 = new DossierAttributeConfig("id3", "Dossier Name", true, "{{dossier.attribute.Name}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig4 = new DossierAttributeConfig("id4", "Company", false, "{{dossier.attribute.Company}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig5 = new DossierAttributeConfig("id5", "Date", true, "{{dossier.attribute.Date}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig6 = new DossierAttributeConfig("id6", "Signature", false, "{{dossier.attribute.Signature}}", DossierAttributeType.IMAGE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig7 = new DossierAttributeConfig("id7", "Does not exist", true, "{{does.not.exist}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig = new DossierAttributeConfig("id",
|
||||
"Active Substance",
|
||||
true,
|
||||
"{{dossier.attribute.ActiveSubstance}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig2 = new DossierAttributeConfig("id2",
|
||||
"Rapporteur Member State",
|
||||
false,
|
||||
"{{dossier.attribute.RapporteurMemberState}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig3 = new DossierAttributeConfig("id3",
|
||||
"Dossier Name",
|
||||
true,
|
||||
"{{dossier.attribute.Name}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig4 = new DossierAttributeConfig("id4",
|
||||
"Company",
|
||||
false,
|
||||
"{{dossier.attribute.Company}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig5 = new DossierAttributeConfig("id5",
|
||||
"Date",
|
||||
true,
|
||||
"{{dossier.attribute.Date}}",
|
||||
DossierAttributeType.DATE,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig6 = new DossierAttributeConfig("id6",
|
||||
"Signature",
|
||||
false,
|
||||
"{{dossier.attribute.Signature}}",
|
||||
DossierAttributeType.IMAGE,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig7 = new DossierAttributeConfig("id7",
|
||||
"Does not exist",
|
||||
true,
|
||||
"{{does.not.exist}}",
|
||||
DossierAttributeType.DATE,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig8 = new DossierAttributeConfig("id8", "test1", true, "{{test1}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig9 = new DossierAttributeConfig("id9", "test1", true, "{{TEST1}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
when(dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId)).thenReturn(List.of(dossierAttributeConfig, dossierAttributeConfig2, dossierAttributeConfig3, dossierAttributeConfig4, dossierAttributeConfig5, dossierAttributeConfig6, dossierAttributeConfig7, dossierAttributeConfig8, dossierAttributeConfig9));
|
||||
when(dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId)).thenReturn(List.of(dossierAttributeConfig,
|
||||
dossierAttributeConfig2,
|
||||
dossierAttributeConfig3,
|
||||
dossierAttributeConfig4,
|
||||
dossierAttributeConfig5,
|
||||
dossierAttributeConfig6,
|
||||
dossierAttributeConfig7,
|
||||
dossierAttributeConfig8,
|
||||
dossierAttributeConfig9));
|
||||
|
||||
FileAttributeConfig fileAttributeConfig1 = FileAttributeConfig.builder().id("config1").label("Label1").placeholder("{{file.test.1}}").build();
|
||||
FileAttributeConfig fileAttributeConfig2 = FileAttributeConfig.builder().id("config2").label("Label2").placeholder("{{file.test.not.exist}}").build();
|
||||
@ -109,6 +154,7 @@ public class PlaceholderTest {
|
||||
Assert.assertEquals(storageId, reportTemplates.get(0).getStorageId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWord() throws IOException {
|
||||
|
||||
@ -122,23 +168,65 @@ public class PlaceholderTest {
|
||||
|
||||
when(reportTemplateClient.getReportTemplate(dossierTemplateId, reportTemplateId)).thenReturn(ReportTemplate.builder().storageId(storageId).build());
|
||||
|
||||
DossierAttributeConfig dossierAttributeConfig = new DossierAttributeConfig("id", "Active Substance", true, "{{dossier.attribute.ActiveSubstance}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig2 = new DossierAttributeConfig("id2", "Rapporteur Member State", false, "{{dossier.attribute.RapporteurMemberState}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig3 = new DossierAttributeConfig("id3", "Dossier Name", true, "{{dossier.attribute.Name}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig4 = new DossierAttributeConfig("id4", "Company", false, "{{dossier.attribute.Company}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig5 = new DossierAttributeConfig("id5", "Date", true, "{{dossier.attribute.Date}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig6 = new DossierAttributeConfig("id6", "Signature", false, "{{dossier.attribute.Signature}}", DossierAttributeType.IMAGE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig7 = new DossierAttributeConfig("id7", "Does not exist", true, "{{does.not.exist}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig = new DossierAttributeConfig("id",
|
||||
"Active Substance",
|
||||
true,
|
||||
"{{dossier.attribute.ActiveSubstance}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig2 = new DossierAttributeConfig("id2",
|
||||
"Rapporteur Member State",
|
||||
false,
|
||||
"{{dossier.attribute.RapporteurMemberState}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig3 = new DossierAttributeConfig("id3",
|
||||
"Dossier Name",
|
||||
true,
|
||||
"{{dossier.attribute.Name}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig4 = new DossierAttributeConfig("id4",
|
||||
"Company",
|
||||
false,
|
||||
"{{dossier.attribute.Company}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig5 = new DossierAttributeConfig("id5",
|
||||
"Date",
|
||||
true,
|
||||
"{{dossier.attribute.Date}}",
|
||||
DossierAttributeType.DATE,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig6 = new DossierAttributeConfig("id6",
|
||||
"Signature",
|
||||
false,
|
||||
"{{dossier.attribute.Signature}}",
|
||||
DossierAttributeType.IMAGE,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig7 = new DossierAttributeConfig("id7",
|
||||
"Does not exist",
|
||||
true,
|
||||
"{{does.not.exist}}",
|
||||
DossierAttributeType.DATE,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig8 = new DossierAttributeConfig("id8", "test1", true, "{{test1}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig9 = new DossierAttributeConfig("id9", "test1", true, "{{TEST1}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
when(dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId)).thenReturn(List.of(dossierAttributeConfig, dossierAttributeConfig2, dossierAttributeConfig3, dossierAttributeConfig4, dossierAttributeConfig5, dossierAttributeConfig6, dossierAttributeConfig7, dossierAttributeConfig8, dossierAttributeConfig9));
|
||||
when(dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId)).thenReturn(List.of(dossierAttributeConfig,
|
||||
dossierAttributeConfig2,
|
||||
dossierAttributeConfig3,
|
||||
dossierAttributeConfig4,
|
||||
dossierAttributeConfig5,
|
||||
dossierAttributeConfig6,
|
||||
dossierAttributeConfig7,
|
||||
dossierAttributeConfig8,
|
||||
dossierAttributeConfig9));
|
||||
|
||||
FileAttributeConfig fileAttributeConfig1 = FileAttributeConfig.builder().id("config1").label("Label1").placeholder("{{file.test.1}}").build();
|
||||
FileAttributeConfig fileAttributeConfig2 = FileAttributeConfig.builder().id("config2").label("Label2").placeholder("{{file.test.not.exist}}").build();
|
||||
|
||||
when(fileAttributesClient.getFileAttributeConfigs(dossierTemplateId)).thenReturn(List.of(fileAttributeConfig1, fileAttributeConfig2));
|
||||
|
||||
|
||||
// Act
|
||||
Set<String> placeholders = placeholderService.getPlaceholdersOfTemplate(dossierTemplateId, reportTemplateId);
|
||||
|
||||
@ -155,6 +243,7 @@ public class PlaceholderTest {
|
||||
Assert.assertFalse(placeholders.contains("{{file.test.not.exist}}"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExcel() throws IOException {
|
||||
|
||||
@ -168,16 +257,59 @@ public class PlaceholderTest {
|
||||
|
||||
when(reportTemplateClient.getReportTemplate(dossierTemplateId, reportTemplateId)).thenReturn(ReportTemplate.builder().storageId(storageId).build());
|
||||
|
||||
DossierAttributeConfig dossierAttributeConfig = new DossierAttributeConfig("id", "Active Substance", true, "{{dossier.attribute.ActiveSubstance}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig2 = new DossierAttributeConfig("id2", "Rapporteur Member State", false, "{{dossier.attribute.RapporteurMemberState}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig3 = new DossierAttributeConfig("id3", "Dossier Name", true, "{{dossier.attribute.Name}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig4 = new DossierAttributeConfig("id4", "Company", false, "{{dossier.attribute.Company}}", DossierAttributeType.TEXT, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig5 = new DossierAttributeConfig("id5", "Date", true, "{{dossier.attribute.Date}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig6 = new DossierAttributeConfig("id6", "Signature", false, "{{dossier.attribute.Signature}}", DossierAttributeType.IMAGE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig7 = new DossierAttributeConfig("id7", "Does not exist", true, "{{does.not.exist}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig = new DossierAttributeConfig("id",
|
||||
"Active Substance",
|
||||
true,
|
||||
"{{dossier.attribute.ActiveSubstance}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig2 = new DossierAttributeConfig("id2",
|
||||
"Rapporteur Member State",
|
||||
false,
|
||||
"{{dossier.attribute.RapporteurMemberState}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig3 = new DossierAttributeConfig("id3",
|
||||
"Dossier Name",
|
||||
true,
|
||||
"{{dossier.attribute.Name}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig4 = new DossierAttributeConfig("id4",
|
||||
"Company",
|
||||
false,
|
||||
"{{dossier.attribute.Company}}",
|
||||
DossierAttributeType.TEXT,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig5 = new DossierAttributeConfig("id5",
|
||||
"Date",
|
||||
true,
|
||||
"{{dossier.attribute.Date}}",
|
||||
DossierAttributeType.DATE,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig6 = new DossierAttributeConfig("id6",
|
||||
"Signature",
|
||||
false,
|
||||
"{{dossier.attribute.Signature}}",
|
||||
DossierAttributeType.IMAGE,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig7 = new DossierAttributeConfig("id7",
|
||||
"Does not exist",
|
||||
true,
|
||||
"{{does.not.exist}}",
|
||||
DossierAttributeType.DATE,
|
||||
dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig8 = new DossierAttributeConfig("id8", "test1", true, "{{test1}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
DossierAttributeConfig dossierAttributeConfig9 = new DossierAttributeConfig("id9", "test1", true, "{{TEST1}}", DossierAttributeType.DATE, dossierTemplateId);
|
||||
when(dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId)).thenReturn(List.of(dossierAttributeConfig, dossierAttributeConfig2, dossierAttributeConfig3, dossierAttributeConfig4, dossierAttributeConfig5, dossierAttributeConfig6, dossierAttributeConfig7, dossierAttributeConfig8, dossierAttributeConfig9));
|
||||
when(dossierAttributesConfigClient.getDossierAttributes(dossierTemplateId)).thenReturn(List.of(dossierAttributeConfig,
|
||||
dossierAttributeConfig2,
|
||||
dossierAttributeConfig3,
|
||||
dossierAttributeConfig4,
|
||||
dossierAttributeConfig5,
|
||||
dossierAttributeConfig6,
|
||||
dossierAttributeConfig7,
|
||||
dossierAttributeConfig8,
|
||||
dossierAttributeConfig9));
|
||||
|
||||
FileAttributeConfig fileAttributeConfig1 = FileAttributeConfig.builder().id("config1").label("Label1").placeholder("{{file.test.1}}").build();
|
||||
FileAttributeConfig fileAttributeConfig2 = FileAttributeConfig.builder().id("config2").label("Label2").placeholder("{{file.test.not.exist}}").build();
|
||||
|
||||
@ -122,7 +122,18 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = Dossier.builder().dossierName("dossierName").build();
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
|
||||
var placeholders = buildPlaceHolderModel(Map.of("{{dossier.attribute.ActiveSubstance}}", "Aktive Substanz \n Test Return", "{{dossier.attribute.RapporteurMemberState}}", "Reporter Status", "{{dossier.attribute.Name}}", "Dossier Name", "{{dossier.attribute.Company}}", "Firma", "{{dossier.attribute.Date}}", "2021-11-09T23:00:00.000Z"), Map.of("{{file.attribute.placeholder}}", "Test"), List.of(new ImagePlaceholder("{{dossier.attribute.Signature}}", IOUtils.toByteArray(imageResource.getInputStream()))));
|
||||
var placeholders = buildPlaceHolderModel(Map.of("{{dossier.attribute.ActiveSubstance}}",
|
||||
"Aktive Substanz \n Test Return",
|
||||
"{{dossier.attribute.RapporteurMemberState}}",
|
||||
"Reporter Status",
|
||||
"{{dossier.attribute.Name}}",
|
||||
"Dossier Name",
|
||||
"{{dossier.attribute.Company}}",
|
||||
"Firma",
|
||||
"{{dossier.attribute.Date}}",
|
||||
"2021-11-09T23:00:00.000Z"),
|
||||
Map.of("{{file.attribute.placeholder}}", "Test"),
|
||||
List.of(new ImagePlaceholder("{{dossier.attribute.Signature}}", IOUtils.toByteArray(imageResource.getInputStream()))));
|
||||
|
||||
XWPFDocument doc = new XWPFDocument(wordTemplateResource.getInputStream());
|
||||
wordReportGenerationService.generateWordReport(reportEntries, placeholders, "test", doc, fileModel, dossier, true);
|
||||
@ -148,7 +159,18 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = Dossier.builder().dossierName("dossierName").build();
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
|
||||
var placeholders = buildPlaceHolderModel(Map.of("{{dossier.attribute.ActiveSubstance}}", "Aktive Substanz \n Test Return", "{{dossier.attribute.RapporteurMemberState}}", "Reporter Status", "{{dossier.attribute.Name}}", "Dossier Name", "{{dossier.attribute.Company}}", "Firma", "{{dossier.attribute.Date}}", "2021-11-09T23:00:00.000Z"), Map.of("{{file.attribute.placeholder}}", "Test"), List.of(new ImagePlaceholder("{{dossier.attribute.Signature}}", IOUtils.toByteArray(imageResource.getInputStream()))));
|
||||
var placeholders = buildPlaceHolderModel(Map.of("{{dossier.attribute.ActiveSubstance}}",
|
||||
"Aktive Substanz \n Test Return",
|
||||
"{{dossier.attribute.RapporteurMemberState}}",
|
||||
"Reporter Status",
|
||||
"{{dossier.attribute.Name}}",
|
||||
"Dossier Name",
|
||||
"{{dossier.attribute.Company}}",
|
||||
"Firma",
|
||||
"{{dossier.attribute.Date}}",
|
||||
"2021-11-09T23:00:00.000Z"),
|
||||
Map.of("{{file.attribute.placeholder}}", "Test"),
|
||||
List.of(new ImagePlaceholder("{{dossier.attribute.Signature}}", IOUtils.toByteArray(imageResource.getInputStream()))));
|
||||
|
||||
XWPFDocument doc = new XWPFDocument(wordTemplateResource.getInputStream());
|
||||
wordReportGenerationService.generateWordReport(reportEntries, placeholders, "test", doc, fileModel, dossier, true);
|
||||
@ -257,7 +279,18 @@ public class RedactionReportIntegrationTest {
|
||||
Dossier dossier = Dossier.builder().dossierName("dossierName").build();
|
||||
FileModel fileModel = FileModel.builder().filename("filename").build();
|
||||
|
||||
var placeholders = buildPlaceHolderModel(Map.of("{{dossier.attribute.ActiveSubstance}}", "Aktive Substanz \n Test Return", "{{dossier.attribute.RapporteurMemberState}}", "Reporter Status", "{{dossier.attribute.Name}}", "Dossier Name", "{{dossier.attribute.Company}}", "Firma", "{{dossier.attribute.Date}}", "2021-11-09T23:00:00.000Z"), Map.of("{{file.attribute.placeholder}}", "Test"), List.of(new ImagePlaceholder("{{dossier.attribute.Signature}}", IOUtils.toByteArray(imageResource.getInputStream()))));
|
||||
var placeholders = buildPlaceHolderModel(Map.of("{{dossier.attribute.ActiveSubstance}}",
|
||||
"Aktive Substanz \n Test Return",
|
||||
"{{dossier.attribute.RapporteurMemberState}}",
|
||||
"Reporter Status",
|
||||
"{{dossier.attribute.Name}}",
|
||||
"Dossier Name",
|
||||
"{{dossier.attribute.Company}}",
|
||||
"Firma",
|
||||
"{{dossier.attribute.Date}}",
|
||||
"2021-11-09T23:00:00.000Z"),
|
||||
Map.of("{{file.attribute.placeholder}}", "Test"),
|
||||
List.of(new ImagePlaceholder("{{dossier.attribute.Signature}}", IOUtils.toByteArray(imageResource.getInputStream()))));
|
||||
|
||||
XWPFDocument doc = new XWPFDocument(wordTemplateResource.getInputStream());
|
||||
wordReportGenerationService.generateWordReport(reportEntries, placeholders, "test", doc, fileModel, dossier, true);
|
||||
@ -278,7 +311,7 @@ public class RedactionReportIntegrationTest {
|
||||
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(redactionLog);
|
||||
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName);
|
||||
|
||||
FileModel fileModel = FileModel.builder().filename("filename").fileAttributes(Map.of("TestAttribute","Lorem Ipsum")).build();
|
||||
FileModel fileModel = FileModel.builder().filename("filename").fileAttributes(Map.of("TestAttribute", "Lorem Ipsum")).build();
|
||||
|
||||
ClassPathResource templateResource = new ClassPathResource("templates/Excel Report.xlsx");
|
||||
|
||||
@ -323,7 +356,14 @@ public class RedactionReportIntegrationTest {
|
||||
RedactionLog redactionLogSecondFile = objectMapper.readValue(new ClassPathResource("files/excelReportRedactionLog.json").getInputStream(), RedactionLog.class);
|
||||
List<ReportRedactionEntry> reportEntriesSecondFile = redactionLogConverterService.convertAndSort(redactionLogSecondFile, legalBasisMapping, mapOfEntityDisplayName);
|
||||
FileModel fileModelSecondFile = FileModel.builder().filename("secondFile").build();
|
||||
excelTemplateReportGenerationService.generateExcelReport(reportEntriesSecondFile, placeholders, "test", writeWorkbook, "dossierName", fileModelSecondFile, excelModel, true);
|
||||
excelTemplateReportGenerationService.generateExcelReport(reportEntriesSecondFile,
|
||||
placeholders,
|
||||
"test",
|
||||
writeWorkbook,
|
||||
"dossierName",
|
||||
fileModelSecondFile,
|
||||
excelModel,
|
||||
true);
|
||||
|
||||
byte[] excelTemplateReport3 = excelTemplateReportGenerationService.toByteArray(writeWorkbook);
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(getTemporaryDirectory() + "/Excel Report_multifile.xlsx")) {
|
||||
@ -347,7 +387,9 @@ public class RedactionReportIntegrationTest {
|
||||
|
||||
ClassPathResource templateResource = new ClassPathResource("templates/Excel Report_PlaceholderTest.xlsx");
|
||||
|
||||
var placeholders = buildPlaceHolderModel(Map.of("{{dossier_attribute.test1}}", "replaced_dossier_test1"), Map.of("{{file_attribute.test1}}", "replaced_file_test1", "{{file_attribute.test2}}", "replaced_file_test2"), List.of(new ImagePlaceholder("{{dossier.attribute.Signature}}", IOUtils.toByteArray(imageResource.getInputStream()))));
|
||||
var placeholders = buildPlaceHolderModel(Map.of("{{dossier_attribute.test1}}", "replaced_dossier_test1"),
|
||||
Map.of("{{file_attribute.test1}}", "replaced_file_test1", "{{file_attribute.test2}}", "replaced_file_test2"),
|
||||
List.of(new ImagePlaceholder("{{dossier.attribute.Signature}}", IOUtils.toByteArray(imageResource.getInputStream()))));
|
||||
|
||||
XSSFWorkbook readWorkbook = new XSSFWorkbook(templateResource.getInputStream());
|
||||
var excelModel = excelTemplateReportGenerationService.calculateExcelModel(readWorkbook.getSheetAt(0));
|
||||
@ -362,8 +404,6 @@ public class RedactionReportIntegrationTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private Map<String, String> createEntityDisplayNames(RedactionLog redactionLog) {
|
||||
|
||||
Type t1 = new Type();
|
||||
@ -391,7 +431,15 @@ public class RedactionReportIntegrationTest {
|
||||
|
||||
private PlaceholderModel buildPlaceHolderModel(Map<String, String> dossierAttributes, Map<String, String> fileAttributes, List<ImagePlaceholder> imagePlaceholders) {
|
||||
|
||||
var defaultPlaceHolder = new HashSet<>(Set.of(FILE_NAME_PLACEHOLDER, FORMAT_DATE_ISO_PLACEHOLDER, FORMAT_DATE_GER_PLACEHOLDER, FORMAT_DATE_ENG_PLACEHOLDER, FORMAT_TIME_ISO_PLACEHOLDER, DOSSIER_NAME_PLACEHOLDER, IUCLID_FUNCTION_PLACEHOLDER, SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER, SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER));
|
||||
var defaultPlaceHolder = new HashSet<>(Set.of(FILE_NAME_PLACEHOLDER,
|
||||
FORMAT_DATE_ISO_PLACEHOLDER,
|
||||
FORMAT_DATE_GER_PLACEHOLDER,
|
||||
FORMAT_DATE_ENG_PLACEHOLDER,
|
||||
FORMAT_TIME_ISO_PLACEHOLDER,
|
||||
DOSSIER_NAME_PLACEHOLDER,
|
||||
IUCLID_FUNCTION_PLACEHOLDER,
|
||||
SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER,
|
||||
SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER));
|
||||
defaultPlaceHolder.addAll(dossierAttributes.keySet());
|
||||
defaultPlaceHolder.addAll(fileAttributes.keySet());
|
||||
return new PlaceholderModel(defaultPlaceHolder, imagePlaceholders, dossierAttributes, null, fileAttributes, new HashMap<>());
|
||||
|
||||
@ -1,5 +1,33 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.utils.OsUtils.getTemporaryDirectory;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@ -13,7 +41,14 @@ import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.do
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileModel;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportRequestMessage;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.*;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DictionaryClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesConfigClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesConfigClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.RedactionLogClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.ReportTemplateClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.ReportGenerationService;
|
||||
import com.iqser.red.service.redaction.report.v1.server.utils.FileSystemBackedStorageService;
|
||||
@ -24,30 +59,6 @@ import com.iqser.red.storage.commons.service.StorageService;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.utils.OsUtils.getTemporaryDirectory;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@Slf4j
|
||||
@RunWith(SpringRunner.class)
|
||||
@Import(RedactionReportV2IntegrationTest.TestConfiguration.class)
|
||||
@ -197,7 +208,7 @@ public class RedactionReportV2IntegrationTest {
|
||||
@SneakyThrows
|
||||
public void testBasicExcelReportFlow() {
|
||||
|
||||
var reportRequestMessage = prepareFlow(1,"templates/Excel Report.xlsx");
|
||||
var reportRequestMessage = prepareFlow(1, "templates/Excel Report.xlsx");
|
||||
processRequest(reportRequestMessage, ".xlsx");
|
||||
}
|
||||
|
||||
@ -206,7 +217,7 @@ public class RedactionReportV2IntegrationTest {
|
||||
@SneakyThrows
|
||||
public void testMultifileWordReportFlow() {
|
||||
|
||||
var reportRequestMessage = prepareFlow(2,"templates/Justification Appendix A1.docx");
|
||||
var reportRequestMessage = prepareFlow(2, "templates/Justification Appendix A1.docx");
|
||||
processRequest(reportRequestMessage, ".docx");
|
||||
}
|
||||
|
||||
@ -215,7 +226,7 @@ public class RedactionReportV2IntegrationTest {
|
||||
@SneakyThrows
|
||||
public void test2FilesConcurrently() {
|
||||
|
||||
var reportRequestMessage = prepareFlow(1,"templates/report.xlsx", "templates/report-advanced.xlsx");
|
||||
var reportRequestMessage = prepareFlow(1, "templates/report.xlsx", "templates/report-advanced.xlsx");
|
||||
processRequest(reportRequestMessage, ".xlsx");
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,5 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.commons.jackson.ObjectMapperFactory;
|
||||
import com.iqser.red.storage.commons.exception.StorageObjectDoesNotExist;
|
||||
import com.iqser.red.storage.commons.service.StorageService;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -18,13 +10,26 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.commons.jackson.ObjectMapperFactory;
|
||||
import com.iqser.red.storage.commons.exception.StorageObjectDoesNotExist;
|
||||
import com.iqser.red.storage.commons.service.StorageService;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
public class FileSystemBackedStorageService implements StorageService {
|
||||
|
||||
private final Map<String, File> dataMap = new HashMap<>();
|
||||
|
||||
|
||||
public FileSystemBackedStorageService() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public InputStreamResource getObject(String objectId) {
|
||||
@ -37,48 +42,62 @@ public class FileSystemBackedStorageService implements StorageService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteObject(String objectId) {
|
||||
|
||||
dataMap.remove(objectId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean objectExists(String objectId) {
|
||||
|
||||
return dataMap.containsKey(objectId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public <T> void storeJSONObject(String objectId, T any) {
|
||||
|
||||
File tempFile = File.createTempFile("test", ".tmp");
|
||||
getMapper().writeValue(new FileOutputStream(tempFile), any);
|
||||
dataMap.put(objectId, tempFile);
|
||||
}
|
||||
|
||||
|
||||
private ObjectMapper getMapper() {
|
||||
|
||||
return ObjectMapperFactory.create();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public <T> T readJSONObject(String objectId, Class<T> clazz) {
|
||||
|
||||
if (dataMap.get(objectId) == null || !dataMap.get(objectId).exists()) {
|
||||
throw new StorageObjectDoesNotExist("Stored object not found");
|
||||
}
|
||||
return getMapper().readValue(new FileInputStream(dataMap.get(objectId)), clazz);
|
||||
}
|
||||
|
||||
|
||||
public List<String> listPaths() {
|
||||
|
||||
return new ArrayList<>(dataMap.keySet());
|
||||
}
|
||||
|
||||
|
||||
public List<String> listFilePaths() {
|
||||
|
||||
return dataMap.values().stream().map(File::getAbsolutePath).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ -86,6 +105,7 @@ public class FileSystemBackedStorageService implements StorageService {
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void storeObject(String objectId, InputStream stream) {
|
||||
|
||||
File tempFile = File.createTempFile("test", ".tmp");
|
||||
|
||||
try (var fileOutputStream = new FileOutputStream(tempFile)) {
|
||||
@ -97,9 +117,11 @@ public class FileSystemBackedStorageService implements StorageService {
|
||||
|
||||
|
||||
public void clearStorage() {
|
||||
|
||||
this.dataMap.forEach((k, v) -> {
|
||||
v.delete();
|
||||
});
|
||||
this.dataMap.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user