Search in sources :

Example 66 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionCreateHandler method lookupAbsoluteParent.

Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) {
    final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID));
    if (optionalParent.isPresent()) {
        final ItemDefinition parent = optionalParent.get();
        final boolean isStructure = parent.getTypeRef() == null;
        if (isStructure) {
            return Optional.of(parent);
        } else {
            return findItemDefinitionByName(parent.getTypeRef().getLocalPart());
        }
    }
    return Optional.empty();
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)

Example 67 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ImportedItemDefinitionConverterTest method testWbFromDMN.

@Test
public void testWbFromDMN() {
    final org.kie.dmn.model.api.ItemDefinition itemDefinition = new TItemDefinition();
    final org.kie.dmn.model.api.ItemDefinition itemComponent1 = new TItemDefinition();
    final org.kie.dmn.model.api.ItemDefinition itemComponent2 = new TItemDefinition();
    final org.kie.dmn.model.api.ItemDefinition itemComponent3 = new TItemDefinition();
    itemDefinition.setName("tPerson");
    itemDefinition.setTypeRef(null);
    itemDefinition.getItemComponent().addAll(asList(itemComponent1, itemComponent2, itemComponent3));
    itemComponent1.setName("id");
    itemComponent1.setTypeRef(new QName("tUUID"));
    itemComponent2.setName("name");
    itemComponent2.setTypeRef(new QName("string"));
    itemComponent3.setName("age");
    itemComponent3.setTypeRef(new QName("number"));
    final ItemDefinition actualItemDefinition = ImportedItemDefinitionConverter.wbFromDMN(itemDefinition, "model");
    assertEquals("model.tPerson", actualItemDefinition.getName().getValue());
    assertNull(actualItemDefinition.getTypeRef());
    assertTrue(actualItemDefinition.isAllowOnlyVisualChange());
    assertEquals(3, actualItemDefinition.getItemComponent().size());
    final ItemDefinition actualItemDefinition1 = actualItemDefinition.getItemComponent().get(0);
    assertEquals("model.id", actualItemDefinition1.getName().getValue());
    assertEquals("model.tUUID", actualItemDefinition1.getTypeRef().getLocalPart());
    assertTrue(actualItemDefinition1.isAllowOnlyVisualChange());
    final ItemDefinition actualItemDefinition2 = actualItemDefinition.getItemComponent().get(1);
    assertEquals("model.name", actualItemDefinition2.getName().getValue());
    assertEquals("string", actualItemDefinition2.getTypeRef().getLocalPart());
    assertTrue(actualItemDefinition2.isAllowOnlyVisualChange());
    final ItemDefinition actualItemDefinition3 = actualItemDefinition.getItemComponent().get(2);
    assertEquals("model.age", actualItemDefinition3.getName().getValue());
    assertEquals("number", actualItemDefinition3.getTypeRef().getLocalPart());
    assertTrue(actualItemDefinition3.isAllowOnlyVisualChange());
}
Also used : QName(javax.xml.namespace.QName) TItemDefinition(org.kie.dmn.model.v1_2.TItemDefinition) TItemDefinition(org.kie.dmn.model.v1_2.TItemDefinition) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Test(org.junit.Test)

Example 68 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionHandler method update.

@Override
public void update(final String oldModelName, final String newModelName) {
    final List<ItemDefinition> updatedItemDefinitionsByName = findItemDefinitionsByOldName(oldModelName);
    final List<ItemDefinition> updatedItemDefinitionsByType = findItemDefinitionsByUpdatedItemDefinitions(updatedItemDefinitionsByName);
    updatedItemDefinitionsByName.forEach(itemDefinition -> {
        final String oldName = itemDefinition.getName().getValue();
        final String newName = oldName.replaceAll("^" + oldModelName, newModelName);
        final Name name = new Name(newName);
        itemDefinition.setName(name);
        notifyPropertiesPanel(oldName, newName);
    });
    updatedItemDefinitionsByType.forEach(itemDefinition -> {
        final QName oldType = itemDefinition.getTypeRef();
        final String newLocalPart = oldType.getLocalPart().replaceAll("^" + oldModelName, newModelName);
        final QName qName = new QName(oldType.getNamespaceURI(), newLocalPart, oldType.getPrefix());
        itemDefinition.setTypeRef(qName);
    });
    refreshDataTypesList();
}
Also used : QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 69 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class DataTypePickerWidget method addItemDefinitions.

void addItemDefinitions() {
    final Definitions definitions = dmnGraphUtils.getModelDefinitions();
    final List<ItemDefinition> itemDefinitions = definitions != null ? definitions.getItemDefinition() : Collections.emptyList();
    final OptGroup group = GWT.create(OptGroup.class);
    group.setLabel(translationService.getTranslation(DMNEditorConstants.DataTypeSelectView_CustomTitle));
    itemDefinitions.stream().sorted(ITEM_DEFINITION_COMPARATOR).map(this::makeTypeSelector).filter(Optional::isPresent).forEach(o -> group.add(o.get()));
    typeSelector.add(group);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) OptGroup(org.gwtbootstrap3.extras.select.client.ui.OptGroup)

Example 70 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class DataTypeConfirmation method hasLostSubDataTypes.

private boolean hasLostSubDataTypes(final DataType dataType) {
    final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID());
    final boolean isDataTypeNotStructure = !isStructure(dataType);
    final boolean hasItemDefinitionSubItemDefinitions = !itemDefinition.getItemComponent().isEmpty();
    return isDataTypeNotStructure && hasItemDefinitionSubItemDefinitions;
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)

Aggregations

ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)119 Test (org.junit.Test)86 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)39 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)37 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)36 ArrayList (java.util.ArrayList)18 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)16 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)9 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)8 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)7 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)7 JSITItemDefinition (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)7 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)6 DataTypeManager (org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager)6 QName (javax.xml.namespace.QName)4 Import (org.kie.workbench.common.dmn.api.definition.model.Import)4 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)4 RefreshDataTypesListEvent (org.kie.workbench.common.dmn.client.editors.types.common.events.RefreshDataTypesListEvent)4 DMNGraphUtils (org.kie.workbench.common.dmn.client.graph.DMNGraphUtils)4 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)3