package org.appfuse.service;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.appfuse.model.Degree;
import org.appfuse.model.LabelValue;
import org.appfuse.model.Role;
import org.appfuse.model.Template;
import org.appfuse.model.WorkStatus;
import org.appfuse.persistence.LookupDAO;
public class LookupManagerImpl extends BaseManager implements LookupManager {
private Log log = LogFactory.getLog(LookupManagerImpl.class);
private LookupDAO dao;
public void setLookupDAO(LookupDAO dao) {
this.dao = dao;
}
public List getAllRoles() throws Exception {
List roles = dao.getRoles();
List list = new ArrayList();
Role role = null;
for (int i = 0; i < roles.size(); i++) {
role = (Role) roles.get(i);
list.add(new LabelValue(role.getName(), role.getName()));
}
return list;
}
public List getTemplates() throws Exception {
List templates = dao.getAvailableTemplates();
List options = new LinkedList();
Template template = null;
for (Iterator it = templates.iterator(); it.hasNext();) {
template = (Template) it.next();
options.add(new LabelValue(template.getName(),
String.valueOf(template.getId())));
}
return options;
}
public List getWorkStatuses() throws Exception {
List statuses = dao.getWorkStatuses();
List options = new LinkedList();
WorkStatus status = null;
for (Iterator it = statuses.iterator(); it.hasNext();) {
status = (WorkStatus) it.next();
options.add(new LabelValue(status.getStatus(),
String.valueOf(status.getId())));
}
return options;
}
public List getDegrees() throws Exception {
List degrees = dao.getDegrees();
List options = new LinkedList();
Degree degree = null;
for (Iterator it = degrees.iterator(); it.hasNext();) {
degree = (Degree) it.next();
options.add(new LabelValue(degree.getName(),
String.valueOf(degree.getId())));
}
return options;
}
}