Commit 1d88d322 authored by Passam KASSEM's avatar Passam KASSEM Committed by Ro3034
Browse files

[VAS] Item 8358 : Accession Register Facets implementation

parent c593da6d
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="2 - Security-Internal" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings"/>
<option name="myRunnerSettings"/>
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set/>
</option>
<option name="goals">
<list>
<option value="spring-boot:run"/>
<option value="-Pdev"/>
</list>
</option>
<option name="pomFileName"/>
<option name="profilesMap">
<map/>
</option>
<option name="resolveToWorkspace" value="false"/>
<option name="workingDirPath" value="$PROJECT_DIR$/api/api-security/security-internal"/>
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2"/>
</configuration>
</component>
<configuration default="false" name="2 - Security-Internal" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="spring-boot:run" />
</list>
</option>
<option name="pomFileName" />
<option name="profilesMap">
<map />
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/api/api-security/security-internal" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
</component>
\ No newline at end of file
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="3 - IAM-Internal" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings"/>
<option name="myRunnerSettings"/>
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set/>
</option>
<option name="goals">
<list>
<option value="spring-boot:run"/>
<option value="-Pdev"/>
</list>
</option>
<option name="pomFileName"/>
<option name="profilesMap">
<map/>
</option>
<option name="resolveToWorkspace" value="false"/>
<option name="workingDirPath" value="$PROJECT_DIR$/api/api-iam/iam-internal"/>
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2"/>
</configuration>
</component>
<configuration default="false" name="3 - IAM-Internal" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="spring-boot:run" />
</list>
</option>
<option name="pomFileName" />
<option name="profilesMap">
<map />
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/api/api-iam/iam-internal" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
</component>
\ No newline at end of file
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="4 - IAM-External" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings"/>
<option name="myRunnerSettings"/>
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set/>
</option>
<option name="goals">
<list>
<option value="spring-boot:run"/>
<option value="-Pdev"/>
</list>
</option>
<option name="pomFileName"/>
<option name="profilesMap">
<map/>
</option>
<option name="resolveToWorkspace" value="false"/>
<option name="workingDirPath" value="$PROJECT_DIR$/api/api-iam/iam-external"/>
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2"/>
</configuration>
</component>
<configuration default="false" name="4 - IAM-External" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="spring-boot:run" />
</list>
</option>
<option name="pomFileName" />
<option name="profilesMap">
<map />
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/api/api-iam/iam-external" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
</component>
\ No newline at end of file
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="6 - UI-Portal back" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings"/>
<option name="myRunnerSettings"/>
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set/>
</option>
<option name="goals">
<list>
<option value="spring-boot:run"/>
<option value="-Pdev"/>
</list>
</option>
<option name="pomFileName"/>
<option name="profilesMap">
<map/>
</option>
<option name="resolveToWorkspace" value="false"/>
<option name="workingDirPath" value="$PROJECT_DIR$/ui/ui-portal"/>
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2"/>
</configuration>
</component>
<configuration default="false" name="6 - UI-Portal back" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="spring-boot:run" />
</list>
</option>
<option name="pomFileName" />
<option name="profilesMap">
<map />
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/ui/ui-portal" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
</component>
\ No newline at end of file
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="7 - UI-Identity back" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings"/>
<option name="myRunnerSettings"/>
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set/>
</option>
<option name="goals">
<list>
<option value="spring-boot:run"/>
<option value="-Pdev"/>
</list>
</option>
<option name="pomFileName"/>
<option name="profilesMap">
<map/>
</option>
<option name="resolveToWorkspace" value="false"/>
<option name="workingDirPath" value="$PROJECT_DIR$/ui/ui-identity"/>
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2"/>
</configuration>
</component>
<configuration default="false" name="7 - UI-Identity back" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="spring-boot:run" />
</list>
</option>
<option name="pomFileName" />
<option name="profilesMap">
<map />
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/ui/ui-identity" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
</component>
\ No newline at end of file
......@@ -240,7 +240,7 @@
<executable>true</executable>
<attach>false</attach> <!-- Need to use the original jar for integration-tests -->
<mainClass>fr.gouv.vitamui.ingest.internal.server.ApiIngestInternalServerApplication</mainClass>
<jvmArguments>-Xmx512m</jvmArguments>
<jvmArguments>-Xmx512m -Dvitam.config.folder=${basedir}/src/main/resources/dev/vitam</jvmArguments>
<arguments>
<!-- use src/main/config/application-dev.yml when using mvn spring-boot:run -->
<!-- See : https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files -->
......
......@@ -36,17 +36,26 @@
*/
package fr.gouv.vitamui.referential.common.dsl;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.gouv.vitam.common.database.builder.query.BooleanQuery;
import fr.gouv.vitam.common.database.builder.query.CompareQuery;
import fr.gouv.vitam.common.database.builder.query.QueryHelper;
import fr.gouv.vitam.common.database.builder.request.exception.InvalidCreateOperationException;
import fr.gouv.vitam.common.database.builder.request.single.Select;
import fr.gouv.vitam.common.exception.InvalidParseOperationException;
import fr.gouv.vitamui.commons.api.domain.AccessionRegisterDetailsSearchStatsDto;
import fr.gouv.vitamui.commons.api.domain.DirectionDto;
import fr.gouv.vitamui.commons.api.logger.VitamUILogger;
import fr.gouv.vitamui.commons.api.logger.VitamUILoggerFactory;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -78,6 +87,11 @@ public class VitamQueryHelper {
private static final String EV_DATE_TIME_END = "evDateTime_End";
private static final String OPI = "Opi";
private static final String ORIGINATING_AGENCY = "OriginatingAgency";
private static final String START_DATE = "StartDate";
private VitamQueryHelper() {
throw new UnsupportedOperationException("Utility class");
}
/**
* create a valid VITAM DSL Query from a map of criteria
......@@ -168,6 +182,9 @@ public class VitamQueryHelper {
case EV_DATE_TIME_END:
query.add(lt("evDateTime", (String) entry.getValue()));
break;
case START_DATE:
addStartDateToQuery(query, entry.getValue());
break;
default:
LOGGER.error("Can not find binding for key: {}", searchKey);
break;
......@@ -187,6 +204,33 @@ public class VitamQueryHelper {
return select.getFinalSelect();
}
private static void addStartDateToQuery(BooleanQuery query, Object value) {
try {
ObjectMapper mapper = new ObjectMapper();
AccessionRegisterDetailsSearchStatsDto.DateInterval dateInterval = mapper.convertValue(value, new TypeReference<>() {});
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String dateMinStr = dateInterval.getStartDateMin();
String dateMaxStr = dateInterval.getStartDateMax();
if(dateMinStr != null && dateMaxStr == null) {
query.add(lte(START_DATE, formatter.parse(dateMinStr)));
}
if(dateMinStr == null && dateMaxStr != null) {
query.add(lte(START_DATE, formatter.parse(dateMaxStr)));
}
if(dateMinStr != null && dateMaxStr != null) {
query.add(range(START_DATE, formatter.parse(dateMinStr), true, formatter.parse(dateMaxStr), false));
}
} catch (InvalidCreateOperationException | ParseException e) {
LOGGER.error("Can not find binding for StartDate key: \n {}", e);
}
}
public static JsonNode getLastOperationQuery(String operationType) throws InvalidCreateOperationException, InvalidParseOperationException {
Select select = new Select();
......
/**
* 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.referential.common.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class AccessionRegisterStatsDto {
private long totalUnits;
private long totalObjectsGroups;
private long totalObjects;
private long objectSizes;
}
......@@ -36,9 +36,12 @@
*/
package fr.gouv.vitamui.referential.common.service;
import com.fasterxml.jackson.databind.JsonNode;
import fr.gouv.vitam.access.external.client.AdminExternalClient;
import fr.gouv.vitam.common.client.VitamContext;
import fr.gouv.vitam.common.database.builder.request.exception.InvalidCreateOperationException;
import fr.gouv.vitam.common.database.builder.request.single.Select;
import fr.gouv.vitam.common.exception.InvalidParseOperationException;
import fr.gouv.vitam.common.exception.VitamClientException;
import fr.gouv.vitam.common.model.RequestResponse;
import fr.gouv.vitam.common.model.administration.AccessionRegisterSummaryModel;
......@@ -62,4 +65,10 @@ public class AccessionRegisterService {
LOGGER.info("Accession Register EvIdAppSession : {} " , context.getApplicationSessionId());
return this.adminExternalClient.findAccessionRegister(context, new Select().getFinalSelect());
}
public RequestResponse<AccessionRegisterSummaryModel> findAccessionRegisterSummaryByQuery(VitamContext context, JsonNode query) throws VitamClientException {
LOGGER.debug("findAccessionRegisterSummary by query projections");
LOGGER.info("Accession Register Summary by projection query on wanted fields stats : {} " , context.getApplicationSessionId());
return this.adminExternalClient.findAccessionRegister(context, query);
}
}
......@@ -36,13 +36,19 @@
*/
package fr.gouv.vitamui.referential.external.client;
import fr.gouv.vitamui.commons.api.domain.AccessionRegisterDetailsSearchStatsDto;
import fr.gouv.vitamui.commons.api.domain.PaginatedValuesDto;
import fr.gouv.vitamui.commons.rest.client.BasePaginatingAndSortingRestClient;
import fr.gouv.vitamui.commons.rest.client.ExternalHttpContext;
import fr.gouv.vitamui.referential.common.dto.AccessionRegisterDetailDto;
import fr.gouv.vitamui.referential.common.dto.AccessionRegisterStatsDto;
import fr.gouv.vitamui.referential.common.rest.RestApi;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import java.util.List;
......@@ -74,4 +80,13 @@ public class AccessionRegisterDetailExternalRestClient extends
};
}
public AccessionRegisterStatsDto getAccessionRegisterDetailStats(ExternalHttpContext context, AccessionRegisterDetailsSearchStatsDto detailsSearchDto) {
final UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(getUrl() + "/stats");
final HttpEntity<AccessionRegisterDetailsSearchStatsDto> request = new HttpEntity<>(detailsSearchDto, buildHeaders(context));
final ResponseEntity<AccessionRegisterStatsDto> response = restTemplate
.exchange(uriBuilder.toUriString(), HttpMethod.POST, request, AccessionRegisterStatsDto.class);
checkResponse(response);
return response.getBody();
}
}
......@@ -36,6 +36,7 @@
*/
package fr.gouv.vitamui.referential.external.server.rest;
import fr.gouv.vitamui.commons.api.domain.AccessionRegisterDetailsSearchStatsDto;
import fr.gouv.vitamui.commons.api.domain.DirectionDto;
import fr.gouv.vitamui.commons.api.domain.PaginatedValuesDto;
import fr.gouv.vitamui.commons.api.domain.ServicesData;
......@@ -43,6 +44,7 @@ import fr.gouv.vitamui.commons.api.logger.VitamUILogger;
import fr.gouv.vitamui.commons.api.logger.VitamUILoggerFactory;
import fr.gouv.vitamui.commons.rest.util.RestUtils;
import fr.gouv.vitamui.referential.common.dto.AccessionRegisterDetailDto;
import fr.gouv.vitamui.referential.common.dto.AccessionRegisterStatsDto;
import fr.gouv.vitamui.referential.common.dto.AccessionRegisterSummaryDto;
import fr.gouv.vitamui.referential.common.rest.RestApi;
import fr.gouv.vitamui.referential.external.server.service.AccessionRegisterDetailExternalService;
......@@ -50,6 +52,8 @@ import fr.gouv.vitamui.referential.external.server.service.AccessionRegisterSumm
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -91,4 +95,11 @@ public class AccessionRegisterExternalController {
return accessionRegisterDetailExternalService.getAllPaginated(page, size, criteria, orderBy, direction);
}
@PostMapping("/details/stats")
@Secured(ServicesData.ROLE_GET_ACCESSION_REGISTER_DETAIL)
public AccessionRegisterStatsDto getAccessionRegisterDetailStats(@RequestBody
AccessionRegisterDetailsSearchStatsDto detailsSearchDto) {
return accessionRegisterDetailExternalService.getAccessionRegisterDetailStats(detailsSearchDto);
}
}
......@@ -37,6 +37,7 @@
package fr.gouv.vitamui.referential.external.server.service;
import fr.gouv.vitamui.commons.api.ParameterChecker;
import fr.gouv.vitamui.commons.api.domain.AccessionRegisterDetailsSearchStatsDto;
import fr.gouv.vitamui.commons.api.domain.DirectionDto;
import fr.gouv.vitamui.commons.api.domain.PaginatedValuesDto;
import fr.gouv.vitamui.commons.rest.client.BasePaginatingAndSortingRestClient;
......@@ -44,6 +45,7 @@ import fr.gouv.vitamui.commons.rest.client.InternalHttpContext;
import fr.gouv.vitamui.iam.security.client.AbstractResourceClientService;
import fr.gouv.vitamui.iam.security.service.ExternalSecurityService;
import fr.gouv.vitamui.referential.common.dto.AccessionRegisterDetailDto;
import fr.gouv.vitamui.referential.common.dto.AccessionRegisterStatsDto;
import fr.gouv.vitamui.referential.internal.client.AccessionRegisterDetailInternalRestClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -76,4 +78,9 @@ public class AccessionRegisterDetailExternalService extends
return accessionRegisterDetailInternalRestClient;
}
public AccessionRegisterStatsDto getAccessionRegisterDetailStats(
AccessionRegisterDetailsSearchStatsDto detailsSearchDto) {
return accessionRegisterDetailInternalRestClient.getAccessionRegisterDetailStats(getInternalHttpContext(), detailsSearchDto);
}
}
......@@ -36,13 +36,19 @@
*/
package fr.gouv.vitamui.referential.internal.client;
import fr.gouv.vitamui.commons.api.domain.AccessionRegisterDetailsSearchStatsDto;
import fr.gouv.vitamui.commons.api.domain.PaginatedValuesDto;
import fr.gouv.vitamui.commons.rest.client.BasePaginatingAndSortingRestClient;
import fr.gouv.vitamui.commons.rest.client.InternalHttpContext;
import fr.gouv.vitamui.referential.common.dto.AccessionRegisterDetailDto;
import fr.gouv.vitamui.referential.common.dto.AccessionRegisterStatsDto;
import fr.gouv.vitamui.referential.common.rest.RestApi;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import java.util.List;
......@@ -69,4 +75,13 @@ public class AccessionRegisterDetailInternalRestClient extends BasePaginatingAnd
return new ParameterizedTypeReference<>() { };
}
public AccessionRegisterStatsDto getAccessionRegisterDetailStats(InternalHttpContext context, AccessionRegisterDetailsSearchStatsDto detailsSearchDto) {
final UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(getUrl() + "/stats");
final HttpEntity<AccessionRegisterDetailsSearchStatsDto> request = new HttpEntity<>(detailsSearchDto, buildHeaders(context));
final ResponseEntity<AccessionRegisterStatsDto> response = restTemplate
.exchange(uriBuilder.toUriString(), HttpMethod.POST, request, AccessionRegisterStatsDto.class);