@NotNull @Override public List<ObjectFilter> createSpecificFilters(@NotNull WorkBucketType bucket, AbstractWorkSegmentationType configuration, Class<? extends ObjectType> type, Function<ItemPath, ItemDefinition<?>> itemDefinitionProvider) { AbstractWorkBucketContentType content = bucket.getContent(); if (hasNoBoundaries(content)) { return new ArrayList<>(); } if (configuration == null) { throw new IllegalStateException("No buckets configuration but having defined bucket content: " + content); } ItemPath discriminator = getDiscriminator(configuration, content); ItemDefinition<?> discriminatorDefinition = itemDefinitionProvider != null ? itemDefinitionProvider.apply(discriminator) : null; QName matchingRuleName = configuration.getMatchingRule() != null ? QNameUtil.uriToQName(configuration.getMatchingRule(), PrismConstants.NS_MATCHING_RULE) : null; List<ObjectFilter> filters = new ArrayList<>(); if (getFrom(content) != null) { filters.add(prismContext.queryFor(type) .item(discriminator, discriminatorDefinition).ge(getFrom(content)).matching(matchingRuleName) .buildFilter()); } if (getTo(content) != null) { filters.add(prismContext.queryFor(type) .item(discriminator, discriminatorDefinition).lt(getTo(content)).matching(matchingRuleName) .buildFilter()); } return filters; }
@Test public void test305GreaterOrEqual() throws Exception { final String TEST_NAME = "test305GreaterOrEqual"; displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_COST_CENTER).ge("100000") .build(); checkQueryRoundtripFile(UserType.class, q, TEST_NAME); }
@Test public void test305GreaterLesserMatchingNorm() throws Exception { final String TEST_NAME = "test305GreaterLesserMatchingNorm"; displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_NAME).ge(new PolyString("00", "00")).matchingNorm() .and().item(UserType.F_NAME).lt(new PolyString("0a", "0a")).matchingNorm() .build(); checkQueryRoundtripFile(UserType.class, q, TEST_NAME); }
assertEquals("Wrong # of queries", 3, qe.size()); ObjectQuery q1 = prismContext.queryFor(UserType.class) .item(UserType.F_ITERATION).ge(BigInteger.valueOf(0)) .and().item(UserType.F_ITERATION).lt(BigInteger.valueOf(10)) .build(); ObjectQuery q2 = prismContext.queryFor(UserType.class) .item(UserType.F_ITERATION).ge(BigInteger.valueOf(10)) .and().item(UserType.F_ITERATION).lt(BigInteger.valueOf(20)) .build(); ObjectQuery q3 = prismContext.queryFor(UserType.class) .item(UserType.F_ITERATION).ge(BigInteger.valueOf(20)) .and().item(UserType.F_ITERATION).lt(BigInteger.valueOf(30)) .build();
@Test public void test1320OidGeLtTest() throws Exception { Session session = open(); try { ObjectQuery query = prismContext.queryFor(ObjectType.class) .item(PrismConstants.T_ID).ge("1") .and().item(PrismConstants.T_ID).lt("2") .build(); String real = getInterpretedQuery2(session, ObjectType.class, query, false); String expected = "select\n" + " o.oid, o.fullObject,\n" + " o.stringsCount,\n" + " o.longsCount,\n" + " o.datesCount,\n" + " o.referencesCount,\n" + " o.polysCount,\n" + " o.booleansCount\n" + "from\n" + " RObject o\n" + "where\n" + " ( o.oid >= :oid and o.oid < :oid2 )\n"; assertEqualsIgnoreWhitespace(expected, real); } finally { close(session); } }
@Test public void test310AllComparisons() throws Exception { final String TEST_NAME = "test310AllComparisons"; displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_COST_CENTER).gt("100000") .and().item(UserType.F_COST_CENTER).lt("999999") .or() .item(UserType.F_COST_CENTER).ge("X100") .and().item(UserType.F_COST_CENTER).le("X999") .build(); checkQueryRoundtripFile(UserType.class, q, TEST_NAME); }
ObjectQuery query = prismContext.queryFor(GenericObjectType.class) .item(F_NAME).eqPoly("generic object", "generic object").matchingNorm() .and().item(F_EXTENSION, new QName("intType")).ge(100) .and().item(F_EXTENSION, new QName("intType")).lt(200) .and().item(F_EXTENSION, new QName("longType")).eq(335)
.item(UserType.F_ITERATION).ge(BigInteger.valueOf(123)) .and().item(UserType.F_ITERATION).lt(BigInteger.valueOf(200)) .build(); assertOptimizedCompletedBuckets(taskAfter); expectedQuery = prismContext.queryFor(UserType.class) .item(UserType.F_ITERATION).ge(BigInteger.valueOf(200)) .build(); PrismAsserts.assertQueriesEquivalent("Wrong narrowed query (3)", expectedQuery, narrowedQuery);
.item(ShadowType.F_NAME).ge(new PolyString("a", "a")) .and().item(ShadowType.F_NAME).lt(new PolyString("m", "m")) .build(); assertOptimizedCompletedBuckets(taskAfter); expectedQuery = prismContext.queryFor(ShadowType.class) .item(ShadowType.F_NAME).ge(new PolyString("m", "m")) .build(); PrismAsserts.assertQueriesEquivalent("Wrong narrowed query (3)", expectedQuery, narrowedQuery);
display("narrowed query (2)", narrowedQuery); expectedQuery = prismContext.queryFor(UserType.class) .item(UserType.F_NAME).ge("00").matchingNorm() .and().item(UserType.F_NAME).lt("0a").matchingNorm() .build();