Tabnine Logo
SimpleFlow
Code IndexAdd Tabnine to your IDE (free)

How to use
SimpleFlow
in
org.springframework.batch.core.job.flow.support

Best Java code snippets using org.springframework.batch.core.job.flow.support.SimpleFlow (Showing top 20 results out of 315)

origin: spring-projects/spring-batch

@Test
public void testGetStepSplitFlow() throws Exception {
  SimpleFlow flow = new SimpleFlow("job");
  SimpleFlow flow1 = new SimpleFlow("flow1");
  SimpleFlow flow2 = new SimpleFlow("flow2");
  List<StateTransition> transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "end0"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end0")));
  flow1.setStateTransitions(new ArrayList<>(transitions));
  flow1.afterPropertiesSet();
  transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step2")), "end1"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end1")));
  flow2.setStateTransitions(new ArrayList<>(transitions));
  flow2.afterPropertiesSet();
  transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new SplitState(Arrays.<Flow> asList(flow1, flow2),
      "split"), "end2"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end2")));
  flow.setStateTransitions(transitions);
  flow.afterPropertiesSet();
  job.setFlow(flow);
  job.afterPropertiesSet();
  List<String> names = new ArrayList<>(job.getStepNames());
  Collections.sort(names);
  assertEquals("[step1, step2]", names.toString());
}
origin: spring-projects/spring-batch

@Test
public void testGetStepNamesWithPrefix() throws Exception {
  SimpleFlow flow = new SimpleFlow("job");
  List<StateTransition> transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new StepState("job.step", new StubStep("step")), "end0"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end0")));
  flow.setStateTransitions(transitions);
  flow.afterPropertiesSet();
  job.setFlow(flow);
  job.setName(flow.getName());
  job.afterPropertiesSet();
  assertEquals("[step]", job.getStepNames().toString());
}
origin: spring-projects/spring-batch

@Test
public void testResume() throws Exception {
  flow.setStateTransitions(collect(StateTransition.createStateTransition(new StubState("step1"), "step2"),
      StateTransition.createEndStateTransition(new StubState("step2"))));
  flow.afterPropertiesSet();
  FlowExecution execution = flow.resume("step2", executor);
  assertEquals(FlowExecutionStatus.COMPLETED, execution.getStatus());
  assertEquals("step2", execution.getName());
}
origin: spring-projects/spring-batch

/**
 * @see Flow#start(FlowExecutor)
 */
@Override
public FlowExecution start(FlowExecutor executor) throws FlowExecutionException {
  if (startState == null) {
    initializeTransitions();
  }
  State state = startState;
  String stateName = state.getName();
  return resume(stateName, executor);
}
origin: spring-projects/spring-batch

protected Flow flow() {
  if (!dirty) {
    // optimization in case this method is called consecutively
    return flow;
  }
  flow = new SimpleFlow(name);
  // optimization for flows that only have one state that itself is a flow:
  if (currentState instanceof FlowState && states.size() == 1) {
    return ((FlowState) currentState).getFlows().iterator().next();
  }
  addDanglingEndStates();
  flow.setStateTransitions(transitions);
  dirty = false;
  return flow;
}
origin: spring-projects/spring-batch

@Override
public SimpleFlow getObject() throws Exception {
  SimpleFlow flow = flowType.getConstructor(String.class).newInstance(name);
  flow.setStateTransitionComparator(stateTransitionComparator);
  List<StateTransition> updatedTransitions = new ArrayList<>();
  for (StateTransition stateTransition : stateTransitions) {
    State state = getProxyState(stateTransition.getState());
    updatedTransitions.add(StateTransition.switchOriginAndDestination(stateTransition, state,
        getNext(stateTransition.getNext())));
  }
  flow.setStateTransitions(updatedTransitions);
  flow.afterPropertiesSet();
  return flow;
}
origin: spring-projects/spring-batch

@Test(expected = IllegalArgumentException.class)
public void testEmptySteps() throws Exception {
  flow.setStateTransitions(Collections.<StateTransition> emptyList());
  flow.afterPropertiesSet();
}
origin: spring-projects/spring-batch

@Test
public void testOneStep() throws Exception {
  flow.setStateTransitions(Collections.singletonList(StateTransition.createEndStateTransition(new StubState(
      "step1"))));
  flow.afterPropertiesSet();
  FlowExecution execution = flow.start(executor);
  assertEquals(FlowExecutionStatus.COMPLETED, execution.getStatus());
  assertEquals("step1", execution.getName());
}
origin: spring-projects/spring-batch

@Test
public void testGetStepNamesWithPrefix() throws Exception {
  SimpleFlow flow = new JsrFlow("job");
  List<StateTransition> transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new StepState("job.step", new StubStep("step")), "end0"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end0")));
  flow.setStateTransitions(transitions);
  flow.afterPropertiesSet();
  job.setFlow(flow);
  job.setName(flow.getName());
  job.afterPropertiesSet();
  assertEquals("[step]", job.getStepNames().toString());
}
origin: spring-projects/spring-batch

@Test
public void testBranching() throws Exception {
  flow.setStateTransitions(collect(StateTransition.createStateTransition(new StubState("step1"), "step2"),
      StateTransition.createStateTransition(new StubState("step1"), ExitStatus.COMPLETED.getExitCode(), "step3"),
      StateTransition.createEndStateTransition(new StubState("step2")), StateTransition
      .createEndStateTransition(new StubState("step3"))));
  flow.setStateTransitionComparator(new DefaultStateTransitionComparator());
  flow.afterPropertiesSet();
  FlowExecution execution = flow.start(executor);
  assertEquals(FlowExecutionStatus.COMPLETED, execution.getStatus());
  assertEquals("step3", execution.getName());
}
origin: spring-projects/spring-batch

@Test
public void testBranching() throws Exception {
  SimpleFlow flow = new SimpleFlow("job");
  List<StateTransition> transitions = new ArrayList<>();
  StepState step1 = new StepState(new StubStep("step1"));
  transitions.add(StateTransition.createStateTransition(step1, "step2"));
  transitions.add(StateTransition.createStateTransition(step1, "COMPLETED", "step3"));
  StepState step2 = new StepState(new StubStep("step2"));
  transitions.add(StateTransition.createStateTransition(step2, ExitStatus.COMPLETED.getExitCode(), "end0"));
  transitions.add(StateTransition.createStateTransition(step2, ExitStatus.FAILED.getExitCode(), "end1"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end0")));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.FAILED, "end1")));
  StepState step3 = new StepState(new StubStep("step3"));
  transitions.add(StateTransition.createStateTransition(step3, ExitStatus.FAILED.getExitCode(), "end2"));
  transitions.add(StateTransition.createStateTransition(step3, ExitStatus.COMPLETED.getExitCode(), "end3"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.FAILED, "end2")));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end3")));
  flow.setStateTransitions(transitions);
  flow.setStateTransitionComparator(new DefaultStateTransitionComparator());
  job.setFlow(flow);
  job.afterPropertiesSet();
  job.doExecute(jobExecution);
  StepExecution stepExecution = getStepExecution(jobExecution, "step3");
  assertEquals(ExitStatus.COMPLETED, stepExecution.getExitStatus());
  assertEquals(2, jobExecution.getStepExecutions().size());
}
origin: spring-projects/spring-batch

@Test
public void testGetStateDoesNotExist() throws Exception {
  flow.setStateTransitions(Collections.singletonList(StateTransition.createEndStateTransition(new StubState(
      "step1"))));
  flow.afterPropertiesSet();
  State state = flow.getState("bar");
  assertNull(state);
}
origin: spring-projects/spring-batch

while (isFlowContinued(state, status, stepExecution)) {
  stateName = state.getName();
  state = nextState(stateName, status, stepExecution);
origin: spring-projects/spring-batch

@Test
public void testBasicFlow() throws Throwable {
  SimpleFlow flow = new JsrFlow("job");
  List<StateTransition> transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step")), "end0"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end0")));
  flow.setStateTransitions(transitions);
  job.setFlow(flow);
  job.execute(jobExecution);
  if (!jobExecution.getAllFailureExceptions().isEmpty()) {
    throw jobExecution.getAllFailureExceptions().get(0);
  }
  assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
}
origin: spring-projects/spring-batch

throw new FlowExecutionException(String.format("No transitions found in flow=%s for state=%s", getName(),
                           stateName));
throw new FlowExecutionException(String.format("Next state not found in flow=%s for state=%s with exit status=%s", getName(), stateName, status.getName()));
                           getName(), next));
origin: spring-projects/spring-batch

/**
 * Locate start state and pre-populate data structures needed for execution.
 *
 * @see InitializingBean#afterPropertiesSet()
 */
@Override
public void afterPropertiesSet() throws Exception {
  if (startState == null) {
    initializeTransitions();
  }
}
origin: spring-projects/spring-batch

@Before
public void setUp() {
  flow = new SimpleFlow("job");
}
origin: spring-projects/spring-batch

@Override
protected boolean isFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution) {
  if(state instanceof DelegateState) {
    state = ((DelegateState) state).getState();
  }
  if(state instanceof JsrStepState) {
    currentStep = (JsrStepState) state;
  }
  return super.isFlowContinued(state, status, stepExecution);
}
origin: org.springframework.batch/org.springframework.batch.core

state = nextState(stateName, status);
origin: spring-projects/spring-batch

@Bean
public SimpleFlow simpleFlow() {
  SimpleFlow simpleFlow = new SimpleFlow("simpleFlow");
  List<StateTransition> transitions = new ArrayList<>();
  transitions.add(StateTransition.createStateTransition(new StepState(dummyStep()), "end0"));
  transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end0")));
  simpleFlow.setStateTransitions(transitions);
  return simpleFlow;
}

org.springframework.batch.core.job.flow.supportSimpleFlow

Javadoc

A Flow that branches conditionally depending on the exit status of the last State. The input parameters are the state transitions (in no particular order). The start state name can be specified explicitly (and must exist in the set of transitions), or computed from the existing transitions, if unambiguous.

Most used methods

  • <init>
    Create a flow with the given name.
  • afterPropertiesSet
    Locate start state and pre-populate data structures needed for execution.
  • getName
    Get the name for this flow.
  • resume
  • setStateTransitions
    Public setter for the stateTransitions.
  • initializeTransitions
    Analyse the transitions provided and generate all the information needed to execute the flow.
  • nextState
  • setStateTransitionComparator
  • isFlowContinued
  • getState
  • start
  • start

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getApplicationContext (Context)
  • findViewById (Activity)
  • putExtra (Intent)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Option (scala)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now