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