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 + "')")
|
@PreAuthorize("hasAuthority('" + READ_RULES + "')")
|
||||||
public ResponseEntity<InputStreamResource> downloadComponentRules(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId,
|
public ResponseEntity<InputStreamResource> downloadComponentRules(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId) {
|
||||||
@PathVariable(RULE_FILE_TYPE_PARAMETER_NAME) RuleFileType ruleFileType) {
|
|
||||||
|
|
||||||
return downloadRules(dossierTemplateId, RuleFileType.COMPONENT);
|
return downloadRules(dossierTemplateId, RuleFileType.COMPONENT);
|
||||||
}
|
}
|
||||||
@ -112,7 +111,13 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
|||||||
|
|
||||||
var fileAttributeConfigs = fileAttributesController.getFileAttributesConfiguration(dossierTemplateId);
|
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()
|
.map(fileAttributeConfig -> FileAttributeDefinition.builder()
|
||||||
.id(fileAttributeConfig.getId())
|
.id(fileAttributeConfig.getId())
|
||||||
.name(fileAttributeConfig.getLabel())
|
.name(fileAttributeConfig.getLabel())
|
||||||
@ -126,7 +131,9 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
|||||||
.displayedInFileList(fileAttributeConfig.isDisplayedInFileList())
|
.displayedInFileList(fileAttributeConfig.isDisplayedInFileList())
|
||||||
.build())
|
.build())
|
||||||
.build())
|
.build())
|
||||||
.toList());
|
.toList();
|
||||||
|
|
||||||
|
return new FileAttributeDefinitionList(csvImportSettings, fileAttributeDefinitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@ -166,7 +173,7 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
|||||||
.userId(KeycloakSecurity.getUserId())
|
.userId(KeycloakSecurity.getUserId())
|
||||||
.objectId(rulesUploadRequest.getDossierTemplateId())
|
.objectId(rulesUploadRequest.getDossierTemplateId())
|
||||||
.category(AuditCategory.DOSSIER_TEMPLATE.name())
|
.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());
|
.build());
|
||||||
|
|
||||||
// TODO Add warning and deprecations to response
|
// TODO Add warning and deprecations to response
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
package com.iqser.red.service.persistence.service.v2.api.external.model;
|
package com.iqser.red.service.persistence.service.v2.api.external.model;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -14,6 +19,31 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class FileAttributeDefinitionList {
|
public class FileAttributeDefinitionList {
|
||||||
|
|
||||||
|
private CsvImportSettings csvImportSettings;
|
||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private List<FileAttributeDefinition> fileAttributeDefinitions = new ArrayList<>();
|
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
|
@ResponseBody
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@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")})
|
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
||||||
@GetMapping(value = PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + ENTITY_RULES_PATH, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
@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);
|
ResponseEntity<InputStreamResource> downloadEntityRules(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId);
|
||||||
@ -84,10 +84,10 @@ public interface DossierTemplateResource {
|
|||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@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")})
|
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
||||||
@GetMapping(value = PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + COMPONENT_RULES_PATH, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
@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")
|
@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)
|
@GetMapping(value = PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + FILE_ATTRIBUTE_DEFINITIONS_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
|||||||
@ -1460,25 +1460,25 @@ components:
|
|||||||
primaryAttribute:
|
primaryAttribute:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: |
|
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:
|
editable:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: |
|
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:
|
filterable:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: |
|
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:
|
displayedInFileList:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: |
|
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:
|
required:
|
||||||
- primaryAttribute
|
- primaryAttribute
|
||||||
- editable
|
- editable
|
||||||
- filterable
|
- filterable
|
||||||
- displayedInFileList
|
- displayedInFileList
|
||||||
example: :
|
example:
|
||||||
primaryAttribute: false
|
primaryAttribute: false
|
||||||
editable: true
|
editable: true
|
||||||
filterable: true
|
filterable: true
|
||||||
@ -1487,11 +1487,19 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
description: A list of file attribute definitions.
|
description: A list of file attribute definitions.
|
||||||
properties:
|
properties:
|
||||||
|
csvImportSettings:
|
||||||
|
$ref: '#/components/schemas/CsvImportSettings'
|
||||||
fileAttributeDefinitions:
|
fileAttributeDefinitions:
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/FileAttributeDefinition'
|
$ref: '#/components/schemas/FileAttributeDefinition'
|
||||||
type: array
|
type: array
|
||||||
example:
|
example:
|
||||||
|
csvImportSettings:
|
||||||
|
csvMappingActive: true
|
||||||
|
filenameMappingCsvColumnHeader: "Filename"
|
||||||
|
delimiter: ","
|
||||||
|
encoding: "UTF-8"
|
||||||
|
fileAttributeDefinitions:
|
||||||
- id: "123e4567-e89b-12d3-a456-426614174000"
|
- id: "123e4567-e89b-12d3-a456-426614174000"
|
||||||
name: "Document Type"
|
name: "Document Type"
|
||||||
type: "TEXT"
|
type: "TEXT"
|
||||||
@ -1511,6 +1519,39 @@ components:
|
|||||||
editable: true
|
editable: true
|
||||||
filterable: false
|
filterable: false
|
||||||
displayedInFileList: 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:
|
Dossier:
|
||||||
type: object
|
type: object
|
||||||
description: |
|
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;
|
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.ISO_8859_1;
|
||||||
}
|
}
|
||||||
return StandardCharsets.UTF_8;
|
return StandardCharsets.UTF_8;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iqser.red</groupId>
|
<groupId>com.iqser.red</groupId>
|
||||||
<artifactId>platform-dependency</artifactId>
|
<artifactId>platform-dependency</artifactId>
|
||||||
<version>2.19.0</version>
|
<version>2.20.0</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user