use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNCanvasHandlerTest method getElementForTestUpdateDiagramId.
private Element getElementForTestUpdateDiagramId(final String diagramId, final String currentDiagramId, final HasContentDefinitionId hasContentDefinitionId) {
final Element element = mock(Element.class);
final Definition definition = mock(Definition.class);
final GraphsProvider graphsProvider = mock(GraphsProvider.class);
when(graphsProvider.getCurrentDiagramId()).thenReturn(diagramId);
when(definition.getDefinition()).thenReturn(hasContentDefinitionId);
when(element.getContent()).thenReturn(definition);
when(hasContentDefinitionId.getDiagramId()).thenReturn(currentDiagramId);
when(canvasHandler.getGraphsProvider()).thenReturn(graphsProvider);
return element;
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class ConnectorParentsMatchContainmentHandler method evaluateSingleContainment.
@SuppressWarnings("unchecked")
private void evaluateSingleContainment(final DefaultRuleViolations result, final RuleExtension rule, final NodeContainmentContext context, final Node<? extends Definition<?>, ? extends Edge> candidate) {
final GraphEvaluationState state = context.getState();
final Graph<?, ? extends Node> graph = context.getState().getGraph();
final String connectorId = rule.getId();
// Walk throw the graph and evaluate connector source and target nodes parent match.
treeWalkTraverseProcessor.traverse(graph, candidate, new AbstractTreeTraverseCallback<Graph, Node, Edge>() {
@Override
public boolean startNodeTraversal(final Node node) {
// Process incoming edges into the node as well.
final List<? extends Edge> inEdges = node.getInEdges();
if (null != inEdges) {
inEdges.stream().forEach(this::process);
}
return true;
}
@Override
public boolean startEdgeTraversal(final Edge edge) {
return process(edge);
}
private boolean process(final Edge edge) {
final Optional<String> eId = getId(definitionManager, edge);
if (eId.isPresent() && connectorId.equals(eId.get())) {
final Node sourceNode = state.getConnectionState().getSource(edge);
final Node targetNode = state.getConnectionState().getTarget(edge);
final boolean valid = new ParentTypesMatcher(() -> definitionManager, e -> getParent(context, e), rule.getTypeArguments()).matcher().test(sourceNode, targetNode);
if (!valid) {
addViolation(edge.getUUID(), rule, result);
}
}
return true;
}
});
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class CaseManagementUtilsTest method checkGetFirstDiagramNodeWithNonEmptyGraph.
@Test
@SuppressWarnings("unchecked")
public void checkGetFirstDiagramNodeWithNonEmptyGraph() {
final Graph graph = new GraphImpl<>("uuid", new GraphNodeStoreImpl());
final Node node = new NodeImpl<Definition>("node-uuid");
final CaseManagementDiagram content = new CaseManagementDiagram.CaseManagementDiagramBuilder().build();
node.setContent(new DefinitionImpl<>(content));
graph.addNode(node);
final Node<Definition<CaseManagementDiagram>, ?> fNode = CaseManagementUtils.getFirstDiagramNode(graph);
assertNotNull(fNode);
assertEquals("node-uuid", fNode.getUUID());
assertEquals(content, fNode.getContent().getDefinition());
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class StartEventFilterProvider method provideFilters.
@Override
public Collection<FormElementFilter> provideFilters(String elementUUID, Element<? extends Definition<?>> element, Object definition) {
Predicate predicate = o -> isParentAnEventSubProcess(elementUUID);
FormElementFilter isInterruptingFilter = new FormElementFilter("executionSet.isInterrupting", predicate);
return Arrays.asList(isInterruptingFilter);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class BaseDiagramMarshaller method getTitle.
private String getTitle(final Graph graph) {
final Node<Definition<BPMNDiagram>, ?> diagramNode = getFirstDiagramNode(graph);
final BPMNDiagram diagramBean = null != diagramNode ? (BPMNDiagram) ((Definition) diagramNode.getContent()).getDefinition() : null;
return getTitle(diagramBean);
}
Aggregations