BrightSide Workbench Full Report + Source Code
org.turro.contacts.model.ContactsVM Class Reference

Public Member Functions

 ContactsVM ()
 
void sec (@BindingParam("selected") Set< SecItem > selected)
 
void tag (@BindingParam("selected") Set< TagItem > selected)
 
void skill (@BindingParam("selected") Set< SkillItem > selected)
 
void edit (@BindingParam("item") ContactItem item)
 
void organigram (@BindingParam("item") ContactItem item)
 
void vcard (@BindingParam("item") ContactItem item)
 
void qrcode (@BindingParam("item") ContactItem item)
 
void participations (@BindingParam("item") ContactItem item)
 
void subscriptions (@BindingParam("item") ContactItem item)
 
void delete (@BindingParam("item") ContactItem item, @BindingParam("ctrl") Component ctrl)
 
void select (@BindingParam("item") IElephantEntity item)
 
void add ()
 
void selectall ()
 
void deselectall ()
 
void togglesel ()
 
void export ()
 
void copy ()
 
void copyrel ()
 
void addtosc ()
 
void delfromsc ()
 
void resyndicate ()
 
void settype ()
 
void activate ()
 
void deactivate ()
 
void update ()
 
Set< DirectoryTypegetTypeSet ()
 
void setTypeSet (Set< DirectoryType > typeSet)
 
String getSearchValue ()
 
void setSearchValue (String searchValue)
 
boolean isUseConnector ()
 
void setUseConnector (boolean useConnector)
 
boolean isUseAddress ()
 
void setUseAddress (boolean useAddress)
 
boolean isUseComment ()
 
void setUseComment (boolean useComment)
 
ContactModel getModel ()
 
ListModel getTypeModel ()
 

Detailed Description

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

Definition at line 75 of file ContactsVM.java.

Constructor & Destructor Documentation

◆ ContactsVM()

org.turro.contacts.model.ContactsVM.ContactsVM ( )

Definition at line 89 of file ContactsVM.java.

89  {
90  this.search = new ModelSearch();
91  this.typeSet = new HashSet<>(EnumSet.allOf(DirectoryType.class));
92  this.secSet = new HashSet<>();
93  this.tagSet = new HashSet<>();
94  this.skillSet = new HashSet<>();
95  this.allContacts = Application.getApplication().isInRole("contact:all");
96 
97  // Migration
98  Secs.removeSyndication(getDao(), "directory");
99  Tags.removeTags("contact", List.of("directory"));
100  Tags.removeTags("contact", List.of("student"));
101  Tags.removeTags("contact", SecurityGroups.getAll().stream()
102  .map(sg -> sg.getTags()).flatMap(Set::stream).collect(Collectors.toList()));
103  }
Here is the call graph for this function:

Member Function Documentation

◆ activate()

void org.turro.contacts.model.ContactsVM.activate ( )

Definition at line 328 of file ContactsVM.java.

328  {
329  if(model != null && !model.getSelected().isEmpty()) {
330  List<Contact> contacts = model.getSelected().stream().map(ci -> ci.getContact())
331  .collect(Collectors.toList());
332  contacts.forEach(contact -> contact.setDeactivated(false));
333  getDao().saveCollection(contacts);
334  BindUtils.postNotifyChange(null, null, ContactsVM.this, "model");
335  }
336  }
void saveCollection(Collection objs)
Definition: Dao.java:144
Here is the call graph for this function:

◆ add()

void org.turro.contacts.model.ContactsVM.add ( )

Definition at line 176 of file ContactsVM.java.

176  {
177  ContactMenu.showContact((String) null);
178  }
Here is the call graph for this function:

◆ addtosc()

void org.turro.contacts.model.ContactsVM.addtosc ( )

Definition at line 226 of file ContactsVM.java.

226  {
227  if(model != null && !model.getSelected().isEmpty()) {
228  Dialogs.title(I_.get("Add to social group"))
229  .width("400px")
230  .height("500px")
231  .addField(DialogField.field("Social group").onEditor(() -> {
232  SocialGroupListbox sglb = new SocialGroupListbox();
233  sglb.setMultiple(true);
234  sglb.setCheckmark(true);
235  sglb.setRows(11);
236  sglb.loadSocialGroups(true);
237  return sglb;
238  }))
239  .onOk((dialogs) -> {
240  Collection<SocialGroupValue> sgs = dialogs.<SocialGroupListbox>getEditor("Social group").getObjectValues();
241  if(!sgs.isEmpty()) {
242  List<Contact> selection = model.getSelected().stream().map(ci -> ci.getContact()).collect(Collectors.toList());
243  SocialGroups.syndicate(
244  selection,
245  sgs.stream().map(sgv -> sgv.getKey()).collect(Collectors.toSet()),
246  getDao());
247  SocialGroups.checkInheritance(selection, getDao());
248  BindUtils.postNotifyChange(null, null, ContactsVM.this, "model");
249  }
250  })
251  .emptyCancel()
252  .show();
253  }
254  }
Here is the call graph for this function:

◆ copy()

void org.turro.contacts.model.ContactsVM.copy ( )

Definition at line 216 of file ContactsVM.java.

216  {
217  Framework.getClipboard().put("bbf_clip_contact", contactsFromModel());
218  }
Here is the call graph for this function:

◆ copyrel()

void org.turro.contacts.model.ContactsVM.copyrel ( )

Definition at line 221 of file ContactsVM.java.

221  {
222  Framework.getClipboard().put("bbf_clip_contact", relationsFromModel());
223  }
Here is the call graph for this function:

◆ deactivate()

void org.turro.contacts.model.ContactsVM.deactivate ( )

Definition at line 339 of file ContactsVM.java.

339  {
340  if(model != null && !model.getSelected().isEmpty()) {
341  List<Contact> contacts = model.getSelected().stream().map(ci -> ci.getContact())
342  .collect(Collectors.toList());
343  contacts.forEach(contact -> contact.setDeactivated(true));
344  getDao().saveCollection(contacts);
345  BindUtils.postNotifyChange(null, null, ContactsVM.this, "model");
346  }
347  }
Here is the call graph for this function:

◆ delete()

void org.turro.contacts.model.ContactsVM.delete ( @BindingParam("item") ContactItem  item,
@BindingParam("ctrl") Component  ctrl 
)

Definition at line 154 of file ContactsVM.java.

154  {
155  ElephantMenu.showEntityModal(item.getContact().getId(), "contactId", "/contact/delContact.zul", new org.turro.command.Command() {
156  @Override
157  public Object execute(Context context) {
158  ModalWindow mw = (ModalWindow) context.get("win");
159  if(mw.getResult() == 1) {
160  new ContactWrapper(item.getContact()).delete();
161  Row row = Components.from(ctrl).parent(Row.class);
162  if(row != null) row.detach();
163  }
164  return true;
165  }
166  });
167  }
Here is the call graph for this function:

◆ delfromsc()

void org.turro.contacts.model.ContactsVM.delfromsc ( )

Definition at line 257 of file ContactsVM.java.

257  {
258  if(model != null && !model.getSelected().isEmpty()) {
259  Dialogs.title(I_.get("Remove from social group"))
260  .width("400px")
261  .height("500px")
262  .addField(DialogField.field("Social group").onEditor(() -> {
263  SocialGroupListbox sglb = new SocialGroupListbox();
264  sglb.setMultiple(true);
265  sglb.setCheckmark(true);
266  sglb.setRows(11);
267  sglb.loadSocialGroups(true);
268  return sglb;
269  }))
270  .onOk((dialogs) -> {
271  Collection<SocialGroupValue> sgs = dialogs.<SocialGroupListbox>getEditor("Social group").getObjectValues();
272  if(!sgs.isEmpty()) {
273  List<Contact> selection = model.getSelected().stream().map(ci -> ci.getContact()).collect(Collectors.toList());
274  SocialGroups.unsyndicate(
275  selection,
276  sgs.stream().map(sgv -> sgv.getKey()).collect(Collectors.toSet()),
277  getDao());
278  SocialGroups.checkInheritance(selection, getDao());
279  BindUtils.postNotifyChange(null, null, ContactsVM.this, "model");
280  }
281  })
282  .emptyCancel()
283  .show();
284  }
285  }
Here is the call graph for this function:

◆ deselectall()

void org.turro.contacts.model.ContactsVM.deselectall ( )

Definition at line 191 of file ContactsVM.java.

191  {
192  if(model != null) {
193  model.deselectAll();
194  doNotLoad = true;
195  }
196  }
Here is the call graph for this function:

◆ edit()

void org.turro.contacts.model.ContactsVM.edit ( @BindingParam("item") ContactItem  item)

Definition at line 124 of file ContactsVM.java.

124  {
125  ContactMenu.showContact(item.getContact().getId());
126  }
Here is the call graph for this function:

◆ export()

void org.turro.contacts.model.ContactsVM.export ( )

Definition at line 208 of file ContactsVM.java.

208  {
209  Button export = (Button) Plugins.loadImplementation(IPlugin.class, "vcard");
210  if(export != null) {
211  ((IPlugin) export).setData("export", contactsFromModel());
212  }
213  }
Here is the call graph for this function:

◆ getModel()

ContactModel org.turro.contacts.model.ContactsVM.getModel ( )

Definition at line 393 of file ContactsVM.java.

393  {
394  if(doNotLoad) {
395  doNotLoad = false;
396  return model;
397  }
398  model = null;
399  if(selected != null) {
400  model = new ContactModel(getDao(), selected);
401  selected = null;
402  } else {
403  if(typeSet.isEmpty()) return new ContactModel(getDao(), Collections.EMPTY_LIST);
404  WhereClause wc = new WhereClause();
405  wc.addClause("select distinct contact.id from Contact contact");
406  wc.addClause("left outer join contact.businessRelations relation");
407  wc.addClause("left outer join contact.connectors connector");
408  wc.addClause("left outer join contact.addresses address");
409  wc.addClause("left outer join contact.syndications syndication");
410  wc.addClause("left outer join contact.comments comment");
411  search.apply("where", searchValue, wc, secSet.isEmpty() && tagSet.isEmpty() && skillSet.isEmpty());
412  if(!typeSet.equals(EnumSet.allOf(DirectoryType.class))) {
413  wc.addClause("and (");
414  String sep = "";
415  if(typeSet.contains(DirectoryType.DIRECTORY_COMPANIES)) {
416  wc.addClause(sep + "contact.type = :typeb");
417  wc.addNamedValue("typeb", ContactType.CONTACT_COMPANY);
418  sep = "or ";
419  }
420  if(typeSet.contains(DirectoryType.DIRECTORY_CENTERS)) {
421  wc.addClause(sep + "contact.type = :typec");
422  wc.addNamedValue("typec", ContactType.CONTACT_LEARNINGCENTER);
423  sep = "or ";
424  }
425  if(typeSet.contains(DirectoryType.DIRECTORY_PROFESSIONALS)) {
426  FuzzyRelationTypes.isProfessional(wc, sep, "relation");
427  sep = "or ";
428  }
429  if(typeSet.contains(DirectoryType.DIRECTORY_EDUCATORS)) {
430  FuzzyRelationTypes.isEducator(wc, sep, "relation");
431  sep = "or ";
432  }
433  if(typeSet.contains(DirectoryType.DIRECTORY_STUDENTS)) {
434  FuzzyRelationTypes.isStudent(wc, sep, "relation");
435  sep = "or ";
436  }
437  if(typeSet.contains(DirectoryType.DIRECTORY_SINGLETONS)) {
438  FuzzyRelationTypes.isSingleton(wc, sep, "contact", "relation");
439  sep = "or ";
440  }
441  wc.addClause(")");
442  }
443  if(secSet != null && !secSet.isEmpty()) {
444  List<String> ids = Secs.getIdentifiers(getDao(), secSet);
445  if(ids == null || ids.isEmpty()) {
446  wc.addClause("and 1=2");
447  } else {
448  wc.addIn("and", "contact.id", ids);
449  }
450  }
451  if(tagSet != null && !tagSet.isEmpty()) {
452  List<String> ids = Tags.getIdentifiers("contact", tagSet);
453  if(ids == null || ids.isEmpty()) {
454  wc.addClause("and 1=2");
455  } else {
456  wc.addIn("and", "contact.id", ids);
457  }
458  }
459  if(skillSet != null && !skillSet.isEmpty()) {
460  List<String> ids = SkillTags.getIdentifiers("contact", skillSet);
461  if(ids == null || ids.isEmpty()) {
462  wc.addClause("and 1=2");
463  } else {
464  wc.addIn("and", "contact.id", ids);
465  }
466  }
467  if(!allContacts) {
468  wc.addIn("and", "syndication.name",
469  SocialGroups.allowedSocialGroups().stream().map(sg -> sg.getId()).collect(Collectors.toList()));
470  }
471  wc.addClause("order by contact.name");
472  model = new ContactModel(getDao(), getDao().getResultList(wc));
473  }
474  return model;
475  }
void apply(String operator, String value, WhereClause wc, boolean stopIfEmpty)
Here is the call graph for this function:

◆ getSearchValue()

String org.turro.contacts.model.ContactsVM.getSearchValue ( )

Definition at line 361 of file ContactsVM.java.

361  {
362  return searchValue;
363  }

◆ getTypeModel()

ListModel org.turro.contacts.model.ContactsVM.getTypeModel ( )

Definition at line 477 of file ContactsVM.java.

477  {
478  return new ListModelSet(DirectoryType.values());
479  }

◆ getTypeSet()

Set<DirectoryType> org.turro.contacts.model.ContactsVM.getTypeSet ( )

Definition at line 353 of file ContactsVM.java.

353  {
354  return typeSet;
355  }

◆ isUseAddress()

boolean org.turro.contacts.model.ContactsVM.isUseAddress ( )

Definition at line 377 of file ContactsVM.java.

377  {
378  return search.isUseAddress();
379  }
Here is the call graph for this function:

◆ isUseComment()

boolean org.turro.contacts.model.ContactsVM.isUseComment ( )

Definition at line 385 of file ContactsVM.java.

385  {
386  return search.isUseComment();
387  }
Here is the call graph for this function:

◆ isUseConnector()

boolean org.turro.contacts.model.ContactsVM.isUseConnector ( )

Definition at line 369 of file ContactsVM.java.

369  {
370  return search.isUseConnector();
371  }
Here is the call graph for this function:

◆ organigram()

void org.turro.contacts.model.ContactsVM.organigram ( @BindingParam("item") ContactItem  item)

Definition at line 129 of file ContactsVM.java.

129  {
130  ContactMenu.showOrganigram(item.getContact());
131  }
Here is the call graph for this function:

◆ participations()

void org.turro.contacts.model.ContactsVM.participations ( @BindingParam("item") ContactItem  item)

Definition at line 144 of file ContactsVM.java.

144  {
145  ContactMenu.showParticipations(ContactsPU.getObjectPath(item.getContact()));
146  }
Here is the call graph for this function:

◆ qrcode()

void org.turro.contacts.model.ContactsVM.qrcode ( @BindingParam("item") ContactItem  item)

Definition at line 139 of file ContactsVM.java.

139  {
140  ElephantMenu.showEntityModal(item.getContact().getId(), "contactId", "/contact/qrcode.zul", null);
141  }
Here is the call graph for this function:

◆ resyndicate()

void org.turro.contacts.model.ContactsVM.resyndicate ( )

Definition at line 288 of file ContactsVM.java.

288  {
289  if(model != null && !model.getSelected().isEmpty()) {
290  List<Contact> selection = model.getSelected().stream().map(ci -> ci.getContact()).collect(Collectors.toList());
291  SocialGroups.resyndicate(
292  selection,
293  getDao());
294  SocialGroups.checkInheritance(selection, getDao());
295  BindUtils.postNotifyChange(null, null, ContactsVM.this, "model");
296  }
297  }
Here is the call graph for this function:

◆ sec()

void org.turro.contacts.model.ContactsVM.sec ( @BindingParam("selected") Set< SecItem selected)

Definition at line 107 of file ContactsVM.java.

107  {
108  secSet = new HashSet<>(selected);
109  }

◆ select()

void org.turro.contacts.model.ContactsVM.select ( @BindingParam("item") IElephantEntity  item)

Definition at line 171 of file ContactsVM.java.

171  {
172  selected = new ContactItem(getDao(), item.getStringId(), true);
173  }
Here is the call graph for this function:

◆ selectall()

void org.turro.contacts.model.ContactsVM.selectall ( )

Definition at line 182 of file ContactsVM.java.

182  {
183  if(model != null) {
184  model.selectAll();
185  doNotLoad = true;
186  }
187  }
Here is the call graph for this function:

◆ setSearchValue()

void org.turro.contacts.model.ContactsVM.setSearchValue ( String  searchValue)

Definition at line 365 of file ContactsVM.java.

365  {
366  this.searchValue = searchValue;
367  }

◆ settype()

void org.turro.contacts.model.ContactsVM.settype ( )

Definition at line 300 of file ContactsVM.java.

300  {
301  if(model != null && !model.getSelected().isEmpty()) {
302  Dialogs.title(I_.get("Set type"))
303  .width("400px")
304  .height("300px")
305  .addField(DialogField.field("Type").onEditor(() -> {
306  ContactTypeListbox ctl = new ContactTypeListbox();
307  ctl.setSelectFirst(false);
308  ctl.setCheckmark(true);
309  ctl.setRows(4);
310  return ctl;
311  }))
312  .onOk((dialogs) -> {
313  ContactType type = dialogs.<ContactTypeListbox>getEditor("Type").getObjectValue();
314  if(type != null) {
315  List<Contact> contacts = model.getSelected().stream().map(ci -> ci.getContact())
316  .collect(Collectors.toList());
317  contacts.forEach(contact -> contact.setType(type));
318  getDao().saveCollection(contacts);
319  BindUtils.postNotifyChange(null, null, ContactsVM.this, "model");
320  }
321  })
322  .emptyCancel()
323  .show();
324  }
325  }
Here is the call graph for this function:

◆ setTypeSet()

void org.turro.contacts.model.ContactsVM.setTypeSet ( Set< DirectoryType typeSet)

Definition at line 357 of file ContactsVM.java.

357  {
358  this.typeSet = typeSet;
359  }

◆ setUseAddress()

void org.turro.contacts.model.ContactsVM.setUseAddress ( boolean  useAddress)

Definition at line 381 of file ContactsVM.java.

381  {
382  search.setUseAddress(useAddress);
383  }
void setUseAddress(boolean useAddress)
Here is the call graph for this function:

◆ setUseComment()

void org.turro.contacts.model.ContactsVM.setUseComment ( boolean  useComment)

Definition at line 389 of file ContactsVM.java.

389  {
390  search.setUseComment(useComment);
391  }
void setUseComment(boolean useComment)
Here is the call graph for this function:

◆ setUseConnector()

void org.turro.contacts.model.ContactsVM.setUseConnector ( boolean  useConnector)

Definition at line 373 of file ContactsVM.java.

373  {
374  search.setUseConnector(useConnector);
375  }
void setUseConnector(boolean useConnector)
Here is the call graph for this function:

◆ skill()

void org.turro.contacts.model.ContactsVM.skill ( @BindingParam("selected") Set< SkillItem selected)

Definition at line 119 of file ContactsVM.java.

119  {
120  skillSet = new HashSet<>(selected);
121  }

◆ subscriptions()

void org.turro.contacts.model.ContactsVM.subscriptions ( @BindingParam("item") ContactItem  item)

Definition at line 149 of file ContactsVM.java.

149  {
150  ContactMenu.showSubscriptions(item.getContact());
151  }
Here is the call graph for this function:

◆ tag()

void org.turro.contacts.model.ContactsVM.tag ( @BindingParam("selected") Set< TagItem selected)

Definition at line 113 of file ContactsVM.java.

113  {
114  tagSet = new HashSet<>(selected);
115  }

◆ togglesel()

void org.turro.contacts.model.ContactsVM.togglesel ( )

Definition at line 200 of file ContactsVM.java.

200  {
201  if(model != null) {
202  model.toggleSelection();
203  doNotLoad = true;
204  }
205  }
Here is the call graph for this function:

◆ update()

void org.turro.contacts.model.ContactsVM.update ( )

Definition at line 351 of file ContactsVM.java.

351 {}

◆ vcard()

void org.turro.contacts.model.ContactsVM.vcard ( @BindingParam("item") ContactItem  item)

Definition at line 134 of file ContactsVM.java.

134  {
135  ElephantMenu.showEntityModal(item.getContact().getId(), "contactId", "/contact/vcard.zul", null);
136  }
Here is the call graph for this function:

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