Search in sources :

Example 1 with AssignActionExpressionType

use of com.evolveum.midpoint.xml.ns._public.model.scripting_3.AssignActionExpressionType in project midpoint by Evolveum.

the class AssignExecutor method parseParameters.

@Override
AssignParameters parseParameters(ActionExpressionType action, PipelineData input, ExecutionContext context, OperationResult result) throws SchemaException, ScriptExecutionException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    AssignParameters parameters = new AssignParameters();
    // Dynamic parameters
    Collection<ObjectReferenceType> dynamicRoleRefs = getRolesParameter(action, input, context, result);
    Collection<ObjectReferenceType> dynamicResourceRefs = getResourcesParameter(action, input, context, result);
    Collection<QName> relationSpecifications = getRelationsParameter(action, input, context, result);
    QName relationSpecification = MiscUtil.extractSingleton(relationSpecifications, () -> new IllegalArgumentException("Using 'relation' as a multivalued parameter is not allowed"));
    if (PrismConstants.Q_ANY.matches(relationSpecification)) {
        throw new IllegalArgumentException("Using 'q:any' as relation specification is not allowed");
    }
    QName relationOverride;
    if (relationSpecification != null) {
        List<RelationDefinitionType> relationDefinitions = relationRegistry.getRelationDefinitions();
        relationOverride = relationDefinitions.stream().filter(definition -> prismContext.relationMatches(relationSpecification, definition.getRef())).findFirst().orElseThrow(() -> new IllegalArgumentException("Relation matching '" + relationSpecification + "' not found")).getRef();
    } else {
        relationOverride = null;
    }
    // Static parameters
    Collection<ObjectReferenceType> staticTargetRefs;
    Collection<ObjectReferenceType> staticResourceRefs;
    Collection<ConstructionType> staticConstructions;
    if (action instanceof AssignActionExpressionType) {
        staticTargetRefs = ((AssignActionExpressionType) action).getTargetRef();
        staticResourceRefs = ((AssignActionExpressionType) action).getResourceRef();
        staticConstructions = ((AssignActionExpressionType) action).getConstruction();
    } else {
        staticTargetRefs = emptyList();
        staticResourceRefs = emptyList();
        staticConstructions = emptyList();
    }
    // Consolidation
    Task task = context.getTask();
    parameters.targetRefs.addAll(resolve(staticTargetRefs, relationOverride, task, result));
    parameters.targetRefs.addAll(resolve(dynamicRoleRefs, relationOverride, task, result));
    QName defaultRelation = relationRegistry.getDefaultRelation();
    parameters.constructions.addAll(staticConstructions);
    parameters.constructions.addAll(resourceRefsToConstructions(resolve(staticResourceRefs, defaultRelation, task, result)));
    parameters.constructions.addAll(resourceRefsToConstructions(resolve(dynamicResourceRefs, defaultRelation, task, result)));
    return parameters;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) AssignActionExpressionType(com.evolveum.midpoint.xml.ns._public.model.scripting_3.AssignActionExpressionType)

Aggregations

Task (com.evolveum.midpoint.task.api.Task)1 AssignActionExpressionType (com.evolveum.midpoint.xml.ns._public.model.scripting_3.AssignActionExpressionType)1 QName (javax.xml.namespace.QName)1