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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations