Search in sources :

Example 1 with ExtItemDictionary

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;
}
Also used : AndCondition(com.evolveum.midpoint.repo.sql.query.hqm.condition.AndCondition) Condition(com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition) ExtItemDictionary(com.evolveum.midpoint.repo.sql.data.common.dictionary.ExtItemDictionary) ArrayList(java.util.ArrayList) List(java.util.List) RObject(com.evolveum.midpoint.repo.sql.data.common.RObject) RExtItem(com.evolveum.midpoint.repo.sql.data.common.any.RExtItem) AndCondition(com.evolveum.midpoint.repo.sql.query.hqm.condition.AndCondition)

Example 2 with ExtItemDictionary

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);
            }
        }
    }
}
Also used : PrismIdentifierGenerator(com.evolveum.midpoint.repo.sql.util.PrismIdentifierGenerator) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Session(org.hibernate.Session) Autowired(org.springframework.beans.factory.annotation.Autowired) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) FullTextSearchConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FullTextSearchConfigurationType) RObjectTextInfo(com.evolveum.midpoint.repo.sql.data.common.RObjectTextInfo) DebugUtil(com.evolveum.midpoint.util.DebugUtil) StringUtils(org.apache.commons.lang3.StringUtils) SqlRepositoryConfiguration(com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration) FullTextSearchUtil(com.evolveum.midpoint.schema.util.FullTextSearchUtil) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) EquivalenceStrategy(com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) PrismContext(com.evolveum.midpoint.prism.PrismContext) RepositoryContext(com.evolveum.midpoint.repo.sql.data.RepositoryContext) RelationRegistry(com.evolveum.midpoint.schema.RelationRegistry) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) Collection(java.util.Collection) Set(java.util.Set) PrismObject(com.evolveum.midpoint.prism.PrismObject) Collectors(java.util.stream.Collectors) ObjectUpdater(com.evolveum.midpoint.repo.sql.helpers.ObjectUpdater) Component(org.springframework.stereotype.Component) PrismEntityMapper(com.evolveum.midpoint.repo.sql.helpers.modify.PrismEntityMapper) RepoModifyOptions(com.evolveum.midpoint.repo.api.RepoModifyOptions) ManagedType(javax.persistence.metamodel.ManagedType) ExtItemDictionary(com.evolveum.midpoint.repo.sql.data.common.dictionary.ExtItemDictionary) RObjectType(com.evolveum.midpoint.repo.sql.data.common.other.RObjectType) EntityRegistry(com.evolveum.midpoint.repo.sql.helpers.modify.EntityRegistry) RObject(com.evolveum.midpoint.repo.sql.data.common.RObject) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) RShadow(com.evolveum.midpoint.repo.sql.data.common.RShadow) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) RepositoryContext(com.evolveum.midpoint.repo.sql.data.RepositoryContext) FullTextSearchConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FullTextSearchConfigurationType) RObjectTextInfo(com.evolveum.midpoint.repo.sql.data.common.RObjectTextInfo)

Aggregations

RObject (com.evolveum.midpoint.repo.sql.data.common.RObject)2 ExtItemDictionary (com.evolveum.midpoint.repo.sql.data.common.dictionary.ExtItemDictionary)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 EquivalenceStrategy (com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy)1 RepoModifyOptions (com.evolveum.midpoint.repo.api.RepoModifyOptions)1 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)1 SqlRepositoryConfiguration (com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration)1 RepositoryContext (com.evolveum.midpoint.repo.sql.data.RepositoryContext)1 RObjectTextInfo (com.evolveum.midpoint.repo.sql.data.common.RObjectTextInfo)1 RShadow (com.evolveum.midpoint.repo.sql.data.common.RShadow)1 RExtItem (com.evolveum.midpoint.repo.sql.data.common.any.RExtItem)1 RObjectType (com.evolveum.midpoint.repo.sql.data.common.other.RObjectType)1 ObjectUpdater (com.evolveum.midpoint.repo.sql.helpers.ObjectUpdater)1 EntityRegistry (com.evolveum.midpoint.repo.sql.helpers.modify.EntityRegistry)1 PrismEntityMapper (com.evolveum.midpoint.repo.sql.helpers.modify.PrismEntityMapper)1 AndCondition (com.evolveum.midpoint.repo.sql.query.hqm.condition.AndCondition)1 Condition (com.evolveum.midpoint.repo.sql.query.hqm.condition.Condition)1 PrismIdentifierGenerator (com.evolveum.midpoint.repo.sql.util.PrismIdentifierGenerator)1