@NotNull public static List<PrismReferenceValue> asReferenceValues(@NotNull Collection<? extends Referencable> referencables) { return referencables.stream().map(ref -> ref.asReferenceValue()).collect(Collectors.toList()); }
@NotNull public static List<PrismReferenceValue> asReferenceValues(@NotNull Collection<? extends Referencable> referencables) { return referencables.stream().map(ref -> ref.asReferenceValue()).collect(Collectors.toList()); }
@Override public PrismValue createValue(Object realValue) { if (realValue instanceof Containerable) { return ((Containerable) realValue).asPrismContainerValue(); } else if (realValue instanceof Referencable) { return ((Referencable) realValue).asReferenceValue(); } else { return createPropertyValue(realValue); } }
protected ObjectReferenceType buildReference(Referencable input) { ObjectReferenceType objectRef; if (input instanceof ObjectReferenceType) { objectRef = (ObjectReferenceType) input; } else { objectRef = new ObjectReferenceType(); objectRef.setupReferenceValue(input.asReferenceValue()); } return objectRef; } }
private PrismValue toPrismValue(ItemDelta<?,?> currentDelta, @NotNull Object v) { ItemDefinition definition = currentDelta.getDefinition(); if (definition instanceof PrismPropertyDefinition) { return new PrismPropertyValueImpl<>(v); } else if (definition instanceof PrismContainerDefinition) { return ((Containerable) v).asPrismContainerValue(); } else if (definition instanceof PrismReferenceDefinition) { if (v instanceof Referencable) { return ((Referencable) v).asReferenceValue(); } else { throw new IllegalStateException("Expected Referencable, got: " + v); } } else { throw new IllegalStateException("Unsupported definition type: " + definition); } }
public PipelineData evaluateConstantExpression(@NotNull RawType constant, @Nullable Class<?> expectedClass, ExecutionContext context, String desc, OperationResult result) throws ScriptExecutionException { try { // TODO fix this brutal hacking PrismValue value; if (expectedClass == null) { value = constant.getParsedValue(null, null); } else { Object object = constant.getParsedRealValue(expectedClass); if (object instanceof Referencable) { value = ((Referencable) object).asReferenceValue(); } else if (object instanceof Containerable) { value = ((Containerable) object).asPrismContainerValue(); } else { value = prismContext.itemFactory().createPropertyValue(object); } } if (value.isRaw()) { throw new IllegalStateException("Raw value while " + desc + ": " + value + ". Please specify type of the value."); } return PipelineData.createItem(value, context.getInitialVariables()); } catch (SchemaException e) { throw new ScriptExecutionException(e.getMessage(), e); } }
PrismReferenceValue refValue = ((Referencable) jaxbBean).asReferenceValue(); reference.merge(refValue); subItem = (Item<IV,ID>) reference;
public static Function<Object, Object> createRefConvertor(QName defaultType) { return (o) -> { if (o == null || o instanceof ObjectReferenceType) { return o; } else if (o instanceof Referencable) { ObjectReferenceType rv = new ObjectReferenceType(); rv.setupReferenceValue(((Referencable) o).asReferenceValue()); return rv; } else if (o instanceof PrismReferenceValue) { ObjectReferenceType rv = new ObjectReferenceType(); rv.setupReferenceValue((PrismReferenceValue) o); return rv; } else if (o instanceof String) { return new ObjectReferenceType().oid((String) o).type(defaultType); } else { //throw new IllegalArgumentException("The value couldn't be converted to an object reference: " + o); return o; // let someone else complain at this } }; }
static PipelineData parseFrom(ValueListType input, Map<String, Object> frozenInitialVariables, PrismContext prismContext) { PipelineData rv = new PipelineData(); if (input != null) { for (Object o : input.getValue()) { if (o instanceof RawType) { // a bit of hack: this should have been solved by the parser (we'll fix this later) RawType raw = (RawType) o; PrismValue prismValue = raw.getAlreadyParsedValue(); if (prismValue != null) { rv.addValue(prismValue, frozenInitialVariables); } else { throw new IllegalArgumentException("Raw value in the input data: " + DebugUtil.debugDump(raw.getXnode())); // TODO attempt to parse it somehow (e.g. by passing to the pipeline and then parsing based on expected type) } } else { if (o instanceof Containerable) { rv.addValue(((Containerable) o).asPrismContainerValue(), frozenInitialVariables); } else if (o instanceof Referencable) { rv.addValue(((Referencable) o).asReferenceValue(), frozenInitialVariables); } else { rv.addValue(prismContext.itemFactory().createPropertyValue(o), frozenInitialVariables); } } } } return rv; }
PrismReferenceValue prv = ((Referencable) value).asReferenceValue(); if (!prv.isImmutable()) { PrismReferenceValue clone = prv.clone();