use of com.evolveum.midpoint.prism.PrismPropertyDefinition 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.PrismPropertyDefinition 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.PrismPropertyDefinition in project midpoint by Evolveum.
the class TaskQuartzImpl method setExtensionPropertyValueTransient.
@Override
public <T> void setExtensionPropertyValueTransient(QName propertyName, T value) throws SchemaException {
PrismPropertyDefinition propertyDef = getPrismContext().getSchemaRegistry().findPropertyDefinitionByElementName(propertyName);
if (propertyDef == null) {
throw new SchemaException("Unknown property " + propertyName);
}
ArrayList<PrismPropertyValue<T>> values = new ArrayList(1);
if (value != null) {
values.add(new PrismPropertyValue<T>(value));
}
ItemDelta delta = new PropertyDelta(new ItemPath(TaskType.F_EXTENSION, propertyName), propertyDef, getPrismContext());
delta.setValuesToReplace(values);
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>(1);
modifications.add(delta);
PropertyDelta.applyTo(modifications, taskPrism);
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TaskQuartzImpl method setExtensionPropertyValue.
// use this method to avoid cloning the value
@Override
public <T> void setExtensionPropertyValue(QName propertyName, T value) throws SchemaException {
PrismPropertyDefinition propertyDef = getPrismContext().getSchemaRegistry().findPropertyDefinitionByElementName(propertyName);
if (propertyDef == null) {
throw new SchemaException("Unknown property " + propertyName);
}
ArrayList<PrismPropertyValue<T>> values = new ArrayList(1);
if (value != null) {
values.add(new PrismPropertyValue<T>(value));
}
processModificationBatched(setExtensionPropertyAndPrepareDelta(propertyName, propertyDef, values));
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class ACAttributePanel method initLayout.
protected void initLayout(boolean ignoreMandatoryAttributes) {
Label attributeLabel = new Label(ID_ATTRIBUTE_LABEL, new PropertyModel(getModel(), ACAttributeDto.F_NAME));
add(attributeLabel);
WebMarkupContainer required = new WebMarkupContainer(ID_REQUIRED);
required.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
ACAttributeDto dto = getModel().getObject();
PrismPropertyDefinition def = dto.getDefinition();
return def.isMandatory();
}
});
add(required);
WebMarkupContainer hasOutbound = new WebMarkupContainer(ID_HAS_OUTBOUND);
hasOutbound.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return hasOutbound();
}
});
add(hasOutbound);
ListView<ACValueConstructionDto> values = new ListView<ACValueConstructionDto>(ID_VALUES, new PropertyModel<List<ACValueConstructionDto>>(getModel(), ACAttributeDto.F_VALUES)) {
@Override
protected void populateItem(ListItem<ACValueConstructionDto> listItem) {
Form form = findParent(Form.class);
listItem.add(new ACAttributeValuePanel(ID_VALUE, listItem.getModel(), ignoreMandatoryAttributes, form));
}
};
add(values);
}
Aggregations