Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
* 'master' of github.com:Evolveum/midpoint:
  simulation ui, processed objects searching and navigation from widgets implemented
  Check activities for supported execution modes
  iterative searches: fixed ordering for strict-ordering column OID/repoID
  Added support for deletion of Simulated Processed Result Transaction
  simulation ui, metric widget implementation
  simulation ui, metric widget implementation
  searchReferencesIterative() strict ordering implementation (WIP)
  ModelController: fixes of operationResult handling
  simulation ui, improved search configuration
  • Loading branch information
katkav committed Feb 3, 2023
2 parents 797fe47 + 698bbf4 commit 634fa71
Show file tree
Hide file tree
Showing 55 changed files with 1,064 additions and 559 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.Collection;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.model.api.simulation.SimulationResultManager;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.wicket.Component;
Expand Down Expand Up @@ -235,6 +237,9 @@ public abstract class PageAdminLTE extends WebPage implements ModelServiceLocato
@SpringBean
private CorrelationService correlationService;

@SpringBean
private SimulationResultManager simulationResultManager;

// No need for this to store in session. It is used only during single init and render.
private transient Task pageTask;

Expand Down Expand Up @@ -526,6 +531,11 @@ public CorrelationService getCorrelationService() {
return correlationService;
}

@Override
public SimulationResultManager getSimulationResultManager() {
return simulationResultManager;
}

