diff --git a/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/ManagementContractDtoToModelConverter.java b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/ManagementContractDtoToModelConverter.java new file mode 100644 index 00000000000..a17c356c09f --- /dev/null +++ b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/ManagementContractDtoToModelConverter.java @@ -0,0 +1,178 @@ +/* + * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) + * + * contact.vitam@culture.gouv.fr + * + * This software is a computer program whose purpose is to implement a digital archiving back-office system managing + * high volumetry securely and efficiently. + * + * This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free + * software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as + * circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, + * users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the + * successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or + * developing or reproducing the software by the user in light of its specific status of free software, that may mean + * that it is complicated to manipulate, and that also therefore means that it is reserved for developers and + * experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the + * software's suitability as regards their requirements in conditions enabling the security of their systems and/or data + * to be ensured and, more generally, to use and operate it in the same conditions as regards security. + * + * The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you + * accept its terms. + */ + +package fr.gouv.vitamui.referential.internal.server.managementcontract; + +import fr.gouv.vitam.common.model.administration.ActivationStatus; +import fr.gouv.vitam.common.model.administration.DataObjectVersionType; +import fr.gouv.vitam.common.model.administration.ManagementContractModel; +import fr.gouv.vitam.common.model.administration.PersistentIdentifierPolicy; +import fr.gouv.vitam.common.model.administration.PersistentIdentifierPolicyTypeEnum; +import fr.gouv.vitam.common.model.administration.PersistentIdentifierUsage; +import fr.gouv.vitam.common.model.administration.StorageDetailModel; +import fr.gouv.vitam.common.model.administration.VersionRetentionPolicyModel; +import fr.gouv.vitam.common.model.administration.VersionUsageModel; +import fr.gouv.vitamui.commons.api.domain.ManagementContractDto; +import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierPolicyMgtContractDto; +import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierUsageMgtContractDto; +import fr.gouv.vitamui.commons.api.domain.StorageManagementContractDto; +import fr.gouv.vitamui.commons.api.domain.VersionRetentionPolicyMgtContractDto; +import fr.gouv.vitamui.commons.api.domain.VersionUsageMgtContractDto; +import org.jetbrains.annotations.NotNull; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +@Component +public class ManagementContractDtoToModelConverter + implements Converter { + + @Override + public ManagementContractModel convert(@NotNull ManagementContractDto source) { + ManagementContractModel managementContractModel = new ManagementContractModel(); + copyBasicProperties(source, managementContractModel); + managementContractModel.setStorage(convertStorage(source.getStorage())); + managementContractModel.setVersionRetentionPolicy( + convertVersionRetentionPolicy(source.getVersionRetentionPolicy())); + managementContractModel.setPersistentIdentifierPolicyList( + convertPersistentIdentifierPolicies(source.getPersistentIdentifierPolicyList())); + return managementContractModel; + } + + private void copyBasicProperties(ManagementContractDto source, ManagementContractModel target) { + target.setTenant(source.getTenant()); + target.setVersion(source.getVersion()); + target.setName(source.getName()); + target.setIdentifier(source.getIdentifier()); + target.setDescription(source.getDescription()); + target.setStatus(source.getStatus() != null ? Enum.valueOf(ActivationStatus.class, source.getStatus()) : null); + target.setCreationdate(source.getCreationDate()); + target.setLastupdate(source.getLastUpdate()); + target.setDeactivationdate(source.getDeactivationDate()); + target.setActivationdate(source.getActivationDate()); + } + + private StorageDetailModel convertStorage(StorageManagementContractDto storageDto) { + if (storageDto == null) { + return null; + } + StorageDetailModel storageModel = new StorageDetailModel(); + storageModel.setUnitStrategy(storageDto.getUnitStrategy()); + storageModel.setObjectGroupStrategy(storageDto.getObjectGroupStrategy()); + storageModel.setObjectStrategy(storageDto.getObjectStrategy()); + return storageModel; + } + + private VersionRetentionPolicyModel convertVersionRetentionPolicy(VersionRetentionPolicyMgtContractDto dto) { + if (dto == null) { + return null; + } + VersionRetentionPolicyModel versionRetentionPolicyModel = new VersionRetentionPolicyModel(); + versionRetentionPolicyModel.setInitialVersion(dto.isInitialVersion()); + versionRetentionPolicyModel.setIntermediaryVersion( + Optional.ofNullable(dto.getIntermediaryVersion()) + .map(intermediaryVersionDto -> Enum.valueOf(VersionUsageModel.IntermediaryVersionEnum.class, intermediaryVersionDto.name())) + .orElse(null)); + versionRetentionPolicyModel.setUsages(convertVersionUsages(dto.getUsages())); + return versionRetentionPolicyModel; + } + + private Set convertVersionUsages(Set usageDtos) { + if (usageDtos == null) { + return null; + } + return usageDtos.stream().map(this::convertVersionUsage).collect(Collectors.toSet()); + } + + private VersionUsageModel convertVersionUsage(VersionUsageMgtContractDto dto) { + if (dto == null) { + return null; + } + VersionUsageModel versionUsageModel = new VersionUsageModel(); + versionUsageModel.setUsageName(dto.getUsageName()); + versionUsageModel.setInitialVersion(dto.isInitialVersion()); + versionUsageModel.setIntermediaryVersion( + Optional.ofNullable(dto.getIntermediaryVersion()) + .map(intermediaryVersionDto -> Enum.valueOf(VersionUsageModel.IntermediaryVersionEnum.class, intermediaryVersionDto.name())) + .orElse(null)); + return versionUsageModel; + } + + private List convertPersistentIdentifierPolicies( + List policyDtos) { + if (policyDtos == null) { + return null; + } + return policyDtos.stream().map(this::convertPersistentIdentifierPolicy).collect(Collectors.toList()); + } + + private PersistentIdentifierPolicy convertPersistentIdentifierPolicy( + PersistentIdentifierPolicyMgtContractDto dto) { + if (dto == null) { + return null; + } + PersistentIdentifierPolicy policy = new PersistentIdentifierPolicy(); + policy.setPersistentIdentifierAuthority(dto.getPersistentIdentifierAuthority()); + policy.setPersistentIdentifierUnit(dto.isPersistentIdentifierUnit()); + policy.setPersistentIdentifierPolicyType( + Optional.ofNullable(dto.getPersistentIdentifierPolicyType()) + .map(policyTypeDto -> Enum.valueOf(PersistentIdentifierPolicyTypeEnum.class, policyTypeDto)) + .orElse(null)); + policy.setPersistentIdentifierUsages(convertPersistentIdentifierUsages(dto.getPersistentIdentifierUsages())); + return policy; + } + + private List convertPersistentIdentifierUsages( + List usageDtos) { + if (usageDtos == null) { + return null; + } + return usageDtos.stream().map(this::convertPersistentIdentifierUsage).collect(Collectors.toList()); + } + + private PersistentIdentifierUsage convertPersistentIdentifierUsage( + PersistentIdentifierUsageMgtContractDto dto) { + if (dto == null) { + return null; + } + PersistentIdentifierUsage usage = new PersistentIdentifierUsage(); + usage.setUsageName( + Optional.ofNullable(dto.getUsageName()) + .map(DataObjectVersionType::fromName) + .orElse(null)); + usage.setInitialVersion(dto.isInitialVersion()); + usage.setIntermediaryVersion( + Optional.ofNullable(dto.getIntermediaryVersion()) + .map(intermediaryVersionDto -> Enum.valueOf(VersionUsageModel.IntermediaryVersionEnum.class, intermediaryVersionDto.name())) + .orElse(null)); + return usage; + } +} \ No newline at end of file diff --git a/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/ManagementContractModelToDtoConverter.java b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/ManagementContractModelToDtoConverter.java new file mode 100644 index 00000000000..ca338ec3aa6 --- /dev/null +++ b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/ManagementContractModelToDtoConverter.java @@ -0,0 +1,183 @@ +/* + * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) + * + * contact.vitam@culture.gouv.fr + * + * This software is a computer program whose purpose is to implement a digital archiving back-office system managing + * high volumetry securely and efficiently. + * + * This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free + * software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as + * circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, + * users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the + * successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or + * developing or reproducing the software by the user in light of its specific status of free software, that may mean + * that it is complicated to manipulate, and that also therefore means that it is reserved for developers and + * experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the + * software's suitability as regards their requirements in conditions enabling the security of their systems and/or data + * to be ensured and, more generally, to use and operate it in the same conditions as regards security. + * + * The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you + * accept its terms. + */ + +package fr.gouv.vitamui.referential.internal.server.managementcontract; + +import fr.gouv.vitam.common.model.administration.ManagementContractModel; +import fr.gouv.vitam.common.model.administration.PersistentIdentifierPolicy; +import fr.gouv.vitam.common.model.administration.PersistentIdentifierUsage; +import fr.gouv.vitam.common.model.administration.StorageDetailModel; +import fr.gouv.vitam.common.model.administration.VersionRetentionPolicyModel; +import fr.gouv.vitam.common.model.administration.VersionUsageModel; +import fr.gouv.vitamui.commons.api.domain.ManagementContractDto; +import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierPolicyMgtContractDto; +import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierUsageMgtContractDto; +import fr.gouv.vitamui.commons.api.domain.StorageManagementContractDto; +import fr.gouv.vitamui.commons.api.domain.VersionRetentionPolicyMgtContractDto; +import fr.gouv.vitamui.commons.api.domain.VersionUsageMgtContractDto; +import fr.gouv.vitamui.commons.api.enums.IntermediaryVersionEnum; +import org.jetbrains.annotations.NotNull; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@Component +public class ManagementContractModelToDtoConverter + implements Converter { + + @Override + public ManagementContractDto convert(@NotNull ManagementContractModel source) { + ManagementContractDto managementContractDto = new ManagementContractDto(); + copyBasicProperties(source, managementContractDto); + managementContractDto.setStorage(convertStorage(source.getStorage())); + managementContractDto.setVersionRetentionPolicy( + convertVersionRetentionPolicy(source.getVersionRetentionPolicy())); + managementContractDto.setPersistentIdentifierPolicyList( + convertPersistentIdentifierPolicies(source.getPersistentIdentifierPolicyList())); + return managementContractDto; + } + + private void copyBasicProperties(ManagementContractModel source, ManagementContractDto target) { + if (source != null && target != null) { + target.setTenant(source.getTenant()); + target.setVersion(source.getVersion()); + target.setName(source.getName()); + target.setIdentifier(source.getIdentifier()); + target.setDescription(source.getDescription()); + target.setStatus(source.getStatus() != null ? source.getStatus().name() : null); + target.setCreationDate(source.getCreationdate()); + target.setLastUpdate(source.getLastupdate()); + target.setDeactivationDate(source.getDeactivationdate()); + target.setActivationDate(source.getActivationdate()); + } + } + + private StorageManagementContractDto convertStorage(StorageDetailModel storage) { + if (storage == null) { + return null; + } + + StorageManagementContractDto storageDto = new StorageManagementContractDto(); + storageDto.setUnitStrategy(storage.getUnitStrategy()); + storageDto.setObjectGroupStrategy(storage.getObjectGroupStrategy()); + storageDto.setObjectStrategy(storage.getObjectStrategy()); + return storageDto; + } + + private VersionRetentionPolicyMgtContractDto convertVersionRetentionPolicy( + VersionRetentionPolicyModel versionRetentionPolicy) { + if (versionRetentionPolicy == null) { + return null; + } + + VersionRetentionPolicyMgtContractDto dto = new VersionRetentionPolicyMgtContractDto(); + dto.setInitialVersion(versionRetentionPolicy.getInitialVersion()); + dto.setIntermediaryVersion( + versionRetentionPolicy.getIntermediaryVersion() != null ? + IntermediaryVersionEnum.valueOf(versionRetentionPolicy.getIntermediaryVersion().name()) : + null); + dto.setUsages(convertVersionUsages(versionRetentionPolicy.getUsages())); + return dto; + } + + private Set convertVersionUsages(Set versionUsages) { + if (versionUsages == null) { + return null; + } + + return versionUsages.stream().map(this::convertVersionUsage).collect(Collectors.toSet()); + } + + private VersionUsageMgtContractDto convertVersionUsage(VersionUsageModel versionUsageModel) { + if (versionUsageModel == null) { + return null; + } + + VersionUsageMgtContractDto dto = new VersionUsageMgtContractDto(); + dto.setUsageName(versionUsageModel.getUsageName()); + dto.setInitialVersion(versionUsageModel.getInitialVersion()); + dto.setIntermediaryVersion( + versionUsageModel.getIntermediaryVersion() != null ? + IntermediaryVersionEnum.valueOf(versionUsageModel.getIntermediaryVersion().name()) : + null); + return dto; + } + + private List convertPersistentIdentifierPolicies( + List policies) { + if (policies == null) { + return null; + } + + return policies.stream().map(this::convertPersistentIdentifierPolicy).collect(Collectors.toList()); + } + + private PersistentIdentifierPolicyMgtContractDto convertPersistentIdentifierPolicy( + PersistentIdentifierPolicy policy) { + if (policy == null) { + return null; + } + + PersistentIdentifierPolicyMgtContractDto dto = new PersistentIdentifierPolicyMgtContractDto(); + dto.setPersistentIdentifierAuthority(policy.getPersistentIdentifierAuthority()); + dto.setPersistentIdentifierUnit(policy.isPersistentIdentifierUnit()); + dto.setPersistentIdentifierPolicyType( + policy.getPersistentIdentifierPolicyType() != null ? + policy.getPersistentIdentifierPolicyType().name() : + null); + dto.setPersistentIdentifierUsages(convertPersistentIdentifierUsages(policy.getPersistentIdentifierUsages())); + return dto; + } + + private List convertPersistentIdentifierUsages( + List usages) { + if (usages == null) { + return null; + } + + return usages.stream().map(this::convertPersistentIdentifierUsage).collect(Collectors.toList()); + } + + private PersistentIdentifierUsageMgtContractDto convertPersistentIdentifierUsage( + PersistentIdentifierUsage usage) { + if (usage == null) { + return null; + } + + PersistentIdentifierUsageMgtContractDto dto = new PersistentIdentifierUsageMgtContractDto(); + dto.setUsageName(usage.getUsageName() != null ? usage.getUsageName().getName() : null); + dto.setInitialVersion(usage.isInitialVersion()); + dto.setIntermediaryVersion( + usage.getIntermediaryVersion() != null ? + IntermediaryVersionEnum.valueOf(usage.getIntermediaryVersion().name()) : + null); + return dto; + } +} diff --git a/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/PatchManagementContractModel.java b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/PatchManagementContractModel.java new file mode 100644 index 00000000000..86df7595c89 --- /dev/null +++ b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/PatchManagementContractModel.java @@ -0,0 +1,96 @@ +/* + * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) + * + * contact.vitam@culture.gouv.fr + * + * This software is a computer program whose purpose is to implement a digital archiving back-office system managing + * high volumetry securely and efficiently. + * + * This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free + * software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as + * circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, + * users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the + * successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or + * developing or reproducing the software by the user in light of its specific status of free software, that may mean + * that it is complicated to manipulate, and that also therefore means that it is reserved for developers and + * experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the + * software's suitability as regards their requirements in conditions enabling the security of their systems and/or data + * to be ensured and, more generally, to use and operate it in the same conditions as regards security. + * + * The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you + * accept its terms. + */ + +package fr.gouv.vitamui.referential.internal.server.managementcontract; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierPolicyDto; +import fr.gouv.vitamui.commons.api.domain.StorageDetailDto; +import fr.gouv.vitamui.commons.api.domain.VersionRetentionPolicyDto; +import lombok.Data; + +import java.util.List; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PatchManagementContractModel { + @JsonIgnore + @JsonProperty("#id") + private String id; + + @JsonIgnore + @JsonProperty("#tenant") + private Integer tenant; + + @JsonIgnore + @JsonProperty("#version") + private Integer version; + + @JsonIgnore + @JsonProperty("Identifier") + private String identifier; + + @JsonProperty("Storage") + private StorageDetailDto storage; + + @JsonIgnore + @JsonProperty("VersionRetentionPolicy") + private VersionRetentionPolicyDto versionRetentionPolicy; + + @JsonProperty("PersistentIdentifierPolicy") + private List persistentIdentifierPolicyList; + + @JsonProperty("Name") + private String name; + + @JsonProperty("Description") + private String description; + + @JsonProperty("Status") + private String status; + + @JsonIgnore + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS", timezone = "UTC") + private String creationDate; + + @JsonIgnore + @JsonProperty("LastUpdate") + private String lastUpdate; + + @JsonIgnore + @JsonProperty("DeactivationDate") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS", timezone = "UTC") + private String deactivationDate; + + @JsonIgnore + @JsonProperty("ActivationDate") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS", timezone = "UTC") + private String activationDate; +} diff --git a/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/converter/ManagementContractConverter.java b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/converter/ManagementContractConverter.java index d3edd712fe7..db865658ba5 100644 --- a/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/converter/ManagementContractConverter.java +++ b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/converter/ManagementContractConverter.java @@ -28,11 +28,13 @@ */ package fr.gouv.vitamui.referential.internal.server.managementcontract.converter; +import fr.gouv.vitam.common.model.administration.PersistentIdentifierUsage; import fr.gouv.vitamui.commons.api.domain.ManagementContractDto; import fr.gouv.vitamui.commons.api.domain.ManagementContractModelDto; import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierPolicyDto; import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierPolicyMgtContractDto; import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierUsageDto; +import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierUsageMgtContractDto; import fr.gouv.vitamui.commons.api.domain.StorageDetailDto; import fr.gouv.vitamui.commons.api.domain.StorageManagementContractDto; import fr.gouv.vitamui.commons.api.domain.VersionRetentionPolicyDto; @@ -152,6 +154,40 @@ public ManagementContractDto convertVitamMgtContractToVitamUiDto( versionRetentionPolicyMgtContractDto.setUsages(versionUsageMgtContractDtoSet); managementContractDto.setVersionRetentionPolicy(versionRetentionPolicyMgtContractDto); } + + if (managementContractVitamDto.getPersistentIdentifierPolicyList() == null) { + return managementContractDto; + } + + managementContractDto.setPersistentIdentifierPolicyList( + managementContractVitamDto.getPersistentIdentifierPolicyList().stream().map(persistentIdentifierPolicyVitamDto -> { + PersistentIdentifierPolicyMgtContractDto persistentIdentifierPolicyMgtContractDto = new PersistentIdentifierPolicyMgtContractDto(); + + persistentIdentifierPolicyMgtContractDto.setPersistentIdentifierPolicyType( + persistentIdentifierPolicyVitamDto.getPersistentIdentifierPolicyType()); + persistentIdentifierPolicyMgtContractDto.setPersistentIdentifierUnit( + persistentIdentifierPolicyVitamDto.getPersistentIdentifierUnit()); + persistentIdentifierPolicyMgtContractDto.setPersistentIdentifierAuthority( + persistentIdentifierPolicyVitamDto.getPersistentIdentifierAuthority()); + + if (persistentIdentifierPolicyVitamDto.getPersistentIdentifierUsages() != null) { + + List persistentIdentifierUsages = + persistentIdentifierPolicyVitamDto.getPersistentIdentifierUsages().stream() + .map(usageMgtContractDto -> { + PersistentIdentifierUsageMgtContractDto usageDto = new PersistentIdentifierUsageMgtContractDto(); + usageDto.setUsageName(usageMgtContractDto.getUsageName()); + usageDto.setInitialVersion(usageMgtContractDto.getInitialVersion()); + usageDto.setIntermediaryVersion(usageMgtContractDto.getIntermediaryVersion()); + return usageDto; + }).collect(Collectors.toList()); + + persistentIdentifierPolicyMgtContractDto.setPersistentIdentifierUsages(persistentIdentifierUsages); + } + return persistentIdentifierPolicyMgtContractDto; + }).collect(Collectors.toList()) + ); + return managementContractDto; } diff --git a/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/service/ManagementContractInternalService.java b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/service/ManagementContractInternalService.java index 21f10a75c55..61f06e3ab43 100644 --- a/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/service/ManagementContractInternalService.java +++ b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/managementcontract/service/ManagementContractInternalService.java @@ -46,7 +46,6 @@ import fr.gouv.vitamui.commons.api.domain.DirectionDto; import fr.gouv.vitamui.commons.api.domain.ManagementContractDto; import fr.gouv.vitamui.commons.api.domain.PaginatedValuesDto; -import fr.gouv.vitamui.commons.api.exception.BadRequestException; import fr.gouv.vitamui.commons.api.exception.ConflictException; import fr.gouv.vitamui.commons.api.exception.InternalServerException; import fr.gouv.vitamui.commons.api.logger.VitamUILogger; @@ -57,6 +56,9 @@ import fr.gouv.vitamui.referential.common.dto.ManagementContractResponseDto; import fr.gouv.vitamui.referential.common.dto.ManagementContractVitamDto; import fr.gouv.vitamui.referential.common.service.VitamUIManagementContractService; +import fr.gouv.vitamui.referential.internal.server.managementcontract.ManagementContractDtoToModelConverter; +import fr.gouv.vitamui.referential.internal.server.managementcontract.ManagementContractModelToDtoConverter; +import fr.gouv.vitamui.referential.internal.server.managementcontract.PatchManagementContractModel; import fr.gouv.vitamui.referential.internal.server.managementcontract.converter.ManagementContractConverter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -89,11 +91,17 @@ public class ManagementContractInternalService { private final LogbookService logbookService; + private ManagementContractDtoToModelConverter managementContractDtoToModelConverter; + private ManagementContractModelToDtoConverter managementContractModelToDtoConverter; + @Autowired - public ManagementContractInternalService(ManagementContractService managementContractService, - VitamUIManagementContractService - vitamUIManagementContractService, ObjectMapper objectMapper, ManagementContractConverter converter, - LogbookService logbookService) { + public ManagementContractInternalService( + final ManagementContractService managementContractService, + final VitamUIManagementContractService vitamUIManagementContractService, + final ObjectMapper objectMapper, + final ManagementContractConverter converter, + final LogbookService logbookService + ) { this.managementContractService = managementContractService; this.vitamUIManagementContractService = vitamUIManagementContractService; this.objectMapper = objectMapper; @@ -196,7 +204,7 @@ public Boolean check(VitamContext vitamContext, ManagementContractDto management public ManagementContractDto create(VitamContext vitamContext, ManagementContractDto managementContractDto) { try { - LOGGER.debug(MANAGEMENT_CONTRACT_EVENT_ID_APP_SESSION , vitamContext.getApplicationSessionId()); + LOGGER.debug(MANAGEMENT_CONTRACT_EVENT_ID_APP_SESSION, vitamContext.getApplicationSessionId()); RequestResponse requestResponse = managementContractService.createManagementContracts(vitamContext, Collections.singletonList(converter .convertVitamUiManagementContractToVitamMgt(managementContractDto))); @@ -210,88 +218,22 @@ public ManagementContractDto create(VitamContext vitamContext, ManagementContrac } } - private JsonNode convertMapPartialDtoToUpperCaseVitamFields(Map partialDto) { - - ObjectNode propertiesToUpdate = JsonHandler.createObjectNode(); - - // Transform Vitam-UI fields into Vitam fields - if (partialDto.get("name") != null) { - propertiesToUpdate.put("Name", (String) partialDto.get("name")); - } - if (partialDto.get("description") != null) { - propertiesToUpdate.put("Description", (String) partialDto.get("description")); - } - if (partialDto.get("status") != null) { - propertiesToUpdate.put("Status", (String) partialDto.get("status")); - } - if (partialDto.get("activationDate") != null) { - propertiesToUpdate.put("ActivationDate", (String) partialDto.get("activationDate")); - } - if (partialDto.get("deactivationDate") != null) { - propertiesToUpdate.put("DeactivationDate", (String) partialDto.get("deactivationDate")); - } - if (partialDto.get("lastUpdate") != null) { - propertiesToUpdate.put("LastUpdate", (String) partialDto.get("lastUpdate")); - } - if (partialDto.get("creationDate") != null) { - propertiesToUpdate.put("CreationDate", (String) partialDto.get("creationDate")); - } - if (partialDto.get("unitStrategy") != null) { - propertiesToUpdate.put("Storage.UnitStrategy", (String) partialDto.get("unitStrategy")); - } - if (partialDto.get("objectStrategy") != null) { - propertiesToUpdate.put("Storage.ObjectStrategy", (String) partialDto.get("objectStrategy")); - } - if (partialDto.get("objectGroupStrategy") != null) { - propertiesToUpdate.put("Storage.ObjectGroupStrategy", (String) partialDto.get("objectGroupStrategy")); - } - /** - * the versionRetentionPolicy property is not taken into account by the back of vitam - * therefore impossible to test at this time. - */ - if (partialDto.get("versionRetentionPolicy") != null) { - LOGGER.debug("versionRetentionPolicy = {}", partialDto.get("versionRetentionPolicy")); - } - return propertiesToUpdate; - } - - public ManagementContractDto patch(VitamContext vitamContext, final Map partialDto) { - String id = (String) partialDto.get("identifier"); - if (id == null) { - LOGGER.error("id must be one of the update criteria"); - throw new BadRequestException("id must be one of the update criteria"); + public ManagementContractDto patch(VitamContext vitamContext, final ManagementContractDto managementContractDto) + throws AccessExternalClientException, InvalidParseOperationException, JsonProcessingException { + final String identifier = managementContractDto.getIdentifier(); + final ManagementContractModel managementContractModel = + managementContractDtoToModelConverter.convert(managementContractDto); + final String serializedManagementContractModel = objectMapper.writeValueAsString(managementContractModel); + final PatchManagementContractModel patchManagementContractModel = + objectMapper.readValue(serializedManagementContractModel, PatchManagementContractModel.class); + final JsonNode patchQuery = buildPatchQuery(patchManagementContractModel); + final RequestResponse requestResponse = + vitamUIManagementContractService.patchManagementContract(vitamContext, identifier, patchQuery); + if (Response.Status.OK.getStatusCode() != requestResponse.getHttpCode()) { + throw new AccessExternalClientException(MANAGEMENT_CONTRACT_NOT_PATCH); } - partialDto.remove("id"); - partialDto.remove("identifier"); - - try { - LOGGER.debug(MANAGEMENT_CONTRACT_EVENT_ID_APP_SESSION, vitamContext.getApplicationSessionId()); - JsonNode fieldsUpdated = convertMapPartialDtoToUpperCaseVitamFields(partialDto); - ObjectNode action = JsonHandler.createObjectNode(); - action.set("$set", fieldsUpdated); - - ArrayNode actions = JsonHandler.createArrayNode(); - actions.add(action); - - ObjectNode query = JsonHandler.createObjectNode(); - query.set("$action", actions); - - LOGGER.debug("Send ManagementContract update request: {}", query); - - RequestResponse requestResponse = - vitamUIManagementContractService.patchManagementContract(vitamContext, id, query); - - if (Response.Status.OK.getStatusCode() != requestResponse.getHttpCode()) { - throw new AccessExternalClientException(MANAGEMENT_CONTRACT_NOT_PATCH); - } - - return getOne(vitamContext, id); - - } catch (InvalidParseOperationException | AccessExternalClientException e) { - LOGGER.error(MANAGEMENT_CONTRACT_NOT_PATCH); - throw new InternalServerException(MANAGEMENT_CONTRACT_NOT_PATCH, e); - } + return getOne(vitamContext, identifier); } public JsonNode findHistoryByIdentifier(VitamContext vitamContext, final String id) throws VitamClientException { @@ -304,4 +246,29 @@ public JsonNode findHistoryByIdentifier(VitamContext vitamContext, final String } } + @Autowired + public void setManagementContractDtoToModelConverter( + ManagementContractDtoToModelConverter managementContractDtoToModelConverter) { + this.managementContractDtoToModelConverter = managementContractDtoToModelConverter; + } + + @Autowired + public void setManagementContractModelToDtoConverter( + ManagementContractModelToDtoConverter managementContractModelToDtoConverter) { + this.managementContractModelToDtoConverter = managementContractModelToDtoConverter; + } + + private JsonNode buildPatchQuery(PatchManagementContractModel patchManagementContractModel) { + final JsonNode jsonNode = objectMapper.valueToTree(patchManagementContractModel); + final ObjectNode action = JsonHandler.createObjectNode(); + action.set("$set", jsonNode); + + final ArrayNode actions = JsonHandler.createArrayNode(); + actions.add(action); + + final ObjectNode query = JsonHandler.createObjectNode(); + query.set("$action", actions); + + return query; + } } diff --git a/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/rest/ManagementContractInternalController.java b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/rest/ManagementContractInternalController.java index a36df971208..f74537f07fd 100644 --- a/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/rest/ManagementContractInternalController.java +++ b/api/api-referential/referential-internal/src/main/java/fr/gouv/vitamui/referential/internal/server/rest/ManagementContractInternalController.java @@ -36,7 +36,9 @@ */ package fr.gouv.vitamui.referential.internal.server.rest; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; +import fr.gouv.vitam.access.external.common.exception.AccessExternalClientException; import fr.gouv.vitam.common.client.VitamContext; import fr.gouv.vitam.common.exception.InvalidParseOperationException; import fr.gouv.vitam.common.exception.VitamClientException; @@ -150,14 +152,15 @@ public ManagementContractDto create(@Valid @RequestBody ManagementContractDto ma } @PatchMapping(CommonConstants.PATH_ID) - public ManagementContractDto patch(final @PathVariable("id") String id, @RequestBody final Map partialDto) - throws InvalidParseOperationException, PreconditionFailedException { + public ManagementContractDto patch(final @PathVariable("id") String id, @RequestBody final ManagementContractDto partialDto) + throws InvalidParseOperationException, PreconditionFailedException, AccessExternalClientException, + JsonProcessingException { ParameterChecker.checkParameter(MANDATORY_IDENTIFIER, id); SanityChecker.sanitizeCriteria(partialDto); SanityChecker.checkSecureParameter(id); LOGGER.debug("Patch {} with {}", id, partialDto); final VitamContext vitamContext = securityService.buildVitamContext(securityService.getTenantIdentifier()); - Assert.isTrue(StringUtils.equals(id, (String) partialDto.get("id")), "The DTO identifier must match the path identifier for update."); + Assert.isTrue(StringUtils.equals(id, partialDto.getId()), "The DTO identifier must match the path identifier for update."); return managementContractInternalService.patch(vitamContext, partialDto); } diff --git a/api/api-referential/referential-internal/src/test/java/fr/gouv/vitamui/referential/internal/server/managementcontract/PatchManagementContractModelTest.java b/api/api-referential/referential-internal/src/test/java/fr/gouv/vitamui/referential/internal/server/managementcontract/PatchManagementContractModelTest.java new file mode 100644 index 00000000000..a0a7b4fa259 --- /dev/null +++ b/api/api-referential/referential-internal/src/test/java/fr/gouv/vitamui/referential/internal/server/managementcontract/PatchManagementContractModelTest.java @@ -0,0 +1,122 @@ +/* + * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) + * + * contact.vitam@culture.gouv.fr + * + * This software is a computer program whose purpose is to implement a digital archiving back-office system managing + * high volumetry securely and efficiently. + * + * This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free + * software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as + * circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, + * users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the + * successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or + * developing or reproducing the software by the user in light of its specific status of free software, that may mean + * that it is complicated to manipulate, and that also therefore means that it is reserved for developers and + * experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the + * software's suitability as regards their requirements in conditions enabling the security of their systems and/or data + * to be ensured and, more generally, to use and operate it in the same conditions as regards security. + * + * The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you + * accept its terms. + */ + +package fr.gouv.vitamui.referential.internal.server.managementcontract; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierPolicyDto; +import fr.gouv.vitamui.commons.api.domain.PersistentIdentifierUsageDto; +import fr.gouv.vitamui.commons.api.domain.StorageDetailDto; +import fr.gouv.vitamui.commons.api.domain.VersionRetentionPolicyDto; +import fr.gouv.vitamui.commons.api.enums.IntermediaryVersionEnum; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +class PatchManagementContractModelTest { + private final ObjectMapper objectMapper = new ObjectMapper(); + + @Test + void testJsonIgnoreFields() throws JsonProcessingException { + PatchManagementContractModel patchDto = new PatchManagementContractModel(); + patchDto.setId("aefqaaaaaeecgkwkabam4aml6kss4saaaaaq"); + patchDto.setTenant(1); + patchDto.setVersion(12); + patchDto.setName("CG - DRA - 1"); + patchDto.setIdentifier("CG - DRA - 1"); + patchDto.setDescription("xxx"); + patchDto.setStatus("INACTIVE"); + patchDto.setCreationDate("2023-11-21T16:09:53.472"); + patchDto.setLastUpdate(null); // Le champ lastUpdate est ignoré + patchDto.setDeactivationDate("2023-11-21T16:09:52.947"); + patchDto.setActivationDate("2023-11-21T16:09:53.472"); + + // Création de l'objet StorageDetailDto + StorageDetailDto storageDto = new StorageDetailDto(); + storageDto.setUnitStrategy("default"); + storageDto.setObjectGroupStrategy("default"); + storageDto.setObjectStrategy("default"); + patchDto.setStorage(storageDto); + + // Création de l'objet VersionRetentionPolicyDto + VersionRetentionPolicyDto versionRetentionPolicyDto = new VersionRetentionPolicyDto(); + + // Création de la liste d'objets PersistentIdentifierPolicyDto + List persistentIdentifierPolicyList = new ArrayList<>(); + + PersistentIdentifierPolicyDto persistentIdentifierPolicyDto = new PersistentIdentifierPolicyDto(); + persistentIdentifierPolicyDto.setPersistentIdentifierPolicyType("ARK"); + persistentIdentifierPolicyDto.setPersistentIdentifierUnit(true); + persistentIdentifierPolicyDto.setPersistentIdentifierAuthority("000043"); + + // Création de la liste d'objets UsageDto + List persistentIdentifierUsages = new ArrayList<>(); + + PersistentIdentifierUsageDto binaryMasterUsage = new PersistentIdentifierUsageDto(); + binaryMasterUsage.setUsageName("BinaryMaster"); + binaryMasterUsage.setInitialVersion(true); + binaryMasterUsage.setIntermediaryVersion(IntermediaryVersionEnum.ALL); + persistentIdentifierUsages.add(binaryMasterUsage); + + PersistentIdentifierUsageDto disseminationUsage = new PersistentIdentifierUsageDto(); + disseminationUsage.setUsageName("Dissemination"); + disseminationUsage.setInitialVersion(true); + disseminationUsage.setIntermediaryVersion(IntermediaryVersionEnum.ALL); + persistentIdentifierUsages.add(disseminationUsage); + + persistentIdentifierPolicyDto.setPersistentIdentifierUsages(persistentIdentifierUsages); + + persistentIdentifierPolicyList.add(persistentIdentifierPolicyDto); + + patchDto.setVersionRetentionPolicy(versionRetentionPolicyDto); + patchDto.setPersistentIdentifierPolicyList(persistentIdentifierPolicyList); + + // Conversion de l'objet en chaîne JSON + String json = objectMapper.writeValueAsString(patchDto); + + // Conversion de la chaîne JSON en objet PatchManagementContractDto + PatchManagementContractModel patchedDto = objectMapper.readValue(json, PatchManagementContractModel.class); + + assertNotNull(patchedDto); + + // Vérification que les champs ignorés par @JsonIgnore sont à null + assertNull(patchedDto.getId()); + assertNull(patchedDto.getTenant()); + assertNull(patchedDto.getVersion()); + assertNull(patchedDto.getIdentifier()); + assertNull(patchedDto.getVersionRetentionPolicy()); + assertNull(patchedDto.getCreationDate()); + assertNull(patchedDto.getLastUpdate()); + assertNull(patchedDto.getActivationDate()); + assertNull(patchedDto.getDeactivationDate()); + } +} \ No newline at end of file diff --git a/ui/ui-frontend-common/src/app/modules/models/managementContract/management-contract.interface.ts b/ui/ui-frontend-common/src/app/modules/models/managementContract/management-contract.interface.ts index d0b324ce916..2846709a593 100644 --- a/ui/ui-frontend-common/src/app/modules/models/managementContract/management-contract.interface.ts +++ b/ui/ui-frontend-common/src/app/modules/models/managementContract/management-contract.interface.ts @@ -25,7 +25,7 @@ * accept its terms. */ -import {Id} from '../id.interface'; +import { Id } from '../id.interface'; export interface ManagementContract extends Id { tenant: number; @@ -43,28 +43,23 @@ export interface ManagementContract extends Id { persistentIdentifierPolicyList?: PersistentIdentifierPolicy[]; } - export interface PersistentIdentifierPolicy { - persistentIdentifierPolicyType: PersistentIdentifierPolicyTypeEnum; persistentIdentifierUnit: boolean; persistentIdentifierAuthority: string; persistentIdentifierUsages: PersistentIdentifierUsage[]; - } export interface PersistentIdentifierUsage { - DataObjectVersionType: string; + intermediaryVersion: string; initialVersion: string; usageName: string; } - export enum PersistentIdentifierPolicyTypeEnum { - ARK = 'ARK' + ARK = 'ARK', } - export interface StorageStrategy { unitStrategy: string; objectGroupStrategy: string; diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.html b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.html index c2d52f77627..e62b1bb380b 100644 --- a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.html +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.html @@ -9,13 +9,12 @@

