Search in sources :

Example 11 with ItemDefinition

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

the class ItemDefinitionPropertyConverter method dmnFromWB.

public static org.kie.dmn.model.api.ItemDefinition dmnFromWB(final ItemDefinition wb) {
    if (wb == null) {
        return null;
    }
    final org.kie.dmn.model.api.ItemDefinition result = new org.kie.dmn.model.v1_2.TItemDefinition();
    result.setId(wb.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    result.setName(wb.getName().getValue());
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    result.setTypeLanguage(wb.getTypeLanguage());
    result.setIsCollection(wb.isIsCollection());
    final org.kie.dmn.model.api.UnaryTests utConverted = UnaryTestsPropertyConverter.dmnFromWB(wb.getAllowedValues());
    if (utConverted != null) {
        utConverted.setParent(result);
    }
    result.setAllowedValues(utConverted);
    for (ItemDefinition child : wb.getItemComponent()) {
        final org.kie.dmn.model.api.ItemDefinition convertedChild = ItemDefinitionPropertyConverter.dmnFromWB(child);
        convertedChild.setParent(result);
        result.getItemComponent().add(convertedChild);
    }
    return result;
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)

Example 12 with ItemDefinition

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

the class ItemDefinitionPropertyConverter method wbFromDMN.

public static ItemDefinition wbFromDMN(final org.kie.dmn.model.api.ItemDefinition dmn) {
    if (dmn == null) {
        return null;
    }
    final Id id = new Id(dmn.getId());
    final Name name = new Name(dmn.getName());
    final Description description = wbDescriptionFromDMN(dmn);
    final QName typeRef = wbTypeRefFromDMN(dmn);
    final String typeLanguage = dmn.getTypeLanguage();
    final boolean isCollection = dmn.isIsCollection();
    final ItemDefinition wb = new ItemDefinition(id, description, name, typeRef, null, null, typeLanguage, isCollection, false);
    setUnaryTests(wb, dmn);
    setItemComponent(wb, dmn);
    return wb;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 13 with ItemDefinition

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

the class ItemDefinitionRecordEngine method update.

@Override
public List<DataType> update(final DataType dataType) {
    if (!dataType.isValid()) {
        throw new UnsupportedOperationException("An invalid Data Type cannot be updated.");
    }
    final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID());
    final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue();
    doUpdate(dataType, itemDefinition);
    return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)

Example 14 with ItemDefinition

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

the class ItemDefinitionCreateHandler method insertSibling.

public ItemDefinition insertSibling(final DataType record, final DataType reference, final CreationType creationType) {
    final ItemDefinition itemDefinition = getItemDefinition(record);
    final ItemDefinition itemDefinitionReference = getIndexedItemDefinition(reference.getUUID());
    final List<ItemDefinition> siblings = getItemDefinitionSiblings(reference);
    siblings.add(siblings.indexOf(itemDefinitionReference) + creationType.getIndexIncrement(), itemDefinition);
    return itemDefinition;
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)

Example 15 with ItemDefinition

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

the class ItemDefinitionCreateHandler method insertNested.

public ItemDefinition insertNested(final DataType record, final DataType reference) {
    final ItemDefinition itemDefinition = getItemDefinition(record);
    final ItemDefinition relativeParent = getIndexedItemDefinition(reference.getUUID());
    final Optional<ItemDefinition> absoluteParent = lookupAbsoluteParent(reference.getUUID());
    final List<ItemDefinition> itemComponent;
    if (absoluteParent.isPresent()) {
        itemComponent = absoluteParent.get().getItemComponent();
    } else {
        itemComponent = relativeParent.getItemComponent();
        relativeParent.setTypeRef(null);
    }
    itemComponent.add(0, itemDefinition);
    return itemDefinition;
}
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