Skip to content

Commit

Permalink
org tree members panel - configurable scope and object type
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Oct 30, 2018
1 parent 303bc76 commit db23822
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
Expand Up @@ -132,6 +132,7 @@ private void initLayout() {
form.setOutputMarkupId(true);
add(form);

initDefaultSearchParameters();
initSearch(form);

initMemberTable(form);
Expand All @@ -141,6 +142,9 @@ private void initLayout() {

protected abstract void initCustomLayout(Form form, ModelServiceLocator serviceLocator);

protected void initDefaultSearchParameters(){
}

protected abstract void initSearch(Form form);

private void initMemberTable(Form form) {
Expand Down
Expand Up @@ -103,13 +103,9 @@ public class OrgMemberPanel extends AbstractRoleMemberPanel<OrgType> {
protected static final String ID_MANAGER_MENU = "managerMenu";
protected static final String ID_MANAGER_MENU_BODY = "managerMenuBody";

protected static final String SEARCH_SCOPE_SUBTREE = "subtree";
protected static final String SEARCH_SCOPE_ONE = "one";

protected static final ObjectTypes OBJECT_TYPES_DEFAULT = ObjectTypes.USER;

protected static final List<String> SEARCH_SCOPE_VALUES = Arrays.asList(SEARCH_SCOPE_SUBTREE,
SEARCH_SCOPE_ONE);
protected SearchBoxScopeType scopeDefaultValue = null;
protected QName objectTypeDefaultValue = null;

protected static final String DOT_CLASS = OrgMemberPanel.class.getName() + ".";
protected static final String OPERATION_SEARCH_MANAGERS = DOT_CLASS + "searchManagers";
Expand All @@ -128,6 +124,21 @@ public OrgMemberPanel(String id, IModel<OrgType> model) {
setOutputMarkupId(true);
}

@Override
protected void initDefaultSearchParameters(){
GuiObjectListType panelConfig = WebComponentUtil.getViewTypeConfig(OrgType.COMPLEX_TYPE, getPageBase());
if (panelConfig != null && panelConfig.getSearchBoxConfiguration() != null) {
scopeDefaultValue = panelConfig.getSearchBoxConfiguration().getDefaultScope();
objectTypeDefaultValue = panelConfig.getSearchBoxConfiguration().getDefaultObjectType();
}
if (scopeDefaultValue == null){
scopeDefaultValue = SearchBoxScopeType.ONE_LEVEL;
}
if (objectTypeDefaultValue == null){
objectTypeDefaultValue = OBJECT_TYPES_DEFAULT.getTypeQName();
}
}

@Override
protected void initSearch(Form form) {

Expand All @@ -151,7 +162,7 @@ public int compare(ObjectTypes o1, ObjectTypes o2) {
});

DropDownChoice<ObjectTypes> objectType = new DropDownChoice<ObjectTypes>(ID_SEARCH_BY_TYPE,
Model.of(OBJECT_TYPES_DEFAULT), objectTypes, new EnumChoiceRenderer<ObjectTypes>());
Model.of(ObjectTypes.getObjectType(objectTypeDefaultValue.getLocalPart())), objectTypes, new EnumChoiceRenderer<ObjectTypes>());
objectType.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;

Expand All @@ -164,9 +175,9 @@ protected void onUpdate(AjaxRequestTarget target) {
objectType.setOutputMarkupId(true);
form.add(objectType);

DropDownChoice<String> seachScrope = new DropDownChoice<String>(ID_SEARCH_SCOPE,
Model.of(SEARCH_SCOPE_SUBTREE), SEARCH_SCOPE_VALUES,
new StringResourceChoiceRenderer("TreeTablePanel.search.scope"));
DropDownChoice<SearchBoxScopeType> seachScrope = new DropDownChoice<SearchBoxScopeType>(ID_SEARCH_SCOPE,
Model.of(scopeDefaultValue), Arrays.asList(SearchBoxScopeType.values()),
new EnumChoiceRenderer<>());
seachScrope.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -680,9 +691,9 @@ protected void recomputeManagersPerformed(QueryScope scope, AjaxRequestTarget ta
protected ObjectQuery createContentQuery() {
String oid = getModelObject().getOid();

DropDownChoice<String> searchScopeChoice = (DropDownChoice<String>) get(
DropDownChoice<SearchBoxScopeType> searchScopeChoice = (DropDownChoice<SearchBoxScopeType>) get(
createComponentPath(ID_FORM, ID_SEARCH_SCOPE));
String scope = searchScopeChoice.getModelObject();
SearchBoxScopeType scope = searchScopeChoice.getModelObject();

ObjectTypes searchType = getSearchType();
S_FilterEntryOrEmpty q = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext());
Expand All @@ -700,7 +711,7 @@ protected ObjectQuery createContentQuery() {
PrismReferenceValue ref = new PrismReferenceValue(oid);
ref.setRelation(relationValue);
ObjectQuery query;
if (SEARCH_SCOPE_ONE.equals(scope)) {
if (SearchBoxScopeType.ONE_LEVEL.equals(scope)) {
query = q.isDirectChildOf(ref)
.build();
} else {
Expand Down
Expand Up @@ -695,3 +695,5 @@ relation.consent=consent
AbstractCredentialType.forceChange=Force change on next login
PasswordType.value=Value
AdminGuiConfigurationType.enableExperimentalFeatures=Enable GUI experimental features
SearchBoxScopeType.ONE_LEVEL=One level
SearchBoxScopeType.SUBTREE=Subtree

0 comments on commit db23822

Please sign in to comment.