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';
|
|
|
|
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
|
|
|
|
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
|
|
|
import {SearchPageTableViewComponent } from '../searchUtils/searchPageTableView.component';
|
|
|
|
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
|
|
|
|
|
|
|
|
@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"
|
|
|
|
[showResultCount]=false
|
|
|
|
[disableForms]="disableForms"
|
|
|
|
[searchViewLink]="'/search/content-providers'"
|
|
|
|
searchFormClass="compatibleDatasourcesTableSearchForm"
|
|
|
|
formPlaceholderText="Search for OpenAIRE Content Providers">
|
|
|
|
</search-page-table>
|
|
|
|
`
|
|
|
|
|
|
|
|
})
|
|
|
|
export class SearchCompatibleDataprovidersTableComponent {
|
|
|
|
private errorCodes: ErrorCodes;
|
|
|
|
|
|
|
|
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 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;
|
|
|
|
|
|
|
|
@ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ;
|
|
|
|
|
|
|
|
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) {
|
|
|
|
this.errorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
this.baseUrl = OpenaireProperties.getLinkToSearchCompatibleDataProvidersTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
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'];
|
|
|
|
this.filters = this.createFilters();
|
|
|
|
this.searchPage.getParametersFromUrl(params);
|
|
|
|
this._getResults();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
if(this.sub){
|
|
|
|
this.sub.unsubscribe();
|
|
|
|
}
|
|
|
|
if(this.subResults){
|
|
|
|
this.subResults.unsubscribe();
|
|
|
|
} }
|
|
|
|
private _getResults(){
|
|
|
|
//this.csvParams = this.resourcesQuery+"&type=datasources";
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
this.disableForms = true;
|
|
|
|
this.results = [];
|
|
|
|
this.searchUtils.totalResults = 0;
|
|
|
|
|
|
|
|
let size: number = 0;
|
|
|
|
this.subResults = this._searchDataprovidersService.searchCompatibleDataprovidersTable().subscribe(
|
|
|
|
data => {
|
|
|
|
size = data;
|
|
|
|
if(size > 0) {
|
|
|
|
this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders("", null, 1, size, []).subscribe(
|
|
|
|
data => {
|
|
|
|
this.searchUtils.totalResults = data[0];
|
|
|
|
console.info("search Content Providers [total results:"+this.searchUtils.totalResults+"]");
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
this.disableForms = false;
|
2018-01-11 11:55:54 +01:00
|
|
|
this.searchPage.triggerInitialLoad();
|
|
|
|
this.searchPage.transform(this.results);
|
2017-12-19 13:53:46 +01:00
|
|
|
},
|
|
|
|
err => {
|
|
|
|
console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
|
|
|
if(err.status == '404') {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.disableForms = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.searchPage.checkSelectedFilters(this.filters);
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
this.disableForms = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
|
|
|
if(err.status == '404') {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
private setFilters(){
|
|
|
|
//TODO set filters from
|
|
|
|
}
|
|
|
|
|
|
|
|
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",
|
|
|
|
"Thematic Repositories Aggregators", "Publication Repository Aggregator",
|
|
|
|
"Data Repository", "Data Repository Aggregator", "CRIS Systems", "Publication Catalogue"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
["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)"]];
|
|
|
|
|
|
|
|
var value_original_ids=[
|
|
|
|
["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::institutional","aggregator::pubsrepository::thematic","aggregator::pubsrepository::unknown",
|
|
|
|
"datarepository::unknown", "aggregator::datarepository", "cris", "pubscatalogue::unknown"],
|
|
|
|
//["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
|
|
|
|
["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)"]];
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or' };
|
|
|
|
filters.push(filter);
|
|
|
|
}
|
|
|
|
return filters;
|
|
|
|
}
|
|
|
|
}
|