BrightSide Workbench Full Report + Source Code
ProjectGrant.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2021 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.dossier.entity;
20 
21 import java.time.Instant;
22 import java.util.Date;
23 import java.util.List;
24 import javax.persistence.AttributeOverride;
25 import javax.persistence.AttributeOverrides;
26 import javax.persistence.Column;
27 import javax.persistence.Embedded;
28 import javax.persistence.Entity;
29 import javax.persistence.GeneratedValue;
30 import javax.persistence.GenerationType;
31 import javax.persistence.Id;
32 import javax.persistence.Temporal;
33 import org.turro.string.Strings;
34 import org.turro.entities.IElephantEntity;
35 import org.turro.html.HtmlContent;
36 import org.turro.jpa.embeddables.Wiki;
37 import org.turro.jpa.entity.IDaoEntity;
38 
43 @Entity
44 public class ProjectGrant implements java.io.Serializable, IDaoEntity {
45 
46  @Id
47  @GeneratedValue(strategy=GenerationType.IDENTITY)
48  @Column(name="IDENTIFIER")
49  private Long id;
50 
51  private String title;
52 
53  @Embedded
54  @AttributeOverrides({
55  @AttributeOverride( name = "text", column = @Column(name = "goal")),
56  @AttributeOverride( name = "wiki", column = @Column(name = "wgoal"))
57  })
58  private Wiki goal = new Wiki();
59 
60  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
61  private java.util.Date endDate;
62 
63  private boolean recurrent, endOfBudget;
64 
65  @Embedded
66  @AttributeOverrides({
67  @AttributeOverride( name = "text", column = @Column(name = "deadline")),
68  @AttributeOverride( name = "wiki", column = @Column(name = "wdeadline"))
69  })
70  private Wiki deadline = new Wiki();
71 
72  private boolean micro, small, medium, big, otherOrgs;
73 
74  @Embedded
75  @AttributeOverrides({
76  @AttributeOverride( name = "text", column = @Column(name = "beneficiaries")),
77  @AttributeOverride( name = "wiki", column = @Column(name = "wbeneficiaries"))
78  })
79  private Wiki beneficiaries = new Wiki();
80 
81  private double budget;
82 
83  @Embedded
84  private GrantMatchCriteria matchCriteria;
85 
86  @Embedded
87  @AttributeOverrides({
88  @AttributeOverride( name = "text", column = @Column(name = "elegible")),
89  @AttributeOverride( name = "wiki", column = @Column(name = "welegible"))
90  })
91  private Wiki elegible = new Wiki();
92 
93  private boolean subvention, loan, inKind;
94  private boolean collaboration;
95 
96  @Embedded
97  @AttributeOverrides({
98  @AttributeOverride( name = "text", column = @Column(name = "features")),
99  @AttributeOverride( name = "wiki", column = @Column(name = "wfeatures"))
100  })
101  private Wiki features = new Wiki();
102 
103  @Embedded
104  @AttributeOverrides({
105  @AttributeOverride( name = "text", column = @Column(name = "intensity")),
106  @AttributeOverride( name = "wiki", column = @Column(name = "wintensity"))
107  })
108  private Wiki intensity = new Wiki();
109 
110  private boolean minimis;
111 
112  private String source;
113 
114  private String convocation, basis;
115 
116  public Long getId() {
117  return id;
118  }
119 
120  public void setId(Long id) {
121  this.id = id;
122  }
123 
124  public String getTitle() {
125  return title;
126  }
127 
128  public void setTitle(String title) {
129  this.title = title;
130  }
131 
132  public Wiki getGoal() {
133  return goal;
134  }
135 
136  public void setGoal(Wiki goal) {
137  this.goal = goal;
138  }
139 
140  public Date getEndDate() {
141  return endDate;
142  }
143 
144  public void setEndDate(Date endDate) {
145  this.endDate = endDate;
146  }
147 
148  public boolean isRecurrent() {
149  return recurrent;
150  }
151 
152  public void setRecurrent(boolean recurrent) {
153  this.recurrent = recurrent;
154  }
155 
156  public boolean isEndOfBudget() {
157  return endOfBudget;
158  }
159 
160  public void setEndOfBudget(boolean endOfBudget) {
161  this.endOfBudget = endOfBudget;
162  }
163 
164  public Wiki getDeadline() {
165  return deadline;
166  }
167 
168  public void setDeadline(Wiki deadline) {
169  this.deadline = deadline;
170  }
171 
172  public boolean isMicro() {
173  return micro;
174  }
175 
176  public void setMicro(boolean micro) {
177  this.micro = micro;
178  }
179 
180  public boolean isSmall() {
181  return small;
182  }
183 
184  public void setSmall(boolean small) {
185  this.small = small;
186  }
187 
188  public boolean isMedium() {
189  return medium;
190  }
191 
192  public void setMedium(boolean medium) {
193  this.medium = medium;
194  }
195 
196  public boolean isBig() {
197  return big;
198  }
199 
200  public void setBig(boolean big) {
201  this.big = big;
202  }
203 
204  public boolean isOtherOrgs() {
205  return otherOrgs;
206  }
207 
208  public void setOtherOrgs(boolean otherOrgs) {
209  this.otherOrgs = otherOrgs;
210  }
211 
213  return beneficiaries;
214  }
215 
216  public void setBeneficiaries(Wiki beneficiaries) {
217  this.beneficiaries = beneficiaries;
218  }
219 
220  public double getBudget() {
221  return budget;
222  }
223 
224  public void setBudget(double budget) {
225  this.budget = budget;
226  }
227 
229  return matchCriteria;
230  }
231 
232  public void setMatchCriteria(GrantMatchCriteria matchCriteria) {
233  this.matchCriteria = matchCriteria;
234  }
235 
236  public Wiki getElegible() {
237  return elegible;
238  }
239 
240  public void setElegible(Wiki elegible) {
241  this.elegible = elegible;
242  }
243 
244  public boolean isSubvention() {
245  return subvention;
246  }
247 
248  public void setSubvention(boolean subvention) {
249  this.subvention = subvention;
250  }
251 
252  public boolean isLoan() {
253  return loan;
254  }
255 
256  public void setLoan(boolean loan) {
257  this.loan = loan;
258  }
259 
260  public boolean isInKind() {
261  return inKind;
262  }
263 
264  public void setInKind(boolean inKind) {
265  this.inKind = inKind;
266  }
267 
268  public boolean isCollaboration() {
269  return collaboration;
270  }
271 
272  public void setCollaboration(boolean collaboration) {
273  this.collaboration = collaboration;
274  }
275 
276  public Wiki getFeatures() {
277  return features;
278  }
279 
280  public void setFeatures(Wiki features) {
281  this.features = features;
282  }
283 
284  public Wiki getIntensity() {
285  return intensity;
286  }
287 
288  public void setIntensity(Wiki intensity) {
289  this.intensity = intensity;
290  }
291 
292  public boolean isMinimis() {
293  return minimis;
294  }
295 
296  public void setMinimis(boolean minimis) {
297  this.minimis = minimis;
298  }
299 
300  public String getSource() {
301  return source;
302  }
303 
304  public void setSource(String source) {
305  this.source = source;
306  }
307 
308  public String getConvocation() {
309  return convocation;
310  }
311 
312  public void setConvocation(String convocation) {
313  this.convocation = convocation;
314  }
315 
316  public String getBasis() {
317  return basis;
318  }
319 
320  public void setBasis(String basis) {
321  this.basis = basis;
322  }
323 
324  /* IDaoEntity */
325 
326  @Override
327  public Object entityId() {
328  return id;
329  }
330 
331  @Override
332  public boolean isEmpty() {
333  if(goal == null) goal = new Wiki();
334  if(deadline == null) deadline = new Wiki();
335  if(beneficiaries == null) beneficiaries = new Wiki();
336  if(elegible == null) elegible = new Wiki();
337  if(features == null) features = new Wiki();
338  if(intensity == null) intensity = new Wiki();
339  if(matchCriteria == null) matchCriteria = new GrantMatchCriteria();
340  return Strings.isBlank(title) || goal.isEmpty();
341  }
342 
343  /* Helpers */
344 
345  public String getName() {
346  return title == null ? "!***" : title;
347  }
348 
349  public String getDescription() {
350  return goal == null ? "!***" : HtmlContent.plain(goal.getText(), 500);
351  }
352 
353  public boolean isCompanyType() {
354  return micro | small | medium | big;
355  }
356 
357  public boolean isActive() {
358  return endDate == null || endDate.toInstant().isAfter(Instant.now());
359  }
360 
361  public List<IElephantEntity> getGrantMatches() {
362  return matchCriteria != null ? matchCriteria.getMatchingsForProjectGrant(id) : null;
363  }
364 
365 }
void setSubvention(boolean subvention)
List< IElephantEntity > getGrantMatches()
void setOtherOrgs(boolean otherOrgs)
void setMatchCriteria(GrantMatchCriteria matchCriteria)
void setRecurrent(boolean recurrent)
void setEndOfBudget(boolean endOfBudget)
void setCollaboration(boolean collaboration)
void setBeneficiaries(Wiki beneficiaries)
void setConvocation(String convocation)