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