Project

General

Profile

« Previous | Next » 

Revision 36874

changed currency fields from String to the enum

View differences:

modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/CurrencyConverter.java
9 9
import javax.xml.xpath.XPathExpression;
10 10
import javax.xml.xpath.XPathExpressionException;
11 11
import javax.xml.xpath.XPathFactory;
12
import java.io.Serializable;
12 13
import java.util.HashMap;
13 14
import java.util.Map;
14 15
import java.util.concurrent.Executors;
......
20 21
 */
21 22
public class CurrencyConverter {
22 23

  
23
    public enum Currency {
24
    public enum Currency implements Serializable {
25
        // values taken from http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
24 26
        EUR("Euro"),
25 27
        USD("US dollar"),
28
        GBP("Pound sterling"),
29
        CHF("Swiss franc"),
26 30
        CZK("Czech koruna"),
27 31
        DKK("Danish krone"),
28
        GBP("Pound sterling"),
29
        CHF("Swiss franc"),
30 32
        NOK("Norwegian krone");
31 33

  
32 34
        private String name;
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/dao/PublisherDAO.java
1 1
package eu.dnetlib.goldoa.service.dao;
2 2

  
3 3
import eu.dnetlib.goldoa.domain.*;
4
import eu.dnetlib.goldoa.service.CurrencyConverter;
4 5
import org.apache.commons.codec.digest.DigestUtils;
5 6
import org.springframework.beans.factory.annotation.Autowired;
6 7
import org.springframework.jdbc.core.JdbcTemplate;
......
47 48
                Person person = rs.getString("contact")!=null?new Person(rs.getString("contact")):null;
48 49
                BankAccount bankAccount = new BankAccount(rs.getString("bank_name"), rs.getString("bank_address"), rs.getString("bank_code"), rs.getString("bank_holder"), rs.getString("bank_iban"));
49 50

  
50
                return new Publisher(rs.getString("id"), rs.getString("name"), rs.getString("email"), person, rs.getFloat("apc"), rs.getString("apc_currency"), rs.getFloat("discount"), bankAccount, rs.getString("source"));
51
                return new Publisher(rs.getString("id"), rs.getString("name"), rs.getString("email"), person, rs.getFloat("apc"), CurrencyConverter.Currency.valueOf(rs.getString("apc_currency")), rs.getFloat("discount"), bankAccount, rs.getString("source"));
51 52
            }
52 53
        });
53 54
    }
......
58 59
                Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR};
59 60
        BankAccount bankAccount = publisher.getBankAccount()!=null?publisher.getBankAccount():new BankAccount();
60 61

  
61
        Object[] args = {publisher.getName(), publisher.getEmail(), publisher.getContact()!=null?publisher.getContact().getId():null, publisher.getAPC(), publisher.getCurrency(),
62
        Object[] args = {publisher.getName(), publisher.getEmail(), publisher.getContact()!=null?publisher.getContact().getId():null, publisher.getAPC(), publisher.getCurrency().name(),
62 63
                publisher.getDiscount(), bankAccount.getBankName(), bankAccount.getBankAddress(), bankAccount.getBankCode(), bankAccount.getAccountHolder(),
63 64
                bankAccount.getIban(), publisher.getSource(), publisher.getId()};
64 65

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

  
3 3
import eu.dnetlib.goldoa.domain.*;
4
import eu.dnetlib.goldoa.service.CurrencyConverter;
4 5
import org.apache.commons.codec.digest.DigestUtils;
5 6
import org.apache.commons.lang3.ArrayUtils;
6 7
import org.springframework.beans.factory.annotation.Autowired;
......
50 51
            Request request = new Request(
51 52
                    rs.getString("id"), rs.getString("user"), rs.getTimestamp("date"), rs.getString("researcher"), rs.getString("organization"),
52 53
                    rs.getString("project"), rs.getString("publication"), rs.getString("journal"), rs.getString("publisher"),
53
                    rs.getString("budget"), rs.getString("invoice"), rs.getFloat("projectparticipation"), rs.getFloat("fundingrequested"), rs.getString("currency"), bankAccount, rs.getInt("status"));
54
                    rs.getString("budget"), rs.getString("invoice"), rs.getFloat("projectparticipation"), rs.getFloat("fundingrequested"), CurrencyConverter.Currency.valueOf(rs.getString("currency")), bankAccount, rs.getInt("status"));
