use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.
the class DataObjectsServiceImpl method convertDataType.
private String convertDataType(final String typeName, final List<DataObject> dataObjects, final ClassLoader classLoader) {
for (DataObject dataObject : dataObjects) {
if (Objects.equals(typeName, dataObject.getClassType())) {
return typeName;
}
}
try {
final String className = PrimitiveUtilities.getClassNameForPrimitiveType(typeName);
final Class<?> clazz = classLoader.loadClass(Objects.nonNull(className) ? className : typeName);
final BuiltInType builtInType = determineBuiltInTypeFromClass(clazz);
if (Objects.nonNull(builtInType)) {
return builtInType.getName();
}
} catch (ClassNotFoundException cnfe) {
// Swallow as BuiltInType.ANY is the default response
}
return BuiltInType.ANY.getName();
}
use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.
the class DataTypeList method updatePropertiesReferences.
void updatePropertiesReferences(final List<DataObject> imported, final Map<String, String> renamed) {
for (final DataObject dataObject : imported) {
for (final DataObjectProperty property : dataObject.getProperties()) {
String propertyType = renamed.getOrDefault(property.getType(), property.getType());
if (!isPropertyTypePresent(propertyType, imported)) {
propertyType = BuiltInType.ANY.getName();
}
property.setType(propertyType);
}
}
}
use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.
the class DataTypeList method importDataObjects.
public void importDataObjects(final List<DataObject> selectedDataObjects) {
removeFullQualifiedNames(selectedDataObjects);
for (final DataObject dataObject : selectedDataObjects) {
final DataType newDataType = createNewDataType(dataObject);
final Optional<DataType> existing = findDataTypeByName(dataObject.getClassType());
if (existing.isPresent()) {
replace(existing.get(), newDataType);
} else {
insert(newDataType);
}
insertProperties(dataObject);
}
}
use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.
the class ImportDataObjectModalView method addItems.
@Override
public void addItems(final List<DataObject> dataObjects) {
final List<TreeListItem> dataObjectItems = new ArrayList<>();
for (final DataObject data : dataObjects) {
dataObjectItems.add(createTreeListItem(data));
}
treeList.populate(dataObjectItems);
itemsContainer.appendChild(treeList.getElement());
}
use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.
the class DataTypeListTest method testCreateNewDataTypeFromDataObject.
@Test
public void testCreateNewDataTypeFromDataObject() {
final DataObject dataObject = mock(DataObject.class);
final DataType dataType = mock(DataType.class);
final String structure = "structure";
final String classType = "classType";
when(dataObject.getClassType()).thenReturn(classType);
when(dataTypeManager.structure()).thenReturn(structure);
when(dataTypeManager.fromNew()).thenReturn(dataTypeManager);
when(dataTypeManager.withType(structure)).thenReturn(dataTypeManager);
when(dataTypeManager.get()).thenReturn(dataType);
final DataType actual = dataTypeList.createNewDataType(dataObject);
assertEquals(dataType, actual);
verify(dataType).setName(classType);
}
Aggregations