use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class JaxbTypeConverter method toPolyStringType.
private static PolyStringType toPolyStringType(PolyString polyString) {
if (polyString == null) {
return null;
}
PolyStringType polyStringType = new PolyStringType();
polyStringType.setOrig(polyString.getOrig());
polyStringType.setNorm(polyString.getNorm());
return polyStringType;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class MultipleAssignmentSelectorPanel method createTenantOrgDto.
private AssignmentEditorDto createTenantOrgDto() {
//doesn't matter the type
AssignmentEditorDtoType aType = AssignmentEditorDtoType.ROLE;
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid("");
targetRef.setType(aType.getQname());
targetRef.setTargetName(new PolyStringType(""));
AssignmentType assignment = new AssignmentType();
assignment.setTargetRef(targetRef);
AssignmentEditorDto tenantOrgDto = new AssignmentEditorDto(UserDtoStatus.ADD, assignment, getPageBase());
if (tenantEditorObject != null && tenantEditorObject.size() > 0) {
OrgType org = tenantEditorObject.get(0);
ObjectViewDto<OrgType> dto = new ObjectViewDto(org.getOid(), tenantEditorObject.get(0).getName() == null ? "" : tenantEditorObject.get(0).getName().toString());
dto.setType(OrgType.class);
tenantOrgDto.setTenantRef(dto);
}
if (orgEditorObject != null && orgEditorObject.size() > 0) {
OrgType org = orgEditorObject.get(0);
ObjectViewDto<OrgType> dto = new ObjectViewDto(org.getOid(), orgEditorObject.get(0).getName() == null ? "" : orgEditorObject.get(0).getName().toString());
dto.setType(OrgType.class);
tenantOrgDto.setOrgRef(dto);
}
return tenantOrgDto;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class TestDiffEquals method testDiffShadow.
@Test
public void testDiffShadow() throws Exception {
System.out.println("\n\n===[ testDiffShadow ]===\n");
PrismContext prismContext = PrismTestUtil.getPrismContext();
PrismObject<ShadowType> shadow1 = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class).instantiate();
ShadowType shadow1Type = shadow1.asObjectable();
shadow1Type.setName(new PolyStringType("Whatever"));
shadow1Type.setFailedOperationType(FailedOperationTypeType.ADD);
shadow1Type.getAuxiliaryObjectClass().add(new QName(NS_TEST_RI, "foo"));
PrismContainer<Containerable> shadow1Attrs = shadow1.findOrCreateContainer(ShadowType.F_ATTRIBUTES);
ShadowType shadow2Type = new ShadowType();
PrismObject<ShadowType> shadow2 = shadow2Type.asPrismObject();
prismContext.adopt(shadow2Type);
shadow2Type.setName(new PolyStringType("Whatever"));
shadow2Type.getAuxiliaryObjectClass().add(new QName(NS_TEST_RI, "foo"));
shadow2Type.getAuxiliaryObjectClass().add(new QName(NS_TEST_RI, "bar"));
PrismContainer<Containerable> shadow2Attrs = shadow2.findOrCreateContainer(ShadowType.F_ATTRIBUTES);
PrismProperty<String> attrEntryUuid = new PrismProperty<>(new QName(NS_TEST_RI, "entryUuid"), prismContext);
PrismPropertyDefinition<String> attrEntryUuidDef = new PrismPropertyDefinitionImpl<>(new QName(NS_TEST_RI, "entryUuid"), DOMUtil.XSD_STRING, prismContext);
attrEntryUuid.setDefinition(attrEntryUuidDef);
shadow2Attrs.add(attrEntryUuid);
attrEntryUuid.addRealValue("1234-5678-8765-4321");
PrismProperty<String> attrDn = new PrismProperty<>(new QName(NS_TEST_RI, "dn"), prismContext);
PrismPropertyDefinition<String> attrDnDef = new PrismPropertyDefinitionImpl<>(new QName(NS_TEST_RI, "dn"), DOMUtil.XSD_STRING, prismContext);
attrDn.setDefinition(attrDnDef);
shadow2Attrs.add(attrDn);
attrDn.addRealValue("uid=foo,o=bar");
System.out.println("Shadow 1");
System.out.println(shadow1.debugDump(1));
System.out.println("Shadow 2");
System.out.println(shadow2.debugDump(1));
// WHEN
ObjectDelta<ShadowType> delta = shadow1.diff(shadow2);
// THEN
assertNotNull("No delta", delta);
System.out.println("Delta");
System.out.println(delta.debugDump(1));
PrismAsserts.assertIsModify(delta);
PrismAsserts.assertPropertyDelete(delta, ShadowType.F_FAILED_OPERATION_TYPE, FailedOperationTypeType.ADD);
PrismAsserts.assertPropertyAdd(delta, ShadowType.F_AUXILIARY_OBJECT_CLASS, new QName(NS_TEST_RI, "bar"));
PrismAsserts.assertContainerAdd(delta, ShadowType.F_ATTRIBUTES, shadow2Attrs.getValue().clone());
PrismAsserts.assertModifications(delta, 3);
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class ReconciliationTaskHandler method launch.
/**
* Launch an import. Calling this method will start import in a new
* thread, possibly on a different node.
*/
public void launch(ResourceType resource, QName objectclass, Task task, OperationResult parentResult) {
LOGGER.info("Launching reconciliation for resource {} as asynchronous task", ObjectTypeUtil.toShortString(resource));
OperationResult result = parentResult.createSubresult(ReconciliationTaskHandler.class.getName() + ".launch");
result.addParam("resource", resource);
result.addParam("objectclass", objectclass);
// TODO
// Set handler URI so we will be called back
task.setHandlerUri(HANDLER_URI);
// Readable task name
PolyStringType polyString = new PolyStringType("Reconciling " + resource.getName());
task.setName(polyString);
// Set reference to the resource
task.setObjectRef(ObjectTypeUtil.createObjectRef(resource));
try {
task.setExtensionPropertyValue(ModelConstants.OBJECTCLASS_PROPERTY_NAME, objectclass);
// just to be sure (if the task was already persistent)
task.savePendingModifications(result);
} catch (ObjectNotFoundException e) {
LOGGER.error("Task object not found, expecting it to exist (task {})", task, e);
result.recordFatalError("Task object not found", e);
throw new IllegalStateException("Task object not found, expecting it to exist", e);
} catch (ObjectAlreadyExistsException e) {
LOGGER.error("Task object wasn't updated (task {})", task, e);
result.recordFatalError("Task object wasn't updated", e);
throw new IllegalStateException("Task object wasn't updated", e);
} catch (SchemaException e) {
LOGGER.error("Error dealing with schema (task {})", task, e);
result.recordFatalError("Error dealing with schema", e);
throw new IllegalStateException("Error dealing with schema", e);
}
// Switch task to background. This will start new thread and call
// the run(task) method.
// Note: the thread may be actually started on a different node
taskManager.switchToBackground(task, result);
result.setBackgroundTaskOid(task.getOid());
result.computeStatus("Reconciliation launch failed");
LOGGER.trace("Reconciliation for resource {} switched to background, control thread returning with task {}", ObjectTypeUtil.toShortString(resource), task);
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class PrismUnmarshaller method parseReferenceValueAsReference.
private PrismReferenceValue parseReferenceValueAsReference(@NotNull XNode xnode, @NotNull PrismReferenceDefinition definition, @NotNull ParsingContext pc, boolean allowMissingRefTypesOverride) throws SchemaException {
if (!(xnode instanceof MapXNode)) {
throw new IllegalArgumentException("Cannot parse reference from " + xnode);
}
MapXNode map = (MapXNode) xnode;
String oid = map.getParsedPrimitiveValue(XNode.KEY_REFERENCE_OID, DOMUtil.XSD_STRING);
PrismReferenceValue refVal = new PrismReferenceValue(oid);
QName type = map.getParsedPrimitiveValue(XNode.KEY_REFERENCE_TYPE, DOMUtil.XSD_QNAME);
if (type == null) {
if (!pc.isAllowMissingRefTypes() && !allowMissingRefTypesOverride) {
type = definition.getTargetTypeName();
if (type == null) {
throw new SchemaException("Target type in reference " + definition.getName() + " not specified in reference nor in the schema");
}
}
} else {
if (QNameUtil.noNamespace(type)) {
type = getSchemaRegistry().resolveUnqualifiedTypeName(type);
}
QName defTargetType = definition.getTargetTypeName();
if (defTargetType != null) {
if (!(prismContext.getSchemaRegistry().isAssignableFrom(defTargetType, type))) {
throw new SchemaException("Target type specified in reference " + definition.getName() + " (" + type + ") does not match target type in schema (" + defTargetType + ")");
}
}
}
PrismObjectDefinition<Objectable> objectDefinition = null;
if (type != null) {
objectDefinition = getSchemaRegistry().findObjectDefinitionByType(type);
if (objectDefinition == null) {
throw new SchemaException("No definition for type " + type + " in reference");
}
refVal.setTargetType(type);
}
QName relationAttribute = map.getParsedPrimitiveValue(XNode.KEY_REFERENCE_RELATION, DOMUtil.XSD_QNAME);
refVal.setRelation(relationAttribute);
refVal.setDescription(map.getParsedPrimitiveValue(XNode.KEY_REFERENCE_DESCRIPTION, DOMUtil.XSD_STRING));
refVal.setFilter(parseFilter(map.get(XNode.KEY_REFERENCE_FILTER)));
String resolutionTimeString = map.getParsedPrimitiveValue(XNode.KEY_REFERENCE_RESOLUTION_TIME, DOMUtil.XSD_STRING);
if (resolutionTimeString != null) {
EvaluationTimeType resolutionTime = EvaluationTimeType.fromValue(resolutionTimeString);
refVal.setResolutionTime(resolutionTime);
}
XNode xnodeForTargetName = map.get(XNode.KEY_REFERENCE_TARGET_NAME);
if (xnodeForTargetName != null) {
PolyStringType targetName = getBeanUnmarshaller().unmarshal(xnodeForTargetName, PolyStringType.class, pc);
refVal.setTargetName(targetName);
}
XNode xrefObject = map.get(XNode.KEY_REFERENCE_OBJECT);
if (xrefObject != null) {
if (!(xrefObject instanceof MapXNode)) {
throw new SchemaException("Cannot parse object from " + xrefObject);
}
if (type == null) {
throw new SchemaException("Cannot parse object from " + xrefObject + " without knowing its type");
}
PrismObject<Objectable> object = parseObject((MapXNode) xrefObject, objectDefinition, pc);
setReferenceObject(refVal, object);
}
return refVal;
}
Aggregations