use of org.kie.workbench.common.dmn.api.definition.HasVariable in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricher method getOutputClauseTypeRef.
private Optional<QName> getOutputClauseTypeRef(final HasVariable hasVariable) {
final IsInformationItem variable = hasVariable.getVariable();
if (Objects.nonNull(variable)) {
return Optional.ofNullable(variable.getTypeRef());
}
final DMNModelInstrumentedBase base = hasVariable.asDMNModelInstrumentedBase().getParent();
final DMNModelInstrumentedBase parent = base.getParent();
if (parent instanceof HasTypeRef) {
return Optional.ofNullable(((HasTypeRef) parent).getTypeRef());
}
if (parent instanceof HasVariable) {
return getOutputClauseTypeRef((HasVariable) parent);
}
return Optional.empty();
}
use of org.kie.workbench.common.dmn.api.definition.HasVariable in project kie-wb-common by kiegroup.
the class PropertiesPanelNotifierTest method testNotifyVariables.
@Test
public void testNotifyVariables() {
final Node node = mock(Node.class);
final HasVariable hasVariable = mock(HasVariable.class);
final IsInformationItem informationItem = mock(IsInformationItem.class);
when(hasVariable.getVariable()).thenReturn(informationItem);
doNothing().when(notifier).notifyOutdatedElement(any(), any());
notifier.notifyVariables(node, hasVariable);
verify(notifier).notifyOutdatedElement(node, informationItem);
}
use of org.kie.workbench.common.dmn.api.definition.HasVariable in project kie-wb-common by kiegroup.
the class DMNIncludedNodeFactory method withNamespace.
private DRGElement withNamespace(final DRGElement drgElement, final IncludedModel includeModel) {
final String modelName = includeModel.getModelName();
drgElement.setName(new Name(modelName + "." + drgElement.getName().getValue()));
drgElement.setAllowOnlyVisualChange(true);
if (drgElement instanceof HasVariable) {
final HasVariable hasVariable = (HasVariable) drgElement;
final IsInformationItem variable = hasVariable.getVariable();
final QName qName = variable.getTypeRef();
if (qName != null && !isBuiltInType(qName.getLocalPart())) {
final QName typeRef = new QName(qName.getNamespaceURI(), modelName + "." + qName.getLocalPart(), qName.getPrefix());
setVariable(hasVariable, variable, typeRef);
}
}
return drgElement;
}
use of org.kie.workbench.common.dmn.api.definition.HasVariable in project kie-wb-common by kiegroup.
the class DMNIncludedModelHandler method updateDRGElementsVariableAndId.
private void updateDRGElementsVariableAndId(final String oldModelName, final String newModelName) {
dmnGraphUtils.getModelDRGElements().forEach(drgElement -> {
final Id oldId = drgElement.getId();
if (oldId.getValue().startsWith(oldModelName)) {
final String newId = oldId.getValue().replaceAll("^" + oldModelName, newModelName);
drgElement.setId(new Id(newId));
}
if (drgElement instanceof HasVariable) {
final HasVariable hasVariable = (HasVariable) drgElement;
final IsInformationItem variable = hasVariable.getVariable();
final QName typeRef = variable.getTypeRef();
final String oldType = typeRef.getLocalPart();
if (oldType.startsWith(oldModelName)) {
final String newType = oldType.replaceAll("^" + oldModelName, newModelName);
variable.setTypeRef(new QName(typeRef.getNamespaceURI(), newType, typeRef.getPrefix()));
}
}
});
}
use of org.kie.workbench.common.dmn.api.definition.HasVariable in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricher method getOutputClauseName.
private Optional<String> getOutputClauseName(final HasVariable hasVariable) {
final IsInformationItem variable = hasVariable.getVariable();
if (variable instanceof InformationItem) {
return Optional.ofNullable((variable).getName().getValue());
}
final DMNModelInstrumentedBase base = hasVariable.asDMNModelInstrumentedBase().getParent();
final DMNModelInstrumentedBase parent = base.getParent();
if (parent instanceof HasName) {
return Optional.ofNullable(((HasName) parent).getName().getValue());
}
if (parent instanceof HasVariable) {
return getOutputClauseName((HasVariable) parent);
}
return Optional.empty();
}
Aggregations