package org.talend.dataprep.api.preparation;

import java.util.HashMap;
import java.util.Map;

import org.talend.dataprep.transformation.api.action.DataSetMetadataAction;
import org.talend.dataprep.transformation.api.action.DataSetRowAction;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonRootName;

@JsonRootName("action")
public class Action {

    public static final DataSetRowAction IDLE_ROW_ACTION = (row, context) -> {};

    public static final DataSetMetadataAction IDLE_METADATA_ACTION = (metadata, context) -> {};

    private final transient DataSetRowAction rowAction;

    private final transient DataSetMetadataAction metadataAction;

    private String action;

    private Map<String, String> parameters = new HashMap<>(1);

    public Action() {
        rowAction = IDLE_ROW_ACTION;
        metadataAction = IDLE_METADATA_ACTION;
    }

    public Action(DataSetRowAction rowAction, DataSetMetadataAction metadataAction) {
        this.rowAction = rowAction;
        this.metadataAction = metadataAction;
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public Map<String, String> getParameters() {
        return parameters;
    }

    public void setParameters(Map<String, String> parameters) {
        this.parameters = parameters;
    }

    @JsonIgnore(true)
    public DataSetRowAction getRowAction() {
        return rowAction;
    }

    @JsonIgnore(true)
    public DataSetMetadataAction getMetadataAction() {
        return metadataAction;
    }

    public static class Builder {

        private DataSetRowAction rowAction = IDLE_ROW_ACTION;

        private DataSetMetadataAction metadataAction = IDLE_METADATA_ACTION;

        public static Builder builder() {
            return new Builder();
        }

        public Builder withRow(DataSetRowAction rowAction) {
            this.rowAction = rowAction;
            return this;
        }

        public Builder withMetadata(DataSetMetadataAction metadataAction) {
            this.metadataAction = metadataAction;
            return this;
        }

        public Action build() {
            return new Action(rowAction, metadataAction);
        }

    }
}

@@ -88,16 +88,70 @@
 l.Map;%0A%0A
+import org.springframework.data.annotation.Transient;%0A
 import o
@@ -619,24 +619,39 @@
 xt) -%3E %7B%7D;%0A%0A
+    @Transient%0A
     private 
@@ -687,32 +687,47 @@
 ion rowAction;%0A%0A
+    @Transient%0A
     private fina
@@ -1505,32 +1505,47 @@
 sonIgnore(true)%0A
+    @Transient%0A
     public DataS
@@ -1624,24 +1624,39 @@
 gnore(true)%0A
+    @Transient%0A
     public D

Fix serialization of action closures in MongoDB preparation.