Skip to content

Commit

Permalink
tag details, nasty hack for global policy rule panel (should be reimp…
Browse files Browse the repository at this point in the history
…lemented, but there refactoring rabbit hole waiting)
  • Loading branch information
1azyman committed Jan 16, 2023
1 parent 2a14e44 commit e3ea73b
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,6 @@ public class GuiStyleConstants {
public static final String CLASS_ICON_HISTORY = "fa fa-history";

public static final String CLASS_SIMULATION_RESULT = CLASS_CIRCLE_FULL;

public static final String CLASS_TAG = CLASS_CIRCLE_FULL;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

package com.evolveum.midpoint.gui.impl.page.admin.simulation;

import java.util.Arrays;
import java.util.List;
import javax.xml.namespace.QName;

import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
Expand All @@ -16,10 +20,17 @@
import com.evolveum.midpoint.authentication.api.authorization.Url;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.AssignmentHolderDetailsModel;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails;
import com.evolveum.midpoint.gui.impl.util.GuiImplUtil;
import com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.ObjectSummaryPanel;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GlobalPolicyRuleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectDetailsPageType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TagType;

/**
Expand All @@ -42,6 +53,8 @@ public class PageTag extends PageAssignmentHolderDetails<TagType, AssignmentHold

private static final long serialVersionUID = 1L;

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

public PageTag() {
super();
}
Expand Down Expand Up @@ -79,4 +92,40 @@ protected String getBoxAdditionalCssClass() {
}
};
}

private List<Class<? extends Containerable>> getAllDetailsTypes() {
return Arrays.asList(
TagType.class,
GlobalPolicyRuleType.class
);
}

@Override
protected AssignmentHolderDetailsModel<TagType> createObjectDetailsModels(PrismObject<TagType> object) {
return new AssignmentHolderDetailsModel<>(createPrismObjectModel(object), this) {

@Override
protected GuiObjectDetailsPageType loadDetailsPageConfiguration() {
CompiledGuiProfile profile = getModelServiceLocator().getCompiledGuiProfile();
try {
GuiObjectDetailsPageType defaultPageConfig = null;
for (Class<? extends Containerable> clazz : getAllDetailsTypes()) {
QName type = GuiImplUtil.getContainerableTypeName(clazz);
if (defaultPageConfig == null) {
defaultPageConfig = profile.findObjectDetailsConfiguration(type);
} else {
GuiObjectDetailsPageType anotherConfig = profile.findObjectDetailsConfiguration(type);
defaultPageConfig = getModelServiceLocator().getAdminGuiConfigurationMergeManager().mergeObjectDetailsPageConfiguration(defaultPageConfig, anotherConfig);
}
}

return applyArchetypePolicy(defaultPageConfig);
} catch (Exception ex) {
LOGGER.error("Couldn't create default gui object details page and apply archetype policy", ex);
}

return null;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.GlobalPolicyRuleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;

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

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.html.list.ListItem;
Expand Down Expand Up @@ -59,7 +61,10 @@ public GlobalPolicyRuleContentPanel(String id, AssignmentHolderDetailsModel mode
super(id, GlobalPolicyRuleType.class, configurationType);

this.model = PrismContainerWrapperModel.fromContainerWrapper(model.getObjectWrapperModel(), ItemPath.create(
SystemConfigurationType.F_GLOBAL_POLICY_RULE
// todo nasty hack to get one instance of panel work for different containers (same type, different objects)
// should be handled via @PanelInstances, but there's no way to configure it properly
// If containerPath & type in {@link @PanelInstance} is used then there are too many NPE and ContainerPanelConfigurationType misconfigurations
model.getObjectType() instanceof SystemConfigurationType ? SystemConfigurationType.F_GLOBAL_POLICY_RULE :TagType.F_POLICY_RULE
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,37 @@
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.AssignmentHolderDetailsModel;
import com.evolveum.midpoint.web.application.SimpleCounter;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TagType;

/**
* Created by Viliam Repan (lazyman).
*
* TODO actual implementation not very nice since it contains multiple ifs based on for which
* {@link com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType} and specific field we're doing the count
* <p/>
* It either should be multiple classes per concrete use (type and itempath) or probably better pointer to container
* which values we want to count (in this case GlobalPolicyRuleType container)
*/
public class GlobalPolicyRuleCounter extends SimpleCounter<AssignmentHolderDetailsModel<SystemConfigurationType>, SystemConfigurationType> {
public class GlobalPolicyRuleCounter extends SimpleCounter<AssignmentHolderDetailsModel<AssignmentHolderType>, AssignmentHolderType> {

public GlobalPolicyRuleCounter() {
super();
}

@Override
public int count(AssignmentHolderDetailsModel<SystemConfigurationType> model, PageBase pageBase) {
SystemConfigurationType object = model.getObjectType();
return object.getGlobalPolicyRule().size();
public int count(AssignmentHolderDetailsModel<AssignmentHolderType> model, PageBase pageBase) {
AssignmentHolderType object = model.getObjectType();
if (object instanceof SystemConfigurationType) {
return ((SystemConfigurationType) object).getGlobalPolicyRule().size();
}

if (object instanceof TagType) {
return ((TagType) object).getPolicyRule().size();
}

return 0;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@
in the system configuration. (Provided that this tag is in appropriate lifecycle state.)
</xsd:documentation>
<xsd:appinfo>
<a:displayName>TagType.uri</a:displayName>
<a:displayName>TagType.policyRule</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand Down

0 comments on commit e3ea73b

Please sign in to comment.