18 package org.turro.acceptance;
20 import java.util.Date;
21 import java.util.List;
22 import javax.persistence.NoResultException;
23 import org.turro.action.AcceptanceStatus;
24 import org.turro.contacts.Acceptance;
25 import org.turro.contacts.Contact;
26 import org.turro.contacts.db.ContactsPU;
27 import org.turro.jpa.Dao;
28 import org.turro.plugin.contacts.IContact;
38 if(list.isEmpty())
return false;
40 if(a.getDateAcceptance() ==
null) {
49 return !list.isEmpty();
61 boolean accepted =
false, pending =
false;
64 if(a.getDateAcceptance() !=
null) {
66 if(a.getContact().getId().equals(contact.
getId())) {
71 if(a.getContact().getId().equals(contact.
getId())) {
89 return dao.getResultList(
90 "select a from Acceptance a " +
103 return dao.getResultList(
104 "select a from Acceptance as a " +
105 "where a.contact = ? " +
106 "and a.dateAcceptance is null",
118 return dao.getResultList(
119 "select a from Acceptance as a " +
120 "where a.petitioner = ? " +
121 "and a.dateAcceptance is null",
140 "select a from Acceptance as a " +
141 "where a.contact = ? " +
142 "and a.petitioner = ? " +
144 "and a.dateAcceptance is null",
146 contact, petitioner, path
148 if(comment !=
null) {
152 a = dao.saveObject(a);
153 }
catch(NoResultException ex) {
167 "select a from Acceptance as a " +
168 "where a.contact = ? " +
169 "and a.petitioner = ? " +
172 contact, petitioner, path
174 if(comment !=
null) {
177 a = dao.saveObject(a);
178 }
catch(NoResultException ex) {
180 a.setAcceptanceComment(comment);
181 a.setPetitioner(petitioner);
182 a.setContact(contact);
183 a.setDateRequest(
new Date());
185 a = dao.saveObject(a);
190 public static void delete(
IContact contact, String path) {
191 delete((
Contact) contact.getContact(), path);
194 public static void delete(
Contact contact, String path) {
197 "delete from Acceptance " +
198 "where contact = ? " +
static List< Acceptance > getPendingRequests(Contact contact)
static boolean isBlocked(String path)
static boolean isAccepted(String path)
static Acceptance accept(Contact petitioner, Contact contact, String path, String comment)
static Acceptance request(IContact petitioner, IContact contact, String path, String comment)
static List< Acceptance > getPendingRequests(IContact contact)
static List< Acceptance > getPendingAcceptances(IContact contact)
static Acceptance accept(Acceptance a)
static AcceptanceStatus getStatusFor(String path, IContact contact)
static Acceptance accept(IContact petitioner, IContact contact, String path, String comment)
static List< Acceptance > getAcceptances(String path)
static List< Acceptance > getPendingAcceptances(Contact contact)
static AcceptanceStatus getStatusFor(String path, Contact contact)
static Acceptance request(Contact petitioner, Contact contact, String path, String comment)
int executeUpdate(String query)
Object getSingleResult(WhereClause wc)