ConfigurationAlgorithm { static void prune(final Definitions definitions, final Set<BaseElement> pruningSet) { for (final BaseElement rootElement : definitions.getRootElement()) { if (rootElement instanceof Process) { final Process process = (Process) rootElement; for (final FlowElement flowElement : process.getFlowElement()) { substituteReferences(flowElement, pruningSet, null); } process.getFlowElement().removeAll(pruningSet); } } for (final BPMNDiagram bpmnDiagram : definitions.getDiagram()) { for (DiagramElement element : new ArrayList<DiagramElement>(bpmnDiagram.getBPMNPlane().getDiagramElement())) { if (element instanceof BPMNEdge) { BPMNEdge edge = (BPMNEdge) element; if (pruningSet.contains(edge.getBpmnElement())) { bpmnDiagram.getBPMNPlane().getDiagramElement().remove(edge); } } else if (element instanceof BPMNShape) { BPMNShape shape = (BPMNShape) element; if (pruningSet.contains(shape.getBpmnElement())) { bpmnDiagram.getBPMNPlane().getDiagramElement().remove(shape); } } } } }  static void configure(final Definitions definitions); static Map<BaseElement, DiagramElement> findBpmndiMap(final Definitions definitions); static Set<Gateway> findConfiguredGateways(final Definitions definitions); static Set<SequenceFlow> findAbsentSequenceFlows(final Set<Gateway> reconfiguredGatewaySet); static void main(final String[] arg);  }
@Test public final void testPrune1() throws IOException, JAXBException, SAXException { Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(IDResolver.class.getName(), new DefinitionsIDResolver()); Definitions definitions = (Definitions) unmarshaller.unmarshal(test1File); ConfigurationAlgorithm.prune(definitions, java.util.Collections.EMPTY_SET); assertValidBPMN(definitions, "test-prune1.bpmn.xml"); }
@Test public final void testPrune2() throws IOException, JAXBException, SAXException { Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(IDResolver.class.getName(), new DefinitionsIDResolver()); Definitions definitions = (Definitions) unmarshaller.unmarshal(test1File); Process process = (Process) definitions.getRootElement().get(0); Task airbus = (Task) process.getFlowElement().get(0); Set<BaseElement> pruningSet = new HashSet<BaseElement>(); pruningSet.add(airbus); ConfigurationAlgorithm.prune(definitions, pruningSet); assertTrue(airbus != process.getFlowElement().get(0)); }