@Test public void testUpdateDMNDiagramIdFromSelectedDMNDiagram() { final DRGElement newDefinition = mock(DRGElement.class); final Element element = mock(Element.class); final View elementContent = mock(View.class); final Object definition = mock(Object.class); final String selectedDiagramId = "selected diagram id"; final DMNDiagramElement selectedDiagram = mock(DMNDiagramElement.class); final Id id = mock(Id.class); when(id.getValue()).thenReturn(selectedDiagramId); when(selectedDiagram.getId()).thenReturn(id); when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(selectedDiagram)); when(elementContent.getDefinition()).thenReturn(newDefinition); when(element.getContent()).thenReturn(elementContent); observerBuilderControl.updateElementFromDefinition(element, definition); verify(newDefinition).setDiagramId(selectedDiagramId); }
@Override @SuppressWarnings("unchecked") protected void updateElementFromDefinition(final Element element, final Object definition) { final Object content = element.getContent(); if (!(content instanceof View)) { return; } final Object newDefinition = ((View) content).getDefinition(); if (newDefinition instanceof HasName && definition instanceof HasName) { ((HasName) newDefinition).getName().setValue(((HasName) definition).getName().getValue()); } if (newDefinition instanceof DynamicReadOnly && definition instanceof DynamicReadOnly) { ((DynamicReadOnly) newDefinition).setAllowOnlyVisualChange(((DynamicReadOnly) definition).isAllowOnlyVisualChange()); } if (newDefinition instanceof HasVariable && definition instanceof HasVariable) { ((HasVariable) newDefinition).setVariable(((HasVariable) definition).getVariable()); } if (newDefinition instanceof BusinessKnowledgeModel && definition instanceof BusinessKnowledgeModel) { ((BusinessKnowledgeModel) newDefinition).setEncapsulatedLogic(((BusinessKnowledgeModel) definition).getEncapsulatedLogic()); } if (newDefinition instanceof HasExpression && definition instanceof HasExpression) { ((HasExpression) newDefinition).setExpression(((HasExpression) definition).getExpression()); } if (newDefinition instanceof DMNElement && definition instanceof DMNElement) { final DMNElement dmnElement = (DMNElement) definition; if (!StringUtils.isEmpty(dmnElement.getId().getValue())) { ((DMNElement) newDefinition).getId().setValue(dmnElement.getId().getValue()); } } final Optional<DMNDiagramElement> currentDMNDiagramElement = getDMNDiagramsSession().getCurrentDMNDiagramElement(); if (currentDMNDiagramElement.isPresent() && newDefinition instanceof HasContentDefinitionId) { ((HasContentDefinitionId) newDefinition).setDiagramId(currentDMNDiagramElement.get().getId().getValue()); } }
ObserverBuilderControl extends org.kie.workbench.common.stunner.core.client.canvas.controls.builder.impl.ObserverBuilderControl { @Override @SuppressWarnings("unchecked") protected void updateElementFromDefinition(final Element element, final Object definition) { final Object content = element.getContent(); if (!(content instanceof View)) { return; } final Object newDefinition = ((View) content).getDefinition(); if (newDefinition instanceof HasName && definition instanceof HasName) { ((HasName) newDefinition).getName().setValue(((HasName) definition).getName().getValue()); } if (newDefinition instanceof DynamicReadOnly && definition instanceof DynamicReadOnly) { ((DynamicReadOnly) newDefinition).setAllowOnlyVisualChange(((DynamicReadOnly) definition).isAllowOnlyVisualChange()); } if (newDefinition instanceof HasVariable && definition instanceof HasVariable) { ((HasVariable) newDefinition).setVariable(((HasVariable) definition).getVariable()); } if (newDefinition instanceof BusinessKnowledgeModel && definition instanceof BusinessKnowledgeModel) { ((BusinessKnowledgeModel) newDefinition).setEncapsulatedLogic(((BusinessKnowledgeModel) definition).getEncapsulatedLogic()); } if (newDefinition instanceof HasExpression && definition instanceof HasExpression) { ((HasExpression) newDefinition).setExpression(((HasExpression) definition).getExpression()); } if (newDefinition instanceof DMNElement && definition instanceof DMNElement) { final DMNElement dmnElement = (DMNElement) definition; if (!StringUtils.isEmpty(dmnElement.getId().getValue())) { ((DMNElement) newDefinition).getId().setValue(dmnElement.getId().getValue()); } } final Optional<DMNDiagramElement> currentDMNDiagramElement = getDMNDiagramsSession().getCurrentDMNDiagramElement(); if (currentDMNDiagramElement.isPresent() && newDefinition instanceof HasContentDefinitionId) { ((HasContentDefinitionId) newDefinition).setDiagramId(currentDMNDiagramElement.get().getId().getValue()); } } }
ObserverBuilderControl extends org.kie.workbench.common.stunner.core.client.canvas.controls.builder.impl.ObserverBuilderControl { @Override @SuppressWarnings("unchecked") protected void updateElementFromDefinition(final Element element, final Object definition) { final Object content = element.getContent(); if (!(content instanceof View)) { return; } final Object newDefinition = ((View) content).getDefinition(); if (newDefinition instanceof HasName && definition instanceof HasName) { ((HasName) newDefinition).getName().setValue(((HasName) definition).getName().getValue()); } if (newDefinition instanceof DynamicReadOnly && definition instanceof DynamicReadOnly) { ((DynamicReadOnly) newDefinition).setAllowOnlyVisualChange(((DynamicReadOnly) definition).isAllowOnlyVisualChange()); } if (newDefinition instanceof HasVariable && definition instanceof HasVariable) { ((HasVariable) newDefinition).setVariable(((HasVariable) definition).getVariable()); } if (newDefinition instanceof BusinessKnowledgeModel && definition instanceof BusinessKnowledgeModel) { ((BusinessKnowledgeModel) newDefinition).setEncapsulatedLogic(((BusinessKnowledgeModel) definition).getEncapsulatedLogic()); } if (newDefinition instanceof HasExpression && definition instanceof HasExpression) { ((HasExpression) newDefinition).setExpression(((HasExpression) definition).getExpression()); } if (newDefinition instanceof DMNElement && definition instanceof DMNElement) { final DMNElement dmnElement = (DMNElement) definition; if (!StringUtils.isEmpty(dmnElement.getId().getValue())) { ((DMNElement) newDefinition).getId().setValue(dmnElement.getId().getValue()); } } final Optional<DMNDiagramElement> currentDMNDiagramElement = getDMNDiagramsSession().getCurrentDMNDiagramElement(); if (currentDMNDiagramElement.isPresent() && newDefinition instanceof HasContentDefinitionId) { ((HasContentDefinitionId) newDefinition).setDiagramId(currentDMNDiagramElement.get().getId().getValue()); } } @Inject  ObserverBuilderControl(final ClientDefinitionManager clientDefinitionManager,
                                  final ClientFactoryService clientFactoryServices,
                                  final RuleManager ruleManager,
                                  final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory,
                                  final ClientTranslationMessages translationMessages,
                                  final GraphBoundsIndexer graphBoundsIndexer,
                                  final Event<CanvasSelectionEvent> canvasSelectionEvent,
                                  final DMNDiagramsSession dmnDiagramsSession); }
