use of org.drools.compiler.lang.Expander in project drools-wb by kiegroup.
the class GuidedRuleDSLRSourceService 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;
}
use of org.drools.compiler.lang.Expander in project drools-wb by kiegroup.
the class GuidedRuleDslrFileIndexer method getDSLExpander.
/**
* Returns an expander for DSLs (only if there is a DSL configured for this package).
* @param path The {@link Path} of the resource to index
* @return a {@link Expander} used to produce a DRL of the file
*/
public 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;
}
use of org.drools.compiler.lang.Expander in project drools by kiegroup.
the class DrlParser method parse.
/**
* Parse and build a rule package from a DRL source with a domain specific
* language.
*
* @param source
* As Text.
* @param dsl
* @return
* @throws DroolsParserException
*/
public PackageDescr parse(boolean isEditor, final String source, final Reader dsl) throws DroolsParserException {
DefaultExpanderResolver resolver = getDefaultResolver(dsl);
final Expander expander = resolver.get("*", null);
final String expanded = expander.expand(source);
if (expander.hasErrors()) {
this.results.addAll(expander.getErrors());
}
return this.parse(isEditor, expanded);
}
use of org.drools.compiler.lang.Expander in project drools-wb by kiegroup.
the class GuidedDecisionTableSourceService 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;
}
use of org.drools.compiler.lang.Expander in project drools-wb by kiegroup.
the class GuidedDecisionTableSourceService method getSource.
@Override
public String getSource(final Path path, final GuidedDecisionTable52 model) throws SourceGenerationFailedException {
try {
final String dslr = GuidedDTDRLPersistence.getInstance().marshal(model);
final Expander expander = getDSLExpander(path);
final String drl = expander.expand(dslr);
return drl;
} catch (Exception e) {
throw new SourceGenerationFailedException(e.getMessage());
}
}
Aggregations