Commit 4ce24e6e authored by couzinie's avatar couzinie
Browse files

Fix problem while importing twice a profile with nsName attribute

parent 3ea17089
......@@ -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);
}
});
}
......
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