{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.CREATION_ACTION' | translate }}

{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.INFORMATIONS' | translate }}
- -
+
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.CONTRACT_STATUS' | translate - }} + }}
@@ -30,7 +29,7 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.INFORMATIONS' | {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.MANDATORY_FIELD' | translate - }} + }} {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.NAME_ALREADY_EXIST' | translate }} @@ -74,8 +73,7 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.INFORMATIONS' |
- +
@@ -83,9 +81,9 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.INFORMATIONS' |
-

{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.CREATION_ACTION' | translate }}

-
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.STORAGE_POLICIES' | translate }} +
+ {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.STORAGE_POLICIES' | translate }} {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.STORAGE_PO >
-
@@ -121,22 +118,19 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.STORAGE_PO
-
+
- -
- +
- -
@@ -144,41 +138,40 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.STORAGE_PO {{ 'COMMON.BACK' | translate }}
-
-
-
- -

{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.CREATION_ACTION' | translate }} -

-
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.PARAMETRAGE_IDENTIFICATION_PERENNE' | translate }} +

{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.CREATION_ACTION' | translate }}

+
+ {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.PARAMETRAGE_IDENTIFICATION_PERENNE' | translate }}
+ > +
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.IDENTIFIER_TYPE' | translate }} - - {{ persistentIdentifierPolicyType }} + {{ persistentIdentifierPolicyType }} {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.CHOOSE_IDENTIFIER_TYPE' | translate }} @@ -197,10 +190,8 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.PARAMETRAGE_IDENTIFICATION_PERE >
-
-
@@ -211,37 +202,29 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.PARAMETRAGE_IDENTIFICATION_PERE
- -
+
-
- +
-
- -
- - +
- {{'Usage cible ' + i}} - - + {{ 'Usage cible ' + i }} + {{ usage.label }}
@@ -253,10 +236,12 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.PARAMETRAGE_IDENTIFICATION_PERE
- {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.YES' | translate }} - {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.NO' | translate }} + {{ + 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.YES' | translate + }} + {{ + 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.NO' | translate + }}
@@ -265,43 +250,44 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.PARAMETRAGE_IDENTIFICATION_PERE
- {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.ALL' | translate }} - {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.LAST' | translate }} - {{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.NONE' | translate }} + {{ + 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.ALL' | translate + }} + {{ + 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.LAST' | translate + }} + {{ + 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.NONE' | translate + }}
-
-
-
-
+
-
- -
+
- -
- -
@@ -322,14 +306,10 @@
{{ 'CONTRACT_MANAGEMENT.CONTRACTS_CREATION.PARAMETRAGE_IDENTIFICATION_PERE {{ 'COMMON.BACK' | translate }}
-
-
-
- diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.scss b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.scss index 6d629b2908b..148abd52134 100644 --- a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.scss +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.scss @@ -15,10 +15,8 @@ h5 { min-width: 152.22px; } - .form-persistent-identifier { .object-menu { - padding: 0 5px; border-radius: 5px; margin-left: 0; @@ -35,44 +33,36 @@ h5 { } .mat-checkbox { - .span { color: var(--vitamui-primary) !important; - background-color: #00B1D5; + background-color: #00b1d5; } } - } - - .object-details { padding: 15px 15px; margin-top: 5px; background-color: var(--vitamui-background); font-size: 14px; - .vitamui-mat-select.mat-form-field { - font-size: 14px; } .delete-button { border: 1px solid var(--vitamui-primary); border-radius: 50%; - background-color: #FFFFFF; + background-color: #ffffff; width: 30px; height: 30px; font-size: medium; color: var(--vitamui-primary); cursor: pointer; - } label { color: var(--vitamui-primary); } } - } diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.ts b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.ts index 8a01865751d..e9fa07feab8 100644 --- a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.ts +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.component.ts @@ -25,20 +25,21 @@ * accept its terms. */ -import {Component, Inject, OnDestroy, OnInit} from '@angular/core'; -import {FormArray, FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'; -import {MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; -import {Subscription} from 'rxjs'; +import { Component, Inject, OnDestroy, OnInit } from '@angular/core'; +import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { Subscription } from 'rxjs'; import { ConfirmDialogService, Logger, - ManagementContract, Option, + ManagementContract, + Option, PersistentIdentifierPolicyTypeEnum, - StorageStrategy + StorageStrategy, } from 'ui-frontend-common'; import * as uuid from 'uuid'; -import {ManagementContractService} from '../management-contract.service'; -import {ManagementContractCreateValidators} from '../validators/management-contract-create.validators'; +import { ManagementContractService } from '../management-contract.service'; +import { ManagementContractCreateValidators } from '../validators/management-contract-create.validators'; const PROGRESS_BAR_MULTIPLICATOR = 100; @@ -48,7 +49,6 @@ const PROGRESS_BAR_MULTIPLICATOR = 100; styleUrls: ['./management-contract-create.component.scss'], }) export class ManagementContractCreateComponent implements OnInit, OnDestroy { - constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, @@ -57,8 +57,7 @@ export class ManagementContractCreateComponent implements OnInit, OnDestroy { private managementContractService: ManagementContractService, private managementContractCreateValidators: ManagementContractCreateValidators, private logger: Logger - ) { - } + ) {} get stepProgress() { return ((this.stepIndex + 1) / this.stepCount) * PROGRESS_BAR_MULTIPLICATOR; @@ -84,14 +83,13 @@ export class ManagementContractCreateComponent implements OnInit, OnDestroy { technicalObjectActivated = false; usages: Option[] = [ - {key: 'BinaryMaster', label: 'Original numérique', info: ''}, - {key: 'Dissemination', label: 'Copie de diffusion', info: ''}, - {key: 'Thumbnail', label: 'Vignette', info: ''}, - {key: 'TextContent', label: 'Contenu brut', info: ''}, - {key: 'PhysicalMaster', label: 'Original papier', info: ''}, + { key: 'BinaryMaster', label: 'Original numérique', info: '' }, + { key: 'Dissemination', label: 'Copie de diffusion', info: '' }, + { key: 'Thumbnail', label: 'Vignette', info: '' }, + { key: 'TextContent', label: 'Contenu brut', info: '' }, + { key: 'PhysicalMaster', label: 'Original papier', info: '' }, ]; - ngOnInit() { this.form = this.formBuilder.group({ // Step 1 @@ -111,8 +109,8 @@ export class ManagementContractCreateComponent implements OnInit, OnDestroy { persistentIdentifierUnit: [false], persistentIdentifierObject: [false], persistentIdentifierAuthority: ['', [Validators.required, Validators.pattern('^[0-9]{5,9}$')]], - persistentIdentifierUsages: this.formBuilder.array([this.createUsageFormGroup()]) - }) + persistentIdentifierUsages: this.formBuilder.array([this.createUsageFormGroup()]), + }), }); this.statusControlValueChangesSubscribe = this.statusControl.valueChanges.subscribe((value: boolean) => { @@ -155,7 +153,6 @@ export class ManagementContractCreateComponent implements OnInit, OnDestroy { delete managementContractFrom.persistentIdentifierPolicy.persistentIdentifierObject; managementContractFrom.persistentIdentifierPolicyList = [managementContractFrom.persistentIdentifierPolicy]; - const managementContract = managementContractFrom as ManagementContract; managementContract.status === 'ACTIVE' ? (managementContract.activationDate = new Date().toISOString()) @@ -175,10 +172,10 @@ export class ManagementContractCreateComponent implements OnInit, OnDestroy { this.apiSubscriptions = this.managementContractService.create(managementContract).subscribe( () => { this.isDisabledButton = false; - this.dialogRef.close({success: true, action: 'none'}); + this.dialogRef.close({ success: true, action: 'none' }); }, (error: any) => { - this.dialogRef.close({success: false, action: 'none'}); + this.dialogRef.close({ success: false, action: 'none' }); this.logger.error(error); } ); @@ -219,7 +216,6 @@ export class ManagementContractCreateComponent implements OnInit, OnDestroy { ); } - thirdStepValid(): boolean { const persistentIdentifierPolicy = this.form.get('persistentIdentifierPolicy'); @@ -227,7 +223,6 @@ export class ManagementContractCreateComponent implements OnInit, OnDestroy { return false; } - const persistentIdentifierPolicyType = persistentIdentifierPolicy.get('persistentIdentifierPolicyType'); const persistentIdentifierUnit = persistentIdentifierPolicy.get('persistentIdentifierUnit'); const persistentIdentifierObject = persistentIdentifierPolicy.get('persistentIdentifierObject'); @@ -253,7 +248,6 @@ export class ManagementContractCreateComponent implements OnInit, OnDestroy { ); } - openClose() { this.gotOpened = !this.gotOpened; } @@ -268,19 +262,7 @@ export class ManagementContractCreateComponent implements OnInit, OnDestroy { return this.formBuilder.group({ usageName: [null, Validators.required], initialVersion: ['true', Validators.required], - intermediaryVersion: ['ALL', Validators.required] + intermediaryVersion: ['ALL', Validators.required], }); } - - deleteUsage(index: number) { - const persistentIdentifierUsagesArray = this.form.get('persistentIdentifierPolicy.persistentIdentifierUsages') as FormArray; - - if (persistentIdentifierUsagesArray && persistentIdentifierUsagesArray.length > 1) { - persistentIdentifierUsagesArray.removeAt(index); - } else { - const firstElement = persistentIdentifierUsagesArray.at(0); - firstElement.reset(); - } - } - } diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.module.ts b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.module.ts index 48c620c6a88..f4dd4c8819b 100644 --- a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.module.ts +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-create/management-contract-create.module.ts @@ -27,7 +27,7 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatButtonToggleModule } from '@angular/material/button-toggle'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; @@ -38,30 +38,32 @@ import { MatTooltipModule } from '@angular/material/tooltip'; import { VitamUILibraryModule } from 'projects/vitamui-library/src/public-api'; import { VitamUICommonModule } from 'ui-frontend-common'; +import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatRadioModule } from '@angular/material/radio'; import { SharedModule } from 'projects/identity/src/app/shared/shared.module'; +import { PermanentIdentifierFormModule } from '../management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.module'; import { ManagementContractCreateComponent } from './management-contract-create.component'; -import {MatCheckboxModule} from "@angular/material/checkbox"; -import {MatRadioModule} from "@angular/material/radio"; @NgModule({ declarations: [ManagementContractCreateComponent], entryComponents: [ManagementContractCreateComponent], - imports: [ - CommonModule, - SharedModule, - MatButtonToggleModule, - MatFormFieldModule, - MatInputModule, - MatProgressBarModule, - MatSelectModule, - MatSnackBarModule, - MatTooltipModule, - ReactiveFormsModule, - VitamUICommonModule, - VitamUILibraryModule, - MatCheckboxModule, - MatRadioModule, - FormsModule, - ], + imports: [ + CommonModule, + SharedModule, + MatButtonToggleModule, + MatFormFieldModule, + MatInputModule, + MatProgressBarModule, + MatSelectModule, + MatSnackBarModule, + MatTooltipModule, + ReactiveFormsModule, + VitamUICommonModule, + VitamUILibraryModule, + MatCheckboxModule, + MatRadioModule, + FormsModule, + PermanentIdentifierFormModule, + ], }) export class ManagementContractCreateModule {} diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-list/management-contract-list.component.ts b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-list/management-contract-list.component.ts index 725a5f60436..fa041dc12b8 100644 --- a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-list/management-contract-list.component.ts +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-list/management-contract-list.component.ts @@ -26,7 +26,7 @@ */ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; -import { merge, Subject, Subscription } from 'rxjs'; +import { Subject, Subscription, merge } from 'rxjs'; import { debounceTime } from 'rxjs/operators'; import { DEFAULT_PAGE_SIZE, Direction, InfiniteScrollTable, ManagementContract, PageRequest } from 'ui-frontend-common'; import { ManagementContractService } from '../management-contract.service'; @@ -106,21 +106,7 @@ export class ManagementContractListComponent extends InfiniteScrollTable mngContract.identifier === managementContract.identifier ); if (index > -1) { - this.dataSource[index] = { - id: managementContract.id, - tenant: managementContract.tenant, - version: managementContract.version, - name: managementContract.name, - identifier: managementContract.identifier, - description: managementContract.description, - status: managementContract.status, - creationDate: managementContract.creationDate, - lastUpdate: managementContract.lastUpdate, - activationDate: managementContract.activationDate, - deactivationDate: managementContract.deactivationDate, - storage: managementContract.storage, - versionRetentionPolicy: managementContract.versionRetentionPolicy, - }; + this.dataSource[index] = { ...managementContract }; } }); } diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.component.html b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.component.html new file mode 100644 index 00000000000..42fcc110bb0 --- /dev/null +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.component.html @@ -0,0 +1,135 @@ +
{{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.TITLE' | translate }}
+
+
+
+ + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.IDENTIFIER_TYPE' | translate }} + + {{ + policyTypeOption.label | translate + }} + + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.CHOOSE_IDENTIFIER_TYPE' | translate }} +
+ keyboard_arrow_up + keyboard_arrow_down +
+
+ + + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.ERROR_MESSAGES.INVALID_OBJECT_USAGE_POLICY' | translate }} + + +
+
+
{{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.POSITIONING_TITLE' | translate }}
+
+
+ + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.ARCHIVAL_UNIT' | translate }} + +
+
+
+
+ +
+ + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.TECHNICAL_OBJECT' | translate }} +
+
+
+
+
+
+ +
+
+
+
+ + {{ ('CONTRACT_MANAGEMENT.FORM_UPDATE.TARGET_USAGE' | translate) + i }} + + + {{ objectUsageOption.label | translate }} + + +
+ keyboard_arrow_up + keyboard_arrow_down +
+
+
+
+ +
+
+
+
+ +
+ + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.YES' | translate }} + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.NO' | translate }} + +
+
+
+ +
+ + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.ALL' | translate }} + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.LAST' | translate }} + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.NONE' | translate }} + +
+
+
+ + {{ 'CONTRACT_MANAGEMENT.FORM_UPDATE.ERROR_MESSAGES.INVALID_OBJECT_USAGE_POLICY' | translate }} + +
+
+
+
+
+ +
+
+
+
+
diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.component.scss b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.component.scss new file mode 100644 index 00000000000..f1510f3a8fb --- /dev/null +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.component.scss @@ -0,0 +1,62 @@ +h5 { + font-size: 1rem; + font-weight: 700; +} + +.header { + margin: 0.5rem 0; + padding: 1rem; + background-color: white; + border-radius: 5px; + font-weight: 700; + box-shadow: 0 0 2px rgba(var(--vitamui-grey-rgb), 0.2), 0 1px 4px rgba(var(--vitamui-grey-rgb), 0.05); + border-left: 2px solid transparent; + + &.opened { + border-left: 2px solid var(--vitamui-primary); + } + + .mat-checkbox-layout, + .mat-checkbox-label, + span { + font-size: 1rem; + color: var(--vitamui-primary); + } +} + +.icon { + font-size: 1.5rem !important; +} + +.content { + background-color: white; + padding: 1rem 0.5rem; + border-radius: 5px; + + label { + color: var(--vitamui-primary); + font-size: 0.75rem; + font-weight: 700; + margin: 0.5rem 0; + } +} + +.delete-button { + border: 1px solid var(--vitamui-primary); + border-radius: 50%; +} + +.mat-checkbox-frame, +.mat-checkbox-background, +.mat-checkbox-anim-unchecked-checked .mat-checkbox-anim-checked-unchecked { + transform: scale(1.2); +} + +.radio-button-group-wrapper { + padding: 0.5rem 0; +} + +// To override +.vitamui-mat-select { + padding-bottom: 0; +} diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.component.ts b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.component.ts new file mode 100644 index 00000000000..d3876a23039 --- /dev/null +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.component.ts @@ -0,0 +1,160 @@ +/** + * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) + * + * contact.vitam@culture.gouv.fr + * + * This software is a computer program whose purpose is to implement a digital archiving back-office system managing + * high volumetry securely and efficiently. + * + * This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free + * software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as + * circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, + * users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the + * successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or + * developing or reproducing the software by the user in light of its specific status of free software, that may mean + * that it is complicated to manipulate, and that also therefore means that it is reserved for developers and + * experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the + * software's suitability as regards their requirements in conditions enabling the security of their systems and/or data + * to be ensured and, more generally, to use and operate it in the same conditions as regards security. + * + * The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you + * accept its terms. + */ +import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; +import { AbstractControl, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { PersistentIdentifierPolicyTypeEnum } from 'ui-frontend-common'; + +interface PermanentIdentifierPolicyTypeOption { + label: string; + value: PersistentIdentifierPolicyTypeEnum | string; +} + +interface ObjectUsageOption { + label: string; + value: string; + disabled: false; +} + +@Component({ + selector: 'app-permanent-identifier-form', + templateUrl: './permanent-identifier-form.component.html', + styleUrls: ['./permanent-identifier-form.component.scss'], +}) +export class PermanentIdentifierFormComponent implements OnChanges { + @Input() form: FormGroup; + @Output() objectUsagePolicyAdded: EventEmitter = new EventEmitter(); + @Output() objectUsagePolicyRemoved: EventEmitter = new EventEmitter(); + + policyTypeOptions: PermanentIdentifierPolicyTypeOption[] = [ + { label: 'CONTRACT_MANAGEMENT.FORM_UPDATE.PERMANENT_IDENTIFIER_POLICY_OPTION.NONE.LABEL', value: '' }, + ...Object.values(PersistentIdentifierPolicyTypeEnum).map((pipt) => ({ + label: `CONTRACT_MANAGEMENT.FORM_UPDATE.PERMANENT_IDENTIFIER_POLICY_OPTION.${pipt.toUpperCase()}.LABEL`, + value: pipt, + })), + ]; + objectUsageOptions: ObjectUsageOption[] = [ + { label: 'CONTRACT_MANAGEMENT.FORM_UPDATE.OBJECT_USAGE_OPTION.BINARYMASTER.LABEL', value: 'BinaryMaster', disabled: false }, + { label: 'CONTRACT_MANAGEMENT.FORM_UPDATE.OBJECT_USAGE_OPTION.DISSEMINATION.LABEL', value: 'Dissemination', disabled: false }, + { label: 'CONTRACT_MANAGEMENT.FORM_UPDATE.OBJECT_USAGE_OPTION.PHYSICALMASTER.LABEL', value: 'PhysicalMaster', disabled: false }, + { label: 'CONTRACT_MANAGEMENT.FORM_UPDATE.OBJECT_USAGE_OPTION.TEXTCONTENT.LABEL', value: 'TextContent', disabled: false }, + { label: 'CONTRACT_MANAGEMENT.FORM_UPDATE.OBJECT_USAGE_OPTION.THUMBNAIL.LABEL', value: 'Thumbnail', disabled: false }, + ]; + + objectUsagePoliciesToggle = true; + addButtonDisabled = false; + + constructor(private formBuilder: FormBuilder) {} + + ngOnChanges(changes: SimpleChanges): void { + if (changes.form) { + this.updateAddButtonState(); + + this.form.get('shouldConcernObjects').valueChanges.subscribe((shouldConcernObjects) => { + this.objectUsagePoliciesToggle = shouldConcernObjects; + + const formArray = this.form.get('objectUsagePolicies') as FormArray; + if (!shouldConcernObjects) { + while (formArray.length !== 0) { + formArray.removeAt(0); + } + } + + if (formArray.length === 0 && shouldConcernObjects) { + this.addObjectUsagePolicy(); + } + }); + } + } + + toggle($event: Event): void { + const element = $event.target as any; + + if (['col', 'row', 'header'].some((cssClass) => element.className.includes(cssClass))) { + this.objectUsagePoliciesToggle = !this.objectUsagePoliciesToggle; + } + } + + removeObjectUsagePolicy(index: number): void { + this.objectUsagePolicies.removeAt(index); + this.objectUsagePolicyRemoved.emit(); + this.updateAddButtonState(); + } + + addObjectUsagePolicy(): void { + const objectUsageOption = this.findAvailableObjectUsageOption(); + if (!objectUsageOption) { + this.updateAddButtonState(); + return; + } + + const objectUsagePolicy: FormGroup = this.formBuilder.group( + { + objectUsage: [objectUsageOption.value, Validators.required], + initialVersion: [true, Validators.required], + intermediaryVersion: ['ALL', Validators.required], + }, + { validators: [this.objectUsagePolicyValidator] } + ); + + this.objectUsagePolicies.push(objectUsagePolicy); + this.objectUsagePolicyAdded.emit(); + this.updateAddButtonState(); + } + + findAvailableObjectUsageOption(): ObjectUsageOption { + return this.objectUsageOptions.find((objectUsageOption) => { + return this.getObjectUsagePolicies().every((objectUsagePolicy) => objectUsagePolicy.value.objectUsage !== objectUsageOption.value); + }); + } + + getObjectUsagePolicies(): AbstractControl[] { + return this.objectUsagePolicies.controls; + } + + isObjectUsageOptionDisabled(optionValue: string): boolean { + return this.getObjectUsagePolicies().some((policy: FormGroup) => policy.get('objectUsage').value === optionValue); + } + + private get objectUsagePolicies(): FormArray { + return this.form.get('objectUsagePolicies') as FormArray; + } + + private updateAddButtonState(): void { + this.addButtonDisabled = this.objectUsagePolicies.length >= this.objectUsageOptions.length; + } + + private objectUsagePolicyValidator(control: AbstractControl): { [key: string]: boolean } | null { + const initialVersion = control.get('initialVersion'); + const intermediaryVersion = control.get('intermediaryVersion'); + + if (initialVersion.value === false && intermediaryVersion.value === 'NONE') { + return { invalidObjectUsagePolicy: true }; + } + + return null; + } +} diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.module.ts b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.module.ts new file mode 100644 index 00000000000..c52f1543651 --- /dev/null +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.module.ts @@ -0,0 +1,66 @@ +/** + * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) + * + * contact.vitam@culture.gouv.fr + * + * This software is a computer program whose purpose is to implement a digital archiving back-office system managing + * high volumetry securely and efficiently. + * + * This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free + * software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as + * circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, + * users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the + * successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or + * developing or reproducing the software by the user in light of its specific status of free software, that may mean + * that it is complicated to manipulate, and that also therefore means that it is reserved for developers and + * experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the + * software's suitability as regards their requirements in conditions enabling the security of their systems and/or data + * to be ensured and, more generally, to use and operate it in the same conditions as regards security. + * + * The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you + * accept its terms. + */ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatButtonToggleModule } from '@angular/material/button-toggle'; +import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatInputModule } from '@angular/material/input'; +import { MatProgressBarModule } from '@angular/material/progress-bar'; +import { MatRadioModule } from '@angular/material/radio'; +import { MatSelectModule } from '@angular/material/select'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { SharedModule } from 'projects/identity/src/app/shared/shared.module'; +import { VitamUILibraryModule } from 'projects/vitamui-library/src/public-api'; +import { VitamUICommonModule } from 'ui-frontend-common'; +import { PermanentIdentifierFormComponent } from './permanent-identifier-form.component'; + +@NgModule({ + declarations: [PermanentIdentifierFormComponent], + entryComponents: [PermanentIdentifierFormComponent], + imports: [ + CommonModule, + SharedModule, + FormsModule, + ReactiveFormsModule, + MatButtonToggleModule, + MatFormFieldModule, + MatInputModule, + MatProgressBarModule, + MatSelectModule, + MatSnackBarModule, + MatTooltipModule, + MatCheckboxModule, + MatRadioModule, + VitamUICommonModule, + VitamUILibraryModule, + ], + exports: [PermanentIdentifierFormComponent], +}) +export class PermanentIdentifierFormModule {} diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/contract-form-converter.service.ts b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/contract-form-converter.service.ts new file mode 100644 index 00000000000..67990b09871 --- /dev/null +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/contract-form-converter.service.ts @@ -0,0 +1,92 @@ +/** + * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) + * + * contact.vitam@culture.gouv.fr + * + * This software is a computer program whose purpose is to implement a digital archiving back-office system managing + * high volumetry securely and efficiently. + * + * This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free + * software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as + * circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, + * users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the + * successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or + * developing or reproducing the software by the user in light of its specific status of free software, that may mean + * that it is complicated to manipulate, and that also therefore means that it is reserved for developers and + * experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the + * software's suitability as regards their requirements in conditions enabling the security of their systems and/or data + * to be ensured and, more generally, to use and operate it in the same conditions as regards security. + * + * The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you + * accept its terms. + */ +import { Injectable } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { ManagementContract, PersistentIdentifierPolicy, PersistentIdentifierUsage, VersionRetentionPolicy } from 'ui-frontend-common'; + +@Injectable({ + providedIn: 'root', +}) +export class ContractFormConverterService { + constructor() {} + + // Convertir le formulaire en objet ManagementContract + convertToManagementContract(form: FormGroup): ManagementContract { + const contractFormValue = form.value; + + const persistentIdentifierPolicyList: PersistentIdentifierPolicy[] = contractFormValue.permanentIdentifiers + .filter((policyFormValue: any) => policyFormValue.policyTypeOption) + .map((policyFormValue: any) => { + const persistentIdentifierUsages: PersistentIdentifierUsage[] = policyFormValue.objectUsagePolicies.map((usageFormValue: any) => { + return { + intermediaryVersion: usageFormValue.intermediaryVersion, + initialVersion: usageFormValue.initialVersion, + usageName: usageFormValue.objectUsage, + }; + }); + + return { + persistentIdentifierPolicyType: policyFormValue.policyTypeOption, + persistentIdentifierUnit: policyFormValue.shouldConcernArchiveUnits, + persistentIdentifierAuthority: policyFormValue.authority, + persistentIdentifierUsages: persistentIdentifierUsages, + }; + }); + + const managementContract: ManagementContract = { + // Ajoutez les propriétés nécessaires ici + id: null, + tenant: contractFormValue.tenant, + version: contractFormValue.version, + name: contractFormValue.name, + identifier: contractFormValue.identifier, + description: contractFormValue.description, + status: contractFormValue.status, + creationDate: contractFormValue.creationDate, + lastUpdate: contractFormValue.lastUpdate, + activationDate: contractFormValue.activationDate, + deactivationDate: contractFormValue.deactivationDate, + storage: contractFormValue.storage, + versionRetentionPolicy: this.extractVersionRetentionPolicy(contractFormValue), + persistentIdentifierPolicyList: persistentIdentifierPolicyList, + }; + + return managementContract; + } + + private extractVersionRetentionPolicy(contractFormValue: any): VersionRetentionPolicy | undefined { + if (contractFormValue.versionRetentionPolicy) { + return { + initialVersion: contractFormValue.versionRetentionPolicy.initialVersion, + intermediaryVersionEnum: contractFormValue.versionRetentionPolicy.intermediaryVersionEnum, + usages: new Set(contractFormValue.versionRetentionPolicy.usages), + }; + } + + return undefined; + } +} diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/management-contract-identification-tab.component.html b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/management-contract-identification-tab.component.html new file mode 100644 index 00000000000..6f33c537db9 --- /dev/null +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/management-contract-identification-tab.component.html @@ -0,0 +1,30 @@ +
+
+
+ +
+
+ + {{ error }} + +
+
+ +
+
+ +
+
+
diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/management-contract-identification-tab.component.scss b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/management-contract-identification-tab.component.scss new file mode 100644 index 00000000000..aa9a4abf31e --- /dev/null +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/management-contract-identification-tab.component.scss @@ -0,0 +1,57 @@ +.header { + margin: 0.5rem 0; + padding: 1rem; + background-color: white; + border-radius: 5px; + font-weight: 700; + box-shadow: 0 0 2px rgba(var(--vitamui-grey-rgb), 0.2), 0 1px 4px rgba(var(--vitamui-grey-rgb), 0.05); + border-left: 2px solid transparent; + + &.opened { + border-left: 2px solid var(--vitamui-primary); + } + + .mat-checkbox-layout, + .mat-checkbox-label, + span { + font-size: 1rem; + color: var(--vitamui-primary); + } +} + +.icon { + font-size: 1.5rem !important; +} + +.content { + background-color: white; + padding: 1rem 0.5rem; + border-radius: 5px; + + label { + color: var(--vitamui-primary); + font-size: 0.75rem; + font-weight: 700; + margin: 0.5rem 0; + } +} + +.delete-button { + border: 1px solid var(--vitamui-primary); + border-radius: 50%; +} + +.mat-checkbox-frame, +.mat-checkbox-background, +.mat-checkbox-anim-unchecked-checked .mat-checkbox-anim-checked-unchecked { + transform: scale(1.2); +} + +.radio-button-group-wrapper { + padding: 0.5rem 0; +} + +// To override +.vitamui-mat-select { + padding-bottom: 0; +} diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/management-contract-identification-tab.component.ts b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/management-contract-identification-tab.component.ts new file mode 100644 index 00000000000..9b88008f14e --- /dev/null +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-identification-tab/management-contract-identification-tab.component.ts @@ -0,0 +1,182 @@ +/** + * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) + * + * contact.vitam@culture.gouv.fr + * + * This software is a computer program whose purpose is to implement a digital archiving back-office system managing + * high volumetry securely and efficiently. + * + * This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free + * software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as + * circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, + * users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the + * successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or + * developing or reproducing the software by the user in light of its specific status of free software, that may mean + * that it is complicated to manipulate, and that also therefore means that it is reserved for developers and + * experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the + * software's suitability as regards their requirements in conditions enabling the security of their systems and/or data + * to be ensured and, more generally, to use and operate it in the same conditions as regards security. + * + * The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you + * accept its terms. + */ +import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; +import { AbstractControl, FormArray, FormBuilder, FormGroup, ValidationErrors, Validators } from '@angular/forms'; +import { Observable, Subscription, of } from 'rxjs'; +import { mergeMap, tap } from 'rxjs/operators'; +import { ManagementContract, PersistentIdentifierPolicy, PersistentIdentifierUsage } from 'ui-frontend-common'; +import { ManagementContractService } from '../../management-contract.service'; +import { ContractFormConverterService } from './contract-form-converter.service'; + +@Component({ + selector: 'app-management-contract-identification-tab', + templateUrl: './management-contract-identification-tab.component.html', + styleUrls: ['./management-contract-identification-tab.component.scss'], + providers: [ContractFormConverterService], +}) +export class ManagementContractIdentificationTabComponent implements OnChanges { + @Input() managementContract: ManagementContract; + @Output() updated: EventEmitter = new EventEmitter(); + + contractForm: FormGroup; + sending = false; + + private subscriptions: Subscription = new Subscription(); + + constructor( + private formBuilder: FormBuilder, + private contractFormConverterService: ContractFormConverterService, + private managementContractService: ManagementContractService + ) {} + + ngOnChanges(changes: SimpleChanges): void { + if (changes.managementContract) { + this.resetForm(changes.managementContract.currentValue); + } + } + + private buildForm(managementContract: ManagementContract): void { + this.contractForm = this.formBuilder.group({ + permanentIdentifiers: this.formBuilder.array( + managementContract.persistentIdentifierPolicyList.map((policy) => this.buildPolicyGroup(policy)) + ), + }); + } + + private buildPolicyGroup(policy: PersistentIdentifierPolicy): FormGroup { + return this.formBuilder.group({ + policyTypeOption: [policy.persistentIdentifierPolicyType], + authority: [policy.persistentIdentifierAuthority, [Validators.required, Validators.pattern('^[0-9]{5,9}$')]], + shouldConcernArchiveUnits: [policy.persistentIdentifierUnit], + shouldConcernObjects: [Boolean(policy.persistentIdentifierUsages.length)], + objectUsagePolicies: this.formBuilder.array( + policy.persistentIdentifierUsages.map((objectUsagePolicy) => this.buildObjectUsageGroup(objectUsagePolicy)) + ), + }); + } + + private buildObjectUsageGroup(objectUsagePolicy: PersistentIdentifierUsage): FormGroup { + return this.formBuilder.group( + { + objectUsage: [objectUsagePolicy.usageName, Validators.required], + initialVersion: [objectUsagePolicy.initialVersion, Validators.required], + intermediaryVersion: [objectUsagePolicy.intermediaryVersion, Validators.required], + }, + { validators: [this.objectUsagePolicyValidator] } + ); + } + + objectUsagePolicyValidator(control: AbstractControl): ValidationErrors | null { + const initialVersion = control.get('initialVersion'); + const intermediaryVersion = control.get('intermediaryVersion'); + + if (initialVersion.value === false && intermediaryVersion.value === 'NONE') { + return { invalidObjectUsagePolicy: true }; + } + + return null; + } + + submit(): void { + const subscription = this.prepareSubmit() + .pipe(tap((managementContract) => (this.managementContract = managementContract))) + .subscribe(() => subscription.unsubscribe()); + } + + prepareSubmit(): Observable { + return of((this.sending = true)).pipe( + mergeMap(() => this.managementContractService.patch(this.getUpdatedManagementContract())), + tap( + () => (this.sending = false), + () => (this.sending = false) + ), + tap(() => this.updated.emit(false)), + tap(() => { + this.contractForm.markAsPristine(); + }) + ); + } + + resetForm(managementContract: ManagementContract): void { + this.buildForm(managementContract); + this.updated.emit(false); + + this.subscriptions.add( + this.contractForm.valueChanges.subscribe(() => { + this.updated.emit(true); + }) + ); + } + + getUpdatedManagementContract(): ManagementContract { + const updates = this.contractFormConverterService.convertToManagementContract(this.contractForm); + + return { + ...this.managementContract, + persistentIdentifierPolicyList: updates.persistentIdentifierPolicyList, + }; + } + + getPermanentIdentifiers(): FormArray { + return this.contractForm.get('permanentIdentifiers') as FormArray; + } + + isSubmitButtonDisabled(): boolean { + const hasNoChanges = this.deepEqual(this.managementContract, this.getUpdatedManagementContract()); + + if (hasNoChanges) { + this.updated.emit(false); + } + + return this.contractForm.invalid || this.contractForm.pristine || hasNoChanges; + } + + private deepEqual(obj1: any, obj2: any): boolean { + if (obj1 === obj2) { + return true; + } + + if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null) { + return false; + } + + const keys1 = Object.keys(obj1); + const keys2 = Object.keys(obj2); + + if (keys1.length !== keys2.length) { + return false; + } + + for (const key of keys1) { + if (!keys2.includes(key) || !this.deepEqual(obj1[key], obj2[key])) { + return false; + } + } + + return true; + } +} diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-preview.component.html b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-preview.component.html index 1c116eb49f1..3099d68f9c1 100644 --- a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-preview.component.html +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-preview.component.html @@ -10,20 +10,28 @@
- + - + + + = new EventEmitter(); +export class ManagementContractPreviewComponent implements OnChanges, AfterViewInit { + @Output() previewClose: EventEmitter = new EventEmitter(); + @Input() inputManagementContract: ManagementContract; + @ViewChild('tabs', { static: false }) tabs: MatTabGroup; + @ViewChild('informationTab', { static: false }) informationTab: ManagementContractInformationTabComponent; + @ViewChild('storageTab', { static: false }) storageTab: ManagementContractStorageTabComponent; + @ViewChild('identificationTab', { static: false }) identificationTab: ManagementContractIdentificationTabComponent; - @Input() - inputManagementContract: ManagementContract; + private tabUpdated: boolean[] = [false, false, false, false]; + private tabLinks: Array< + ManagementContractInformationTabComponent | ManagementContractStorageTabComponent | ManagementContractIdentificationTabComponent + > = []; - tabUpdated: boolean[] = [false, false]; + @HostListener('window:beforeunload', ['$event']) + async beforeunloadHandler(event: any) { + if (this.tabUpdated[this.tabs.selectedIndex]) { + event.preventDefault(); + await this.checkBeforeExit(); + return ''; + } + } + + constructor(private matDialog: MatDialog) {} - constructor() {} + ngOnChanges(changes: SimpleChanges): void { + if (changes.inputManagementContract && this.tabUpdated.some((update) => update)) { + this.inputManagementContract = changes.inputManagementContract.previousValue; + this.checkBeforeExit().then(() => { + this.inputManagementContract = changes.inputManagementContract.currentValue; + }); + } + } - ngOnInit() {} + ngAfterViewInit(): void { + this.tabs._handleClick = this.interceptTabChange.bind(this); + this.tabLinks.push(this.informationTab); + this.tabLinks.push(this.storageTab); + this.tabLinks.push(this.identificationTab); + } updatedChange(updated: boolean, index: number) { this.tabUpdated[index] = updated; @@ -66,7 +101,41 @@ export class ManagementContractPreviewComponent implements OnInit { ); } - emitClose() { + async emitClose() { + if (this.tabUpdated[this.tabs.selectedIndex]) { + await this.checkBeforeExit(); + } this.previewClose.emit(); } + + async checkBeforeExit() { + if (await this.confirmAction()) { + const subscription: Subscription = this.tabLinks[this.tabs.selectedIndex] + .prepareSubmit() + .pipe( + tap((managementContract) => { + this.inputManagementContract = managementContract; + }) + ) + .subscribe(() => subscription.unsubscribe()); + } else { + this.tabLinks[this.tabs.selectedIndex].resetForm(this.inputManagementContract); + } + } + + async confirmAction(): Promise { + const dialog = this.matDialog.open(ConfirmActionComponent, { panelClass: 'vitamui-confirm-dialog' }); + + dialog.componentInstance.dialogType = 'changeTab'; + + return await dialog.afterClosed().toPromise(); + } + + async interceptTabChange(tab: MatTab, tabHeader: MatTabHeader, idx: number) { + if (this.tabUpdated[this.tabs.selectedIndex]) { + await this.checkBeforeExit(); + } + + return MatTabGroup.prototype._handleClick.apply(this.tabs, [tab, tabHeader, idx]); + } } diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-preview.module.ts b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-preview.module.ts index b1ffc3ec588..ef1ca7cadff 100644 --- a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-preview.module.ts +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-preview.module.ts @@ -49,6 +49,8 @@ import { RouterModule } from '@angular/router'; import { VitamUILibraryModule } from 'projects/vitamui-library/src/public-api'; import { VitamUICommonModule } from 'ui-frontend-common'; +import { PermanentIdentifierFormModule } from './management-contract-identification-tab/components/forms/permanent-identifier-form/permanent-identifier-form.module'; +import { ManagementContractIdentificationTabComponent } from './management-contract-identification-tab/management-contract-identification-tab.component'; import { ManagementContractInformationTabComponent } from './management-contract-information-tab/management-contract-information-tab.component'; import { ManagementContractPreviewComponent } from './management-contract-preview.component'; import { ManagementContractStorageTabComponent } from './management-contract-storage-tab/management-contract-storage-tab.component'; @@ -69,8 +71,14 @@ import { ManagementContractStorageTabComponent } from './management-contract-sto MatSelectModule, MatOptionModule, MatTabsModule, + PermanentIdentifierFormModule, + ], + declarations: [ + ManagementContractPreviewComponent, + ManagementContractInformationTabComponent, + ManagementContractStorageTabComponent, + ManagementContractIdentificationTabComponent, ], - declarations: [ManagementContractPreviewComponent, ManagementContractInformationTabComponent, ManagementContractStorageTabComponent], exports: [ManagementContractPreviewComponent], }) export class ManagementContractPreviewModule {} diff --git a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-storage-tab/management-contract-storage-tab.component.ts b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-storage-tab/management-contract-storage-tab.component.ts index 3d05b3ddd15..ff1414e66ca 100644 --- a/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-storage-tab/management-contract-storage-tab.component.ts +++ b/ui/ui-frontend/projects/referential/src/app/management-contract/management-contract-preview/management-contract-storage-tab/management-contract-storage-tab.component.ts @@ -27,9 +27,9 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { Observable, of, Subscription } from 'rxjs'; +import { Observable, Subscription, of } from 'rxjs'; import { catchError, filter, map, switchMap } from 'rxjs/operators'; -import { diff, ManagementContract, StorageStrategy } from 'ui-frontend-common'; +import { ManagementContract, StorageStrategy, diff } from 'ui-frontend-common'; import { extend, isEmpty } from 'underscore'; import { ManagementContractService } from '../../management-contract.service'; @@ -69,7 +69,7 @@ export class ManagementContractStorageTabComponent implements OnInit, OnDestroy this._inputManagementContract = managementContract; - this.resetForm(this.inputManagementContract.storage); + this.resetForm(this.inputManagementContract); this.updated.emit(false); } @@ -129,8 +129,8 @@ export class ManagementContractStorageTabComponent implements OnInit, OnDestroy ); } - resetForm(storageStrategy: StorageStrategy) { - this.form.reset(storageStrategy, { emitEvent: false }); + resetForm(managementContract: ManagementContract) { + this.form.reset(managementContract.storage, { emitEvent: false }); } ngOnDestroy() { diff --git a/ui/ui-frontend/projects/referential/src/assets/i18n/en.json b/ui/ui-frontend/projects/referential/src/assets/i18n/en.json index 84d500a0511..3e1d0f578a7 100644 --- a/ui/ui-frontend/projects/referential/src/assets/i18n/en.json +++ b/ui/ui-frontend/projects/referential/src/assets/i18n/en.json @@ -60,6 +60,7 @@ "PREVIEW": { "INFORMATIONS": "Informations", "STORAGE": "Storage", + "IDENTIFICATION": "Identification", "HISTORY": "History", "INFORMATION": { "NAME": "Contract name", @@ -76,6 +77,55 @@ "OBJECT_GROUP_STRATEGY": "Technical object groups", "OBJECT_STRATEGY": "Digital files" } + }, + "FORM_UPDATE": { + "TITLE": "Persistent identifier settings", + "IDENTIFIER_TYPE": "Identifier type", + "CHOOSE_IDENTIFIER_TYPE": "Choose identifier type", + "NAMING_AUTORITY": "Naming authority", + "ERROR_MESSAGES": { + "INVALID_OBJECT_USAGE_POLICY": "Invalid object usage policy" + }, + "POSITIONING_TITLE": "Positioning title", + "ARCHIVAL_UNIT": "Archival unit", + "TECHNICAL_OBJECT": "Technical object", + "FORMAT": "Format", + "REMOVE_USAGE": "Remove usage", + "TARGET_USAGE": "Target usage", + "INITIAL_VERSION": "Initial version", + "YES": "Yes", + "NO": "No", + "LATER_VERSIONS": "Later versions", + "ALL": "All", + "LAST": "Last", + "NONE": "None", + "ADD_USAGE": "Add usage", + "SAVE": "Save", + "PERMANENT_IDENTIFIER_POLICY_OPTION": { + "NONE": { + "LABEL": "None" + }, + "ARK": { + "LABEL": "ARK" + } + }, + "OBJECT_USAGE_OPTION": { + "BINARYMASTER": { + "LABEL": "Binary master" + }, + "DISSEMINATION": { + "LABEL": "Dissemination" + }, + "PHYSICALMASTER": { + "LABEL": "Physical master" + }, + "TEXTCONTENT": { + "LABEL": "Text content" + }, + "THUMBNAIL": { + "LABEL": "Thumbnail" + } + } } }, "LOGBOOK_OPERATION_LIST": { diff --git a/ui/ui-frontend/projects/referential/src/assets/i18n/fr.json b/ui/ui-frontend/projects/referential/src/assets/i18n/fr.json index 169938d13ce..b87b92b30d0 100644 --- a/ui/ui-frontend/projects/referential/src/assets/i18n/fr.json +++ b/ui/ui-frontend/projects/referential/src/assets/i18n/fr.json @@ -60,6 +60,7 @@ "PREVIEW": { "INFORMATIONS": "Informations", "STORAGE": "Stockage", + "IDENTIFICATION": "Identification", "HISTORY": "Historique", "INFORMATION": { "NAME": "Nom du contrat", @@ -76,6 +77,55 @@ "OBJECT_GROUP_STRATEGY": "Groupes d’objets techniques", "OBJECT_STRATEGY": "Fichiers numériques" } + }, + "FORM_UPDATE": { + "TITLE": "Paramétrage d'identification pérenne", + "IDENTIFIER_TYPE": "Type d'identifiant", + "CHOOSE_IDENTIFIER_TYPE": "Choisissez un type d'identifiant", + "NAMING_AUTORITY": "Autorité nommante", + "ERROR_MESSAGES": { + "INVALID_OBJECT_USAGE_POLICY": "La règle sur l'oject d'usage n'est pas valide" + }, + "POSITIONING_TITLE": "Positionnement des identifiants", + "ARCHIVAL_UNIT": "Unité archivistique", + "TECHNICAL_OBJECT": "Objet technique", + "FORMAT": "Format", + "REMOVE_USAGE": "Supprimer cet usage", + "TARGET_USAGE": "Usage cible ", + "INITIAL_VERSION": "Version initiale", + "YES": "Oui", + "NO": "Non", + "LATER_VERSIONS": "Versions ultérieures", + "ALL": "Toutes", + "LAST": "Dernière", + "NONE": "Aucune", + "ADD_USAGE": "Ajouter un usage", + "SAVE": "Enregistrer", + "PERMANENT_IDENTIFIER_POLICY_OPTION": { + "NONE": { + "LABEL": "Aucun" + }, + "ARK": { + "LABEL": "ARK" + } + }, + "OBJECT_USAGE_OPTION": { + "BINARYMASTER": { + "LABEL": "Original numérique" + }, + "DISSEMINATION": { + "LABEL": "Copie de diffusion" + }, + "PHYSICALMASTER": { + "LABEL": "Original papier" + }, + "TEXTCONTENT": { + "LABEL": "Contenu brut" + }, + "THUMBNAIL": { + "LABEL": "Vignette" + } + } } }, "LOGBOOK_OPERATION_LIST": {