Skip to content

Commit

Permalink
do not load resource for projections table, do not cache resource a a…
Browse files Browse the repository at this point in the history
…ssociations definitions in association wrapper
  • Loading branch information
katkav committed Sep 30, 2021
1 parent 5ec7d7b commit ef69846
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package com.evolveum.midpoint.gui.api.factory.wrapper;

import com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition;
import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition;
import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.model.api.MetadataItemProcessingSpec;
import com.evolveum.midpoint.prism.PrismObject;
Expand Down Expand Up @@ -44,6 +46,9 @@ public class WrapperContext {
private ResourceType resource;
private ResourceShadowDiscriminator discriminator;

//Association related attributes
private Collection<RefinedAssociationDefinition> refinedAssociationDefinitions;

//used e.g. for metadata - opertionsla attributes but want to create wrappers for them
private boolean createOperational;

Expand Down Expand Up @@ -112,6 +117,14 @@ public void setResource(ResourceType resource) {
this.resource = resource;
}

public Collection<RefinedAssociationDefinition> getRefinedAssociationDefinitions() {
return refinedAssociationDefinitions;
}

public void setRefinedAssociationDefinitions(Collection<RefinedAssociationDefinition> refinedAssociationDefinitions) {
this.refinedAssociationDefinitions = refinedAssociationDefinitions;
}

public void setDiscriminator(ResourceShadowDiscriminator discriminator) {
this.discriminator = discriminator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,7 @@ protected Panel createValuePanel(String id, IModel<PrismReferenceWrapper<R>> mod

@Override
protected Panel createLink(String id, IModel<PrismValueWrapper<R>> object) {
AjaxLinkPanel ajaxLinkPanel = new AjaxLinkPanel(id, new IModel<String>() {

@Override
public String getObject() {
return createLabel(object.getObject());
}

}) {
AjaxLinkPanel ajaxLinkPanel = new AjaxLinkPanel(id, (IModel<String>) () -> createLabel(object.getObject())) {
private static final long serialVersionUID = 1L;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ protected PrismContainerWrapper<ShadowAssociationType> createWrapperInternal(Pri
return super.createWrapperInternal(parent, childContainer, status, ctx);
}

ctx.setResource(resource.asObjectable());
ctx.setRefinedAssociationDefinitions(refinedAssociationDefinitions);

ShadowAssociationWrapperImpl associationWrapper = createShadowAssociationWrapper(parent, childContainer, resource,
refinedAssociationDefinitions, shadow, status, parentResult);

ShadowAssociationWrapperImpl associationWrapper = createShadowAssociationWrapper(parent, childContainer, shadow, status, ctx);
if (associationWrapper == null) {
return super.createWrapperInternal(parent, childContainer, status, ctx);
}
Expand Down Expand Up @@ -177,13 +179,14 @@ private boolean isNotShadow(WrapperContext ctx, OperationResult parentResult) {
}

private ShadowAssociationWrapperImpl createShadowAssociationWrapper(PrismContainerValueWrapper<?> parent,
PrismContainer<ShadowAssociationType> childContainer, PrismObject<ResourceType> resource,
Collection<RefinedAssociationDefinition> refinedAssociationDefinitions,
ShadowType shadow, ItemStatus status, OperationResult parentResult) {
PrismContainer<ShadowAssociationType> childContainer, ShadowType shadow, ItemStatus status, WrapperContext ctx) {
//we need to switch association wrapper to single value
//the transformation will be as following:
// we have single value ShadowAssociationType || ResourceObjectAssociationType, and from each shadowAssociationType we will create
// property - name of the property will be association type(QName) and the value will be shadowRef
OperationResult parentResult = ctx.getResult();

ResourceType resource = ctx.getResource();
PrismContainerDefinition<ShadowAssociationType> associationDefinition = childContainer.getDefinition().clone();
associationDefinition.toMutable().setMaxOccurs(1);
PrismContainer associationTransformed;
Expand All @@ -196,9 +199,6 @@ private ShadowAssociationWrapperImpl createShadowAssociationWrapper(PrismContain

}
ShadowAssociationWrapperImpl associationWrapper = new ShadowAssociationWrapperImpl(parent, associationTransformed, status);

associationWrapper.setResource(resource.asObjectable());
associationWrapper.setRefinedAssociationDefinitions(refinedAssociationDefinitions);
return associationWrapper;
}

Expand All @@ -215,12 +215,12 @@ protected List<PrismContainerValueWrapper<ShadowAssociationType>> createValuesWr
ItemStatus.ADDED == associationWrapper.getStatus() ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, context);

Collection<PrismReferenceWrapper> shadowReferences = new ArrayList<>();
for (RefinedAssociationDefinition def : associationWrapper.getRefinedAssociationDefinitions()) {
for (RefinedAssociationDefinition def : context.getRefinedAssociationDefinitions()) {
PrismReference shadowAss = fillInShadowReference(def, item);

PrismReferenceWrapper shadowReference = (PrismReferenceWrapper) referenceWrapperFactory.createWrapper(shadowValueWrapper, shadowAss, shadowAss.isEmpty() ? ItemStatus.ADDED : ItemStatus.NOT_CHANGED, context);
shadowReference.setFilter(WebComponentUtil.createAssociationShadowRefFilter(def,
getPrismContext(), associationWrapper.getResource().getOid()));
getPrismContext(), context.getResource().getOid()));
shadowReferences.add(shadowReference);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private List<ShadowWrapper> loadShadowWrappers() {

private Collection<SelectorOptions<GetOperationOptions>> createLoadOptionForShadowWrapper() {
return getPageBase().getOperationOptionsBuilder()
.item(ShadowType.F_RESOURCE_REF).resolve().readOnly()
.resolveNames()
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@
import java.util.stream.Collectors;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.FocusDetailsModels;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ResourceShadowDiscriminator;
import com.evolveum.midpoint.schema.SelectorOptions;

import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.web.application.*;

import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -65,22 +53,28 @@
import com.evolveum.midpoint.gui.impl.component.data.column.PrismReferenceWrapperColumn;
import com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon;
import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder;
import com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.FocusDetailsModels;
import com.evolveum.midpoint.gui.impl.prism.panel.ShadowPanel;
import com.evolveum.midpoint.model.api.AssignmentObjectRelation;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ResourceShadowDiscriminator;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DisplayableValue;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.application.*;
import com.evolveum.midpoint.web.component.data.ISelectableDataProvider;
import com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn;
import com.evolveum.midpoint.web.component.data.column.ColumnMenuAction;
import com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn;
import com.evolveum.midpoint.web.component.dialog.ConfirmationPanel;
import com.evolveum.midpoint.web.component.dialog.Popupable;
import com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem;
Expand Down Expand Up @@ -485,10 +479,8 @@ protected <IW extends ItemWrapper> Component createColumnPanel(String componentI
return new WebMarkupContainer(componentId);
}
List<PrismValueWrapper<PendingOperationType>> values = object.getValues();
List<PendingOperationType> pendingOperations = new ArrayList<>();
values.forEach(value -> pendingOperations.add(value.getRealValue()));
return new PendingOperationPanel(componentId,
(IModel<List<PendingOperationType>>) () -> pendingOperations);
List<PendingOperationType> pendingOperations = values.stream().map(operation -> operation.getRealValue()).collect(Collectors.toList());
return new PendingOperationPanel(componentId, Model.ofList(pendingOperations));
}
});

Expand Down Expand Up @@ -957,7 +949,7 @@ private List<ShadowWrapper> loadShadowWrappers() {

private Collection<SelectorOptions<GetOperationOptions>> createLoadOptionForShadowWrapper() {
return getPageBase().getOperationOptionsBuilder()
.item(ShadowType.F_RESOURCE_REF).resolve().readOnly()
.resolveNames()
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public class ShadowAssociationWrapperImpl extends PrismContainerWrapperImpl<Shad

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

private ResourceType resource;
private Collection<RefinedAssociationDefinition> refinedAssociationDefinitions;

public ShadowAssociationWrapperImpl(PrismContainerValueWrapper<?> parent, PrismContainer<ShadowAssociationType> item, ItemStatus status) {
super(parent, item, status);
}
Expand Down Expand Up @@ -79,7 +76,7 @@ public <D extends ItemDelta<?,?>> Collection<D> getDelta()
ShadowAssociationType shadowAssociationType = new ShadowAssociationType();
shadowAssociationType.asPrismContainerValue().applyDefinition(getItemDefinition());
shadowAssociationType.setName(refWrapper.getItemName());
shadowAssociationType.setShadowRef(ObjectTypeUtil.createObjectRef((PrismReferenceValue) updatedRefValue.getNewValue()));
shadowAssociationType.setShadowRef(ObjectTypeUtil.createObjectRef(updatedRefValue.getNewValue()));
delta.addValueToAdd(shadowAssociationType.asPrismContainerValue());
}

Expand Down Expand Up @@ -107,7 +104,7 @@ public <D extends ItemDelta<?,?>> Collection<D> getDelta()
ShadowAssociationType shadowAssociationType = new ShadowAssociationType();
shadowAssociationType.asPrismContainerValue().applyDefinition(getItemDefinition());
shadowAssociationType.setName(refWrapper.getItemName());
shadowAssociationType.setShadowRef(ObjectTypeUtil.createObjectRef((PrismReferenceValue) updatedRefValue.getNewValue()));
shadowAssociationType.setShadowRef(ObjectTypeUtil.createObjectRef(updatedRefValue.getNewValue()));

switch (updatedRefValue.getStatus()) {
case ADDED:
Expand Down Expand Up @@ -157,21 +154,5 @@ public <D extends ItemDelta<?,?>> Collection<D> getDelta()

return deltas;
}

public ResourceType getResource() {
return resource;
}

public void setResource(ResourceType resource) {
this.resource = resource;
}

public Collection<RefinedAssociationDefinition> getRefinedAssociationDefinitions() {
return refinedAssociationDefinitions;
}

public void setRefinedAssociationDefinitions(Collection<RefinedAssociationDefinition> refinedAssociationDefinitions) {
this.refinedAssociationDefinitions = refinedAssociationDefinitions;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected List<ItemPath> getFixedSearchItems() {

private Collection<SelectorOptions<GetOperationOptions>> getQueryOptions() {
return getOperationOptionsBuilder()
.item(ObjectType.F_PARENT_ORG_REF).resolve()
.resolveNames()
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
import org.apache.wicket.core.util.objects.checker.ObjectSerializationChecker;
import org.apache.wicket.core.util.resource.locator.IResourceStreamLocator;
import org.apache.wicket.core.util.resource.locator.caching.CachingResourceStreamLocator;
import org.apache.wicket.devutils.inspector.InspectorPage;
import org.apache.wicket.devutils.inspector.LiveSessionsPage;
import org.apache.wicket.devutils.pagestore.PageStorePage;
import org.apache.wicket.markup.head.PriorityFirstComparator;
import org.apache.wicket.markup.html.SecurePackageResourceGuard;
import org.apache.wicket.markup.html.WebPage;
Expand Down Expand Up @@ -249,6 +252,9 @@ public void init() {
getDebugSettings().setAjaxDebugModeEnabled(true);
getDebugSettings().setDevelopmentUtilitiesEnabled(true);
initializeDevelopmentSerializers();
mount(new MountedMapper("/inspector", InspectorPage.class, new PageParametersEncoder()));
mount(new MountedMapper("/liveSession", LiveSessionsPage.class, new PageParametersEncoder()));
mount(new MountedMapper("/pageStore", PageStorePage.class, new PageParametersEncoder()));
}

//pretty url for resources (e.g. images)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static com.evolveum.midpoint.security.api.AuthorizationConstants.*;
import static com.evolveum.midpoint.web.page.admin.configuration.PageAdminConfiguration.AUTH_CONFIGURATION_ALL;

import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.util.DisplayableValue;
import com.evolveum.midpoint.web.application.AuthorizationActionValue;
import com.evolveum.midpoint.web.page.admin.configuration.PageAdminConfiguration;
Expand Down Expand Up @@ -191,7 +192,21 @@ public enum PageUrlMapping {
"RestEndpoint.authRest.all.label", "RestEndpoint.authRest.all.description")),
REST3("/api/**",
new AuthorizationActionValue(AUTZ_REST_ALL_URL,
"RestEndpoint.authRest.all.label", "RestEndpoint.authRest.all.description"));
"RestEndpoint.authRest.all.label", "RestEndpoint.authRest.all.description")),


INSPECTOR("/inspector/**",
new AuthorizationActionValue(AUTZ_GUI_ALL_URL,
"WicketDebugInfo.authUri.guiAll.label", "WicketDebugInfo.authUri.guiAll.description")),
LIVE_SESSION("/liveSession/**",
new AuthorizationActionValue(AUTZ_GUI_ALL_URL,
"WicketDebugInfo.authUri.guiAll.label", "WicketDebugInfo.authUri.guiAll.description")),
PAGE_STORE("/pageStore/**",
new AuthorizationActionValue(AUTZ_GUI_ALL_URL,
"WicketDebugInfo.authUri.guiAll.label", "WicketDebugInfo.authUri.guiAll.description")),
WICKET_PAGE("/wicket/**",
new AuthorizationActionValue(AUTZ_GUI_ALL_URL,
"WicketDebugInfo.authUri.guiAll.label", "WicketDebugInfo.authUri.guiAll.description"));

private final String url;

Expand Down

0 comments on commit ef69846

Please sign in to comment.