package com.acme.vcutil.supplier;

import com.acme.model.domain.ad.entity.City;
import com.acme.structure.util.ConversionUtil;
import com.acme.structure.util.datalist.CriteriaListSupplier;
import com.acme.vcutil.bean.UtilBean;

public class DistrictForCitySupplier extends CriteriaListSupplier
{
    public DistrictForCitySupplier(boolean blankItemApplied, Object criteria)
    {
        super(blankItemApplied, criteria);
    }

    public DistrictForCitySupplier(Object criteria)
    {
        super(criteria);
    }

    @Override
    public void loadList(Object criteria)
    {
        try
        {
            clearList();
            if(criteria==null)
                return;
            City city = (City)criteria;
            UtilBean utilBean = new UtilBean();
            list.addAll(utilBean.findDistrictsForCityList(city));
            itemList.addAll(ConversionUtil.getConvertedToSelectItemList(list, isBlankItemApplied()));
        }
        catch (Exception exc)
        {
            System.out.println(exc.toString());
        }
    }

    public String getListName()
    {
        return "districtsforcity";
    }

    protected boolean isEmptyCriteriaAccepted()
    {
        return true;
    }
}

