10 |
10 |
import org.apache.commons.logging.Log;
|
11 |
11 |
import org.apache.commons.logging.LogFactory;
|
12 |
12 |
import org.hibernate.Criteria;
|
|
13 |
import org.hibernate.Hibernate;
|
13 |
14 |
import org.hibernate.Query;
|
14 |
15 |
import org.hibernate.criterion.Restrictions;
|
15 |
16 |
import org.hibernate.type.StringType;
|
|
17 |
import org.hibernate.type.TextType;
|
16 |
18 |
import org.hibernate.type.Type;
|
17 |
19 |
import org.springframework.beans.factory.annotation.Autowired;
|
18 |
20 |
import org.springframework.stereotype.Repository;
|
... | ... | |
42 |
44 |
|
43 |
45 |
public void saveRequest(final Request request) {
|
44 |
46 |
|
45 |
|
//Request r = getRequest(request.getId());
|
46 |
47 |
|
47 |
|
System.out.println("Request on dao object -> " + request);
|
48 |
|
|
49 |
|
/*if(request.getBankAccount()!=null){
|
|
48 |
if(request.getBankAccount()!=null){
|
50 |
49 |
if(request.getBankAccount().getId() == null)
|
51 |
50 |
request.getBankAccount().setId(getBankId());
|
52 |
51 |
}
|
... | ... | |
54 |
53 |
if(request.getRequestCoFunders() !=null) {
|
55 |
54 |
for (RequestCoFunder rc : request.getRequestCoFunders())
|
56 |
55 |
rc.getPk().setRequest(request);
|
57 |
|
}*/
|
|
56 |
}
|
58 |
57 |
|
59 |
|
/*if ( r == null){
|
|
58 |
|
|
59 |
if ( getRequest(request.getId()) == null){
|
60 |
60 |
Date date = new Date();
|
61 |
61 |
request.setDate(new Timestamp(date.getTime()));
|
62 |
|
}*/
|
63 |
|
getSession().saveOrUpdate(request);
|
|
62 |
persist(request);
|
|
63 |
}
|
|
64 |
|
|
65 |
//getSession().saveOrUpdate(request);
|
|
66 |
Request persistened_request = (Request) getSession().merge(request);
|
64 |
67 |
}
|
65 |
68 |
|
66 |
69 |
|
... | ... | |
245 |
248 |
" c.name as country, p.id as pid, p.acronym, p.startdate, p.enddate, p.scientificarea, " +
|
246 |
249 |
"pub.title, pub.type, j.title as journal,j.issn as issn,(case when jp.id is not null then jp.name else mp.name end) as publisher, " +
|
247 |
250 |
" r.approvaldate as approvaldate, r.apc as apc,r.currency as currency,r.datepaid, r.apcpaid, r.transfercost, " +
|
248 |
|
" r.othercost, comment.comment as comment from (" + requestQuery + ") r " +
|
|
251 |
" r.othercost, comment.comment as comment, " +
|
|
252 |
" pub.license as license , pub.doi as doi , pub.repository as repository , f.identifiers as identifiers " +
|
|
253 |
"from (" + requestQuery + ") r " +
|
249 |
254 |
"left join \"user\" u on r.researcher = u.email " +
|
250 |
255 |
"left join project p on r.project=p.id " +
|
251 |
256 |
"left join publication pub on r.publication=pub.id " +
|
|
257 |
"left join (select publication,array_to_string ( array_agg(concat_ws('#', type, value)),'@') as identifiers" +
|
|
258 |
" from publication_identifier pi, identifier i " +
|
|
259 |
" where pi.identifier = i.id" +
|
|
260 |
" group by pi.publication" +
|
|
261 |
" ) as f on r.publication = f.publication " +
|
252 |
262 |
"left join journal j on j.id=r.journal " +
|
253 |
263 |
"left join publisher jp on j.publisher=jp.id " +
|
254 |
264 |
"left join publisher mp on mp.id=r.publisher " +
|
... | ... | |
271 |
281 |
List<String[]> requests = new ArrayList<>();
|
272 |
282 |
Type[] t = new Type[types.size()];
|
273 |
283 |
t = types.toArray(t);
|
|
284 |
|
|
285 |
|
274 |
286 |
List<Object[]> resultSet = getSession().createSQLQuery(query)
|
275 |
287 |
.setParameters(args.toArray(), t).list();
|
276 |
288 |
|
277 |
289 |
for(Object rs[] : resultSet){
|
278 |
290 |
|
279 |
|
String[] objs = new String[25];
|
|
291 |
String[] objs = new String[28];
|
280 |
292 |
objs[0] = rs[0].toString();
|
281 |
293 |
objs[1] = String.valueOf(Request.RequestStatus.forStatus(Integer.parseInt(rs[1].toString())));
|
282 |
294 |
objs[2] = rs[2]!=null?new SimpleDateFormat("yyyy/MM/dd").format(rs[2]):null;
|
... | ... | |
284 |
296 |
objs[4] = rs[4]!=null?rs[4].toString():null;
|
285 |
297 |
objs[5] = rs[5]!=null?rs[5].toString():null;
|
286 |
298 |
objs[6] = rs[6]!=null?rs[6].toString():null;
|
287 |
|
//project id
|
288 |
|
objs[7] = rs[7]!=null?rs[7].toString():null;
|
|
299 |
objs[7] = rs[7]!=null?rs[7].toString().split("::")[1]:null;
|
289 |
300 |
objs[8] = rs[8]!=null?rs[8].toString():null;
|
290 |
301 |
objs[9] = rs[9]!=null?new SimpleDateFormat("yyyy/MM/dd").format(rs[9]):null;
|
291 |
302 |
objs[10] = rs[10]!=null?new SimpleDateFormat("yyyy/MM/dd").format(rs[10]):null;
|
... | ... | |
303 |
314 |
objs[22] = rs[22]!=null?rs[22].toString() + "":null;
|
304 |
315 |
objs[23] = rs[23]!=null?rs[23].toString() + "":null;
|
305 |
316 |
objs[24] = rs[24]!=null?rs[24].toString():null;
|
|
317 |
objs[25] = rs[25]!=null?rs[25].toString():null;
|
|
318 |
|
|
319 |
objs[26] = rs[26]!=null?"Doi: " + rs[26].toString() + ";":"";
|
|
320 |
objs[27] = rs[27]!=null?rs[27].toString():null;
|
|
321 |
|
|
322 |
|
|
323 |
String[] identifiers = rs[28]!=null?rs[28].toString().split("@"):null;
|
|
324 |
|
|
325 |
if (identifiers != null){
|
|
326 |
for(String identifier : identifiers){
|
|
327 |
String[] type_values = identifier.split("#");
|
|
328 |
String type = type_values[0];
|
|
329 |
String value = type_values[1];
|
|
330 |
objs[26] += type + ":" + value;
|
|
331 |
}
|
|
332 |
}
|
306 |
333 |
requests.add(objs);
|
307 |
334 |
}
|
308 |
335 |
|
... | ... | |
312 |
339 |
csvWriter.writeNext(new String[]{"id", "Status", "Submission Date", "Firstname", "Lastname", "Organization",
|
313 |
340 |
"Country", "Project id", "Acronym", "Start Date", "End Date", "Scientific Area", "Title", "Type",
|
314 |
341 |
"Journal","Journal ISSN", "Publisher", "Date Approved", "APC requested", "Currency", "Date Paid", "APC paid",
|
315 |
|
"Transfer Cost", "Other Expenses", "Rejection Reason"}, false);
|
|
342 |
"Transfer Cost", "Other Expenses", "Rejection Reason", "License" , "Identifiers", "Repository"}, false);
|
316 |
343 |
csvWriter.writeAll(requests, false);
|
317 |
344 |
|
318 |
345 |
csvWriter.close();
|
- Request save/update bug fix ( saveOrupdate -> merge )