use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class ModuleDataModelOracleUtils method addDataObjectType.
private static void addDataObjectType(DataModel dataModel, ModuleDataModelOracle oracleDataModel, String factType, ClassMetadata classMetadata) throws ModelDriverException {
String superClass = DataModelOracleUtilities.getSuperType(oracleDataModel, factType);
Visibility visibility = DriverUtils.buildVisibility(classMetadata.getModifiers());
DataObject dataObject;
logger.debug("Adding dataObjectType: " + factType + ", to dataModel: " + dataModel + ", from oracleDataModel: " + oracleDataModel);
dataObject = dataModel.addDataObject(factType, visibility, Modifier.isAbstract(classMetadata.getModifiers()), Modifier.isFinal(classMetadata.getModifiers()), ObjectSource.DEPENDENCY);
dataObject.setSuperClassName(superClass);
Map<String, ModelField[]> fields = oracleDataModel.getModuleModelFields();
if (fields != null) {
ModelField[] factFields = fields.get(factType);
ModelField field;
if (factFields != null && factFields.length > 0) {
for (int j = 0; j < factFields.length; j++) {
field = factFields[j];
if (isLoadableField(field)) {
if (field.getType().equals("Collection")) {
// read the correct bag and item classes.
String bag = DataModelOracleUtilities.getFieldClassName(oracleDataModel, factType, field.getName());
String itemsClass = DataModelOracleUtilities.getParametricFieldType(oracleDataModel, factType, field.getName());
if (itemsClass == null) {
// if we don't know the items class, the property will be managed as a simple property.
dataObject.addProperty(field.getName(), bag);
} else {
dataObject.addProperty(field.getName(), itemsClass, true, bag);
}
} else {
dataObject.addProperty(field.getName(), field.getClassName());
}
}
}
}
} else {
logger.debug("No fields found for factTye: " + factType);
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class DataModelImpl method addDataObject.
private DataObject addDataObject(String packageName, String name, Visibility visibility, boolean isAbstract, boolean isFinal, Map<String, DataObject> objectsMap) {
DataObject dataObject = new DataObjectImpl(packageName, name, visibility, isAbstract, isFinal);
objectsMap.put(dataObject.getClassName(), dataObject);
return dataObject;
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject 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.DataObject in project kie-wb-common by kiegroup.
the class DataObjectFinderServiceImplFinderTest method testFindDataObject.
@Test
public void testFindDataObject() {
DataObject result = service.getDataObject(TYPE_NAME, path);
assertEquals(dataObject, result);
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject 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