use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult in project drools-wb by kiegroup.
the class DecisionTableXLSEditorPresenter method convert.
private void convert() {
busyIndicatorView.showBusyIndicator(DecisionTableXLSEditorConstants.INSTANCE.Converting());
decisionTableXLSService.call(new RemoteCallback<ConversionResult>() {
@Override
public void callback(final ConversionResult response) {
busyIndicatorView.hideBusyIndicator();
if (response.getMessages().size() > 0) {
final PopupListWidget popup = new PopupListWidget();
for (ConversionMessage message : response.getMessages()) {
popup.addListItem(new ConversionMessageWidget(message));
}
popup.show();
}
}
}).convert(versionRecordManager.getCurrentPath());
}
use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult in project drools-wb by kiegroup.
the class DecisionTableXLSToDecisionTableGuidedConverter method convert.
@Override
public ConversionResult convert(final Path path) {
ConversionResult result = new ConversionResult();
// Check Asset is of the correct format
if (!(xlsDTableType.accept(path) || xlsxDTableType.accept(path))) {
result.addMessage("Source Asset must be either a XLS or XLSX Decision Table file.", ConversionMessageType.ERROR);
return result;
}
final PackageDataModelOracle dmo = dataModelService.getDataModel(path);
// Perform conversion!
final GuidedDecisionTableGeneratorListener listener = parseAssets(path, result, dmo);
// Root path for new resources is the same folder as the XLS file
final Path context = Paths.convert(Paths.convert(path).getParent());
// Add Ancillary resources
createNewImports(context, listener.getImports(), result);
createNewFunctions(context, listener.getImports(), listener.getFunctions(), result);
createNewQueries(context, listener.getImports(), listener.getQueries(), result);
makeNewJavaTypes(context, listener.getTypeDeclarations(), result);
createNewGlobals(context, listener.getImports(), listener.getGlobals(), result);
// Add Web Guided Decision Tables
createNewDecisionTables(context, listener.getImports(), listener.getGuidedDecisionTables(), result);
return result;
}
use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult in project drools-wb by kiegroup.
the class DecisionTableXLSServiceImplCDITest method testConvertFunctionAndBigDecimal.
/**
* Covers RHBA-48 - BigDecimal fields in table
*/
@Test
public void testConvertFunctionAndBigDecimal() throws Exception {
final String resourcePath = "dtables/src/main/resources/guvnor/feature/dtables/FunctionAndBigDecimalTable.xls";
final ConversionResult conversionResult = convertResource(resourcePath);
final List<ConversionMessage> messages = conversionResult.getMessages();
Assertions.assertThat(messages).hasSize(1);
final String message = messages.get(0).getMessage();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(message).startsWith("Created Guided Decision Table 'FunctionAndBigDecimalTable (converted on");
softly.assertThat(message).endsWith(").gdst'");
});
}
use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult in project drools-wb by kiegroup.
the class DecisionTableXLSToDecisionTableGuidedConverterTest method testGlobalGeneration.
@Test
public // https://bugzilla.redhat.com/show_bug.cgi?id=1310208
void testGlobalGeneration() {
final InputStream is = this.getClass().getResourceAsStream("BZ1310208.xls");
when(ioService.newInputStream(any(org.uberfire.java.nio.file.Path.class))).thenReturn(is);
final ConversionResult result = converter.convert(path);
assertNotNull(result);
final ArgumentCaptor<GlobalsModel> globalsModelArgumentCaptor = ArgumentCaptor.forClass(GlobalsModel.class);
verify(globalsService, times(1)).create(any(Path.class), any(String.class), globalsModelArgumentCaptor.capture(), any(String.class));
assertNotNull(globalsModelArgumentCaptor.getValue());
final GlobalsModel globalsModel = globalsModelArgumentCaptor.getValue();
assertEquals(1, globalsModel.getGlobals().size());
assertEquals("list", globalsModel.getGlobals().get(0).getAlias());
assertEquals("java.util.List", globalsModel.getGlobals().get(0).getClassName());
verify(guidedDecisionTableService, times(1)).create(any(Path.class), any(String.class), any(GuidedDecisionTable52.class), any(String.class));
verify(drlService, never()).create(any(Path.class), any(String.class), any(String.class), any(String.class));
}
use of org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult in project drools-wb by kiegroup.
the class DecisionTableXLSToDecisionTableGuidedConverterTest method checkConversionOfXLSXFiles.
@Test
public // https://issues.jboss.org/browse/GUVNOR-2696
void checkConversionOfXLSXFiles() {
final InputStream is = this.getClass().getResourceAsStream("GUVNOR-2696.xlsx");
when(ioService.newInputStream(any(org.uberfire.java.nio.file.Path.class))).thenReturn(is);
final ConversionResult result = converter.convert(path);
assertNotNull(result);
assertEquals(1, result.getMessages().size());
assertTrue(result.getMessages().get(0).getMessage().startsWith("Created Guided Decision Table 'Weather"));
verify(guidedDecisionTableService, times(1)).create(any(Path.class), any(String.class), any(GuidedDecisionTable52.class), any(String.class));
}
Aggregations