Search in sources :

Example 41 with SearchResultList

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

the class SqaleRepoSearchTest method test915SearchByUpperCaseOidPrefixGoe.

@Test
public void test915SearchByUpperCaseOidPrefixGoe() throws SchemaException {
    when("searching for objects with upper-case OID prefix greater than or equal");
    OperationResult operationResult = createOperationResult();
    SearchResultList<ServiceType> result = repositorySearchObjects(ServiceType.class, prismContext.queryFor(ServiceType.class).item(ServiceType.F_COST_CENTER).eq("OIDTEST").and().item(PrismConstants.T_ID).ge("FF").build(), operationResult);
    then("user with OID greater than or equal to specified prefix ignoring case are returned");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(result).extracting(o -> o.getOid()).containsExactlyInAnyOrder("ff000000-0000-0000-0000-000000000000", "ffffffff-ffff-ffff-ffff-ffffffffffff");
}
Also used : QFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.QFocus) XmlTypeConverter.createXMLGregorianCalendar(com.evolveum.midpoint.prism.xml.XmlTypeConverter.createXMLGregorianCalendar) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) T_PARENT(com.evolveum.midpoint.prism.PrismConstants.T_PARENT) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) F_VALID_FROM(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_FROM) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Assert(org.testng.Assert) F_ACTIVATION(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) Assertions(org.assertj.core.api.Assertions) BigInteger(java.math.BigInteger) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QAssignmentHolder(com.evolveum.midpoint.repo.sqale.qmodel.object.QAssignmentHolder) QObject(com.evolveum.midpoint.repo.sqale.qmodel.object.QObject) BeforeClass(org.testng.annotations.BeforeClass) ORG_DEFAULT(com.evolveum.midpoint.schema.constants.SchemaConstants.ORG_DEFAULT) MiscUtil(com.evolveum.midpoint.util.MiscUtil) UUID(java.util.UUID) F_VALID_TO(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_TO) Instant(java.time.Instant) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) MiscUtil.asXMLGregorianCalendar(com.evolveum.midpoint.util.MiscUtil.asXMLGregorianCalendar) PolyStringItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor) List(java.util.List) ItemName(com.evolveum.midpoint.prism.path.ItemName) SchemaService(com.evolveum.midpoint.schema.SchemaService) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) F_ASSIGNMENT(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType.F_ASSIGNMENT) SystemException(com.evolveum.midpoint.util.exception.SystemException) MObject(com.evolveum.midpoint.repo.sqale.qmodel.object.MObject) T_OBJECT_REFERENCE(com.evolveum.midpoint.prism.PrismConstants.T_OBJECT_REFERENCE) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 42 with SearchResultList

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

the class SqaleRepoSearchTest method searchCaseWorkItemByAssignee.

private void searchCaseWorkItemByAssignee(String assigneeOid, String... expectedCaseOids) throws Exception {
    when("searching case with query for workitem/assigneeRef OID " + assigneeOid);
    OperationResult operationResult = createOperationResult();
    SearchResultList<CaseType> result = searchObjects(CaseType.class, prismContext.queryFor(CaseType.class).item(CaseType.F_WORK_ITEM, CaseWorkItemType.F_ASSIGNEE_REF).ref(assigneeOid).build(), operationResult);
    then("case with the matching workitem assigneeRef is returned");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(result).extracting(o -> o.getOid()).containsExactlyInAnyOrder(expectedCaseOids);
}
Also used : QFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.QFocus) XmlTypeConverter.createXMLGregorianCalendar(com.evolveum.midpoint.prism.xml.XmlTypeConverter.createXMLGregorianCalendar) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) T_PARENT(com.evolveum.midpoint.prism.PrismConstants.T_PARENT) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) F_VALID_FROM(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_FROM) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Assert(org.testng.Assert) F_ACTIVATION(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) Assertions(org.assertj.core.api.Assertions) BigInteger(java.math.BigInteger) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QAssignmentHolder(com.evolveum.midpoint.repo.sqale.qmodel.object.QAssignmentHolder) QObject(com.evolveum.midpoint.repo.sqale.qmodel.object.QObject) BeforeClass(org.testng.annotations.BeforeClass) ORG_DEFAULT(com.evolveum.midpoint.schema.constants.SchemaConstants.ORG_DEFAULT) MiscUtil(com.evolveum.midpoint.util.MiscUtil) UUID(java.util.UUID) F_VALID_TO(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_TO) Instant(java.time.Instant) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) MiscUtil.asXMLGregorianCalendar(com.evolveum.midpoint.util.MiscUtil.asXMLGregorianCalendar) PolyStringItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor) List(java.util.List) ItemName(com.evolveum.midpoint.prism.path.ItemName) SchemaService(com.evolveum.midpoint.schema.SchemaService) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) F_ASSIGNMENT(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType.F_ASSIGNMENT) SystemException(com.evolveum.midpoint.util.exception.SystemException) MObject(com.evolveum.midpoint.repo.sqale.qmodel.object.MObject) T_OBJECT_REFERENCE(com.evolveum.midpoint.prism.PrismConstants.T_OBJECT_REFERENCE) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 43 with SearchResultList

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

