protected internal virtual void verifyOrderingProperties(IList <QueryOrderingProperty> expectedProperties, IList <QueryOrderingProperty> actualProperties) { assertEquals(expectedProperties.Count, actualProperties.Count); for (int i = 0; i < expectedProperties.Count; i++) { QueryOrderingProperty expectedProperty = expectedProperties[i]; QueryOrderingProperty actualProperty = actualProperties[i]; assertEquals(expectedProperty.Relation, actualProperty.Relation); assertEquals(expectedProperty.Direction, actualProperty.Direction); assertEquals(expectedProperty.ContainedProperty, actualProperty.ContainedProperty); assertEquals(expectedProperty.QueryProperty, actualProperty.QueryProperty); IList <QueryEntityRelationCondition> expectedRelationConditions = expectedProperty.RelationConditions; IList <QueryEntityRelationCondition> actualRelationConditions = expectedProperty.RelationConditions; if (expectedRelationConditions != null && actualRelationConditions != null) { assertEquals(expectedRelationConditions.Count, actualRelationConditions.Count); foreach (QueryEntityRelationCondition expectedFilteringProperty in expectedRelationConditions) { assertEquals(expectedFilteringProperty.Property, expectedFilteringProperty.Property); assertEquals(expectedFilteringProperty.ComparisonProperty, expectedFilteringProperty.ComparisonProperty); assertEquals(expectedFilteringProperty.ScalarValue, expectedFilteringProperty.ScalarValue); } } else if (expectedRelationConditions != null || actualRelationConditions != null) { fail("Expected filtering properties: " + expectedRelationConditions + ". " + "Actual filtering properties: " + actualRelationConditions); } } }
public static string orderBySelection(QueryOrderingProperty orderingProperty, int index) { QueryProperty queryProperty = orderingProperty.QueryProperty; StringBuilder sb = new StringBuilder(); if (!string.ReferenceEquals(queryProperty.Function, null)) { sb.Append(queryProperty.Function); sb.Append("("); } sb.Append(tableAlias(orderingProperty.Relation, index)); sb.Append("."); sb.Append(queryProperty.Name); if (!string.ReferenceEquals(queryProperty.Function, null)) { sb.Append(")"); } return(sb.ToString()); }
public static string orderBy(QueryOrderingProperty orderingProperty, int index) { QueryProperty queryProperty = orderingProperty.QueryProperty; StringBuilder sb = new StringBuilder(); sb.Append(tableAlias(orderingProperty.Relation, index)); if (orderingProperty.ContainedProperty) { sb.Append("."); } else { sb.Append("_"); } sb.Append(queryProperty.Name); sb.Append(" "); sb.Append(orderingProperty.Direction.Name); return(sb.ToString()); }
public virtual IList <QueryOrderingProperty> fromOrderByString(string orderByString) { IList <QueryOrderingProperty> properties = new List <QueryOrderingProperty>(); string[] orderByClauses = orderByString.Split(ORDER_BY_DELIMITER, true); foreach (string orderByClause in orderByClauses) { orderByClause = orderByClause.Trim(); string[] clauseParts = orderByClause.Split(" ", true); if (clauseParts.Length == 0) { continue; } else if (clauseParts.Length > 2) { throw new ProcessEngineException("Invalid order by clause: " + orderByClause); } string function = null; string propertyPart = clauseParts[0]; int functionArgumentBegin = propertyPart.IndexOf("(", StringComparison.Ordinal); if (functionArgumentBegin >= 0) { function = propertyPart.Substring(0, functionArgumentBegin); int functionArgumentEnd = propertyPart.IndexOf(")", StringComparison.Ordinal); propertyPart = propertyPart.Substring(functionArgumentBegin + 1, functionArgumentEnd - (functionArgumentBegin + 1)); } string[] propertyParts = propertyPart.Split("\\.", true); string property = null; if (propertyParts.Length == 1) { property = propertyParts[0]; } else if (propertyParts.Length == 2) { property = propertyParts[1]; } else { throw new ProcessEngineException("Invalid order by property part: " + clauseParts[0]); } QueryProperty queryProperty = new QueryPropertyImpl(property, function); Direction direction = null; if (clauseParts.Length == 2) { string directionPart = clauseParts[1]; direction = Direction.findByName(directionPart); } QueryOrderingProperty orderingProperty = new QueryOrderingProperty(null, queryProperty); orderingProperty.Direction = direction; properties.Add(orderingProperty); } return(properties); }