BrightSide Workbench Full Report + Source Code
VoteItParticipationCatcher.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2015 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.activity;
20 
21 import org.turro.contacts.VoteIt;
22 import org.turro.contacts.db.ContactsPU;
23 import org.turro.elephant.db.WhereClause;
24 import org.turro.entities.Entities;
25 import org.turro.jpa.Dao;
26 import org.turro.path.Path;
27 
32 @ParticipationCatcher
34 
35  @Override
36  public String getDescription() {
37  return "BrightSide Contacts - VoteIt";
38  }
39 
40  @Override
41  public Dao createDao() {
42  return new ContactsPU();
43  }
44 
45  @Override
46  public WhereClause getQuery(Path entityPath) {
47  WhereClause wc = new WhereClause();
48  wc.addClause("select distinct a from VoteIt as a");
49  wc.addClause("where (a.creator.id = :idc or a.path = :path)");
50  wc.addNamedValue("idc", entityPath.getLastNode());
51  wc.addNamedValue("path", entityPath.getPath());
52  return wc;
53  }
54 
55  @Override
56  public boolean getCanDelete(VoteIt v) {
57  return true;
58  }
59 
60  @Override
61  public String getDescription(VoteIt v) {
62  return v.getVote() + "";
63  }
64 
65  @Override
66  public void doDelete(VoteIt v) {
67  getDao().deleteObject(v);
68  }
69 
70  @Override
71  public void doShow(VoteIt v) {
72  // nothing to show?
73  }
74 
75  @Override
76  public void onChange(Object entity) {
77  // do nothing
78  }
79 
80  @Override
81  public void onDelete(Object entity) {
82  // do nothing
83  }
84 
85  @Override
86  public boolean getCanChangeFor(VoteIt v) {
87  return false;
88  }
89 
90  @Override
91  public void doChangeFor(VoteIt v, Path toPath) {
92  // do nothing
93  }
94 
95  @Override
96  public Object getReferringEntity(VoteIt v) {
98  }
99 
100 }
101 
102 
void addNamedValue(String name, Object value)
static IElephantEntity getController(String path)
Definition: Entities.java:78
void deleteObject(Object obj)
Definition: Dao.java:162