use of org.drools.workbench.screens.globals.model.GlobalsModel in project drools-wb by kiegroup.
the class DecisionTableXLSToDecisionTableGuidedConverter method createNewGlobals.
private void createNewGlobals(final Path context, final List<Import> imports, final List<Global> globals, final ConversionResult result) {
if (globals == null || globals.isEmpty()) {
return;
}
// Create new asset for Globals. All Globals can be in one file.
final String assetName = makeNewAssetName("Global", globalsType);
final GlobalsModel model = makeGlobalsModel(imports, globals, result);
globalsService.create(context, assetName, model, "Converted from XLS Decision Table");
result.addMessage("Created Globals '" + assetName + "'", ConversionMessageType.INFO);
}
use of org.drools.workbench.screens.globals.model.GlobalsModel in project drools-wb by kiegroup.
the class NewGlobalHandler method create.
@Override
public void create(final Package pkg, final String baseFileName, final NewResourcePresenter presenter) {
final GlobalsModel model = new GlobalsModel();
busyIndicatorView.showBusyIndicator(CommonConstants.INSTANCE.Saving());
globalsService.call(getSuccessCallback(presenter), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).create(pkg.getPackageMainResourcesPath(), buildFileName(baseFileName, resourceType), model, "");
}
use of org.drools.workbench.screens.globals.model.GlobalsModel in project drools-wb by kiegroup.
the class GlobalsPersistence method unmarshal.
public GlobalsModel unmarshal(final String content) {
// De-serialize model
final List<Pair<String, String>> parsedGlobalsContent = GlobalsParser.parseGlobals(content);
final List<Global> globals = makeGlobals(parsedGlobalsContent);
final GlobalsModel model = new GlobalsModel();
model.setGlobals(globals);
// De-serialize Package name
final String packageName = PackageNameParser.parsePackageName(content);
model.setPackageName(packageName);
return model;
}
use of org.drools.workbench.screens.globals.model.GlobalsModel in project drools-wb by kiegroup.
the class GlobalsEditorServiceTest method save.
@Test
public void save() {
Path path = PathFactory.newPath("test", "file:///test");
GlobalsModel globalsModel = mock(GlobalsModel.class);
when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(false);
globalsEditorService.create(path, "test", globalsModel, "comment");
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), anyString(), any(CommentedOption.class));
}
use of org.drools.workbench.screens.globals.model.GlobalsModel in project drools-wb by kiegroup.
the class GlobalsEditorServiceTest method generate.
@Test
public void generate() {
Path path = PathFactory.newPath("test", "file:///test");
GlobalsModel globalsModel = mock(GlobalsModel.class);
when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(false);
Map<String, Object> metadataMap = new HashMap<String, Object>() {
{
put(GeneratedAttributesView.GENERATED_ATTRIBUTE_NAME, true);
}
};
when(metadataService.configAttrs(anyMapOf(String.class, Object.class), any(Metadata.class))).thenReturn(metadataMap);
globalsEditorService.generate(path, "test", globalsModel, "comment");
ArgumentCaptor<Map> mapArgumentCaptor = ArgumentCaptor.forClass(Map.class);
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), anyString(), mapArgumentCaptor.capture(), any(CommentedOption.class));
Map capturedMap = mapArgumentCaptor.getValue();
assertEquals(metadataMap, capturedMap);
Object generatedAttribute = capturedMap.get(GeneratedAttributesView.GENERATED_ATTRIBUTE_NAME);
assertNotNull(generatedAttribute);
assertTrue(Boolean.parseBoolean(generatedAttribute.toString()));
}
Aggregations