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

Public Member Functions

void removeSocials (Contact contact, Set< String > socialGroupIds)
 
void synchronizeSocials (Contact contact, Set< String > socialGroupIds)
 
void synchronizeTags (Contact contact, Set< String > tags)
 
Set< String > flatSocialGroups (Contact contact, Set< String > socials)
 
Set< String > flatRoles (Set< Syndication > syndications)
 
Set< String > flatTags (Set< Syndication > syndications)
 
void checkInheritance (Contact contact, Dao dao)
 
Contact checkCompanyInheritance (Contact contact, Dao dao)
 
List< String > getInheritedFrom (Contact contact)
 
- Public Member Functions inherited from org.turro.security.SecurityGroups
SecurityGroup getSocialGroup (String id)
 

Static Public Member Functions

static Collection< SecurityGroupallowedSocialGroups ()
 
static Collection< SecurityGroupallowedSocialGroups (IContact contact)
 
static void syndicate (List< Contact > contacts, Set< String > socialGroupIds, Dao dao)
 
static void unsyndicate (List< Contact > contacts, Set< String > socialGroupIds, Dao dao)
 
static void absoluteSyndicate (List< Contact > contacts, Set< String > socialGroupIds, Dao dao)
 
static void resyndicate (List< Contact > contacts, Dao dao)
 
static void checkInheritance (List< Contact > contacts, Dao dao)
 
static SocialGroups instance ()
 
- Static Public Member Functions inherited from org.turro.security.SecurityGroups
static SecurityGroup get (String id)
 
static Collection< SecurityGroupgetAll ()
 
static void reset ()
 

Additional Inherited Members

- Protected Member Functions inherited from org.turro.security.SecurityGroups
void recurseSocialGroups (Set< String > flatSocials, SecurityGroup sg)
 
boolean possibleTag (String tag)
 
 SecurityGroups ()
 
- Protected Attributes inherited from org.turro.security.SecurityGroups
final Map< String, SecurityGroupsocialGroups
 

Detailed Description

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

Definition at line 40 of file SocialGroups.java.

Member Function Documentation

◆ absoluteSyndicate()

static void org.turro.security.SocialGroups.absoluteSyndicate ( List< Contact contacts,
Set< String >  socialGroupIds,
Dao  dao 
)
static

Definition at line 80 of file SocialGroups.java.

80  {
81  SocialGroups socials = instance();
82  contacts.forEach(contact -> {
83  socials.synchronizeSocials(contact, socials.flatSocialGroups(null, socialGroupIds));
84  if(dao != null) {
85  dao.saveObject(contact);
86  }
87  });
88  }
static SocialGroups instance()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ allowedSocialGroups() [1/2]

static Collection<SecurityGroup> org.turro.security.SocialGroups.allowedSocialGroups ( )
static

Definition at line 42 of file SocialGroups.java.

42  {
43  return SocialGroups.allowedSocialGroups(Authentication.getIContact());
44  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ allowedSocialGroups() [2/2]

static Collection<SecurityGroup> org.turro.security.SocialGroups.allowedSocialGroups ( IContact  contact)
static

Definition at line 46 of file SocialGroups.java.

46  {
47  SocialGroups instance = instance();
48  if(contact.isAdmin()) {
49  return instance.socialGroups.values();
50  } else {
51  Set<SecurityGroup> socials = new HashSet<>();
52  contact.getSyndications().forEach(syndication -> {
53  socials.addAll(instance.socialGroups.get(syndication).getAllowed().stream()
54  .map(asg -> instance.socialGroups.get(asg.getId())).collect(Collectors.toList()));
55  });
56  return socials;
57  }
58  }
final Map< String, SecurityGroup > socialGroups
Here is the call graph for this function:

◆ checkCompanyInheritance()

Contact org.turro.security.SocialGroups.checkCompanyInheritance ( Contact  contact,
Dao  dao 
)

Definition at line 185 of file SocialGroups.java.

185  {
186  final Contact current = dao.find(Contact.class, contact.getId());
187  if(current != null) {
188  List<String> inheritance = getInheritedFrom(current);
189  // Delete dynamically assigned
190  SqlClause.delete("Syndication")
191  .where().notIn("name", inheritance)
192  .and().equal("dynamic", true)
193  .and().equal("contact", current)
194  .dao(dao)
195  .execute();
196  // Dynamize existing
197  SqlClause.update("Syndication")
198  .set("dynamic", true)
199  .where().in("name", inheritance)
200  .and().equal("contact", current)
201  .dao(dao)
202  .execute();
203  // Add missing
204  List<String> currentNames = SqlClause.select("s.name").from("Syndication s")
205  .where().equal("contact", current)
206  .dao(dao)
207  .resultList(String.class);
208  inheritance.stream().filter(name -> !currentNames.contains(name))
209  .forEach(name -> {
210  Syndication syndication = new Syndication();
211  syndication.setContact(current);
212  syndication.setName(name);
213  syndication.setDynamic(true);
214  dao.saveObject(syndication);
215  });
216  return dao.find(Contact.class, current.getId());
217  } else {
218  return contact;
219  }
220 
221  }
List< String > getInheritedFrom(Contact contact)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkInheritance() [1/2]

void org.turro.security.SocialGroups.checkInheritance ( Contact  contact,
Dao  dao 
)

Definition at line 175 of file SocialGroups.java.

175  {
176  if(ContactType.juridicals().contains(contact.getType())) {
177  contact.getWorkerSet().getWorkers().forEach(staff -> {
178  checkCompanyInheritance(staff, dao);
179  });
180  } else {
181  checkCompanyInheritance(contact, dao);
182  }
183  }
Contact checkCompanyInheritance(Contact contact, Dao dao)
Here is the call graph for this function:

◆ checkInheritance() [2/2]

static void org.turro.security.SocialGroups.checkInheritance ( List< Contact contacts,
Dao  dao 
)
static

Definition at line 103 of file SocialGroups.java.

103  {
104  SocialGroups socials = instance();
105  contacts.forEach(contact -> {
106  socials.checkInheritance(contact, dao);
107  });
108  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flatRoles()

Set<String> org.turro.security.SocialGroups.flatRoles ( Set< Syndication syndications)

Definition at line 152 of file SocialGroups.java.

152  {
153  Set<String> flatRoles = new HashSet<>();
154  syndications.forEach(syndication -> {
155  SecurityGroup sg = socialGroups.get(syndication.getName());
156  if(sg != null) {
157  flatRoles.addAll(sg.getRoles());
158  }
159  });
160  return flatRoles;
161  }
Set< String > flatRoles(Set< Syndication > syndications)

◆ flatSocialGroups()

Set<String> org.turro.security.SocialGroups.flatSocialGroups ( Contact  contact,
Set< String >  socials 
)

Definition at line 140 of file SocialGroups.java.

140  {
141  Set<String> flatSocials = new HashSet<>();
142  if(contact != null) {
143  flatSocials.addAll(contact.getSyndications().stream()
144  .map(syndication -> syndication.getName()).collect(Collectors.toSet()));
145  }
146  socials.forEach(social -> {
147  recurseSocialGroups(flatSocials, socialGroups.get(social));
148  });
149  return flatSocials;
150  }
void recurseSocialGroups(Set< String > flatSocials, SecurityGroup sg)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flatTags()

Set<String> org.turro.security.SocialGroups.flatTags ( Set< Syndication syndications)

Definition at line 164 of file SocialGroups.java.

164  {
165  Set<String> flatTags = new HashSet<>();
166  syndications.forEach(syndication -> {
167  SecurityGroup sg = socialGroups.get(syndication.getName());
168  if(sg != null) {
169  flatTags.addAll(sg.getTags());
170  }
171  });
172  return flatTags;
173  }
Set< String > flatTags(Set< Syndication > syndications)

◆ getInheritedFrom()

List<String> org.turro.security.SocialGroups.getInheritedFrom ( Contact  contact)

Definition at line 223 of file SocialGroups.java.

223  {
224  List<String> inheritance = new ArrayList<>();
225  if(contact != null) {
226  contact.getBusinessSet().getBusinessList().forEach(business -> {
227  inheritance.addAll(business.getSyndications().stream()
228  .filter(syndication -> syndication.getSocialGroup().isInherits())
229  .map(syndication -> syndication.getName())
230  .toList());
231  });
232  }
233  return inheritance;
234  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ instance()

static SocialGroups org.turro.security.SocialGroups.instance ( )
static

Reimplemented from org.turro.security.SecurityGroups.

Definition at line 237 of file SocialGroups.java.

237  {
238  return new SocialGroups();
239  }
Here is the caller graph for this function:

◆ removeSocials()

void org.turro.security.SocialGroups.removeSocials ( Contact  contact,
Set< String >  socialGroupIds 
)

Definition at line 112 of file SocialGroups.java.

112  {
113  contact.getSyndications().removeIf(syndication -> socialGroupIds.contains(syndication.getName()));
114  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resyndicate()

static void org.turro.security.SocialGroups.resyndicate ( List< Contact contacts,
Dao  dao 
)
static

Definition at line 90 of file SocialGroups.java.

90  {
91  SocialGroups socials = instance();
92  Set<String> socialGroupIds = new HashSet<>();
93  contacts.forEach(contact -> {
94  socials.synchronizeSocials(contact, socials.flatSocialGroups(contact, socialGroupIds));
95  if(dao != null) {
96  dao.saveObject(contact);
97  }
98  });
99  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ synchronizeSocials()

void org.turro.security.SocialGroups.synchronizeSocials ( Contact  contact,
Set< String >  socialGroupIds 
)

Definition at line 116 of file SocialGroups.java.

116  {
117  contact.getSyndications().removeIf(syndication -> !socialGroupIds.contains(syndication.getName()));
118  Set<String> syndicationNames = contact.getSyndications().stream()
119  .map(syndication -> syndication.getName()).collect(Collectors.toSet());
120  socialGroupIds.stream().filter(social -> !syndicationNames.contains(social)).forEach(social -> {
121  Syndication syndication = new Syndication();
122  syndication.setContact(contact);
123  syndication.setName(social);
124  contact.getSyndications().add(syndication);
125  });
126  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ synchronizeTags()

void org.turro.security.SocialGroups.synchronizeTags ( Contact  contact,
Set< String >  tags 
)

Definition at line 129 of file SocialGroups.java.

129  {
130  Set<String> currentTags = Tags.getTags(contact).stream()
131  .map(tag -> tag.getTagName()).collect(Collectors.toSet());
132  currentTags.stream().filter(tag -> !tags.contains(tag) && possibleTag(tag)).forEach(tag -> {
133  Tags.removeTag(contact, tag);
134  });
135  tags.stream().filter(tag -> !currentTags.contains(tag)).forEach(tag -> {
136  Tags.addTag(contact, tag);
137  });
138  }
Here is the call graph for this function:

◆ syndicate()

static void org.turro.security.SocialGroups.syndicate ( List< Contact contacts,
Set< String >  socialGroupIds,
Dao  dao 
)
static

Definition at line 60 of file SocialGroups.java.

60  {
61  SocialGroups socials = instance();
62  contacts.forEach(contact -> {
63  socials.synchronizeSocials(contact, socials.flatSocialGroups(contact, socialGroupIds));
64  if(dao != null) {
65  dao.saveObject(contact);
66  }
67  });
68  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unsyndicate()

static void org.turro.security.SocialGroups.unsyndicate ( List< Contact contacts,
Set< String >  socialGroupIds,
Dao  dao 
)
static

Definition at line 70 of file SocialGroups.java.

70  {
71  SocialGroups socials = instance();
72  contacts.forEach(contact -> {
73  socials.removeSocials(contact, socials.flatSocialGroups(null, socialGroupIds));
74  if(dao != null) {
75  dao.saveObject(contact);
76  }
77  });
78  }
Here is the call graph for this function:
Here is the caller graph for this function:

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