package com.eactive.eai.rms.onl.loader.transform;

import com.eactive.eai.data.DataService;
import com.eactive.eai.data.entity.AbstractEntity;
import com.eactive.eai.data.entity.onl.transformer.transform.TransformEntity;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.data.entity.onl.transform.TransformService;
import com.eactive.eai.rms.onl.loader.service.DeployService;
import com.eactive.eai.rms.onl.loader.transform.deploy.TransformDeploy;
import com.eactive.eai.rms.onl.loader.transform.mapper.TransformDeployMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Service("transformDeployService")
@Transactional
public class TransformDeployService extends DeployService {

    @Autowired
    private TransformService transformService;

    @Autowired
    private TransformDeployMapper transformDeployMapper;

    public TransformDeploy selectDeploy(String cnvsnName) {
        return transformService.findById(cnvsnName).map(transformDeployMapper::toVo).orElse(null);
    }

    public void saveDeploy(TransformDeploy transformDeploy) {
        deleteAndSave(transformDeploy, transformDeployMapper, transformService);
    }

}
