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