ObserverBuilderControl extends org.kie.workbench.common.stunner.core.client.canvas.controls.builder.impl.ObserverBuilderControl { @Override @SuppressWarnings("unchecked") protected void updateElementFromDefinition(final Element element, final Object definition) { final Object content = element.getContent(); if (!(content instanceof View)) { return; } final Object newDefinition = ((View) content).getDefinition(); if (newDefinition instanceof HasName && definition instanceof HasName) { ((HasName) newDefinition).getName().setValue(((HasName) definition).getName().getValue()); } if (newDefinition instanceof DynamicReadOnly && definition instanceof DynamicReadOnly) { ((DynamicReadOnly) newDefinition).setAllowOnlyVisualChange(((DynamicReadOnly) definition).isAllowOnlyVisualChange()); } if (newDefinition instanceof HasVariable && definition instanceof HasVariable) { ((HasVariable) newDefinition).setVariable(((HasVariable) definition).getVariable()); } if (newDefinition instanceof BusinessKnowledgeModel && definition instanceof BusinessKnowledgeModel) { ((BusinessKnowledgeModel) newDefinition).setEncapsulatedLogic(((BusinessKnowledgeModel) definition).getEncapsulatedLogic()); } if (newDefinition instanceof HasExpression && definition instanceof HasExpression) { ((HasExpression) newDefinition).setExpression(((HasExpression) definition).getExpression()); } if (newDefinition instanceof DMNElement && definition instanceof DMNElement) { final DMNElement dmnElement = (DMNElement) definition; if (!StringUtils.isEmpty(dmnElement.getId().getValue())) { ((DMNElement) newDefinition).getId().setValue(dmnElement.getId().getValue()); } } final Optional<DMNDiagramElement> currentDMNDiagramElement = getDMNDiagramsSession().getCurrentDMNDiagramElement(); if (currentDMNDiagramElement.isPresent() && newDefinition instanceof HasContentDefinitionId) { ((HasContentDefinitionId) newDefinition).setDiagramId(currentDMNDiagramElement.get().getId().getValue()); } } @Inject  ObserverBuilderControl(final ClientDefinitionManager clientDefinitionManager,
                                  final ClientFactoryService clientFactoryServices,
                                  final RuleManager ruleManager,
                                  final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory,
                                  final ClientTranslationMessages translationMessages,
                                  final GraphBoundsIndexer graphBoundsIndexer,
                                  final Event<CanvasSelectionEvent> canvasSelectionEvent,
                                  final DMNDiagramsSession dmnDiagramsSession);  }
