Search in sources :

Example 1 with JPADomainHandler

use of org.kie.workbench.common.screens.datamodeller.backend.server.handler.JPADomainHandler 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);
}
Also used : JPADomainHandler(org.kie.workbench.common.screens.datamodeller.backend.server.handler.JPADomainHandler) HashMap(java.util.HashMap) DataModelImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) PropertyTypeFactoryImpl(org.kie.workbench.common.services.datamodeller.core.impl.PropertyTypeFactoryImpl)

Aggregations

HashMap (java.util.HashMap)1 JPADomainHandler (org.kie.workbench.common.screens.datamodeller.backend.server.handler.JPADomainHandler)1 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)1 DataModelImpl (org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl)1 PropertyTypeFactoryImpl (org.kie.workbench.common.services.datamodeller.core.impl.PropertyTypeFactoryImpl)1