Search in sources :

Example 1 with DSLMapping

use of org.drools.compiler.lang.dsl.DSLMapping in project drools-wb by kiegroup.

the class DslFileIndexer method fillIndexBuilder.

@Override
public DefaultIndexBuilder 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:
            }
        }
        final String drl = makeDrl(path, lhs, rhs);
        return fillDrlIndexBuilder(path, drl);
    }
    return null;
}
Also used : DSLMapping(org.drools.compiler.lang.dsl.DSLMapping) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) DSLMappingEntry(org.drools.compiler.lang.dsl.DSLMappingEntry) DSLTokenizedMappingFile(org.drools.compiler.lang.dsl.DSLTokenizedMappingFile)

Aggregations

StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 DSLMapping (org.drools.compiler.lang.dsl.DSLMapping)1 DSLMappingEntry (org.drools.compiler.lang.dsl.DSLMappingEntry)1 DSLTokenizedMappingFile (org.drools.compiler.lang.dsl.DSLTokenizedMappingFile)1