54 55

  
55 56
            rs.getFloat("projectparticipation");
56 57
            if (rs.wasNull())
......
74 75
        if (request.getBankAccount() != null) {
75 76
            args = new Object[]{request.getUser(), request.getDate(), request.getResearcher(), request.getOrganization(), request.getProject(),
76 77
                    request.getPublication(), request.getJournal(), request.getPublisher(), request.getBudget(), request.getInvoice(),
77
                    request.getProjectParticipation(), request.getFundingRequested(), request.getCurrency(), request.getStatus(), request.getBankAccount().getBankName(),
78
                    request.getProjectParticipation(), request.getFundingRequested(), request.getCurrency().name(), request.getStatus(), request.getBankAccount().getBankName(),
78 79
                    request.getBankAccount().getBankAddress(), request.getBankAccount().getBankCode(), request.getBankAccount().getAccountHolder(),
79 80
                    request.getBankAccount().getIban(),request.getId()};
80 81
        } else {
81 82
            args = new Object[]{request.getUser(), request.getDate(), request.getResearcher(), request.getOrganization(), request.getProject(),
82 83
                    request.getPublication(), request.getJournal(), request.getPublisher(), request.getBudget(), request.getInvoice(),
83
                    request.getProjectParticipation(), request.getFundingRequested(), request.getCurrency(), request.getStatus(), null, null, null, null, null, request.getId()};
84
                    request.getProjectParticipation(), request.getFundingRequested(), request.getCurrency().name(), request.getStatus(), null, null, null, null, null, request.getId()};
84 85
        }
85 86

  
86 87
        if (jdbcTemplate.update(UPDATE_REQUEST, args, types) == 0) {
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/dao/JournalDAO.java
3 3
import eu.dnetlib.goldoa.domain.Journal;
4 4
import eu.dnetlib.goldoa.domain.Publisher;
5 5
import eu.dnetlib.goldoa.domain.Vocabulary;
6
import eu.dnetlib.goldoa.service.CurrencyConverter;
6 7
import org.apache.commons.codec.digest.DigestUtils;
7 8
import org.springframework.beans.factory.annotation.Autowired;
8 9
import org.springframework.context.annotation.Bean;
......
59 60
                        rs.getString("subjects"),
60 61
                        rs.getString("licence"),
61 62
                        rs.getFloat("apc"),
62
                        rs.getString("apc_currency"),
63
                        CurrencyConverter.Currency.valueOf(rs.getString("apc_currency")),
63 64
                        rs.getFloat("discount"),
64 65
                        rs.getString("status"),
65 66
                        rs.getString("source"));
......
72 73
        Object[] args = { journal.getTitle(), journal.getAlternativeTitle(),
73 74
                journal.getUrl(), journal.getPublisher()!=null?journal.getPublisher().getId():null, journal.getLanguages(),
74 75
                journal.getIssn(), journal.getCountry(), journal.getSubjects(), journal.getLicence(),
75
                journal.getApc(), journal.getCurrency(), journal.getStatus(), journal.getDiscount(), journal.getSource(), journal.getId()};
76
                journal.getApc(), journal.getCurrency().name(), journal.getStatus(), journal.getDiscount(), journal.getSource(), journal.getId()};
76 77
        int[] types = {
77 78
                Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
78 79
                Types.VARCHAR, Types.VARCHAR, Types.REAL, Types.VARCHAR, Types.VARCHAR, Types.REAL, Types.VARCHAR, Types.VARCHAR };
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/eligibility/AccountingEligibilityManager.java
38 38

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

  
43 43
            switch (publication.getType()) {
44 44
                case ARTICLE:
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/domain/RequestInfo.java
1 1
package eu.dnetlib.goldoa.domain;
2 2

  
3
import eu.dnetlib.goldoa.service.CurrencyConverter;
4

  
3 5
import java.io.Serializable;
4 6
import java.util.Date;
5 7

  
......
18 20
    private Invoice invoice;
19 21
    private Float projectParticipation;
20 22
    private Float fundingRequested;
21
    private String currency;
23
    private CurrencyConverter.Currency currency;
22 24
    private Request.RequestStatus status;
23 25
    private Eligibility eligibility;
24 26
    private String comment;
......
116 118
        this.fundingRequested = fundingRequested;
117 119
    }
