Package hu.sztaki.ilab.longneck.process.block

Examples of hu.sztaki.ilab.longneck.process.block.Sequence


        assertEquals("b2", rec.get("d").getValue());
    }
   
    public static Sequence createBlockRefSuppressErrorSequence(FrameAddressResolver far) {
        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);
       
        // Block 1
        GenericBlock b1 = new GenericBlock();
        b1.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", null, 1, 1, 0));
        b1.setId("b1");
        b1.setVersion("1");
       
        Set b1set = new Set();
        b1set.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 2, 2, 0));
        far.put(b1set);
        b1set.setApplyTo("b");
        b1set.setValue("b1");       
       
        BlockReference br2 = new BlockReference();
        br2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 3, 3, 0));
        far.put(br2);
        br2.setId("pkg1:b2");
        br2.setVersion("1");
       
        Set b1set2 = new Set();
        b1set2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 4, 4, 0));
        far.put(b1set2);
        b1set2.setApplyTo("c");
        b1set2.setValue("b1");
       
        b1.setBlocks(Arrays.asList(new Block[] { b1set, br2, b1set2 }));
       
        // Block 2
        GenericBlock b2 = new GenericBlock();
        b2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", null, 5, 5, 0));
        b2.setId("b2");
        b2.setVersion("1");
       
        Check b2check = new Check();
        b2check.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 6, 6, 0));
        far.put(b2check);
       
        EqualsConstraint equals = new EqualsConstraint();
        equals.setApplyTo("a");
        equals.setValue("xxx");
        b2check.setConstraints(Arrays.asList(new Constraint[] { equals }));
       
        Set b2set = new Set();
        b2set.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 6, 6, 0));
        far.put(b2set);
        b2set.setApplyTo("b");
        b2set.setValue("b2");
       
        Set b2set2 = new Set();
        b2set2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 7, 7, 0));
        far.put(b2set2);
        b2set2.setApplyTo("d");
        b2set2.setValue("b2");
       
        b2.setBlocks(Arrays.asList(new Block[] { b2check, b2set, b2set2 }));
        br2.setReferredBlock(b2);
       
       
        BlockReference br1 = new BlockReference();
        br1.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(br1);
        br1.setId("pkg1:b1");
        br1.setVersion("1");
       
        br1.setReferredBlock(b1);
        seq.setBlocks(Arrays.asList(new Block[] { br1 }));
       
        return seq;      
    }
View Full Code Here


    }

    @Test
    public void testBlockReferenceSupressError() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createBlockRefSuppressErrorSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "bbb"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

        assertFalse("Check that b2 did not set fields", rec.has("d"));
    }

    public static Sequence createBlockRefPropagateErrorSequence(FrameAddressResolver far) {
        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);
       
        // Block 1
        GenericBlock b1 = new GenericBlock();
        b1.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", null, 1, 1, 0));
        b1.setId("b1");
        b1.setVersion("1");
       
        Set b1set = new Set();
        b1set.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 2, 2, 0));
        far.put(b1set);
        b1set.setApplyTo("b");
        b1set.setValue("b1");       
       
        BlockReference br2 = new BlockReference();
        br2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 3, 3, 0));
        far.put(br2);
        br2.setId("pkg1:b2");
        br2.setVersion("1");
        br2.setPropagateFailure(true);
       
        Set b1set2 = new Set();
        b1set2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 4, 4, 0));
        far.put(b1set2);
        b1set2.setApplyTo("c");
        b1set2.setValue("b1");
       
        b1.setBlocks(Arrays.asList(new Block[] { b1set, br2, b1set2 }));
       
        // Block 2
        GenericBlock b2 = new GenericBlock();
        b2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", null, 5, 5, 0));
        b2.setId("b2");
        b2.setVersion("1");
       
        Check b2check = new Check();
        b2check.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 6, 6, 0));
        far.put(b2check);
       
        EqualsConstraint equals = new EqualsConstraint();
        equals.setApplyTo("a");
        equals.setValue("xxx");
        b2check.setConstraints(Arrays.asList(new Constraint[] { equals }));
       
        Set b2set = new Set();
        b2set.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 7, 7, 0));
        far.put(b2set);
        b2set.setApplyTo("b");
        b2set.setValue("b2");
       
        Set b2set2 = new Set();
        b2set2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 8, 8, 0));
        far.put(b2set2);
        b2set2.setApplyTo("d");
        b2set2.setValue("b2");
       
        b2.setBlocks(Arrays.asList(new Block[] { b2check, b2set, b2set2 }));
        br2.setReferredBlock(b2);
       
       
        BlockReference br1 = new BlockReference();
        br1.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(br1);
        br1.setId("pkg1:b1");
        br1.setVersion("1");
       
        br1.setReferredBlock(b1);
        seq.setBlocks(Arrays.asList(new Block[] { br1 }));
       
        return seq;      
    }
