BrightSide Workbench Full Report + Source Code
org.turro.agreements.AgreementsUtil Class Reference

Public Member Functions

 AgreementsUtil (IContact contact)
 
 AgreementsUtil (String idContact)
 
IContact getContact ()
 
boolean isValid ()
 
boolean canNotify ()
 
boolean canAccess ()
 
boolean canAct (String action)
 
boolean declinedNotifications ()
 
boolean declinedAccessing ()
 
boolean declinedActing (String action)
 
List< AgreementSignaturegetPeremptories ()
 
List< AgreementSignaturegetSignatures (String action)
 
List< AgreementSignaturegetNotSigned ()
 
List< AgreementSignaturegetSigned ()
 
void sign (Agreement agreement, boolean agreed)
 
void sign (Long agreementId, boolean agreed)
 
void markAsSent (AgreementSignature as)
 

Static Public Member Functions

static List< AgreementgetAgreements ()
 
static boolean deleteAgreement (Agreement agreement)
 
static List< AgreementSignaturenotSigned (IContact contact)
 

Detailed Description

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

Definition at line 38 of file AgreementsUtil.java.

Constructor & Destructor Documentation

◆ AgreementsUtil() [1/2]

org.turro.agreements.AgreementsUtil.AgreementsUtil ( IContact  contact)

Definition at line 62 of file AgreementsUtil.java.

62  {
63  this.contact = contact;
64  }
Here is the caller graph for this function:

◆ AgreementsUtil() [2/2]

org.turro.agreements.AgreementsUtil.AgreementsUtil ( String  idContact)

Definition at line 66 of file AgreementsUtil.java.

66  {
67  this.contact = Contacts.getContactById(idContact);
68  }
Here is the call graph for this function:

Member Function Documentation

◆ canAccess()

boolean org.turro.agreements.AgreementsUtil.canAccess ( )

Definition at line 82 of file AgreementsUtil.java.

82  {
83  return getSignatures(null).stream().noneMatch((as) -> (as.getAgreement().isRequiredToAccess() && !as.doesAgree()));
84  }
List< AgreementSignature > getSignatures(String action)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ canAct()

boolean org.turro.agreements.AgreementsUtil.canAct ( String  action)

Definition at line 86 of file AgreementsUtil.java.

