package com.bytesw.bytebot.service;

import com.bytesw.bytebot.etl.beans.ActionBean;
import com.bytesw.bytebot.etl.dao.ActionRepository;
import com.bytesw.bytebot.etl.model.Action;
import com.bytesw.xdf.service.XDFService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
@Log4j2
public class ActionService extends XDFService<Action, ActionBean, Long> {
    protected ActionService(ActionRepository repository) {
        super(repository);
    }

    @Override
    protected Action toModel(Action model, ActionBean bean) {
        if (model == null) {
            model = new Action();
        }
        BeanUtils.copyProperties(bean, model);
        return model;
    }

    @Override
    protected ActionBean toBean(Action model) {
        ActionBean bean = new ActionBean();
        BeanUtils.copyProperties(model, bean);
        return bean;
    }
}
