use of com.evolveum.midpoint.prism.MutablePrismPropertyDefinition in project midpoint by Evolveum.
the class SmsMessageTransport method evaluateExpression.
// A little hack: for single-value cases we always return single-item list (even if the returned value is null)
@NotNull
private List<String> evaluateExpression(ExpressionType expressionType, VariablesMap VariablesMap, boolean multipleValues, String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
if (expressionType == null) {
return multipleValues ? emptyList() : singletonList(null);
}
QName resultName = new QName(SchemaConstants.NS_C, "result");
MutablePrismPropertyDefinition<String> resultDef = transportSupport.prismContext().definitionFactory().createPropertyDefinition(resultName, DOMUtil.XSD_STRING);
if (multipleValues) {
resultDef.setMaxOccurs(-1);
}
Expression<PrismPropertyValue<String>, PrismPropertyDefinition<String>> expression = transportSupport.expressionFactory().makeExpression(expressionType, resultDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result);
ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, VariablesMap, shortDesc, task);
PrismValueDeltaSetTriple<PrismPropertyValue<String>> exprResult = ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result);
if (!multipleValues) {
if (exprResult.getZeroSet().size() > 1) {
throw new SystemException("Invalid number of return values (" + exprResult.getZeroSet().size() + "), expected at most 1.");
} else if (exprResult.getZeroSet().isEmpty()) {
return singletonList(null);
} else {
// single-valued response is treated below
}
}
return exprResult.getZeroSet().stream().map(ppv -> ppv.getValue()).collect(Collectors.toList());
}
use of com.evolveum.midpoint.prism.MutablePrismPropertyDefinition in project midpoint by Evolveum.
the class LegacySimpleSmsTransport method evaluateExpression.
// A little hack: for single-value cases we always return single-item list (even if the returned value is null)
@NotNull
private List<String> evaluateExpression(ExpressionType expressionType, VariablesMap VariablesMap, boolean multipleValues, String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
if (expressionType == null) {
return multipleValues ? emptyList() : singletonList(null);
}
QName resultName = new QName(SchemaConstants.NS_C, "result");
MutablePrismPropertyDefinition<String> resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, DOMUtil.XSD_STRING);
if (multipleValues) {
resultDef.setMaxOccurs(-1);
}
Expression<PrismPropertyValue<String>, PrismPropertyDefinition<String>> expression = expressionFactory.makeExpression(expressionType, resultDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result);
ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, VariablesMap, shortDesc, task);
PrismValueDeltaSetTriple<PrismPropertyValue<String>> exprResult = ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result);
if (!multipleValues) {
if (exprResult.getZeroSet().size() > 1) {
throw new SystemException("Invalid number of return values (" + exprResult.getZeroSet().size() + "), expected at most 1.");
} else if (exprResult.getZeroSet().isEmpty()) {
return singletonList(null);
} else {
// single-valued response is treated below
}
}
return exprResult.getZeroSet().stream().map(ppv -> ppv.getValue()).collect(Collectors.toList());
}
use of com.evolveum.midpoint.prism.MutablePrismPropertyDefinition in project midpoint by Evolveum.
the class ExtDictionaryTest method test100ParallelAdd.
@Test
public void test100ParallelAdd() throws Exception {
for (int round = 0; round < ROUNDS; round++) {
List<TestingThread> threads = new ArrayList<>();
for (int i = 0; i < THREADS; i++) {
final int round1 = round;
final int thread1 = i;
Runnable runnable = () -> {
try {
UserType user = new UserType(prismContext).name("u-" + round1 + "-" + thread1);
QName propertyName = new QName(NS_TEST, "round" + round1);
MutablePrismPropertyDefinition<String> propertyDefinition = prismContext.definitionFactory().createPropertyDefinition(propertyName, DOMUtil.XSD_STRING);
PrismProperty<String> property = propertyDefinition.instantiate();
property.setRealValue("value");
user.asPrismObject().addExtensionItem(property);
repositoryService.addObject(user.asPrismObject(), null, new OperationResult("addObject"));
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new SystemException(e);
}
};
TestingThread thread = new TestingThread(runnable);
threads.add(thread);
thread.start();
}
for (int i = 0; i < THREADS; i++) {
TestingThread thread = threads.get(i);
thread.join(60000L);
if (thread.throwable != null) {
fail("Exception in " + thread + ": " + thread.throwable);
}
}
}
Session session = open();
// noinspection unchecked
List<RExtItem> extItems = session.createQuery("from RExtItem").list();
System.out.println("ext items: " + extItems.size());
for (RExtItem extItem : extItems) {
System.out.println(extItem);
logger.info("{}", extItem);
}
session.close();
}
Aggregations