Commit 537c09d9 authored by Baptiste Toulemonde's avatar Baptiste Toulemonde
Browse files

fixes

parent 94d8ca67
......@@ -211,6 +211,7 @@ customer-init:
app-name: PASTIS_APP
level:
roles:
- ROLE_GET_PASTIS
- ROLE_GET_ARCHIVE_PROFILES_UNIT
- ROLE_UPDATE_ARCHIVE_PROFILES_UNIT
- ROLE_CREATE_ARCHIVE_PROFILES_UNIT
......
......@@ -45,6 +45,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
import fr.gouv.vitamui.pastis.common.dto.ElementProperties;
import fr.gouv.vitamui.pastis.common.dto.PuaData;
import fr.gouv.vitamui.pastis.common.dto.pua.PuaMetadata;
import fr.gouv.vitamui.pastis.common.dto.pua.PuaMetadataDetails;
import fr.gouv.vitamui.pastis.common.dto.seda.SedaNode;
import org.json.JSONArray;
......@@ -395,6 +396,13 @@ public class PuaPastisValidator {
JSONObject grandChildrenOfRule = sortedJSON();
JSONObject propertiesRules = sortedJSON();
// add endDate by default cardinality 0-1
PuaMetadataDetails endDateDetails = new PuaMetadataDetails();
endDateDetails.setType("string");
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
grandChildrenOfRule.put("EndDate", new JSONObject(mapper.writeValueAsString(endDateDetails)));
PuaMetadataDetails ruleTypeMetadataDetails = new PuaMetadataDetails();
SedaNode sedaElement = getSedaMetadata(childElement.getName(), null);
......@@ -434,8 +442,8 @@ public class PuaPastisValidator {
putChildrenIntoRules(childrenOfRule, grandChildrenOfRule, propertiesRules, requiredChildren);
// 4. Convert to jsonobject via map and update its property
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new AfterburnerModule());
ObjectMapper mapper2 = new ObjectMapper();
mapper2.registerModule(new AfterburnerModule());
JSONObject ruleTypeMetadata = new JSONObject(ruleTypeMetadataMap);
ruleTypeMetadata.getJSONObject(childElement.getName()).put(PROPERTIES, propertiesRules);
putRequiredNonSpecialChildren(childElement, requiredNonSpecialChildren, ruleTypeMetadata, requiredChildren);
......@@ -444,7 +452,11 @@ public class PuaPastisValidator {
if(entry.getKey().equals("PreventInheritance") || entry.getKey().equals("PreventRulesId")) {
JSONObject inheritance = new JSONObject();
PuaMetadataDetails preventRulesId = new PuaMetadataDetails();
preventRulesId.setType("array");
if (entry.getKey().equals("PreventInheritance")) {
preventRulesId.setType("boolean");
} else {
preventRulesId.setType("array");
}
Optional<ElementProperties> elOpt =
childElement.getChildren()
.stream()
......@@ -454,6 +466,8 @@ public class PuaPastisValidator {
preventRulesId.setDescription(el.getDocumentation());
if (el.getCardinality().equals("0-1")) {
getMinAndMAxItems( el, preventRulesId);
} else if (el.getCardinality().equals("1")) {
getMinAndMAxItems( el, preventRulesId);
}
if (null != el.getPuaData()) {
if (null != el.getPuaData().getPattern()) {
......@@ -559,8 +573,12 @@ public class PuaPastisValidator {
JSONObject propretyOfItems = new JSONObject().put(TYPE, OBJECT);
propretyOfItems.put(ADDITIONAL_PROPERTIES, false);
propretyOfItems.put(PROPERTIES, grandChildrenOfRule);
if(requiredChildren.isEmpty()) {
if (requiredChildren.isEmpty()) {
childrenOfRule.put("maxItems", 1);
} else {
childrenOfRule.put("minItems", 1);
childrenOfRule.put("maxItems", 1);
propretyOfItems.put(REQUIRED, requiredChildren);
}
childrenOfRule.put("type", "array");
childrenOfRule.put(ITEMS, propretyOfItems);
......@@ -757,7 +775,10 @@ public class PuaPastisValidator {
json.getJSONObject(el.getName()).put(ITEMS, items);
json.getJSONObject(el.getName()).remove(ADDITIONAL_PROPERTIES);
json.getJSONObject(el.getName()).getJSONObject(ITEMS).put(PROPERTIES, new JSONObject(new PuaData()));
json.getJSONObject(el.getName()).getJSONObject(ITEMS).put(REQUIRED, puaMetadataDetails.getRequired());
if (null != puaMetadataDetails.getRequired() && !puaMetadataDetails.getRequired().isEmpty()) {
json.getJSONObject(el.getName()).getJSONObject(ITEMS).put(REQUIRED, puaMetadataDetails.getRequired());
}
getJSONObjectFromElement(el,
json.getJSONObject(el.getName()).getJSONObject(ITEMS).getJSONObject(PROPERTIES));
} else {
......@@ -852,7 +873,7 @@ public class PuaPastisValidator {
elementProperties.getChildren().forEach(child -> {
try {
SedaNode sedaElement = getSedaMetadata(child.getName(), elementProperties.getName());
if ((child.getCardinality().equals("1-N") && sedaElement.getCardinality().equals("0-N"))
if ((child.getCardinality().equals("1-N") && (sedaElement.getCardinality().equals("0-N") || sedaElement.getCardinality().equals("1-N")))
|| (child.getCardinality().equals("1") && !sedaElement.getCardinality().equals("1"))
|| sedaElement.getCardinality().equals("1")) {
setMetadataName(child);
......
......@@ -8,7 +8,7 @@
"lastUpdate": "2020-11-26T14:08:20.987",
"activationDate": "2016-12-10T00:00:00.000",
"deactivationDate": "2016-12-10T00:00:00.000",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"definitions\":{\"pattern-simple-date\":{\"type\":\"string\",\"pattern\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}\"},\"pattern-date\":{\"type\":\"string\",\"pattern\":\"^([0-8][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))$\"}},\"properties\":{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"properties\":{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"tenant": 8,
"version": 1,
"fields": [
......
......@@ -8,7 +8,7 @@
"lastUpdate": "2020-11-26T14:08:20.987",
"activationDate": "2016-12-10T00:00:00.000",
"deactivationDate": "2016-12-10T00:00:00.000",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"definitions\":{\"pattern-simple-date\":{\"type\":\"string\",\"pattern\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}\"},\"pattern-date\":{\"type\":\"string\",\"pattern\":\"^([0-8][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))$\"}},\"properties\":{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"properties\":{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"tenant": 8,
"version": 1,
"fields": [
......
......@@ -8,7 +8,7 @@
"lastUpdate": "2020-11-26T14:08:20.987",
"activationDate": "2016-12-10T00:00:00.000",
"deactivationDate": "2016-12-10T00:00:00.000",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"definitions\":{\"pattern-simple-date\":{\"type\":\"string\",\"pattern\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}\"},\"pattern-date\":{\"type\":\"string\",\"pattern\":\"^([0-8][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))$\"}},\"properties\":{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"properties\":{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"tenant": 8,
"version": 1,
"fields": [
......
......@@ -8,7 +8,7 @@
"lastUpdate": "2020-11-26T14:08:20.987",
"activationDate": "2016-12-10T00:00:00.000",
"deactivationDate": "2016-12-10T00:00:00.000",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"definitions\":{\"pattern-simple-date\":{\"type\":\"string\",\"pattern\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}\"},\"pattern-date\":{\"type\":\"string\",\"pattern\":\"^([0-8][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))$\"}},\"properties\":{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"properties\":{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"tenant": 8,
"version": 1,
"fields": [
......
......@@ -213,6 +213,7 @@ customer-init:
app-name: PASTIS_APP
level:
roles:
- ROL_GET_PASTIS
- ROLE_GET_ARCHIVE_PROFILES_UNIT
- ROLE_UPDATE_ARCHIVE_PROFILES_UNIT
- ROLE_CREATE_ARCHIVE_PROFILES_UNIT
......
......@@ -30,30 +30,21 @@ db.tenants.find({ "identifier": { $gte: 0 } }).forEach(function (tenant) {
},
{
"name": "ROLE_CREATE_ARCHIVE_PROFILES_UNIT"
},
{
"name": "ROLE_IMPORT_ARCHIVE_PROFILES_UNIT"
},
{
"name": "ROLE_DELETE_ARCHIVE_PROFILES_UNIT"
},
{
"name": "ROLE_CREATE_PASTIS"
},
{
"name": "ROLE_UPDATE_PASTIS"
"name": "ROLE_IMPORT_ARCHIVE_PROFILES_UNIT"
},
{
"name" : "ROLE_IMPORT_ARCHIVE_PROFILES_UNIT"
"name": "ROLE_DELETE_ARCHIVE_PROFILES_UNIT"
},
{
"name" : "ROLE_CREATE_ARCHIVE_PROFILES_UNIT"
"name": "ROLE_CREATE_PASTIS"
},
{
"name" : "ROLE_UPDATE_ARCHIVE_PROFILES_UNIT"
"name": "ROLE_UPDATE_PASTIS"
},
{
"name" : "ROLE_GET_ARCHIVE_PROFILES_UNIT"
"name": "ROLE_GET_PASTIS"
},
{
"name" : "ROLE_IMPORT_ARCHIVE_PROFILES"
......
......@@ -269,6 +269,10 @@ export class ProfileService implements OnDestroy {
return this.puaService.getOne(id, headers);
}
checkPuaProfile(profile: ArchivalProfileUnit, headers?: HttpHeaders): Observable<boolean> {
return this.puaService.check(profile, headers);
}
getPaProfile(id: string, headers?: HttpHeaders): Observable<Profile> {
return this.paService.getOne(id, headers);
}
......
......@@ -930,12 +930,12 @@ export class FileTreeMetadataComponent {
}
onDeleteControls() {
if (this.enumerationControl) {
this.clickedNode.puaData.enum = null;
this.clickedNode.sedaData.Enumeration = [];
if (this.clickedControl) {
this.clickedControl.puaData.enum = null;
this.clickedControl.sedaData.Enumeration = [];
}
if (this.expressionControl) {
this.clickedNode.puaData.pattern = null;
this.clickedControl.puaData.pattern = null;
}
this.resetContols();
}
......@@ -943,10 +943,10 @@ export class FileTreeMetadataComponent {
onSubmitControls() {
if (this.enumerationControl) {
if (this.clickedNode.puaData) {
this.clickedNode.puaData.enum = this.enumsControlSeleted;
if (this.clickedControl.puaData) {
this.clickedControl.puaData.enum = this.enumsControlSeleted;
} else {
this.clickedNode.puaData = {
this.clickedControl.puaData = {
enum: this.enumsControlSeleted
};
}
......
......@@ -140,7 +140,7 @@
<button mat-menu-item (click)="fileInput.click()">
<i class="vitamui-icon vitamui-icon-download"></i>
&nbsp;&nbsp;&nbsp;
<span class="text normal">Charger un profile</span>
<span class="text normal">{{'PROFILE.LIST_PROFILE.LOAD_PROFILE' | translate}}</span>
<input #fileInput (change)="updateProfileNotice(element, $event.target.files)" [uploader]="uploader" accept=".json, .rng" class="buttons"
ng2FileSelect style="display:none;" type="file"/>
</button>
......
......@@ -10,7 +10,7 @@
<div class="row">
<div class="col-10 form-control">
<vitamui-common-input [disabled]="editNotice" (change)="checkIdentifier(modePUA)" [(ngModel)]="notice.identifier" class="col-9 px-0"
placeholder="identifier" formControlName="identifier">
placeholder="{{ 'PROFILE.POP_UP_CREATION_NOTICE.IDENTIFIER' | translate }}" formControlName="identifier">
</vitamui-common-input>
</div>
</div>
......
......@@ -10,6 +10,7 @@ import { ProfileService } from '../../core/services/profile.service';
import { Notice } from '../../models/notice.model';
import {PastisDialogData} from '../../shared/pastis-dialog/classes/pastis-dialog-data';
import {PastisDialogDataCreate} from '../save-profile/save-profile.component';
import {ArchivalProfileUnit} from "../../models/archival-profile-unit";
interface Status {
......@@ -99,9 +100,8 @@ export class CreateNoticeComponent implements OnInit {
this.modePUA = true;
}
this.information = 'texte d\'information';
const identifierForm = [null, Validators.required];
this.form = this.formBuilder.group({
identifier: identifierForm,
identifier: [null, Validators.required],
intitule: [null, Validators.required],
selectedStatus: [null],
description: [null],
......@@ -159,13 +159,17 @@ export class CreateNoticeComponent implements OnInit {
if (this.notice.identifier.length !== 0) {
if(modePUA) {
this.profileService.getPuaProfile(this.notice.identifier).subscribe(
() => {
alert('Identifier already exists use another identifier');
this.validate = false;
}, () => {
this.validate = true;
this.checkIntitule();
const profile = {} as ArchivalProfileUnit;
profile.identifier = this.notice.identifier;
this.profileService.checkPuaProfile(profile).subscribe(
(response: boolean) => {
if (response) {
alert('Identifier already exists use another identifier');
this.validate = false;
} else {
this.validate = true;
this.checkIntitule();
}
}
);
}
......
......@@ -53,7 +53,7 @@
"TYPE": "Type",
"PROFILE_ARCHIVAGE": "Archival profile",
"PROFILE_UNITE_ARCHIVISTIQUE": "Archival Unit Profile",
"INTITULE": "Entitled",
"INTITULE": "Title",
"DESCRIPTION": "Description",
"PROFIL_ATTACHE": "Attached profile",
"PRESENCE_PROFIL_ATTACHE": "Presence of an attached profile",
......@@ -91,6 +91,7 @@
"AUTORISER_PRESENCE_METADONNEES": "Allow in the manifest the presence of metadata not declared in the PUA?",
"ENREGISTRER_ACTIF_INACTIF": "Would you like to save it in active or inactive state?",
"INTITULE": "Title",
"IDENTIFIER": "Identifier",
"DESCRIPTION" : "Description",
"CHOICE": {
"PROFIL_ACTIF": "Active Profile",
......@@ -231,6 +232,7 @@
"DERNIERES_MODIFICATIONS": "Latest changes"
},
"MODIFIER_PROFIL_TOOLTIP": "Modify the profile",
"LOAD_PROFILE": "Load a profile",
"PROFILE_PREVIEW": {
"MODIFICATION_SUCCESS": "The modification of the profile has been carried out successfully ",
"MODIFICATION_ERROR": "Failed to edit profile"
......
......@@ -91,6 +91,7 @@
"AUTORISER_PRESENCE_METADONNEES": "Autoriser dans le manifeste la présence de métadonnées non déclarées dans le PUA ?",
"ENREGISTRER_ACTIF_INACTIF": "Souhaitez-vous l'enregistrer en état actif ou inactif ?",
"INTITULE": "Intitulé",
"IDENTIFIER": "Identifiant",
"DESCRIPTION" : "Description",
"CHOICE": {
"PROFIL_ACTIF": "Profil actif",
......@@ -231,6 +232,7 @@
"DERNIERES_MODIFICATIONS": "Dernières modifications"
},
"MODIFIER_PROFIL_TOOLTIP": "Modifier le profil",
"LOAD_PROFILE": "Charger un profil",
"PROFILE_PREVIEW": {
"MODIFICATION_SUCCESS": "La modification du profil a bien été effectué",
"MODIFICATION_ERROR": "Echec de la modification du profil"
......
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