Revision 35658
Added by Antonis Lempesis over 9 years ago
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/dao/PublisherDAO.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
private static final String SEARCH_PUBLISHERS = "select id, name from publisher where lower(name) like lower(?)"; |
29 | 29 |
|
30 |
private static final String GET_PUBLISHER = "select id, name, email, contact, discount, source from publisher where id=?"; |
|
30 |
private static final String GET_PUBLISHER = "select id, name, email, contact, apc, discount, source from publisher where id=?";
|
|
31 | 31 |
|
32 |
private static final String UPDATE_PUBLISHER = "update publisher set name=?, email=?, contact=?, discount=?, source=? where id=?"; |
|
32 |
private static final String UPDATE_PUBLISHER = "update publisher set name=?, email=?, contact=?, apc=?, discount=?, source=? where id=?";
|
|
33 | 33 |
|
34 |
private static final String INSERT_PUBLISHER = "insert into publisher (name, email, contact, discount, source, id) values (?, ?, ?, ?, ?, ?)";
|
|
34 |
private static final String INSERT_PUBLISHER = "insert into publisher (name, email, contact, apc, discount, source, id) values (?, ?, ?, ?, ?, ?, ?)";
|
|
35 | 35 |
|
36 | 36 |
|
37 | 37 |
public List<Vocabulary> search(String term) { |
... | ... | |
49 | 49 |
public Publisher mapRow(ResultSet rs, int i) throws SQLException { |
50 | 50 |
Person person = rs.getString("contact")!=null?new Person(rs.getString("contact")):null; |
51 | 51 |
|
52 |
return new Publisher(rs.getString("id"), rs.getString("name"), rs.getString("email"), person, rs.getFloat("discount"), rs.getString("source")); |
|
52 |
return new Publisher(rs.getString("id"), rs.getString("name"), rs.getString("email"), person, rs.getFloat("apc"), rs.getFloat("discount"), rs.getString("source"));
|
|
53 | 53 |
} |
54 | 54 |
}); |
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
public Publisher savePublisher(Publisher publisher) { |
58 | 58 |
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); |
59 |
Object[] args = {publisher.getName(), publisher.getEmail(), publisher.getContact()!=null?publisher.getContact().getEmail():null, publisher.getDiscount(), publisher.getSource(), publisher.getId()}; |
|
60 |
int[] types = {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.REAL, Types.VARCHAR, Types.VARCHAR}; |
|
59 |
Object[] args = {publisher.getName(), publisher.getEmail(), publisher.getContact()!=null?publisher.getContact().getEmail():null, publisher.getAPC(), publisher.getDiscount(), publisher.getSource(), publisher.getId()};
|
|
60 |
int[] types = {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.REAL, Types.REAL, Types.VARCHAR, Types.VARCHAR};
|
|
61 | 61 |
|
62 | 62 |
if (jdbcTemplate.update(UPDATE_PUBLISHER, args, types) == 0) { |
63 | 63 |
jdbcTemplate.update(INSERT_PUBLISHER, args, types); |
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/dao/ProjectDAO.java | ||
---|---|---|
54 | 54 |
Project project = new Project(); |
55 | 55 |
|
56 | 56 |
project.setId(rs.getString("id")); |
57 |
project.setTitle(rs.getString("title")); |
|
57 | 58 |
project.setAcronym(rs.getString("acronym")); |
58 | 59 |
project.setFunder(rs.getString("funder")); |
59 | 60 |
project.setFundingString(rs.getString("fundingstream")); |
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/dao/PublicationDAO.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
private static final String UPDATE_PUBLICATION = "update publication set title=?, languages=?, subjects=?, doi=?, source=?, date=?, type=?, journal=?, publisher=?, repository=? where id=?"; |
23 | 23 |
|
24 |
private static final String INSERT_PUBLICATION = "insert into publication (title, languages, subjects, doi, source, date, type, journal, publisher, repository, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|
24 |
private static final String INSERT_PUBLICATION = "insert into publication (title, languages, subjects, doi, source, date, type, journal, publisher, repository, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
|
25 | 25 |
|
26 | 26 |
private static final String GET_PUBLICATION = |
27 | 27 |
"select p.id, title, languages, subjects, doi, source, date, p.type, journal, publisher, repository, array_agg(distinct pa.affiliation) as authors, array_agg(distinct i.type || '||' || i.identifier) as identifiers\n" + |
... | ... | |
33 | 33 |
private static final String INSERT_PUBLICATION_AFFILIATIONS = |
34 | 34 |
"with aff as (insert into affiliation (person, organization, startdate, enddate, department) values (?, ?, ?, ?, ?) returning id as affid) insert into publication_affiliation (publication, affiliation) select ?, affid from aff"; |
35 | 35 |
|
36 |
private static final String UPDATE_PUBLICATION_AFFILIATIONS = |
|
37 |
"with aff as (select id from affiliation where person=? and organization=?) insert into publication_affiliation (publication, affiliation) select ?, aff.id from aff"; |
|
38 |
|
|
36 | 39 |
private static final String LOAD_AFFILIATIONS = "select a.id, startdate, enddate, department, p.email || '||' || p.firstname || '||' || p.lastname || '||' || case when p.initials is null then '' else p.initials end as person, o.id || '||' || o.name as organisation\n" + |
37 | 40 |
"from affiliation a\n" + |
38 | 41 |
"left join person p on a.person=p.email\n" + |
... | ... | |
114 | 117 |
} |
115 | 118 |
|
116 | 119 |
public void saveAffiliations(final Publication publication) { |
117 |
new JdbcTemplate(dataSource).batchUpdate(INSERT_PUBLICATION_AFFILIATIONS, new BatchPreparedStatementSetter() { |
|
118 |
@Override |
|
119 |
public void setValues(PreparedStatement ps, int i) throws SQLException { |
|
120 |
Affiliation affiliation = publication.getAuthors().get(i); |
|
120 |
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); |
|
121 | 121 |
|
122 |
ps.setString(1, affiliation.getPerson().getEmail()); |
|
123 |
|
|
124 |
if (affiliation.getOrganization() != null) |
|
125 |
ps.setString(2, affiliation.getOrganization().getId()); |
|
126 |
else |
|
127 |
ps.setString(2, null); |
|
128 |
|
|
129 |
if (affiliation.getStart() != null) |
|
130 |
ps.setTimestamp(3, new Timestamp(affiliation.getStart().getTime())); |
|
131 |
else |
|
132 |
ps.setTimestamp(3, null); |
|
133 |
|
|
134 |
if (affiliation.getEnd() != null) |
|
135 |
ps.setTimestamp(4, new Timestamp(affiliation.getEnd().getTime())); |
|
136 |
else |
|
137 |
ps.setTimestamp(4, null); |
|
138 |
|
|
139 |
ps.setString(5, affiliation.getDepartment()); |
|
140 |
|
|
141 |
ps.setString(6, publication.getId()); |
|
142 |
|
|
122 |
if (publication.getAuthors() != null) { |
|
123 |
for (Affiliation affiliation:publication.getAuthors()) { |
|
124 |
if (jdbcTemplate.update(UPDATE_PUBLICATION_AFFILIATIONS, new String[] {affiliation.getPerson().getEmail(), affiliation.getOrganization().getId(), publication.getId()}, new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR}) == 0) { |
|
125 |
jdbcTemplate.update(INSERT_PUBLICATION_AFFILIATIONS, |
|
126 |
new Object[] {affiliation.getPerson().getEmail(), affiliation.getOrganization().getId(), affiliation.getStart()!=null?affiliation.getStart():null, affiliation.getEnd()!=null?affiliation.getEnd():null, affiliation.getDepartment(), publication.getId()}, |
|
127 |
new int[] {Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR}); |
|
128 |
} |
|
143 | 129 |
} |
144 |
|
|
145 |
@Override |
|
146 |
public int getBatchSize() { |
|
147 |
return publication.getAuthors() != null? publication.getAuthors().size():0; |
|
148 |
} |
|
149 |
}); |
|
130 |
} |
|
150 | 131 |
} |
151 | 132 |
|
152 | 133 |
public void loadAffiliations(Publication publication) { |
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/eligibility/AccountingEligibilityManager.java | ||
---|---|---|
1 |
package eu.dnetlib.goldoa.service.eligibility; |
|
2 |
|
|
3 |
import eu.dnetlib.goldoa.domain.Eligibility; |
|
4 |
import eu.dnetlib.goldoa.domain.Request; |
|
5 |
import eu.dnetlib.goldoa.service.EligibilityManager; |
|
6 |
|
|
7 |
/** |
|
8 |
* Created by antleb on 3/25/15. |
|
9 |
*/ |
|
10 |
public class AccountingEligibilityManager implements EligibilityManager { |
|
11 |
|
|
12 |
private String participationNoNoMessage; |
|
13 |
private String fundingRequestedNoNoMessage; |
|
14 |
|
|
15 |
@Override |
|
16 |
public Eligibility validate(Request request) { |
|
17 |
Eligibility eligibility = new Eligibility(); |
|
18 |
|
|
19 |
if (request.getProjectParticipation() <= 0 || request.getProjectParticipation() > 100) |
|
20 |
eligibility.merge(new Eligibility(Eligibility.Status.NONO, this.participationNoNoMessage)); |
|
21 |
|
|
22 |
if (request.getFundingRequested() <= 0) |
|
23 |
eligibility.merge(new Eligibility(Eligibility.Status.NONO, this.fundingRequestedNoNoMessage)); |
|
24 |
|
|
25 |
return eligibility; |
|
26 |
} |
|
27 |
|
|
28 |
public String getParticipationNoNoMessage() { |
|
29 |
return participationNoNoMessage; |
|
30 |
} |
|
31 |
|
|
32 |
public void setParticipationNoNoMessage(String participationNoNoMessage) { |
|
33 |
this.participationNoNoMessage = participationNoNoMessage; |
|
34 |
} |
|
35 |
|
|
36 |
public String getFundingRequestedNoNoMessage() { |
|
37 |
return fundingRequestedNoNoMessage; |
|
38 |
} |
|
39 |
|
|
40 |
public void setFundingRequestedNoNoMessage(String fundingRequestedNoNoMessage) { |
|
41 |
this.fundingRequestedNoNoMessage = fundingRequestedNoNoMessage; |
|
42 |
} |
|
43 |
} |
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/domain/Publisher.java | ||
---|---|---|
10 | 10 |
private String name; |
11 | 11 |
private String email; |
12 | 12 |
private Person contact; |
13 |
private float APC; |
|
13 | 14 |
private float discount; |
14 | 15 |
private String source; |
15 | 16 |
|
... | ... | |
17 | 18 |
this.id = id; |
18 | 19 |
} |
19 | 20 |
|
20 |
public Publisher(String id, String name, String email, Person contact, float discount, String source) { |
|
21 |
this.id = id; |
|
22 |
this.name = name; |
|
23 |
this.email = email; |
|
24 |
this.contact = contact; |
|
25 |
this.discount = discount; |
|
26 |
this.source = source; |
|
27 |
} |
|
21 |
public Publisher(String id, String name, String email, Person contact, float APC, float discount, String source) { |
|
22 |
this.id = id; |
|
23 |
this.name = name; |
|
24 |
this.email = email; |
|
25 |
this.contact = contact; |
|
26 |
this.APC = APC; |
|
27 |
this.discount = discount; |
|
28 |
this.source = source; |
|
29 |
} |
|
28 | 30 |
|
29 |
public Publisher() {
|
|
31 |
public Publisher() {
|
|
30 | 32 |
} |
31 | 33 |
|
32 | 34 |
public String getId() { |
... | ... | |
69 | 71 |
this.discount = discount; |
70 | 72 |
} |
71 | 73 |
|
72 |
public String getSource() { |
|
74 |
public float getAPC() { |
|
75 |
return APC; |
|
76 |
} |
|
77 |
|
|
78 |
public void setAPC(float APC) { |
|
79 |
this.APC = APC; |
|
80 |
} |
|
81 |
|
|
82 |
public String getSource() { |
|
73 | 83 |
return source; |
74 | 84 |
} |
75 | 85 |
|
modules/uoa-goldoa-service/trunk/src/main/resources/eu/dnetlib/goldoa/service/applicationContext-goldoa-service.properties | ||
---|---|---|
20 | 20 |
goldoa.eligibility.project.expiration.iffy.message = end date iffy message! |
21 | 21 |
goldoa.eligibility.project.expiration.nono.message = end date nono message! |
22 | 22 |
goldoa.eligibility.project.request.count = 3 |
23 |
goldoa.eligibility.project.request.nono.message = request per project nono message! |
|
23 |
goldoa.eligibility.project.request.nono.message = request per project nono message! |
|
24 |
|
|
25 |
goldoa.eligibility.accounting.participation.nono.message = participation no no! |
|
26 |
goldoa.eligibility.accounting.funding.nono.message = funding request no no! |
Also available in: Unified diff