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

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

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 ReqMaterialListMyCenters extends ReqListMyCenters
{
	@WireVariable
	protected RequirementService reqMaterialService;

	@Init(superclass = true)
	public void initReqMaterialListMyCenters()
	{
		service = reqMaterialService;
		formZul = "/main/orders/material/reqHeadForm.zul";
	}

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