Package services

Source Code of services.DistrictUpdater

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package services;

import dao.DAO;
import domain.District;
import domain.Lpu;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
import services.utils.DistrictConvertor;
import services.utils.LpuConvertor;
import utils.AddressManager;

/**
*
* @author petr
*/
public class DistrictUpdater {

    private DAO dao;

    public List<DistrictConvertor> getDistrictList(int lpuId){
        ArrayList<DistrictConvertor> districts = new ArrayList<DistrictConvertor>();
        districts.add(new DistrictConvertor());
        Lpu lpu = getDao().getById(Lpu.class, lpuId);
        if (lpu != null){
            List<District> districtList = getDao().getDistrictList(lpu);
            for (District district : districtList) {
                districts.add(new DistrictConvertor(district));
            }
        }
        return districts;
    }

    public DistrictConvertor getDefaultDistrict(int streetId, String building){
        District district = AddressManager.getDefaultDistrict(getDao(), streetId, building);
        if (district != null){
            Lpu lpu = district.getLpu();
            DistrictConvertor dc = new DistrictConvertor(district);
            dc.setLpu(new LpuConvertor(lpu));
            return dc;
        }else{
            return null;
        }
    }

    public DAO getDao() {
        return dao;
    }

    @Required
    public void setDao(DAO dao) {
        this.dao = dao;
    }


}
TOP

Related Classes of services.DistrictUpdater

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.