Project

General

Profile

1
package eu.dnetlib.goldoa.domain;
2

    
3
import com.google.gwt.user.client.rpc.IsSerializable;
4

    
5
import java.util.ArrayList;
6
import java.util.Date;
7
import java.util.List;
8

    
9
/**
10
 * Created by antleb on 3/9/15.
11
 */
12
public class Request implements IsSerializable {
13

    
14
	public enum RequestStatus implements IsSerializable {
15

    
16
		INCOMPLETE("Incomplete", 0),
17
		SUBMITTED("Submitted", 1),
18
		CONDITIONALLY_APPROVED("Conditionally approved", 2),
19
		APPROVED("Approved", 4),
20
		REJECTED("Rejected", 8),
21
		ACCOUNTING_PROCESSING("Processing payment", 16),
22
		ACCOUNTING_PAID("Paid", 32),
23
		ACCOUNTING_ON_HOLD("On hold", 64),
24
		ACCOUNTING_DENIED("Denied", 128),
25
		COMPLETED("Completed", 256);
26

    
27
		private String value;
28
		private int code;
29

    
30
		RequestStatus(String value, int code) {
31
			this.value = value;
32
			this.code = code;
33
		}
34

    
35
		public String getValue() {
36
			return value;
37
		}
38

    
39
		public int getCode() {
40
			return code;
41
		}
42

    
43
		public static RequestStatus forStatus(int status) {
44
			if (status == 0)
45
				return INCOMPLETE;
46
			else
47
				return RequestStatus.values()[((int) Math.round(Math.log(status)/Math.log(2)) + 1)];
48
		}
49

    
50
	}
51

    
52
	private String id;
53
	private String user;
54
	private Date date = new Date();
55
	private String researcher;
56
	private String organization;
57
	private String project;
58
	private String publication;
59
	private String journal;
60
	private String publisher;
61
	private String publisherEmail;
62
	private String budget;
63
	private String invoice;
64
	private Float apc;
65
	private Float discount;
66
	private Float projectParticipation;
67
	private Float fundingRequested;
68
	private Currency currency;
69
	private BankAccount bankAccount;
70
	private List<RequestCoFunder> coFunders = new ArrayList<RequestCoFunder>();
71
	private Float apc_paid;
72
	private Float transfer_cost;
73
	private Float other_cost;
74
	private Date date_paid;
75
	private int status = 0;
76
	private Date submissionDate = new Date();
77
	private Date approvalDate = new Date();
78

    
79
	public Request() {
80
	}
81

    
82
	public Request(String id, String user, Date date, String researcher, String organization, String project, String publication, String journal, String publisher, String publisherEmail, String budget, String invoice, Float apc, Float discount, Float projectParticipation, Float fundingRequested, Currency currency, BankAccount bankAccount, List<RequestCoFunder> coFunders, Float apc_paid, Float transfer_cost, Float other_cost, Date date_paid, int status, Date submissionDate, Date approvalDate) {
83
		this.id = id;
84
		this.user = user;
85
		this.date = date;
86
		this.researcher = researcher;
87
		this.organization = organization;
88
		this.project = project;
89
		this.publication = publication;
90
		this.journal = journal;
91
		this.publisher = publisher;
92
		this.publisherEmail = publisherEmail;
93
		this.budget = budget;
94
		this.invoice = invoice;
95
		this.apc = apc;
96
		this.discount = discount;
97
		this.projectParticipation = projectParticipation;
98
		this.fundingRequested = fundingRequested;
99
		this.currency = currency;
100
		this.bankAccount = bankAccount;
101
		this.coFunders = coFunders;
102
		this.apc_paid = apc_paid;
103
		this.transfer_cost = transfer_cost;
104
		this.other_cost = other_cost;
105
		this.date_paid = date_paid;
106
		this.status = status;
107
		this.submissionDate = submissionDate;
108
		this.approvalDate = approvalDate;
109
	}
110

    
111
	public Request(RequestInfo requestInfo) {
112
		id = requestInfo.getId();
113
		user = requestInfo.getUser() != null ? requestInfo.getUser().getId() : null;
114
		date = requestInfo.getDate();
115
		researcher = requestInfo.getResearcher() != null ? requestInfo.getResearcher().getId() : null;
116
		organization = requestInfo.getOrganization() != null ? requestInfo.getOrganization().getId() : null;
117
		project = requestInfo.getProject() != null ? requestInfo.getProject().getId() : null;
118
		publication = requestInfo.getPublication() != null ? requestInfo.getPublication().getId() : null;
119
		publisherEmail = requestInfo.getPublisherEmail();
120
		budget = requestInfo.getBudget() != null ? requestInfo.getBudget().getId() : null;
121
		invoice = requestInfo.getInvoice() != null ? requestInfo.getInvoice().getId() : null;
122
		apc = requestInfo.getApc();
123
		discount = requestInfo.getDiscount();
124
		projectParticipation = requestInfo.getProjectParticipation();
125
		fundingRequested = requestInfo.getFundingRequested();
126
		currency = requestInfo.getCurrency();
127
		apc_paid = requestInfo.getApc_paid();
128
		transfer_cost = requestInfo.getTransfer_cost();
129
		other_cost = requestInfo.getOther_cost();
130
		date_paid = requestInfo.getDate_paid();
131
		status = requestInfo.getStatus().code;
132
		submissionDate = requestInfo.getSubmissionDate();
133
		approvalDate = requestInfo.getApprovalDate();
134

    
135
		if (requestInfo.getPublication() != null && requestInfo.getPublication().getJournal() != null) {
136
			journal = requestInfo.getPublication().getJournal().getId();
137
		}
138

    
139
		if (requestInfo.getPublication() != null && requestInfo.getPublication().getPublisher() != null) {
140
			publisher = requestInfo.getPublication().getPublisher().getId();
141
		}
142

    
143
		coFunders = requestInfo.getCoFunders();
144

    
145
		bankAccount = requestInfo.getBankAccount();
146
	}
147

    
148
	public String getId() {
149
		return id;
150
	}
151

    
152
	public void setId(String id) {
153
		this.id = id;
154
	}
155

    
156
	public String getUser() {
157
		return user;
158
	}
159

    
160
	public void setUser(String user) {
161
		this.user = user;
162
	}
163

    
164
	public Date getDate() {
165
		return date;
166
	}
167

    
168
	public void setDate(Date date) {
169
		this.date = date;
170
	}
171

    
172
	public String getResearcher() {
173
		return researcher;
174
	}
175

    
176
	public void setResearcher(String researcher) {
177
		this.researcher = researcher;
178
	}
179

    
180
	public String getOrganization() {
181
		return organization;
182
	}
183

    
184
	public void setOrganization(String organization) {
185
		this.organization = organization;
186
	}
187

    
188
	public String getProject() {
189
		return project;
190
	}
191

    
192
	public void setProject(String project) {
193
		this.project = project;
194
	}
195

    
196
	public String getPublication() {
197
		return publication;
198
	}
199

    
200
	public void setPublication(String publication) {
201
		this.publication = publication;
202
	}
203

    
204
	public String getJournal() {
205
		return journal;
206
	}
207

    
208
	public void setJournal(String journal) {
209
		this.journal = journal;
210
	}
211

    
212
	public String getBudget() {
213
		return budget;
214
	}
215

    
216
	public void setBudget(String budget) {
217
		this.budget = budget;
218
	}
219

    
220
	public void addStatus(RequestStatus status) {
221
		this.status = status.code;
222
	}
223

    
224
	public boolean getStatus(RequestStatus status) {
225
		return (this.status & status.code) == status.code;
226
	}
227

    
228
	public int getStatus() {
229
		return status;
230
	}
231

    
232
	public String getPublisher() {
233
		return publisher;
234
	}
235

    
236
	public void setPublisher(String publisher) {
237
		this.publisher = publisher;
238
	}
239

    
240
	public String getPublisherEmail() {
241
		return publisherEmail;
242
	}
243

    
244
	public void setPublisherEmail(String publisherEmail) {
245
		this.publisherEmail = publisherEmail;
246
	}
247

    
248
	public String getInvoice() {
249
		return invoice;
250
	}
251

    
252
	public void setInvoice(String invoice) {
253
		this.invoice = invoice;
254
	}
255

    
256
	public Float getApc() {
257
		return apc;
258
	}
259

    
260
	public void setApc(Float apc) {
261
		this.apc = apc;
262
	}
263

    
264
	public Float getDiscount() {
265
		return discount;
266
	}
267

    
268
	public void setDiscount(Float discount) {
269
		this.discount = discount;
270
	}
271

    
272
	public Float getProjectParticipation() {
273
		return projectParticipation;
274
	}
275

    
276
	public void setProjectParticipation(Float projectParticipation) {
277
		this.projectParticipation = projectParticipation;
278
	}
279

    
280
	public Float getFundingRequested() {
281
		return fundingRequested;
282
	}
283

    
284
	public void setFundingRequested(Float fundingRequested) {
285
		this.fundingRequested = fundingRequested;
286
	}
287

    
288
	public Currency getCurrency() {
289
		return currency;
290
	}
291

    
292
	public void setCurrency(Currency currency) {
293
		this.currency = currency;
294
	}
295

    
296
	public BankAccount getBankAccount() {
297
		return bankAccount;
298
	}
299

    
300
	public void setBankAccount(BankAccount bankAccount) {
301
		this.bankAccount = bankAccount;
302
	}
303

    
304
	public List<RequestCoFunder> getCoFunders() {
305
		return coFunders;
306
	}
307

    
308
	public void setCoFunders(List<RequestCoFunder> coFunders) {
309
		this.coFunders = coFunders;
310
	}
311

    
312
	public Float getApc_paid() {
313
		return apc_paid;
314
	}
315

    
316
	public void setApc_paid(Float apc_paid) {
317
		this.apc_paid = apc_paid;
318
	}
319

    
320
	public Float getTransfer_cost() {
321
		return transfer_cost;
322
	}
323

    
324
	public void setTransfer_cost(Float transfer_cost) {
325
		this.transfer_cost = transfer_cost;
326
	}
327

    
328
	public Float getOther_cost() {
329
		return other_cost;
330
	}
331

    
332
	public void setOther_cost(Float other_cost) {
333
		this.other_cost = other_cost;
334
	}
335

    
336
	public Date getDate_paid() {
337
		return date_paid;
338
	}
339

    
340
	public void setDate_paid(Date date_paid) {
341
		this.date_paid = date_paid;
342
	}
343

    
344
	public Date getSubmissionDate() {
345
		return submissionDate;
346
	}
347

    
348
	public void setSubmissionDate(Date submissionDate) {
349
		this.submissionDate = submissionDate;
350
	}
351

    
352
	public Date getApprovalDate() {
353
		return approvalDate;
354
	}
355

    
356
	public void setApprovalDate(Date approvalDate) {
357
		this.approvalDate = approvalDate;
358
	}
359
}
(28-28/39)