Skip to content

Commit

Permalink
simulations, processed result objects page. prepared for all objects …
Browse files Browse the repository at this point in the history
…and objects filtered by tag
  • Loading branch information
1azyman committed Jan 12, 2023
1 parent 0a09be1 commit a0a8e8b
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
~ Copyright (c) 2021 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">
<body>
<wicket:extend>
<div class="row" >
<div class="col-md-12" wicket:id="table"/>
</div>
</wicket:extend>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2010-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.gui.impl.page.admin.simulation;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.mapper.parameter.PageParametersEncoder;
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;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.web.page.admin.PageAdmin;
import com.evolveum.midpoint.web.page.error.PageError404;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SimulationResultType;

/**
* Created by Viliam Repan (lazyman).
*/
@PageDescriptor(
urls = {
@Url(mountUrl = "/admin/simulations/result/${RESULT_OID}/objects"),
@Url(mountUrl = "/admin/simulations/result/${RESULT_OID}/tag/${TAG_OID}")
},
encoder = PageParametersEncoder.class,
// todo authorizations
action = {
@AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_SIMULATIONS_ALL_URL,
label = "PageSimulationResults.auth.simulationsAll.label",
description = "PageSimulationResults.auth.simulationsAll.description"),
@AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_SIMULATION_RESULT_URL,
label = "PageSimulationResults.auth.simulationResult.label",
description = "PageSimulationResults.auth.simulationResult.description")
}
)
public class PageSimulationResultObjects extends PageAdmin {

private static final long serialVersionUID = 1L;

private static final String PAGE_PARAMETER_RESULT_OID = "RESULT_OID";
private static final String PAGE_PARAMETER_TAG_OID = "TAG_OID";

private static final String ID_TABLE = "table";

public PageSimulationResultObjects() {
this(new PageParameters());
}

public PageSimulationResultObjects(PageParameters parameters) {
super(parameters);

initLayout();
}

private void initLayout() {
ProcessedObjectsPanel table = new ProcessedObjectsPanel(ID_TABLE) {

@Override
protected @NotNull String getSimulationResultOid() {
String oid = getPageParameterResultOid();
if (StringUtils.isEmpty(oid)) {
throw new RestartResponseException(PageError404.class);
}

return oid;
}
};
add(table);
}

private String getPageParameterResultOid() {
PageParameters params = getPageParameters();
return params.get(PAGE_PARAMETER_RESULT_OID).toString();
}

@Override
protected IModel<String> createPageTitleModel() {
return () -> {
String oid = getPageParameterResultOid();

if (StringUtils.isEmpty(oid)) {
throw new RestartResponseException(PageError404.class);
}

String name = WebModelServiceUtils.resolveReferenceName(
new ObjectReferenceType().oid(oid).type(SimulationResultType.COMPLEX_TYPE), this);

return getString("PageSimulationResultObjects.title", name);
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2010-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.gui.impl.page.admin.simulation;

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

import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.gui.impl.component.ContainerableListPanel;
import com.evolveum.midpoint.web.component.data.ISelectableDataProvider;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SimulationResultProcessedObjectType;

/**
* Created by Viliam Repan (lazyman).
*/
public class ProcessedObjectsPanel extends ContainerableListPanel<SimulationResultProcessedObjectType, SelectableBean<SimulationResultProcessedObjectType>> {

private static final long serialVersionUID = 1L;

public ProcessedObjectsPanel(String id) {
super(id, SimulationResultProcessedObjectType.class);
}

@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PAGE_SIMULATION_RESULT_PROCESSED_OBJECTS;
}

@Override
protected SimulationResultProcessedObjectType getRowRealValue(SelectableBean<SimulationResultProcessedObjectType> bean) {
return bean != null ? bean.getValue() : null;
}

@Override
protected IColumn<SelectableBean<SimulationResultProcessedObjectType>, String> createIconColumn() {
// TODO
return null;
}

@Override
protected ISelectableDataProvider<SelectableBean<SimulationResultProcessedObjectType>> createProvider() {
return new ProcessedObjectsProvider(this, getSearchModel()) {

@Override
protected @NotNull String getSimulationResultOid() {
return ProcessedObjectsPanel.this.getSimulationResultOid();
}
};
}

@NotNull
protected String getSimulationResultOid() {
return null;
}

@Override
public List<SimulationResultProcessedObjectType> getSelectedRealObjects() {
return getSelectedObjects().stream().map(o -> o.getValue()).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2010-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.gui.impl.page.admin.simulation;

import org.apache.wicket.Component;
import org.apache.wicket.model.IModel;
import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.gui.impl.component.search.Search;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SimulationResultProcessedObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SimulationResultType;

/**
* Created by Viliam Repan (lazyman).
*/
public class ProcessedObjectsProvider extends SelectableBeanContainerDataProvider<SimulationResultProcessedObjectType> {

public ProcessedObjectsProvider(Component component, @NotNull IModel<Search<SimulationResultProcessedObjectType>> search) {
super(component, search, null, false);
}

@Override
protected ObjectQuery getCustomizeContentQuery() {
String oid = getSimulationResultOid();

return getPrismContext().queryFor(SimulationResultProcessedObjectType.class)
.ownedBy(SimulationResultType.class, SimulationResultType.F_PROCESSED_OBJECT)
.id(oid)
.build();
}

@NotNull
protected String getSimulationResultOid() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.core.request.mapper.MountedMapper;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.mapper.parameter.IPageParametersEncoder;

Expand Down Expand Up @@ -85,13 +86,19 @@ private void mountPage(PageDescriptor descriptor, Class<WebPage> clazz, MidPoint
LOGGER.trace("Mounting page '{}' to url '{}' with encoder '{}'.",
clazz.getName(), url, encoder.getClass().getSimpleName());

application.mount(new ExactMatchMountedMapper(url.mountUrl(), clazz, encoder));
String mountUrl = url.mountUrl();
if (mountUrl.matches(".*\\$\\{[a-zA-Z_\\-]+\\}.*")) {
application.mount(new MountedMapper(mountUrl, clazz, encoder));
} else {
application.mount(new ExactMatchMountedMapper(mountUrl, clazz, encoder));
}

if (urlClassMap.containsKey(mountUrl)) {
throw new IllegalStateException("Mount url '" + mountUrl
+ "' is already used by '" + urlClassMap.get(mountUrl).getName()
+ "'. Attempting to add another class '" + clazz.getName() + "'");
}

urlClassMap.put(mountUrl, clazz);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.OrderDirection;
import com.evolveum.midpoint.prism.query.ValueFilter;
import com.evolveum.midpoint.prism.query.builder.S_FilterExit;
import com.evolveum.midpoint.schema.SchemaConstantsGenerated;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
Expand Down Expand Up @@ -247,18 +248,16 @@ public ObjectQuery getQuery() {
filter = idFilter;
}

if (filter != null) {
return getPrismContext().queryFor(AssignmentType.class)
.filter(filter)
.and()
.ownedBy(objectType, path)
.id(oid)
.build();
}
return getPrismContext().queryFor(AssignmentType.class)
.ownedBy(objectType, path)
.id(oid)
.build();
S_FilterExit builder = getPrismContext().queryFor(AssignmentType.class)
.ownedBy(objectType, path)
.id(oid);

if (filter != null) {
builder = builder.and()
.filter(filter);
}

return builder.build();
}

private QName determineTargetRefType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ public enum TableId {

PAGE_SIMULATION_RESULTS,

PAGE_SIMULATION_RESULT_TAGS
PAGE_SIMULATION_RESULT_TAGS,

PAGE_SIMULATION_RESULT_PROCESSED_OBJECTS;
}

private final Map<String, Integer> tables = new HashMap<>();
Expand Down

0 comments on commit a0a8e8b

Please sign in to comment.