Project

General

Profile

« Previous | Next » 

Revision 48864

- Request save/update bug fix ( saveOrupdate -> merge )

View differences:

modules/uoa-goldoa-service/branches/hibernate/src/test/java/unitest/ManageRequestsTest.java
48 48
    @Rollback(true)
49 49
    public void getRequestsForLibrarian() throws PersonManagerException {
50 50
        List<String> organizationIds = new ArrayList<>();
51
        for(Affiliation affiliation : um.getByEmail("ant.lebesis@gmail.com")
51
        for(Affiliation affiliation : um.getByEmail("pkanakakis@di.uoa.gr")
52 52
                .getAffiliations()) {
53 53
            if(affiliation.getOrganization()!=null)
54 54
                organizationIds.add(affiliation.getOrganization().getId());
......
229 229
    @Transactional
230 230
    @Rollback(true)
231 231
    public void getRequest() throws PersonManagerException {
232
        Request r = rm.getById("20170118-1302");
232
        Request r = rm.getById("20170524-1518");
233
        System.out.println(r.getBankTransferReceipt());
233 234
        System.out.println(r.getPublisherEmail());
234 235
        System.out.println(r.getEligibility().getStatus());
235 236
    }
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/RequestManagerImpl.java
71 71
	@Override
72 72
	public Request saveRequest(final Request request) {
73 73

  
74
		System.out.println("Request object -> " + request);
75

  
76 74
		if (request.getId() == null) {
77 75
			request.setId(new SimpleDateFormat("yyyyMMdd-").format(new Date()) + requestDAO.getRequestId());
78 76
			Budget budget = null;
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/dao/RequestDAO.java
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();
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/eligibility/ProjectEligibiliyManager.java
87 87
			return new Eligibility(Eligibility.Status.NONO, stillRunningNono);
88 88
		} else if (enddate.after(new Date(System.currentTimeMillis() - expirationOk * 1000L * 60 * 60 * 24 * 30))) {
89 89
			return Eligibility.OK;
90
		} else if (enddate.after(new Date((long) (System.currentTimeMillis() - (1.0f + expirationThreshold) * expirationOk* 1000L * 60 * 60 * 24 * 30)))) {
90
		} else if (enddate.after(new Date((long) (System.currentTimeMillis() - (1.0f + expirationThreshold) * expirationOk * 1000L * 60 * 60 * 24 * 30)))) {
91 91
			return new Eligibility(Eligibility.Status.IFFY, expirationIffy);
92 92
		} else {
93 93
			return new Eligibility(Eligibility.Status.NONO, expirationNono);

Also available in: Unified diff