Project

General

Profile

« Previous | Next » 

Revision 36871

checking for max requested apcs in eligibility

View differences:

modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/eligibility/AccountingEligibilityManager.java
1 1
package eu.dnetlib.goldoa.service.eligibility;
2 2

  
3 3
import eu.dnetlib.goldoa.domain.Eligibility;
4
import eu.dnetlib.goldoa.domain.Publication;
4 5
import eu.dnetlib.goldoa.domain.Request;
6
import eu.dnetlib.goldoa.service.CurrencyConverter;
5 7
import eu.dnetlib.goldoa.service.EligibilityManager;
8
import eu.dnetlib.goldoa.service.dao.PublicationDAO;
9
import org.springframework.beans.factory.annotation.Autowired;
6 10

  
7 11
/**
8 12
 * Created by antleb on 3/25/15.
9 13
 */
10 14
public class AccountingEligibilityManager implements EligibilityManager {
11 15

  
16
    @Autowired
17
    private PublicationDAO publicationDAO;
18
    @Autowired
19
    private CurrencyConverter currencyConverter;
20

  
12 21
    private String participationNoNoMessage;
13 22
    private String fundingRequestedNoNoMessage;
14 23

  
24
    private float maxArticleAPC;
25
    private String maxArticleAPCNoNoMessage;
26
    private float maxMonographAPC;
27
    private String maxMonographAPCNoNoMessage;
28

  
15 29
    @Override
16 30
    public Eligibility validate(Request request) {
17 31
        Eligibility eligibility = new Eligibility();
......
22 36
        if (request.getFundingRequested() != null && (request.getFundingRequested() <= 0))
23 37
            eligibility.merge(new Eligibility(Eligibility.Status.NONO, this.fundingRequestedNoNoMessage));
24 38

  
39
        if (request.getPublication() != null) {
40
            Publication publication = publicationDAO.getPublication(request.getPublication());
41
            Float amount = currencyConverter.convert(CurrencyConverter.Currency.valueOf(request.getCurrency()), CurrencyConverter.Currency.EUR, request.getFundingRequested());
42

  
43
            switch (publication.getType()) {
44
                case ARTICLE:
45
                    if (amount > maxArticleAPC)
46
                        eligibility.merge(new Eligibility(Eligibility.Status.NONO, maxArticleAPCNoNoMessage));
47
                    break;
48
                case MONOGRAPH:
49
                    if (amount > maxMonographAPC)
50
                        eligibility.merge(new Eligibility(Eligibility.Status.NONO, maxMonographAPCNoNoMessage));
51
                    break;
52
            }
53
        }
54

  
25 55
        return eligibility;
26 56
    }
27 57

  
......
40 70
    public void setFundingRequestedNoNoMessage(String fundingRequestedNoNoMessage) {
41 71
        this.fundingRequestedNoNoMessage = fundingRequestedNoNoMessage;
42 72
    }
73

  
74
    public float getMaxArticleAPC() {
75
        return maxArticleAPC;
76
    }
77

  
78
    public void setMaxArticleAPC(float maxArticleAPC) {
79
        this.maxArticleAPC = maxArticleAPC;
80
    }
81

  
82
    public String getMaxArticleAPCNoNoMessage() {
83
        return maxArticleAPCNoNoMessage;
84
    }
85

  
86
    public void setMaxArticleAPCNoNoMessage(String maxArticleAPCNoNoMessage) {
87
        this.maxArticleAPCNoNoMessage = maxArticleAPCNoNoMessage;
88
    }
89

  
90
    public float getMaxMonographAPC() {
91
        return maxMonographAPC;
92
    }
93

  
94
    public void setMaxMonographAPC(float maxMonographAPC) {
95
        this.maxMonographAPC = maxMonographAPC;
96
    }
97

  
98
    public String getMaxMonographAPCNoNoMessage() {
99
        return maxMonographAPCNoNoMessage;
100
    }
101

  
102
    public void setMaxMonographAPCNoNoMessage(String maxMonographAPCNoNoMessage) {
103
        this.maxMonographAPCNoNoMessage = maxMonographAPCNoNoMessage;
104
    }
43 105
}
modules/uoa-goldoa-service/trunk/src/main/resources/eu/dnetlib/goldoa/service/applicationContext-goldoa-service.properties
28 28

  
29 29
goldoa.eligibility.accounting.participation.nono.message = The project participation must be between 0 and 100.
30 30
goldoa.eligibility.accounting.funding.nono.message = You must specify the funding requested.
31
goldoa.eligibility.accounting.apc.article.max = 2000
32
goldoa.eligibility.accounting.apc.article.nono.message = The maximum funding per request for journal articles is 2000 Euro
33
goldoa.eligibility.accounting.apc.monograph.max = 6000
34
goldoa.eligibility.accounting.apc.monograph.nono.message = The maximum funding per request for monograph is 6000 Euro
31 35

  
32 36
goldoa.eligibility.organization.budgetAvailableNONOMessage = Your organization is already funded by the Gold Open Access Pilot. Perhaps, it's better to check with your library first.
33 37

  

Also available in: Unified diff