ObserverBuilderControl extends org.kie.workbench.common.stunner.core.client.canvas.controls.builder.impl.ObserverBuilderControl { @Override @SuppressWarnings("unchecked") protected void updateElementFromDefinition(final Element element, final Object definition) { final Object content = element.getContent(); if (!(content instanceof View)) { return; } final Object newDefinition = ((View) content).getDefinition(); if (newDefinition instanceof HasName && definition instanceof HasName) { ((HasName) newDefinition).getName().setValue(((HasName) definition).getName().getValue()); } if (newDefinition instanceof DynamicReadOnly && definition instanceof DynamicReadOnly) { ((DynamicReadOnly) newDefinition).setAllowOnlyVisualChange(((DynamicReadOnly) definition).isAllowOnlyVisualChange()); } if (newDefinition instanceof HasVariable && definition instanceof HasVariable) { ((HasVariable) newDefinition).setVariable(((HasVariable) definition).getVariable()); } if (newDefinition instanceof BusinessKnowledgeModel && definition instanceof BusinessKnowledgeModel) { ((BusinessKnowledgeModel) newDefinition).setEncapsulatedLogic(((BusinessKnowledgeModel) definition).getEncapsulatedLogic()); } if (newDefinition instanceof HasExpression && definition instanceof HasExpression) { ((HasExpression) newDefinition).setExpression(((HasExpression) definition).getExpression()); } if (newDefinition instanceof DMNElement && definition instanceof DMNElement) { final DMNElement dmnElement = (DMNElement) definition; if (!StringUtils.isEmpty(dmnElement.getId().getValue())) { ((DMNElement) newDefinition).getId().setValue(dmnElement.getId().getValue()); } } final Optional<DMNDiagramElement> currentDMNDiagramElement = getDMNDiagramsSession().getCurrentDMNDiagramElement(); if (currentDMNDiagramElement.isPresent() && newDefinition instanceof HasContentDefinitionId) { ((HasContentDefinitionId) newDefinition).setDiagramId(currentDMNDiagramElement.get().getId().getValue()); } } @Inject  ObserverBuilderControl(final ClientDefinitionManager clientDefinitionManager,
                                  final ClientFactoryService clientFactoryServices,
                                  final RuleManager ruleManager,
                                  final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory,
                                  final ClientTranslationMessages translationMessages,
                                  final GraphBoundsIndexer graphBoundsIndexer,
                                  final Event<CanvasSelectionEvent> canvasSelectionEvent,
                                  final DMNDiagramsSession dmnDiagramsSession);   }