Search in sources :

Example 11 with PrismPropertyDefinitionImpl

use of com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl in project midpoint by Evolveum.

the class SimpleSmsTransport method evaluateExpression.

private String evaluateExpression(ExpressionType expressionType, ExpressionVariables expressionVariables, String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException {
    QName resultName = new QName(SchemaConstants.NS_C, "result");
    PrismPropertyDefinition<String> resultDef = new PrismPropertyDefinitionImpl(resultName, DOMUtil.XSD_STRING, prismContext);
    Expression<PrismPropertyValue<String>, PrismPropertyDefinition<String>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result);
    ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result);
    PrismValueDeltaSetTriple<PrismPropertyValue<String>> exprResult = ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result);
    if (exprResult.getZeroSet().size() != 1) {
        throw new SystemException("Invalid number of return values (" + exprResult.getZeroSet().size() + "), expected 1.");
    }
    return exprResult.getZeroSet().iterator().next().getValue();
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) SystemException(com.evolveum.midpoint.util.exception.SystemException) QName(javax.xml.namespace.QName) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 12 with PrismPropertyDefinitionImpl

use of com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl in project midpoint by Evolveum.

the class BaseHandler method evaluateBooleanExpression.

protected boolean evaluateBooleanExpression(ExpressionType expressionType, ExpressionVariables expressionVariables, String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException {
    QName resultName = new QName(SchemaConstants.NS_C, "result");
    PrismPropertyDefinition<Boolean> resultDef = new PrismPropertyDefinitionImpl<>(resultName, DOMUtil.XSD_BOOLEAN, prismContext);
    Expression<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result);
    ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result);
    PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> exprResultTriple = ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result);
    Collection<PrismPropertyValue<Boolean>> exprResult = exprResultTriple.getZeroSet();
    if (exprResult.size() == 0) {
        return false;
    } else if (exprResult.size() > 1) {
        throw new IllegalStateException("Filter expression should return exactly one boolean value; it returned " + exprResult.size() + " ones");
    }
    Boolean boolResult = exprResult.iterator().next().getValue();
    return boolResult != null ? boolResult : false;
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) QName(javax.xml.namespace.QName) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 13 with PrismPropertyDefinitionImpl

use of com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl in project midpoint by Evolveum.

the class PageDebugList method deleteObjectsAsync.

private String deleteObjectsAsync(QName type, ObjectQuery objectQuery, boolean raw, String taskName, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
    Task task = createSimpleTask(result.getOperation());
    task.setHandlerUri(ModelPublicConstants.DELETE_TASK_HANDLER_URI);
    if (objectQuery == null) {
        objectQuery = new ObjectQuery();
    }
    QueryType query = QueryJaxbConvertor.createQueryType(objectQuery, getPrismContext());
    PrismPropertyDefinition queryDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.COMPLEX_TYPE, getPrismContext());
    PrismProperty<QueryType> queryProp = queryDef.instantiate();
    queryProp.setRealValue(query);
    task.setExtensionProperty(queryProp);
    PrismPropertyDefinition typeDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE, DOMUtil.XSD_QNAME, getPrismContext());
    PrismProperty<QName> typeProp = typeDef.instantiate();
    typeProp.setRealValue(type);
    task.setExtensionProperty(typeProp);
    PrismPropertyDefinition rawDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OPTION_RAW, DOMUtil.XSD_BOOLEAN, getPrismContext());
    PrismProperty<QName> rawProp = rawDef.instantiate();
    rawProp.setRealValue(raw);
    task.setExtensionProperty(rawProp);
    task.setName(taskName);
    task.savePendingModifications(result);
    TaskManager taskManager = getTaskManager();
    taskManager.switchToBackground(task, result);
    result.setBackgroundTaskOid(task.getOid());
    return task.getOid();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TaskManager(com.evolveum.midpoint.task.api.TaskManager) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) QName(javax.xml.namespace.QName) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Example 14 with PrismPropertyDefinitionImpl

use of com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl in project midpoint by Evolveum.

the class AbstractScannerTaskHandler method finish.

@Override
protected void finish(H handler, TaskRunResult runResult, Task task, OperationResult opResult) throws SchemaException {
    super.finish(handler, runResult, task, opResult);
    PrismPropertyDefinition<XMLGregorianCalendar> lastScanTimestampDef = new PrismPropertyDefinitionImpl<>(SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME, DOMUtil.XSD_DATETIME, prismContext);
    PropertyDelta<XMLGregorianCalendar> lastScanTimestampDelta = new PropertyDelta<XMLGregorianCalendar>(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME), lastScanTimestampDef, prismContext);
    lastScanTimestampDelta.setValueToReplace(new PrismPropertyValue<XMLGregorianCalendar>(handler.getThisScanTimestamp()));
    task.modifyExtension(lastScanTimestampDelta);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 15 with PrismPropertyDefinitionImpl

use of com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl in project midpoint by Evolveum.

the class CustomTransport method evaluateExpression.

// TODO deduplicate
private void evaluateExpression(ExpressionType expressionType, ExpressionVariables expressionVariables, String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException {
    QName resultName = new QName(SchemaConstants.NS_C, "result");
    PrismPropertyDefinition<String> resultDef = new PrismPropertyDefinitionImpl<>(resultName, DOMUtil.XSD_STRING, prismContext);
    Expression<PrismPropertyValue<String>, PrismPropertyDefinition<String>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result);
    ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result);
    ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) QName(javax.xml.namespace.QName) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Aggregations

PrismPropertyDefinitionImpl (com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl)26 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)19 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)18 QName (javax.xml.namespace.QName)16 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10 Test (org.testng.annotations.Test)10 ExpressionVariables (com.evolveum.midpoint.repo.common.expression.ExpressionVariables)6 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)6 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 ScriptExpression (com.evolveum.midpoint.model.common.expression.script.ScriptExpression)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)3 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)2 Task (com.evolveum.midpoint.task.api.Task)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ScriptExpressionEvaluatorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExpressionEvaluatorType)2