Search in sources :

Example 1 with PersistenceDescriptorModel

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

the class PersistencePresenterTest method newPersistenceDescriptorEditorContent.

private PersistenceDescriptorEditorContent newPersistenceDescriptorEditorContent() {
    final PersistenceDescriptorEditorContent content = new PersistenceDescriptorEditorContent();
    final PersistenceDescriptorModel model = new PersistenceDescriptorModel();
    model.setVersion("2.0");
    final PersistenceUnitModel unitModel = new PersistenceUnitModel();
    model.setPersistenceUnit(unitModel);
    unitModel.setName("UnitName");
    unitModel.setTransactionType(TransactionType.JTA);
    unitModel.setProvider("ProviderClass");
    unitModel.setJtaDataSource("JTADataSource");
    unitModel.setClasses(Arrays.asList("Class1", "Class2"));
    content.setDescriptorModel(model);
    content.setOverview(new Overview());
    return content;
}
Also used : PersistenceUnitModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceUnitModel) PersistenceDescriptorEditorContent(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) PersistenceDescriptorModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel)

Example 2 with PersistenceDescriptorModel

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

the class PersistenceDescriptorXMLMarshallerTest method readFromXMLTest.

@Test
public void readFromXMLTest() {
    try {
        PersistenceDescriptorModel descriptor = PersistenceDescriptorXMLMarshaller.fromXML(getInputStream("persistence.xml"), false);
        assertEqualsDescriptor(expectedDescriptor(), descriptor);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : PersistenceDescriptorModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel) Test(org.junit.Test)

Example 3 with PersistenceDescriptorModel

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

the class PersistenceDescriptorXMLMarshallerTest method expectedDescriptor.

private PersistenceDescriptorModel expectedDescriptor() {
    PersistenceDescriptorModel descriptor = new PersistenceDescriptorModel();
    descriptor.setVersion("2.1");
    PersistenceUnitModel persistenceUnit = new PersistenceUnitModel();
    descriptor.setPersistenceUnit(persistenceUnit);
    persistenceUnit.setName("org.test.persistence-unit");
    persistenceUnit.setDescription("org.test.description");
    persistenceUnit.setProvider("org.test.Provider");
    persistenceUnit.setJtaDataSource("java:jboss/datasources/ExampleDS");
    persistenceUnit.getMappingFile().add("META-INF/Mapping1.xml");
    persistenceUnit.getMappingFile().add("META-INF/Mapping2.xml");
    persistenceUnit.getJarFile().add("file1.jar");
    persistenceUnit.getJarFile().add("file2.jar");
    persistenceUnit.getClasses().add("org.test.Entity1");
    persistenceUnit.getClasses().add("org.test.Entity2");
    persistenceUnit.setExcludeUnlistedClasses(true);
    persistenceUnit.setSharedCacheMode(CachingType.ALL);
    persistenceUnit.setValidationMode(ValidationMode.AUTO);
    persistenceUnit.setTransactionType(TransactionType.JTA);
    persistenceUnit.addProperty(new Property("property1", "property1_value"));
    persistenceUnit.addProperty(new Property("property2", "property2_value"));
    return descriptor;
}
Also used : PersistenceUnitModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceUnitModel) PersistenceDescriptorModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel) Property(org.kie.workbench.common.screens.datamodeller.model.persistence.Property)

Example 4 with PersistenceDescriptorModel

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

the class DataModelerEventObserver method onDataObjectCreated.

public void onDataObjectCreated(@Observes DataObjectCreatedEvent event) {
    Path descriptorPath;
    PersistenceDescriptorModel persistenceDescriptor;
    if (isPersistable(event.getCurrentDataObject())) {
        descriptorPath = descriptorService.calculatePersistenceDescriptorPath(event.getCurrentModule());
        persistenceDescriptor = safeLoad(descriptorPath);
        if (persistenceDescriptor != null && !containsClass(persistenceDescriptor.getPersistenceUnit(), event.getCurrentDataObject().getClassName())) {
            persistenceDescriptor.getPersistenceUnit().getClasses().add(event.getCurrentDataObject().getClassName());
            descriptorService.save(descriptorPath, persistenceDescriptor, null, "Entity added to persistence descriptor");
        }
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) PersistenceDescriptorModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel)

Example 5 with PersistenceDescriptorModel

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

the class PersistenceDescriptorEditorServiceImpl method constructContent.

@Override
protected PersistenceDescriptorEditorContent constructContent(Path path, Overview overview) {
    PersistenceDescriptorEditorContent content = new PersistenceDescriptorEditorContent();
    PersistenceDescriptorModel descriptorModel = descriptorService.load(path);
    content.setDescriptorModel(descriptorModel);
    content.setOverview(overview);
    content.setSource(ioService.readAllString(Paths.convert(path)));
    return content;
}
Also used : PersistenceDescriptorEditorContent(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent) PersistenceDescriptorModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel)

Aggregations

PersistenceDescriptorModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel)16 Path (org.uberfire.backend.vfs.Path)7 Test (org.junit.Test)5 PersistenceUnitModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceUnitModel)5 Module (org.guvnor.common.services.project.model.Module)4 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)4 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)4 DataObjectImpl (org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl)4 DataObjectCreatedEvent (org.kie.workbench.common.screens.datamodeller.events.DataObjectCreatedEvent)3 Property (org.kie.workbench.common.screens.datamodeller.model.persistence.Property)3 PersistenceDescriptorEditorContent (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent)2 AnnotationImpl (org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 Ignore (org.junit.Ignore)1 DataObjectDeletedEvent (org.kie.workbench.common.screens.datamodeller.events.DataObjectDeletedEvent)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 Pair (org.uberfire.commons.data.Pair)1 NodeList (org.w3c.dom.NodeList)1