package com.bytesw.bytebot.etl.batch.processor;

import com.bytesw.bytebot.etl.batch.beans.DynaBean;
import com.bytesw.bytebot.etl.beans.EventBean;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.batch.item.ItemProcessor;

public class  ConvertToBeanProcessor implements ItemProcessor<DynaBean, DynaBean> {

    private ObjectMapper mapper = new ObjectMapper();

    @Override
    public DynaBean process(DynaBean dynaBean) throws Exception {
        Long id = new Long(String.valueOf(dynaBean.get("id")));
        String data = (String) dynaBean.get("data");
        String senderId = (String) dynaBean.get("sender_id");
        EventBean eventBean = new EventBean();
        eventBean.setId(id);
        eventBean.setData(data);
        eventBean.setSenderId(senderId);
        dynaBean.put("bean", eventBean);
        return dynaBean;
    }
}
