Search in sources :

Example 1 with DataType

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

the class DataTypeCreateHandler method insertSibling.

public List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition) {
    final Optional<DataType> parentOptional = lookupAbsoluteParent(reference);
    if (parentOptional.isPresent()) {
        final DataType parent = parentOptional.get();
        final List<DataType> siblings = parent.getSubDataTypes();
        final DataType updatedDataType = updateDataTypeProperties(dataType, parent.getUUID(), itemDefinition);
        final DataType parentReference = findParentReference(reference, siblings);
        siblings.add(siblings.indexOf(parentReference) + creationType.getIndexIncrement(), updatedDataType);
        recordEngine.doUpdate(dataType, itemDefinition);
        return recordEngine.update(parent);
    } else {
        final DataType updatedDataType = updateDataTypeProperties(dataType, reference.getParentUUID(), itemDefinition);
        recordEngine.doUpdate(updatedDataType, itemDefinition);
        return new ArrayList<>();
    }
}
Also used : ArrayList(java.util.ArrayList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType)

Example 2 with DataType

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

the class DataTypeSearchEngine method getStack.

private List<DataType> getStack(final List<DataType> stack, final DataType dataType) {
    final DataType parent = parent(dataType);
    stack.add(dataType);
    if (dataType.isTopLevel() || Objects.isNull(parent)) {
        return stack;
    }
    return getStack(stack, parent);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType)

Example 3 with DataType

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

the class DataTypeList method createNewDataType.

DataType createNewDataType(final DataObject dataObject) {
    final DataType newDataType = dataTypeManager.fromNew().withType(dataTypeManager.structure()).get();
    newDataType.setName(dataObject.getClassType());
    return newDataType;
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType)

Example 4 with DataType

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

the class DataTypeList method refreshSubItemsFromListItem.

void refreshSubItemsFromListItem(final DataTypeListItem listItem, final List<DataType> subDataTypes) {
    final DataType dataType = listItem.getDataType();
    final int level = listItem.getLevel();
    final List<DataTypeListItem> listItems = new ArrayList<>();
    for (final DataType subDataType : subDataTypes) {
        listItems.addAll(makeTreeListItems(subDataType, level + 1));
    }
    final List<HTMLElement> children = listItems.stream().map(e -> e.getDragAndDropElement()).collect(Collectors.toList());
    dndListComponent.setInitialPositionY(listItem.getDragAndDropElement(), children);
    cleanAndUnIndex(dataType);
    addNewSubItems(dataType, listItems);
    listItems.forEach(this::reIndexDataTypes);
    getItems().addAll(listItems);
}
Also used : Element(elemental2.dom.Element) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) DataObjectProperty(org.kie.workbench.common.dmn.api.editors.types.DataObjectProperty) DNDDataTypesHandler(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDDataTypesHandler) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Inject(javax.inject.Inject) BuiltInTypeUtils(org.kie.workbench.common.dmn.api.editors.types.BuiltInTypeUtils) IsElement(org.jboss.errai.ui.client.local.api.elemental2.IsElement) HTMLElement(elemental2.dom.HTMLElement) Map(java.util.Map) Observes(javax.enterprise.event.Observes) BiConsumer(java.util.function.BiConsumer) DataTypeEditModeToggleEvent(org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeEditModeToggleEvent) DataTypeSearchBar(org.kie.workbench.common.dmn.client.editors.types.search.DataTypeSearchBar) DNDListComponent(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent) DataTypeStackHash(org.kie.workbench.common.dmn.client.editors.types.listview.common.DataTypeStackHash) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) DataTypeManager(org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Consumer(java.util.function.Consumer) List(java.util.List) PostConstruct(javax.annotation.PostConstruct) BuiltInType(org.kie.workbench.common.dmn.api.property.dmn.types.BuiltInType) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) UberElemental(org.uberfire.client.mvp.UberElemental) HTMLElement(elemental2.dom.HTMLElement) ArrayList(java.util.ArrayList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType)

Example 5 with DataType

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

the class DataTypeList method createNewDataType.

DataType createNewDataType(final DataObjectProperty dataProperty) {
    final DataType newDataType = dataTypeManager.fromNew().withType(dataProperty.getType()).asList(dataProperty.isList()).get();
    newDataType.setName(dataProperty.getProperty());
    return newDataType;
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType)

Aggregations

DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)274 Test (org.junit.Test)245 HTMLElement (elemental2.dom.HTMLElement)44 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)39 Element (elemental2.dom.Element)30 ArrayList (java.util.ArrayList)26 DOMTokenList (elemental2.dom.DOMTokenList)24 DataTypeListItem (org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem)14 HTMLDivElement (elemental2.dom.HTMLDivElement)13 HTMLButtonElement (elemental2.dom.HTMLButtonElement)12 Command (org.uberfire.mvp.Command)12 FlashMessage (org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage)9 DataTypeManager (org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager)9 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)8 DNDListComponent (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)6 HTMLInputElement (elemental2.dom.HTMLInputElement)6 DataObject (org.kie.workbench.common.dmn.api.editors.types.DataObject)6