Merge branch 'RED-7962' into 'master'
RED-7962 Fixed error 500 and improved response of endpoint to get file attributes ... Closes RED-7962 See merge request redactmanager/persistence-service!230
This commit is contained in:
commit
00dff315b7
@ -101,8 +101,7 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
||||
|
||||
|
||||
@PreAuthorize("hasAuthority('" + READ_RULES + "')")
|
||||
public ResponseEntity<InputStreamResource> downloadComponentRules(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId,
|
||||
@PathVariable(RULE_FILE_TYPE_PARAMETER_NAME) RuleFileType ruleFileType) {
|
||||
public ResponseEntity<InputStreamResource> downloadComponentRules(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId) {
|
||||
|
||||
return downloadRules(dossierTemplateId, RuleFileType.COMPONENT);
|
||||
}
|
||||
@ -112,7 +111,13 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
||||
|
||||
var fileAttributeConfigs = fileAttributesController.getFileAttributesConfiguration(dossierTemplateId);
|
||||
|
||||
return new FileAttributeDefinitionList(fileAttributeConfigs.getFileAttributeConfigs().stream()
|
||||
var csvImportSettings = FileAttributeDefinitionList.CsvImportSettings.builder()
|
||||
.encoding(fileAttributeConfigs.getEncoding())
|
||||
.delimiter(fileAttributeConfigs.getDelimiter())
|
||||
.filenameMappingCsvColumnHeader(fileAttributeConfigs.getFilenameMappingColumnHeaderName())
|
||||
.build();
|
||||
|
||||
var fileAttributeDefinitions = fileAttributeConfigs.getFileAttributeConfigs().stream()
|
||||
.map(fileAttributeConfig -> FileAttributeDefinition.builder()
|
||||
.id(fileAttributeConfig.getId())
|
||||
.name(fileAttributeConfig.getLabel())
|
||||
@ -126,7 +131,9 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
||||
.displayedInFileList(fileAttributeConfig.isDisplayedInFileList())
|
||||
.build())
|
||||
.build())
|
||||
.toList());
|
||||
.toList();
|
||||
|
||||
return new FileAttributeDefinitionList(csvImportSettings, fileAttributeDefinitions);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@ -166,7 +173,7 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(rulesUploadRequest.getDossierTemplateId())
|
||||
.category(AuditCategory.DOSSIER_TEMPLATE.name())
|
||||
.message(String.format("%s Rules have been updated", rulesUploadRequest.getRuleFileType()))
|
||||
.message(String.format("%s rules have been %s", rulesUploadRequest.getRuleFileType(), dryRun ? "validated" : "updated"))
|
||||
.build());
|
||||
|
||||
// TODO Add warning and deprecations to response
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
package com.iqser.red.service.persistence.service.v2.api.external.model;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -14,6 +19,31 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class FileAttributeDefinitionList {
|
||||
|
||||
private CsvImportSettings csvImportSettings;
|
||||
|
||||
@Builder.Default
|
||||
private List<FileAttributeDefinition> fileAttributeDefinitions = new ArrayList<>();
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class CsvImportSettings {
|
||||
|
||||
private String filenameMappingCsvColumnHeader;
|
||||
|
||||
@Builder.Default
|
||||
private String delimiter = ",";
|
||||
|
||||
@Builder.Default
|
||||
private String encoding = StandardCharsets.UTF_8.name();
|
||||
|
||||
// TODO: make csvMappingActive a persistent value instead of a transient one when implementing the endpoint to set the csv mapping
|
||||
@JsonProperty("csvMappingActive")
|
||||
public boolean isCsvMappingActive() {
|
||||
return StringUtils.isBlank(filenameMappingCsvColumnHeader);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ public interface DossierTemplateResource {
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@Operation(summary = "Returns file containing the currently used Drools rules.")
|
||||
@Operation(summary = "Returns file containing the currently used entity rules.")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
||||
@GetMapping(value = PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + ENTITY_RULES_PATH, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
ResponseEntity<InputStreamResource> downloadEntityRules(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId);
|
||||
@ -84,10 +84,10 @@ public interface DossierTemplateResource {
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@Operation(summary = "Returns file containing the currently used Drools rules.")
|
||||
@Operation(summary = "Returns file containing the currently used component rules.")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
||||
@GetMapping(value = PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + COMPONENT_RULES_PATH, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
ResponseEntity<InputStreamResource> downloadComponentRules(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId, @PathVariable(RULE_FILE_TYPE_PARAMETER_NAME) RuleFileType ruleFileType);
|
||||
ResponseEntity<InputStreamResource> downloadComponentRules(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId);
|
||||
|
||||
@Operation(summary = "Get the file attribute definitions of a DossierTemplate.", description = "None")
|
||||
@GetMapping(value = PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + FILE_ATTRIBUTE_DEFINITIONS_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@ -1460,25 +1460,25 @@ components:
|
||||
primaryAttribute:
|
||||
type: boolean
|
||||
description: |
|
||||
If true, the RedactManager and DocuMine user interfaces show the value of the file attribute in the file list below the file name.
|
||||
If `true`, the RedactManager and DocuMine user interfaces show the value of the file attribute in the file list below the file name.
|
||||
editable:
|
||||
type: boolean
|
||||
description: |
|
||||
If true, the RedactManager and DocuMine user interfaces allow manual editing of the value. Otherwise only importing and setting by rules would be possible.
|
||||
If `true`, the RedactManager and DocuMine user interfaces allow manual editing of the value. Otherwise only importing and setting by rules would be possible.
|
||||
filterable:
|
||||
type: boolean
|
||||
description: |
|
||||
If true, the RedactManager and DocuMine user interfaces add filter options to the file list.
|
||||
If `true`, the RedactManager and DocuMine user interfaces add filter options to the file list.
|
||||
displayedInFileList:
|
||||
type: boolean
|
||||
description: |
|
||||
if true, the RedactManager and DocuMine user interfaces show the values in the file list.
|
||||
if `true`, the RedactManager and DocuMine user interfaces show the values in the file list.
|
||||
required:
|
||||
- primaryAttribute
|
||||
- editable
|
||||
- filterable
|
||||
- displayedInFileList
|
||||
example: :
|
||||
example:
|
||||
primaryAttribute: false
|
||||
editable: true
|
||||
filterable: true
|
||||
@ -1487,30 +1487,71 @@ components:
|
||||
type: object
|
||||
description: A list of file attribute definitions.
|
||||
properties:
|
||||
csvImportSettings:
|
||||
$ref: '#/components/schemas/CsvImportSettings'
|
||||
fileAttributeDefinitions:
|
||||
items:
|
||||
$ref: '#/components/schemas/FileAttributeDefinition'
|
||||
type: array
|
||||
example:
|
||||
- id: "123e4567-e89b-12d3-a456-426614174000"
|
||||
name: "Document Type"
|
||||
type: "TEXT"
|
||||
mappedCsvColumnHeader: "DocumentCategory"
|
||||
reportingPlaceholder: "{{file.attribute.DocumentType}}"
|
||||
displaySettings:
|
||||
primaryAttribute: true
|
||||
editable: true
|
||||
filterable: true
|
||||
displayedInFileList: false
|
||||
- id: "23e45678-e90b-12d3-a456-765114174321"
|
||||
name: "Comment"
|
||||
type: "TEXT"
|
||||
reportingPlaceholder: "{{file.attribute.Comment}}"
|
||||
displaySettings:
|
||||
primaryAttribute: false
|
||||
editable: true
|
||||
filterable: false
|
||||
displayedInFileList: false
|
||||
csvImportSettings:
|
||||
csvMappingActive: true
|
||||
filenameMappingCsvColumnHeader: "Filename"
|
||||
delimiter: ","
|
||||
encoding: "UTF-8"
|
||||
fileAttributeDefinitions:
|
||||
- id: "123e4567-e89b-12d3-a456-426614174000"
|
||||
name: "Document Type"
|
||||
type: "TEXT"
|
||||
mappedCsvColumnHeader: "DocumentCategory"
|
||||
reportingPlaceholder: "{{file.attribute.DocumentType}}"
|
||||
displaySettings:
|
||||
primaryAttribute: true
|
||||
editable: true
|
||||
filterable: true
|
||||
displayedInFileList: false
|
||||
- id: "23e45678-e90b-12d3-a456-765114174321"
|
||||
name: "Comment"
|
||||
type: "TEXT"
|
||||
reportingPlaceholder: "{{file.attribute.Comment}}"
|
||||
displaySettings:
|
||||
primaryAttribute: false
|
||||
editable: true
|
||||
filterable: false
|
||||
displayedInFileList: false
|
||||
CsvImportSettings:
|
||||
type: object
|
||||
description: |
|
||||
This object defines the settings for importing data from a CSV file. It includes
|
||||
information that indicates if the CSV mapping is active, specifies the column header
|
||||
used for filename matching, sets the delimiter for column separation, and determines
|
||||
the encoding of the CSV file. These settings are crucial for accurately importing and
|
||||
mapping file attributes based on the corresponding CSV records.
|
||||
properties:
|
||||
csvMappingActive:
|
||||
type: boolean
|
||||
description: |
|
||||
If `true`, the CSV mapping is active.
|
||||
filenameMappingCsvColumnHeader:
|
||||
type: string
|
||||
description: |
|
||||
The header of a specific column in the CSV file that should contain values
|
||||
matching the filenames. A matching value identifies the record that is used
|
||||
to import the mapped file attributes.
|
||||
delimiter:
|
||||
type: string
|
||||
maxLength: 1
|
||||
description: |
|
||||
The delimiter of the CSV file that is used to distinguish different columns.
|
||||
encoding:
|
||||
type: string
|
||||
description: |
|
||||
The encoding of the CSV file that is expected when uploading for the import of file attributes.
|
||||
example:
|
||||
csvMappingActive: true
|
||||
filenameMappingCsvColumnHeader: "Filename"
|
||||
delimiter: ","
|
||||
encoding: "UTF-8"
|
||||
Dossier:
|
||||
type: object
|
||||
description: |
|
||||
|
||||
@ -148,12 +148,14 @@ public class FileAttributesManagementService {
|
||||
}
|
||||
|
||||
|
||||
private Charset parseEncoding(String encoding) {
|
||||
public static Charset parseEncoding(String encoding) {
|
||||
|
||||
if (ASCII_ENCODING.equalsIgnoreCase(encoding)) {
|
||||
// accept both "ASCII" (historical name) and the actual name "US-ASCII" of the charset
|
||||
if (ASCII_ENCODING.equalsIgnoreCase(encoding) || StandardCharsets.US_ASCII.name().equalsIgnoreCase(encoding)) {
|
||||
return StandardCharsets.US_ASCII;
|
||||
}
|
||||
if (ISO_ENCODING.equalsIgnoreCase(encoding)) {
|
||||
// accept both "ISO" (non-unique name) and the actual name "US-ASCII" of the charset
|
||||
if (ISO_ENCODING.equalsIgnoreCase(encoding) || StandardCharsets.ISO_8859_1.name().equalsIgnoreCase(encoding)) {
|
||||
return StandardCharsets.ISO_8859_1;
|
||||
}
|
||||
return StandardCharsets.UTF_8;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.iqser.red</groupId>
|
||||
<artifactId>platform-dependency</artifactId>
|
||||
<version>2.19.0</version>
|
||||
<version>2.20.0</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user