Search in sources :

Example 1 with RObjectTextInfo

use of com.evolveum.midpoint.repo.sql.data.common.RObjectTextInfo 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

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 RObject (com.evolveum.midpoint.repo.sql.data.common.RObject)1 RObjectTextInfo (com.evolveum.midpoint.repo.sql.data.common.RObjectTextInfo)1 RShadow (com.evolveum.midpoint.repo.sql.data.common.RShadow)1 ExtItemDictionary (com.evolveum.midpoint.repo.sql.data.common.dictionary.ExtItemDictionary)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 PrismIdentifierGenerator (com.evolveum.midpoint.repo.sql.util.PrismIdentifierGenerator)1 RelationRegistry (com.evolveum.midpoint.schema.RelationRegistry)1 FullTextSearchUtil (com.evolveum.midpoint.schema.util.FullTextSearchUtil)1 ObjectTypeUtil (com.evolveum.midpoint.schema.util.ObjectTypeUtil)1