Revision 60614
Added by Konstantinos Triantafyllou about 3 years ago
searchResearchResults.service.ts | ||
---|---|---|
11 | 11 |
|
12 | 12 |
@Injectable() |
13 | 13 |
export class SearchResearchResultsService { |
14 |
private sizeOfDescription: number = 270; |
|
15 |
public parsingFunctions: ParsingFunctions = new ParsingFunctions(); |
|
16 |
|
|
17 |
constructor(private http: HttpClient ) { |
|
14 |
private sizeOfDescription: number = 270; |
|
15 |
public parsingFunctions: ParsingFunctions = new ParsingFunctions(); |
|
16 |
|
|
17 |
constructor(private http: HttpClient) { |
|
18 |
} |
|
19 |
|
|
20 |
|
|
21 |
search(resultType: string, params: string, refineParams: string, page: number, size: number, sortBy: string, refineFields: string[], properties: EnvProperties): any { |
|
22 |
let link = properties.searchAPIURLLAst + this.getEntityName(resultType, true); |
|
23 |
|
|
24 |
let url = link + "?"; |
|
25 |
if (params != null && params != '') { |
|
26 |
url += params; |
|
18 | 27 |
} |
19 |
|
|
20 |
|
|
21 |
search (resultType:string, params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[] , properties:EnvProperties):any { |
|
22 |
let link = properties.searchAPIURLLAst+this.getEntityName(resultType,true); |
|
23 |
|
|
24 |
let url = link+"?"; |
|
25 |
if(params!= null && params != '' ) { |
|
26 |
url += params; |
|
27 |
} |
|
28 |
if(refineParams!= null && refineParams != '' ) { |
|
29 |
url += refineParams; |
|
30 |
} |
|
31 |
if(sortBy) { |
|
32 |
url += "&sortBy=" + sortBy; |
|
33 |
} |
|
34 |
url += "&page="+(page-1)+"&size="+size+"&format=json"; |
|
35 |
|
|
36 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
37 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")])); |
|
28 |
if (refineParams != null && refineParams != '') { |
|
29 |
url += refineParams; |
|
38 | 30 |
} |
39 |
|
|
40 |
searchById (resultType:string, id: string, properties:EnvProperties ):any { |
|
41 |
let url = properties.searchAPIURLLAst+this.getEntityName(resultType,true) +"/"+id+"?format=json"; |
|
42 |
|
|
43 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
44 |
.pipe(map(res => this.parseResults(resultType, res, properties))); |
|
31 |
if (sortBy) { |
|
32 |
url += "&sortBy=" + sortBy; |
|
45 | 33 |
} |
46 |
|
|
47 |
searchAggregators (resultType:string, id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any { |
|
48 |
let link = properties.searchAPIURLLAst+this.getEntityName(resultType,true); |
|
49 |
|
|
50 |
let url = link+"?"+"&format=json"; |
|
51 |
if(params!= null && params != '' ) { |
|
52 |
url += params; |
|
53 |
} |
|
54 |
if(refineParams!= null && refineParams != '' ) { |
|
55 |
url += refineParams; |
|
56 |
} |
|
57 |
url += "&page="+(page-1)+"&size="+size; |
|
58 |
|
|
59 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
60 |
.pipe(map(res => this.parseRefineResults(id, res['refineResults']))); |
|
34 |
url += "&page=" + (page - 1) + "&size=" + size + "&format=json"; |
|
35 |
|
|
36 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
37 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); |
|
38 |
} |
|
39 |
|
|
40 |
searchById(resultType: string, id: string, properties: EnvProperties): any { |
|
41 |
let url = properties.searchAPIURLLAst + this.getEntityName(resultType, true) + "/" + id + "?format=json"; |
|
42 |
|
|
43 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
44 |
.pipe(map(res => this.parseResults(resultType, res, properties))); |
|
45 |
} |
|
46 |
|
|
47 |
searchAggregators(resultType: string, id: string, params: string, refineParams: string, page: number, size: number, properties: EnvProperties): any { |
|
48 |
let link = properties.searchAPIURLLAst + this.getEntityName(resultType, true); |
|
49 |
|
|
50 |
let url = link + "?" + "&format=json"; |
|
51 |
if (params != null && params != '') { |
|
52 |
url += params; |
|
61 | 53 |
} |
62 |
|
|
63 |
searchByListOfDOI (resultType:string, DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any { |
|
64 |
let link = properties.searchAPIURLLAst+ this.getEntityName(resultType,true); |
|
65 |
|
|
66 |
let url = link+"?"+"&format=json&"; |
|
67 |
var doisParams = ""; |
|
68 |
|
|
69 |
for(var i =0 ;i < DOIs.length; i++){ |
|
70 |
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; |
|
71 |
} |
|
72 |
if(doisParams.length > 0){ |
|
73 |
url +="&"+doisParams; |
|
74 |
|
|
75 |
} |
|
76 |
if(refineParams!= null && refineParams != '' ) { |
|
77 |
url += refineParams; |
|
78 |
} |
|
79 |
url += "&page="+(page-1)+"&size="+size; |
|
80 |
|
|
81 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
82 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")])); |
|
54 |
if (refineParams != null && refineParams != '') { |
|
55 |
url += refineParams; |
|
83 | 56 |
} |
84 |
|
|
85 |
advancedSearch (resultType:string, params: string, page: number, size: number, sortBy: string, properties:EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null ):any { |
|
86 |
let url = properties.searchResourcesAPIURL; |
|
87 |
var basicQuery = "(oaftype exact result) and (resulttypeid exact "+this.getEntityName(resultType,false) + ") "; |
|
88 |
url += "?query="; |
|
89 |
if(params!= null && params != '' ) { |
|
90 |
url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; |
|
91 |
}else{ |
|
92 |
url +=" ( "+basicQuery+ " ) "; |
|
93 |
} |
|
94 |
if(refineParams!= null && refineParams != '' ) { |
|
95 |
url += refineParams; |
|
96 |
} |
|
97 |
if(sortBy) { |
|
98 |
let sortOptions = sortBy.split(","); |
|
99 |
url += "sortBy "+sortOptions[0]+"/sort."+sortOptions[1]+" "; |
|
100 |
} |
|
101 |
if(refineQuery) { |
|
102 |
url += "&" + refineQuery; |
|
103 |
} |
|
104 |
|
|
105 |
url += "&page="+(page-1)+"&size="+size; |
|
106 |
url += "&format=json"; |
|
107 |
|
|
108 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
109 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")])); |
|
57 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
58 |
|
|
59 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
60 |
.pipe(map(res => this.parseRefineResults(id, res['refineResults']))); |
|
61 |
} |
|
62 |
|
|
63 |
searchByListOfDOI(resultType: string, DOIs: string[], refineParams: string, page: number, size: number, refineFields: string[], properties: EnvProperties): any { |
|
64 |
let link = properties.searchAPIURLLAst + this.getEntityName(resultType, true); |
|
65 |
|
|
66 |
let url = link + "?" + "&format=json&"; |
|
67 |
var doisParams = ""; |
|
68 |
|
|
69 |
for (var i = 0; i < DOIs.length; i++) { |
|
70 |
doisParams += (doisParams.length > 0 ? "&" : "") + 'doi="' + DOIs[i] + '"'; |
|
110 | 71 |
} |
111 |
advancedSearchResults (resultType:string, params: string, page: number, size: number, sortBy: string, properties:EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null ):any { |
|
112 |
let url = properties.searchAPIURLLAst+"resources2/?format=json"; |
|
113 |
if(params!= null && params != '' ) { |
|
114 |
url +="&query=(" + params + ")"; |
|
72 |
if (doisParams.length > 0) { |
|
73 |
url += "&" + doisParams; |
|
74 |
|
|
115 | 75 |
} |
116 |
if(sortBy) { |
|
76 |
if (refineParams != null && refineParams != '') { |
|
77 |
url += refineParams; |
|
78 |
} |
|
79 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
80 |
|
|
81 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
82 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); |
|
83 |
} |
|
84 |
|
|
85 |
advancedSearch(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null): any { |
|
86 |
let url = properties.searchResourcesAPIURL; |
|
87 |
var basicQuery = "(oaftype exact result) and (resulttypeid exact " + this.getEntityName(resultType, false) + ") "; |
|
88 |
url += "?query="; |
|
89 |
if (params != null && params != '') { |
|
90 |
url += " ( " + basicQuery + " ) " + " and (" + params + ")"; |
|
91 |
} else { |
|
92 |
url += " ( " + basicQuery + " ) "; |
|
93 |
} |
|
94 |
if (refineParams != null && refineParams != '') { |
|
95 |
url += refineParams; |
|
96 |
} |
|
97 |
if (sortBy) { |
|
117 | 98 |
let sortOptions = sortBy.split(","); |
118 |
url += (params ? " " : "&query=(*) ")+"sortBy "+sortOptions[0]+"/sort."+sortOptions[1]+(params ? " " : " ");
|
|
99 |
url += "sortBy " + sortOptions[0] + "/sort." + sortOptions[1] + " ";
|
|
119 | 100 |
} |
120 |
if(refineParams!= null && refineParams != '' ) { |
|
101 |
if (refineQuery) { |
|
102 |
url += "&" + refineQuery; |
|
103 |
} |
|
104 |
|
|
105 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
106 |
url += "&format=json"; |
|
107 |
|
|
108 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
109 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); |
|
110 |
} |
|
111 |
|
|
112 |
advancedSearchResults(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null): any { |
|
113 |
let url = properties.searchAPIURLLAst + "resources2/?format=json"; |
|
114 |
if (params != null && params != '') { |
|
115 |
url += "&query=(" + params + ")"; |
|
116 |
} |
|
117 |
if (sortBy) { |
|
118 |
let sortOptions = sortBy.split(","); |
|
119 |
url += (params ? " " : "&query=(*) ") + "sortBy " + sortOptions[0] + "/sort." + sortOptions[1] + (params ? " " : " "); |
|
120 |
} |
|
121 |
if (refineParams != null && refineParams != '') { |
|
121 | 122 |
url += refineParams; |
122 | 123 |
} |
123 |
if(refineQuery) { |
|
124 |
if (refineQuery) {
|
|
124 | 125 |
url += "&" + refineQuery; |
125 | 126 |
} |
126 |
|
|
127 |
url += "&page="+(page-1)+"&size="+size;
|
|
127 |
|
|
128 |
url += "&page=" + (page - 1) + "&size=" + size;
|
|
128 | 129 |
// url += "&format=json"; |
129 |
|
|
130 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
|
131 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
|
|
130 |
|
|
131 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
|
132 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")]));
|
|
132 | 133 |
} |
134 |
|
|
135 |
searchResultForEntity(resultType: string, params: string, page: number, size: number, properties: EnvProperties): any { |
|
136 |
let link = properties.searchAPIURLLAst; |
|
137 |
//let url = link+params+"/"+this.getEntityName(resultType,true)+ "?format=json"; |
|
138 |
//url += "&page="+(page-1)+"&size="+size; |
|
139 |
//url += "&sortBy=resultdateofacceptance,descending"; |
|
140 |
|
|
141 |
//let url = link+"/resources2?format=json&query="+params+" sortBy resultdateofacceptance/sort.descending&type="+this.getEntityName(resultType,true); |
|
142 |
|
|
143 |
let url = link + "/" + this.getEntityName(resultType, true); |
|
144 |
url += "?format=json"; |
|
145 |
url += "&fq=" + params; |
|
146 |
url += "&sortBy=resultdateofacceptance,descending"; |
|
147 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
148 |
|
|
149 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
150 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); |
|
151 |
} |
|
133 | 152 |
|
134 |
searchResultForEntity (resultType:string, params: string, page: number, size: number, properties:EnvProperties):any { |
|
135 |
let link = properties.searchAPIURLLAst; |
|
136 |
//let url = link+params+"/"+this.getEntityName(resultType,true)+ "?format=json"; |
|
137 |
//url += "&page="+(page-1)+"&size="+size; |
|
138 |
//url += "&sortBy=resultdateofacceptance,descending"; |
|
139 |
|
|
140 |
//let url = link+"/resources2?format=json&query="+params+" sortBy resultdateofacceptance/sort.descending&type="+this.getEntityName(resultType,true); |
|
141 |
|
|
142 |
let url = link+"/"+this.getEntityName(resultType,true); |
|
143 |
url += "?format=json"; |
|
144 |
url += "&fq="+params; |
|
145 |
url += "&sortBy=resultdateofacceptance,descending"; |
|
146 |
url += "&page="+(page-1)+"&size="+size; |
|
147 |
|
|
148 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
149 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); |
|
150 |
} |
|
151 | 153 |
//???? why different from above? |
152 |
searchForDataproviders(resultType:string, params: string, page: number, size: number, properties:EnvProperties):any { |
|
153 |
let link = properties.searchAPIURLLAst; |
|
154 |
let url = link+params; |
|
155 |
url += "&sortBy=resultdateofacceptance,descending"; |
|
156 |
url += "&page="+(page-1)+"&size="+size + "&format=json"; |
|
157 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
158 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); |
|
154 |
searchForDataproviders(resultType: string, params: string, page: number, size: number, properties: EnvProperties): any { |
|
155 |
let link = properties.searchAPIURLLAst; |
|
156 |
let url = link + params; |
|
157 |
url += "&sortBy=resultdateofacceptance,descending"; |
|
158 |
url += "&page=" + (page - 1) + "&size=" + size + "&format=json"; |
|
159 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
160 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); |
|
161 |
} |
|
162 |
|
|
163 |
searchForMyOrcidLinks(resultType: string, orcidQuery: string, typeQuery: string, page: number, size: number): any { |
|
164 |
let url = properties.searchAPIURLLAst + "resources2/?format=json"; |
|
165 |
if (orcidQuery != null && orcidQuery != '') { |
|
166 |
url += "&query=(" + orcidQuery + ")"; |
|
159 | 167 |
} |
160 |
|
|
161 |
searchForMyOrcidLinks (resultType:string, orcidQuery: string, typeQuery: string, page: number, size: number):any { |
|
162 |
let url = properties.searchAPIURLLAst+"resources2/?format=json"; |
|
163 |
if(orcidQuery!= null && orcidQuery != '' ) { |
|
164 |
url +="&query=(" + orcidQuery + ")"; |
|
165 |
} |
|
166 | 168 |
url += typeQuery; |
167 |
url += "&page="+(page-1)+"&size="+size;
|
|
168 |
|
|
169 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
|
169 |
url += "&page=" + (page - 1) + "&size=" + size;
|
|
170 |
|
|
171 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
|
170 | 172 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); |
171 | 173 |
} |
172 |
|
|
173 |
parseResults(resultType:string, data: any, properties: EnvProperties): SearchResult[] { |
|
174 |
let results: SearchResult[] = []; |
|
175 |
|
|
176 |
let length = Array.isArray(data) ? data.length : 1; |
|
177 |
|
|
178 |
for(let i=0; i<length; i++) { |
|
179 |
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result']; |
|
180 |
|
|
181 |
var result: SearchResult = new SearchResult(); |
|
182 |
if(resData['resulttype']) { |
|
183 |
result.entityType = resData['resulttype']['classname']; |
|
184 |
} else { |
|
185 |
result.entityType = resultType; |
|
174 |
|
|
175 |
parseResults(resultType: string, data: any, properties: EnvProperties): SearchResult[] { |
|
176 |
let results: SearchResult[] = []; |
|
177 |
|
|
178 |
let length = Array.isArray(data) ? data.length : 1; |
|
179 |
|
|
180 |
for (let i = 0; i < length; i++) { |
|
181 |
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result']; |
|
182 |
|
|
183 |
var result: SearchResult = new SearchResult(); |
|
184 |
if (resData['resulttype']) { |
|
185 |
result.entityType = resData['resulttype']['classname']; |
|
186 |
} else { |
|
187 |
result.entityType = resultType; |
|
188 |
} |
|
189 |
result.types = new Array<string>(); |
|
190 |
let types = new Set<string>(); |
|
191 |
|
|
192 |
let instance; |
|
193 |
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1; |
|
194 |
|
|
195 |
for (let i = 0; i < length; i++) { |
|
196 |
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance']; |
|
197 |
this.parsingFunctions.parseTypes(result.types, types, instance); |
|
198 |
} |
|
199 |
/////////////////////////// Athena Code /////////////////////////// |
|
200 |
if (resData['pid']) { |
|
201 |
if (!Array.isArray(resData['pid'])) { |
|
202 |
if (resData['pid'].classid && resData['pid'].classid == 'doi') { |
|
203 |
if (resData['pid'].content != '' && resData['pid'].content != null) { |
|
204 |
result.DOIs.push(resData['pid'].content.replace("https://doi.org/", "")); |
|
186 | 205 |
} |
187 |
result.types = new Array<string>(); |
|
188 |
let types = new Set<string>(); |
|
189 |
|
|
190 |
let instance; |
|
191 |
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1; |
|
192 |
|
|
193 |
for(let i=0; i<length; i++) { |
|
194 |
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance']; |
|
195 |
this.parsingFunctions.parseTypes(result.types, types, instance); |
|
196 |
} |
|
197 |
/////////////////////////// Athena Code /////////////////////////// |
|
198 |
if(resData['pid']) { |
|
199 |
if(!Array.isArray(resData['pid'])) { |
|
200 |
if(resData['pid'].classid && resData['pid'].classid == 'doi'){ |
|
201 |
if(resData['pid'].content != '' && resData['pid'].content != null){ |
|
202 |
result.DOIs.push(resData['pid'].content.replace("https://doi.org/","")); |
|
203 |
} |
|
204 |
} |
|
205 |
} else { |
|
206 |
for(let i=0; i<resData['pid'].length; i++){ |
|
207 |
if(resData['pid'][i].classid == 'doi'){ |
|
208 |
if(resData['pid'][i].content != '' && resData['pid'][i].content != null){ |
|
209 |
result.DOIs.push(resData['pid'][i].content.replace("https://doi.org/","")); |
|
210 |
} |
|
211 |
} |
|
212 |
} |
|
206 |
} |
|
207 |
} else { |
|
208 |
for (let i = 0; i < resData['pid'].length; i++) { |
|
209 |
if (resData['pid'][i].classid == 'doi') { |
|
210 |
if (resData['pid'][i].content != '' && resData['pid'][i].content != null) { |
|
211 |
result.DOIs.push(resData['pid'][i].content.replace("https://doi.org/", "")); |
|
213 | 212 |
} |
214 |
result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']); |
|
215 | 213 |
} |
216 |
/////////////////////////// Athena Code /////////////////////////// |
|
217 |
if(resData['programmingLanguage'] && resData['programmingLanguage'] != null) { |
|
218 |
result.programmingLanguages = new Array<string>(); |
|
219 |
|
|
220 |
if(!Array.isArray(resData['programmingLanguage'])) { |
|
221 |
if(resData['programmingLanguage'].classname != "Undetermined" && resData['programmingLanguage'].classname) { |
|
222 |
result.programmingLanguages.push(resData['programmingLanguage'].classname); |
|
223 |
} |
|
224 |
} else { |
|
225 |
for(let i=0; i<resData['programmingLanguage'].length; i++) { |
|
226 |
if(resData['programmingLanguage'][i].classname != "Undetermined" && resData['programmingLanguage'][i].classname) { |
|
227 |
result.programmingLanguages.push(resData['programmingLanguage'][i].classname); |
|
228 |
} |
|
229 |
} |
|
230 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']); |
|
217 |
} |
|
218 |
/////////////////////////// Athena Code /////////////////////////// |
|
219 |
if (resData['programmingLanguage'] && resData['programmingLanguage'] != null) { |
|
220 |
result.programmingLanguages = new Array<string>(); |
|
221 |
|
|
222 |
if (!Array.isArray(resData['programmingLanguage'])) { |
|
223 |
if (resData['programmingLanguage'].classname != "Undetermined" && resData['programmingLanguage'].classname) { |
|
224 |
result.programmingLanguages.push(resData['programmingLanguage'].classname); |
|
225 |
} |
|
226 |
} else { |
|
227 |
for (let i = 0; i < resData['programmingLanguage'].length; i++) { |
|
228 |
if (resData['programmingLanguage'][i].classname != "Undetermined" && resData['programmingLanguage'][i].classname) { |
|
229 |
result.programmingLanguages.push(resData['programmingLanguage'][i].classname); |
|
231 | 230 |
} |
232 |
|
|
233 |
if(resData['language'] && resData['language'] != null) {
|
|
234 |
result.languages = new Array<string>();
|
|
235 |
|
|
236 |
if(!Array.isArray(resData['language'])) {
|
|
237 |
if(resData['language'].classname != "Undetermined" && resData['language'].classname) {
|
|
238 |
result.languages.push(resData['language'].classname); |
|
239 |
}
|
|
240 |
} else {
|
|
241 |
for(let i=0; i<resData['language'].length; i++) {
|
|
242 |
if(resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
|
|
243 |
result.languages.push(resData['language'][i].classname);
|
|
244 |
}
|
|
245 |
}
|
|
246 |
}
|
|
231 |
} |
|
232 |
}
|
|
233 |
}
|
|
234 |
|
|
235 |
if (resData['language'] && resData['language'] != null) {
|
|
236 |
result.languages = new Array<string>();
|
|
237 |
|
|
238 |
if (!Array.isArray(resData['language'])) {
|
|
239 |
if (resData['language'].classname != "Undetermined" && resData['language'].classname) {
|
|
240 |
result.languages.push(resData['language'].classname);
|
|
241 |
}
|
|
242 |
} else {
|
|
243 |
for (let i = 0; i < resData['language'].length; i++) {
|
|
244 |
if (resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
|
|
245 |
result.languages.push(resData['language'][i].classname);
|
|
247 | 246 |
} |
248 |
|
|
249 |
if(resData['country'] && resData['country'] != null) {
|
|
250 |
result.countriesForResults = new Array<string>();
|
|
251 |
|
|
252 |
if(!Array.isArray(resData['country'])) {
|
|
253 |
if(resData['country'].classname != "Undetermined" && resData['country'].classname) {
|
|
254 |
result.countriesForResults.push(resData['country'].classname); |
|
255 |
}
|
|
256 |
} else {
|
|
257 |
for(let i=0; i<resData['country'].length; i++) {
|
|
258 |
if(resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
|
|
259 |
result.countriesForResults.push(resData['country'][i].classname);
|
|
260 |
}
|
|
261 |
}
|
|
262 |
}
|
|
247 |
} |
|
248 |
}
|
|
249 |
}
|
|
250 |
|
|
251 |
if (resData['country'] && resData['country'] != null) {
|
|
252 |
result.countriesForResults = new Array<string>();
|
|
253 |
|
|
254 |
if (!Array.isArray(resData['country'])) {
|
|
255 |
if (resData['country'].classname != "Undetermined" && resData['country'].classname) {
|
|
256 |
result.countriesForResults.push(resData['country'].classname);
|
|
257 |
}
|
|
258 |
} else {
|
|
259 |
for (let i = 0; i < resData['country'].length; i++) {
|
|
260 |
if (resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
|
|
261 |
result.countriesForResults.push(resData['country'][i].classname);
|
|
263 | 262 |
} |
264 |
|
|
265 |
result['title'] = {"name": '', "accessMode": '', "sc39": ''}; |
|
266 |
|
|
267 |
if(Array.isArray(resData['title'])) { |
|
268 |
for(let i=0; i<resData['title'].length; i++) { |
|
269 |
if(resData['title'][i] && resData['title'][i].content) { |
|
270 |
if(!result.title.name || resData['title'][i].classid == "main title") { |
|
271 |
result['title'].name = String(resData['title'][i].content); |
|
272 |
} |
|
273 |
if(resData['title'][i].classid == "main title") { |
|
274 |
break; |
|
275 |
} |
|
276 |
} |
|
277 |
} |
|
278 |
if(!result.title.name) { |
|
279 |
result['title'].name = ""; |
|
280 |
} |
|
281 |
// result['title'].name = (resData['title'][0] && resData['title'][0].content) ? String(resData['title'][0].content) : ""; |
|
282 |
} else { |
|
283 |
result['title'].name = (resData['title'] && resData['title'].content) ? String(resData['title'].content) : ""; |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 |
result['title'] = {"name": '', "accessMode": '', "sc39": ''}; |
|
268 |
|
|
269 |
if (Array.isArray(resData['title'])) { |
|
270 |
for (let i = 0; i < resData['title'].length; i++) { |
|
271 |
if (resData['title'][i] && resData['title'][i].content) { |
|
272 |
if (!result.title.name || resData['title'][i].classid == "main title") { |
|
273 |
result['title'].name = String(resData['title'][i].content); |
|
284 | 274 |
} |
285 |
|
|
286 |
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier']; |
|
287 |
let canId = ParsingFunctions.parseRelCanonicalId(Array.isArray(data) ? data[i] : data, "result"); |
|
288 |
if(canId){ |
|
289 |
result['id'] = canId; |
|
275 |
if (resData['title'][i].classid == "main title") { |
|
276 |
break; |
|
290 | 277 |
} |
291 |
result['relcanId'] = result['id']; |
|
292 |
|
|
293 |
if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classname")) { |
|
294 |
result['title'].accessMode = resData['bestaccessright'].classname; |
|
278 |
} |
|
279 |
} |
|
280 |
if (!result.title.name) { |
|
281 |
result['title'].name = ""; |
|
282 |
} |
|
283 |
// result['title'].name = (resData['title'][0] && resData['title'][0].content) ? String(resData['title'][0].content) : ""; |
|
284 |
} else { |
|
285 |
result['title'].name = (resData['title'] && resData['title'].content) ? String(resData['title'].content) : ""; |
|
286 |
} |
|
287 |
|
|
288 |
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier']; |
|
289 |
let canId = ParsingFunctions.parseRelCanonicalId(Array.isArray(data) ? data[i] : data, "result"); |
|
290 |
if (canId) { |
|
291 |
result['id'] = canId; |
|
292 |
} |
|
293 |
result['relcanId'] = result['id']; |
|
294 |
|
|
295 |
if (resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classname")) { |
|
296 |
result['title'].accessMode = resData['bestaccessright'].classname; |
|
297 |
} |
|
298 |
if (resData['rels'].hasOwnProperty("rel")) { |
|
299 |
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1; |
|
300 |
|
|
301 |
for (let j = 0; j < relLength; j++) { |
|
302 |
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel']; |
|
303 |
|
|
304 |
if (relation.hasOwnProperty("to")) { |
|
305 |
if (relation['to'].class == "isProducedBy") { |
|
306 |
result['projects'] = this.parseProjects(result['projects'], relation); |
|
295 | 307 |
} |
296 |
if(resData['rels'].hasOwnProperty("rel")) { |
|
297 |
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1; |
|
298 |
|
|
299 |
for(let j=0; j<relLength; j++) { |
|
300 |
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel']; |
|
301 |
|
|
302 |
if(relation.hasOwnProperty("to")) { |
|
303 |
if(relation['to'].class == "isProducedBy") { |
|
304 |
result['projects'] = this.parseProjects(result['projects'], relation); |
|
305 |
} |
|
306 |
} |
|
307 |
} |
|
308 |
} |
|
309 |
|
|
310 |
if(resData.hasOwnProperty("creator") && resData['creator'] != null) { |
|
311 |
if(result['authors'] == undefined) { |
|
312 |
result['authors'] = new Array<{"fullName": string, "orcid": string, "orcid_pending": string}>(); |
|
313 |
} |
|
314 |
|
|
315 |
let authors = resData['creator']; |
|
316 |
let length = Array.isArray(authors) ? authors.length : 1; |
|
317 |
|
|
318 |
for(let i=0; i<length; i++) { |
|
319 |
let author = Array.isArray(authors) ? authors[i] : authors; |
|
320 |
if(author) { |
|
321 |
result['authors'][author.rank] = {"fullName": author.content, "orcid": author.orcid, "orcid_pending": author.orcid_pending}; |
|
322 |
} |
|
323 |
} |
|
324 |
result.authors = result.authors.filter(function (item) { |
|
325 |
return (item != undefined && item.fullName != undefined); |
|
326 |
}); |
|
327 |
} |
|
328 |
|
|
329 |
var date:string = (resData.dateofacceptance)+""; // transform to string in case it is an integer |
|
330 |
result.year = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date; |
|
331 |
|
|
332 |
if(!Array.isArray(resData.description)) { |
|
333 |
result.description = (resData.description) ? String(resData.description) : ""; |
|
334 |
} else { |
|
335 |
result.description = (resData.description[0]) ? String(resData.description[0]) : ""; |
|
336 |
} |
|
337 |
|
|
338 |
if(result.description && result.description.length > this.sizeOfDescription) { |
|
339 |
result.description = result.description.substring(0, this.sizeOfDescription) + "..."; |
|
340 |
} |
|
341 |
|
|
342 |
if(resData.embargoenddate && resData.embargoenddate != '') { |
|
343 |
result.embargoEndDate = Dates.getDate(resData.embargoenddate); |
|
344 |
} |
|
345 |
|
|
346 |
if(!Array.isArray(resData.publisher)) { |
|
347 |
result.publisher = resData.publisher; |
|
348 |
} else { |
|
349 |
for(let i=0; i<resData.publisher.length; i++) { |
|
350 |
if(result.publisher != undefined){ |
|
351 |
result.publisher += ', '+resData['publisher'][i]; |
|
352 |
} else { |
|
353 |
result.publisher = resData['publisher'][i]; |
|
354 |
} |
|
355 |
} |
|
356 |
} |
|
357 |
|
|
358 |
results.push(result); |
|
308 |
} |
|
359 | 309 |
} |
360 |
|
|
361 |
return results; |
|
362 |
} |
|
363 |
|
|
364 |
parseProjects(projects: { "id": string, "acronym": string, "title": string, |
|
365 |
"funderShortname": string, "funderName": string, |
|
366 |
"code": string }[], relation: any ) : { |
|
367 |
"id": string, "acronym": string, "title": string, |
|
368 |
"funderShortname": string, "funderName": string, |
|
369 |
"code": string }[] { |
|
370 |
if(projects == undefined) { |
|
371 |
projects = new Array< |
|
372 |
{ "id": string, "acronym": string, "title": string, |
|
373 |
"funderShortname": string, "funderName": string, |
|
374 |
"code": string |
|
375 |
}>(); |
|
376 | 310 |
} |
377 |
|
|
378 |
let countProjects = projects.length; |
|
379 |
|
|
380 |
projects[countProjects] = { |
|
381 |
"id": "", "acronym": "", "title": "", |
|
382 |
"funderShortname": "", "funderName": "", |
|
383 |
"code": "" |
|
384 |
}; |
|
385 |
|
|
386 |
if(relation.title != 'unidentified') { |
|
387 |
projects[countProjects]['id'] = relation['to'].content; |
|
388 |
projects[countProjects]['acronym'] = relation.acronym; |
|
389 |
projects[countProjects]['title'] = relation.title; |
|
390 |
projects[countProjects]['code'] = relation.code; |
|
311 |
|
|
312 |
if (resData.hasOwnProperty("creator") && resData['creator'] != null) { |
|
313 |
if (result['authors'] == undefined) { |
|
314 |
result['authors'] = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>(); |
|
315 |
} |
|
316 |
|
|
317 |
let authors = resData['creator']; |
|
318 |
let length = Array.isArray(authors) ? authors.length : 1; |
|
319 |
|
|
320 |
for (let i = 0; i < length; i++) { |
|
321 |
let author = Array.isArray(authors) ? authors[i] : authors; |
|
322 |
if (author) { |
|
323 |
result['authors'][author.rank] = { |
|
324 |
"fullName": author.content, |
|
325 |
"orcid": author.orcid, |
|
326 |
"orcid_pending": author.orcid_pending |
|
327 |
}; |
|
328 |
} |
|
329 |
} |
|
330 |
result.authors = result.authors.filter(function (item) { |
|
331 |
return (item != undefined && item.fullName != undefined); |
|
332 |
}); |
|
333 |
} |
|
334 |
|
|
335 |
var date: string = (resData.dateofacceptance) + ""; // transform to string in case it is an integer |
|
336 |
result.year = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date; |
|
337 |
|
|
338 |
if (!Array.isArray(resData.description)) { |
|
339 |
result.description = (resData.description) ? String(resData.description) : ""; |
|
391 | 340 |
} else { |
392 |
projects[countProjects]['id'] = ""; |
|
393 |
projects[countProjects]['acronym'] = ""; |
|
394 |
projects[countProjects]['title'] = ""; |
|
395 |
projects[countProjects]['code'] = ""; |
|
341 |
result.description = (resData.description[0]) ? String(resData.description[0]) : ""; |
|
396 | 342 |
} |
397 |
|
|
398 |
if(relation.hasOwnProperty("funding")) { |
|
399 |
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1; |
|
400 |
|
|
401 |
for(let z=0; z<fundingLength; z++) { |
|
402 |
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding']; |
|
403 |
|
|
404 |
if(fundingData.hasOwnProperty("funder")) { |
|
405 |
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname; |
|
406 |
projects[countProjects]['funderName'] = fundingData['funder'].name; |
|
407 |
} |
|
343 |
|
|
344 |
if (result.description && result.description.length > this.sizeOfDescription) { |
|
345 |
result.description = result.description.substring(0, this.sizeOfDescription) + "..."; |
|
346 |
} |
|
347 |
|
|
348 |
if (resData.embargoenddate && resData.embargoenddate != '') { |
|
349 |
result.embargoEndDate = Dates.getDate(resData.embargoenddate); |
|
350 |
} |
|
351 |
|
|
352 |
if (!Array.isArray(resData.publisher)) { |
|
353 |
result.publisher = resData.publisher; |
|
354 |
} else { |
|
355 |
for (let i = 0; i < resData.publisher.length; i++) { |
|
356 |
if (result.publisher != undefined) { |
|
357 |
result.publisher += ', ' + resData['publisher'][i]; |
|
358 |
} else { |
|
359 |
result.publisher = resData['publisher'][i]; |
|
408 | 360 |
} |
361 |
} |
|
409 | 362 |
} |
410 |
|
|
411 |
return projects;
|
|
363 |
|
|
364 |
results.push(result);
|
|
412 | 365 |
} |
413 |
parseRefineResults(id: string, data: any): any { |
|
414 |
var results:any = []; |
|
415 |
if(data.hasOwnProperty("resulthostingdatasource")) { |
|
416 |
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1; |
|
417 |
|
|
418 |
for(let i=0; i<length; i++) { |
|
419 |
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource']; |
|
420 |
|
|
421 |
let result: {"name": string, "id": string, "count": number} = {"name": "", "id": "", "count": 0}; |
|
422 |
result['name'] = datasource.name; |
|
423 |
result['id'] = datasource.id.split("||")[0]; |
|
424 |
result['count'] = datasource.count; |
|
425 |
|
|
426 |
if(result['id'] != id && result['name'] != "Unknown Repository") { |
|
427 |
results.push(result); |
|
428 |
} |
|
429 |
} |
|
366 |
|
|
367 |
return results; |
|
368 |
} |
|
369 |
|
|
370 |
parseProjects(projects: { |
|
371 |
"id": string, "acronym": string, "title": string, |
|
372 |
"funderShortname": string, "funderName": string, |
|
373 |
"code": string |
|
374 |
}[], relation: any): { |
|
375 |
"id": string, "acronym": string, "title": string, |
|
376 |
"funderShortname": string, "funderName": string, |
|
377 |
"code": string |
|
378 |
}[] { |
|
379 |
if (projects == undefined) { |
|
380 |
projects = new Array<{ |
|
381 |
"id": string, "acronym": string, "title": string, |
|
382 |
"funderShortname": string, "funderName": string, |
|
383 |
"code": string |
|
384 |
}>(); |
|
385 |
} |
|
386 |
|
|
387 |
let countProjects = projects.length; |
|
388 |
|
|
389 |
projects[countProjects] = { |
|
390 |
"id": "", "acronym": "", "title": "", |
|
391 |
"funderShortname": "", "funderName": "", |
|
392 |
"code": "" |
|
393 |
}; |
|
394 |
|
|
395 |
if (relation.title != 'unidentified') { |
|
396 |
projects[countProjects]['id'] = relation['to'].content; |
|
397 |
projects[countProjects]['acronym'] = relation.acronym; |
|
398 |
projects[countProjects]['title'] = relation.title; |
|
399 |
projects[countProjects]['code'] = relation.code; |
|
400 |
} else { |
|
401 |
projects[countProjects]['id'] = ""; |
|
402 |
projects[countProjects]['acronym'] = ""; |
|
403 |
projects[countProjects]['title'] = ""; |
|
404 |
projects[countProjects]['code'] = ""; |
|
405 |
} |
|
406 |
|
|
407 |
if (relation.hasOwnProperty("funding")) { |
|
408 |
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1; |
|
409 |
|
|
410 |
for (let z = 0; z < fundingLength; z++) { |
|
411 |
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding']; |
|
412 |
|
|
413 |
if (fundingData.hasOwnProperty("funder")) { |
|
414 |
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname; |
|
415 |
projects[countProjects]['funderName'] = fundingData['funder'].name; |
|
430 | 416 |
} |
431 |
return results;
|
|
417 |
}
|
|
432 | 418 |
} |
433 |
|
|
434 |
private numOfResults(url: string, properties:EnvProperties): any { |
|
435 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
436 |
.pipe(map(res => res['total'])); |
|
419 |
|
|
420 |
return projects; |
|
421 |
} |
|
422 |
|
|
423 |
parseRefineResults(id: string, data: any): any { |
|
424 |
var results: any = []; |
|
425 |
if (data.hasOwnProperty("resulthostingdatasource")) { |
|
426 |
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1; |
|
427 |
|
|
428 |
for (let i = 0; i < length; i++) { |
|
429 |
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource']; |
|
430 |
|
|
431 |
let result: { "name": string, "id": string, "count": number } = {"name": "", "id": "", "count": 0}; |
|
432 |
result['name'] = datasource.name; |
|
433 |
result['id'] = datasource.id.split("||")[0]; |
|
434 |
result['count'] = datasource.count; |
|
435 |
|
|
436 |
if (result['id'] != id && result['name'] != "Unknown Repository") { |
|
437 |
results.push(result); |
|
438 |
} |
|
439 |
} |
|
437 | 440 |
} |
438 |
|
|
439 |
numOfEntityResults(resultType:string, id: string, entity: string, properties:EnvProperties):any { |
|
440 |
var parameters: string = ""; |
|
441 |
parameters = this.getEntityName(entity, true) + "/"+id+"/"+this.getEntityName(resultType, true)+"/count"; |
|
442 |
let url = properties.searchAPIURLLAst+parameters+"?format=json"; |
|
443 |
return this.numOfResults(url , properties); |
|
444 |
} |
|
445 |
numOfResearchOutcomes( params: string, properties:EnvProperties, refineParams:string=null):any { |
|
446 |
let url = properties.searchAPIURLLAst+"resources2/?format=json&size=0&type=results"; |
|
447 |
if(params.length > 0){ |
|
441 |
return results; |
|
442 |
} |
|
443 |
|
|
444 |
private numOfResults(url: string, properties: EnvProperties): any { |
|
445 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
446 |
.pipe(map(res => res['total'])); |
|
447 |
} |
|
448 |
|
|
449 |
numOfEntityResults(resultType: string, id: string, entity: string, properties: EnvProperties): any { |
|
450 |
var parameters: string = ""; |
|
451 |
parameters = this.getEntityName(entity, true) + "/" + id + "/" + this.getEntityName(resultType, true) + "/count"; |
|
452 |
let url = properties.searchAPIURLLAst + parameters + "?format=json"; |
|
453 |
return this.numOfResults(url, properties); |
|
454 |
} |
|
455 |
|
|
456 |
numOfResearchOutcomes(params: string, properties: EnvProperties, refineParams: string = null): any { |
|
457 |
let url = properties.searchAPIURLLAst + "resources2/?format=json&size=0&type=results"; |
|
458 |
if (params.length > 0) { |
|
448 | 459 |
// var DOIs:string[] = DOI.getDOIsFromString(params); |
449 | 460 |
// var doisParams = ""; |
450 | 461 |
// |
... | ... | |
458 | 469 |
// } |
459 | 470 |
url += "&query=" + params; |
460 | 471 |
} |
461 |
|
|
462 |
if(refineParams!= null && refineParams != '' ) {
|
|
472 |
|
|
473 |
if (refineParams != null && refineParams != '') {
|
|
463 | 474 |
url += refineParams; |
464 | 475 |
} |
465 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
|
476 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
|
466 | 477 |
.pipe(map(res => res['meta']['total'])); |
467 | 478 |
} |
468 |
numOfSearchResults(resultType:string, params: string, properties:EnvProperties, refineParams:string=null):any { |
|
469 |
let url = properties.searchAPIURLLAst+this.getEntityName(resultType, true)+"/count?format=json"; |
|
470 |
if(params.length > 0){ |
|
471 |
var DOIs:string[] = DOI.getDOIsFromString(params); |
|
472 |
var doisParams = ""; |
|
473 |
|
|
474 |
for(var i =0 ;i < DOIs.length; i++){ |
|
475 |
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; |
|
476 |
} |
|
477 |
if(doisParams.length > 0){ |
|
478 |
url += "&"+doisParams; |
|
479 |
}else{ |
|
480 |
url += "&q=" + StringUtils.URIEncode(params); |
|
481 |
} |
|
482 |
} |
|
483 |
|
|
484 |
if(refineParams!= null && refineParams != '' ) { |
|
485 |
url += refineParams; |
|
486 |
} |
|
487 |
return this.numOfResults(url, properties); |
|
479 |
|
|
480 |
numOfSearchResults(resultType: string, params: string, properties: EnvProperties, refineParams: string = null): any { |
|
481 |
let url = properties.searchAPIURLLAst + this.getEntityName(resultType, true) + "/count?format=json"; |
|
482 |
if (params.length > 0) { |
|
483 |
var DOIs: string[] = DOI.getDOIsFromString(params); |
|
484 |
var doisParams = ""; |
|
485 |
|
|
486 |
for (var i = 0; i < DOIs.length; i++) { |
|
487 |
doisParams += (doisParams.length > 0 ? "&" : "") + 'doi="' + DOIs[i] + '"'; |
|
488 |
} |
|
489 |
if (doisParams.length > 0) { |
|
490 |
url += "&" + doisParams; |
|
491 |
} else { |
|
492 |
url += "&q=" + StringUtils.URIEncode(params); |
|
493 |
} |
|
488 | 494 |
} |
489 |
numOfSearchResultsLinkedToPub(resultType:string, properties:EnvProperties):any { |
|
490 |
let url = properties.searchAPIURLLAst+"resources?query="+encodeURIComponent("( (oaftype exact result) and (resulttypeid exact "+resultType+") and (relresulttype=publication) )")+"&page=0&size=0&format=json"; |
|
491 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
495 |
|
|
496 |
if (refineParams != null && refineParams != '') { |
|
497 |
url += refineParams; |
|
498 |
} |
|
499 |
return this.numOfResults(url, properties); |
|
500 |
} |
|
501 |
|
|
502 |
numOfSearchResultsLinkedToPub(resultType: string, properties: EnvProperties): any { |
|
503 |
let url = properties.searchAPIURLLAst + "resources?query=" + encodeURIComponent("( (oaftype exact result) and (resulttypeid exact " + resultType + ") and (relresulttype=publication) )") + "&page=0&size=0&format=json"; |
|
504 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
492 | 505 |
.pipe(map(res => res['meta']['total'])); |
493 | 506 |
} |
494 |
|
|
495 |
countTotalResults(resultType:string, properties:EnvProperties, refineParams:string=null):any { |
|
496 |
let url = properties.searchAPIURLLAst+this.getEntityName(resultType, true)+"/count?format=json"+refineParams; |
|
497 |
return this.numOfResults(url, properties); |
|
498 |
} |
|
499 |
/* |
|
500 |
private quote(word: any): string { |
|
501 |
return '"'+word+'"'; |
|
502 |
} |
|
503 |
*/ |
|
504 |
|
|
505 |
private getEntityName (entityType:string, plural:boolean){ |
|
506 |
if(entityType == "publication" ||entityType == "dataset" || entityType == "organization" || entityType == "datasource" || entityType == "project" ){ |
|
507 |
if(plural){ |
|
508 |
return entityType+ "s"; |
|
509 |
}else{ |
|
510 |
return entityType; |
|
511 |
} |
|
512 |
}else{ |
|
507 |
|
|
508 |
countTotalResults(resultType: string, properties: EnvProperties, refineParams: string = null): any { |
|
509 |
let url = properties.searchAPIURLLAst + this.getEntityName(resultType, true) + "/count?format=json" + refineParams; |
|
510 |
return this.numOfResults(url, properties); |
|
511 |
} |
|
512 |
|
|
513 |
/* |
|
514 |
private quote(word: any): string { |
|
515 |
return '"'+word+'"'; |
|
516 |
} |
|
517 |
*/ |
|
518 |
|
|
519 |
private getEntityName(entityType: string, plural: boolean) { |
|
520 |
if (entityType == "publication" || entityType == "dataset" || entityType == "organization" || entityType == "datasource" || entityType == "project") { |
|
521 |
if (plural) { |
|
522 |
return entityType + "s"; |
|
523 |
} else { |
|
513 | 524 |
return entityType; |
514 | 525 |
} |
526 |
} else { |
|
527 |
return entityType; |
|
515 | 528 |
} |
529 |
} |
|
516 | 530 |
} |
Also available in: Unified diff
[Library | Trunk]: Add dmps on project