19 package org.turro.acceptance;
21 import java.util.Date;
22 import java.util.List;
23 import javax.persistence.NoResultException;
24 import org.turro.action.AcceptanceSingleStatus;
25 import org.turro.action.AcceptanceStatus;
26 import org.turro.action.IAcceptance;
27 import org.turro.action.IAcceptances;
28 import org.turro.annotation.ElephantPlugin;
29 import org.turro.contacts.Acceptance;
30 import org.turro.contacts.db.ContactsPU;
31 import org.turro.jpa.Dao;
32 import org.turro.plugin.contacts.IContact;
44 if(list.isEmpty())
return false;
46 if(a.getDateAcceptance() ==
null) {
56 return !list.isEmpty();
70 boolean accepted =
false, pending =
false;
73 if(a.getDateAcceptance() !=
null) {
75 if(contact !=
null && a.getIContact().
getId().equals(contact.
getId())) {
80 if(contact !=
null && a.getIContact().
getId().equals(contact.
getId())) {
99 if(acceptance !=
null) {
112 return getDao().getResultList(
113 "select a from Acceptance a " +
122 return getDao().getResultList(
123 "select a from Acceptance as a " +
124 "where a.contact = ? " +
125 "and a.dateAcceptance is null",
133 return getDao().getResultList(
134 "select a from Acceptance as a " +
135 "where a.petitioner = ? " +
136 "and a.dateAcceptance is null",
153 "select a from Acceptance as a " +
154 "where a.contact = ? " +
155 "and a.petitioner = ? " +
157 "and a.dateAcceptance is null",
161 if(comment !=
null) {
165 a = dao.saveObject(a);
166 }
catch(NoResultException ex) {
177 "select a from Acceptance as a " +
178 "where a.contact = ? " +
179 "and a.petitioner = ? " +
184 if(comment !=
null) {
187 a = dao.saveObject(a);
188 }
catch(NoResultException ex) {
190 a.setAcceptanceComment(comment);
191 a.setIPetitioner(petitioner);
192 a.setIContact(contact);
193 a.setDateRequest(
new Date());
195 a = dao.saveObject(a);
201 public void delete(
IContact contact, String path) {
202 getDao().executeUpdate(
203 "delete from Acceptance " +
204 "where contact = ? " +
207 contact.getContact(), path
213 return (
IAcceptance) getDao().getSingleResultOrNull(
214 "select a from Acceptance as a " +
215 "where a.contact = ? " +
216 "and a.petitioner = ? " +
225 return createPetition(path, contact, link,
null);
235 private Dao getDao() {
String createPetition(String path, IContact contact, String link)
IAcceptance request(IContact petitioner, IContact contact, String path, String comment)
List< IAcceptance > getPendingRequests(IContact contact)
List< IAcceptance > getAcceptances(String path)
IAcceptance accept(IContact petitioner, IContact contact, String path, String comment)
String createPetition(String path, IContact contact, String link, String template)
boolean isBlocked(String path)
IAcceptance getAcceptanceFor(String path, IContact petitioner, IContact contact)
AcceptanceStatus getStatusFor(String path, IContact contact)
IAcceptance accept(IAcceptance a)
List< IAcceptance > getPendingAcceptances(IContact contact)
boolean isAccepted(String path)
AcceptanceSingleStatus getStatusFor(String path, IContact petitioner, IContact contact)
AcceptanceStatus getStatusFor(String path)
static String createPetition(String path, IContact contact, String link)
Object getSingleResult(WhereClause wc)
String getAcceptanceComment()
IContact getIPetitioner()
void setAcceptanceComment(String acceptanceComment)
void setDateAcceptance(Date dateAcceptance)