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 Feb 3, 2023
2 parents 0f89404 + 53a15b6 commit f0849aa
Show file tree
Hide file tree
Showing 13 changed files with 244 additions and 13 deletions.
19 changes: 19 additions & 0 deletions gui/admin-gui/src/frontend/scss/midpoint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,25 @@ th.debug-list-buttons {
}
}

.assignmentPath {
list-style: none;
margin-bottom: 0px;

& > li {

& + li {
margin-left: 10px;

&::before {
color: $text-muted;
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f061";
}
}
}
}

@each $breakpoint in map-keys($grid-breakpoints) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
@include media-breakpoint-up($breakpoint, $grid-breakpoints) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public String getDslQuery() {
}

public void setDslQuery(String dslQuery) {
axiomQueryWrapper = new AxiomQueryWrapper();
axiomQueryWrapper = new AxiomQueryWrapper(null);
axiomQueryWrapper.setDslQuery(dslQuery);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ private SearchBoxConfigurationType getMergedConfiguration() {
return SearchConfigurationMerger.mergeConfigurations(defaultSearchBoxConfig, configuredSearchBox, modelServiceLocator);
}

public ItemDefinition<?> getDefinitionOverride() {
return additionalSearchContext == null ? null : additionalSearchContext.getDefinitionOverride();
}
private Search<C> createSearch(SearchBoxConfigurationType mergedConfig, BasicQueryWrapper basicSearchWrapper) {
AxiomQueryWrapper axiomWrapper = new AxiomQueryWrapper();
AxiomQueryWrapper axiomWrapper = new AxiomQueryWrapper(getDefinitionOverride());
AdvancedQueryWrapper advancedQueryWrapper = new AdvancedQueryWrapper(null);
FulltextQueryWrapper fulltextQueryWrapper = new FulltextQueryWrapper(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.schema.processor.ResourceObjectDefinition;
import com.evolveum.midpoint.util.DisplayableValue;
Expand All @@ -20,7 +21,7 @@
public class SearchContext {

private ResourceObjectDefinition resourceObjectDefinition;
private PrismContainerDefinition<? extends Containerable> definitionOverride;
private ItemDefinition<?> definitionOverride;

private CollectionPanelType collectionPanelType;

Expand Down Expand Up @@ -63,11 +64,11 @@ public void setReportCollection(ObjectCollectionReportEngineConfigurationType re
this.reportCollection = reportCollection;
}

public PrismContainerDefinition<? extends Containerable> getDefinitionOverride() {
public ItemDefinition<?> getDefinitionOverride() {
return definitionOverride;
}

public void setDefinitionOverride(PrismContainerDefinition<? extends Containerable> definitionOverride) {
public void setDefinitionOverride(ItemDefinition<?> definitionOverride) {
this.definitionOverride = definitionOverride;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class AxiomQueryWrapper extends AbstractQueryWrapper {
//TODO
private ItemDefinition<?> containerDefinitionOverride;

public AxiomQueryWrapper(ItemDefinition<?> containerDefinitionOverride) {
this.containerDefinitionOverride = containerDefinitionOverride;
}

public <T> ObjectQuery createQuery(Class<T> typeClass, PageBase pageBase, VariablesMap variablesMap) throws SchemaException {
if (StringUtils.isEmpty(dslQuery)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.evolveum.midpoint.gui.impl.component.ContainerableListPanel;
import com.evolveum.midpoint.gui.impl.component.data.column.ConfigurableExpressionColumn;
import com.evolveum.midpoint.gui.impl.component.search.Search;
import com.evolveum.midpoint.gui.impl.component.search.SearchContext;
import com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel;
import com.evolveum.midpoint.gui.impl.page.admin.user.UserDetailsModel;
import com.evolveum.midpoint.prism.*;
Expand All @@ -27,6 +28,7 @@
import com.evolveum.midpoint.gui.api.component.data.provider.ISelectableDataProvider;
import com.evolveum.midpoint.gui.impl.component.data.provider.SelectableBeanReferenceDataProvider;
import com.evolveum.midpoint.web.component.assignment.AssignmentsUtil;
import com.evolveum.midpoint.web.component.data.column.AssignmentPathPanel;
import com.evolveum.midpoint.web.component.data.column.ObjectReferenceColumn;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.session.UserProfileStorage;
Expand All @@ -40,6 +42,7 @@
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -97,6 +100,20 @@ protected List<IColumn<SelectableBean<ObjectReferenceType>, String>> createDefau
return createAllAccessesColumns();
}

@Override
protected SearchContext createAdditionalSearchContext() {
SearchContext ctx = new SearchContext();
ctx.setDefinitionOverride(getContainerDefinitionForColumns());
return ctx;
}

@Override
protected ItemDefinition<?> getContainerDefinitionForColumns() {
PrismReferenceDefinition refDef = getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class)
.findReferenceDefinition(UserType.F_ROLE_MEMBERSHIP_REF);
return getPageBase().getModelInteractionService().refDefinitionWithConcreteTargetRefType(refDef, AbstractRoleType.COMPLEX_TYPE);
}

@Override
protected IColumn<SelectableBean<ObjectReferenceType>, String> createCustomExportableColumn(IModel<String> columnDisplayModel, GuiObjectColumnType customColumn, ExpressionType expression) {
return new ConfigurableExpressionColumn<>(columnDisplayModel, null, customColumn, expression, getPageBase()) {
Expand Down Expand Up @@ -181,14 +198,18 @@ public IModel<List<ObjectReferenceType>> extractDataModel(IModel<SelectableBean<

@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ObjectReferenceType>>> cellItem, String componentId, IModel<SelectableBean<ObjectReferenceType>> rowModel) {
RepeatingView repeatingView = new RepeatingView(componentId);
cellItem.add(repeatingView);

List<String> paths = resolvedPaths(rowModel.getObject());
for (String path : paths) {
Label pathLabel = new Label(repeatingView.newChildId(), path);
repeatingView.add(pathLabel);
List<ProvenanceMetadataType> metadataValues = collectProvenanceMetadata(rowModel.getObject().getValue().asReferenceValue());
if (metadataValues == null) {
return;
}
List<AssignmentPathType> assignmentPaths = new ArrayList<>();
for (ProvenanceMetadataType metadataType : metadataValues) {
assignmentPaths.addAll(metadataType.getAssignmentPath());
}

AssignmentPathPanel panel = new AssignmentPathPanel(componentId, Model.ofList(assignmentPaths));
cellItem.add(panel);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
~ Copyright (c) 2010-2013 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div wicket:id="paths">
<ul class="assignmentPath" wicket:id="path"/>
</div>
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (C) 2023 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.web.component.data.column;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathSegmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathType;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class AssignmentPathPanel extends BasePanel<List<AssignmentPathType>> {
private static final String ID_PATHS = "paths";
private static final String ID_PATH = "path";

public AssignmentPathPanel(String id, IModel<List<AssignmentPathType>> model) {
super(id, model);
}

@Override
protected void onInitialize() {
super.onInitialize();
initLayout();
}

private void initLayout() {

ListView<AssignmentPathType> assignmentPaths = new ListView<>(ID_PATHS, getModel()) {
@Override
protected void populateItem(ListItem<AssignmentPathType> listItem) {
listItem.add(new AssignmentPathSegmentPanel(ID_PATH, loadSegmentsModel(listItem.getModel())));
}
};
add(assignmentPaths);
}

private IModel<List<AssignmentPathSegmentType>> loadSegmentsModel(IModel<AssignmentPathType> assignmentModel) {
return () -> {
AssignmentPathType assignmentPathType = assignmentModel.getObject();
List<AssignmentPathSegmentType> segments = assignmentPathType.getSegment();
if (CollectionUtils.isEmpty(segments) || segments.size() == 1) {
return new ArrayList<>();
}
return segments;
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
~ Copyright (c) 2010-2013 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<li class="row" wicket:id="segments">
<div class="col-10" wicket:id="segment"/>
</li>
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2023 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.web.component.data.column;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathSegmentType;

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

import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class AssignmentPathSegmentPanel extends BasePanel<List<AssignmentPathSegmentType>> {
private static final String ID_SEGMENTS = "segments";
private static final String ID_SEGMENT = "segment";


public AssignmentPathSegmentPanel(String id, IModel<List<AssignmentPathSegmentType>> model) {
super(id, model);
}

@Override
protected void onInitialize() {
super.onInitialize();
initLayout();
}

private void initLayout() {

ListView<AssignmentPathSegmentType> segments = new ListView<>(ID_SEGMENTS, getModel()) {
@Override
protected void populateItem(ListItem<AssignmentPathSegmentType> listItem) {
listItem.add(new ObjectReferenceColumnPanel(ID_SEGMENT, () -> listItem.getModelObject().getTargetRef()));
}
};
add(segments);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.evolveum.midpoint.gui.api.model.ReadOnlyModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel;
import com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon;
import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder;
Expand Down Expand Up @@ -40,7 +41,7 @@ protected void onInitialize() {
private void initLayout() {
CompositedIconPanel iconPanel = new CompositedIconPanel(ID_IMAGE, createCompositedIconModel());
add(iconPanel);
LinkPanel label = new LinkPanel(ID_NAME, () -> WebComponentUtil.getDisplayNameOrName(getModelObject())) {
LinkPanel label = new LinkPanel(ID_NAME, () -> WebComponentUtil.getDisplayNameOrName(getResolvedTarget())) {
@Override
public void onClick() {
WebComponentUtil.dispatchToObjectDetailsPage(getModelObject(), ObjectReferenceColumnPanel.this, false);
Expand All @@ -50,6 +51,24 @@ public void onClick() {

}

private <R extends AbstractRoleType> PrismObject<R> getResolvedTarget() {
ObjectReferenceType rowValue = getModelObject();
if (rowValue == null) {
return null;
}
if (rowValue.getObject() != null) {
return rowValue.getObject();
}

if (rowValue.getOid() != null) {
PrismObject<R> resolvedTarget = WebModelServiceUtils.loadObject(rowValue, getPageBase());
if (resolvedTarget != null) {
return resolvedTarget;
}
}
return null;
}

private IModel<CompositedIcon> createCompositedIconModel() {
return () -> {
ObjectReferenceType ref = getModelObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,18 @@ void expandConfigurationObject(
PrismContainerDefinition<AssignmentType> assignmentTypeDefinitionWithConcreteTargetRefType(
PrismContainerDefinition<AssignmentType> orig, QName targetType);

/**
* Returns Container Definition of Assignment Type with target type of assignment replaced by more concrete situation
*
* This allows for using more specific definition when searching for definitions for dereference, in GUI search or columns
* where we are sure (on other criteria) only assignment types we are processing have concrete target type.
*
* @param orig Original definition of Assignment Type
* @param targetType Concrete target type
*/
PrismReferenceDefinition refDefinitionWithConcreteTargetRefType(
PrismReferenceDefinition orig, QName targetType);

/**
* Executes the code in `functionCall` parameter ({@link SimulatedFunctionCall}) in the simulation mode (`mode` parameter),
* with the provided simulation result definition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,13 @@ public PrismContainerDefinition<AssignmentType> assignmentTypeDefinitionWithConc
return transformed;
}

@Override
public PrismReferenceDefinition refDefinitionWithConcreteTargetRefType(PrismReferenceDefinition orig, QName targetType) {
var transformed = TransformableReferenceDefinition.of(orig);
transformed.setTargetTypeName(targetType);
return transformed;
}

@Override
public <X> X executeInSimulationMode(
@NotNull TaskExecutionMode mode,
Expand Down

0 comments on commit f0849aa

Please sign in to comment.