BrightSide Workbench Full Report + Source Code
PublicationUtil.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 java.util.Date;
21 import java.util.List;
22 import org.turro.plugin.contacts.IContact;
23 import org.turro.publication.db.PublicationPU;
24 import org.turro.publication.entity.PublicationCategory;
25 import org.turro.publication.entity.PublicationSubscription;
26 
31 @Deprecated
32 public class PublicationUtil {
33 
34  public static boolean getChecked(IContact contact, PublicationCategory v) {
35  List l = new PublicationPU().getResultList(
36  "select pubsubs from PublicationSubscription as pubsubs " +
37  "where pubsubs.publicationCategory = ? " +
38  "and pubsubs.idContact = ?",
39  new Object[] { v, contact.getId() }
40  );
41  return l != null && !l.isEmpty();
42  }
43 
44  public static void setChecked(IContact contact, PublicationCategory v, boolean checked) {
45  if(checked && !getChecked(contact, v)) {
47  ps.setCreation(new Date());
48  ps.setIdContact(contact.getId());
50  new PublicationPU().saveObject(ps);
51  } else if(!checked) {
53  "delete from PublicationSubscription " +
54  "where publicationCategory = ? " +
55  "and idContact = ?",
56  new Object[] { v, contact.getId() }
57  );
58  }
59  }
60 
61  public static void subscribeAll(IContact contact, boolean checked) {
63  setChecked(contact, pc, checked);
64  }
65  }
66 
67  private PublicationUtil() {
68  }
69 
70 }
int executeUpdate(String query)
Definition: Dao.java:436
void setPublicationCategory(PublicationCategory publicationCategory)
static Collection< PublicationCategory > getPublicCategories()
static boolean getChecked(IContact contact, PublicationCategory v)
static void subscribeAll(IContact contact, boolean checked)
static void setChecked(IContact contact, PublicationCategory v, boolean checked)