Examples of DSLMappingFile


Examples of org.drools.lang.dsl.DSLMappingFile

  private DefaultExpanderResolver resolveDSLFiles() throws IOException {

    DefaultExpanderResolver resolver = new DefaultExpanderResolver();
    final File dir = new File(this.srcdir.getAbsolutePath());
    DSLMappingFile file = new DSLMappingFile();

    FilenameFilter filter = new FilenameFilter() {
      public boolean accept(File dir, String name) {
        return name.endsWith(".dsl");
      }
    };

    String[] children = dir.list(filter);
    if (children.length == 0) {
      throw new BuildException(
          "There are no DSL files for this directory:"
              + this.srcdir.getAbsolutePath());
    }

    for (int index = 0; index < children.length; index++) {
      if (file.parseAndLoad(new StringReader(loadResource(children[index])))) {
        final Expander expander = new DefaultExpander();
        expander.addDSLMapping(file.getMapping());
        resolver.addExpander("*", expander);
      } else {
        throw new RuntimeDroolsException(
            "Error parsing and loading DSL file."
                + file.getErrors());
      }
    }

    return resolver;
  }
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingFile

       
       
        DefaultExpanderResolver resolver = new DefaultExpanderResolver(new StringReader(dsl));
       
       
        final DSLMappingFile file = new DSLTokenizedMappingFile();
        if ( file.parseAndLoad( new StringReader(dsl) ) ) {
            final Expander expander = new DefaultExpander();
            expander.addDSLMapping( file.getMapping() );
            resolver.addExpander("*", expander);
        } else {
            throw new RuntimeDroolsException( "Error parsing and loading DSL file." + file.getErrors() );
        }

        DrlParser parser = new DrlParser();
        String result = parser.getExpandedDRL( drl, resolver);
        assertEqualsIgnoreWhitespace( "rule 'foo' \n when \n Something() \n then \n another(); \nend", result );
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingFile

    private DefaultExpanderResolver resolveDSLFiles() throws IOException {

        DefaultExpanderResolver resolver = new DefaultExpanderResolver();
        final File dir = new File( this.srcdir.getAbsolutePath() );
        DSLMappingFile file = new DSLTokenizedMappingFile();

        FilenameFilter filter = new FilenameFilter() {
            public boolean accept(File dir,
                                  String name) {
                return name.endsWith( ".dsl" );
            }
        };

        String[] children = dir.list( filter );
        if ( children.length == 0 ) {
            throw new BuildException( "There are no DSL files for this directory:" + this.srcdir.getAbsolutePath() );
        }

        for ( int index = 0; index < children.length; index++ ) {
            if ( file.parseAndLoad( new StringReader( loadResource( children[index] ) ) ) ) {
                final Expander expander = new DefaultExpander();
                expander.addDSLMapping( file.getMapping() );
                resolver.addExpander( "*",
                                      expander );
            } else {
                throw new RuntimeDroolsException( "Error parsing and loading DSL file." + file.getErrors() );
            }
        }

        return resolver;
    }
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingFile

                String content = dslRuleEditor.getContent();
                Reader reader = DSLAdapter.getDSLContent(content, dslRuleEditor.getResource());
                if (reader == null) {
                    throw new IllegalArgumentException("Could not find dsl definition.");
                }
                DSLMappingFile mapping = new DSLTokenizedMappingFile();
                mapping.parseAndLoad(reader);
                reader.close();
                expander.addDSLMapping(mapping.getMapping());
                expander.expand(content);
                // if translation succeeds, change to drl viewer
                drlRuleViewer.setInput(getEditorInput());
                drlRuleViewer.setSelectedRange(selection);
            } catch (Throwable t) {
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingFile

    protected String transformInput(String content) {
        DefaultExpander expander = new DefaultExpander();
        try {
            Reader reader = DSLAdapter.getDSLContent(content, viewer.getResource());
            DSLMappingFile mapping = new DSLTokenizedMappingFile();
            mapping.parseAndLoad(reader);
            reader.close();
            expander.addDSLMapping(mapping.getMapping());
            return expander.expand(content);
        } catch (Throwable t) {
            //viewer.handleError(t);
            return content;
        }
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingFile

                IStorageEditorInput input = (IStorageEditorInput) editorInput;
                stream = input.getStorage().getContents();
            }

            model = new NLGrammarModel();
            DSLMappingFile file = new DSLTokenizedMappingFile();
            file.parseAndLoad( new InputStreamReader( stream ) );
            model.addEntries( file.getMapping().getEntries() );
            stream.close();

        } catch ( CoreException e ) {
            throw new IllegalStateException( "Unable to load DSL configuration file. (CoreException: " + e.getMessage() + ")" );
        } catch ( IOException e ) {
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingFile

        // e.getMessage() );
        // }
        // }

        for ( final Iterator it = dsls.iterator(); it.hasNext(); ) {
            final DSLMappingFile file = (DSLMappingFile) it.next();
            final DSLMapping mapping = file.getMapping();
            for ( final Iterator entries = mapping.getEntries().iterator(); entries.hasNext(); ) {
                final DSLMappingEntry entry = (DSLMappingEntry) entries.next();
                if ( entry.getSection() == DSLMappingEntry.CONDITION ) {
                    this.builder.addDSLConditionSentence( entry.getMappingKey() );
                } else if ( entry.getSection() == DSLMappingEntry.CONSEQUENCE ) {
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingFile

    private DefaultExpanderResolver resolveDSLFiles() throws IOException {

        DefaultExpanderResolver resolver = new DefaultExpanderResolver();
        final File dir = new File(this.srcdir.getAbsolutePath());
        DSLMappingFile file = new DSLTokenizedMappingFile();

        FilenameFilter filter = new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.endsWith(".dsl");
            }
        };

        String[] children = dir.list(filter);
        if (children.length == 0) {
            throw new BuildException(
                    "There are no DSL files for this directory:"
                            + this.srcdir.getAbsolutePath());
        }

        for (int index = 0; index < children.length; index++) {
            if (file.parseAndLoad(new StringReader(
                    loadResource(children[index])))) {
                final Expander expander = new DefaultExpander();
                expander.addDSLMapping(file.getMapping());
                resolver.addExpander("*", expander);
            } else {
                throw new RuntimeDroolsException(
                        "Error parsing and loading DSL file."
                                + file.getErrors());
            }
        }

        return resolver;
    }
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingFile

        // e.getMessage() );
        // }
        // }

        for ( final Iterator it = dsls.iterator(); it.hasNext(); ) {
            final DSLMappingFile file = (DSLMappingFile) it.next();
            final DSLMapping mapping = file.getMapping();
            for ( final Iterator entries = mapping.getEntries().iterator(); entries.hasNext(); ) {
                final DSLMappingEntry entry = (DSLMappingEntry) entries.next();
                if ( entry.getSection() == DSLMappingEntry.CONDITION ) {
                    this.builder.addDSLConditionSentence( entry.getMappingKey() );
                } else if ( entry.getSection() == DSLMappingEntry.CONSEQUENCE ) {
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingFile

       
       
        DefaultExpanderResolver resolver = new DefaultExpanderResolver(new StringReader(dsl));
       
       
        final DSLMappingFile file = new DSLTokenizedMappingFile();
        if ( file.parseAndLoad( new StringReader(dsl) ) ) {
            final Expander expander = new DefaultExpander();
            expander.addDSLMapping( file.getMapping() );
            resolver.addExpander("*", expander);
        } else {
            throw new RuntimeDroolsException( "Error parsing and loading DSL file." + file.getErrors() );
        }       

        DrlParser parser = new DrlParser();
        String result = parser.getExpandedDRL( drl, resolver);
        assertEqualsIgnoreWhitespace( "rule 'foo' \n when \n Something() \n then \n another(); \nend", result );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.