congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
DSLMapping.getEntries
Code IndexAdd Tabnine to your IDE (free)

How to use
getEntries
method
in
org.drools.compiler.lang.dsl.DSLMapping

Best Java code snippets using org.drools.compiler.lang.dsl.DSLMapping.getEntries (Showing top 15 results out of 315)

origin: org.drools/drools-compiler

private DSLMappingEntry createEntry(final String inputKey,
                  final String inputValue) throws IOException {
  String mapping = "[condition][]" + inputKey + "=" + inputValue;
  StringReader dsl = new StringReader( mapping );
  DSLMappingEntry entry = null;
  try {
    DSLTokenizedMappingFile parser = new DSLTokenizedMappingFile();
    if ( parser.parseAndLoad( dsl ) ) {
      entry = parser.getMapping().getEntries().get( 0 );
    } else {
      throw new RuntimeException( "Error parsing entry: " + mapping + ": " + parser.getErrors().toString() );
    }
  } finally {
    dsl.close();
  }
  return entry;
}
origin: org.drools/drools-compiler

  @Test
  public void testMe() throws Exception{
    DSLTokenizedMappingFile tokenizedFile = null;
    final String filename = "test_antlr.dsl";
    final Reader reader = new InputStreamReader( this.getClass().getResourceAsStream( filename ) );
    tokenizedFile = new DSLTokenizedMappingFile();
    tokenizedFile.parseAndLoad( reader );
    reader.close();
    for (Iterator it = tokenizedFile.getMapping().getEntries().iterator(); it.hasNext();) {
      DSLMappingEntry entry = (DSLMappingEntry) it.next();
//            System.out.println("ENTRY: " + entry.getKeyPattern() + "   :::::   " + entry.getValuePattern());
    }
    
    DefaultExpander ex = new DefaultExpander();
    ex.addDSLMapping( tokenizedFile.getMapping() );
    
    System.err.println(ex.expand( "rule 'x' \n when \n address is present where name is \"foo\" and age is \"32\" \n then \n end" ));
  }

origin: org.drools/drools-compiler

@Test
public void testParseFile() {
  try {
    final Reader reader = new InputStreamReader( this.getClass().getResourceAsStream( this.filename ) );
    this.file = new DSLTokenizedMappingFile();
    final boolean parsingResult = this.file.parseAndLoad( reader );
    reader.close();
    assertTrue( this.file.getErrors().toString(),
          parsingResult );
    assertTrue( this.file.getErrors().isEmpty() );
    assertEquals( 31,
           this.file.getMapping().getEntries().size() );
  } catch ( final IOException e ) {
    e.printStackTrace();
    fail( "Should not raise exception " );
  }
}
origin: org.drools/drools-compiler

@Test
public void testParseFile() {
  try {
    final Reader reader = new InputStreamReader( this.getClass().getResourceAsStream( this.filename ) );
    this.file = new DSLTokenizedMappingFile();
    final boolean parsingResult = this.file.parseAndLoad( reader );
    reader.close();
    assertTrue( this.file.getErrors().toString(),
          parsingResult );
    assertTrue( this.file.getErrors().isEmpty() );
    assertEquals( 31,
           this.file.getMapping().getEntries().size() );
  } catch ( final IOException e ) {
    e.printStackTrace();
    fail( "Should not raise exception " );
  }
}
origin: org.drools/drools-compiler

@Test
public void testParseFileWithBrackets() {
  String file = "[when]ATTRIBUTE \"{attr}\" IS IN [{list}]=Attribute( {attr} in ({list}) )";
  try {
    final Reader reader = new StringReader( file );
    this.file = new DSLTokenizedMappingFile();
    final boolean parsingResult = this.file.parseAndLoad( reader );
    reader.close();
    assertTrue( this.file.getErrors().toString(),
          parsingResult );
    assertTrue( this.file.getErrors().isEmpty() );
    assertEquals( 1,
           this.file.getMapping().getEntries().size() );
    DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
    assertEquals( DSLMappingEntry.CONDITION,
           entry.getSection() );
    assertEquals( DSLMappingEntry.EMPTY_METADATA,
           entry.getMetaData() );
    assertEquals( lookbehind + "ATTRIBUTE\\s+\"(.*?)\"\\s+IS\\s+IN\\s+[(.*?)](?=\\W|$)",
           entry.getKeyPattern().toString() );
    //Attribute( {attr} in ({list}) )
    assertEquals( "Attribute( {attr} in ({list}) )",
           entry.getValuePattern() );
  } catch ( final IOException e ) {
    e.printStackTrace();
    fail( "Should not raise exception " );
  }
}
origin: org.drools/drools-compiler

       this.file.getMapping().getEntries().size() );
DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
origin: org.drools/drools-compiler

@Test
public void testParseFileWithEscaptedBrackets() {
  String file = "[when]ATTRIBUTE \"{attr}\" IS IN \\[{list}\\]=Attribute( {attr} in ({list}) )";
  try {
    final Reader reader = new StringReader( file );
    this.file = new DSLTokenizedMappingFile();
    final boolean parsingResult = this.file.parseAndLoad( reader );
    reader.close();
    assertTrue( this.file.getErrors().toString(),
          parsingResult );
    assertTrue( this.file.getErrors().isEmpty() );
    assertEquals( 1,
           this.file.getMapping().getEntries().size() );
    DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
    assertEquals( DSLMappingEntry.CONDITION,
           entry.getSection() );
    assertEquals( DSLMappingEntry.EMPTY_METADATA,
           entry.getMetaData() );
    
    assertEquals( lookbehind + "ATTRIBUTE\\s+\"(.*?)\"\\s+IS\\s+IN\\s+\\[(.*?)\\](?=\\W|$)",
           entry.getKeyPattern().toString() );
    //Attribute( {attr} in ({list}) )
    assertEquals( "Attribute( {attr} in ({list}) )",
           entry.getValuePattern() );
  } catch ( final IOException e ) {
    e.printStackTrace();
    fail( "Should not raise exception " );
  }
}
origin: org.drools/drools-compiler

@Test
public void testParseFileWithEscaptedBrackets() {
  String file = "[when][]ATTRIBUTE \"{attr}\" IS IN \\[{list}\\]=Attribute( {attr} in ({list}) )";
  try {
    final Reader reader = new StringReader( file );
    this.file = new DSLTokenizedMappingFile();
    final boolean parsingResult = this.file.parseAndLoad( reader );
    reader.close();
    assertTrue( this.file.getErrors().toString(),
          parsingResult );
    assertTrue( this.file.getErrors().isEmpty() );
    assertEquals( 1,
           this.file.getMapping().getEntries().size() );
    DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
    assertEquals( DSLMappingEntry.CONDITION,
           entry.getSection() );
    assertEquals( DSLMappingEntry.EMPTY_METADATA,
           entry.getMetaData() );
    assertEquals( "ATTRIBUTE \"{attr}\" IS IN \\[{list}\\]",
           entry.getMappingKey() );
    assertEquals( "Attribute( {attr} in ({list}) )",
           entry.getMappingValue() );
  } catch ( final IOException e ) {
    e.printStackTrace();
    fail( "Should not raise exception " );
  }
}
origin: org.drools/drools-compiler

       this.file.getMapping().getEntries().size() );
DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
origin: org.drools/drools-compiler

@Test @Ignore
public void testParseFileWithEscaptedEquals() {
  String file = "[when][]something:\\={value}=Attribute( something == \"{value}\" )";
  try {
    final Reader reader = new StringReader( file );
    this.file = new DSLTokenizedMappingFile();
    final boolean parsingResult = this.file.parseAndLoad( reader );
    reader.close();
    assertTrue( this.file.getErrors().toString(),
          parsingResult );
    assertTrue( this.file.getErrors().isEmpty() );
    assertEquals( 1,
           this.file.getMapping().getEntries().size() );
    DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
    assertEquals( DSLMappingEntry.CONDITION,
           entry.getSection() );
    assertEquals( DSLMappingEntry.EMPTY_METADATA,
           entry.getMetaData() );
    assertEquals( "something:={value}",
           entry.getMappingKey() );
    assertEquals( "Attribute( something == \"{value}\" )",
           entry.getMappingValue() );
  } catch ( final IOException e ) {
    e.printStackTrace();
    fail( "Should not raise exception " );
  }
}
origin: org.drools/drools-compiler

       this.file.getMapping().getEntries().size() );
DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
origin: org.drools/drools-wb-dsl-text-editor-backend

@Override
public IndexBuilder fillIndexBuilder(final Path path) throws Exception {
  final List<String> lhs = new ArrayList<String>();
  final List<String> rhs = new ArrayList<String>();
  final String dsl = ioService.readAllString(path);
  //Construct a dummy DRL file to parse index elements
  final DSLTokenizedMappingFile dslLoader = new DSLTokenizedMappingFile();
  if (dslLoader.parseAndLoad(new StringReader(dsl))) {
    DSLMapping dslMapping = dslLoader.getMapping();
    for (DSLMappingEntry e : dslMapping.getEntries()) {
      switch (e.getSection()) {
        case CONDITION:
          lhs.add(e.getValuePattern());
          break;
        case CONSEQUENCE:
          rhs.add(e.getValuePattern());
          break;
        default:
          // no-op
      }
    }
    final String drl = makeDrl(path,
                  lhs,
                  rhs);
    return fillDrlIndexBuilder(path,
                  drl);
  }
  return null;
}
origin: kiegroup/drools-wb

@Override
public IndexBuilder fillIndexBuilder(final Path path) throws Exception {
  final List<String> lhs = new ArrayList<String>();
  final List<String> rhs = new ArrayList<String>();
  final String dsl = ioService.readAllString(path);
  //Construct a dummy DRL file to parse index elements
  final DSLTokenizedMappingFile dslLoader = new DSLTokenizedMappingFile();
  if (dslLoader.parseAndLoad(new StringReader(dsl))) {
    DSLMapping dslMapping = dslLoader.getMapping();
    for (DSLMappingEntry e : dslMapping.getEntries()) {
      switch (e.getSection()) {
        case CONDITION:
          lhs.add(e.getValuePattern());
          break;
        case CONSEQUENCE:
          rhs.add(e.getValuePattern());
          break;
        default:
          // no-op
      }
    }
    final String drl = makeDrl(path,
                  lhs,
                  rhs);
    return fillDrlIndexBuilder(path,
                  drl);
  }
  return null;
}
origin: kiegroup/drools-wb

try {
  if (dslLoader.parseAndLoad(new StringReader(content))) {
    for (DSLMappingEntry entry : dslLoader.getMapping().getEntries()) {
      if (entry.getSection() == DSLMappingEntry.CONDITION) {
        final DSLMappingEntry definition = entry;
origin: org.kie.guvnor/guvnor-datamodel-backend

private void populateDSLSentences( final DSLTokenizedMappingFile dslLoader ) {
  for ( DSLMappingEntry entry : dslLoader.getMapping().getEntries() ) {
    if ( entry.getSection() == DSLMappingEntry.CONDITION ) {
      addDSLConditionSentence( entry.getMappingKey() );
    } else if ( entry.getSection() == DSLMappingEntry.CONSEQUENCE ) {
      addDSLActionSentence( entry.getMappingKey() );
    } else if ( entry.getSection() == DSLMappingEntry.KEYWORD ) {
      addDSLKeywordMapping( entry.getMappingKey() );
    } else if ( entry.getSection() == DSLMappingEntry.ANY ) {
      addDSLAnyScopeMapping( entry.getMappingKey() );
    }
  }
}
org.drools.compiler.lang.dslDSLMappinggetEntries

Popular methods of DSLMapping

    Popular in Java

    • Finding current android device location
    • putExtra (Intent)
    • compareTo (BigDecimal)
    • setRequestProperty (URLConnection)
    • Table (com.google.common.collect)
      A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
    • SocketTimeoutException (java.net)
      This exception is thrown when a timeout expired on a socket read or accept operation.
    • Map (java.util)
      A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
    • Collectors (java.util.stream)
    • XPath (javax.xml.xpath)
      XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
    • SAXParseException (org.xml.sax)
      Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
    • Top 17 Plugins for Android Studio
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now