[new-search-json | WIP | CHANGED]: Updated parsing according to new json schema.
1. dataProvider.service.ts: Parse jurisdiction (label instead of classname) according to new schema. 2. organization/deletedByInference/deletedByInference.service.ts & result/deletedByInference/deletedByInference.service.ts: Not used - added @deprecated annotation to methods "getDeletedByInferenceResults()" and "parseDeletedByInferenceResults()". 3. project.service.ts: Added @deprecated annotation to method "getHTMLInfo()". 4. result/deletedByInference/deletedByInference.component.ts: Updated parsing of versions (previously children, now links with relations "merges") according to new json schema. 5. resultLanding.component.html: In <deletedByInference> updated parameter [id]="resultLandingInfo.record['header']['id']". 6. resultLanding.service.ts: Exclude relation "merges" from the related research. 7. organization.service.ts: Updated parsing according to new json schema for methods "getOrganizationNameAndUrlById()" and "parseOrganizationNameAndUrl()". 8. searchDataproviders.service.ts: Updated parsing of "eosctype" field and added TODO comment to check if parsing is correct. 9. searchOrganizations.service.ts: Added @deprecated annotation to method "parseResultsForDeposit()". 10. searchProjects.service.ts: Removed a console.log. 11. entitiesAutoComplete.component.ts: Commented @Input() public depositType:string and everything related to it. 12. entitySearch.service.ts: Added @deprecated annotation to method "searchByDepositType()" | Updated parsing according to new json schema for methods "searchByType()", "fetchByType()", "parse()".
This commit is contained in:
parent
ccdf2f16dc
commit
a8e2a509d5
|
@ -195,7 +195,7 @@ export class DataProviderService {
|
|||
this.dataProviderInfo.thematic = datasource.thematic;
|
||||
|
||||
if(datasource.jurisdiction) {
|
||||
this.dataProviderInfo.jurisdiction = datasource.jurisdiction.classname;
|
||||
this.dataProviderInfo.jurisdiction = datasource.jurisdiction.label;
|
||||
}
|
||||
|
||||
// TODO: Add check for array
|
||||
|
|
|
@ -13,6 +13,9 @@ export class OrganizationsDeletedByInferenceService {
|
|||
|
||||
public parsingFunctions: ParsingFunctions;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
getDeletedByInferenceResults(id: string, size: string, properties: EnvProperties): any {
|
||||
let url = properties.searchAPIURLLAst + 'deletedByInferenceOrganizations/' + id + "?format=json&size=" + size;
|
||||
|
||||
|
@ -21,6 +24,9 @@ export class OrganizationsDeletedByInferenceService {
|
|||
.pipe(map(res => this.parseDeletedByInferenceResults(res, properties)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
parseDeletedByInferenceResults(_results: any, properties: EnvProperties): OrganizationInfo[] {
|
||||
let results: OrganizationInfo[] = [];
|
||||
if (_results) {
|
||||
|
|
|
@ -58,6 +58,9 @@ export class ProjectService {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
getHTMLInfo(id: string, properties: EnvProperties): any {
|
||||
let url = properties.searchAPIURLLAst + 'projects/' + id + "?format=json";
|
||||
let key = url;
|
||||
|
|
|
@ -92,33 +92,27 @@ export class DeletedByInferenceComponent {
|
|||
for (let i = 0; i < length; i++) {
|
||||
let result = Array.isArray(this.children) ? this.children[i] : this.children;
|
||||
let preview = new ResultPreview();
|
||||
if(result.hasOwnProperty("creator")) {
|
||||
if(result["author"]) {
|
||||
preview.authors = [];
|
||||
let authorsLength = Array.isArray(result.creator) ? result.creator.length : 1;
|
||||
let authorsLength = Array.isArray(result.author) ? result.author.length : 1;
|
||||
for (let j = 0; j < authorsLength; j++) {
|
||||
let author = {"fullName": Array.isArray(result.creator) ? result.creator[j] : result.creator, "orcid": null, "orcid_pending": null};
|
||||
let author = {"fullName": Array.isArray(result.author) ? result.author[j] : result.author, "orcid": null, "orcid_pending": null};
|
||||
preview.authors.push(author);
|
||||
}
|
||||
}
|
||||
if(result.hasOwnProperty("dateofacceptance")) {
|
||||
preview.year = new Date(result.dateofacceptance).getFullYear().toString();
|
||||
}
|
||||
if(result.hasOwnProperty("title")) {
|
||||
let titleLength = Array.isArray(result.title) ? result.title.length : 1;
|
||||
for (let j = 0; j < titleLength; j++) {
|
||||
let title = Array.isArray(result.title) ? result.title[j] : result.title;
|
||||
if (!preview.title || title.classid == "main title") {
|
||||
preview.title = StringUtils.HTMLToString(String(title.content));
|
||||
}
|
||||
}
|
||||
if (result['title']) {
|
||||
preview.title = StringUtils.HTMLToString(String(result['title']));
|
||||
}
|
||||
|
||||
if(result.hasOwnProperty("description")) {
|
||||
preview.description = result.description;
|
||||
}
|
||||
preview.resultType = result?.resulttype?.classid ? result.resulttype.classid : this.resultType;
|
||||
preview.resultType = result?.resulttype ? result.resulttype : this.resultType;
|
||||
|
||||
|
||||
if (result.hasOwnProperty("instance")) {
|
||||
if (result.hasOwnProperty("instances")) {
|
||||
preview.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>();
|
||||
|
||||
preview.types = new Array<string>();
|
||||
|
@ -127,10 +121,10 @@ export class DeletedByInferenceComponent {
|
|||
let counter = 0;
|
||||
let instance;
|
||||
|
||||
let instanesLength = Array.isArray(result['instance']) ? result['instance'].length : 1;
|
||||
let instanesLength = Array.isArray(result['instances']) ? result['instances'].length : 1;
|
||||
|
||||
for (let j = 0; j < instanesLength; j++) {
|
||||
instance = Array.isArray(result['instance']) ? result['instance'][j] : result['instance'];
|
||||
instance = Array.isArray(result['instances']) ? result['instances'][j] : result['instances'];
|
||||
if(result.hasOwnProperty('collectedfrom')) {
|
||||
if(Array.isArray(result['collectedfrom'])) {
|
||||
// not sure if this is correct mapping
|
||||
|
@ -142,12 +136,12 @@ export class DeletedByInferenceComponent {
|
|||
|
||||
parsingFunctions.parseTypes(preview.types, types, instance);
|
||||
|
||||
if (instance.hasOwnProperty("webresource")) {
|
||||
if (instance.hasOwnProperty("url")) {
|
||||
let url;
|
||||
if (!Array.isArray(instance['webresource'])) {
|
||||
url = instance['webresource'].url;
|
||||
if (!Array.isArray(instance['url'])) {
|
||||
url = instance['url'];
|
||||
} else {
|
||||
url = instance['webresource'][0].url;
|
||||
url = instance['url'][0];
|
||||
}
|
||||
if (url.includes('&')) {
|
||||
url = url.replace(/&/gmu, '&');
|
||||
|
|
|
@ -16,6 +16,9 @@ export class DeletedByInferenceService {
|
|||
|
||||
public parsingFunctions: ParsingFunctions;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
getDeletedByInferenceResults (id: string, size: string, properties:EnvProperties):any {
|
||||
let url = properties.searchAPIURLLAst + 'deletedByInferenceResults/' +id+"?format=json&size="+size;
|
||||
let key = url;
|
||||
|
@ -26,6 +29,9 @@ export class DeletedByInferenceService {
|
|||
.pipe(map(res => this.parseDeletedByInferenceResults(res)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
parseDeletedByInferenceResults (_results: any): ResultLandingInfo[] {
|
||||
/*title, authors, abstract, List of projects, PIDs,
|
||||
collectedfrom (link pointing to the download url), access rights*/
|
||||
|
|
|
@ -721,25 +721,25 @@
|
|||
<modal-alert *ngIf="resultLandingInfo && resultLandingInfo.deletedByInferenceIds"
|
||||
#AlertModalDeletedByInference large="true">
|
||||
<deletedByInference *ngIf="type == 'publication' && deleteByInferenceOpened"
|
||||
[id]="resultLandingInfo.record['result']['header']['dri:objIdentifier']"
|
||||
[id]="resultLandingInfo.record['header']['id']"
|
||||
[ids]="resultLandingInfo.deletedByInferenceIds"
|
||||
[modal]="AlertModalDeletedByInference"
|
||||
[resultType]="type" [type]="openaireEntities.PUBLICATIONS" [prevPath]="prevPath"
|
||||
[children]="resultLandingInfo.children"></deletedByInference>
|
||||
<deletedByInference *ngIf="type == 'dataset' && deleteByInferenceOpened"
|
||||
[id]="resultLandingInfo.record['result']['header']['dri:objIdentifier']"
|
||||
[id]="resultLandingInfo.record['header']['id']"
|
||||
[ids]="resultLandingInfo.deletedByInferenceIds"
|
||||
[modal]="AlertModalDeletedByInference"
|
||||
[resultType]="'dataset'" [type]="openaireEntities.DATASETS" [prevPath]="prevPath"
|
||||
[children]="resultLandingInfo.children"></deletedByInference>
|
||||
<deletedByInference *ngIf="type == 'software' && deleteByInferenceOpened"
|
||||
[id]="resultLandingInfo.record['result']['header']['dri:objIdentifier']"
|
||||
[id]="resultLandingInfo.record['header']['id']"
|
||||
[ids]="resultLandingInfo.deletedByInferenceIds"
|
||||
[modal]="AlertModalDeletedByInference"
|
||||
[resultType]="type" [type]="openaireEntities.SOFTWARE" [prevPath]="prevPath"
|
||||
[children]="resultLandingInfo.children"></deletedByInference>
|
||||
<deletedByInference *ngIf="type == 'orp' && deleteByInferenceOpened"
|
||||
[id]="resultLandingInfo.record['result']['header']['dri:objIdentifier']"
|
||||
[id]="resultLandingInfo.record['header']['id']"
|
||||
[ids]="resultLandingInfo.deletedByInferenceIds"
|
||||
[modal]="AlertModalDeletedByInference"
|
||||
[resultType]="'other'" [type]="openaireEntities.OTHER" [prevPath]="prevPath"
|
||||
|
@ -1197,28 +1197,28 @@
|
|||
<ng-container *ngIf="isMobile">
|
||||
<fs-modal *ngIf="resultLandingInfo && resultLandingInfo.deletedByInferenceIds" #AlertModalDeletedByInferenceFS classTitle="uk-tile-default uk-border-bottom">
|
||||
<deletedByInference *ngIf="type == 'publication' && deleteByInferenceOpened"
|
||||
[id]="resultLandingInfo.record['result']['header']['dri:objIdentifier']"
|
||||
[id]="resultLandingInfo.record['header']['id']"
|
||||
[ids]="resultLandingInfo.deletedByInferenceIds"
|
||||
[resultType]="type" [type]="openaireEntities.PUBLICATIONS"
|
||||
[isMobile]="isMobile"
|
||||
[modal]="alertModalDeletedByInferenceFS"
|
||||
[children]="resultLandingInfo.children"></deletedByInference>
|
||||
<deletedByInference *ngIf="type == 'dataset' && deleteByInferenceOpened"
|
||||
[id]="resultLandingInfo.record['result']['header']['dri:objIdentifier']"
|
||||
[id]="resultLandingInfo.record['header']['id']"
|
||||
[ids]="resultLandingInfo.deletedByInferenceIds"
|
||||
[resultType]="'dataset'" [type]="openaireEntities.DATASETS"
|
||||
[isMobile]="isMobile"
|
||||
[modal]="alertModalDeletedByInferenceFS"
|
||||
[children]="resultLandingInfo.children"></deletedByInference>
|
||||
<deletedByInference *ngIf="type == 'software' && deleteByInferenceOpened"
|
||||
[id]="resultLandingInfo.record['result']['header']['dri:objIdentifier']"
|
||||
[id]="resultLandingInfo.record['header']['id']"
|
||||
[ids]="resultLandingInfo.deletedByInferenceIds"
|
||||
[resultType]="type" [type]="openaireEntities.SOFTWARE"
|
||||
[isMobile]="isMobile"
|
||||
[modal]="alertModalDeletedByInferenceFS"
|
||||
[children]="resultLandingInfo.children"></deletedByInference>
|
||||
<deletedByInference *ngIf="type == 'orp' && deleteByInferenceOpened"
|
||||
[id]="resultLandingInfo.record['result']['header']['dri:objIdentifier']"
|
||||
[id]="resultLandingInfo.record['header']['id']"
|
||||
[ids]="resultLandingInfo.deletedByInferenceIds"
|
||||
[resultType]="'other'" [type]="openaireEntities.OTHER"
|
||||
[isMobile]="isMobile"
|
||||
|
|
|
@ -368,7 +368,7 @@ export class ResultLandingService {
|
|||
this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation);
|
||||
}
|
||||
// links.header.relationType (==resultResult)
|
||||
if (relation['header'].relationType == "resultResult") {
|
||||
if (relation['header'].relationType == "resultResult" && (!relation['header'].relationClass || relation['header'].relationClass.toLowerCase() != "merges")) {
|
||||
let relationName: string = relation.header.relationClass;
|
||||
if (!this.resultLandingInfo.relatedClassFilters.has(relationName)) {
|
||||
this.resultLandingInfo.relatedClassFilters.add(relationName);
|
||||
|
|
|
@ -37,7 +37,7 @@ export class OrganizationService {
|
|||
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['result']['metadata']['oaf:entity']['oaf:organization']))
|
||||
// .pipe(map(res => res['result']['metadata']['oaf:entity']['oaf:organization']))
|
||||
.pipe(map(res => this.parseOrganizationNameAndUrl(res)));
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,12 @@ export class OrganizationService {
|
|||
return this.organizationInfo;
|
||||
}
|
||||
|
||||
parseOrganizationNameAndUrl(organization: any): any {
|
||||
parseOrganizationNameAndUrl(res: any): any {
|
||||
if(!res || res.organization) {
|
||||
return null;
|
||||
}
|
||||
let organization = res.organization;
|
||||
|
||||
let title: {"name": string, "url": string} = {"name": "", "url": ""};
|
||||
|
||||
if(organization != null) {
|
||||
|
|
|
@ -132,7 +132,8 @@ export class SearchDataprovidersService {
|
|||
|
||||
result['type'] = this.getDataproviderType(resData);
|
||||
if (resData['eosctype']) {
|
||||
result.entityType = resData['eosctype'].classname == "Service" ? "service" : "dataprovider";
|
||||
// TODO: Check if field is available, .label is correct?
|
||||
result.entityType = resData['eosctype'].label == "Service" ? "service" : "dataprovider";
|
||||
}
|
||||
|
||||
let abstracts = this.parsingFunctions.parseDescription(resData.description, true);
|
||||
|
|
|
@ -17,26 +17,29 @@ export class SearchOrganizationsService {
|
|||
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
parseResultsForDeposit(data: any): {"name": string, "id": string}[] {
|
||||
let results: {"name": string, "id": string}[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let name: string = '';
|
||||
let id: string = '';
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:organization'] : data['result']['metadata']['oaf:entity']['oaf:organization'];
|
||||
name = resData.legalname;
|
||||
if(name == '') {
|
||||
name = resData.legalshortname;
|
||||
}
|
||||
|
||||
id = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
|
||||
results.push({"name": name, "id": id});
|
||||
}
|
||||
return results;
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
// parseResultsForDeposit(data: any): {"name": string, "id": string}[] {
|
||||
// let results: {"name": string, "id": string}[] = [];
|
||||
//
|
||||
// let length = Array.isArray(data) ? data.length : 1;
|
||||
//
|
||||
// for(let i=0; i<length; i++) {
|
||||
// let name: string = '';
|
||||
// let id: string = '';
|
||||
// let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:organization'] : data['result']['metadata']['oaf:entity']['oaf:organization'];
|
||||
// name = resData.legalname;
|
||||
// if(name == '') {
|
||||
// name = resData.legalshortname;
|
||||
// }
|
||||
//
|
||||
// id = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
//
|
||||
// results.push({"name": name, "id": id});
|
||||
// }
|
||||
// return results;
|
||||
// }
|
||||
|
||||
searchOrganizations (params: string, refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties):any {
|
||||
|
||||
|
|
|
@ -145,7 +145,6 @@ export class SearchProjectsService {
|
|||
if (resBody["project"]) {
|
||||
let resData = resBody['project'];
|
||||
result.openAccessMandatePublications = resData['oamandatepublications'];
|
||||
console.log("!!! "+result.openAccessMandatePublications, resData['oamandatepublications']);
|
||||
|
||||
if (resData["oamandatedata"]) {
|
||||
result.openAccessMandateDatasets = resData['oamandatedata'];
|
||||
|
|
|
@ -200,6 +200,7 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
|
|||
return doc;
|
||||
}
|
||||
|
||||
// TODO: Update parsing everywhere on this service
|
||||
private getTitle(result: any): String[] {
|
||||
const title = _.get(result, "result.metadata.oaf:entity.oaf:result.title", null);
|
||||
let return_title;
|
||||
|
|
|
@ -84,7 +84,7 @@ export class EntitiesAutocompleteComponent {
|
|||
|
||||
@Input() public funderId:string;
|
||||
@Input() public entityType:string ;
|
||||
@Input() public depositType:string ;
|
||||
// @Input() public depositType:string ;
|
||||
public results = 0;
|
||||
public focus:boolean = false;
|
||||
constructor (public _search:EntitiesSearchService, private myElement: ElementRef) {
|
||||
|
@ -117,17 +117,17 @@ export class EntitiesAutocompleteComponent {
|
|||
}),);
|
||||
}else */
|
||||
|
||||
if(this.entityType == "organization" && this.depositType ){
|
||||
this.filtered = this.searchTermStream.pipe(
|
||||
debounceTime(300),distinctUntilChanged(),
|
||||
switchMap((term: string) => {
|
||||
var results = this._search.searchByDepositType(term, this.depositType, this.properties);
|
||||
this.showLoading = false;
|
||||
this.results = results.length;
|
||||
return results;
|
||||
}),);
|
||||
|
||||
}else{
|
||||
// if(this.entityType == "organization" && this.depositType ){
|
||||
// this.filtered = this.searchTermStream.pipe(
|
||||
// debounceTime(300),distinctUntilChanged(),
|
||||
// switchMap((term: string) => {
|
||||
// var results = this._search.searchByDepositType(term, this.depositType, this.properties);
|
||||
// this.showLoading = false;
|
||||
// this.results = results.length;
|
||||
// return results;
|
||||
// }),);
|
||||
//
|
||||
// }else{
|
||||
|
||||
this.filtered = this.searchTermStream.pipe(
|
||||
debounceTime(300),
|
||||
|
@ -140,7 +140,7 @@ export class EntitiesAutocompleteComponent {
|
|||
}),);
|
||||
|
||||
this.getSelectedNameFromGivenId();
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
ngOnDestroy(){
|
||||
|
|
|
@ -7,6 +7,8 @@ import {throwError} from 'rxjs';
|
|||
import{EnvProperties} from '../properties/env-properties';
|
||||
|
||||
import {catchError, map} from "rxjs/operators";
|
||||
import {StringUtils} from "../string-utils.class";
|
||||
|
||||
@Injectable()
|
||||
export class EntitiesSearchService {
|
||||
public ready:boolean = false;
|
||||
|
@ -40,79 +42,79 @@ export class EntitiesSearchService {
|
|||
}*/
|
||||
|
||||
// not used
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
searchByDepositType(keyword:string, DepositType:string, properties:EnvProperties ):any {
|
||||
this.ready = false;
|
||||
|
||||
let link = properties.searchResourcesAPIURL;
|
||||
|
||||
let url = link+"?query=";
|
||||
if(keyword!= null && keyword != '' ) {
|
||||
/*url += "((oaftype exact organization and deletedbyinference=false and "+
|
||||
"(reldatasourcecompatibilityid=driver or reldatasourcecompatibilityid=driver-openaire2.0 or reldatasourcecompatibilityid=openaire2.0 or reldatasourcecompatibilityid=openaire3.0 or reldatasourcecompatibilityid=openaire2.0_data or reldatasourcecompatibilityid=hostedBy or relprojectid=* or reldatasourcecompatibilityid = native))"+
|
||||
" and ((organizationlegalname all "+'"'+keyword+'"'+") or (organizationlegalshortname all "+'"'+keyword+'"'+")) " +
|
||||
// "and " + this.quote(params) + " " +
|
||||
"and (collectedfrom exact "+StringUtils.quote(StringUtils.URIEncode(DepositType))+")) "*/
|
||||
|
||||
// in search there is this filter:
|
||||
//reldatasourcecompatibilityid exact driver or reldatasourcecompatibilityid exact driver-openaire2.0 or reldatasourcecompatibilityid exact openaire2.0 or reldatasourcecompatibilityid exact openaire3.0 or reldatasourcecompatibilityid exact openaire2.0_data or reldatasourcecompatibilityid exact hostedBy or relproject=*
|
||||
|
||||
|
||||
//url += "((oaftype exact organization and deletedbyinference=false )"+
|
||||
url += "((oaftype exact organization and deletedbyinference=false and"+
|
||||
"(reldatasourcecompatibilityid=driver or reldatasourcecompatibilityid=driver-openaire2.0 or reldatasourcecompatibilityid=openaire2.0 or reldatasourcecompatibilityid=openaire3.0 or reldatasourcecompatibilityid=openaire4.0 or reldatasourcecompatibilityid=openaire2.0_data or reldatasourcecompatibilityid=hostedBy or relprojectid=* or reldatasourcecompatibilityid = native))"+
|
||||
" and ((organizationlegalname all "+'"'+keyword+'"'+") or (organizationlegalshortname all "+'"'+keyword+'"'+")) " +
|
||||
// "and " + this.quote(params) + " " +
|
||||
//"and (collectedfrom exact "+StringUtils.quote(StringUtils.URIEncode(DepositType))+")) "
|
||||
")";
|
||||
}
|
||||
|
||||
url += "&page=0&size=10";
|
||||
url += "&format=json";
|
||||
|
||||
// let url = properties.searchAPIURLLAst+"projects?"+((keyword && keyword.length > 0)?("q=" +keyword):"")+((funderId && funderId.length > 0 )?"&fq=funderid exact " + '"'+funderId+ '"':"")+"&size=10&page=0&format=json";
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).toPromise()
|
||||
.then(request =>
|
||||
{
|
||||
//request = request.json().results;
|
||||
request = request['results'];
|
||||
//console.log(request);
|
||||
this.ready = true;
|
||||
return this.parse(request,"oaf:organization","organization");
|
||||
}).catch((ex) => {
|
||||
console.error('An error occured', ex);
|
||||
return [{id:'-2',label:'Error'}];
|
||||
});
|
||||
}
|
||||
// /**
|
||||
// * @deprecated
|
||||
// */
|
||||
// searchByDepositType(keyword:string, DepositType:string, properties:EnvProperties ):any {
|
||||
// this.ready = false;
|
||||
//
|
||||
// let link = properties.searchResourcesAPIURL;
|
||||
//
|
||||
// let url = link+"?query=";
|
||||
// if(keyword!= null && keyword != '' ) {
|
||||
// /*url += "((oaftype exact organization and deletedbyinference=false and "+
|
||||
// "(reldatasourcecompatibilityid=driver or reldatasourcecompatibilityid=driver-openaire2.0 or reldatasourcecompatibilityid=openaire2.0 or reldatasourcecompatibilityid=openaire3.0 or reldatasourcecompatibilityid=openaire2.0_data or reldatasourcecompatibilityid=hostedBy or relprojectid=* or reldatasourcecompatibilityid = native))"+
|
||||
// " and ((organizationlegalname all "+'"'+keyword+'"'+") or (organizationlegalshortname all "+'"'+keyword+'"'+")) " +
|
||||
// // "and " + this.quote(params) + " " +
|
||||
// "and (collectedfrom exact "+StringUtils.quote(StringUtils.URIEncode(DepositType))+")) "*/
|
||||
//
|
||||
// // in search there is this filter:
|
||||
// //reldatasourcecompatibilityid exact driver or reldatasourcecompatibilityid exact driver-openaire2.0 or reldatasourcecompatibilityid exact openaire2.0 or reldatasourcecompatibilityid exact openaire3.0 or reldatasourcecompatibilityid exact openaire2.0_data or reldatasourcecompatibilityid exact hostedBy or relproject=*
|
||||
//
|
||||
//
|
||||
// //url += "((oaftype exact organization and deletedbyinference=false )"+
|
||||
// url += "((oaftype exact organization and deletedbyinference=false and"+
|
||||
// "(reldatasourcecompatibilityid=driver or reldatasourcecompatibilityid=driver-openaire2.0 or reldatasourcecompatibilityid=openaire2.0 or reldatasourcecompatibilityid=openaire3.0 or reldatasourcecompatibilityid=openaire4.0 or reldatasourcecompatibilityid=openaire2.0_data or reldatasourcecompatibilityid=hostedBy or relprojectid=* or reldatasourcecompatibilityid = native))"+
|
||||
// " and ((organizationlegalname all "+'"'+keyword+'"'+") or (organizationlegalshortname all "+'"'+keyword+'"'+")) " +
|
||||
// // "and " + this.quote(params) + " " +
|
||||
// //"and (collectedfrom exact "+StringUtils.quote(StringUtils.URIEncode(DepositType))+")) "
|
||||
// ")";
|
||||
// }
|
||||
//
|
||||
// url += "&page=0&size=10";
|
||||
// url += "&format=json";
|
||||
//
|
||||
// // let url = properties.searchAPIURLLAst+"projects?"+((keyword && keyword.length > 0)?("q=" +keyword):"")+((funderId && funderId.length > 0 )?"&fq=funderid exact " + '"'+funderId+ '"':"")+"&size=10&page=0&format=json";
|
||||
// return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).toPromise()
|
||||
// .then(request =>
|
||||
// {
|
||||
// //request = request.json().results;
|
||||
// request = request['results'];
|
||||
// //console.log(request);
|
||||
// this.ready = true;
|
||||
// return this.parse(request,"oaf:organization","organization");
|
||||
// }).catch((ex) => {
|
||||
// console.error('An error occured', ex);
|
||||
// return [{id:'-2',label:'Error'}];
|
||||
// });
|
||||
// }
|
||||
|
||||
searchByType(keyword:string,type:string, properties:EnvProperties ){
|
||||
if (type == "project"){
|
||||
return this.searchEntity(keyword,"projects","oaf:project","project", properties);
|
||||
return this.searchEntity(keyword,"projects","project","project", properties);
|
||||
}else if (type == "dataset"){
|
||||
return this.searchEntity(keyword,"datasets","oaf:result","dataset", properties);
|
||||
return this.searchEntity(keyword,"datasets","result","dataset", properties);
|
||||
}else if (type == "datasource" || type == "hostedBy" || type== "collectedFrom"){
|
||||
return this.searchEntity(keyword,"datasources","oaf:datasource","datasource", properties);
|
||||
return this.searchEntity(keyword,"datasources","datasource","datasource", properties);
|
||||
}else if (type == "publication"){
|
||||
return this.searchEntity(keyword,"publications","oaf:result","publication", properties);
|
||||
return this.searchEntity(keyword,"publications","result","publication", properties);
|
||||
}else if (type == "organization"){
|
||||
return this.searchEntity(keyword,"organizations","oaf:organization","organization", properties);
|
||||
return this.searchEntity(keyword,"organizations","organization","organization", properties);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
fetchByType(id:string,type:string, properties:EnvProperties ){
|
||||
if (type == "project"){
|
||||
return this.fetchEntity(id,"projects","oaf:project","project", properties);
|
||||
return this.fetchEntity(id,"projects","project","project", properties);
|
||||
}else if (type == "dataset"){
|
||||
return this.fetchEntity(id,"datasets","oaf:result","dataset", properties);
|
||||
return this.fetchEntity(id,"datasets","result","dataset", properties);
|
||||
}else if (type == "datasource" || type == "hostedBy" || type== "collectedFrom"){
|
||||
return this.fetchEntity(id,"datasources","oaf:datasource","datasource", properties);
|
||||
return this.fetchEntity(id,"datasources","datasource","datasource", properties);
|
||||
}else if (type == "publication"){
|
||||
return this.fetchEntity(id,"publications","oaf:result","publication", properties);
|
||||
return this.fetchEntity(id,"publications","result","publication", properties);
|
||||
}else if (type == "organization"){
|
||||
return this.fetchEntity(id,"organizations","oaf:organization","organization", properties);
|
||||
return this.fetchEntity(id,"organizations","organization","organization", properties);
|
||||
|
||||
}
|
||||
|
||||
|
@ -174,105 +176,99 @@ private fetch (link,id,oafEntityType,type, properties:EnvProperties ){
|
|||
}
|
||||
|
||||
private parse(data: any,oafEntityType:string, type:string){
|
||||
var array:any =[]
|
||||
let results: any[] = [];
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity'][oafEntityType] : data['result']['metadata']['oaf:entity'][oafEntityType];
|
||||
for (let i = 0; i < length; i++) {
|
||||
let resBody = Array.isArray(data) ? data[i] : data;
|
||||
var result: any = {};
|
||||
|
||||
var value:any={} ;
|
||||
if(resData['title']){
|
||||
if(Array.isArray(resData['title'])) {
|
||||
value.label = resData['title'][0];
|
||||
} else {
|
||||
value.label = resData['title'];
|
||||
}
|
||||
if(oafEntityType=="oaf:result"){
|
||||
value.label = value.label.content;
|
||||
value.result = resData;
|
||||
}
|
||||
}else if(resData["fullname"]){
|
||||
if(Array.isArray(resData["fullname"])) {
|
||||
value.label = resData["fullname"][0];
|
||||
} else {
|
||||
value.label = resData["fullname"];
|
||||
}
|
||||
}else if(resData["legalname"]){
|
||||
if (resBody["header"]) {
|
||||
result.id = resBody['header']['id'];
|
||||
}
|
||||
|
||||
if(Array.isArray(resData["legalname"])) {
|
||||
value.label = resData["legalname"][0];
|
||||
} else {
|
||||
value.label = resData["legalname"];
|
||||
}
|
||||
if(resData["legalshortname"]){
|
||||
if (resBody[oafEntityType]) {
|
||||
let resData = resBody[oafEntityType];
|
||||
|
||||
if(Array.isArray(resData["legalshortname"])) {
|
||||
value.label += " (" + resData["legalshortname"][0] +")";
|
||||
} else {
|
||||
value.label += " (" + resData["legalshortname"] +")";
|
||||
if (oafEntityType == "result") {
|
||||
result.result = resData;
|
||||
}
|
||||
if (resData['mainTitle']) { // result
|
||||
result.label = StringUtils.HTMLToString(String(resData['mainTitle']));
|
||||
} else if (resData['title']) { // project
|
||||
if (Array.isArray(resData['title'])) {
|
||||
result.label = StringUtils.HTMLToString(String(resData['title'][0]));
|
||||
} else {
|
||||
result.label = StringUtils.HTMLToString(String(resData['title']));
|
||||
}
|
||||
// } else if(resData["fullname"]) {
|
||||
// if(Array.isArray(resData["fullname"])) {
|
||||
// value.label = resData["fullname"][0];
|
||||
// } else {
|
||||
// value.label = resData["fullname"];
|
||||
// }
|
||||
} else if (resData["legalname"]) { // organization
|
||||
result.label = resData["legalname"];
|
||||
if (resData["legalshortname"]) {
|
||||
result.label += " (" + resData["legalshortname"] + ")";
|
||||
}
|
||||
} else if (resData["officialname"]) { // datasource
|
||||
result.label = resData["officialname"];
|
||||
} else if(resData['otherTitles']) {
|
||||
result.label = StringUtils.HTMLToString(String(resData['otherTitles'][0]));
|
||||
}
|
||||
|
||||
if (type == "project") {
|
||||
result.projectAcronym = resData['acronym'] ? resData['acronym'] : "";
|
||||
result.projectName = result.label;
|
||||
result.endDate = resData.enddate ? resData.enddate.split('-')[0] : null;
|
||||
result.startDate = resData.startdate ? resData.startdate.split('-')[0] : null;
|
||||
result.funderId = "";
|
||||
result.funderName = "";
|
||||
result.jurisdiction = "";
|
||||
result.fundingLevel0 = "";
|
||||
result.code = resData['code'];
|
||||
|
||||
if(resData['funding'] && type == "project") {
|
||||
let fundingLength = Array.isArray(resData['funding']) ? resData['funding'].length : 1;
|
||||
|
||||
for (let z = 0; z < fundingLength; z++) {
|
||||
|
||||
let fundingData = Array.isArray(resData['funding']) ? resData['funding'][z] : resData['funding'];
|
||||
if (fundingData["funder"]) {
|
||||
result['funderId'] = fundingData['funder'].id ? fundingData['funder'].id : "";
|
||||
result['funderName'] = fundingData['funder'].name ? fundingData['funder'].name : "";
|
||||
result['funderShortName'] = fundingData['funder'].shortname ? fundingData['funder'].shortname : "";
|
||||
result['jurisdiction'] = (fundingData['funder']['jurisdiction'] && fundingData['funder']['jurisdiction'].code) ? fundingData['funder']['jurisdiction'].code : "";
|
||||
|
||||
if (fundingData['level2']) {
|
||||
result['fundingLevel0'] = (fundingData['level2'] && fundingData['level2']['parent'] &&
|
||||
fundingData['level2']['parent']['level1'] && fundingData['level2']['parent']['level1']['parent']
|
||||
&& fundingData['level2']['parent']['level1']['parent']['level0']) ?
|
||||
fundingData['level2']['parent']['level1']['parent']['level0']['name'] : "";
|
||||
} else if (fundingData['level1']) {
|
||||
result['level0'] = (fundingData['level1'] && fundingData['level1']['parent'] && fundingData['level1']['parent']['level0']) ?
|
||||
fundingData['level1']['parent']['level0']['name'] : "";
|
||||
} else if (fundingData['level0']) {
|
||||
result['fundingLevel0'] = (fundingData['level0']) ? fundingData['level0']['name'] : "";
|
||||
} else {
|
||||
result['fundingLevel0'] = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}else if(resData["officialname"]){
|
||||
|
||||
if(Array.isArray(resData["officialname"])) {
|
||||
value.label = resData["officialname"][0];
|
||||
} else {
|
||||
value.label = resData["officialname"];
|
||||
}
|
||||
}
|
||||
|
||||
value.id = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
|
||||
if(type=="project"){
|
||||
value.projectAcronym = resData['acronym'];
|
||||
value.projectName = value.label;
|
||||
value.endDate = null;
|
||||
value.startDate = null;
|
||||
value.funderId = "";
|
||||
value.funderName = "";
|
||||
value.jurisdiction = "";
|
||||
value.fundingLevel0 = "";
|
||||
value.code = resData['code'];
|
||||
|
||||
if(resData['fundingtree'] && resData['fundingtree']['funder']){
|
||||
value.funderId = (resData['fundingtree']['funder']['id'] )?resData['fundingtree']['funder']['id']:"";
|
||||
value.funderName = (resData['fundingtree']['funder']['name'] )?resData['fundingtree']['funder']['name']:"";
|
||||
value.funderShortName = (resData['fundingtree']['funder']['shortname'] )?resData['fundingtree']['funder']['shortname']:"";
|
||||
value.jurisdiction = (resData['fundingtree']['funder']['jurisdiction'] )?resData['fundingtree']['funder']['jurisdiction']:"";
|
||||
if(resData['fundingtree']['funding_level_2']){
|
||||
value.fundingLevel0 = (resData['fundingtree']['funding_level_2'] && resData['fundingtree']['funding_level_2']['parent'] &&
|
||||
resData['fundingtree']['funding_level_2']['parent']['funding_level_1'] && resData['fundingtree']['funding_level_2']['parent']['funding_level_1']['parent']
|
||||
&& resData['fundingtree']['funding_level_2']['parent']['funding_level_1']['parent']['funding_level_0'])?
|
||||
resData['fundingtree']['funding_level_2']['parent']['funding_level_1']['parent']['funding_level_0']['name']:"";
|
||||
}else if(resData['fundingtree']['funding_level_1']){
|
||||
value.fundingLevel0 = (resData['fundingtree']['funding_level_1'] && resData['fundingtree']['funding_level_1']['parent'] && resData['fundingtree']['funding_level_1']['parent']['funding_level_0'])?
|
||||
resData['fundingtree']['funding_level_1']['parent']['funding_level_0']['name']:"";
|
||||
}else if(resData['fundingtree']['funding_level_0']){
|
||||
value.fundingLevel0 = (resData['fundingtree']['funding_level_0'] )?resData['fundingtree']['funding_level_0']['name']:"";
|
||||
}else {
|
||||
value.fundingLevel0="";
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.hasOwnProperty("startdate")) {
|
||||
value.startDate = resData.startdate.split('-')[0];
|
||||
}
|
||||
if(resData.hasOwnProperty("enddate")) {
|
||||
value.endDate = resData.enddate.split('-')[0];
|
||||
}
|
||||
|
||||
}
|
||||
// console.info("add:"+value.label+" "+value.id);
|
||||
|
||||
array.push(value);
|
||||
}
|
||||
}
|
||||
if(array.length == 0){
|
||||
array.push({id:'-1',label:'No results found'});
|
||||
}
|
||||
//console.info("Parsing results.... Size:"+array.length);
|
||||
|
||||
return array;
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
if(results.length == 0){
|
||||
results.push({id:'-1',label:'No results found'});
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private handleError (error: HttpErrorResponse) {
|
||||
|
|
Loading…
Reference in New Issue