Search in sources :

Example 11 with Expander

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

the class GuidedRuleDslrFileIndexer method fillIndexBuilder.

@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
    final String dslr = ioService.readAllString(path);
    final Expander expander = getDSLExpander(path);
    final String drl = expander.expand(dslr);
    return fillDrlIndexBuilder(path, drl);
}
Also used : DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) Expander(org.drools.compiler.lang.Expander)

Example 12 with Expander

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

the class GuidedRuleTemplateSourceService method getDSLExpander.

/**
 * Returns an expander for DSLs (only if there is a DSL configured for this package).
 */
private Expander getDSLExpander(final Path path) {
    final Expander expander = new DefaultExpander();
    final List<DSLMappingFile> dsls = getDSLMappingFiles(path);
    for (DSLMappingFile dsl : dsls) {
        expander.addDSLMapping(dsl.getMapping());
    }
    return expander;
}
Also used : DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) Expander(org.drools.compiler.lang.Expander) DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) DSLMappingFile(org.drools.compiler.lang.dsl.DSLMappingFile)

Example 13 with Expander

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

the class GuidedRuleTemplateSourceService method getSource.

@Override
public String getSource(final Path path, final TemplateModel model) throws SourceGenerationFailedException {
    try {
        if (model == null) {
            return "";
        } else {
            final String dslr = RuleTemplateModelDRLPersistenceImpl.getInstance().marshal(model);
            final Expander expander = getDSLExpander(path);
            final String drl = expander.expand(dslr);
            return drl;
        }
    } catch (Exception e) {
        throw new SourceGenerationFailedException(e.getMessage());
    }
}
Also used : SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) Expander(org.drools.compiler.lang.Expander) SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) IOException(java.io.IOException)

Example 14 with Expander

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

the class DslrFileIndexer method getDSLExpander.

/**
 * Returns an expander for DSLs (only if there is a DSL configured for this package).
 */
private Expander getDSLExpander(final Path path) {
    final Expander expander = new DefaultExpander();
    final List<DSLMappingFile> dsls = getDSLMappingFiles(path);
    for (DSLMappingFile dsl : dsls) {
        expander.addDSLMapping(dsl.getMapping());
    }
    return expander;
}
Also used : DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) Expander(org.drools.compiler.lang.Expander) DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) DSLMappingFile(org.drools.compiler.lang.dsl.DSLMappingFile)

Example 15 with Expander

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

the class DslrFileIndexer method fillIndexBuilder.

@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
    final String dslr = ioService.readAllString(path);
    final Expander expander = getDSLExpander(path);
    final String drl = expander.expand(dslr);
    return fillDrlIndexBuilder(path, drl);
}
Also used : DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) Expander(org.drools.compiler.lang.Expander)

Aggregations

Expander (org.drools.compiler.lang.Expander)15 DefaultExpander (org.drools.compiler.lang.dsl.DefaultExpander)12 DSLMappingFile (org.drools.compiler.lang.dsl.DSLMappingFile)7 IOException (java.io.IOException)4 StringReader (java.io.StringReader)3 DefaultExpanderResolver (org.drools.compiler.lang.dsl.DefaultExpanderResolver)3 Test (org.junit.Test)3 SourceGenerationFailedException (org.kie.workbench.common.services.shared.source.SourceGenerationFailedException)3 DSLTokenizedMappingFile (org.drools.compiler.lang.dsl.DSLTokenizedMappingFile)2 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 ArrayList (java.util.ArrayList)1 ExpanderException (org.drools.compiler.lang.ExpanderException)1 DSLSentence (org.drools.workbench.models.datamodel.rule.DSLSentence)1 DSLVariableValue (org.drools.workbench.models.datamodel.rule.DSLVariableValue)1 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)1