1 |
41791
|
argiro.kok
|
package eu.dnetlib.data.claims.migration.handler;
|
2 |
|
|
|
3 |
|
|
import eu.dnetlib.data.claims.migration.JsonldBuilder;
|
4 |
|
|
import eu.dnetlib.data.claims.migration.entity.*;
|
5 |
|
|
import eu.dnetlib.data.claimsDemo.ClaimUtils;
|
6 |
|
|
import eu.dnetlib.data.claimsDemo.QueryGenerator;
|
7 |
|
|
import eu.dnetlib.data.claimsDemo.SqlDAO;
|
8 |
42279
|
argiro.kok
|
import org.apache.log4j.Logger;
|
9 |
41791
|
argiro.kok
|
|
10 |
|
|
import java.sql.ResultSet;
|
11 |
|
|
import java.sql.SQLException;
|
12 |
42278
|
argiro.kok
|
import java.text.DateFormat;
|
13 |
|
|
import java.text.SimpleDateFormat;
|
14 |
41791
|
argiro.kok
|
import java.util.ArrayList;
|
15 |
|
|
import java.util.Date;
|
16 |
|
|
import java.util.List;
|
17 |
|
|
|
18 |
|
|
/**
|
19 |
|
|
* Created by argirok on 9/3/2016.
|
20 |
|
|
*/
|
21 |
|
|
public class FetchClaimHandler {
|
22 |
42279
|
argiro.kok
|
private Logger log = Logger.getLogger(this.getClass());
|
23 |
41791
|
argiro.kok
|
|
24 |
|
|
SqlDAO sqlDAO = null;
|
25 |
42199
|
argiro.kok
|
QueryGenerator queryGenerator = null;
|
26 |
41791
|
argiro.kok
|
|
27 |
|
|
public FetchClaimHandler(){
|
28 |
42214
|
argiro.kok
|
// ApplicationContext context = new ClassPathXmlApplicationContext("../claims/migration/springContext-claimsDemo.xml");
|
29 |
41791
|
argiro.kok
|
// sqlDAO = context.getBean(SqlDAO.class);
|
30 |
|
|
|
31 |
|
|
}
|
32 |
47003
|
konstantin
|
|
33 |
41791
|
argiro.kok
|
public String claims2JSON(List<Claim> claims) throws Exception {
|
34 |
|
|
return JsonldBuilder.toJsonld(claims);
|
35 |
|
|
}
|
36 |
42270
|
argiro.kok
|
public String claim2JSON(Claim claim) throws Exception {
|
37 |
|
|
return JsonldBuilder.toJsonld(claim);
|
38 |
|
|
}
|
39 |
46956
|
konstantin
|
|
40 |
42214
|
argiro.kok
|
/**
|
41 |
|
|
*
|
42 |
|
|
* @param user - user e-mail stored in claims DB
|
43 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
44 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
45 |
|
|
* @return
|
46 |
|
|
* @throws Exception
|
47 |
|
|
*/
|
48 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByUser(String user, Integer limit, Integer offset, List<String> types, boolean addCurationInfo) throws Exception {
|
49 |
|
|
return fetchClaimsByUser(user,limit,offset,null,"claim.claim_date",true, types, addCurationInfo);
|
50 |
42762
|
argiro.kok
|
}
|
51 |
|
|
/**
|
52 |
|
|
*
|
53 |
|
|
* @param user - user e-mail stored in claims DB
|
54 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
55 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
56 |
|
|
* @param keyword filters in specific fields per type (result: {title,doi},project: {name.acronym. funder_name, funder_acronym}, context: {name})
|
57 |
|
|
* @param orderField
|
58 |
|
|
* @param descending
|
59 |
|
|
* @return
|
60 |
|
|
* @throws Exception
|
61 |
|
|
*/
|
62 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByUser(String user, Integer limit, Integer offset,String keyword,String orderField,boolean descending, List<String> types, boolean addCurationInfo) throws Exception {
|
63 |
42762
|
argiro.kok
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchClaimsByUser(user, limit, offset,keyword,orderField,descending, types));
|
64 |
47003
|
konstantin
|
return fetchClaimsByResultSet(rs, addCurationInfo);
|
65 |
41791
|
argiro.kok
|
}
|
66 |
42762
|
argiro.kok
|
/**
|
67 |
|
|
*
|
68 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
69 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
70 |
|
|
* @return
|
71 |
|
|
* @throws Exception
|
72 |
|
|
*/
|
73 |
47003
|
konstantin
|
public List<Claim> fetchAllClaims( Integer limit, Integer offset, boolean addCurationInfo) throws Exception {
|
74 |
|
|
return fetchAllClaims(limit,offset,null,"claim.claim_date",true,new ArrayList<String>(), addCurationInfo);
|
75 |
42762
|
argiro.kok
|
}
|
76 |
41791
|
argiro.kok
|
|
77 |
42214
|
argiro.kok
|
/**
|
78 |
|
|
*
|
79 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
80 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
81 |
42762
|
argiro.kok
|
* @param keyword filters in specific fields per type (result: {title,doi},project: {name.acronym. funder_name, funder_acronym}, context: {name})
|
82 |
|
|
* @param orderField
|
83 |
|
|
* @param descending
|
84 |
42214
|
argiro.kok
|
* @return
|
85 |
|
|
* @throws Exception
|
86 |
|
|
*/
|
87 |
47003
|
konstantin
|
public List<Claim> fetchAllClaims( Integer limit, Integer offset, String keyword, String orderField, boolean descending, List<String> types, boolean addCurationInfo) throws Exception {
|
88 |
42762
|
argiro.kok
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchClaims(limit, offset,keyword,orderField,descending,types));
|
89 |
47003
|
konstantin
|
return fetchClaimsByResultSet(rs, addCurationInfo);
|
90 |
41791
|
argiro.kok
|
}
|
91 |
42214
|
argiro.kok
|
|
92 |
|
|
/**
|
93 |
|
|
*
|
94 |
|
|
* @param dateFrom
|
95 |
|
|
* @param dataTo
|
96 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
97 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
98 |
|
|
* @return
|
99 |
|
|
* @throws Exception
|
100 |
|
|
*/
|
101 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByDate(String dateFrom, String dataTo, Integer limit, Integer offset, boolean addCurationInfo) throws Exception {
|
102 |
|
|
return fetchClaimsByDate(dateFrom, dataTo, limit, offset, null, "claim.claim_date",true, new ArrayList<String>(),addCurationInfo);
|
103 |
42762
|
argiro.kok
|
}
|
104 |
|
|
/**
|
105 |
|
|
*
|
106 |
|
|
* @param dateFrom
|
107 |
|
|
* @param dataTo
|
108 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
109 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
110 |
|
|
* @return
|
111 |
|
|
* @throws Exception
|
112 |
|
|
*/
|
113 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByDate(String dateFrom, String dataTo, Integer limit, Integer offset, String keyword, String orderField, boolean descending, List<String> types, boolean addCurationInfo) throws Exception {
|
114 |
42762
|
argiro.kok
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchClaimsByDate(dateFrom, dataTo, limit, offset,keyword, orderField, descending,types));
|
115 |
47003
|
konstantin
|
return fetchClaimsByResultSet(rs, addCurationInfo);
|
116 |
41791
|
argiro.kok
|
}
|
117 |
42214
|
argiro.kok
|
|
118 |
|
|
/**
|
119 |
|
|
*
|
120 |
|
|
* @param openaireId for project
|
121 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
122 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
123 |
|
|
* @return
|
124 |
|
|
* @throws Exception
|
125 |
|
|
*/
|
126 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByProject(String openaireId, Integer limit, Integer offset, boolean addCurationInfo) throws Exception {
|
127 |
42762
|
argiro.kok
|
|
128 |
47003
|
konstantin
|
return fetchClaimsByProject(openaireId,limit, offset, null, "claim.claim_date",true, new ArrayList<String>(), addCurationInfo);
|
129 |
42762
|
argiro.kok
|
}
|
130 |
|
|
/**
|
131 |
|
|
*
|
132 |
|
|
* @param openaireId for project
|
133 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
134 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
135 |
|
|
* @param orderField
|
136 |
|
|
* @param descending
|
137 |
|
|
* @return
|
138 |
|
|
* @throws Exception
|
139 |
|
|
*/
|
140 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByProject(String openaireId, Integer limit, Integer offset, String keyword, String orderField, boolean descending, List<String> types, boolean addCurationInfo) throws Exception {
|
141 |
42762
|
argiro.kok
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchClaimsByProject(openaireId, limit, offset, keyword, orderField,descending,types));
|
142 |
47003
|
konstantin
|
return fetchClaimsByResultSet(rs, addCurationInfo);
|
143 |
41791
|
argiro.kok
|
}
|
144 |
42214
|
argiro.kok
|
/**
|
145 |
|
|
*
|
146 |
|
|
* @param openaireId of Funder
|
147 |
|
|
* @param limit
|
148 |
|
|
* @param offset
|
149 |
|
|
* @return
|
150 |
|
|
* @throws Exception
|
151 |
|
|
*/
|
152 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByFunder(String openaireId, Integer limit, Integer offset, boolean addCurationInfo) throws Exception {
|
153 |
|
|
return fetchClaimsByFunder(openaireId,limit,offset,null,"claim.claim_date",true, new ArrayList<String>(), addCurationInfo);
|
154 |
42762
|
argiro.kok
|
}
|
155 |
|
|
/**
|
156 |
|
|
*
|
157 |
|
|
* @param openaireId of Funder
|
158 |
|
|
* @param limit
|
159 |
|
|
* @param offset
|
160 |
|
|
* @param orderField
|
161 |
|
|
* @param descending
|
162 |
|
|
* @return
|
163 |
|
|
* @throws Exception
|
164 |
|
|
*/
|
165 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByFunder(String openaireId, Integer limit, Integer offset,String keyword, String orderField, boolean descending, List<String> types, boolean addCurationInfo) throws Exception {
|
166 |
42762
|
argiro.kok
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchClaimsByFunder(openaireId, limit, offset,keyword, orderField,descending,types));
|
167 |
47003
|
konstantin
|
return fetchClaimsByResultSet(rs, addCurationInfo);
|
168 |
41791
|
argiro.kok
|
}
|
169 |
42214
|
argiro.kok
|
/**
|
170 |
|
|
*
|
171 |
|
|
* @param openaireId for result
|
172 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
173 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
174 |
|
|
* @return
|
175 |
|
|
* @throws Exception
|
176 |
|
|
*/
|
177 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByResult(String openaireId, Integer limit, Integer offset, boolean addCurationInfo) throws Exception {
|
178 |
|
|
return fetchClaimsByResult(openaireId,limit,offset,null, "claim.claim_date",true, new ArrayList<String>(), addCurationInfo);
|
179 |
42762
|
argiro.kok
|
}
|
180 |
|
|
/**
|
181 |
|
|
*
|
182 |
|
|
* @param openaireId for result
|
183 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
184 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
185 |
|
|
* @param orderField
|
186 |
|
|
* @param descending
|
187 |
|
|
* @return
|
188 |
|
|
* @throws Exception
|
189 |
|
|
*/
|
190 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByResult(String openaireId, Integer limit, Integer offset,String keyword, String orderField, boolean descending, List<String> types, boolean addCurationInfo) throws Exception {
|
191 |
42762
|
argiro.kok
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchClaimsByResult(openaireId, limit, offset,keyword, orderField, descending,types));
|
192 |
47003
|
konstantin
|
return fetchClaimsByResultSet(rs, addCurationInfo);
|
193 |
42199
|
argiro.kok
|
}
|
194 |
42214
|
argiro.kok
|
/**
|
195 |
|
|
*
|
196 |
|
|
* @param openaireId
|
197 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
198 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
199 |
|
|
* @return
|
200 |
|
|
* @throws Exception
|
201 |
|
|
*/
|
202 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByContext(String openaireId, Integer limit, Integer offset, boolean addCurationInfo) throws Exception {
|
203 |
|
|
return fetchClaimsByContext(openaireId,limit,offset,null,"claim.claim_date",true, new ArrayList<String>(), addCurationInfo);
|
204 |
42762
|
argiro.kok
|
}
|
205 |
|
|
/**
|
206 |
|
|
*
|
207 |
|
|
* @param openaireId
|
208 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
209 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
210 |
|
|
* @param orderField
|
211 |
|
|
* @param descending
|
212 |
|
|
* @return
|
213 |
|
|
* @throws Exception
|
214 |
|
|
*/
|
215 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByContext(String openaireId, Integer limit, Integer offset, String keyword, String orderField, boolean descending, List<String> types, boolean addCurationInfo) throws Exception {
|
216 |
42762
|
argiro.kok
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchClaimsByContext(openaireId, limit, offset,keyword,orderField, descending,types));
|
217 |
47003
|
konstantin
|
return fetchClaimsByResultSet(rs, addCurationInfo);
|
218 |
42214
|
argiro.kok
|
}
|
219 |
47003
|
konstantin
|
public Claim fetchClaimById(String claimId, boolean addCurationInfo) throws Exception {
|
220 |
42270
|
argiro.kok
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateSelectClaimQuery(claimId));
|
221 |
|
|
if(rs.next()) {
|
222 |
|
|
String sourceType =rs.getString(2);
|
223 |
|
|
String sourceId =rs.getString(3);
|
224 |
|
|
String targetType =rs.getString(4);
|
225 |
|
|
String targetId =rs.getString(5);
|
226 |
|
|
rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchClaimsByClaimId(claimId,sourceType,targetType));
|
227 |
|
|
}else{
|
228 |
42279
|
argiro.kok
|
log.info("No claim with id : "+ claimId+"\n");
|
229 |
42270
|
argiro.kok
|
}
|
230 |
|
|
Claim claim = null;
|
231 |
47003
|
konstantin
|
List<Claim> claims=fetchClaimsByResultSet(rs, addCurationInfo);
|
232 |
42270
|
argiro.kok
|
if(claims.size()==1){
|
233 |
|
|
claim=claims.get(0);
|
234 |
|
|
}
|
235 |
|
|
return claim;
|
236 |
|
|
}
|
237 |
47034
|
konstantin
|
|
238 |
|
|
/**
|
239 |
|
|
*
|
240 |
|
|
* @param token for project token
|
241 |
|
|
* @param email for check if this email belongs to one project manager of the project specified by token
|
242 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
243 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
244 |
|
|
* @return
|
245 |
|
|
* @throws Exception
|
246 |
|
|
*/
|
247 |
|
|
public List<Claim> fetchClaimsByToken(String token, String email, Integer limit, Integer offset, boolean addCurationInfo) throws Exception {
|
248 |
|
|
return fetchClaimsByToken(token, email, limit, offset, null, "claim.claim_date",true, new ArrayList<String>(), addCurationInfo);
|
249 |
|
|
}
|
250 |
|
|
/**
|
251 |
|
|
*
|
252 |
|
|
* @param token for project token
|
253 |
|
|
* @param email for check if this email belongs to one project manager of the project specified by token
|
254 |
|
|
* @param limit returns at most 'limit' claims (use -1 or null for no limit)
|
255 |
|
|
* @param offset returns claims after 'offset' position (null for no offset)
|
256 |
|
|
* @param orderField
|
257 |
|
|
* @param descending
|
258 |
|
|
* @return
|
259 |
|
|
* @throws Exception
|
260 |
|
|
*/
|
261 |
|
|
public List<Claim> fetchClaimsByToken(String token, String email, Integer limit, Integer offset, String keyword, String orderField, boolean descending, List<String> types, boolean addCurationInfo) throws Exception {
|
262 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchClaimsByToken(token, email, limit, offset, keyword, orderField,descending,types));
|
263 |
|
|
return fetchClaimsByResultSet(rs, addCurationInfo);
|
264 |
|
|
}
|
265 |
|
|
|
266 |
47003
|
konstantin
|
public List<Claim> fetchClaimsByResultSet(ResultSet rs, boolean addCurationInfo) throws Exception {
|
267 |
41791
|
argiro.kok
|
List<Claim> claims= new ArrayList<Claim>();
|
268 |
|
|
while(rs.next()) {
|
269 |
|
|
Claim claim= new Claim();
|
270 |
|
|
claims.add(claim);
|
271 |
|
|
claim.setId(rs.getString(1));
|
272 |
47003
|
konstantin
|
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
273 |
42278
|
argiro.kok
|
Date date = format.parse(rs.getString(2));
|
274 |
|
|
claim.setDate(date);
|
275 |
41791
|
argiro.kok
|
claim.setUserMail(rs.getString(3));
|
276 |
|
|
claim.setSourceType(rs.getString(4));
|
277 |
|
|
claim.setTargetType(rs.getString(5));
|
278 |
|
|
claim.setSemantics(rs.getString(6));
|
279 |
47003
|
konstantin
|
|
280 |
|
|
if(addCurationInfo) {
|
281 |
|
|
date = format.parse(rs.getString(7));
|
282 |
|
|
claim.setCurationDate(date);
|
283 |
|
|
claim.setCuratedBy(rs.getString(8));
|
284 |
|
|
}
|
285 |
46918
|
argiro.kok
|
claim.setApproved(rs.getBoolean(9));
|
286 |
|
|
claim.setSource(buildEntity(rs,10,claim.getSourceType()));
|
287 |
|
|
claim.setTarget(buildEntity(rs,20,claim.getTargetType()));
|
288 |
41791
|
argiro.kok
|
|
289 |
|
|
}
|
290 |
|
|
return claims;
|
291 |
|
|
}
|
292 |
42270
|
argiro.kok
|
public Integer countClaimsByResultSet(ResultSet rs) throws Exception {
|
293 |
41791
|
argiro.kok
|
|
294 |
42270
|
argiro.kok
|
while(rs.next()) {
|
295 |
|
|
return rs.getInt(1);
|
296 |
|
|
}
|
297 |
|
|
return null;
|
298 |
|
|
}
|
299 |
42762
|
argiro.kok
|
public List<Project> getProjectsByResultSet(ResultSet rs) throws Exception {
|
300 |
|
|
List<Project> projects= new ArrayList<Project>();
|
301 |
|
|
while(rs.next()) {
|
302 |
|
|
Project project=(Project)(buildEntity(rs, 1, ClaimUtils.PROJECT));
|
303 |
|
|
projects.add(project);
|
304 |
|
|
}
|
305 |
|
|
return projects;
|
306 |
|
|
}
|
307 |
|
|
public List<Context> getContextsByResultSet(ResultSet rs) throws Exception {
|
308 |
|
|
List<Context> contexts= new ArrayList<Context>();
|
309 |
|
|
while(rs.next()) {
|
310 |
|
|
Context context=(Context)(buildEntity(rs, 1, ClaimUtils.CONTEXT));
|
311 |
|
|
contexts.add(context);
|
312 |
|
|
}
|
313 |
|
|
return contexts;
|
314 |
|
|
}
|
315 |
|
|
public Integer countAllClaims(String keyword, List<String> types) throws Exception {
|
316 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateCountAllClaims(keyword,types));
|
317 |
42270
|
argiro.kok
|
return countClaimsByResultSet(rs);
|
318 |
|
|
}
|
319 |
42762
|
argiro.kok
|
public Integer countClaimsByUser(String user,String keyword, List<String> types)throws Exception {
|
320 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateCountByUser(user,keyword,types));
|
321 |
42270
|
argiro.kok
|
return countClaimsByResultSet(rs);
|
322 |
|
|
}
|
323 |
42762
|
argiro.kok
|
public Integer countClaimsByProject(String projectId,String keyword, List<String> types)throws Exception {
|
324 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateCountByProject(projectId,keyword,types));
|
325 |
42270
|
argiro.kok
|
return countClaimsByResultSet(rs);
|
326 |
|
|
}
|
327 |
42762
|
argiro.kok
|
public Integer countClaimsByFunder(String funderId,String keyword, List<String> types)throws Exception {
|
328 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateCountByFunder(funderId,keyword,types));
|
329 |
42270
|
argiro.kok
|
return countClaimsByResultSet(rs);
|
330 |
|
|
}
|
331 |
42762
|
argiro.kok
|
public Integer countClaimsByResult(String resultId,String keyword, List<String> types)throws Exception {
|
332 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateCountByResult(resultId,keyword,types));
|
333 |
42270
|
argiro.kok
|
return countClaimsByResultSet(rs);
|
334 |
|
|
}
|
335 |
42762
|
argiro.kok
|
public Integer countClaimsByContext(String contextId,String keyword, List<String> types)throws Exception {
|
336 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateCountByContext(contextId,keyword,types));
|
337 |
42270
|
argiro.kok
|
return countClaimsByResultSet(rs);
|
338 |
|
|
}
|
339 |
42762
|
argiro.kok
|
public Integer countClaimsByDate(String dateFrom,String dateTo,String keyword, List<String> types)throws Exception {
|
340 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateCountByDate(dateFrom,dateTo,keyword,types));
|
341 |
42270
|
argiro.kok
|
return countClaimsByResultSet(rs);
|
342 |
|
|
}
|
343 |
42762
|
argiro.kok
|
|
344 |
|
|
public List<Project> getAllclaimedProjects()throws Exception {
|
345 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchAllProjectsQuery());
|
346 |
|
|
return getProjectsByResultSet(rs);
|
347 |
|
|
}
|
348 |
|
|
public List<Context> getAllclaimedContexts()throws Exception {
|
349 |
|
|
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateFetchAllContextsQuery());
|
350 |
|
|
return getContextsByResultSet(rs);
|
351 |
|
|
}
|
352 |
41791
|
argiro.kok
|
/**
|
353 |
|
|
*
|
354 |
|
|
* @param rs
|
355 |
|
|
* @param index
|
356 |
|
|
* @return
|
357 |
|
|
* @throws SQLException
|
358 |
|
|
*/
|
359 |
|
|
private static Result buildResult(ResultSet rs, Integer index) throws SQLException {
|
360 |
|
|
Result result = new Result();
|
361 |
|
|
result.setOpenaireId(rs.getString(index));
|
362 |
|
|
result.setTitle(rs.getString(index + 1));
|
363 |
|
|
result.setResultType(rs.getString(index + 2));
|
364 |
|
|
result.setDoi(rs.getString(index + 3));
|
365 |
|
|
result.setOrcidworkid(rs.getString(index + 4));
|
366 |
|
|
result.setAccessRights(rs.getString(index + 5));
|
367 |
|
|
result.setEmbargoEndDate(rs.getString(index + 6));
|
368 |
|
|
result.setBestLicense(rs.getString(index + 7));
|
369 |
|
|
result.setExternalUrl(rs.getString(index + 8));
|
370 |
|
|
result.setCollectedFrom(rs.getString(index + 9));
|
371 |
|
|
return result;
|
372 |
|
|
|
373 |
|
|
}
|
374 |
|
|
private static Project buildProject(ResultSet rs, Integer index) throws SQLException {
|
375 |
|
|
Project project = new Project();
|
376 |
|
|
project.setOpenaireId(rs.getString(index));
|
377 |
|
|
project.setName(rs.getString(index + 1));
|
378 |
|
|
project.setAcronym(rs.getString(index + 2));
|
379 |
|
|
project.setFunderId(rs.getString(index + 3));
|
380 |
|
|
project.setFunderName(rs.getString(index + 4));
|
381 |
|
|
project.setFunderShortName(rs.getString(index + 5));
|
382 |
|
|
return project;
|
383 |
|
|
|
384 |
|
|
}
|
385 |
|
|
private static Context buildContext(ResultSet rs, Integer index) throws SQLException {
|
386 |
|
|
Context context = new Context();
|
387 |
|
|
context.setOpenaireId(rs.getString(index));
|
388 |
|
|
context.setTitle(rs.getString(index + 1));
|
389 |
|
|
return context;
|
390 |
|
|
|
391 |
|
|
}
|
392 |
|
|
private static OpenaireEntity buildEntity(ResultSet rs, Integer index, String type) throws SQLException {
|
393 |
|
|
OpenaireEntity openaireEntity = null;
|
394 |
|
|
if(type == null){
|
395 |
|
|
openaireEntity = null;
|
396 |
|
|
}else if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)) {
|
397 |
|
|
openaireEntity= buildResult(rs, index);
|
398 |
|
|
}else if(type.equals(ClaimUtils.PROJECT)){
|
399 |
|
|
openaireEntity = buildProject(rs,index);
|
400 |
|
|
}else if(type.equals(ClaimUtils.CONTEXT)){
|
401 |
|
|
openaireEntity = buildContext(rs,index);
|
402 |
|
|
}
|
403 |
|
|
return openaireEntity;
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
public SqlDAO getSqlDAO() {
|
407 |
|
|
return sqlDAO;
|
408 |
|
|
}
|
409 |
|
|
|
410 |
|
|
public void setSqlDAO(SqlDAO sqlDAO) {
|
411 |
|
|
this.sqlDAO = sqlDAO;
|
412 |
|
|
}
|
413 |
|
|
|
414 |
42199
|
argiro.kok
|
public QueryGenerator getQueryGenerator() {
|
415 |
|
|
return queryGenerator;
|
416 |
|
|
}
|
417 |
41791
|
argiro.kok
|
|
418 |
42199
|
argiro.kok
|
public void setQueryGenerator(QueryGenerator queryGenerator) {
|
419 |
|
|
this.queryGenerator = queryGenerator;
|
420 |
|
|
}
|
421 |
41791
|
argiro.kok
|
}
|