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(); }
public static String orderBySelection(QueryOrderingProperty orderingProperty, int index) { QueryProperty queryProperty = orderingProperty.getQueryProperty(); StringBuilder sb = new StringBuilder(); if (queryProperty.getFunction() != null) { sb.append(queryProperty.getFunction()); sb.append("("); } sb.append(tableAlias(orderingProperty.getRelation(), index)); sb.append("."); sb.append(queryProperty.getName()); if (queryProperty.getFunction() != null) { sb.append(")"); } return sb.toString(); }
public static String orderBySelection(QueryOrderingProperty orderingProperty, int index) { QueryProperty queryProperty = orderingProperty.getQueryProperty(); StringBuilder sb = new StringBuilder(); if (queryProperty.getFunction() != null) { sb.append(queryProperty.getFunction()); sb.append("("); } sb.append(tableAlias(orderingProperty.getRelation(), index)); sb.append("."); sb.append(queryProperty.getName()); if (queryProperty.getFunction() != null) { sb.append(")"); } return sb.toString(); }
protected void applyRequestControls(AbstractQuery<?, ?> query) { try { List<Control> controls = new ArrayList<>(); List<QueryOrderingProperty> orderBy = query.getOrderingProperties(); if(orderBy != null) { for (QueryOrderingProperty orderingProperty : orderBy) { String propertyName = orderingProperty.getQueryProperty().getName(); if(UserQueryProperty.USER_ID.getName().equals(propertyName)) { controls.add(new SortControl(ldapConfiguration.getUserIdAttribute(), Control.CRITICAL)); } else if(UserQueryProperty.EMAIL.getName().equals(propertyName)) { controls.add(new SortControl(ldapConfiguration.getUserEmailAttribute(), Control.CRITICAL)); } else if(UserQueryProperty.FIRST_NAME.getName().equals(propertyName)) { controls.add(new SortControl(ldapConfiguration.getUserFirstnameAttribute(), Control.CRITICAL)); } else if(UserQueryProperty.LAST_NAME.getName().equals(propertyName)) { controls.add(new SortControl(ldapConfiguration.getUserLastnameAttribute(), Control.CRITICAL)); } } } initialContext.setRequestControls(controls.toArray(new Control[0])); } catch (Exception e) { throw new IdentityProviderException("Exception while setting paging settings", e); } }
public static SortingDto convertQueryOrderingPropertyToSortingDto(QueryOrderingProperty orderingProperty) { SortingDto sortingDto = new SortingDto(); sortingDto.setSortBy(sortByValueForQueryProperty(orderingProperty.getQueryProperty())); sortingDto.setSortOrder(sortOrderValueForDirection(orderingProperty.getDirection())); return sortingDto; }
public static SortingDto convertQueryOrderingPropertyToSortingDto(QueryOrderingProperty orderingProperty) { SortingDto sortingDto = new SortingDto(); sortingDto.setSortBy(sortByValueForQueryProperty(orderingProperty.getQueryProperty())); sortingDto.setSortOrder(sortOrderValueForDirection(orderingProperty.getDirection())); return sortingDto; }
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()); }
public JsonObject toJsonObject(QueryOrderingProperty property) { JsonObject jsonObject = JsonUtil.createObject(); JsonUtil.addField(jsonObject, RELATION, property.getRelation()); QueryProperty queryProperty = property.getQueryProperty(); if (queryProperty != null) { JsonUtil.addField(jsonObject, QUERY_PROPERTY, queryProperty.getName()); JsonUtil.addField(jsonObject, QUERY_PROPERTY_FUNCTION, queryProperty.getFunction()); } Direction direction = property.getDirection(); if (direction != null) { JsonUtil.addField(jsonObject, DIRECTION, direction.getName()); } if (property.hasRelationConditions()) { JsonArray relationConditionsJson = JsonQueryFilteringPropertyConverter.ARRAY_CONVERTER .toJsonArray(property.getRelationConditions()); JsonUtil.addField(jsonObject, RELATION_CONDITIONS, relationConditionsJson); } return jsonObject; }
/** * 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()); }
public JsonObject toJsonObject(QueryOrderingProperty property) { JsonObject jsonObject = JsonUtil.createObject(); JsonUtil.addField(jsonObject, RELATION, property.getRelation()); QueryProperty queryProperty = property.getQueryProperty(); if (queryProperty != null) { JsonUtil.addField(jsonObject, QUERY_PROPERTY, queryProperty.getName()); JsonUtil.addField(jsonObject, QUERY_PROPERTY_FUNCTION, queryProperty.getFunction()); } Direction direction = property.getDirection(); if (direction != null) { JsonUtil.addField(jsonObject, DIRECTION, direction.getName()); } if (property.hasRelationConditions()) { JsonArray relationConditionsJson = JsonQueryFilteringPropertyConverter.ARRAY_CONVERTER .toJsonArray(property.getRelationConditions()); JsonUtil.addField(jsonObject, RELATION_CONDITIONS, relationConditionsJson); } return jsonObject; }
assertNull(orderingProperty1.getRelationConditions()); assertTrue(orderingProperty1.isContainedProperty()); assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty1.getQueryProperty().getName()); assertNull(orderingProperty1.getQueryProperty().getFunction()); 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(); }
public static String orderBySelection(QueryOrderingProperty orderingProperty, int index) { QueryProperty queryProperty = orderingProperty.getQueryProperty(); StringBuilder sb = new StringBuilder(); if (queryProperty.getFunction() != null) { sb.append(queryProperty.getFunction()); sb.append("("); } sb.append(tableAlias(orderingProperty.getRelation(), index)); sb.append("."); sb.append(queryProperty.getName()); if (queryProperty.getFunction() != null) { sb.append(")"); } return sb.toString(); }
protected void applyRequestControls(AbstractQuery<?, ?> query) { try { List<Control> controls = new ArrayList<Control>(); List<QueryOrderingProperty> orderBy = query.getOrderingProperties(); if(orderBy != null) { for (QueryOrderingProperty orderingProperty : orderBy) { String propertyName = orderingProperty.getQueryProperty().getName(); if(UserQueryProperty.USER_ID.getName().equals(propertyName)) { controls.add(new SortControl(ldapConfiguration.getUserIdAttribute(), Control.CRITICAL)); } else if(UserQueryProperty.EMAIL.getName().equals(propertyName)) { controls.add(new SortControl(ldapConfiguration.getUserEmailAttribute(), Control.CRITICAL)); } else if(UserQueryProperty.FIRST_NAME.getName().equals(propertyName)) { controls.add(new SortControl(ldapConfiguration.getUserFirstnameAttribute(), Control.CRITICAL)); } else if(UserQueryProperty.LAST_NAME.getName().equals(propertyName)) { controls.add(new SortControl(ldapConfiguration.getUserLastnameAttribute(), Control.CRITICAL)); } } } initialContext.setRequestControls(controls.toArray(new Control[0])); } catch (Exception e) { throw new IdentityProviderException("Exception while setting paging settings", e); } }
public static SortingDto convertQueryOrderingPropertyToSortingDto(QueryOrderingProperty orderingProperty) { SortingDto sortingDto = new SortingDto(); sortingDto.setSortBy(sortByValueForQueryProperty(orderingProperty.getQueryProperty())); sortingDto.setSortOrder(sortOrderValueForDirection(orderingProperty.getDirection())); return sortingDto; }
public JSONObject toJsonObject(QueryOrderingProperty property) { JSONObject jsonObject = new JSONObject(); JsonUtil.addField(jsonObject, RELATION, property.getRelation()); QueryProperty queryProperty = property.getQueryProperty(); if (queryProperty != null) { JsonUtil.addField(jsonObject, QUERY_PROPERTY, queryProperty.getName()); JsonUtil.addField(jsonObject, QUERY_PROPERTY_FUNCTION, queryProperty.getFunction()); } Direction direction = property.getDirection(); if (direction != null) { JsonUtil.addField(jsonObject, DIRECTION, direction.getName()); } if (property.hasRelationConditions()) { JSONArray relationConditionsJson = JsonQueryFilteringPropertyConverter.ARRAY_CONVERTER .toJsonArray(property.getRelationConditions()); JsonUtil.addField(jsonObject, RELATION_CONDITIONS, relationConditionsJson); } return jsonObject; }
/** * 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()); }