Search in sources :

Example 6 with RShadow

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

the class ExtensionTest method test450DeleteWholeContainer.

@Test
public void test450DeleteWholeContainer() throws Exception {
    OperationResult result = new OperationResult(ExtensionTest.class.getName() + ".test450DeleteWholeContainer");
    PrismContainerValue<?> existingAttributes = expectedShadow.findContainer(ShadowType.F_ATTRIBUTES).getValue().clone();
    // there are two values of this kind there
    existingAttributes.removeProperty(ATTR_MEMBER);
    ObjectDelta<ShadowType> delta = getPrismContext().deltaFor(ShadowType.class).item(ShadowType.F_ATTRIBUTES).delete(existingAttributes).asObjectDelta("");
    expectedShadow.asObjectable().setAttributes(null);
    queryListener.start();
    repositoryService.modifyObject(ShadowType.class, shadowOid, delta.getModifications(), getOptions(), result);
    queryListener.dumpAndStop();
    try (Session session = factory.openSession()) {
        RShadow s = session.get(RShadow.class, shadowOid);
        assertExtension(s, itemGroupName);
        assertExtension(s, itemMember);
        assertExtension(s, itemManager);
    }
    assertGetObject(result);
    /*
 [1] select oid from m_object where oid = ? for update
 [1] select rshadow0_.oid as oid1_27_, rshadow0_1_.createChannel as createCh2_27_, rshadow0_1_.createTimestamp as createTi3_27_, rshadow0_1_.creatorRef_relation as creatorR4_27_, rshadow0_1_.creatorRef_targetOid as creatorR5_27_, rshadow0_1_.creatorRef_type as creatorR6_27_, rshadow0_1_.fullObject as fullObje7_27_, rshadow0_1_.lifecycleState as lifecycl8_27_, rshadow0_1_.modifierRef_relation as modifier9_27_, rshadow0_1_.modifierRef_targetOid as modifie10_27_, rshadow0_1_.modifierRef_type as modifie11_27_, rshadow0_1_.modifyChannel as modifyC12_27_, rshadow0_1_.modifyTimestamp as modifyT13_27_, rshadow0_1_.name_norm as name_no14_27_, rshadow0_1_.name_orig as name_or15_27_, rshadow0_1_.objectTypeClass as objectT16_27_, rshadow0_1_.tenantRef_relation as tenantR17_27_, rshadow0_1_.tenantRef_targetOid as tenantR18_27_, rshadow0_1_.tenantRef_type as tenantR19_27_, rshadow0_1_.version as version20_27_, rshadow0_.attemptNumber as attemptN1_41_, rshadow0_.dead as dead2_41_, rshadow0_.exist as exist3_41_, rshadow0_.failedOperationType as failedOp4_41_, rshadow0_.fullSynchronizationTimestamp as fullSync5_41_, rshadow0_.intent as intent6_41_, rshadow0_.kind as kind7_41_, rshadow0_.name_norm as name_nor8_41_, rshadow0_.name_orig as name_ori9_41_, rshadow0_.objectClass as objectC10_41_, rshadow0_.pendingOperationCount as pending11_41_, rshadow0_.primaryIdentifierValue as primary12_41_, rshadow0_.resourceRef_relation as resourc13_41_, rshadow0_.resourceRef_targetOid as resourc14_41_, rshadow0_.resourceRef_type as resourc15_41_, rshadow0_.status as status16_41_, rshadow0_.synchronizationSituation as synchro17_41_, rshadow0_.synchronizationTimestamp as synchro18_41_ from m_shadow rshadow0_ inner join m_object rshadow0_1_ on rshadow0_.oid=rshadow0_1_.oid where rshadow0_.oid=?
 [1] select booleans0_.owner_oid as owner_oi2_28_0_, booleans0_.item_id as item_id1_28_0_, booleans0_.ownerType as ownerTyp3_28_0_, booleans0_.booleanValue as booleanV4_28_0_, booleans0_.item_id as item_id1_28_1_, booleans0_.owner_oid as owner_oi2_28_1_, booleans0_.ownerType as ownerTyp3_28_1_, booleans0_.booleanValue as booleanV4_28_1_ from m_object_ext_boolean booleans0_ where booleans0_.owner_oid=?
 [1] select dates0_.owner_oid as owner_oi2_29_0_, dates0_.item_id as item_id1_29_0_, dates0_.ownerType as ownerTyp3_29_0_, dates0_.dateValue as dateValu4_29_0_, dates0_.item_id as item_id1_29_1_, dates0_.owner_oid as owner_oi2_29_1_, dates0_.ownerType as ownerTyp3_29_1_, dates0_.dateValue as dateValu4_29_1_ from m_object_ext_date dates0_ where dates0_.owner_oid=?
 [1] select longs0_.owner_oid as owner_oi2_30_0_, longs0_.item_id as item_id1_30_0_, longs0_.ownerType as ownerTyp3_30_0_, longs0_.longValue as longValu4_30_0_, longs0_.item_id as item_id1_30_1_, longs0_.owner_oid as owner_oi2_30_1_, longs0_.ownerType as ownerTyp3_30_1_, longs0_.longValue as longValu4_30_1_ from m_object_ext_long longs0_ where longs0_.owner_oid=?
 [1] select polys0_.owner_oid as owner_oi2_31_0_, polys0_.item_id as item_id1_31_0_, polys0_.ownerType as ownerTyp3_31_0_, polys0_.orig as orig4_31_0_, polys0_.item_id as item_id1_31_1_, polys0_.owner_oid as owner_oi2_31_1_, polys0_.ownerType as ownerTyp3_31_1_, polys0_.orig as orig4_31_1_, polys0_.norm as norm5_31_1_ from m_object_ext_poly polys0_ where polys0_.owner_oid=?
 [1] select references0_.owner_oid as owner_oi2_32_0_, references0_.item_id as item_id1_32_0_, references0_.ownerType as ownerTyp3_32_0_, references0_.targetoid as targetoi4_32_0_, references0_.item_id as item_id1_32_1_, references0_.owner_oid as owner_oi2_32_1_, references0_.ownerType as ownerTyp3_32_1_, references0_.targetoid as targetoi4_32_1_, references0_.relation as relation5_32_1_, references0_.targetType as targetTy6_32_1_ from m_object_ext_reference references0_ where references0_.owner_oid=?
 [1] select strings0_.owner_oid as owner_oi2_33_0_, strings0_.item_id as item_id1_33_0_, strings0_.ownerType as ownerTyp3_33_0_, strings0_.stringValue as stringVa4_33_0_, strings0_.item_id as item_id1_33_1_, strings0_.owner_oid as owner_oi2_33_1_, strings0_.ownerType as ownerTyp3_33_1_, strings0_.stringValue as stringVa4_33_1_ from m_object_ext_string strings0_ where strings0_.owner_oid=?
 [1] 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=?
 [4] delete from m_object_ext_string where item_id=? and owner_oid=? and ownerType=? and stringValue=?
         */
    assertCounts(10, 13);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RShadow(com.evolveum.midpoint.repo.sql.data.common.RShadow) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 7 with RShadow

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

the class ExtensionTest method test458AddWholeContainerDifferentValue.

/**
 * This is really tricky. We try to add another value to single-valued attributes container.
 */
@Test
public void test458AddWholeContainerDifferentValue() throws Exception {
    OperationResult result = new OperationResult(ExtensionTest.class.getName() + ".test458AddWholeContainerDifferentValue");
    PrismContainer<?> attributesContainer = shadowAttributesDefinition.instantiate();
    PrismContainerValue<?> attributes = attributesContainer.getValue();
    ResourceAttribute<String> name = attrGroupNameDefinition.instantiate();
    name.setRealValue("alumni2");
    attributes.add(name);
    ResourceAttribute<String> member = attrMemberDefinition.instantiate();
    member.addRealValues("banderson2", "kwhite2");
    attributes.add(member);
    ResourceAttribute<String> manager = attrManagerDefinition.instantiate();
    manager.addRealValues("jack2", "jim2");
    attributes.add(manager);
    ObjectDelta<ShadowType> delta = getPrismContext().deltaFor(ShadowType.class).item(ShadowType.F_ATTRIBUTES).add(attributes.clone()).asObjectDelta("");
    delta.applyTo(expectedShadow);
    queryListener.start();
    repositoryService.modifyObject(ShadowType.class, shadowOid, delta.getModifications(), getOptions(), result);
    queryListener.dumpAndStop();
    try (Session session = factory.openSession()) {
        RShadow s = session.get(RShadow.class, shadowOid);
        assertExtension(s, itemGroupName, "alumni2");
        assertExtension(s, itemMember, "banderson2", "kwhite2");
        assertExtension(s, itemManager, "jack2", "jim2");
    }
    assertGetObject(result);
    /*
 [1] select oid from m_object where oid = ? for update
 [1] select rshadow0_.oid as oid1_27_, rshadow0_1_.createChannel as createCh2_27_, rshadow0_1_.createTimestamp as createTi3_27_, rshadow0_1_.creatorRef_relation as creatorR4_27_, rshadow0_1_.creatorRef_targetOid as creatorR5_27_, rshadow0_1_.creatorRef_type as creatorR6_27_, rshadow0_1_.fullObject as fullObje7_27_, rshadow0_1_.lifecycleState as lifecycl8_27_, rshadow0_1_.modifierRef_relation as modifier9_27_, rshadow0_1_.modifierRef_targetOid as modifie10_27_, rshadow0_1_.modifierRef_type as modifie11_27_, rshadow0_1_.modifyChannel as modifyC12_27_, rshadow0_1_.modifyTimestamp as modifyT13_27_, rshadow0_1_.name_norm as name_no14_27_, rshadow0_1_.name_orig as name_or15_27_, rshadow0_1_.objectTypeClass as objectT16_27_, rshadow0_1_.tenantRef_relation as tenantR17_27_, rshadow0_1_.tenantRef_targetOid as tenantR18_27_, rshadow0_1_.tenantRef_type as tenantR19_27_, rshadow0_1_.version as version20_27_, rshadow0_.attemptNumber as attemptN1_41_, rshadow0_.dead as dead2_41_, rshadow0_.exist as exist3_41_, rshadow0_.failedOperationType as failedOp4_41_, rshadow0_.fullSynchronizationTimestamp as fullSync5_41_, rshadow0_.intent as intent6_41_, rshadow0_.kind as kind7_41_, rshadow0_.name_norm as name_nor8_41_, rshadow0_.name_orig as name_ori9_41_, rshadow0_.objectClass as objectC10_41_, rshadow0_.pendingOperationCount as pending11_41_, rshadow0_.primaryIdentifierValue as primary12_41_, rshadow0_.resourceRef_relation as resourc13_41_, rshadow0_.resourceRef_targetOid as resourc14_41_, rshadow0_.resourceRef_type as resourc15_41_, rshadow0_.status as status16_41_, rshadow0_.synchronizationSituation as synchro17_41_, rshadow0_.synchronizationTimestamp as synchro18_41_ from m_shadow rshadow0_ inner join m_object rshadow0_1_ on rshadow0_.oid=rshadow0_1_.oid where rshadow0_.oid=?
 [1] select booleans0_.owner_oid as owner_oi2_28_0_, booleans0_.item_id as item_id1_28_0_, booleans0_.ownerType as ownerTyp3_28_0_, booleans0_.booleanValue as booleanV4_28_0_, booleans0_.item_id as item_id1_28_1_, booleans0_.owner_oid as owner_oi2_28_1_, booleans0_.ownerType as ownerTyp3_28_1_, booleans0_.booleanValue as booleanV4_28_1_ from m_object_ext_boolean booleans0_ where booleans0_.owner_oid=?
 [1] select dates0_.owner_oid as owner_oi2_29_0_, dates0_.item_id as item_id1_29_0_, dates0_.ownerType as ownerTyp3_29_0_, dates0_.dateValue as dateValu4_29_0_, dates0_.item_id as item_id1_29_1_, dates0_.owner_oid as owner_oi2_29_1_, dates0_.ownerType as ownerTyp3_29_1_, dates0_.dateValue as dateValu4_29_1_ from m_object_ext_date dates0_ where dates0_.owner_oid=?
 [1] select longs0_.owner_oid as owner_oi2_30_0_, longs0_.item_id as item_id1_30_0_, longs0_.ownerType as ownerTyp3_30_0_, longs0_.longValue as longValu4_30_0_, longs0_.item_id as item_id1_30_1_, longs0_.owner_oid as owner_oi2_30_1_, longs0_.ownerType as ownerTyp3_30_1_, longs0_.longValue as longValu4_30_1_ from m_object_ext_long longs0_ where longs0_.owner_oid=?
 [1] select polys0_.owner_oid as owner_oi2_31_0_, polys0_.item_id as item_id1_31_0_, polys0_.ownerType as ownerTyp3_31_0_, polys0_.orig as orig4_31_0_, polys0_.item_id as item_id1_31_1_, polys0_.owner_oid as owner_oi2_31_1_, polys0_.ownerType as ownerTyp3_31_1_, polys0_.orig as orig4_31_1_, polys0_.norm as norm5_31_1_ from m_object_ext_poly polys0_ where polys0_.owner_oid=?
 [1] select references0_.owner_oid as owner_oi2_32_0_, references0_.item_id as item_id1_32_0_, references0_.ownerType as ownerTyp3_32_0_, references0_.targetoid as targetoi4_32_0_, references0_.item_id as item_id1_32_1_, references0_.owner_oid as owner_oi2_32_1_, references0_.ownerType as ownerTyp3_32_1_, references0_.targetoid as targetoi4_32_1_, references0_.relation as relation5_32_1_, references0_.targetType as targetTy6_32_1_ from m_object_ext_reference references0_ where references0_.owner_oid=?
 [1] select strings0_.owner_oid as owner_oi2_33_0_, strings0_.item_id as item_id1_33_0_, strings0_.ownerType as ownerTyp3_33_0_, strings0_.stringValue as stringVa4_33_0_, strings0_.item_id as item_id1_33_1_, strings0_.owner_oid as owner_oi2_33_1_, strings0_.ownerType as ownerTyp3_33_1_, strings0_.stringValue as stringVa4_33_1_ from m_object_ext_string strings0_ where strings0_.owner_oid=?
 [5] insert into m_object_ext_string (item_id, owner_oid, ownerType, stringValue) values (?, ?, ?, ?)
 [1] 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=?
 [5] delete from m_object_ext_string where item_id=? and owner_oid=? and ownerType=? and stringValue=?

        safe insertions (can be improved)

 [1] select oid from m_object where oid = ? for update
 [1] select rshadow0_.oid as oid1_27_, rshadow0_1_.createChannel as createCh2_27_, rshadow0_1_.createTimestamp as createTi3_27_, rshadow0_1_.creatorRef_relation as creatorR4_27_, rshadow0_1_.creatorRef_targetOid as creatorR5_27_, rshadow0_1_.creatorRef_type as creatorR6_27_, rshadow0_1_.fullObject as fullObje7_27_, rshadow0_1_.lifecycleState as lifecycl8_27_, rshadow0_1_.modifierRef_relation as modifier9_27_, rshadow0_1_.modifierRef_targetOid as modifie10_27_, rshadow0_1_.modifierRef_type as modifie11_27_, rshadow0_1_.modifyChannel as modifyC12_27_, rshadow0_1_.modifyTimestamp as modifyT13_27_, rshadow0_1_.name_norm as name_no14_27_, rshadow0_1_.name_orig as name_or15_27_, rshadow0_1_.objectTypeClass as objectT16_27_, rshadow0_1_.tenantRef_relation as tenantR17_27_, rshadow0_1_.tenantRef_targetOid as tenantR18_27_, rshadow0_1_.tenantRef_type as tenantR19_27_, rshadow0_1_.version as version20_27_, rshadow0_.attemptNumber as attemptN1_41_, rshadow0_.dead as dead2_41_, rshadow0_.exist as exist3_41_, rshadow0_.failedOperationType as failedOp4_41_, rshadow0_.fullSynchronizationTimestamp as fullSync5_41_, rshadow0_.intent as intent6_41_, rshadow0_.kind as kind7_41_, rshadow0_.name_norm as name_nor8_41_, rshadow0_.name_orig as name_ori9_41_, rshadow0_.objectClass as objectC10_41_, rshadow0_.pendingOperationCount as pending11_41_, rshadow0_.primaryIdentifierValue as primary12_41_, rshadow0_.resourceRef_relation as resourc13_41_, rshadow0_.resourceRef_targetOid as resourc14_41_, rshadow0_.resourceRef_type as resourc15_41_, rshadow0_.status as status16_41_, rshadow0_.synchronizationSituation as synchro17_41_, rshadow0_.synchronizationTimestamp as synchro18_41_ from m_shadow rshadow0_ inner join m_object rshadow0_1_ on rshadow0_.oid=rshadow0_1_.oid where rshadow0_.oid=?
 [1] select booleans0_.owner_oid as owner_oi2_28_0_, booleans0_.item_id as item_id1_28_0_, booleans0_.ownerType as ownerTyp3_28_0_, booleans0_.booleanValue as booleanV4_28_0_, booleans0_.item_id as item_id1_28_1_, booleans0_.owner_oid as owner_oi2_28_1_, booleans0_.ownerType as ownerTyp3_28_1_, booleans0_.booleanValue as booleanV4_28_1_ from m_object_ext_boolean booleans0_ where booleans0_.owner_oid=?
 [1] select dates0_.owner_oid as owner_oi2_29_0_, dates0_.item_id as item_id1_29_0_, dates0_.ownerType as ownerTyp3_29_0_, dates0_.dateValue as dateValu4_29_0_, dates0_.item_id as item_id1_29_1_, dates0_.owner_oid as owner_oi2_29_1_, dates0_.ownerType as ownerTyp3_29_1_, dates0_.dateValue as dateValu4_29_1_ from m_object_ext_date dates0_ where dates0_.owner_oid=?
 [1] select longs0_.owner_oid as owner_oi2_30_0_, longs0_.item_id as item_id1_30_0_, longs0_.ownerType as ownerTyp3_30_0_, longs0_.longValue as longValu4_30_0_, longs0_.item_id as item_id1_30_1_, longs0_.owner_oid as owner_oi2_30_1_, longs0_.ownerType as ownerTyp3_30_1_, longs0_.longValue as longValu4_30_1_ from m_object_ext_long longs0_ where longs0_.owner_oid=?
 [1] select polys0_.owner_oid as owner_oi2_31_0_, polys0_.item_id as item_id1_31_0_, polys0_.ownerType as ownerTyp3_31_0_, polys0_.orig as orig4_31_0_, polys0_.item_id as item_id1_31_1_, polys0_.owner_oid as owner_oi2_31_1_, polys0_.ownerType as ownerTyp3_31_1_, polys0_.orig as orig4_31_1_, polys0_.norm as norm5_31_1_ from m_object_ext_poly polys0_ where polys0_.owner_oid=?
 [1] select references0_.owner_oid as owner_oi2_32_0_, references0_.item_id as item_id1_32_0_, references0_.ownerType as ownerTyp3_32_0_, references0_.targetoid as targetoi4_32_0_, references0_.item_id as item_id1_32_1_, references0_.owner_oid as owner_oi2_32_1_, references0_.ownerType as ownerTyp3_32_1_, references0_.targetoid as targetoi4_32_1_, references0_.relation as relation5_32_1_, references0_.targetType as targetTy6_32_1_ from m_object_ext_reference references0_ where references0_.owner_oid=?
 [1] select strings0_.owner_oid as owner_oi2_33_0_, strings0_.item_id as item_id1_33_0_, strings0_.ownerType as ownerTyp3_33_0_, strings0_.stringValue as stringVa4_33_0_, strings0_.item_id as item_id1_33_1_, strings0_.owner_oid as owner_oi2_33_1_, strings0_.ownerType as ownerTyp3_33_1_, strings0_.stringValue as stringVa4_33_1_ from m_object_ext_string strings0_ where strings0_.owner_oid=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [5] insert into m_object_ext_string (item_id, owner_oid, ownerType, stringValue) values (?, ?, ?, ?)
 [1] 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=?
 [5] delete from m_object_ext_string where item_id=? and owner_oid=? and ownerType=? and stringValue=?
         */
    assertCounts(11 + getExtraSafeInsertionSelects(5), 19 + getExtraSafeInsertionSelects(5));
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RShadow(com.evolveum.midpoint.repo.sql.data.common.RShadow) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 8 with RShadow

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

the class ObjectDeltaUpdater method modifyObject.

/**
 * modify
 */
public <T extends ObjectType> RObject modifyObject(Class<T> type, String oid, Collection<? extends ItemDelta<?, ?>> modifications, PrismObject<T> prismObject, RepoModifyOptions modifyOptions, Session session, ObjectUpdater.AttemptContext attemptContext) throws SchemaException {
    LOGGER.trace("Starting to build entity changes for {}, {}, \n{}", type, oid, DebugUtil.debugDumpLazily(modifications));
    // normalize reference.relation QNames like it's done here ObjectTypeUtil.normalizeAllRelations(prismObject);
    // how to generate identifiers correctly now? to repo entities and to full xml, ids in full XML are generated
    // on different place than we later create new containers...how to match them
    // set proper owner/ownerOid/ownerType for containers/references/result and others
    // todo implement transformation from prism to entity (PrismEntityMapper), probably ROperationResult missing
    // validate lookup tables and certification campaigns
    // mark newly added containers/references as transient
    // validate metadata/*, assignment/metadata/*, assignment/construction/resourceRef changes
    PrismIdentifierGenerator idGenerator = new PrismIdentifierGenerator(PrismIdentifierGenerator.Operation.MODIFY);
    idGenerator.collectUsedIds(prismObject);
    UpdateContext ctx = new UpdateContext(this, modifyOptions, idGenerator, session, attemptContext);
    // Preprocess modifications: We want to process only real modifications.
    // 
    // What is "real"? There are three types of changes:
    // 1) changes that need to be reflected both in XML and in tables
    // 2) changes that need to be reflected in XML but not in tables (e.g. adding values with different metadata or operational data)
    // 3) changes that need to be reflected in tables but not in XML (index-only items, photo, task result, and so on)
    // 
    // Category-2 changes are to be treated very carefully: we should avoid phantom add+delete in tables.
    // Category-3 changes are (hopefully) not narrowed out. [See assumeMissingItems / MID-5280.]
    Collection<? extends ItemDelta<?, ?>> narrowedModifications = prismObject.narrowModifications(modifications, EquivalenceStrategy.DATA, EquivalenceStrategy.REAL_VALUE_CONSIDER_DIFFERENT_IDS, true);
    LOGGER.trace("Narrowed modifications:\n{}", DebugUtil.debugDumpLazily(narrowedModifications));
    // Here we can still have some ADD or REPLACE operations that are significant from the point of full object application
    // but irrelevant as far as "index" tables are concerned. I.e. category-2 changes. For example, ADD values with
    // different operational data or value metadata.
    Class<? extends RObject> objectClass = RObjectType.getByJaxbType(type).getClazz();
    RObject object = session.byId(objectClass).getReference(oid);
    ManagedType<T> mainEntityType = entityRegistry.getJaxbMapping(type);
    for (ItemDelta<?, ?> delta : narrowedModifications) {
        UpdateDispatcher.dispatchModification(prismObject, ctx, object, mainEntityType, delta);
    }
    // the following will apply deltas to prismObject
    handleObjectCommonAttributes(type, narrowedModifications, prismObject, object, idGenerator);
    if (ctx.shadowPendingOperationModified) {
        ((RShadow) object).setPendingOperationCount(((ShadowType) prismObject.asObjectable()).getPendingOperation().size());
    }
    LOGGER.trace("Entity changes applied");
    return object;
}
Also used : RObject(com.evolveum.midpoint.repo.sql.data.common.RObject) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PrismIdentifierGenerator(com.evolveum.midpoint.repo.sql.util.PrismIdentifierGenerator) RShadow(com.evolveum.midpoint.repo.sql.data.common.RShadow)

Example 9 with RShadow

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

the class UpdateDispatcher method dispatchModification.

static <T extends ObjectType> void dispatchModification(PrismObject<T> prismObject, UpdateContext ctx, RObject object, ManagedType<T> mainEntityType, ItemDelta<?, ?> delta) throws SchemaException {
    ItemPath path = delta.getPath();
    LOGGER.trace("Processing delta with path '{}'", path);
    if (isObjectExtensionDelta(path) || isShadowAttributesDelta(path)) {
        if (delta.getPath().size() == 1) {
            ObjectExtensionUpdate.handleWholeContainerDelta(object, delta, ctx);
        } else {
            new ObjectExtensionUpdate(object, delta, ctx).handleItemDelta();
        }
    } else if (isOperationResult(delta)) {
        new OperationResultUpdate(object, delta, ctx).handleItemDelta();
    } else if (ObjectType.F_METADATA.equivalent(delta.getPath())) {
        new MetadataUpdate(object, object, delta, ctx).handleWholeContainerDelta();
    } else if (FocusType.F_JPEG_PHOTO.equivalent(delta.getPath())) {
        new PhotoUpdate(object, delta, ctx).handlePropertyDelta();
    } else if (ItemPath.create(FocusType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_METADATA).equivalent(delta.getPath())) {
        new PasswordMetadataUpdate(object, delta, ctx).handlePropertyDelta();
    } else {
        if (object instanceof RShadow && ShadowType.F_PENDING_OPERATION.equivalent(delta.getPath())) {
            ctx.shadowPendingOperationModified = true;
        }
        new GeneralUpdate(object, delta, prismObject, mainEntityType, ctx).handleItemDelta();
    }
}
Also used : RShadow(com.evolveum.midpoint.repo.sql.data.common.RShadow) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 10 with RShadow

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

the class ExtensionTest method test460ReplaceWholeContainer.

@Test
public void test460ReplaceWholeContainer() throws Exception {
    OperationResult result = new OperationResult(ExtensionTest.class.getName() + ".test460ReplaceWholeContainer");
    PrismContainer<?> attributesContainer = shadowAttributesDefinition.instantiate();
    PrismContainerValue<?> attributes = attributesContainer.getValue();
    ResourceAttribute<String> name = attrGroupNameDefinition.instantiate();
    name.setRealValue("alumni3");
    attributes.add(name);
    ResourceAttribute<String> member = attrMemberDefinition.instantiate();
    member.addRealValues("banderson3", "kwhite3");
    attributes.add(member);
    ResourceAttribute<String> manager = attrManagerDefinition.instantiate();
    manager.addRealValues("jack3", "jim3");
    attributes.add(manager);
    ObjectDelta<ShadowType> delta = getPrismContext().deltaFor(ShadowType.class).item(ShadowType.F_ATTRIBUTES).replace(attributes.clone()).asObjectDelta("");
    delta.applyTo(expectedShadow);
    queryListener.start();
    repositoryService.modifyObject(ShadowType.class, shadowOid, delta.getModifications(), getOptions(), result);
    queryListener.dumpAndStop();
    try (Session session = factory.openSession()) {
        RShadow s = session.get(RShadow.class, shadowOid);
        assertExtension(s, itemGroupName, "alumni3");
        assertExtension(s, itemMember, "banderson3", "kwhite3");
        assertExtension(s, itemManager, "jack3", "jim3");
    }
    assertGetObject(result);
    /*
 [1] select oid from m_object where oid = ? for update
 [1] select rshadow0_.oid as oid1_27_, rshadow0_1_.createChannel as createCh2_27_, rshadow0_1_.createTimestamp as createTi3_27_, rshadow0_1_.creatorRef_relation as creatorR4_27_, rshadow0_1_.creatorRef_targetOid as creatorR5_27_, rshadow0_1_.creatorRef_type as creatorR6_27_, rshadow0_1_.fullObject as fullObje7_27_, rshadow0_1_.lifecycleState as lifecycl8_27_, rshadow0_1_.modifierRef_relation as modifier9_27_, rshadow0_1_.modifierRef_targetOid as modifie10_27_, rshadow0_1_.modifierRef_type as modifie11_27_, rshadow0_1_.modifyChannel as modifyC12_27_, rshadow0_1_.modifyTimestamp as modifyT13_27_, rshadow0_1_.name_norm as name_no14_27_, rshadow0_1_.name_orig as name_or15_27_, rshadow0_1_.objectTypeClass as objectT16_27_, rshadow0_1_.tenantRef_relation as tenantR17_27_, rshadow0_1_.tenantRef_targetOid as tenantR18_27_, rshadow0_1_.tenantRef_type as tenantR19_27_, rshadow0_1_.version as version20_27_, rshadow0_.attemptNumber as attemptN1_41_, rshadow0_.dead as dead2_41_, rshadow0_.exist as exist3_41_, rshadow0_.failedOperationType as failedOp4_41_, rshadow0_.fullSynchronizationTimestamp as fullSync5_41_, rshadow0_.intent as intent6_41_, rshadow0_.kind as kind7_41_, rshadow0_.name_norm as name_nor8_41_, rshadow0_.name_orig as name_ori9_41_, rshadow0_.objectClass as objectC10_41_, rshadow0_.pendingOperationCount as pending11_41_, rshadow0_.primaryIdentifierValue as primary12_41_, rshadow0_.resourceRef_relation as resourc13_41_, rshadow0_.resourceRef_targetOid as resourc14_41_, rshadow0_.resourceRef_type as resourc15_41_, rshadow0_.status as status16_41_, rshadow0_.synchronizationSituation as synchro17_41_, rshadow0_.synchronizationTimestamp as synchro18_41_ from m_shadow rshadow0_ inner join m_object rshadow0_1_ on rshadow0_.oid=rshadow0_1_.oid where rshadow0_.oid=?
 [1] select booleans0_.owner_oid as owner_oi2_28_0_, booleans0_.item_id as item_id1_28_0_, booleans0_.ownerType as ownerTyp3_28_0_, booleans0_.booleanValue as booleanV4_28_0_, booleans0_.item_id as item_id1_28_1_, booleans0_.owner_oid as owner_oi2_28_1_, booleans0_.ownerType as ownerTyp3_28_1_, booleans0_.booleanValue as booleanV4_28_1_ from m_object_ext_boolean booleans0_ where booleans0_.owner_oid=?
 [1] select dates0_.owner_oid as owner_oi2_29_0_, dates0_.item_id as item_id1_29_0_, dates0_.ownerType as ownerTyp3_29_0_, dates0_.dateValue as dateValu4_29_0_, dates0_.item_id as item_id1_29_1_, dates0_.owner_oid as owner_oi2_29_1_, dates0_.ownerType as ownerTyp3_29_1_, dates0_.dateValue as dateValu4_29_1_ from m_object_ext_date dates0_ where dates0_.owner_oid=?
 [1] select longs0_.owner_oid as owner_oi2_30_0_, longs0_.item_id as item_id1_30_0_, longs0_.ownerType as ownerTyp3_30_0_, longs0_.longValue as longValu4_30_0_, longs0_.item_id as item_id1_30_1_, longs0_.owner_oid as owner_oi2_30_1_, longs0_.ownerType as ownerTyp3_30_1_, longs0_.longValue as longValu4_30_1_ from m_object_ext_long longs0_ where longs0_.owner_oid=?
 [1] select polys0_.owner_oid as owner_oi2_31_0_, polys0_.item_id as item_id1_31_0_, polys0_.ownerType as ownerTyp3_31_0_, polys0_.orig as orig4_31_0_, polys0_.item_id as item_id1_31_1_, polys0_.owner_oid as owner_oi2_31_1_, polys0_.ownerType as ownerTyp3_31_1_, polys0_.orig as orig4_31_1_, polys0_.norm as norm5_31_1_ from m_object_ext_poly polys0_ where polys0_.owner_oid=?
 [1] select references0_.owner_oid as owner_oi2_32_0_, references0_.item_id as item_id1_32_0_, references0_.ownerType as ownerTyp3_32_0_, references0_.targetoid as targetoi4_32_0_, references0_.item_id as item_id1_32_1_, references0_.owner_oid as owner_oi2_32_1_, references0_.ownerType as ownerTyp3_32_1_, references0_.targetoid as targetoi4_32_1_, references0_.relation as relation5_32_1_, references0_.targetType as targetTy6_32_1_ from m_object_ext_reference references0_ where references0_.owner_oid=?
 [1] select strings0_.owner_oid as owner_oi2_33_0_, strings0_.item_id as item_id1_33_0_, strings0_.ownerType as ownerTyp3_33_0_, strings0_.stringValue as stringVa4_33_0_, strings0_.item_id as item_id1_33_1_, strings0_.owner_oid as owner_oi2_33_1_, strings0_.ownerType as ownerTyp3_33_1_, strings0_.stringValue as stringVa4_33_1_ from m_object_ext_string strings0_ where strings0_.owner_oid=?
 [5] insert into m_object_ext_string (item_id, owner_oid, ownerType, stringValue) values (?, ?, ?, ?)
 [1] 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=?
 [5] delete from m_object_ext_string where item_id=? and owner_oid=? and ownerType=? and stringValue=?

        safe insertions (can be improved)

 [1] select oid from m_object where oid = ? for update
 [1] select rshadow0_.oid as oid1_27_, rshadow0_1_.createChannel as createCh2_27_, rshadow0_1_.createTimestamp as createTi3_27_, rshadow0_1_.creatorRef_relation as creatorR4_27_, rshadow0_1_.creatorRef_targetOid as creatorR5_27_, rshadow0_1_.creatorRef_type as creatorR6_27_, rshadow0_1_.fullObject as fullObje7_27_, rshadow0_1_.lifecycleState as lifecycl8_27_, rshadow0_1_.modifierRef_relation as modifier9_27_, rshadow0_1_.modifierRef_targetOid as modifie10_27_, rshadow0_1_.modifierRef_type as modifie11_27_, rshadow0_1_.modifyChannel as modifyC12_27_, rshadow0_1_.modifyTimestamp as modifyT13_27_, rshadow0_1_.name_norm as name_no14_27_, rshadow0_1_.name_orig as name_or15_27_, rshadow0_1_.objectTypeClass as objectT16_27_, rshadow0_1_.tenantRef_relation as tenantR17_27_, rshadow0_1_.tenantRef_targetOid as tenantR18_27_, rshadow0_1_.tenantRef_type as tenantR19_27_, rshadow0_1_.version as version20_27_, rshadow0_.attemptNumber as attemptN1_41_, rshadow0_.dead as dead2_41_, rshadow0_.exist as exist3_41_, rshadow0_.failedOperationType as failedOp4_41_, rshadow0_.fullSynchronizationTimestamp as fullSync5_41_, rshadow0_.intent as intent6_41_, rshadow0_.kind as kind7_41_, rshadow0_.name_norm as name_nor8_41_, rshadow0_.name_orig as name_ori9_41_, rshadow0_.objectClass as objectC10_41_, rshadow0_.pendingOperationCount as pending11_41_, rshadow0_.primaryIdentifierValue as primary12_41_, rshadow0_.resourceRef_relation as resourc13_41_, rshadow0_.resourceRef_targetOid as resourc14_41_, rshadow0_.resourceRef_type as resourc15_41_, rshadow0_.status as status16_41_, rshadow0_.synchronizationSituation as synchro17_41_, rshadow0_.synchronizationTimestamp as synchro18_41_ from m_shadow rshadow0_ inner join m_object rshadow0_1_ on rshadow0_.oid=rshadow0_1_.oid where rshadow0_.oid=?
 [1] select booleans0_.owner_oid as owner_oi2_28_0_, booleans0_.item_id as item_id1_28_0_, booleans0_.ownerType as ownerTyp3_28_0_, booleans0_.booleanValue as booleanV4_28_0_, booleans0_.item_id as item_id1_28_1_, booleans0_.owner_oid as owner_oi2_28_1_, booleans0_.ownerType as ownerTyp3_28_1_, booleans0_.booleanValue as booleanV4_28_1_ from m_object_ext_boolean booleans0_ where booleans0_.owner_oid=?
 [1] select dates0_.owner_oid as owner_oi2_29_0_, dates0_.item_id as item_id1_29_0_, dates0_.ownerType as ownerTyp3_29_0_, dates0_.dateValue as dateValu4_29_0_, dates0_.item_id as item_id1_29_1_, dates0_.owner_oid as owner_oi2_29_1_, dates0_.ownerType as ownerTyp3_29_1_, dates0_.dateValue as dateValu4_29_1_ from m_object_ext_date dates0_ where dates0_.owner_oid=?
 [1] select longs0_.owner_oid as owner_oi2_30_0_, longs0_.item_id as item_id1_30_0_, longs0_.ownerType as ownerTyp3_30_0_, longs0_.longValue as longValu4_30_0_, longs0_.item_id as item_id1_30_1_, longs0_.owner_oid as owner_oi2_30_1_, longs0_.ownerType as ownerTyp3_30_1_, longs0_.longValue as longValu4_30_1_ from m_object_ext_long longs0_ where longs0_.owner_oid=?
 [1] select polys0_.owner_oid as owner_oi2_31_0_, polys0_.item_id as item_id1_31_0_, polys0_.ownerType as ownerTyp3_31_0_, polys0_.orig as orig4_31_0_, polys0_.item_id as item_id1_31_1_, polys0_.owner_oid as owner_oi2_31_1_, polys0_.ownerType as ownerTyp3_31_1_, polys0_.orig as orig4_31_1_, polys0_.norm as norm5_31_1_ from m_object_ext_poly polys0_ where polys0_.owner_oid=?
 [1] select references0_.owner_oid as owner_oi2_32_0_, references0_.item_id as item_id1_32_0_, references0_.ownerType as ownerTyp3_32_0_, references0_.targetoid as targetoi4_32_0_, references0_.item_id as item_id1_32_1_, references0_.owner_oid as owner_oi2_32_1_, references0_.ownerType as ownerTyp3_32_1_, references0_.targetoid as targetoi4_32_1_, references0_.relation as relation5_32_1_, references0_.targetType as targetTy6_32_1_ from m_object_ext_reference references0_ where references0_.owner_oid=?
 [1] select strings0_.owner_oid as owner_oi2_33_0_, strings0_.item_id as item_id1_33_0_, strings0_.ownerType as ownerTyp3_33_0_, strings0_.stringValue as stringVa4_33_0_, strings0_.item_id as item_id1_33_1_, strings0_.owner_oid as owner_oi2_33_1_, strings0_.ownerType as ownerTyp3_33_1_, strings0_.stringValue as stringVa4_33_1_ from m_object_ext_string strings0_ where strings0_.owner_oid=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [1] select roextstrin0_.item_id as item_id1_33_0_, roextstrin0_.owner_oid as owner_oi2_33_0_, roextstrin0_.ownerType as ownerTyp3_33_0_, roextstrin0_.stringValue as stringVa4_33_0_ from m_object_ext_string roextstrin0_ where roextstrin0_.item_id=? and roextstrin0_.owner_oid=? and roextstrin0_.ownerType=? and roextstrin0_.stringValue=?
 [5] insert into m_object_ext_string (item_id, owner_oid, ownerType, stringValue) values (?, ?, ?, ?)
 [1] 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=?
 [5] delete from m_object_ext_string where item_id=? and owner_oid=? and ownerType=? and stringValue=?
         */
    assertCounts(11 + getExtraSafeInsertionSelects(5), 19 + getExtraSafeInsertionSelects(5));
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RShadow(com.evolveum.midpoint.repo.sql.data.common.RShadow) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Aggregations

RShadow (com.evolveum.midpoint.repo.sql.data.common.RShadow)18 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 Session (org.hibernate.Session)16 Test (org.testng.annotations.Test)16 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 RObject (com.evolveum.midpoint.repo.sql.data.common.RObject)1 PrismIdentifierGenerator (com.evolveum.midpoint.repo.sql.util.PrismIdentifierGenerator)1 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)1