public static String orderBy(QueryOrderingProperty orderingProperty, int index) { QueryProperty queryProperty = orderingProperty.getQueryProperty(); StringBuilder sb = new StringBuilder(); sb.append(tableAlias(orderingProperty.getRelation(), index)); if (orderingProperty.isContainedProperty()) { sb.append("."); } else { sb.append("_"); } sb.append(queryProperty.getName()); sb.append(" "); sb.append(orderingProperty.getDirection().getName()); return sb.toString(); }
public static String orderBy(QueryOrderingProperty orderingProperty, int index) { QueryProperty queryProperty = orderingProperty.getQueryProperty(); StringBuilder sb = new StringBuilder(); sb.append(tableAlias(orderingProperty.getRelation(), index)); if (orderingProperty.isContainedProperty()) { sb.append("."); } else { sb.append("_"); } sb.append(queryProperty.getName()); sb.append(" "); sb.append(orderingProperty.getDirection().getName()); return sb.toString(); }
protected void verifyOrderingProperties(List<QueryOrderingProperty> expectedProperties, List<QueryOrderingProperty> actualProperties) { assertEquals(expectedProperties.size(), actualProperties.size()); for (int i = 0; i < expectedProperties.size(); i++) { QueryOrderingProperty expectedProperty = expectedProperties.get(i); QueryOrderingProperty actualProperty = actualProperties.get(i); assertEquals(expectedProperty.getRelation(), actualProperty.getRelation()); assertEquals(expectedProperty.getDirection(), actualProperty.getDirection()); assertEquals(expectedProperty.isContainedProperty(), actualProperty.isContainedProperty()); assertEquals(expectedProperty.getQueryProperty(), actualProperty.getQueryProperty()); List<QueryEntityRelationCondition> expectedRelationConditions = expectedProperty.getRelationConditions(); List<QueryEntityRelationCondition> actualRelationConditions = expectedProperty.getRelationConditions(); if (expectedRelationConditions != null && actualRelationConditions != null) { assertEquals(expectedRelationConditions.size(), actualRelationConditions.size()); for (int j = 0; j < expectedRelationConditions.size(); j++) { QueryEntityRelationCondition expectedFilteringProperty = expectedRelationConditions.get(j); QueryEntityRelationCondition actualFilteringProperty = expectedRelationConditions.get(j); assertEquals(expectedFilteringProperty.getProperty(), actualFilteringProperty.getProperty()); assertEquals(expectedFilteringProperty.getComparisonProperty(), actualFilteringProperty.getComparisonProperty()); assertEquals(expectedFilteringProperty.getScalarValue(), actualFilteringProperty.getScalarValue()); } } else if ((expectedRelationConditions == null && actualRelationConditions != null) || (expectedRelationConditions != null && actualRelationConditions == null)) { fail("Expected filtering properties: " + expectedRelationConditions + ". " + "Actual filtering properties: " + actualRelationConditions); } } }
/** * Tests compatibility with serialization format that was used in 7.2 */ @SuppressWarnings("deprecation") public void testDeprecatedOrderingFormatDeserializationSingleOrdering() { String sortByNameAsc = "RES." + TaskQueryProperty.NAME.getName() + " " + Direction.ASCENDING.getName(); JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK); JsonObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery()); // when I apply a specific ordering by one dimension queryJson.addProperty(JsonTaskQueryConverter.ORDER_BY, sortByNameAsc); TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson); // then the ordering is applied accordingly assertEquals(1, deserializedTaskQuery.getOrderingProperties().size()); QueryOrderingProperty orderingProperty = deserializedTaskQuery.getOrderingProperties().get(0); assertNull(orderingProperty.getRelation()); assertEquals("asc", orderingProperty.getDirection().getName()); assertNull(orderingProperty.getRelationConditions()); assertTrue(orderingProperty.isContainedProperty()); assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty.getQueryProperty().getName()); assertNull(orderingProperty.getQueryProperty().getFunction()); }
/** * Tests compatibility with serialization format that was used in 7.2 */ @SuppressWarnings("deprecation") public void testDeprecatedOrderingFormatDeserializationFunctionOrdering() { String orderingWithFunction = "LOWER(RES." + TaskQueryProperty.NAME.getName() + ") asc"; JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK); JsonObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery()); // when I apply an ordering with a function queryJson.addProperty(JsonTaskQueryConverter.ORDER_BY, orderingWithFunction); TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson); assertEquals(1, deserializedTaskQuery.getOrderingProperties().size()); // then the ordering is applied accordingly QueryOrderingProperty orderingProperty = deserializedTaskQuery.getOrderingProperties().get(0); assertNull(orderingProperty.getRelation()); assertEquals("asc", orderingProperty.getDirection().getName()); assertNull(orderingProperty.getRelationConditions()); assertFalse(orderingProperty.isContainedProperty()); assertEquals(TaskQueryProperty.NAME_CASE_INSENSITIVE.getName(), orderingProperty.getQueryProperty().getName()); assertEquals(TaskQueryProperty.NAME_CASE_INSENSITIVE.getFunction(), orderingProperty.getQueryProperty().getFunction()); }
assertEquals("asc", orderingProperty1.getDirection().getName()); assertNull(orderingProperty1.getRelationConditions()); assertTrue(orderingProperty1.isContainedProperty()); assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty1.getQueryProperty().getName()); assertNull(orderingProperty1.getQueryProperty().getFunction()); assertEquals("desc", orderingProperty2.getDirection().getName()); assertNull(orderingProperty2.getRelationConditions()); assertTrue(orderingProperty2.isContainedProperty()); assertEquals(TaskQueryProperty.ASSIGNEE.getName(), orderingProperty2.getQueryProperty().getName()); assertNull(orderingProperty2.getQueryProperty().getFunction());
public static String orderBy(QueryOrderingProperty orderingProperty, int index) { QueryProperty queryProperty = orderingProperty.getQueryProperty(); StringBuilder sb = new StringBuilder(); sb.append(tableAlias(orderingProperty.getRelation(), index)); if (orderingProperty.isContainedProperty()) { sb.append("."); } else { sb.append("_"); } sb.append(queryProperty.getName()); sb.append(" "); sb.append(orderingProperty.getDirection().getName()); return sb.toString(); }
protected void verifyOrderingProperties(List<QueryOrderingProperty> expectedProperties, List<QueryOrderingProperty> actualProperties) { assertEquals(expectedProperties.size(), actualProperties.size()); for (int i = 0; i < expectedProperties.size(); i++) { QueryOrderingProperty expectedProperty = expectedProperties.get(i); QueryOrderingProperty actualProperty = actualProperties.get(i); assertEquals(expectedProperty.getRelation(), actualProperty.getRelation()); assertEquals(expectedProperty.getDirection(), actualProperty.getDirection()); assertEquals(expectedProperty.isContainedProperty(), actualProperty.isContainedProperty()); assertEquals(expectedProperty.getQueryProperty(), actualProperty.getQueryProperty()); List<QueryEntityRelationCondition> expectedRelationConditions = expectedProperty.getRelationConditions(); List<QueryEntityRelationCondition> actualRelationConditions = expectedProperty.getRelationConditions(); if (expectedRelationConditions != null && actualRelationConditions != null) { assertEquals(expectedRelationConditions.size(), actualRelationConditions.size()); for (int j = 0; j < expectedRelationConditions.size(); j++) { QueryEntityRelationCondition expectedFilteringProperty = expectedRelationConditions.get(j); QueryEntityRelationCondition actualFilteringProperty = expectedRelationConditions.get(j); assertEquals(expectedFilteringProperty.getProperty(), actualFilteringProperty.getProperty()); assertEquals(expectedFilteringProperty.getComparisonProperty(), actualFilteringProperty.getComparisonProperty()); assertEquals(expectedFilteringProperty.getScalarValue(), actualFilteringProperty.getScalarValue()); } } else if ((expectedRelationConditions == null && actualRelationConditions != null) || (expectedRelationConditions != null && actualRelationConditions == null)) { fail("Expected filtering properties: " + expectedRelationConditions + ". " + "Actual filtering properties: " + actualRelationConditions); } } }
/** * Tests compatibility with serialization format that was used in 7.2 */ @SuppressWarnings("deprecation") public void testDeprecatedOrderingFormatDeserializationSingleOrdering() { String sortByNameAsc = "RES." + TaskQueryProperty.NAME.getName() + " " + Direction.ASCENDING.getName(); JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK); JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery()); // when I apply a specific ordering by one dimension queryJson.put(JsonTaskQueryConverter.ORDER_BY, sortByNameAsc); TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson); // then the ordering is applied accordingly assertEquals(1, deserializedTaskQuery.getOrderingProperties().size()); QueryOrderingProperty orderingProperty = deserializedTaskQuery.getOrderingProperties().get(0); assertNull(orderingProperty.getRelation()); assertEquals("asc", orderingProperty.getDirection().getName()); assertNull(orderingProperty.getRelationConditions()); assertTrue(orderingProperty.isContainedProperty()); assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty.getQueryProperty().getName()); assertNull(orderingProperty.getQueryProperty().getFunction()); }
/** * Tests compatibility with serialization format that was used in 7.2 */ @SuppressWarnings("deprecation") public void testDeprecatedOrderingFormatDeserializationFunctionOrdering() { String orderingWithFunction = "LOWER(RES." + TaskQueryProperty.NAME.getName() + ") asc"; JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK); JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery()); // when I apply an ordering with a function queryJson.put(JsonTaskQueryConverter.ORDER_BY, orderingWithFunction); TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson); assertEquals(1, deserializedTaskQuery.getOrderingProperties().size()); // then the ordering is applied accordingly QueryOrderingProperty orderingProperty = deserializedTaskQuery.getOrderingProperties().get(0); assertNull(orderingProperty.getRelation()); assertEquals("asc", orderingProperty.getDirection().getName()); assertNull(orderingProperty.getRelationConditions()); assertFalse(orderingProperty.isContainedProperty()); assertEquals(TaskQueryProperty.NAME_CASE_INSENSITIVE.getName(), orderingProperty.getQueryProperty().getName()); assertEquals(TaskQueryProperty.NAME_CASE_INSENSITIVE.getFunction(), orderingProperty.getQueryProperty().getFunction()); }
assertEquals("asc", orderingProperty1.getDirection().getName()); assertNull(orderingProperty1.getRelationConditions()); assertTrue(orderingProperty1.isContainedProperty()); assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty1.getQueryProperty().getName()); assertNull(orderingProperty1.getQueryProperty().getFunction()); assertEquals("desc", orderingProperty2.getDirection().getName()); assertNull(orderingProperty2.getRelationConditions()); assertTrue(orderingProperty2.isContainedProperty()); assertEquals(TaskQueryProperty.ASSIGNEE.getName(), orderingProperty2.getQueryProperty().getName()); assertNull(orderingProperty2.getQueryProperty().getFunction());