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 {SearchPageTableViewComponent } from '../searchUtils/searchPageTableView.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-table',
|
|
|
|
template: `
|
|
|
|
|
|
|
|
<search-page-table pageTitle="OpenAIRE Content Providers Table"
|
|
|
|
type="content providers" entityType="dataprovider" [(filters)] = "filters"
|
|
|
|
[(results)] = "results" [(searchUtils)] = "searchUtils"
|
2018-03-01 13:03:40 +01:00
|
|
|
[columnNames]="columnNames"
|
2017-12-19 13:53:46 +01:00
|
|
|
[showResultCount]=false
|
|
|
|
[disableForms]="disableForms"
|
2018-05-23 15:24:13 +02:00
|
|
|
[enableSearchView]="enableSearchView"
|
2017-12-19 13:53:46 +01:00
|
|
|
[searchViewLink]="'/search/content-providers'"
|
|
|
|
searchFormClass="compatibleDatasourcesTableSearchForm"
|
2019-02-12 12:15:21 +01:00
|
|
|
formPlaceholderText="Search for OpenAIRE Content Providers"
|
|
|
|
[mapUrl]="mapUrl" [mapTooltipType]="'repositories'">
|
2017-12-19 13:53:46 +01:00
|
|
|
</search-page-table>
|
|
|
|
`
|
|
|
|
|
|
|
|
})
|
|
|
|
export class SearchCompatibleDataprovidersTableComponent {
|
|
|
|
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 =[];
|
2018-03-01 13:03:40 +01:00
|
|
|
public columnNames = ["Name", "Type", "Country", "Institution", "Compatibility"];
|
2017-12-19 13:53:46 +01:00
|
|
|
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;
|
2019-02-12 12:15:21 +01:00
|
|
|
public mapUrl: string;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
/*public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ],
|
|
|
|
"export":[]
|
|
|
|
};
|
|
|
|
public CSVDownloaded = false;
|
|
|
|
public csvParams: string;
|
|
|
|
public resourcesQuery = "&query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))";*/
|
|
|
|
|
|
|
|
public disableForms: boolean = false;
|
2018-05-23 15:24:13 +02:00
|
|
|
public enableSearchView: boolean = true;
|
2018-02-05 14:14:59 +01:00
|
|
|
properties:EnvProperties;
|
2017-12-19 13:53:46 +01:00
|
|
|
@ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ;
|
|
|
|
|
|
|
|
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;
|
2018-02-05 14:14:59 +01:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
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.searchLinkToEntityRegistriesDataProvidersTable;
|
2019-02-12 12:15:21 +01:00
|
|
|
this.mapUrl = this.properties.statisticsFrameAPIURL+"markers-test.html";
|
2018-02-05 14:14:59 +01:00
|
|
|
});
|
2019-02-12 12:15:21 +01:00
|
|
|
this.refineFields.push("datasourcecountryname");
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchPage.refineFields = this.refineFields;
|
|
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
|
|
|
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
|
|
|
//this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
|
2019-02-12 12:15:21 +01:00
|
|
|
//this.filters = this.createFilters();
|
|
|
|
//this.searchPage.getParametersFromUrl(params);
|
|
|
|
this._getResults(params);
|
2017-12-19 13:53:46 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
if(this.sub){
|
|
|
|
this.sub.unsubscribe();
|
|
|
|
}
|
|
|
|
if(this.subResults){
|
|
|
|
this.subResults.unsubscribe();
|
|
|
|
} }
|
2019-02-12 12:15:21 +01:00
|
|
|
private _getResults(params){
|
2017-12-19 13:53:46 +01:00
|
|
|
//this.csvParams = this.resourcesQuery+"&type=datasources";
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
this.disableForms = true;
|
2018-05-23 15:24:13 +02:00
|
|
|
this.enableSearchView = false;
|
2017-12-19 13:53:46 +01:00
|
|
|
this.results = [];
|
|
|
|
this.searchUtils.totalResults = 0;
|
|
|
|
|
|
|
|
let size: number = 0;
|
2018-02-05 14:14:59 +01:00
|
|
|
this.subResults = this._searchDataprovidersService.searchCompatibleDataprovidersTable(this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
size = data;
|
|
|
|
if(size > 0) {
|
2018-02-05 14:14:59 +01:00
|
|
|
this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders("", null, 1, size, [],this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
2019-02-12 12:15:21 +01:00
|
|
|
this.filters = this.createFilters(data[1], params);
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchUtils.totalResults = data[0];
|
|
|
|
this.results = data[1];
|
|
|
|
|
|
|
|
this.searchPage.checkSelectedFilters(this.filters);
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if(this.searchUtils.totalResults == 0 ){
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
2018-05-23 15:24:13 +02:00
|
|
|
} else {
|
|
|
|
this.searchPage.triggerInitialLoad();
|
|
|
|
this.searchPage.transform(this.results);
|
|
|
|
this.disableForms = false;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2018-05-23 15:24:13 +02:00
|
|
|
this.enableSearchView = true;
|
2017-12-19 13:53:46 +01:00
|
|
|
},
|
|
|
|
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
|
|
|
}*/
|
2018-05-23 15:24:13 +02:00
|
|
|
this.enableSearchView = true;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.searchPage.checkSelectedFilters(this.filters);
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
2018-05-23 15:24:13 +02:00
|
|
|
this.enableSearchView = true;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
2019-02-15 13:50:24 +01:00
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error getting compatible content providers (size=0)", 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
|
|
|
}*/
|
2018-05-23 15:24:13 +02:00
|
|
|
this.enableSearchView = true;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
private setFilters(){
|
|
|
|
//TODO set filters from
|
|
|
|
}
|
|
|
|
|
2019-02-12 12:15:21 +01:00
|
|
|
private createFilters(data, params):Filter[] {
|
|
|
|
let length = Array.isArray(data) ? data.length : 1;
|
|
|
|
|
|
|
|
var filter_names=["Type","Compatibility","Country"];
|
|
|
|
var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname","datasourcecountryname"];
|
2017-12-19 13:53:46 +01:00
|
|
|
var searchFields = new SearchFields();
|
|
|
|
var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS;
|
2019-02-12 12:15:21 +01:00
|
|
|
filter_original_ids.push("datasourcecountryname");
|
|
|
|
var filter_valueIsExact = [true, true, false];
|
|
|
|
|
|
|
|
//this.refineFields = ["relfunder"];
|
|
|
|
//this.searchPage.refineFields = this.refineFields;
|
|
|
|
this.searchPage.getParametersFromUrl(params);
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
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",
|
|
|
|
"Data Repository", "Data Repository Aggregator", "CRIS Systems", "Publication Catalogue",
|
|
|
|
"Software Repository", "Software Repository Aggregator"],
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-05 17:50:43 +02:00
|
|
|
["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)",
|
|
|
|
"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",
|
2018-07-05 17:50:43 +02:00
|
|
|
"datarepository::unknown", "aggregator::datarepository", "cris", "pubscatalogue::unknown", "softwarerepository", "aggregator::softwarerepository"],
|
2017-12-19 13:53:46 +01:00
|
|
|
//["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
|
2018-07-05 17:50:43 +02:00
|
|
|
["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)",
|
|
|
|
"collected from a compatible aggregator", "proprietary", "under validation"]];
|
2019-02-12 12:15:21 +01:00
|
|
|
|
|
|
|
var countries = new Set<String>();
|
|
|
|
var value_name = [];
|
|
|
|
var value_original_id = [];
|
|
|
|
let i, j;
|
2019-02-15 13:50:24 +01:00
|
|
|
|
2019-02-12 12:15:21 +01:00
|
|
|
for(i=0; i<length; i++) {
|
|
|
|
let resData = Array.isArray(data) ? data[i] : data;
|
|
|
|
if(resData.countries) {
|
|
|
|
let length2 = Array.isArray(resData.countries) ? resData.countries.length : 1;
|
|
|
|
|
|
|
|
for(j=0; j<length2; j++) {
|
|
|
|
let datasourceCountry = Array.isArray(resData.countries) ? resData.countries[j] : resData.countries;
|
|
|
|
if(!countries.has(datasourceCountry)) {
|
|
|
|
countries.add(datasourceCountry);
|
|
|
|
value_name.push(datasourceCountry);
|
|
|
|
value_original_id.push(datasourceCountry.trim());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
value_names.push(value_name);
|
|
|
|
value_original_ids.push(value_original_id);
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
var filters: Filter[] =[];
|
2019-02-12 12:15:21 +01:00
|
|
|
for(i =0 ; i < filter_names.length;i++){
|
2017-12-19 13:53:46 +01:00
|
|
|
var values:Value[] = [];
|
2019-02-12 12:15:21 +01:00
|
|
|
for(j =0 ; j < value_names[i].length;j++){
|
2017-12-19 13:53:46 +01:00
|
|
|
var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false}
|
|
|
|
values.push(value);
|
|
|
|
}
|
2019-07-15 18:11:07 +02:00
|
|
|
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: filter_valueIsExact[i], valueIsUnique: false };
|
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 - Table view: "+message, error);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|