Package com.hp.jena.ymris.deploy.local

Examples of com.hp.jena.ymris.deploy.local.BindingSink


    public BindingSink translate( TranslationContext c, final BindingSink sink )
        {
        final int size = c.bindingSize();
        List<YTriple> triples = this.premise.triples;
        final int offset = c.varOffset( id );
        BindingSink select = new BindingSink()
            {
            protected final Set<Node> elements = new HashSet<Node>();
           
            @Override public void finish()
                {
View Full Code Here


   
    @Override public void rebind()
        {
        RuleSet ruleSet = reasoner.ruleSet;
        deductions.getBulkUpdateHandler().removeAll();
        BindingSink output = new BindingSink()
            {           
            @Override public void consume( Node[] item )
                { deductions.add( asTriple( item ) ); }

            private Triple asTriple( Node[] item )
                { return Triple.create( item[1], item[2], item[3] ); }
            };
        BindingSink input = ruleSet.toCode( reasoner.getHowTo( this ), output );
        input.start();
        for (Iterator<Triple> it = base.find( Triple.ANY ); it.hasNext();)
            input.consume( asBinding( it.next() ) );
        }
View Full Code Here

    protected final List<Node> nodes = new ArrayList<Node>();
   
    @Test public void testActionWithConclusion()
        {
        String rules = "RULE { ?x <eh:/P> ?y } => DO spoo(?x, ?y) { ?x a <eh:/PD> }";
        BindingSink in = rulesToDeployment( sink, rules, new A( nodes ) );
    //
        in.consume( nodeArray( "X S P O" ) );
        assertEquals( bindings( "S rdf:type PD" ), sink.bindings );
        assertEquals( bindings( "S O" ).get( 0 ), nodes );
        }
View Full Code Here

        }
       
    @Test public void testActionWithEmptyConclusion()
        {
        String rules = "RULE { ?x <eh:/P> ?y } => DO spoo(?x, ?y) {}";
        BindingSink in = rulesToDeployment( sink, rules, new A( nodes ) );
    //
        in.consume( GraphTestBase.nodeArray( "X S P O" ) );
        assertEquals( bindings( "" ), sink.bindings );
        assertEquals( bindings( "S O" ).get( 0 ), nodes );
        }
View Full Code Here

   
    @Test public void testLessThan()
        {
        LogBindings sink = new LogBindings();
        String rules = "RULE { ?x <eh:/P> ?y FILTER 1 > 0 } => { <eh:/P> a <eh:/Neg>  }";
        BindingSink in = Utils.rulesToDeployment( sink, rules, howTo );
    //
        in.consume( GraphTestBase.nodeArray( "X 1 P '-1'xsd:integer" ) );
        assertEquals( Utils.bindings( "P rdf:type Neg" ), sink.bindings );
        }
View Full Code Here

        }

    public static BindingSink rulesToDeployment( BindingSink sink, String rules, HowTo h )
        {
        RuleSet ruleSet = parseRuleSet( rules ).ruleSets().get( 0 );
        BindingSink result = ruleSet.toCode( h, sink );
        result.start();
        return result;
        }
View Full Code Here

    @Test public void testAndFilters()
        {
        String rules =
            "RULE { ?x ?P ?y FILTER ?x = <eh:/x> && ?y = <eh:/y> } => { ?P <eh:/is> <eh:/xy> }";
        BindingSink in = Utils.rulesToDeployment( sink, rules );
    //
        in.consume( nodeArray( "X x P y" ) );
        assertEquals( bindings( "P is xy" ), sink.bindings );
        }
View Full Code Here

    @Test public void testOrFilters()
        {
        String rules =
            "RULE { ?x ?P ?y FILTER (?x = <eh:/x>) || (?y = <eh:/y>) } => { ?P <eh:/is> <eh:/xory> }"
            + " ";
        BindingSink in = Utils.rulesToDeployment( sink, rules );
    //
        in.consume( nodeArray( "X x P z" ) );
        in.consume( nodeArray( "X z Q y" ) );
        in.consume( nodeArray( "X x R y" ) );
        in.consume( nodeArray( "X z S z" ) );
        assertEquals( bindings( "P is xory; Q is xory; R is xory" ), sink.bindings );
        }
View Full Code Here

    @Test public void testPlainUnless()
        {
        LogBindings sink = new LogBindings();
        Graph given = GraphTestBase.graphWith( "b Q c" );
        String rules = "RULE { ?a <eh:/P> ?b UNLESS ?b <eh:/Q> ?c } => { ?a a <eh:/UnQed-b> }";
        BindingSink in = Utils.rulesToDeployment( sink, rules, new MyHowTo( given ) );
    //
        in.consume( GraphTestBase.nodeArray( "X a P b" ) );
        in.consume( GraphTestBase.nodeArray( "X b Q c" ) );
        in.consume( GraphTestBase.nodeArray( "X x P y" ) );
        assertEquals( Utils.bindings( "x rdf:type UnQed-b" ), sink.bindings );
        }
View Full Code Here

    @Test public void testUnlessWithFilter()
        {
        LogBindings sink = new LogBindings();
        Graph given = GraphTestBase.graphWith( "b Q 1; y Q 2" );
        String rules = "RULE { ?a <eh:/P> ?b UNLESS GIVEN { ?b <eh:/Q> ?c FILTER ?c = 1 } } => { ?a a <eh:/UnQed-b> }";
        BindingSink in = Utils.rulesToDeployment( sink, rules, new MyHowTo( given ) );
    //
        in.consume( GraphTestBase.nodeArray( "X a P b" ) );
        in.consume( GraphTestBase.nodeArray( "X x P y" ) );
        assertEquals( Utils.bindings( "x rdf:type UnQed-b" ), sink.bindings );
        }
View Full Code Here

TOP

Related Classes of com.hp.jena.ymris.deploy.local.BindingSink

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.