Skip to content

Commit

Permalink
finishing task page visibility behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Mar 24, 2020
1 parent 394d3ed commit ccf6d4a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 14 deletions.
Expand Up @@ -18,7 +18,6 @@
*/
public interface PrismObjectWrapper<O extends ObjectType> extends PrismContainerWrapper<O> {

// List<PrismContainerWrapper<?>> getContainers();

ObjectDelta<O> getObjectDelta() throws SchemaException;

Expand Down
Expand Up @@ -19,6 +19,8 @@
*/
public interface PrismObjectWrapperFactory<O extends ObjectType> {

public PrismObjectWrapper<O> createObjectWrapper(PrismObject<O> object, ItemStatus status, WrapperContext context) throws SchemaException;
PrismObjectWrapper<O> createObjectWrapper(PrismObject<O> object, ItemStatus status, WrapperContext context) throws SchemaException;

void updateWrapper(PrismObjectWrapper<O> wrapper, WrapperContext context) throws SchemaException;

}
Expand Up @@ -74,13 +74,40 @@ public PrismObjectWrapper<O> createObjectWrapper(PrismObject<O> object, ItemStat
context.setShowEmpty(ItemStatus.ADDED == status);
objectWrapper.setExpanded(true);
PrismContainerValueWrapper<O> valueWrapper = createValueWrapper(objectWrapper, object.getValue(), ItemStatus.ADDED == status ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, context);
objectWrapper.getValues().clear();
objectWrapper.getValues().add(valueWrapper);

registry.registerWrapperPanel(object.getDefinition().getTypeName(), PrismContainerPanel.class);
return objectWrapper;

}

public void updateWrapper(PrismObjectWrapper<O> wrapper, WrapperContext context) throws SchemaException {
try {
applySecurityConstraints(wrapper.getObject(), context);
} catch (CommunicationException | ObjectNotFoundException | SecurityViolationException | ConfigurationException | ExpressionEvaluationException e) {
context.getResult().recordFatalError("Cannot create object wrapper for " + wrapper.getObject() + ". An error occurred: " + e.getMessage(), e);
throw new SchemaException(e.getMessage(), e);
}
if (context.getObjectStatus() == null) {
context.setObjectStatus(wrapper.getStatus());
}
context.setObject(wrapper.getObject());

Collection<VirtualContainersSpecificationType> virtualContainers = modelInteractionService.determineVirtualContainers(wrapper.getObject(), context.getTask(), context.getResult());
context.setVirtualContainers(virtualContainers);
context.setShowEmpty(ItemStatus.ADDED == wrapper.getStatus());
wrapper.setExpanded(true);

wrapper.getValue().getItems().clear();

PrismContainerValueWrapper<O> valueWrapper = createValueWrapper(wrapper, wrapper.getObject().getValue(), ItemStatus.ADDED == wrapper.getStatus() ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, context);
wrapper.getValues().clear();
wrapper.getValues().add(valueWrapper);

registry.registerWrapperPanel(wrapper.getObject().getDefinition().getTypeName(), PrismContainerPanel.class);
}

@Override
public PrismObjectValueWrapper<O> createContainerValueWrapper(PrismContainerWrapper<O> objectWrapper, PrismContainerValue<O> objectValue, ValueStatus status, WrapperContext context) {
return new PrismObjectValueWrapperImpl<O>((PrismObjectWrapper<O>) objectWrapper, (PrismObjectValue<O>) objectValue, status);
Expand Down
Expand Up @@ -6,18 +6,32 @@
*/
package com.evolveum.midpoint.web.page.admin.server;

import java.util.*;
import java.util.stream.Collectors;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.prism.PrismObjectWrapper;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebPrismUtil;
import com.evolveum.midpoint.gui.impl.factory.PrismObjectWrapperFactory;
import com.evolveum.midpoint.gui.impl.factory.WrapperContext;
import com.evolveum.midpoint.gui.impl.prism.*;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskHandler;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
Expand All @@ -29,23 +43,15 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import java.util.*;
import java.util.stream.Collectors;

public class TaskBasicTabPanel extends BasePanel<PrismObjectWrapper<TaskType>> implements RefreshableTabPanel {

private static final transient Trace LOGGER = TraceManager.getTrace(TaskBasicTabPanel.class);
private static final String ID_MAIN_PANEL = "main";
private static final String ID_HANDLER = "handler";

private static final String DOT_CLASS = TaskBasicTabPanel.class.getName() + ".";
private static final String OPERATION_UPDATE_WRAPPER = DOT_CLASS + "updateWrapper";


public TaskBasicTabPanel(String id, IModel<PrismObjectWrapper<TaskType>> model) {
super(id, model);
Expand Down Expand Up @@ -88,6 +94,15 @@ protected void onUpdatePerformed(AjaxRequestTarget target) {
}
}

PrismObjectWrapperFactory<TaskType> wrapperFactory = TaskBasicTabPanel.this.getPageBase().findObjectWrapperFactory(getTask().asPrismObject().getDefinition());
Task task = getPageBase().createSimpleTask(OPERATION_UPDATE_WRAPPER);
OperationResult result = task.getResult();
WrapperContext ctx = new WrapperContext(task, result);
try {
wrapperFactory.updateWrapper(TaskBasicTabPanel.this.getModelObject(), ctx);
} catch (SchemaException e) {
LOGGER.error("Unexpected problem occurs during updating wrapper. Reason: {}", e.getMessage(), e);
}
updateHandlerPerformed(target);

}
Expand Down Expand Up @@ -147,6 +162,11 @@ private ItemVisibility getBasicTabVisibility(ItemPath path) {
return ItemVisibility.AUTO;
}

if (hasArchetypeAssignemnt() && !isUtilityArchetypeAssignemnt() && !isSystemArchetypeAssignemnt()) {
//Visibility defined in archetype definition
return ItemVisibility.AUTO;
}

List<ItemPath> pathsToShow = new ArrayList<>();
if (taskHandler.endsWith("synchronization/task/delete/handler-3")) {
pathsToShow = Arrays.asList(SchemaConstants.PATH_MODEL_EXTENSION_OBJECT_TYPE,
Expand Down

0 comments on commit ccf6d4a

Please sign in to comment.