/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package services;
import services.utils.AddressContainer;
import dao.DAO;
import domain.address.AddressObject;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
/**
*
* @author petr
*/
public class AddressUpdater {
private DAO dao;
public AddressContainer getAddressList(int parentId){
if (parentId != 0){
AddressObject parent = getDao().getById(AddressObject.class, parentId);
List<AddressObject> childList = getDao().getChildList(parent);
AddressContainer ac = new AddressContainer(parent.getType().getLevel(), childList);
return ac;
}else{
return new AddressContainer(parentId, new ArrayList<AddressObject>());
}
}
public DAO getDao() {
return dao;
}
@Required
public void setDao(DAO dao) {
this.dao = dao;
}
}