use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionTest method testClear.
@Test
public void testClear() {
final DMNDiagramElement dmnDiagram = mock(DMNDiagramElement.class);
final Diagram stunnerDiagram = mock(Diagram.class);
final String diagramId = "0000";
when(dmnDiagram.getId()).thenReturn(new Id(diagramId));
dmnDiagramsSession.add(dmnDiagram, stunnerDiagram);
assertEquals(dmnDiagram, dmnDiagramsSession.getDMNDiagramElement(diagramId));
assertEquals(stunnerDiagram, dmnDiagramsSession.getDiagram(diagramId));
assertEquals(dmnDiagram, dmnDiagramsSession.getDiagramTuple(diagramId).getDMNDiagram());
assertEquals(stunnerDiagram, dmnDiagramsSession.getDiagramTuple(diagramId).getStunnerDiagram());
dmnDiagramsSession.clear();
assertNull(dmnDiagramsSession.getDMNDiagramElement(diagramId));
assertNull(dmnDiagramsSession.getDiagram(diagramId));
assertNull(dmnDiagramsSession.getDiagramTuple(diagramId).getDMNDiagram());
assertNull(dmnDiagramsSession.getDiagramTuple(diagramId).getStunnerDiagram());
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class ObserverBuilderControl method updateElementFromDefinition.
@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());
}
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DMNMarshallerService method onDiagramSelected.
public void onDiagramSelected(@Observes final DMNDiagramSelected selected) {
final DMNDiagramElement dmnDiagramElement = selected.getDiagramElement();
if (isActiveService()) {
final String diagramId = dmnDiagramElement.getId().getValue();
final Diagram stunnerDiagram = dmnDiagramsSession.getDiagram(diagramId);
final Metadata metadata = dmnDiagramsSession.getDRGDiagram().getMetadata();
final String fileName = metadata.getPath().getFileName();
final Diagram diagram = dmnDiagramFactory.build(fileName, metadata, stunnerDiagram.getGraph());
onDiagramLoad(diagram);
}
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionState method getDiagramTuple.
DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId) {
final Diagram diagram = getDiagram(dmnDiagramElementId);
final DMNDiagramElement dmnDiagramElement = getDMNDiagramElement(dmnDiagramElementId);
return new DMNDiagramTuple(diagram, dmnDiagramElement);
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DecisionNavigatorItemFactory method makeRoot.
public DecisionNavigatorItem makeRoot(final DMNDiagramTuple diagramTuple) {
final DMNDiagramElement dmnDiagramElement = diagramTuple.getDMNDiagram();
final String uuid = dmnDiagramElement.getId().getValue();
final String diagramName = dmnDiagramElement.getName().getValue();
final String label;
final boolean isDRG = isDRG(dmnDiagramElement);
if (isDRG) {
final Graph graph = diagramTuple.getStunnerDiagram().getGraph();
final Node<?, ?> rootNode = getRootNode(graph);
label = getNodeName(rootNode);
} else {
label = diagramName;
}
return navigatorItemBuilder().withUUID(uuid).withLabel(label).withType(ROOT).withIsDRG(isDRG).withOnClick(getOnClickAction(dmnDiagramElement)).withOnUpdate(getOnUpdate(dmnDiagramElement)).withOnRemove(getOnRemove(dmnDiagramElement)).build();
}
Aggregations