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(); }
@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); }
@Test public void test0020QueryTwoOrganizationsNormAnd() throws Exception { Session session = open(); try { /* * UserType: And (Equal (organization, 'asdf', PolyStringNorm), * Equal (organization, 'ghjk', PolyStringNorm)) */ ObjectQuery query = prismContext.queryFor(UserType.class) .item(UserType.F_ORGANIZATION).eqPoly("asdf", "asdf").matchingNorm() .and().item(UserType.F_ORGANIZATION).eqPoly("ghjk", "ghjk").matchingNorm() .build(); String expected = "select\n" + " u.oid, u.fullObject, u.stringsCount, u.longsCount, u.datesCount, u.referencesCount, u.polysCount, u.booleansCount\n" + "from\n" + " RUser u\n" + " left join u.organization o\n" + " left join u.organization o2\n" + "where\n" + " ( o.norm = :norm and o2.norm = :norm2 )"; String real = getInterpretedQuery2(session, UserType.class, query); assertEqualsIgnoreWhitespace(expected, real); } finally { close(session); } }
@Test public void test0001QueryNameNorm() throws Exception { Session session = open(); try { /* * ### user: Equal (name, "asdf", PolyStringNorm) */ ObjectQuery query = prismContext.queryFor(UserType.class) .item(F_NAME).eqPoly("asdf", "asdf").matchingNorm().build(); String expected = "select\n" + " u.oid, u.fullObject, u.stringsCount, u.longsCount, u.datesCount, u.referencesCount, u.polysCount, u.booleansCount\n" + "from\n" + " RUser u\n" + "where\n" + " u.nameCopy.norm = :norm"; String real = getInterpretedQuery2(session, UserType.class, query); assertEqualsIgnoreWhitespace(expected, real); } finally { close(session); } }
.item(UserType.F_LINK_REF, PrismConstants.T_OBJECT_REFERENCE, ShadowType.F_RESOURCE_REF, PrismConstants.T_OBJECT_REFERENCE, F_NAME).containsPoly("CSV").matchingNorm() .build();
@Test public void test0010QueryOrganizationNorm() throws Exception { Session session = open(); try { /* * ### user: Equal (organization, "...", PolyStringNorm) */ ObjectQuery query = prismContext.queryFor(UserType.class) .item(UserType.F_ORGANIZATION).eqPoly("guľôčka v jamôčke").matchingNorm().build(); String expected = "select\n" + " u.oid, u.fullObject, u.stringsCount, u.longsCount, u.datesCount, u.referencesCount, u.polysCount, u.booleansCount\n" + "from\n" + " RUser u\n" + " left join u.organization o\n" + "where\n" + " o.norm = :norm"; RQueryImpl rQuery = (RQueryImpl) getInterpretedQuery2Whole(session, UserType.class, query, false, null); String real = rQuery.getQuery().getQueryString(); assertEqualsIgnoreWhitespace(expected, real); assertEquals("Wrong parameter value", "gulocka v jamocke", rQuery.getQuerySource().getParameters().get("norm").getValue()); } finally { close(session); } }
try { 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)
.item(UserType.F_FULL_NAME).eqPoly(existingNameNorm).matchingNorm() .build(), false, 1); .item(UserType.F_FULL_NAME).eqPoly(existingNameOrig).matchingNorm() .build(), false, 1); .item(UserType.F_FULL_NAME).eq(existingNameNorm).matchingNorm() .build(), false, 1); .item(UserType.F_FULL_NAME).eq(existingNameOrig).matchingNorm() .build(), false, 1); .item(UserType.F_FULL_NAME).containsPoly(existingNameNorm).matchingNorm() .build(), false, 1); .item(UserType.F_FULL_NAME).containsPoly(existingNameOrig).matchingNorm() .build(), false, 1); .item(UserType.F_FULL_NAME).contains(existingNameNorm).matchingNorm() .build(), false, 1); .item(UserType.F_FULL_NAME).contains(existingNameOrig).matchingNorm()
.item(RoleType.F_RISK_LEVEL).eq("critical") .and().item(RoleType.F_IDENTIFIER).eq("001") .and().item(RoleType.F_DISPLAY_NAME).eqPoly("aaa", "aaa").matchingNorm() .build(); String real = getInterpretedQuery2(session, RoleType.class, query);
display("narrowed query (1)", narrowedQuery); ObjectQuery expectedQuery = prismContext.queryFor(UserType.class) .item(UserType.F_NAME).lt("00").matchingNorm() .build(); PrismAsserts.assertQueriesEquivalent("Wrong narrowed query (1)", 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(); PrismAsserts.assertQueriesEquivalent("Wrong narrowed query (2)", expectedQuery, narrowedQuery);
try { ObjectQuery query = prismContext.queryFor(UserType.class) .item(UserType.F_FULL_NAME).eq(toPolyString(USER_FULL_NAME)).matchingNorm() .build(); subresult1.addParam("query", query);
display("narrowed query (1)", narrowedQuery); ObjectQuery expectedQuery = prismContext.queryFor(UserType.class) .item(UserType.F_NAME).startsWith("a00").matchingNorm() .build(); PrismAsserts.assertQueriesEquivalent("Wrong narrowed query (1)", expectedQuery, narrowedQuery);