118 120

  
119
    public String getCurrency() {
121
    public CurrencyConverter.Currency getCurrency() {
120 122
        return currency;
121 123
    }
122 124

  
123
    public void setCurrency(String currency) {
125
    public void setCurrency(CurrencyConverter.Currency currency) {
124 126
        this.currency = currency;
125 127
    }
126 128

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

  
3
import eu.dnetlib.goldoa.service.CurrencyConverter;
4

  
3 5
import java.io.Serializable;
4 6

  
5 7
/**
......
18 20
	private String subjects;
19 21
	private String licence;
20 22
	private float apc;
21
    private String currency;
23
    private CurrencyConverter.Currency currency;
22 24
	private float discount;
23 25
	private String status;
24 26
	private String source;
......
26 28
	public Journal() {
27 29
	}
28 30

  
29
    public Journal(String id, String title, String alternativeTitle, String url, Publisher publisher, String languages, String issn, String country, String subjects, String licence, float apc, String currency, float discount, String status, String source) {
31
    public Journal(String id, String title, String alternativeTitle, String url, Publisher publisher, String languages, String issn, String country, String subjects, String licence, float apc, CurrencyConverter.Currency currency, float discount, String status, String source) {
30 32
        this.id = id;
31 33
        this.title = title;
32 34
        this.alternativeTitle = alternativeTitle;
......
136 138
		this.apc = apc;
137 139
	}
138 140

  
139
    public String getCurrency() {
141
    public CurrencyConverter.Currency getCurrency() {
140 142
        return currency;
141 143
    }
142 144

  
143
    public void setCurrency(String currency) {
145
    public void setCurrency(CurrencyConverter.Currency currency) {
144 146
        this.currency = currency;
145 147
    }
146 148

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

  
3
import eu.dnetlib.goldoa.service.CurrencyConverter;
4

  
3 5
import java.io.Serializable;
4 6
import java.util.Date;
5 7

  
......
49 51
    private String invoice;
50 52
    private Float projectParticipation;
51 53
    private Float fundingRequested;
52
    private String currency;
54
    private CurrencyConverter.Currency currency;
53 55
    private BankAccount bankAccount;
54 56
	private int status = 0;
55 57

  
56 58
	public Request() {
57 59
	}
58 60

  
59
    public Request(String id, String user, Date date, String researcher, String organization, String project, String publication, String journal, String publisher, String budget, String invoice, Float projectParticipation, Float fundingRequested, String currency, BankAccount bankAccount, int status) {
61
    public Request(String id, String user, Date date, String researcher, String organization, String project, String publication, String journal, String publisher, String budget, String invoice, Float projectParticipation, Float fundingRequested, CurrencyConverter.Currency currency, BankAccount bankAccount, int status) {
60 62
        this.id = id;
61 63
        this.user = user;
62 64
        this.date = date;
......
217 219
        this.fundingRequested = fundingRequested;
218 220
    }
219 221

  
220
    public String getCurrency() {
222
    public CurrencyConverter.Currency getCurrency() {
221 223
        return currency;
222 224
    }
223 225

  
224
    public void setCurrency(String currency) {
226
    public void setCurrency(CurrencyConverter.Currency currency) {
225 227
        this.currency = currency;
226 228
    }
227 229

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

  
3
import eu.dnetlib.goldoa.service.CurrencyConverter;
4

  
3 5
import java.io.Serializable;
4 6

  
5 7
/**
......
11 13
	private String email;
12 14
	private Person contact;
13 15
    private float APC;
14
    private String currency;
16
    private CurrencyConverter.Currency currency;
15 17
	private float discount;
16 18
    private BankAccount bankAccount;
17 19
	private String source;
......
23 25
    public Publisher() {
24 26
	}
25 27

  
26
    public Publisher(String id, String name, String email, Person contact, float APC, String currency, float discount, BankAccount bankAccount, String source) {
28
    public Publisher(String id, String name, String email, Person contact, float APC, CurrencyConverter.Currency currency, float discount, BankAccount bankAccount, String source) {
27 29
        this.id = id;
28 30
        this.name = name;
29 31
        this.email = email;
......
83 85
        this.APC = APC;
84 86
    }
85 87

  
86
    public String getCurrency() {
88
    public CurrencyConverter.Currency getCurrency() {
87 89
        return currency;
88 90
    }
89 91

  
90
    public void setCurrency(String currency) {
92
    public void setCurrency(CurrencyConverter.Currency currency) {
91 93
        this.currency = currency;
92 94
    }
93 95

  

Also available in: Unified diff