use of com.evolveum.midpoint.repo.sql.data.common.dictionary.ExtItemDictionary 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.dictionary.ExtItemDictionary in project midpoint by Evolveum.
the class ObjectDeltaUpdater method handleObjectTextInfoChanges.
private void handleObjectTextInfoChanges(Class<? extends ObjectType> type, Collection<? extends ItemDelta<?, ?>> modifications, PrismObject<?> prismObject, RObject object) {
FullTextSearchConfigurationType config = repositoryService.getFullTextSearchConfiguration();
if (!FullTextSearchUtil.isObjectTextInfoRecomputationNeeded(config, type, modifications)) {
return;
}
Set<RObjectTextInfo> newInfos = RObjectTextInfo.createItemsSet((ObjectType) prismObject.asObjectable(), object, new RepositoryContext(repositoryService, prismContext, relationRegistry, extItemDictionary, repositoryConfiguration));
if (newInfos == null || newInfos.isEmpty()) {
object.getTextInfoItems().clear();
} else {
Set<String> existingTexts = object.getTextInfoItems().stream().map(info -> info.getText()).collect(Collectors.toSet());
Set<String> newTexts = newInfos.stream().map(info -> info.getText()).collect(Collectors.toSet());
object.getTextInfoItems().removeIf(existingInfo -> !newTexts.contains(existingInfo.getText()));
for (RObjectTextInfo newInfo : newInfos) {
if (!existingTexts.contains(newInfo.getText())) {
object.getTextInfoItems().add(newInfo);
}
}
}
}
Aggregations