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) Sebastien BALARD <sbalard@wilos-project.org>
005: * Copyright (C) 2007-2008 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
006: *
007: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
008: * General Public License as published by the Free Software Foundation; either version 2 of the License,
009: * or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
012: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: * GNU General Public License for more details.
014: *
015: * You should have received a copy of the GNU General Public License along with this program; if not,
016: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
017: */
018:
019: package wilos.business.services.misc.concreteactivity;
020:
021: import java.util.HashSet;
022: import java.util.List;
023: import java.util.Set;
024: import java.util.SortedSet;
025: import java.util.TreeSet;
026:
027: import org.springframework.transaction.annotation.Propagation;
028: import org.springframework.transaction.annotation.Transactional;
029:
030: import wilos.business.services.misc.concretemilestone.ConcreteMilestoneService;
031: import wilos.business.services.misc.stateservice.StateService;
032: import wilos.hibernate.misc.concreteactivity.ConcreteActivityDao;
033: import wilos.model.misc.concreteactivity.ConcreteActivity;
034: import wilos.model.misc.concretebreakdownelement.ConcreteBreakdownElement;
035:
036: @Transactional(readOnly=false,propagation=Propagation.REQUIRED)
037: public class ConcreteActivityService {
038:
039: private ConcreteActivityDao concreteActivityDao;
040:
041: private ConcreteMilestoneService concreteMilestoneService;
042:
043: private StateService stateService;
044:
045: /**
046: *Allows to get the sorted set of concreteBreakdownElements with a concreteActivity
047: * @param _cact
048: * @return the sorted set of concreteBreakdownElements
049: */
050: public SortedSet<ConcreteBreakdownElement> getConcreteBreakdownElements(
051: ConcreteActivity _cact) {
052: SortedSet<ConcreteBreakdownElement> tmp = new TreeSet<ConcreteBreakdownElement>();
053: this .concreteActivityDao.getSessionFactory()
054: .getCurrentSession().saveOrUpdate(_cact);
055: for (ConcreteBreakdownElement cbde : _cact
056: .getConcreteBreakdownElements()) {
057: tmp.add(cbde);
058: }
059: return tmp;
060: }
061:
062: /**
063: * Allows to save the concrete activity which passed in parameters
064: *
065: * @param _concreteActivity
066: */
067: public void saveConcreteActivity(ConcreteActivity _concreteActivity) {
068: this .concreteActivityDao
069: .saveOrUpdateConcreteActivity(_concreteActivity);
070: }
071:
072: /**
073: * Allows to get the concrete activity which has the same id than the
074: * parameter
075: *
076: * @param _concreteActivityId
077: * the id of the concreteActivity asked
078: * @return the ConcreteActivity which has the same id
079: */
080: public boolean existsConcreteActivity(String _concreteActivityId) {
081: return this .concreteActivityDao
082: .existsConcreteActivity(_concreteActivityId);
083: }
084:
085: /**
086: * Allows to get the concrete activity which has the same id than the
087: * parameter
088: *
089: * @param _concreteActivityId
090: * the id of the concreteActivity asked
091: * @return the ConcreteActivity which has the same id
092: */
093: public ConcreteActivity getConcreteActivity(
094: String _concreteActivityId) {
095: return this .concreteActivityDao
096: .getConcreteActivity(_concreteActivityId);
097: }
098:
099: /**
100: * Return the list of all the Concrete Activities
101: *
102: * @return the list of all the concreteActivities
103: */
104: public List<ConcreteActivity> getAllConcreteActivities() {
105: return this .concreteActivityDao.getAllConcreteActivities();
106: }
107:
108: /* Getters & Setters */
109:
110: /**
111: * Return the concreteActivityDao
112: *
113: * @return the concreteActivityDao
114: */
115: public ConcreteActivityDao getConcreteActivityDao() {
116: return concreteActivityDao;
117: }
118:
119: /**
120: * Initialize the concreteActivityDao with the value in parameter
121: *
122: * @param concreteActivityDao
123: * the concreteActivityDao to set
124: */
125: public void setConcreteActivityDao(
126: ConcreteActivityDao concreteActivityDao) {
127: this .concreteActivityDao = concreteActivityDao;
128: }
129:
130: /**
131: * Allows to get the set of concreteActivities from a project
132: * @param _cact
133: * @return the set of concreteActivities
134: */
135: public Set<ConcreteActivity> getConcreteActivitiesFromProject(
136: ConcreteActivity _cact) {
137: Set<ConcreteActivity> tmp = new HashSet<ConcreteActivity>();
138:
139: this .concreteActivityDao.getSessionFactory()
140: .getCurrentSession().saveOrUpdate(_cact);
141: for (ConcreteActivity cact : this .getAllConcreteActivities()) {
142: if ((cact.getProject() != null)
143: && (cact.getProject().equals(_cact))) {
144: tmp.add(cact);
145: }
146: }
147: return tmp;
148: }
149:
150: /**
151: * Allows to get the set of concreteActivities
152: * @return the set of concreteActivities
153: */
154: public ConcreteMilestoneService getConcreteMilestoneService() {
155: return concreteMilestoneService;
156: }
157:
158: /**
159: * Allows to set the concreteMilestoneService
160: * @param _concreteMilestoneService
161: */
162: public void setConcreteMilestoneService(
163: ConcreteMilestoneService _concreteMilestoneService) {
164: concreteMilestoneService = _concreteMilestoneService;
165: }
166:
167: /**
168: *Allows to get the service's state
169: * @return the stateService
170: */
171: public StateService getStateService() {
172: return this .stateService;
173: }
174:
175: /**
176: * Allows to set the service's state
177: * @param _stateService
178: */
179: public void setStateService(StateService _stateService) {
180: this .stateService = _stateService;
181: }
182:
183: /**
184: * Allows to get the maxDisplayOrder
185: * @param _cact
186: * @return the maxDisplayOrder
187: */
188: public String getMaxDisplayOrder(ConcreteActivity _cact) {
189: return this.concreteActivityDao.getMaxDisplayOrder(_cact);
190: }
191: }
|