Search in sources :

Example 31 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method test150AddDeleteLinkRef.

@Test
public void test150AddDeleteLinkRef() throws Exception {
    OperationResult result = new OperationResult("test150AddDeleteLinkRef");
    List<ItemDelta<?, ?>> modifications = prismContext.deltaFor(UserType.class).item(UserType.F_LINK_REF).delete(createRef(ShadowType.COMPLEX_TYPE, "456")).add(createRef(ShadowType.COMPLEX_TYPE, "789")).asItemDeltas();
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, modifications, result);
    TestStatementInspector.dump();
    /*
         - select oid from m_object where oid = ? for update
         - select ruser0_.oid as oid1_27_, ruser0_2_.createChannel as createCh2_27_, ruser0_2_.createTimestamp as createTi3_27_, ruser0_2_.creatorRef_relation as creatorR4_27_, ruser0_2_.creatorRef_targetOid as creatorR5_27_, ruser0_2_.creatorRef_type as creatorR6_27_, ruser0_2_.fullObject as fullObje7_27_, ruser0_2_.lifecycleState as lifecycl8_27_, ruser0_2_.modifierRef_relation as modifier9_27_, ruser0_2_.modifierRef_targetOid as modifie10_27_, ruser0_2_.modifierRef_type as modifie11_27_, ruser0_2_.modifyChannel as modifyC12_27_, ruser0_2_.modifyTimestamp as modifyT13_27_, ruser0_2_.name_norm as name_no14_27_, ruser0_2_.name_orig as name_or15_27_, ruser0_2_.objectTypeClass as objectT16_27_, ruser0_2_.tenantRef_relation as tenantR17_27_, ruser0_2_.tenantRef_targetOid as tenantR18_27_, ruser0_2_.tenantRef_type as tenantR19_27_, ruser0_2_.version as version20_27_, ruser0_1_.administrativeStatus as administ1_53_, ruser0_1_.archiveTimestamp as archiveT2_53_, ruser0_1_.disableReason as disableR3_53_, ruser0_1_.disableTimestamp as disableT4_53_, ruser0_1_.effectiveStatus as effectiv5_53_, ruser0_1_.enableTimestamp as enableTi6_53_, ruser0_1_.validFrom as validFro7_53_, ruser0_1_.validTo as validTo8_53_, ruser0_1_.validityChangeTimestamp as validity9_53_, ruser0_1_.validityStatus as validit10_53_, ruser0_1_.costCenter as costCen11_53_, ruser0_1_.emailAddress as emailAd12_53_, ruser0_1_.hasPhoto as hasPhot13_53_, ruser0_1_.locale as locale14_53_, ruser0_1_.locality_norm as localit15_53_, ruser0_1_.locality_orig as localit16_53_, ruser0_1_.preferredLanguage as preferr17_53_, ruser0_1_.telephoneNumber as telepho18_53_, ruser0_1_.timezone as timezon19_53_, ruser0_.additionalName_norm as addition1_73_, ruser0_.additionalName_orig as addition2_73_, ruser0_.employeeNumber as employee3_73_, ruser0_.familyName_norm as familyNa4_73_, ruser0_.familyName_orig as familyNa5_73_, ruser0_.fullName_norm as fullName6_73_, ruser0_.fullName_orig as fullName7_73_, ruser0_.givenName_norm as givenNam8_73_, ruser0_.givenName_orig as givenNam9_73_, ruser0_.honorificPrefix_norm as honorif10_73_, ruser0_.honorificPrefix_orig as honorif11_73_, ruser0_.honorificSuffix_norm as honorif12_73_, ruser0_.honorificSuffix_orig as honorif13_73_, ruser0_.name_norm as name_no14_73_, ruser0_.name_orig as name_or15_73_, ruser0_.nickName_norm as nickNam16_73_, ruser0_.nickName_orig as nickNam17_73_, ruser0_.title_norm as title_n18_73_, ruser0_.title_orig as title_o19_73_ from m_user ruser0_ inner join m_focus ruser0_1_ on ruser0_.oid=ruser0_1_.oid inner join m_object ruser0_2_ on ruser0_.oid=ruser0_2_.oid where ruser0_.oid=?
         - select linkref0_.owner_oid as owner_oi1_39_0_, linkref0_.reference_type as referenc2_39_0_, linkref0_.relation as relation3_39_0_, linkref0_.targetOid as targetOi4_39_0_, linkref0_.owner_oid as owner_oi1_39_1_, linkref0_.reference_type as referenc2_39_1_, linkref0_.relation as relation3_39_1_, linkref0_.targetOid as targetOi4_39_1_, linkref0_.targetType as targetTy5_39_1_ from m_reference linkref0_ where ( linkref0_.reference_type= 1) and linkref0_.owner_oid=?
         - insert into m_reference (targetType, owner_oid, reference_type, relation, targetOid) values (?, ?, ?, ?, ?)
         - update m_object set createChannel=?, createTimestamp=?, creatorRef_relation=?, creatorRef_targetOid=?, creatorRef_type=?, fullObject=?, lifecycleState=?, modifierRef_relation=?, modifierRef_targetOid=?, modifierRef_type=?, modifyChannel=?, modifyTimestamp=?, name_norm=?, name_orig=?, objectTypeClass=?, tenantRef_relation=?, tenantRef_targetOid=?, tenantRef_type=?, version=? where oid=?
         - delete from m_reference where owner_oid=? and reference_type=? and relation=? and targetOid=?
         */
    if (isUsingH2()) {
        AssertJUnit.assertEquals(6, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        // noinspection unchecked
        assertReferences((Collection) u.getLinkRef(), createRepoRef(ShadowType.COMPLEX_TYPE, "123"), createRepoRef(ShadowType.COMPLEX_TYPE, "789"));
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 32 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method test200ReplaceAssignmentMetadataCreateChannel.

@Test
public void test200ReplaceAssignmentMetadataCreateChannel() throws Exception {
    OperationResult result = new OperationResult("test200ReplaceAssignmentMetadataCreateChannel");
    List<ItemDelta<?, ?>> modifications = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_METADATA, MetadataType.F_CREATE_CHANNEL).replace("asdf2").asItemDeltas();
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, modifications, result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(5, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        AssertJUnit.assertEquals("asdf2", u.getAssignments().iterator().next().getCreateChannel());
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 33 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method test140AddActivationToAssignmentOldApi.

@Test
public void test140AddActivationToAssignmentOldApi() throws Exception {
    OperationResult result = new OperationResult("test140AddActivationToAssignmentOldApi");
    ObjectDelta<UserType> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid);
    ActivationType activation = new ActivationType();
    activation.setAdministrativeStatus(ActivationStatusType.ENABLED);
    delta.addModificationAddContainer(ItemPath.create(UserType.F_ASSIGNMENT, 2, AssignmentType.F_ACTIVATION), activation.asPrismContainerValue());
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(5, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        Set<RAssignment> assignments = u.getAssignments();
        AssertJUnit.assertEquals(1, assignments.size());
        RAssignment a = assignments.iterator().next();
        RActivation act = a.getActivation();
        AssertJUnit.assertNotNull(act);
        AssertJUnit.assertEquals(RActivationStatus.ENABLED, act.getAdministrativeStatus());
    }
}
Also used : RAssignment(com.evolveum.midpoint.repo.sql.data.common.container.RAssignment) RActivation(com.evolveum.midpoint.repo.sql.data.common.embedded.RActivation) RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 34 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method test194AddWholeMetadata.

@Test
public void test194AddWholeMetadata() throws Exception {
    OperationResult result = new OperationResult("test194AddWholeMetadata");
    List<ItemDelta<?, ?>> modifications = prismContext.deltaFor(UserType.class).item(UserType.F_METADATA).add(new MetadataType(prismContext).createChannel("ch1").modifierRef(createRef(UserType.COMPLEX_TYPE, "44")).createApproverRef(createRef(UserType.COMPLEX_TYPE, "55")).createApproverRef(createRef(UserType.COMPLEX_TYPE, "77")).modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "55")).modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "66"))).asItemDeltas();
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, modifications, result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(10, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        AssertJUnit.assertEquals("ch1", u.getCreateChannel());
        AssertJUnit.assertEquals(2, u.getModifyApproverRef().size());
        AssertJUnit.assertEquals(2, u.getCreateApproverRef().size());
        assertEquals(u.getModifierRef(), createEmbeddedRepoRef(UserType.COMPLEX_TYPE, "44"));
        // noinspection unchecked
        assertReferences((Collection) u.getCreateApproverRef(), createRepoRef(UserType.COMPLEX_TYPE, "55"), createRepoRef(UserType.COMPLEX_TYPE, "77"));
        // noinspection unchecked
        assertReferences((Collection) u.getModifyApproverRef(), createRepoRef(UserType.COMPLEX_TYPE, "55"), createRepoRef(UserType.COMPLEX_TYPE, "66"));
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 35 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method test190ReplaceWholeMetadata.

@Test
public void test190ReplaceWholeMetadata() throws Exception {
    OperationResult result = new OperationResult("test190ReplaceWholeMetadata");
    List<ItemDelta<?, ?>> modifications = prismContext.deltaFor(UserType.class).item(UserType.F_METADATA).replace(new MetadataType(prismContext).createChannel("ch1").modifierRef(createRef(UserType.COMPLEX_TYPE, "44")).createApproverRef(createRef(UserType.COMPLEX_TYPE, "55")).createApproverRef(createRef(UserType.COMPLEX_TYPE, "77")).modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "55")).modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "66"))).asItemDeltas();
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, modifications, result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(11, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        AssertJUnit.assertEquals("ch1", u.getCreateChannel());
        AssertJUnit.assertEquals(2, u.getModifyApproverRef().size());
        AssertJUnit.assertEquals(2, u.getCreateApproverRef().size());
        assertEquals(u.getModifierRef(), createEmbeddedRepoRef(UserType.COMPLEX_TYPE, "44"));
        // noinspection unchecked
        assertReferences((Collection) u.getCreateApproverRef(), createRepoRef(UserType.COMPLEX_TYPE, "55"), createRepoRef(UserType.COMPLEX_TYPE, "77"));
        // noinspection unchecked
        assertReferences((Collection) u.getModifyApproverRef(), createRepoRef(UserType.COMPLEX_TYPE, "55"), createRepoRef(UserType.COMPLEX_TYPE, "66"));
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Aggregations

RUser (com.evolveum.midpoint.repo.sql.data.common.RUser)56 Session (org.hibernate.Session)56 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)55 Test (org.testng.annotations.Test)55 RAssignment (com.evolveum.midpoint.repo.sql.data.common.container.RAssignment)19 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)15 RFocusPhoto (com.evolveum.midpoint.repo.sql.data.common.RFocusPhoto)3 RActivation (com.evolveum.midpoint.repo.sql.data.common.embedded.RActivation)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 RAssignmentExtension (com.evolveum.midpoint.repo.sql.data.common.any.RAssignmentExtension)1 RPolyString (com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString)1 File (java.io.File)1 QName (javax.xml.namespace.QName)1