Search in sources :

Example 1 with RelationRegistry

use of com.evolveum.midpoint.schema.RelationRegistry in project midpoint by Evolveum.

the class AccCertReviewersHelper method getMembers.

private List<ObjectReferenceType> getMembers(ObjectReferenceType abstractRoleRef, OperationResult result) throws SchemaException {
    Collection<PrismReferenceValue> references = ObjectQueryUtil.createReferences(abstractRoleRef.getOid(), RelationKindType.MEMBER, relationRegistry);
    ObjectQuery query = references.isEmpty() ? prismContext.queryFor(UserType.class).none().build() : prismContext.queryFor(UserType.class).item(UserType.F_ROLE_MEMBERSHIP_REF).ref(references).build();
    return repositoryService.searchObjects(UserType.class, query, null, result).stream().map(obj -> ObjectTypeUtil.createObjectRef(obj, prismContext)).collect(Collectors.toList());
}
Also used : java.util(java.util) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) Trace(com.evolveum.midpoint.util.logging.Trace) ModelExpressionThreadLocalHolder(com.evolveum.midpoint.model.common.expression.ModelExpressionThreadLocalHolder) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) ExpressionConstants(com.evolveum.midpoint.schema.constants.ExpressionConstants) ExpressionEnvironment(com.evolveum.midpoint.model.common.expression.ExpressionEnvironment) QNameUtil(com.evolveum.midpoint.util.QNameUtil) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) PrismContext(com.evolveum.midpoint.prism.PrismContext) RelationRegistry(com.evolveum.midpoint.schema.RelationRegistry) Qualifier(org.springframework.beans.factory.annotation.Qualifier) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) OrgStructFunctions(com.evolveum.midpoint.model.api.expr.OrgStructFunctions) ObjectQueryUtil(com.evolveum.midpoint.schema.util.ObjectQueryUtil) ResourceTypeUtil(com.evolveum.midpoint.schema.util.ResourceTypeUtil) PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) CertCampaignTypeUtil(com.evolveum.midpoint.schema.util.CertCampaignTypeUtil) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QName(javax.xml.namespace.QName) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 2 with RelationRegistry

use of com.evolveum.midpoint.schema.RelationRegistry in project midpoint by Evolveum.

the class AbstractWfTest method checkVisibleWorkItem.

protected void checkVisibleWorkItem(ExpectedWorkItem expectedWorkItem, int count, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, CommunicationException {
    S_AtomicFilterExit q = QueryUtils.filterForAssignees(prismContext.queryFor(CaseWorkItemType.class), SecurityUtil.getPrincipal(), OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, relationRegistry);
    q = q.and().item(CaseWorkItemType.F_CLOSE_TIMESTAMP).isNull();
    List<CaseWorkItemType> currentWorkItems = modelService.searchContainers(CaseWorkItemType.class, q.build(), null, task, result);
    long found = currentWorkItems.stream().filter(wi -> expectedWorkItem == null || expectedWorkItem.matches(wi)).count();
    assertEquals("Wrong # of matching work items", count, found);
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) AssertJUnit(org.testng.AssertJUnit) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) CaseManager(com.evolveum.midpoint.cases.api.CaseManager) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) TaskManager(com.evolveum.midpoint.task.api.TaskManager) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) CaseWorkItemUtil(com.evolveum.midpoint.schema.util.cases.CaseWorkItemUtil) WorkItemManager(com.evolveum.midpoint.cases.impl.WorkItemManager) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) Clockwork(com.evolveum.midpoint.model.impl.lens.Clockwork) CaseAsserter(com.evolveum.midpoint.test.asserter.CaseAsserter) Map(java.util.Map) RelationRegistry(com.evolveum.midpoint.schema.RelationRegistry) IntegrationTestTools(com.evolveum.midpoint.test.IntegrationTestTools) CaseService(com.evolveum.midpoint.model.api.CaseService) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ClassMode(org.springframework.test.annotation.DirtiesContext.ClassMode) PrismUtil(com.evolveum.midpoint.prism.util.PrismUtil) MiscHelper(com.evolveum.midpoint.wf.impl.util.MiscHelper) IOException(java.io.IOException) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit) Task(com.evolveum.midpoint.task.api.Task) File(java.io.File) AbstractModelImplementationIntegrationTest(com.evolveum.midpoint.model.impl.AbstractModelImplementationIntegrationTest) WorkItemId(com.evolveum.midpoint.schema.util.WorkItemId) List(java.util.List) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) SecurityUtil(com.evolveum.midpoint.security.api.SecurityUtil) CaseEngineImpl(com.evolveum.midpoint.cases.impl.engine.CaseEngineImpl) PrimaryChangeProcessor(com.evolveum.midpoint.wf.impl.processors.primary.PrimaryChangeProcessor) ContextConfiguration(org.springframework.test.context.ContextConfiguration) SystemObjectCache(com.evolveum.midpoint.model.common.SystemObjectCache) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Checker(com.evolveum.midpoint.test.Checker) Collections(java.util.Collections) QueryUtils(com.evolveum.midpoint.cases.api.util.QueryUtils) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit)

Example 3 with RelationRegistry

use of com.evolveum.midpoint.schema.RelationRegistry 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

RelationRegistry (com.evolveum.midpoint.schema.RelationRegistry)3 ObjectTypeUtil (com.evolveum.midpoint.schema.util.ObjectTypeUtil)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 com.evolveum.midpoint.util.exception (com.evolveum.midpoint.util.exception)2 Trace (com.evolveum.midpoint.util.logging.Trace)2 TraceManager (com.evolveum.midpoint.util.logging.TraceManager)2 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)2 Collectors (java.util.stream.Collectors)2 QName (javax.xml.namespace.QName)2 Component (org.springframework.stereotype.Component)2 CaseManager (com.evolveum.midpoint.cases.api.CaseManager)1 QueryUtils (com.evolveum.midpoint.cases.api.util.QueryUtils)1 WorkItemManager (com.evolveum.midpoint.cases.impl.WorkItemManager)1 CaseEngineImpl (com.evolveum.midpoint.cases.impl.engine.CaseEngineImpl)1