public MidPointApplication getMidpointApplication() {
return (MidPointApplication) getApplication();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile;
import com.evolveum.midpoint.model.api.correlation.CorrelationService;
import com.evolveum.midpoint.model.api.interaction.DashboardService;
import com.evolveum.midpoint.model.api.simulation.SimulationResultManager;
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObjectDefinition;
Expand Down Expand Up @@ -103,4 +104,9 @@ default ObjectResolver getModelObjectResolver() {
AdminGuiConfigurationMergeManager getAdminGuiConfigurationMergeManager();

CorrelationService getCorrelationService();

/**
* Experimental, functionality will be probably later hidden behind {@link ModelInteractionService}
*/
SimulationResultManager getSimulationResultManager();
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void initSearchModel() {
}
}

private boolean isUseStorageSearch(Search search) {
protected boolean isUseStorageSearch(Search search) {
if (search == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
*/
public interface IconCssStyle {

public static final BottomLeftIconCssStyle BOTTOM_LEFT_STYLE = new BottomLeftIconCssStyle();
public static final BottomRightIconCssStyle BOTTOM_RIGHT_STYLE = new BottomRightIconCssStyle();
public static final BottomLeftForColumnIconCssStyle BOTTOM_LEFT_FOR_COLUMN_STYLE = new BottomLeftForColumnIconCssStyle();
public static final BottomRightForColumnIconCssStyle BOTTOM_RIGHT_FOR_COLUMN_STYLE = new BottomRightForColumnIconCssStyle();
public static final CenterIconCssStyle CENTER_STYLE = new CenterIconCssStyle();
public static final CenterForColumnIconCssStyle CENTER_FOR_COLUMN_STYLE = new CenterForColumnIconCssStyle();
public static final CenterWithRightShiftCssStyle CENTER_STYLE_WITH_RIGHT_SHIFT = new CenterWithRightShiftCssStyle();
public static final InRowIconCssStyle IN_ROW_STYLE = new InRowIconCssStyle();
public static final TopLeftIconCssStyle TOP_LEFT_STYLE = new TopLeftIconCssStyle();
public static final TopRightIconCssStyle TOP_RIGHT_STYLE = new TopRightIconCssStyle();
public static final TopRightForColumnIconCssStyle TOP_RIGHT_FOR_COLUMN_STYLE = new TopRightForColumnIconCssStyle();
BottomLeftIconCssStyle BOTTOM_LEFT_STYLE = new BottomLeftIconCssStyle();
BottomRightIconCssStyle BOTTOM_RIGHT_STYLE = new BottomRightIconCssStyle();
BottomLeftForColumnIconCssStyle BOTTOM_LEFT_FOR_COLUMN_STYLE = new BottomLeftForColumnIconCssStyle();
BottomRightForColumnIconCssStyle BOTTOM_RIGHT_FOR_COLUMN_STYLE = new BottomRightForColumnIconCssStyle();
CenterIconCssStyle CENTER_STYLE = new CenterIconCssStyle();
CenterForColumnIconCssStyle CENTER_FOR_COLUMN_STYLE = new CenterForColumnIconCssStyle();
CenterWithRightShiftCssStyle CENTER_STYLE_WITH_RIGHT_SHIFT = new CenterWithRightShiftCssStyle();
InRowIconCssStyle IN_ROW_STYLE = new InRowIconCssStyle();
TopLeftIconCssStyle TOP_LEFT_STYLE = new TopLeftIconCssStyle();
TopRightIconCssStyle TOP_RIGHT_STYLE = new TopRightIconCssStyle();
TopRightForColumnIconCssStyle TOP_RIGHT_FOR_COLUMN_STYLE = new TopRightForColumnIconCssStyle();

public String getBasicCssClass();
String getBasicCssClass();

public String getLayerCssClass();
String getLayerCssClass();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class SearchContext {

private List<DisplayableValue<String>> availableEventMarks;

private String selectedEventMark;

public ResourceObjectDefinition getResourceObjectDefinition() {
return resourceObjectDefinition;
}
Expand Down Expand Up @@ -80,4 +82,12 @@ public List<DisplayableValue<String>> getAvailableEventMarks() {
public void setAvailableEventMarks(List<DisplayableValue<String>> availableEventMarks) {
this.availableEventMarks = availableEventMarks;
}

public String getSelectedEventMark() {
return selectedEventMark;
}

public void setSelectedEventMark(String selectedEventMark) {
this.selectedEventMark = selectedEventMark;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.evolveum.midpoint.gui.impl.component.search.SearchContext;
import com.evolveum.midpoint.gui.impl.component.search.factory.AbstractSearchItemWrapperFactory;
Expand All @@ -27,9 +28,22 @@ protected AvailableMarkSearchItemWrapper createSearchWrapper(SearchItemContext c
List<DisplayableValue<String>> availableEventMarks = additionalSearchContext != null ?
additionalSearchContext.getAvailableEventMarks() : new ArrayList<>();

DisplayableValue<String> selected = availableEventMarks.stream()
.filter(d -> Objects.equals(d.getValue(), additionalSearchContext.getSelectedEventMark()))
.findFirst().orElse(null);

AvailableMarkSearchItemWrapper wrapper = new AvailableMarkSearchItemWrapper(availableEventMarks);
wrapper.setCanConfigure(false);
wrapper.setValue(selected);

return wrapper;
}

@Override
public AvailableMarkSearchItemWrapper create(SearchItemContext ctx) {
AvailableMarkSearchItemWrapper wrapper = super.create(ctx);
wrapper.setVisible(true);

return wrapper;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.schema.expression.VariablesMap;
import com.evolveum.midpoint.util.DisplayableValue;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SimulationResultProcessedObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MarkType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SimulationResultProcessedObjectType;

/**
* Created by Viliam Repan (lazyman).
Expand All @@ -25,6 +25,9 @@ public class AvailableMarkSearchItemWrapper extends ChoicesSearchItemWrapper<Str

public AvailableMarkSearchItemWrapper(List<DisplayableValue<String>> availableValues) {
super(SimulationResultProcessedObjectType.F_EVENT_MARK_REF, availableValues);

setApplyFilter(true);
setVisible(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,6 @@

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

import static com.evolveum.midpoint.schema.util.SimulationMetricReferenceTypeUtil.getDisplayableIdentifier;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import javax.xml.datatype.XMLGregorianCalendar;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
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.LoadableDetachableModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction;
import com.evolveum.midpoint.authentication.api.authorization.PageDescriptor;
import com.evolveum.midpoint.authentication.api.authorization.Url;
Expand All @@ -43,6 +20,7 @@
import com.evolveum.midpoint.gui.impl.page.admin.task.PageTask;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.impl.PrismPropertyValueImpl;
import com.evolveum.midpoint.schema.util.SimulationMetricValuesTypeUtil;
import com.evolveum.midpoint.schema.util.ValueDisplayUtil;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.util.MiscUtil;
Expand All @@ -55,6 +33,30 @@
import com.evolveum.midpoint.web.page.admin.PageAdmin;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
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.LoadableDetachableModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.jetbrains.annotations.NotNull;

import javax.xml.datatype.XMLGregorianCalendar;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
* Created by Viliam Repan (lazyman).
Expand Down Expand Up @@ -210,20 +212,47 @@ protected void populateItem(ListItem<ResultDetail> item) {
};
add(details);

// todo implement
IModel<List<DashboardWidgetType>> data = () -> {

List<SimulationMetricValuesType> metrics = resultModel.getObject().getMetric();
return metrics.stream().map(m -> {
DashboardWidgetType dw = new DashboardWidgetType();
dw.setDescription(getDisplayableIdentifier(m.getRef()));
// dw.setTitle("TODO");//todo + SimulationMetricValuesTypeUtil.getValue(m));
// dw.setSmallBoxCssClass("bg-info");
// dw.setLinkText("More info");
// dw.setIcon("fa fa-database");
IModel<List<DashboardWidgetType>> data = new LoadableDetachableModel<List<DashboardWidgetType>>() {
@Override
protected List<DashboardWidgetType> load() {
List<SimulationMetricValuesType> metrics = resultModel.getObject().getMetric();
return metrics.stream().map(m -> {

BigDecimal value = SimulationMetricValuesTypeUtil.getValue(m);

DashboardWidgetType dw = new DashboardWidgetType();
dw.beginData()
.sourceType(DashboardWidgetSourceTypeType.METRIC)
.metricRef(m.getRef())
.storedData(value.toString())
.end();

SimulationMetricReferenceType metricRef = m.getRef();
if (metricRef.getEventMarkRef() != null) {
PrismObject<MarkType> mark = WebModelServiceUtils.loadObject(metricRef.getEventMarkRef(), PageSimulationResult.this);
if (mark != null) {
DisplayType display = mark.asObjectable().getDisplay();
if (display == null) {
display = new DisplayType();
display.setLabel(new PolyStringType(mark.getName()));
}
dw.setDisplay(display);
}
} else {
SimulationMetricDefinitionType def = getSimulationResultManager().getMetricDefinition(metricRef.getIdentifier());
if (def != null) {
DisplayType display = def.getDisplay();
if (display == null) {
display = new DisplayType();
display.setLabel(new PolyStringType(def.getIdentifier()));
}
dw.setDisplay(display);
}
}

return dw;
}).collect(Collectors.toList());
return dw;
}).collect(Collectors.toList());
}
};

ListView<DashboardWidgetType> widgets = new ListView<>(ID_WIDGETS, data) {
Expand All @@ -233,23 +262,39 @@ protected void populateItem(ListItem<DashboardWidgetType> item) {
item.add(new MetricWidgetPanel(ID_WIDGET, item.getModel()) {

@Override
protected void onOpenPerformed(AjaxRequestTarget target) {
openMarkMetricPerformed(target);
protected void onMoreInfoPerformed(AjaxRequestTarget target) {
openMarkMetricPerformed(target, item.getModelObject());
}
});
}
};

add(widgets);
}

private void onBackPerformed(AjaxRequestTarget target) {
redirectBack();
}

private void openMarkMetricPerformed(AjaxRequestTarget target) {
private void openMarkMetricPerformed(AjaxRequestTarget target, DashboardWidgetType widget) {
if (widget == null || widget.getData() == null) {
return;
}

DashboardWidgetDataType data = widget.getData();
if (data.getMetricRef() == null) {
return;
}

ObjectReferenceType ref = data.getMetricRef().getEventMarkRef();
if (ref == null || StringUtils.isEmpty(ref.getOid())) {
return;
}

PageParameters params = new PageParameters();
params.add(SimulationPage.PAGE_PARAMETER_RESULT_OID, getPageParameterResultOid());
// params.add(SimulationPage.PAGE_PARAMETER_MARK_OID, null); // todo add mark oid somehow
params.add(SimulationPage.PAGE_PARAMETER_MARK_OID, ref.getOid());

navigateToNext(PageSimulationResultObjects.class, params);
}

Expand Down Expand Up @@ -290,7 +335,8 @@ public static String createResultDurationText(SimulationResultType result, Compo
return DurationFormatUtils.formatDurationWords(duration, true, true);
}

public static Component createTaskStateLabel(String id, IModel<SimulationResultType> model, IModel<TaskType> taskModel, PageBase page) {
public static Component createTaskStateLabel(String
id, IModel<SimulationResultType> model, IModel<TaskType> taskModel, PageBase page) {
IModel<TaskExecutionStateType> stateModel = () -> {
TaskType task;
if (taskModel != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ protected String getMarkOid() {
}

private void onBackPerformed() {
redirectBack();
if (canRedirectBack()) {
redirectBack();
return;
}

clearBreadcrumbs();

PageParameters params = new PageParameters();
params.set(SimulationPage.PAGE_PARAMETER_RESULT_OID, resultModel.getObject().getOid());

navigateToNext(PageSimulationResult.class, params);
}
}

0 comments on commit 634fa71

Please sign in to comment.