<commit_before>package edu.yu.einstein.wasp.batch;

import edu.yu.einstein.wasp.model.*;
import edu.yu.einstein.wasp.service.*;

import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.support.transaction.FlushFailedException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.stereotype.Component;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;

import util.spring.PostInitialize;

/**
 * DoSendInvoiceStateProcessor
 * sends an invoice to proper party
 *
 * ** **  currently test to echo hello world via System.exec
 *
 * throws an retryable exception unless
 * a sibling state for that job has hit a status of property status 
 * if it does, update that sibling status w/ a new target status
 *
 * this only supports the first task of the job, anticipated
 * rewrite to take a mapping of types, list of statuses, etc.
 * 
 */

@Component
public class DoSendInvoiceTasklet extends org.springframework.batch.core.step.tasklet.SystemCommandTasklet implements ItemProcessor {

	@Autowired
	StateService stateService;

	@Autowired
	StatejobService statejobService;

	List<String> params;
	public void setParams(List<String> s) { 
		this.params = s; 
		this.setCommand(org.springframework.util.StringUtils.collectionToDelimitedString(params, " "));
	}
	public List<String> getParams() { return this.params;}

	// afterPropertySet to reassemble the properties
	@PostInitialize
	void postInitialize() {
		this.setCommand(org.springframework.util.StringUtils.collectionToDelimitedString(params, " "));

	}


	public State process(Object stateId) throws Exception {
		
		State state = stateService.getStateByStateId(((Integer) stateId).intValue());
		return state;

	}

/*

	String task; 
	public void setTask(String task) {
		this.task = task; 
	}

	String status; 
	public void setStatus(String status) {
		this.status = status; 
	}
<commit_msg>spel enabled<commit_after>package edu.yu.einstein.wasp.batch;

import edu.yu.einstein.wasp.model.*;
import edu.yu.einstein.wasp.service.*;

import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.support.transaction.FlushFailedException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.stereotype.Component;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.ExpressionParser;

import java.util.*;

/**
 * DoSendInvoiceStateProcessor
 * sends an invoice to proper party
 *
 * ** **  currently test to echo hello world via System.exec
 *
 * throws an retryable exception unless
 * a sibling state for that job has hit a status of property status 
 * if it does, update that sibling status w/ a new target status
 *
 * this only supports the first task of the job, anticipated
 * rewrite to take a mapping of types, list of statuses, etc.
 * 
 */

@Component
public class DoSendInvoiceTasklet extends org.springframework.batch.core.step.tasklet.SystemCommandTasklet implements ItemProcessor {

	@Autowired
	StateService stateService;

	@Autowired
	StatejobService statejobService;

	List<String> params;
	public void setParams(List<String> params) { 
		this.params = params; 

		List<String> parsedParams = new ArrayList<String>();
		ExpressionParser parser = new SpelExpressionParser();
		for (String s: params) {
			parsedParams.add((String) parser.parseExpression(s).getValue());
		}

		this.setCommand(org.springframework.util.StringUtils.collectionToDelimitedString(parsedParams, " "));
	}
	public List<String> getParams() { return this.params;}



	public State process(Object stateId) throws Exception {
		
		State state = stateService.getStateByStateId(((Integer) stateId).intValue());
		return state;

	}

/*

	String task; 
	public void setTask(String task) {
		this.task = task; 
	}

	String status; 
	public void setStatus(String status) {
		this.status = status; 
	}

{'fraction_non_alphanumeric': 0.0964785335262904, 'fraction_numerical': 0.0, 'mean_word_length': 4.80812324929972, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5107498', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1190, 'n_words': 320}