Search in sources :

Example 6 with PersistableDataObject

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

the class PersistenceDescriptorValidatorTest method createValidDescriptor.

private PersistenceDescriptorModel createValidDescriptor() {
    PersistenceDescriptorModel descriptor = new PersistenceDescriptorModel();
    descriptor.setVersion(VERSION);
    PersistenceUnitModel unit = new PersistenceUnitModel();
    descriptor.setPersistenceUnit(unit);
    unit.setJtaDataSource(JTA_DATASOURCE);
    unit.setName(PERSISTENCE_UNIT_NAME);
    unit.setProvider(PERSISTENCE_PROVIDER);
    unit.setTransactionType(TransactionType.JTA);
    List<Property> properties = new ArrayList<>();
    properties.add(new Property("name1", "value1"));
    properties.add(new Property("name2", "value2"));
    unit.setProperties(properties);
    List<PersistableDataObject> classes = new ArrayList<>();
    classes.add(new PersistableDataObject(PersistableClass1.class.getName()));
    classes.add(new PersistableDataObject(PersistableClass2.class.getName()));
    classes.add(new PersistableDataObject(PersistableClass3.class.getName()));
    descriptor.getPersistenceUnit().setClasses(classes);
    return descriptor;
}
Also used : PersistableDataObject(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject) PersistenceUnitModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceUnitModel) ArrayList(java.util.ArrayList) PersistenceDescriptorModel(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel) Property(org.kie.workbench.common.screens.datamodeller.model.persistence.Property)

Example 7 with PersistableDataObject

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

the class PersistenceDescriptorValidatorTest method testValidateNonPersistableClass.

@Test
public void testValidateNonPersistableClass() {
    // add a non persistable class
    descriptor.getPersistenceUnit().getClasses().add(new PersistableDataObject(NonPersistableClass1.class.getName()));
    List<ValidationMessage> result = validator.validate(path, descriptor);
    ValidationMessage expectedMessage;
    // validation for the non persistable class should fail.
    expectedMessage = newErrorMessage(PersistenceDescriptorValidationMessages.CLASS_NOT_PERSISTABLE_ID, MessageFormat.format(PersistenceDescriptorValidationMessages.CLASS_NOT_PERSISTABLE, NonPersistableClass1.class.getName()), NonPersistableClass1.class.getName());
    assertTrue(result.contains(expectedMessage));
}
Also used : PersistableDataObject(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) Test(org.junit.Test)

Example 8 with PersistableDataObject

use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject 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(new PersistableDataObject("org.test.Entity1"));
    persistenceUnit.getClasses().add(new PersistableDataObject("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 : PersistableDataObject(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject) 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 9 with PersistableDataObject

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

the class PersistencePresenter method add.

public void add(final String className) {
    persistableDataObjectsListPresenter.add(new PersistableDataObject(className));
    fireChangeEvent();
}
Also used : PersistableDataObject(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject)

Example 10 with PersistableDataObject

use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject 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(new PersistableDataObject("Class1"), new PersistableDataObject("Class2")));
    content.setDescriptorModel(model);
    content.setOverview(new Overview());
    return content;
}
Also used : PersistableDataObject(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject) 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)

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