예제 #1
0
 private string CompileMaxValue(PropertyLiteral literal)
 {
     //<##>
     //return ValueFormatter.GetMaxValue(literal.DataType);
     return(null);
     //</##>
 }
예제 #2
0
        private Query CompileBinaryExpression(PropertyLiteral left, Operator op, Literal right)
        {
            //PropertyLiteral left = expression.BinExp.LeftValue;
            //Operator op = expression.BinExp.Operator;
            //Literal right = expression.BinExp.RightValue;

            if (!right.IsValue)
            {
                throw new NotSupportedException();
            }

            var formatterName = left.DataType.ToString();

            if (left.Name == "Path" && op == Operator.StartsWith)
            {
                return(CompileInTreeQuery((string)right.Value));
            }

            var  leftName   = CompileLeftValue(left);
            var  rightValue = CompileLiteralValue(right.Value, formatterName);
            Term rightTerm  = CreateRightTerm(leftName, op, rightValue);
            Term minTerm;
            Term maxTerm;

            switch (op)
            {
            case Operator.StartsWith:                                      // left:right*
                return(new PrefixQuery(rightTerm));

            case Operator.EndsWith:                                        // left:*right
            case Operator.Contains:                                        // left:*right*
                return(new WildcardQuery(rightTerm));

            case Operator.Equal:                                           // left:right
                return(new TermQuery(rightTerm));

            case Operator.NotEqual:                                        // -(left:right)
                throw new NotSupportedException("##Wrong optimizer");

            case Operator.LessThan:                                        // left:{minValue TO right}
                minTerm = new Term(leftName, CompileMinValue(left));
                return(new RangeQuery(minTerm, rightTerm, false));

            case Operator.GreaterThan:                                     // left:{right TO maxValue}
                maxTerm = new Term(leftName, CompileMaxValue(left));
                return(new RangeQuery(rightTerm, maxTerm, false));

            case Operator.LessThanOrEqual:                                 // left:[minValue TO right]
                minTerm = new Term(leftName, CompileMinValue(left));
                return(new RangeQuery(minTerm, rightTerm, true));

            case Operator.GreaterThanOrEqual:                              // left:[right TO maxValue]
                maxTerm = new Term(leftName, CompileMaxValue(left));
                return(new RangeQuery(rightTerm, maxTerm, true));

            default:
                throw new NotImplementedException();
            }
        }
예제 #3
0
 public SearchOrder(PropertyType propertyToOrder, OrderDirection direction)
 {
     if (propertyToOrder == null)
     {
         throw new ArgumentNullException("propertyToOrder");
     }
     _propertyToOrder = new PropertyLiteral(propertyToOrder);
     _direction       = direction;
 }
예제 #4
0
 public ReferenceExpression(ReferenceAttribute referrerProperty, Expression expression)
 {
     if (expression == null)
     {
         throw new ArgumentNullException("expression");
     }
     _referrerProperty = new PropertyLiteral((NodeAttribute)referrerProperty);
     _expression       = expression;
 }
예제 #5
0
 private string CompileLeftValue(PropertyLiteral propLit)
 {
     if (propLit.IsSlot)
     {
         return(CompilePropertySlot(propLit.PropertySlot));
     }
     else
     {
         return(CompileNodeAttribute(propLit.NodeAttribute));
     }
 }
예제 #6
0
 public ReferenceExpression(PropertyType referrerProperty)
 {
     if (referrerProperty == null)
     {
         throw new ArgumentNullException("referrerProperty");
     }
     if (referrerProperty.DataType != DataType.Reference)
     {
         throw new ArgumentOutOfRangeException("referrerProperty", "The DataType of 'referrerProperty' must be Reference");
     }
     _referrerProperty = new PropertyLiteral(referrerProperty);
     _existenceOnly    = true;
 }
예제 #7
0
        private Query CompileBinaryExpression(PropertyLiteral left, Operator op, Literal right)
        {
            if (!right.IsValue)
            {
                throw new NotSupportedException();
            }

            var formatterName = left.DataType.ToString();

            if (left.Name == "Path" && op == Operator.StartsWith)
            {
                return(CompileInTreeQuery((string)right.Value));
            }

            var  leftName   = CompileLeftValue(left);
            var  rightValue = CompileLiteralValue(right.Value, formatterName);
            Term rightTerm  = CreateRightTerm(leftName, op, rightValue);

            switch (op)
            {
            case Operator.StartsWith:                                      // left:right*
                return(new PrefixQuery(rightTerm));

            case Operator.EndsWith:                                        // left:*right
            case Operator.Contains:                                        // left:*right*
                return(new WildcardQuery(rightTerm));

            case Operator.Equal:                                           // left:right
                return(new TermQuery(rightTerm));

            case Operator.NotEqual:                                        // -(left:right)
                throw new NotSupportedException("##Wrong optimizer");

            case Operator.LessThan:                                        // left:{minValue TO right}
                return(new TermRangeQuery(leftName, CompileMinValue(left), rightValue, false, false));

            case Operator.GreaterThan:                                     // left:{right TO maxValue}
                return(new TermRangeQuery(leftName, rightValue, CompileMaxValue(left), false, false));

            case Operator.LessThanOrEqual:                                 // left:[minValue TO right]
                return(new TermRangeQuery(leftName, CompileMinValue(left), rightValue, true, true));

            case Operator.GreaterThanOrEqual:                              // left:[right TO maxValue]
                return(new TermRangeQuery(leftName, rightValue, CompileMaxValue(left), true, true));

            default:
                throw new SenseNet.ContentRepository.Storage.SnNotSupportedException();
            }
        }
예제 #8
0
 public ReferenceExpression(PropertyType referrerProperty, Expression expression)
 {
     if (referrerProperty == null)
     {
         throw new ArgumentNullException("referrerProperty");
     }
     if (referrerProperty.DataType != DataType.Reference)
     {
         throw new ArgumentOutOfRangeException("referrerProperty", "The DataType of ''referrerProperty'' must be Reference");
     }
     if (expression == null)
     {
         throw new ArgumentNullException("expression");
     }
     _referrerProperty = new PropertyLiteral(referrerProperty);
     _expression       = expression;
 }
예제 #9
0
 public ReferenceExpression(ReferenceAttribute referrerProperty, Node referencedNode)
 {
     _referrerProperty = new PropertyLiteral((NodeAttribute)referrerProperty);
     _referencedNode   = referencedNode;
     //_existenceOnly = false;
 }
예제 #10
0
 public ReferenceExpression(ReferenceAttribute referrerProperty)
 {
     _referrerProperty = new PropertyLiteral((NodeAttribute)referrerProperty);
     _existenceOnly    = true;
 }
예제 #11
0
 internal SearchOrder(NodeAttribute propertyToOrder, OrderDirection direction)
 {
     _propertyToOrder = new PropertyLiteral(propertyToOrder);
     _direction       = direction;
 }
예제 #12
0
 private string CompileMaxValue(PropertyLiteral literal)
 {
     return(null);
 }