BrightSide Workbench Full Report + Source Code
org.turro.acceptance.AcceptanceUtil Class Reference

Static Public Member Functions

static boolean isAccepted (String path)
 
static boolean isBlocked (String path)
 
static AcceptanceStatus getStatusFor (String path, IContact contact)
 
static AcceptanceStatus getStatusFor (String path, Contact contact)
 
static List< AcceptancegetAcceptances (String path)
 
static List< AcceptancegetPendingAcceptances (IContact contact)
 
static List< AcceptancegetPendingAcceptances (Contact contact)
 
static List< AcceptancegetPendingRequests (IContact contact)
 
static List< AcceptancegetPendingRequests (Contact contact)
 
static Acceptance accept (Acceptance a)
 
static Acceptance accept (IContact petitioner, IContact contact, String path, String comment)
 
static Acceptance accept (Contact petitioner, Contact contact, String path, String comment)
 
static Acceptance request (IContact petitioner, IContact contact, String path, String comment)
 
static Acceptance request (Contact petitioner, Contact contact, String path, String comment)
 
static void delete (IContact contact, String path)
 
static void delete (Contact contact, String path)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 34 of file AcceptanceUtil.java.

Member Function Documentation

◆ accept() [1/3]

static Acceptance org.turro.acceptance.AcceptanceUtil.accept ( Acceptance  a)
static

Definition at line 127 of file AcceptanceUtil.java.

127  {
128  return accept(a.getPetitioner(), a.getContact(), a.getPath(), null);
129  }
static Acceptance accept(Acceptance a)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ accept() [2/3]

static Acceptance org.turro.acceptance.AcceptanceUtil.accept ( Contact  petitioner,
Contact  contact,
String  path,
String  comment 
)
static

Definition at line 135 of file AcceptanceUtil.java.

135  {
136  Dao dao = new ContactsPU();
137  Acceptance a = null;
138  try {
139  a = (Acceptance) dao.getSingleResult(
140  "select a from Acceptance as a " +
141  "where a.contact = ? " +
142  "and a.petitioner = ? " +
143  "and a.path = ? " +
144  "and a.dateAcceptance is null",
145  new Object[] {
146  contact, petitioner, path
147  });
148  if(comment != null) {
149  a.setAcceptanceComment(a.getAcceptanceComment() + "\n" + comment);
150  }
151  a.setDateAcceptance(new Date());
152  a = dao.saveObject(a);
153  } catch(NoResultException ex) {
154  }
155  return a;
156  }
Here is the call graph for this function:

◆ accept() [3/3]

static Acceptance org.turro.acceptance.AcceptanceUtil.accept ( IContact  petitioner,
IContact  contact,
String  path,
String  comment 
)
static

Definition at line 131 of file AcceptanceUtil.java.

131  {
132  return accept((Contact) petitioner.getContact(), (Contact) contact.getContact(), path, comment);
133  }
Here is the call graph for this function:

◆ delete() [1/2]

static void org.turro.acceptance.AcceptanceUtil.delete ( Contact  contact,
String  path 
)
static

Definition at line 194 of file AcceptanceUtil.java.

194  {
195  Dao dao = new ContactsPU();
196  dao.executeUpdate(
197  "delete from Acceptance " +
198  "where contact = ? " +
199  "and path = ?",
200  new Object[] {
201  contact, path
202  });
203  }
Here is the call graph for this function:

◆ delete() [2/2]

static void org.turro.acceptance.AcceptanceUtil.delete ( IContact  contact,
String  path 
)
static

Definition at line 190 of file AcceptanceUtil.java.

190  {
191  delete((Contact) contact.getContact(), path);
192  }

◆ getAcceptances()

static List<Acceptance> org.turro.acceptance.AcceptanceUtil.getAcceptances ( String  path)
static

Definition at line 87 of file AcceptanceUtil.java.

87  {
88  Dao dao = new ContactsPU();
89  return dao.getResultList(
90  "select a from Acceptance a " +
91  "where a.path = ?",
92  new Object[] {
93  path
94  });
95  }
Here is the caller graph for this function:

◆ getPendingAcceptances() [1/2]

static List<Acceptance> org.turro.acceptance.AcceptanceUtil.getPendingAcceptances ( Contact  contact)
static

Definition at line 101 of file AcceptanceUtil.java.

101  {
102  Dao dao = new ContactsPU();
103  return dao.getResultList(
104  "select a from Acceptance as a " +
105  "where a.contact = ? " +
106  "and a.dateAcceptance is null",
107  new Object[] {
108  contact
109  });
110  }

◆ getPendingAcceptances() [2/2]

static List<Acceptance> org.turro.acceptance.AcceptanceUtil.getPendingAcceptances ( IContact  contact)
static

Definition at line 97 of file AcceptanceUtil.java.

97  {
98  return getPendingAcceptances((Contact) contact.getContact());
99  }
static List< Acceptance > getPendingAcceptances(IContact contact)
Here is the call graph for this function:

◆ getPendingRequests() [1/2]

