01: /*
02: * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
03: * Copyright (C) 2006-2007 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
04: * Copyright (C) Sebastien BALARD <sbalard@wilos-project.org>
05: *
06: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
07: * General Public License as published by the Free Software Foundation; either version 2 of the License,
08: * or (at your option) any later version.
09: *
10: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
11: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License along with this program; if not,
15: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16: */
17:
18: package wilos.hibernate.misc.project;
19:
20: import java.util.ArrayList;
21: import java.util.List;
22:
23: import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
24:
25: import wilos.model.misc.project.Project;
26:
27: /**
28: * ProjectDao manage requests from the system to store Project into the
29: * database.
30: */
31: public class ProjectDao extends HibernateDaoSupport {
32: /**
33: * Saves or updates a Project
34: *
35: * @param _project The Project to be saved or updated
36: */
37: public String saveOrUpdateProject(Project _project) {
38: if (_project != null) {
39: this .getHibernateTemplate().saveOrUpdate(_project);
40: return _project.getId();
41: }
42: return "";
43: }
44:
45: /**
46: * Returns a list of all the Projects
47: *
48: * @return A list of all the Projects
49: */
50: public List<Project> getAllProjects() {
51: List<Project> projects = new ArrayList<Project>();
52: for (Object obj : this .getHibernateTemplate().loadAll(
53: Project.class)) {
54: Project p = (Project) obj;
55: projects.add(p);
56: }
57: return projects;
58: }
59:
60: /**
61: * Returns the Project which has the specified ID
62: *
63: * @param _id The wanted Project's ID
64: * @return The wanted Project
65: */
66: public Project getProject(String _id) {
67: if (!_id.equals(""))
68: return (Project) this .getHibernateTemplate().get(
69: Project.class, _id);
70: return null;
71: }
72:
73: /**
74: * Deletes the Project
75: *
76: * @param _project The Project to be deleted
77: */
78: public void deleteProject(Project _project) {
79: this.getHibernateTemplate().delete(_project);
80: }
81: }
|