BrightSide Workbench Full Report + Source Code
org.turro.contacts.social.SocialGroupVM Class Reference

Public Member Functions

 SocialGroupVM ()
 
void checkBusiness (@BindingParam("relation") SocialRelation relation)
 
void checkContact (@BindingParam("relation") SocialRelation relation)
 
SocialGroupValue getSocialGroup ()
 
void setSocialGroup (SocialGroupValue socialGroup)
 
boolean isActive ()
 
void setActive (boolean active)
 
boolean isStudents ()
 
void setStudents (boolean students)
 
Set< SocialGroupValuegetSocialGroupModel ()
 
void update ()
 
List< SocialRelationgetModel ()
 

Detailed Description

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

Definition at line 39 of file SocialGroupVM.java.

Constructor & Destructor Documentation

◆ SocialGroupVM()

org.turro.contacts.social.SocialGroupVM.SocialGroupVM ( )

Definition at line 44 of file SocialGroupVM.java.

44  {
45  }

Member Function Documentation

◆ checkBusiness()

void org.turro.contacts.social.SocialGroupVM.checkBusiness ( @BindingParam("relation") SocialRelation  relation)

Definition at line 49 of file SocialGroupVM.java.

49  {
50  IContact contact = relation.getBusiness().getIContact();
51  contact.syndicate(socialGroup.getKey(), !contact.getSyndications().contains(socialGroup.getKey()));
52  }
Here is the call graph for this function:

◆ checkContact()

void org.turro.contacts.social.SocialGroupVM.checkContact ( @BindingParam("relation") SocialRelation  relation)

Definition at line 56 of file SocialGroupVM.java.

56  {
57  IContact contact = relation.getContact().getIContact();
58  contact.syndicate(socialGroup.getKey(), !contact.getSyndications().contains(socialGroup.getKey()));
59  }
Here is the call graph for this function:

◆ getModel()

List<SocialRelation> org.turro.contacts.social.SocialGroupVM.getModel ( )

Definition at line 97 of file SocialGroupVM.java.

97  {
98  ArrayList<SocialRelation> list = new ArrayList<>();
99  if(socialGroup != null) {
100  WhereClause wc = new WhereClause();
101  wc.addClause("select br from BusinessRelation br");
102  wc.addClause("where br.validated = TRUE");
103  if(active) {
104  wc.addInRange("and", "br.startDate", "br.endDate", "date", new Date());
105  }
106 
107  wc.addClause("and ( exists (");
108  wc.addClause("select s from Syndication s");
109  wc.addClause("where s.name = :name");
110  wc.addClause("and s.contact = br.business");
111  wc.addClause(") and not exists (");
112  wc.addClause("select s from Syndication s");
113  wc.addClause("where s.name = :name");
114  wc.addClause("and s.contact = br.contact");
115  wc.addClause(")) or ( not exists (");
116  wc.addClause("select s from Syndication s");
117  wc.addClause("where s.name = :name");
118  wc.addClause("and s.contact = br.business");
119  wc.addClause(") and exists (");
120  wc.addClause("select s from Syndication s");
121  wc.addClause("where s.name = :name");
122  wc.addClause("and s.contact = br.contact");
123  wc.addClause("))");
124 
125  wc.addClause("and not exists (");
126  wc.addClause("select b2 from BusinessRelation b2");
127  wc.addClause("where b2.validated = TRUE");
128  wc.addInRange("and", "b2.startDate", "b2.endDate", "date", new Date());
129  wc.addClause("and b2.contact = br.contact");
130  wc.addClause("and b2.business <> br.business");
131  wc.addClause("and exists (");
132  wc.addClause("select s from Syndication s");
133  wc.addClause("where s.name = :name");
134  wc.addClause("and s.contact = b2.business");
135  wc.addClause("))");
136 
137  wc.addNamedValue("name", socialGroup.getKey());
138 
139  wc.addClause("order by br.business.name, br.contact.name");
140 
141  for(BusinessRelation br : new ContactsPU().getResultList(BusinessRelation.class, wc)) {
142  list.add(new SocialRelation(br.getBusiness(), br.getContact(), socialGroup.getKey()));
143  }
144  }
145  return list;
146  }
Here is the call graph for this function:

◆ getSocialGroup()

SocialGroupValue org.turro.contacts.social.SocialGroupVM.getSocialGroup ( )

Definition at line 61 of file SocialGroupVM.java.

61  {
62  return socialGroup;
63  }

◆ getSocialGroupModel()

Set<SocialGroupValue> org.turro.contacts.social.SocialGroupVM.getSocialGroupModel ( )

Definition at line 85 of file SocialGroupVM.java.

85  {
86  TreeSet<SocialGroupValue> set = new TreeSet<>();
87  SocialGroups.allowedSocialGroups().forEach(social -> {
88  set.add(new SocialGroupValue(social.getName(), social.getId(), social.getType()));
89  });
90  return set;
91  }
Here is the call graph for this function:

◆ isActive()

boolean org.turro.contacts.social.SocialGroupVM.isActive ( )

Definition at line 69 of file SocialGroupVM.java.

69  {
70  return active;
71  }

◆ isStudents()

boolean org.turro.contacts.social.SocialGroupVM.isStudents ( )

Definition at line 77 of file SocialGroupVM.java.

77  {
78  return students;
79  }

◆ setActive()

void org.turro.contacts.social.SocialGroupVM.setActive ( boolean  active)

Definition at line 73 of file SocialGroupVM.java.

73  {
74  this.active = active;
75  }

◆ setSocialGroup()

void org.turro.contacts.social.SocialGroupVM.setSocialGroup ( SocialGroupValue  socialGroup)

Definition at line 65 of file SocialGroupVM.java.

65  {
66  this.socialGroup = socialGroup;
67  }

◆ setStudents()

void org.turro.contacts.social.SocialGroupVM.setStudents ( boolean  students)

Definition at line 81 of file SocialGroupVM.java.

81  {
82  this.students = students;
83  }

◆ update()

void org.turro.contacts.social.SocialGroupVM.update ( )

Definition at line 95 of file SocialGroupVM.java.

95 {}

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