@ -2,9 +2,6 @@ import {Injectable} from '@angular/core';
import { HttpClient } from "@angular/common/http" ;
import { SearchResult } from '../utils/entities/searchResult' ;
import { RefineResultsUtils } from './servicesUtils/refineResults.class' ;
import { StringUtils } from '../utils/string-utils.class' ;
import { EnvProperties } from '../utils/properties/env-properties' ;
import { map } from "rxjs/operators" ;
@ -31,11 +28,9 @@ export class SearchDataprovidersService {
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
//.do(res => console.info(res))
. pipe ( map ( res = > [ res [ 'meta' ] . total , this . parseResults ( res [ 'results' ] ) , RefineResultsUtils . parse ( res [ 'refineResults' ] , refineFields , "datasource" , usedBy ) ] ) ) ;
}
//((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb"))
advancedSearchDataproviders ( params : string , page : number , size : number , properties : EnvProperties , refineParams :string = null , refineFields :string [ ] = null , refineQuery :string = null , depositQuery :boolean = false ) : any {
let url = properties . searchAPIURLLAst + "resources" + ( depositQuery ? '' : 2 ) + "/?format=json" ;
@ -52,100 +47,9 @@ export class SearchDataprovidersService {
url += "&page=" + ( page - 1 ) + "&size=" + size ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
//.do(res => console.info(res))
. pipe ( map ( res = > [ res [ 'meta' ] . total , this . parseResults ( res [ 'results' ] ) , RefineResultsUtils . parse ( res [ 'refineResults' ] , refineFields , "datasource" ) ] ) ) ;
}
searchCompatibleDataprovidersTable ( properties :EnvProperties ) : any {
let size : number = 0 ;
let url : string = properties . searchResourcesAPIURL ;
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))' ;
url += "&page=0&size=0&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
. pipe ( map ( res = > res [ 'meta' ] . total ) ) ;
}
searchCompatibleDataproviders ( params : string , refineParams :string , page : number , size : number , refineFields :string [ ] , properties :EnvProperties ) : any {
let url : string = properties . searchResourcesAPIURL ;
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))' ;
if ( params != null && params != '' ) {
url += params ;
}
if ( refineParams != null && refineParams != '' ) {
url += refineParams ;
}
url += "&page=" + ( page - 1 ) + "&size=" + size + "&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
//.do(res => console.info(res))
. pipe ( map ( res = > [ res [ 'meta' ] . total , this . parseResults ( res [ 'results' ] ) , RefineResultsUtils . parse ( res [ 'refineResults' ] , refineFields , "datasource" ) ] ) ) ;
}
searchEntityRegistriesTable ( properties :EnvProperties ) : any {
let size : number = 0 ;
let url : string = properties . searchResourcesAPIURL ;
url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))" ;
url += "&page=0&size=0&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
. pipe ( map ( res = > res [ 'meta' ] . total ) ) ;
}
searchEntityRegistries ( params : string , refineParams :string , page : number , size : number , refineFields :string [ ] , properties :EnvProperties ) : any {
let url = properties . searchResourcesAPIURL ;
url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))" ;
if ( params != null && params != '' ) {
url += params ;
}
if ( refineParams != null && refineParams != '' ) {
url += refineParams ;
}
url += "&page=" + ( page - 1 ) + "&size=" + size + "&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
//.do(res => console.info(res))
. pipe ( map ( res = > [ res [ 'meta' ] . total , this . parseResults ( res [ 'results' ] ) , RefineResultsUtils . parse ( res [ 'refineResults' ] , refineFields , "datasource" ) ] ) ) ;
}
searchJournalsTable ( properties :EnvProperties ) : any {
let size : number = 0 ;
let url : string = properties . searchResourcesAPIURL ;
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))' ;
url += "&page=0&size=0&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url ) //.map(res => <any> res.json())
. pipe ( map ( res = > res [ 'meta' ] . total ) ) ;
}
searchJournals ( params : string , refineParams :string , page : number , size : number , refineFields :string [ ] , properties :EnvProperties ) : any {
let url : string = properties . searchResourcesAPIURL ;
//url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))' ;
if ( params != null && params != '' ) {
url += params ;
}
if ( refineParams != null && refineParams != '' ) {
url += refineParams ;
}
url += "&page=" + ( page - 1 ) + "&size=" + size + "&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
//.do(res => console.info(res))
. pipe ( map ( res = > [ res [ 'meta' ] . total , this . parseResults ( res [ 'results' ] ) , RefineResultsUtils . parse ( res [ 'refineResults' ] , refineFields , "datasource" ) ] ) ) ;
}
searchDataprovidersForDeposit ( id : string , type : string , page : number , size : number , properties :EnvProperties ) : any {
let link = properties . searchResourcesAPIURL ;
var compatibilities = "" ;
@ -165,39 +69,6 @@ export class SearchDataprovidersService {
. pipe ( map ( res = > [ res [ 'meta' ] . total , this . parseResults ( res [ 'results' ] ) ] ) ) ;
}
searchDataprovidersForDepositSearch ( params : string , refineParams :string , page : number , size : number , refineFields :string [ ] , properties :EnvProperties , usedBy : string = "search" ) : any {
let link = properties . searchResourcesAPIURL ;
let url = link + "?query=((deletedbyinference = false) AND (oaftype exact datasource)) " + params ;
if ( refineParams != null && refineParams != '' ) {
url += refineParams ;
}
url += "&page=" + ( page - 1 ) + "&size=" + size + "&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
. pipe ( map ( res = > [ res [ 'meta' ] . total , this . parseResults ( res [ 'results' ] ) , RefineResultsUtils . parse ( res [ 'refineResults' ] ,
refineFields , "datasource" , usedBy ) ] ) ) ;
}
searchDataProvidersBySubjects ( keyword :string , type : string , page : number , size : number , properties :EnvProperties ) : any {
let link = properties . searchResourcesAPIURL ;
var compatibilities = "" ;
if ( type == "Research Data" ) {
compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid = openaire2.0_data)"
} else if ( type == "Publications" ) {
compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)"
}
let url = link + "?query=(((deletedbyinference = false) AND (oaftype exact datasource)) " + ( ( compatibilities && compatibilities . length > 0 ) ? " " +
compatibilities + " " : "" ) + ") " +
" and (datasourcesubject all " + '"' + keyword + '"' + ") " ;
url += "&page=" + ( page - 1 ) + "&size=" + size + "&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
. pipe ( map ( res = > [ res [ 'meta' ] . total , this . parseResults ( res [ 'results' ] ) ] ) ) ;
}
getDataProvidersforEntityRegistry ( datasourceId : string , page : number , size : number , properties :EnvProperties ) : any {
let url = properties . searchResourcesAPIURL ;
var basicQuery = "(oaftype exact datasource) "
@ -222,66 +93,6 @@ export class SearchDataprovidersService {
//.map(res => <any> res.json())
. pipe ( map ( res = > [ res [ 'meta' ] . total , this . parseResults ( res [ 'results' ] ) ] ) ) ;
}
/ *
searchDataprovidersCSV ( params : string , refineParams :string , page : number , size : number ) : any {
let link = OpenaireProperties . getSearchAPIURLLast ( ) + "datasources" ;
let url = link + "?" ;
if ( params != null && params != '' ) {
url += params ;
}
if ( refineParams != null && refineParams != '' ) {
url += refineParams ;
}
url += "&page=" + ( page - 1 ) + "&size=" + size + "&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
. map ( res = > < any > res . json ( ) )
//.do(res => console.info(res))
. map ( res = > this . parseResultsCSV ( res [ 'results' ] ) ) ;
}
* /
/ *
searchEntityRegistriesCSV ( params : string , refineParams :string , page : number , size : number ) : any {
let url = properties . searchAPIURLLAst ;
url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))"
if ( params != null && params != '' ) {
url += params ;
}
if ( refineParams != null && refineParams != '' ) {
url += refineParams ;
}
url += "&page=" + ( page - 1 ) + "&size=" + size + "&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
. map ( res = > < any > res . json ( ) )
//.do(res => console.info(res))
. map ( res = > this . parseResultsCSV ( res [ 'results' ] ) ) ;
}
* /
/ *
searchCompatibleDataprovidersCSV ( params : string , refineParams :string , page : number , size : number ) : any {
let url = properties . searchAPIURLLAst ;
url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"
if ( params != null && params != '' ) {
url += params ;
}
if ( refineParams != null && refineParams != '' ) {
url += refineParams ;
}
url += "&page=" + ( page - 1 ) + "&size=" + size + "&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
. map ( res = > < any > res . json ( ) )
//.do(res => console.info(res))
. map ( res = > this . parseResultsCSV ( res [ 'results' ] ) ) ;
}
* /
parseResults ( data : any ) : SearchResult [ ] {
let results : SearchResult [ ] = [ ] ;
@ -319,7 +130,6 @@ export class SearchDataprovidersService {
}
let typeid : string = resData [ 'datasourcetype' ] . classid ;
//console.info(typeid);
if ( typeid != "entityregistry" && typeid != "entityregistry::projects" && typeid != "entityregistry::repositories" ) {
if ( resData . hasOwnProperty ( 'accessinfopackage' ) ) {
@ -349,7 +159,6 @@ export class SearchDataprovidersService {
result [ 'organizations' ] = res [ 1 ] ;
result [ 'countries' ] = res [ 0 ] ;
result [ 'subjects' ] = this . getDataproviderSubjects ( resData ) ;
//console.log(result['subjects']);
if ( resData [ 'pid' ] ) {
result . identifiers = this . parsingFunctions . parseIdentifiers ( resData [ 'pid' ] ) ;
@ -432,30 +241,9 @@ export class SearchDataprovidersService {
}
return [ countries , organizations ] ;
}
/ *
parseResultsCSV ( data : any ) : 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' ] [ 'oaf:datasource' ] : data [ 'result' ] [ 'metadata' ] [ 'oaf:entity' ] [ 'oaf:datasource' ] ;
var result : any = [ ] ;
result . push ( this . quote ( resData . officialname ) ) ;
result . push ( this . quote ( this . getDataproviderType ( resData ) ) ) ;
result . push ( this . quote ( this . getDataproviderCountriesOrganizations ( resData , true , false ) [ 0 ] ) ) ;
result . push ( this . quote ( this . getDataproviderCompatibility ( resData ) ) ) ;
results . push ( result ) ;
}
return results ;
}
* /
numOfDataproviders ( url : string , properties :EnvProperties ) : any {
//let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
. pipe ( map ( res = > res [ 'total' ] ) ) ;
}
@ -491,29 +279,4 @@ export class SearchDataprovidersService {
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
. pipe ( map ( res = > res [ 'meta' ] [ 'total' ] ) ) ;
}
/ *
private quote ( word : any ) : string {
return '"' + word + '"' ;
}
* /
getDataprovidersTableResults ( queryType :string , properties :EnvProperties ) : any {
let size : number = 0 ;
let url : string = properties . searchAPIURLLAst ;
if ( queryType == "compatible" ) {
url += '?query=((oaftype exact datasource) not (datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))' ;
} else if ( queryType == "registries" ) {
url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))" ;
} else if ( queryType == "journals" ) {
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))' ;
}
url += "&page=0&size=0&format=json" ;
return this . http . get ( ( properties . useCache ) ? ( properties . cacheUrl + encodeURIComponent ( url ) ) : url )
//.map(res => <any> res.json())
. pipe ( map ( res = > res [ 'meta' ] . total ) ) ;
}
}