@Override protected boolean transformGraphInPlaceUsing( Transformed<ElementGraph> transformed, ElementGraph graph, Match match ) { ElementFactory elementFactory = transformed.getPlannerContext().getElementFactoryFor( factoryName ); if( elementFactory == null ) return false; Set<FlowElement> captured = match.getCapturedElements( ElementCapture.Primary ); if( captured.isEmpty() ) return false; else if( captured.size() != 1 ) throw new IllegalStateException( "expected one, but found multiple flow elements in the match expression: " + captured ); FlowElement replace = captured.iterator().next(); FlowElement replaceWith = elementFactory.create( graph, replace ); ElementGraphs.replaceElementWith( graph, replace, replaceWith ); return true; } }
@Override protected ElementGraph prepareForMatch( ProcessLogger processLogger, Transformed<ElementGraph> transformed, ElementGraph graph ) { if( graphTransformer == null ) return graph; if( processLogger.isDebugEnabled() ) processLogger.logDebug( "transforming with: {}", graphTransformer.getClass().getSimpleName() ); Transformed child = graphTransformer.transform( transformed.getPlannerContext(), graph ); transformed.addChildTransform( child ); return child.getEndGraph(); } }
@Override protected ElementGraph prepareForMatch( ProcessLogger processLogger, Transformed<ElementGraph> transformed, ElementGraph graph ) { if( graphTransformer == null ) return makeAnnotated( graph ); Transformed child = graphTransformer.transform( transformed.getPlannerContext(), graph ); transformed.addChildTransform( child ); ElementGraph endGraph = child.getEndGraph(); return makeAnnotated( endGraph ); }
match = finder.findAllMatches( transformed.getPlannerContext(), prepared, exclusions ); else match = finder.findFirstMatch( transformed.getPlannerContext(), prepared, exclusions );
return false; ElementFactory elementFactory = transformed.getPlannerContext().getElementFactoryFor( factoryName );