BrightSide Workbench Full Report + Source Code
PublicationPlugin.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.plugin.IPlugin;
21 import org.turro.plugin.contacts.IContact;
22 import org.turro.publication.db.PublicationPU;
23 import org.turro.publication.zul.ctrl.SubscriptionsGrid;
24 import org.turro.publication.zul.ctrl.SubscriptionsListbox;
25 
30 //@ElephantPlugin(label="publication")
31 @Deprecated
32 public class PublicationPlugin implements IPlugin {
33 
34  private Object data;
35 
36  @Override
37  public void setData(String id, Object data) {
38  if("icontact".equals(id)) {
39  this.data = data;
40  } else if("icategory".equals(id)) {
41  this.data = data;
42  }
43  }
44 
45  @Override
46  public Object getData(String id) {
47  if("subscription".equals(id)) {
48  IContact contact = (IContact) data;
49  return new PublicationPU().getResultList(
50  "select pubsubs from PublicationSubscription as pubsubs " +
51  "where pubsubs.idContact = ? " +
52  "order by pubsubs.publicationCategory.name",
53  new Object[] { contact.getId() }
54  );
55  } else if("subscription_listbox".equals(id)) {
56  IContact contact = (IContact) data;
57  return new SubscriptionsListbox(contact);
58  } else if("subscription_grid".equals(id)) {
59  IContact contact = (IContact) data;
60  return new SubscriptionsGrid(contact);
61  } else if("subscriptors".equals(id)) {
62  Long category = (Long) data;
63  return new PublicationPU().getResultList(
64  "select pubsubs.idContact from PublicationSubscription as pubsubs " +
65  "where pubsubs.publicationCategory.id = ?",
66  new Object[] { category }
67  );
68  }
69  return null;
70  }
71 
72 }