target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void getCategory() { assertNotNull(tested.getCategory()); }
public String getCategory() { return category; }
BaseArtifacts implements BPMNViewDefinition { public String getCategory() { return category; } }
BaseArtifacts implements BPMNViewDefinition { public String getCategory() { return category; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); }
BaseArtifacts implements BPMNViewDefinition { public String getCategory() { return category; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); }
BaseArtifacts implements BPMNViewDefinition { public String getCategory() { return category; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); @Category static final transient String category; }
@Test public void getBackgroundSet() { assertNotNull(tested.getBackgroundSet()); }
public BackgroundSet getBackgroundSet() { return backgroundSet; }
BaseArtifacts implements BPMNViewDefinition { public BackgroundSet getBackgroundSet() { return backgroundSet; } }
BaseArtifacts implements BPMNViewDefinition { public BackgroundSet getBackgroundSet() { return backgroundSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); }
BaseArtifacts implements BPMNViewDefinition { public BackgroundSet getBackgroundSet() { return backgroundSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); }
BaseArtifacts implements BPMNViewDefinition { public BackgroundSet getBackgroundSet() { return backgroundSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); @Category static final transient String category; }
@Test public void getFontSet() { assertNotNull(tested.getFontSet()); }
public FontSet getFontSet() { return fontSet; }
BaseArtifacts implements BPMNViewDefinition { public FontSet getFontSet() { return fontSet; } }
BaseArtifacts implements BPMNViewDefinition { public FontSet getFontSet() { return fontSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); }
BaseArtifacts implements BPMNViewDefinition { public FontSet getFontSet() { return fontSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); }
BaseArtifacts implements BPMNViewDefinition { public FontSet getFontSet() { return fontSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); @Category static final transient String category; }
@Test public void getDimensionsSet() { assertNotNull(tested.getDimensionsSet()); }
public RectangleDimensionsSet getDimensionsSet() { return dimensionsSet; }
BaseArtifacts implements BPMNViewDefinition { public RectangleDimensionsSet getDimensionsSet() { return dimensionsSet; } }
BaseArtifacts implements BPMNViewDefinition { public RectangleDimensionsSet getDimensionsSet() { return dimensionsSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); }
BaseArtifacts implements BPMNViewDefinition { public RectangleDimensionsSet getDimensionsSet() { return dimensionsSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); }
BaseArtifacts implements BPMNViewDefinition { public RectangleDimensionsSet getDimensionsSet() { return dimensionsSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); @Category static final transient String category; }
@Test public void setBackgroundSet() { BackgroundSet backgroundSet = new BackgroundSet(); tested.setBackgroundSet(backgroundSet); assertEquals(backgroundSet, tested.getBackgroundSet()); }
public void setBackgroundSet(final BackgroundSet backgroundSet) { this.backgroundSet = backgroundSet; }
BaseArtifacts implements BPMNViewDefinition { public void setBackgroundSet(final BackgroundSet backgroundSet) { this.backgroundSet = backgroundSet; } }
BaseArtifacts implements BPMNViewDefinition { public void setBackgroundSet(final BackgroundSet backgroundSet) { this.backgroundSet = backgroundSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); }
BaseArtifacts implements BPMNViewDefinition { public void setBackgroundSet(final BackgroundSet backgroundSet) { this.backgroundSet = backgroundSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); }
BaseArtifacts implements BPMNViewDefinition { public void setBackgroundSet(final BackgroundSet backgroundSet) { this.backgroundSet = backgroundSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); @Category static final transient String category; }
@Test public void setFontSet() { FontSet fontSet = new FontSet(); tested.setFontSet(fontSet); assertEquals(fontSet, tested.getFontSet()); }
public void setFontSet(final FontSet fontSet) { this.fontSet = fontSet; }
BaseArtifacts implements BPMNViewDefinition { public void setFontSet(final FontSet fontSet) { this.fontSet = fontSet; } }
BaseArtifacts implements BPMNViewDefinition { public void setFontSet(final FontSet fontSet) { this.fontSet = fontSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); }
BaseArtifacts implements BPMNViewDefinition { public void setFontSet(final FontSet fontSet) { this.fontSet = fontSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); }
BaseArtifacts implements BPMNViewDefinition { public void setFontSet(final FontSet fontSet) { this.fontSet = fontSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); @Category static final transient String category; }
@Test public void setDimensionsSet() { RectangleDimensionsSet dimensionsSet = new RectangleDimensionsSet(); tested.setDimensionsSet(dimensionsSet); assertEquals(dimensionsSet, tested.getDimensionsSet()); }
public void setDimensionsSet(final RectangleDimensionsSet dimensionsSet) { this.dimensionsSet = dimensionsSet; }
BaseArtifacts implements BPMNViewDefinition { public void setDimensionsSet(final RectangleDimensionsSet dimensionsSet) { this.dimensionsSet = dimensionsSet; } }
BaseArtifacts implements BPMNViewDefinition { public void setDimensionsSet(final RectangleDimensionsSet dimensionsSet) { this.dimensionsSet = dimensionsSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); }
BaseArtifacts implements BPMNViewDefinition { public void setDimensionsSet(final RectangleDimensionsSet dimensionsSet) { this.dimensionsSet = dimensionsSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); }
BaseArtifacts implements BPMNViewDefinition { public void setDimensionsSet(final RectangleDimensionsSet dimensionsSet) { this.dimensionsSet = dimensionsSet; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); @Category static final transient String category; }
@Test public void testHashCode() { assertNotEquals(new DataObject().hashCode(), tested.hashCode()); assertNotEquals(new TextAnnotation().hashCode(), tested.hashCode()); }
@Override public int hashCode() { return HashUtil.combineHashCodes(Objects.hashCode(backgroundSet), Objects.hashCode(fontSet), Objects.hashCode(dimensionsSet)); }
BaseArtifacts implements BPMNViewDefinition { @Override public int hashCode() { return HashUtil.combineHashCodes(Objects.hashCode(backgroundSet), Objects.hashCode(fontSet), Objects.hashCode(dimensionsSet)); } }
BaseArtifacts implements BPMNViewDefinition { @Override public int hashCode() { return HashUtil.combineHashCodes(Objects.hashCode(backgroundSet), Objects.hashCode(fontSet), Objects.hashCode(dimensionsSet)); } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); }
BaseArtifacts implements BPMNViewDefinition { @Override public int hashCode() { return HashUtil.combineHashCodes(Objects.hashCode(backgroundSet), Objects.hashCode(fontSet), Objects.hashCode(dimensionsSet)); } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); }
BaseArtifacts implements BPMNViewDefinition { @Override public int hashCode() { return HashUtil.combineHashCodes(Objects.hashCode(backgroundSet), Objects.hashCode(fontSet), Objects.hashCode(dimensionsSet)); } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); @Category static final transient String category; }
@Test public void testAddChild() { final DecisionNavigatorItem item = new DecisionNavigatorItemBuilder().withUUID("uuid").build(); final DecisionNavigatorItem child = new DecisionNavigatorItemBuilder().withUUID("child").build(); final TreeSet<DecisionNavigatorItem> expectedChildren = new TreeSet<DecisionNavigatorItem>() {{ add(child); }}; item.addChild(child); item.addChild(child); assertEquals(expectedChildren, item.getChildren()); }
public void addChild(final DecisionNavigatorItem item) { removeChild(item); getChildren().add(item); item.setParentUUID(uuid); }
DecisionNavigatorItem implements Comparable { public void addChild(final DecisionNavigatorItem item) { removeChild(item); getChildren().add(item); item.setParentUUID(uuid); } }
DecisionNavigatorItem implements Comparable { public void addChild(final DecisionNavigatorItem item) { removeChild(item); getChildren().add(item); item.setParentUUID(uuid); } }
DecisionNavigatorItem implements Comparable { public void addChild(final DecisionNavigatorItem item) { removeChild(item); getChildren().add(item); item.setParentUUID(uuid); } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
DecisionNavigatorItem implements Comparable { public void addChild(final DecisionNavigatorItem item) { removeChild(item); getChildren().add(item); item.setParentUUID(uuid); } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
@Test public void testEquals() { assertTrue(tested.equals(new DataObject())); assertFalse(tested.equals("")); final DataObject dataObject = new DataObject(); BgColor color = new BgColor(); color.setValue("Black"); dataObject.getBackgroundSet().setBgColor(color); assertFalse(tested.equals(dataObject)); tested.getBackgroundSet().setBgColor(color); assertTrue(tested.equals(dataObject)); dataObject.getFontSet().setFontSize(new FontSize(11.0)); assertFalse(tested.equals(dataObject)); tested.getFontSet().setFontSize(new FontSize(11.0)); assertTrue(tested.equals(dataObject)); dataObject.getDimensionsSet().setHeight(new Height(11.0)); assertFalse(tested.equals(dataObject)); tested.getDimensionsSet().setHeight(new Height(11.0)); assertTrue(tested.equals(dataObject)); }
@Override public boolean equals(Object o) { if (o instanceof BaseArtifacts) { BaseArtifacts other = (BaseArtifacts) o; return Objects.equals(backgroundSet, other.backgroundSet) && Objects.equals(fontSet, other.fontSet) && Objects.equals(dimensionsSet, other.dimensionsSet); } return false; }
BaseArtifacts implements BPMNViewDefinition { @Override public boolean equals(Object o) { if (o instanceof BaseArtifacts) { BaseArtifacts other = (BaseArtifacts) o; return Objects.equals(backgroundSet, other.backgroundSet) && Objects.equals(fontSet, other.fontSet) && Objects.equals(dimensionsSet, other.dimensionsSet); } return false; } }
BaseArtifacts implements BPMNViewDefinition { @Override public boolean equals(Object o) { if (o instanceof BaseArtifacts) { BaseArtifacts other = (BaseArtifacts) o; return Objects.equals(backgroundSet, other.backgroundSet) && Objects.equals(fontSet, other.fontSet) && Objects.equals(dimensionsSet, other.dimensionsSet); } return false; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); }
BaseArtifacts implements BPMNViewDefinition { @Override public boolean equals(Object o) { if (o instanceof BaseArtifacts) { BaseArtifacts other = (BaseArtifacts) o; return Objects.equals(backgroundSet, other.backgroundSet) && Objects.equals(fontSet, other.fontSet) && Objects.equals(dimensionsSet, other.dimensionsSet); } return false; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); }
BaseArtifacts implements BPMNViewDefinition { @Override public boolean equals(Object o) { if (o instanceof BaseArtifacts) { BaseArtifacts other = (BaseArtifacts) o; return Objects.equals(backgroundSet, other.backgroundSet) && Objects.equals(fontSet, other.fontSet) && Objects.equals(dimensionsSet, other.dimensionsSet); } return false; } BaseArtifacts(final @MapsTo("backgroundSet") BackgroundSet backgroundSet, final @MapsTo("fontSet") FontSet fontSet, final @MapsTo("dimensionsSet") RectangleDimensionsSet dimensionsSet); String getCategory(); BackgroundSet getBackgroundSet(); FontSet getFontSet(); RectangleDimensionsSet getDimensionsSet(); void setBackgroundSet(final BackgroundSet backgroundSet); void setFontSet(final FontSet fontSet); void setDimensionsSet(final RectangleDimensionsSet dimensionsSet); @Override int hashCode(); @Override boolean equals(Object o); @Category static final transient String category; }
@Test public void testInit() { final List<DefinitionSetService> definitionSetServices = new LinkedList<>(); final DefinitionSetService definitionSetService1 = mock(DefinitionSetService.class); final DefinitionSetService definitionSetService2 = mock(DefinitionSetService.class); definitionSetServices.add(definitionSetService1); definitionSetServices.add(definitionSetService2); when(definitionSetServiceInstances.iterator()).thenReturn(definitionSetServices.iterator()); doAnswer(invocation -> { final Consumer consumer = invocation.getArgumentAt(0, Consumer.class); Iterator var2 = definitionSetServiceInstances.iterator(); while (var2.hasNext()) { Object t = var2.next(); consumer.accept(t); } return null; }).when(definitionSetServiceInstances).forEach(any(Consumer.class)); tested.init(); assertEquals(tested.definitionSetServices.size(), definitionSetServices.size()); tested.definitionSetServices.containsAll(definitionSetServices); }
@PostConstruct public void init() { definitionSetServiceInstances.forEach(i -> definitionSetServices.add(i)); }
CaseManagementSwitchViewServiceImpl implements CaseManagementSwitchViewService { @PostConstruct public void init() { definitionSetServiceInstances.forEach(i -> definitionSetServices.add(i)); } }
CaseManagementSwitchViewServiceImpl implements CaseManagementSwitchViewService { @PostConstruct public void init() { definitionSetServiceInstances.forEach(i -> definitionSetServices.add(i)); } @Inject CaseManagementSwitchViewServiceImpl(final FactoryManager factoryManager, final Instance<DefinitionSetService> definitionSetServiceInstances); }
CaseManagementSwitchViewServiceImpl implements CaseManagementSwitchViewService { @PostConstruct public void init() { definitionSetServiceInstances.forEach(i -> definitionSetServices.add(i)); } @Inject CaseManagementSwitchViewServiceImpl(final FactoryManager factoryManager, final Instance<DefinitionSetService> definitionSetServiceInstances); @PostConstruct void init(); @Override @SuppressWarnings("unchecked") Optional<ProjectDiagram> switchView(final Diagram diagram, final String mappedDefSetId, final String mappedShapeSetId); }
CaseManagementSwitchViewServiceImpl implements CaseManagementSwitchViewService { @PostConstruct public void init() { definitionSetServiceInstances.forEach(i -> definitionSetServices.add(i)); } @Inject CaseManagementSwitchViewServiceImpl(final FactoryManager factoryManager, final Instance<DefinitionSetService> definitionSetServiceInstances); @PostConstruct void init(); @Override @SuppressWarnings("unchecked") Optional<ProjectDiagram> switchView(final Diagram diagram, final String mappedDefSetId, final String mappedShapeSetId); }
@Test public void testSwitchView() throws IOException { final DefinitionSetService definitionSetService1 = mock(DefinitionSetService.class); String defSetId = "defSetId"; when(definitionSetService1.accepts(eq(defSetId))).thenReturn(true); tested.definitionSetServices.add(definitionSetService1); final DiagramMarshaller diagramMarsaller1 = mock(DiagramMarshaller.class); String rawData = "rawData"; when(diagramMarsaller1.marshall(any(Diagram.class))).thenReturn(rawData); when(definitionSetService1.getDiagramMarshaller()).thenReturn(diagramMarsaller1); final DefinitionSetService definitionSetService2 = mock(DefinitionSetService.class); String mappedDefSetId = "mappedDefSetId"; when(definitionSetService2.accepts(eq(mappedDefSetId))).thenReturn(true); tested.definitionSetServices.add(definitionSetService2); final DiagramMarshaller diagramMarsaller2 = mock(DiagramMarshaller.class); final Graph graph = mock(Graph.class); final DefinitionSet content = mock(DefinitionSet.class); when(graph.getContent()).thenReturn(content); when(diagramMarsaller2.unmarshall(any(Metadata.class), any(InputStream.class))).thenReturn(graph); when(definitionSetService2.getDiagramMarshaller()).thenReturn(diagramMarsaller2); final FactoryRegistry factoryRegistry = mock(FactoryRegistry.class); final DiagramFactory diagramFactory = mock(DiagramFactory.class); when(factoryRegistry.getDiagramFactory(any(String.class), any(Class.class))).thenReturn(diagramFactory); when(factoryManager.registry()).thenReturn(factoryRegistry); final ProjectDiagram projectDiagram = mock(ProjectDiagram.class); final ProjectMetadata projectMetadata = mock(ProjectMetadata.class); when(projectDiagram.getMetadata()).thenReturn(projectMetadata); when(diagramFactory.build(any(String.class), any(Metadata.class), any(Graph.class))).thenReturn(projectDiagram); final Diagram diagram = mock(Diagram.class); final AbstractMetadata metadata = mock(AbstractMetadata.class); when(diagram.getMetadata()).thenReturn(metadata); when(metadata.getDefinitionSetId()).thenReturn(defSetId); String mappedShapeSetId = "mappedShapeSetId"; Optional<ProjectDiagram> result = tested.switchView(diagram, mappedDefSetId, mappedShapeSetId); assertTrue(result.filter(d -> projectDiagram.equals(d)).isPresent()); verify(metadata).setDefinitionSetId(eq(mappedDefSetId)); verify(projectMetadata).setShapeSetId(eq(mappedShapeSetId)); }
@Override @SuppressWarnings("unchecked") public Optional<ProjectDiagram> switchView(final Diagram diagram, final String mappedDefSetId, final String mappedShapeSetId) { final Metadata metadata = diagram.getMetadata(); final String defSetId = metadata.getDefinitionSetId(); final Optional<DefinitionSetService> definitionSetServiceOptional = definitionSetServices.stream().filter(s -> s.accepts(defSetId)).findAny(); return definitionSetServiceOptional.map(service -> { try { final String rawData = service.getDiagramMarshaller().marshall(diagram); final Optional<DefinitionSetService> mappedDefinitionSetServiceOptional = definitionSetServices.stream() .filter(s -> s.accepts(mappedDefSetId)).findAny(); return mappedDefinitionSetServiceOptional.map(mappedService -> { ((AbstractMetadata) metadata).setDefinitionSetId(mappedDefSetId); try (final InputStream inputStream = new ByteArrayInputStream(rawData.getBytes())) { final Graph<DefinitionSet, Node> graph = mappedService.getDiagramMarshaller().unmarshall(metadata, inputStream); final DiagramFactory factory = factoryManager.registry().getDiagramFactory(graph.getContent().getDefinition(), metadata.getMetadataType()); final ProjectDiagram mappedDiagram = (ProjectDiagram) factory.build(metadata.getTitle(), metadata, graph); mappedDiagram.getMetadata().setShapeSetId(mappedShapeSetId); return mappedDiagram; } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }).orElseGet(() -> CaseManagementSwitchViewServiceImpl.this.handleError(Optional.empty())); } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }); }
CaseManagementSwitchViewServiceImpl implements CaseManagementSwitchViewService { @Override @SuppressWarnings("unchecked") public Optional<ProjectDiagram> switchView(final Diagram diagram, final String mappedDefSetId, final String mappedShapeSetId) { final Metadata metadata = diagram.getMetadata(); final String defSetId = metadata.getDefinitionSetId(); final Optional<DefinitionSetService> definitionSetServiceOptional = definitionSetServices.stream().filter(s -> s.accepts(defSetId)).findAny(); return definitionSetServiceOptional.map(service -> { try { final String rawData = service.getDiagramMarshaller().marshall(diagram); final Optional<DefinitionSetService> mappedDefinitionSetServiceOptional = definitionSetServices.stream() .filter(s -> s.accepts(mappedDefSetId)).findAny(); return mappedDefinitionSetServiceOptional.map(mappedService -> { ((AbstractMetadata) metadata).setDefinitionSetId(mappedDefSetId); try (final InputStream inputStream = new ByteArrayInputStream(rawData.getBytes())) { final Graph<DefinitionSet, Node> graph = mappedService.getDiagramMarshaller().unmarshall(metadata, inputStream); final DiagramFactory factory = factoryManager.registry().getDiagramFactory(graph.getContent().getDefinition(), metadata.getMetadataType()); final ProjectDiagram mappedDiagram = (ProjectDiagram) factory.build(metadata.getTitle(), metadata, graph); mappedDiagram.getMetadata().setShapeSetId(mappedShapeSetId); return mappedDiagram; } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }).orElseGet(() -> CaseManagementSwitchViewServiceImpl.this.handleError(Optional.empty())); } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }); } }
CaseManagementSwitchViewServiceImpl implements CaseManagementSwitchViewService { @Override @SuppressWarnings("unchecked") public Optional<ProjectDiagram> switchView(final Diagram diagram, final String mappedDefSetId, final String mappedShapeSetId) { final Metadata metadata = diagram.getMetadata(); final String defSetId = metadata.getDefinitionSetId(); final Optional<DefinitionSetService> definitionSetServiceOptional = definitionSetServices.stream().filter(s -> s.accepts(defSetId)).findAny(); return definitionSetServiceOptional.map(service -> { try { final String rawData = service.getDiagramMarshaller().marshall(diagram); final Optional<DefinitionSetService> mappedDefinitionSetServiceOptional = definitionSetServices.stream() .filter(s -> s.accepts(mappedDefSetId)).findAny(); return mappedDefinitionSetServiceOptional.map(mappedService -> { ((AbstractMetadata) metadata).setDefinitionSetId(mappedDefSetId); try (final InputStream inputStream = new ByteArrayInputStream(rawData.getBytes())) { final Graph<DefinitionSet, Node> graph = mappedService.getDiagramMarshaller().unmarshall(metadata, inputStream); final DiagramFactory factory = factoryManager.registry().getDiagramFactory(graph.getContent().getDefinition(), metadata.getMetadataType()); final ProjectDiagram mappedDiagram = (ProjectDiagram) factory.build(metadata.getTitle(), metadata, graph); mappedDiagram.getMetadata().setShapeSetId(mappedShapeSetId); return mappedDiagram; } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }).orElseGet(() -> CaseManagementSwitchViewServiceImpl.this.handleError(Optional.empty())); } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }); } @Inject CaseManagementSwitchViewServiceImpl(final FactoryManager factoryManager, final Instance<DefinitionSetService> definitionSetServiceInstances); }
CaseManagementSwitchViewServiceImpl implements CaseManagementSwitchViewService { @Override @SuppressWarnings("unchecked") public Optional<ProjectDiagram> switchView(final Diagram diagram, final String mappedDefSetId, final String mappedShapeSetId) { final Metadata metadata = diagram.getMetadata(); final String defSetId = metadata.getDefinitionSetId(); final Optional<DefinitionSetService> definitionSetServiceOptional = definitionSetServices.stream().filter(s -> s.accepts(defSetId)).findAny(); return definitionSetServiceOptional.map(service -> { try { final String rawData = service.getDiagramMarshaller().marshall(diagram); final Optional<DefinitionSetService> mappedDefinitionSetServiceOptional = definitionSetServices.stream() .filter(s -> s.accepts(mappedDefSetId)).findAny(); return mappedDefinitionSetServiceOptional.map(mappedService -> { ((AbstractMetadata) metadata).setDefinitionSetId(mappedDefSetId); try (final InputStream inputStream = new ByteArrayInputStream(rawData.getBytes())) { final Graph<DefinitionSet, Node> graph = mappedService.getDiagramMarshaller().unmarshall(metadata, inputStream); final DiagramFactory factory = factoryManager.registry().getDiagramFactory(graph.getContent().getDefinition(), metadata.getMetadataType()); final ProjectDiagram mappedDiagram = (ProjectDiagram) factory.build(metadata.getTitle(), metadata, graph); mappedDiagram.getMetadata().setShapeSetId(mappedShapeSetId); return mappedDiagram; } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }).orElseGet(() -> CaseManagementSwitchViewServiceImpl.this.handleError(Optional.empty())); } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }); } @Inject CaseManagementSwitchViewServiceImpl(final FactoryManager factoryManager, final Instance<DefinitionSetService> definitionSetServiceInstances); @PostConstruct void init(); @Override @SuppressWarnings("unchecked") Optional<ProjectDiagram> switchView(final Diagram diagram, final String mappedDefSetId, final String mappedShapeSetId); }
CaseManagementSwitchViewServiceImpl implements CaseManagementSwitchViewService { @Override @SuppressWarnings("unchecked") public Optional<ProjectDiagram> switchView(final Diagram diagram, final String mappedDefSetId, final String mappedShapeSetId) { final Metadata metadata = diagram.getMetadata(); final String defSetId = metadata.getDefinitionSetId(); final Optional<DefinitionSetService> definitionSetServiceOptional = definitionSetServices.stream().filter(s -> s.accepts(defSetId)).findAny(); return definitionSetServiceOptional.map(service -> { try { final String rawData = service.getDiagramMarshaller().marshall(diagram); final Optional<DefinitionSetService> mappedDefinitionSetServiceOptional = definitionSetServices.stream() .filter(s -> s.accepts(mappedDefSetId)).findAny(); return mappedDefinitionSetServiceOptional.map(mappedService -> { ((AbstractMetadata) metadata).setDefinitionSetId(mappedDefSetId); try (final InputStream inputStream = new ByteArrayInputStream(rawData.getBytes())) { final Graph<DefinitionSet, Node> graph = mappedService.getDiagramMarshaller().unmarshall(metadata, inputStream); final DiagramFactory factory = factoryManager.registry().getDiagramFactory(graph.getContent().getDefinition(), metadata.getMetadataType()); final ProjectDiagram mappedDiagram = (ProjectDiagram) factory.build(metadata.getTitle(), metadata, graph); mappedDiagram.getMetadata().setShapeSetId(mappedShapeSetId); return mappedDiagram; } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }).orElseGet(() -> CaseManagementSwitchViewServiceImpl.this.handleError(Optional.empty())); } catch (IOException e) { return CaseManagementSwitchViewServiceImpl.this.handleError(Optional.of(e)); } }); } @Inject CaseManagementSwitchViewServiceImpl(final FactoryManager factoryManager, final Instance<DefinitionSetService> definitionSetServiceInstances); @PostConstruct void init(); @Override @SuppressWarnings("unchecked") Optional<ProjectDiagram> switchView(final Diagram diagram, final String mappedDefSetId, final String mappedShapeSetId); }
@Test public void assertDiagamType() { factory.init(); verify(bpmnDiagramFactory, times(1)).setDiagramType(eq(CaseManagementDiagram.class)); }
@PostConstruct public void init() { this.bpmnDiagramFactory.setDiagramType(CaseManagementDiagram.class); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @PostConstruct public void init() { this.bpmnDiagramFactory.setDiagramType(CaseManagementDiagram.class); } }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @PostConstruct public void init() { this.bpmnDiagramFactory.setDiagramType(CaseManagementDiagram.class); } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @PostConstruct public void init() { this.bpmnDiagramFactory.setDiagramType(CaseManagementDiagram.class); } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); @PostConstruct void init(); @Override Class<? extends Metadata> getMetadataType(); @Override ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @PostConstruct public void init() { this.bpmnDiagramFactory.setDiagramType(CaseManagementDiagram.class); } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); @PostConstruct void init(); @Override Class<? extends Metadata> getMetadataType(); @Override ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph); }
@Test public void assertDefinitionSetType() { assertEquals(CaseManagementDefinitionSet.class, factory.getDefinitionSetType()); }
@Override protected Class<?> getDefinitionSetType() { return CaseManagementDefinitionSet.class; }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override protected Class<?> getDefinitionSetType() { return CaseManagementDefinitionSet.class; } }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override protected Class<?> getDefinitionSetType() { return CaseManagementDefinitionSet.class; } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override protected Class<?> getDefinitionSetType() { return CaseManagementDefinitionSet.class; } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); @PostConstruct void init(); @Override Class<? extends Metadata> getMetadataType(); @Override ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override protected Class<?> getDefinitionSetType() { return CaseManagementDefinitionSet.class; } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); @PostConstruct void init(); @Override Class<? extends Metadata> getMetadataType(); @Override ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph); }
@Test public void assertMetadataType() { assertEquals(ProjectMetadata.class, factory.getMetadataType()); }
@Override public Class<? extends Metadata> getMetadataType() { return ProjectMetadata.class; }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override public Class<? extends Metadata> getMetadataType() { return ProjectMetadata.class; } }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override public Class<? extends Metadata> getMetadataType() { return ProjectMetadata.class; } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override public Class<? extends Metadata> getMetadataType() { return ProjectMetadata.class; } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); @PostConstruct void init(); @Override Class<? extends Metadata> getMetadataType(); @Override ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override public Class<? extends Metadata> getMetadataType() { return ProjectMetadata.class; } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); @PostConstruct void init(); @Override Class<? extends Metadata> getMetadataType(); @Override ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph); }
@Test @SuppressWarnings("unchecked") public void testBuild() { factory.init(); factory.build("diagram1", metadata, graph); verify(bpmnDiagramFactory, times(1)).build(eq("diagram1"), eq(metadata), eq(graph)); }
@Override public ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph) { return bpmnDiagramFactory.build(name, metadata, graph); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override public ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph) { return bpmnDiagramFactory.build(name, metadata, graph); } }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override public ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph) { return bpmnDiagramFactory.build(name, metadata, graph); } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override public ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph) { return bpmnDiagramFactory.build(name, metadata, graph); } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); @PostConstruct void init(); @Override Class<? extends Metadata> getMetadataType(); @Override ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph); }
CaseManagementProjectDiagramFactory extends BindableDiagramFactory<ProjectMetadata, ProjectDiagram> { @Override public ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph) { return bpmnDiagramFactory.build(name, metadata, graph); } protected CaseManagementProjectDiagramFactory(); @Inject CaseManagementProjectDiagramFactory(final BPMNProjectDiagramFactory bpmnDiagramFactory); @PostConstruct void init(); @Override Class<? extends Metadata> getMetadataType(); @Override ProjectDiagram build(final String name, final ProjectMetadata metadata, final Graph<DefinitionSet, ?> graph); }
@Test public void testBuild_rectangle() throws Exception { final SVGShapeView shapeView = tested.build("rectangle", new SVGPrimitiveShape(new Rectangle(0d, 0d)), 10d, 10d, false); assertTrue(shapeView instanceof CaseManagementDiagramShapeView); }
@Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
@Test public void testBuild_stage() throws Exception { final SVGShapeView shapeView = tested.build("stage", new SVGPrimitiveShape(new Rectangle(0d, 0d)), 10d, 10d, false); assertTrue(shapeView instanceof CaseManagementStageShapeView); }
@Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
@Test public void testBuild_subcase() throws Exception { final SVGShapeView shapeView = tested.build("subcase", new SVGPrimitiveShape(new Rectangle(0d, 0d)), 10d, 10d, false); assertTrue(shapeView instanceof CaseManagementShapeView); }
@Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
@Test public void testCompareToWhenObjectIsNotADecisionNavigatorItem() { final DecisionNavigatorItem item = new DecisionNavigatorItemBuilder().withUUID("123").build(); final Object object = null; final int result = item.compareTo(object); assertTrue(result > 0); }
@Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
@Test public void testBuild_subprocess() throws Exception { final SVGShapeView shapeView = tested.build("subprocess", new SVGPrimitiveShape(new Rectangle(0d, 0d)), 10d, 10d, false); assertTrue(shapeView instanceof CaseManagementShapeView); }
@Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
@Test public void testBuild_task() throws Exception { final SVGShapeView shapeView = tested.build("task", new SVGPrimitiveShape(new Rectangle(0d, 0d)), 10d, 10d, false); assertTrue(shapeView instanceof CaseManagementShapeView); }
@Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
CaseManagementSVGViewBuilder implements SVGShapeViewBuilder { @Override public SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable) { switch (name) { case "stage": return new CaseManagementStageShapeView(name, primitiveShape, width, height, false); case "rectangle": return new CaseManagementDiagramShapeView(name, primitiveShape, width, height, false); default: return new CaseManagementShapeView(name, primitiveShape, width, height, false); } } @Override SVGShapeView build(final String name, final SVGPrimitiveShape primitiveShape, final double width, final double height, final boolean resizable); }
@Test public void create() { CaseManagementShape shape = CaseManagementShapeCommand.create(def, shapeView, shapeDef); verify(shapeDef).fontHandler(); verify(shapeView).setTitlePosition(HasTitle.VerticalAlignment.MIDDLE, HasTitle.HorizontalAlignment.CENTER, HasTitle.ReferencePosition.INSIDE, HasTitle.Orientation.HORIZONTAL); verify(shapeView).setTextSizeConstraints(new HasTitle.Size(100, 100, HasTitle.Size.SizeType.PERCENTAGE)); }
public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); }
CaseManagementShapeCommand { public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); } }
CaseManagementShapeCommand { public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); } }
CaseManagementShapeCommand { public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); } static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef); }
CaseManagementShapeCommand { public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); } static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef); }
@Test public void create_noShape() { CaseManagementShapeCommand.create(new Object(), shapeView, shapeDef); verify(shapeDef, never()).fontHandler(); verify(shapeView, never()).setTitlePosition(any(HasTitle.VerticalAlignment.class), any(HasTitle.HorizontalAlignment.class), any(HasTitle.ReferencePosition.class), any(HasTitle.Orientation.class)); verify(shapeView, never()).setTextSizeConstraints(any(HasTitle.Size.class)); }
public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); }
CaseManagementShapeCommand { public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); } }
CaseManagementShapeCommand { public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); } }
CaseManagementShapeCommand { public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); } static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef); }
CaseManagementShapeCommand { public static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef) { Command command = CM_SHAPE_TYPES.get(definition.getClass()); if (command == null) { return null; } applyShapeViewHandlers(definition, shapeView, shapeDef); return command.configure(shapeView, shapeDef); } static CaseManagementShape create(Object definition, CaseManagementShapeView shapeView, CaseManagementSvgShapeDef shapeDef); }
@Test public void checkLogicalReplacementWithOneChild() { final CaseManagementShapeView child = createShapeView("child"); final CaseManagementShapeView replacement = createShapeView("replacement"); shape.add(child); verify(layoutHandler, times(1)).requestLayout(shape); assertEquals(1, shape.getChildShapes().size()); assertEquals(child, shape.getChildShapes().get(0)); assertEquals(shape, child.getParent()); shape.logicallyReplace(child, replacement); assertEquals(1, shape.getChildShapes().size()); assertEquals(replacement, shape.getChildShapes().get(0)); assertEquals(shape, replacement.getParent()); assertNull(child.getParent()); verify(layoutHandler, times(2)).requestLayout(shape); }
public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); } }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
@Test public void checkLogicalReplacementWithMultipleChildren() { final CaseManagementShapeView child1 = createShapeView("child1"); final CaseManagementShapeView child2 = createShapeView("child2"); final CaseManagementShapeView replacement = createShapeView("replacement"); shape.add(child1); shape.add(child2); verify(layoutHandler, times(2)).requestLayout(shape); assertEquals(2, shape.getChildShapes().size()); assertEquals(child1, shape.getChildShapes().get(0)); assertEquals(child2, shape.getChildShapes().get(1)); assertEquals(shape, child1.getParent()); assertEquals(shape, child2.getParent()); shape.logicallyReplace(child1, replacement); assertEquals(2, shape.getChildShapes().size()); assertEquals(replacement, shape.getChildShapes().get(0)); assertEquals(child2, shape.getChildShapes().get(1)); assertEquals(shape, replacement.getParent()); assertNull(child1.getParent()); verify(layoutHandler, times(3)).requestLayout(shape); }
public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); } }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
@Test public void checkAddShapeAtIndex0WithNoExistingChildren() { final CaseManagementShapeView child = createShapeView("child"); shape.addShape(child, 0); verify(layoutHandler, times(1)).requestLayout(shape); assertEquals(1, shape.getChildShapes().size()); assertEquals(child, shape.getChildShapes().get(0)); }
public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
@Test public void checkAddShapeAtIndex1WithNoExistingChildren() { final CaseManagementShapeView child = createShapeView("child"); shape.addShape(child, 1); verify(layoutHandler, never()).requestLayout(shape); assertEquals(0, shape.getChildShapes().size()); }
public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
@Test public void checkAddShapeAtNegativeIndexWithNoExistingChildren() { final CaseManagementShapeView child = createShapeView("child"); shape.addShape(child, -1); verify(layoutHandler, never()).requestLayout(shape); assertEquals(0, shape.getChildShapes().size()); }
public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
@Test public void testGetIndex() throws Exception { final CaseManagementShapeView child1 = createShapeView("child1"); final CaseManagementShapeView child2 = createShapeView("child2"); shape.add(child1); shape.add(child2); assertEquals(shape.getIndex(child1), 0); assertEquals(shape.getIndex(child2), 1); }
public int getIndex(final WiresShape shape) { final NFastArrayList<WiresShape> children = getChildShapes(); for (int i = 0, n = children.size(); i < n; i++) { final WiresShape child = children.get(i); if (child == shape || isUUIDSame(shape, child)) { return i; } } return -1; }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public int getIndex(final WiresShape shape) { final NFastArrayList<WiresShape> children = getChildShapes(); for (int i = 0, n = children.size(); i < n; i++) { final WiresShape child = children.get(i); if (child == shape || isUUIDSame(shape, child)) { return i; } } return -1; } }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public int getIndex(final WiresShape shape) { final NFastArrayList<WiresShape> children = getChildShapes(); for (int i = 0, n = children.size(); i < n; i++) { final WiresShape child = children.get(i); if (child == shape || isUUIDSame(shape, child)) { return i; } } return -1; } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public int getIndex(final WiresShape shape) { final NFastArrayList<WiresShape> children = getChildShapes(); for (int i = 0, n = children.size(); i < n; i++) { final WiresShape child = children.get(i); if (child == shape || isUUIDSame(shape, child)) { return i; } } return -1; } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public int getIndex(final WiresShape shape) { final NFastArrayList<WiresShape> children = getChildShapes(); for (int i = 0, n = children.size(); i < n; i++) { final WiresShape child = children.get(i); if (child == shape || isUUIDSame(shape, child)) { return i; } } return -1; } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
@Test public void testCompareToWhenItemAndObjectAreEqual() { final DecisionNavigatorItem item = new DecisionNavigatorItemBuilder().withUUID("123").build(); final Object object = new DecisionNavigatorItemBuilder().withUUID("123").build(); final int result = item.compareTo(object); assertEquals(0, result); }
@Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
@Test public void testGetGhost() throws Exception { final CaseManagementShapeView child = createShapeView("child"); shape.add(child); final CaseManagementShapeView ghost = shape.getGhost(); assertTrue(ILayoutHandler.NONE.equals(ghost.getLayoutHandler())); assertEquals(ghost.getUUID(), shape.getUUID()); assertTrue(ghost.getChildShapes().size() == 1); CaseManagementShapeView ghostChild = (CaseManagementShapeView) ghost.getChildShapes().toList().get(0); assertEquals(ghostChild.getUUID(), child.getUUID()); }
public CaseManagementShapeView getGhost() { final CaseManagementShapeView ghost = createGhost(); if (null != ghost) { ghost.setFillColor(ColorName.GRAY.getColorString()); ghost.setFillAlpha(0.5d); ghost.setStrokeAlpha(0.5d); ghost.setUUID(getUUID()); } return ghost; }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public CaseManagementShapeView getGhost() { final CaseManagementShapeView ghost = createGhost(); if (null != ghost) { ghost.setFillColor(ColorName.GRAY.getColorString()); ghost.setFillAlpha(0.5d); ghost.setStrokeAlpha(0.5d); ghost.setUUID(getUUID()); } return ghost; } }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public CaseManagementShapeView getGhost() { final CaseManagementShapeView ghost = createGhost(); if (null != ghost) { ghost.setFillColor(ColorName.GRAY.getColorString()); ghost.setFillAlpha(0.5d); ghost.setStrokeAlpha(0.5d); ghost.setUUID(getUUID()); } return ghost; } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public CaseManagementShapeView getGhost() { final CaseManagementShapeView ghost = createGhost(); if (null != ghost) { ghost.setFillColor(ColorName.GRAY.getColorString()); ghost.setFillAlpha(0.5d); ghost.setStrokeAlpha(0.5d); ghost.setUUID(getUUID()); } return ghost; } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public CaseManagementShapeView getGhost() { final CaseManagementShapeView ghost = createGhost(); if (null != ghost) { ghost.setFillColor(ColorName.GRAY.getColorString()); ghost.setFillAlpha(0.5d); ghost.setStrokeAlpha(0.5d); ghost.setUUID(getUUID()); } return ghost; } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
@Test public void testAddShape() throws Exception { final CaseManagementShapeView child1 = createShapeView("child1"); final CaseManagementShapeView child2 = createShapeView("child2"); final CaseManagementShapeView child3 = createShapeView("child2"); { shape.addShape(child1, 0); verify(shape, times(1)).add(child1); verify(layoutHandler, times(1)).requestLayout(shape); assertEquals(1, shape.getChildShapes().size()); } { reset(shape); reset(layoutHandler); shape.addShape(child2, 0); final ArgumentCaptor<WiresShape> childShapes = ArgumentCaptor.forClass(WiresShape.class); verify(shape, times(2)).add(childShapes.capture()); assertTrue(childShapes.getAllValues().containsAll(Lists.newArrayList(child1, child2))); verify(layoutHandler, atLeast(2)).requestLayout(shape); assertEquals(2, shape.getChildShapes().size()); } { reset(shape); reset(layoutHandler); shape.addShape(child3, 1); final ArgumentCaptor<WiresShape> childShapes = ArgumentCaptor.forClass(WiresShape.class); verify(shape, times(3)).add(childShapes.capture()); assertTrue(childShapes.getAllValues().containsAll(Lists.newArrayList(child1, child2, child3))); verify(layoutHandler, atLeast(3)).requestLayout(shape); assertEquals(3, shape.getChildShapes().size()); } assertEquals(shape.getIndex(child1), 2); assertEquals(shape.getIndex(child2), 0); assertEquals(shape.getIndex(child3), 1); }
public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void addShape(final WiresShape shape, final int targetIndex) { if (shape == null || (targetIndex < 0 || targetIndex > getChildShapes().size())) { return; } final List<WiresShape> childShapes = getChildShapes().toList(); childShapes.forEach(WiresShape::removeFromParent); final List<WiresShape> existingChildShapes = childShapes.stream() .filter(s -> !((WiresShapeView) s).getUUID().equals(((WiresShapeView) shape).getUUID())) .collect(Collectors.toList()); existingChildShapes.add(targetIndex, shape); existingChildShapes.forEach(this::add); } CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable); CaseManagementShapeView(final String name, final SVGPrimitiveShape svgPrimitive, final double width, final double height, final boolean resizable, final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas); }
@Test public void testMakeDropZone() throws Exception { Optional<MultiPath> dropZone = tested.getDropZone(); assertTrue(dropZone.isPresent()); }
@Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); }
CaseManagementStageShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); } }
CaseManagementStageShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); } CaseManagementStageShapeView(String name, SVGPrimitiveShape svgPrimitive, double width, double height, boolean resizable); }
CaseManagementStageShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); } CaseManagementStageShapeView(String name, SVGPrimitiveShape svgPrimitive, double width, double height, boolean resizable); @Override Optional<MultiPath> getDropZone(); }
CaseManagementStageShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); } CaseManagementStageShapeView(String name, SVGPrimitiveShape svgPrimitive, double width, double height, boolean resizable); @Override Optional<MultiPath> getDropZone(); }
@Test public void testGetDropZone() throws Exception { Optional<MultiPath> dropZone1 = tested.getDropZone(); when(canvas.getPanelBounds()).thenReturn(Optional.of(Bounds.build(0.0, 0.0, 0.0, 9999.0))); Optional<MultiPath> dropZone2 = tested.getDropZone(); assertNotEquals(dropZone1, dropZone2); }
@Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); }
CaseManagementStageShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); } }
CaseManagementStageShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); } CaseManagementStageShapeView(String name, SVGPrimitiveShape svgPrimitive, double width, double height, boolean resizable); }
CaseManagementStageShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); } CaseManagementStageShapeView(String name, SVGPrimitiveShape svgPrimitive, double width, double height, boolean resizable); @Override Optional<MultiPath> getDropZone(); }
CaseManagementStageShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(b -> this.createDropZone(b.getHeight()))); return super.getDropZone(); } CaseManagementStageShapeView(String name, SVGPrimitiveShape svgPrimitive, double width, double height, boolean resizable); @Override Optional<MultiPath> getDropZone(); }
@Test public void testGetDropZone() throws Exception { Optional<MultiPath> dropZone1 = tested.getDropZone(); assertTrue(dropZone1.isPresent()); when(canvas.getPanelBounds()).thenReturn(Optional.of(Bounds.build(0.0, 0.0, 2000.0, 1000.0))); Optional<MultiPath> dropZone2 = tested.getDropZone(); assertTrue(dropZone2.isPresent()); assertNotEquals(dropZone1, dropZone2); }
@Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(this::createDropZone)); return super.getDropZone(); }
CaseManagementDiagramShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(this::createDropZone)); return super.getDropZone(); } }
CaseManagementDiagramShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(this::createDropZone)); return super.getDropZone(); } CaseManagementDiagramShapeView(String name, SVGPrimitiveShape svgPrimitive, double width, double height, boolean resizable); }
CaseManagementDiagramShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(this::createDropZone)); return super.getDropZone(); } CaseManagementDiagramShapeView(String name, SVGPrimitiveShape svgPrimitive, double width, double height, boolean resizable); @Override Optional<MultiPath> getDropZone(); }
CaseManagementDiagramShapeView extends CaseManagementShapeView { @Override public Optional<MultiPath> getDropZone() { this.getCanvas() .ifPresent(c -> c.getPanelBounds(). ifPresent(this::createDropZone)); return super.getDropZone(); } CaseManagementDiagramShapeView(String name, SVGPrimitiveShape svgPrimitive, double width, double height, boolean resizable); @Override Optional<MultiPath> getDropZone(); }
@Test public void testNewViewInstance() throws Exception { tested.newViewInstance(factory, new UserTask()); verify(factory, times(1)).task(); }
@Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final UserTask obj) { return newViewInstance(Optional.empty(), Optional.empty(), factory.task()); }
CaseManagementSvgUserTaskShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<UserTask> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final UserTask obj) { return newViewInstance(Optional.empty(), Optional.empty(), factory.task()); } }
CaseManagementSvgUserTaskShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<UserTask> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final UserTask obj) { return newViewInstance(Optional.empty(), Optional.empty(), factory.task()); } }
CaseManagementSvgUserTaskShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<UserTask> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final UserTask obj) { return newViewInstance(Optional.empty(), Optional.empty(), factory.task()); } @Override SizeHandler<UserTask, SVGShapeView> newSizeHandler(); @Override @SuppressWarnings("unchecked") BiConsumer<UserTask, SVGShapeView> viewHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final UserTask obj); @Override FontHandler<UserTask, SVGShapeView> newFontHandler(); @Override Glyph getGlyph(final Class<? extends UserTask> type, final String defId); }
CaseManagementSvgUserTaskShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<UserTask> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final UserTask obj) { return newViewInstance(Optional.empty(), Optional.empty(), factory.task()); } @Override SizeHandler<UserTask, SVGShapeView> newSizeHandler(); @Override @SuppressWarnings("unchecked") BiConsumer<UserTask, SVGShapeView> viewHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final UserTask obj); @Override FontHandler<UserTask, SVGShapeView> newFontHandler(); @Override Glyph getGlyph(final Class<? extends UserTask> type, final String defId); }
@Test public void testGetGlyph() throws Exception { Glyph glyph = tested.getGlyph(UserTask.class, ""); assertEquals(CaseManagementSVGGlyphFactory.TASK_GLYPH, glyph); }
@Override public Glyph getGlyph(final Class<? extends UserTask> type, final String defId) { return CaseManagementSVGGlyphFactory.TASK_GLYPH; }
CaseManagementSvgUserTaskShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<UserTask> { @Override public Glyph getGlyph(final Class<? extends UserTask> type, final String defId) { return CaseManagementSVGGlyphFactory.TASK_GLYPH; } }
CaseManagementSvgUserTaskShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<UserTask> { @Override public Glyph getGlyph(final Class<? extends UserTask> type, final String defId) { return CaseManagementSVGGlyphFactory.TASK_GLYPH; } }
CaseManagementSvgUserTaskShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<UserTask> { @Override public Glyph getGlyph(final Class<? extends UserTask> type, final String defId) { return CaseManagementSVGGlyphFactory.TASK_GLYPH; } @Override SizeHandler<UserTask, SVGShapeView> newSizeHandler(); @Override @SuppressWarnings("unchecked") BiConsumer<UserTask, SVGShapeView> viewHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final UserTask obj); @Override FontHandler<UserTask, SVGShapeView> newFontHandler(); @Override Glyph getGlyph(final Class<? extends UserTask> type, final String defId); }
CaseManagementSvgUserTaskShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<UserTask> { @Override public Glyph getGlyph(final Class<? extends UserTask> type, final String defId) { return CaseManagementSVGGlyphFactory.TASK_GLYPH; } @Override SizeHandler<UserTask, SVGShapeView> newSizeHandler(); @Override @SuppressWarnings("unchecked") BiConsumer<UserTask, SVGShapeView> viewHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final UserTask obj); @Override FontHandler<UserTask, SVGShapeView> newFontHandler(); @Override Glyph getGlyph(final Class<? extends UserTask> type, final String defId); }
@Test public void testNewViewInstance() throws Exception { tested.newViewInstance(factory, new AdHocSubprocess()); verify(factory, times(1)).stage(); }
@Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); } }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); } }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); } @Override SizeHandler<AdHocSubprocess, SVGShapeView> newSizeHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean); @Override Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId); }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); } @Override SizeHandler<AdHocSubprocess, SVGShapeView> newSizeHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean); @Override Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId); }
@Test public void testNewViewInstance_zeroDimension() throws Exception { final Width width = new Width(0.0); final Height height = new Height(0.0); final RectangleDimensionsSet dimensionsSet = new RectangleDimensionsSet(); dimensionsSet.setWidth(width); dimensionsSet.setHeight(height); final AdHocSubprocess adHocSubprocess = new AdHocSubprocess(); adHocSubprocess.setDimensionsSet(dimensionsSet); tested.newViewInstance(factory, new AdHocSubprocess()); verify(factory, times(1)).stage(); }
@Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); } }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); } }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); } @Override SizeHandler<AdHocSubprocess, SVGShapeView> newSizeHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean); @Override Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId); }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), factory.stage()); } @Override SizeHandler<AdHocSubprocess, SVGShapeView> newSizeHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean); @Override Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId); }
@Test public void testGetGlyph() throws Exception { Glyph glyph = tested.getGlyph(AdHocSubprocess.class, ""); assertEquals(CaseManagementSVGGlyphFactory.STAGE_GLYPH, glyph); }
@Override public Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId) { return CaseManagementSVGGlyphFactory.STAGE_GLYPH; }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId) { return CaseManagementSVGGlyphFactory.STAGE_GLYPH; } }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId) { return CaseManagementSVGGlyphFactory.STAGE_GLYPH; } }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId) { return CaseManagementSVGGlyphFactory.STAGE_GLYPH; } @Override SizeHandler<AdHocSubprocess, SVGShapeView> newSizeHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean); @Override Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId); }
CaseManagementSvgStageShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<AdHocSubprocess> { @Override public Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId) { return CaseManagementSVGGlyphFactory.STAGE_GLYPH; } @Override SizeHandler<AdHocSubprocess, SVGShapeView> newSizeHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final AdHocSubprocess bean); @Override Glyph getGlyph(final Class<? extends AdHocSubprocess> type, final String defId); }
@Test public void testCompareToWhenItemOrderingNameIsGreaterThanObjectOrderingName() { final DecisionNavigatorItem item = new DecisionNavigatorItemBuilder().withUUID("123").withLabel("Hat").build(); final Object object = new DecisionNavigatorItemBuilder().withUUID("456").withLabel("Red").build(); final int result = item.compareTo(object); assertTrue(result < 0); }
@Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
@Test public void testNewViewInstance() throws Exception { tested.newViewInstance(factory, new CaseManagementDiagram()); verify(factory, times(1)).rectangle(); }
@Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final CaseManagementDiagram diagram) { return newViewInstance(Optional.of(new Width(0d)), Optional.of(new Height(0d)), factory.rectangle()); }
CaseManagementSvgDiagramShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<CaseManagementDiagram> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final CaseManagementDiagram diagram) { return newViewInstance(Optional.of(new Width(0d)), Optional.of(new Height(0d)), factory.rectangle()); } }
CaseManagementSvgDiagramShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<CaseManagementDiagram> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final CaseManagementDiagram diagram) { return newViewInstance(Optional.of(new Width(0d)), Optional.of(new Height(0d)), factory.rectangle()); } }
CaseManagementSvgDiagramShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<CaseManagementDiagram> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final CaseManagementDiagram diagram) { return newViewInstance(Optional.of(new Width(0d)), Optional.of(new Height(0d)), factory.rectangle()); } @Override SizeHandler<CaseManagementDiagram, SVGShapeView> newSizeHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final CaseManagementDiagram diagram); }
CaseManagementSvgDiagramShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<CaseManagementDiagram> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final CaseManagementDiagram diagram) { return newViewInstance(Optional.of(new Width(0d)), Optional.of(new Height(0d)), factory.rectangle()); } @Override SizeHandler<CaseManagementDiagram, SVGShapeView> newSizeHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final CaseManagementDiagram diagram); }
@Test public void testNewViewInstance() throws Exception { tested.newViewInstance(factory, new CaseReusableSubprocess()); verify(factory, times(1)).subcase(); tested.newViewInstance(factory, new ProcessReusableSubprocess()); verify(factory, times(1)).subprocess(); }
@Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final ReusableSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), VIEW_RESOURCES.getResource(factory, bean)); }
CaseManagementSvgSubprocessShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<ReusableSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final ReusableSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), VIEW_RESOURCES.getResource(factory, bean)); } }
CaseManagementSvgSubprocessShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<ReusableSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final ReusableSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), VIEW_RESOURCES.getResource(factory, bean)); } }
CaseManagementSvgSubprocessShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<ReusableSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final ReusableSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), VIEW_RESOURCES.getResource(factory, bean)); } @Override SizeHandler<ReusableSubprocess, SVGShapeView> newSizeHandler(); @Override FontHandler<ReusableSubprocess, SVGShapeView> newFontHandler(); @Override @SuppressWarnings("unchecked") BiConsumer<ReusableSubprocess, SVGShapeView> viewHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final ReusableSubprocess bean); @Override Glyph getGlyph(final Class<? extends ReusableSubprocess> type, final String defId); }
CaseManagementSvgSubprocessShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<ReusableSubprocess> { @Override public SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final ReusableSubprocess bean) { return newViewInstance(Optional.empty(), Optional.empty(), VIEW_RESOURCES.getResource(factory, bean)); } @Override SizeHandler<ReusableSubprocess, SVGShapeView> newSizeHandler(); @Override FontHandler<ReusableSubprocess, SVGShapeView> newFontHandler(); @Override @SuppressWarnings("unchecked") BiConsumer<ReusableSubprocess, SVGShapeView> viewHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final ReusableSubprocess bean); @Override Glyph getGlyph(final Class<? extends ReusableSubprocess> type, final String defId); static final SVGShapeViewResources<ReusableSubprocess, CaseManagementSVGViewFactory> VIEW_RESOURCES; static final Map<Class<? extends ReusableSubprocess>, Glyph> GLYPHS; }
@Test public void testGetGlyph() throws Exception { Glyph subcaseGlyph = tested.getGlyph(CaseReusableSubprocess.class, ""); assertEquals(CaseManagementSVGGlyphFactory.SUBCASE_GLYPH, subcaseGlyph); Glyph subprocessGlyph = tested.getGlyph(ProcessReusableSubprocess.class, ""); assertEquals(CaseManagementSVGGlyphFactory.SUBPROCESS_GLYPH, subprocessGlyph); }
@Override public Glyph getGlyph(final Class<? extends ReusableSubprocess> type, final String defId) { return GLYPHS.get(type); }
CaseManagementSvgSubprocessShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<ReusableSubprocess> { @Override public Glyph getGlyph(final Class<? extends ReusableSubprocess> type, final String defId) { return GLYPHS.get(type); } }
CaseManagementSvgSubprocessShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<ReusableSubprocess> { @Override public Glyph getGlyph(final Class<? extends ReusableSubprocess> type, final String defId) { return GLYPHS.get(type); } }
CaseManagementSvgSubprocessShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<ReusableSubprocess> { @Override public Glyph getGlyph(final Class<? extends ReusableSubprocess> type, final String defId) { return GLYPHS.get(type); } @Override SizeHandler<ReusableSubprocess, SVGShapeView> newSizeHandler(); @Override FontHandler<ReusableSubprocess, SVGShapeView> newFontHandler(); @Override @SuppressWarnings("unchecked") BiConsumer<ReusableSubprocess, SVGShapeView> viewHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final ReusableSubprocess bean); @Override Glyph getGlyph(final Class<? extends ReusableSubprocess> type, final String defId); }
CaseManagementSvgSubprocessShapeDef extends BaseDimensionedShapeDef implements CaseManagementSvgShapeDef<ReusableSubprocess> { @Override public Glyph getGlyph(final Class<? extends ReusableSubprocess> type, final String defId) { return GLYPHS.get(type); } @Override SizeHandler<ReusableSubprocess, SVGShapeView> newSizeHandler(); @Override FontHandler<ReusableSubprocess, SVGShapeView> newFontHandler(); @Override @SuppressWarnings("unchecked") BiConsumer<ReusableSubprocess, SVGShapeView> viewHandler(); @Override SVGShapeView<?> newViewInstance(final CaseManagementSVGViewFactory factory, final ReusableSubprocess bean); @Override Glyph getGlyph(final Class<? extends ReusableSubprocess> type, final String defId); static final SVGShapeViewResources<ReusableSubprocess, CaseManagementSVGViewFactory> VIEW_RESOURCES; static final Map<Class<? extends ReusableSubprocess>, Glyph> GLYPHS; }
@Test public void testNewGraphCommand() { final Command graphCommand = command.newGraphCommand(canvasHandler); assertTrue(graphCommand instanceof CaseManagementSetChildNodeGraphCommand); final CaseManagementSetChildNodeGraphCommand cmGraphCommand = (CaseManagementSetChildNodeGraphCommand) graphCommand; assertTrue(cmGraphCommand.getIndex().isPresent()); assertEquals(0, cmGraphCommand.getIndex().getAsInt()); assertFalse(cmGraphCommand.getOriginalIndex().isPresent()); }
@Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
@Test public void testNewGraphCommand_moveForward() { final Node last = mock(Node.class); final Edge lEdge = mock(Edge.class); when(lEdge.getTargetNode()).thenReturn(last); parent.getOutEdges().add(lEdge); final Edge cEdge = mock(Edge.class); when(cEdge.getTargetNode()).thenReturn(candidate); parent.getOutEdges().add(cEdge); command = new CaseManagementSetChildCommand(parent, candidate, Optional.of(last), null, Optional.of(parent), null); final Command graphCommand = command.newGraphCommand(canvasHandler); assertTrue(graphCommand instanceof CaseManagementSetChildNodeGraphCommand); final CaseManagementSetChildNodeGraphCommand cmGraphCommand = (CaseManagementSetChildNodeGraphCommand) graphCommand; assertTrue(cmGraphCommand.getIndex().isPresent()); assertEquals(1, cmGraphCommand.getIndex().getAsInt()); assertTrue(cmGraphCommand.getOriginalIndex().isPresent()); assertEquals(1, cmGraphCommand.getOriginalIndex().getAsInt()); }
@Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
@Test public void testNewGraphCommand_moveBackward() { final Edge cEdge = mock(Edge.class); when(cEdge.getTargetNode()).thenReturn(candidate); parent.getOutEdges().add(cEdge); final Node last = mock(Node.class); final Edge lEdge = mock(Edge.class); when(lEdge.getTargetNode()).thenReturn(last); parent.getOutEdges().add(lEdge); command = new CaseManagementSetChildCommand(parent, candidate, Optional.of(last), null, Optional.of(parent), null); final Command graphCommand = command.newGraphCommand(canvasHandler); assertTrue(graphCommand instanceof CaseManagementSetChildNodeGraphCommand); final CaseManagementSetChildNodeGraphCommand cmGraphCommand = (CaseManagementSetChildNodeGraphCommand) graphCommand; assertTrue(cmGraphCommand.getIndex().isPresent()); assertEquals(1, cmGraphCommand.getIndex().getAsInt()); assertTrue(cmGraphCommand.getOriginalIndex().isPresent()); assertEquals(0, cmGraphCommand.getOriginalIndex().getAsInt()); }
@Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
@Test public void testNewGraphCommand_addNew() { command = new CaseManagementSetChildCommand(parent, candidate, Optional.empty(), OptionalInt.empty(), Optional.empty(), null); final Command graphCommand = command.newGraphCommand(canvasHandler); assertTrue(graphCommand instanceof CaseManagementSetChildNodeGraphCommand); final CaseManagementSetChildNodeGraphCommand cmGraphCommand = (CaseManagementSetChildNodeGraphCommand) graphCommand; assertFalse(cmGraphCommand.getIndex().isPresent()); assertFalse(cmGraphCommand.getOriginalIndex().isPresent()); }
@Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
@Test public void testNewGraphCommand_addNewStage() { final Node childNode = mock(Node.class); final View cContent = mock(View.class); when(childNode.getContent()).thenReturn(cContent); when(cContent.getDefinition()).thenReturn(mock(AdHocSubprocess.class)); when(childNode.getOutEdges()).thenReturn(new LinkedList()); final Node parentNode = mock(Node.class); final View pContent = mock(View.class); when(parentNode.getContent()).thenReturn(pContent); when(pContent.getDefinition()).thenReturn(mock(CaseManagementDiagram.class)); when(parentNode.getOutEdges()).thenReturn(new LinkedList()); final Node start = mock(Node.class); final View sContent = mock(View.class); when(start.getContent()).thenReturn(sContent); when(sContent.getDefinition()).thenReturn(mock(StartNoneEvent.class)); final Edge sEdge = mock(Edge.class); when(sEdge.getTargetNode()).thenReturn(start); parentNode.getOutEdges().add(sEdge); command = new CaseManagementSetChildCommand(parentNode, childNode, Optional.empty(), OptionalInt.of(0), Optional.empty(), null); final Command graphCommand = command.newGraphCommand(canvasHandler); assertTrue(graphCommand instanceof CaseManagementSetChildNodeGraphCommand); final CaseManagementSetChildNodeGraphCommand cmGraphCommand = (CaseManagementSetChildNodeGraphCommand) graphCommand; assertTrue(cmGraphCommand.getIndex().isPresent()); assertEquals(1, cmGraphCommand.getIndex().getAsInt()); assertFalse(cmGraphCommand.getOriginalIndex().isPresent()); }
@Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
CaseManagementSetChildCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetChildrenCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { OptionalInt originalIndex = originalParent .map(p -> OptionalInt.of(getChildGraphIndex(p, getCandidate()))) .orElseGet(OptionalInt::empty); OptionalInt index = last.map(s -> { int i = getChildGraphIndex(parent, s); if (originalIndex.isPresent() && originalIndex.getAsInt() < i) { return OptionalInt.of(i); } else { return OptionalInt.of(i + 1); } }).orElseGet(() -> { if (canvasIndex.isPresent() && canvasIndex.getAsInt() == 0 ) { if (isStage(parent, getCandidate())) { List<Node<View<?>, Edge>> childNodes = ((Node<View<?>, Edge>) parent).getOutEdges().stream() .map(e -> (Node<View<?>, Edge>) e.getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = childNodes.size(); i < n; i++) { if (childNodes.get(i).getContent().getDefinition() instanceof StartNoneEvent) { return OptionalInt.of(++i); } } return OptionalInt.of(0); } else { return canvasIndex; } } else { return OptionalInt.empty(); } }); return new CaseManagementSetChildNodeGraphCommand(parent, getCandidate(), index, originalParent, originalIndex); } CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); CaseManagementSetChildCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt canvasIndex, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originaCanvaslIndex); Node getCandidate(); }
@Test public void checkGetFirstDiagramNodeWithEmptyGraph() { final Graph graph = new GraphImpl<>("uuid", new GraphNodeStoreImpl()); final Node<Definition<CaseManagementDiagram>, ?> fNode = CaseManagementCommandUtil.getFirstDiagramNode(graph); assertNull(fNode); }
@SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@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(); node.setContent(new DefinitionImpl<>(content)); graph.addNode(node); final Node<Definition<CaseManagementDiagram>, ?> fNode = CaseManagementCommandUtil.getFirstDiagramNode(graph); assertNotNull(fNode); assertEquals("node-uuid", fNode.getUUID()); assertEquals(content, fNode.getContent().getDefinition()); }
@SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph) { return GraphUtils.getFirstNode(graph, CaseManagementDiagram.class); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testCompareToWhenItemOrderingNameIsLessThanObjectOrderingName() { final DecisionNavigatorItem item = new DecisionNavigatorItemBuilder().withUUID("123").withLabel("Red").build(); final Object object = new DecisionNavigatorItemBuilder().withUUID("456").withLabel("Hat").build(); final int result = item.compareTo(object); assertTrue(result > 0); }
@Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
DecisionNavigatorItem implements Comparable { @Override public int compareTo(final Object o) { if (o == null || getClass() != o.getClass()) { return 1; } final DecisionNavigatorItem that = (DecisionNavigatorItem) o; if (this.equals(that)) { return 0; } else { return getOrderingName().compareTo(that.getOrderingName()); } } String getUUID(); String getLabel(); Type getType(); TreeSet<DecisionNavigatorItem> getChildren(); Optional<Command> getOnClick(); String getParentUUID(); void setLabel(final String label); void removeChild(final DecisionNavigatorItem item); void addChild(final DecisionNavigatorItem item); void onClick(); void onUpdate(); void onRemove(); boolean isEditable(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Object o); }
@Test public void testGetDocumentByPathWithUnknownPath() { final Path path = mock(Path.class); when(path.toURI()).thenReturn(URI); when(ioService.newInputStream(any())).thenThrow(new NoSuchFileException()); final PMMLDocumentMetadata document = factory.getDocumentByPath(path); assertThat(document).isNotNull(); assertThat(document.getPath()).isEqualTo(URI); assertThat(document.getImportType()).isEqualTo(NAMESPACE); assertThat(document.getModels()).isEmpty(); }
public PMMLDocumentMetadata getDocumentByPath(final Path path) { return Optional.ofNullable(loadPMMLInfo(path)).map(pmml -> convertPMMLInfo(path, pmml)).orElse(emptyPMMLDocumentMetadata(path)); }
PMMLIncludedDocumentFactory { public PMMLDocumentMetadata getDocumentByPath(final Path path) { return Optional.ofNullable(loadPMMLInfo(path)).map(pmml -> convertPMMLInfo(path, pmml)).orElse(emptyPMMLDocumentMetadata(path)); } }
PMMLIncludedDocumentFactory { public PMMLDocumentMetadata getDocumentByPath(final Path path) { return Optional.ofNullable(loadPMMLInfo(path)).map(pmml -> convertPMMLInfo(path, pmml)).orElse(emptyPMMLDocumentMetadata(path)); } PMMLIncludedDocumentFactory(); @Inject PMMLIncludedDocumentFactory(final @Named("ioStrategy") IOService ioService); }
PMMLIncludedDocumentFactory { public PMMLDocumentMetadata getDocumentByPath(final Path path) { return Optional.ofNullable(loadPMMLInfo(path)).map(pmml -> convertPMMLInfo(path, pmml)).orElse(emptyPMMLDocumentMetadata(path)); } PMMLIncludedDocumentFactory(); @Inject PMMLIncludedDocumentFactory(final @Named("ioStrategy") IOService ioService); PMMLDocumentMetadata getDocumentByPath(final Path path); PMMLDocumentMetadata getDocumentByPath(final Path path, final PMMLIncludedModel includeModel); }
PMMLIncludedDocumentFactory { public PMMLDocumentMetadata getDocumentByPath(final Path path) { return Optional.ofNullable(loadPMMLInfo(path)).map(pmml -> convertPMMLInfo(path, pmml)).orElse(emptyPMMLDocumentMetadata(path)); } PMMLIncludedDocumentFactory(); @Inject PMMLIncludedDocumentFactory(final @Named("ioStrategy") IOService ioService); PMMLDocumentMetadata getDocumentByPath(final Path path); PMMLDocumentMetadata getDocumentByPath(final Path path, final PMMLIncludedModel includeModel); }
@Test public void testGetCanvasChildIndex() { final Edge edge = mock(Edge.class); when(edge.getTargetNode()).thenReturn(child); when(parent.getOutEdges()).thenReturn(Collections.singletonList(edge)); assertEquals(0, CaseManagementCommandUtil.getChildCanvasIndex(parent, child)); }
@SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testGetCanvasChildIndex_withStage() { setupForStage(); assertEquals(1, CaseManagementCommandUtil.getChildCanvasIndex(parent, child)); }
@SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testGetCanvasChildIndex_withSubStage() { setupForSubStage(); assertEquals(1, CaseManagementCommandUtil.getChildCanvasIndex(parent, child)); }
@SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { Predicate<Node> predicate = (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; for (int i = 0, c = 0, n = outEdges.size(); i < n; i++) { final Node cNode = outEdges.get(i).getTargetNode(); if (child.equals(cNode)) { return c; } if (predicate.test(cNode)) { c++; } } } } return -1; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testGetGraphIndex() { final Edge edge = mock(Edge.class); when(edge.getTargetNode()).thenReturn(child); when(parent.getOutEdges()).thenReturn(Collections.singletonList(edge)); assertEquals(0, CaseManagementCommandUtil.getChildGraphIndex(parent, child)); }
@SuppressWarnings("unchecked") public static int getChildGraphIndex(final Node parent, final Node child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { for (int i = 0, n = outEdges.size(); i < n; i++) { if (child.equals(outEdges.get(i).getTargetNode())) { return i; } } } } return -1; }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildGraphIndex(final Node parent, final Node child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { for (int i = 0, n = outEdges.size(); i < n; i++) { if (child.equals(outEdges.get(i).getTargetNode())) { return i; } } } } return -1; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildGraphIndex(final Node parent, final Node child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { for (int i = 0, n = outEdges.size(); i < n; i++) { if (child.equals(outEdges.get(i).getTargetNode())) { return i; } } } } return -1; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildGraphIndex(final Node parent, final Node child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { for (int i = 0, n = outEdges.size(); i < n; i++) { if (child.equals(outEdges.get(i).getTargetNode())) { return i; } } } } return -1; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getChildGraphIndex(final Node parent, final Node child) { if (parent != null && child != null) { List<Edge> outEdges = parent.getOutEdges(); if (null != outEdges && !outEdges.isEmpty()) { for (int i = 0, n = outEdges.size(); i < n; i++) { if (child.equals(outEdges.get(i).getTargetNode())) { return i; } } } } return -1; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testIsStage_withStage() { setupForStage(); assertTrue(CaseManagementCommandUtil.isStage(parent, child)); }
public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); }
CaseManagementCommandUtil { public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); } }
CaseManagementCommandUtil { public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); } }
CaseManagementCommandUtil { public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testIsStage_withSubStage() { setupForSubStage(); assertFalse(CaseManagementCommandUtil.isStage(parent, child)); }
public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); }
CaseManagementCommandUtil { public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); } }
CaseManagementCommandUtil { public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); } }
CaseManagementCommandUtil { public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { public static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child) { return !Objects.isNull(parent.getContent()) && parent.getContent().getDefinition() instanceof CaseManagementDiagram && isStageNode(child); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testIsStageNode() { setupForStage(); assertTrue(CaseManagementCommandUtil.isStageNode(child)); }
public static boolean isStageNode(final Node<View<?>, Edge> node) { if (node.getContent().getDefinition() instanceof AdHocSubprocess) { final List<Node> childNodes = node.getOutEdges().stream() .filter(childPredicate()) .map(Edge::getTargetNode).collect(Collectors.toList()); return childNodes.isEmpty() || childNodes.stream().allMatch(CaseManagementCommandUtil::isSubStageNode); } return false; }
CaseManagementCommandUtil { public static boolean isStageNode(final Node<View<?>, Edge> node) { if (node.getContent().getDefinition() instanceof AdHocSubprocess) { final List<Node> childNodes = node.getOutEdges().stream() .filter(childPredicate()) .map(Edge::getTargetNode).collect(Collectors.toList()); return childNodes.isEmpty() || childNodes.stream().allMatch(CaseManagementCommandUtil::isSubStageNode); } return false; } }
CaseManagementCommandUtil { public static boolean isStageNode(final Node<View<?>, Edge> node) { if (node.getContent().getDefinition() instanceof AdHocSubprocess) { final List<Node> childNodes = node.getOutEdges().stream() .filter(childPredicate()) .map(Edge::getTargetNode).collect(Collectors.toList()); return childNodes.isEmpty() || childNodes.stream().allMatch(CaseManagementCommandUtil::isSubStageNode); } return false; } }
CaseManagementCommandUtil { public static boolean isStageNode(final Node<View<?>, Edge> node) { if (node.getContent().getDefinition() instanceof AdHocSubprocess) { final List<Node> childNodes = node.getOutEdges().stream() .filter(childPredicate()) .map(Edge::getTargetNode).collect(Collectors.toList()); return childNodes.isEmpty() || childNodes.stream().allMatch(CaseManagementCommandUtil::isSubStageNode); } return false; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { public static boolean isStageNode(final Node<View<?>, Edge> node) { if (node.getContent().getDefinition() instanceof AdHocSubprocess) { final List<Node> childNodes = node.getOutEdges().stream() .filter(childPredicate()) .map(Edge::getTargetNode).collect(Collectors.toList()); return childNodes.isEmpty() || childNodes.stream().allMatch(CaseManagementCommandUtil::isSubStageNode); } return false; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testIsSubStageNode() { setupForSubStage(); assertTrue(CaseManagementCommandUtil.isSubStageNode(child)); }
public static boolean isSubStageNode(final Node<View<?>, Edge> node) { return node.getContent().getDefinition() instanceof UserTask || node.getContent().getDefinition() instanceof ReusableSubprocess; }
CaseManagementCommandUtil { public static boolean isSubStageNode(final Node<View<?>, Edge> node) { return node.getContent().getDefinition() instanceof UserTask || node.getContent().getDefinition() instanceof ReusableSubprocess; } }
CaseManagementCommandUtil { public static boolean isSubStageNode(final Node<View<?>, Edge> node) { return node.getContent().getDefinition() instanceof UserTask || node.getContent().getDefinition() instanceof ReusableSubprocess; } }
CaseManagementCommandUtil { public static boolean isSubStageNode(final Node<View<?>, Edge> node) { return node.getContent().getDefinition() instanceof UserTask || node.getContent().getDefinition() instanceof ReusableSubprocess; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { public static boolean isSubStageNode(final Node<View<?>, Edge> node) { return node.getContent().getDefinition() instanceof UserTask || node.getContent().getDefinition() instanceof ReusableSubprocess; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testChildPredicate() { final Predicate<Edge> predicate = CaseManagementCommandUtil.childPredicate(); final Edge edge = mock(Edge.class); when(edge.getContent()).thenReturn(mock(Child.class)); assertTrue(predicate.test(edge)); }
public static Predicate<Edge> childPredicate() { return edge -> edge.getContent() instanceof Child; }
CaseManagementCommandUtil { public static Predicate<Edge> childPredicate() { return edge -> edge.getContent() instanceof Child; } }
CaseManagementCommandUtil { public static Predicate<Edge> childPredicate() { return edge -> edge.getContent() instanceof Child; } }
CaseManagementCommandUtil { public static Predicate<Edge> childPredicate() { return edge -> edge.getContent() instanceof Child; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { public static Predicate<Edge> childPredicate() { return edge -> edge.getContent() instanceof Child; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testSequencePredicate() { final Predicate<Edge> predicate = CaseManagementCommandUtil.sequencePredicate(); final Edge edge = mock(Edge.class); final ViewConnector viewConnector = mock(ViewConnector.class); when(viewConnector.getDefinition()).thenReturn(mock(SequenceFlow.class)); when(edge.getContent()).thenReturn(viewConnector); assertTrue(predicate.test(edge)); }
public static Predicate<Edge> sequencePredicate() { return edge -> edge.getContent() instanceof ViewConnector && ((ViewConnector) edge.getContent()).getDefinition() instanceof SequenceFlow; }
CaseManagementCommandUtil { public static Predicate<Edge> sequencePredicate() { return edge -> edge.getContent() instanceof ViewConnector && ((ViewConnector) edge.getContent()).getDefinition() instanceof SequenceFlow; } }
CaseManagementCommandUtil { public static Predicate<Edge> sequencePredicate() { return edge -> edge.getContent() instanceof ViewConnector && ((ViewConnector) edge.getContent()).getDefinition() instanceof SequenceFlow; } }
CaseManagementCommandUtil { public static Predicate<Edge> sequencePredicate() { return edge -> edge.getContent() instanceof ViewConnector && ((ViewConnector) edge.getContent()).getDefinition() instanceof SequenceFlow; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { public static Predicate<Edge> sequencePredicate() { return edge -> edge.getContent() instanceof ViewConnector && ((ViewConnector) edge.getContent()).getDefinition() instanceof SequenceFlow; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testFocusWhenLazyLoadIsEmpty() { utils.releaseFocus(); verify(canvasFocusUtils, never()).focus(anyString()); }
public void releaseFocus() { getFocusedNodeUUID().ifPresent(canvasFocusUtils::focus); releaseNodeUUID(); }
LazyCanvasFocusUtils { public void releaseFocus() { getFocusedNodeUUID().ifPresent(canvasFocusUtils::focus); releaseNodeUUID(); } }
LazyCanvasFocusUtils { public void releaseFocus() { getFocusedNodeUUID().ifPresent(canvasFocusUtils::focus); releaseNodeUUID(); } LazyCanvasFocusUtils(); @Inject LazyCanvasFocusUtils(final CanvasFocusUtils canvasFocusUtils); }
LazyCanvasFocusUtils { public void releaseFocus() { getFocusedNodeUUID().ifPresent(canvasFocusUtils::focus); releaseNodeUUID(); } LazyCanvasFocusUtils(); @Inject LazyCanvasFocusUtils(final CanvasFocusUtils canvasFocusUtils); void lazyFocus(final String nodeUUID); void releaseFocus(); }
LazyCanvasFocusUtils { public void releaseFocus() { getFocusedNodeUUID().ifPresent(canvasFocusUtils::focus); releaseNodeUUID(); } LazyCanvasFocusUtils(); @Inject LazyCanvasFocusUtils(final CanvasFocusUtils canvasFocusUtils); void lazyFocus(final String nodeUUID); void releaseFocus(); }
@Test public void testGetCanvasNewChildIndex_withStage() { setupForStage(); assertEquals(2, CaseManagementCommandUtil.getNewChildCanvasIndex(parent)); }
@SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testGetCanvasNewChildIndex_withSubStage() { setupForSubStage(); assertEquals(2, CaseManagementCommandUtil.getNewChildCanvasIndex(parent)); }
@SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) { Predicate<Node> predicate = Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram) ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode; return (int) parent.getOutEdges().stream() .filter(childPredicate()) .filter(edge -> predicate.test(edge.getTargetNode())).count(); } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testGetGraphNewChildIndex_withStage() { setupForStage(); assertEquals(2, CaseManagementCommandUtil.getNewChildGraphIndex(parent)); }
@SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testGetGraphNewChildIndex_withSubStage() { setupForSubStage(); assertEquals(2, CaseManagementCommandUtil.getNewChildGraphIndex(parent)); }
@SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; } }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
CaseManagementCommandUtil { @SuppressWarnings("unchecked") public static int getNewChildGraphIndex(final Node<View<?>, Edge> parent) { if (Objects.isNull(parent.getContent()) || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)) { return parent.getOutEdges().size(); } List<Node<View<?>, Edge>> childNodes = parent.getOutEdges().stream() .map(edge -> (Node<View<?>, Edge>) edge.getTargetNode()) .collect(Collectors.toList()); for (int n = childNodes.size(), i = n - 1; i >= 0; i--) { Node<View<?>, Edge> node = childNodes.get(i); if (isStageNode(node) || node.getContent().getDefinition() instanceof StartNoneEvent) { return i + 1; } } return 0; } @SuppressWarnings("unchecked") static Node<Definition<CaseManagementDiagram>, ?> getFirstDiagramNode(final Graph<?, Node> graph); @SuppressWarnings("unchecked") static int getChildGraphIndex(final Node parent, final Node child); @SuppressWarnings("unchecked") static int getChildCanvasIndex(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStage(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child); static boolean isStageNode(final Node<View<?>, Edge> node); static boolean isSubStageNode(final Node<View<?>, Edge> node); static Predicate<Edge> childPredicate(); static Predicate<Edge> sequencePredicate(); @SuppressWarnings("unchecked") static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent); @SuppressWarnings("unchecked") static int getNewChildGraphIndex(final Node<View<?>, Edge> parent); }
@Test public void testExecute() throws Exception { tested.execute(canvasHandler); verify(canvasHandler, times(1)).deregister(eq(rootShape), eq(rootNode), eq(true)); verify(canvasHandler, times(1)).register(eq(SHAPE_SET_ID), eq(rootNode)); }
@Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(AbstractCanvasHandler context) { final String rootUUID = context.getDiagram().getMetadata().getCanvasRootUUID(); final Shape rootShape = context.getCanvas().getShape(rootUUID); final CommandResult<CanvasViolation> result = super.execute(context); final Node<View, Edge> node = context.getGraphIndex().getNode(rootUUID); context.deregister(rootShape, node, true); context.register(context.getDiagram().getMetadata().getShapeSetId(), node); return result; }
CaseManagementClearCommand extends ClearCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(AbstractCanvasHandler context) { final String rootUUID = context.getDiagram().getMetadata().getCanvasRootUUID(); final Shape rootShape = context.getCanvas().getShape(rootUUID); final CommandResult<CanvasViolation> result = super.execute(context); final Node<View, Edge> node = context.getGraphIndex().getNode(rootUUID); context.deregister(rootShape, node, true); context.register(context.getDiagram().getMetadata().getShapeSetId(), node); return result; } }
CaseManagementClearCommand extends ClearCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(AbstractCanvasHandler context) { final String rootUUID = context.getDiagram().getMetadata().getCanvasRootUUID(); final Shape rootShape = context.getCanvas().getShape(rootUUID); final CommandResult<CanvasViolation> result = super.execute(context); final Node<View, Edge> node = context.getGraphIndex().getNode(rootUUID); context.deregister(rootShape, node, true); context.register(context.getDiagram().getMetadata().getShapeSetId(), node); return result; } }
CaseManagementClearCommand extends ClearCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(AbstractCanvasHandler context) { final String rootUUID = context.getDiagram().getMetadata().getCanvasRootUUID(); final Shape rootShape = context.getCanvas().getShape(rootUUID); final CommandResult<CanvasViolation> result = super.execute(context); final Node<View, Edge> node = context.getGraphIndex().getNode(rootUUID); context.deregister(rootShape, node, true); context.register(context.getDiagram().getMetadata().getShapeSetId(), node); return result; } @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(AbstractCanvasHandler context); }
CaseManagementClearCommand extends ClearCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(AbstractCanvasHandler context) { final String rootUUID = context.getDiagram().getMetadata().getCanvasRootUUID(); final Shape rootShape = context.getCanvas().getShape(rootUUID); final CommandResult<CanvasViolation> result = super.execute(context); final Node<View, Edge> node = context.getGraphIndex().getNode(rootUUID); context.deregister(rootShape, node, true); context.register(context.getDiagram().getMetadata().getShapeSetId(), node); return result; } @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(AbstractCanvasHandler context); }
@Test public void testNewGraphCommand() { final Command<GraphCommandExecutionContext, RuleViolation> command = tested.newGraphCommand(canvasHandler); assertNotNull(command); assertTrue(command instanceof org.kie.workbench.common.stunner.cm.client.command.graph.CaseManagementAddNodeCommand); assertEquals(candidate, ((org.kie.workbench.common.stunner.cm.client.command.graph.CaseManagementAddNodeCommand) command).getCandidate()); }
@Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new org.kie.workbench.common.stunner.cm.client.command.graph.CaseManagementAddNodeCommand(getCandidate()); }
CaseManagementAddNodeCommand extends AddNodeCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new org.kie.workbench.common.stunner.cm.client.command.graph.CaseManagementAddNodeCommand(getCandidate()); } }
CaseManagementAddNodeCommand extends AddNodeCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new org.kie.workbench.common.stunner.cm.client.command.graph.CaseManagementAddNodeCommand(getCandidate()); } CaseManagementAddNodeCommand(Node candidate, String shapeSetId); }
CaseManagementAddNodeCommand extends AddNodeCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new org.kie.workbench.common.stunner.cm.client.command.graph.CaseManagementAddNodeCommand(getCandidate()); } CaseManagementAddNodeCommand(Node candidate, String shapeSetId); }
CaseManagementAddNodeCommand extends AddNodeCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new org.kie.workbench.common.stunner.cm.client.command.graph.CaseManagementAddNodeCommand(getCandidate()); } CaseManagementAddNodeCommand(Node candidate, String shapeSetId); }
@Test public void checkDrawCommandType() { final CanvasCommand<AbstractCanvasHandler> command = factory.draw(); assertNotNull(command); assertTrue(command instanceof CaseManagementDrawCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> draw() { return new CaseManagementDrawCommand(newChildrenTraverseProcessor()); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> draw() { return new CaseManagementDrawCommand(newChildrenTraverseProcessor()); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> draw() { return new CaseManagementDrawCommand(newChildrenTraverseProcessor()); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> draw() { return new CaseManagementDrawCommand(newChildrenTraverseProcessor()); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> draw() { return new CaseManagementDrawCommand(newChildrenTraverseProcessor()); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test public void checkAddChildNodeCommandType() { final CanvasCommand<AbstractCanvasHandler> command = factory.addChildNode(parent, child, CaseManagementShapeSet.class.getName()); assertNotNull(command); assertTrue(command instanceof CaseManagementAddChildCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId) { return new CaseManagementAddChildCommand(parent, child, shapeSetId); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId) { return new CaseManagementAddChildCommand(parent, child, shapeSetId); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId) { return new CaseManagementAddChildCommand(parent, child, shapeSetId); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId) { return new CaseManagementAddChildCommand(parent, child, shapeSetId); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId) { return new CaseManagementAddChildCommand(parent, child, shapeSetId); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test public void checkSetChildNodeCommandType() { final CanvasCommand<AbstractCanvasHandler> command = factory.setChildNode(parent, child); assertNotNull(command); assertTrue(command instanceof CaseManagementSetChildCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test public void checkSetChildNodeForCanvasManagementCommandType() { final CanvasCommand<AbstractCanvasHandler> command = factory.setChildNode(parent, child, Optional.empty(), OptionalInt.of(0), Optional.empty(), OptionalInt.empty()); assertNotNull(command); assertTrue(command instanceof CaseManagementSetChildCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child) { return new CaseManagementSetChildCommand(parent, child); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test public void testFocus() { final CanvasHandler canvasHandler = mock(CanvasHandler.class); final Canvas canvas = mock(Canvas.class); final String uuid = "uuid"; final CanvasSelectionEvent canvasSelection = new CanvasSelectionEvent(canvasHandler, uuid); final CanvasFocusedShapeEvent canvasFocusedShape = new CanvasFocusedShapeEvent(canvasHandler, uuid); when(dmnGraphUtils.getCanvasHandler()).thenReturn(canvasHandler); doReturn(canvasSelection).when(canvasFocusUtils).makeCanvasSelectionEvent(canvasHandler, uuid); doReturn(canvasFocusedShape).when(canvasFocusUtils).makeCanvasFocusedShapeEvent(canvasHandler, uuid); doReturn(canvas).when(canvasHandler).getCanvas(); canvasFocusUtils.focus(uuid); verify(canvasSelectionEvent).fire(canvasSelection); verify(canvasFocusedSelectionEvent).fire(canvasFocusedShape); verify(canvas).focus(); }
public void focus(final String nodeUUID) { final CanvasHandler canvasHandler = dmnGraphUtils.getCanvasHandler(); canvasSelectionEvent.fire(makeCanvasSelectionEvent(canvasHandler, nodeUUID)); canvasFocusedSelectionEvent.fire(makeCanvasFocusedShapeEvent(canvasHandler, nodeUUID)); if (canvasHandler != null && canvasHandler.getCanvas() != null) { canvasHandler.getCanvas().focus(); } }
CanvasFocusUtils { public void focus(final String nodeUUID) { final CanvasHandler canvasHandler = dmnGraphUtils.getCanvasHandler(); canvasSelectionEvent.fire(makeCanvasSelectionEvent(canvasHandler, nodeUUID)); canvasFocusedSelectionEvent.fire(makeCanvasFocusedShapeEvent(canvasHandler, nodeUUID)); if (canvasHandler != null && canvasHandler.getCanvas() != null) { canvasHandler.getCanvas().focus(); } } }
CanvasFocusUtils { public void focus(final String nodeUUID) { final CanvasHandler canvasHandler = dmnGraphUtils.getCanvasHandler(); canvasSelectionEvent.fire(makeCanvasSelectionEvent(canvasHandler, nodeUUID)); canvasFocusedSelectionEvent.fire(makeCanvasFocusedShapeEvent(canvasHandler, nodeUUID)); if (canvasHandler != null && canvasHandler.getCanvas() != null) { canvasHandler.getCanvas().focus(); } } @Inject CanvasFocusUtils(final DMNGraphUtils dmnGraphUtils, final Event<CanvasFocusedShapeEvent> canvasFocusedSelectionEvent, final Event<CanvasSelectionEvent> canvasSelectionEvent); }
CanvasFocusUtils { public void focus(final String nodeUUID) { final CanvasHandler canvasHandler = dmnGraphUtils.getCanvasHandler(); canvasSelectionEvent.fire(makeCanvasSelectionEvent(canvasHandler, nodeUUID)); canvasFocusedSelectionEvent.fire(makeCanvasFocusedShapeEvent(canvasHandler, nodeUUID)); if (canvasHandler != null && canvasHandler.getCanvas() != null) { canvasHandler.getCanvas().focus(); } } @Inject CanvasFocusUtils(final DMNGraphUtils dmnGraphUtils, final Event<CanvasFocusedShapeEvent> canvasFocusedSelectionEvent, final Event<CanvasSelectionEvent> canvasSelectionEvent); void focus(final String nodeUUID); }
CanvasFocusUtils { public void focus(final String nodeUUID) { final CanvasHandler canvasHandler = dmnGraphUtils.getCanvasHandler(); canvasSelectionEvent.fire(makeCanvasSelectionEvent(canvasHandler, nodeUUID)); canvasFocusedSelectionEvent.fire(makeCanvasFocusedShapeEvent(canvasHandler, nodeUUID)); if (canvasHandler != null && canvasHandler.getCanvas() != null) { canvasHandler.getCanvas().focus(); } } @Inject CanvasFocusUtils(final DMNGraphUtils dmnGraphUtils, final Event<CanvasFocusedShapeEvent> canvasFocusedSelectionEvent, final Event<CanvasSelectionEvent> canvasSelectionEvent); void focus(final String nodeUUID); }
@Test public void checkRemoveChildCommandType() { final CanvasCommand<AbstractCanvasHandler> command = factory.removeChild(parent, child); assertNotNull(command); assertTrue(command instanceof CaseManagementRemoveChildCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate) { return new CaseManagementRemoveChildCommand(parent, candidate); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate) { return new CaseManagementRemoveChildCommand(parent, candidate); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate) { return new CaseManagementRemoveChildCommand(parent, candidate); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate) { return new CaseManagementRemoveChildCommand(parent, candidate); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate) { return new CaseManagementRemoveChildCommand(parent, candidate); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test @SuppressWarnings("unchecked") public void checkUpdatePositionCommandType() { final CanvasCommand<AbstractCanvasHandler> command = factory.updatePosition(child, new Point2D(0.0, 0.0)); assertNotNull(command); assertTrue(command instanceof CaseManagementUpdatePositionCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location) { return new CaseManagementUpdatePositionCommand(element, location); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location) { return new CaseManagementUpdatePositionCommand(element, location); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location) { return new CaseManagementUpdatePositionCommand(element, location); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location) { return new CaseManagementUpdatePositionCommand(element, location); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location) { return new CaseManagementUpdatePositionCommand(element, location); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test public void checkDelete() { final CanvasCommand<AbstractCanvasHandler> command = factory.delete(Collections.singletonList(child)); assertNotNull(command); assertTrue(command instanceof CaseManagementDeleteElementsCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates) { return new CaseManagementDeleteElementsCommand(candidates); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates) { return new CaseManagementDeleteElementsCommand(candidates); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates) { return new CaseManagementDeleteElementsCommand(candidates); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates) { return new CaseManagementDeleteElementsCommand(candidates); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates) { return new CaseManagementDeleteElementsCommand(candidates); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test public void checkDeleteNode() { final CanvasCommand<AbstractCanvasHandler> command = factory.deleteNode(child); assertNotNull(command); assertTrue(command instanceof CaseManagementDeleteNodeCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate) { return new CaseManagementDeleteNodeCommand(candidate); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate) { return new CaseManagementDeleteNodeCommand(candidate); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate) { return new CaseManagementDeleteNodeCommand(candidate); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate) { return new CaseManagementDeleteNodeCommand(candidate); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate) { return new CaseManagementDeleteNodeCommand(candidate); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test public void checkAddNode() { final CanvasCommand<AbstractCanvasHandler> command = factory.addNode(child, CaseManagementShapeSet.class.getName()); assertNotNull(command); assertTrue(command instanceof CaseManagementAddNodeCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId) { return new CaseManagementAddNodeCommand(candidate, shapeSetId); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId) { return new CaseManagementAddNodeCommand(candidate, shapeSetId); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId) { return new CaseManagementAddNodeCommand(candidate, shapeSetId); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId) { return new CaseManagementAddNodeCommand(candidate, shapeSetId); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId) { return new CaseManagementAddNodeCommand(candidate, shapeSetId); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test public void checkClearCanvas() { final CanvasCommand<AbstractCanvasHandler> command = factory.clearCanvas(); assertNotNull(command); assertTrue(command instanceof CaseManagementClearCommand); }
@Override public CanvasCommand<AbstractCanvasHandler> clearCanvas() { return new CaseManagementClearCommand(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> clearCanvas() { return new CaseManagementClearCommand(); } }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> clearCanvas() { return new CaseManagementClearCommand(); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> clearCanvas() { return new CaseManagementClearCommand(); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
CaseManagementCanvasCommandFactory extends LienzoCanvasCommandFactory { @Override public CanvasCommand<AbstractCanvasHandler> clearCanvas() { return new CaseManagementClearCommand(); } @Inject CaseManagementCanvasCommandFactory(final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessors, final ManagedInstance<ViewTraverseProcessor> viewTraverseProcessors); @Override CanvasCommand<AbstractCanvasHandler> addNode(final Node candidate, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> draw(); @Override CanvasCommand<AbstractCanvasHandler> addChildNode(final Node parent, final Node child, final String shapeSetId); @Override CanvasCommand<AbstractCanvasHandler> setChildNode(final Node parent, final Node child); CanvasCommand<AbstractCanvasHandler> setChildNode(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final Optional<Node<View<?>, Edge>> last, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override CanvasCommand<AbstractCanvasHandler> removeChild(final Node parent, final Node candidate); @Override //This command is used to update a Node location following 'Drag', 'Resize' or 'Add from Palette' operations //Case Management does not update the location of any Nodes, preserving the layout information that may have //been set using the full BPMN2 editor. This command equates to a NOP for Case Management. CanvasCommand<AbstractCanvasHandler> updatePosition(final Node<View<?>, Edge> element, final Point2D location); @Override CanvasCommand<AbstractCanvasHandler> cloneNode(Node candidate, String parentUuid, Point2D cloneLocation, Consumer<Node> callback); @Override CanvasCommand<AbstractCanvasHandler> delete(Collection<Element> candidates); @Override CanvasCommand<AbstractCanvasHandler> deleteNode(Node candidate); @Override CanvasCommand<AbstractCanvasHandler> clearCanvas(); }
@Test public void checkUndo() { final CaseManagementSetChildNodeGraphCommand command = setChildNode(parent, candidate, index, originalParent, originalIndex); command.undo(context); assertEquals(0, parent.getOutEdges().size()); assertEquals(0, candidate.getInEdges().size()); }
@Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; } }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
@Test public void checkUndoWhenChildHasExistingParent() { setChildNode(parent, candidate, index, originalParent, originalIndex); final Node<View<?>, Edge> newParent = CommandTestUtils.makeNode("uuid3", "existingParent", 10.0, 20.0, 50.0, 50.0); final CaseManagementSetChildNodeGraphCommand addToNewParentCommand = setChildNode(newParent, candidate, index, Optional.of(parent), OptionalInt.of(0)); addToNewParentCommand.undo(context); assertEquals(0, newParent.getOutEdges().size()); assertEquals(1, parent.getOutEdges().size()); assertEquals(1, candidate.getInEdges().size()); assertEquals(parent.getOutEdges().get(0), candidate.getInEdges().get(0)); final Edge edge = parent.getOutEdges().get(0); assertEquals(parent, edge.getSourceNode()); assertEquals(candidate, edge.getTargetNode()); assertTrue(edge.getContent() instanceof Child); }
@Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; } }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { getEdgeForTarget(in, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, in.get(), child, context)); getEdgeForSource(out, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, out.get(), context)); getEdgeForTarget(Optional.of(parent), child, childPredicate()) .ifPresent((e) -> removeRelationship(e, parent, child, context)); edge.ifPresent(e -> addRelationship(in.get(), out.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); if (originalIn.isPresent() && originalOut.isPresent()) { getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), originalOut.get(), context)); } originalOut.ifPresent((p) -> addRelationship(child, originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier())); originalIn.ifPresent((p) -> addRelationship(originalIn.get(), child, OptionalInt.empty(), context, sequenceFlowSupplier())); originalParent.ifPresent((p) -> addRelationship(originalParent.get(), child, originalIndex, context, Child::new)); undoResizeNodes(); return GraphCommandResultBuilder.SUCCESS; } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
@Test public void testRemoveExistingRelationship() { final Node diagram = createNode(CaseManagementDiagram.class); final Node stage = createNode(AdHocSubprocess.class); final Node start = createNode(StartNoneEvent.class); final Node end = createNode(EndNoneEvent.class); createChildEdge(diagram, start); createChildEdge(diagram, stage); createChildEdge(diagram, end); createSequenceFlow(start, stage); createSequenceFlow(stage, end); final CaseManagementSetChildNodeGraphCommand command = new CaseManagementSetChildNodeGraphCommand(diagram, stage, index, Optional.of(diagram), originalIndex); command.removeExistingRelationship(context); assertTrue(command.originalIn.isPresent()); assertEquals(start, command.originalIn.get()); assertTrue(command.originalOut.isPresent()); assertEquals(end, command.originalOut.get()); assertEquals(2, diagram.getOutEdges().size()); assertEquals(1, start.getOutEdges().size()); assertEquals(2, end.getInEdges().size()); assertEquals(end, ((Edge) start.getOutEdges().get(0)).getTargetNode()); }
@SuppressWarnings("unchecked") void removeExistingRelationship(final GraphCommandExecutionContext context) { originalParent.ifPresent(p -> { if (isStage(p, child)) { originalIn = child.getInEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getSourceNode()).findAny(); originalOut = child.getOutEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getTargetNode()).findAny(); } }); getEdgeForTarget(originalParent, child, childPredicate()) .ifPresent((e) -> removeRelationship(e, originalParent.get(), child, context)); getEdgeForTarget(originalIn, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), child, context)); getEdgeForSource(originalOut, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, originalOut.get(), context)); if (originalIn.isPresent() && originalOut.isPresent()) { addRelationship(originalIn.get(), originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier()); } }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void removeExistingRelationship(final GraphCommandExecutionContext context) { originalParent.ifPresent(p -> { if (isStage(p, child)) { originalIn = child.getInEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getSourceNode()).findAny(); originalOut = child.getOutEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getTargetNode()).findAny(); } }); getEdgeForTarget(originalParent, child, childPredicate()) .ifPresent((e) -> removeRelationship(e, originalParent.get(), child, context)); getEdgeForTarget(originalIn, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), child, context)); getEdgeForSource(originalOut, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, originalOut.get(), context)); if (originalIn.isPresent() && originalOut.isPresent()) { addRelationship(originalIn.get(), originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier()); } } }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void removeExistingRelationship(final GraphCommandExecutionContext context) { originalParent.ifPresent(p -> { if (isStage(p, child)) { originalIn = child.getInEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getSourceNode()).findAny(); originalOut = child.getOutEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getTargetNode()).findAny(); } }); getEdgeForTarget(originalParent, child, childPredicate()) .ifPresent((e) -> removeRelationship(e, originalParent.get(), child, context)); getEdgeForTarget(originalIn, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), child, context)); getEdgeForSource(originalOut, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, originalOut.get(), context)); if (originalIn.isPresent() && originalOut.isPresent()) { addRelationship(originalIn.get(), originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier()); } } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void removeExistingRelationship(final GraphCommandExecutionContext context) { originalParent.ifPresent(p -> { if (isStage(p, child)) { originalIn = child.getInEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getSourceNode()).findAny(); originalOut = child.getOutEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getTargetNode()).findAny(); } }); getEdgeForTarget(originalParent, child, childPredicate()) .ifPresent((e) -> removeRelationship(e, originalParent.get(), child, context)); getEdgeForTarget(originalIn, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), child, context)); getEdgeForSource(originalOut, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, originalOut.get(), context)); if (originalIn.isPresent() && originalOut.isPresent()) { addRelationship(originalIn.get(), originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier()); } } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void removeExistingRelationship(final GraphCommandExecutionContext context) { originalParent.ifPresent(p -> { if (isStage(p, child)) { originalIn = child.getInEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getSourceNode()).findAny(); originalOut = child.getOutEdges().stream() .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getTargetNode()).findAny(); } }); getEdgeForTarget(originalParent, child, childPredicate()) .ifPresent((e) -> removeRelationship(e, originalParent.get(), child, context)); getEdgeForTarget(originalIn, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, originalIn.get(), child, context)); getEdgeForSource(originalOut, child, sequencePredicate()) .ifPresent((e) -> removeRelationship(e, child, originalOut.get(), context)); if (originalIn.isPresent() && originalOut.isPresent()) { addRelationship(originalIn.get(), originalOut.get(), OptionalInt.empty(), context, sequenceFlowSupplier()); } } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
@Test public void testAddNewRelationship_withIndex() { final Node diagram = createNode(CaseManagementDiagram.class); final Node start = createNode(StartNoneEvent.class); final Node end = createNode(EndNoneEvent.class); final Node stage = createNode(AdHocSubprocess.class); final Node candidate = createNode(AdHocSubprocess.class); createChildEdge(diagram, start); createChildEdge(diagram, stage); createChildEdge(diagram, end); final Edge edge = createSequenceFlow(start, stage); createSequenceFlow(stage, end); final CaseManagementSetChildNodeGraphCommand command = new CaseManagementSetChildNodeGraphCommand(diagram, candidate, OptionalInt.of(1), Optional.of(diagram), originalIndex); command.addNewRelationship(context); assertTrue(command.in.isPresent()); assertEquals(start, command.in.get()); assertTrue(command.out.isPresent()); assertEquals(stage, command.out.get()); assertTrue(command.edge.isPresent()); assertEquals(edge, command.edge.get()); assertEquals(candidate, ((Edge) diagram.getOutEdges().get(1)).getTargetNode()); assertEquals(candidate, ((Edge) start.getOutEdges().get(0)).getTargetNode()); assertEquals(1, stage.getInEdges().stream().filter(sequencePredicate()).count()); assertEquals(candidate, ((List) stage.getInEdges().stream().filter(sequencePredicate()) .map(e -> ((Edge) e).getSourceNode()).collect(Collectors.toList())).get(0)); }
@SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); } }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
@Test public void testSetup() { presenter.setup(); verify(view).init(presenter); }
@PostConstruct void setup() { view.init(this); }
DecisionNavigatorTreePresenter { @PostConstruct void setup() { view.init(this); } }
DecisionNavigatorTreePresenter { @PostConstruct void setup() { view.init(this); } @Inject DecisionNavigatorTreePresenter(final View view); }
DecisionNavigatorTreePresenter { @PostConstruct void setup() { view.init(this); } @Inject DecisionNavigatorTreePresenter(final View view); View getView(); void setupItems(final List<DecisionNavigatorItem> items); void removeAllItems(); DecisionNavigatorItem getActiveParent(); void setActiveParentUUID(final String activeParentUUID); void selectItem(final String uuid); void deselectItem(); }
DecisionNavigatorTreePresenter { @PostConstruct void setup() { view.init(this); } @Inject DecisionNavigatorTreePresenter(final View view); View getView(); void setupItems(final List<DecisionNavigatorItem> items); void removeAllItems(); DecisionNavigatorItem getActiveParent(); void setActiveParentUUID(final String activeParentUUID); void selectItem(final String uuid); void deselectItem(); }
@Test public void testAddNewRelationship_noIndex() { final Node diagram = createNode(CaseManagementDiagram.class); final Node start = createNode(StartNoneEvent.class); final Node end = createNode(EndNoneEvent.class); final Node stage = createNode(AdHocSubprocess.class); final Node candidate = createNode(AdHocSubprocess.class); createChildEdge(diagram, start); createChildEdge(diagram, stage); createChildEdge(diagram, end); createSequenceFlow(start, stage); final Edge edge = createSequenceFlow(stage, end); final CaseManagementSetChildNodeGraphCommand command = new CaseManagementSetChildNodeGraphCommand(diagram, candidate, OptionalInt.empty(), Optional.of(diagram), originalIndex); command.addNewRelationship(context); assertTrue(command.in.isPresent()); assertEquals(stage, command.in.get()); assertTrue(command.out.isPresent()); assertEquals(end, command.out.get()); assertTrue(command.edge.isPresent()); assertEquals(edge, command.edge.get()); assertEquals(candidate, ((Edge) diagram.getOutEdges().get(2)).getTargetNode()); assertEquals(candidate, ((Edge) stage.getOutEdges().get(0)).getTargetNode()); assertEquals(1, end.getInEdges().stream().filter(sequencePredicate()).count()); assertEquals(candidate, ((List) end.getInEdges().stream().filter(sequencePredicate()) .map(e -> ((Edge) e).getSourceNode()).collect(Collectors.toList())).get(0)); }
@SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); } }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void addNewRelationship(final GraphCommandExecutionContext context) { OptionalInt insertIndex = index; if (isStage(parent, child)) { List<Node> childNodes = parent.getOutEdges().stream() .map(Edge::getTargetNode).collect(Collectors.toList()); if (index.isPresent()) { for (int i = index.getAsInt() - 1; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); break; } } for (int i = index.getAsInt(), n = childNodes.size(); i < n; i++) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } else { int n = childNodes.size(); int i = n - 1; for (; i >= 0; i--) { Node node = childNodes.get(i); if (isStageNode(node) || ((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof StartNoneEvent) { in = Optional.of(node); insertIndex = OptionalInt.of(i + 1); break; } } if (i == 0) { insertIndex = OptionalInt.of(0); } if (i >= 0) { for (; i < n; i++) { Node node = childNodes.get(i); if (((Node<View<?>, Edge>) node).getContent().getDefinition() instanceof EndNoneEvent) { out = Optional.of(node); break; } } } } } if (in.isPresent() && out.isPresent()) { edge = getEdgeForTarget(in, out.get(), sequencePredicate()); } edge.ifPresent(e -> removeRelationship(e, in.get(), out.get(), context)); addRelationship(parent, child, insertIndex, context, Child::new); in.ifPresent(n -> addRelationship(n, child, OptionalInt.empty(), context, sequenceFlowSupplier())); out.ifPresent(n -> addRelationship(child, n, OptionalInt.empty(), context, sequenceFlowSupplier())); } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
@Test public void testSequenceFlowSupplier() { final CaseManagementSetChildNodeGraphCommand command = new CaseManagementSetChildNodeGraphCommand(parent, candidate, index, originalParent, originalIndex); final Supplier<ViewConnector<SequenceFlow>> supplier = command.sequenceFlowSupplier(); final ViewConnector<SequenceFlow> viewConnector = supplier.get(); assertNotNull(viewConnector); assertNotNull(viewConnector.getSourceConnection()); assertNotNull(viewConnector.getTargetConnection()); assertNotNull(viewConnector.getBounds()); assertNotNull(viewConnector.getDefinition()); }
Supplier<ViewConnector<SequenceFlow>> sequenceFlowSupplier() { ViewConnector<SequenceFlow> viewConnector = new ViewConnectorImpl<>(new SequenceFlow(), Bounds.create(0d, 0d, 30d, 30d)); viewConnector.setSourceConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); viewConnector.setTargetConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); return () -> viewConnector; }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { Supplier<ViewConnector<SequenceFlow>> sequenceFlowSupplier() { ViewConnector<SequenceFlow> viewConnector = new ViewConnectorImpl<>(new SequenceFlow(), Bounds.create(0d, 0d, 30d, 30d)); viewConnector.setSourceConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); viewConnector.setTargetConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); return () -> viewConnector; } }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { Supplier<ViewConnector<SequenceFlow>> sequenceFlowSupplier() { ViewConnector<SequenceFlow> viewConnector = new ViewConnectorImpl<>(new SequenceFlow(), Bounds.create(0d, 0d, 30d, 30d)); viewConnector.setSourceConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); viewConnector.setTargetConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); return () -> viewConnector; } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { Supplier<ViewConnector<SequenceFlow>> sequenceFlowSupplier() { ViewConnector<SequenceFlow> viewConnector = new ViewConnectorImpl<>(new SequenceFlow(), Bounds.create(0d, 0d, 30d, 30d)); viewConnector.setSourceConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); viewConnector.setTargetConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); return () -> viewConnector; } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { Supplier<ViewConnector<SequenceFlow>> sequenceFlowSupplier() { ViewConnector<SequenceFlow> viewConnector = new ViewConnectorImpl<>(new SequenceFlow(), Bounds.create(0d, 0d, 30d, 30d)); viewConnector.setSourceConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); viewConnector.setTargetConnection(new MagnetConnection.Builder().atX(475d).atY(475d).auto(true).build()); return () -> viewConnector; } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
@Test public void testResizeNodes() { final Node stage = createNode(AdHocSubprocess.class, 1.0, 1.0, 25.0, 25.0); final Node task = createNode(UserTask.class, 1.0, 1.0, 5.0, 5.0); final CaseManagementSetChildNodeGraphCommand command = new CaseManagementSetChildNodeGraphCommand(stage, task, index, originalParent, originalIndex); final Edge childEdge = mock(Edge.class); when(childEdge.getContent()).thenReturn(mock(Child.class)); when(childEdge.getTargetNode()).thenReturn(task); when(stage.getOutEdges()).thenReturn(Collections.singletonList(childEdge)); command.resizeNodes(); assertEquals(Optional.of(Bounds.create(1.0, 1.0, 25.0, 25.0)), command.originalParentBounds); assertEquals(1, command.originalBounds.size()); assertEquals(Optional.of(Bounds.create(1.0, 1.0, 5.0, 5.0)), command.originalBounds.get(task.getUUID())); assertEquals(Bounds.create(1.0, 1.0, 1.0 + CHILD_WIDTH + STAGE_GAP * 2, 1.0 + CHILD_HEIGHT + STAGE_GAP * 2), ((View) stage.getContent()).getBounds()); assertEquals(Bounds.create(STAGE_GAP, STAGE_GAP, STAGE_GAP + CHILD_WIDTH, STAGE_GAP + CHILD_HEIGHT), ((View) task.getContent()).getBounds()); command.undoResizeNodes(); assertEquals(Bounds.create(1.0, 1.0, 25.0, 25.0), ((View) stage.getContent()).getBounds()); assertEquals(Bounds.create(1.0, 1.0, 5.0, 5.0), ((View) task.getContent()).getBounds()); }
@SuppressWarnings("unchecked") void resizeNodes() { if (isStageNode(parent) && isSubStageNode(child)) { final List<Node> childNodes = parent.getOutEdges().stream() .filter(childPredicate()).map(Edge::getTargetNode).collect(Collectors.toList()); childNodes.stream().forEach(cNode -> { final Bounds cBounds = ((Node<View, Edge>) cNode).getContent().getBounds(); originalBounds.put(cNode.getUUID(), Optional.of(Bounds.create(cBounds.getUpperLeft().getX(), cBounds.getUpperLeft().getY(), cBounds.getLowerRight().getX(), cBounds.getLowerRight().getY()))); }); IntStream.range(0, childNodes.size()).forEach(i -> { final Node<View, Edge> childNode = childNodes.get(i); final double cx = STAGE_GAP; final double cy = STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * i; childNode.getContent().setBounds( Bounds.create(cx, cy, cx + CHILD_WIDTH, cy + CHILD_HEIGHT)); }); Bounds pBounds = parent.getContent().getBounds(); originalParentBounds = Optional.of(Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getLowerRight().getX(), pBounds.getLowerRight().getY())); Bounds parentBounds = Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getUpperLeft().getX() + CHILD_WIDTH + STAGE_GAP * 2, pBounds.getUpperLeft().getY() + STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * childNodes.size()); parent.getContent().setBounds(parentBounds); } }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void resizeNodes() { if (isStageNode(parent) && isSubStageNode(child)) { final List<Node> childNodes = parent.getOutEdges().stream() .filter(childPredicate()).map(Edge::getTargetNode).collect(Collectors.toList()); childNodes.stream().forEach(cNode -> { final Bounds cBounds = ((Node<View, Edge>) cNode).getContent().getBounds(); originalBounds.put(cNode.getUUID(), Optional.of(Bounds.create(cBounds.getUpperLeft().getX(), cBounds.getUpperLeft().getY(), cBounds.getLowerRight().getX(), cBounds.getLowerRight().getY()))); }); IntStream.range(0, childNodes.size()).forEach(i -> { final Node<View, Edge> childNode = childNodes.get(i); final double cx = STAGE_GAP; final double cy = STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * i; childNode.getContent().setBounds( Bounds.create(cx, cy, cx + CHILD_WIDTH, cy + CHILD_HEIGHT)); }); Bounds pBounds = parent.getContent().getBounds(); originalParentBounds = Optional.of(Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getLowerRight().getX(), pBounds.getLowerRight().getY())); Bounds parentBounds = Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getUpperLeft().getX() + CHILD_WIDTH + STAGE_GAP * 2, pBounds.getUpperLeft().getY() + STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * childNodes.size()); parent.getContent().setBounds(parentBounds); } } }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void resizeNodes() { if (isStageNode(parent) && isSubStageNode(child)) { final List<Node> childNodes = parent.getOutEdges().stream() .filter(childPredicate()).map(Edge::getTargetNode).collect(Collectors.toList()); childNodes.stream().forEach(cNode -> { final Bounds cBounds = ((Node<View, Edge>) cNode).getContent().getBounds(); originalBounds.put(cNode.getUUID(), Optional.of(Bounds.create(cBounds.getUpperLeft().getX(), cBounds.getUpperLeft().getY(), cBounds.getLowerRight().getX(), cBounds.getLowerRight().getY()))); }); IntStream.range(0, childNodes.size()).forEach(i -> { final Node<View, Edge> childNode = childNodes.get(i); final double cx = STAGE_GAP; final double cy = STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * i; childNode.getContent().setBounds( Bounds.create(cx, cy, cx + CHILD_WIDTH, cy + CHILD_HEIGHT)); }); Bounds pBounds = parent.getContent().getBounds(); originalParentBounds = Optional.of(Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getLowerRight().getX(), pBounds.getLowerRight().getY())); Bounds parentBounds = Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getUpperLeft().getX() + CHILD_WIDTH + STAGE_GAP * 2, pBounds.getUpperLeft().getY() + STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * childNodes.size()); parent.getContent().setBounds(parentBounds); } } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void resizeNodes() { if (isStageNode(parent) && isSubStageNode(child)) { final List<Node> childNodes = parent.getOutEdges().stream() .filter(childPredicate()).map(Edge::getTargetNode).collect(Collectors.toList()); childNodes.stream().forEach(cNode -> { final Bounds cBounds = ((Node<View, Edge>) cNode).getContent().getBounds(); originalBounds.put(cNode.getUUID(), Optional.of(Bounds.create(cBounds.getUpperLeft().getX(), cBounds.getUpperLeft().getY(), cBounds.getLowerRight().getX(), cBounds.getLowerRight().getY()))); }); IntStream.range(0, childNodes.size()).forEach(i -> { final Node<View, Edge> childNode = childNodes.get(i); final double cx = STAGE_GAP; final double cy = STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * i; childNode.getContent().setBounds( Bounds.create(cx, cy, cx + CHILD_WIDTH, cy + CHILD_HEIGHT)); }); Bounds pBounds = parent.getContent().getBounds(); originalParentBounds = Optional.of(Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getLowerRight().getX(), pBounds.getLowerRight().getY())); Bounds parentBounds = Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getUpperLeft().getX() + CHILD_WIDTH + STAGE_GAP * 2, pBounds.getUpperLeft().getY() + STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * childNodes.size()); parent.getContent().setBounds(parentBounds); } } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand { @SuppressWarnings("unchecked") void resizeNodes() { if (isStageNode(parent) && isSubStageNode(child)) { final List<Node> childNodes = parent.getOutEdges().stream() .filter(childPredicate()).map(Edge::getTargetNode).collect(Collectors.toList()); childNodes.stream().forEach(cNode -> { final Bounds cBounds = ((Node<View, Edge>) cNode).getContent().getBounds(); originalBounds.put(cNode.getUUID(), Optional.of(Bounds.create(cBounds.getUpperLeft().getX(), cBounds.getUpperLeft().getY(), cBounds.getLowerRight().getX(), cBounds.getLowerRight().getY()))); }); IntStream.range(0, childNodes.size()).forEach(i -> { final Node<View, Edge> childNode = childNodes.get(i); final double cx = STAGE_GAP; final double cy = STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * i; childNode.getContent().setBounds( Bounds.create(cx, cy, cx + CHILD_WIDTH, cy + CHILD_HEIGHT)); }); Bounds pBounds = parent.getContent().getBounds(); originalParentBounds = Optional.of(Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getLowerRight().getX(), pBounds.getLowerRight().getY())); Bounds parentBounds = Bounds.create(pBounds.getUpperLeft().getX(), pBounds.getUpperLeft().getY(), pBounds.getUpperLeft().getX() + CHILD_WIDTH + STAGE_GAP * 2, pBounds.getUpperLeft().getY() + STAGE_GAP + (STAGE_GAP + CHILD_HEIGHT) * childNodes.size()); parent.getContent().setBounds(parentBounds); } } CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent, final Node<View<?>, Edge> child, final OptionalInt index, final Optional<Node<View<?>, Edge>> originalParent, final OptionalInt originalIndex); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); OptionalInt getIndex(); OptionalInt getOriginalIndex(); }
@Test @SuppressWarnings("unchecked") public void testCreateRemoveChildCommand() { final CaseManagementRemoveChildCommand command = tested.createRemoveChildCommand(parent, candidate); assertEquals(parent, command.getParent()); assertEquals(candidate, command.getCandidate()); }
@Override @SuppressWarnings("unchecked") protected CaseManagementRemoveChildCommand createRemoveChildCommand(final Element<?> parent, final Node<?, Edge> candidate) { return new CaseManagementRemoveChildCommand((Node<View<?>, Edge>) parent, (Node<View<?>, Edge>) candidate); }
CaseManagementSafeDeleteNodeCommand extends SafeDeleteNodeCommand { @Override @SuppressWarnings("unchecked") protected CaseManagementRemoveChildCommand createRemoveChildCommand(final Element<?> parent, final Node<?, Edge> candidate) { return new CaseManagementRemoveChildCommand((Node<View<?>, Edge>) parent, (Node<View<?>, Edge>) candidate); } }
CaseManagementSafeDeleteNodeCommand extends SafeDeleteNodeCommand { @Override @SuppressWarnings("unchecked") protected CaseManagementRemoveChildCommand createRemoveChildCommand(final Element<?> parent, final Node<?, Edge> candidate) { return new CaseManagementRemoveChildCommand((Node<View<?>, Edge>) parent, (Node<View<?>, Edge>) candidate); } CaseManagementSafeDeleteNodeCommand(@MapsTo("candidateUUID") String candidateUUID, @MapsTo("options") Options options); CaseManagementSafeDeleteNodeCommand(Node<?, Edge> node); CaseManagementSafeDeleteNodeCommand(Node<?, Edge> node, Options options); CaseManagementSafeDeleteNodeCommand(Node<?, Edge> node, SafeDeleteNodeCommandCallback safeDeleteCallback, Options options); }
CaseManagementSafeDeleteNodeCommand extends SafeDeleteNodeCommand { @Override @SuppressWarnings("unchecked") protected CaseManagementRemoveChildCommand createRemoveChildCommand(final Element<?> parent, final Node<?, Edge> candidate) { return new CaseManagementRemoveChildCommand((Node<View<?>, Edge>) parent, (Node<View<?>, Edge>) candidate); } CaseManagementSafeDeleteNodeCommand(@MapsTo("candidateUUID") String candidateUUID, @MapsTo("options") Options options); CaseManagementSafeDeleteNodeCommand(Node<?, Edge> node); CaseManagementSafeDeleteNodeCommand(Node<?, Edge> node, Options options); CaseManagementSafeDeleteNodeCommand(Node<?, Edge> node, SafeDeleteNodeCommandCallback safeDeleteCallback, Options options); }
CaseManagementSafeDeleteNodeCommand extends SafeDeleteNodeCommand { @Override @SuppressWarnings("unchecked") protected CaseManagementRemoveChildCommand createRemoveChildCommand(final Element<?> parent, final Node<?, Edge> candidate) { return new CaseManagementRemoveChildCommand((Node<View<?>, Edge>) parent, (Node<View<?>, Edge>) candidate); } CaseManagementSafeDeleteNodeCommand(@MapsTo("candidateUUID") String candidateUUID, @MapsTo("options") Options options); CaseManagementSafeDeleteNodeCommand(Node<?, Edge> node); CaseManagementSafeDeleteNodeCommand(Node<?, Edge> node, Options options); CaseManagementSafeDeleteNodeCommand(Node<?, Edge> node, SafeDeleteNodeCommandCallback safeDeleteCallback, Options options); }
@Test public void testUndo() { parent.getOutEdges().clear(); tested.undo(context); assertEquals(1, parent.getOutEdges().size()); assertEquals(1, candidate.getInEdges().size()); assertEquals(parent.getOutEdges().get(0), candidate.getInEdges().get(0)); final Edge edge = parent.getOutEdges().get(0); assertEquals(parent, edge.getSourceNode()); assertEquals(candidate, edge.getTargetNode()); assertTrue(edge.getContent() instanceof Child); }
@Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(GraphCommandExecutionContext context) { final Node<View<?>, Edge> parent = (Node<View<?>, Edge>) getParent(context); final Node<View<?>, Edge> candidate = (Node<View<?>, Edge>) getCandidate(context); final CaseManagementSetChildNodeGraphCommand undoCommand = new CaseManagementSetChildNodeGraphCommand(parent, candidate, OptionalInt.of(index), Optional.empty(), OptionalInt.empty()); return undoCommand.execute(context); }
CaseManagementRemoveChildCommand extends RemoveChildrenCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(GraphCommandExecutionContext context) { final Node<View<?>, Edge> parent = (Node<View<?>, Edge>) getParent(context); final Node<View<?>, Edge> candidate = (Node<View<?>, Edge>) getCandidate(context); final CaseManagementSetChildNodeGraphCommand undoCommand = new CaseManagementSetChildNodeGraphCommand(parent, candidate, OptionalInt.of(index), Optional.empty(), OptionalInt.empty()); return undoCommand.execute(context); } }
CaseManagementRemoveChildCommand extends RemoveChildrenCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(GraphCommandExecutionContext context) { final Node<View<?>, Edge> parent = (Node<View<?>, Edge>) getParent(context); final Node<View<?>, Edge> candidate = (Node<View<?>, Edge>) getCandidate(context); final CaseManagementSetChildNodeGraphCommand undoCommand = new CaseManagementSetChildNodeGraphCommand(parent, candidate, OptionalInt.of(index), Optional.empty(), OptionalInt.empty()); return undoCommand.execute(context); } CaseManagementRemoveChildCommand(@MapsTo("parentUUID") String parentUUID, @MapsTo("candidateUUID") String candidateUUID); CaseManagementRemoveChildCommand(Node<View<?>, Edge> parent, Node<View<?>, Edge> candidate); }
CaseManagementRemoveChildCommand extends RemoveChildrenCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(GraphCommandExecutionContext context) { final Node<View<?>, Edge> parent = (Node<View<?>, Edge>) getParent(context); final Node<View<?>, Edge> candidate = (Node<View<?>, Edge>) getCandidate(context); final CaseManagementSetChildNodeGraphCommand undoCommand = new CaseManagementSetChildNodeGraphCommand(parent, candidate, OptionalInt.of(index), Optional.empty(), OptionalInt.empty()); return undoCommand.execute(context); } CaseManagementRemoveChildCommand(@MapsTo("parentUUID") String parentUUID, @MapsTo("candidateUUID") String candidateUUID); CaseManagementRemoveChildCommand(Node<View<?>, Edge> parent, Node<View<?>, Edge> candidate); Node<?, Edge> getCandidate(); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); }
CaseManagementRemoveChildCommand extends RemoveChildrenCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> undo(GraphCommandExecutionContext context) { final Node<View<?>, Edge> parent = (Node<View<?>, Edge>) getParent(context); final Node<View<?>, Edge> candidate = (Node<View<?>, Edge>) getCandidate(context); final CaseManagementSetChildNodeGraphCommand undoCommand = new CaseManagementSetChildNodeGraphCommand(parent, candidate, OptionalInt.of(index), Optional.empty(), OptionalInt.empty()); return undoCommand.execute(context); } CaseManagementRemoveChildCommand(@MapsTo("parentUUID") String parentUUID, @MapsTo("candidateUUID") String candidateUUID); CaseManagementRemoveChildCommand(Node<View<?>, Edge> parent, Node<View<?>, Edge> candidate); Node<?, Edge> getCandidate(); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); }
@Test @SuppressWarnings("unchecked") public void testCreateSafeDeleteNodeCommand() { final CaseManagementSafeDeleteNodeCommand command = tested.createSafeDeleteNodeCommand(node, SafeDeleteNodeCommand.Options.defaults(), new DeleteElementsCommand.DeleteCallback() { }); assertEquals(node, command.getNode()); }
@Override protected CaseManagementSafeDeleteNodeCommand createSafeDeleteNodeCommand(final Node<?, Edge> node, final SafeDeleteNodeCommand.Options options, final DeleteCallback callback) { return new CaseManagementSafeDeleteNodeCommand(node, callback.onDeleteNode(node, options), options); }
CaseManagementDeleteElementsCommand extends DeleteElementsCommand { @Override protected CaseManagementSafeDeleteNodeCommand createSafeDeleteNodeCommand(final Node<?, Edge> node, final SafeDeleteNodeCommand.Options options, final DeleteCallback callback) { return new CaseManagementSafeDeleteNodeCommand(node, callback.onDeleteNode(node, options), options); } }
CaseManagementDeleteElementsCommand extends DeleteElementsCommand { @Override protected CaseManagementSafeDeleteNodeCommand createSafeDeleteNodeCommand(final Node<?, Edge> node, final SafeDeleteNodeCommand.Options options, final DeleteCallback callback) { return new CaseManagementSafeDeleteNodeCommand(node, callback.onDeleteNode(node, options), options); } CaseManagementDeleteElementsCommand(@MapsTo("uuids") Collection<String> uuids); CaseManagementDeleteElementsCommand(Supplier<Collection<Element>> elements); CaseManagementDeleteElementsCommand(Supplier<Collection<Element>> elements, DeleteCallback callback); }
CaseManagementDeleteElementsCommand extends DeleteElementsCommand { @Override protected CaseManagementSafeDeleteNodeCommand createSafeDeleteNodeCommand(final Node<?, Edge> node, final SafeDeleteNodeCommand.Options options, final DeleteCallback callback) { return new CaseManagementSafeDeleteNodeCommand(node, callback.onDeleteNode(node, options), options); } CaseManagementDeleteElementsCommand(@MapsTo("uuids") Collection<String> uuids); CaseManagementDeleteElementsCommand(Supplier<Collection<Element>> elements); CaseManagementDeleteElementsCommand(Supplier<Collection<Element>> elements, DeleteCallback callback); }
CaseManagementDeleteElementsCommand extends DeleteElementsCommand { @Override protected CaseManagementSafeDeleteNodeCommand createSafeDeleteNodeCommand(final Node<?, Edge> node, final SafeDeleteNodeCommand.Options options, final DeleteCallback callback) { return new CaseManagementSafeDeleteNodeCommand(node, callback.onDeleteNode(node, options), options); } CaseManagementDeleteElementsCommand(@MapsTo("uuids") Collection<String> uuids); CaseManagementDeleteElementsCommand(Supplier<Collection<Element>> elements); CaseManagementDeleteElementsCommand(Supplier<Collection<Element>> elements, DeleteCallback callback); }
@Test public void testCreateNodeCommands() throws Exception { tested.createNodeCommands(graphInstance.containerNode, graphInstance.parentNode.getUUID(), position); assertEquals(2, tested.getCommands().size()); assertTrue(RegisterNodeCommand.class.isInstance(tested.getCommands().get(0))); assertTrue(CaseManagementAddChildNodeGraphCommand.class.isInstance(tested.getCommands().get(1))); }
@Override protected void createNodeCommands(final Node<View, Edge> clone, final String parentUUID, final Point2D position) { addCommand(new RegisterNodeCommand(clone)); addCommand(new CaseManagementAddChildNodeGraphCommand(parentUUID, clone, OptionalInt.empty())); }
CaseManagementCloneNodeCommand extends CloneNodeCommand { @Override protected void createNodeCommands(final Node<View, Edge> clone, final String parentUUID, final Point2D position) { addCommand(new RegisterNodeCommand(clone)); addCommand(new CaseManagementAddChildNodeGraphCommand(parentUUID, clone, OptionalInt.empty())); } }
CaseManagementCloneNodeCommand extends CloneNodeCommand { @Override protected void createNodeCommands(final Node<View, Edge> clone, final String parentUUID, final Point2D position) { addCommand(new RegisterNodeCommand(clone)); addCommand(new CaseManagementAddChildNodeGraphCommand(parentUUID, clone, OptionalInt.empty())); } protected CaseManagementCloneNodeCommand(); CaseManagementCloneNodeCommand(@MapsTo("candidate") Node candidate, @MapsTo("parentUuid") String parentUuid); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback, ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback); }
CaseManagementCloneNodeCommand extends CloneNodeCommand { @Override protected void createNodeCommands(final Node<View, Edge> clone, final String parentUUID, final Point2D position) { addCommand(new RegisterNodeCommand(clone)); addCommand(new CaseManagementAddChildNodeGraphCommand(parentUUID, clone, OptionalInt.empty())); } protected CaseManagementCloneNodeCommand(); CaseManagementCloneNodeCommand(@MapsTo("candidate") Node candidate, @MapsTo("parentUuid") String parentUuid); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback, ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback); @Override CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); }
CaseManagementCloneNodeCommand extends CloneNodeCommand { @Override protected void createNodeCommands(final Node<View, Edge> clone, final String parentUUID, final Point2D position) { addCommand(new RegisterNodeCommand(clone)); addCommand(new CaseManagementAddChildNodeGraphCommand(parentUUID, clone, OptionalInt.empty())); } protected CaseManagementCloneNodeCommand(); CaseManagementCloneNodeCommand(@MapsTo("candidate") Node candidate, @MapsTo("parentUuid") String parentUuid); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback, ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback); @Override CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); }
@Test public void testCreateCloneChildCommand() throws Exception { final CloneNodeCommand command = tested.createCloneChildCommand(graphInstance.containerNode, graphInstance.parentNode.getUUID(), position, null, childrenTraverseProcessorManagedInstance); assertTrue(CaseManagementCloneNodeCommand.class.isInstance(command)); }
@Override protected CloneNodeCommand createCloneChildCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor) { return new CaseManagementCloneNodeCommand(candidate, parentUuid, position, callback, childrenTraverseProcessor); }
CaseManagementCloneNodeCommand extends CloneNodeCommand { @Override protected CloneNodeCommand createCloneChildCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor) { return new CaseManagementCloneNodeCommand(candidate, parentUuid, position, callback, childrenTraverseProcessor); } }
CaseManagementCloneNodeCommand extends CloneNodeCommand { @Override protected CloneNodeCommand createCloneChildCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor) { return new CaseManagementCloneNodeCommand(candidate, parentUuid, position, callback, childrenTraverseProcessor); } protected CaseManagementCloneNodeCommand(); CaseManagementCloneNodeCommand(@MapsTo("candidate") Node candidate, @MapsTo("parentUuid") String parentUuid); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback, ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback); }
CaseManagementCloneNodeCommand extends CloneNodeCommand { @Override protected CloneNodeCommand createCloneChildCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor) { return new CaseManagementCloneNodeCommand(candidate, parentUuid, position, callback, childrenTraverseProcessor); } protected CaseManagementCloneNodeCommand(); CaseManagementCloneNodeCommand(@MapsTo("candidate") Node candidate, @MapsTo("parentUuid") String parentUuid); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback, ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback); @Override CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); }
CaseManagementCloneNodeCommand extends CloneNodeCommand { @Override protected CloneNodeCommand createCloneChildCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor) { return new CaseManagementCloneNodeCommand(candidate, parentUuid, position, callback, childrenTraverseProcessor); } protected CaseManagementCloneNodeCommand(); CaseManagementCloneNodeCommand(@MapsTo("candidate") Node candidate, @MapsTo("parentUuid") String parentUuid); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback, ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor); CaseManagementCloneNodeCommand(Node candidate, String parentUuid, Point2D position, Consumer<Node> callback); @Override CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); }
@Test public void testExecute() { tested.execute(context); verify(tested).executeCommands(eq(context), commandsCapture.capture()); final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commands = commandsCapture.getValue(); assertEquals(5, commands.size()); Map<Class<?>, Long> commandsMap = IntStream.range(0, commands.size()) .mapToObj(commands::get).collect(Collectors.groupingBy(Object::getClass, Collectors.counting())); assertEquals(2, commandsMap.size()); assertEquals(1, commandsMap.get(AddCanvasNodeCommand.class).longValue()); assertEquals(4, commandsMap.get(AddCanvasChildNodeCommand.class).longValue()); }
@Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Diagram diagram = context.getDiagram(); final String shapeSetId = context.getDiagram().getMetadata().getShapeSetId(); this.sortNodes(diagram); final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>().forward(); childrenTraverseProcessor .traverse(diagram.getGraph(), new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public void startNodeTraversal(final Node<View, Edge> node) { super.startNodeTraversal(node); commandBuilder.addCommand(new AddCanvasNodeCommand((Node) node, shapeSetId)); } @Override public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> node) { super.startNodeTraversal(parents, node); if (isDrawable(parents.get(parents.size() - 1), node)) { commandBuilder.addCommand(new AddCanvasChildNodeCommand(parents.get(parents.size() - 1), node, shapeSetId)); } return true; } @Override public void endGraphTraversal() { super.endGraphTraversal(); } }); return executeCommands(context, commandBuilder); }
CaseManagementDrawCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Diagram diagram = context.getDiagram(); final String shapeSetId = context.getDiagram().getMetadata().getShapeSetId(); this.sortNodes(diagram); final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>().forward(); childrenTraverseProcessor .traverse(diagram.getGraph(), new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public void startNodeTraversal(final Node<View, Edge> node) { super.startNodeTraversal(node); commandBuilder.addCommand(new AddCanvasNodeCommand((Node) node, shapeSetId)); } @Override public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> node) { super.startNodeTraversal(parents, node); if (isDrawable(parents.get(parents.size() - 1), node)) { commandBuilder.addCommand(new AddCanvasChildNodeCommand(parents.get(parents.size() - 1), node, shapeSetId)); } return true; } @Override public void endGraphTraversal() { super.endGraphTraversal(); } }); return executeCommands(context, commandBuilder); } }
CaseManagementDrawCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Diagram diagram = context.getDiagram(); final String shapeSetId = context.getDiagram().getMetadata().getShapeSetId(); this.sortNodes(diagram); final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>().forward(); childrenTraverseProcessor .traverse(diagram.getGraph(), new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public void startNodeTraversal(final Node<View, Edge> node) { super.startNodeTraversal(node); commandBuilder.addCommand(new AddCanvasNodeCommand((Node) node, shapeSetId)); } @Override public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> node) { super.startNodeTraversal(parents, node); if (isDrawable(parents.get(parents.size() - 1), node)) { commandBuilder.addCommand(new AddCanvasChildNodeCommand(parents.get(parents.size() - 1), node, shapeSetId)); } return true; } @Override public void endGraphTraversal() { super.endGraphTraversal(); } }); return executeCommands(context, commandBuilder); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); }
CaseManagementDrawCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Diagram diagram = context.getDiagram(); final String shapeSetId = context.getDiagram().getMetadata().getShapeSetId(); this.sortNodes(diagram); final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>().forward(); childrenTraverseProcessor .traverse(diagram.getGraph(), new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public void startNodeTraversal(final Node<View, Edge> node) { super.startNodeTraversal(node); commandBuilder.addCommand(new AddCanvasNodeCommand((Node) node, shapeSetId)); } @Override public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> node) { super.startNodeTraversal(parents, node); if (isDrawable(parents.get(parents.size() - 1), node)) { commandBuilder.addCommand(new AddCanvasChildNodeCommand(parents.get(parents.size() - 1), node, shapeSetId)); } return true; } @Override public void endGraphTraversal() { super.endGraphTraversal(); } }); return executeCommands(context, commandBuilder); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); }
CaseManagementDrawCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Diagram diagram = context.getDiagram(); final String shapeSetId = context.getDiagram().getMetadata().getShapeSetId(); this.sortNodes(diagram); final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> commandBuilder = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>().forward(); childrenTraverseProcessor .traverse(diagram.getGraph(), new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public void startNodeTraversal(final Node<View, Edge> node) { super.startNodeTraversal(node); commandBuilder.addCommand(new AddCanvasNodeCommand((Node) node, shapeSetId)); } @Override public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> node) { super.startNodeTraversal(parents, node); if (isDrawable(parents.get(parents.size() - 1), node)) { commandBuilder.addCommand(new AddCanvasChildNodeCommand(parents.get(parents.size() - 1), node, shapeSetId)); } return true; } @Override public void endGraphTraversal() { super.endGraphTraversal(); } }); return executeCommands(context, commandBuilder); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); }
@Test public void testSortNodes_Stage() { final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram = mock(Diagram.class); final Graph<DefinitionSet, Node> graph = mock(Graph.class); when(diagram.getGraph()).thenReturn(graph); final List<Node> nodes = new LinkedList<>(); when(graph.nodes()).thenReturn(nodes); final Node root = createNode(CaseManagementDiagram.class); final Node start = createNode(StartNoneEvent.class); final Node end = createNode(EndNoneEvent.class); final Node stage1 = createNode(AdHocSubprocess.class); final Node stage2 = createNode(AdHocSubprocess.class); nodes.add(root); nodes.add(start); nodes.add(end); nodes.add(stage1); nodes.add(stage2); createChildEdge(root, end); createChildEdge(root, start); createChildEdge(root, stage2); createChildEdge(root, stage1); createSequenceFlow(start, stage1); createSequenceFlow(stage1, stage2); createSequenceFlow(stage2, end); tested.sortNodes(diagram); final List<Edge> rEdges = root.getOutEdges(); assertEquals(4, rEdges.size()); assertEquals(start, rEdges.get(0).getTargetNode()); assertEquals(stage1, rEdges.get(1).getTargetNode()); assertEquals(stage2, rEdges.get(2).getTargetNode()); assertEquals(end, rEdges.get(3).getTargetNode()); }
@SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); }
CaseManagementDrawCommand extends AbstractCanvasCommand { @SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); } }
CaseManagementDrawCommand extends AbstractCanvasCommand { @SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); }
CaseManagementDrawCommand extends AbstractCanvasCommand { @SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); }
CaseManagementDrawCommand extends AbstractCanvasCommand { @SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); }
@Test public void testSetupItems() { final ArrayList<DecisionNavigatorItem> items = new ArrayList<>(); doNothing().when(presenter).index(items); presenter.setupItems(items); verify(presenter).index(items); verify(view).clean(); verify(view).setup(items); }
public void setupItems(final List<DecisionNavigatorItem> items) { getIndexedItems().clear(); index(items); view.clean(); view.setup(items); }
DecisionNavigatorTreePresenter { public void setupItems(final List<DecisionNavigatorItem> items) { getIndexedItems().clear(); index(items); view.clean(); view.setup(items); } }
DecisionNavigatorTreePresenter { public void setupItems(final List<DecisionNavigatorItem> items) { getIndexedItems().clear(); index(items); view.clean(); view.setup(items); } @Inject DecisionNavigatorTreePresenter(final View view); }
DecisionNavigatorTreePresenter { public void setupItems(final List<DecisionNavigatorItem> items) { getIndexedItems().clear(); index(items); view.clean(); view.setup(items); } @Inject DecisionNavigatorTreePresenter(final View view); View getView(); void setupItems(final List<DecisionNavigatorItem> items); void removeAllItems(); DecisionNavigatorItem getActiveParent(); void setActiveParentUUID(final String activeParentUUID); void selectItem(final String uuid); void deselectItem(); }
DecisionNavigatorTreePresenter { public void setupItems(final List<DecisionNavigatorItem> items) { getIndexedItems().clear(); index(items); view.clean(); view.setup(items); } @Inject DecisionNavigatorTreePresenter(final View view); View getView(); void setupItems(final List<DecisionNavigatorItem> items); void removeAllItems(); DecisionNavigatorItem getActiveParent(); void setActiveParentUUID(final String activeParentUUID); void selectItem(final String uuid); void deselectItem(); }
@Test public void testSortNodes_SubStage() { final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram = mock(Diagram.class); final Graph<DefinitionSet, Node> graph = mock(Graph.class); when(diagram.getGraph()).thenReturn(graph); final List<Node> nodes = new LinkedList<>(); when(graph.nodes()).thenReturn(nodes); final Node root = createNode(CaseManagementDiagram.class); final Node start = createNode(StartNoneEvent.class); final Node end = createNode(EndNoneEvent.class); final Node stage = createNode(AdHocSubprocess.class); nodes.add(root); nodes.add(start); nodes.add(end); nodes.add(stage); createChildEdge(root, end); createChildEdge(root, start); createChildEdge(root, stage); createSequenceFlow(start, stage); createSequenceFlow(stage, end); final Node ss1 = createNode(UserTask.class, 3.0); final Node ss2 = createNode(CaseReusableSubprocess.class, 2.0); final Node ss3 = createNode(ProcessReusableSubprocess.class, 1.0); nodes.add(ss1); nodes.add(ss2); nodes.add(ss3); createChildEdge(stage, ss1); createChildEdge(stage, ss2); createChildEdge(stage, ss3); tested.sortNodes(diagram); final List<Edge> rEdges = root.getOutEdges(); assertEquals(3, rEdges.size()); assertEquals(start, rEdges.get(0).getTargetNode()); assertEquals(stage, rEdges.get(1).getTargetNode()); assertEquals(end, rEdges.get(2).getTargetNode()); final List<Edge> sEdges = stage.getOutEdges(); assertEquals(4, sEdges.size()); assertEquals(ss3, sEdges.get(0).getTargetNode()); assertEquals(ss2, sEdges.get(1).getTargetNode()); assertEquals(ss1, sEdges.get(2).getTargetNode()); }
@SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); }
CaseManagementDrawCommand extends AbstractCanvasCommand { @SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); } }
CaseManagementDrawCommand extends AbstractCanvasCommand { @SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); }
CaseManagementDrawCommand extends AbstractCanvasCommand { @SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); }
CaseManagementDrawCommand extends AbstractCanvasCommand { @SuppressWarnings("unchecked") void sortNodes(final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram) { List<Node<View<?>, Edge>> nodes = StreamSupport.stream(diagram.getGraph().nodes().spliterator(), false) .map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList()); nodes.stream() .filter(node -> node.getContent().getDefinition() instanceof CaseManagementDiagram) .findAny().ifPresent(root -> { Map<Node<View<?>, Edge>, Edge> childNodes = root.getOutEdges().stream() .filter(childPredicate()).collect(Collectors.toMap(e -> (Node<View<?>, Edge>) e.getTargetNode(), identity())); Node<View<?>, Edge> startNode = root.getOutEdges().stream().map(Edge::getTargetNode) .filter(n -> ((Node<View<?>, Edge>) n).getContent().getDefinition() instanceof StartNoneEvent).findAny() .orElseGet(() -> childNodes.keySet().stream().filter(n -> n.getInEdges().size() == 1).findAny().orElse(null)); if (startNode != null) { Node<View<?>, Edge> node = startNode; List<Edge> childEdges = new LinkedList<>(); do { childEdges.add(0, childNodes.get(node)); node = node.getOutEdges().stream().filter(sequencePredicate()) .map(Edge::getTargetNode).filter(childNodes::containsKey).findAny().orElse(null); } while (node != null); childEdges.forEach(e -> root.getOutEdges().remove(e)); childEdges.forEach(e -> root.getOutEdges().add(0, e)); } Stream<Node<View<?>, Edge>> stageStream = root.getOutEdges().stream().filter(childPredicate()).map(Edge::getTargetNode); stageStream.filter(CaseManagementCommandUtil::isStageNode) .forEach(n -> { List<Edge> edges = n.getOutEdges().stream().filter(childPredicate()).collect(Collectors.toList()); Collections.sort(edges, (e1, e2) -> { final double y1 = ((Node<View, Edge>) e1.getTargetNode()).getContent().getBounds().getY(); final double y2 = ((Node<View, Edge>) e2.getTargetNode()).getContent().getBounds().getY(); return Double.compare(y2, y1); }); edges.forEach(e -> n.getOutEdges().remove(e)); edges.forEach(e -> n.getOutEdges().add(0, e)); }); }); } CaseManagementDrawCommand(final ChildrenTraverseProcessor childrenTraverseProcessor); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); }
@Test public void testNewGraphCommand() { final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = tested.newGraphCommand(canvasHandler); assertNotNull(graphCommand); assertTrue(graphCommand instanceof CaseManagementSafeDeleteNodeCommand); assertEquals(candidate, ((CaseManagementSafeDeleteNodeCommand) graphCommand).getNode()); }
@Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new CaseManagementSafeDeleteNodeCommand(candidate, deleteProcessor, options); }
CaseManagementDeleteNodeCommand extends DeleteNodeCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new CaseManagementSafeDeleteNodeCommand(candidate, deleteProcessor, options); } }
CaseManagementDeleteNodeCommand extends DeleteNodeCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new CaseManagementSafeDeleteNodeCommand(candidate, deleteProcessor, options); } CaseManagementDeleteNodeCommand(Node candidate); CaseManagementDeleteNodeCommand(Node candidate, SafeDeleteNodeCommand.Options options); }
CaseManagementDeleteNodeCommand extends DeleteNodeCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new CaseManagementSafeDeleteNodeCommand(candidate, deleteProcessor, options); } CaseManagementDeleteNodeCommand(Node candidate); CaseManagementDeleteNodeCommand(Node candidate, SafeDeleteNodeCommand.Options options); }
CaseManagementDeleteNodeCommand extends DeleteNodeCommand { @Override @SuppressWarnings("unchecked") protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(AbstractCanvasHandler context) { return new CaseManagementSafeDeleteNodeCommand(candidate, deleteProcessor, options); } CaseManagementDeleteNodeCommand(Node candidate); CaseManagementDeleteNodeCommand(Node candidate, SafeDeleteNodeCommand.Options options); }