@@ -0,0 +1,1889 @@
+package edu.yu.einstein.wasp.batch;%0A%0Aimport edu.yu.einstein.wasp.model.*;%0Aimport edu.yu.einstein.wasp.service.*;%0A%0Aimport org.springframework.batch.item.ItemProcessor;%0Aimport org.springframework.batch.support.transaction.FlushFailedException;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0A%0Aimport org.springframework.stereotype.Component;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0A%0Aimport java.util.List;%0Aimport java.util.Date;%0A%0A/**%0A * Created State Processor%0A * simply creates a new State with targetTask and copies%0A * the original stated from state Sample and creates a state sample out of it.%0A * %0A */%0A%0A@Component%0Apublic class CreateSampleStateProcessor implements ItemProcessor %7B%0A%0A  @Autowired%0A  StateService stateService;%0A%0A  @Autowired%0A  TaskService taskService;%0A%0A  @Autowired%0A  StatesampleService statesampleService;%0A%0A  String targetTask; %0A  public void setTargetTask(String targetTask) %7B%0A    this.targetTask = targetTask; %0A  %7D%0A%0A  String targetStatus = %22CREATED%22; %0A%0A  public State process(Object stateId) throws Exception %7B%0A    %0A    State state = stateService.getStateByStateId(((Integer) stateId).intValue());%0A%0ASystem.out.println(%22%5CnCreating %22 + targetTask + %22 for %22 + stateId);%0A%0A    List%3CStatesample%3E stateSamples = state.getStatesample();%0A%0A    Task t = taskService.getTaskByIName(targetTask); %0A%0A    State newState = new State();%0A    newState.setStatus(targetStatus);%0A    newState.setTaskId(t.getTaskId());%0A    newState.setName(t.getName());%0A    newState.setStartts(new Date());%0A    State newStateDb = stateService.save(newState);%0A%0A    for (Statesample ss: stateSamples) %7B%0A      Statesample newStateSample = new Statesample(); %0A      newStateSample.setStateId(newStateDb.getStateId());%0A      newStateSample.setSampleId(ss.getSampleId());%0A%0A      statesampleService.save(newStateSample);%0A    %7D%0A%0A    return newState;%0A  %7D%0A%7D%0A%0A

create sample state