Skip to content

Commit

Permalink
Merge pull request #95 from vanacekj/indirectAssignmentTooltip
Browse files Browse the repository at this point in the history
adding a tooltip with assignemntParent for indirect assignment column…
  • Loading branch information
katkav committed Mar 6, 2019
2 parents b901df5 + b236f4f commit 779c9df
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 11 deletions.
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.api.context.AssignmentPath;
import com.evolveum.midpoint.model.api.context.EvaluatedAssignment;
import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget;
import com.evolveum.midpoint.model.api.context.EvaluatedConstruction;
Expand Down Expand Up @@ -848,16 +849,13 @@ public List<AssignmentInfoDto> showAllAssignmentsPerformed(AjaxRequestTarget aja
private AssignmentInfoDto createAssignmentsPreviewDto(EvaluatedAssignmentTarget evaluatedAbstractRole,
Task task, OperationResult result) {
return createAssignmentsPreviewDto(evaluatedAbstractRole.getTarget(), evaluatedAbstractRole.isDirectlyAssigned(),
evaluatedAbstractRole.getAssignment(), task, result);
evaluatedAbstractRole.getAssignmentPath(), evaluatedAbstractRole.getAssignment(), task, result);
}

protected AssignmentInfoDto createAssignmentsPreviewDto(ObjectReferenceType reference,
Task task, OperationResult result) {
protected AssignmentInfoDto createAssignmentsPreviewDto(ObjectReferenceType reference, Task task, OperationResult result) {
PrismObject<? extends FocusType> targetObject = WebModelServiceUtils.resolveReferenceNoFetch(reference,
PageAdminFocus.this, task, result);

return createAssignmentsPreviewDto(targetObject, true,
null, task, result);
return createAssignmentsPreviewDto(targetObject, true, null, null, task, result);
}

protected AssignmentInfoDto createDelegableAssignmentsPreviewDto(AssignmentType assignment, Task task, OperationResult result) {
Expand All @@ -872,15 +870,15 @@ protected AssignmentInfoDto createDelegableAssignmentsPreviewDto(AssignmentType
isDelegable = targetObject.asObjectable().isDelegable();
}
if (Boolean.TRUE.equals(isDelegable)) {
return createAssignmentsPreviewDto(targetObject, true, assignment, task, result);
return createAssignmentsPreviewDto(targetObject, true, null, assignment, task, result);
}
}
}
return null;
}

private AssignmentInfoDto createAssignmentsPreviewDto(PrismObject<? extends AssignmentHolderType> targetObject,
boolean isDirectlyAssigned, AssignmentType assignment,
boolean isDirectlyAssigned, AssignmentPath assignmentPath, AssignmentType assignment,
Task task, OperationResult result) {
AssignmentInfoDto dto = new AssignmentInfoDto();
dto.setTargetOid(targetObject.getOid());
Expand All @@ -889,6 +887,7 @@ private AssignmentInfoDto createAssignmentsPreviewDto(PrismObject<? extends Assi
dto.setTargetClass(targetObject.getCompileTimeClass());
dto.setTargetType(WebComponentUtil.classToQName(getPrismContext(), targetObject.getCompileTimeClass()));
dto.setDirect(isDirectlyAssigned);
dto.setAssignmentParent(assignmentPath);
if (assignment != null) {
if (assignment.getTenantRef() != null) {
dto.setTenantName(nameFromReference(assignment.getTenantRef(),
Expand Down Expand Up @@ -949,6 +948,7 @@ private AssignmentInfoDto createAssignmentsPreviewDto(EvaluatedConstruction eval
dto.setTargetDescription(resource.asObjectable().getDescription());
dto.setTargetClass(resource.getCompileTimeClass());
dto.setDirect(evaluatedConstruction.isDirectlyAssigned());
dto.setAssignmentParent(evaluatedConstruction.getAssignmentPath());
dto.setKind(evaluatedConstruction.getKind());
dto.setIntent(evaluatedConstruction.getIntent());
return dto;
Expand Down
Expand Up @@ -18,6 +18,7 @@

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.model.api.context.AssignmentPath;
import com.evolveum.midpoint.web.component.util.Selectable;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.wicket.Component;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class AssignmentInfoDto extends Selectable<AssignmentInfoDto> implements
private String targetDescription;
private Class<? extends ObjectType> targetClass;
private boolean direct; // true if directly assigned; used only in some contexts
private ObjectType assignmentParent;
private QName targetType;
// for resource assignments
private ShadowKindType kind;
Expand Down Expand Up @@ -107,6 +109,16 @@ public void setDirect(boolean direct) {
this.direct = direct;
}

public void setAssignmentParent(AssignmentPath assignmentPath) {
if (assignmentPath.size() > 1 ) {
assignmentParent = assignmentPath.last().getSource();
}
}

public ObjectType getAssignmentParent() {
return assignmentParent;
}

public ShadowKindType getKind() {
return kind;
}
Expand Down
Expand Up @@ -33,6 +33,7 @@
import com.evolveum.midpoint.web.page.admin.users.PageOrgUnit;
import com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
Expand All @@ -54,6 +55,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.wicket.AttributeModifier;

/**
* Abstract superclass for dialogs that display a list of assignments.
Expand Down Expand Up @@ -155,6 +157,10 @@ public String getObject() {
createStringResource("AssignmentPreviewDialog.type.indirect").getString();
}
}));
ObjectType assignmentParent = rowModel.getObject().getAssignmentParent();
if (assignmentParent != null) {
cellItem.add(AttributeModifier.replace("title", createStringResource("AssignmentPreviewDialog.tooltip.indirect.parent").getString() + ": " + assignmentParent.getName()));
}
}
});
}
Expand Down
Expand Up @@ -110,6 +110,7 @@ AssignmentPreviewDialog.label=View direct & indirect assignments
AssignmentPreviewDialog.delegationPreviewLabel=Limit privileges
AssignmentPreviewDialog.type.direct=Direct
AssignmentPreviewDialog.type.indirect=Indirect
AssignmentPreviewDialog.tooltip.indirect.parent=Parent
AssignmentTablePanel.menu.assign=Assign
AssignmentTablePanel.menu.assignOrg=Assign Org.
AssignmentTablePanel.menu.assignOrg.noorgs=No organization structure defined.
Expand Down
Expand Up @@ -110,6 +110,7 @@ AssignmentPreviewDialog.label=Zobrazit přímá i nepřímá přiřazení
AssignmentPreviewDialog.delegationPreviewLabel=Omezit výsady
AssignmentPreviewDialog.type.direct=Přímé
AssignmentPreviewDialog.type.indirect=Nepřímé
AssignmentPreviewDialog.tooltip.indirect.parent=Předchůdce
AssignmentTablePanel.menu.assign=Přidat přiřazení
AssignmentTablePanel.menu.assignOrg=Přiřadit organizaci
AssignmentTablePanel.menu.assignOrg.noorgs=Organizační struktura není definovaná.
Expand Down
Expand Up @@ -110,6 +110,7 @@ AssignmentPreviewDialog.label=View direct & indirect assignments
AssignmentPreviewDialog.delegationPreviewLabel=Limit privileges
AssignmentPreviewDialog.type.direct=Direct
AssignmentPreviewDialog.type.indirect=Indirect
AssignmentPreviewDialog.tooltip.indirect.parent=Parent
AssignmentTablePanel.menu.assign=Assign
AssignmentTablePanel.menu.assignOrg=Assign Org.
AssignmentTablePanel.menu.assignOrg.noorgs=No organization structure defined.
Expand Down
Expand Up @@ -33,6 +33,8 @@ public interface EvaluatedConstruction extends DebugDumpable {
String getIntent();

boolean isDirectlyAssigned();


AssignmentPath getAssignmentPath();

boolean isWeak();
}
Expand Up @@ -16,6 +16,7 @@

package com.evolveum.midpoint.model.impl.lens;

import com.evolveum.midpoint.model.api.context.AssignmentPath;
import com.evolveum.midpoint.model.api.context.EvaluatedConstruction;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
Expand All @@ -24,7 +25,6 @@
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;

Expand All @@ -37,13 +37,15 @@ public class EvaluatedConstructionImpl implements EvaluatedConstruction {
final private ShadowKindType kind;
final private String intent;
final private boolean directlyAssigned;
final private AssignmentPath assignmentPath;
final private boolean weak;

public <AH extends AssignmentHolderType> EvaluatedConstructionImpl(Construction<AH> construction, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException {
resource = construction.getResource(task, result).asPrismObject();
kind = construction.getKind();
intent = construction.getIntent();
directlyAssigned = construction.getAssignmentPath() == null || construction.getAssignmentPath().size() == 1;
assignmentPath = construction.getAssignmentPath();
directlyAssigned = assignmentPath == null || assignmentPath.size() == 1;
weak = construction.isWeak();
}

Expand All @@ -67,6 +69,11 @@ public boolean isDirectlyAssigned() {
return directlyAssigned;
}

@Override
public AssignmentPath getAssignmentPath() {
return assignmentPath;
}

@Override
public boolean isWeak() {
return weak;
Expand Down

0 comments on commit 779c9df

Please sign in to comment.