Search in sources :

Example 11 with PersistableDataObject

use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject in project kie-wb-common by kiegroup.

the class DataModelerEventObserver method onDataObjectDeleted.

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");
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) PersistableDataObject(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject) PersistenceDescriptorModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel)

Example 12 with PersistableDataObject

use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject in project kie-wb-common by kiegroup.

the class PersistenceDescriptor2DOMVisitor method visitPersistenceUnit.

private void visitPersistenceUnit(Element parent, PersistenceUnitModel persistenceUnit) {
    Element persistenceUnitElement = document.createElement(PersistenceDescriptorXMLMarshaller.PERSISTENCE_UNIT);
    parent.appendChild(persistenceUnitElement);
    persistenceUnitElement.setAttribute(PersistenceDescriptorXMLMarshaller.NAME, persistenceUnit.getName());
    if (persistenceUnit.getTransactionType() != null) {
        persistenceUnitElement.setAttribute(PersistenceDescriptorXMLMarshaller.TRANSACTION_TYPE, persistenceUnit.getTransactionType().name());
    }
    visitDescription(persistenceUnitElement, persistenceUnit.getDescription());
    visitProvider(persistenceUnitElement, persistenceUnit.getProvider());
    visitJTADataSource(persistenceUnitElement, persistenceUnit.getJtaDataSource());
    visitNonJTADataSource(persistenceUnitElement, persistenceUnit.getNonJtaDataSource());
    if (persistenceUnit.getMappingFile() != null) {
        for (String mappingFile : persistenceUnit.getMappingFile()) {
            visitMappingFile(persistenceUnitElement, mappingFile);
        }
    }
    if (persistenceUnit.getJarFile() != null) {
        for (String jarFile : persistenceUnit.getJarFile()) {
            visitJarFile(persistenceUnitElement, jarFile);
        }
    }
    if (persistenceUnit.getClasses() != null) {
        for (PersistableDataObject clazz : persistenceUnit.getClasses()) {
            visitClass(persistenceUnitElement, clazz.getValue());
        }
    }
    visitExcludeUnlistedClasses(persistenceUnitElement, persistenceUnit.getExcludeUnlistedClasses());
    visitSharedChacheMode(persistenceUnitElement, persistenceUnit.getSharedCacheMode());
    visitValidationMode(persistenceUnitElement, persistenceUnit.getValidationMode());
    visitProperties(persistenceUnitElement, persistenceUnit.getProperties());
}
Also used : PersistableDataObject(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject) Element(org.w3c.dom.Element)

Example 13 with PersistableDataObject

use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject in project kie-wb-common by kiegroup.

the class PersistableDataObjectsItemPresenterTest method testSetup.

@Test
public void testSetup() {
    persistableDataObjectsItemPresenter.setup(new PersistableDataObject("ClassName"), mock(PersistencePresenter.class));
    verify(view).init(eq(persistableDataObjectsItemPresenter));
    verify(view).setClassName(eq("ClassName"));
}
Also used : PersistableDataObject(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject) PersistencePresenter(org.kie.workbench.common.screens.library.client.settings.sections.persistence.PersistencePresenter) Test(org.junit.Test)

Aggregations

PersistableDataObject (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject)13 Test (org.junit.Test)6 PersistenceDescriptorModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel)5 DataObjectCreatedEvent (org.kie.workbench.common.screens.datamodeller.events.DataObjectCreatedEvent)3 PersistenceUnitModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceUnitModel)3 Property (org.kie.workbench.common.screens.datamodeller.model.persistence.Property)2 Path (org.uberfire.backend.vfs.Path)2 ArrayList (java.util.ArrayList)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)1 DataObjectDeletedEvent (org.kie.workbench.common.screens.datamodeller.events.DataObjectDeletedEvent)1 PersistenceDescriptorEditorContent (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent)1 PersistencePresenter (org.kie.workbench.common.screens.library.client.settings.sections.persistence.PersistencePresenter)1 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)1 DataObjectImpl (org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl)1 Element (org.w3c.dom.Element)1