Package org.drools.guvnor.server.util

Examples of org.drools.guvnor.server.util.DataEnumLoader


    }

    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.guvnor.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


        assertEquals("yeah yeah,\nyeah,\nyeah", DataEnumLoader.addCommasForNewLines( s ));
    }

    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

public class EnumerationContentHandler extends PlainTextContentHandler implements IValidating {

    public BuilderResult[] validateAsset(AssetItem asset) {

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


            for ( Iterator iter = errs.iterator(); iter.hasNext(); ) {

                BuilderResult result = new BuilderResult();
View Full Code Here

    }

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

    }
View Full Code Here

TOP

Related Classes of org.drools.guvnor.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.