1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.wizards.any;
20
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24 import org.apache.commons.collections4.CollectionUtils;
25 import org.apache.syncope.client.console.panels.search.SearchClause;
26 import org.apache.syncope.client.console.panels.search.SearchUtils;
27 import org.apache.syncope.client.lib.SyncopeClient;
28 import org.apache.syncope.client.ui.commons.wizards.any.AnyWrapper;
29 import org.apache.syncope.common.lib.to.GroupTO;
30
31 public class GroupWrapper extends AnyWrapper<GroupTO> {
32
33 private static final long serialVersionUID = 8058288034211558376L;
34
35 private GroupTO previousGroupTO;
36
37 private List<SearchClause> uDynClauses;
38
39 private Map<String, List<SearchClause>> aDynClauses;
40
41 public GroupWrapper(final GroupTO groupTO) {
42 this(null, groupTO);
43 }
44
45 public GroupWrapper(final GroupTO previousGroupTO, final GroupTO groupTO) {
46 super(groupTO);
47 this.previousGroupTO = previousGroupTO;
48 getUDynClauses();
49 getADynClauses();
50 }
51
52 public GroupTO getPreviousGroupTO() {
53 return previousGroupTO;
54 }
55
56 public final List<SearchClause> getUDynClauses() {
57 if (this.uDynClauses == null) {
58 this.uDynClauses = SearchUtils.getSearchClauses(this.anyTO.getUDynMembershipCond());
59 }
60 return this.uDynClauses;
61 }
62
63 public void setUDynClauses(final List<SearchClause> uDynClauses) {
64 this.uDynClauses = uDynClauses;
65 }
66
67 public final Map<String, List<SearchClause>> getADynClauses() {
68 if (this.aDynClauses == null) {
69 this.aDynClauses = SearchUtils.getSearchClauses(this.anyTO.getADynMembershipConds());
70 }
71 return this.aDynClauses;
72 }
73
74 public void setADynClauses(final Map<String, List<SearchClause>> aDynClauses) {
75 this.aDynClauses = aDynClauses;
76 }
77
78 public String getUDynMembershipCond() {
79 return CollectionUtils.isEmpty(this.uDynClauses)
80 ? null
81 : SearchUtils.buildFIQL(this.uDynClauses, SyncopeClient.getUserSearchConditionBuilder());
82 }
83
84 public Map<String, String> getADynMembershipConds() {
85 Map<String, String> res = new HashMap<>();
86 if (this.aDynClauses != null && !this.aDynClauses.isEmpty()) {
87 this.aDynClauses.entrySet().stream().
88 filter(entry -> CollectionUtils.isNotEmpty(entry.getValue())).
89 forEach(entry -> {
90 String fiql = SearchUtils.buildFIQL(entry.getValue(),
91 SyncopeClient.getAnyObjectSearchConditionBuilder(entry.getKey()));
92 if (fiql != null) {
93 res.put(entry.getKey(), fiql);
94 }
95 });
96 }
97
98 return res;
99 }
100
101 public GroupTO fillDynamicConditions() {
102 this.anyTO.setUDynMembershipCond(this.getUDynMembershipCond());
103 this.anyTO.getADynMembershipConds().clear();
104 this.anyTO.getADynMembershipConds().putAll(this.getADynMembershipConds());
105 return this.anyTO;
106 }
107 }