1 |
35215
|
antonis.le
|
package eu.dnetlib.goldoa.service;
|
2 |
|
|
|
3 |
50823
|
panagiotis
|
import com.sun.org.apache.xpath.internal.operations.Bool;
|
4 |
39539
|
antonis.le
|
import eu.dnetlib.goldoa.domain.*;
|
5 |
35828
|
antonis.le
|
import eu.dnetlib.goldoa.service.dao.RequestDAO;
|
6 |
35686
|
antonis.le
|
import eu.dnetlib.goldoa.service.utils.EmailUtils;
|
7 |
46741
|
panagiotis
|
import org.apache.commons.logging.Log;
|
8 |
|
|
import org.apache.commons.logging.LogFactory;
|
9 |
50823
|
panagiotis
|
import org.jboss.logging.annotations.Pos;
|
10 |
35478
|
antonis.le
|
import org.springframework.beans.factory.annotation.Autowired;
|
11 |
47283
|
panagiotis
|
import org.springframework.beans.factory.annotation.Value;
|
12 |
38128
|
antonis.le
|
import org.springframework.dao.EmptyResultDataAccessException;
|
13 |
45595
|
panagiotis
|
import org.springframework.stereotype.Service;
|
14 |
48369
|
panagiotis
|
import org.springframework.transaction.annotation.Propagation;
|
15 |
35215
|
antonis.le
|
import org.springframework.transaction.annotation.Transactional;
|
16 |
|
|
|
17 |
50823
|
panagiotis
|
import javax.annotation.PostConstruct;
|
18 |
35686
|
antonis.le
|
import javax.mail.MessagingException;
|
19 |
39564
|
antonis.le
|
import java.io.IOException;
|
20 |
38128
|
antonis.le
|
import java.io.InputStream;
|
21 |
47054
|
panagiotis
|
import java.math.BigInteger;
|
22 |
45595
|
panagiotis
|
import java.sql.Timestamp;
|
23 |
48369
|
panagiotis
|
import java.text.ParseException;
|
24 |
35639
|
antonis.le
|
import java.text.SimpleDateFormat;
|
25 |
35667
|
antonis.le
|
import java.util.ArrayList;
|
26 |
48519
|
panagiotis
|
import java.util.Arrays;
|
27 |
35639
|
antonis.le
|
import java.util.Date;
|
28 |
35215
|
antonis.le
|
import java.util.List;
|
29 |
35780
|
antonis.le
|
import java.util.concurrent.ExecutorService;
|
30 |
35215
|
antonis.le
|
|
31 |
45595
|
panagiotis
|
/*
|
32 |
|
|
* Created by antleb on 3/10/15.
|
33 |
45403
|
panagiotis
|
*/
|
34 |
|
|
|
35 |
45595
|
panagiotis
|
|
36 |
35215
|
antonis.le
|
@Transactional
|
37 |
46139
|
panagiotis
|
@Service("requestManager")
|
38 |
35215
|
antonis.le
|
public class RequestManagerImpl implements RequestManager {
|
39 |
|
|
|
40 |
39076
|
antonis.le
|
@Autowired
|
41 |
|
|
private RequestDAO requestDAO;
|
42 |
|
|
@Autowired
|
43 |
45595
|
panagiotis
|
private UserManager userManager;
|
44 |
39076
|
antonis.le
|
@Autowired
|
45 |
|
|
private OrganizationManager organizationManager;
|
46 |
|
|
@Autowired
|
47 |
|
|
private ProjectManager projectManager;
|
48 |
|
|
@Autowired
|
49 |
|
|
private PublicationManager publicationManager;
|
50 |
|
|
@Autowired
|
51 |
|
|
private InvoiceManager invoiceManager;
|
52 |
|
|
@Autowired
|
53 |
|
|
private BudgetManager budgetManager;
|
54 |
|
|
@Autowired
|
55 |
|
|
private EligibilityManager eligibilityManager;
|
56 |
|
|
@Autowired
|
57 |
|
|
private EmailUtils emailUtils;
|
58 |
|
|
@Autowired
|
59 |
|
|
private ExecutorService executorService;
|
60 |
48369
|
panagiotis
|
@Autowired
|
61 |
|
|
private SearchManager searchManager;
|
62 |
48546
|
panagiotis
|
@Autowired
|
63 |
|
|
private PublisherManager publisherManager;
|
64 |
35670
|
antonis.le
|
|
65 |
49828
|
panagiotis
|
|
66 |
47283
|
panagiotis
|
@Value("${goldoa.sendCoordinatorEmails}")
|
67 |
|
|
private String sendCoordinatorEmails ;//= false;
|
68 |
|
|
@Value("${goldoa.sendEvaEmail}")
|
69 |
|
|
private String sendEvaEmail ;//= false;
|
70 |
|
|
@Value("${goldoa.evaEmail}")
|
71 |
|
|
private String evaEmail;// = null;
|
72 |
|
|
|
73 |
50823
|
panagiotis
|
@Value("${goldoa.pendingemails}")
|
74 |
50824
|
panagiotis
|
private String pendingemails;
|
75 |
50823
|
panagiotis
|
|
76 |
49828
|
panagiotis
|
private Log LOGGER = LogFactory.getLog(RequestManagerImpl.class);
|
77 |
50825
|
panagiotis
|
private boolean sendPendingMails = false;
|
78 |
47054
|
panagiotis
|
|
79 |
50823
|
panagiotis
|
@PostConstruct
|
80 |
|
|
public void init(){
|
81 |
50824
|
panagiotis
|
LOGGER.debug("Pending emails: " + pendingemails);
|
82 |
50825
|
panagiotis
|
if(!sendPendingMails){
|
83 |
|
|
sendPendingMails = true;
|
84 |
|
|
sendEmailForPendingIncompleteRequests();
|
85 |
|
|
sendEmailForPendingConditionallyApprovedRequests();
|
86 |
|
|
|
87 |
|
|
}
|
88 |
50823
|
panagiotis
|
}
|
89 |
|
|
|
90 |
35215
|
antonis.le
|
@Override
|
91 |
|
|
public Request saveRequest(final Request request) {
|
92 |
48860
|
panagiotis
|
|
93 |
35215
|
antonis.le
|
if (request.getId() == null) {
|
94 |
35828
|
antonis.le
|
request.setId(new SimpleDateFormat("yyyyMMdd-").format(new Date()) + requestDAO.getRequestId());
|
95 |
46741
|
panagiotis
|
Budget budget = null;
|
96 |
48860
|
panagiotis
|
/*if(request.getPublisher() != null)
|
97 |
46741
|
panagiotis
|
budget = budgetManager.getForRequest(request.getOrganization().getId(),
|
98 |
|
|
request.getPublisher().getEmail());
|
99 |
|
|
|
100 |
43084
|
antonis.le
|
if (budget != null) {
|
101 |
45595
|
panagiotis
|
request.setBudget(budget);
|
102 |
43084
|
antonis.le
|
// TODO fix amounts
|
103 |
48860
|
panagiotis
|
budget.setRemaining(budget.getRemaining() - request.getFundingRequested());
|
104 |
|
|
budgetManager.saveBudget(budget);
|
105 |
|
|
}*/
|
106 |
35215
|
antonis.le
|
}
|
107 |
47100
|
panagiotis
|
request.setEligibility(eligibilityManager.validate(request));
|
108 |
39076
|
antonis.le
|
requestDAO.saveRequest(request);
|
109 |
35215
|
antonis.le
|
return request;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
@Override
|
113 |
45618
|
panagiotis
|
public Request getById(String requestId) {
|
114 |
47100
|
panagiotis
|
return requestDAO.getRequest(requestId);
|
115 |
45618
|
panagiotis
|
}
|
116 |
|
|
|
117 |
|
|
@Override
|
118 |
47054
|
panagiotis
|
public RequestPage getForUser(String email, Date fromDate, Date toDate, RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, String term, Request.RequestStatus[] statusFilter, int from, int to) {
|
119 |
|
|
RequestPage requests = requestDAO.getForUser(email, fromDate, toDate, requestSortBy, order, requestFilter, term, statusFilter, from, to);
|
120 |
45678
|
panagiotis
|
return requests;
|
121 |
39076
|
antonis.le
|
}
|
122 |
35215
|
antonis.le
|
|
123 |
39076
|
antonis.le
|
@Override
|
124 |
45678
|
panagiotis
|
public RequestPage getForPublisher(String publisherId, Date fromDate, Date toDate, RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, String term, Request.RequestStatus[] statusFilter, int from, int to) {
|
125 |
39539
|
antonis.le
|
RequestPage requests = requestDAO.getForPublisher(publisherId, fromDate, toDate, requestSortBy, order, requestFilter, term, statusFilter, from, to);
|
126 |
45678
|
panagiotis
|
return requests;
|
127 |
39076
|
antonis.le
|
}
|
128 |
36429
|
antonis.le
|
|
129 |
39076
|
antonis.le
|
@Override
|
130 |
45678
|
panagiotis
|
public RequestPage getForOrganization(List<String> organizationIds, Date fromDate, Date toDate, RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, String term, Request.RequestStatus[] statusFilter, int from, int to) {
|
131 |
39539
|
antonis.le
|
RequestPage requests = requestDAO.getForOrganization(organizationIds, fromDate, toDate, requestSortBy, order, requestFilter, term, statusFilter, from, to);
|
132 |
45678
|
panagiotis
|
return requests;
|
133 |
39076
|
antonis.le
|
}
|
134 |
36198
|
antonis.le
|
|
135 |
39076
|
antonis.le
|
@Override
|
136 |
35215
|
antonis.le
|
public List<Request> getForProject(String projectId) {
|
137 |
35828
|
antonis.le
|
return requestDAO.getForProject(projectId);
|
138 |
35639
|
antonis.le
|
}
|
139 |
35215
|
antonis.le
|
|
140 |
39076
|
antonis.le
|
@Override
|
141 |
39564
|
antonis.le
|
public String getCSV(String mode, RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, String term, Request.RequestStatus[] statusFilter) {
|
142 |
|
|
Integer[] statuses = null;
|
143 |
|
|
|
144 |
|
|
if ("moderator".equals(mode)) {
|
145 |
|
|
if (statusFilter == null || statusFilter.length == 0) {
|
146 |
|
|
|
147 |
|
|
} else {
|
148 |
|
|
statuses = new Integer[statusFilter.length];
|
149 |
|
|
|
150 |
|
|
for (int i = 0; i < statusFilter.length; i++) {
|
151 |
|
|
statuses[i] = statusFilter[i].getCode();
|
152 |
|
|
}
|
153 |
|
|
}
|
154 |
|
|
} else if ("accounting".equals(mode)) {
|
155 |
|
|
if (statusFilter == null || statusFilter.length == 0)
|
156 |
40596
|
antonis.le
|
statuses = new Integer[] {
|
157 |
|
|
Request.RequestStatus.APPROVED.getCode(),
|
158 |
|
|
Request.RequestStatus.ACCOUNTING_PROCESSING.getCode(),
|
159 |
|
|
Request.RequestStatus.ACCOUNTING_ON_HOLD.getCode(),
|
160 |
|
|
Request.RequestStatus.ACCOUNTING_DENIED.getCode(),
|
161 |
|
|
Request.RequestStatus.ACCOUNTING_PAID.getCode()};
|
162 |
39564
|
antonis.le
|
|
163 |
|
|
else {
|
164 |
|
|
statuses = new Integer[statusFilter.length];
|
165 |
|
|
|
166 |
|
|
for (int i = 0; i < statusFilter.length; i++) {
|
167 |
|
|
Request.RequestStatus s = statusFilter[i];
|
168 |
|
|
|
169 |
40596
|
antonis.le
|
statuses[i] = s.getCode();
|
170 |
39564
|
antonis.le
|
}
|
171 |
|
|
}
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
try {
|
175 |
|
|
return requestDAO.getCSV(requestSortBy, order, requestFilter, term, statuses);
|
176 |
|
|
} catch (IOException e) {
|
177 |
|
|
e.printStackTrace();
|
178 |
|
|
|
179 |
|
|
return e.getMessage();
|
180 |
|
|
}
|
181 |
|
|
}
|
182 |
|
|
|
183 |
|
|
@Override
|
184 |
45678
|
panagiotis
|
public RequestPage getRequests(Date fromDate, Date toDate, RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, String term, Request.RequestStatus[] statusFilter, int from, int to) {
|
185 |
45820
|
panagiotis
|
RequestPage requestPage = requestDAO.getRequests(fromDate, toDate, requestSortBy, order, requestFilter, term, statusFilter, from, to);
|
186 |
|
|
return requestPage;
|
187 |
39076
|
antonis.le
|
}
|
188 |
35662
|
antonis.le
|
|
189 |
39076
|
antonis.le
|
@Override
|
190 |
45678
|
panagiotis
|
public RequestPage getForAccounting(Date fromDate, Date toDate, RequestSort requestSortBy, RequestSortOrder order, RequestFilter requestFilter, String term, Request.RequestStatus[] statusFilter, int from, int to) {
|
191 |
39381
|
antonis.le
|
Integer[] statuses;
|
192 |
|
|
|
193 |
|
|
if (statusFilter == null || statusFilter.length == 0)
|
194 |
40374
|
antonis.le
|
statuses = new Integer[] {Request.RequestStatus.APPROVED.getCode(), Request.RequestStatus.ACCOUNTING_PROCESSING.getCode(), Request.RequestStatus.ACCOUNTING_ON_HOLD.getCode()
|
195 |
|
|
, Request.RequestStatus.ACCOUNTING_DENIED.getCode(), Request.RequestStatus.ACCOUNTING_PAID.getCode()};
|
196 |
39381
|
antonis.le
|
|
197 |
|
|
else {
|
198 |
|
|
statuses = new Integer[statusFilter.length];
|
199 |
|
|
|
200 |
|
|
for (int i = 0; i < statusFilter.length; i++) {
|
201 |
|
|
Request.RequestStatus s = statusFilter[i];
|
202 |
|
|
|
203 |
40374
|
antonis.le
|
statuses[i] = s.getCode();
|
204 |
39381
|
antonis.le
|
}
|
205 |
|
|
}
|
206 |
|
|
|
207 |
39539
|
antonis.le
|
RequestPage requests = requestDAO.getRequests(fromDate, toDate, requestSortBy, order, requestFilter, term, statuses, from, to);
|
208 |
45678
|
panagiotis
|
return requests;
|
209 |
39381
|
antonis.le
|
}
|
210 |
|
|
|
211 |
|
|
@Override
|
212 |
39076
|
antonis.le
|
public Request submitRequest(final Request request) {
|
213 |
35684
|
antonis.le
|
|
214 |
43256
|
antonis.le
|
if (request.getBudget() != null) {
|
215 |
45595
|
panagiotis
|
Budget budget = request.getBudget();
|
216 |
43256
|
antonis.le
|
|
217 |
46633
|
panagiotis
|
Organization organization = budget.getOrganizations().get(0);
|
218 |
|
|
if (organization != null)
|
219 |
45595
|
panagiotis
|
request.setStatus(Request.RequestStatus.LIBRARY_FUND_SUBMITTED);
|
220 |
43256
|
antonis.le
|
else if (budget.getPublisher() != null)
|
221 |
45595
|
panagiotis
|
request.setStatus(Request.RequestStatus.PUBLISHER_FUND_SUBMITTED);
|
222 |
43256
|
antonis.le
|
} else {
|
223 |
45595
|
panagiotis
|
request.setStatus(Request.RequestStatus.SUBMITTED);
|
224 |
43256
|
antonis.le
|
}
|
225 |
45595
|
panagiotis
|
request.setSubmissiondate(new Timestamp(new Date().getTime()));
|
226 |
47100
|
panagiotis
|
request.setEligibility(eligibilityManager.validate(request));
|
227 |
47054
|
panagiotis
|
requestDAO.submitRequest(request);
|
228 |
35780
|
antonis.le
|
|
229 |
47054
|
panagiotis
|
|
230 |
|
|
final List<User> moderators = userManager.getModerators();
|
231 |
45733
|
panagiotis
|
executorService.submit(new Runnable() {
|
232 |
39076
|
antonis.le
|
@Override
|
233 |
|
|
public void run() {
|
234 |
47054
|
panagiotis
|
try {
|
235 |
45733
|
panagiotis
|
switch (request.getEligibility().getStatus()) {
|
236 |
39076
|
antonis.le
|
case OK:
|
237 |
45733
|
panagiotis
|
emailUtils.sendRequesterOKEmail(request);
|
238 |
47054
|
panagiotis
|
for (User user : moderators)
|
239 |
45733
|
panagiotis
|
emailUtils.sendModeratorOKEmail(request, user);
|
240 |
39076
|
antonis.le
|
break;
|
241 |
|
|
case IFFY:
|
242 |
45733
|
panagiotis
|
emailUtils.sendRequesterIFFYEmail(request);
|
243 |
47054
|
panagiotis
|
for (User user : moderators)
|
244 |
45733
|
panagiotis
|
emailUtils.sendModeratorIFFYEmail(request, user);
|
245 |
39076
|
antonis.le
|
break;
|
246 |
|
|
case NONO:
|
247 |
|
|
break;
|
248 |
|
|
}
|
249 |
36854
|
antonis.le
|
|
250 |
47283
|
panagiotis
|
if (Boolean.parseBoolean(sendCoordinatorEmails)) {
|
251 |
45733
|
panagiotis
|
for (User coordinator : request.getProject().getCoordinators())
|
252 |
|
|
emailUtils.sendCoordinatorRequestSubmittedEmail(coordinator, request);
|
253 |
39076
|
antonis.le
|
}
|
254 |
|
|
} catch (MessagingException e) {
|
255 |
37916
|
antonis.le
|
e.printStackTrace();
|
256 |
39076
|
antonis.le
|
} catch (Exception e) {
|
257 |
|
|
e.printStackTrace();
|
258 |
47054
|
panagiotis
|
}
|
259 |
39076
|
antonis.le
|
}
|
260 |
45733
|
panagiotis
|
});
|
261 |
35684
|
antonis.le
|
|
262 |
39076
|
antonis.le
|
return request;
|
263 |
|
|
}
|
264 |
35684
|
antonis.le
|
|
265 |
39076
|
antonis.le
|
@Override
|
266 |
43084
|
antonis.le
|
public Request submitLibraryRequest(final Request request) throws PersonManagerException {
|
267 |
45595
|
panagiotis
|
request.setStatus(Request.RequestStatus.LIBRARY_FUND_SUBMITTED);
|
268 |
|
|
request.setSubmissiondate(new Timestamp(new Date().getTime()));
|
269 |
43084
|
antonis.le
|
|
270 |
|
|
// requestDAO.submitRequest(request.getId());
|
271 |
|
|
|
272 |
|
|
saveRequest(request);
|
273 |
|
|
|
274 |
|
|
// executorService.submit(new Runnable() {
|
275 |
|
|
// @Override
|
276 |
|
|
// public void run() {
|
277 |
|
|
// RequestInfo requestInfo = null;
|
278 |
|
|
// try {
|
279 |
|
|
// requestInfo = getRequestInfo(request);
|
280 |
|
|
//
|
281 |
|
|
// switch (requestInfo.getEligibility().getStatus()) {
|
282 |
|
|
// case OK:
|
283 |
|
|
// emailUtils.sendRequesterOKEmail(requestInfo);
|
284 |
|
|
//
|
285 |
|
|
// for (Person person : personManager.getModerators())
|
286 |
|
|
// emailUtils.sendModeratorOKEmail(requestInfo, person);
|
287 |
|
|
// break;
|
288 |
|
|
// case IFFY:
|
289 |
|
|
// emailUtils.sendRequesterIFFYEmail(requestInfo);
|
290 |
|
|
//
|
291 |
|
|
// for (Person person : personManager.getModerators())
|
292 |
|
|
// emailUtils.sendModeratorIFFYEmail(requestInfo, person);
|
293 |
|
|
// break;
|
294 |
|
|
// case NONO:
|
295 |
|
|
// break;
|
296 |
|
|
// }
|
297 |
|
|
//
|
298 |
|
|
// if (sendCoordinatorEmails) {
|
299 |
|
|
// for (Person coordinator : requestInfo.getProject().getCoordinators())
|
300 |
|
|
// emailUtils.sendCoordinatorRequestSubmittedEmail(coordinator, requestInfo);
|
301 |
|
|
// }
|
302 |
|
|
// } catch (MessagingException e) {
|
303 |
|
|
// e.printStackTrace();
|
304 |
|
|
// } catch (PersonManagerException e) {
|
305 |
|
|
// e.printStackTrace();
|
306 |
|
|
// } catch (Exception e) {
|
307 |
|
|
// e.printStackTrace();
|
308 |
|
|
// }
|
309 |
|
|
// }
|
310 |
|
|
// });
|
311 |
|
|
|
312 |
|
|
return request;
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
@Override
|
316 |
|
|
public Request submitPublisherRequest(Request request) throws PersonManagerException {
|
317 |
45595
|
panagiotis
|
request.setStatus(Request.RequestStatus.PUBLISHER_FUND_SUBMITTED);
|
318 |
|
|
request.setSubmissiondate(new Timestamp(new Date().getTime()));
|
319 |
43084
|
antonis.le
|
|
320 |
|
|
// requestDAO.submitRequest(request.getId());
|
321 |
|
|
|
322 |
|
|
saveRequest(request);
|
323 |
|
|
|
324 |
|
|
// executorService.submit(new Runnable() {
|
325 |
|
|
// @Override
|
326 |
|
|
// public void run() {
|
327 |
|
|
// RequestInfo requestInfo = null;
|
328 |
|
|
// try {
|
329 |
|
|
// requestInfo = getRequestInfo(request);
|
330 |
|
|
//
|
331 |
|
|
// switch (requestInfo.getEligibility().getStatus()) {
|
332 |
|
|
// case OK:
|
333 |
|
|
// emailUtils.sendRequesterOKEmail(requestInfo);
|
334 |
|
|
//
|
335 |
|
|
// for (Person person : personManager.getModerators())
|
336 |
|
|
// emailUtils.sendModeratorOKEmail(requestInfo, person);
|
337 |
|
|
// break;
|
338 |
|
|
// case IFFY:
|
339 |
|
|
// emailUtils.sendRequesterIFFYEmail(requestInfo);
|
340 |
|
|
//
|
341 |
|
|
// for (Person person : personManager.getModerators())
|
342 |
|
|
// emailUtils.sendModeratorIFFYEmail(requestInfo, person);
|
343 |
|
|
// break;
|
344 |
|
|
// case NONO:
|
345 |
|
|
// break;
|
346 |
|
|
// }
|
347 |
|
|
//
|
348 |
|
|
// if (sendCoordinatorEmails) {
|
349 |
|
|
// for (Person coordinator : requestInfo.getProject().getCoordinators())
|
350 |
|
|
// emailUtils.sendCoordinatorRequestSubmittedEmail(coordinator, requestInfo);
|
351 |
|
|
// }
|
352 |
|
|
// } catch (MessagingException e) {
|
353 |
|
|
// e.printStackTrace();
|
354 |
|
|
// } catch (PersonManagerException e) {
|
355 |
|
|
// e.printStackTrace();
|
356 |
|
|
// } catch (Exception e) {
|
357 |
|
|
// e.printStackTrace();
|
358 |
|
|
// }
|
359 |
|
|
// }
|
360 |
|
|
// });
|
361 |
|
|
|
362 |
|
|
return request;
|
363 |
|
|
}
|
364 |
|
|
|
365 |
|
|
@Override
|
366 |
45618
|
panagiotis
|
public void conditionallyApproveRequest(final String requestId, final String email, final String comment, String template) {
|
367 |
|
|
User user = null;
|
368 |
|
|
try {
|
369 |
|
|
user = userManager.getByEmail(email);
|
370 |
|
|
} catch (PersonManagerException e) {
|
371 |
|
|
e.printStackTrace();
|
372 |
|
|
}
|
373 |
|
|
requestDAO.conditionallyApproveRequest(requestId, user, comment, template);
|
374 |
39075
|
antonis.le
|
|
375 |
47054
|
panagiotis
|
final Request request = getById(requestId);
|
376 |
39076
|
antonis.le
|
executorService.submit(new Runnable() {
|
377 |
|
|
@Override
|
378 |
|
|
public void run() {
|
379 |
|
|
try {
|
380 |
45595
|
panagiotis
|
emailUtils.sendRequesterInitiallyApprovedEmail(request);
|
381 |
39076
|
antonis.le
|
} catch (MessagingException e) {
|
382 |
|
|
e.printStackTrace();
|
383 |
|
|
}
|
384 |
|
|
}
|
385 |
|
|
});
|
386 |
|
|
}
|
387 |
39075
|
antonis.le
|
|
388 |
39076
|
antonis.le
|
@Override
|
389 |
45618
|
panagiotis
|
public void approveRequest(final String requestId, final String email, final String comment, String template) {
|
390 |
|
|
User user = null;
|
391 |
|
|
try {
|
392 |
|
|
user = userManager.getByEmail(email);
|
393 |
|
|
} catch (PersonManagerException e) {
|
394 |
|
|
e.printStackTrace();
|
395 |
|
|
}
|
396 |
|
|
requestDAO.approveRequest(requestId, user, comment, template);
|
397 |
35766
|
antonis.le
|
|
398 |
47054
|
panagiotis
|
final Request request = getById(requestId);
|
399 |
|
|
executorService.submit(new Runnable() {
|
400 |
39076
|
antonis.le
|
@Override
|
401 |
|
|
public void run() {
|
402 |
|
|
try {
|
403 |
45595
|
panagiotis
|
emailUtils.sendRequesterApprovedEmail(request);
|
404 |
39076
|
antonis.le
|
} catch (MessagingException e) {
|
405 |
|
|
e.printStackTrace();
|
406 |
|
|
}
|
407 |
45595
|
panagiotis
|
if (request.getInvoice() == null) {
|
408 |
39076
|
antonis.le
|
try {
|
409 |
45595
|
panagiotis
|
emailUtils.sendRequesterInvoiceNotification(request);
|
410 |
|
|
emailUtils.sendPublisherInvoiceNotification(request);
|
411 |
39076
|
antonis.le
|
} catch (MessagingException e) {
|
412 |
|
|
e.printStackTrace();
|
413 |
|
|
}
|
414 |
|
|
} else {
|
415 |
|
|
try {
|
416 |
45595
|
panagiotis
|
for (User user : userManager.getAccountingOfficers())
|
417 |
|
|
emailUtils.sendAccountingRequestApprovedEmail(user, request);
|
418 |
39076
|
antonis.le
|
} catch (MessagingException e) {
|
419 |
|
|
e.printStackTrace();
|
420 |
|
|
}
|
421 |
|
|
}
|
422 |
|
|
}
|
423 |
47054
|
panagiotis
|
});
|
424 |
39076
|
antonis.le
|
}
|
425 |
35693
|
antonis.le
|
|
426 |
39076
|
antonis.le
|
@Override
|
427 |
45618
|
panagiotis
|
public void rejectRequest(final String requestId, String email, String comment, String template) {
|
428 |
|
|
User user = null;
|
429 |
|
|
try {
|
430 |
|
|
user = userManager.getByEmail(email);
|
431 |
|
|
} catch (PersonManagerException e) {
|
432 |
|
|
e.printStackTrace();
|
433 |
|
|
}
|
434 |
|
|
requestDAO.rejectRequest(requestId, user, comment, template);
|
435 |
47054
|
panagiotis
|
final Request request = getById(requestId);
|
436 |
|
|
executorService.submit(new Runnable() {
|
437 |
39076
|
antonis.le
|
@Override
|
438 |
|
|
public void run() {
|
439 |
|
|
try {
|
440 |
45595
|
panagiotis
|
emailUtils.sendRequesterRejectedEmail(request);
|
441 |
39076
|
antonis.le
|
} catch (MessagingException e) {
|
442 |
|
|
e.printStackTrace();
|
443 |
|
|
}
|
444 |
|
|
}
|
445 |
47054
|
panagiotis
|
});
|
446 |
39076
|
antonis.le
|
}
|
447 |
35693
|
antonis.le
|
|
448 |
39076
|
antonis.le
|
@Override
|
449 |
45618
|
panagiotis
|
public void processingRequest(final String requestId, String email, String comment, String template) {
|
450 |
|
|
User user = null;
|
451 |
|
|
try {
|
452 |
|
|
user = userManager.getByEmail(email);
|
453 |
|
|
} catch (PersonManagerException e) {
|
454 |
|
|
e.printStackTrace();
|
455 |
|
|
}
|
456 |
|
|
requestDAO.processingRequest(requestId, user, comment, template);
|
457 |
47054
|
panagiotis
|
final Request request = getById(requestId);
|
458 |
|
|
executorService.submit(new Runnable() {
|
459 |
39786
|
antonis.le
|
@Override
|
460 |
|
|
public void run() {
|
461 |
|
|
try {
|
462 |
45595
|
panagiotis
|
for (User user : userManager.getModerators())
|
463 |
|
|
emailUtils.sendModeratorProcessingEmail(user, request);
|
464 |
39786
|
antonis.le
|
|
465 |
|
|
} catch (MessagingException e) {
|
466 |
|
|
e.printStackTrace();
|
467 |
|
|
}
|
468 |
|
|
}
|
469 |
47054
|
panagiotis
|
});
|
470 |
39786
|
antonis.le
|
}
|
471 |
|
|
|
472 |
|
|
@Override
|
473 |
45618
|
panagiotis
|
public void paidRequest(final String requestId, String email, String comment, String template, float apc_paid,
|
474 |
|
|
float transfer_cost, float other_cost, Date datePaid) {
|
475 |
|
|
User user = null;
|
476 |
|
|
try {
|
477 |
|
|
user = userManager.getByEmail(email);
|
478 |
|
|
} catch (PersonManagerException e) {
|
479 |
|
|
e.printStackTrace();
|
480 |
|
|
}
|
481 |
36847
|
antonis.le
|
|
482 |
45618
|
panagiotis
|
requestDAO.paidRequest(requestId, user, comment, template, apc_paid, transfer_cost, other_cost, datePaid);
|
483 |
47054
|
panagiotis
|
final Request request = getById(requestId);
|
484 |
|
|
executorService.submit(new Runnable() {
|
485 |
39076
|
antonis.le
|
@Override
|
486 |
|
|
public void run() {
|
487 |
36847
|
antonis.le
|
|
488 |
39076
|
antonis.le
|
try {
|
489 |
45595
|
panagiotis
|
emailUtils.sendRequesterPaidEmail(request);
|
490 |
|
|
emailUtils.sendPublisherPaidEmail(request);
|
491 |
39077
|
antonis.le
|
|
492 |
45595
|
panagiotis
|
for (User user : userManager.getModerators())
|
493 |
|
|
emailUtils.sendModeratorPaidEmail(user, request);
|
494 |
39077
|
antonis.le
|
|
495 |
47283
|
panagiotis
|
if (Boolean.parseBoolean(sendEvaEmail))
|
496 |
45595
|
panagiotis
|
emailUtils.sendEvaPaidEmail(evaEmail, request);
|
497 |
40181
|
antonis.le
|
|
498 |
39076
|
antonis.le
|
} catch (MessagingException e) {
|
499 |
|
|
e.printStackTrace();
|
500 |
|
|
}
|
501 |
|
|
}
|
502 |
47054
|
panagiotis
|
});
|
503 |
39076
|
antonis.le
|
}
|
504 |
36847
|
antonis.le
|
|
505 |
39076
|
antonis.le
|
@Override
|
506 |
45618
|
panagiotis
|
public void paidLibraryRequest(String requestId, String email, String comment, String template, float apc_paid, float transfer_cost, float other_cost, Date datePaid) {
|
507 |
|
|
User user = null;
|
508 |
|
|
try {
|
509 |
|
|
user = userManager.getByEmail(email);
|
510 |
|
|
} catch (PersonManagerException e) {
|
511 |
|
|
e.printStackTrace();
|
512 |
|
|
}
|
513 |
|
|
requestDAO.paidLibraryRequest(requestId, user, comment, template, apc_paid, transfer_cost, other_cost, datePaid);
|
514 |
43084
|
antonis.le
|
|
515 |
|
|
// executorService.submit(new Runnable() {
|
516 |
|
|
// @Override
|
517 |
|
|
// public void run() {
|
518 |
|
|
// RequestInfo requestInfo = getById(requestId);
|
519 |
|
|
//
|
520 |
|
|
// try {
|
521 |
|
|
// emailUtils.sendRequesterPaidEmail(requestInfo);
|
522 |
|
|
// emailUtils.sendPublisherPaidEmail(requestInfo);
|
523 |
|
|
//
|
524 |
|
|
// for (Person person : personManager.getModerators())
|
525 |
|
|
// emailUtils.sendModeratorPaidEmail(person, requestInfo);
|
526 |
|
|
//
|
527 |
|
|
// if (sendEvaEmail)
|
528 |
|
|
// emailUtils.sendEvaPaidEmail(evaEmail, requestInfo);
|
529 |
|
|
//
|
530 |
|
|
// } catch (MessagingException e) {
|
531 |
|
|
// e.printStackTrace();
|
532 |
|
|
// }
|
533 |
|
|
// }
|
534 |
|
|
// });
|
535 |
|
|
}
|
536 |
|
|
|
537 |
|
|
@Override
|
538 |
45618
|
panagiotis
|
public void paidPublisherRequest(String requestId, String email, String comment,
|
539 |
|
|
String template, float apc_paid, float transfer_cost, float other_cost, Date datePaid) {
|
540 |
|
|
User user = null;
|
541 |
|
|
try {
|
542 |
|
|
user = userManager.getByEmail(email);
|
543 |
|
|
} catch (PersonManagerException e) {
|
544 |
|
|
e.printStackTrace();
|
545 |
|
|
}
|
546 |
|
|
requestDAO.paidPublisherRequest(requestId, user, comment, template, apc_paid, transfer_cost, other_cost, datePaid);
|
547 |
43084
|
antonis.le
|
|
548 |
|
|
// executorService.submit(new Runnable() {
|
549 |
|
|
// @Override
|
550 |
|
|
// public void run() {
|
551 |
|
|
// RequestInfo requestInfo = getById(requestId);
|
552 |
|
|
//
|
553 |
|
|
// try {
|
554 |
|
|
// emailUtils.sendRequesterPaidEmail(requestInfo);
|
555 |
|
|
// emailUtils.sendPublisherPaidEmail(requestInfo);
|
556 |
|
|
//
|
557 |
|
|
// for (Person person : personManager.getModerators())
|
558 |
|
|
// emailUtils.sendModeratorPaidEmail(person, requestInfo);
|
559 |
|
|
//
|
560 |
|
|
// if (sendEvaEmail)
|
561 |
|
|
// emailUtils.sendEvaPaidEmail(evaEmail, requestInfo);
|
562 |
|
|
//
|
563 |
|
|
// } catch (MessagingException e) {
|
564 |
|
|
// e.printStackTrace();
|
565 |
|
|
// }
|
566 |
|
|
// }
|
567 |
|
|
// });
|
568 |
|
|
}
|
569 |
|
|
|
570 |
|
|
@Override
|
571 |
45618
|
panagiotis
|
public void onHoldRequest(final String requestId, String email, String comment, String template) {
|
572 |
|
|
User user = null;
|
573 |
|
|
try {
|
574 |
|
|
user = userManager.getByEmail(email);
|
575 |
|
|
} catch (PersonManagerException e) {
|
576 |
|
|
e.printStackTrace();
|
577 |
|
|
}
|
578 |
|
|
requestDAO.onHoldRequest(requestId, user, comment, template);
|
579 |
36847
|
antonis.le
|
|
580 |
47054
|
panagiotis
|
final Request request = getById(requestId);
|
581 |
|
|
executorService.submit(new Runnable() {
|
582 |
39076
|
antonis.le
|
@Override
|
583 |
|
|
public void run() {
|
584 |
|
|
try {
|
585 |
45595
|
panagiotis
|
emailUtils.sendRequesterOnHoldEmail(request);
|
586 |
|
|
emailUtils.sendPublisherOnHoldEmail(request);
|
587 |
39786
|
antonis.le
|
|
588 |
45595
|
panagiotis
|
for (User user : userManager.getModerators())
|
589 |
|
|
emailUtils.sendModeratorOnHoldEmail(user, request);
|
590 |
39076
|
antonis.le
|
} catch (MessagingException e) {
|
591 |
|
|
e.printStackTrace();
|
592 |
|
|
}
|
593 |
|
|
}
|
594 |
47054
|
panagiotis
|
});
|
595 |
39076
|
antonis.le
|
}
|
596 |
36847
|
antonis.le
|
|
597 |
39076
|
antonis.le
|
@Override
|
598 |
45618
|
panagiotis
|
public void deniedRequest(final String requestId, String email, String comment, String template) {
|
599 |
|
|
User user = null;
|
600 |
|
|
try {
|
601 |
|
|
user = userManager.getByEmail(email);
|
602 |
|
|
} catch (PersonManagerException e) {
|
603 |
|
|
e.printStackTrace();
|
604 |
|
|
}
|
605 |
|
|
requestDAO.deniedRequest(requestId, user, comment, template);
|
606 |
47054
|
panagiotis
|
final Request request = getById(requestId);
|
607 |
|
|
executorService.submit(new Runnable() {
|
608 |
39076
|
antonis.le
|
@Override
|
609 |
|
|
public void run() {
|
610 |
|
|
try {
|
611 |
45595
|
panagiotis
|
emailUtils.sendRequesterDeniedEmail(request);
|
612 |
|
|
emailUtils.sendPublisherDeniedEmail(request);
|
613 |
39786
|
antonis.le
|
|
614 |
45595
|
panagiotis
|
for (User user : userManager.getModerators())
|
615 |
|
|
emailUtils.sendModeratorDeniedEmail(user, request);
|
616 |
39076
|
antonis.le
|
} catch (MessagingException e) {
|
617 |
|
|
e.printStackTrace();
|
618 |
|
|
}
|
619 |
|
|
}
|
620 |
47054
|
panagiotis
|
});
|
621 |
39076
|
antonis.le
|
}
|
622 |
36847
|
antonis.le
|
|
623 |
39076
|
antonis.le
|
@Override
|
624 |
47271
|
panagiotis
|
public Invoice invoiceUploaded(final String requestId, String invoiceId) throws ManagerException {
|
625 |
47260
|
panagiotis
|
|
626 |
47054
|
panagiotis
|
final Request request = getById(requestId);
|
627 |
47260
|
panagiotis
|
|
628 |
47054
|
panagiotis
|
final List<User> moderators = userManager.getModerators();
|
629 |
|
|
executorService.submit(new Runnable() {
|
630 |
39076
|
antonis.le
|
@Override
|
631 |
|
|
public void run() {
|
632 |
45595
|
panagiotis
|
if (request.getStatus() == Request.RequestStatus.CONDITIONALLY_APPROVED) {
|
633 |
39076
|
antonis.le
|
try {
|
634 |
47054
|
panagiotis
|
for (User user : moderators)
|
635 |
45595
|
panagiotis
|
emailUtils.sendModeratorInvoiceUploaded(user, request);
|
636 |
39076
|
antonis.le
|
} catch (MessagingException e) {
|
637 |
|
|
e.printStackTrace();
|
638 |
|
|
}
|
639 |
|
|
}
|
640 |
|
|
}
|
641 |
47054
|
panagiotis
|
});
|
642 |
47271
|
panagiotis
|
return invoiceManager.getInvoice(invoiceId);
|
643 |
39076
|
antonis.le
|
}
|
644 |
35759
|
antonis.le
|
|
645 |
39076
|
antonis.le
|
@Override
|
646 |
|
|
public void uploadTransferReceipt(String requestid, String contentType, InputStream inputStream) {
|
647 |
|
|
requestDAO.uploadBankTransferReceipt(requestid, contentType, inputStream);
|
648 |
|
|
}
|
649 |
38128
|
antonis.le
|
|
650 |
45595
|
panagiotis
|
|
651 |
39076
|
antonis.le
|
public BankTransferReceipt downloadBankTransferReceipt(String requestId) throws RequestManagerException {
|
652 |
|
|
try {
|
653 |
|
|
return requestDAO.downloadBankTransferReceipt(requestId);
|
654 |
|
|
} catch (EmptyResultDataAccessException e) {
|
655 |
|
|
throw new RequestManagerException(RequestManagerException.ErrorCause.NOT_EXISTS);
|
656 |
|
|
}
|
657 |
|
|
}
|
658 |
38128
|
antonis.le
|
|
659 |
45595
|
panagiotis
|
|
660 |
41561
|
antonis.le
|
public List<CommentTemplate> getCommentTemplates(Request.RequestStatus requestStatus) {
|
661 |
41560
|
antonis.le
|
try {
|
662 |
|
|
return requestDAO.getCommentTemplates(requestStatus);
|
663 |
|
|
} catch (EmptyResultDataAccessException e) {
|
664 |
41561
|
antonis.le
|
return new ArrayList<CommentTemplate>();
|
665 |
41560
|
antonis.le
|
}
|
666 |
|
|
}
|
667 |
|
|
|
668 |
45633
|
panagiotis
|
@Override
|
669 |
48564
|
panagiotis
|
@Transactional(propagation = Propagation.REQUIRED , rollbackFor = {PersonManagerException.class,
|
670 |
|
|
ManagerException.class,ParseException.class,Exception.class})
|
671 |
49828
|
panagiotis
|
public void importCSV(String csv) throws PersonManagerException, ManagerException, ParseException, OrganizationManagerException {
|
672 |
48369
|
panagiotis
|
|
673 |
48519
|
panagiotis
|
String linesWithHeader[] = csv.split("\\r?\\n");
|
674 |
|
|
String lines[] = Arrays.copyOfRange(linesWithHeader,1,linesWithHeader.length);
|
675 |
|
|
for(String str : lines){
|
676 |
50089
|
panagiotis
|
|
677 |
50096
|
panagiotis
|
LOGGER.debug("Importing line from csv -> " + str);
|
678 |
50089
|
panagiotis
|
|
679 |
48519
|
panagiotis
|
String line[] = str.split(",");
|
680 |
48369
|
panagiotis
|
|
681 |
49828
|
panagiotis
|
String firstname = !line[0].equals("")?line[0].trim():null;
|
682 |
|
|
String lastname = !line[1].equals("")?line[1].trim():null;
|
683 |
50089
|
panagiotis
|
String organization = !line[2].equals("")?line[2].trim():null;
|
684 |
|
|
String email = !line[3].equals("")?line[3].trim():null;
|
685 |
49828
|
panagiotis
|
|
686 |
|
|
String grant = !line[4].equals("")?line[4].trim():null;
|
687 |
|
|
String doi = !line[5].equals("")?line[5].trim():null;
|
688 |
|
|
String acceptanceDate = !line[6].equals("")?line[6].trim():null;
|
689 |
|
|
String identifierType = !line[7].equals("")?line[7].trim():null;
|
690 |
|
|
String identifierValue = !line[8].equals("")?line[8].trim():null;
|
691 |
|
|
String apc = !line[9].equals("")?line[9].trim():"0";
|
692 |
|
|
String apcCurrency = !line[10].equals("")?line[10].trim():null;
|
693 |
50141
|
panagiotis
|
String discount = !line[11].equals("")?line[11].trim():null;
|
694 |
|
|
String status = line.length>12?line[12].trim():"0";
|
695 |
49828
|
panagiotis
|
|
696 |
50141
|
panagiotis
|
LOGGER.debug(discount + "/" + status);
|
697 |
|
|
|
698 |
49828
|
panagiotis
|
importRequestFromCSV(firstname,lastname,organization,email,
|
699 |
|
|
grant,doi,acceptanceDate, identifierType,
|
700 |
50141
|
panagiotis
|
identifierValue,apc, apcCurrency,discount,status);
|
701 |
48369
|
panagiotis
|
}
|
702 |
|
|
}
|
703 |
|
|
|
704 |
|
|
|
705 |
50766
|
panagiotis
|
|
706 |
|
|
|
707 |
49828
|
panagiotis
|
private void importRequestFromCSV(String firstname, String lastname, String organization, String email, String grant,
|
708 |
|
|
String doi, String acceptanceDate,
|
709 |
49202
|
panagiotis
|
String identifierType, String identifierValue,
|
710 |
50141
|
panagiotis
|
String apc, String apcCurrency, String discount, String status)
|
711 |
49828
|
panagiotis
|
throws PersonManagerException, ParseException, ManagerException, OrganizationManagerException {
|
712 |
48369
|
panagiotis
|
|
713 |
50089
|
panagiotis
|
List<Object> orgs = organizationManager.search(organization);
|
714 |
|
|
if(orgs == null){
|
715 |
49828
|
panagiotis
|
LOGGER.debug("Organization " + organization + " not exists!");
|
716 |
50089
|
panagiotis
|
//org = organizationManager.createOrganization(organization);
|
717 |
49828
|
panagiotis
|
}
|
718 |
50089
|
panagiotis
|
Organization org = (Organization) organizationManager.search(organization).get(0);
|
719 |
49828
|
panagiotis
|
|
720 |
48355
|
panagiotis
|
User user = null;
|
721 |
|
|
try {
|
722 |
49828
|
panagiotis
|
user = userManager.getByEmail(email);
|
723 |
48355
|
panagiotis
|
} catch (PersonManagerException e) {
|
724 |
50096
|
panagiotis
|
LOGGER.debug("User with email : " + email + " not exists!");
|
725 |
49828
|
panagiotis
|
LOGGER.debug("Creating new inactive user with default password!");
|
726 |
|
|
user = userManager.createInActiveResearcher(firstname,lastname,email,org);
|
727 |
48355
|
panagiotis
|
}
|
728 |
|
|
|
729 |
48519
|
panagiotis
|
List<Object> rs = projectManager.search(grant);
|
730 |
|
|
Project project = null;
|
731 |
|
|
if(rs.size() == 0) {
|
732 |
49828
|
panagiotis
|
LOGGER.debug("Project with specified grant("+grant+") not found!");
|
733 |
48519
|
panagiotis
|
throw new ManagerException("Project with specified grant("+grant+") not found!");
|
734 |
|
|
}else
|
735 |
|
|
project = (Project) rs.get(0);
|
736 |
|
|
|
737 |
48369
|
panagiotis
|
Publication publication = null;
|
738 |
|
|
try {
|
739 |
50354
|
panagiotis
|
LOGGER.debug("Resolving doi...");
|
740 |
48369
|
panagiotis
|
publication = publicationManager.resolveDOI(doi);
|
741 |
|
|
} catch (ManagerException e) {
|
742 |
49828
|
panagiotis
|
LOGGER.debug("Requested doi("+doi+") not found!" , e);
|
743 |
48519
|
panagiotis
|
throw new ManagerException("Requested doi("+doi+") not found!");
|
744 |
48369
|
panagiotis
|
}
|
745 |
48355
|
panagiotis
|
|
746 |
48564
|
panagiotis
|
|
747 |
50354
|
panagiotis
|
if(publication.getJournal()!=null && publication.getJournal().getPublisher()!=null) {
|
748 |
|
|
LOGGER.debug("publisher not null!");
|
749 |
48546
|
panagiotis
|
publisherManager.savePublisher(publication.getJournal().getPublisher());
|
750 |
50354
|
panagiotis
|
}else if(publication.getPublisher()!=null)
|
751 |
48546
|
panagiotis
|
publisherManager.savePublisher(publication.getPublisher());
|
752 |
48369
|
panagiotis
|
|
753 |
50354
|
panagiotis
|
LOGGER.debug(publication.getJournal().getPublisher().getName());
|
754 |
49202
|
panagiotis
|
if ( publicationManager.getPublication(publication.getId()) == null )
|
755 |
|
|
publicationManager.savePublication(publication);
|
756 |
48519
|
panagiotis
|
|
757 |
49202
|
panagiotis
|
|
758 |
49828
|
panagiotis
|
Request request = requestDAO.getRequestFromCSV(user,project,publication,org,
|
759 |
50141
|
panagiotis
|
acceptanceDate, identifierType,identifierValue,apc, apcCurrency,discount,status);
|
760 |
48564
|
panagiotis
|
|
761 |
48519
|
panagiotis
|
request.setId("L" + new SimpleDateFormat("yyyyMMdd-").format(new Date()) + requestDAO.getRequestId());
|
762 |
49202
|
panagiotis
|
request.setEligibility(Eligibility.OK);
|
763 |
48564
|
panagiotis
|
|
764 |
49828
|
panagiotis
|
|
765 |
48564
|
panagiotis
|
if(!request.getEligibility().getStatus().equals(Eligibility.Status.OK))
|
766 |
|
|
throw new ManagerException("Request for project "+grant+" is not eligible!");
|
767 |
49202
|
panagiotis
|
requestDAO.saveRequest(request);
|
768 |
50624
|
panagiotis
|
LOGGER.debug(request.getPublication().getType());
|
769 |
48355
|
panagiotis
|
}
|
770 |
|
|
|
771 |
48546
|
panagiotis
|
|
772 |
48355
|
panagiotis
|
@Override
|
773 |
47054
|
panagiotis
|
public BigInteger getActiveNumber() {
|
774 |
45633
|
panagiotis
|
return requestDAO.getActiveNumber();
|
775 |
|
|
}
|
776 |
|
|
|
777 |
|
|
@Override
|
778 |
47054
|
panagiotis
|
public BigInteger getPaidNumber() {
|
779 |
45633
|
panagiotis
|
return requestDAO.getPaidNumber();
|
780 |
|
|
}
|
781 |
|
|
|
782 |
|
|
@Override
|
783 |
47054
|
panagiotis
|
public BigInteger getNumberOfProjects() {
|
784 |
45633
|
panagiotis
|
return requestDAO.getNumberOfProjects();
|
785 |
|
|
}
|
786 |
|
|
|
787 |
|
|
@Override
|
788 |
47054
|
panagiotis
|
public Float getTotalAmount() {
|
789 |
45633
|
panagiotis
|
return requestDAO.getTotalAmount();
|
790 |
|
|
}
|
791 |
|
|
|
792 |
|
|
@Override
|
793 |
45837
|
panagiotis
|
public Double getAverageAmount() {
|
794 |
45633
|
panagiotis
|
return requestDAO.getAverageAmount();
|
795 |
|
|
}
|
796 |
|
|
|
797 |
|
|
@Override
|
798 |
47054
|
panagiotis
|
public Double getAverageAmountPerBookChapter() {
|
799 |
|
|
return requestDAO.getAverageAmountPerBookChapter();
|
800 |
45633
|
panagiotis
|
}
|
801 |
|
|
|
802 |
|
|
@Override
|
803 |
48369
|
panagiotis
|
public Double getAverageAmountPerMonograph() {
|
804 |
|
|
return requestDAO.getAverageAmountPerMonograph();
|
805 |
|
|
}
|
806 |
|
|
|
807 |
|
|
@Override
|
808 |
48355
|
panagiotis
|
public Double getAverageAmountPbooleanerMonograph() {
|
809 |
47054
|
panagiotis
|
return requestDAO.getAverageAmountPerMonograph();
|
810 |
45633
|
panagiotis
|
}
|
811 |
|
|
|
812 |
|
|
@Override
|
813 |
47054
|
panagiotis
|
public Double getAverageAmountPerArticle() {
|
814 |
|
|
return requestDAO.getAverageAmountPerArticle();
|
815 |
45633
|
panagiotis
|
}
|
816 |
|
|
|
817 |
|
|
@Override
|
818 |
47054
|
panagiotis
|
public BigInteger getNumberOfPaidPublicationPerArticle() {
|
819 |
|
|
return requestDAO.getNumberOfPaidPublicationPerArticle();
|
820 |
45633
|
panagiotis
|
}
|
821 |
|
|
|
822 |
47054
|
panagiotis
|
@Override
|
823 |
|
|
public BigInteger getNumberOfPaidPublicationPerMonograph() {
|
824 |
|
|
return requestDAO.getNumberOfPaidPublicationPerMonograph();
|
825 |
|
|
}
|
826 |
|
|
|
827 |
|
|
@Override
|
828 |
|
|
public BigInteger getNumberOfPaidPublicationPerBookChapter() {
|
829 |
|
|
return requestDAO.getNumberOfPaidPublicationPerBookChapter();
|
830 |
|
|
}
|
831 |
|
|
|
832 |
|
|
|
833 |
|
|
@Override
|
834 |
|
|
public BigInteger getNumberOfPaidRequestsWithDOI() {
|
835 |
|
|
return requestDAO.getNumberOfPaidRequestsWithDOI();
|
836 |
|
|
}
|
837 |
|
|
|
838 |
|
|
@Override
|
839 |
|
|
public BigInteger getNumberOfApprovedRequestsWithDOI() {
|
840 |
|
|
return requestDAO.getNumberOfApprovedRequestsWithDOI();
|
841 |
|
|
}
|
842 |
|
|
|
843 |
47283
|
panagiotis
|
public String isSendCoordinatorEmails() {
|
844 |
39076
|
antonis.le
|
return sendCoordinatorEmails;
|
845 |
|
|
}
|
846 |
39070
|
antonis.le
|
|
847 |
47283
|
panagiotis
|
public void setSendCoordinatorEmails(String sendCoordinatorEmails) {
|
848 |
39076
|
antonis.le
|
this.sendCoordinatorEmails = sendCoordinatorEmails;
|
849 |
|
|
}
|
850 |
40181
|
antonis.le
|
|
851 |
47283
|
panagiotis
|
public String isSendEvaEmail() {
|
852 |
40181
|
antonis.le
|
return sendEvaEmail;
|
853 |
|
|
}
|
854 |
|
|
|
855 |
47283
|
panagiotis
|
public void setSendEvaEmail(String sendEvaEmail) {
|
856 |
40181
|
antonis.le
|
this.sendEvaEmail = sendEvaEmail;
|
857 |
|
|
}
|
858 |
|
|
|
859 |
|
|
public String getEvaEmail() {
|
860 |
|
|
return evaEmail;
|
861 |
|
|
}
|
862 |
|
|
|
863 |
|
|
public void setEvaEmail(String evaEmail) {
|
864 |
|
|
this.evaEmail = evaEmail;
|
865 |
|
|
}
|
866 |
50766
|
panagiotis
|
|
867 |
|
|
@Override
|
868 |
|
|
public List<Request> getPendingRequestsByStatus(int status) {
|
869 |
|
|
return requestDAO.getPendingRequestsByStatus(status);
|
870 |
|
|
}
|
871 |
|
|
|
872 |
|
|
@Override
|
873 |
50825
|
panagiotis
|
public void sendEmailForPendingIncompleteRequests(){
|
874 |
50823
|
panagiotis
|
|
875 |
50824
|
panagiotis
|
if(Boolean.parseBoolean(pendingemails)) {
|
876 |
50823
|
panagiotis
|
List<Request> pendingRequests = getPendingRequestsByStatus(Request.RequestStatus.INCOMPLETE.getCode());
|
877 |
|
|
int counter = 1;
|
878 |
|
|
for (Request r : pendingRequests) {
|
879 |
50825
|
panagiotis
|
if(counter > 54) {
|
880 |
|
|
try {
|
881 |
|
|
LOGGER.debug("Send email " + counter + " of " + pendingRequests.size());
|
882 |
|
|
emailUtils.sendEmailForPendingIncompleteRequests(r);
|
883 |
|
|
} catch (MessagingException e) {
|
884 |
|
|
LOGGER.debug(e);
|
885 |
|
|
}
|
886 |
|
|
}
|
887 |
|
|
counter++;
|
888 |
50823
|
panagiotis
|
}
|
889 |
|
|
}
|
890 |
|
|
else{
|
891 |
|
|
List<Request> pendingRequests = getPendingRequestsByStatus(Request.RequestStatus.INCOMPLETE.getCode());
|
892 |
|
|
Request r = pendingRequests.get(0);
|
893 |
|
|
LOGGER.debug("Sending email for debug.");
|
894 |
|
|
}
|
895 |
|
|
|
896 |
50766
|
panagiotis
|
}
|
897 |
|
|
|
898 |
|
|
@Override
|
899 |
50825
|
panagiotis
|
public void sendEmailForPendingConditionallyApprovedRequests() {
|
900 |
50824
|
panagiotis
|
if(Boolean.parseBoolean(pendingemails)) {
|
901 |
50823
|
panagiotis
|
List<Request> pendingRequests = getPendingRequestsByStatus(Request.RequestStatus.CONDITIONALLY_APPROVED.getCode());
|
902 |
|
|
int counter = 1;
|
903 |
|
|
for (Request r : pendingRequests) {
|
904 |
|
|
LOGGER.debug("Send email " + counter + " of " + pendingRequests.size());
|
905 |
50825
|
panagiotis
|
try {
|
906 |
|
|
emailUtils.sendEmailForPendingConditionallyApprovedRequests(r);
|
907 |
|
|
} catch (MessagingException e) {
|
908 |
|
|
LOGGER.debug(e);
|
909 |
|
|
}
|
910 |
|
|
|
911 |
50823
|
panagiotis
|
counter++;
|
912 |
|
|
}
|
913 |
|
|
}
|
914 |
|
|
else{
|
915 |
|
|
List<Request> pendingRequests= getPendingRequestsByStatus(Request.RequestStatus.CONDITIONALLY_APPROVED.getCode());
|
916 |
|
|
Request r = pendingRequests.get(0);
|
917 |
|
|
LOGGER.debug("Sending email for debug.");
|
918 |
|
|
}
|
919 |
50766
|
panagiotis
|
}
|
920 |
|
|
|
921 |
|
|
|
922 |
35215
|
antonis.le
|
}
|