BrightSide Workbench Full Report + Source Code
Agreement.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2018 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.elephant.entities.db;
20 
21 import java.util.List;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.GenerationType;
26 import javax.persistence.Id;
27 import javax.persistence.Lob;
28 import org.turro.string.Strings;
29 import org.turro.elephant.context.Application;
30 import org.turro.elephant.context.ElephantContext;
31 import org.turro.elephant.db.ElephantPU;
32 import org.turro.elephant.db.WhereClause;
33 import org.turro.elephant.impl.util.Parser;
34 import org.turro.jpa.entity.IDaoEntity;
35 
40 @Entity
41 public class Agreement implements java.io.Serializable, IDaoEntity {
42 
43  @Id
44  @GeneratedValue(strategy=GenerationType.IDENTITY)
45  @Column(name="IDENTIFIER")
46  private Long id;
47 
48  private String title, appliesTo, action;
49 
50  @Lob
51  @Column(length=4096)
52  private String wiki, text;
53 
54  private boolean requiredToAccess, requiredToNotify, requiredToAction, peremptory;
55 
56  public Long getId() {
57  return id;
58  }
59 
60  public void setId(Long id) {
61  this.id = id;
62  }
63 
64  public String getTitle() {
65  return title;
66  }
67 
68  public void setTitle(String title) {
69  this.title = title;
70  }
71 
72  public String getWiki() {
73  return wiki;
74  }
75 
76  public void setWiki(String wiki) {
77  this.wiki = wiki;
78  }
79 
80  public String getText() {
81  return text.replaceAll("\\{site\\}", ElephantContext.getSiteName());
82  }
83 
84  public void setText(String text) {
85  this.text = text;
86  }
87 
88  public String getAppliesTo() {
89  return appliesTo;
90  }
91 
92  public void setAppliesTo(String appliesTo) {
93  this.appliesTo = appliesTo;
94  }
95 
96  public String getAction() {
97  return action;
98  }
99 
100  public void setAction(String action) {
101  this.action = action;
102  }
103 
104  public boolean isRequiredToAccess() {
105  return requiredToAccess;
106  }
107 
108  public void setRequiredToAccess(boolean requiredToAccess) {
109  this.requiredToAccess = requiredToAccess;
110  }
111 
112  public boolean isRequiredToNotify() {
113  return requiredToNotify;
114  }
115 
116  public void setRequiredToNotify(boolean requiredToNotify) {
117  this.requiredToNotify = requiredToNotify;
118  }
119 
120  public boolean isRequiredToAction() {
121  return requiredToAction;
122  }
123 
124  public void setRequiredToAction(boolean requiredToAction) {
125  this.requiredToAction = requiredToAction;
126  }
127 
128  public boolean isPeremptory() {
129  return peremptory;
130  }
131 
132  public void setPeremptory(boolean peremptory) {
133  this.peremptory = peremptory;
134  }
135 
136  /* IDaoEntity */
137 
138  @Override
139  public Object entityId() {
140  return id;
141  }
142 
143  @Override
144  public boolean isEmpty() {
145  return !(requiredToAccess || requiredToNotify) ||
146  Strings.isBlank(text) || Strings.isBlank(title) ||
147  Strings.isBlank(appliesTo);
148  }
149 
150  /* Helpers */
151 
152  public List<AgreementSignature> getSignatures() {
153  WhereClause wc = new WhereClause();
154  wc.addClause("select asig from AgreementSignature asig");
155  wc.addClause("where asig.agreement = :agreement");
156  wc.addNamedValue("agreement", this);
157  wc.addClause("order by asig.signedDate");
158  return new ElephantPU().getResultList(wc);
159  }
160 
161 }
void addNamedValue(String name, Object value)
void setRequiredToAction(boolean requiredToAction)
Definition: Agreement.java:124
void setAppliesTo(String appliesTo)
Definition: Agreement.java:92
void setRequiredToNotify(boolean requiredToNotify)
Definition: Agreement.java:116
void setRequiredToAccess(boolean requiredToAccess)
Definition: Agreement.java:108
List< AgreementSignature > getSignatures()
Definition: Agreement.java:152
void setPeremptory(boolean peremptory)
Definition: Agreement.java:132