Example #1
0
        private Query CompileReferenceExpressionNode(ReferenceExpression expression)
        {
            if (expression.Expression != null)
                throw new NotImplementedException();

            var leftName = CompileLeftValue(expression.ReferrerProperty);

            if (expression.ExistenceOnly)
            {
                // not null --> not empty --> -(name:)
                var boolQuery = new BooleanQuery();
                boolQuery.Add(new BooleanClause(new TermQuery(new Term(leftName)), BooleanClause.Occur.MUST_NOT));
                return boolQuery;
            }
            //if (!expression.ReferrerProperty.IsSlot)
            //{
            //    // simple nodeid
            //    return new TermQuery(new Term(leftName, ValueFormatter.Format(DataType.Int, expression.ReferencedNode.Id)[0]));
            //}
            //// reference slot
            //return new TermQuery(new Term(leftName, ValueFormatter.Format(DataType.Reference, new int[] { expression.ReferencedNode.Id })));
            //<##>
            //return new TermQuery(new Term(leftName, ValueFormatter.Format(DataType.Int, expression.ReferencedNode.Id)[0]));
            return new TermQuery(new Term(leftName, expression.ReferencedNode.Id.ToString()));
            //</##>
        }
Example #2
0
 public void ReferenceExpression_Constuctor_NullExpr()
 {
     ReferenceExpression refExp = new ReferenceExpression(ReferenceAttribute.Parent, (Expression)null);
 }
Example #3
0
        public void ReferenceExpression_Constuctor()
        {
            PropertyType slot = new SchemaEditor().CreatePropertyType("slot", DataType.Reference);
            SearchExpression exp = new SearchExpression("FullTextExpression");
            Node node = Repository.Root;

            ReferenceExpression refExp;

            refExp = new ReferenceExpression(ReferenceAttribute.Parent);
            refExp = new ReferenceExpression(slot);
            refExp = new ReferenceExpression(ReferenceAttribute.Parent, exp);
            refExp = new ReferenceExpression(slot, exp);
            refExp = new ReferenceExpression(ReferenceAttribute.Parent, node);
            refExp = new ReferenceExpression(slot, node);
        }
Example #4
0
 public void ReferenceExpression_Constuctor_WrongLeftValue()
 {
     PropertyType slot = new SchemaEditor().CreatePropertyType("slot", DataType.String);
     ReferenceExpression refExp = new ReferenceExpression(slot);
 }
Example #5
0
        //-- Test helper ---------------------------------------------------------------------

        private static NodeQuery CreateComplexQuery()
        {
            //	(
            //		Node.Doughter.Father.Name = "Adam"
            //		Or
            //		Node.Doughter.Mother.Name = "Adam"
            //	)
            //	Or
            //	(
            //		Node.Son.Father.Name = "Adam"
            //		Or
            //		Node.Son.Mother.Name = "Adam"
            //	)

            PropertyType motherSlot = ActiveSchema.PropertyTypes["Mother"];
            PropertyType fatherSlot = ActiveSchema.PropertyTypes["Father"];
            PropertyType daughterSlot = ActiveSchema.PropertyTypes["Daughter"];
            PropertyType sonSlot = ActiveSchema.PropertyTypes["Son"];

            StringExpression nameExp1 = new StringExpression(StringAttribute.Name, StringOperator.Equal, "Adam");

            ReferenceExpression refExp1 = new ReferenceExpression(fatherSlot, nameExp1);
            ReferenceExpression refExp2 = new ReferenceExpression(motherSlot, nameExp1);
            ExpressionList orList1 = new ExpressionList(ChainOperator.Or);
            orList1.Add(refExp1);
            orList1.Add(refExp2);

            ReferenceExpression refExp3 = new ReferenceExpression(daughterSlot, orList1);
            ReferenceExpression refExp4 = new ReferenceExpression(sonSlot, orList1);
            ExpressionList orList2 = new ExpressionList(ChainOperator.Or);
            orList2.Add(refExp3);
            orList2.Add(refExp4);

            ExpressionList orList3 = new ExpressionList(ChainOperator.Or);
            orList3.Add(refExp3);
            orList3.Add(refExp4);

            NodeQuery query = new NodeQuery();
            query.Add(orList3);
            return query;
        }