BrightSide Workbench Full Report + Source Code
ServiceParticipationCatcher.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.activity;
20 
21 import org.turro.contacts.ContactService;
22 import org.turro.contacts.db.ContactsPU;
23 import org.turro.elephant.db.WhereClause;
24 import org.turro.i18n.I_;
25 import org.turro.jpa.Dao;
26 import org.turro.path.Path;
27 
32 @ParticipationCatcher
33 public class ServiceParticipationCatcher extends JpaParticipationCatcher<ContactService> {
34 
35  @Override
36  public String getDescription() {
37  return "BrightSide Contacts - " + I_.get("Service");
38  }
39 
40  @Override
41  public Dao createDao() {
42  return new ContactsPU();
43  }
44 
45  @Override
46  public WhereClause getQuery(Path entityPath) {
47  if(!entityPath.isRoot() && "contact".equals(entityPath.getRoot())) {
48  WhereClause wc = new WhereClause();
49  wc.addClause("select distinct a from ContactService as a");
50  wc.addClause("where a.responsible.id = :idc");
51  wc.addClause("or a.contact.id = :idc");
52  wc.addNamedValue("idc", entityPath.getLastNode());
53  return wc;
54  }
55  return null;
56  }
57 
58  @Override
59  public boolean getCanDelete(ContactService v) {
60  return false;
61  }
62 
63  @Override
64  public String getDescription(ContactService v) {
65  return v.getTitle();
66  }
67 
68  @Override
69  public void doDelete(ContactService v) {
70  getDao().deleteObject(v);
71  }
72 
73  @Override
74  public void doShow(ContactService v) {
75  // do nothing
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
89  public boolean getCanChangeFor(ContactService v) {
90  return false;
91  }
92 
93  @Override
94  public void doChangeFor(ContactService v, Path toPath) {
95  // do nothing
96  }
97 
98  @Override
100  return null;
101  }
102 
103 }
void addNamedValue(String name, Object value)
static String get(String msg)
Definition: I_.java:41
void deleteObject(Object obj)
Definition: Dao.java:162