Skip to content

Commit 631295c

Browse files
committed
delete _defaut, clean _config, fusion
1 parent 6d7e17d commit 631295c

File tree

17 files changed

+160
-805
lines changed

17 files changed

+160
-805
lines changed

src/management/identities/jsonforms/_config/inetorgperson.local.ui.yml renamed to configs/identities/default/jsonforms/inetorgperson.local.ui.yml

File renamed without changes.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
type: Group
2+
label: Identité
3+
elements:
4+
- type: HorizontalLayout
5+
elements:
6+
- type: Control
7+
label: UID
8+
scope: "#/properties/uid"
9+
options:
10+
required: true
11+
- type: Control
12+
label: Nom
13+
scope: "#/properties/sn"
14+
options:
15+
required: true
16+
readOnly: true
17+
- type: Control
18+
label: Prénom
19+
scope: "#/properties/givenName"
20+
options:
21+
required: true
22+
readOnly: true
23+
- type: HorizontalLayout
24+
elements:
25+
- type: Control
26+
label: Adresse postale
27+
scope: "#/properties/postalAddress"
28+
options:
29+
readOnly: true
30+
- type: HorizontalLayout
31+
elements:
32+
- type: Control
33+
label: Email
34+
scope: "#/properties/mail"
35+
options:
36+
format: email
37+
- type: Control
38+
label: Mobile
39+
scope: "#/properties/mobile"
40+
- type: Control
41+
label: Téléphone
42+
scope: "#/properties/telephoneNumber"
43+
options:
44+
readOnly: true
45+
- type: HorizontalLayout
46+
elements:
47+
- type: Control
48+
label: Titre
49+
scope: "#/properties/title"
50+
options:
51+
format: email
52+
- type: Control
53+
label: Type de population
54+
scope: "#/properties/departmentNumber"
55+
options:
56+
required: false
57+
readOnly: true
58+
suggestion:
59+
- "adm"
60+
- "etd"
61+
- "esn"
62+
- type: HorizontalLayout
63+
elements:
64+
- type: Control
65+
label: Photo
66+
scope: "#/properties/jpegPhoto"
67+
options:
68+
format: file
69+
storage: picture

src/management/identities/jsonforms/_default/supannPerson.ui.yml renamed to configs/identities/default/jsonforms/supannPerson.ui.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ elements:
77
label: Civilité
88
scope: "#/properties/supanncivilite"
99
options:
10+
readOnly: true
1011
required: true
1112
suggestion:
1213
- M.
@@ -16,13 +17,15 @@ elements:
1617
label: supannNomdeNaissance
1718
scope: "#/properties/supannNomdeNaissance"
1819
options:
20+
readOnly: true
1921
required: false
2022
- type: Control
2123
label: supannOIDCDatedeNaissance
2224
scope: "#/properties/supannOIDCDatedeNaissance"
2325
options:
2426
format: date
2527
required: true
28+
readOnly: true
2629
dateFormat: "dd/MM/yyyy"
2730
- type: HorizontalLayout
2831
elements:
@@ -31,50 +34,59 @@ elements:
3134
scope: "#/properties/supannOIDCGenre"
3235
options:
3336
required: true
37+
readOnly: true
3438
- type: Control
3539
label: supannPrenomsEtatCivil
3640
scope: "#/properties/supannPrenomsEtatCivil"
3741
options:
3842
required: true
43+
readOnly: true
3944
- type: Control
4045
label: supannCodeINSEEPaysDeNaissance
4146
scope: "#/properties/supannCodeINSEEPaysDeNaissance"
4247
options:
4348
required: true
49+
readOnly: true
4450
- type: HorizontalLayout
4551
elements:
4652
- type: Control
4753
label: supannCodeINSEEVilleDeNaissance
4854
scope: "#/properties/supannCodeINSEEVilleDeNaissance"
4955
options:
5056
required: false
57+
readOnly: true
5158
- type: Control
5259
label: supannAutreMail
5360
scope: "#/properties/supannAutreMail"
5461
options:
5562
required: true
63+
readOnly: true
5664
- type: Control
5765
label: supannListeRouge
5866
scope: "#/properties/supannListeRouge"
5967
options:
6068
required: false
69+
readOnly: true
6170
- type: HorizontalLayout
6271
elements:
6372
- type: Control
6473
label: mailForwardingAddress
6574
scope: "#/properties/mailForwardingAddress"
6675
options:
6776
required: false
77+
readOnly: true
6878
- type: Control
6979
label: supannMailPerso
7080
scope: "#/properties/supannMailPerso"
7181
options:
7282
required: false
83+
readOnly: true
7384
- type: Control
7485
label: supannRoleGenerique
7586
scope: "#/properties/supannRoleGenerique"
7687
options:
7788
required: false
89+
readOnly: true
7890
- type: HorizontalLayout
7991
elements:
8092
- type: Control
@@ -83,6 +95,7 @@ elements:
8395
options:
8496
format: number
8597
required: false
98+
readOnly: true
8699
- type: Control
87100
label: supannParrainDN
88101
scope: "#/properties/supannParrainDN"
@@ -105,8 +118,10 @@ elements:
105118
scope: "#/properties/supannActivite"
106119
options:
107120
required: false
121+
readOnly: true
108122
- type: Control
109123
label: supannEmpDateFin
110124
scope: "#/properties/supannEmpDateFin"
111125
options:
112126
required: false
127+
readOnly: true

