2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input, ViewChild} from '@angular/core';
|
|
|
|
import {Location} from '@angular/common';
|
|
|
|
import { ActivatedRoute} from '@angular/router';
|
|
|
|
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
|
|
|
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
|
|
|
import {SearchResult} from '../../utils/entities/searchResult';
|
2018-02-15 11:36:12 +01:00
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
2019-02-15 13:50:24 +01:00
|
|
|
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
2017-12-19 13:53:46 +01:00
|
|
|
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
|
|
|
import {SearchPageComponent } from '../searchUtils/searchPage.component';
|
|
|
|
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
|
2018-02-05 14:14:59 +01:00
|
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'search-content-providers',
|
|
|
|
template: `
|
|
|
|
|
|
|
|
<search-page pageTitle="OpenAIRE Content Providers"
|
|
|
|
formPlaceholderText = "Search for OpenAIRE Content Providers"
|
|
|
|
type="content providers" entityType="dataprovider" [(filters)] = "filters"
|
|
|
|
[(results)] = "results" [(searchUtils)] = "searchUtils"
|
|
|
|
[baseUrl] = "baseUrl" [showResultCount]=false
|
2018-10-11 11:10:35 +02:00
|
|
|
[csvParams]="csvParams" csvPath="datasources"
|
2017-12-19 13:53:46 +01:00
|
|
|
[disableForms]="disableForms"
|
|
|
|
[tableViewLink]="'/search/content-providers-table'"
|
2019-02-12 12:15:21 +01:00
|
|
|
searchFormClass="compatibleDatasourcesSearchForm"
|
|
|
|
[mapUrl]="mapUrl" [mapTooltipType]="'repositories'"
|
|
|
|
[newQueryButton]="false">
|
2017-12-19 13:53:46 +01:00
|
|
|
</search-page>
|
|
|
|
|
|
|
|
`
|
|
|
|
|
|
|
|
})
|
|
|
|
export class SearchCompatibleDataprovidersComponent {
|
|
|
|
private errorCodes: ErrorCodes;
|
2019-02-15 13:50:24 +01:00
|
|
|
private errorMessages: ErrorMessagesComponent;
|
2017-12-19 13:53:46 +01:00
|
|
|
public results =[];
|
|
|
|
public filters =[];
|
|
|
|
public baseUrl:string;
|
|
|
|
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
|
|
|
public sub: any; public subResults: any;
|
|
|
|
public _location:Location;
|
|
|
|
public searchFields:SearchFields = new SearchFields();
|
|
|
|
public refineFields: string[] = this.searchFields.COMPATIBLE_DATAPROVIDER_FIELDS;
|
|
|
|
public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS;
|
|
|
|
public _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[{field:"compatibility",opName:"cm",opValue:"not", values:["UNKNOWN","hostedBy","notCompatible"]},{field:"type",opName:"tp",opValue:"not",values: ["other"]}];
|
|
|
|
// ["entityregistry","entityregistry::projects","entityregistry::repositories"]}];
|
|
|
|
public _prefixQuery: string = "";
|
|
|
|
|
|
|
|
public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ],
|
|
|
|
"export":[]
|
|
|
|
};
|
2018-10-11 11:10:35 +02:00
|
|
|
public resourcesQuery = '((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
|
2017-12-19 13:53:46 +01:00
|
|
|
public csvParams: string;
|
|
|
|
public disableForms: boolean = false;
|
2019-02-12 12:15:21 +01:00
|
|
|
public mapUrl: string;
|
2018-02-05 14:14:59 +01:00
|
|
|
properties:EnvProperties;
|
2017-12-19 13:53:46 +01:00
|
|
|
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
|
|
|
|
|
|
|
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) {
|
|
|
|
this.errorCodes = new ErrorCodes();
|
2019-02-15 13:50:24 +01:00
|
|
|
this.errorMessages = new ErrorMessagesComponent();
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
for(var i = 0; i < this._prefixQueryFields.length; i++ ){
|
|
|
|
for(var j =0; j < this._prefixQueryFields[i].values.length; j++){
|
|
|
|
this._prefixQuery+="&" + this._prefixQueryFields[i].field + "="
|
|
|
|
+ this._prefixQueryFields[i].values[j] + "&" +
|
|
|
|
this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this._prefixQuery+="&";
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
2018-02-05 14:14:59 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
|
|
|
this.baseUrl = data.envSpecific.searchLinkToCompatibleDataProviders
|
2020-02-25 16:40:56 +01:00
|
|
|
// this.mapUrl = this.properties.statisticsFrameAPIURL+"markers-test.html";
|
2018-02-05 14:14:59 +01:00
|
|
|
|
|
|
|
});
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchPage.refineFields = this.refineFields;
|
|
|
|
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
|
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
|
|
|
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
|
|
|
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
|
|
|
|
this.filters = this.createFilters();
|
|
|
|
var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params);
|
2018-10-11 11:10:35 +02:00
|
|
|
var csvParameters = this.searchPage.getQueryParametersFromUrl(params);
|
|
|
|
|
2019-02-14 11:15:44 +01:00
|
|
|
//console.info("|"+queryParameters+"|");
|
2018-10-11 11:10:35 +02:00
|
|
|
this._getResults(queryParameters, csvParameters, false, this.searchUtils.page, this.searchUtils.size);
|
2017-12-19 13:53:46 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
if(this.sub){
|
|
|
|
this.sub.unsubscribe();
|
|
|
|
}
|
|
|
|
if(this.subResults){
|
|
|
|
this.subResults.unsubscribe();
|
|
|
|
} }
|
2018-10-11 11:10:35 +02:00
|
|
|
private _getResults(parameters:string, csv_parameters:string, refine:boolean, page: number, size: number){
|
|
|
|
if(csv_parameters.indexOf("fq=") != -1) {
|
|
|
|
this.csvParams = csv_parameters+" and "+this.resourcesQuery;
|
|
|
|
} else {
|
|
|
|
this.csvParams = csv_parameters+"&fq="+this.resourcesQuery;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
//this.searchPage.openLoading();
|
|
|
|
this.disableForms = true;
|
|
|
|
this.results = [];
|
|
|
|
this.searchUtils.totalResults = 0;
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, [],this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
this.searchUtils.totalResults = data[0];
|
2019-02-14 11:15:44 +01:00
|
|
|
//console.info("search Content Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
2017-12-19 13:53:46 +01:00
|
|
|
this.results = data[1];
|
|
|
|
this.searchPage.checkSelectedFilters(this.filters);
|
|
|
|
this.searchPage.updateBaseUrlWithParameters(this.filters);
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if(this.searchUtils.totalResults == 0 ){
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
//this.searchPage.closeLoading();
|
|
|
|
this.disableForms = false;
|
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
2019-02-15 13:50:24 +01:00
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error getting compatible content providers", err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
2019-02-15 13:50:24 +01:00
|
|
|
/*if(err.status == '404') {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
2019-02-15 13:50:24 +01:00
|
|
|
}*/
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
//this.searchPage.closeLoading();
|
|
|
|
this.disableForms = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
private setFilters(){
|
|
|
|
//TODO set filters from
|
|
|
|
}
|
|
|
|
|
2018-10-11 11:10:35 +02:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
private createFilters():Filter[] {
|
|
|
|
var filter_names=["Type","Compatibility Level"];
|
|
|
|
var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname"];
|
|
|
|
var searchFields = new SearchFields();
|
|
|
|
var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS;
|
|
|
|
var value_names=[
|
|
|
|
/*[
|
|
|
|
"Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository",
|
|
|
|
"Institutional Repositories Aggregators",
|
|
|
|
"Thematic Repositories Aggregators", "Other Repositories Aggregators",
|
|
|
|
"Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"],
|
|
|
|
*/
|
|
|
|
[
|
|
|
|
"Institutional Repository", "Thematic Repository", "Publication Repository",
|
|
|
|
"Institutional Repository Aggregator",
|
2018-07-05 17:50:43 +02:00
|
|
|
"Thematic Repository Aggregator", "Publication Repository Aggregator",
|
2019-03-01 11:21:47 +01:00
|
|
|
"Data Repository", "Data Repository Aggregator", "CRIS System", "Publication Catalogue",
|
2018-07-05 17:50:43 +02:00
|
|
|
"Software Repository", "Software Repository Aggregator"],
|
2020-02-26 12:24:50 +01:00
|
|
|
["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", "OpenAIRE CRIS v1.1",
|
2018-07-05 17:50:43 +02:00
|
|
|
"collected from a compatible aggregator", "proprietary", "under validation"]];
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
var value_original_ids=[
|
|
|
|
["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::institutional","aggregator::pubsrepository::thematic","aggregator::pubsrepository::unknown",
|
2019-03-01 11:21:47 +01:00
|
|
|
"datarepository::unknown", "aggregator::datarepository", "crissystem", "pubscatalogue::unknown", "softwarerepository", "aggregator::softwarerepository"],
|
2017-12-19 13:53:46 +01:00
|
|
|
//["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
|
2020-02-26 12:24:50 +01:00
|
|
|
["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", "OpenAIRE CRIS v1.1",
|
2018-07-05 17:50:43 +02:00
|
|
|
"collected from a compatible aggregator", "proprietary", "under validation"]];
|
2017-12-19 13:53:46 +01:00
|
|
|
var filters: Filter[] =[];
|
|
|
|
for(var i =0 ; i < filter_names.length;i++){
|
|
|
|
var values:Value[] = [];
|
|
|
|
for(var j =0 ; j < value_names[i].length;j++){
|
|
|
|
var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false}
|
|
|
|
values.push(value);
|
|
|
|
}
|
2020-02-17 15:19:14 +01:00
|
|
|
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" };
|
2017-12-19 13:53:46 +01:00
|
|
|
filters.push(filter);
|
|
|
|
}
|
|
|
|
return filters;
|
|
|
|
}
|
2019-02-15 13:50:24 +01:00
|
|
|
|
|
|
|
private handleError(message: string, error) {
|
|
|
|
console.error("Compatible Content Providers (Repositories) Search Page: "+message, error);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|