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.concretephase;
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.concretephase.ConcretePhase;
026:
027: /**
028: *
029: * @author Soosuske
030: *
031: */
032: public class ConcretePhaseDao extends HibernateDaoSupport {
033: /**
034: * Saves or updates a ConcretePhase
035: *
036: * @param _concretePhase The ConcretePhase to be saved or updated
037: */
038: public String saveOrUpdateConcretePhase(ConcretePhase _concretePhase) {
039: if (_concretePhase != null) {
040: this .getHibernateTemplate().saveOrUpdate(_concretePhase);
041: return _concretePhase.getId();
042: }
043: return "";
044: }
045:
046: /**
047: * Returns a list of all the ConcretePhases
048: *
049: * @return A list of all the ConcretePhases
050: */
051: public List<ConcretePhase> getAllConcretePhases() {
052: List<ConcretePhase> concretePhases = new ArrayList<ConcretePhase>();
053: for (Object obj : this .getHibernateTemplate().loadAll(
054: ConcretePhase.class)) {
055: ConcretePhase cp = (ConcretePhase) obj;
056: concretePhases.add(cp);
057: }
058: return concretePhases;
059: }
060:
061: /**
062: * Returns the Concrete Phase which has the ID _id
063: *
064: * @param _id The wanted ID
065: * @return The wanted ConcretePhase
066: */
067: public ConcretePhase getConcretePhase(String _id) {
068: if (!_id.equals(""))
069: return (ConcretePhase) this .getHibernateTemplate().get(
070: ConcretePhase.class, _id);
071: return null;
072: }
073:
074: /*public List<BreakdownElement> getBreakdownElementsFromPhase(String _concretePhaseId) {
075: List bdes = this.getHibernateTemplate().find(
076: "from BreakdownElement bde join bde.superActivities s where s.id=?", _concretePhaseId);
077: List<BreakdownElement> listBdes = new ArrayList<BreakdownElement>();
078: if (bdes.get(0) instanceof List) {
079: for (Object o : (ArrayList) bdes.get(0)) {
080: if (o instanceof BreakdownElement) {
081: BreakdownElement bde = (BreakdownElement) o;
082: listBdes.add(bde);
083: }
084: }
085: }
086: return listBdes;
087: }*/
088:
089: /**
090: * Deletes the ConcretePhase
091: *
092: * @param _concretePhase The ConcretePhase to be deleted
093: */
094: public void deleteConcretePhase(ConcretePhase _concretePhase) {
095: this .getHibernateTemplate().delete(_concretePhase);
096: }
097:
098: /*public String getConcretePhaseName(String _concretePhaseId) {
099: Query query = this.getSession().createQuery(
100: "select cp.concreteName from ConcretePhase cp where cp.id='" + _concretePhaseId + "'");
101: List results = query.list();
102: if (results.size() == 1)
103: return (String) results.get(0);
104: return null;
105: }*/
106: }
|