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