the class AuditSearchTest method test252SearchByChangedItemsComplexPath.

@Test
public void test252SearchByChangedItemsComplexPath() throws SchemaException {
    when("searching audit by changed items equal to complex path");
    SearchResultList<AuditEventRecordType> result = searchObjects(prismContext.queryFor(AuditEventRecordType.class).item(AuditEventRecordType.F_CHANGED_ITEM).eq(new ItemPathType(ItemPath.create(ObjectType.F_METADATA, MetadataType.F_REQUEST_TIMESTAMP))).build());
    then("only audit events with the specified changed items are returned");
    assertThat(result).hasSize(1);
    assertThat(result).extracting(aer -> aer.getParameter()).containsExactlyInAnyOrder("1");
}
Also used : Arrays(java.util.Arrays) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) com.evolveum.midpoint.xml.ns._public.common.audit_3(com.evolveum.midpoint.xml.ns._public.common.audit_3) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) BeforeClass(org.testng.annotations.BeforeClass) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UUID(java.util.UUID) PrismObject(com.evolveum.midpoint.prism.PrismObject) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) CHANNEL_REST_URI(com.evolveum.midpoint.schema.constants.SchemaConstants.CHANNEL_REST_URI) Collectors(java.util.stream.Collectors) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) List(java.util.List) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) Comparator(java.util.Comparator) NotNull(org.jetbrains.annotations.NotNull) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 44 with SearchResultList

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

the class AuditSearchTest method test250SearchByChangedItemsSimplePath.

@Test
public void test250SearchByChangedItemsSimplePath() throws SchemaException {
    when("searching audit by changed items equal to simple path");
    SearchResultList<AuditEventRecordType> result = searchObjects(prismContext.queryFor(AuditEventRecordType.class).item(AuditEventRecordType.F_CHANGED_ITEM).eq(new ItemPathType(UserType.F_FULL_NAME)).build());
    then("audit events with the specified changed items are returned");
    assertThat(result).hasSize(2);
    assertThat(result).extracting(aer -> aer.getParameter()).containsExactlyInAnyOrder("1", "2");
}
Also used : Arrays(java.util.Arrays) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) com.evolveum.midpoint.xml.ns._public.common.audit_3(com.evolveum.midpoint.xml.ns._public.common.audit_3) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) BeforeClass(org.testng.annotations.BeforeClass) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UUID(java.util.UUID) PrismObject(com.evolveum.midpoint.prism.PrismObject) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) CHANNEL_REST_URI(com.evolveum.midpoint.schema.constants.SchemaConstants.CHANNEL_REST_URI) Collectors(java.util.stream.Collectors) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) List(java.util.List) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) Comparator(java.util.Comparator) NotNull(org.jetbrains.annotations.NotNull) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 45 with SearchResultList

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

the class TaskRetriever method searchTasks.

@NotNull
public SearchResultList<PrismObject<TaskType>> searchTasks(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
    // returns null if noFetch is set
    ClusterStatusInformation csi = clusterStatusInformationRetriever.getClusterStatusInformation(options, TaskType.class, true, result);
    List<PrismObject<TaskType>> tasksInRepository;
    try {
        tasksInRepository = repositoryService.searchObjects(TaskType.class, query, options, result);
    } catch (SchemaException e) {
        result.recordFatalError("Couldn't get tasks from repository: " + e.getMessage(), e);
        throw e;
    }
    boolean retrieveNextRunStartTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RUN_START_TIMESTAMP, options);
    boolean retrieveRetryTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RETRY_TIMESTAMP, options);
    boolean retrieveNodeAsObserved = SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options);
    boolean loadSubtasks = SelectorOptions.hasToLoadPath(TaskType.F_SUBTASK_REF, options);
    List<PrismObject<TaskType>> tasks = new ArrayList<>();
    for (PrismObject<TaskType> taskInRepository : tasksInRepository) {
        addTransientTaskInformation(taskInRepository, csi, retrieveNextRunStartTime, retrieveRetryTime, retrieveNodeAsObserved, result);
        if (loadSubtasks) {
            fillInSubtasks(taskInRepository, csi, options, result);
        }
        tasks.add(taskInRepository);
    }
    return new SearchResultList<>(tasks);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) ArrayList(java.util.ArrayList) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SearchResultList (com.evolveum.midpoint.schema.SearchResultList)45 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)38 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)33 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)31 Test (org.testng.annotations.Test)28 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)27 List (java.util.List)27 PrismObject (com.evolveum.midpoint.prism.PrismObject)26 ObjectTypeUtil (com.evolveum.midpoint.schema.util.ObjectTypeUtil)25 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)24 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)23 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)23 MiscUtil (com.evolveum.midpoint.util.MiscUtil)23 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)17 TestUtil (com.evolveum.midpoint.test.util.TestUtil)17 UUID (java.util.UUID)17 BeforeClass (org.testng.annotations.BeforeClass)17 com.evolveum.midpoint.prism (com.evolveum.midpoint.prism)14 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)14 SystemException (com.evolveum.midpoint.util.exception.SystemException)10