use of org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl in project kie-wb-common by kiegroup.
the class DataModelTestUtil method createModel.
public DataModel createModel(Class... classes) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
DataModel dataModel = new DataModelImpl();
for (Class clazz : classes) {
DataObject dataObject = createDataObject(clazz);
dataModel.addDataObject(dataObject);
}
return dataModel;
}
use of org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl in project kie-wb-common by kiegroup.
the class ModuleDataModelOracleUtilsTest method loadExternalDepsTest.
@Test
public void loadExternalDepsTest() {
DataModel dataModel = new DataModelImpl();
try {
ModuleDataModelOracleUtils.loadExternalDependencies(dataModel, dataModelOracle, ModuleDataModelOracleUtilsTest.class.getClassLoader());
// check that the expected classes were properly loaded.
List<DataObject> expectedExternalClasses = createExpectedExternalClasses();
assertEquals(expectedExternalClasses.size(), dataModel.getExternalClasses().size());
for (DataObject externalClass : dataModel.getExternalClasses()) {
// properties read from DMO are not necessary sorted.
sortProperties(externalClass);
assertTrue(expectedExternalClasses.contains(externalClass));
}
// check that the expected enums where properly loaded.
List<JavaEnum> expectedExternalEnums = createExpectedExternalEnums();
assertEquals(expectedExternalEnums.size(), dataModel.getDependencyJavaEnums().size());
for (JavaEnum externalEnum : dataModel.getDependencyJavaEnums()) {
assertTrue(expectedExternalEnums.contains(externalEnum));
}
} catch (Exception e) {
fail("External deps loading test failed: " + e.getMessage());
}
}
use of org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriverTest method createModel.
private DataModel createModel() {
DataModel dataModel = new DataModelImpl();
dataModel.addDataObject(createPojo1());
dataModel.addDataObject(createPojo2());
dataModel.addJavaEnum(createInternalEnum1());
dataModel.addDataObject(createAnnotationValuesAnnotationTest());
dataModel.addDataObject(createClassAnnotationTest());
dataModel.addDataObject(createEnumsAnnotationTest());
dataModel.addDataObject(createMarkerAnnotationTest());
dataModel.addDataObject(createPrimitivesAnnotationTest());
dataModel.addDataObject(createAnnotationsUpdateTest());
dataModel.addDataObject(createAnnotationsUpdateTestResult());
dataModel.addDataObject(createNestedClassUpdateTest());
dataModel.addDataObject(createNestedClassUpdateTestResult());
dataModel.addDataObject(createMethodsUpdateTest());
dataModel.addDataObject(createMethodsUpdateTestResult());
dataModel.addDataObject(createImportsUpdateTest());
dataModel.addDataObject(createImportsUpdateTestResult());
return dataModel;
}
use of org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl in project drools-wb by kiegroup.
the class DecisionTableXLSToDecisionTableGuidedConverter method makeNewJavaTypes.
private void makeNewJavaTypes(final Path context, final List<String> declaredTypes, final ConversionResult result) {
if (declaredTypes == null || declaredTypes.isEmpty()) {
return;
}
final KieModule module = moduleService.resolveModule(context);
for (String declaredType : declaredTypes) {
final FactModels factModels = FactModelPersistence.unmarshal(declaredType);
final String packageName = factModels.getPackageName();
final DataModel dataModel = new DataModelImpl();
for (FactMetaModel factMetaModel : factModels.getModels()) {
final DataObject dataObject = new DataObjectImpl(packageName, factMetaModel.getName());
dataObject.setSuperClassName(factMetaModel.getSuperType());
final List<AnnotationMetaModel> annotationMetaModel = factMetaModel.getAnnotations();
addAnnotations(dataObject, annotationMetaModel);
final List<FieldMetaModel> fields = factMetaModel.getFields();
for (FieldMetaModel fieldMetaModel : fields) {
final String fieldName = fieldMetaModel.getName();
final String fieldType = fieldMetaModel.getType();
// Guvnor 5.5 (and earlier) does not have MultipleType
boolean isMultiple = false;
ObjectProperty property = new ObjectPropertyImpl(fieldName, fieldType, isMultiple);
// field has no annotation in Guvnor 5.5 (and earlier)
dataObject.addProperty(property);
result.addMessage("Created Java Type " + getJavaTypeFQCN(dataObject), ConversionMessageType.INFO);
}
dataModel.getDataObjects().add(dataObject);
}
modellerService.saveModel(dataModel, module);
}
}
use of org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl in project kie-wb-common by kiegroup.
the class DataObjectFormModelHandlerTest method createModel.
private void createModel() {
dataModel = new DataModelImpl();
dataObject = dataModel.addDataObject("Person1");
// makeTheClassPersistable
Map<String, Object> params = new HashMap<String, Object>();
params.put("persistable", true);
JPADomainHandler jpaDomainHandler = new JPADomainHandler();
jpaDomainHandler.setDefaultValues(dataObject, params);
// adding serialVersionUID field
addProperty(dataObject, DataObjectFormModelHandler.SERIAL_VERSION_UID, Long.class.getName(), false, false);
// add all base type properties
PropertyTypeFactoryImpl propertyTypeFactory = new PropertyTypeFactoryImpl();
propertyTypeFactory.getBasePropertyTypes().forEach(baseProperty -> addProperty(dataObject, baseProperty.getName(), baseProperty.getClassName(), false, false));
// add data object property
addProperty(dataObject, "address", NESTED_CLASSNAME, false, false);
// add list of data objects
addProperty(dataObject, "address_list", NESTED_CLASSNAME, true, false);
}
Aggregations