001: /*
002: * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
003: * Copyright (C) 2006-2007 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
004: *
005: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
006: * General Public License as published by the Free Software Foundation; either version 2 of the License,
007: * or (at your option) any later version.
008: *
009: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
010: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: * GNU General Public License for more details.
012: *
013: * You should have received a copy of the GNU General Public License along with this program; if not,
014: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
015: */
016:
017: package wilos.hibernate.misc.concretetask;
018:
019: import java.util.ArrayList;
020: import java.util.List;
021:
022: import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
023:
024: import wilos.model.misc.concretetask.ConcreteTaskDescriptor;
025:
026: /**
027: * ConcreteTaskDescriptorDao manage requests from the system to store
028: * ConcreteTaskDescriptorDao to the database
029: *
030: * @author mat, seb
031: *
032: */
033: public class ConcreteTaskDescriptorDao extends HibernateDaoSupport {
034:
035: /**
036: * Saves or updates a ConcreteTaskDescriptor
037: *
038: * @param _concreteTaskdescriptor The ConcreteTaskDescriptor to be saved or updated
039: */
040: public String saveOrUpdateConcreteTaskDescriptor(
041: ConcreteTaskDescriptor _concreteTaskDescriptor) {
042: if (_concreteTaskDescriptor != null) {
043: this .getHibernateTemplate().saveOrUpdate(
044: _concreteTaskDescriptor);
045: return _concreteTaskDescriptor.getId();
046: }
047: return "";
048: }
049:
050: /**
051: * Returns a list of all the ConcreteTaskDescriptor
052: *
053: * @return A list of all the ConcreteTaskDescriptor
054: */
055: public List<ConcreteTaskDescriptor> getAllConcreteTaskDescriptors() {
056: List<ConcreteTaskDescriptor> concreteTaskDescriptors = new ArrayList<ConcreteTaskDescriptor>();
057: for (Object obj : this .getHibernateTemplate().loadAll(
058: ConcreteTaskDescriptor.class)) {
059: ConcreteTaskDescriptor ctd = (ConcreteTaskDescriptor) obj;
060: concreteTaskDescriptors.add(ctd);
061: }
062: return concreteTaskDescriptors;
063: }
064:
065: /**
066: * Returns the ConcreteTaskDescriptor which has the specified ID
067: *
068: * @param _id The wanted ConcreteTaskDescriptor ID
069: * @return The wanted ConcreteTaskDescriptor
070: */
071: public ConcreteTaskDescriptor getConcreteTaskDescriptor(String _id) {
072: if (!_id.equals(""))
073: return (ConcreteTaskDescriptor) this .getHibernateTemplate()
074: .get(ConcreteTaskDescriptor.class, _id);
075: return null;
076: }
077:
078: /**
079: * Deletes the ConcreteTaskDescriptor
080: *
081: * @param _concreteTaskdescriptor The ConcreteTaskDescriptor to be deleted
082: */
083: public void deleteConcreteTaskDescriptor(
084: ConcreteTaskDescriptor _concreteTaskdescriptor) {
085: this .getHibernateTemplate().delete(_concreteTaskdescriptor);
086: }
087:
088: /**
089: * Returns all the ConcreteTaskDescriptors of the project which has the specified ID
090: *
091: * @param _projectId The wanted Project ID
092: * @return A list of ConcreteTaskDescriptor
093: */
094: public List<ConcreteTaskDescriptor> getAllConcreteTaskDescriptorsForProject(
095: String _projectId) {
096: List<ConcreteTaskDescriptor> concreteTaskDescriptors = new ArrayList<ConcreteTaskDescriptor>();
097: for (Object obj : this
098: .getHibernateTemplate()
099: .find(
100: "from ConcreteTaskDescriptor ctd where ctd.project.id=?",
101: _projectId)) {
102: ConcreteTaskDescriptor ctd = (ConcreteTaskDescriptor) obj;
103: concreteTaskDescriptors.add(ctd);
104: }
105: return concreteTaskDescriptors;
106: }
107: }
|