19 package org.turro.interest;
21 import java.util.HashSet;
22 import java.util.List;
24 import org.turro.action.EntityInfoContent;
25 import org.turro.action.EntityInfoType;
26 import org.turro.action.LinkType;
27 import org.turro.auth.Authentication;
28 import org.turro.cache.SessionObjects;
29 import org.turro.elephant.context.Application;
30 import org.turro.elephant.context.ElephantContext;
31 import org.zkoss.bind.annotation.BindingParam;
32 import org.zkoss.bind.annotation.Command;
33 import org.zkoss.bind.annotation.NotifyChange;
43 selectedCategories = objects.sync(
"interest-categories", HashSet.class, () ->
new HashSet<>());
44 selectedLabels = objects.sync(
"interest-labels", HashSet.class, () ->
new HashSet<>());
47 @NotifyChange({
"model",
"categories",
"labels"})
48 @Command(
"selectAllCats")
54 @NotifyChange({
"model",
"categories",
"labels"})
55 @Command(
"removeAllCats")
57 selectedCategories.clear();
62 return selectedCategories.contains(category);
65 @NotifyChange({
"model",
"labels"})
66 @Command(
"toggleCategory")
68 if(selectedCategories.contains(category)) {
69 selectedCategories.remove(category);
71 selectedCategories.add(category);
76 @NotifyChange({
"model",
"labels"})
77 @Command(
"selectAllLabels")
79 selectedLabels.addAll(interests.
labels());
83 @NotifyChange({
"model",
"labels"})
84 @Command(
"removeAllLabels")
86 selectedLabels.clear();
91 return selectedLabels.contains(label);
94 @NotifyChange(
"model")
95 @Command(
"toggleLabel")
96 public
void toggleLabel(@BindingParam("label") String label) {
97 if(selectedLabels.contains(label)) {
98 selectedLabels.remove(label);
100 selectedLabels.add(label);
106 private final Set<InterestCategory> selectedCategories;
107 private final Set<String> selectedLabels;
115 interests.
collect(selectedCategories);
117 return interests.
get().stream()
118 .filter(i -> selectedLabels.contains(i.getLabel()))
127 return interests.
labels();
134 case "contact",
"convocation",
"issue",
"publication",
"service",
"practicalwork" ->
139 default ->
"href=\"" +
static String createURL(EntityInfoType type, LinkType link)
static IContact getIContact()
static HttpServletRequest getResolverRequest()
static String getRootWebPath()
static final List< InterestCategory > get()
IElephantEntity getEntity()
List< InterestCategory > getCategories()
boolean isSelected(InterestCategory category)
void toggleLabel(@BindingParam("label") String label)
void toggleCategory(@BindingParam("category") InterestCategory category)
List< Interest > getModel()
boolean isSelected(String label)
List< String > getLabels()
String getLinkAttribute(Interest interest)
void collect(Set< InterestCategory > categories)
static Interests from(IContact contact)