-
Notifications
You must be signed in to change notification settings - Fork 188
/
OrgMemberPanel.java
153 lines (125 loc) · 5.79 KB
/
OrgMemberPanel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**
* Copyright (c) 2015-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.web.page.admin.users.component;
import java.util.Collection;
import java.util.List;
import javax.xml.namespace.QName;
import com.evolveum.midpoint.web.session.MemberPanelStorage;
import com.evolveum.midpoint.web.session.PageStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.form.DropDownFormGroup;
import com.evolveum.midpoint.web.page.admin.roles.AbstractRoleMemberPanel;
import com.evolveum.midpoint.web.page.admin.roles.MemberOperationsHelper;
public class OrgMemberPanel extends AbstractRoleMemberPanel<OrgType> {
private static final Trace LOGGER = TraceManager.getTrace(OrgMemberPanel.class);
protected static final String ID_SEARCH_BY_TYPE = "searchByType";
protected static final ObjectTypes OBJECT_TYPES_DEFAULT = ObjectTypes.USER;
protected static final String DOT_CLASS = OrgMemberPanel.class.getName() + ".";
private static final long serialVersionUID = 1L;
public OrgMemberPanel(String id, IModel<OrgType> model) {
super(id, model);
setOutputMarkupId(true);
}
@Override
protected void initLayout() {
super.initLayout();
}
@Override
protected ObjectQuery createMemberQuery(boolean indirect, Collection<QName> relations) {
ObjectTypes searchType = getSearchType();
if (SearchBoxScopeType.ONE_LEVEL.equals(getOrgSearchScope())) {
if (FocusType.class.isAssignableFrom(searchType.getClassDefinition())) {
return super.createMemberQuery(indirect, relations);
}
else {
ObjectReferenceType ref = MemberOperationsHelper.createReference(getModelObject(), getSelectedRelation());
return getPageBase().getPrismContext().queryFor(searchType.getClassDefinition())
.type(searchType.getClassDefinition())
.isDirectChildOf(ref.asReferenceValue()).build();
}
}
String oid = getModelObject().getOid();
ObjectReferenceType ref = MemberOperationsHelper.createReference(getModelObject(), getSelectedRelation());
ObjectQuery query = getPageBase().getPrismContext().queryFor(searchType.getClassDefinition())
.type(searchType.getClassDefinition())
.isChildOf(ref.asReferenceValue()).build();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Searching members of org {} with query:\n{}", oid, query.debugDump());
}
return query;
}
protected SearchBoxScopeType getOrgSearchScope() {
DropDownFormGroup<SearchBoxScopeType> searchorgScope = (DropDownFormGroup<SearchBoxScopeType>) get(
createComponentPath(ID_FORM, ID_SEARCH_SCOPE));
return searchorgScope.getModelObject();
}
@Override
protected void assignMembers(AjaxRequestTarget target, List<QName> availableRelationList) {
MemberOperationsHelper.assignOrgMembers(getPageBase(), getModelObject(), target, availableRelationList);
}
// @Override
// protected void unassignMembersPerformed(QName objectType, QueryScope scope, Collection<QName> relations, AjaxRequestTarget target) {
// super.unassignMembersPerformed(objectType, scope, relations, target);
//// if (relations != null && relations.size() > 0) {
//// MemberOperationsHelper.unassignOtherOrgMembersPerformed(getPageBase(), getModelObject(), scope, getActionQuery(scope, relations), relations, target);
//// }
// }
@Override
protected List<QName> getSupportedObjectTypes(boolean includeAbstractTypes) {
List<QName> objectTypes = WebComponentUtil.createAssignmentHolderTypeQnamesList();
objectTypes.remove(ShadowType.COMPLEX_TYPE);
objectTypes.remove(ObjectType.COMPLEX_TYPE);
return objectTypes;
}
@Override
protected <O extends ObjectType> Class<O> getDefaultObjectType() {
return getMemberPanelStorage().getType() != null ? (Class) WebComponentUtil.qnameToClass(getPageBase().getPrismContext(),
getMemberPanelStorage().getType().getTypeQName()) : (Class) UserType.class;
}
@Override
protected List<QName> getSupportedRelations() {
return WebComponentUtil.getCategoryRelationChoices(AreaCategoryType.ORGANIZATION, getPageBase());
}
@Override
protected MemberPanelStorage getMemberPanelStorage(){
String storageKey = WebComponentUtil.getStorageKeyForTableId(getTableId(getComplexTypeQName()));
PageStorage storage = null;
if (StringUtils.isNotEmpty(storageKey)) {
storage = getPageBase().getSessionStorage().getPageStorageMap().get(storageKey);
if (storage == null) {
storage = getPageBase().getSessionStorage().initPageStorage(storageKey);
}
}
return (MemberPanelStorage) storage;
}
@Override
protected GuiObjectListPanelConfigurationType getAdditionalPanelConfig(){
CompiledObjectCollectionView orgViewType = getPageBase().getCompiledUserProfile().findObjectCollectionView(OrgType.COMPLEX_TYPE, null);
if (orgViewType == null || orgViewType.getAdditionalPanels() == null){
return null;
}
return orgViewType.getAdditionalPanels().getMemberPanel();
}
}