1
|
import {merge as observableMerge} from 'rxjs';
|
2
|
import {Component, Input} from '@angular/core';
|
3
|
import {ActivatedRoute, Router} from '@angular/router';
|
4
|
import {Meta, Title} from '@angular/platform-browser';
|
5
|
|
6
|
|
7
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
8
|
|
9
|
import {DataProviderInfo} from '../../utils/entities/dataProviderInfo';
|
10
|
import {DataProviderService} from './dataProvider.service';
|
11
|
import {FetchPublications} from '../../utils/fetchEntitiesClasses/fetchPublications.class';
|
12
|
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
13
|
import {FetchDatasets} from '../../utils/fetchEntitiesClasses/fetchDatasets.class';
|
14
|
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
15
|
import {FetchSoftware} from '../../utils/fetchEntitiesClasses/fetchSoftware.class';
|
16
|
import {SearchSoftwareService} from '../../services/searchSoftware.service';
|
17
|
import {FetchOrps} from '../../utils/fetchEntitiesClasses/fetchOrps.class';
|
18
|
import {SearchOrpsService} from '../../services/searchOrps.service';
|
19
|
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
|
20
|
import {SearchProjectsService} from '../../services/searchProjects.service';
|
21
|
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
|
22
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
23
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
24
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
25
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
26
|
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
27
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
28
|
import {HelperService} from "../../utils/helper/helper.service";
|
29
|
|
30
|
|
31
|
@Component({
|
32
|
selector: 'dataprovider',
|
33
|
templateUrl: 'dataProvider.component.html',
|
34
|
})
|
35
|
|
36
|
export class DataProviderComponent {
|
37
|
@Input() piwikSiteId = null;
|
38
|
@Input() communityId = null;
|
39
|
public dataProviderInfo: DataProviderInfo;
|
40
|
public datasourceId: string;
|
41
|
|
42
|
// Message variables
|
43
|
public warningMessage = "";
|
44
|
public errorMessage = "";
|
45
|
public showLoading: boolean = true;
|
46
|
|
47
|
// Variable to specify requests with either collectedFrom or hostedBy
|
48
|
public paramsForSearchLink = {};
|
49
|
|
50
|
// Metrics tab variables
|
51
|
public metricsClicked: boolean;
|
52
|
public viewsFrameUrl: string;
|
53
|
public downloadsFrameUrl: string;
|
54
|
public totalViews: number;
|
55
|
public totalDownloads: number;
|
56
|
public pageViews: number;
|
57
|
|
58
|
// Statistics tab variables
|
59
|
public statsClicked: boolean = false;
|
60
|
public docsTimelineUrl: string;
|
61
|
public docsTypesUrl: string;
|
62
|
public docsFunderUrl: string;
|
63
|
public dataProjectsUrl: string;
|
64
|
public pubsProjectsUrl: string;
|
65
|
|
66
|
// Variables for publications, research data, projects, content providers, related content providers tabs
|
67
|
public fetchPublications: FetchPublications;
|
68
|
public fetchDatasets: FetchDatasets;
|
69
|
public fetchSoftware: FetchSoftware;
|
70
|
public fetchOrps: FetchOrps;
|
71
|
public fetchProjects: FetchProjects;
|
72
|
public fetchDataproviders: FetchDataproviders;
|
73
|
public fetchAggregatorsPublications: FetchPublications;
|
74
|
public fetchAggregatorsDatasets: FetchDatasets;
|
75
|
public fetchAggregatorsSoftware: FetchSoftware;
|
76
|
public fetchAggregatorsOrps: FetchOrps;
|
77
|
|
78
|
public loadingRelatedDatasources: boolean = true;
|
79
|
|
80
|
// Active tab variable for responsiveness - show tabs only if main request is completed
|
81
|
public activeTab: string = "";
|
82
|
public showTabs: boolean = false;
|
83
|
|
84
|
public routerHelper: RouterHelper = new RouterHelper();
|
85
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
86
|
public pageContents = null;
|
87
|
public divContents = null;
|
88
|
|
89
|
// Request results of each tab only the one time (first time tab is clicked)
|
90
|
private reloadPublications: boolean = true;
|
91
|
private reloadDatasets: boolean = true;
|
92
|
private reloadSoftware: boolean = true;
|
93
|
private reloadOrps: boolean = true;
|
94
|
private reloadProjects: boolean = true;
|
95
|
private reloadDataproviders: boolean = true;
|
96
|
private reloadRelatedDatasources: boolean = true;
|
97
|
|
98
|
sub: any;
|
99
|
piwiksub: any;
|
100
|
subInfo: any;
|
101
|
relatedDatasourcesSub: any;
|
102
|
properties: EnvProperties;
|
103
|
|
104
|
constructor(private _dataproviderService: DataProviderService,
|
105
|
private _piwikService: PiwikService,
|
106
|
private route: ActivatedRoute,
|
107
|
private _meta: Meta,
|
108
|
private _title: Title,
|
109
|
private _router: Router,
|
110
|
private _searchPublicationsService: SearchPublicationsService,
|
111
|
private _searchDatasetsService: SearchDatasetsService,
|
112
|
private _searchSoftwareService: SearchSoftwareService,
|
113
|
private _searchOrpsService: SearchOrpsService,
|
114
|
private _searchProjectsService: SearchProjectsService,
|
115
|
private _searchDataprovidersService: SearchDataprovidersService,
|
116
|
private seoService: SEOService,
|
117
|
private helper: HelperService) {
|
118
|
this.fetchPublications = new FetchPublications(this._searchPublicationsService);
|
119
|
this.fetchDatasets = new FetchDatasets(this._searchDatasetsService);
|
120
|
this.fetchSoftware = new FetchSoftware(this._searchSoftwareService);
|
121
|
this.fetchOrps = new FetchOrps(this._searchOrpsService);
|
122
|
this.fetchProjects = new FetchProjects(this._searchProjectsService);
|
123
|
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
124
|
|
125
|
}
|
126
|
|
127
|
ngOnInit() {
|
128
|
this.route.data
|
129
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
130
|
this.properties = data.envSpecific;
|
131
|
//this.getDivContents();
|
132
|
this.getPageContents();
|
133
|
this.updateUrl(data.envSpecific.baseLink + this._router.url);
|
134
|
|
135
|
});
|
136
|
this.sub = this.route.queryParams.subscribe(data => {
|
137
|
this.updateTitle("Content provider");
|
138
|
this.updateDescription("");
|
139
|
this.datasourceId = data['datasourceId'];
|
140
|
if (this.datasourceId) {
|
141
|
this.getDataProviderInfo(this.datasourceId);
|
142
|
}
|
143
|
|
144
|
HelperFunctions.scroll();
|
145
|
});
|
146
|
}
|
147
|
|
148
|
private getPageContents() {
|
149
|
this.helper.getPageHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
|
150
|
this.pageContents = contents;
|
151
|
})
|
152
|
}
|
153
|
|
154
|
private getDivContents() {
|
155
|
this.helper.getDivHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
|
156
|
this.divContents = contents;
|
157
|
})
|
158
|
}
|
159
|
|
160
|
ngOnDestroy() {
|
161
|
if (this.sub) {
|
162
|
this.sub.unsubscribe();
|
163
|
}
|
164
|
if (this.piwiksub) {
|
165
|
this.piwiksub.unsubscribe();
|
166
|
}
|
167
|
if (this.subInfo) {
|
168
|
this.subInfo.unsubscribe();
|
169
|
}
|
170
|
|
171
|
if (this.relatedDatasourcesSub) {
|
172
|
this.relatedDatasourcesSub.unsubscribe();
|
173
|
}
|
174
|
}
|
175
|
|
176
|
private getDataProviderInfo(id: string) {
|
177
|
this.warningMessage = '';
|
178
|
this.errorMessage = ""
|
179
|
this.showLoading = true;
|
180
|
|
181
|
this.dataProviderInfo = null;
|
182
|
|
183
|
this.showTabs = false;
|
184
|
if (this.datasourceId == null || this.datasourceId == '') {
|
185
|
this.showLoading = false;
|
186
|
this.warningMessage = "No valid datasource id";
|
187
|
} else {
|
188
|
this.subInfo = this._dataproviderService.getDataproviderInfo(this.datasourceId, this.properties).subscribe(
|
189
|
data => {
|
190
|
this.dataProviderInfo = data;
|
191
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this._router.url);
|
192
|
if (typeof document !== 'undefined') {
|
193
|
this.getDataProviderAggregationStatus(this.dataProviderInfo.originalId);
|
194
|
}
|
195
|
this.initTabs();
|
196
|
this.showTabs = true;
|
197
|
this.updateTitle(this.dataProviderInfo.title.name);
|
198
|
this.updateDescription("Content provider, " + this.dataProviderInfo.title.name);
|
199
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
200
|
this.piwiksub = this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name, this.piwikSiteId).subscribe();
|
201
|
}
|
202
|
|
203
|
this.showLoading = false;
|
204
|
|
205
|
if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
|
206
|
this.activeTab = this.dataProviderInfo.tabs[0].name;
|
207
|
}
|
208
|
},
|
209
|
err => {
|
210
|
//console.log(err);
|
211
|
this.handleError("Error getting content provider for id: " + this.datasourceId, err);
|
212
|
this.errorMessage = 'No dataProvider found';
|
213
|
this.showLoading = false;
|
214
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToDataProviders);
|
215
|
}
|
216
|
);
|
217
|
}
|
218
|
}
|
219
|
|
220
|
private getDataProviderAggregationStatus(originalId: string) {
|
221
|
this.subInfo = this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe(
|
222
|
data => {
|
223
|
this.dataProviderInfo.aggregationStatus = data;
|
224
|
},
|
225
|
err => {
|
226
|
//console.log(err);
|
227
|
this.handleError("Error getting content provider aggregation status for id: " + this.datasourceId, err);
|
228
|
}
|
229
|
);
|
230
|
}
|
231
|
|
232
|
private updateDescription(description: string) {
|
233
|
this._meta.updateTag({content: description}, "name='description'");
|
234
|
this._meta.updateTag({content: description}, "property='og:description'");
|
235
|
}
|
236
|
|
237
|
private updateTitle(title: string) {
|
238
|
var _prefix = "";
|
239
|
if(this.communityId) {
|
240
|
_prefix = "OpenAIRE | ";
|
241
|
}
|
242
|
var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
|
243
|
this._title.setTitle(_title);
|
244
|
this._meta.updateTag({content: _title}, "property='og:title'");
|
245
|
}
|
246
|
|
247
|
private updateUrl(url: string) {
|
248
|
this._meta.updateTag({content: url}, "property='og:url'");
|
249
|
}
|
250
|
|
251
|
private initTabs() {
|
252
|
|
253
|
if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
|
254
|
this.reloadPublications = true;
|
255
|
this.reloadDatasets = true;
|
256
|
this.reloadSoftware = true;
|
257
|
this.reloadOrps = true;
|
258
|
this.reloadProjects = true;
|
259
|
this.reloadDataproviders = true;
|
260
|
this.reloadRelatedDatasources = true;
|
261
|
this.statsClicked = false;
|
262
|
|
263
|
//this.search(this.dataProviderInfo.tabs[0].content, 1, 10);
|
264
|
this.count(1, 0);
|
265
|
|
266
|
this.metricsClicked = false;
|
267
|
|
268
|
this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoViews","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
269
|
/*this.viewsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"dtsrcOpenAIRETimeline", "dtsrcName":"'+this.datasourceId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"OpenAIRE","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]},{"query":"dtsrcRepoTimeline", "dtsrcName":"'+this.datasourceId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":[""],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column","column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true';
|
270
|
*/
|
271
|
|
272
|
this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoDownloads","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
273
|
/*
|
274
|
this.downloadsFrameUrl = this.properties.framesAPIURL +'merge.php?com=query&data=[{"query":"dtsrcDownloadsTimeline","dtsrcName":"'+this.datasourceId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"chart","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true';
|
275
|
*/
|
276
|
|
277
|
this.docsTimelineUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcYear","dtsrcName":"' + this.datasourceId + '","table": "result", "fields": [{"fld": "number", "agg": "count", "type": "line", "yaxis":1, "c":true}], "xaxis":{"name": "year", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": -30, "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [{"f":0, "text": "Yearly"}], "filters": [{"name":"year","max":"2016","min":"1997"},{"name": "result_datasources-datasource-name", "values":[""], "to": "-1"}],"having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": "Year"}&w=100%&h=250';
|
278
|
this.docsTypesUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcPubs","dtsrcName":"' + this.datasourceId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=100%&h=250';
|
279
|
this.docsFunderUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcPubsFund","dtsrcName":"' + this.datasourceId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=100%&h=250';
|
280
|
this.dataProjectsUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcProjData","dtsrcName":"' + this.datasourceId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Data"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=100%&h=250';
|
281
|
this.pubsProjectsUrl = this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"dtsrcProjPubs","dtsrcName":"' + this.datasourceId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=100%&h=250';
|
282
|
|
283
|
//if({"name": "Publications", "content": "publicationsTab"} in this.dataProviderInfo.tabs) {
|
284
|
//if(this.dataProviderInfo.tabs.some(function (tab) {
|
285
|
// return tab.name === 'Publications';
|
286
|
//})) {
|
287
|
// this.relatedDataprovidersResultsType = 'publications';
|
288
|
this.fetchAggregatorsPublications = new FetchPublications(this._searchPublicationsService);
|
289
|
//} else {
|
290
|
// this.relatedDataprovidersResultsType = 'datasets';
|
291
|
this.fetchAggregatorsDatasets = new FetchDatasets(this._searchDatasetsService);
|
292
|
//}
|
293
|
this.fetchAggregatorsSoftware = new FetchSoftware(this._searchSoftwareService);
|
294
|
this.fetchAggregatorsOrps = new FetchOrps(this._searchOrpsService);
|
295
|
}
|
296
|
if (this.dataProviderInfo.resultsBy == "collectedFrom") {
|
297
|
//this.paramsForSearchLink = "?collectedFrom="+this.datasourceId+"&co=and";
|
298
|
this.paramsForSearchLink = this.routerHelper.createQueryParams(['collectedFrom', 'cl'], [this.datasourceId, 'and']);
|
299
|
} else if (this.dataProviderInfo.resultsBy == "hostedBy") {
|
300
|
//this.paramsForSearchLink = "?hostedBy="+this.datasourceId+"&ho=and";
|
301
|
this.paramsForSearchLink = this.routerHelper.createQueryParams(['hostedBy', 'hs'], [this.datasourceId, 'and']);
|
302
|
}
|
303
|
|
304
|
}
|
305
|
|
306
|
private count(page: number, size: number) {
|
307
|
for (let i = 0; i < this.dataProviderInfo.tabs.length; i++) {
|
308
|
let content: string = this.dataProviderInfo.tabs[i].content;
|
309
|
|
310
|
if (content == 'publicationsTab') {
|
311
|
this.countPublications(page, size);
|
312
|
} else if (content == 'datasetsTab') {
|
313
|
this.countDatasets(page, size);
|
314
|
} else if (content == 'softwareTab') {
|
315
|
this.countSoftware(page, size);
|
316
|
} else if (content == 'orpsTab') {
|
317
|
this.countOrps(page, size);
|
318
|
} else if (content == 'projectsTab') {
|
319
|
this.countProjects(page, size);
|
320
|
} else if (content == 'datasourcesTab') {
|
321
|
this.countDatasources(page, size);
|
322
|
}// else if(content=='relatedDatasourcesTab') {
|
323
|
// this.countRelatedDatasources(page, size);
|
324
|
//}
|
325
|
}
|
326
|
}
|
327
|
|
328
|
public search(content: string, page: number, size: number) {
|
329
|
if (content == 'publicationsTab') {
|
330
|
this.searchPublications(page, size);
|
331
|
} else if (content == 'datasetsTab') {
|
332
|
this.searchDatasets(page, size);
|
333
|
} else if (content == 'softwareTab') {
|
334
|
this.searchSoftware(page, size);
|
335
|
} else if (content == 'orpsTab') {
|
336
|
this.searchOrps(page, size);
|
337
|
} else if (content == 'projectsTab') {
|
338
|
this.searchProjects(page, size);
|
339
|
} else if (content == 'datasourcesTab') {
|
340
|
this.searchDatasources(page, size);
|
341
|
} else if (content == 'relatedDatasourcesTab') {
|
342
|
this.searchRelatedDatasources(1, 0);
|
343
|
} else if (content == 'metricsTab') {
|
344
|
this.metricsClicked = true;
|
345
|
} else if (content == 'statisticsTab') {
|
346
|
this.statsClicked = !this.statsClicked;
|
347
|
}
|
348
|
}
|
349
|
|
350
|
private searchPublications(page: number, size: number) {
|
351
|
if (this.reloadPublications &&
|
352
|
(this.fetchPublications.searchUtils.status == this.errorCodes.LOADING ||
|
353
|
this.fetchPublications.searchUtils.status == this.errorCodes.DONE)) {
|
354
|
this.fetchPublications.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
355
|
}
|
356
|
this.reloadPublications = false;
|
357
|
}
|
358
|
|
359
|
private countPublications(page: number, size: number) {
|
360
|
this.fetchPublications.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
361
|
}
|
362
|
|
363
|
private searchDatasets(page: number, size: number) {
|
364
|
if (this.reloadDatasets &&
|
365
|
(this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING ||
|
366
|
this.fetchDatasets.searchUtils.status == this.errorCodes.DONE)) {
|
367
|
this.fetchDatasets.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
368
|
}
|
369
|
this.reloadDatasets = false;
|
370
|
}
|
371
|
|
372
|
private countDatasets(page: number, size: number) {
|
373
|
this.fetchDatasets.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
374
|
}
|
375
|
|
376
|
private searchSoftware(page: number, size: number) {
|
377
|
if (this.reloadSoftware &&
|
378
|
(this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING ||
|
379
|
this.fetchSoftware.searchUtils.status == this.errorCodes.DONE)) {
|
380
|
this.fetchSoftware.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
381
|
}
|
382
|
this.reloadSoftware = false;
|
383
|
}
|
384
|
|
385
|
private countSoftware(page: number, size: number) {
|
386
|
this.fetchSoftware.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
387
|
}
|
388
|
|
389
|
private searchOrps(page: number, size: number) {
|
390
|
if (this.reloadOrps &&
|
391
|
(this.fetchOrps.searchUtils.status == this.errorCodes.LOADING ||
|
392
|
this.fetchOrps.searchUtils.status == this.errorCodes.DONE)) {
|
393
|
this.fetchOrps.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
394
|
}
|
395
|
this.reloadOrps = false;
|
396
|
}
|
397
|
|
398
|
private countOrps(page: number, size: number) {
|
399
|
this.fetchOrps.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
400
|
}
|
401
|
|
402
|
private searchProjects(page: number, size: number) {
|
403
|
if (this.reloadProjects &&
|
404
|
(this.fetchProjects.searchUtils.status == this.errorCodes.LOADING ||
|
405
|
this.fetchProjects.searchUtils.status == this.errorCodes.DONE)) {
|
406
|
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
|
407
|
}
|
408
|
this.reloadProjects = false;
|
409
|
}
|
410
|
|
411
|
private countProjects(page: number, size: number) {
|
412
|
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
|
413
|
}
|
414
|
|
415
|
private searchDatasources(page: number, size: number) {
|
416
|
if (this.reloadDataproviders &&
|
417
|
(this.fetchDataproviders.searchUtils.status == this.errorCodes.LOADING ||
|
418
|
this.fetchDataproviders.searchUtils.status == this.errorCodes.DONE)) {
|
419
|
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
|
420
|
}
|
421
|
this.reloadDataproviders = false;
|
422
|
}
|
423
|
|
424
|
private countDatasources(page: number, size: number) {
|
425
|
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
|
426
|
}
|
427
|
|
428
|
private searchRelatedDatasources(page: number, size: number) {
|
429
|
// Currently no counting is done for this tab. Following condition is always false
|
430
|
|
431
|
if (this.reloadRelatedDatasources &&
|
432
|
(this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.LOADING ||
|
433
|
this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE)
|
434
|
&&
|
435
|
(this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.LOADING ||
|
436
|
this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.DONE)
|
437
|
&&
|
438
|
(this.fetchAggregatorsSoftware.searchUtils.status == this.errorCodes.LOADING ||
|
439
|
this.fetchAggregatorsSoftware.searchUtils.status == this.errorCodes.DONE)
|
440
|
&&
|
441
|
(this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.LOADING ||
|
442
|
this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.DONE)) {
|
443
|
this.relatedDatasourcesSub = observableMerge(this.fetchAggregatorsPublications.requestComplete, this.fetchAggregatorsDatasets.requestComplete, this.fetchAggregatorsSoftware.requestComplete, this.fetchAggregatorsOrps.requestComplete)
|
444
|
.subscribe(
|
445
|
data => {
|
446
|
},
|
447
|
err => {
|
448
|
},
|
449
|
() => {
|
450
|
this.preprocessRelatedDatasources();
|
451
|
}
|
452
|
)
|
453
|
|
454
|
this.fetchAggregatorsPublications.getAggregatorResults(this.datasourceId, page, size, this.properties);
|
455
|
this.fetchAggregatorsDatasets.getAggregatorResults(this.datasourceId, page, size, this.properties);
|
456
|
this.fetchAggregatorsSoftware.getAggregatorResults(this.datasourceId, page, size, this.properties);
|
457
|
this.fetchAggregatorsOrps.getAggregatorResults(this.datasourceId, page, size, this.properties);
|
458
|
} else {
|
459
|
this.loadingRelatedDatasources = false;
|
460
|
}
|
461
|
|
462
|
|
463
|
this.reloadRelatedDatasources = false;
|
464
|
}
|
465
|
|
466
|
private countRelatedDatasources(page: number, size: number) {
|
467
|
this.fetchAggregatorsPublications.getAggregatorResults(this.datasourceId, page, size, this.properties);
|
468
|
this.fetchAggregatorsDatasets.getAggregatorResults(this.datasourceId, page, size, this.properties);
|
469
|
this.fetchAggregatorsSoftware.getAggregatorResults(this.datasourceId, page, size, this.properties);
|
470
|
this.fetchAggregatorsOrps.getAggregatorResults(this.datasourceId, page, size, this.properties);
|
471
|
}
|
472
|
|
473
|
|
474
|
private preprocessRelatedDatasources() {
|
475
|
if (this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE ||
|
476
|
this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.DONE ||
|
477
|
this.fetchAggregatorsSoftware.searchUtils.status == this.errorCodes.DONE ||
|
478
|
this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.DONE) {
|
479
|
this.dataProviderInfo.relatedDatasources = new Map<string, { "name": string, "countPublications": string, "countDatasets": string, "countSoftware": string, "countOrps": string }>();
|
480
|
}
|
481
|
for (let result of this.fetchAggregatorsPublications.results) {
|
482
|
if (!this.dataProviderInfo.relatedDatasources.has(result.id)) {
|
483
|
this.dataProviderInfo.relatedDatasources.set(result.id, {
|
484
|
"name": result.name,
|
485
|
"countPublications": result.count,
|
486
|
"countDatasets": "0",
|
487
|
"countSoftware": "0",
|
488
|
"countOrps": "0"
|
489
|
});
|
490
|
} else {
|
491
|
this.dataProviderInfo.relatedDatasources.get(result.id).countPublications = parseInt(this.dataProviderInfo.relatedDatasources.get(result.id).countPublications + result.count) + "";
|
492
|
}
|
493
|
}
|
494
|
|
495
|
for (let result of this.fetchAggregatorsDatasets.results) {
|
496
|
if (!this.dataProviderInfo.relatedDatasources.has(result.id)) {
|
497
|
this.dataProviderInfo.relatedDatasources.set(result.id, {
|
498
|
"name": result.name,
|
499
|
"countPublications": "0",
|
500
|
"countDatasets": result.count,
|
501
|
"countSoftware": "0",
|
502
|
"countOrps": "0"
|
503
|
});
|
504
|
} else {
|
505
|
this.dataProviderInfo.relatedDatasources.get(result.id).countDatasets = parseInt(this.dataProviderInfo.relatedDatasources.get(result.id).countDatasets + result.count) + "";
|
506
|
}
|
507
|
}
|
508
|
|
509
|
for (let result of this.fetchAggregatorsSoftware.results) {
|
510
|
if (!this.dataProviderInfo.relatedDatasources.has(result.id)) {
|
511
|
this.dataProviderInfo.relatedDatasources.set(result.id, {
|
512
|
"name": result.name,
|
513
|
"countPublications": "0",
|
514
|
"countDatasets": "0",
|
515
|
"countSoftware": result.count,
|
516
|
"countOrps": "0"
|
517
|
});
|
518
|
} else {
|
519
|
this.dataProviderInfo.relatedDatasources.get(result.id).countSoftware = parseInt(this.dataProviderInfo.relatedDatasources.get(result.id).countSoftware + result.count) + "";
|
520
|
}
|
521
|
}
|
522
|
|
523
|
for (let result of this.fetchAggregatorsOrps.results) {
|
524
|
if (!this.dataProviderInfo.relatedDatasources.has(result.id)) {
|
525
|
this.dataProviderInfo.relatedDatasources.set(result.id, {
|
526
|
"name": result.name,
|
527
|
"countPublications": "0",
|
528
|
"countDatasets": "0",
|
529
|
"countSoftware": "0",
|
530
|
"countOrps": result.count
|
531
|
});
|
532
|
} else {
|
533
|
this.dataProviderInfo.relatedDatasources.get(result.id).countOrps = parseInt(this.dataProviderInfo.relatedDatasources.get(result.id).countOrps + result.count) + "";
|
534
|
}
|
535
|
}
|
536
|
this.loadingRelatedDatasources = false;
|
537
|
}
|
538
|
|
539
|
public metricsResults($event) {
|
540
|
this.totalViews = $event.totalViews;
|
541
|
this.totalDownloads = $event.totalDownloads;
|
542
|
this.pageViews = $event.pageViews;
|
543
|
}
|
544
|
|
545
|
private handleError(message: string, error) {
|
546
|
console.error("Content Provider Landing Page: " + message, error);
|
547
|
}
|
548
|
}
|