use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class SchemaDebugUtil method prettyPrint.
public static String prettyPrint(ItemDeltaType change) throws SchemaException {
if (change == null) {
return "null";
}
StringBuilder sb = new StringBuilder("PropertyModification(");
sb.append(change.getModificationType());
sb.append(",");
if (change.getPath() != null) {
// todo ... with declarations?
sb.append(change.getPath().getItemPath());
} else {
sb.append("xpath=null");
}
sb.append(",");
List<RawType> values = change.getValue();
for (RawType value : values) {
// todo implement correctly...
sb.append(prettyPrint(value.serializeToXNode()));
sb.append(",");
}
return sb.toString();
}
use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class StaticExpressionUtil method getRawType.
private static RawType getRawType(Object valueElement, String contextDescription) throws SchemaException {
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);
}
return (RawType) jaxbElement.getValue();
}
use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class StaticExpressionUtil method deriveOutputDefinitionFromValueElements.
public static ItemDefinition<?> deriveOutputDefinitionFromValueElements(QName elementName, Collection<JAXBElement<?>> valueElements, String contextDescription, PrismContext prismContext) throws SchemaException {
QName overallType = null;
for (Object valueElement : valueElements) {
RawType rawType = getRawType(valueElement, contextDescription);
QName currentType = rawType.getExplicitTypeName();
if (currentType != null) {
QName unified = prismContext.getSchemaRegistry().unifyTypes(overallType, currentType);
if (unified == null) {
throw new SchemaException("Couldn't unify types " + overallType + " and " + currentType + " in " + contextDescription);
}
overallType = unified;
}
}
if (overallType == null) {
overallType = DOMUtil.XSD_STRING;
}
int maxOccurs = valueElements.size() > 1 ? -1 : 1;
return prismContext.getSchemaRegistry().createAdHocDefinition(elementName, overallType, 0, maxOccurs);
}
use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class ExpressionUtil method isShadowRefNodeExists.
public static boolean isShadowRefNodeExists(ExpressionType expression) {
if (expression == null) {
return false;
}
JAXBElement<?> element = ExpressionUtil.findFirstEvaluatorByName(expression, SchemaConstantsGenerated.C_VALUE);
if (element == null) {
return false;
}
if (element.getValue() instanceof RawType) {
RawType raw = (RawType) element.getValue();
PrismValue prismValue = raw.getAlreadyParsedValue();
if (prismValue instanceof PrismContainerValue && ((PrismContainerValue<?>) prismValue).getComplexTypeDefinition() != null && ShadowAssociationType.class.equals(((PrismContainerValue<?>) prismValue).getComplexTypeDefinition().getCompileTimeClass())) {
return true;
}
} else if (element.getValue() instanceof ShadowAssociationType) {
return true;
}
return false;
}
use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.
the class ExpressionUtil method updateLiteralExpressionValue.
public static void updateLiteralExpressionValue(ExpressionType expression, List<String> values, PrismContext prismContext) {
if (expression == null) {
// TODO ??? this is thrown away
expression = new ExpressionType();
}
removeEvaluatorByName(expression, SchemaConstantsGenerated.C_VALUE);
for (String value : values) {
PrimitiveXNode<String> newValueNode = prismContext.xnodeFactory().primitive(value);
RawType raw = new RawType(newValueNode.frozen(), prismContext);
JAXBElement element = new JAXBElement<>(SchemaConstantsGenerated.C_VALUE, RawType.class, raw);
expression.expressionEvaluator(element);
}
}
Aggregations