use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType in project midpoint by Evolveum.
the class GetAssignmentResult method toConstruction.
private ConstructionType toConstruction(REmbeddedReference resourceRef, PrismContext prismContext) {
if (resourceRef == null) {
return null;
}
ConstructionType construction = new ConstructionType(prismContext);
ObjectReferenceType ref = new ObjectReferenceType();
REmbeddedReference.copyToJAXB(resourceRef, ref, prismContext);
construction.setResourceRef(ref);
return construction;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType in project midpoint by Evolveum.
the class SchemaTestUtil method assertFocusDefinition.
public static void assertFocusDefinition(ComplexTypeDefinition complexTypeDefinition, String defDesc, QName expectedExtensionTypeName, int expectedExtensionItemDefs) {
assertNotNull("No " + defDesc + " definition", complexTypeDefinition);
PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_NAME, PolyStringType.COMPLEX_TYPE, 0, 1);
PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_NAME, "ObjectType.name");
PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_NAME, 0);
PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_DESCRIPTION, DOMUtil.XSD_STRING, 0, 1);
PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_DESCRIPTION, "ObjectType.description");
PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_DESCRIPTION, 10);
assertFalse("" + defDesc + " definition is marked as runtime", complexTypeDefinition.isRuntimeSchema());
PrismContainerDefinition extensionContainer = complexTypeDefinition.findContainerDefinition(UserType.F_EXTENSION);
PrismAsserts.assertDefinition(extensionContainer, UserType.F_EXTENSION, expectedExtensionTypeName, 0, 1);
assertTrue("Extension is NOT runtime", extensionContainer.isRuntimeSchema());
// assertTrue("Extension is NOT dynamic", extensionContainer.isDynamic());
assertEquals("Extension size", expectedExtensionItemDefs, extensionContainer.getDefinitions().size());
PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, UserType.F_EXTENSION, "ObjectType.extension");
PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, UserType.F_EXTENSION, 1000);
PrismContainerDefinition<ActivationType> activationContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ACTIVATION);
PrismAsserts.assertDefinition(activationContainer, UserType.F_ACTIVATION, ActivationType.COMPLEX_TYPE, 0, 1);
assertFalse("Activation is runtime", activationContainer.isRuntimeSchema());
assertEquals("Activation size", 12, activationContainer.getDefinitions().size());
PrismAsserts.assertPropertyDefinition(activationContainer, ActivationType.F_ADMINISTRATIVE_STATUS, SchemaConstants.C_ACTIVATION_STATUS_TYPE, 0, 1);
PrismContainerDefinition<AssignmentType> assignmentContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ASSIGNMENT);
PrismAsserts.assertDefinition(assignmentContainer, UserType.F_ASSIGNMENT, AssignmentType.COMPLEX_TYPE, 0, -1);
assertFalse("Assignment is runtime", assignmentContainer.isRuntimeSchema());
assertEquals("Assignment definition size", 24, assignmentContainer.getDefinitions().size());
PrismContainerDefinition<ConstructionType> constructionContainer = assignmentContainer.findContainerDefinition(AssignmentType.F_CONSTRUCTION);
PrismAsserts.assertDefinition(constructionContainer, AssignmentType.F_CONSTRUCTION, ConstructionType.COMPLEX_TYPE, 0, 1);
assertFalse("Construction is runtime", constructionContainer.isRuntimeSchema());
PrismReferenceDefinition accountRefDef = complexTypeDefinition.findItemDefinition(UserType.F_LINK_REF, PrismReferenceDefinition.class);
PrismAsserts.assertDefinition(accountRefDef, UserType.F_LINK_REF, ObjectReferenceType.COMPLEX_TYPE, 0, -1);
assertEquals("Wrong target type in accountRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
PrismContainerDefinition<MetadataType> metadataContainer = complexTypeDefinition.findContainerDefinition(UserType.F_METADATA);
assertFalse("Metadata is runtime", metadataContainer.isRuntimeSchema());
assertFalse("Metadata is dynamic", metadataContainer.isDynamic());
assertTrue("Metadata is NOT operational", metadataContainer.isOperational());
assertEquals("Metadata size", 23, metadataContainer.getDefinitions().size());
PrismReferenceDefinition tenantRefDef = complexTypeDefinition.findItemDefinition(UserType.F_TENANT_REF, PrismReferenceDefinition.class);
PrismAsserts.assertDefinition(tenantRefDef, UserType.F_TENANT_REF, ObjectReferenceType.COMPLEX_TYPE, 0, 1);
assertEquals("Wrong target type in tenantRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType in project midpoint by Evolveum.
the class TestModelServiceContract method test191ModifyUserJackModifyAssignment.
/**
* We try to modify an assignment of the account and see whether changes will be recorded in the account itself.
*
* We also check the metadata.channel migration for both the object and the assignment (MID-6547).
*/
@Test
public void test191ModifyUserJackModifyAssignment() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
PrismObject<ResourceType> dummyResource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result);
ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(dummyResource);
// This explicitly parses the schema, therefore ...
assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 1);
ResourceObjectTypeDefinition accountDefinition = refinedSchema.findObjectTypeDefinitionRequired(ShadowKindType.ACCOUNT, null);
PrismPropertyDefinition gossipDefinition = accountDefinition.findPropertyDefinition(new ItemName("http://midpoint.evolveum.com/xml/ns/public/resource/instance-3", DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME));
assertNotNull("gossip attribute definition not found", gossipDefinition);
ConstructionType accountConstruction = createAccountConstruction(RESOURCE_DUMMY_OID, null);
ResourceAttributeDefinitionType radt = new ResourceAttributeDefinitionType();
radt.setRef(new ItemPathType(gossipDefinition.getItemName()));
MappingType outbound = new MappingType();
radt.setOutbound(outbound);
ExpressionType expression = new ExpressionType();
outbound.setExpression(expression);
MappingType value = new MappingType();
// noinspection unchecked
PrismProperty<String> property = gossipDefinition.instantiate();
property.addRealValue("q");
List evaluators = expression.getExpressionEvaluator();
Collection<JAXBElement<RawType>> collection = StaticExpressionUtil.serializeValueElements(property);
ObjectFactory of = new ObjectFactory();
for (JAXBElement<RawType> obj : collection) {
// noinspection unchecked
evaluators.add(of.createValue(obj.getValue()));
}
value.setExpression(expression);
radt.setOutbound(value);
accountConstruction.getAttribute().add(radt);
PrismObject<UserType> jackBefore = getUserFromRepo(USER_JACK_OID);
assertEquals("Wrong # of assignments", 1, jackBefore.asObjectable().getAssignment().size());
Long assignmentId = jackBefore.asObjectable().getAssignment().get(0).getId();
ObjectDelta<UserType> accountAssignmentUserDelta = createReplaceAccountConstructionUserDelta(USER_JACK_OID, assignmentId, accountConstruction);
deltas.add(accountAssignmentUserDelta);
// Set user and assignment create channel to legacy value.
repositoryService.modifyObject(UserType.class, jackBefore.getOid(), deltaFor(UserType.class).item(UserType.F_METADATA, MetadataType.F_CREATE_CHANNEL).replace(Channel.USER.getLegacyUri()).item(UserType.F_ASSIGNMENT, assignmentId, AssignmentType.F_METADATA, MetadataType.F_CREATE_CHANNEL).replace(Channel.USER.getLegacyUri()).asItemDeltas(), result);
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
PrismObject<UserType> userJackOld = getUser(USER_JACK_OID);
display("User before change execution", userJackOld);
display("Deltas to execute execution", deltas);
when();
modelService.executeChanges(deltas, null, task, result);
then();
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
// First fetch: initial account read
// Second fetch: fetchback after modification to correctly process inbound
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Jack Sparrow");
accountJackOid = getSingleLinkOid(userJack);
// MID-6547 (channel URI migration)
assertThat(userJack.asObjectable().getMetadata().getCreateChannel()).isEqualTo(Channel.USER.getUri());
assertThat(userJack.asObjectable().getAssignment().get(0).getMetadata().getCreateChannel()).isEqualTo(Channel.USER.getUri());
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, SelectorOptions.createCollection(GetOperationOptions.createRaw()), result);
assertDummyAccountShadowRepo(accountShadow, accountJackOid, USER_JACK_USERNAME);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountJackOid, null, task, result);
assertDummyAccountShadowModel(accountModel, accountJackOid, USER_JACK_USERNAME, "Cpt. Jack Sparrow");
// Check account in dummy resource
assertDefaultDummyAccount(USER_JACK_USERNAME, "Cpt. Jack Sparrow", true);
DummyAccount dummyAccount = getDummyAccount(null, USER_JACK_USERNAME);
display(dummyAccount.debugDump());
assertDummyAccountAttribute(null, USER_JACK_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, "q");
assertDummyScriptsModify(userJack, true);
// Check audit
displayDumpable("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
Collection<ObjectDeltaOperation<? extends ObjectType>> auditExecutionDeltas = dummyAuditService.getExecutionDeltas();
assertEquals("Wrong number of execution deltas", 2, auditExecutionDeltas.size());
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();
assertCounterIncrement(InternalCounters.SCRIPT_COMPILE_COUNT, 0);
assertSteadyResources();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType in project midpoint by Evolveum.
the class QAssignmentMapping method toSchemaObject.
@Override
public AssignmentType toSchemaObject(MAssignment row) {
// TODO is there any place we can put row.ownerOid reasonably?
// repositoryContext().prismContext().itemFactory().createObject(... definition?)
// assignment.asPrismContainerValue().setParent(new ObjectType().oid(own)); abstract not possible
// For assignments we can use ownerType, but this is not general for all containers.
// Inspiration: com.evolveum.midpoint.repo.sql.helpers.CertificationCaseHelper.updateLoadedCertificationCase
// (if even possible with abstract type definition)
AssignmentType assignment = new AssignmentType().id(row.cid).lifecycleState(row.lifecycleState).order(row.orderValue).orgRef(objectReference(row.orgRefTargetOid, row.orgRefTargetType, row.orgRefRelationId)).targetRef(objectReference(row.targetRefTargetOid, row.targetRefTargetType, row.targetRefRelationId)).tenantRef(objectReference(row.tenantRefTargetOid, row.tenantRefTargetType, row.tenantRefRelationId));
if (row.policySituations != null) {
for (Integer policySituationId : row.policySituations) {
assignment.policySituation(resolveIdToUri(policySituationId));
}
}
if (row.subtypes != null) {
for (String subtype : row.subtypes) {
assignment.subtype(subtype);
}
}
if (row.resourceRefTargetOid != null) {
assignment.construction(new ConstructionType(prismContext()).resourceRef(objectReference(row.resourceRefTargetOid, row.resourceRefTargetType, row.resourceRefRelationId)));
}
ActivationType activation = new ActivationType(prismContext()).administrativeStatus(row.administrativeStatus).effectiveStatus(row.effectiveStatus).enableTimestamp(asXMLGregorianCalendar(row.enableTimestamp)).disableTimestamp(asXMLGregorianCalendar(row.disableTimestamp)).disableReason(row.disableReason).validityStatus(row.validityStatus).validFrom(asXMLGregorianCalendar(row.validFrom)).validTo(asXMLGregorianCalendar(row.validTo)).validityChangeTimestamp(asXMLGregorianCalendar(row.validityChangeTimestamp)).archiveTimestamp(asXMLGregorianCalendar(row.archiveTimestamp));
if (!activation.asPrismContainerValue().isEmpty()) {
assignment.activation(activation);
}
MetadataType metadata = new MetadataType(prismContext()).creatorRef(objectReference(row.creatorRefTargetOid, row.creatorRefTargetType, row.creatorRefRelationId)).createChannel(resolveIdToUri(row.createChannelId)).createTimestamp(asXMLGregorianCalendar(row.createTimestamp)).modifierRef(objectReference(row.modifierRefTargetOid, row.modifierRefTargetType, row.modifierRefRelationId)).modifyChannel(resolveIdToUri(row.modifyChannelId)).modifyTimestamp(asXMLGregorianCalendar(row.modifyTimestamp));
if (!metadata.asPrismContainerValue().isEmpty()) {
assignment.metadata(metadata);
}
return assignment;
}
Aggregations