1
|
package eu.dnetlib.goldoa.service.eligibility;
|
2
|
|
3
|
import eu.dnetlib.goldoa.domain.Currency;
|
4
|
import eu.dnetlib.goldoa.domain.Eligibility;
|
5
|
import eu.dnetlib.goldoa.domain.Publication;
|
6
|
import eu.dnetlib.goldoa.domain.Request;
|
7
|
import eu.dnetlib.goldoa.service.CurrencyConverter;
|
8
|
import eu.dnetlib.goldoa.service.EligibilityManager;
|
9
|
import eu.dnetlib.goldoa.service.dao.PublicationDAO;
|
10
|
import org.springframework.beans.factory.annotation.Autowired;
|
11
|
import org.springframework.stereotype.Component;
|
12
|
|
13
|
/*
|
14
|
* Created by antleb on 3/25/15.
|
15
|
*/
|
16
|
|
17
|
@Component(value = "accountingEligibilityManager")
|
18
|
public class AccountingEligibilityManager implements EligibilityManager {
|
19
|
@Autowired
|
20
|
private PublicationDAO publicationDAO;
|
21
|
@Autowired
|
22
|
private CurrencyConverter currencyConverter;
|
23
|
|
24
|
private String participationNoNoMessage;
|
25
|
private String fundingRequestedNoNoMessage;
|
26
|
|
27
|
private float maxArticleAPC;
|
28
|
private String maxArticleAPCNoNoMessage;
|
29
|
private float maxMonographAPC;
|
30
|
private String maxMonographAPCNoNoMessage;
|
31
|
|
32
|
@Override
|
33
|
public Eligibility validate(Request request) {
|
34
|
Eligibility eligibility = new Eligibility();
|
35
|
|
36
|
if (request.getProjectparticipation() != null && (request.getProjectparticipation() <= 0 || request.getProjectparticipation() > 100))
|
37
|
eligibility.merge(new Eligibility(Eligibility.Status.NONO, this.participationNoNoMessage));
|
38
|
|
39
|
if (request.getFundingrequested() != null && (request.getFundingrequested() <= 0))
|
40
|
eligibility.merge(new Eligibility(Eligibility.Status.NONO, this.fundingRequestedNoNoMessage));
|
41
|
|
42
|
if (request.getPublication() != null && request.getFundingrequested() != null) {
|
43
|
Publication publication = request.getPublication();
|
44
|
float amount = currencyConverter.convert(request.getCurrency(), Currency.EUR, request.getFundingrequested());
|
45
|
|
46
|
switch (publication.getType()) {
|
47
|
case ARTICLE:
|
48
|
case BOOK_CHAPTER:
|
49
|
if (amount > maxArticleAPC)
|
50
|
eligibility.merge(new Eligibility(Eligibility.Status.NONO, maxArticleAPCNoNoMessage));
|
51
|
break;
|
52
|
case MONOGRAPH:
|
53
|
if (amount > maxMonographAPC)
|
54
|
eligibility.merge(new Eligibility(Eligibility.Status.NONO, maxMonographAPCNoNoMessage));
|
55
|
break;
|
56
|
}
|
57
|
}
|
58
|
|
59
|
return eligibility;
|
60
|
}
|
61
|
|
62
|
public String getParticipationNoNoMessage() {
|
63
|
return participationNoNoMessage;
|
64
|
}
|
65
|
|
66
|
public void setParticipationNoNoMessage(String participationNoNoMessage) {
|
67
|
this.participationNoNoMessage = participationNoNoMessage;
|
68
|
}
|
69
|
|
70
|
public String getFundingRequestedNoNoMessage() {
|
71
|
return fundingRequestedNoNoMessage;
|
72
|
}
|
73
|
|
74
|
public void setFundingRequestedNoNoMessage(String fundingRequestedNoNoMessage) {
|
75
|
this.fundingRequestedNoNoMessage = fundingRequestedNoNoMessage;
|
76
|
}
|
77
|
|
78
|
public float getMaxArticleAPC() {
|
79
|
return maxArticleAPC;
|
80
|
}
|
81
|
|
82
|
public void setMaxArticleAPC(float maxArticleAPC) {
|
83
|
this.maxArticleAPC = maxArticleAPC;
|
84
|
}
|
85
|
|
86
|
public String getMaxArticleAPCNoNoMessage() {
|
87
|
return maxArticleAPCNoNoMessage;
|
88
|
}
|
89
|
|
90
|
public void setMaxArticleAPCNoNoMessage(String maxArticleAPCNoNoMessage) {
|
91
|
this.maxArticleAPCNoNoMessage = maxArticleAPCNoNoMessage;
|
92
|
}
|
93
|
|
94
|
public float getMaxMonographAPC() {
|
95
|
return maxMonographAPC;
|
96
|
}
|
97
|
|
98
|
public void setMaxMonographAPC(float maxMonographAPC) {
|
99
|
this.maxMonographAPC = maxMonographAPC;
|
100
|
}
|
101
|
|
102
|
public String getMaxMonographAPCNoNoMessage() {
|
103
|
return maxMonographAPCNoNoMessage;
|
104
|
}
|
105
|
|
106
|
public void setMaxMonographAPCNoNoMessage(String maxMonographAPCNoNoMessage) {
|
107
|
this.maxMonographAPCNoNoMessage = maxMonographAPCNoNoMessage;
|
108
|
}
|
109
|
}
|