BrightSide Workbench Full Report + Source Code
org.turro.assistant.ParticipationInfo Class Reference

Public Member Functions

 ParticipationInfo (Object entity, ParticipationReason reason)
 
 ParticipationInfo (Object entity, IContact contact, ParticipationReason reason)
 
 ParticipationInfo (String entityPath, ParticipationReason reason)
 
 ParticipationInfo (String entityPath, String participatorPath, ParticipationReason reason)
 
long getCount ()
 
List< IEntityParticipationgetParticipations ()
 
List< IEntityParticipationgetParticipations (Date from)
 
List< IEntityParticipationgetCrossParticipations ()
 
List< IEntityParticipationgetCrossParticipations (Date from)
 
List< IEntityParticipationgetAnyParticipations (Date from)
 
void getAnyParticipations (Date from, Consumer< IEntityParticipation > action)
 
boolean isChecked ()
 
boolean isUser ()
 
boolean isEmpty ()
 
boolean toggle ()
 
void check ()
 
void uncheck ()
 
IElephantEntity getParticipator ()
 
IElephantEntity getEntity ()
 
String getReasonStr ()
 
ContactList getParticipants ()
 

Static Public Member Functions

static long getParticipationCount (String root, IContact contact, ParticipationReason reason)
 
static void cleanup (String entityPath)
 
static Set< String > getAllPaths (String root)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 46 of file ParticipationInfo.java.

Constructor & Destructor Documentation

◆ ParticipationInfo() [1/4]

org.turro.assistant.ParticipationInfo.ParticipationInfo ( Object  entity,
ParticipationReason  reason 
)

Definition at line 54 of file ParticipationInfo.java.

54  {
55  this(entity, Authentication.getIContact(), reason);
56  }
Here is the call graph for this function:

◆ ParticipationInfo() [2/4]

org.turro.assistant.ParticipationInfo.ParticipationInfo ( Object  entity,
IContact  contact,
ParticipationReason  reason 
)

Definition at line 58 of file ParticipationInfo.java.

58  {
59  entityPath = Entities.getController(entity).getPath();
60  if(!Strings.isBlank(entityPath)) {
61  if(contact != null && contact.isValid()) {
62  participatorPath = "/contact/" + contact.getId();
63  }
64  }
65  this.reason = reason;
66  }
Here is the call graph for this function:

◆ ParticipationInfo() [3/4]

org.turro.assistant.ParticipationInfo.ParticipationInfo ( String  entityPath,
ParticipationReason  reason 
)

Definition at line 68 of file ParticipationInfo.java.

68  {
69  this(entityPath, (String) null, reason);
70  }

◆ ParticipationInfo() [4/4]

org.turro.assistant.ParticipationInfo.ParticipationInfo ( String  entityPath,
String  participatorPath,
ParticipationReason  reason 
)

Definition at line 72 of file ParticipationInfo.java.

72  {
73  this.entityPath = entityPath;
74  this.participatorPath = participatorPath;
75  this.reason = reason;
76  }

Member Function Documentation

◆ check()

void org.turro.assistant.ParticipationInfo.check ( )

Definition at line 211 of file ParticipationInfo.java.

