Skip to content

Commit

Permalink
Organizationa structure page: performance improvement (MID-3938)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed May 29, 2017
1 parent 5e7910a commit 76f7039
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 25 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,11 +20,16 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.column.InlineMenuable;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType;

/**
Expand All @@ -34,6 +39,8 @@ public class SelectableBean<T extends Serializable> extends Selectable implement
private static final long serialVersionUID = 1L;

public static final String F_VALUE = "value";

private static final Trace LOGGER = TraceManager.getTrace(SelectableBean.class);

/**
* Value of object that this bean represents. It may be null in case that non-success result is set.
Expand Down Expand Up @@ -90,6 +97,7 @@ public int hashCode() {
return result;
}

@SuppressWarnings("rawtypes")
@Override
public boolean equals(Object obj) {
if (this == obj) {
Expand All @@ -113,7 +121,11 @@ public boolean equals(Object obj) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
// In case both values are objects then compare only OIDs.
// that should be enough. Comparing complete objects may be slow
// (e.g. if the objects have many assignments) and Wicket
// invokes compare a lot ...
} else if (!MiscSchemaUtil.quickEquals(value, other.value)) {
return false;
}
return true;
Expand Down
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2010-2017 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.orgs;

import java.util.ArrayList;
Expand Down Expand Up @@ -32,8 +47,9 @@
import com.evolveum.midpoint.web.session.SessionStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;

public abstract class AbstractOrgTabPanel extends BasePanel{

public abstract class AbstractOrgTabPanel extends BasePanel {
private static final long serialVersionUID = 1L;

private static final Trace LOGGER = TraceManager.getTrace(AbstractOrgTabPanel.class);

public static final String PARAM_ORG_RETURN = "org";
Expand All @@ -52,7 +68,8 @@ public AbstractOrgTabPanel(String id, PageBase pageBase) {

private void initLayout() {
final IModel<List<ITab>> tabModel = new LoadableModel<List<ITab>>(false) {

private static final long serialVersionUID = 1L;

@Override
protected List<ITab> load() {
LOGGER.debug("Loading org. roots for tabs for tabbed panel.");
Expand All @@ -62,11 +79,14 @@ protected List<ITab> load() {
for (PrismObject<OrgType> root : roots) {
final String oid = root.getOid();
tabs.add(new AbstractTab(createTabTitle(root)) {
private static final long serialVersionUID = 1L;
private int tabId = tabs.size();

@Override
public WebMarkupContainer getPanel(String panelId) {
add(new AjaxEventBehavior("load") {
private static final long serialVersionUID = 1L;

protected void onEvent(final AjaxRequestTarget target) {
SessionStorage storage = getPageBase().getSessionStorage();
storage.getUsers().setSelectedTabId(tabId);
Expand All @@ -91,7 +111,7 @@ protected void onEvent(final AjaxRequestTarget target) {
final SessionStorage storage = getPageBase().getSessionStorage();
int selectedTab = storage.getUsers().getSelectedTabId() == -1 ? 0 : storage.getUsers().getSelectedTabId();
List<ITab> tabsList = tabModel.getObject();
if (tabsList == null || (selectedTab > tabsList.size() - 1)){
if (tabsList == null || (selectedTab > tabsList.size() - 1)) {
storage.getUsers().setSelectedTabId(0);
selectedTab = 0;
}
Expand Down Expand Up @@ -125,6 +145,7 @@ public AjaxTabbedPanel<ITab> getTabbedPanel(){

private IModel<String> createTabTitle(final PrismObject<OrgType> org) {
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;

@Override
public String getObject() {
Expand Down Expand Up @@ -160,7 +181,6 @@ private List<PrismObject<OrgType>> loadOrgRoots() {
if (WebComponentUtil.showResultInPage(result)) {
getPageBase().showResult(result);
}

return list;
}

Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015-2016 Evolveum
* Copyright (c) 2015-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,6 @@

import com.evolveum.midpoint.web.page.admin.users.PageOrgTree;
import com.evolveum.midpoint.web.session.OrgTreeStateStorage;
import com.evolveum.midpoint.web.session.PageStorage;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
Expand All @@ -41,6 +40,8 @@
import org.apache.wicket.model.Model;

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.TabbedPanel;
import com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn;
import com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn;
Expand All @@ -58,6 +59,8 @@

public class OrgTreePanel extends AbstractTreeTablePanel {

private static final Trace LOGGER = TraceManager.getTrace(OrgTreePanel.class);

private boolean selectable;
private String treeTitleKey = "";
SessionStorage storage;
Expand All @@ -76,6 +79,8 @@ public OrgTreePanel(String id, IModel<String> rootOid, boolean selectable, Strin
this.treeTitleKey = treeTitleKey;
this.selectable = selectable;
selected = new LoadableModel<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;

@Override
protected SelectableBean<OrgType> load() {
TabbedPanel currentTabbedPanel = null;
Expand All @@ -90,11 +95,13 @@ protected SelectableBean<OrgType> load() {
}
}
}
SelectableBean<OrgType> bean;
if (OrgTreePanel.this.getSelectedItem(getOrgTreeStateStorage()) != null) {
return OrgTreePanel.this.getSelectedItem(getOrgTreeStateStorage());
bean = OrgTreePanel.this.getSelectedItem(getOrgTreeStateStorage());
} else {
return getRootFromProvider();
bean = getRootFromProvider();
}
return bean;
}
};

Expand Down Expand Up @@ -129,6 +136,8 @@ private void initLayout() {
treeHeader.add(treeMenu);

ISortableTreeProvider provider = new OrgTreeProvider(this, getModel()) {
private static final long serialVersionUID = 1L;

@Override
protected List<InlineMenuItem> createInlineMenuItems(OrgType org) {
return createTreeChildrenMenu(org);
Expand All @@ -145,6 +154,7 @@ protected List<InlineMenuItem> createInlineMenuItems(OrgType org) {
columns.add(new InlineMenuHeaderColumn(createTreeChildrenMenu(null)));

WebMarkupContainer treeContainer = new WebMarkupContainer(ID_TREE_CONTAINER) {
private static final long serialVersionUID = 1L;

@Override
public void renderHead(IHeaderResponse response) {
Expand All @@ -162,8 +172,9 @@ public void renderHead(IHeaderResponse response) {
};
add(treeContainer);

TableTree<SelectableBean<OrgType>, String> tree = new TableTree<SelectableBean<OrgType>, String>(
ID_TREE, columns, provider, Integer.MAX_VALUE, new TreeStateModel(this, provider){
TreeStateModel treeStateMode = new TreeStateModel(this, provider) {
private static final long serialVersionUID = 1L;

@Override
public Set<SelectableBean<OrgType>> getExpandedItems(){
return OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
Expand All @@ -176,11 +187,16 @@ public SelectableBean<OrgType> getCollapsedItem(){
public void setCollapsedItem(SelectableBean<OrgType> item){
OrgTreePanel.this.setCollapsedItem(null, getOrgTreeStateStorage());
}
}) {
};

TableTree<SelectableBean<OrgType>, String> tree = new TableTree<SelectableBean<OrgType>, String>(
ID_TREE, columns, provider, Integer.MAX_VALUE, treeStateMode) {
private static final long serialVersionUID = 1L;

@Override
protected Component newContentComponent(String id, IModel<SelectableBean<OrgType>> model) {
return new SelectableFolderContent(id, this, model, selected) {
private static final long serialVersionUID = 1L;

@Override
protected void onClick(AjaxRequestTarget target) {
Expand All @@ -198,7 +214,8 @@ protected Item<SelectableBean<OrgType>> newRowItem(String id, int index,
final IModel<SelectableBean<OrgType>> model) {
Item<SelectableBean<OrgType>> item = super.newRowItem(id, index, model);
item.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {

private static final long serialVersionUID = 1L;

@Override
public String getObject() {
SelectableBean<OrgType> itemObject = model.getObject();
Expand Down Expand Up @@ -242,6 +259,7 @@ protected void onModelChanged() {
}

private static class TreeStateModel extends AbstractReadOnlyModel<Set<SelectableBean<OrgType>>> {
private static final long serialVersionUID = 1L;

private TreeStateSet<SelectableBean<OrgType>> set = new TreeStateSet<SelectableBean<OrgType>>();
private ISortableTreeProvider provider;
Expand Down Expand Up @@ -313,6 +331,7 @@ private List<InlineMenuItem> createTreeMenuInternal() {

InlineMenuItem item = new InlineMenuItem(createStringResource("TreeTablePanel.collapseAll"),
new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
Expand All @@ -322,6 +341,7 @@ public void onClick(AjaxRequestTarget target) {
items.add(item);
item = new InlineMenuItem(createStringResource("TreeTablePanel.expandAll"),
new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.web.page.admin.users;

import org.apache.wicket.markup.html.panel.Panel;
Expand Down Expand Up @@ -61,7 +60,8 @@ public PageOrgTree() {

private void initLayout() {
AbstractOrgTabPanel tabbedPanel = new AbstractOrgTabPanel(ID_ORG_PANEL, this) {

private static final long serialVersionUID = 1L;

@Override
protected Panel createTreePanel(String id, Model<String> model, PageBase pageBase) {
return new TreeTablePanel(id, model, PageOrgTree.this);
Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015-2016 Evolveum
* Copyright (c) 2015-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -142,7 +142,6 @@ 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>());
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,6 +30,7 @@
* @author lazyman
*/
public class SelectableFolderContent extends Folder<SelectableBean<OrgType>> {
private static final long serialVersionUID = 1L;

private AbstractTree tree;
private IModel<SelectableBean<OrgType>> selected;
Expand All @@ -45,6 +46,7 @@ public SelectableFolderContent(String id, AbstractTree<SelectableBean<OrgType>>
@Override
protected IModel<?> newLabelModel(final IModel<SelectableBean<OrgType>> model) {
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;

@Override
public String getObject() {
Expand Down

0 comments on commit 76f7039

Please sign in to comment.