use of com.evolveum.midpoint.repo.sql.data.common.any.RExtItem in project midpoint by Evolveum.
the class ExtDictionaryTest method test100ParallelAdd.
@Test
public void test100ParallelAdd() throws Exception {
for (int round = 0; round < ROUNDS; round++) {
List<TestingThread> threads = new ArrayList<>();
for (int i = 0; i < THREADS; i++) {
final int round1 = round;
final int thread1 = i;
Runnable runnable = () -> {
try {
UserType user = new UserType(prismContext).name("u-" + round1 + "-" + thread1);
QName propertyName = new QName(NS_TEST, "round" + round1);
MutablePrismPropertyDefinition<String> propertyDefinition = prismContext.definitionFactory().createPropertyDefinition(propertyName, DOMUtil.XSD_STRING);
PrismProperty<String> property = propertyDefinition.instantiate();
property.setRealValue("value");
user.asPrismObject().addExtensionItem(property);
repositoryService.addObject(user.asPrismObject(), null, new OperationResult("addObject"));
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new SystemException(e);
}
};
TestingThread thread = new TestingThread(runnable);
threads.add(thread);
thread.start();
}
for (int i = 0; i < THREADS; i++) {
TestingThread thread = threads.get(i);
thread.join(60000L);
if (thread.throwable != null) {
fail("Exception in " + thread + ": " + thread.throwable);
}
}
}
Session session = open();
// noinspection unchecked
List<RExtItem> extItems = session.createQuery("from RExtItem").list();
System.out.println("ext items: " + extItems.size());
for (RExtItem extItem : extItems) {
System.out.println(extItem);
logger.info("{}", extItem);
}
session.close();
}
use of com.evolveum.midpoint.repo.sql.data.common.any.RExtItem in project midpoint by Evolveum.
the class ExtItemDictionary method createOrFindItemByDefinitionInternal.
@Contract("_, _, true -> !null")
private RExtItem createOrFindItemByDefinitionInternal(@NotNull ItemDefinition<?> definition, boolean create, boolean throwExceptionAfterCreate) {
boolean fetchedNow = fetchItemsIfNeeded();
RExtItem.Key key = RExtItem.createKeyFromDefinition(definition);
RExtItem item = itemsByKey.get(key);
if (item == null && !fetchedNow) {
LOGGER.debug("Ext item for {} not found, fetching all items.", key);
fetchItems();
item = itemsByKey.get(key);
}
if (item == null && create) {
LOGGER.debug("Ext item for {} not found even in current items; creating it.", key);
item = RExtItem.createFromDefinition(definition);
addExtItemAttempt(item);
if (throwExceptionAfterCreate) {
throw new RestartOperationRequestedException("Restarting parent operation because an extension item was created");
}
}
return item;
}
use of com.evolveum.midpoint.repo.sql.data.common.any.RExtItem in project midpoint by Evolveum.
the class ExtItemDictionary method getItemById.
public synchronized RExtItem getItemById(Integer extItemId) {
boolean fresh = fetchItemsIfNeeded();
RExtItem extItem = itemsById.get(extItemId);
if (extItem != null || fresh) {
return extItem;
}
fetchItems();
return itemsById.get(extItemId);
}
use of com.evolveum.midpoint.repo.sql.data.common.any.RExtItem in project midpoint by Evolveum.
the class ItemPathResolver method createJoinCondition.
private Condition createJoinCondition(String joinedItemAlias, JpaLinkDefinition<?> joinedItemDefinition, RootHibernateQuery hibernateQuery) throws QueryException {
Condition condition = null;
if (joinedItemDefinition instanceof JpaAnyItemLinkDefinition) {
JpaAnyItemLinkDefinition anyLinkDef = (JpaAnyItemLinkDefinition) joinedItemDefinition;
AndCondition conjunction = hibernateQuery.createAnd();
if (anyLinkDef.getOwnerType() != null) {
// null for assignment extensions
conjunction.add(hibernateQuery.createEq(joinedItemAlias + ".ownerType", anyLinkDef.getOwnerType()));
}
ExtItemDictionary dictionary = context.getExtItemDictionary();
RExtItem extItemDefinition = dictionary.findItemByDefinition(anyLinkDef.getItemDefinition());
if (extItemDefinition != null) {
conjunction.add(hibernateQuery.createEq(joinedItemAlias + "." + RAnyValue.F_ITEM_ID, extItemDefinition.getId()));
} else {
// there are no rows referencing this item, because it does not exist in RExtItem (yet)
conjunction.add(hibernateQuery.createFalse());
}
condition = conjunction;
} else if (joinedItemDefinition.getCollectionSpecification() instanceof VirtualCollectionSpecification) {
VirtualCollectionSpecification vcd = (VirtualCollectionSpecification) joinedItemDefinition.getCollectionSpecification();
List<Condition> conditions = new ArrayList<>(vcd.getAdditionalParams().length);
for (VirtualQueryParam vqp : vcd.getAdditionalParams()) {
// e.g. name = "assignmentOwner", type = RAssignmentOwner.class, value = "ABSTRACT_ROLE"
Object value = createQueryParamValue(vqp);
Condition c = hibernateQuery.createEq(joinedItemAlias + "." + vqp.name(), value);
conditions.add(c);
}
if (conditions.size() > 1) {
condition = hibernateQuery.createAnd(conditions);
} else if (conditions.size() == 1) {
condition = conditions.iterator().next();
}
}
return condition;
}
use of com.evolveum.midpoint.repo.sql.data.common.any.RExtItem in project midpoint by Evolveum.
the class ExtensionTest method test129ReplaceNonIndexedExtensionProperty.
@Test
public void test129ReplaceNonIndexedExtensionProperty() throws Exception {
OperationResult result = new OperationResult("test129ReplaceNonIndexedExtensionProperty");
ObjectDelta<UserType> delta = getPrismContext().deltaFor(UserType.class).item(UserType.F_ASSIGNMENT, 1, AssignmentType.F_EXTENSION, EXT_LOOT).replace(34).asObjectDelta("");
delta.applyTo(expectedUser);
queryListener.start();
repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), getOptions(), result);
queryListener.dumpAndStop();
RExtItem extItemDef = extItemDictionary.findItemByDefinition(delta.getModifications().iterator().next().getDefinition());
assertNull("ext item definition for loot exists", extItemDef);
assertGetObject(result);
/*
[1] select oid from m_object where oid = ? for update
[1] 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=?
[1] select assignment0_.owner_oid as owner_oi2_5_0_, assignment0_.id as id1_5_0_, assignment0_.id as id1_5_1_, assignment0_.owner_oid as owner_oi2_5_1_, assignment0_.administrativeStatus as administ3_5_1_, assignment0_.archiveTimestamp as archiveT4_5_1_, assignment0_.disableReason as disableR5_5_1_, assignment0_.disableTimestamp as disableT6_5_1_, assignment0_.effectiveStatus as effectiv7_5_1_, assignment0_.enableTimestamp as enableTi8_5_1_, assignment0_.validFrom as validFro9_5_1_, assignment0_.validTo as validTo10_5_1_, assignment0_.validityChangeTimestamp as validit11_5_1_, assignment0_.validityStatus as validit12_5_1_, assignment0_.assignmentOwner as assignm13_5_1_, assignment0_.createChannel as createC14_5_1_, assignment0_.createTimestamp as createT15_5_1_, assignment0_.creatorRef_relation as creator16_5_1_, assignment0_.creatorRef_targetOid as creator17_5_1_, assignment0_.creatorRef_type as creator18_5_1_, assignment0_.extId as extId38_5_1_, assignment0_.extOid as extOid39_5_1_, assignment0_.lifecycleState as lifecyc19_5_1_, assignment0_.modifierRef_relation as modifie20_5_1_, assignment0_.modifierRef_targetOid as modifie21_5_1_, assignment0_.modifierRef_type as modifie22_5_1_, assignment0_.modifyChannel as modifyC23_5_1_, assignment0_.modifyTimestamp as modifyT24_5_1_, assignment0_.orderValue as orderVa25_5_1_, assignment0_.orgRef_relation as orgRef_26_5_1_, assignment0_.orgRef_targetOid as orgRef_27_5_1_, assignment0_.orgRef_type as orgRef_28_5_1_, assignment0_.resourceRef_relation as resourc29_5_1_, assignment0_.resourceRef_targetOid as resourc30_5_1_, assignment0_.resourceRef_type as resourc31_5_1_, assignment0_.targetRef_relation as targetR32_5_1_, assignment0_.targetRef_targetOid as targetR33_5_1_, assignment0_.targetRef_type as targetR34_5_1_, assignment0_.tenantRef_relation as tenantR35_5_1_, assignment0_.tenantRef_targetOid as tenantR36_5_1_, assignment0_.tenantRef_type as tenantR37_5_1_, rassignmen1_.owner_id as owner_id1_12_2_, rassignmen1_.owner_owner_oid as owner_ow2_12_2_ from m_assignment assignment0_ left outer join m_assignment_extension rassignmen1_ on assignment0_.extId=rassignmen1_.owner_id and assignment0_.extOid=rassignmen1_.owner_owner_oid where assignment0_.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=?
*/
assertCounts(4, 4);
}
Aggregations