211  {
212  if(isEmpty()) return;
213  EntityParticipationPK key = new EntityParticipationPK();
214  key.setEntityPath(entityPath);
215  key.setParticipatorPath(participatorPath);
216  key.setReason(reason);
217  EntityParticipation ep = getDao().find(EntityParticipation.class, key);
218  if(ep == null) {
219  ep = new EntityParticipation();
220  ep.setEntityPath(entityPath);
221  ep.setParticipatorPath(participatorPath);
222  ep.setReason(reason);
223  ep.setParticipationDate(new Date());
224  getDao().saveObject(ep);
225  }
226  reset();
227  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

static void org.turro.assistant.ParticipationInfo.cleanup ( String  entityPath)
static

Definition at line 285 of file ParticipationInfo.java.

285  {
286  SqlClause.delete("EntityParticipation")
287  .where().equal("entityPath", entityPath)
288  .or().equal("participatorPath", entityPath)
289  .dao(new ElephantPU())
290  .execute();
291  }
Here is the caller graph for this function:

◆ getAllPaths()

static Set<String> org.turro.assistant.ParticipationInfo.getAllPaths ( String  root)
static

Definition at line 295 of file ParticipationInfo.java.

295  {
296  return new HashSet<>(SqlClause.select("distinct ep.entityPath").from("EntityParticipation ep")
297  .where().startsWith("ep.entityPath", "/" + root + "/")
298  .dao(new ElephantPU())
299  .resultList(String.class));
300  }
Here is the caller graph for this function:

◆ getAnyParticipations() [1/2]

List<IEntityParticipation> org.turro.assistant.ParticipationInfo.getAnyParticipations ( Date  from)

Definition at line 133 of file ParticipationInfo.java.

133  {
134  WhereClause wc = new WhereClause();
135  wc.addClause("select ep from EntityParticipation ep");
136  wc.addClause("where 1=1");
137  if(reason != null) {
138  wc.addClause("and ep.reason = :reason");
139  wc.addNamedValue("reason", reason);
140  }
141  if(from != null) {
142  wc.addClause("and ep.participationDate >= :from");
143  wc.addNamedValue("from", from);
144  }
145  return getDao().getResultList(wc);
146  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAnyParticipations() [2/2]

void org.turro.assistant.ParticipationInfo.getAnyParticipations ( Date  from,
Consumer< IEntityParticipation action 
)

Definition at line 148 of file ParticipationInfo.java.

148  {
149  WhereClause wc = new WhereClause();
150  wc.addClause("select ep from EntityParticipation ep");
151  wc.addClause("where 1=1");
152  if(reason != null) {
153  wc.addClause("and ep.reason = :reason");
154  wc.addNamedValue("reason", reason);
155  }
156  if(from != null) {
157  wc.addClause("and ep.participationDate >= :from");
158  wc.addNamedValue("from", from);
159  }
160  getDao().forEach(IEntityParticipation.class, wc, action);
161  }
Here is the call graph for this function:

◆ getCount()

long org.turro.assistant.ParticipationInfo.getCount ( )

Definition at line 78 of file ParticipationInfo.java.

78  {
79  if(count == null) {
80  WhereClause wc = new WhereClause();
81  wc.addClause("select count(ep) from EntityParticipation ep");
82  wc.addClause("where ep.entityPath = :entityPath");
83  wc.addNamedValue("entityPath", entityPath);
84  if(reason != null) {
85  wc.addClause("and ep.reason = :reason");
86  wc.addNamedValue("reason", reason);
87  }
88  count = (long) getDao().getSingleResult(wc);
89  }
90  return count;
91  }
Object getSingleResult(WhereClause wc)
Definition: Dao.java:380
Here is the call graph for this function:

◆ getCrossParticipations() [1/2]

List<IEntityParticipation> org.turro.assistant.ParticipationInfo.getCrossParticipations ( )

Definition at line 113 of file ParticipationInfo.java.

113  {
114  return getCrossParticipations(null);
115  }
List< IEntityParticipation > getCrossParticipations()
Here is the caller graph for this function:

◆ getCrossParticipations() [2/2]

List<IEntityParticipation> org.turro.assistant.ParticipationInfo.getCrossParticipations ( Date  from)

Definition at line 117 of file ParticipationInfo.java.

117  {
118  WhereClause wc = new WhereClause();
119  wc.addClause("select ep from EntityParticipation ep");
120  wc.addClause("where ep.participatorPath = :entityPath");
121  wc.addNamedValue("entityPath", entityPath);
122  if(reason != null) {
123  wc.addClause("and ep.reason = :reason");
124  wc.addNamedValue("reason", reason);
125  }
126  if(from != null) {
127  wc.addClause("and ep.participationDate >= :from");
128  wc.addNamedValue("from", from);
129  }
130  return getDao().getResultList(wc);
131  }
Here is the call graph for this function:

◆ getEntity()

IElephantEntity org.turro.assistant.ParticipationInfo.getEntity ( )

Definition at line 248 of file ParticipationInfo.java.

248  {
249  return Entities.getController(entityPath);
250  }
Here is the call graph for this function:

◆ getParticipants()

ContactList org.turro.assistant.ParticipationInfo.getParticipants ( )

Definition at line 258 of file ParticipationInfo.java.

258  {
259  ContactList list = new ContactList();
260  for(IEntityParticipation ep : getParticipations()) {
261  list.add(ep.getContact());
262  }
263  return list;
264  }
List< IEntityParticipation > getParticipations()
Here is the call graph for this function:

◆ getParticipationCount()

static long org.turro.assistant.ParticipationInfo.getParticipationCount ( String  root,
IContact  contact,
ParticipationReason  reason 
)
static

Definition at line 273 of file ParticipationInfo.java.

273  {
274  WhereClause wc = new WhereClause();
275  wc.addClause("select count(ep) from EntityParticipation ep");
276  wc.addClause("where ep.entityPath like concat('/', :rootPath, '/%')");
277  wc.addNamedValue("rootPath", root);
278  wc.addClause("and ep.participatorPath = concat('/contact/', :participator)");
279  wc.addNamedValue("participator", contact.getId());
280  wc.addClause("and ep.reason = :reason");
281  wc.addNamedValue("reason", reason);
282  return (long) new ElephantPU().getSingleResult(wc);
283  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getParticipations() [1/2]

List<IEntityParticipation> org.turro.assistant.ParticipationInfo.getParticipations ( )

Definition at line 93 of file ParticipationInfo.java.

93  {
94  return getParticipations(null);
95  }
Here is the caller graph for this function:

◆ getParticipations() [2/2]

List<IEntityParticipation> org.turro.assistant.ParticipationInfo.getParticipations ( Date  from)

Definition at line 97 of file ParticipationInfo.java.

97  {
98  WhereClause wc = new WhereClause();
99  wc.addClause("select ep from EntityParticipation ep");
100  wc.addClause("where ep.entityPath = :entityPath");
101  wc.addNamedValue("entityPath", entityPath);
102  if(reason != null) {
103  wc.addClause("and ep.reason = :reason");
104  wc.addNamedValue("reason", reason);
105  }
106  if(from != null) {
107  wc.addClause("and ep.participationDate >= :from");
108  wc.addNamedValue("from", from);
109  }
110  return getDao().getResultList(wc);
111  }
Here is the call graph for this function:

◆ getParticipator()

IElephantEntity org.turro.assistant.ParticipationInfo.getParticipator ( )

Definition at line 244 of file ParticipationInfo.java.

244  {
245  return Entities.getController(participatorPath);
246  }
Here is the call graph for this function:

◆ getReasonStr()

String org.turro.assistant.ParticipationInfo.getReasonStr ( )

Definition at line 252 of file ParticipationInfo.java.

252  {
253  return I_.byKey(reason.toString());
254  }
Here is the call graph for this function:

◆ isChecked()

boolean org.turro.assistant.ParticipationInfo.isChecked ( )

Definition at line 163 of file ParticipationInfo.java.

163  {
164  if(checked == null) {
165  checked = false;
166  if(!isEmpty()) {
167  EntityParticipationPK key = new EntityParticipationPK();
168  key.setEntityPath(entityPath);
169  key.setParticipatorPath(participatorPath);
170  key.setReason(reason);
171  EntityParticipation ep = getDao().find(EntityParticipation.class, key);
172  checked = ep != null;
173  }
174  }
175  return checked;
176  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEmpty()

boolean org.turro.assistant.ParticipationInfo.isEmpty ( )

Definition at line 182 of file ParticipationInfo.java.

182  {
183  return Strings.isBlank(entityPath) || Strings.isBlank(participatorPath) || reason == null;
184  }
Here is the caller graph for this function:

◆ isUser()

boolean org.turro.assistant.ParticipationInfo.isUser ( )

Definition at line 178 of file ParticipationInfo.java.

178  {
179  return !Strings.isBlank(participatorPath);
180  }

◆ toggle()

boolean org.turro.assistant.ParticipationInfo.toggle ( )

Definition at line 186 of file ParticipationInfo.java.

186  {
187  boolean result = false;
188  if(!isEmpty()) {
189  EntityParticipationPK key = new EntityParticipationPK();
190  key.setEntityPath(entityPath);
191  key.setParticipatorPath(participatorPath);
192  key.setReason(reason);
193  EntityParticipation ep = getDao().find(EntityParticipation.class, key);
194  if(ep != null) {
195  getDao().deleteObject(ep);
196  result = false;
197  } else {
198  ep = new EntityParticipation();
199  ep.setEntityPath(entityPath);
200  ep.setParticipatorPath(participatorPath);
201  ep.setReason(reason);
202  ep.setParticipationDate(new Date());
203  getDao().saveObject(ep);
204  result = true;
205  }
206  reset();
207  }
208  return result;
209  }
void deleteObject(Object obj)
Definition: Dao.java:162
Here is the call graph for this function:

◆ uncheck()

void org.turro.assistant.ParticipationInfo.uncheck ( )

Definition at line 229 of file ParticipationInfo.java.

229  {
230  if(isEmpty()) return;
231  EntityParticipationPK key = new EntityParticipationPK();
232  key.setEntityPath(entityPath);
233  key.setParticipatorPath(participatorPath);
234  key.setReason(reason);
235  EntityParticipation ep = getDao().find(EntityParticipation.class, key);
236  if(ep != null) {
237  getDao().deleteObject(ep);
238  }
239  reset();
240  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: