Class ChildPipelineBuilder
Helper class for realizing a child pipeline that gets 'smooshed' back in to a parent as part of realizing a step
-
Constructor Summary
ConstructorsConstructorDescriptionChildPipelineBuilder(nz.org.riskscape.engine.pipeline.RealizationInput input, nz.org.riskscape.rl.ast.InputChain inputChain) ChildPipelineBuilder(nz.org.riskscape.engine.pipeline.RealizationInput input, nz.org.riskscape.rl.ast.PipelineDeclaration childAst) Constructs a new ChildPipelineBuilder for realizing and integrating a child pipeline into a parent pipeline. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInputStep(nz.org.riskscape.engine.pipeline.RealizedStep stepFromParent) Adds an input step from the parent pipeline into the child pipeline (named in) by creating a stub step.voidaddInputStep(nz.org.riskscape.engine.pipeline.RealizedStep stepFromParent, String stubName) Adds an input step from the parent pipeline into the child pipeline by creating a stub step.voidaddParameter(String key, nz.org.riskscape.rl.ast.Expression value) addParameters(Map<String, nz.org.riskscape.rl.ast.Expression> parameters) nz.org.riskscape.engine.pipeline.RealizedPipelineaddWellKnownOutput(nz.org.riskscape.engine.pipeline.RealizedStep outputStep, List<nz.org.riskscape.problem.Problem> warnings) Adds a step to the combined pipeline named after the input's prototype step (so will have the expected name) for any dependencies that are chained to this step.protected booleannz.org.riskscape.engine.pipeline.RealizedPipelinecombine()Combines the realized child pipeline back into the parent pipeline.combineWith(nz.org.riskscape.engine.pipeline.RealizedPipeline newParent) Update this builder to realize against a different parentRealizedPipelineto the one that was provided in the RealizationInput.voiddrainWarningsFromChild(Consumer<nz.org.riskscape.problem.Problem> sink) Updates the realized child to remove any warnings (and sends them to the sink, e.g.booleannz.org.riskscape.engine.pipeline.RealizedPipelinenz.org.riskscape.rl.ast.PipelineDeclarationnz.org.riskscape.engine.pipeline.RealizedStepgetChildInputStep(nz.org.riskscape.engine.pipeline.RealizedStep originalInputStep) Retrieves the stub step that was created in the child pipeline for a given parent input step.Used to customize any error message that results from realizing the child ast, defaults to the AST's locationnz.org.riskscape.engine.pipeline.RealizedPipelinenz.org.riskscape.engine.pipeline.RealizationInputgetInput()Map<nz.org.riskscape.engine.pipeline.RealizedStep,nz.org.riskscape.engine.pipeline.RealizedStep> nz.org.riskscape.engine.pipeline.RealizedPipelineMap<nz.org.riskscape.engine.pipeline.RealizedStep,nz.org.riskscape.engine.pipeline.RealizedStep> nz.org.riskscape.engine.pipeline.RealizedStepgetRebuiltEndStep(nz.org.riskscape.rl.ast.InputChain rhs) While an input chain AST has only one end step (because it is a single branch), if any of the steps in that branch realize a subpipeline, then there's potential for there to be more than one end step in the child.nz.org.riskscape.engine.pipeline.RealizedStepgetRebuiltStep(nz.org.riskscape.engine.pipeline.RealizedStep childStep) nz.org.riskscape.engine.steps.ChildPipelineBuilder.StategetState()inthashCode()booleannz.org.riskscape.engine.pipeline.RealizedPipelineRealizes the child pipeline using the configured AST and input steps.voidsetBuilding(nz.org.riskscape.engine.pipeline.RealizedPipeline building) setChildPipelineFrom(Object pipelineSource) Customize errors resulting from combine to use a non-stanard 'failed to realize child pipeline' error.voidsetChildStepPrefix(String childStepPrefix) voidsetCombined(nz.org.riskscape.engine.pipeline.RealizedPipeline combined) voidsetParent(nz.org.riskscape.engine.pipeline.RealizedPipeline parent) voidsetRebuilt(Map<nz.org.riskscape.engine.pipeline.RealizedStep, nz.org.riskscape.engine.pipeline.RealizedStep> rebuilt) voidsetState(nz.org.riskscape.engine.steps.ChildPipelineBuilder.State state) toString()
-
Constructor Details
-
ChildPipelineBuilder
public ChildPipelineBuilder(nz.org.riskscape.engine.pipeline.RealizationInput input, nz.org.riskscape.rl.ast.InputChain inputChain) -
ChildPipelineBuilder
public ChildPipelineBuilder(nz.org.riskscape.engine.pipeline.RealizationInput input, nz.org.riskscape.rl.ast.PipelineDeclaration childAst) Constructs a new ChildPipelineBuilder for realizing and integrating a child pipeline into a parent pipeline.
- Parameters:
input- the realization input containing the parent pipeline and contextchildAst- the AST declaration of the child pipeline to be realized
-
-
Method Details
-
combineWith
public ChildPipelineBuilder combineWith(nz.org.riskscape.engine.pipeline.RealizedPipeline newParent) Update this builder to realize against a different parent
RealizedPipelineto the one that was provided in the RealizationInput. This must be done before any input steps are set. -
addInputStep
public void addInputStep(nz.org.riskscape.engine.pipeline.RealizedStep stepFromParent) Adds an input step from the parent pipeline into the child pipeline (named in) by creating a stub step. The stub step mirrors the parent step's output schema but won't be executed during child pipeline realization.
- Parameters:
stepFromParent- the realized step from the parent pipeline to use as input
-
addInputStep
public void addInputStep(nz.org.riskscape.engine.pipeline.RealizedStep stepFromParent, String stubName) Adds an input step from the parent pipeline into the child pipeline by creating a stub step. The stub step mirrors the parent step's output schema but won't be executed during child pipeline realization.
- Parameters:
stepFromParent- the realized step from the parent pipeline to use as inputstubName- the name to give the stub step in the child pipeline - this is how the child pipeline will refer to it
-
setChildPipelineFrom
Customize errors resulting from combine to use a non-stanard 'failed to realize child pipeline' error. Added to support specifying a sub-pipeline, instead of a URI, as the source of problems.
-
getChildInputStep
public nz.org.riskscape.engine.pipeline.RealizedStep getChildInputStep(nz.org.riskscape.engine.pipeline.RealizedStep originalInputStep) Retrieves the stub step that was created in the child pipeline for a given parent input step.
- Parameters:
originalInputStep- the original step from the parent pipeline- Returns:
- the corresponding stub step in the child pipeline, or null if not found
-
realizeChild
public nz.org.riskscape.engine.pipeline.RealizedPipeline realizeChild()Realizes the child pipeline using the configured AST and input steps. This method must be called after all input steps have been added via
addInputStep(nz.org.riskscape.engine.pipeline.RealizedStep).- Returns:
- the realized child pipeline, which may contain failures if realization encountered problems
-
drainWarningsFromChild
Updates the realized child to remove any warnings (and sends them to the sink, e.g. List::add)
-
combine
public nz.org.riskscape.engine.pipeline.RealizedPipeline combine()Combines the realized child pipeline back into the parent pipeline.
If the child pipeline failed to realize, a failure step is added to the resulting pipeline to represent those errors
All child steps are prefixed with the parent step name to ensure unique naming.
- Returns:
- the combined pipeline containing both parent and child steps
-
addWellKnownOutput
public nz.org.riskscape.engine.pipeline.RealizedPipeline addWellKnownOutput(nz.org.riskscape.engine.pipeline.RealizedStep outputStep, List<nz.org.riskscape.problem.Problem> warnings) Adds a step to the combined pipeline named after the input's prototype step (so will have the expected name) for any dependencies that are chained to this step.
# Future clean up idea
Not really needed right now, but it might be good to make this an argument or optional version of the combine method, and so make it easier to move the problems from child realization somewhere so that it's handled consistently. I think we probably always want a well known step, it's just a question of whether it's the output step or some other arbitrary step from the pipeline (if it doesn't produce output). The well-known step should always be the one that receives any realization problems that weren't specific to a step.
-
getCombined
public nz.org.riskscape.engine.pipeline.RealizedPipeline getCombined() -
isChildFailed
public boolean isChildFailed()- Returns:
- true if the child pipeline has failures.
-
getRebuiltStep
public nz.org.riskscape.engine.pipeline.RealizedStep getRebuiltStep(nz.org.riskscape.engine.pipeline.RealizedStep childStep) - Returns:
- the step in combined pipeline that was rebuilt for the child step, i.e. it is the child step, but renamed and in the combined pipeline
-
addParameters
public ChildPipelineBuilder addParameters(Map<String, nz.org.riskscape.rl.ast.Expression> parameters) -
addParameter
-
getRebuiltEndStep
public nz.org.riskscape.engine.pipeline.RealizedStep getRebuiltEndStep(nz.org.riskscape.rl.ast.InputChain rhs) While an input chain AST has only one end step (because it is a single branch), if any of the steps in that branch realize a subpipeline, then there's potential for there to be more than one end step in the child. This means we must look for the step that corresponds to the last step definition in our AST (because that's what ChildPipelineBuilder#addWellKnownOutput does).
-
getState
public nz.org.riskscape.engine.steps.ChildPipelineBuilder.State getState() -
getInput
public nz.org.riskscape.engine.pipeline.RealizationInput getInput() -
getParent
public nz.org.riskscape.engine.pipeline.RealizedPipeline getParent() -
getChildAst
public nz.org.riskscape.rl.ast.PipelineDeclaration getChildAst() -
getInputSteps
public Map<nz.org.riskscape.engine.pipeline.RealizedStep,nz.org.riskscape.engine.pipeline.RealizedStep> getInputSteps() -
getPipelineParameters
-
getRebuilt
public Map<nz.org.riskscape.engine.pipeline.RealizedStep,nz.org.riskscape.engine.pipeline.RealizedStep> getRebuilt() -
getBuilding
public nz.org.riskscape.engine.pipeline.RealizedPipeline getBuilding() -
getChildPipelineFrom
Used to customize any error message that results from realizing the child ast, defaults to the AST's location
-
setState
public void setState(nz.org.riskscape.engine.steps.ChildPipelineBuilder.State state) -
setParent
public void setParent(nz.org.riskscape.engine.pipeline.RealizedPipeline parent) -
setRebuilt
public void setRebuilt(Map<nz.org.riskscape.engine.pipeline.RealizedStep, nz.org.riskscape.engine.pipeline.RealizedStep> rebuilt) -
setBuilding
public void setBuilding(nz.org.riskscape.engine.pipeline.RealizedPipeline building) -
setCombined
public void setCombined(nz.org.riskscape.engine.pipeline.RealizedPipeline combined) -
setChildStepPrefix
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-
getChildStepPrefix
-