Codota Logo
DataEnumLoader
Code IndexAdd Codota to your IDE (free)

How to use
DataEnumLoader
in
org.drools.ide.common.server.util

Best Java code snippets using org.drools.ide.common.server.util.DataEnumLoader (Showing top 11 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ArrayList a =
  • Codota Iconnew ArrayList<String>()
  • Codota Iconnew ArrayList()
  • Codota Iconnew ArrayList<Object>()
  • Smart code suggestions by Codota
}
origin: org.chtijbug.drools/droolsjbpm-ide-common

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() );
    }
  }
}
origin: org.drools/droolsjbpm-ide-common

/**
 * This is the source of the asset, which is an MVEL map (minus the outer "[") of course.
 */
public DataEnumLoader(String mvelSource) {
  errors = new ArrayList<String>();
  this.data = loadEnum(mvelSource);
}
origin: org.drools/droolsjbpm-ide-common

@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());
}
origin: org.chtijbug.drools/droolsjbpm-ide-common

  mvelSource = mvelSource.substring(1);
} else {
  mvelSource = "[ " + addCommasForNewLines(mvelSource) + " ]";
  mvelData = MVEL.eval(mvelSource, new HashMap<String, Object>());
} catch (RuntimeException e) {
  addError("Unable to load enumeration data.");
  addError(e.getMessage());
  addError("Error type: " + e.getClass().getName());
  return Collections.emptyMap();
  addError("The expression is not a map, it is a " + mvelData.getClass().getName());
  return Collections.emptyMap();
  if (!(list instanceof List<?> || list instanceof String)) {
    if (list == null) {
      addError("The item with " + key + " is null.");
    } else {
      addError("The item with " + key + " is not a list or a string, it is a " + list.getClass().getName());
origin: org.drools/droolsjbpm-ide-common

@Test
public void testNewLines() {
  String s = "yeah yeah, \nyeah \nyeah";
  assertEquals("yeah yeah,\nyeah,\nyeah", DataEnumLoader.addCommasForNewLines( s ));
}
origin: org.drools/droolsjbpm-ide-common

@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]);
}
origin: org.drools/droolsjbpm-ide-common

  mvelSource = mvelSource.substring(1);
} else {
  mvelSource = "[ " + addCommasForNewLines(mvelSource) + " ]";
  mvelData = MVEL.eval(mvelSource, new HashMap<String, Object>());
} catch (RuntimeException e) {
  addError("Unable to load enumeration data.");
  addError(e.getMessage());
  addError("Error type: " + e.getClass().getName());
  return Collections.emptyMap();
  addError("The expression is not a map, it is a " + mvelData.getClass().getName());
  return Collections.emptyMap();
  if (!(list instanceof List<?> || list instanceof String)) {
    if (list == null) {
      addError("The item with " + key + " is null.");
    } else {
      addError("The item with " + key + " is not a list or a string, it is a " + list.getClass().getName());
origin: org.drools/droolsjbpm-ide-common

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() );
    }
  }
}
origin: org.drools/droolsjbpm-ide-common

@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);
}
origin: org.chtijbug.drools/droolsjbpm-ide-common

/**
 * This is the source of the asset, which is an MVEL map (minus the outer "[") of course.
 */
public DataEnumLoader(String mvelSource) {
  errors = new ArrayList<String>();
  this.data = loadEnum(mvelSource);
}
origin: org.drools/droolsjbpm-ide-common

@Test
@Ignore
public void testEnumGeneration() throws Exception {
  Object result = MVEL.eval("[2, 3, 4, ]", new HashMap());
  assertTrue(result instanceof List);
  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());
}
org.drools.ide.common.server.utilDataEnumLoader

Javadoc

Use mvel to load up map/list of valid items for fields - used by the Guided rule editor.

Most used methods

  • <init>
    This is the source of the asset, which is an MVEL map (minus the outer "[") of course.
  • addCommasForNewLines
  • getData
    Return the map of Fact.field to List (of Strings).
  • getErrors
    Return a list of any errors found.
  • hasErrors
  • addError
  • loadEnum

Popular in Java

  • Reading from database using SQL prepared statement
  • setScale (BigDecimal)
  • getContentResolver (Context)
  • setContentView (Activity)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • BoxLayout (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now