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: * Copyright (C) 2007 Sebastien BALARD <sbalard@wilos-project.org>
005: *
006: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
007: * General Public License as published by the Free Software Foundation; either version 2 of the License,
008: * or (at your option) any later version.
009: *
010: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
011: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License along with this program; if not,
015: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
016: */
017:
018: package wilos.hibernate.misc.concreteiteration;
019:
020: import java.util.ArrayList;
021: import java.util.List;
022:
023: import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
024:
025: import wilos.model.misc.concreteiteration.ConcreteIteration;
026:
027: /**
028: * ConcreteIterationDao manage requests from the system to store iterations to the
029: * database
030: */
031: public class ConcreteIterationDao extends HibernateDaoSupport {
032: /**
033: * Saves or updates an ConcreteIteration
034: *
035: * @param _ConcreteIteration The ConcreteIteration to be saved or updated
036: */
037: public String saveOrUpdateConcreteIteration(
038: ConcreteIteration _concreteIteration) {
039: if (_concreteIteration != null) {
040: this .getHibernateTemplate()
041: .saveOrUpdate(_concreteIteration);
042: return _concreteIteration.getId();
043: }
044: return "";
045: }
046:
047: /**
048: * Returns a list of all the ConcreteIterations
049: *
050: * @return A list of all the ConcreteIterations
051: */
052: public List<ConcreteIteration> getAllConcreteIterations() {
053: List<ConcreteIteration> concreteIterations = new ArrayList<ConcreteIteration>();
054: for (Object obj : this .getHibernateTemplate().loadAll(
055: ConcreteIteration.class)) {
056: ConcreteIteration ci = (ConcreteIteration) obj;
057: concreteIterations.add(ci);
058: }
059: return concreteIterations;
060: }
061:
062: /*public List<ConcreteBreakdownElement> getBreakdownElementsFromConcreteIteration(String _concreteIterationId) {
063: List bdes = this.getHibernateTemplate().find(
064: "from BreakdownElement bde join bde.superActivities s where s.id=?", _concreteIterationId);
065: List<ConcreteBreakdownElement> listBdes = new ArrayList<ConcreteBreakdownElement>();
066: if (bdes.get(0) instanceof List) {
067: for (Object o : (ArrayList) bdes.get(0)) {
068: if (o instanceof ConcreteBreakdownElement) {
069: ConcreteBreakdownElement bde = (ConcreteBreakdownElement) o;
070: listBdes.add(bde);
071: }
072: }
073: }
074: return listBdes;
075: }*/
076:
077: /**
078: * Returns the ConcreteIteration which has the ID _id
079: *
080: * @param _id The wanted ID
081: * @return The wanted ConcreteIteration
082: */
083: public ConcreteIteration getConcreteIteration(String _id) {
084: if (!_id.equals(""))
085: return (ConcreteIteration) this .getHibernateTemplate().get(
086: ConcreteIteration.class, _id);
087: return null;
088: }
089:
090: /**
091: * Deletes the ConcreteIteration
092: *
093: * @param _ConcreteIteration The ConcreteIteration to be deleted
094: */
095: public void deleteConcreteIteration(
096: ConcreteIteration _concreteIteration) {
097: this .getHibernateTemplate().delete(_concreteIteration);
098: }
099:
100: /*public String getConcreteIterationName(String _concreteIterationId) {
101: Query query = this.getSession().createQuery(
102: "select ca.concreteName from ConcreteIteration ca where ca.id='" + _concreteIterationId + "'");
103: List results = query.list();
104: if (results.size() == 1)
105: return (String) results.get(0);
106: return null;
107: }*/
108: }
|