package com.utopiaindustries.service;

import com.utopiaindustries.controller.ProcessListWrapper;
import com.utopiaindustries.dao.ctp.ProcessDAO;
import com.utopiaindustries.model.ctp.Process;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProcessService {

    public final ProcessDAO processDAO;

    public ProcessService( ProcessDAO processDAO ) {
        this.processDAO = processDAO;
    }

    /*
    *  get all
    * */
    public List<Process> findAllProcesses(){
        return processDAO.findAll();
    }

    /*
    *  get processes with wrapper
    * */
    public ProcessListWrapper getAllProcessWrapper(){
        ProcessListWrapper processListWrapper = new ProcessListWrapper();
        processListWrapper.setProcesses( processDAO.findAll() );
        return processListWrapper;
    }

    /*
    *  save all
    * */
    public void saveAll( ProcessListWrapper processListWrapper ){
        processDAO.saveAll( processListWrapper.getProcesses() );
    }
}
