use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class DeltaConvertor method addModValues.
// requires delta.prismContext to be set
private static void addModValues(ItemDelta delta, ItemDeltaType mod, Collection<PrismValue> values, DeltaConversionOptions options) throws SchemaException {
if (values == null || values.isEmpty()) {
// RawType modValue = new RawType(delta.getPrismContext());
// mod.getValue().add(modValue);
} else {
for (PrismValue value : values) {
XNode xnode = toXNode(delta, value, options);
RawType modValue = new RawType(xnode, value.getPrismContext());
mod.getValue().add(modValue);
}
}
}
use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class StaticExpressionUtil method serializeValueElements.
public static <IV extends PrismValue, ID extends ItemDefinition> List<JAXBElement<RawType>> serializeValueElements(Item<IV, ID> item, String contextDescription) throws SchemaException {
if (item == null) {
return null;
}
List<JAXBElement<RawType>> elements = new ArrayList<>(item.size());
for (PrismValue value : item.getValues()) {
RootXNode xnode = item.getPrismContext().xnodeSerializer().serialize(value);
RawType rawType = new RawType(xnode.getSubnode(), item.getPrismContext());
JAXBElement<RawType> jaxbElement = new JAXBElement<>(SchemaConstants.C_VALUE, RawType.class, rawType);
elements.add(jaxbElement);
}
return elements;
}
use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class StaticExpressionUtil method parseValueElements.
public static <IV extends PrismValue, ID extends ItemDefinition> Item<IV, ID> parseValueElements(Collection<?> valueElements, ID outputDefinition, String contextDescription, PrismContext prismContext) throws SchemaException {
Item<IV, ID> output = null;
for (Object valueElement : valueElements) {
if (!(valueElement instanceof JAXBElement<?>)) {
throw new SchemaException("Literal expression cannot handle element " + valueElement + " " + valueElement.getClass().getName() + " in " + contextDescription);
}
QName valueElementName = JAXBUtil.getElementQName(valueElement);
if (!valueElementName.equals(SchemaConstants.C_VALUE)) {
throw new SchemaException("Literal expression cannot handle element <" + valueElementName + "> in " + contextDescription);
}
JAXBElement<?> jaxbElement = (JAXBElement<?>) valueElement;
// not checking declaredType because it may be Object.class instead ... but actual type must be of RawType
if (jaxbElement.getValue() != null && !(jaxbElement.getValue() instanceof RawType)) {
throw new SchemaException("Literal expression cannot handle JAXBElement value type " + jaxbElement.getValue().getClass() + " in " + contextDescription);
}
RawType rawType = (RawType) jaxbElement.getValue();
//Item<V> elementItem = xnodeProcessor.parseItem(rawType.getXnode(), outputDefinition.getName(), outputDefinition);
Item<IV, ID> elementItem = rawType.getParsedItem(outputDefinition);
if (output == null) {
output = elementItem;
} else {
output.addAll(elementItem.getClonedValues());
}
}
return output;
}
use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class ItemDeltaBeanToNativeConversion method getParsedValues.
private Collection<IV> getParsedValues(List<RawType> values) throws SchemaException {
List<IV> parsedValues = new ArrayList<>();
for (RawType rawValue : values) {
if (itemDefinition == null) {
assert parentDefinition != null;
// noinspection unchecked
itemDefinition = (ID) ((PrismContextImpl) parentDefinition.getPrismContext()).getPrismUnmarshaller().locateItemDefinition(parentDefinition, itemName, rawValue.getXnode());
}
// Note this can be a slight problem if itemDefinition is PRD and the value is a full object.
PrismValue parsed = rawValue.getParsedValue(itemDefinition, itemName);
if (parsed != null) {
PrismValue converted;
if (itemDefinition instanceof PrismReferenceDefinition) {
converted = convertValueForReferenceDelta(parsed);
} else {
converted = parsed;
}
// noinspection unchecked
parsedValues.add((IV) converted.cloneComplex(CloneStrategy.LITERAL));
}
}
return parsedValues;
}
use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class ParamsTypeUtil method fromParamsType.
public static Map<String, Serializable> fromParamsType(ParamsType paramsType, PrismContext prismContext) throws SchemaException {
if (paramsType != null) {
Map<String, Serializable> params = new HashMap<>();
for (EntryType entry : paramsType.getEntry()) {
Serializable realValue;
if (entry.getEntryValue() != null) {
Serializable value = (Serializable) entry.getEntryValue().getValue();
if (value instanceof RawType) {
RawType raw = (RawType) value;
if (raw.isParsed()) {
realValue = raw.getAlreadyParsedValue().getRealValue();
} else {
realValue = raw.guessFormattedValue();
}
} else {
realValue = value;
}
} else {
realValue = null;
}
params.put(entry.getKey(), realValue);
}
return params;
}
return null;
}
Aggregations