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) 2007 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.spem2.task;
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.spem2.task.Step;
26:
27: /**
28: * A Step is a Section and Work Definition that is used to organize Tasks into parts or subunits of
29: * work
30: *
31: * StepDao manage requests from the system to store Steps into the database
32: *
33: * @author garwind
34: */
35: public class StepDao extends HibernateDaoSupport {
36:
37: /**
38: * Saves or updates a Step
39: *
40: * @param _step The Step to be saved or updated
41: */
42: public String saveOrUpdateStep(Step _step) {
43: if (_step != null) {
44: this .getHibernateTemplate().saveOrUpdate(_step);
45: return _step.getId();
46: }
47: return "";
48: }
49:
50: /**
51: * Returns a list of all the Steps
52: *
53: * @return A list of all the Steps
54: */
55: public List<Step> getAllSteps() {
56: List<Step> steps = new ArrayList<Step>();
57: for (Object obj : this .getHibernateTemplate().loadAll(
58: Step.class)) {
59: Step s = (Step) obj;
60: steps.add(s);
61: }
62: return steps;
63: }
64:
65: /**
66: * Returns the Step which has the specified ID
67: *
68: * @param _id The wanted Step's ID
69: * @return The wanted Step
70: */
71: public Step getStep(String _id) {
72: if (!_id.equals(""))
73: return (Step) this .getHibernateTemplate().get(Step.class,
74: _id);
75: return null;
76: }
77:
78: /**
79: * Deletes a Step
80: *
81: * @param _step The Step be deleted
82: */
83: public void deleteStep(Step _step) {
84: this.getHibernateTemplate().delete(_step);
85: }
86: }
|