add fos/sdg in advanced search, add autocomplete methods, add initial json files
This commit is contained in:
parent
77092a7e66
commit
95b56039e4
|
@ -19,7 +19,7 @@ export class SearchFields {
|
|||
"resultbestaccessright", "community", "collectedfromdatasourceid", "resulthostingdatasourceid", "resultdateofacceptance",
|
||||
"relfunder",
|
||||
"relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id",
|
||||
"resultlanguagename", "relorganizationid", "pid", "relprojectid", "instancetypename"];
|
||||
"resultlanguagename", "relorganizationid", "pid", "relprojectid", "instancetypename", "fos", "sdg"];
|
||||
public RESULT_FIELDS: { [key: string]: FieldDetails } = {
|
||||
["q"]: {name: "All fields", type: "keyword", param: "q", operator: "op", equalityOperator: "=", filterType: null},
|
||||
["resulttitle"]: {
|
||||
|
@ -233,7 +233,7 @@ export class SearchFields {
|
|||
},
|
||||
["sdg"]: {
|
||||
name: "SDG",
|
||||
type: "refine",
|
||||
type: "vocabulary",
|
||||
param: "sdg",
|
||||
operator: "sg",
|
||||
equalityOperator: " exact ",
|
||||
|
@ -241,7 +241,7 @@ export class SearchFields {
|
|||
},
|
||||
["fos"]: {
|
||||
name: "Field of Science",
|
||||
type: "refine",
|
||||
type: "vocabulary",
|
||||
param: "fos",
|
||||
operator: "fs",
|
||||
equalityOperator: " exact ",
|
||||
|
|
|
@ -78,6 +78,12 @@ export class ISVocabulariesService {
|
|||
//return this.getVocabularyFromService(vocabulary, properties);
|
||||
return from(this.getVocabularyFromServiceAsync(vocabulary, properties));
|
||||
|
||||
} else if (field == "fos") {
|
||||
vocabulary = "fos";
|
||||
return from(this.getVocabularyFromServiceAsync(vocabulary, properties));
|
||||
} else if (field == "sdg") {
|
||||
vocabulary = "sdg";
|
||||
return from(this.getVocabularyFromServiceAsync(vocabulary, properties));
|
||||
}
|
||||
return null;
|
||||
|
||||
|
@ -106,6 +112,9 @@ export class ISVocabulariesService {
|
|||
|
||||
getVocabularyFromService(vocabularyName: string, properties: EnvProperties): Observable<AutoCompleteValue[]> {
|
||||
let url = properties.vocabulariesAPI + vocabularyName;
|
||||
if(vocabularyName == 'fos' || vocabularyName == 'sdg'){
|
||||
return this.getLocalVocabularyFromService(vocabularyName, properties);
|
||||
}
|
||||
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['terms']))
|
||||
|
@ -114,6 +123,57 @@ export class ISVocabulariesService {
|
|||
|
||||
}
|
||||
|
||||
getLocalVocabularyFromService(vocabularyName: string, properties: EnvProperties): Observable<AutoCompleteValue[]> {
|
||||
if(vocabularyName == "sdg"){
|
||||
let url = "/assets/vocabulary/sdg.json";
|
||||
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['sdg']))
|
||||
.pipe(map(res => this.parseSDGs(res)))
|
||||
.pipe(catchError(this.handleError));
|
||||
}else if( vocabularyName == "fos"){
|
||||
let url = "/assets/vocabulary/fos.json";
|
||||
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['fos']))
|
||||
.pipe(map(res => this.parseFOS(res)))
|
||||
.pipe(catchError(this.handleError));
|
||||
}
|
||||
}
|
||||
|
||||
parseSDGs(data: any): AutoCompleteValue[] {
|
||||
var array: AutoCompleteValue[] = []
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var value: AutoCompleteValue = new AutoCompleteValue();
|
||||
value.id = data[i].id;//data[i].code;
|
||||
value.label = data[i].label;
|
||||
array.push(value);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
parseFOS(data: any): AutoCompleteValue[] {
|
||||
let array: AutoCompleteValue[] = []
|
||||
for (let fos of data) {
|
||||
let value: AutoCompleteValue = new AutoCompleteValue();
|
||||
value.id = fos.id;//data[i].code;
|
||||
value.label = fos.label;
|
||||
array.push(value);
|
||||
for (let fos2 of fos.children) {
|
||||
let value: AutoCompleteValue = new AutoCompleteValue();
|
||||
value.id = fos2.id;//data[i].code;
|
||||
value.label = fos2.label;
|
||||
array.push(value);
|
||||
for (let fos3 of fos2.children) {
|
||||
let value: AutoCompleteValue = new AutoCompleteValue();
|
||||
value.id = fos3.id;//data[i].code;
|
||||
value.label = fos3.label;
|
||||
array.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
parse(data: any, vocabularyName: string): AutoCompleteValue[] {
|
||||
var array: AutoCompleteValue[] = []
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
|
|
Loading…
Reference in New Issue