use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedDecisionTreeEditorServiceImpl method save.
@Override
public Path save(final Path resource, final GuidedDecisionTree model, final Metadata metadata, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(resource);
final String packageName = (pkg == null ? null : pkg.getPackageName());
model.setPackageName(packageName);
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource), GuidedDecisionTreeDRLPersistence.getInstance().marshal(model), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
fireMetadataSocialEvents(resource, currentMetadata, metadata);
return resource;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedRuleTemplateEditorServiceImpl method save.
@Override
public Path save(final Path resource, final TemplateModel model, final Metadata metadata, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(resource);
final String packageName = (pkg == null ? null : pkg.getPackageName());
model.setPackageName(packageName);
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource), RuleTemplateModelXMLPersistenceImpl.getInstance().marshal(model), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
fireMetadataSocialEvents(resource, currentMetadata, metadata);
return resource;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewScoreCardXLSHandlerTest method testSuccessMultiByteProjectNameAndFileName.
@Test
public void testSuccessMultiByteProjectNameAndFileName() {
final String fileName = "あああ";
final Package pkg = mock(Package.class);
final Path resourcesPath = PathFactory.newPath("resources", "default://" + encode("ああ") + "/src/main/resources");
when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath);
handler.create(pkg, fileName, newResourcePresenter);
verify(uploadWidget, times(1)).submit(eq(resourcesPath), eq(fileName + "." + resourceType.getSuffix()), any(String.class), successCmdCaptor.capture(), failureCmdCaptor.capture());
successCmdCaptor.getValue().execute();
verify(busyIndicatorView, times(1)).hideBusyIndicator();
verify(newResourcePresenter, times(1)).complete();
verify(mockNotificationEvent, times(1)).fire(any(NotificationEvent.class));
verify(newResourceSuccessEventMock, times(1)).fire(any(NewResourceSuccessEvent.class));
verify(placeManager, times(1)).goTo(newPathCaptor.capture());
assertEquals("default://%E3%81%82%E3%81%82/src/main/resources/%E3%81%82%E3%81%82%E3%81%82.sxls", newPathCaptor.getValue().toURI());
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImpl method load.
@Override
public Scenario load(final Path path) {
try {
final String content = ioService.readAllString(Paths.convert(path));
final Scenario scenario = ScenarioXMLPersistence.getInstance().unmarshal(content);
scenario.setName(path.getFileName());
return scenario;
} catch (final Exception e) {
logger.error("Unable to unmarshal content. Returning an empty Test Scenario.", e);
final Package resolvedPackage = moduleService.resolvePackage(path);
final Scenario scenario = new Scenario();
if (resolvedPackage != null) {
scenario.setPackageName(resolvedPackage.getPackageName());
}
scenario.setImports(new Imports());
return scenario;
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImplTest method loadBrokenScenario.
@Test
public void loadBrokenScenario() throws Exception {
final Package pgk = mock(Package.class);
when(pgk.getPackageName()).thenReturn("org.test");
when(moduleService.resolvePackage(path)).thenReturn(pgk);
final Scenario load = testEditorService.load(path);
assertNotNull(load);
assertEquals("org.test", load.getPackageName());
assertNotNull(load.getImports());
}
Aggregations