Search in sources :

Example 11 with Metadata

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);
    }
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) InvalidateDMOPackageCacheEvent(org.guvnor.common.services.project.builder.events.InvalidateDMOPackageCacheEvent) Package(org.guvnor.common.services.project.model.Package) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 12 with Metadata

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) GlobalsModel(org.drools.workbench.screens.globals.model.GlobalsModel) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 13 with Metadata

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);
    }
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 14 with Metadata

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 15 with Metadata

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);
    }
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) InvalidateDMOPackageCacheEvent(org.guvnor.common.services.project.builder.events.InvalidateDMOPackageCacheEvent) DSLMappingParseException(org.drools.compiler.lang.dsl.DSLMappingParseException) IOException(java.io.IOException) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Aggregations

Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)62 Test (org.junit.Test)45 Path (org.uberfire.backend.vfs.Path)35 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)13 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)9 Package (org.guvnor.common.services.project.model.Package)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 HashMap (java.util.HashMap)5 POM (org.guvnor.common.services.project.model.POM)5 ProjectImports (org.guvnor.common.services.project.model.ProjectImports)5 ObservablePath (org.uberfire.backend.vfs.ObservablePath)5 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)5 Overview (org.guvnor.common.services.shared.metadata.model.Overview)4 WhiteList (org.kie.workbench.common.services.shared.whitelist.WhiteList)4 Map (java.util.Map)3 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)3 InvalidateDMOPackageCacheEvent (org.guvnor.common.services.project.builder.events.InvalidateDMOPackageCacheEvent)3 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)3 KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)3 Mockito.anyString (org.mockito.Mockito.anyString)3