View Full Code Here

    }

    @Test
    public void createBlockRefPropagateErrorSequence() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createBlockRefPropagateErrorSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "bbb"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

        assertFalse("Check that b2 did not set fields", rec.has("d"));
    }

    public static Sequence createMatchExtractSequence(FrameAddressResolver far) {
        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);
       
        MatchExtract me = new MatchExtract();
        me.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(me);
       
        me.setApplyTo("a");
        me.setRegexp("^(.)(.)(.)$");
       
        Copy copy1 = new Copy();
        copy1.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 3, 3, 0));
        far.put(copy1);
        copy1.setApplyTo("var1");
        copy1.setFrom("$1");
       
        Copy copy2 = new Copy();
        copy2.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 4, 4, 0));
        far.put(copy1);
        copy2.setApplyTo("var2");
        copy2.setFrom("$2");
       
        Copy copy3 = new Copy();
        copy3.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 5, 5, 0));
        far.put(copy1);
        copy3.setApplyTo("var3");
        copy3.setFrom("$3");

        me.setBlocks(Arrays.asList(new Block[]{copy1, copy2, copy3}));

        seq.setBlocks(Arrays.asList(new Block[]{me}));

        return seq;
    }
View Full Code Here

    }

    @Test
    public void testMatchExtract() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createMatchExtractSequence(far);

        Record rec = new RecordImpl();
        rec.add(new Field("a", "abc"));

        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

    }

    @Test
    public void testFilter() throws FailException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);

        Filter filter = new Filter();
        filter.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(filter);

        seq.setBlocks(Arrays.asList(new Block[]{filter}));

        Record rec = new RecordImpl();
        rec.add(new Field("a", "abc"));

        Kernel kernel = new Kernel(seq, far, null);
View Full Code Here

    }

    @Test
    public void testMapping() throws FailException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createMappingTestSequence1(far);
        List<Record> localCloneQueue = new ArrayList<>();

        Record record = new RecordImpl();
        record.add(new Field("a", "a1"));
View Full Code Here

        assertTrue("Check that another field isn't exist.", record.getFields().size() == 2);
    }

    public static Sequence createMappingTestSequence1(FrameAddressResolver far) {
        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);

        // Block 1
        GenericBlock b1 = new GenericBlock();
        b1.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", null, 1, 1, 0));
        b1.setId("b1");
        b1.setVersion("1");

        Set b1set = new Set();
        b1set.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 2, 2, 0));
        far.put(b1set);
        b1set.setApplyTo("b");
        b1set.setValue("b1");

        BlockReference br2 = new BlockReference();
        br2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 3, 3, 0));
        far.put(br2);
        br2.setId("pkg1:b2");
        br2.setVersion("1");
        Mapping mapping1 = new Mapping();
        Map map1 = new Map();
        map1.setTo("d");
        map1.setFrom("b");
        mapping1.addRule(map1);
        Map map11 = new Map();
        map11.setTo("c");
        map11.setFrom("f");
        mapping1.addRule(map11);
        br2.setMapping(mapping1);

        Set b1set2 = new Set();
        b1set2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 4, 4, 0));
        far.put(b1set2);
        b1set2.setApplyTo("a");
        b1set2.setValue("error");
       
        CloneRecord b1clone = new CloneRecord();
        b1clone.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 5, 5, 0));
        far.put(b1clone);
        b1clone.setFieldName("b");
        b1clone.setFieldValue("b3");

        b1.setBlocks(Arrays.asList(new Block[]{b1set, br2, b1set2, b1clone}));

        // Block 2
        GenericBlock b2 = new GenericBlock();
        b2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", null, 6, 6, 0));
        b2.setId("b2");
        b2.setVersion("1");

        Set b2set = new Set();
        b2set.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 7, 7, 0));
        far.put(b2set);
        b2set.setApplyTo("e");
        b2set.setValue("b2");

        Copy b2copy = new Copy();
        b2copy.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 8, 8, 0));
        far.put(b2copy);
        b2copy.setApplyTo("d");
        b2copy.setFrom("e");

        Set b2set2 = new Set();
        b2set2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 9, 9, 0));
        far.put(b2set2);
        b2set2.setApplyTo("b");
        b2set2.setValue("error");

        Set b2set3 = new Set();
        b2set3.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 10, 10, 0));
        far.put(b2set2);
        b2set3.setApplyTo("a");
        b2set3.setValue("error");

        Set b2set4 = new Set();
        b2set4.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 11, 11, 0));
        far.put(b2set4);
        b2set4.setApplyTo("c");
        b2set4.setValue("ok");
       
        CloneRecord b2clone = new CloneRecord();
        b2clone.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 12, 12, 0));
        far.put(b2clone);

        b2.setBlocks(Arrays.asList(new Block[]{b2set, b2copy, b2set2, b2set3, b2set4, b2clone}));
        br2.setReferredBlock(b2);

        BlockReference br1 = new BlockReference();
        br1.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(br1);
        br1.setId("pkg1:b1");
        br1.setVersion("1");
        Mapping mapping0 = new Mapping();
        Map map0 = new Map();
        map0.setTo("b");
        map0.setFrom("a");
        mapping0.addRule(map0);
        Map map01 = new Map();
        map01.setTo("f");
        map01.setFrom("c");
        mapping0.addRule(map01);
        br1.setMapping(mapping0);

        br1.setReferredBlock(b1);
        seq.setBlocks(Arrays.asList(new Block[]{br1}));

        return seq;
    }
View Full Code Here

TOP

Related Classes of hu.sztaki.ilab.longneck.process.block.Sequence

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.