You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2012/12/20 16:45:31 UTC
svn commit: r1424538 [2/6] - in /syncope/trunk:
console/src/main/java/org/apache/syncope/console/
console/src/main/java/org/apache/syncope/console/commons/
console/src/main/java/org/apache/syncope/console/pages/
console/src/main/java/org/apache/syncope...
Added: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchPanel.java?rev=1424538&view=auto
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchPanel.java (added)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchPanel.java Thu Dec 20 15:45:28 2012
@@ -0,0 +1,370 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.syncope.console.pages.panels;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.syncope.client.search.AttributableCond;
+import org.apache.syncope.client.search.AttributeCond;
+import org.apache.syncope.client.search.MembershipCond;
+import org.apache.syncope.client.search.NodeCond;
+import org.apache.syncope.client.search.ResourceCond;
+import org.apache.syncope.client.to.ResourceTO;
+import org.apache.syncope.client.to.RoleTO;
+import org.apache.syncope.client.to.UserTO;
+import org.apache.syncope.console.commons.SearchCondWrapper;
+import org.apache.syncope.console.commons.SearchCondWrapper.OperationType;
+import org.apache.syncope.console.rest.ResourceRestClient;
+import org.apache.syncope.console.rest.SchemaRestClient;
+import org.apache.syncope.types.AttributableType;
+import org.apache.wicket.feedback.FeedbackMessage;
+import org.apache.wicket.feedback.IFeedbackMessageFilter;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractSearchPanel extends Panel {
+
+ private static final long serialVersionUID = 5922413053568696414L;
+
+ /**
+ * Logger.
+ */
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractSearchPanel.class);
+
+ protected static final String[] ATTRIBUTES_NOTINCLUDED = {"attributes", "derivedAttributes", "virtualAttributes",
+ "serialVersionUID", "memberships", "resources", "password", "propagationTOs", "propagationStatusMap"};
+
+ protected IModel<List<String>> dnames;
+
+ protected IModel<List<String>> anames;
+
+ protected IModel<List<String>> resourceNames;
+
+ protected IModel<List<AttributeCond.Type>> attributeTypes;
+
+ protected IModel<List<SearchCondWrapper.FilterType>> filterTypes;
+
+ protected IModel<List<String>> roleNames;
+
+ @SpringBean
+ protected SchemaRestClient schemaRestClient;
+
+ @SpringBean
+ protected ResourceRestClient resourceRestClient;
+
+ protected FeedbackPanel searchFeedback;
+
+ protected List<SearchCondWrapper> searchConditionList;
+
+ protected WebMarkupContainer searchFormContainer;
+
+ protected AttributableType attributableType;
+
+ protected boolean required;
+
+ protected AbstractSearchPanel(final String id, final AttributableType attributableType) {
+ this(id, attributableType, null, true);
+ }
+
+ protected AbstractSearchPanel(final String id, final AttributableType attributableType, final NodeCond initCond,
+ final boolean required) {
+
+ super(id);
+ populate();
+
+ this.attributableType = attributableType;
+ this.required = required;
+
+ setOutputMarkupId(true);
+
+ searchFormContainer = new WebMarkupContainer("searchFormContainer");
+ searchFormContainer.setOutputMarkupId(true);
+
+ searchFeedback = new FeedbackPanel("searchFeedback", new IFeedbackMessageFilter() {
+
+ private static final long serialVersionUID = 6895024863321391672L;
+
+ @Override
+ public boolean accept(final FeedbackMessage message) {
+ boolean result;
+
+ // messages reported on the session have a null reporter
+ if (message.getReporter() == null) {
+ result = false;
+ } else {
+ // only accept messages coming from the children of the search form container
+ result = searchFormContainer.contains(message.getReporter(), true);
+ }
+
+ return result;
+ }
+ });
+ searchFeedback.setOutputMarkupId(true);
+ add(searchFeedback);
+
+ if (initCond == null) {
+ searchConditionList = new ArrayList<SearchCondWrapper>();
+ searchConditionList.add(new SearchCondWrapper());
+ } else {
+ searchConditionList = getSearchCondWrappers(initCond, null);
+ }
+ searchFormContainer.add(new SearchView("searchView", searchConditionList, searchFormContainer, required,
+ attributeTypes, filterTypes, anames, dnames, roleNames, resourceNames));
+
+ add(searchFormContainer);
+ }
+
+ protected void populate() {
+ dnames = new LoadableDetachableModel<List<String>>() {
+
+ private static final long serialVersionUID = 5275935387613157437L;
+
+ @Override
+ protected List<String> load() {
+ final List<String> details = new ArrayList<String>();
+
+ Class<?> clazz = attributableType == AttributableType.USER
+ ? UserTO.class
+ : RoleTO.class;
+
+ // loop on class and all superclasses searching for field
+ while (clazz != null && clazz != Object.class) {
+ for (Field field : clazz.getDeclaredFields()) {
+ if (!ArrayUtils.contains(ATTRIBUTES_NOTINCLUDED, field.getName())) {
+ details.add(field.getName());
+ }
+ }
+ clazz = clazz.getSuperclass();
+ }
+
+ Collections.reverse(details);
+ return details;
+ }
+ };
+
+ anames = new LoadableDetachableModel<List<String>>() {
+
+ private static final long serialVersionUID = 5275935387613157437L;
+
+ @Override
+ protected List<String> load() {
+ return schemaRestClient.getSchemaNames(attributableType);
+ }
+ };
+
+ resourceNames = new LoadableDetachableModel<List<String>>() {
+
+ private static final long serialVersionUID = 5275935387613157437L;
+
+ @Override
+ protected List<String> load() {
+ List<ResourceTO> resourceTOs = resourceRestClient.getAllResources();
+
+ List<String> result = new ArrayList<String>(resourceTOs.size());
+
+ for (ResourceTO resource : resourceTOs) {
+ result.add(resource.getName());
+ }
+
+ return result;
+ }
+ };
+
+ attributeTypes = new LoadableDetachableModel<List<AttributeCond.Type>>() {
+
+ private static final long serialVersionUID = 5275935387613157437L;
+
+ @Override
+ protected List<AttributeCond.Type> load() {
+ return Arrays.asList(AttributeCond.Type.values());
+ }
+ };
+ }
+
+ public FeedbackPanel getSearchFeedback() {
+ return searchFeedback;
+ }
+
+ private List<SearchCondWrapper> getSearchCondWrappers(final NodeCond searchCond, final NodeCond.Type type) {
+ LOG.debug("Search condition: {}", searchCond);
+
+ List<SearchCondWrapper> wrappers = new ArrayList<SearchCondWrapper>();
+
+ switch (searchCond.getType()) {
+ case LEAF:
+ case NOT_LEAF:
+ final SearchCondWrapper wrapper = getSearchCondWrapper(searchCond);
+
+ if (type != null) {
+ switch (type) {
+ case AND:
+ wrapper.setOperationType(OperationType.AND);
+ break;
+ case OR:
+ wrapper.setOperationType(OperationType.OR);
+ break;
+ default:
+ // nothing to specify
+ }
+ }
+
+ wrappers.add(wrapper);
+ break;
+
+ case AND:
+ case OR:
+ wrappers.addAll(getSearchCondWrappers(searchCond.getLeftNodeCond(), type));
+ wrappers.addAll(getSearchCondWrappers(searchCond.getRightNodeCond(), searchCond.getType()));
+ break;
+
+ default:
+ }
+
+ LOG.debug("Search condition wrappers: {}", wrappers);
+
+ return wrappers;
+ }
+
+ private SearchCondWrapper getSearchCondWrapper(final NodeCond searchCond) {
+ SearchCondWrapper wrapper = new SearchCondWrapper();
+
+ if (searchCond.getAttributableCond() != null) {
+ wrapper.setFilterType(SearchCondWrapper.FilterType.ATTRIBUTE);
+ wrapper.setFilterName(searchCond.getAttributableCond().getSchema());
+ wrapper.setType(searchCond.getAttributableCond().getType());
+ wrapper.setFilterValue(searchCond.getAttributableCond().getExpression());
+ }
+ if (searchCond.getAttributeCond() != null) {
+ wrapper.setFilterType(SearchCondWrapper.FilterType.ATTRIBUTE);
+ wrapper.setFilterName(searchCond.getAttributeCond().getSchema());
+ wrapper.setType(searchCond.getAttributeCond().getType());
+ wrapper.setFilterValue(searchCond.getAttributeCond().getExpression());
+ }
+ if (searchCond.getMembershipCond() != null) {
+ wrapper.setFilterType(SearchCondWrapper.FilterType.MEMBERSHIP);
+ RoleTO role = new RoleTO();
+ role.setId(searchCond.getMembershipCond().getRoleId());
+ role.setName(searchCond.getMembershipCond().getRoleName());
+ wrapper.setFilterName(role.getDisplayName());
+ }
+ if (searchCond.getResourceCond() != null) {
+ wrapper.setFilterType(SearchCondWrapper.FilterType.RESOURCE);
+ wrapper.setFilterName(searchCond.getResourceCond().getResourceName());
+ }
+
+ wrapper.setNotOperator(searchCond.getType() == NodeCond.Type.NOT_LEAF);
+
+ return wrapper;
+ }
+
+ public NodeCond buildSearchCond() {
+ return buildSearchCond(searchConditionList);
+ }
+
+ private NodeCond buildSearchCond(final List<SearchCondWrapper> conditions) {
+ SearchCondWrapper searchConditionWrapper = conditions.get(0);
+ if (searchConditionWrapper == null || searchConditionWrapper.getFilterType() == null) {
+ return null;
+ }
+
+ LOG.debug("Search conditions: fname {}; ftype {}; fvalue {}; OP {}; type {}; isnot {}", new Object[]{
+ searchConditionWrapper.getFilterName(), searchConditionWrapper.getFilterType(),
+ searchConditionWrapper.getFilterValue(), searchConditionWrapper.getOperationType(),
+ searchConditionWrapper.getType(), searchConditionWrapper.isNotOperator()});
+
+ NodeCond nodeCond = null;
+
+ switch (searchConditionWrapper.getFilterType()) {
+ case ATTRIBUTE:
+ // AttributeCond or SyncopeUserCond
+ final String schema = searchConditionWrapper.getFilterName();
+
+ final AttributeCond attributeCond;
+ if (dnames.getObject().contains(schema)) {
+ attributeCond = new AttributableCond();
+ nodeCond = searchConditionWrapper.isNotOperator()
+ ? NodeCond.getNotLeafCond((AttributableCond) attributeCond)
+ : NodeCond.getLeafCond((AttributableCond) attributeCond);
+ } else {
+ attributeCond = new AttributeCond();
+ nodeCond = searchConditionWrapper.isNotOperator()
+ ? NodeCond.getNotLeafCond(attributeCond)
+ : NodeCond.getLeafCond(attributeCond);
+ }
+
+ attributeCond.setSchema(schema);
+ attributeCond.setType(searchConditionWrapper.getType());
+ attributeCond.setExpression(searchConditionWrapper.getFilterValue());
+
+ break;
+
+ case MEMBERSHIP:
+ final MembershipCond membershipCond = new MembershipCond();
+ membershipCond.setRoleId(RoleTO.fromDisplayName(searchConditionWrapper.getFilterName()));
+ membershipCond.setRoleName(searchConditionWrapper.getFilterName().split(" ")[1]);
+
+ if (searchConditionWrapper.isNotOperator()) {
+ nodeCond = NodeCond.getNotLeafCond(membershipCond);
+ } else {
+ nodeCond = NodeCond.getLeafCond(membershipCond);
+ }
+
+ break;
+
+ case RESOURCE:
+ final ResourceCond resourceCond = new ResourceCond();
+ resourceCond.setResourceName(searchConditionWrapper.getFilterName());
+
+ if (searchConditionWrapper.isNotOperator()) {
+ nodeCond = NodeCond.getNotLeafCond(resourceCond);
+ } else {
+ nodeCond = NodeCond.getLeafCond(resourceCond);
+ }
+
+ break;
+
+ default:
+ // nothing to do
+ }
+
+ LOG.debug("Processed condition {}", nodeCond);
+
+ if (conditions.size() > 1) {
+ List<SearchCondWrapper> subList = conditions.subList(1, conditions.size());
+
+ if (OperationType.OR.equals(subList.get(0).getOperationType())) {
+ nodeCond = NodeCond.getOrCond(nodeCond, buildSearchCond(subList));
+ } else {
+ nodeCond = NodeCond.getAndCond(nodeCond, buildSearchCond(subList));
+ }
+ }
+
+ return nodeCond;
+ }
+}
Propchange: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchPanel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchPanel.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchPanel.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchResultPanel.java (from r1423830, syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ResultSetPanel.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchResultPanel.java?p2=syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchResultPanel.java&p1=syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ResultSetPanel.java&r1=1423830&r2=1424538&rev=1424538&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ResultSetPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AbstractSearchResultPanel.java Thu Dec 20 15:45:28 2012
@@ -18,28 +18,17 @@
*/
package org.apache.syncope.console.pages.panels;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import org.apache.syncope.client.search.NodeCond;
import org.apache.syncope.client.to.AbstractAttributableTO;
-import org.apache.syncope.client.to.UserTO;
-import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.console.commons.AttributableDataProvider;
import org.apache.syncope.console.commons.Constants;
import org.apache.syncope.console.commons.PreferenceManager;
-import org.apache.syncope.console.commons.UserDataProvider;
import org.apache.syncope.console.commons.XMLRolesReader;
import org.apache.syncope.console.pages.AbstractBasePage;
import org.apache.syncope.console.pages.DisplayAttributesModalPage;
-import org.apache.syncope.console.pages.EditUserModalPage;
-import org.apache.syncope.console.pages.StatusModalPage;
+import org.apache.syncope.console.rest.AbstractAttributableRestClient;
import org.apache.syncope.console.rest.UserRestClient;
-import org.apache.syncope.console.wicket.extensions.markup.html.repeater.data.table.DatePropertyColumn;
-import org.apache.syncope.console.wicket.extensions.markup.html.repeater.data.table.TokenColumn;
-import org.apache.syncope.console.wicket.extensions.markup.html.repeater.data.table.UserAttrColumn;
-import org.apache.syncope.console.wicket.markup.html.form.ActionLink;
-import org.apache.syncope.console.wicket.markup.html.form.ActionLinksPanel;
import org.apache.wicket.Component;
import org.apache.wicket.Page;
import org.apache.wicket.PageReference;
@@ -54,32 +43,26 @@ import org.apache.wicket.event.IEventSou
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.markup.repeater.Item;
-import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ResultSetPanel extends Panel implements IEventSource {
+public abstract class AbstractSearchResultPanel extends Panel implements IEventSource {
private static final long serialVersionUID = -9170191461250434024L;
/**
* Logger.
*/
- private static final Logger LOG = LoggerFactory.getLogger(ResultSetPanel.class);
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractSearchResultPanel.class);
/**
* Edit modal window height.
@@ -112,16 +95,10 @@ public class ResultSetPanel extends Pane
private final static int STATUS_MODAL_WIN_WIDTH = 500;
/**
- * User rest client.
- */
- @SpringBean
- private UserRestClient userRestClient;
-
- /**
* Application preferences.
*/
@SpringBean
- private PreferenceManager prefMan;
+ protected PreferenceManager prefMan;
/**
* Role reader for authorizations management.
@@ -129,6 +106,8 @@ public class ResultSetPanel extends Pane
@SpringBean
protected XMLRolesReader xmlRolesReader;
+ protected final AbstractAttributableRestClient restClient;
+
/**
* Number of rows per page.
*/
@@ -142,7 +121,7 @@ public class ResultSetPanel extends Pane
/**
* Feedback panel specified by the caller.
*/
- private final FeedbackPanel feedbackPanel;
+ protected final FeedbackPanel feedbackPanel;
/**
* Specify if results are about a filtered search or not. Using this attribute it is possible to use this panel to
@@ -158,46 +137,48 @@ public class ResultSetPanel extends Pane
/**
* Result table.
*/
- private AjaxFallbackDefaultDataTable<UserTO, String> resultTable;
+ private AjaxFallbackDefaultDataTable<AbstractAttributableTO, String> resultTable;
/**
* Data provider used to search for users.
*/
- private UserDataProvider dataProvider;
+ private AttributableDataProvider dataProvider;
/**
* Modal window to be used for user profile editing. Global visibility is required ...
*/
- private final ModalWindow editmodal = new ModalWindow("editModal");
+ protected final ModalWindow editmodal = new ModalWindow("editModal");
/**
* Modal window to be used for attributes choosing to display in tables.
*/
- private final ModalWindow displaymodal = new ModalWindow("displayModal");
+ protected final ModalWindow displaymodal = new ModalWindow("displayModal");
/**
* Modal window to be used for user status management.
*/
- private final ModalWindow statusmodal = new ModalWindow("statusModal");
+ protected final ModalWindow statusmodal = new ModalWindow("statusModal");
/**
* Owner page.
*/
- private final AbstractBasePage page;
+ protected final AbstractBasePage page;
- public <T extends AbstractAttributableTO> ResultSetPanel(final String id, final boolean filtered,
- final NodeCond searchCond, final PageReference callerRef) {
+ protected <T extends AbstractAttributableTO> AbstractSearchResultPanel(final String id, final boolean filtered,
+ final NodeCond searchCond, final PageReference callerRef, final AbstractAttributableRestClient restClient) {
super(id);
setOutputMarkupId(true);
- page = (AbstractBasePage) callerRef.getPage();
+ this.page = (AbstractBasePage) callerRef.getPage();
this.filtered = filtered;
this.filter = searchCond;
this.feedbackPanel = page.getFeedbackPanel();
+ this.restClient = restClient;
+
editmodal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
editmodal.setInitialHeight(EDIT_MODAL_WIN_HEIGHT);
editmodal.setInitialWidth(EDIT_MODAL_WIN_WIDTH);
@@ -229,52 +210,61 @@ public class ResultSetPanel extends Pane
updateResultTable(false);
// ---------------------------
- // ---------------------------
- // Link to select schemas/columns to be shown
- // ---------------------------
- final AjaxLink displayAttrsLink = new IndicatingAjaxLink("displayAttrsLink") {
+ final AjaxLink displayAttrsLink;
+ if (restClient instanceof UserRestClient) {
+ // ---------------------------
+ // Link to select schemas/columns to be shown (User)
+ // ---------------------------
+ displayAttrsLink = new IndicatingAjaxLink("displayAttrsLink") {
- private static final long serialVersionUID = -7978723352517770644L;
+ private static final long serialVersionUID = -7978723352517770644L;
- @Override
- public void onClick(final AjaxRequestTarget target) {
+ @Override
+ public void onClick(final AjaxRequestTarget target) {
- displaymodal.setPageCreator(new ModalWindow.PageCreator() {
+ displaymodal.setPageCreator(new ModalWindow.PageCreator() {
- private static final long serialVersionUID = -7834632442532690940L;
+ private static final long serialVersionUID = -7834632442532690940L;
- @Override
- public Page createPage() {
- return new DisplayAttributesModalPage(page.getPageReference(), displaymodal);
- }
- });
-
- displaymodal.show(target);
- }
- };
-
- // Add class to specify relative position of the link.
- // Position depends on result pages number.
- displayAttrsLink.add(new Behavior() {
-
- private static final long serialVersionUID = 1469628524240283489L;
+ @Override
+ public Page createPage() {
+ return new DisplayAttributesModalPage(page.getPageReference(), displaymodal);
+ }
+ });
- @Override
- public void onComponentTag(final Component component, final ComponentTag tag) {
+ displaymodal.show(target);
+ }
+ };
- if (resultTable.getRowCount() > rows) {
- tag.remove("class");
- tag.put("class", "settingsPosMultiPage");
- } else {
- tag.remove("class");
- tag.put("class", "settingsPos");
+ // Add class to specify relative position of the link.
+ // Position depends on result pages number.
+ displayAttrsLink.add(new Behavior() {
+
+ private static final long serialVersionUID = 1469628524240283489L;
+
+ @Override
+ public void onComponentTag(final Component component, final ComponentTag tag) {
+ if (resultTable.getRowCount() > rows) {
+ tag.remove("class");
+ tag.put("class", "settingsPosMultiPage");
+ } else {
+ tag.remove("class");
+ tag.put("class", "settingsPos");
+ }
}
- }
- });
+ });
- MetaDataRoleAuthorizationStrategy.authorize(
- displayAttrsLink, ENABLE, xmlRolesReader.getAllAllowedRoles("Users", "changeView"));
+ MetaDataRoleAuthorizationStrategy.authorize(
+ displayAttrsLink, ENABLE, xmlRolesReader.getAllAllowedRoles("Users", "changeView"));
+ } else {
+ displayAttrsLink = new AjaxLink("displayAttrsLink") {
+ @Override
+ public void onClick(final AjaxRequestTarget target) {
+ }
+ };
+ displayAttrsLink.setVisible(false);
+ }
container.add(displayAttrsLink);
final AjaxLink reload = new IndicatingAjaxLink("reload") {
@@ -353,16 +343,17 @@ public class ResultSetPanel extends Pane
}
private void updateResultTable(final boolean create, final int rows) {
- dataProvider = new UserDataProvider(userRestClient, rows, filtered);
+ dataProvider = new AttributableDataProvider(restClient, rows, filtered);
dataProvider.setSearchCond(filter);
final int currentPage = resultTable != null
? (create
- ? (int)resultTable.getPageCount() - 1
- : (int)resultTable.getCurrentPage())
+ ? (int) resultTable.getPageCount() - 1
+ : (int) resultTable.getCurrentPage())
: 0;
- resultTable = new AjaxFallbackDefaultDataTable<UserTO, String>("resultTable", getColumns(), dataProvider, rows);
+ resultTable = new AjaxFallbackDefaultDataTable<AbstractAttributableTO, String>(
+ "resultTable", getColumns(), dataProvider, rows);
resultTable.setCurrentPage(currentPage);
@@ -371,151 +362,11 @@ public class ResultSetPanel extends Pane
container.addOrReplace(resultTable);
}
- private List<IColumn<UserTO, String>> getColumns() {
- final List<IColumn<UserTO, String>> columns = new ArrayList<IColumn<UserTO, String>>();
-
- for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_DETAILS_VIEW)) {
-
- Field field = null;
-
- try {
- field = UserTO.class.getDeclaredField(name);
- } catch (Exception ue) {
- LOG.debug("Error retrieving UserTO field {}", name, ue);
- try {
- field = AbstractAttributableTO.class.getDeclaredField(name);
- } catch (Exception aae) {
- LOG.error("Error retrieving AbstractAttributableTO field {}", name, aae);
- }
- }
-
- if ("token".equalsIgnoreCase(name)) {
- columns.add(new TokenColumn("token"));
- } else if (field != null && field.getType().equals(Date.class)) {
- columns.add(new DatePropertyColumn<UserTO>(new ResourceModel(name, name), name, name));
- } else {
- columns.add(new PropertyColumn<UserTO, String>(new ResourceModel(name, name), name, name));
- }
- }
-
- for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_ATTRIBUTES_VIEW)) {
- columns.add(new UserAttrColumn(name, UserAttrColumn.SchemaType.schema));
- }
-
- for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_DERIVED_ATTRIBUTES_VIEW)) {
- columns.add(new UserAttrColumn(name, UserAttrColumn.SchemaType.derivedSchema));
- }
-
- for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_VIRTUAL_ATTRIBUTES_VIEW)) {
- columns.add(new UserAttrColumn(name, UserAttrColumn.SchemaType.virtualSchema));
- }
-
- // Add defaults in case of no selection
- if (columns.isEmpty()) {
- for (String name : DisplayAttributesModalPage.DEFAULT_SELECTION) {
- columns.add(new PropertyColumn<UserTO, String>(new ResourceModel(name, name), name, name));
- }
-
- prefMan.setList(getRequest(), getResponse(), Constants.PREF_USERS_DETAILS_VIEW,
- DisplayAttributesModalPage.DEFAULT_SELECTION);
- }
-
- columns.add(new AbstractColumn<UserTO, String>(new ResourceModel("actions", "")) {
-
- private static final long serialVersionUID = 2054811145491901166L;
-
- @Override
- public String getCssClass() {
- return "action";
- }
-
- @Override
- public void populateItem(final Item<ICellPopulator<UserTO>> cellItem, final String componentId,
- final IModel<UserTO> model) {
-
- final ActionLinksPanel panel = new ActionLinksPanel(componentId, model);
-
- panel.add(new ActionLink() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- statusmodal.setPageCreator(new ModalWindow.PageCreator() {
-
- private static final long serialVersionUID = -7834632442532690940L;
-
- @Override
- public Page createPage() {
- return new StatusModalPage(page.getPageReference(), statusmodal, model.getObject());
- }
- });
-
- statusmodal.show(target);
- }
- }, ActionLink.ActionType.SEARCH, "Users", "read");
-
- panel.add(new ActionLink() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- editmodal.setPageCreator(new ModalWindow.PageCreator() {
-
- private static final long serialVersionUID = -7834632442532690940L;
-
- @Override
- public Page createPage() {
- return new EditUserModalPage(page.getPageReference(), editmodal, model.getObject());
- }
- });
-
- editmodal.show(target);
- }
- }, ActionLink.ActionType.EDIT, "Users", "read");
-
- panel.add(new ActionLink() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- try {
- final UserTO userTO = userRestClient.delete(model.getObject().getId());
-
- page.setModalResult(true);
-
- editmodal.setPageCreator(new ModalWindow.PageCreator() {
-
- private static final long serialVersionUID = -7834632442532690940L;
-
- @Override
- public Page createPage() {
- return new EditUserModalPage(editmodal, userTO);
- }
- });
-
- editmodal.show(target);
-
- } catch (SyncopeClientCompositeErrorException scce) {
- error(getString("operation_error") + ": " + scce.getMessage());
- target.add(feedbackPanel);
- }
- }
- }, ActionLink.ActionType.DELETE, "Users", "delete");
-
- cellItem.add(panel);
- }
- });
-
- return columns;
- }
+ protected abstract List<IColumn<AbstractAttributableTO, String>> getColumns();
@Override
public void onEvent(final IEvent<?> event) {
if (event.getPayload() instanceof EventDataWrapper) {
-
final EventDataWrapper data = (EventDataWrapper) event.getPayload();
if (data.getRows() < 1) {
Copied: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchPanel.java (from r1422934, syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/UserSearchPanel.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchPanel.java?p2=syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchPanel.java&p1=syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/UserSearchPanel.java&r1=1422934&r2=1424538&rev=1424538&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/UserSearchPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchPanel.java Thu Dec 20 15:45:28 2012
@@ -18,594 +18,55 @@
*/
package org.apache.syncope.console.pages.panels;
-import java.lang.reflect.Field;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.syncope.client.search.AttributableCond;
-import org.apache.syncope.client.search.AttributeCond;
-import org.apache.syncope.client.search.MembershipCond;
import org.apache.syncope.client.search.NodeCond;
-import org.apache.syncope.client.search.ResourceCond;
-import org.apache.syncope.client.to.ResourceTO;
-import org.apache.syncope.client.to.RoleTO;
-import org.apache.syncope.client.to.UserTO;
import org.apache.syncope.console.commons.SearchCondWrapper;
-import org.apache.syncope.console.commons.SearchCondWrapper.FilterType;
-import org.apache.syncope.console.commons.SearchCondWrapper.OperationType;
-import org.apache.syncope.console.rest.ResourceRestClient;
-import org.apache.syncope.console.rest.RoleRestClient;
-import org.apache.syncope.console.rest.SchemaRestClient;
import org.apache.syncope.types.AttributableType;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.ajax.markup.html.form.AjaxButton;
-import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
-import org.apache.wicket.feedback.FeedbackMessage;
-import org.apache.wicket.feedback.IFeedbackMessageFilter;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.CheckBox;
-import org.apache.wicket.markup.html.form.DropDownChoice;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.IChoiceRenderer;
-import org.apache.wicket.markup.html.form.TextField;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.FeedbackPanel;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.ResourceModel;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class UserSearchPanel extends Panel {
+public class RoleSearchPanel extends AbstractSearchPanel {
- private static final long serialVersionUID = -1769527800450203738L;
+ private static final long serialVersionUID = 5757183539269316263L;
- /**
- * Logger.
- */
- private static final Logger LOG = LoggerFactory.getLogger(UserSearchPanel.class);
-
- private List<String> ATTRIBUTES_NOTINCLUDED = Arrays.asList(new String[]{
- "attributes", "derivedAttributes", "virtualAttributes", "serialVersionUID", "memberships", "resources",
- "password", "propagationStatusMap"});
-
- @SpringBean
- private SchemaRestClient schemaRestClient;
-
- @SpringBean
- private RoleRestClient roleRestClient;
-
- @SpringBean
- private ResourceRestClient resourceRestClient;
-
- private final boolean required;
-
- final private IModel<List<String>> dnames = new LoadableDetachableModel<List<String>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<String> load() {
- final List<String> details = new ArrayList<String>();
-
- Class<?> clazz = UserTO.class;
-
- // loop on class and all superclasses searching for field
- while (clazz != null && clazz != Object.class) {
- for (Field field : clazz.getDeclaredFields()) {
- if (!ATTRIBUTES_NOTINCLUDED.contains(field.getName())) {
- details.add(field.getName());
- }
- }
- clazz = clazz.getSuperclass();
- }
-
- Collections.reverse(details);
- return details;
- }
- };
-
- final private IModel<List<String>> unames = new LoadableDetachableModel<List<String>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<String> load() {
- return schemaRestClient.getSchemaNames(AttributableType.USER);
- }
- };
-
- final private IModel<List<String>> roleNames = new LoadableDetachableModel<List<String>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<String> load() {
- List<RoleTO> roleTOs = roleRestClient.getAllRoles();
-
- List<String> result = new ArrayList<String>(roleTOs.size());
- for (RoleTO role : roleTOs) {
- result.add(role.getDisplayName());
- }
-
- return result;
- }
- };
-
- final private IModel<List<String>> resourceNames = new LoadableDetachableModel<List<String>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<String> load() {
- List<ResourceTO> resourceTOs = resourceRestClient.getAllResources();
-
- List<String> result = new ArrayList<String>(resourceTOs.size());
-
- for (ResourceTO resource : resourceTOs) {
- result.add(resource.getName());
- }
-
- return result;
- }
- };
-
- final private IModel<List<AttributeCond.Type>> attributeTypes =
- new LoadableDetachableModel<List<AttributeCond.Type>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<AttributeCond.Type> load() {
- return Arrays.asList(AttributeCond.Type.values());
- }
- };
-
- final private IModel<List<FilterType>> filterTypes = new LoadableDetachableModel<List<FilterType>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<FilterType> load() {
- return Arrays.asList(FilterType.values());
- }
- };
-
- final FeedbackPanel searchFeedback;
-
- final List<SearchCondWrapper> searchConditionList;
-
- public UserSearchPanel(final String id) {
+ public RoleSearchPanel(final String id) {
this(id, null, true);
}
- public UserSearchPanel(final String id, final NodeCond initCond) {
+ public RoleSearchPanel(final String id, final NodeCond initCond) {
this(id, initCond, true);
}
- public UserSearchPanel(final String id, final NodeCond initNodeCond, final boolean required) {
- super(id);
- this.required = required;
-
- setOutputMarkupId(true);
+ public RoleSearchPanel(final String id, final NodeCond initCond, final boolean required) {
+ super(id, AttributableType.ROLE, initCond, required);
+ }
- final WebMarkupContainer searchFormContainer = new WebMarkupContainer("searchFormContainer");
- searchFormContainer.setOutputMarkupId(true);
+ @Override
+ protected void populate() {
+ super.populate();
- searchFeedback = new FeedbackPanel("searchFeedback", new IFeedbackMessageFilter() {
+ this.filterTypes = new LoadableDetachableModel<List<SearchCondWrapper.FilterType>>() {
- private static final long serialVersionUID = 6895024863321391672L;
+ private static final long serialVersionUID = 5275935387613157437L;
@Override
- public boolean accept(final FeedbackMessage message) {
- boolean result;
-
- // messages reported on the session have a null reporter
- if (message.getReporter() != null) {
- // only accept messages coming from the children
- // of the search form container
- result = searchFormContainer.contains(message.getReporter(), true);
- } else {
- result = false;
- }
-
+ protected List<SearchCondWrapper.FilterType> load() {
+ List<SearchCondWrapper.FilterType> result = new ArrayList<SearchCondWrapper.FilterType>();
+ result.add(SearchCondWrapper.FilterType.ATTRIBUTE);
+ result.add(SearchCondWrapper.FilterType.RESOURCE);
return result;
}
- });
- searchFeedback.setOutputMarkupId(true);
- add(searchFeedback);
-
- if (initNodeCond == null) {
- searchConditionList = new ArrayList<SearchCondWrapper>();
- searchConditionList.add(new SearchCondWrapper());
- } else {
- searchConditionList = getSearchCondWrappers(initNodeCond, null);
- }
- searchFormContainer.add(new SearchView("searchView", searchConditionList, searchFormContainer));
-
- AjaxButton addAndButton = new IndicatingAjaxButton("addAndButton", new ResourceModel("addAndButton")) {
-
- private static final long serialVersionUID = -4804368561204623354L;
-
- @Override
- protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
-
- SearchCondWrapper conditionWrapper = new SearchCondWrapper();
- conditionWrapper.setOperationType(OperationType.AND);
- searchConditionList.add(conditionWrapper);
- target.add(searchFormContainer);
- }
-
- @Override
- protected void onError(final AjaxRequestTarget target, final Form<?> form) {
- target.add(searchFormContainer);
- }
};
- addAndButton.setDefaultFormProcessing(false);
- searchFormContainer.add(addAndButton);
- AjaxButton addOrButton = new IndicatingAjaxButton("addOrButton", new ResourceModel("addOrButton")) {
+ this.roleNames = new LoadableDetachableModel<List<String>>() {
- private static final long serialVersionUID = -4804368561204623354L;
+ private static final long serialVersionUID = 5275935387613157437L;
@Override
- protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
- SearchCondWrapper conditionWrapper = new SearchCondWrapper();
- conditionWrapper.setOperationType(OperationType.OR);
- searchConditionList.add(conditionWrapper);
- target.add(searchFormContainer);
- }
-
- @Override
- protected void onError(final AjaxRequestTarget target, final Form<?> form) {
- target.add(searchFormContainer);
+ protected List<String> load() {
+ return Collections.<String>emptyList();
}
};
- addOrButton.setDefaultFormProcessing(false);
- searchFormContainer.add(addOrButton);
-
- add(searchFormContainer);
- }
-
- public FeedbackPanel getSearchFeedback() {
- return searchFeedback;
- }
-
- private List<SearchCondWrapper> getSearchCondWrappers(final NodeCond searchCond, final NodeCond.Type type) {
- LOG.debug("Search condition: {}", searchCond);
-
- List<SearchCondWrapper> wrappers = new ArrayList<SearchCondWrapper>();
-
- switch (searchCond.getType()) {
- case LEAF:
- case NOT_LEAF:
- final SearchCondWrapper wrapper = getSearchCondWrapper(searchCond);
-
- if (type != null) {
- switch (type) {
- case AND:
- wrapper.setOperationType(OperationType.AND);
- break;
- case OR:
- wrapper.setOperationType(OperationType.OR);
- break;
- default:
- // nothing to specify
- }
- }
-
- wrappers.add(wrapper);
- break;
-
- case AND:
- case OR:
- wrappers.addAll(getSearchCondWrappers(searchCond.getLeftNodeCond(), type));
- wrappers.addAll(getSearchCondWrappers(searchCond.getRightNodeCond(), searchCond.getType()));
- break;
-
- default:
- }
-
- LOG.debug("Search condition wrappers: {}", wrappers);
-
- return wrappers;
- }
-
- private SearchCondWrapper getSearchCondWrapper(final NodeCond searchCond) {
- SearchCondWrapper wrapper = new SearchCondWrapper();
-
- if (searchCond.getAttributableCond() != null) {
- wrapper.setFilterType(FilterType.ATTRIBUTE);
- wrapper.setFilterName(searchCond.getAttributableCond().getSchema());
- wrapper.setType(searchCond.getAttributableCond().getType());
- wrapper.setFilterValue(searchCond.getAttributableCond().getExpression());
- }
- if (searchCond.getAttributeCond() != null) {
- wrapper.setFilterType(FilterType.ATTRIBUTE);
- wrapper.setFilterName(searchCond.getAttributeCond().getSchema());
- wrapper.setType(searchCond.getAttributeCond().getType());
- wrapper.setFilterValue(searchCond.getAttributeCond().getExpression());
- }
- if (searchCond.getMembershipCond() != null) {
- wrapper.setFilterType(FilterType.MEMBERSHIP);
- RoleTO role = new RoleTO();
- role.setId(searchCond.getMembershipCond().getRoleId());
- role.setName(searchCond.getMembershipCond().getRoleName());
- wrapper.setFilterName(role.getDisplayName());
- }
- if (searchCond.getResourceCond() != null) {
- wrapper.setFilterType(FilterType.RESOURCE);
- wrapper.setFilterName(searchCond.getResourceCond().getResourceName());
- }
-
- wrapper.setNotOperator(searchCond.getType() == NodeCond.Type.NOT_LEAF);
-
- return wrapper;
- }
-
- public NodeCond buildSearchCond() {
- return buildSearchCond(searchConditionList);
- }
-
- private NodeCond buildSearchCond(final List<SearchCondWrapper> conditions) {
- SearchCondWrapper searchConditionWrapper = conditions.get(0);
- if (searchConditionWrapper == null || searchConditionWrapper.getFilterType() == null) {
- return null;
- }
-
- LOG.debug("Search conditions: fname {}; ftype {}; fvalue {}; OP {}; type {}; isnot {}", new Object[]{
- searchConditionWrapper.getFilterName(), searchConditionWrapper.getFilterType(),
- searchConditionWrapper.getFilterValue(), searchConditionWrapper.getOperationType(),
- searchConditionWrapper.getType(), searchConditionWrapper.isNotOperator()});
-
- NodeCond nodeCond = null;
-
- switch (searchConditionWrapper.getFilterType()) {
- case ATTRIBUTE:
- // AttributeCond or SyncopeUserCond
- final String schema = searchConditionWrapper.getFilterName();
-
- final AttributeCond attributeCond;
- if (dnames.getObject().contains(schema)) {
- attributeCond = new AttributableCond();
- nodeCond = searchConditionWrapper.isNotOperator()
- ? NodeCond.getNotLeafCond((AttributableCond) attributeCond)
- : NodeCond.getLeafCond((AttributableCond) attributeCond);
- } else {
- attributeCond = new AttributeCond();
- nodeCond = searchConditionWrapper.isNotOperator()
- ? NodeCond.getNotLeafCond(attributeCond)
- : NodeCond.getLeafCond(attributeCond);
- }
-
- attributeCond.setSchema(schema);
- attributeCond.setType(searchConditionWrapper.getType());
- attributeCond.setExpression(searchConditionWrapper.getFilterValue());
-
- break;
-
- case MEMBERSHIP:
- final MembershipCond membershipCond = new MembershipCond();
- membershipCond.setRoleId(RoleTO.fromDisplayName(searchConditionWrapper.getFilterName()));
- membershipCond.setRoleName(searchConditionWrapper.getFilterName().split(" ")[1]);
-
- if (searchConditionWrapper.isNotOperator()) {
- nodeCond = NodeCond.getNotLeafCond(membershipCond);
- } else {
- nodeCond = NodeCond.getLeafCond(membershipCond);
- }
-
- break;
-
- case RESOURCE:
- final ResourceCond resourceCond = new ResourceCond();
- resourceCond.setResourceName(searchConditionWrapper.getFilterName());
-
- if (searchConditionWrapper.isNotOperator()) {
- nodeCond = NodeCond.getNotLeafCond(resourceCond);
- } else {
- nodeCond = NodeCond.getLeafCond(resourceCond);
- }
-
- break;
-
- default:
- // nothing to do
- }
-
- LOG.debug("Processed condition {}", nodeCond);
-
- if (conditions.size() > 1) {
- List<SearchCondWrapper> subList = conditions.subList(1, conditions.size());
-
- if (OperationType.OR.equals(subList.get(0).getOperationType())) {
- nodeCond = NodeCond.getOrCond(nodeCond, buildSearchCond(subList));
- } else {
- nodeCond = NodeCond.getAndCond(nodeCond, buildSearchCond(subList));
- }
- }
-
- return nodeCond;
- }
-
- private class SearchView extends ListView<SearchCondWrapper> {
-
- private static final long serialVersionUID = -527351923968737757L;
-
- final private WebMarkupContainer searchFormContainer;
-
- public SearchView(final String id, final List<? extends SearchCondWrapper> list,
- final WebMarkupContainer searchFormContainer) {
-
- super(id, list);
- this.searchFormContainer = searchFormContainer;
- }
-
- @Override
- protected void populateItem(final ListItem<SearchCondWrapper> item) {
- final SearchCondWrapper searchCondition = item.getModelObject();
-
- if (item.getIndex() == 0) {
- item.add(new Label("operationType", ""));
- } else {
- item.add(new Label("operationType", searchCondition.getOperationType().toString()));
- }
-
- final CheckBox notOperator = new CheckBox("notOperator", new PropertyModel(searchCondition, "notOperator"));
- notOperator.add(new AjaxFormComponentUpdatingBehavior("onchange") {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- }
- });
- item.add(notOperator);
-
- final DropDownChoice<AttributeCond.Type> type = new DropDownChoice<AttributeCond.Type>("type",
- new PropertyModel<AttributeCond.Type>(searchCondition, "type"), attributeTypes);
- type.add(new AjaxFormComponentUpdatingBehavior("onchange") {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- }
- });
- item.add(type);
-
- final DropDownChoice<String> filterNameChooser = new DropDownChoice<String>("filterName",
- new PropertyModel<String>(searchCondition, "filterName"), (IModel) null);
- filterNameChooser.setOutputMarkupId(true);
- filterNameChooser.setRequired(required);
- filterNameChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- }
- });
- item.add(filterNameChooser);
-
- final TextField<String> filterValue = new TextField<String>("filterValue", new PropertyModel<String>(
- searchCondition, "filterValue"));
- filterValue.add(new AjaxFormComponentUpdatingBehavior("onchange") {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- }
- });
- item.add(filterValue);
-
- final DropDownChoice<FilterType> filterTypeChooser = new DropDownChoice<FilterType>("filterType",
- new PropertyModel<FilterType>(searchCondition, "filterType"), filterTypes);
- filterTypeChooser.setOutputMarkupId(true);
- filterTypeChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- target.add(searchFormContainer);
- }
- });
- filterTypeChooser.setRequired(required);
- item.add(filterTypeChooser);
-
- AjaxButton dropButton = new IndicatingAjaxButton("dropButton", new ResourceModel("dropButton")) {
-
- private static final long serialVersionUID = -4804368561204623354L;
-
- @Override
- protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
- getList().remove(Integer.valueOf(getParent().getId()).intValue());
- target.add(searchFormContainer);
- }
-
- @Override
- protected void onError(final AjaxRequestTarget target, final Form<?> form) {
- target.add(searchFormContainer);
- }
- };
- dropButton.setDefaultFormProcessing(false);
- if (item.getIndex() == 0) {
- dropButton.setVisible(false);
- }
- item.add(dropButton);
-
- if (searchCondition == null || searchCondition.getFilterType() == null) {
- filterNameChooser.setChoices(Collections.EMPTY_LIST);
- } else {
- switch (searchCondition.getFilterType()) {
- case ATTRIBUTE:
- final List<String> names = new ArrayList<String>(dnames.getObject());
-
- if (unames.getObject() != null && !unames.getObject().isEmpty()) {
- names.addAll(unames.getObject());
- }
- Collections.sort(names);
-
- filterNameChooser.setChoices(names);
- if (!type.isEnabled()) {
- type.setEnabled(true);
- type.setRequired(true);
- }
- if (!filterValue.isEnabled()) {
- filterValue.setEnabled(true);
- }
-
- break;
-
- case MEMBERSHIP:
- filterNameChooser.setChoices(roleNames);
- filterNameChooser.setChoiceRenderer(new IChoiceRenderer<String>() {
-
- private static final long serialVersionUID = -4288397951948436434L;
-
- @Override
- public Object getDisplayValue(String object) {
- return object;
- }
-
- @Override
- public String getIdValue(String object, int index) {
- return object;
- }
- });
- type.setEnabled(false);
- type.setRequired(false);
- type.setModelObject(null);
-
- filterValue.setEnabled(false);
- filterValue.setModelObject("");
-
- break;
-
- case RESOURCE:
- filterNameChooser.setChoices(resourceNames);
- type.setEnabled(false);
- type.setRequired(false);
- type.setModelObject(null);
-
- filterValue.setEnabled(false);
- filterValue.setModelObject("");
-
- break;
-
- default:
- filterNameChooser.setChoices(Collections.EMPTY_LIST);
- }
- }
- }
}
}
Added: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchResultPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchResultPanel.java?rev=1424538&view=auto
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchResultPanel.java (added)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchResultPanel.java Thu Dec 20 15:45:28 2012
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.syncope.console.pages.panels;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.syncope.client.search.NodeCond;
+import org.apache.syncope.client.to.AbstractAttributableTO;
+import org.apache.syncope.client.to.RoleTO;
+import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.console.pages.ResultStatusModalPage;
+import org.apache.syncope.console.pages.RoleModalPage;
+import org.apache.syncope.console.pages.StatusModalPage;
+import org.apache.syncope.console.rest.AbstractAttributableRestClient;
+import org.apache.syncope.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.wicket.Page;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
+import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.ResourceModel;
+
+public class RoleSearchResultPanel extends AbstractSearchResultPanel {
+
+ public <T extends AbstractAttributableTO> RoleSearchResultPanel(final String id, final boolean filtered,
+ final NodeCond searchCond, final PageReference callerRef,
+ final AbstractAttributableRestClient restClient) {
+
+ super(id, filtered, searchCond, callerRef, restClient);
+ }
+
+ @Override
+ protected List<IColumn<AbstractAttributableTO, String>> getColumns() {
+ final List<IColumn<AbstractAttributableTO, String>> columns =
+ new ArrayList<IColumn<AbstractAttributableTO, String>>();
+
+ final String[] colnames = {"id", "name", "entitlements"};
+ for (String name : colnames) {
+ columns.add(
+ new PropertyColumn<AbstractAttributableTO, String>(new ResourceModel(name, name), name, name));
+ }
+
+ columns.add(new AbstractColumn<AbstractAttributableTO, String>(new ResourceModel("actions", "")) {
+
+ @Override
+ public String getCssClass() {
+ return "action";
+ }
+
+ @Override
+ public void populateItem(final Item<ICellPopulator<AbstractAttributableTO>> cellItem,
+ final String componentId, final IModel<AbstractAttributableTO> model) {
+
+ final ActionLinksPanel panel = new ActionLinksPanel(componentId, model);
+
+ panel.add(new ActionLink() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target) {
+ statusmodal.setPageCreator(new ModalWindow.PageCreator() {
+
+ private static final long serialVersionUID = -7834632442532690940L;
+
+ @Override
+ public Page createPage() {
+ return new StatusModalPage(page.getPageReference(), statusmodal, model.getObject());
+ }
+ });
+
+ statusmodal.show(target);
+ }
+ }, ActionLink.ActionType.SEARCH, "Roles", "read");
+
+ panel.add(new ActionLink() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target) {
+ editmodal.setPageCreator(new ModalWindow.PageCreator() {
+
+ private static final long serialVersionUID = -7834632442532690940L;
+
+ @Override
+ public Page createPage() {
+ return new RoleModalPage(
+ page.getPageReference(), editmodal, (RoleTO) model.getObject());
+ }
+ });
+
+ editmodal.show(target);
+ }
+ }, ActionLink.ActionType.EDIT, "Roles", "update");
+
+ panel.add(new ActionLink() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target) {
+ try {
+ final RoleTO roleTO = (RoleTO) restClient.delete(model.getObject().getId());
+
+ page.setModalResult(true);
+
+ editmodal.setPageCreator(new ModalWindow.PageCreator() {
+
+ private static final long serialVersionUID = -7834632442532690940L;
+
+ @Override
+ public Page createPage() {
+ return new ResultStatusModalPage(editmodal, roleTO);
+ }
+ });
+
+ editmodal.show(target);
+ } catch (SyncopeClientCompositeErrorException scce) {
+ error(getString("operation_error") + ": " + scce.getMessage());
+ target.add(feedbackPanel);
+ }
+ }
+ }, ActionLink.ActionType.DELETE, "Roles", "delete");
+
+ cellItem.add(panel);
+ }
+ });
+
+ return columns;
+ }
+}
Propchange: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchResultPanel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchResultPanel.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSearchResultPanel.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java?rev=1424538&r1=1424537&r2=1424538&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java Thu Dec 20 15:45:28 2012
@@ -51,8 +51,8 @@ public class RoleSummaryPanel extends Pa
this(id, window, callerPageRef, null);
}
- public RoleSummaryPanel(final String id,
- final ModalWindow window, final PageReference callerPageRef, final Long selectedNodeId) {
+ public RoleSummaryPanel(final String id, final ModalWindow window, final PageReference callerPageRef,
+ final Long selectedNodeId) {
super(id);
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleTabPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleTabPanel.java?rev=1424538&r1=1424537&r2=1424538&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleTabPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/RoleTabPanel.java Thu Dec 20 15:45:28 2012
@@ -22,6 +22,7 @@ import org.apache.syncope.client.search.
import org.apache.syncope.client.search.NodeCond;
import org.apache.syncope.client.to.RoleTO;
import org.apache.syncope.console.commons.XMLRolesReader;
+import org.apache.syncope.console.rest.UserRestClient;
import org.apache.syncope.console.wicket.markup.html.tree.TreeActionLinkPanel;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -38,9 +39,12 @@ import org.apache.wicket.spring.injectio
public class RoleTabPanel extends Panel {
private static final long serialVersionUID = 859236186975983959L;
-
+
+ @SpringBean
+ private XMLRolesReader xmlRolesReader;
+
@SpringBean
- protected XMLRolesReader xmlRolesReader;
+ private UserRestClient restClient;
public RoleTabPanel(final String id, final RoleTO roleTO, final ModalWindow window,
final PageReference callerPageRef) {
@@ -57,7 +61,7 @@ public class RoleTabPanel extends Panel
form.setModel(new CompoundPropertyModel(roleTO));
form.setOutputMarkupId(true);
-
+
final RolePanel rolePanel = new RolePanel("rolePanel", form, roleTO);
rolePanel.setEnabled(false);
form.add(rolePanel);
@@ -66,19 +70,18 @@ public class RoleTabPanel extends Panel
userListContainer.setOutputMarkupId(true);
userListContainer.setEnabled(true);
- userListContainer.add(new ResultSetPanel("userList", true, null, callerPageRef));
+ userListContainer.add(new UserSearchResultPanel("userList", true, null, callerPageRef, restClient));
userListContainer.add(new IndicatingAjaxButton("search", new ResourceModel("search")) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
-
final MembershipCond membershipCond = new MembershipCond();
membershipCond.setRoleName(roleTO.getName());
NodeCond cond = NodeCond.getLeafCond(membershipCond);
- userListContainer.replace(new ResultSetPanel("userList", true, cond, callerPageRef));
+ userListContainer.replace(new UserSearchResultPanel("userList", true, cond, callerPageRef, restClient));
target.add(userListContainer);
}
@@ -87,7 +90,7 @@ public class RoleTabPanel extends Panel
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
}
});
-
+
form.add(userListContainer);
add(form);
}
Added: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SearchView.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SearchView.java?rev=1424538&view=auto
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SearchView.java (added)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SearchView.java Thu Dec 20 15:45:28 2012
@@ -0,0 +1,291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.syncope.console.pages.panels;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.syncope.client.search.AttributeCond;
+import org.apache.syncope.console.commons.SearchCondWrapper;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;
+import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.CheckBox;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.IChoiceRenderer;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.model.ResourceModel;
+
+public class SearchView extends ListView<SearchCondWrapper> {
+
+ private static final long serialVersionUID = -527351923968737757L;
+
+ private final WebMarkupContainer searchFormContainer;
+
+ private final boolean required;
+
+ private final IModel<List<AttributeCond.Type>> attributeTypes;
+
+ private final IModel<List<SearchCondWrapper.FilterType>> filterTypes;
+
+ private final IModel<List<String>> anames;
+
+ private final IModel<List<String>> dnames;
+
+ private final IModel<List<String>> roleNames;
+
+ private final IModel<List<String>> resourceNames;
+
+ public SearchView(final String id, final List<? extends SearchCondWrapper> list,
+ final WebMarkupContainer searchFormContainer,
+ final boolean required,
+ final IModel<List<AttributeCond.Type>> attributeTypes,
+ final IModel<List<SearchCondWrapper.FilterType>> filterTypes,
+ final IModel<List<String>> anames,
+ final IModel<List<String>> dnames,
+ final IModel<List<String>> roleNames,
+ final IModel<List<String>> resourceNames) {
+
+ super(id, list);
+
+ this.searchFormContainer = searchFormContainer;
+ this.required = required;
+ this.attributeTypes = attributeTypes;
+ this.filterTypes = filterTypes;
+ this.anames = anames;
+ this.dnames = dnames;
+ this.roleNames = roleNames;
+ this.resourceNames = resourceNames;
+ }
+
+ @Override
+ protected void populateItem(final ListItem<SearchCondWrapper> item) {
+ final SearchCondWrapper searchCondition = item.getModelObject();
+
+ if (item.getIndex() == 0) {
+ item.add(new Label("operationType", ""));
+ } else {
+ item.add(new Label("operationType", searchCondition.getOperationType().toString()));
+ }
+
+ final CheckBox notOperator = new CheckBox("notOperator", new PropertyModel(searchCondition, "notOperator"));
+ notOperator.add(new AjaxFormComponentUpdatingBehavior("onchange") {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ }
+ });
+ item.add(notOperator);
+
+ final DropDownChoice<AttributeCond.Type> type = new DropDownChoice<AttributeCond.Type>("type",
+ new PropertyModel<AttributeCond.Type>(searchCondition, "type"), attributeTypes);
+ type.add(new AjaxFormComponentUpdatingBehavior("onchange") {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ }
+ });
+ item.add(type);
+
+ final DropDownChoice<String> filterNameChooser = new DropDownChoice<String>("filterName",
+ new PropertyModel<String>(searchCondition, "filterName"), (IModel) null);
+ filterNameChooser.setOutputMarkupId(true);
+ filterNameChooser.setRequired(required);
+ filterNameChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ }
+ });
+ item.add(filterNameChooser);
+
+ final TextField<String> filterValue = new TextField<String>("filterValue", new PropertyModel<String>(
+ searchCondition, "filterValue"));
+ filterValue.add(new AjaxFormComponentUpdatingBehavior("onchange") {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ }
+ });
+ item.add(filterValue);
+
+ final DropDownChoice<SearchCondWrapper.FilterType> filterTypeChooser =
+ new DropDownChoice<SearchCondWrapper.FilterType>("filterType",
+ new PropertyModel<SearchCondWrapper.FilterType>(searchCondition, "filterType"), filterTypes);
+ filterTypeChooser.setOutputMarkupId(true);
+ filterTypeChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ target.add(searchFormContainer);
+ }
+ });
+ filterTypeChooser.setRequired(required);
+ item.add(filterTypeChooser);
+
+ AjaxButton addAndButton = new IndicatingAjaxButton("addAndButton", new ResourceModel("addAndButton")) {
+
+ private static final long serialVersionUID = -4804368561204623354L;
+
+ @Override
+ protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
+ SearchCondWrapper conditionWrapper = new SearchCondWrapper();
+ conditionWrapper.setOperationType(SearchCondWrapper.OperationType.AND);
+ SearchView.this.getModelObject().add(conditionWrapper);
+ target.add(searchFormContainer);
+ }
+
+ @Override
+ protected void onError(final AjaxRequestTarget target, final Form<?> form) {
+ target.add(searchFormContainer);
+ }
+ };
+ addAndButton.setDefaultFormProcessing(false);
+ if (item.getIndex() != getModelObject().size() - 1) {
+ addAndButton.setVisible(false);
+ }
+ item.add(addAndButton);
+
+ AjaxButton addOrButton = new IndicatingAjaxButton("addOrButton", new ResourceModel("addOrButton")) {
+
+ private static final long serialVersionUID = -4804368561204623354L;
+
+ @Override
+ protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
+ SearchCondWrapper conditionWrapper = new SearchCondWrapper();
+ conditionWrapper.setOperationType(SearchCondWrapper.OperationType.OR);
+ SearchView.this.getModelObject().add(conditionWrapper);
+ target.add(searchFormContainer);
+ }
+
+ @Override
+ protected void onError(final AjaxRequestTarget target, final Form<?> form) {
+ target.add(searchFormContainer);
+ }
+ };
+ addOrButton.setDefaultFormProcessing(false);
+ if (item.getIndex() != getModelObject().size() - 1) {
+ addOrButton.setVisible(false);
+ }
+ item.add(addOrButton);
+
+ AjaxButton dropButton = new IndicatingAjaxButton("dropButton", new ResourceModel("dropButton")) {
+
+ private static final long serialVersionUID = -4804368561204623354L;
+
+ @Override
+ protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
+ getList().remove(Integer.valueOf(getParent().getId()).intValue());
+ target.add(searchFormContainer);
+ }
+
+ @Override
+ protected void onError(final AjaxRequestTarget target, final Form<?> form) {
+ target.add(searchFormContainer);
+ }
+ };
+ dropButton.setDefaultFormProcessing(false);
+ if (item.getIndex() == 0) {
+ dropButton.setVisible(false);
+ }
+ item.add(dropButton);
+
+ if (searchCondition == null || searchCondition.getFilterType() == null) {
+ filterNameChooser.setChoices(Collections.<String>emptyList());
+ } else {
+ switch (searchCondition.getFilterType()) {
+ case ATTRIBUTE:
+ final List<String> names = new ArrayList<String>(dnames.getObject());
+
+ if (anames.getObject() != null && !anames.getObject().isEmpty()) {
+ names.addAll(anames.getObject());
+ }
+ Collections.sort(names);
+
+ filterNameChooser.setChoices(names);
+ if (!type.isEnabled()) {
+ type.setEnabled(true);
+ type.setRequired(true);
+ }
+ if (!filterValue.isEnabled()) {
+ filterValue.setEnabled(true);
+ }
+
+ break;
+
+ case MEMBERSHIP:
+ filterNameChooser.setChoices(roleNames);
+ filterNameChooser.setChoiceRenderer(new IChoiceRenderer<String>() {
+
+ private static final long serialVersionUID = -4288397951948436434L;
+
+ @Override
+ public Object getDisplayValue(final String object) {
+ return object;
+ }
+
+ @Override
+ public String getIdValue(final String object, final int index) {
+ return object;
+ }
+ });
+ type.setEnabled(false);
+ type.setRequired(false);
+ type.setModelObject(null);
+
+ filterValue.setEnabled(false);
+ filterValue.setModelObject("");
+
+ break;
+
+ case RESOURCE:
+ filterNameChooser.setChoices(resourceNames);
+ type.setEnabled(false);
+ type.setRequired(false);
+ type.setModelObject(null);
+
+ filterValue.setEnabled(false);
+ filterValue.setModelObject("");
+
+ break;
+
+ default:
+ filterNameChooser.setChoices(Collections.<String>emptyList());
+ }
+ }
+ }
+}
Propchange: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SearchView.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SearchView.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SearchView.java
------------------------------------------------------------------------------
svn:mime-type = text/plain