/**
 * 
 */
package edu.yu.einstein.wasp.daemon.batch.tasklets;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;

import edu.yu.einstein.wasp.batch.launch.BatchJobLaunchContext;
import edu.yu.einstein.wasp.integration.messages.templates.BatchJobLaunchMessageTemplate;
import edu.yu.einstein.wasp.service.RunService;

/**
 * Tasklet to launch a job without regard to consequence.
 * 
 * @author calder
 *
 */
public class LaunchJobAndContinueTasklet extends AbandonMessageHandlingTasklet {
	
	private String flowName;
	private Map<String,String> jobParameters;
	
	@Autowired
	private RunService runService;
	
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	public LaunchJobAndContinueTasklet(String flowName, Map<String,String> jobParameters) {
		this.jobParameters = jobParameters;
		this.flowName = flowName;
	}

	@Override
	public RepeatStatus execute(StepContribution contrib, ChunkContext context) throws Exception {
		logger.debug("launching flow " + flowName + " and proceeding to the next step");
		BatchJobLaunchMessageTemplate batchJobLaunchMessageTemplate = new BatchJobLaunchMessageTemplate(new BatchJobLaunchContext(flowName, jobParameters));
        Message<BatchJobLaunchContext> message = batchJobLaunchMessageTemplate.build();
        logger.debug("requesting sendOutboundMessage for: " + message.toString());
        runService.sendOutboundMessage(message, true);
		return super.execute(contrib, context);
	}
	
	

}

@@ -256,24 +256,84 @@
 unkContext;%0A
+import org.springframework.batch.core.step.tasklet.Tasklet;%0A
 import org.s
@@ -823,38 +823,19 @@
 let 
-extend
+implement
 s 
-AbandonMessageHandling
 Task
@@ -1767,47 +1767,33 @@
 urn 
-super.execute(contrib, context);%0A%09%7D%0A%09%0A%09
+RepeatStatus.FINISHED;%0A%09%7D
 %0A%0A%7D%0A

simplify implementation and ensure only runs once