[Trunk | Library]: (Bug Fix) parsingFunctions.class.ts: In 'parseContexts()' method, there may exist multiple categories.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56937 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-08-30 13:39:54 +00:00
parent b1110aca0d
commit 1bce72ccb4
1 changed files with 29 additions and 24 deletions

View File

@ -499,9 +499,9 @@ export class ParsingFunctions {
} }
parseContexts(_contexts: any): {"labelContext": string, "labelCategory": string, parseContexts(_contexts: any): {"labelContext": string, "labelCategory": string,
"labelConcept": string, inline:boolean}[] { "labelConcept": string, inline:boolean}[] {
let contexts = new Array<{"labelContext": string, "labelCategory": string, let contexts = new Array<{"labelContext": string, "labelCategory": string,
"labelConcept": string, inline:boolean}>(); "labelConcept": string, inline:boolean}>();
let position = 0; let position = 0;
let labels = ""; let labels = "";
@ -512,34 +512,39 @@ export class ParsingFunctions {
if(context.hasOwnProperty("type") && (context['type'] == "community" || context['type'] == "ri")) { if(context.hasOwnProperty("type") && (context['type'] == "community" || context['type'] == "ri")) {
if(context.hasOwnProperty("category")) { if(context.hasOwnProperty("category")) {
if(context['category'].hasOwnProperty("concept")) { let category;
let categoryConcept; let length2 = Array.isArray(context['category']) ? context['category'].length : 1;
let length1 = Array.isArray(context['category']['concept']) ? context['category']['concept'].length : 1; for (let z = 0; z < length2; z++) {
for(let j=0; j<length1; j++) { category = Array.isArray(context['category']) ? context['category'][z] : context['category'];
categoryConcept = Array.isArray(context['category']['concept']) ? context['category']['concept'][j] : context['category']['concept']; if (category.hasOwnProperty("concept")) {
let categoryConcept;
let length1 = Array.isArray(category['concept']) ? category['concept'].length : 1;
for (let j = 0; j < length1; j++) {
categoryConcept = Array.isArray(category['concept']) ? category['concept'][j] : category['concept'];
contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false }; contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
contexts[position]['labelContext'] = context.label;
contexts[position]['labelCategory'] = category.label;
contexts[position]['labelConcept'] = categoryConcept.label;
position++;
}
} else {
contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
contexts[position]['labelContext'] = context.label; contexts[position]['labelContext'] = context.label;
contexts[position]['labelCategory'] = context['category'].label; contexts[position]['labelCategory'] = category.label;
contexts[position]['labelConcept'] = categoryConcept.label; contexts[position]['labelConcept'] = null;
position++; position++;
} }
} else {
contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
contexts[position]['labelContext'] = context.label;
contexts[position]['labelCategory'] = context['category'].label;
contexts[position]['labelConcept'] = null;
position++;
} }
} else {
contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
contexts[position]['labelContext'] = context.label;
contexts[position]['labelCategory'] = null;
contexts[position]['labelConcept'] = null;
contexts[position]['new'] = false;
position++;
} }
} else {
contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
contexts[position]['labelContext'] = context.label;
contexts[position]['labelCategory'] = null;
contexts[position]['labelConcept'] = null;
contexts[position]['new'] = false;
position++;
} }
} }
return contexts; return contexts;