use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class GlobalsEditorServiceImpl method save.
@Override
public Path save(final Path resource, final GlobalsModel content, final Metadata metadata, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(resource);
final String packageName = (pkg == null ? null : pkg.getPackageName());
content.setPackageName(packageName);
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource), GlobalsPersistence.getInstance().marshal(content), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
// Invalidate Package-level DMO cache as Globals have changed.
invalidatePackageDMOEvent.fire(new InvalidateDMOPackageCacheEvent(resource));
fireMetadataSocialEvents(resource, currentMetadata, metadata);
return resource;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class GlobalsEditorServiceTest method testSaveAndRename.
@Test
public void testSaveAndRename() throws Exception {
final GlobalsEditorServiceImpl service = (GlobalsEditorServiceImpl) globalsEditorService;
final Path path = mock(Path.class);
final String newFileName = "newFileName";
final Metadata metadata = mock(Metadata.class);
final GlobalsModel content = mock(GlobalsModel.class);
final String comment = "comment";
service.saveAndRename(path, newFileName, metadata, content, comment);
verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class DRLTextEditorServiceImpl method save.
@Override
public Path save(final Path resource, final String content, final Metadata metadata, final String comment) {
try {
final String drl = assertPackageName(content, resource);
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource), drl, 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.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class DRLTextEditorServiceImplTest method testSaveAndRename.
@Test
public void testSaveAndRename() {
final Path path = mock(Path.class);
final String newFileName = "newFileName";
final Metadata metadata = mock(Metadata.class);
final String content = "content";
final String comment = "comment";
drlService.saveAndRename(path, newFileName, metadata, content, comment);
verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class DSLTextEditorServiceImpl method save.
@Override
public Path save(final Path resource, final String content, final Metadata metadata, final String comment) {
try {
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource), content, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
// Invalidate Package-level DMO cache as a DSL has been altered
invalidateDMOPackageCache.fire(new InvalidateDMOPackageCacheEvent(resource));
fireMetadataSocialEvents(resource, currentMetadata, metadata);
return resource;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
Aggregations