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