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();
}
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;
}
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();
}
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);
}
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);
}
Aggregations