Skip to content

Commit

Permalink
session storage for member panels. optimize session size for org tree…
Browse files Browse the repository at this point in the history
… page

(cherry picked from commit 27135bf)
  • Loading branch information
katkav committed Jan 19, 2022
1 parent 8b216bc commit 5194bb5
Show file tree
Hide file tree
Showing 24 changed files with 552 additions and 630 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -658,12 +658,6 @@ protected void onBeforeRender() {
getSession().getFeedbackMessages().clear();
}

@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(OnDomReadyHeaderItem.forScript("jQuery(document).on('scroll', function(){console.trace('blabla')})"));
}

private void initHeaderLayout(WebMarkupContainer container) {
WebMarkupContainer menuToggle = new WebMarkupContainer(ID_MENU_TOGGLE);
menuToggle.add(createUserStatusBehaviour());
Expand Down Expand Up @@ -810,8 +804,8 @@ public boolean isVisible() {

private void initLayout() {
TransparentWebMarkupContainer body = new TransparentWebMarkupContainer(ID_BODY);
body.add(new AttributeAppender("class", "hold-transition ", " "));
body.add(new AttributeAppender("class", "custom-hold-transition ", " "));
// body.add(new AttributeAppender("class", "hold-transition ", " "));
// body.add(new AttributeAppender("class", "custom-hold-transition ", " "));

body.add(AttributeAppender.append("class", new IModel<String>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public Search<C> load() {
}
}
if (storage != null) {

storage.setSearch(search);
}
return search;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.gui.impl.page.admin.focus.component;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.util.DisplayableValue;
import com.evolveum.midpoint.web.component.search.PropertySearchItem;
import com.evolveum.midpoint.web.component.search.Search;
import com.evolveum.midpoint.web.component.search.SearchItemDefinition;

import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

import org.apache.commons.lang3.BooleanUtils;
import org.jetbrains.annotations.NotNull;

public class DeadShadowSearchItem extends PropertySearchItem<Boolean> {

public DeadShadowSearchItem(Search search, @NotNull SearchItemDefinition definition) {
super(search, definition);
setFixed(true);
}

@Override
public ObjectFilter transformToFilter() {
DisplayableValue<Boolean> selectedValue = getValue();
if (selectedValue == null) {
return null;
}
Boolean value = selectedValue.getValue();
if (BooleanUtils.isTrue(value)) {
return null; // let the default behavior to take their chance
}

return PrismContext.get().queryFor(ShadowType.class)
.not()
.item(ShadowType.F_DEAD)
.eq(true)
.buildFilter();
}

@Override
protected boolean canRemoveSearchItem() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -291,33 +291,38 @@ private void addDeadSearchItem(Search search) {
SearchItemDefinition def = new SearchItemDefinition(ShadowType.F_DEAD,
getShadowDefinition().findPropertyDefinition(ShadowType.F_DEAD),
Arrays.asList(new SearchValue<>(true), new SearchValue<>(false)));
PropertySearchItem<Boolean> deadSearchItem = new PropertySearchItem<>(search, def, new SearchValue<>(false)) {

@Override
public ObjectFilter transformToFilter() {
DisplayableValue<Boolean> selectedValue = getValue();
if (selectedValue == null) {
return null;
}
Boolean value = selectedValue.getValue();
if (BooleanUtils.isTrue(value)) {
return null; // let the default behavior to take their chance
}

return PrismContext.get().queryFor(ShadowType.class)
.not()
.item(ShadowType.F_DEAD)
.eq(true)
.buildFilter();
}

@Override
protected boolean canRemoveSearchItem() {
return false;
}
};
deadSearchItem.setFixed(true);
search.addSpecialItem(deadSearchItem);
DeadShadowSearchItem deadShadowSearchItem = new DeadShadowSearchItem(search, def);
search.addSpecialItem(deadShadowSearchItem);
// SearchItemDefinition def = new SearchItemDefinition(ShadowType.F_DEAD,
// getShadowDefinition().findPropertyDefinition(ShadowType.F_DEAD),
// Arrays.asList(new SearchValue<>(true), new SearchValue<>(false)));
// PropertySearchItem<Boolean> deadSearchItem = new PropertySearchItem<>(search, def, new SearchValue<>(false)) {
//
// @Override
// public ObjectFilter transformToFilter() {
// DisplayableValue<Boolean> selectedValue = getValue();
// if (selectedValue == null) {
// return null;
// }
// Boolean value = selectedValue.getValue();
// if (BooleanUtils.isTrue(value)) {
// return null; // let the default behavior to take their chance
// }
//
// return PrismContext.get().queryFor(ShadowType.class)
// .not()
// .item(ShadowType.F_DEAD)
// .eq(true)
// .buildFilter();
// }
//
// @Override
// protected boolean canRemoveSearchItem() {
// return false;
// }
// };
// deadSearchItem.setFixed(true);
// search.addSpecialItem(deadSearchItem);
}

private void loadShadowIfNeeded(IModel<PrismContainerValueWrapper<ShadowType>> rowModel, AjaxRequestTarget target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public OrgMemberPanel(String id, FocusDetailsModels<OrgType> model, ContainerPan

@Override
protected ObjectQuery getActionQuery(QueryScope scope, @NotNull Collection<QName> relations) {
if (getMemberPanelStorage().isSearchScope(SearchBoxScopeType.ONE_LEVEL) ||
(getMemberPanelStorage().isSearchScope(SearchBoxScopeType.SUBTREE)
if (getSearchBoxConfiguration().isSearchScope(SearchBoxScopeType.ONE_LEVEL) ||
(getSearchBoxConfiguration().isSearchScope(SearchBoxScopeType.SUBTREE)
&& !QueryScope.ALL.equals(scope))) {
return super.getActionQuery(scope, relations);
} else {
String oid = getModelObject().getOid();

ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(getModelObject(), getMemberPanelStorage().getDefaultRelation());
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(getModelObject(), getSearchBoxConfiguration().getDefaultRelation());
ObjectQuery query = getPageBase().getPrismContext().queryFor(getSearchTypeClass())
.type(getSearchTypeClass())
.isChildOf(ref.asReferenceValue()).build();
Expand Down Expand Up @@ -154,7 +154,7 @@ protected String getStorageKeyTabSuffix() {

@Override
protected @NotNull List<QName> getRelationsForRecomputeTask() {
if (CollectionUtils.isEmpty(getMemberPanelStorage().getSupportedRelations())) {
if (CollectionUtils.isEmpty(getSearchBoxConfiguration().getSupportedRelations())) {
return Collections.singletonList(PrismConstants.Q_ANY);
}
return super.getRelationsForRecomputeTask();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,19 @@ public String debugDump(int indent) {
DebugUtil.indentDebugDump(sb, indent);
sb.append("Search\n");
DebugUtil.debugDumpWithLabelLn(sb, "advancedQuery", advancedQuery, indent + 1);
DebugUtil.dumpObjectSizeEstimate(sb, "advancedQuery", advancedQuery, indent + 2);
DebugUtil.debugDumpWithLabelLn(sb, "advancedError", advancedError, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "type", getTypeClass(), indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "allDefinitions", allDefinitions, indent + 1);
// DebugUtil.dumpObjectSizeEstimate(sb, "allDefinitions", allDefinitions, indent + 2);
DebugUtil.debugDumpWithLabelLn(sb, "availableDefinitions", availableDefinitions, indent + 1);
// DebugUtil.dumpObjectSizeEstimate(sb, "availableDefinitions", availableDefinitions, indent + 2);
DebugUtil.debugDumpWithLabelLn(sb, "items", items, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "specialItems", specialItems, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "compositedSpecialItems", compositedSpecialItems, indent + 1);
DebugUtil.dumpObjectSizeEstimate(sb, "compositedSpecialItemsSize", compositedSpecialItems, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "objectCollectionSpecialItems", objectCollectionSearchItem, indent + 1);
DebugUtil.dumpObjectSizeEstimate(sb, "objectCollectionSpecialItemsSize", objectCollectionSearchItem, indent + 1);
DebugUtil.debugDumpWithLabel(sb, "items", items, indent + 1);
return sb.toString();
}
Expand Down Expand Up @@ -883,4 +892,13 @@ public boolean isAllowedSearchMode(SearchBoxModeType searchBoxModeType){
public List<SearchBoxModeType> getAllowedSearchType() {
return allowedSearchType;
}

// public SearchBoxConfigurationType getSearchBoxConfig() {
// SearchBoxConfigurationType searchBoxConfigurationType = new SearchBoxConfigurationType();
// searchBoxConfigurationType.setAllowToConfigureSearchItems(canConfigure);
// searchBoxConfigurationType.setDefaultMode(searchType);
//
// ObjectTypeSearchItemConfigurationType objectTypeSearchItemConfigurationType = new ObjectTypeSearchItemConfigurationType();
// searchBoxConfigurationType.setObjectTypeConfiguration();
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;

/**
* @author Viliam Repan (lazyman)
*/
public abstract class SearchItem implements Serializable {
public abstract class SearchItem implements Serializable, DebugDumpable {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -88,4 +90,18 @@ protected boolean canRemoveSearchItem() {
public boolean isEnabled() {
return true;
}

@Override
public String debugDump() {
return debugDump(0);
}

@Override
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
DebugUtil.indentDebugDump(sb, indent);
sb.append("Search item\n");
DebugUtil.debugDumpWithLabelLn(sb, "searchItemDefinition", definition, indent + 1);
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.DisplayableValue;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchItemType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
Expand All @@ -22,14 +24,14 @@

import javax.xml.namespace.QName;

public class SearchItemDefinition implements Serializable, Comparable<SearchItemDefinition> {
public class SearchItemDefinition implements Serializable, Comparable<SearchItemDefinition>, DebugDumpable {

public static final String F_SELECTED = "selected";
public static final String F_NAME = "name";
public static final String F_HELP = "help";

private ItemPath path;
private ItemDefinition def;
private transient ItemDefinition def;
private SearchItemType predefinedFilter;
private PolyStringType displayName;
private List allowedValues;
Expand Down Expand Up @@ -159,4 +161,23 @@ public String getHelp(){
}
return help;
}

@Override
public String debugDump() {
return debugDump(0);
}

@Override
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
DebugUtil.indentDebugDump(sb, indent);
sb.append("Search item definition\n");
DebugUtil.shortDump(sb, path);
DebugUtil.debugDumpWithLabelLn(sb, "def", def, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "predefinedFilter", predefinedFilter, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "displayName", displayName, indent + 1);

DebugUtil.dumpObjectSizeEstimate(sb, "searchItemSize", this, indent + 1);
return sb.toString();
}
}

0 comments on commit 5194bb5

Please sign in to comment.