protected PrismObject<ConnectorType> findConnectorByType(String connectorType, OperationResult result) throws SchemaException { ObjectQuery query = prismContext.queryFor(ConnectorType.class) .item(ConnectorType.F_CONNECTOR_TYPE).eq(connectorType) .build(); List<PrismObject<ConnectorType>> connectors = repositoryService.searchObjects(ConnectorType.class, query, null, result); if (connectors.size() != 1) { throw new IllegalStateException("Cannot find connector type " + connectorType + ", got " + connectors); } return connectors.get(0); }
public static S_AtomicFilterExit createResourceAndObjectClassFilterPrefix(String resourceOid, QName objectClass, PrismContext prismContext) throws SchemaException { Validate.notNull(resourceOid, "Resource where to search must not be null."); Validate.notNull(objectClass, "Object class to search must not be null."); Validate.notNull(prismContext, "Prism context must not be null."); return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resourceOid) .and().item(ShadowType.F_OBJECT_CLASS).eq(objectClass); }
public static ObjectQuery createNameQuery(PolyString name, PrismContext prismContext) throws SchemaException { return prismContext.queryFor(ObjectType.class) .item(ObjectType.F_NAME).eq(name) .build(); }
private static ObjectFilter createResourceAndKindFilter(String resourceOid, ShadowKindType kind, PrismContext prismContext) throws SchemaException { Validate.notNull(resourceOid, "Resource where to search must not be null."); Validate.notNull(kind, "Kind to search must not be null."); Validate.notNull(prismContext, "Prism context must not be null."); return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resourceOid) .and().item(ShadowType.F_KIND).eq(kind) .buildFilter(); }
public static ObjectQuery createOrigNameQuery(PolyString name, PrismContext prismContext) throws SchemaException { return prismContext.queryFor(ObjectType.class) .item(ObjectType.F_NAME).eq(name).matchingOrig() .build(); }
private List<Task> listWaitingTasks(TaskWaitingReason reason, OperationResult result) throws SchemaException { S_AtomicFilterEntry q = prismContext.queryFor(TaskType.class); q = q.item(TaskType.F_EXECUTION_STATUS).eq(TaskExecutionStatusType.WAITING).and(); if (reason != null) { q = q.item(TaskType.F_WAITING_REASON).eq(reason.toTaskType()).and(); } ObjectQuery query = q.all().build(); List<PrismObject<TaskType>> prisms = repositoryService.searchObjects(TaskType.class, query, null, result); List<Task> tasks = resolveTasksFromTaskTypes(prisms, result); result.recordSuccessIfUnknown(); return tasks; }
protected ObjectQuery createShadowQueryByAttribute(ObjectClassComplexTypeDefinition rAccount, String attributeName, String attributeValue, PrismObject<ResourceType> resource) throws SchemaException { ResourceAttributeDefinition<Object> attrDef = rAccount.findAttributeDefinition(attributeName); return prismContext.queryFor(ShadowType.class) .itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getName()).eq(attributeValue) .and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getTypeName()) .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) .build(); }
public static ObjectQuery createNormNameQuery(PolyString name, PrismContext prismContext) throws SchemaException { PolyStringNormalizer normalizer = new AlphanumericPolyStringNormalizer(); name.recompute(normalizer); return prismContext.queryFor(ObjectType.class) .item(ObjectType.F_NAME).eq(name).matchingNorm() .build(); }
boolean hasNoResponseCases(String campaignOid, OperationResult result) { ObjectQuery query = prismContext.queryFor(AccessCertificationCaseType.class) .ownerId(campaignOid) .and().item(AccessCertificationCaseType.F_OUTCOME).eq(SchemaConstants.MODEL_CERTIFICATION_OUTCOME_NO_RESPONSE) .build(); return repositoryService.countContainers(AccessCertificationCaseType.class, query, null, result) > 0; } }
private <T> ObjectFilter createAttributeEqualFilter(ProvisioningContext ctx, ResourceAttribute<T> secondaryIdentifier) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { return prismContext.queryFor(ShadowType.class) .item(secondaryIdentifier.getPath(), secondaryIdentifier.getDefinition()) .eq(getNormalizedValue(secondaryIdentifier, ctx.getObjectClassDefinition())) .buildFilter(); }
public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, QName objectClass, PrismContext prismContext) throws SchemaException { return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) .and().item(ShadowType.F_OBJECT_CLASS).eq(objectClass) .build(); }
@Test public void testMatchOrFilter() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_GIVEN_NAME).eq("Jack") .or().item(UserType.F_GIVEN_NAME).eq("Jackie") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); }
@Test public void test210EqualMultiple() throws Exception { final String TEST_NAME = "test210EqualMultiple"; displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_EMPLOYEE_TYPE).eq("STD", "TEMP") .build(); checkQueryRoundtripFile(UserType.class, q, TEST_NAME); }
@Test public void testDontMatchEqualFilter() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_GIVEN_NAME).eq("Jackie") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); }
@Test public void test220EqualRightHandItem() throws Exception { final String TEST_NAME = "test220EqualRightHandItem"; displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_EMPLOYEE_NUMBER).eq().item(UserType.F_COST_CENTER) .build(); checkQueryRoundtripFile(UserType.class, q, TEST_NAME); }
@Test // MID-4217 public void testMultiRootPositive() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION).eq("Assignment 2") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object, but it should", match); }
@Test // MID-4217 public void testMultiRootNegative() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION).eq("Assignment XXXXX") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); }
private void searchFettucini(int expectedNumberOfFettucinis) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask(TestDummy.class.getName() + ".searchFettucini"); OperationResult result = task.getResult(); ObjectQuery query = prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) .and().item(ShadowType.F_OBJECT_CLASS).eq(new QName(dummyResourceCtl.getNamespace(), "AccountObjectClass")) .and().itemWithDef(getIcfNameDefinition(), ShadowType.F_ATTRIBUTES, getIcfNameDefinition().getName()).eq(ACCOUNT_FETTUCINI_NAME) .build(); // WHEN List<PrismObject<ShadowType>> shadows = provisioningService.searchObjects(ShadowType.class, query, null, task, result); assertEquals("Wrong number of Fettucinis found", expectedNumberOfFettucinis, shadows.size()); }
public List<PrismObject<TaskType>> listPrerequisiteTasksRaw(OperationResult parentResult) throws SchemaException { OperationResult result = parentResult.createMinorSubresult(DOT_INTERFACE + "listPrerequisiteTasksRaw"); result.addContext(OperationResult.CONTEXT_OID, getOid()); result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, TaskQuartzImpl.class); ObjectQuery query = getPrismContext().queryFor(TaskType.class) .item(TaskType.F_DEPENDENT).eq(getTaskIdentifier()) .build(); List<PrismObject<TaskType>> list = taskManager.getRepositoryService().searchObjects(TaskType.class, query, null, result); result.recordSuccessIfUnknown(); return list; }
@Test public void testPolystringMatchEqualFilter() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); PolyString name = new PolyString("jack", "jack"); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_NAME).eq(name) .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); }