Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Apr 4, 2023
2 parents 594a082 + ab0a696 commit 7e5d8fb
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void initSearchModel() {

@Override
protected Search load() {
SearchBuilder searchBuilder = new SearchBuilder(FocusType.class)
SearchBuilder searchBuilder = new SearchBuilder(getSearchableType())
.collectionView(getObjectCollectionView())
.additionalSearchContext(createAdditionalSearchContext())
.modelServiceLocator(getPageBase());
Expand All @@ -112,13 +112,17 @@ protected Search load() {
};
}

protected Class<? extends FocusType> getSearchableType() {
return FocusType.class;
}

private SearchContext createAdditionalSearchContext() {
SearchContext ctx = new SearchContext();
ctx.setPanelType(CollectionPanelType.CARDS_GOVERNANCE);
return ctx;
}

private CompiledObjectCollectionView getObjectCollectionView() {
protected CompiledObjectCollectionView getObjectCollectionView() {
ContainerPanelConfigurationType config = getPanelConfiguration();
if (config == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@
import com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.ResourceUncategorizedPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.TemplateTile;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.web.application.PanelDisplay;
import com.evolveum.midpoint.web.application.PanelInstance;
import com.evolveum.midpoint.web.application.PanelType;
import com.evolveum.midpoint.web.component.data.BoxedTablePanel;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType;

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

import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.html.WebMarkupContainer;
Expand Down Expand Up @@ -64,6 +61,11 @@ protected String getStorageKeyTabSuffix() {
return getConfiguration() == null ? PANEL_TYPE : super.getStorageKeyTabSuffix();
}

@Override
protected Class<? extends FocusType> getSearchableType() {
return UserType.class;
}

@Override
protected Behavior createCardDetailsButtonBehaviour() {
return VisibleEnableBehaviour.ALWAYS_INVISIBLE;
Expand Down Expand Up @@ -93,6 +95,35 @@ protected String getTileCssClasses() {
protected WebMarkupContainer getFeedback() {
return GovernanceMembersWizardPanel.this.getFeedback();
}

protected CompiledObjectCollectionView getObjectCollectionView() {
ContainerPanelConfigurationType config = getPanelConfiguration();
if (config == null) {
return null;
}
GuiObjectListViewType listViewType = config.getListView();
if (listViewType == null) {
listViewType = config.beginListView();
}

if (listViewType.getSearchBoxConfiguration() == null) {
listViewType.beginSearchBoxConfiguration();
}

if (listViewType.getSearchBoxConfiguration().getObjectTypeConfiguration() == null) {
listViewType.getSearchBoxConfiguration().beginObjectTypeConfiguration();
}

if (listViewType.getSearchBoxConfiguration().getObjectTypeConfiguration().getSupportedTypes().isEmpty()) {
listViewType
.getSearchBoxConfiguration()
.getObjectTypeConfiguration()
.getSupportedTypes()
.add(UserType.COMPLEX_TYPE);
}

return WebComponentUtil.getCompiledObjectCollectionView(listViewType, config, getPageBase());
}
};
table.setOutputMarkupId(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="row" wicket:id="multiShadowRefPanel">
<div class="row pb-2" wicket:id="multiShadowRefPanel">
<div class="col-md-10 prism-property" wicket:id="referenceValueInput"/>
<div class="col-md-2" wicket:id="buttonsContainer">
<button wicket:id="removeButton" class="btn btn-tool">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public List<QName> getSupportedTypes() {

@Override
protected <O extends ObjectType> void choosePerformedHook(AjaxRequestTarget target, O object) {
removeObjectPerformed(item.getModelObject());
chooseObjectPerformed(target, object);
}
};
Expand Down Expand Up @@ -169,7 +170,7 @@ public void onClick(AjaxRequestTarget target) {

@Override
public void onClick(AjaxRequestTarget target) {
MultiValueObjectChoosePanel.this.getModelObject().remove(item.getModelObject());
removeObjectPerformed(item.getModelObject());
target.add(MultiValueObjectChoosePanel.this);

}
Expand All @@ -184,6 +185,10 @@ public void onClick(AjaxRequestTarget target) {
add(multiValuesPanel);
}

protected void removeObjectPerformed(R object) {
MultiValueObjectChoosePanel.this.getModelObject().remove(object);
}

private boolean isEmptyModel() {
return CollectionUtils.isEmpty(getModelObject());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>
<div wicket:id="associationTargetSearchContainer">
<div class="prism-properties">
<div class="row prism-property">
<div class="row prism-property pb-2">
<div class="col-md-3 prism-property-label"><wicket:message key="ExpressionValuePanel.path" /></div>
<div class="col-md-8 prism-property-value" wicket:id="targetSearchPathInput" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,25 @@ private void initLayout() {
private void initShadowRefExpressionPanel() {
WebMarkupContainer shadowRefValueContainer = new WebMarkupContainer(ID_SHADOW_REF_VALUE_CONTAINER);
shadowRefValueContainer.setOutputMarkupId(true);
shadowRefValueContainer.add(new VisibleBehaviour(() -> ExpressionUtil.isShadowRefNodeExists(AssociationExpressionValuePanel.this.getModelObject())));
shadowRefValueContainer.add(new VisibleBehaviour(
() -> ExpressionUtil.isShadowRefNodeExists(AssociationExpressionValuePanel.this.getModelObject())));
add(shadowRefValueContainer);

LoadableModel<List<ObjectReferenceType>> loadableModel = new LoadableModel<>() {
private static final long serialVersionUID = 1L;

@Override
protected List<ObjectReferenceType> load() {
List<ObjectReferenceType> refs = ExpressionUtil.getShadowRefValue(AssociationExpressionValuePanel.this.getModelObject(), getPageBase().getPrismContext());
List<ObjectReferenceType> refs = ExpressionUtil.getShadowRefValue(
AssociationExpressionValuePanel.this.getModelObject(),
getPageBase().getPrismContext());
refs.forEach(ref -> WebModelServiceUtils.resolveReferenceName(ref, getPageBase()));

return refs;
}
};
MultiValueObjectChoosePanel<ObjectReferenceType> multiShadowRefPanel = new MultiValueObjectChoosePanel<>(ID_MULTI_SHADOW_REF_PANEL, loadableModel) {
MultiValueObjectChoosePanel<ObjectReferenceType> multiShadowRefPanel = new MultiValueObjectChoosePanel<>(
ID_MULTI_SHADOW_REF_PANEL, loadableModel) {
private static final long serialVersionUID = 1L;

@Override
Expand All @@ -100,7 +104,9 @@ protected List<QName> getSupportedTypes() {

@Override
protected ObjectFilter createCustomFilter() {
return WebComponentUtil.getShadowTypeFilterForAssociation(construction, OPERATION_LOAD_RESOURCE, AssociationExpressionValuePanel.this.getPageBase());
return WebComponentUtil.getShadowTypeFilterForAssociation(
construction, OPERATION_LOAD_RESOURCE,
AssociationExpressionValuePanel.this.getPageBase());
}

@Override
Expand All @@ -113,7 +119,21 @@ protected <O extends ObjectType> ObjectReferenceType createReferencableObject(O

@Override
protected <O extends ObjectType> void chooseObjectPerformed(AjaxRequestTarget target, O object) {
ExpressionUtil.addShadowRefEvaluatorValue(AssociationExpressionValuePanel.this.getModelObject(), object.getOid(), AssociationExpressionValuePanel.this.getPrismContext());
ExpressionUtil.addShadowRefEvaluatorValue(
AssociationExpressionValuePanel.this.getModelObject(),
object.getOid(),
AssociationExpressionValuePanel.this.getPrismContext());
}

@Override
protected void removeObjectPerformed(ObjectReferenceType object) {
List<ObjectReferenceType> refs = ExpressionUtil.getShadowRefValue(
AssociationExpressionValuePanel.this.getModelObject(), getPageBase().getPrismContext());
refs.removeIf(ref -> ref.getOid().equals(object.getOid()));
ExpressionUtil.updateShadowRefEvaluatorValue(
AssociationExpressionValuePanel.this.getModelObject(),
refs);
getModel().detach();
}
};
multiShadowRefPanel.setOutputMarkupId(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ public static JAXBElement<?> createAssociationTargetSearchElement(PrismContext p

XNodeFactory factory = prismContext.xnodeFactory();
Map<QName, XNode> valuesMap = new HashMap<>();
valuesMap.put(new QName("path"), factory.primitive());
valuesMap.put(new QName("value"), factory.primitive());
valuesMap.put(new QName(SchemaConstantsGenerated.NS_QUERY,"path"), factory.primitive());
valuesMap.put(new QName(SchemaConstantsGenerated.NS_QUERY, "value"), factory.primitive());
MapXNode values = factory.map(valuesMap);
MapXNode filterClauseNode = factory.map(new QName("equal"), values);
MapXNode filterClauseNode = factory.map(new QName(SchemaConstantsGenerated.NS_QUERY, "equal"), values);

SearchFilterType filterType = new SearchFilterType();
filterType.setFilterClauseXNode(filterClauseNode);
Expand Down Expand Up @@ -383,10 +383,12 @@ public static MapXNode getOrCreateAssociationTargetSearchValues(ExpressionType e
if (filterClauseNode == null) {
filterClauseNode = prismContext.xnodeFactory().map();
}
if (!filterClauseNode.containsKey(new QName("equal"))) {
prismContext.xnodeMutator().putToMapXNode(filterClauseNode, new QName("equal"), null);
if (!filterClauseNode.containsKey(new QName(SchemaConstantsGenerated.NS_QUERY, "equal"))) {
prismContext.xnodeMutator().putToMapXNode(
filterClauseNode,
new QName(SchemaConstantsGenerated.NS_QUERY, "equal"), null);
}
MapXNode values = (MapXNode) filterClauseNode.get(new QName("equal"));
MapXNode values = (MapXNode) filterClauseNode.get(new QName(SchemaConstantsGenerated.NS_QUERY, "equal"));
if (values == null) {
values = prismContext.xnodeFactory().map(); // todo [med] this has no effect on the map node!
}
Expand Down Expand Up @@ -487,6 +489,19 @@ public static void addShadowRefEvaluatorValue(ExpressionType expression, String
}
}

public static void updateShadowRefEvaluatorValue(ExpressionType expression, List<ObjectReferenceType> values) {
if (expression == null) {
expression = new ExpressionType(); // TODO ??? this is thrown away
}
removeEvaluatorByName(expression, SchemaConstantsGenerated.C_VALUE);
PrismContext prismContext = PrismContext.get();
for (ObjectReferenceType value : values) {
JAXBElement element = new JAXBElement<>(SchemaConstantsGenerated.C_VALUE, ShadowAssociationType.class,
new ShadowAssociationType(prismContext).shadowRef(value));
expression.expressionEvaluator(element);
}
}

public static @NotNull List<String> getLiteralExpressionValues(ExpressionType expression) throws SchemaException {
List<String> values = new ArrayList<>();
List<JAXBElement<?>> elements = ExpressionUtil.findAllEvaluatorsByName(expression, SchemaConstantsGenerated.C_VALUE);
Expand Down Expand Up @@ -572,8 +587,8 @@ public static MapXNode getAssociationTargetSearchFilterValuesMap(ExpressionType
return null;
}
MapXNode filterValue = filter.getFilterClauseXNode();
return filterValue != null && filterValue.containsKey(new QName("equal")) ?
(MapXNode) filterValue.get(new QName("equal")) : null;
return filterValue != null && filterValue.containsKey(new QName(SchemaConstantsGenerated.NS_QUERY, "equal")) ?
(MapXNode) filterValue.get(new QName(SchemaConstantsGenerated.NS_QUERY, "equal")) : null;

}
return null;
Expand All @@ -584,10 +599,11 @@ public static String getTargetSearchExpPathValue(ExpressionType expression) {
return null;
}
MapXNode filterNodeMap = getAssociationTargetSearchFilterValuesMap(expression);
if (filterNodeMap == null || !filterNodeMap.containsKey(new QName("path"))) {
if (filterNodeMap == null || !filterNodeMap.containsKey(new QName(SchemaConstantsGenerated.NS_QUERY, "path"))) {
return null;
}
PrimitiveXNode<ItemPathType> pathValue = (PrimitiveXNode<ItemPathType>) filterNodeMap.get(new QName("path"));
PrimitiveXNode<ItemPathType> pathValue = (PrimitiveXNode<ItemPathType>) filterNodeMap.get(
new QName(SchemaConstantsGenerated.NS_QUERY, "path"));
return pathValue != null && pathValue.getValue() != null ? pathValue.getValue().toString() : null;
}

Expand All @@ -596,10 +612,10 @@ public static String getTargetSearchExpValue(ExpressionType expression) {
return null;
}
MapXNode filterNodeMap = getAssociationTargetSearchFilterValuesMap(expression);
if (filterNodeMap == null || !filterNodeMap.containsKey(new QName("value"))) {
if (filterNodeMap == null || !filterNodeMap.containsKey(new QName(SchemaConstantsGenerated.NS_QUERY, "value"))) {
return null;
}
XNode node = filterNodeMap.get(new QName("value"));
XNode node = filterNodeMap.get(new QName(SchemaConstantsGenerated.NS_QUERY, "value"));
if (node instanceof ListXNode) {
if (((ListXNode) node).size() > 0) {
node = ((ListXNode) node).get(0);
Expand Down

0 comments on commit 7e5d8fb

Please sign in to comment.