Claiming- Contexts: For the new context API, parse hasSubConcept field and check his value before request subconcepts
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@52319 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
e4bc0772aa
commit
2bca86e5eb
|
@ -224,7 +224,7 @@ getCommunities () {
|
|||
this._contextService.getCategories(this.selectedCommunityId,this.properties.contextsAPI).subscribe(
|
||||
data => {
|
||||
|
||||
this.categories =data;// (Array.isArray(data.category))? data.category:[data.category];
|
||||
this.categories =data;
|
||||
this.concepts = [];
|
||||
this.addCommunityInConcepts();
|
||||
this.filteredList = [];
|
||||
|
@ -254,8 +254,9 @@ getCommunities () {
|
|||
data => {
|
||||
|
||||
this.concepts =data;
|
||||
if(this.selectedCategoryId == "egi::classification"){
|
||||
console.log(data);
|
||||
for(var i =0 ; i<data.length; i++){
|
||||
if(data[i].hasSubConcept == true){
|
||||
this.getSubConcepts(data[i].id);
|
||||
}
|
||||
}
|
||||
|
@ -331,23 +332,16 @@ getCommunities () {
|
|||
this.conceptsCategoryLoading[categoryId] = true;
|
||||
this._contextService.getConcepts(categoryId, "",false, this.properties.contextsAPI).subscribe(
|
||||
data => {
|
||||
var concepts = data;//(Array.isArray(data))? data:[data];
|
||||
if(categoryId == "egi::classification"){
|
||||
var concepts = data;
|
||||
this.conceptsClass[categoryId] = [];
|
||||
for(var i =0 ; i<data.length; i++){
|
||||
if(data[i].hasSubConcept == true){
|
||||
this.browseSubConcepts(categoryId, data[i].id);
|
||||
}
|
||||
}else{
|
||||
for(var i=0;i<concepts.length; i++){
|
||||
console.log("Data"+concepts[i]);
|
||||
if(concepts[i].id.split("::").length==3){
|
||||
this.conceptsClass[categoryId].push(concepts[i]);
|
||||
this.conceptsClass[categoryId].push(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(this.conceptsClass[categoryId]);
|
||||
this.conceptsCategoryLoading[categoryId] = false;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
|
@ -362,7 +356,7 @@ getCommunities () {
|
|||
this.conceptsCategoryLoading[categoryId] = true;
|
||||
this._contextService.getSubConcepts(conceptId, "",false, this.properties.contextsAPI).subscribe(
|
||||
data => {
|
||||
var concepts = data[0];//(Array.isArray(data))? data:[data];
|
||||
var concepts = data[0];
|
||||
this.conceptsClass[categoryId].push(concepts)
|
||||
console.log("Data"+concepts);
|
||||
|
||||
|
|
|
@ -68,38 +68,42 @@ export class ContextsService {
|
|||
.map(res => (parsing)?this.parseSubConcepts(res):res);
|
||||
// .do(res => console.info("Result is "+ res.length ));
|
||||
}
|
||||
parse (data: any):AutoCompleteValue[] {
|
||||
var array:AutoCompleteValue[] =[]
|
||||
parse (data: any):any {
|
||||
var array =[]
|
||||
if(!Array.isArray(data) && data.id && data.label){
|
||||
var value:AutoCompleteValue = new AutoCompleteValue();
|
||||
var value ={id:"",label:"",hasSubConcept:""};
|
||||
value.id = data.id;
|
||||
value.label = data.label;
|
||||
value.hasSubConcept = data.hasSubConcept;
|
||||
array.push(value);
|
||||
}
|
||||
for(var i = 0; i < data.length; i++){
|
||||
var value:AutoCompleteValue = new AutoCompleteValue();
|
||||
var value={id:"",label:"",hasSubConcept:""};
|
||||
value.id = data[i].id;
|
||||
value.label = data[i].label;
|
||||
value.hasSubConcept = data[i].hasSubConcept;
|
||||
array.push(value);
|
||||
}
|
||||
|
||||
return array;
|
||||
|
||||
}
|
||||
parseSubConcepts (data: any):AutoCompleteValue[] {
|
||||
var array:AutoCompleteValue[] =[]
|
||||
parseSubConcepts (data: any):any {
|
||||
var array = []
|
||||
if(data.length >0 && data[0].concepts){
|
||||
var concepts = data[0].concepts;
|
||||
for(var i = 0; i < concepts.length; i++){
|
||||
var value:AutoCompleteValue = new AutoCompleteValue();
|
||||
var value ={id:"",label:"",hasSubConcept:""};
|
||||
value.id = concepts[i].id;
|
||||
value.label = concepts[i].label;
|
||||
value.hasSubConcept = concepts[i].hasSubConcept;
|
||||
if(concepts[i].concepts){
|
||||
var subconcepts = concepts[i].concepts;
|
||||
for(var x = 0; x < subconcepts.length; x++){
|
||||
var value:AutoCompleteValue = new AutoCompleteValue();
|
||||
var value ={id:"",label:"",hasSubConcept:""};
|
||||
value.id = subconcepts[x].id;
|
||||
value.label = subconcepts[x].label;
|
||||
value.hasSubConcept = subconcepts[x].hasSubConcept;
|
||||
array.push(value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue