1 package org.whatsitcalled.webflange.service;
2
3 import java.util.List;
4
5 import org.whatsitcalled.webflange.ResourceFactory;
6 import org.whatsitcalled.webflange.model.Project;
7 import org.whatsitcalled.webflange.model.ProjectDAO;
8
9 public class ProjectServiceImpl implements ProjectService {
10 private ProjectDAO projectDAO;
11 public Project getProject(Long id) throws ProjectServiceException {
12 Project project = projectDAO.getProject(id);
13 if (project == null) {
14 throw new ProjectServiceException("Unable to find project for id: " + id);
15 }
16
17 return project;
18 }
19
20 public Long saveProject(Project project) {
21 projectDAO.saveProject(project);
22 return project.getId();
23 }
24
25 public Project[] getProjects() throws ProjectServiceException {
26 List list = projectDAO.getProjects();
27 Project[] projects = (Project[])list.toArray(new Project[list.size()]);
28
29 return projects;
30 }
31
32 public Project findProjectByName(String name) {
33 return projectDAO.findByName(name);
34 }
35
36 public ProjectDAO getProjectDAO() {
37 return projectDAO;
38 }
39
40 public void setProjectDAO(ProjectDAO projectDAO) {
41 this.projectDAO = projectDAO;
42 }
43
44 }