Commit 3e5a894a authored by oussamasic's avatar oussamasic Committed by Ro3034
Browse files

mass update UA rules

parent b8a65538
......@@ -79,6 +79,8 @@ public class ArchiveSearchConsts {
public final static String APPRAISAL_RULE_IDENTIFIER = "APPRAISAL_RULE_IDENTIFIER";
public final static String APPRAISAL_RULE_TITLE = "APPRAISAL_RULE_TITLE";
public final static String APPRAISAL_RULE_END_DATE = "APPRAISAL_RULE_END_DATE";
public final static String APPRAISAL_RULE_START_DATE = "APPRAISAL_RULE_START_DATE";
public final static String APPRAISAL_RULE_START_DATE_FIELD = "#management.AppraisalRule.Rules.StartDate";
public static final String ISO_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static final String ONLY_DATE_FORMAT = "yyyy-MM-dd";
......@@ -145,7 +147,8 @@ public class ArchiveSearchConsts {
ORIGINATING_AGENCY_ID_FIELD, "#originating_agency",
"START_DATE", "StartDate",
"END_DATE", "EndDate",
"SP_LABEL", "originating_agency_label"
"SP_LABEL", "originating_agency_label",
"APPRAISAL_RULE_START_DATE", "#management.AppraisalRule.Rules.StartDate"
);
......
/*
* *
* * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
* * and the signatories of the "VITAM - Accord du Contributeur" agreement.
* *
* * contact@programmevitam.fr
* *
* * This software is a computer program whose purpose is to implement
* * implement a digital archiving front-office system for the secure and
* * efficient high volumetry VITAM solution.
* *
* * This software is governed by the CeCILL-C 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-C
* * license as circulated by CEA, CNRS and INRIA at the following URL
* * "http://www.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-C license and that you accept its terms.
*
*/
package fr.gouv.vitamui.archives.search.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
@ToString
@JsonInclude(JsonInclude.Include.NON_NULL)
@Setter
@Getter
public class RuleSearchCriteriaDto implements Serializable {
private SearchCriteriaDto searchCriteriaDto;
private VitamUiRuleActions ruleActions;
}
/*
* *
* * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
* * and the signatories of the "VITAM - Accord du Contributeur" agreement.
* *
* * contact@programmevitam.fr
* *
* * This software is a computer program whose purpose is to implement
* * implement a digital archiving front-office system for the secure and
* * efficient high volumetry VITAM solution.
* *
* * This software is governed by the CeCILL-C 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-C
* * license as circulated by CEA, CNRS and INRIA at the following URL
* * "http://www.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-C license and that you accept its terms.
*
*/
package fr.gouv.vitamui.archives.search.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
@ToString
@JsonInclude(JsonInclude.Include.NON_NULL)
@Setter
@Getter
public class VitamUiManagementMetadataAction implements Serializable {
@JsonProperty("ArchiveUnitProfile")
String archiveUnitProfile;
}
/*
* *
* * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
* * and the signatories of the "VITAM - Accord du Contributeur" agreement.
* *
* * contact@programmevitam.fr
* *
* * This software is a computer program whose purpose is to implement
* * implement a digital archiving front-office system for the secure and
* * efficient high volumetry VITAM solution.
* *
* * This software is governed by the CeCILL-C 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-C
* * license as circulated by CEA, CNRS and INRIA at the following URL
* * "http://www.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-C license and that you accept its terms.
*
*/
package fr.gouv.vitamui.archives.search.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
@ToString
@JsonInclude(JsonInclude.Include.NON_NULL)
@Setter
@Getter
public class VitamUiRuleAction implements Serializable {
private String rule;
private String startDate;
private String endDate;
private String name;
private String oldRule;
private Boolean deleteStartDate;
private String holdEndDate;
private Boolean deleteHoldEndDate;
private String holdOwner;
private Boolean deleteHoldOwner;
private String holdReason;
private Boolean deleteHoldReason;
private String holdReassessingDate;
private Boolean deleteHoldReassessingDate;
private Boolean preventRearrangement;
private Boolean deletePreventRearrangement;
}
/*
* *
* * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
* * and the signatories of the "VITAM - Accord du Contributeur" agreement.
* *
* * contact@programmevitam.fr
* *
* * This software is a computer program whose purpose is to implement
* * implement a digital archiving front-office system for the secure and
* * efficient high volumetry VITAM solution.
* *
* * This software is governed by the CeCILL-C 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-C
* * license as circulated by CEA, CNRS and INRIA at the following URL
* * "http://www.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-C license and that you accept its terms.
*
*/
package fr.gouv.vitamui.archives.search.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS;
@ToString
@JsonInclude(JsonInclude.Include.NON_NULL)
@Setter
@Getter
public class VitamUiRuleActions implements Serializable {
List<Map<String, VitamUiRuleCategoryAction>> add = new ArrayList<>();
List<Map<String, VitamUiRuleCategoryAction>> update = new ArrayList<>();
@JsonInclude(ALWAYS)
List<Map<String, VitamUiRuleCategoryActionDeletion>> delete = new ArrayList<>();
VitamUiManagementMetadataAction addOrUpdateMetadata;
VitamUiManagementMetadataAction deleteMetadata;
}
/*
* *
* * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
* * and the signatories of the "VITAM - Accord du Contributeur" agreement.
* *
* * contact@programmevitam.fr
* *
* * This software is a computer program whose purpose is to implement
* * implement a digital archiving front-office system for the secure and
* * efficient high volumetry VITAM solution.
* *
* * This software is governed by the CeCILL-C 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-C
* * license as circulated by CEA, CNRS and INRIA at the following URL
* * "http://www.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-C license and that you accept its terms.
*
*/
package fr.gouv.vitamui.archives.search.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
@ToString
@JsonInclude(JsonInclude.Include.NON_NULL)
@Setter
@Getter
public class VitamUiRuleCategoryAction implements Serializable {
private List<VitamUiRuleAction> rules;
private String finalAction;
private String classificationLevel;
private String classificationOwner;
private String classificationAudience;
private String classificationReassessingDate;
private Boolean needReassessingAuthorization;
private Boolean preventInheritance;
private Set<String> preventRulesId;
}
/*
* *
* * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
* * and the signatories of the "VITAM - Accord du Contributeur" agreement.
* *
* * contact@programmevitam.fr
* *
* * This software is a computer program whose purpose is to implement
* * implement a digital archiving front-office system for the secure and
* * efficient high volumetry VITAM solution.
* *
* * This software is governed by the CeCILL-C 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-C
* * license as circulated by CEA, CNRS and INRIA at the following URL
* * "http://www.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-C license and that you accept its terms.
*
*/
package fr.gouv.vitamui.archives.search.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@ToString
@JsonInclude(JsonInclude.Include.NON_NULL)
@Setter
@Getter
public class VitamUiRuleCategoryActionDeletion implements Serializable {
private Optional<List<VitamUiRuleAction>> rules;
private Optional<String> finalAction;
private Optional<String> classificationAudience;
private Optional<String> classificationReassessingDate;
private Optional<Boolean> needReassessingAuthorization;
private Optional<Boolean> preventInheritance;
private Optional<Set<String>> preventRulesId;
}
......@@ -40,4 +40,5 @@ public class RestApi {
public static final String EXPORT_DIP = "/export-dip";
public static final String ELIMINATION_ANALYSIS = "/elimination/analysis";
public static final String ELIMINATION_ACTION = "/elimination/action";
public static final String MASSUPDATEUNITSRULES = "/units/rules";
}
......@@ -30,6 +30,7 @@ package fr.gouv.vitamui.archives.search.external.client;
import com.fasterxml.jackson.databind.JsonNode;
import fr.gouv.vitamui.archives.search.common.dto.ArchiveUnitsDto;
import fr.gouv.vitamui.archives.search.common.dto.ExportDipCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.RuleSearchCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.SearchCriteriaDto;
import fr.gouv.vitamui.archives.search.common.rest.RestApi;
import fr.gouv.vitamui.commons.api.CommonConstants;
......@@ -183,4 +184,14 @@ public class ArchiveSearchExternalRestClient
return restTemplate.exchange(getUrl() + RestApi.ELIMINATION_ACTION, HttpMethod.POST,
request, JsonNode.class);
}
public ResponseEntity<String> updateArchiveUnitsRules(RuleSearchCriteriaDto ruleSearchCriteriaDto, ExternalHttpContext context) {
LOGGER.debug("Calling updateArchiveUnitsRules by criteria");
MultiValueMap<String, String> headers = buildSearchHeaders(context);
final HttpEntity<RuleSearchCriteriaDto> request = new HttpEntity<>(ruleSearchCriteriaDto, headers);
final ResponseEntity<String> response =
restTemplate.exchange(getUrl() + RestApi.MASSUPDATEUNITSRULES, HttpMethod.POST,
request, String.class);
return response;
}
}
......@@ -30,6 +30,7 @@ package fr.gouv.vitamui.archives.search.external.server.rest;
import com.fasterxml.jackson.databind.JsonNode;
import fr.gouv.vitamui.archives.search.common.dto.ArchiveUnitsDto;
import fr.gouv.vitamui.archives.search.common.dto.ExportDipCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.RuleSearchCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.SearchCriteriaDto;
import fr.gouv.vitamui.archives.search.common.rest.RestApi;
import fr.gouv.vitamui.archives.search.external.server.service.ArchivesSearchExternalService;
......@@ -150,4 +151,13 @@ public class ArchivesSearchExternalController {
SanityChecker.sanitizeCriteria(query);
return archivesSearchExternalService.startEliminationAction(query);
}
@PostMapping(RestApi.MASSUPDATEUNITSRULES)
@Secured(ServicesData.ROLE_UPDATE_MANAGEMENT_RULES)
public String updateArchiveUnitsRules(final @RequestBody RuleSearchCriteriaDto ruleSearchCriteriaDto) {
LOGGER.info("Calling Update Archive Units Rules By Criteria {} ", ruleSearchCriteriaDto);
ParameterChecker.checkParameter("The query is a mandatory parameter: ", ruleSearchCriteriaDto);
SanityChecker.sanitizeCriteria(ruleSearchCriteriaDto);
return archivesSearchExternalService.updateArchiveUnitsRules(ruleSearchCriteriaDto);
}
}
......@@ -32,6 +32,7 @@ import fr.gouv.archive.internal.client.ArchiveInternalRestClient;
import fr.gouv.archive.internal.client.ArchiveInternalWebClient;
import fr.gouv.vitamui.archives.search.common.dto.ArchiveUnitsDto;
import fr.gouv.vitamui.archives.search.common.dto.ExportDipCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.RuleSearchCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.SearchCriteriaDto;
import fr.gouv.vitamui.commons.vitam.api.dto.ResultsDto;
import fr.gouv.vitamui.commons.vitam.api.dto.VitamUISearchResponseDto;
......@@ -108,4 +109,8 @@ public class ArchivesSearchExternalService extends AbstractResourceClientService
public ResponseEntity<JsonNode> startEliminationAction(final SearchCriteriaDto query) {
return archiveInternalRestClient.startEliminationAction(getInternalHttpContext(), query);
}
public String updateArchiveUnitsRules(final RuleSearchCriteriaDto ruleSearchCriteriaDto) {
return archiveInternalRestClient.updateArchiveUnitsRules(ruleSearchCriteriaDto, getInternalHttpContext());
}
}
......@@ -31,6 +31,7 @@ import fr.gouv.archive.internal.client.ArchiveInternalRestClient;
import fr.gouv.vitamui.archives.search.common.common.ArchiveSearchConsts;
import fr.gouv.vitamui.archives.search.common.dto.ArchiveUnitsDto;
import fr.gouv.vitamui.archives.search.common.dto.CriteriaValue;
import fr.gouv.vitamui.archives.search.common.dto.RuleSearchCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.SearchCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.SearchCriteriaEltDto;
import fr.gouv.vitamui.archives.search.common.rest.RestApi;
......@@ -193,4 +194,18 @@ public class ArchivesSearchExternalControllerTest extends ApiArchiveSearchExtern
Assertions.assertNotNull(responseCsv);
Assertions.assertEquals(responseCsv, resource);
}
@Test
public void testArchiveUnitsRulesMassUpdateResultsThanReturnVitamOperationId() {
RuleSearchCriteriaDto ruleSearchCriteriaDto = new RuleSearchCriteriaDto();
String expectedResponse = new String();
Mockito
.when(archivesSearchExternalService.updateArchiveUnitsRules(Mockito.eq(ruleSearchCriteriaDto)))
.thenReturn(expectedResponse);
String response = archivesSearchExternalController.updateArchiveUnitsRules(ruleSearchCriteriaDto);
Assertions.assertEquals(response, expectedResponse);
}
}
......@@ -29,6 +29,7 @@ package fr.gouv.archive.internal.client;
import com.fasterxml.jackson.databind.JsonNode;
import fr.gouv.vitamui.archives.search.common.dto.ArchiveUnitsDto;
import fr.gouv.vitamui.archives.search.common.dto.ExportDipCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.RuleSearchCriteriaDto;
import fr.gouv.vitamui.archives.search.common.dto.SearchCriteriaDto;
import fr.gouv.vitamui.archives.search.common.rest.RestApi;
import fr.gouv.vitamui.commons.api.CommonConstants;
......@@ -196,4 +197,17 @@ public class ArchiveInternalRestClient
return response;
}