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(
|
this._contextService.getCategories(this.selectedCommunityId,this.properties.contextsAPI).subscribe(
|
||||||
data => {
|
data => {
|
||||||
|
|
||||||
this.categories =data;// (Array.isArray(data.category))? data.category:[data.category];
|
this.categories =data;
|
||||||
this.concepts = [];
|
this.concepts = [];
|
||||||
this.addCommunityInConcepts();
|
this.addCommunityInConcepts();
|
||||||
this.filteredList = [];
|
this.filteredList = [];
|
||||||
|
@ -254,8 +254,9 @@ getCommunities () {
|
||||||
data => {
|
data => {
|
||||||
|
|
||||||
this.concepts =data;
|
this.concepts =data;
|
||||||
if(this.selectedCategoryId == "egi::classification"){
|
console.log(data);
|
||||||
for(var i =0 ; i<data.length; i++){
|
for(var i =0 ; i<data.length; i++){
|
||||||
|
if(data[i].hasSubConcept == true){
|
||||||
this.getSubConcepts(data[i].id);
|
this.getSubConcepts(data[i].id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,23 +332,16 @@ getCommunities () {
|
||||||
this.conceptsCategoryLoading[categoryId] = true;
|
this.conceptsCategoryLoading[categoryId] = true;
|
||||||
this._contextService.getConcepts(categoryId, "",false, this.properties.contextsAPI).subscribe(
|
this._contextService.getConcepts(categoryId, "",false, this.properties.contextsAPI).subscribe(
|
||||||
data => {
|
data => {
|
||||||
var concepts = data;//(Array.isArray(data))? data:[data];
|
var concepts = data;
|
||||||
if(categoryId == "egi::classification"){
|
|
||||||
this.conceptsClass[categoryId] = [];
|
this.conceptsClass[categoryId] = [];
|
||||||
for(var i =0 ; i<data.length; i++){
|
for(var i =0 ; i<data.length; i++){
|
||||||
|
if(data[i].hasSubConcept == true){
|
||||||
this.browseSubConcepts(categoryId, data[i].id);
|
this.browseSubConcepts(categoryId, data[i].id);
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
for(var i=0;i<concepts.length; i++){
|
this.conceptsClass[categoryId].push(data[i]);
|
||||||
console.log("Data"+concepts[i]);
|
|
||||||
if(concepts[i].id.split("::").length==3){
|
|
||||||
this.conceptsClass[categoryId].push(concepts[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this.conceptsClass[categoryId]);
|
|
||||||
this.conceptsCategoryLoading[categoryId] = false;
|
this.conceptsCategoryLoading[categoryId] = false;
|
||||||
}
|
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -362,7 +356,7 @@ getCommunities () {
|
||||||
this.conceptsCategoryLoading[categoryId] = true;
|
this.conceptsCategoryLoading[categoryId] = true;
|
||||||
this._contextService.getSubConcepts(conceptId, "",false, this.properties.contextsAPI).subscribe(
|
this._contextService.getSubConcepts(conceptId, "",false, this.properties.contextsAPI).subscribe(
|
||||||
data => {
|
data => {
|
||||||
var concepts = data[0];//(Array.isArray(data))? data:[data];
|
var concepts = data[0];
|
||||||
this.conceptsClass[categoryId].push(concepts)
|
this.conceptsClass[categoryId].push(concepts)
|
||||||
console.log("Data"+concepts);
|
console.log("Data"+concepts);
|
||||||
|
|
||||||
|
|
|
@ -68,38 +68,42 @@ export class ContextsService {
|
||||||
.map(res => (parsing)?this.parseSubConcepts(res):res);
|
.map(res => (parsing)?this.parseSubConcepts(res):res);
|
||||||
// .do(res => console.info("Result is "+ res.length ));
|
// .do(res => console.info("Result is "+ res.length ));
|
||||||
}
|
}
|
||||||
parse (data: any):AutoCompleteValue[] {
|
parse (data: any):any {
|
||||||
var array:AutoCompleteValue[] =[]
|
var array =[]
|
||||||
if(!Array.isArray(data) && data.id && data.label){
|
if(!Array.isArray(data) && data.id && data.label){
|
||||||
var value:AutoCompleteValue = new AutoCompleteValue();
|
var value ={id:"",label:"",hasSubConcept:""};
|
||||||
value.id = data.id;
|
value.id = data.id;
|
||||||
value.label = data.label;
|
value.label = data.label;
|
||||||
|
value.hasSubConcept = data.hasSubConcept;
|
||||||
array.push(value);
|
array.push(value);
|
||||||
}
|
}
|
||||||
for(var i = 0; i < data.length; i++){
|
for(var i = 0; i < data.length; i++){
|
||||||
var value:AutoCompleteValue = new AutoCompleteValue();
|
var value={id:"",label:"",hasSubConcept:""};
|
||||||
value.id = data[i].id;
|
value.id = data[i].id;
|
||||||
value.label = data[i].label;
|
value.label = data[i].label;
|
||||||
|
value.hasSubConcept = data[i].hasSubConcept;
|
||||||
array.push(value);
|
array.push(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
|
|
||||||
}
|
}
|
||||||
parseSubConcepts (data: any):AutoCompleteValue[] {
|
parseSubConcepts (data: any):any {
|
||||||
var array:AutoCompleteValue[] =[]
|
var array = []
|
||||||
if(data.length >0 && data[0].concepts){
|
if(data.length >0 && data[0].concepts){
|
||||||
var concepts = data[0].concepts;
|
var concepts = data[0].concepts;
|
||||||
for(var i = 0; i < concepts.length; i++){
|
for(var i = 0; i < concepts.length; i++){
|
||||||
var value:AutoCompleteValue = new AutoCompleteValue();
|
var value ={id:"",label:"",hasSubConcept:""};
|
||||||
value.id = concepts[i].id;
|
value.id = concepts[i].id;
|
||||||
value.label = concepts[i].label;
|
value.label = concepts[i].label;
|
||||||
|
value.hasSubConcept = concepts[i].hasSubConcept;
|
||||||
if(concepts[i].concepts){
|
if(concepts[i].concepts){
|
||||||
var subconcepts = concepts[i].concepts;
|
var subconcepts = concepts[i].concepts;
|
||||||
for(var x = 0; x < subconcepts.length; x++){
|
for(var x = 0; x < subconcepts.length; x++){
|
||||||
var value:AutoCompleteValue = new AutoCompleteValue();
|
var value ={id:"",label:"",hasSubConcept:""};
|
||||||
value.id = subconcepts[x].id;
|
value.id = subconcepts[x].id;
|
||||||
value.label = subconcepts[x].label;
|
value.label = subconcepts[x].label;
|
||||||
|
value.hasSubConcept = subconcepts[x].hasSubConcept;
|
||||||
array.push(value);
|
array.push(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue