Skip to content

Commit

Permalink
[VAS] Story 8084: mutualisation model
Browse files Browse the repository at this point in the history
  • Loading branch information
laedanrex committed Aug 17, 2023
1 parent fb3dc87 commit 66128d3
Show file tree
Hide file tree
Showing 136 changed files with 1,099 additions and 1,542 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
import fr.gouv.vitamui.archives.search.common.dto.UnitDescriptiveMetadataDto;
import fr.gouv.vitamui.archives.search.common.dto.VitamUIArchiveUnitResponseDto;
import fr.gouv.vitamui.commons.api.domain.AgencyModelDto;
import fr.gouv.vitamui.commons.api.dtos.VitamUiOntologyDto;
import fr.gouv.vitamui.commons.api.dtos.SearchCriteriaDto;
import fr.gouv.vitamui.commons.api.dtos.VitamUiOntologyDto;
import fr.gouv.vitamui.commons.api.exception.BadRequestException;
import fr.gouv.vitamui.commons.api.exception.InternalServerException;
import fr.gouv.vitamui.commons.api.exception.UnexpectedDataException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,13 @@ public enum CriteriaOperators {
public static final String PRODUCER_SERVICE = "#originating_agency";
public static final String GUID = "#id";
public static final String ALL_UNIT_UPS = "#allunitups";
public static final String UNIT_UPS = "#unitups";
public static final String TITLE_OR_DESCRIPTION = "TITLE_OR_DESCRIPTION";
public static final String ELIMINATION_TECHNICAL_ID_APPRAISAL_RULE = "ELIMINATION_TECHNICAL_ID_APPRAISAL_RULE";
public static final String ELIMINATION_GUID = "#elimination.OperationId";
public static final String ALL_ARCHIVE_UNIT_TYPES = "#unitType";
public static final String ALL_ARCHIVE_UNIT_TYPES_CRITERIA = "ALL_ARCHIVE_UNIT_TYPES";
public static final String ORPHANS_NODE_CRITERIA = "ORPHANS_NODE";
public static final String DESCRIPTION_LEVEL_CRITERIA = "DESCRIPTION_LEVEL";
public static final String DESCRIPTION_LEVEL = "DescriptionLevel";
public static final String ARCHIVE_UNIT_OBJECTS = "#object";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.CriteriaCategory.NODES;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.CriteriaCategory.REUSE_RULE;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.CriteriaOperators.EQ;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.CriteriaOperators.MISSING;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.DEFAULT_DEPTH;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.FACETS_COMPUTE_RULES_AU_NUMBER;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.FACETS_COUNT_BY_NODE;
Expand Down Expand Up @@ -1045,6 +1046,9 @@ public static void fillQueryFromCriteriaList(BooleanQuery queryToFill, List<Sear
searchCriteria.getValues().stream().map(CriteriaValue::getValue).collect(
Collectors.toList())));
break;
case ArchiveSearchConsts.ORPHANS_NODE_CRITERIA:
queryToFill.add(buildOrphansNodeQuery());
break;

