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