use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class AssociationFromLinkExpressionEvaluator method evaluate.
/* (non-Javadoc)
* @see com.evolveum.midpoint.common.expression.ExpressionEvaluator#evaluate(java.util.Collection, java.util.Map, boolean, java.lang.String, com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public PrismValueDeltaSetTriple<PrismContainerValue<ShadowAssociationType>> evaluate(ExpressionEvaluationContext context) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
String desc = context.getContextDescription();
Object orderOneObject = context.getVariables().get(ExpressionConstants.VAR_ORDER_ONE_OBJECT);
if (orderOneObject == null) {
throw new ExpressionEvaluationException("No order one object variable in " + desc + "; the expression may be used in a wrong place. It is only supposed to work in a role.");
}
if (!(orderOneObject instanceof AbstractRoleType)) {
throw new ExpressionEvaluationException("Order one object variable in " + desc + " is not a role, it is " + orderOneObject.getClass().getName() + "; the expression may be used in a wrong place. It is only supposed to work in a role.");
}
AbstractRoleType thisRole = (AbstractRoleType) orderOneObject;
LOGGER.trace("Evaluating association from link on: {}", thisRole);
RefinedObjectClassDefinition rAssocTargetDef = (RefinedObjectClassDefinition) context.getVariables().get(ExpressionConstants.VAR_ASSOCIATION_TARGET_OBJECT_CLASS_DEFINITION);
if (rAssocTargetDef == null) {
throw new ExpressionEvaluationException("No association target object class definition variable in " + desc + "; the expression may be used in a wrong place. It is only supposed to create an association.");
}
ShadowDiscriminatorType projectionDiscriminator = evaluatorType.getProjectionDiscriminator();
if (projectionDiscriminator == null) {
throw new ExpressionEvaluationException("No projectionDiscriminator in " + desc);
}
ShadowKindType kind = projectionDiscriminator.getKind();
if (kind == null) {
throw new ExpressionEvaluationException("No kind in projectionDiscriminator in " + desc);
}
String intent = projectionDiscriminator.getIntent();
PrismContainer<ShadowAssociationType> output = outputDefinition.instantiate();
QName assocName = context.getMappingQName();
String resourceOid = rAssocTargetDef.getResourceType().getOid();
Collection<SelectorOptions<GetOperationOptions>> options = null;
// Always process the first role (myself) regardless of recursion setting
gatherAssociationsFromAbstractRole(thisRole, output, resourceOid, kind, intent, assocName, options, desc, context);
if (thisRole instanceof OrgType && matchesForRecursion((OrgType) thisRole)) {
gatherAssociationsFromAbstractRoleRecurse((OrgType) thisRole, output, resourceOid, kind, intent, assocName, options, desc, context);
}
return ItemDelta.toDeltaSetTriple(output, null);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class AssociationFromLinkExpressionEvaluator method gatherAssociationsFromAbstractRole.
private void gatherAssociationsFromAbstractRole(AbstractRoleType thisRole, PrismContainer<ShadowAssociationType> output, String resourceOid, ShadowKindType kind, String intent, QName assocName, Collection<SelectorOptions<GetOperationOptions>> options, String desc, ExpressionEvaluationContext params) throws SchemaException {
for (ObjectReferenceType linkRef : thisRole.getLinkRef()) {
ShadowType shadowType;
try {
shadowType = objectResolver.resolve(linkRef, ShadowType.class, options, desc, params.getTask(), params.getResult());
} catch (ObjectNotFoundException e) {
// Linked shadow not found. This may happen e.g. if the account is deleted and model haven't got
// the chance to react yet. Just ignore such shadow.
LOGGER.trace("Ignoring shadow " + linkRef.getOid() + " linked in " + thisRole + " because it no longer exists");
continue;
}
if (ShadowUtil.matches(shadowType, resourceOid, kind, intent)) {
PrismContainerValue<ShadowAssociationType> newValue = output.createNewValue();
ShadowAssociationType shadowAssociationType = newValue.asContainerable();
shadowAssociationType.setName(assocName);
ObjectReferenceType shadowRef = new ObjectReferenceType();
shadowRef.setOid(linkRef.getOid());
shadowAssociationType.setShadowRef(shadowRef);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class RAbstractRole method copyFromJAXB.
// dynamically called
public static void copyFromJAXB(AbstractRoleType jaxb, RAbstractRole repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException {
copyFocusInformationFromJAXB(jaxb, repo, repositoryContext, generatorResult);
repo.setRequestable(jaxb.isRequestable());
repo.setDisplayName(RPolyString.copyFromJAXB(jaxb.getDisplayName()));
repo.setIdentifier(jaxb.getIdentifier());
repo.setRiskLevel(jaxb.getRiskLevel());
if (jaxb.getAutoassign() != null) {
RAutoassignSpecification aa = new RAutoassignSpecification();
RAutoassignSpecification.formJaxb(jaxb.getAutoassign(), aa);
repo.setAutoassign(aa);
}
for (AssignmentType inducement : jaxb.getInducement()) {
RAssignment rInducement = new RAssignment(repo, RAssignmentOwner.ABSTRACT_ROLE);
RAssignment.fromJaxb(inducement, rInducement, jaxb, repositoryContext, generatorResult);
repo.getAssignments().add(rInducement);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class ApplicablePolicyGroupPanel method onPolicyAddedOrRemoved.
private void onPolicyAddedOrRemoved(PrismObject<AbstractRoleType> assignmentTargetObject, boolean added) {
if (isAssignmentAlreadyInList(assignmentTargetObject.getOid())) {
PrismContainerValueWrapper<AssignmentType> assignmentToRemove = null;
for (PrismContainerValueWrapper<AssignmentType> assignment : assignmentsModel.getObject().getValues()) {
ObjectReferenceType targetRef = assignment.getRealValue().getTargetRef();
if (targetRef != null && targetRef.getOid().equals(assignmentTargetObject.getOid())) {
if (added && assignment.getStatus() == ValueStatus.DELETED) {
assignment.setStatus(ValueStatus.NOT_CHANGED);
} else if (!added && assignment.getStatus() == ValueStatus.ADDED) {
assignmentToRemove = assignment;
} else if (!added) {
assignment.setStatus(ValueStatus.DELETED);
}
}
}
assignmentsModel.getObject().getValues().remove(assignmentToRemove);
} else {
if (added) {
// TODO: not sure if this is correct way of creating new value.. this value is added directly to the origin object... what about deltas??
PrismContainerValue<AssignmentType> newAssignment = assignmentsModel.getObject().getItem().createNewValue();
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(assignmentTargetObject, getPageBase().getPrismContext());
AssignmentType assignmentType = newAssignment.asContainerable();
assignmentType.setTargetRef(ref);
Task task = getPageBase().createSimpleTask("Creating new applicable policy");
WrapperContext context = new WrapperContext(task, null);
PrismContainerValueWrapper<AssignmentType> valueWrapper;
try {
valueWrapper = (PrismContainerValueWrapper<AssignmentType>) getPageBase().createValueWrapper(assignmentsModel.getObject(), newAssignment, ValueStatus.ADDED, context);
assignmentsModel.getObject().getValues().add(valueWrapper);
} catch (SchemaException e) {
// TOTO error handling
}
//
// valueWrapper.setShowEmpty(true, false);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class ApplicablePolicyGroupPanel method initLayout.
private void initLayout() {
Label policyGroupName = new Label(ID_POLICY_GROUP_NAME, Model.of(WebComponentUtil.getDisplayNameOrName(getModelObject(), getPageBase(), OPERATION_LOAD_POLICY_GROUP_NAME)));
policyGroupName.setOutputMarkupId(true);
add(policyGroupName);
ListView<PrismObject<AbstractRoleType>> policiesPanel = new ListView<PrismObject<AbstractRoleType>>(ID_POLICIES_CONTAINER, policiesListModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<PrismObject<AbstractRoleType>> listItem) {
PrismObject<AbstractRoleType> abstractRole = listItem.getModelObject();
CheckBoxPanel policyCheckBox = new CheckBoxPanel(ID_POLICY_CHECK_BOX, getCheckboxModel(abstractRole), // label
Model.of(WebComponentUtil.getDisplayNameOrName(abstractRole)), // tooltip
null) {
private static final long serialVersionUID = 1L;
@Override
public void onUpdate(AjaxRequestTarget target) {
onPolicyAddedOrRemoved(listItem.getModelObject(), getValue());
}
};
policyCheckBox.setOutputMarkupId(true);
listItem.add(policyCheckBox);
}
};
policiesPanel.setOutputMarkupId(true);
add(policiesPanel);
}
Aggregations