use of org.drools.workbench.models.datamodel.rule.DSLSentence in project drools-wb by kiegroup.
the class DSLExtension method getExtensions.
@Override
public List<ExtensionMapping<?>> getExtensions(Path path, String content) {
final DSLTokenizedMappingFile dslLoader = new DSLTokenizedMappingFile();
List<DSLSentence> actionSentences = new ArrayList<>();
List<DSLSentence> conditionSentences = new ArrayList<>();
try {
if (dslLoader.parseAndLoad(new StringReader(content))) {
for (DSLMappingEntry entry : dslLoader.getMapping().getEntries()) {
if (entry.getSection() == DSLMappingEntry.CONDITION) {
final DSLMappingEntry definition = entry;
final DSLSentence sentence = new DSLSentence();
sentence.setDrl(definition.getMappingValue());
sentence.setDefinition(definition.getMappingKey());
conditionSentences.add(sentence);
} else if (entry.getSection() == DSLMappingEntry.CONSEQUENCE) {
final DSLMappingEntry definition = entry;
final DSLSentence sentence = new DSLSentence();
sentence.setDrl(definition.getMappingValue());
sentence.setDefinition(definition.getMappingKey());
actionSentences.add(sentence);
}
}
}
} catch (IOException e) {
log.error(e.getMessage());
}
return Arrays.asList(new DSLMapping(DSLActionSentence.INSTANCE, actionSentences), new DSLMapping(DSLConditionSentence.INSTANCE, conditionSentences));
}
use of org.drools.workbench.models.datamodel.rule.DSLSentence in project drools-wb by kiegroup.
the class DRLTextEditorServiceImpl method constructContent.
@Override
protected DrlModelContent constructContent(Path path, Overview overview) {
final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
final String[] fullyQualifiedClassNames = DataModelOracleUtilities.getFactTypes(oracle);
final List<DSLSentence> dslConditions = oracle.getExtensions(DSLConditionSentence.INSTANCE);
final List<DSLSentence> dslActions = oracle.getExtensions(DSLActionSentence.INSTANCE);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new DrlModelContent(load(path), overview, Arrays.asList(fullyQualifiedClassNames), dslConditions, dslActions);
}
use of org.drools.workbench.models.datamodel.rule.DSLSentence in project drools-wb by kiegroup.
the class DSLSentenceBrowserWidget method setDSLSentences.
public void setDSLSentences(final List<DSLSentence> dslSentences) {
if (tree.getItem(0) != null) {
tree.clear();
}
if (dslSentences != null) {
for (DSLSentence dslSentence : dslSentences) {
final TreeItem it = new TreeItem();
it.setHTML("<small>" + dslSentence.toString() + "</small>");
it.setUserObject(dslSentence);
tree.addItem(it);
}
}
}
use of org.drools.workbench.models.datamodel.rule.DSLSentence in project drools-wb by kiegroup.
the class RuleModelCloneVisitorTest method buildDslSentence.
private DSLSentence buildDslSentence() {
DSLSentence dsl = new DSLSentence();
dsl.setDrl("Person( sex == {$sex} )");
dsl.setDefinition("Person is {$sex:ENUM:Person.sex}");
return dsl;
}
use of org.drools.workbench.models.datamodel.rule.DSLSentence in project drools-wb by kiegroup.
the class DSLDropDownTest method testGetDropDown.
@Test
public void testGetDropDown() throws Exception {
final String fact = "Fact";
final String field = "field";
final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
final RuleModeller ruleModeller = mock(RuleModeller.class);
doReturn(oracle).when(ruleModeller).getDataModelOracle();
final String variableDefinition = "varName:type:" + fact + "." + field;
final DSLSentence dslSentence = mock(DSLSentence.class);
final DSLVariableValue dslVariableValue = mock(DSLVariableValue.class);
final boolean isMultipleSelect = false;
final Callback<DSLDropDown> updateEnumsCallback = mock(Callback.class);
testedDropDown = new DSLDropDown(ruleModeller, variableDefinition, dslSentence, dslVariableValue, isMultipleSelect, updateEnumsCallback);
// reset oracle due to calls in DSLDropDown constructor
reset(oracle);
testedDropDown.getDropDownData();
verify(oracle).getEnums(eq(fact), eq(field), anyMap());
}
Aggregations