case ArchiveSearchConsts.DESCRIPTION_LEVEL_CRITERIA:
queryToFill.add(buildArchiveUnitDescriptionLevelQuery(
Expand Down Expand Up @@ -1182,6 +1186,11 @@ private static Query buildStartDateEndDateQuery(String searchCriteria, final Lis
return subQueryAnd;
}

private static Query buildOrphansNodeQuery()
throws InvalidCreateOperationException {
return and().add(VitamQueryHelper.buildSubQueryByOperator(ArchiveSearchConsts.UNIT_UPS, null, MISSING));
}

private static Query buildArchiveUnitTypeQuery(final List<String> searchValues)
throws InvalidCreateOperationException {
BooleanQuery subQueryAnd = and();
Expand Down Expand Up @@ -1275,8 +1284,10 @@ public static void handleSimpleFieldCriteria(BooleanQuery queryToFill, SearchCri
SIMPLE_FIELDS_VALUES_MAPPING.get(searchCriteria.getCriteria()) :
searchCriteria.getCriteria();

List<String> stringValues = searchCriteria.getValues().stream().map(CriteriaValue::getValue)
.collect(Collectors.toList());
List<String> stringValues =
searchCriteria.getValues().stream().filter(Objects::nonNull)
.map(CriteriaValue::getValue).filter(Objects::nonNull)
.collect(Collectors.toList());
if (isADateToReplace(searchCriteria)) {
String stringDate = searchCriteria.getValues().get(0).getValue();
LocalDateTime date = LocalDateTime.parse(stringDate, ArchiveSearchConsts.ISO_FRENCH_FORMATER);
Expand Down
2 changes: 1 addition & 1 deletion ui/ui-frontend-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui-frontend-common",
"version": "2.1.57",
"version": "2.1.58",
"main": "src/index.ts",
"pki": {
"path": "../../dev-deployment/environments/certs/server/hosts/localhost",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,5 @@
* 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.
*/
export * from './node.interface';
export * from './node.utils';
export * from './vitamui-tree-node.component';
export * from './vitamui-tree-node.module';
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* accept its terms.
*/
import { AfterContentChecked, ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { FilingHoldingSchemeNode } from './node.interface';
import { FilingHoldingSchemeNode } from '../../models/nodes';

@Component({
selector: 'vitamui-tree-node',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,9 @@
* 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.
*/

import { Id } from 'ui-frontend-common';
import { CriteriaValue } from './search.criteria';

export interface SearchCriteriaHistory extends Id {
name: string;
userId?: string;
savingDate: string;
searchCriteriaList: SearchCriteriaEltements[];
}

export interface SearchCriteriaEltements {
criteria: string;
operator: string;
keyTranslated: boolean;
valueTranslated: boolean;
values: CriteriaValue[];
category: string;
dataType: string;
}
export * from './criteria.enums';
export * from './criteria.interface';
export * from './criterion.interface';
export * from './search-criteria-history.interface';
export * from './search-criteria.interface';
export * from './search-response.interface';
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
* knowledge of the CeCILL-C license and that you accept its terms.
*/

import { Id } from 'ui-frontend-common';
import { CriteriaValue } from './search.criteria';
import { Id } from '../id.interface';
import { CriteriaValue } from './search-criteria.interface';

export interface SearchCriteriaHistory extends Id {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* 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.
*/

export enum SearchCriteriaStatusEnum {
NOT_INCLUDED = 'NOT_INCLUDED',
INCLUDED = 'INCLUDED',
Expand Down Expand Up @@ -105,6 +106,7 @@ export interface SearchCriteriaEltDto {
values: CriteriaValue[];
dataType: string;
}

export interface SearchCriteriaDto {
criteriaList: SearchCriteriaEltDto[];
pageNumber: number;
Expand All @@ -126,10 +128,12 @@ export interface ResultFacetList {
name: string;
buckets: ResultBucket[];
}

export interface ResultBucket {
value: string;
count: number;
}

export interface ResultFacet {
node: string;
count: number;
Expand All @@ -144,9 +148,11 @@ export interface SearchCriteriaCategory {
name: string;
index: number;
}

export interface CriteriaValue {
id: string;
value?: string;
label?: string;
beginInterval?: string;
endInterval?: string;
}
Expand All @@ -165,8 +171,8 @@ export class ArchiveSearchResultFacets {
export class RuleFacets {
waitingToRecalculateRulesListFacets: ResultFacet[];
expiredRulesListFacets: ResultFacet[];
unexpiredRulesListFacets: ResultFacet[];
rulesListFacets: ResultFacet[];
finalActionsFacets?: ResultFacet[];
noRulesFacets: ResultFacet[];
unexpiredRulesListFacets: ResultFacet[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,10 @@
* knowledge of the CeCILL-C license and that you accept its terms.
*/

import { Id } from 'ui-frontend-common';
import { CriteriaValue } from './search.criteria';
import { Unit } from '../units';

export interface SearchCriteriaHistory extends Id {
name: string;
userId?: string;
savingDate: string;
searchCriteriaList: SearchCriteriaEltements[];
}

export interface SearchCriteriaEltements {
criteria: string;
operator: string;
keyTranslated: boolean;
valueTranslated: boolean;
values: CriteriaValue[];
category: string;
dataType: string;
export interface SearchResponse<T = Unit> {
$hits: any;
$results: T[];
$facetResults?: any[];
}
5 changes: 2 additions & 3 deletions ui/ui-frontend-common/src/app/modules/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@ export * from './application/index';
export * from './breadcrumb/breadcrumb.interface';
export * from './collect/index';
export * from './content-disposition.enum';
export * from './criteria/criteria.enums';
export * from './criteria/criteria.interface';
export * from './criteria/criterion.interface';
export * from './criteria/index';
export * from './customer/index';
export * from './externalparamprofile/index';
export * from './group/index';
export * from './id.interface';
export * from './ingest-contract/index';
export * from './logbook/index';
export * from './managementContract/index';
export * from './nodes/index';
export * from './ontology/index';
export * from './operation/index';
export * from './position/index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
* 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 { DescriptionLevel, FilingHoldingSchemeNode, MatchingNodesNumbers, Unit } from 'ui-frontend-common';
import { ResultFacet } from '../models/search.criteria';
import { DescriptionLevel } from '../../description-level.enum';
import { ResultFacet } from '../criteria';
import { Unit } from '../units';
import { FilingHoldingSchemeHandler } from './filing-holding-scheme.handler';
import { FilingHoldingSchemeNode, MatchingNodesNumbers } from './node.interface';

export function newNode(
currentId: string,
Expand Down Expand Up @@ -336,12 +338,12 @@ describe('FilingHoldingSchemeHandler', () => {
});
describe('filterUnknownFacets', () => {
it('should return an empty array if the newFacets array is full of already known facets', () => {
const oldFacets: ResultFacet[] = [{ node: 'node-0', count: 1 }, { node: 'node-1', count: 65 },];
const newFacets: ResultFacet[] = [{ node: 'node-0', count: 5 }, { node: 'node-1', count: 42 },];
const oldFacets: ResultFacet[] = [{ node: 'node-0', count: 1 }, { node: 'node-1', count: 65 }, ];
const newFacets: ResultFacet[] = [{ node: 'node-0', count: 5 }, { node: 'node-1', count: 42 }, ];
expect(FilingHoldingSchemeHandler.filterUnknownFacets(oldFacets, newFacets)).toEqual([]);
});
it('should return all the facets in the newFacets array if there are no known facets', () => {
const oldFacets: ResultFacet[] = [{ node: 'node-0', count: 1 }, { node: 'node-1', count: 65 },];
const oldFacets: ResultFacet[] = [{ node: 'node-0', count: 1 }, { node: 'node-1', count: 65 }, ];
const newFacets = [{ node: 'node-2', count: 5 }];
expect(FilingHoldingSchemeHandler.filterUnknownFacets(oldFacets, newFacets)).toEqual(newFacets);
});
Expand All @@ -351,7 +353,7 @@ describe('FilingHoldingSchemeHandler', () => {
expect(FilingHoldingSchemeHandler.filterUnknownFacets(oldFacets, newFacets)).toEqual(newFacets);
});
it('should return an empty array if the newFacets array is empty', () => {
const oldFacets: ResultFacet[] = [{ node: 'node-0', count: 1 }, { node: 'node-1', count: 65 },];
const oldFacets: ResultFacet[] = [{ node: 'node-0', count: 1 }, { node: 'node-1', count: 65 }, ];
const newFacets: ResultFacet[] = [];
expect(FilingHoldingSchemeHandler.filterUnknownFacets(oldFacets, newFacets)).toEqual([]);
});
Expand All @@ -366,12 +368,12 @@ describe('FilingHoldingSchemeHandler', () => {
});
it('should return all the facets in the facets array if there are no known nodes', () => {
const nodes: FilingHoldingSchemeNode[] = [];
const facets: ResultFacet[] = [newResultFacet('node-1'), newResultFacet('node-2'),];
const facets: ResultFacet[] = [newResultFacet('node-1'), newResultFacet('node-2'), ];
const unknownFacets: ResultFacet[] = FilingHoldingSchemeHandler.filterUnknownFacetsIds(nodes, facets);
expect(unknownFacets).toEqual(facets);
});
it('should return only the facets in the facets array that have nodes that are not in the knownNodes array', () => {
const unknowFacet = newResultFacet('node-2')
const unknowFacet = newResultFacet('node-2');
const nodes: FilingHoldingSchemeNode[] = [newNode('node-1')];
const facets: ResultFacet[] = [newResultFacet('node-1'), unknowFacet];
const unknownFacets: ResultFacet[] = FilingHoldingSchemeHandler.filterUnknownFacetsIds(nodes, facets);
Expand Down Expand Up @@ -442,7 +444,7 @@ describe('FilingHoldingSchemeHandler', () => {
});
it('should return the sum of the counts of all the nodes in the array if the array is not empty', () => {
const nodes: FilingHoldingSchemeNode[] = [
newTreeNode('node-1', 1, [newTreeNode('node-1-1', 1), newTreeNode('node-1-2', 1),]),
newTreeNode('node-1', 1, [newTreeNode('node-1-1', 1), newTreeNode('node-1-2', 1), ]),
newTreeNode('node-2', 2),
newTreeNode('node-3', 3),
newTreeNode('node-4', 1),
Expand Down
Loading

0 comments on commit 66128d3

Please sign in to comment.