static List<Acceptance> org.turro.acceptance.AcceptanceUtil.getPendingRequests ( Contact  contact)
static

Definition at line 116 of file AcceptanceUtil.java.

116  {
117  Dao dao = new ContactsPU();
118  return dao.getResultList(
119  "select a from Acceptance as a " +
120  "where a.petitioner = ? " +
121  "and a.dateAcceptance is null",
122  new Object[] {
123  contact
124  });
125  }

◆ getPendingRequests() [2/2]

static List<Acceptance> org.turro.acceptance.AcceptanceUtil.getPendingRequests ( IContact  contact)
static

Definition at line 112 of file AcceptanceUtil.java.

112  {
113  return getPendingRequests((Contact) contact.getContact());
114  }
static List< Acceptance > getPendingRequests(IContact contact)
Here is the call graph for this function:

◆ getStatusFor() [1/2]

static AcceptanceStatus org.turro.acceptance.AcceptanceUtil.getStatusFor ( String  path,
Contact  contact 
)
static

Definition at line 56 of file AcceptanceUtil.java.

56  {
57  List<Acceptance> list = getAcceptances(path);
58  if(list.isEmpty()) {
59  return AcceptanceStatus.NONE_EXISTS;
60  }
61  boolean accepted = false, pending = false;
62  AcceptanceStatus selfStatus = null;
63  for(Acceptance a : list) {
64  if(a.getDateAcceptance() != null) {
65  accepted = true;
66  if(a.getContact().getId().equals(contact.getId())) {
67  selfStatus = AcceptanceStatus.SELF_ACCEPTED;
68  }
69  } else {
70  pending = true;
71  if(a.getContact().getId().equals(contact.getId())) {
72  selfStatus = AcceptanceStatus.SELF_PENDING;
73  }
74  }
75  }
76  if(accepted) {
77  if(pending) {
78  return selfStatus == null ? AcceptanceStatus.SOME_PENDING : selfStatus;
79  } else {
80  return AcceptanceStatus.FULLY_ACCEPTED;
81  }
82  } else {
83  return selfStatus == null ? AcceptanceStatus.FULLY_PENDING : selfStatus;
84  }
85  }
static List< Acceptance > getAcceptances(String path)
Here is the call graph for this function:

◆ getStatusFor() [2/2]

static AcceptanceStatus org.turro.acceptance.AcceptanceUtil.getStatusFor ( String  path,
IContact  contact 
)
static

Definition at line 52 of file AcceptanceUtil.java.

52  {
53  return getStatusFor(path, (Contact) contact.getContact());
54  }
static AcceptanceStatus getStatusFor(String path, IContact contact)
Here is the call graph for this function:

◆ isAccepted()

static boolean org.turro.acceptance.AcceptanceUtil.isAccepted ( String  path)
static

Definition at line 36 of file AcceptanceUtil.java.

36  {
37  List<Acceptance> list = getAcceptances(path);
38  if(list.isEmpty()) return false;
39  for(Acceptance a : list) {
40  if(a.getDateAcceptance() == null) {
41  return false;
42  }
43  }
44  return true;
45  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isBlocked()

static boolean org.turro.acceptance.AcceptanceUtil.isBlocked ( String  path)
static

Definition at line 47 of file AcceptanceUtil.java.

47  {
48  List<Acceptance> list = getAcceptances(path);
49  return !list.isEmpty();
50  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ request() [1/2]

static Acceptance org.turro.acceptance.AcceptanceUtil.request ( Contact  petitioner,
Contact  contact,
String  path,
String  comment 
)
static

Definition at line 162 of file AcceptanceUtil.java.

162  {
163  Dao dao = new ContactsPU();
164  Acceptance a = null;
165  try {
166  a = (Acceptance) dao.getSingleResult(
167  "select a from Acceptance as a " +
168  "where a.contact = ? " +
169  "and a.petitioner = ? " +
170  "and a.path = ?",
171  new Object[] {
172  contact, petitioner, path
173  });
174  if(comment != null) {
175  a.setAcceptanceComment(a.getAcceptanceComment() + "\n" + comment);
176  }
177  a = dao.saveObject(a);
178  } catch(NoResultException ex) {
179  a = new Acceptance();
180  a.setAcceptanceComment(comment);
181  a.setPetitioner(petitioner);
182  a.setContact(contact);
183  a.setDateRequest(new Date());
184  a.setPath(path);
185  a = dao.saveObject(a);
186  }
187  return a;
188  }
Here is the call graph for this function:

◆ request() [2/2]

static Acceptance org.turro.acceptance.AcceptanceUtil.request ( IContact  petitioner,
IContact  contact,
String  path,
String  comment 
)
static

Definition at line 158 of file AcceptanceUtil.java.

158  {
159  return request((Contact) petitioner.getContact(), (Contact) contact.getContact(), path, comment);
160  }
static Acceptance request(IContact petitioner, IContact contact, String path, String comment)
Here is the call graph for this function:

The documentation for this class was generated from the following file: