@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), any(Metadata.class), anyString()); assertFalse(descriptorModel.getPersistenceUnit().getClasses().contains(new PersistableDataObject(dataObject.getClassName()))); }
public void onDataObjectDeleted(@Observes DataObjectDeletedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().remove(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity removed from persistence descriptor"); } }
DataModelerEventObserver { public void onDataObjectDeleted(@Observes DataObjectDeletedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().remove(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity removed from persistence descriptor"); } } }
DataModelerEventObserver { public void onDataObjectDeleted(@Observes DataObjectDeletedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().remove(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity removed from persistence descriptor"); } } DataModelerEventObserver(); @Inject  DataModelerEventObserver(final PersistenceDescriptorService descriptorService,
                                    final @Named("ioStrategy") IOService ioService); }
DataModelerEventObserver { public void onDataObjectDeleted(@Observes DataObjectDeletedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().remove(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity removed from persistence descriptor"); } } DataModelerEventObserver(); @Inject  DataModelerEventObserver(final PersistenceDescriptorService descriptorService,
                                    final @Named("ioStrategy") IOService ioService); void onDataObjectCreated(@Observes DataObjectCreatedEvent event); void onDataObjectDeleted(@Observes DataObjectDeletedEvent event); }
DataModelerEventObserver { public void onDataObjectDeleted(@Observes DataObjectDeletedEvent event) { Path descriptorPath; PersistenceDescriptorModel persistenceDescriptor; descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule()); persistenceDescriptor = safeLoad(descriptorPath); if (persistenceDescriptor != null && containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) { persistenceDescriptor.getPersistenceUnit().getClasses().remove(new PersistableDataObject(event.getCurrentDataObject().getClassName())); descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity removed from persistence descriptor"); } } DataModelerEventObserver(); @Inject  DataModelerEventObserver(final PersistenceDescriptorService descriptorService,
                                    final @Named("ioStrategy") IOService ioService); void onDataObjectCreated(@Observes DataObjectCreatedEvent event); void onDataObjectDeleted(@Observes DataObjectDeletedEvent event);  }