package org.appfuse.service;
import java.lang.reflect.Method;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.appfuse.model.Resume;
import org.appfuse.persistence.ResumeDAO;
import org.appfuse.persistence.SkillDAO;
public class ResumeManagerImpl extends BaseManager implements ResumeManager {
private Log log = LogFactory.getLog(ResumeManagerImpl.class);
private ResumeDAO dao;
private SkillDAO skillDao;
public void setResumeDAO(ResumeDAO dao) {
this.dao = dao;
}
public void setSkillDAO(SkillDAO dao) {
this.skillDao = dao;
}
public List getResumesForUser(String userId) throws Exception {
return dao.getResumesByUserId(Long.valueOf(userId));
}
public Object getResume(String resumeId) throws Exception {
return dao.getResume(Long.valueOf(resumeId));
}
public Object saveResume(Object obj) throws Exception {
Resume resume = (Resume) obj;
dao.saveObject(resume);
return getResume(resume.getId().toString());
}
public void removeObject(Object o) throws Exception {
dao.removeObject(o);
}
public Object saveObject(Object o) throws Exception {
dao.saveObject(o);
return getObject(o);
}
public Object getObject(Object pojo) throws Exception {
Method meth = pojo.getClass().getMethod("getId", new Class[0]);
Long id = (Long) meth.invoke(pojo, new Object[0]);
if (log.isDebugEnabled()) {
log.debug("id set to: " + id);
}
String name = pojo.getClass().getName();
name = name.substring(name.lastIndexOf('.') + 1, name.length());
if (log.isDebugEnabled()) {
log.debug("name: " + name);
}
meth =
this.getClass().getMethod("get" + name, new Class[] { String.class });
return meth.invoke(this, new Object[] { String.valueOf(id) });
}
public Object getEducation(String id) throws Exception {
if (id == null) {
throw new IllegalArgumentException("id is a required parameter!");
}
return dao.getEducation(Long.valueOf(id));
}
public Object getResumeSkill(String id) throws Exception {
if (id == null) {
throw new IllegalArgumentException("id is a required parameter!");
}
return skillDao.getResumeSkill(Long.valueOf(id));
}
public List getResumeSkills(String resumeId) throws Exception {
if (resumeId == null) {
throw new IllegalArgumentException("resumeId is a required parameter!");
}
return skillDao.getResumeSkills(Long.valueOf(resumeId));
}
public Object getExperience(String id) throws Exception {
if (id == null) {
throw new IllegalArgumentException("id is a required parameter!");
}
return dao.getExperience(Long.valueOf(id));
}
public Object getMembership(String id) throws Exception {
if (id == null) {
throw new IllegalArgumentException("id is a required parameter!");
}
return dao.getMembership(Long.valueOf(id));
}
public List getMemberships(String resumeId) throws Exception {
if (resumeId == null) {
throw new IllegalArgumentException("resumeId is a required parameter!");
}
return dao.getMemberships(Long.valueOf(resumeId));
}
public Object getReference(String id) throws Exception {
if (id == null) {
throw new IllegalArgumentException("id is a required parameter!");
}
return dao.getReference(Long.valueOf(id));
}
public List getReferences(String resumeId) throws Exception {
if (resumeId == null) {
throw new IllegalArgumentException("resumeId is a required parameter!");
}
return dao.getReferences(Long.valueOf(resumeId));
}
public List getSchools(String resumeId) throws Exception {
if (resumeId == null) {
throw new IllegalArgumentException("resumeId is a required parameter!");
}
return dao.getSchools(Long.valueOf(resumeId));
}
public List getWorkHistory(String resumeId) throws Exception {
if (resumeId == null) {
throw new IllegalArgumentException("resumeId is a required parameter!");
}
return dao.getWorkHistory(Long.valueOf(resumeId));
}
}