use of org.kie.workbench.common.dmn.api.definition.model.IsInformationItem in project kie-wb-common by kiegroup.
the class ObserverBuilderControlTest method testUpdateVariableFromDefinition.
@Test
@SuppressWarnings("unchecked")
public void testUpdateVariableFromDefinition() {
final Element element = mock(Element.class);
final View elementContent = mock(View.class);
final HasVariable newHasVariable = mock(HasVariable.class);
final HasVariable hasVariable = mock(HasVariable.class);
final IsInformationItem isInformationItem = mock(IsInformationItem.class);
when(element.getContent()).thenReturn(elementContent);
when(elementContent.getDefinition()).thenReturn(newHasVariable);
when(hasVariable.getVariable()).thenReturn(isInformationItem);
observerBuilderControl.updateElementFromDefinition(element, hasVariable);
verify(newHasVariable).setVariable(isInformationItem);
}
use of org.kie.workbench.common.dmn.api.definition.model.IsInformationItem in project kie-wb-common by kiegroup.
the class DMNDeepCloneProcess method clone.
/**
* <p>It defines additive fields, specific to DMN domain, to be included in the target</p>
* <p>Then, the "classic" clone operation, defined in {@link DeepCloneProcess} will be executed</p>
* <p>Note that {@link DeepCloneProcess} is already taking care of aspects related to look&feel, such as background color, font, etc.</p>
* <p>Every time we copy a node, in order to respect the name uniqueness logic, a new node will be created with a suffix {@code -X},
* where {@code X} it is an incremental numeric value</p>
*
* @param source node to be cloned
* @param target destination of the cloning operation
* @return cloned instance, i.e. target element
*/
@Override
public <S, T> T clone(final S source, final T target) {
super.clone(source, target);
if (source instanceof DRGElement) {
cloneDRGElementBasicInfo((DRGElement) source, (DRGElement) target);
}
if (source instanceof HasText) {
cloneTextElementBasicInfo((HasText) source, (HasText) target);
}
if (source instanceof HasVariable) {
final IsInformationItem sourceVariable = ((HasVariable) source).getVariable();
final IsInformationItem targetVariable = ((HasVariable) target).getVariable();
cloneTypeRefInfo(sourceVariable, targetVariable);
}
if (source instanceof Decision) {
cloneDecision((Decision) source, (Decision) target);
}
if (source instanceof BusinessKnowledgeModel) {
cloneBusinessKnowledgeModel((BusinessKnowledgeModel) source, (BusinessKnowledgeModel) target);
}
return target;
}
use of org.kie.workbench.common.dmn.api.definition.model.IsInformationItem in project kie-wb-common by kiegroup.
the class DMNIncludedNodeFactory method drgElementWithNamespace.
DRGElement drgElementWithNamespace(final DRGElement drgElement, final IncludedModel includeModel) {
final String modelName = includeModel.getModelName();
drgElement.setName(createName(drgElement, modelName));
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 = createTypeRef(modelName, qName);
setVariable(hasVariable, variable, typeRef);
}
}
return drgElement;
}
use of org.kie.workbench.common.dmn.api.definition.model.IsInformationItem 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.model.IsInformationItem 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);
}
Aggregations