Skip to content

Commit

Permalink
Better usage for summary panel configuration
Browse files Browse the repository at this point in the history
----
- merging summary panel config also from archetype
- adapting summary panels to consider merged configuration

Merge support for overriding expanded behavior for virtual containers (MID-7370)
  • Loading branch information
katkav committed Oct 19, 2021
1 parent f10c3c0 commit 77bfe13
Show file tree
Hide file tree
Showing 54 changed files with 264 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5225,4 +5225,17 @@ private static PrismReferenceValue findResourceReference(PrismPropertyWrapper<QN
return null;
}
}

/**
* only for 'old' object details pages. Should be removed after only new design will be present.
*/
@Deprecated
public static <O extends ObjectType> SummaryPanelSpecificationType getSummaryPanelSpecification(Class<O> type, CompiledGuiProfile compiledGuiProfile) {
GuiObjectDetailsPageType guiObjectDetailsType = compiledGuiProfile.findObjectDetailsConfiguration(type);
if (guiObjectDetailsType == null) {
return null;
}
return guiObjectDetailsType.getSummaryPanel();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import com.evolveum.midpoint.web.component.util.VisibleBehaviour;

import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationTypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -48,9 +48,6 @@
import com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.web.util.validation.SimpleValidationError;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectDetailsPageType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

public abstract class AbstractPageObjectDetails<O extends ObjectType, ODM extends ObjectDetailsModels<O>> extends PageBase {

Expand Down Expand Up @@ -492,4 +489,8 @@ public PrismObject<O> getPrismObject() {
protected void createBreadcrumb() {
createInstanceBreadcrumb();
}

protected SummaryPanelSpecificationType getSummaryPanelSpecification() {
return getObjectDetailsModels().getSummaryPanelSpecification();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.evolveum.midpoint.gui.api.factory.wrapper.PrismObjectWrapperFactory;
import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper;
import com.evolveum.midpoint.gui.api.util.ModelServiceLocator;
Expand All @@ -23,21 +24,28 @@
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
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.MiscUtil;
import com.evolveum.midpoint.util.exception.AuthorizationException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails;
import com.evolveum.midpoint.web.util.validation.MidpointFormValidator;
import com.evolveum.midpoint.web.util.validation.SimpleValidationError;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectDetailsPageType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;

public class ObjectDetailsModels<O extends ObjectType> implements Serializable {

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

private static final String DOT_CLASS = ObjectDetailsModels.class.getName() + ".";
protected static final String OPERATION_LOAD_PARENT_ORG = DOT_CLASS + "loadParentOrgs";

private ModelServiceLocator modelServiceLocator;
private LoadableModel<PrismObject<O>> prismObjectModel;

Expand Down Expand Up @@ -91,12 +99,53 @@ protected O load() {
}

PrismObject<O> object = wrapper.getObject();
// loadParentOrgs(object);
loadParentOrgs(object);
return object.asObjectable();
}
};
}

private void loadParentOrgs(PrismObject<O> object) {
Task task = getModelServiceLocator().createSimpleTask(OPERATION_LOAD_PARENT_ORG);
OperationResult subResult = task.getResult();
// Load parent organizations (full objects). There are used in the
// summary panel and also in the main form.
// Do it here explicitly instead of using resolve option to have ability
// to better handle (ignore) errors.
for (ObjectReferenceType parentOrgRef : object.asObjectable().getParentOrgRef()) {

PrismObject<OrgType> parentOrg = null;
try {

parentOrg = getModelServiceLocator().getModelService().getObject(
OrgType.class, parentOrgRef.getOid(), null, task, subResult);
LOGGER.trace("Loaded parent org with result {}", subResult.getLastSubresult());
} catch (AuthorizationException e) {
// This can happen if the user has permission to read parentOrgRef but it does not have
// the permission to read target org
// It is OK to just ignore it.
subResult.muteLastSubresultError();
PrismObject<? extends FocusType> taskOwner = task.getOwner(subResult);
LOGGER.debug("User {} does not have permission to read parent org unit {} (ignoring error)", taskOwner.getName(), parentOrgRef.getOid());
} catch (Exception ex) {
subResult.recordWarning(getPageBase().createStringResource("PageAdminObjectDetails.message.loadParentOrgs.warning", parentOrgRef.getOid()).getString(), ex);
LOGGER.warn("Cannot load parent org {}: {}", parentOrgRef.getOid(), ex.getMessage(), ex);
}

if (parentOrg != null) {
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(parentOrg, getPrismContext());
ref.asReferenceValue().setObject(parentOrg);
object.asObjectable().getParentOrgRef().add(ref);
}
}
subResult.computeStatus();
}


protected PageBase getPageBase() {
return (PageBase) getModelServiceLocator();
}

protected GuiObjectDetailsPageType loadDetailsPageConfiguration(PrismObject<O> prismObject) {
return modelServiceLocator.getCompiledGuiProfile().findObjectDetailsConfiguration(prismObject.getDefinition().getTypeName());
}
Expand Down Expand Up @@ -277,4 +326,13 @@ protected boolean isReadonly() {
public ItemStatus getObjectStatus() {
return objectWrapperModel.getObject().getStatus();
}

public SummaryPanelSpecificationType getSummaryPanelSpecification() {
GuiObjectDetailsPageType detailsPageConfig = detailsPageConfigurationModel.getObject();
if (detailsPageConfig == null) {
return null;
}

return detailsPageConfig.getSummaryPanel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected Class<ArchetypeType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<ArchetypeType> summaryModel) {
return new ArchetypeSummaryPanel(id, summaryModel, this);
return new ArchetypeSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ protected ExecuteChangeOptionsDto load() {
};
}

private PageBase getPageBase() {
return (PageBase) getModelServiceLocator();
}

private List<ShadowWrapper> loadShadowWrappers() {
LOGGER.trace("Loading shadow wrapper");
long start = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected Class<CaseType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<CaseType> summaryModel) {
return new CaseSummaryPanel(id, summaryModel, this);
return new CaseSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package com.evolveum.midpoint.gui.impl.page.admin.configuration.component;

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

import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
Expand All @@ -17,8 +19,8 @@ public class SystemConfigurationSummaryPanel extends ObjectSummaryPanel<SystemCo

private static final long serialVersionUID = 1L;

public SystemConfigurationSummaryPanel(String id, IModel<SystemConfigurationType> model, ModelServiceLocator serviceLocator) {
super(id, SystemConfigurationType.class, model, serviceLocator);
public SystemConfigurationSummaryPanel(String id, IModel<SystemConfigurationType> model, SummaryPanelSpecificationType summaryPanelSpecificationType) {
super(id, SystemConfigurationType.class, model, summaryPanelSpecificationType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected Class<ObjectCollectionType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<ObjectCollectionType> summaryModel) {
return new ObjectCollectionSummaryPanel(id, summaryModel, this);
return new ObjectCollectionSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ protected Class<ObjectTemplateType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<ObjectTemplateType> summaryModel) {
return new ObjectTemplateSummaryPanel(id, summaryModel, this);
return new ObjectTemplateSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ protected Class<OrgType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<OrgType> summaryModel) {
return new OrgSummaryPanel(id, summaryModel, this);
return new OrgSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected Class<ReportType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<ReportType> summaryModel) {
return new ReportSummaryPanel(id, summaryModel, this);
return new ReportSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected Class<ResourceType> getType() {
@Override
protected Panel createSummaryPanel(String id, LoadableModel<ResourceType> summaryModel) {
return new ResourceSummaryPanel(id,
summaryModel, this);
summaryModel, getSummaryPanelSpecification());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected Class<ShadowType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<ShadowType> summaryModel) {
return new ShadowSummaryPanel(id, summaryModel, this);
return new ShadowSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ protected PrismContainerWrapper<ConnectorConfigurationType> load() {
};
}

private PageBase getPageBase() {
return (PageBase) getModelServiceLocator();
}

private PrismContainerWrapper<ConnectorConfigurationType> createConfigContainerWrappers(OperationResult result) throws SchemaException {

Task task = getModelServiceLocator().createSimpleTask(OPERATION_CREATE_CONFIGURATION_WRAPPERS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ protected Class<RoleType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<RoleType> summaryModel) {
return new RoleSummaryPanel(id, summaryModel, PageRole.this);
return new RoleSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ protected Class<ServiceType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<ServiceType> summaryModel) {
return new ServiceSummaryPanel(id, summaryModel, PageService.this);
return new ServiceSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected TaskDetailsModel createObjectDetailsModels(PrismObject<TaskType> objec

@Override
protected Panel createSummaryPanel(String id, LoadableModel<TaskType> summaryModel) {
return new TaskSummaryPanel(id, summaryModel, getObjectDetailsModels().getRootTaskModel(), this);
return new TaskSummaryPanel(id, summaryModel, getObjectDetailsModels().getRootTaskModel(), getSummaryPanelSpecification());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected Class<UserType> getType() {

@Override
protected Panel createSummaryPanel(String id, LoadableModel<UserType> summaryModel) {
return new UserSummaryPanel(id, summaryModel, PageUser.this);
return new UserSummaryPanel(id, summaryModel, getSummaryPanelSpecification());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public abstract class FocusSummaryPanel<O extends ObjectType> extends ObjectSumm
private static final String DOT_CLASS = FocusSummaryPanel.class.getName() + ".";
private static final String OPERATION_LOAD_PARENT_ORGS = DOT_CLASS + "activationTag";

public FocusSummaryPanel(String id, Class<O> type, final IModel<O> model, ModelServiceLocator serviceLocator) {
super(id, type, model, serviceLocator);
public FocusSummaryPanel(String id, Class<O> type, final IModel<O> model, SummaryPanelSpecificationType summaryPanelSpecification) {
super(id, type, model, summaryPanelSpecification);
}

@Override
Expand Down Expand Up @@ -161,19 +161,19 @@ protected boolean isActivationVisible() {
return true;
}

public static void addSummaryPanel(MarkupContainer parentComponent, PrismObject<FocusType> focus, String id, ModelServiceLocator serviceLocator) {
public static void addSummaryPanel(MarkupContainer parentComponent, PrismObject<FocusType> focus, String id, SummaryPanelSpecificationType summaryPanelSpecificationType) {
if (focus.getCompileTimeClass().equals(UserType.class)) {
parentComponent.add(new UserSummaryPanel(id,
Model.of((UserType) focus.asObjectable()), serviceLocator));
Model.of((UserType) focus.asObjectable()), summaryPanelSpecificationType));
} else if (focus.getCompileTimeClass().equals(RoleType.class)) {
parentComponent.add(new RoleSummaryPanel(id,
Model.of((RoleType) focus.asObjectable()), serviceLocator));
Model.of((RoleType) focus.asObjectable()), summaryPanelSpecificationType));
} else if (focus.getCompileTimeClass().equals(OrgType.class)) {
parentComponent.add(new OrgSummaryPanel(id,
Model.of((OrgType) focus.asObjectable()), serviceLocator));
Model.of((OrgType) focus.asObjectable()), summaryPanelSpecificationType));
} else if (focus.getCompileTimeClass().equals(ServiceType.class)) {
parentComponent.add(new ServiceSummaryPanel(id,
Model.of((ServiceType) focus.asObjectable()), serviceLocator));
Model.of((ServiceType) focus.asObjectable()), summaryPanelSpecificationType));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
package com.evolveum.midpoint.web.component;

import com.evolveum.midpoint.gui.api.util.ModelServiceLocator;
import com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectDetailsPageType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
Expand All @@ -17,15 +16,8 @@
public abstract class ObjectSummaryPanel<O extends ObjectType> extends AbstractSummaryPanel<O> {
private static final long serialVersionUID = -3755521482914447912L;

public ObjectSummaryPanel(String id, Class<O> type, final IModel<O> model, ModelServiceLocator serviceLocator) {
super(id, model, determineConfig(type, serviceLocator.getCompiledGuiProfile()));
public ObjectSummaryPanel(String id, Class<O> type, final IModel<O> model, SummaryPanelSpecificationType summaryPanelSpecification) {
super(id, model, summaryPanelSpecification);
}

private static <O extends ObjectType> SummaryPanelSpecificationType determineConfig(Class<O> type, CompiledGuiProfile compiledGuiProfile) {
GuiObjectDetailsPageType guiObjectDetailsType = compiledGuiProfile.findObjectDetailsConfiguration(type);
if (guiObjectDetailsType == null) {
return null;
}
return guiObjectDetailsType.getSummaryPanel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1219,4 +1219,5 @@ private void finishPreviewProcessing(AjaxRequestTarget target, OperationResult r

protected void processAdditionalFocalObjectsForPreview(Map<PrismObject<O>, ModelContext<? extends ObjectType>> modelContextMap) {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import javax.xml.namespace.QName;

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

import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
Expand All @@ -20,8 +22,8 @@ public class ArchetypeSummaryPanel extends FocusSummaryPanel<ArchetypeType>{
private static final long serialVersionUID = 1L;

public ArchetypeSummaryPanel(String id, IModel<ArchetypeType> model,
ModelServiceLocator serviceLocator) {
super(id, ArchetypeType.class, model, serviceLocator);
SummaryPanelSpecificationType summaryPanelSpecificationType) {
super(id, ArchetypeType.class, model, summaryPanelSpecificationType);
}


Expand Down

0 comments on commit 77bfe13

Please sign in to comment.