Search in sources :

Example 1 with DataObjectDeletedEvent

use of org.kie.workbench.common.screens.datamodeller.events.DataObjectDeletedEvent in project kie-wb-common by kiegroup.

the class DataModelerEventObserverTest method onPersistableDataObjectDeletedTest.

@Test
public void onPersistableDataObjectDeletedTest() {
    DataObjectDeletedEvent deletedEvent = new DataObjectDeletedEvent(module, dataObject);
    descriptorModel.getPersistenceUnit().getClasses().add(new PersistableDataObject(deletedEvent.getCurrentDataObject().getClassName()));
    eventObserver.onDataObjectDeleted(deletedEvent);
    verify(descriptorService, times(1)).save(eq(descriptorPath), eq(descriptorModel), Mockito.<Metadata>any(), anyString());
    assertFalse(descriptorModel.getPersistenceUnit().getClasses().contains(new PersistableDataObject(dataObject.getClassName())));
}
Also used : PersistableDataObject(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject) DataObjectDeletedEvent(org.kie.workbench.common.screens.datamodeller.events.DataObjectDeletedEvent) Test(org.junit.Test)

Example 2 with DataObjectDeletedEvent

use of org.kie.workbench.common.screens.datamodeller.events.DataObjectDeletedEvent in project kie-wb-common by kiegroup.

the class DataModelerServiceImpl method delete.

@Override
public void delete(final Path path, final String comment) {
    try {
        KieModule module = moduleService.resolveModule(path);
        if (module == null) {
            logger.warn("File : " + path.toURI() + " do not belong to a valid module");
            return;
        }
        deleteService.delete(path, comment);
        String className = serviceHelper.calculateClassName(module, path);
        DataObject dataObject = new DataObjectImpl(NamingUtils.extractPackageName(className), NamingUtils.extractClassName(className));
        dataObjectDeletedEvent.fire(new DataObjectDeletedEvent(module, dataObject));
    } catch (final Exception e) {
        logger.error("File: " + path.toURI() + " couldn't be deleted due to the following error. ", e);
        throw new ServiceException("File: " + path.toURI() + " couldn't be deleted due to the following error. " + e.getMessage());
    }
}
Also used : DataObjectImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) ServiceException(org.kie.workbench.common.screens.datamodeller.service.ServiceException) DataObjectDeletedEvent(org.kie.workbench.common.screens.datamodeller.events.DataObjectDeletedEvent) KieModule(org.kie.workbench.common.services.shared.project.KieModule) ModelDriverException(org.kie.workbench.common.services.datamodeller.driver.ModelDriverException) ServiceException(org.kie.workbench.common.screens.datamodeller.service.ServiceException) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Aggregations

DataObjectDeletedEvent (org.kie.workbench.common.screens.datamodeller.events.DataObjectDeletedEvent)2 Test (org.junit.Test)1 PersistableDataObject (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject)1 ServiceException (org.kie.workbench.common.screens.datamodeller.service.ServiceException)1 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)1 DataObjectImpl (org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl)1 ModelDriverException (org.kie.workbench.common.services.datamodeller.driver.ModelDriverException)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)1