Search in sources :

Example 1 with IsInformationItem

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);
}
Also used : HasVariable(org.kie.workbench.common.dmn.api.definition.HasVariable) DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) Element(org.kie.workbench.common.stunner.core.graph.Element) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) IsInformationItem(org.kie.workbench.common.dmn.api.definition.model.IsInformationItem) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 2 with 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;
}
Also used : HasText(org.kie.workbench.common.dmn.api.definition.HasText) HasVariable(org.kie.workbench.common.dmn.api.definition.HasVariable) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) IsInformationItem(org.kie.workbench.common.dmn.api.definition.model.IsInformationItem) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Example 3 with IsInformationItem

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;
}
Also used : HasVariable(org.kie.workbench.common.dmn.api.definition.HasVariable) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) IsInformationItem(org.kie.workbench.common.dmn.api.definition.model.IsInformationItem)

Example 4 with IsInformationItem

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();
}
Also used : HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) HasVariable(org.kie.workbench.common.dmn.api.definition.HasVariable) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) IsInformationItem(org.kie.workbench.common.dmn.api.definition.model.IsInformationItem)

Example 5 with IsInformationItem

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);
}
Also used : HasVariable(org.kie.workbench.common.dmn.api.definition.HasVariable) Node(org.kie.workbench.common.stunner.core.graph.Node) IsInformationItem(org.kie.workbench.common.dmn.api.definition.model.IsInformationItem) Test(org.junit.Test)

Aggregations

HasVariable (org.kie.workbench.common.dmn.api.definition.HasVariable)9 IsInformationItem (org.kie.workbench.common.dmn.api.definition.model.IsInformationItem)9 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)4 Test (org.junit.Test)3 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)3 DMNModelInstrumentedBase (org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)2 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1 HasText (org.kie.workbench.common.dmn.api.definition.HasText)1 HasTypeRef (org.kie.workbench.common.dmn.api.definition.HasTypeRef)1 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)1 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)1 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)1 IncludedModel (org.kie.workbench.common.dmn.api.editors.included.IncludedModel)1 Element (org.kie.workbench.common.stunner.core.graph.Element)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 View (org.kie.workbench.common.stunner.core.graph.content.view.View)1