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.role;
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.role.RoleDefinition;
26:
27: /**
28: * RoleDefinitionDao manage requests from the system to store RoleDefinition to the database
29: *
30: * @author soosuske
31: */
32: public class RoleDefinitionDao extends HibernateDaoSupport {
33:
34: /**
35: * Saves or updates a RoleDefinition
36: *
37: * @param _roleDefinition The RoleDefinition to be saved or updated
38: */
39: public String saveOrUpdateRoleDefinition(
40: RoleDefinition _roleDefinition) {
41: if (_roleDefinition != null) {
42: this .getHibernateTemplate().saveOrUpdate(_roleDefinition);
43: return _roleDefinition.getId();
44: }
45: return "";
46: }
47:
48: /**
49: * Returns a list of all the RoleDefinitions
50: *
51: * @return A list of all the RoleDefinitions
52: */
53: public List<RoleDefinition> getAllRoleDefinitions() {
54: List<RoleDefinition> roleDefinitions = new ArrayList<RoleDefinition>();
55: for (Object obj : this .getHibernateTemplate().loadAll(
56: RoleDefinition.class)) {
57: RoleDefinition rd = (RoleDefinition) obj;
58: roleDefinitions.add(rd);
59: }
60: return roleDefinitions;
61: }
62:
63: /**
64: * Returns the RoleDefinition which has the specified ID
65: *
66: * @param _id The wanted RoleDefinition's ID
67: * @return The wanted RoleDefinition
68: */
69: public RoleDefinition getRoleDefinition(String _id) {
70: if (!_id.equals(""))
71: return (RoleDefinition) this .getHibernateTemplate().get(
72: RoleDefinition.class, _id);
73: return null;
74: }
75:
76: /**
77: * Deletes the RoleDefinition
78: *
79: * @param _roleDefinition The RoleDefinition to be deleted
80: */
81: public void deleteRoleDefinition(RoleDefinition _roleDefinition) {
82: this.getHibernateTemplate().delete(_roleDefinition);
83: }
84: }
|