BrightSide Workbench Full Report + Source Code
SubscriptionActivityCatcher.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.publication.util;
19 
20 import org.turro.activity.JpaParticipationCatcher;
21 import org.turro.elephant.db.WhereClause;
22 import org.turro.i18n.I_;
23 import org.turro.jpa.Dao;
24 import org.turro.path.Path;
25 import org.turro.plugin.contacts.IContact;
26 import org.turro.publication.db.PublicationPU;
27 import org.turro.publication.entity.PublicationSubscription;
28 
34 /*@ActivityCatcher*/
35 @Deprecated
36 public class SubscriptionActivityCatcher extends JpaParticipationCatcher<PublicationSubscription> {
37 
38  @Override
39  public String getDescription() {
40  return "BrightSide Publications - " + I_.get("Subscriptions");
41  }
42 
43  @Override
44  public Dao createDao() {
45  return new PublicationPU();
46  }
47 
48  @Override
49  public WhereClause getQuery(Path entityPath) {
50  if(!entityPath.isRoot() && "contact".equals(entityPath.getRoot())) {
51  WhereClause wc = new WhereClause();
52  wc.addClause("select distinct subscription from PublicationSubscription as subscription");
53  wc.addClause("where subscription.idContact = :id");
54  wc.addNamedValue("id", entityPath.getLastNode());
55  return wc;
56  }
57  return null;
58  }
59 
60  @Override
62  return true;
63  }
64 
65  @Override
67  return v.getPublicationCategory().getName();
68  }
69 
70  @Override
72  getDao().deleteObject(v);
73  }
74 
75  @Override
77  throw new UnsupportedOperationException("Not supported yet.");
78  }
79 
80  @Override
81  public void onChange(Object entity) {
82  if(entity instanceof IContact) {
83  IContact contact = (IContact) entity;
84  // do nothing
85  }
86  }
87 
88  @Override
89  public void onDelete(Object entity) {
90  // do nothing
91  }
92 
93  @Override
95  return false;
96  }
97 
98  @Override
99  public void doChangeFor(PublicationSubscription v, Path toPath) {
100  // do nothing
101  }
102 
103  @Override
105  return v.getPublicationCategory();
106  }
107 
108 }
void addNamedValue(String name, Object value)
static String get(String msg)
Definition: I_.java:41
void deleteObject(Object obj)
Definition: Dao.java:162
void doChangeFor(PublicationSubscription v, Path toPath)