package cokr.xit.fims.crdn.service.bean;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cokr.xit.fims.cmmn.ftp.RemoteSystemInfo;
import cokr.xit.fims.crdn.CrdnQuery;
import cokr.xit.fims.crdn.ExmptnVhcl;
import cokr.xit.fims.crdn.Team;
import cokr.xit.fims.crdn.receive.eqpmnt.LayoutDescriptor;
import cokr.xit.fims.crdn.receive.eqpmnt.service.bean.CrdnEqpmntBean;
import cokr.xit.fims.crdn.service.CrdnStngService;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;

@Service("crdnStngService")
public class CrdnStngServiceBean extends AbstractServiceBean implements CrdnStngService {

	@Resource(name="crdnStngBean")
	protected CrdnStngBean crdnStngBean;

	@Resource(name="crdnEqpmntBean")
	protected CrdnEqpmntBean crdnEqpmntBean;

	@Override
	public List<DataObject> getLinkFileLayoutMetadataList(CrdnQuery query) {
		return crdnEqpmntBean.getLinkFileLayoutMetadataList(query);
	}

	@Override
	public DataObject getLinkFileLayoutMetadataInfo(String fileLayoutId) {
		return crdnEqpmntBean.getLinkFileLayoutMetadataInfo(fileLayoutId);
	}

	@Override
	public String createLinkFileLayoutMetadata(LayoutDescriptor layoutDescriptor, RemoteSystemInfo remoteSystemInfo) {
		return crdnEqpmntBean.createLinkFileLayoutMetadata(layoutDescriptor, remoteSystemInfo) ? "[S]" : "[F]";
	}

	@Override
	public String updateLinkFileLayoutMetadata(LayoutDescriptor layoutDescriptor, RemoteSystemInfo remoteSystemInfo) {
		return crdnEqpmntBean.updateLinkFileLayoutMetadata(layoutDescriptor, remoteSystemInfo) ? "[S]" : "[F]";
	}

	@Override
	public String removeLinkFileLayoutMetadata(String fileLayoutId) {
		return crdnEqpmntBean.removeLinkFileLayoutMetadata(fileLayoutId) ? "[S]" : "[F]";
	}

	@Override
	public List<LayoutDescriptor> getLinkFileLayoutMetadata(String sggCd, String taskSeCd, String instCd, String deptCd) {
		CrdnQuery query = new CrdnQuery()
			.setSggCd(sggCd)
			.setTaskSeCd(taskSeCd)
			.setInstCd(instCd)
			.setDeptCd(deptCd);
		return crdnEqpmntBean.getLinkFileLayoutMetadata(query);
	}

	@Override
	public List<DataObject> getTeamList(CrdnQuery query) {
		return crdnStngBean.selectTeamList(query);
	}

	@Override
	public List<DataObject> getRemovedTeamList(CrdnQuery query) {
		return crdnStngBean.selectRemovedTeamList(query);
	}

	@Override
	public String removeTeamInfo(String teamId) {
		return crdnStngBean.removeTeamInfo(teamId) ? "[S]" : "[F]";
	}


	@Override
	public String saveTeamInfo(Team team) {
		return crdnStngBean.saveTeamInfo(false, team) ? "[S]" : "[F]";
	}

	@Override
	public DataObject getTeamInfo(String teamId) {
		return crdnStngBean.selectTeamInfo(teamId);
	}

	@Override
	public List<DataObject> getExemptionVehicleList(CrdnQuery query) {
		return crdnStngBean.selectExemptionVehicleList(query);
	}

	@Override
	public DataObject getExemptionVehicleInfo(String exemptionVehicleId) {
		return crdnStngBean.getExemptionVehicleInfo(exemptionVehicleId);
	}

	@Override
	public String createExemptionVehicleInfo(ExmptnVhcl exmptnVhcl) {
		return crdnStngBean.createExemptionVehicleInfo(exmptnVhcl) ? "[S]" : "[F]";
	}

	@Override
	public String updateExemptionVehicleInfo(ExmptnVhcl exmptnVhcl) {
		return crdnStngBean.updateExemptionVehicleInfo(exmptnVhcl) ? "[S]" : "[F]";
	}

	@Override
	public String removeExemptionVehicleInfo(ExmptnVhcl exmptnVhcl) {
		return crdnStngBean.removeExemptionVehicleInfo(exmptnVhcl) ? "[S]" : "[F]";
	}

	@Override
	public List<DataObject> getExemptionVehicleHistoryList(String exmptnVhclId) {
		return crdnStngBean.getExemptionVehicleHistoryList(exmptnVhclId);
	}
}