Search in sources :

Example 1 with Property

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

the class PersistenceDescriptor2DOMVisitor method visitProperties.

private void visitProperties(Element element, List<Property> properties) {
    if (properties != null && properties.size() > 0) {
        Element propertiesElement = document.createElement(PersistenceDescriptorXMLMarshaller.PROPERTIES);
        element.appendChild(propertiesElement);
        for (Property property : properties) {
            visitProperty(propertiesElement, property);
        }
    }
}
Also used : Element(org.w3c.dom.Element) Property(org.kie.workbench.common.screens.datamodeller.model.persistence.Property)

Example 2 with Property

use of org.kie.workbench.common.screens.datamodeller.model.persistence.Property 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 3 with Property

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

the class PersistenceDescriptorServiceImpl method createModuleDefaultDescriptor.

@Override
public PersistenceDescriptorModel createModuleDefaultDescriptor(final Path path) {
    KieModule module = moduleService.resolveModule(path);
    if (module == null) {
        return null;
    }
    // TODO read default descriptor parameters from a configuration/template.
    // We can basically copy the configuration from WEB-INF/classes/META-INF/persistence.xml file
    // since this file will always exist for a kie-wb installation.
    // This default values are taken from "org.jbpm.domain" persistence unit shipped by default with kie-wb-distributions
    PersistenceDescriptorModel descriptorModel = new PersistenceDescriptorModel();
    descriptorModel.setVersion("2.0");
    PersistenceUnitModel unitModel = new PersistenceUnitModel();
    descriptorModel.setPersistenceUnit(unitModel);
    unitModel.setName(module.getPom().getGav().toString());
    unitModel.setTransactionType(TransactionType.JTA);
    unitModel.setProvider("org.hibernate.jpa.HibernatePersistenceProvider");
    unitModel.setJtaDataSource("java:jboss/datasources/ExampleDS");
    unitModel.addProperty(new Property("hibernate.dialect", "org.hibernate.dialect.H2Dialect"));
    unitModel.addProperty(new Property("hibernate.max_fetch_depth", "3"));
    unitModel.addProperty(new Property("hibernate.hbm2ddl.auto", "update"));
    unitModel.addProperty(new Property("hibernate.show_sql", "false"));
    // <!-- BZ 841786: AS7/EAP 6/Hib 4 uses new (sequence) generators which seem to cause problems -->
    unitModel.addProperty(new Property("hibernate.id.new_generator_mappings", "false"));
    unitModel.addProperty(new Property("hibernate.transaction.jta.platform", "org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform"));
    // use only entities configured by the user, avoiding in this way that classes in the project classpath (e.g, from dependencies)
    // to be included in the EntityManager
    unitModel.setExcludeUnlistedClasses(true);
    return descriptorModel;
}
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) KieModule(org.kie.workbench.common.services.shared.project.KieModule)

Example 4 with Property

use of org.kie.workbench.common.screens.datamodeller.model.persistence.Property 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<String> classes = new ArrayList<>();
    classes.add(PersistableClass1.class.getName());
    classes.add(PersistableClass2.class.getName());
    classes.add(PersistableClass3.class.getName());
    descriptor.getPersistenceUnit().setClasses(classes);
    return descriptor;
}
Also used : 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 5 with Property

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

the class PersistencePresenter method showNewPropertyModal.

public void showNewPropertyModal() {
    newPropertyModal.show((name, value) -> {
        add(new Property(name, value));
        fireChangeEvent();
    });
}
Also used : Property(org.kie.workbench.common.screens.datamodeller.model.persistence.Property)

Aggregations

Property (org.kie.workbench.common.screens.datamodeller.model.persistence.Property)11 Test (org.junit.Test)4 PersistenceDescriptorModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel)3 PersistenceUnitModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceUnitModel)3 ArrayList (java.util.ArrayList)2 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)2 Element (org.w3c.dom.Element)2 PersistencePresenter (org.kie.workbench.common.screens.library.client.settings.persistence.PersistencePresenter)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 NodeList (org.w3c.dom.NodeList)1