BrightSide Workbench Full Report + Source Code
AcceptanceParticipationCatcher.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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 package org.turro.activity;
19 
20 import org.turro.contacts.Acceptance;
21 import org.turro.contacts.db.ContactsPU;
22 import org.turro.contacts.zul.menu.ContactMenu;
23 import org.turro.elephant.db.WhereClause;
24 import org.turro.entities.Entities;
25 import org.turro.i18n.I_;
26 import org.turro.jpa.Dao;
27 import org.turro.path.Path;
28 
33 @ParticipationCatcher
34 public class AcceptanceParticipationCatcher extends JpaParticipationCatcher<Acceptance> {
35 
36  @Override
37  public String getDescription() {
38  return "BrightSide Contacts - " + I_.get("Acceptance");
39  }
40 
41  @Override
42  public Dao createDao() {
43  return new ContactsPU();
44  }
45 
46  @Override
47  public WhereClause getQuery(Path entityPath) {
48  if(!entityPath.isRoot() && "contact".equals(entityPath.getRoot())) {
49  WhereClause wc = new WhereClause();
50  wc.addClause("select distinct a from Acceptance as a");
51  wc.addClause("where a.contact.id = :idc");
52  wc.addNamedValue("idc", entityPath.getLastNode());
53  wc.addClause("or a.petitioner.id = :idp");
54  wc.addNamedValue("idp", entityPath.getLastNode());
55  return wc;
56  }
57  return null;
58  }
59 
60  @Override
61  public boolean getCanDelete(Acceptance v) {
62  return v.getDateAcceptance() == null;
63  }
64 
65  @Override
66  public String getDescription(Acceptance v) {
67  return Entities.getController(v.getPath()).getName();
68  }
69 
70  @Override
71  public void doDelete(Acceptance v) {
72  getDao().deleteObject(v);
73  }
74 
75  @Override
76  public void doShow(Acceptance v) {
78  }
79 
80  @Override
81  public void onChange(Object entity) {
82  // do nothing
83  }
84 
85  @Override
86  public void onDelete(Object entity) {
87  // do nothing
88  }
89 
90  @Override
91  public boolean getCanChangeFor(Acceptance v) {
92  return false;
93  }
94 
95  @Override
96  public void doChangeFor(Acceptance v, Path toPath) {
97  // do nothing
98  }
99 
100  @Override
101  public Object getReferringEntity(Acceptance v) {
102  return Entities.getController(v.getPath()).getEntity();
103  }
104 
105 }
static void showAcceptance(String path, final Command command)
void addNamedValue(String name, Object value)
static IElephantEntity getController(String path)
Definition: Entities.java:78
static String get(String msg)
Definition: I_.java:41
void deleteObject(Object obj)
Definition: Dao.java:162