1 |
50169
|
argiro.kok
|
import {Component, Input, ViewChild} from '@angular/core';
|
2 |
|
|
import {Location} from '@angular/common';
|
3 |
|
|
import { ActivatedRoute} from '@angular/router';
|
4 |
|
|
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
|
5 |
|
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
6 |
|
|
import {SearchResult} from '../../utils/entities/searchResult';
|
7 |
50761
|
argiro.kok
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
8 |
50169
|
argiro.kok
|
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
9 |
|
|
import {SearchPageTableViewComponent } from '../searchUtils/searchPageTableView.component';
|
10 |
|
|
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
|
11 |
50586
|
argiro.kok
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
12 |
50169
|
argiro.kok
|
|
13 |
|
|
@Component({
|
14 |
|
|
selector: 'search-content-providers-table',
|
15 |
|
|
template: `
|
16 |
|
|
|
17 |
|
|
<search-page-table pageTitle="OpenAIRE Content Providers Table"
|
18 |
|
|
type="content providers" entityType="dataprovider" [(filters)] = "filters"
|
19 |
|
|
[(results)] = "results" [(searchUtils)] = "searchUtils"
|
20 |
|
|
[showResultCount]=false
|
21 |
|
|
[disableForms]="disableForms"
|
22 |
|
|
[searchViewLink]="'/search/content-providers'"
|
23 |
|
|
searchFormClass="compatibleDatasourcesTableSearchForm"
|
24 |
|
|
formPlaceholderText="Search for OpenAIRE Content Providers">
|
25 |
|
|
</search-page-table>
|
26 |
|
|
`
|
27 |
|
|
|
28 |
|
|
})
|
29 |
|
|
export class SearchCompatibleDataprovidersTableComponent {
|
30 |
|
|
private errorCodes: ErrorCodes;
|
31 |
|
|
|
32 |
|
|
public results =[];
|
33 |
|
|
public filters =[];
|
34 |
|
|
public baseUrl:string;
|
35 |
|
|
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
36 |
|
|
public sub: any; public subResults: any;
|
37 |
|
|
public _location:Location;
|
38 |
|
|
public searchFields:SearchFields = new SearchFields();
|
39 |
|
|
public refineFields: string[] = this.searchFields.COMPATIBLE_DATAPROVIDER_FIELDS;
|
40 |
|
|
|
41 |
|
|
/*public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ],
|
42 |
|
|
"export":[]
|
43 |
|
|
};
|
44 |
|
|
public CSVDownloaded = false;
|
45 |
|
|
public csvParams: string;
|
46 |
|
|
public resourcesQuery = "&query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))";*/
|
47 |
|
|
|
48 |
|
|
public disableForms: boolean = false;
|
49 |
50586
|
argiro.kok
|
properties:EnvProperties;
|
50 |
50169
|
argiro.kok
|
@ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ;
|
51 |
|
|
|
52 |
|
|
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) {
|
53 |
|
|
this.errorCodes = new ErrorCodes();
|
54 |
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
55 |
50586
|
argiro.kok
|
}
|
56 |
50169
|
argiro.kok
|
|
57 |
|
|
public ngOnInit() {
|
58 |
50586
|
argiro.kok
|
this.route.data
|
59 |
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
60 |
|
|
this.properties = data.envSpecific;
|
61 |
|
|
this.baseUrl = data.envSpecific.searchLinkToEntityRegistriesDataProvidersTable;
|
62 |
|
|
|
63 |
|
|
});
|
64 |
50169
|
argiro.kok
|
this.searchPage.refineFields = this.refineFields;
|
65 |
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
66 |
|
|
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
67 |
|
|
//this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
|
68 |
|
|
this.filters = this.createFilters();
|
69 |
|
|
this.searchPage.getParametersFromUrl(params);
|
70 |
|
|
this._getResults();
|
71 |
|
|
});
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
public ngOnDestroy() {
|
75 |
|
|
if(this.sub){
|
76 |
|
|
this.sub.unsubscribe();
|
77 |
|
|
}
|
78 |
|
|
if(this.subResults){
|
79 |
|
|
this.subResults.unsubscribe();
|
80 |
|
|
} }
|
81 |
|
|
private _getResults(){
|
82 |
|
|
//this.csvParams = this.resourcesQuery+"&type=datasources";
|
83 |
|
|
|
84 |
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
85 |
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
86 |
|
|
this.disableForms = true;
|
87 |
|
|
this.results = [];
|
88 |
|
|
this.searchUtils.totalResults = 0;
|
89 |
|
|
|
90 |
|
|
let size: number = 0;
|
91 |
50586
|
argiro.kok
|
this.subResults = this._searchDataprovidersService.searchCompatibleDataprovidersTable(this.properties).subscribe(
|
92 |
50169
|
argiro.kok
|
data => {
|
93 |
|
|
size = data;
|
94 |
|
|
if(size > 0) {
|
95 |
50586
|
argiro.kok
|
this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders("", null, 1, size, [],this.properties).subscribe(
|
96 |
50169
|
argiro.kok
|
data => {
|
97 |
|
|
this.searchUtils.totalResults = data[0];
|
98 |
|
|
console.info("search Content Providers [total results:"+this.searchUtils.totalResults+"]");
|
99 |
|
|
this.results = data[1];
|
100 |
|
|
|
101 |
|
|
this.searchPage.checkSelectedFilters(this.filters);
|
102 |
|
|
|
103 |
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
104 |
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
105 |
|
|
if(this.searchUtils.totalResults == 0 ){
|
106 |
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
107 |
|
|
}
|
108 |
|
|
this.disableForms = false;
|
109 |
50277
|
argiro.kok
|
this.searchPage.triggerInitialLoad();
|
110 |
|
|
this.searchPage.transform(this.results);
|
111 |
50169
|
argiro.kok
|
},
|
112 |
|
|
err => {
|
113 |
|
|
console.log(err);
|
114 |
|
|
//TODO check erros (service not available, bad request)
|
115 |
|
|
// if( ){
|
116 |
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
117 |
|
|
// }
|
118 |
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
119 |
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
120 |
|
|
if(err.status == '404') {
|
121 |
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
122 |
|
|
} else if(err.status == '500') {
|
123 |
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
124 |
|
|
} else {
|
125 |
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
this.disableForms = false;
|
129 |
|
|
|
130 |
|
|
}
|
131 |
|
|
);
|
132 |
|
|
} else {
|
133 |
|
|
this.searchPage.checkSelectedFilters(this.filters);
|
134 |
|
|
|
135 |
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
136 |
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
137 |
|
|
this.disableForms = false;
|
138 |
|
|
}
|
139 |
|
|
},
|
140 |
|
|
err => {
|
141 |
|
|
console.log(err);
|
142 |
|
|
//TODO check erros (service not available, bad request)
|
143 |
|
|
// if( ){
|
144 |
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
145 |
|
|
// }
|
146 |
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
147 |
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
148 |
|
|
if(err.status == '404') {
|
149 |
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
150 |
|
|
} else if(err.status == '500') {
|
151 |
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
152 |
|
|
} else {
|
153 |
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
154 |
|
|
}
|
155 |
|
|
}
|
156 |
|
|
);
|
157 |
|
|
|
158 |
|
|
}
|
159 |
|
|
private setFilters(){
|
160 |
|
|
//TODO set filters from
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
private createFilters():Filter[] {
|
164 |
|
|
var filter_names=["Type","Compatibility Level"];
|
165 |
|
|
var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname"];
|
166 |
|
|
var searchFields = new SearchFields();
|
167 |
|
|
var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS;
|
168 |
|
|
var value_names=[
|
169 |
|
|
/*[
|
170 |
|
|
"Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository",
|
171 |
|
|
"Institutional Repositories Aggregators",
|
172 |
|
|
"Thematic Repositories Aggregators", "Other Repositories Aggregators",
|
173 |
|
|
"Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"],
|
174 |
|
|
*/
|
175 |
|
|
[
|
176 |
|
|
"Institutional Repository", "Thematic Repository", "Publication Repository",
|
177 |
|
|
"Institutional Repository Aggregator",
|
178 |
|
|
"Thematic Repositories Aggregators", "Publication Repository Aggregator",
|
179 |
|
|
"Data Repository", "Data Repository Aggregator", "CRIS Systems", "Publication Catalogue"],
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
["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)"]];
|
185 |
|
|
|
186 |
|
|
var value_original_ids=[
|
187 |
|
|
["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::institutional","aggregator::pubsrepository::thematic","aggregator::pubsrepository::unknown",
|
188 |
|
|
"datarepository::unknown", "aggregator::datarepository", "cris", "pubscatalogue::unknown"],
|
189 |
|
|
//["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
|
190 |
|
|
["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)"]];
|
191 |
|
|
var filters: Filter[] =[];
|
192 |
|
|
for(var i =0 ; i < filter_names.length;i++){
|
193 |
|
|
var values:Value[] = [];
|
194 |
|
|
for(var j =0 ; j < value_names[i].length;j++){
|
195 |
|
|
var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false}
|
196 |
|
|
values.push(value);
|
197 |
|
|
}
|
198 |
|
|
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or' };
|
199 |
|
|
filters.push(filter);
|
200 |
|
|
}
|
201 |
|
|
return filters;
|
202 |
|
|
}
|
203 |
|
|
}
|