Package org.drools.ide.common.server.util

Examples of org.drools.ide.common.server.util.DataEnumLoader


    private void populateDateEnums(List<String> dataEnums,
                                   SuggestionCompletionEngine sce) {
        for ( Iterator<String> iter = dataEnums.iterator(); iter.hasNext(); ) {
            String enumFile = iter.next();
            DataEnumLoader enumLoader = new DataEnumLoader( enumFile );
            if ( enumLoader.hasErrors() ) {
                this.errors.addAll( enumLoader.getErrors() );
            } else {
                sce.putAllDataEnumLists( enumLoader.getData() );
            }
        }

    }
View Full Code Here


    private void populateDateEnums(List<String> dataEnums,
                                   SuggestionCompletionEngine sce) {
        for ( Iterator<String> iter = dataEnums.iterator(); iter.hasNext(); ) {
            String enumFile = iter.next();
            DataEnumLoader enumLoader = new DataEnumLoader( enumFile );
            if ( enumLoader.hasErrors() ) {
                this.errors.addAll( enumLoader.getErrors() );
            } else {
                sce.putAllDataEnumLists( enumLoader.getData() );
            }
        }

    }
View Full Code Here

        return builder.getInstance();
    }

    private void populateDateEnums(List<String> dataEnums) {
        for ( String enumFile : dataEnums ) {
            DataEnumLoader enumLoader = new DataEnumLoader( enumFile );
            if ( enumLoader.hasErrors() ) {
                errors.addAll( enumLoader.getErrors() );
            } else {
                builder.addAllDataEnumsList( enumLoader.getData() );
            }
        }
    }
View Full Code Here

        List l = (List) result;
        assertEquals(3, l.size());

        result = MVEL.eval("['Person.age' : [2, 3]\n, 'Person.name' : ['qqq', \n'ccc']]", new HashMap());

        DataEnumLoader loader = new DataEnumLoader(readLines().toString());

        assertFalse(loader.getErrors().toString(), loader.hasErrors());

        Map enumeration = (Map) loader.getData();
        assertEquals(loader.getErrors().toString(), 0, loader.getErrors().size());
        assertEquals(3, enumeration.size());

        String[] list = (String[]) enumeration.get("Person.age");
        assertEquals(4, list.length);
        assertEquals("1", list[0]);
        assertEquals("2", list[1]);

        list = (String[]) enumeration.get("Person.rating");
        assertEquals(2, list.length);
        assertEquals("High", list[0]);
        assertEquals("Low", list[1]);

        loader = new DataEnumLoader("goober poo error");
        assertEquals(0, loader.getData().size());
        assertFalse(loader.getErrors().size() == 0);
        assertTrue(loader.hasErrors());

    }
View Full Code Here

    }

    @Test
    public void testNoOp() {
        DataEnumLoader loader = new DataEnumLoader(" ");
        assertFalse(loader.hasErrors());
        assertEquals(0, loader.getData().size());

        loader = new DataEnumLoader("");
        assertFalse(loader.hasErrors());
        assertEquals(0, loader.getData().size());

    }
View Full Code Here

    }

    @Test
    public void testLiteralHelperUtilityClass() {
        //this shows how you can load it up with a class (which should return a map of keys to List.
        DataEnumLoader loader = new DataEnumLoader("=(new org.drools.ide.common.modeldriven.SampleDataSource2()).loadData()");

        assertFalse(loader.hasErrors());

        assertEquals(1, loader.getData().size());
        String[] res = (String[]) loader.getData().get("whee");
        assertEquals(2, res.length);
        assertEquals("hey", res[0]);
        assertEquals("ho", res[1]);

    }
View Full Code Here

    }

    @Test
    public void testLazyString() {
        //in this case we are dealing with an expression which will not be resolved at load time.
        DataEnumLoader loader = new DataEnumLoader("'Person.type[sex]' : 'something @{sex}'");
        assertFalse(loader.hasErrors());

        Map data = loader.getData();
        String[] sl = (String[]) data.get("Person.type[sex]");
        String s = sl[0];
        assertEquals("something @{sex}", s);
        Map context = new HashMap() {{ put("sex", "cool"); }};

        Object r = TemplateRuntime.eval(s, context);

        assertEquals("something cool", r);

        loader = new DataEnumLoader("'Person.type[sex, money]' : '@{sex} @{money}'");
        assertFalse(loader.hasErrors());

        sl = (String[]) loader.getData().get("Person.type[sex, money]");
        s = sl[0];
        assertEquals("@{sex} @{money}", s);

    }
View Full Code Here

        IHasCustomValidator {

    public BuilderResult validateAsset(AssetItem asset) {

        String content = asset.getContent();
        DataEnumLoader loader = new DataEnumLoader( content );
        if ( !loader.hasErrors() ) {
            return new BuilderResult();
        } else {
            List<BuilderResultLine> errors = new ArrayList<BuilderResultLine>();
            List<String> errs = loader.getErrors();

            for ( String message : errs ) {

                BuilderResultLine result = new BuilderResultLine();
                result.setAssetName(asset.getName());
View Full Code Here

    IValidating {

    public BuilderResult validateAsset(AssetItem asset) {

        String content = asset.getContent();
        DataEnumLoader loader = new DataEnumLoader( content );
        if ( !loader.hasErrors() ) {
            return new BuilderResult();
        } else {
            List<BuilderResultLine> errors = new ArrayList<BuilderResultLine>();
            List<String> errs = loader.getErrors();

            for ( String message : errs ) {

                BuilderResultLine result = new BuilderResultLine();
                result.assetName = asset.getName();
View Full Code Here

        }
    }

    public BuilderResult validateAsset(RuleAsset asset) {
        String content = ((RuleContentText) asset.content).content;
        DataEnumLoader loader = new DataEnumLoader( content );
        if ( !loader.hasErrors() ) {
            return new BuilderResult();
        } else {
            List<BuilderResultLine> errors = new ArrayList<BuilderResultLine>();
            List<String> errs = loader.getErrors();

            for ( String message : errs ) {

                BuilderResultLine result = new BuilderResultLine();
                result.assetName = asset.metaData.name;
View Full Code Here

TOP

Related Classes of org.drools.ide.common.server.util.DataEnumLoader

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.