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);
}
}
}
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;
}
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;
}
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;
}
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();
});
}
Aggregations