Search in sources :

Example 11 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.

the class ImportDataObjectModalTest method testWrap.

@Test
public void testWrap() {
    final Consumer consumer = mock(Consumer.class);
    final ServiceCallback service = modal.wrap(consumer);
    final List<DataObject> items = mock(List.class);
    service.onSuccess(items);
    verify(consumer).accept(items);
}
Also used : ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) Consumer(java.util.function.Consumer) Test(org.junit.Test)

Example 12 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.

the class DataObjectsServiceImpl method loadDataObjects.

@Override
public List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject) {
    final KieModule module = moduleService.resolveModule(workspaceProject.getRootPath());
    final ClassLoader classLoader = moduleClassLoaderHelper.getModuleClassLoader(module);
    final ModuleDataModelOracle dmo = dataModelService.getModuleDataModel(workspaceProject.getRootPath());
    final String[] types = DataModelOracleUtilities.getFactTypes(dmo);
    final Map<String, ModelField[]> typesModelFields = dmo.getModuleModelFields();
    final Map<String, String> parametersType = dmo.getModuleFieldParametersType();
    final List<DataObject> dataObjects = Arrays.stream(types).map(DataObject::new).collect(Collectors.toList());
    dataObjects.forEach(dataObject -> convertProperties(dataObject, dataObjects, typesModelFields, classLoader, parametersType));
    return dataObjects;
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) KieModule(org.kie.workbench.common.services.shared.project.KieModule)

Example 13 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.

the class DataTypeList method removeFullQualifiedNames.

void removeFullQualifiedNames(final List<DataObject> imported) {
    final Map<String, Integer> namesCount = getImportedNamesOccurrencesCount();
    final Map<String, String> renamed = getRenamedImportedDataTypes();
    namesCount.clear();
    renamed.clear();
    for (final DataObject dataObject : imported) {
        final String nameCandidate = dataObject.getClassNameWithoutPackage();
        final String newName = buildName(nameCandidate, namesCount);
        renamed.put(dataObject.getClassType(), newName);
        dataObject.setClassType(newName);
    }
    updatePropertiesReferences(imported, renamed);
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject)

Example 14 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.

the class DataTypeListTest method testUpdatePropertiesReferences.

@Test
public void testUpdatePropertiesReferences() {
    final List<DataObject> imported = new ArrayList<>();
    final HashMap<String, String> renamed = new HashMap<>();
    final String propertyType1 = "type";
    final String propertyNewType1 = "type-1";
    final String uniqueType = "uniqueType";
    renamed.put(propertyType1, propertyNewType1);
    final DataObjectProperty prop1 = mock(DataObjectProperty.class);
    final DataObjectProperty prop2 = mock(DataObjectProperty.class);
    when(prop1.getType()).thenReturn(propertyType1);
    when(prop2.getType()).thenReturn(uniqueType);
    doReturn(true).when(dataTypeList).isPropertyTypePresent(uniqueType, imported);
    doReturn(true).when(dataTypeList).isPropertyTypePresent(propertyNewType1, imported);
    final DataObject do1 = new DataObject();
    do1.setProperties(Arrays.asList(prop1, prop2));
    imported.add(do1);
    dataTypeList.updatePropertiesReferences(imported, renamed);
    verify(prop1).setType(propertyNewType1);
    verify(prop2).setType(uniqueType);
    verify(dataTypeList).isPropertyTypePresent(propertyNewType1, imported);
    verify(dataTypeList).isPropertyTypePresent(uniqueType, imported);
}
Also used : DataObjectProperty(org.kie.workbench.common.dmn.api.editors.types.DataObjectProperty) DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 15 with DataObject

use of org.kie.workbench.common.dmn.api.editors.types.DataObject in project kie-wb-common by kiegroup.

the class DataTypeListTest method createDataObject.

private DataObject createDataObject(final String className) {
    final DataObject dataObject = mock(DataObject.class);
    when(dataObject.getClassType()).thenReturn(className);
    return dataObject;
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject)

Aggregations

DataObject (org.kie.workbench.common.dmn.api.editors.types.DataObject)21 Test (org.junit.Test)13 TreeListItem (org.kie.workbench.common.dmn.client.editors.types.imported.treelist.TreeListItem)5 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)4 DataObjectProperty (org.kie.workbench.common.dmn.api.editors.types.DataObjectProperty)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Consumer (java.util.function.Consumer)1 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)1 BuiltInType (org.kie.workbench.common.dmn.api.property.dmn.types.BuiltInType)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 ServiceCallback (org.kie.workbench.common.stunner.core.client.service.ServiceCallback)1