BrightSide Workbench Full Report + Source Code
org.turro.acceptance.Acceptances Class Reference
Inheritance diagram for org.turro.acceptance.Acceptances:
Collaboration diagram for org.turro.acceptance.Acceptances:

Public Member Functions

boolean isAccepted (String path)
 
boolean isBlocked (String path)
 
AcceptanceStatus getStatusFor (String path)
 
AcceptanceStatus getStatusFor (String path, IContact contact)
 
AcceptanceSingleStatus getStatusFor (String path, IContact petitioner, IContact contact)
 
List< IAcceptancegetAcceptances (String path)
 
List< IAcceptancegetPendingAcceptances (IContact contact)
 
List< IAcceptancegetPendingRequests (IContact contact)
 
IAcceptance accept (IAcceptance a)
 
IAcceptance accept (IContact petitioner, IContact contact, String path, String comment)
 
IAcceptance request (IContact petitioner, IContact contact, String path, String comment)
 
void delete (IContact contact, String path)
 
IAcceptance getAcceptanceFor (String path, IContact petitioner, IContact contact)
 
String createPetition (String path, IContact contact, String link)
 
String createPetition (String path, IContact contact, String link, String template)
 

Detailed Description

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

Definition at line 39 of file Acceptances.java.

Member Function Documentation

◆ accept() [1/2]

IAcceptance org.turro.acceptance.Acceptances.accept ( IAcceptance  a)

Implements org.turro.action.IAcceptances.

Definition at line 143 of file Acceptances.java.

143  {
144  return accept(a.getIPetitioner(), a.getIContact(), a.getPath(), null);
145  }
IAcceptance accept(IAcceptance a)
Here is the call graph for this function:

◆ accept() [2/2]

IAcceptance org.turro.acceptance.Acceptances.accept ( IContact  petitioner,
IContact  contact,
String  path,
String  comment 
)

Implements org.turro.action.IAcceptances.

Definition at line 148 of file Acceptances.java.

148  {
149  Dao dao = getDao();
150  IAcceptance a = null;
151  try {
152  a = (IAcceptance) dao.getSingleResult(
153  "select a from Acceptance as a " +
154  "where a.contact = ? " +
155  "and a.petitioner = ? " +
156  "and a.path = ? " +
157  "and a.dateAcceptance is null",
158  new Object[] {
159  contact.getContact(), petitioner.getContact(), path
160  });
161  if(comment != null) {
162  a.setAcceptanceComment(a.getAcceptanceComment() + "\n" + comment);
163  }
164  a.setDateAcceptance(new Date());
165  a = dao.saveObject(a);
166  } catch(NoResultException ex) {
167  }
168  return a;
169  }
Here is the call graph for this function:

◆ createPetition() [1/2]

String org.turro.acceptance.Acceptances.createPetition ( String  path,
IContact  contact,
String  link 
)

Implements org.turro.action.IAcceptances.

Definition at line 224 of file Acceptances.java.

224  {
225  return createPetition(path, contact, link, null);
226  }
String createPetition(String path, IContact contact, String link)

◆ createPetition() [2/2]

String org.turro.acceptance.Acceptances.createPetition ( String  path,
IContact  contact,
String  link,
String  template 
)

Implements org.turro.action.IAcceptances.

Definition at line 229 of file Acceptances.java.

229  {
230  return PetitionCtrl.createPetition(path, contact, link, template);
231  }
Here is the call graph for this function:

◆ delete()

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

Implements org.turro.action.IAcceptances.

Definition at line 201 of file Acceptances.java.

201  {
202  getDao().executeUpdate(
203  "delete from Acceptance " +
204  "where contact = ? " +
205  "and path = ?",
206  new Object[] {
207  contact.getContact(), path
208  });
209  }
int executeUpdate(String query)
Definition: Dao.java:463

◆ getAcceptanceFor()

IAcceptance org.turro.acceptance.Acceptances.getAcceptanceFor ( String  path,
IContact  petitioner,
IContact  contact 
)

Implements org.turro.action.IAcceptances.

Definition at line 212 of file Acceptances.java.

212  {
213  return (IAcceptance) getDao().getSingleResultOrNull(
214  "select a from Acceptance as a " +
215  "where a.contact = ? " +
216  "and a.petitioner = ? " +
217  "and a.path = ?",
218  new Object[] {
219  contact.getContact(), petitioner.getContact(), path
220  });
221  }
Object getSingleResultOrNull(SqlClause sc)
Definition: Dao.java:419
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAcceptances()

List<IAcceptance> org.turro.acceptance.Acceptances.getAcceptances ( String  path)

Implements org.turro.action.IAcceptances.

Definition at line 111 of file Acceptances.java.

111  {
112  return getDao().getResultList(
113  "select a from Acceptance a " +
114  "where a.path = ?",
115  new Object[] {
116  path
117  });
118  }
Here is the caller graph for this function:

◆ getPendingAcceptances()

List<IAcceptance> org.turro.acceptance.Acceptances.getPendingAcceptances ( IContact  contact)

Implements org.turro.action.IAcceptances.

Definition at line 121 of file Acceptances.java.

