use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class AssociationFromLinkExpressionEvaluator method getLegacyRole.
@NotNull
private AbstractRoleType getLegacyRole(ExpressionEvaluationContext context) throws ExpressionEvaluationException {
@SuppressWarnings("unchecked") TypedValue<AbstractRoleType> orderOneObjectTypedValue = context.getVariables().get(ExpressionConstants.VAR_THIS_OBJECT);
if (orderOneObjectTypedValue == null || orderOneObjectTypedValue.getValue() == null) {
throw new ExpressionEvaluationException("No order one object variable in " + context.getContextDescription() + "; the expression may be used in a wrong place. It is only supposed to work in a role.");
}
Object orderOneObject = orderOneObjectTypedValue.getValue();
if (orderOneObject instanceof AbstractRoleType) {
return (AbstractRoleType) orderOneObject;
} else {
throw new ExpressionEvaluationException("Order one object variable in " + context.getContextDescription() + " 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.");
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class AssociationFromLinkExpressionEvaluator method evaluate.
@Override
public PrismValueDeltaSetTriple<PrismContainerValue<ShadowAssociationType>> evaluate(ExpressionEvaluationContext context, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
checkEvaluatorProfile(context);
String desc = context.getContextDescription();
AbstractRoleType thisRole = getRelevantRole(context);
LOGGER.trace("Evaluating association from link {} on: {}", expressionEvaluatorBean.getDescription(), thisRole);
// noinspection unchecked
TypedValue<ResourceObjectDefinition> rAssocTargetDefTypedValue = context.getVariables().get(ExpressionConstants.VAR_ASSOCIATION_TARGET_OBJECT_CLASS_DEFINITION);
if (rAssocTargetDefTypedValue == null || rAssocTargetDefTypedValue.getValue() == 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.");
}
ResourceObjectDefinition associationTargetDef = (ResourceObjectDefinition) rAssocTargetDefTypedValue.getValue();
ShadowDiscriminatorType projectionDiscriminator = expressionEvaluatorBean.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 = associationTargetDef.getResourceOid();
List<String> candidateShadowOidList = new ArrayList<>();
// Always process the first role (myself) regardless of recursion setting
gatherCandidateShadowsFromAbstractRole(thisRole, candidateShadowOidList);
if (thisRole instanceof OrgType && matchesForRecursion((OrgType) thisRole)) {
gatherCandidateShadowsFromAbstractRoleRecurse((OrgType) thisRole, candidateShadowOidList, null, desc, context, result);
}
LOGGER.trace("Candidate shadow OIDs: {}", candidateShadowOidList);
selectMatchingShadows(candidateShadowOidList, output, resourceOid, kind, intent, assocName, context, result);
return ItemDeltaUtil.toDeltaSetTriple(output, null, prismContext);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class LifecycleUtil method getForcedAssignmentSpecification.
public static <R extends AbstractRoleType> VirtualAssignmenetSpecification<R> getForcedAssignmentSpecification(LifecycleStateModelType lifecycleStateModel, String targetLifecycleState, PrismContext prismContext) throws SchemaException {
LifecycleStateType stateDefinition = findStateDefinition(lifecycleStateModel, targetLifecycleState);
if (stateDefinition == null) {
return null;
}
VirtualAssignmentSpecificationType virtualAssignmentSpecificationType = stateDefinition.getForcedAssignment();
if (virtualAssignmentSpecificationType == null) {
return null;
}
SearchFilterType filter = virtualAssignmentSpecificationType.getFilter();
if (filter == null) {
return null;
}
QName targetType = virtualAssignmentSpecificationType.getTargetType();
Class<R> targetClass = (Class<R>) AbstractRoleType.class;
if (targetType != null) {
targetClass = (Class<R>) prismContext.getSchemaRegistry().getCompileTimeClassForObjectType(targetType);
}
VirtualAssignmenetSpecification<R> virtualAssignmenetSpecification = new VirtualAssignmenetSpecification();
virtualAssignmenetSpecification.setType(targetClass);
ObjectFilter objectFilter = prismContext.getQueryConverter().parseFilter(filter, targetClass);
virtualAssignmenetSpecification.setFilter(objectFilter);
return virtualAssignmenetSpecification;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class RAbstractRole method copyFromJAXB.
public static <T extends AbstractRoleType> void copyFromJAXB(AbstractRoleType jaxb, RAbstractRole<T> repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException {
RFocus.copyFromJAXB(jaxb, repo, repositoryContext, generatorResult);
repo.setRequestable(jaxb.isRequestable());
repo.setDisplayName(RPolyString.copyFromJAXB(jaxb.getDisplayName()));
repo.setIdentifier(jaxb.getIdentifier());
repo.setRiskLevel(jaxb.getRiskLevel());
for (AssignmentType inducement : jaxb.getInducement()) {
RAssignment rInducement = new RAssignment(repo, RAssignmentOwner.ABSTRACT_ROLE);
RAssignment.copyFromJAXB(inducement, rInducement, jaxb, repositoryContext, generatorResult);
repo.getAssignments().add(rInducement);
}
for (ExclusionPolicyConstraintType exclusion : jaxb.getExclusion()) {
RExclusion rExclusion = new RExclusion(repo);
RExclusion.copyFromJAXB(exclusion, rExclusion, jaxb, repositoryContext, generatorResult);
repo.getExclusion().add(rExclusion);
}
for (ObjectReferenceType approverRef : jaxb.getApproverRef()) {
RObjectReference ref = RUtil.jaxbRefToRepo(approverRef, repositoryContext.prismContext, repo, RReferenceOwner.ROLE_APPROVER);
if (ref != null) {
repo.getApproverRef().add(ref);
}
}
//PrismObjectDefinition<AbstractRoleType> roleDefinition = jaxb.asPrismObject().getDefinition();
repo.setApprovalProcess(jaxb.getApprovalProcess());
repo.setOwnerRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getOwnerRef(), repositoryContext.prismContext));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.
the class AutoAssignMappingCollector method collectAutoassignMappings.
<AH extends AssignmentHolderType> void collectAutoassignMappings(LensContext<AH> context, List<FocalMappingEvaluationRequest<?, ?>> mappings, OperationResult result) throws SchemaException {
if (!autoassignEnabled(context.getSystemConfiguration())) {
return;
}
ObjectQuery query = prismContext.queryFor(AbstractRoleType.class).item(SchemaConstants.PATH_AUTOASSIGN_ENABLED).eq(true).build();
ResultHandler<AbstractRoleType> handler = (role, objectResult) -> {
AutoassignSpecificationType autoassign = role.asObjectable().getAutoassign();
if (autoassign == null) {
return true;
}
if (!isTrue(autoassign.isEnabled())) {
return true;
}
FocalAutoassignSpecificationType focalAutoassignSpec = autoassign.getFocus();
if (focalAutoassignSpec == null) {
return true;
}
if (!isApplicableFor(focalAutoassignSpec.getSelector(), context.getFocusContext(), objectResult)) {
return true;
}
for (AutoassignMappingType autoMapping : focalAutoassignSpec.getMapping()) {
AutoassignMappingType mapping = LensUtil.setMappingTarget(autoMapping, new ItemPathType(SchemaConstants.PATH_ASSIGNMENT));
mappings.add(new AutoassignRoleMappingEvaluationRequest(mapping, role.asObjectable()));
LOGGER.trace("Collected autoassign mapping {} from {}", mapping.getName(), role);
}
return true;
};
cacheRepositoryService.searchObjectsIterative(AbstractRoleType.class, query, handler, createReadOnlyCollection(), true, result);
}
Aggregations