package org.myrobotlab.document.transformer;

import org.myrobotlab.document.transformer.StageConfiguration;

import java.util.List;

import org.myrobotlab.document.Document;

/**
 * This will set a field on a document with a value
 * 
 * @author kwatters
 *
 */
public class SetStaticFieldValue extends AbstractStage {

	private String fieldName = null;
	private String value = null;
	
	@Override
	public void startStage(StageConfiguration config) {
		
		if (config != null) {
			fieldName = config.getStringParam("fieldName");
			value = config.getStringParam("value");
		}
	}

	@Override
	public List<Document> processDocument(Document doc) {
		doc.addToField(fieldName, value);
		return null;
	}

	@Override
	public void stopStage() {
		// TODO Auto-generated method stub
	}

	@Override
	public void flush() {
		// Only required if this stage does any batching.  NO-OP here.
	}

	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

}

@@ -378,16 +378,54 @@
 = null;%0A
+  private List%3CString%3E values = null;%0A
 %09%0A%09@Over
@@ -603,16 +603,62 @@
 alue%22);%0A
+      values = config.getListParam(%22values%22);%0A
 %09%09%7D%0A%09%7D%0A%0A
@@ -727,43 +727,179 @@
 ) %7B%0A
-%09%09doc.addToField(fieldName, value);
+    if (values != null) %7B%0A      for (String value : values) %7B%0A        doc.addToField(fieldName, value);%0A      %7D%0A    %7D else %7B%0A      doc.addToField(fieldName, value);%0A    %7D%0A
 %0A%09%09r

Allow a list of static values.