86  {
87  return getSignatures(action).stream().noneMatch((as) -> (as.getAgreement().isRequiredToAction() && action.equals(as.getAgreement().getAction()) && !as.doesAgree()));
88  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ canNotify()

boolean org.turro.agreements.AgreementsUtil.canNotify ( )

Definition at line 78 of file AgreementsUtil.java.

78  {
79  return getSignatures(null).stream().noneMatch((as) -> (as.getAgreement().isRequiredToNotify() && !as.doesAgree()));
80  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ declinedAccessing()

boolean org.turro.agreements.AgreementsUtil.declinedAccessing ( )

Definition at line 94 of file AgreementsUtil.java.

94  {
95  return getSignatures(null).stream().anyMatch((as) -> (as.getAgreement().isRequiredToAccess() && as.isSigned() && !as.isAgreed()));
96  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ declinedActing()

boolean org.turro.agreements.AgreementsUtil.declinedActing ( String  action)

Definition at line 98 of file AgreementsUtil.java.

98  {
99  return getSignatures(action).stream().anyMatch((as) -> (as.getAgreement().isRequiredToAction() && action.equals(as.getAgreement().getAction()) && as.isSigned() && !as.isAgreed()));
100  }
Here is the call graph for this function:

◆ declinedNotifications()

boolean org.turro.agreements.AgreementsUtil.declinedNotifications ( )

Definition at line 90 of file AgreementsUtil.java.

90  {
91  return getSignatures(null).stream().anyMatch((as) -> (as.getAgreement().isRequiredToNotify() && as.isSigned() && !as.isAgreed()));
92  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteAgreement()

static boolean org.turro.agreements.AgreementsUtil.deleteAgreement ( Agreement  agreement)
static

Definition at line 46 of file AgreementsUtil.java.

46  {
47  if(agreement != null && agreement.getSignatures().isEmpty()) {
48  new ElephantPU().deleteObject(agreement);
49  return true;
50  }
51  return false;
52  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAgreements()

static List<Agreement> org.turro.agreements.AgreementsUtil.getAgreements ( )
static

Definition at line 40 of file AgreementsUtil.java.

40  {
41  WhereClause wc = new WhereClause();
42  wc.addClause("select a from Agreement a");
43  return new ElephantPU().getResultList(wc);
44  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContact()

IContact org.turro.agreements.AgreementsUtil.getContact ( )

Definition at line 70 of file AgreementsUtil.java.

70  {
71  return contact;
72  }
Here is the caller graph for this function:

◆ getNotSigned()

List<AgreementSignature> org.turro.agreements.AgreementsUtil.getNotSigned ( )

Definition at line 127 of file AgreementsUtil.java.

127  {
128  return getSignatures(null).stream().filter((s) -> !s.isSigned()).collect(Collectors.toList());
129  }
Here is the call graph for this function:

◆ getPeremptories()

List<AgreementSignature> org.turro.agreements.AgreementsUtil.getPeremptories ( )

Definition at line 102 of file AgreementsUtil.java.

102  {
103  return getSignatures(null).stream().filter((s) -> s.getAgreement().isPeremptory()).collect(Collectors.toList());
104  }
Here is the call graph for this function:

◆ getSignatures()

List<AgreementSignature> org.turro.agreements.AgreementsUtil.getSignatures ( String  action)

Definition at line 106 of file AgreementsUtil.java.

106  {
107  if(signatures == null) {
108  signatures = new ArrayList<>();
109  if(Contacts.isValid(contact)) {
110  signatures.addAll(getAgreementSignatures());
111  notCreated(action).stream().map((a) -> {
112  AgreementSignature as = new AgreementSignature();
113  as.setIdContact(contact.getId());
114  as.setAgreement(a);
115  as.setAgreed(false);
116  as.setSentCount(0);
117  as.setSignedDate(null);
118  return getDao().saveObject(as);
119  }).forEachOrdered((as) -> {
120  signatures.add(as);
121  });
122  }
123  }
124  return signatures;
125  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSigned()

List<AgreementSignature> org.turro.agreements.AgreementsUtil.getSigned ( )

Definition at line 131 of file AgreementsUtil.java.

131  {
132  return getSignatures(null).stream().filter((s) -> s.isSigned()).collect(Collectors.toList());
133  }
Here is the call graph for this function:

◆ isValid()

boolean org.turro.agreements.AgreementsUtil.isValid ( )

Definition at line 74 of file AgreementsUtil.java.

74  {
75  return Contacts.isValid(contact);
76  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ markAsSent()

void org.turro.agreements.AgreementsUtil.markAsSent ( AgreementSignature  as)

Definition at line 162 of file AgreementsUtil.java.

162  {
163  if(as.getId() != null) {
164  WhereClause wc = new WhereClause();
165  wc.addClause("update AgreementSignature");
166  wc.addClause("set sentCount = sentCount + 1");
167  wc.addClause("where agreement = :agreement");
168  wc.addNamedValue("agreement", as.getAgreement());
169  wc.addClause("and idContact = :contact");
170  wc.addNamedValue("contact", as.getIdContact());
171  getDao().executeUpdate(wc);
172  } else {
173  as.setSentCount(1);
174  getDao().saveObject(as);
175  }
176  }
int executeUpdate(String query)
Definition: Dao.java:463
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notSigned()

static List<AgreementSignature> org.turro.agreements.AgreementsUtil.notSigned ( IContact  contact)
static

Definition at line 54 of file AgreementsUtil.java.

54  {
55  return new AgreementsUtil(contact).getNotSigned();
56  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sign() [1/2]

void org.turro.agreements.AgreementsUtil.sign ( Agreement  agreement,
boolean  agreed 
)

Definition at line 135 of file AgreementsUtil.java.

135  {
136  if(agreement != null) {
137  WhereClause wc = new WhereClause();
138  wc.addClause("select asig from AgreementSignature asig");
139  wc.addClause("where asig.agreement = :agreement");
140  wc.addNamedValue("agreement", agreement);
141  wc.addClause("and asig.idContact = :contact");
142  wc.addNamedValue("contact", contact.getId());
143  AgreementSignature as = (AgreementSignature) getDao().getSingleResultOrNull(wc);
144  if(as == null) {
145  as = new AgreementSignature();
146  as.setIdContact(contact.getId());
147  as.setAgreement(agreement);
148  as.setSentCount(0);
149  }
150  if(!as.doesAgree()) {
151  as.setAgreed(agreed);
152  as.setSignedDate(new Date());
153  getDao().saveObject(as);
154  }
155  }
156  }
Object getSingleResultOrNull(SqlClause sc)
Definition: Dao.java:419
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sign() [2/2]

void org.turro.agreements.AgreementsUtil.sign ( Long  agreementId,
boolean  agreed 
)

Definition at line 158 of file AgreementsUtil.java.

158  {
159  sign(getDao().find(Agreement.class, agreementId), agreed);
160  }
void sign(Agreement agreement, boolean agreed)
Here is the call graph for this function:

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