use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class Migrator method migrateObjectTemplate.
private PrismObject<ObjectTemplateType> migrateObjectTemplate(PrismObject<ObjectTemplateType> orig) {
QName elementName = orig.getElementName();
if (elementName.equals(SchemaConstants.C_OBJECT_TEMPLATE)) {
return orig;
}
PrismObject<ObjectTemplateType> migrated = orig.clone();
migrated.setElementName(SchemaConstants.C_OBJECT_TEMPLATE);
return migrated;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class TestParseLookupTable method testParseTableFileRoundTrip.
@Test
public void testParseTableFileRoundTrip() throws Exception {
System.out.println("===[ testParseTableFileRoundTrip ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN
PrismObject<LookupTableType> table = prismContext.parserFor(LOOKUP_TABLE_FILE).xml().parse();
// THEN
System.out.println("Parsed table:");
System.out.println(table.debugDump());
assertTable(table);
// WHEN
String xml = prismContext.serializeObjectToString(table, PrismContext.LANG_XML);
// THEN
System.out.println("Serialized object:");
System.out.println(xml);
// WHEN
PrismObject<ObjectTemplateType> reparsedObject = prismContext.parseObject(xml);
// THEN
System.out.println("Re-parsed object:");
System.out.println(reparsedObject.debugDump());
assertTable(table);
PrismAsserts.assertEquals(table.asObjectable(), reparsedObject.asObjectable());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class TestParseObjectTemplate method assertObjectTemplateInternals.
// checks raw values of mappings
// should be called only on reparsed values in order to catch some raw-data-related serialization issues (MID-2196)
private void assertObjectTemplateInternals(PrismObject<ObjectTemplateType> object, QName elementName) throws SchemaException {
int assignmentValuesFound = 0;
for (ObjectTemplateMappingType mappingType : object.asObjectable().getMapping()) {
if (mappingType.getExpression() != null) {
if (mappingType.getTarget() != null && mappingType.getTarget().getPath() != null && new ItemPath(UserType.F_ASSIGNMENT).equivalent(mappingType.getTarget().getPath().getItemPath())) {
ItemDefinition assignmentDef = PrismTestUtil.getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).findItemDefinition(UserType.F_ASSIGNMENT);
for (JAXBElement evaluator : mappingType.getExpression().getExpressionEvaluator()) {
if (evaluator.getValue() instanceof RawType) {
RawType rawType = (RawType) evaluator.getValue();
Item assignment = rawType.getParsedItem(assignmentDef);
System.out.println("assignment:\n" + assignment.debugDump());
assignmentValuesFound++;
}
}
}
}
}
assertEquals("wrong # of assignment values found in mapping", 2, assignmentValuesFound);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class TestParseObjectTemplate method testParseWrongTemplateFile.
@Test
public void testParseWrongTemplateFile() throws Exception {
final String TEST_NAME = "testParseWrongTemplateFile";
File file = WRONG_TEMPLATE_FILE;
System.out.println("===[ " + TEST_NAME + " ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN
try {
PrismObject<ObjectTemplateType> object = prismContext.parseObject(file);
System.out.println("Parsed object - SHOULD NOT OCCUR:");
System.out.println(object.debugDump());
fail("Object was successfully parsed while it should not!");
}// THEN
catch (SchemaException e) {
// ok
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class SchemaTransformer method applyObjectTemplateToDefinition.
public <O extends ObjectType> void applyObjectTemplateToDefinition(PrismObjectDefinition<O> objectDefinition, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException {
if (objectTemplateType == null) {
return;
}
for (ObjectReferenceType includeRef : objectTemplateType.getIncludeRef()) {
PrismObject<ObjectTemplateType> subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result);
applyObjectTemplateToDefinition(objectDefinition, subTemplate.asObjectable(), result);
}
for (ObjectTemplateItemDefinitionType templateItemDefType : objectTemplateType.getItem()) {
ItemPathType ref = templateItemDefType.getRef();
if (ref == null) {
throw new SchemaException("No 'ref' in item definition in " + objectTemplateType);
}
ItemPath itemPath = ref.getItemPath();
ItemDefinition itemDef = objectDefinition.findItemDefinition(itemPath);
if (itemDef != null) {
applyObjectTemplateItem(itemDef, templateItemDefType, "item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType);
} else {
OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToDefinition");
subResult.recordPartialError("No definition for item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType);
continue;
}
}
}
Aggregations