Search in sources :

Example 21 with ConstructionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType in project midpoint by Evolveum.

the class SchemaDebugUtil method prettyPrint.

public static String prettyPrint(ConstructionType act) {
    if (act == null) {
        return "null";
    }
    StringBuilder sb = new StringBuilder("ConstructionType(");
    if (act.getResourceRef() != null) {
        sb.append(prettyPrint(act.getResourceRef()));
    }
    sb.append(", ");
    if (act.getIntent() != null) {
        sb.append("intent=");
        sb.append(act.getIntent());
        sb.append(", ");
    }
    if (act.getAttribute() != null) {
        for (ResourceAttributeDefinitionType attrConstr : act.getAttribute()) {
            sb.append(prettyPrint(attrConstr));
        }
    }
    // TODO: Other properties
    sb.append(")");
    return sb.toString();
}
Also used : ResourceAttributeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType)

Example 22 with ConstructionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method createConstructionAssignment.

protected AssignmentType createConstructionAssignment(String resourceOid, ShadowKindType kind, String intent) {
    AssignmentType assignmentType = new AssignmentType();
    ConstructionType constructionType = new ConstructionType();
    constructionType.setKind(kind);
    assignmentType.setConstruction(constructionType);
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resourceOid);
    resourceRef.setType(ResourceType.COMPLEX_TYPE);
    constructionType.setResourceRef(resourceRef);
    constructionType.setIntent(intent);
    return assignmentType;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 23 with ConstructionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method modifyRoleAddConstruction.

protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
    Task task = createTask("modifyRoleAddConstruction");
    OperationResult result = task.getResult();
    ConstructionType construction = new ConstructionType();
    ObjectReferenceType resourceRedRef = new ObjectReferenceType();
    resourceRedRef.setOid(resourceOid);
    construction.setResourceRef(resourceRedRef);
    ObjectDelta<RoleType> roleDelta = prismContext.deltaFactory().object().createModificationAddContainer(RoleType.class, roleOid, ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), construction);
    modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 24 with ConstructionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method createAccountConstruction.

protected ConstructionType createAccountConstruction(String resourceOid, String intent) {
    ConstructionType accountConstructionType = new ConstructionType();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resourceOid);
    accountConstructionType.setResourceRef(resourceRef);
    accountConstructionType.setIntent(intent);
    return accountConstructionType;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 25 with ConstructionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test302AddingMoreAssignmentsIncludingNestedContainersAndRefs.

@Test
public void test302AddingMoreAssignmentsIncludingNestedContainersAndRefs() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
    given("delta adding two more assignments for user 1");
    UUID roleOid = UUID.randomUUID();
    UUID resourceOid = UUID.randomUUID();
    ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).add(new AssignmentType(prismContext).targetRef(roleOid.toString(), RoleType.COMPLEX_TYPE).metadata(new MetadataType().createChannel("create-channel").createApproverRef(UUID.randomUUID().toString(), UserType.COMPLEX_TYPE).createApproverRef(UUID.randomUUID().toString(), UserType.COMPLEX_TYPE)).order(48), new AssignmentType(prismContext).construction(new ConstructionType().resourceRef(resourceOid.toString(), ResourceType.COMPLEX_TYPE)).order(49)).asObjectDelta(user1Oid);
    when("modifyObject is called");
    repositoryService.modifyObject(UserType.class, user1Oid, delta.getModifications(), result);
    then("operation is successful");
    assertThatOperationResult(result).isSuccess();
    and("serialized form (fullObject) is updated");
    UserType userObject = repositoryService.getObject(UserType.class, user1Oid, null, result).asObjectable();
    assertThat(userObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
    List<AssignmentType> assignments = userObject.getAssignment();
    assertThat(assignments).hasSize(3).allMatch(a -> a.getId() != null && a.getId() < originalRow.containerIdSeq + 2);
    and("new assignment rows are created");
    MUser row = selectObjectByOid(QUser.class, user1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertThat(row.containerIdSeq).isEqualTo(originalRow.containerIdSeq + 2);
    QAssignment<?> a = QAssignmentMapping.getAssignmentMapping().defaultAlias();
    List<MAssignment> aRows = select(a, a.ownerOid.eq(UUID.fromString(user1Oid)));
    assertThat(aRows).hasSize(3).anyMatch(// previous one
    aRow -> aRow.cid < originalRow.containerIdSeq).anyMatch(aRow -> aRow.cid == row.containerIdSeq - 2 && aRow.orderValue == 48 && aRow.targetRefTargetOid.equals(roleOid) && cachedUriById(aRow.createChannelId).equals("create-channel")).anyMatch(aRow -> aRow.cid == row.containerIdSeq - 1 && aRow.resourceRefTargetOid.equals(resourceOid));
    QAssignmentReference ar = QAssignmentReferenceMapping.getForAssignmentCreateApprover().defaultAlias();
    List<MAssignmentReference> refRows = select(ar, ar.ownerOid.eq(UUID.fromString(user1Oid)).and(ar.assignmentCid.eq(row.containerIdSeq - 2)));
    assertThat(refRows).hasSize(2).allMatch(rr -> rr.targetType == MObjectType.USER);
}
Also used : QService(com.evolveum.midpoint.repo.sqale.qmodel.role.QService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SqaleUtils(com.evolveum.midpoint.repo.sqale.SqaleUtils) MService(com.evolveum.midpoint.repo.sqale.qmodel.role.MService) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) BigDecimal(java.math.BigDecimal) Assertions(org.assertj.core.api.Assertions) MReference(com.evolveum.midpoint.repo.sqale.qmodel.ref.MReference) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) BeforeClass(org.testng.annotations.BeforeClass) MContainerType(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) QConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector) SystemException(com.evolveum.midpoint.util.exception.SystemException) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) MObject(com.evolveum.midpoint.repo.sqale.qmodel.object.MObject) QUserMapping(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUserMapping) QName(javax.xml.namespace.QName) NotNull(org.jetbrains.annotations.NotNull) java.util(java.util) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Item(com.evolveum.midpoint.prism.Item) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Assert.assertEquals(org.testng.Assert.assertEquals) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) QObjectReferenceMapping(com.evolveum.midpoint.repo.sqale.qmodel.ref.QObjectReferenceMapping) MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) Comparator.comparing(java.util.Comparator.comparing) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) QObjectReference(com.evolveum.midpoint.repo.sqale.qmodel.ref.QObjectReference) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) com.evolveum.midpoint.repo.sqale.qmodel.assignment(com.evolveum.midpoint.repo.sqale.qmodel.assignment) PrismObject(com.evolveum.midpoint.prism.PrismObject) QShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.QShadow) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) ItemName(com.evolveum.midpoint.prism.path.ItemName) RepoModifyOptions(com.evolveum.midpoint.repo.api.RepoModifyOptions) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) Assert.assertTrue(org.testng.Assert.assertTrue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QTask(com.evolveum.midpoint.repo.sqale.qmodel.task.QTask) com.evolveum.midpoint.repo.sqale.qmodel.accesscert(com.evolveum.midpoint.repo.sqale.qmodel.accesscert) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

ConstructionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType)17 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)10 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 Test (org.testng.annotations.Test)6 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 Task (com.evolveum.midpoint.task.api.Task)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 QName (javax.xml.namespace.QName)5 ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)4 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)4 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)4 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)4 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)3 ObjectFactory (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory)3 ArrayList (java.util.ArrayList)3 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2