Skip to content
Snippets Groups Projects
Commit aa1ef32e authored by couzinie's avatar couzinie Committed by naji
Browse files

Fix problem while importing twice a profile with nsName attribute

parent d631aa1c
No related branches found
No related tags found
5 merge requests!58compare branch,!54Comparaison de merge vers vitam-ui,!53Comparaison de merge vers vitam-ui,!52Voir difference entre les deux verion,!41MAJ: compare to vitam-ui
......@@ -117,40 +117,42 @@ export class FileService implements OnDestroy {
Array.prototype.forEach.call(nodes, (node: FileNode) => {
node.parent = parent;
let nodeName : string = (node.name === 'xml:id') ? 'id' : node.name;
let sedaDataMatch: SedaData;
if (nodeName) {
let sedaDataMatch: SedaData;
// Si le node en cours est une ArchiveUnit, lui même enfant d'une ArchiveUnit...
if (nodeName === 'ArchiveUnit' && this.sedaDataArchiveUnit != undefined) {
// Alors on utilise la définition SEDA de l'ArchiveUnit mère..
sedaDataMatch = this.sedaDataArchiveUnit;
} else {
// Sinon on recherche la définition SEDA dans l'arbre
sedaDataMatch = sedaData.find(seda => seda.Name === nodeName);
//sedaDataMatch = this.sedaService.getSedaNodeRecursively(sedaData[0],nodeName)
}
if (!sedaDataMatch){
// Sometimes,the sedaData has no property children, but many siblings (e.g. elements on the same level of the tree)
// In this case, the recursivity must be used on each symbling since the service getSedaNodeRecursively
// expects a tree root element with Children key
for (const element of sedaData) {
let resultRecursity = this.sedaService.getSedaNodeRecursively(element,nodeName);
if (resultRecursity) {
sedaDataMatch = resultRecursity;
break;
// Si le node en cours est une ArchiveUnit, lui même enfant d'une ArchiveUnit...
if (nodeName === 'ArchiveUnit' && this.sedaDataArchiveUnit != undefined) {
// Alors on utilise la définition SEDA de l'ArchiveUnit mère..
sedaDataMatch = this.sedaDataArchiveUnit;
} else {
// Sinon on recherche la définition SEDA dans l'arbre
sedaDataMatch = sedaData.find(seda => seda.Name === nodeName);
//sedaDataMatch = this.sedaService.getSedaNodeRecursively(sedaData[0],nodeName)
}
if (!sedaDataMatch){
// Sometimes,the sedaData has no property children, but many siblings (e.g. elements on the same level of the tree)
// In this case, the recursivity must be used on each symbling since the service getSedaNodeRecursively
// expects a tree root element with Children key
for (const element of sedaData) {
let resultRecursity = this.sedaService.getSedaNodeRecursively(element,nodeName);
if (resultRecursity) {
sedaDataMatch = resultRecursity;
break;
}
}
} else {
// Si le node en cours est l'achive ArchiveUnit mère, on la sauvegarde pour l'utiliser pour les ArchivesUnit enfants
if (sedaDataMatch.Name === 'ArchiveUnit' && this.sedaDataArchiveUnit == undefined){
this.sedaDataArchiveUnit = sedaDataMatch;
// On introduit la récursivité sur les ArchivesUnit
this.sedaDataArchiveUnit.Children.find((c: { Name: string; })=>c.Name=='ArchiveUnit').Children = this.sedaDataArchiveUnit.Children;
}
}
} else {
// Si le node en cours est l'achive ArchiveUnit mère, on la sauvegarde pour l'utiliser pour les ArchivesUnit enfants
if (sedaDataMatch.Name === 'ArchiveUnit' && this.sedaDataArchiveUnit == undefined){
this.sedaDataArchiveUnit = sedaDataMatch;
// On introduit la récursivité sur les ArchivesUnit
this.sedaDataArchiveUnit.Children.find((c: { Name: string; })=>c.Name=='ArchiveUnit').Children = this.sedaDataArchiveUnit.Children;
node.sedaData = sedaDataMatch;
if (node.children.length > 0){
this.linkFileNodeToSedaData(node, node.children,node.sedaData.Children);
}
}
node.sedaData = sedaDataMatch;
if (node.children.length > 0){
this.linkFileNodeToSedaData(node, node.children,node.sedaData.Children);
}
});
}
......
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