Commit 5c56566c authored by oussamasic's avatar oussamasic Committed by Ro3034
Browse files

correct code review

parent d97ebd30
......@@ -54,5 +54,5 @@ import java.io.Serializable;
@Getter
public class VitamUiManagementMetadataAction implements Serializable {
String archiveUnitProfile;
private String archiveUnitProfile;
}
......@@ -58,15 +58,14 @@ import static com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS;
@Getter
public class VitamUiRuleActions implements Serializable {
private List<Map<String, VitamUiRuleCategoryAction>> add = new ArrayList<>();
List<Map<String, VitamUiRuleCategoryAction>> add = new ArrayList<>();
List<Map<String, VitamUiRuleCategoryAction>> update = new ArrayList<>();
private List<Map<String, VitamUiRuleCategoryAction>> update = new ArrayList<>();
@JsonInclude(ALWAYS)
List<Map<String, VitamUiRuleCategoryActionDeletion>> delete = new ArrayList<>();
private List<Map<String, VitamUiRuleCategoryActionDeletion>> delete = new ArrayList<>();
VitamUiManagementMetadataAction addOrUpdateMetadata;
private VitamUiManagementMetadataAction addOrUpdateMetadata;
VitamUiManagementMetadataAction deleteMetadata;
private VitamUiManagementMetadataAction deleteMetadata;
}
......@@ -40,5 +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";
public static final String MASS_UPDATE_UNITS_RULES = "/units/rules";
}
......@@ -190,7 +190,7 @@ public class ArchiveSearchExternalRestClient
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,
restTemplate.exchange(getUrl() + RestApi.MASS_UPDATE_UNITS_RULES, HttpMethod.POST,
request, String.class);
return response;
}
......
......@@ -152,7 +152,7 @@ public class ArchivesSearchExternalController {
return archivesSearchExternalService.startEliminationAction(query);
}
@PostMapping(RestApi.MASSUPDATEUNITSRULES)
@PostMapping(RestApi.MASS_UPDATE_UNITS_RULES)
@Secured(ServicesData.ROLE_UPDATE_MANAGEMENT_RULES)
public String updateArchiveUnitsRules(final @RequestBody RuleSearchCriteriaDto ruleSearchCriteriaDto) {
LOGGER.info("Calling Update Archive Units Rules By Criteria {} ", ruleSearchCriteriaDto);
......
......@@ -72,6 +72,8 @@ public class ArchivesSearchExternalControllerTest extends ApiArchiveSearchExtern
public final String ARCHIVE_UNITS_RESULTS_CSV = "data/vitam_archive_units_response.csv";
public final String EXPECTED_RESPONSE = "expected_response";
@MockBean
private ArchivesSearchExternalService archivesSearchExternalService;
......@@ -199,7 +201,7 @@ public class ArchivesSearchExternalControllerTest extends ApiArchiveSearchExtern
public void testArchiveUnitsRulesMassUpdateResultsThanReturnVitamOperationId() {
RuleSearchCriteriaDto ruleSearchCriteriaDto = new RuleSearchCriteriaDto();
String expectedResponse = new String();
String expectedResponse = EXPECTED_RESPONSE;
Mockito
.when(archivesSearchExternalService.updateArchiveUnitsRules(Mockito.eq(ruleSearchCriteriaDto)))
......
......@@ -204,7 +204,7 @@ public class ArchiveInternalRestClient
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,
restTemplate.exchange(getUrl() + RestApi.MASS_UPDATE_UNITS_RULES, HttpMethod.POST,
request, String.class);
checkResponse(response);
return response.getBody();
......
......@@ -227,7 +227,7 @@ public class ArchiveSearchInternalController {
return jsonNode;
}
@PostMapping(RestApi.MASSUPDATEUNITSRULES)
@PostMapping(RestApi.MASS_UPDATE_UNITS_RULES)
public ResponseEntity<String> updateArchiveUnitsRules(
@RequestHeader(value = CommonConstants.X_TENANT_ID_HEADER) final Integer tenantId,
@RequestHeader(value = CommonConstants.X_ACCESS_CONTRACT_ID_HEADER) final String accessContractId,
......
......@@ -52,6 +52,7 @@ import fr.gouv.vitamui.archives.search.common.dto.VitamUiRuleCategoryAction;
import fr.gouv.vitamui.archives.search.common.dto.VitamUiRuleCategoryActionDeletion;
import fr.gouv.vitamui.commons.utils.VitamUIUtils;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
......@@ -65,10 +66,9 @@ import java.util.Map;
*/
@Getter
@Setter
@NoArgsConstructor
public class RuleOperationsConverter {
public RuleOperationsConverter() {
}
public ManagementMetadataAction convertToVitamManagementMetadataAction(
VitamUiManagementMetadataAction vitamUiManagementMetadataAction) {
......
......@@ -703,7 +703,7 @@ public class ArchiveSearchInternalService {
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JsonNode updateQuery = objectMapper.convertValue(massUpdateUnitRuleRequest, JsonNode.class);
LOGGER.info("Add Rules to UA final updateQuery : {}", updateQuery);
LOGGER.debug("Add Rules to UA final updateQuery : {}", updateQuery);
return massUpdateUnitsRules(vitamContext, updateQuery);
}
......
......@@ -31,6 +31,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import fr.gouv.vitam.common.PropertiesUtils;
import fr.gouv.vitam.common.database.builder.query.BooleanQuery;
import fr.gouv.vitam.common.database.builder.request.exception.InvalidCreateOperationException;
import fr.gouv.vitam.common.exception.InvalidParseOperationException;
import fr.gouv.vitam.common.json.JsonHandler;
import fr.gouv.vitamui.archives.search.common.common.ArchiveSearchConsts;
import fr.gouv.vitamui.archives.search.common.dto.CriteriaValue;
......@@ -38,6 +39,7 @@ import fr.gouv.vitamui.archives.search.common.dto.SearchCriteriaEltDto;
import fr.gouv.vitamui.commons.api.logger.VitamUILogger;
import fr.gouv.vitamui.commons.api.logger.VitamUILoggerFactory;
import fr.gouv.vitamui.commons.test.utils.ServerIdentityConfigurationBuilder;
import org.json.JSONException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
......@@ -47,6 +49,7 @@ import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
......@@ -444,6 +447,35 @@ public class ArchivesSearchAppraisalQueryBuilderServiceTest {
JsonNode expectedQuery =
JsonHandler.getFromFile(PropertiesUtils.findFile("data/queries/elimination_analysis_search.json"));
JSONAssert.assertEquals(expectedQuery.toPrettyString(), JsonHandler.getFromString(query.toString()).toPrettyString(), true);
}
@Test
public void testFillQueryFromCriteriaListWhenAppraisalMgtRulesHasStartDateForControlThenReturnTheExactQuery()
throws InvalidCreateOperationException, IOException {
//Given
List<SearchCriteriaEltDto> criteriaList = new ArrayList<>();
SearchCriteriaEltDto searchCriteriaEltDto = new SearchCriteriaEltDto();
searchCriteriaEltDto.setCriteria(ArchiveSearchConsts.APPRAISAL_RULE_START_DATE);
searchCriteriaEltDto.setCategory(ArchiveSearchConsts.CriteriaCategory.FIELDS);
searchCriteriaEltDto.setValues(List.of(new CriteriaValue("2021-11-08T23:00:00.000Z")));
searchCriteriaEltDto.setOperator(ArchiveSearchConsts.CriteriaOperators.EQ.name());
criteriaList.add(searchCriteriaEltDto);
//When
BooleanQuery query = and();
archivesSearchFieldsQueryBuilderService
.fillQueryFromCriteriaList(query, criteriaList);
//then
Assertions.assertFalse(query.getQueries().isEmpty());
Assertions.assertEquals(query.getQueries().size(), 1);
String queryStr = query.getQueries().toString();
LOGGER.info(queryStr);
String queryFileStr = loadFileContent("vitam_query_with_start_date.txt");
Assertions.assertEquals(queryStr.trim(), queryFileStr.trim());
}
private String loadFileContent(String filename) throws IOException {
......
[{"$or":[{"$eq":{"#management.AppraisalRule.Rules.StartDate":"2021-11-09"}}]}]
......@@ -205,7 +205,7 @@ public class ArchivesSearchController extends AbstractUiRestController {
}
@ApiOperation(value = "Update Archive Units Rules by criteria")
@PostMapping(RestApi.MASSUPDATEUNITSRULES)
@PostMapping(RestApi.MASS_UPDATE_UNITS_RULES)
@ResponseStatus(HttpStatus.OK)
public String updateArchiveUnitsRules(@RequestBody final RuleSearchCriteriaDto ruleSearchCriteriaDto) {
LOGGER.debug("Update Archive Units Rules with criteria {} ", ruleSearchCriteriaDto);
......
......@@ -53,7 +53,8 @@
>{{
(endDateInterval
? 'ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.FIELDS.END_DATE_DUA_BEGIN'
: 'ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.FIELDS.END_DATE_DUA_EQUAL') | translate
: 'ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.FIELDS.END_DATE_DUA_EQUAL'
) | translate
}}</span
>
<ng-template #showBeginDtDua
......
......@@ -111,7 +111,7 @@
"END_DATE_DUA_EQUAL": "Date de fin extrême",
"END_DATE_DUA_BEGIN": "Entre le ",
"END_DATE_DUA_END": "et le ",
"GUID_OPI": "GUID du versement",
"GUID_OPI": "Identifiant technique du versement",
"ORIGIN": {
"TITLE": "L'unité archivistique",
"INHERITE_AT_LEAST_ONE_APPRAISAL_RULE": "Hérite d'au moins une règle DUA",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment