BrightSide Workbench Full Report + Source Code
org.turro.interest.InterestsVM Class Reference

Public Member Functions

 InterestsVM ()
 
void selectAllCats ()
 
void removeAllCats ()
 
boolean isSelected (InterestCategory category)
 
void toggleCategory (@BindingParam("category") InterestCategory category)
 
void selectAllLabels ()
 
void removeAllLabels ()
 
boolean isSelected (String label)
 
void toggleLabel (@BindingParam("label") String label)
 
List< InterestgetModel ()
 
List< InterestCategorygetCategories ()
 
List< String > getLabels ()
 
String getLinkAttribute (Interest interest)
 

Detailed Description

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

Definition at line 39 of file InterestsVM.java.

Constructor & Destructor Documentation

◆ InterestsVM()

org.turro.interest.InterestsVM.InterestsVM ( )

Definition at line 41 of file InterestsVM.java.

41  {
42  SessionObjects objects = SessionObjects.instance(Application.getResolverRequest());
43  selectedCategories = objects.sync("interest-categories", HashSet.class, () -> new HashSet<>());
44  selectedLabels = objects.sync("interest-labels", HashSet.class, () -> new HashSet<>());
45  }
Here is the call graph for this function:

Member Function Documentation

◆ getCategories()

List<InterestCategory> org.turro.interest.InterestsVM.getCategories ( )

Definition at line 122 of file InterestsVM.java.

122  {
123  return InterestCategories.get();
124  }
Here is the call graph for this function:

◆ getLabels()

List<String> org.turro.interest.InterestsVM.getLabels ( )

Definition at line 126 of file InterestsVM.java.

126  {
127  return interests.labels();
128  }
List< String > labels()
Definition: Interests.java:62
Here is the call graph for this function:

◆ getLinkAttribute()

String org.turro.interest.InterestsVM.getLinkAttribute ( Interest  interest)

Definition at line 132 of file InterestsVM.java.

132  {
133  return switch(interest.getEntity().getRoot()) {
134  case "contact", "convocation", "issue", "publication", "service", "practicalwork" ->
135  "onclick=\"" +
136  ElephantContext.getRootWebPath() +
137  EntityInfoContent.createURL(EntityInfoType.FULL, LinkType.WEB) + "&path=" + interest.getEntity().getPath() +
138  "\"";
139  default -> "href=\"" +
140  ElephantContext.getRootWebPath() + interest.getEntity().getEntityUrl() +
141  "\"";
142  };
143  }
Here is the call graph for this function:

◆ getModel()

List<Interest> org.turro.interest.InterestsVM.getModel ( )

Definition at line 113 of file InterestsVM.java.

113  {
114  if(interests.isEmpty()) {
115  interests.collect(selectedCategories);
116  }
117  return interests.get().stream()
118  .filter(i -> selectedLabels.contains(i.getLabel()))
119  .toList();
120  }
void collect(Set< InterestCategory > categories)
Definition: Interests.java:35
Set< Interest > get()
Definition: Interests.java:66
Here is the call graph for this function:

◆ isSelected() [1/2]

boolean org.turro.interest.InterestsVM.isSelected ( InterestCategory  category)

Definition at line 61 of file InterestsVM.java.

61  {
62  return selectedCategories.contains(category);
63  }

◆ isSelected() [2/2]

boolean org.turro.interest.InterestsVM.isSelected ( String  label)

Definition at line 90 of file InterestsVM.java.

90  {
91  return selectedLabels.contains(label);
92  }

◆ removeAllCats()

void org.turro.interest.InterestsVM.removeAllCats ( )

Definition at line 56 of file InterestsVM.java.

56  {
57  selectedCategories.clear();
58  interests.clear();
59  }
Here is the call graph for this function:

◆ removeAllLabels()

void org.turro.interest.InterestsVM.removeAllLabels ( )

Definition at line 85 of file InterestsVM.java.

85  {
86  selectedLabels.clear();
87  interests.clear();
88  }
Here is the call graph for this function:

◆ selectAllCats()

void org.turro.interest.InterestsVM.selectAllCats ( )

Definition at line 49 of file InterestsVM.java.

49  {
50  selectedCategories.addAll(InterestCategories.get());
51  interests.clear();
52  }
Here is the call graph for this function:

◆ selectAllLabels()

void org.turro.interest.InterestsVM.selectAllLabels ( )

Definition at line 78 of file InterestsVM.java.

78  {
79  selectedLabels.addAll(interests.labels());
80  interests.clear();
81  }
Here is the call graph for this function:

◆ toggleCategory()

void org.turro.interest.InterestsVM.toggleCategory ( @BindingParam("category") InterestCategory  category)

Definition at line 67 of file InterestsVM.java.

67  {
68  if(selectedCategories.contains(category)) {
69  selectedCategories.remove(category);
70  } else {
71  selectedCategories.add(category);
72  }
73  interests.clear();
74  }
Here is the call graph for this function:

◆ toggleLabel()

void org.turro.interest.InterestsVM.toggleLabel ( @BindingParam("label") String  label)

Definition at line 96 of file InterestsVM.java.

96  {
97  if(selectedLabels.contains(label)) {
98  selectedLabels.remove(label);
99  } else {
100  selectedLabels.add(label);
101  }
102  }

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