Exemplo n.º 1
0
        public override QueryEntityRelationCondition toObject(JsonObject jsonObject)
        {
            // this is limited in that it allows only String values;
            // that is sufficient for current use case with task filters
            // but could be extended by a data type in the future
            string scalarValue = null;

            if (jsonObject.has(SCALAR_VALUE))
            {
                scalarValue = JsonUtil.getString(jsonObject, SCALAR_VALUE);
            }

            QueryProperty baseProperty = null;

            if (jsonObject.has(BASE_PROPERTY))
            {
                baseProperty = new QueryPropertyImpl(JsonUtil.getString(jsonObject, BASE_PROPERTY));
            }

            QueryProperty comparisonProperty = null;

            if (jsonObject.has(COMPARISON_PROPERTY))
            {
                comparisonProperty = new QueryPropertyImpl(JsonUtil.getString(jsonObject, COMPARISON_PROPERTY));
            }

            return(new QueryEntityRelationCondition(baseProperty, comparisonProperty, scalarValue));
        }
Exemplo n.º 2
0
        public override QueryOrderingProperty toObject(JsonObject jsonObject)
        {
            string relation = null;

            if (jsonObject.has(RELATION))
            {
                relation = JsonUtil.getString(jsonObject, RELATION);
            }

            QueryOrderingProperty property = null;

            if (QueryOrderingProperty.RELATION_VARIABLE.Equals(relation))
            {
                property = new VariableOrderProperty();
            }
            else
            {
                property = new QueryOrderingProperty();
            }

            property.Relation = relation;

            if (jsonObject.has(QUERY_PROPERTY))
            {
                string propertyName     = JsonUtil.getString(jsonObject, QUERY_PROPERTY);
                string propertyFunction = null;
                if (jsonObject.has(QUERY_PROPERTY_FUNCTION))
                {
                    propertyFunction = JsonUtil.getString(jsonObject, QUERY_PROPERTY_FUNCTION);
                }

                QueryProperty queryProperty = new QueryPropertyImpl(propertyName, propertyFunction);
                property.QueryProperty = queryProperty;
            }

            if (jsonObject.has(DIRECTION))
            {
                string direction = JsonUtil.getString(jsonObject, DIRECTION);
                property.Direction = Direction.findByName(direction);
            }

            if (jsonObject.has(RELATION_CONDITIONS))
            {
                IList <QueryEntityRelationCondition> relationConditions = JsonQueryFilteringPropertyConverter.ARRAY_CONVERTER.toObject(JsonUtil.getArray(jsonObject, RELATION_CONDITIONS));
                property.RelationConditions = relationConditions;
            }

            return(property);
        }
Exemplo n.º 3
0
        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);
        }