package info.bukova.isspst.ui.main.orders.services;

import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.services.requirement.RequirementService;
import info.bukova.isspst.ui.main.orders.requirements.ReqListMyWorkgroups;

import java.util.ArrayList;
import java.util.List;

import org.springframework.security.access.AccessDeniedException;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;

public class ReqServicesListMyWorkgroups extends ReqListMyWorkgroups
{
	@WireVariable
	protected RequirementService reqServicesService;

	@Init(superclass = true)
	public void initReqServicesListMyWorkgroups()
	{
		service = reqServicesService;
		formZul = "/main/orders/services/reqHeadForm.zul";
	}

	@Override
	protected List<Requirement> getListFromService()
	{
		try
		{
			return reqServicesService.getWorkgroupReq();
		}
		catch (AccessDeniedException e)
		{
			BindUtils.postGlobalCommand(null, null, "disableWorkgroup", null);
			return new ArrayList<Requirement>();
		}
	}
}