121  {
122  return getDao().getResultList(
123  "select a from Acceptance as a " +
124  "where a.contact = ? " +
125  "and a.dateAcceptance is null",
126  new Object[] {
127  contact.getContact()
128  });
129  }
Here is the call graph for this function:

◆ getPendingRequests()

List<IAcceptance> org.turro.acceptance.Acceptances.getPendingRequests ( IContact  contact)

Implements org.turro.action.IAcceptances.

Definition at line 132 of file Acceptances.java.

132  {
133  return getDao().getResultList(
134  "select a from Acceptance as a " +
135  "where a.petitioner = ? " +
136  "and a.dateAcceptance is null",
137  new Object[] {
138  contact.getContact()
139  });
140  }
Here is the call graph for this function:

◆ getStatusFor() [1/3]

AcceptanceStatus org.turro.acceptance.Acceptances.getStatusFor ( String  path)

Implements org.turro.action.IAcceptances.

Definition at line 60 of file Acceptances.java.

60  {
61  return getStatusFor(path, null);
62  }
AcceptanceStatus getStatusFor(String path)

◆ getStatusFor() [2/3]

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

Implements org.turro.action.IAcceptances.

Definition at line 65 of file Acceptances.java.

65  {
66  List<IAcceptance> list = getAcceptances(path);
67  if(list.isEmpty()) {
68  return AcceptanceStatus.NONE_EXISTS;
69  }
70  boolean accepted = false, pending = false;
71  AcceptanceStatus selfStatus = null;
72  for(IAcceptance a : list) {
73  if(a.getDateAcceptance() != null) {
74  accepted = true;
75  if(contact != null && a.getIContact().getId().equals(contact.getId())) {
76  selfStatus = AcceptanceStatus.SELF_ACCEPTED;
77  }
78  } else {
79  pending = true;
80  if(contact != null && a.getIContact().getId().equals(contact.getId())) {
81  selfStatus = AcceptanceStatus.SELF_PENDING;
82  }
83  }
84  }
85  if(accepted) {
86  if(pending) {
87  return selfStatus == null ? AcceptanceStatus.SOME_PENDING : selfStatus;
88  } else {
89  return AcceptanceStatus.FULLY_ACCEPTED;
90  }
91  } else {
92  return selfStatus == null ? AcceptanceStatus.FULLY_PENDING : selfStatus;
93  }
94  }
List< IAcceptance > getAcceptances(String path)
Here is the call graph for this function:

◆ getStatusFor() [3/3]

AcceptanceSingleStatus org.turro.acceptance.Acceptances.getStatusFor ( String  path,
IContact  petitioner,
IContact  contact 
)

Implements org.turro.action.IAcceptances.

Definition at line 97 of file Acceptances.java.

97  {
98  IAcceptance acceptance = getAcceptanceFor(path, petitioner, contact);
99  if(acceptance != null) {
100  if(acceptance.getDateAcceptance() != null) {
101  return AcceptanceSingleStatus.SINGLE_ACCEPTED;
102  } else {
103  return AcceptanceSingleStatus.SINGLE_PENDING;
104  }
105  } else {
106  return AcceptanceSingleStatus.SINGLE_FORBIDDEN;
107  }
108  }
IAcceptance getAcceptanceFor(String path, IContact petitioner, IContact contact)
Here is the call graph for this function:

◆ isAccepted()

boolean org.turro.acceptance.Acceptances.isAccepted ( String  path)

Implements org.turro.action.IAcceptances.

Definition at line 42 of file Acceptances.java.

42  {
43  List<IAcceptance> list = getAcceptances(path);
44  if(list.isEmpty()) return false;
45  for(IAcceptance a : list) {
46  if(a.getDateAcceptance() == null) {
47  return false;
48  }
49  }
50  return true;
51  }
Here is the call graph for this function:

◆ isBlocked()

boolean org.turro.acceptance.Acceptances.isBlocked ( String  path)

Implements org.turro.action.IAcceptances.

Definition at line 54 of file Acceptances.java.

54  {
55  List<IAcceptance> list = getAcceptances(path);
56  return !list.isEmpty();
57  }
Here is the call graph for this function:

◆ request()

IAcceptance org.turro.acceptance.Acceptances.request ( IContact  petitioner,
IContact  contact,
String  path,
String  comment 
)

Implements org.turro.action.IAcceptances.

Definition at line 172 of file Acceptances.java.

172  {
173  Dao dao = getDao();
174  IAcceptance a = null;
175  try {
176  a = (IAcceptance) dao.getSingleResult(
177  "select a from Acceptance as a " +
178  "where a.contact = ? " +
179  "and a.petitioner = ? " +
180  "and a.path = ?",
181  new Object[] {
182  contact.getContact(), petitioner.getContact(), path
183  });
184  if(comment != null) {
185  a.setAcceptanceComment(a.getAcceptanceComment() + "\n" + comment);
186  }
187  a = dao.saveObject(a);
188  } catch(NoResultException ex) {
189  a = new Acceptance();
190  a.setAcceptanceComment(comment);
191  a.setIPetitioner(petitioner);
192  a.setIContact(contact);
193  a.setDateRequest(new Date());
194  a.setPath(path);
195  a = dao.saveObject(a);
196  }
197  return a;
198  }
Here is the call graph for this function:

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