src/management/identities/validations/_config/supannPerson.yml renamed to configs/identities/default/validations/supannPerson.yml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,57 @@ properties:
4343
supannParrainDN:
4444
type: string
4545
description: Field corresponding to supannParrainDN
46+
supannActivite:
47+
type: string
48+
description: Field corresponding to supannActivite
49+
supannEmpDateFin:
50+
type: string
51+
description: Field corresponding to supannEmpDateFin
52+
supannEtablissement:
53+
type: string
54+
description: etablissement
4655
supannTypeEntiteAffectation:
56+
type: array
57+
items:
58+
type: string
59+
supannRefId:
4760
type: array
4861
items:
4962
type: string
63+
supannEtuAnneeInscription:
64+
type: string
65+
description: supannetuanneeinscription
5066
supannEntiteAffectation:
5167
type: array
5268
items:
5369
type: string
5470
supannEntiteAffectationPrincipale:
5571
type: string
5672
description: identifiant de l entité principale d affectation
57-
supannActivite:
73+
supannEtUid:
5874
type: string
59-
description: Field corresponding to supannActivite
60-
supannEmpDateFin:
75+
description: supannetuid
76+
supannEtuCursusAnnee:
6177
type: string
62-
description: Field corresponding to supannEmpDateFin
63-
supannEtablissement:
78+
description: supannetucursusannee
79+
supannEtuDiplome:
6480
type: string
65-
description: etablissement
81+
description: supannetudiplome
82+
supannCodeIne:
83+
type: string
84+
description: supanncodeine
85+
6686
required:
67-
- supanncivilite
87+
#- supanncivilite
6888
- supannAutreMail
6989
# - supannListeRouge
70-
- supannOIDCGenre
71-
- supannRessourceEtatDate
90+
#- supannOIDCGenre
91+
#- supannRessourceEtatDate
7292
# - supannCodeINSEEVilleDeNaissance
7393
# - supannMailPerso
7494
# - supannEntiteAffectationPrincipale
7595
#- supannCodeINSEEPaysDeNaissance
7696
- supannRefId
77-
- supannPrenomsEtatCivil
97+
#- supannPrenomsEtatCivil
7898
# - mailForwardingAddress
79-
- supannOIDCDatedeNaissance
99+
#- supannOIDCDatedeNaissance

src/management/identities/_schemas/_parts/inetOrgPerson.part.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@ export class inetOrgPerson extends Document {
4545
public uid: string;
4646

4747
@Prop({
48-
type: String,
49-
validate: [(employeeNumber: string) => /[A-Za-z0-9_-]+/.test(employeeNumber), 'EmployeeNumber invalide.'],
48+
type: Array,
49+
of: String,
50+
validate: [
51+
{
52+
validator: (employeeNumbers: string[]) => {
53+
console.log(employeeNumbers);
54+
employeeNumbers.every((employeeNumber) => /[A-Za-z0-9_-]+/.test(employeeNumber));
55+
},
56+
message: 'EmployeeNumber invalide.',
57+
},
58+
],
5059
})
51-
public employeeNumber: string;
60+
public employeeNumber: string[];
5261

5362
@Prop({ type: String, required: true })
5463
public employeeType: string;

src/management/identities/_schemas/identities.schema.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ export class Identities extends AbstractSchema {
4545
public customFields?: { [key: string]: MixedValue };
4646

4747
//pour les identités fusionnées ont met les deux identités sources
48-
@Prop({ type: Array, of: Types.ObjectId, required: true, default: [] })
49-
public srcFusionId: Types.ObjectId[];
48+
@Prop({ type: Types.ObjectId, required: false })
49+
public srcFusionId: Types.ObjectId;
5050

5151
//pour les identités qui on servit à une fusion on met la destination (la nouvelle identité fusionnée)
5252
@Prop({ type: Types.ObjectId, required: false })
5353
public destFusionId: Types.ObjectId;
54+
55+
@Prop({ type: String, required: false, default: null })
56+
public primaryEmployeeNumber: string;
5457
}
5558

5659
export const IdentitiesSchema = SchemaFactory.createForClass(Identities)

src/management/identities/identities.service.ts

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import { IdentityState } from './_enums/states.enum';
2222
import { Identities } from './_schemas/identities.schema';
2323
import { IdentitiesValidationService } from './validations/identities.validation.service';
2424
import { FactorydriveService } from '@the-software-compagny/nestjs_module_factorydrive';
25-
import { ApiBadRequestResponse } from "@nestjs/swagger";
26-
import { InitStatesEnum } from "~/management/identities/_enums/init-state.enum";
2725

2826
@Injectable()
2927
export class IdentitiesService extends AbstractServiceSchema {
@@ -346,7 +344,7 @@ export class IdentitiesService extends AbstractServiceSchema {
346344
const agg1 = [
347345
{
348346
$match: {
349-
lastSync: { $eq: null },
347+
state: { $ne: IdentityState.DONT_SYNC },
350348
destFusionId: { $eq: null },
351349
},
352350
},
@@ -373,6 +371,8 @@ export class IdentitiesService extends AbstractServiceSchema {
373371
cn: '$inetOrgPerson.cn',
374372
employeeNumber: '$inetOrgPerson.employeeNumber',
375373
departmentNumber: '$inetOrgPerson.departmentNumber',
374+
state: '$state',
375+
lastSync: '$lastSync',
376376
},
377377
},
378378
},
@@ -388,7 +388,7 @@ export class IdentitiesService extends AbstractServiceSchema {
388388
const agg2 = [
389389
{
390390
$match: {
391-
state: { $ne: IdentityState.SYNCED },
391+
state: { $ne: IdentityState.DONT_SYNC },
392392
destFusionId: { $eq: null },
393393
},
394394
},
@@ -405,6 +405,8 @@ export class IdentitiesService extends AbstractServiceSchema {
405405
cn: '$inetOrgPerson.cn',
406406
employeeNumber: '$inetOrgPerson.employeeNumber',
407407
departmentNumber: '$inetOrgPerson.departmentNumber',
408+
state: '$state',
409+
lastSync: '$lastSync',
408410
},
409411
},
410412
},
@@ -454,53 +456,40 @@ export class IdentitiesService extends AbstractServiceSchema {
454456
throw new BadRequestException('Id2 not found');
455457
}
456458
//test si une ou les deux entités ont deja été fusionnées
457-
const x = identity1.destFusionId
458459
if (identity1.destFusionId !== undefined && identity1.destFusionId !== null) {
459-
throw new BadRequestException('Id1 already fusionned');
460+
throw new BadRequestException('Id1 est déjà fusionnée');
460461
}
461462
if (identity2.destFusionId !== undefined && identity2.destFusionId !== null) {
462-
throw new BadRequestException('Id2 already fusionned');
463+
throw new BadRequestException('Id2 est déjà fusionnée');
463464
}
464-
const plainIdentity1 = toPlainAndCrush(identity1.toJSON(), {
465-
excludePrefixes: ['_id', 'fingerprint', 'metadata'],
466-
});
467-
const plainIdentity2 = toPlainAndCrush(identity2.toJSON(), {
468-
excludePrefixes: ['_id', 'fingerprint', 'metadata'],
469-
});
470-
const newObj: Partial<Identities> & any = construct({ ...plainIdentity2, ...plainIdentity1 });
471-
//const newIdentity = await this.create(newObj);
472-
newObj.inetOrgPerson.employeeType = 'FUSION';
473-
newObj.inetOrgPerson.employeeNumber =
474-
identity1.inetOrgPerson.employeeNumber + '/' + identity2.inetOrgPerson.employeeNumber;
475-
identity2.inetOrgPerson.departmentNumber.forEach((depN) => {
476-
newObj.inetOrgPerson.departmentNumber.push(depN);
477-
});
465+
//pour savoir qu elle est l'identité maitre seule celle-ci sera mise à jour par taiga
466+
identity1.primaryEmployeeNumber = identity1.inetOrgPerson.employeeNumber[0];
467+
468+
identity1.inetOrgPerson.employeeNumber = [
469+
...identity1.inetOrgPerson.employeeNumber,
470+
...identity2.inetOrgPerson.employeeNumber,
471+
];
478472
// si supann est present
479473
if (
480474
identity1.additionalFields.objectClasses.includes('supannPerson') &&
481475
identity2.additionalFields.objectClasses.includes('supannPerson')
482476
) {
483477
identity2.additionalFields.attributes.supannPerson.supannTypeEntiteAffectation.forEach((depN) => {
484-
newObj.additionalFields.attributes.supannPerson.supannTypeEntiteAffectation.push(depN);
478+
identity1.additionalFields.attributes.supannPerson.supannTypeEntiteAffectation.push(depN);
485479
});
486480
// supannRefId
487481
identity2.additionalFields.attributes.supannPerson.supannRefId.forEach((depN) => {
488-
newObj.additionalFields.attributes.supannPerson.supannRefId.push(depN);
482+
identity1.additionalFields.attributes.supannPerson.supannRefId.push(depN);
489483
});
490484
}
491-
newObj.state = IdentityState.TO_VALIDATE;
492-
newObj.srcFusionId = [identity1._id, identity2._id];
493-
const newIdentity = await this.create(newObj) as Identities;
494-
//MAJ identite1
495-
identity1.destFusionId = newIdentity._id;
496-
identity1.state = IdentityState.DONT_SYNC;
485+
identity1.state = IdentityState.TO_VALIDATE;
486+
identity1.srcFusionId = identity2._id;
487+
identity2.destFusionId = identity1._id;
488+
identity2.state = IdentityState.DONT_SYNC;
497489
// modification identité1
498490
super.update(identity1._id, identity1);
499-
//Maj Identity2
500-
identity2.destFusionId = newIdentity._id;
501-
identity2.state = IdentityState.DONT_SYNC;
502491
// modification identité1
503492
super.update(identity2._id, identity2);
504-
return newIdentity._id;
493+
return identity1._id;
505494
}
506495
}

0 commit comments

Comments
 (0)