0001: /*
0002: * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
0003: * Copyright (C) 2006-2007 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
0004: * Copyright (C) 2007 Sebastien BALARD <sbalard@wilos-project.org>
0005: * Copyright (C) 2007-2008 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
0006: *
0007: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
0008: * General Public License as published by the Free Software Foundation; either version 2 of the License,
0009: * or (at your option) any later version.
0010: *
0011: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
0012: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0013: * GNU General Public License for more details.
0014: *
0015: * You should have received a copy of the GNU General Public License along with this program; if not,
0016: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017: */
0018:
0019: package wilos.business.services.misc.concretetask;
0020:
0021: import java.util.ArrayList;
0022: import java.util.Calendar;
0023: import java.util.Date;
0024: import java.util.HashMap;
0025: import java.util.HashSet;
0026: import java.util.Iterator;
0027: import java.util.List;
0028: import java.util.Set;
0029:
0030: import org.apache.commons.logging.Log;
0031: import org.apache.commons.logging.LogFactory;
0032: import org.springframework.transaction.annotation.Propagation;
0033: import org.springframework.transaction.annotation.Transactional;
0034:
0035: import wilos.business.services.misc.concreteactivity.ConcreteActivityService;
0036: import wilos.business.services.misc.concreterole.ConcreteRoleDescriptorService;
0037: import wilos.business.services.misc.concreteworkbreakdownelement.ConcreteWorkBreakdownElementService;
0038: import wilos.business.services.misc.concreteworkbreakdownelement.ConcreteWorkOrderService;
0039: import wilos.business.services.misc.stateservice.StateService;
0040: import wilos.business.services.spem2.role.RoleDescriptorService;
0041: import wilos.business.services.spem2.task.TaskDescriptorService;
0042: import wilos.hibernate.misc.concreteactivity.ConcreteActivityDao;
0043: import wilos.hibernate.misc.concretetask.ConcreteTaskDescriptorDao;
0044: import wilos.hibernate.spem2.workproduct.WorkProductDescriptorDao;
0045: import wilos.model.misc.concreteactivity.ConcreteActivity;
0046: import wilos.model.misc.concreterole.ConcreteRoleDescriptor;
0047: import wilos.model.misc.concretetask.ConcreteTaskDescriptor;
0048: import wilos.model.misc.concreteworkbreakdownelement.ConcreteWorkOrder;
0049: import wilos.model.misc.concreteworkproduct.ConcreteWorkProductDescriptor;
0050: import wilos.model.misc.dailyremainingtime.DailyRemainingTime;
0051: import wilos.model.misc.project.Project;
0052: import wilos.model.misc.wilosuser.Participant;
0053: import wilos.model.spem2.role.RoleDescriptor;
0054: import wilos.model.spem2.task.TaskDescriptor;
0055: import wilos.model.spem2.workproduct.WorkProductDescriptor;
0056: import wilos.utils.Constantes.State;
0057:
0058: /**
0059: *
0060: * @author Soosuske
0061: * @author deder
0062: * @author nicastel
0063: * @author Almiriad
0064: *
0065: */
0066: @Transactional(readOnly=false,propagation=Propagation.REQUIRED)
0067: public class ConcreteTaskDescriptorService {
0068:
0069: private ConcreteTaskDescriptorDao concreteTaskDescriptorDao;
0070:
0071: private ConcreteActivityDao concreteActivityDao;
0072:
0073: private WorkProductDescriptorDao workProductDescriptorDao;
0074:
0075: private StateService stateService;
0076:
0077: private ConcreteWorkBreakdownElementService concreteWorkBreakdownElementService;
0078:
0079: private TaskDescriptorService taskDescriptorService;
0080:
0081: private RoleDescriptorService roleDescriptorService;
0082:
0083: private ConcreteRoleDescriptorService concreteRoleDescriptorService;
0084:
0085: private ConcreteWorkOrderService concreteWorkOrderService;
0086:
0087: private ConcreteActivityService concreteActivityService;
0088:
0089: public static final String CHECKED = "images/expandableTable/checked.gif";
0090:
0091: public static final String UNCHECKED = "images/expandableTable/unchecked.gif";
0092:
0093: protected final Log logger = LogFactory.getLog(this .getClass());
0094:
0095: /**
0096: * Return the list of concreteTaskDescriptors for a project
0097: *
0098: * @return list of concreteTaskDescriptors
0099: */
0100: public List<ConcreteTaskDescriptor> getAllConcreteTaskDescriptorsForProject(
0101: String _projectId) {
0102: return this .getConcreteTaskDescriptorDao()
0103: .getAllConcreteTaskDescriptorsForProject(_projectId);
0104: }
0105:
0106: /**
0107: * Allows to get the concreteTaskDescriptor with its id
0108: *
0109: * @param _concreteTaskDescriptorId
0110: * @return the concreteTaskDescriptor
0111: */
0112: public ConcreteTaskDescriptor getConcreteTaskDescriptor(
0113: String _concreteTaskDescriptorId) {
0114: return this .getConcreteTaskDescriptorDao()
0115: .getConcreteTaskDescriptor(_concreteTaskDescriptorId);
0116: }
0117:
0118: /**
0119: * Save the ConcreteTaskDescriptor modifications into database
0120: *
0121: * @param _concreteTaskDescriptor
0122: */
0123: public void updateConcreteTaskDescriptor(
0124: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0125: this .concreteTaskDescriptorDao
0126: .saveOrUpdateConcreteTaskDescriptor(_concreteTaskDescriptor);
0127: }
0128:
0129: /**
0130: * Start the ConcreteTaskDescriptor and save into the data base changing
0131: * (i.e. State, realStartingDate).
0132: *
0133: * @param _concreteTaskDescriptor
0134: */
0135: public void startConcreteTaskDescriptor(
0136: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0137:
0138: this .stateService.updateStateTo(_concreteTaskDescriptor,
0139: State.STARTED);
0140: }
0141:
0142: /**
0143: * Allows to start a concreteTaskDescriptor with its id
0144: *
0145: * @param id
0146: */
0147: public void startConcreteTaskDescriptor(String id) {
0148: ConcreteTaskDescriptor ct = this .getConcreteTaskDescriptorDao()
0149: .getConcreteTaskDescriptor(id);
0150: this .startConcreteTaskDescriptor(ct);
0151: }
0152:
0153: /**
0154: * Allows to change the accomplished time of a task
0155: *
0156: * @param taskId
0157: * @param newTime
0158: */
0159: public void setAccomplishedTimeByTask(String taskId, float newTime) {
0160: ConcreteTaskDescriptor ct = this .getConcreteTaskDescriptorDao()
0161: .getConcreteTaskDescriptor(taskId);
0162: ct.setAccomplishedTime(newTime);
0163: this .getConcreteTaskDescriptorDao()
0164: .saveOrUpdateConcreteTaskDescriptor(ct);
0165: }
0166:
0167: /**
0168: * Allows to change the remaining time of a tsk
0169: *
0170: * @param taskId
0171: * @param newTime
0172: */
0173: public void setRemainingTimeByTask(String taskId, float newTime) {
0174: ConcreteTaskDescriptor ct = this .getConcreteTaskDescriptorDao()
0175: .getConcreteTaskDescriptor(taskId);
0176: ct.setRemainingTime(newTime);
0177: this .getConcreteTaskDescriptorDao()
0178: .saveOrUpdateConcreteTaskDescriptor(ct);
0179: }
0180:
0181: /**
0182: * Allows to remove a concreteTaskDescriptor
0183: *
0184: * @param _concreteTaskDescriptor
0185: */
0186: public void removeConcreteTaskDescriptor(
0187: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0188: List<ConcreteWorkOrder> tmp = new ArrayList<ConcreteWorkOrder>();
0189:
0190: this .concreteTaskDescriptorDao.getSessionFactory()
0191: .getCurrentSession().saveOrUpdate(
0192: _concreteTaskDescriptor);
0193: this .concreteTaskDescriptorDao.getSessionFactory()
0194: .getCurrentSession().refresh(_concreteTaskDescriptor);
0195:
0196: // remove dependencies linked to the task descriptor
0197: for (ConcreteWorkOrder cwo : _concreteTaskDescriptor
0198: .getConcretePredecessors()) {
0199: tmp.add(cwo);
0200: }
0201: for (ConcreteWorkOrder cwo : tmp)
0202: this .concreteWorkOrderService.deleteConcreteWorkOrder(cwo);
0203: tmp.clear();
0204: for (ConcreteWorkOrder cwo : _concreteTaskDescriptor
0205: .getConcreteSuccessors()) {
0206: tmp.add(cwo);
0207: }
0208: for (ConcreteWorkOrder cwo : tmp)
0209: this .concreteWorkOrderService.deleteConcreteWorkOrder(cwo);
0210:
0211: for (ConcreteActivity sca : _concreteTaskDescriptor
0212: .getSuperConcreteActivities()) {
0213: this .concreteActivityDao.getSessionFactory()
0214: .getCurrentSession().saveOrUpdate(sca);
0215: sca.getConcreteBreakdownElements().remove(
0216: _concreteTaskDescriptor);
0217: this .concreteActivityDao.saveOrUpdateConcreteActivity(sca);
0218: }
0219:
0220: ConcreteRoleDescriptor tmpConcreteRoleDescriptor;
0221: if (_concreteTaskDescriptor.getMainConcreteRoleDescriptor() != null) {
0222: tmpConcreteRoleDescriptor = _concreteTaskDescriptor
0223: .getMainConcreteRoleDescriptor();
0224: this .concreteRoleDescriptorService
0225: .getConcreteRoleDescriptorDao().getSessionFactory()
0226: .getCurrentSession().saveOrUpdate(
0227: tmpConcreteRoleDescriptor);
0228: tmpConcreteRoleDescriptor
0229: .getPrimaryConcreteTaskDescriptors().remove(
0230: _concreteTaskDescriptor);
0231: this .concreteRoleDescriptorService
0232: .saveConcreteRoleDescriptor(tmpConcreteRoleDescriptor);
0233: }
0234:
0235: // TaskDescriptor td = this.taskDescriptorService
0236: // .getTaskDescriptorById(_concreteTaskDescriptor
0237: // .getTaskDescriptor().getId());
0238: TaskDescriptor td = _concreteTaskDescriptor.getTaskDescriptor();
0239: this .taskDescriptorService.getTaskDescriptorDao()
0240: .getSessionFactory().getCurrentSession().saveOrUpdate(
0241: td);
0242: td.removeConcreteTaskDescriptor(_concreteTaskDescriptor);
0243: this .taskDescriptorService.saveTaskDescriptor(td);
0244: this .taskDescriptorService.getTaskDescriptorDao()
0245: .getSessionFactory().getCurrentSession().refresh(td);
0246: this .saveConcreteTaskDescriptor(_concreteTaskDescriptor);
0247: this .getConcreteTaskDescriptorDao()
0248: .deleteConcreteTaskDescriptor(_concreteTaskDescriptor);
0249: }
0250:
0251: /**
0252: * Checks if the participant can be affected to a concreteTask (the
0253: * participant must be affected to the corresponding concrete role)
0254: *
0255: * @param _concreteTaskDescriptor
0256: * @param _participant
0257: * @return true if the participant can be affected to a concreteTask, false
0258: * in the other case
0259: */
0260: public boolean checkAffectationToRole(
0261: ConcreteTaskDescriptor _concreteTaskDescriptor,
0262: Participant _participant) {
0263:
0264: boolean afficher = false;
0265:
0266: this .concreteTaskDescriptorDao.getSessionFactory()
0267: .getCurrentSession().saveOrUpdate(
0268: _concreteTaskDescriptor);
0269:
0270: TaskDescriptor tmp = _concreteTaskDescriptor
0271: .getTaskDescriptor();
0272: RoleDescriptor tmpRoleDescriptor;
0273: // ConcreteTaskDescriptor ctd = new ConcreteTaskDescriptor();
0274: TaskDescriptor tmp2 = this .taskDescriptorService
0275: .getTaskDescriptorById(tmp.getId());
0276:
0277: if (tmp2.getMainRole() == null) {
0278: return true;
0279: }
0280: tmpRoleDescriptor = tmp2.getMainRole();
0281: RoleDescriptor rd = this .roleDescriptorService
0282: .getRoleDescriptor(tmpRoleDescriptor.getId());
0283: // recuperation des deux listes.
0284: // this.roleDescriptorService.
0285: List<ConcreteRoleDescriptor> crdList = this .concreteRoleDescriptorService
0286: .getAllConcreteRoleDescriptorForARoleDescriptor(rd
0287: .getId());
0288:
0289: // on parcours les deux liste afin de trouver le bon
0290: // concreteRoledescriptor
0291: for (ConcreteRoleDescriptor currentCrd : crdList) {
0292:
0293: ConcreteRoleDescriptor crd = this .concreteRoleDescriptorService
0294: .getConcreteRoleDescriptor(currentCrd.getId());
0295: if (crd.getParticipant() == null) {
0296: afficher = false;
0297: } else {
0298: if (crd.getParticipant().getId().equals(
0299: _participant.getId())) {
0300: // check if the concreteRole and the concreteTask form
0301: // part
0302: // of the same concreteActivity
0303: for (ConcreteActivity cact1 : crd
0304: .getSuperConcreteActivities()) {
0305: for (ConcreteActivity cact2 : _concreteTaskDescriptor
0306: .getSuperConcreteActivities()) {
0307: if (cact1.getId().equals(cact2.getId())) {
0308: return true;
0309: }
0310: }
0311: }
0312: }
0313: }
0314:
0315: }
0316: return afficher;
0317:
0318: }
0319:
0320: /**
0321: * Checks if the participant IS affected to a concreteTask (the participant
0322: * must be affected to the corresponding concrete role)
0323: *
0324: * @param _concreteTaskDescriptor
0325: * @param _participant
0326: * @return true if the participant IS affected to a concreteTask, false in
0327: * the other case
0328: */
0329: public boolean checkAffectationToTask(
0330: ConcreteTaskDescriptor _concreteTaskDescriptor,
0331: Participant _participant) {
0332: this .concreteTaskDescriptorDao.getSessionFactory()
0333: .getCurrentSession().saveOrUpdate(
0334: _concreteTaskDescriptor);
0335: return _concreteTaskDescriptor.getIsParticipant();
0336: }
0337:
0338: /**
0339: * When the user click on the button affected.
0340: *
0341: * @param _concreteTaskDescriptor
0342: */
0343: public void affectedConcreteTaskDescriptor(
0344: ConcreteTaskDescriptor _concreteTaskDescriptor,
0345: Participant _user) {
0346:
0347: this .concreteTaskDescriptorDao.getSessionFactory()
0348: .getCurrentSession().saveOrUpdate(
0349: _concreteTaskDescriptor);
0350:
0351: RoleDescriptor mainRole = _concreteTaskDescriptor
0352: .getTaskDescriptor().getMainRole();
0353:
0354: if (mainRole == null) {
0355:
0356: mainRole = this .getConcreteRoleDescriptorService()
0357: .createOutOfProcessConcreteRoleDescriptor(_user,
0358: _concreteTaskDescriptor);
0359: }
0360:
0361: this .roleDescriptorService.getRoleDescriptorDao()
0362: .getSessionFactory().getCurrentSession().saveOrUpdate(
0363: mainRole);
0364:
0365: Set<ConcreteRoleDescriptor> listeRd = mainRole
0366: .getConcreteRoleDescriptors();
0367:
0368: // on parcours les deux liste afin de trouver le bon
0369: // concreteRoledescriptor
0370: for (ConcreteRoleDescriptor tmpListeRd : listeRd) {
0371:
0372: if (tmpListeRd.getParticipant() != null) {
0373: if (tmpListeRd.getParticipant().getId().equals(
0374: _user.getId())) {
0375: this .concreteRoleDescriptorService
0376: .getConcreteRoleDescriptorDao()
0377: .saveOrUpdateConcreteRoleDescriptor(
0378: tmpListeRd);
0379: _concreteTaskDescriptor
0380: .addMainConcreteRoleDescriptor(tmpListeRd);
0381: break;
0382: }
0383: }
0384: }
0385: }
0386:
0387: /**
0388: * Suspend a concreteTaskDescriptor and save it into the data base (i.e.
0389: * State).
0390: *
0391: * @param _concreteTaskDescriptor
0392: */
0393: public void suspendConcreteTaskDescriptor(
0394: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0395: this .stateService.updateStateTo(_concreteTaskDescriptor,
0396: State.SUSPENDED);
0397: }
0398:
0399: /**
0400: * Suspend a concreteTaskDescriptor with its id and save it into the data
0401: * base
0402: *
0403: * @param id
0404: */
0405: public void suspendConcreteTaskDescriptor(String id) {
0406: ConcreteTaskDescriptor ct = this .getConcreteTaskDescriptorDao()
0407: .getConcreteTaskDescriptor(id);
0408: this .suspendConcreteTaskDescriptor(ct);
0409: }
0410:
0411: /**
0412: * Finish a ConcreteTaskDescriptor and save it into the data base (i.e.
0413: * State, realFinishingDate).
0414: *
0415: * @param _concreteTaskDescriptor
0416: */
0417: public void finishConcreteTaskDescriptor(
0418: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0419: this .stateService.updateStateTo(_concreteTaskDescriptor,
0420: State.FINISHED);
0421: }
0422:
0423: /**
0424: * Finish a ConcreteTaskDescriptor with its id and save it into the data
0425: * base
0426: *
0427: * @param id
0428: */
0429: public void finishConcreteTaskDescriptor(String id) {
0430: ConcreteTaskDescriptor ct = this .getConcreteTaskDescriptorDao()
0431: .getConcreteTaskDescriptor(id);
0432: ct.setRemainingTime((float) 0.0);
0433: this .finishConcreteTaskDescriptor(ct);
0434: }
0435:
0436: /**
0437: * Allows to check if a concreteTaskDescriptor is ready to finish
0438: *
0439: * @param _concreteTaskDescriptor
0440: * @return true if the concreteTaskDescriptor is ready to finish, false in
0441: * the other case
0442: */
0443: public boolean isConcreteTaskDescriptorFinishable(
0444: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0445: return this .stateService
0446: .isConcreteWorkBreakdownElementFinishable(_concreteTaskDescriptor);
0447: }
0448:
0449: /**
0450: * Allows to save a concreteTaskDescriptor
0451: *
0452: * @param _concreteTaskDescriptor
0453: */
0454: public void saveConcreteTaskDescriptor(
0455: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0456: this .concreteTaskDescriptorDao
0457: .saveOrUpdateConcreteTaskDescriptor(_concreteTaskDescriptor);
0458: }
0459:
0460: /**
0461: * Dissociates a concreteTask
0462: *
0463: * @param _concreteTaskDescriptor
0464: *
0465: */
0466: public void dissociateConcreteTaskDescriptor(
0467: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0468: ConcreteRoleDescriptor cmrd = _concreteTaskDescriptor
0469: .getMainConcreteRoleDescriptor();
0470:
0471: cmrd
0472: .removePrimaryConcreteTaskDescriptor(_concreteTaskDescriptor);
0473: this .concreteTaskDescriptorDao
0474: .saveOrUpdateConcreteTaskDescriptor(_concreteTaskDescriptor);
0475: this .concreteRoleDescriptorService
0476: .saveConcreteRoleDescriptor(cmrd);
0477: }
0478:
0479: /*
0480: * public String getConcreteTaskDescriptorName(String
0481: * _concreteTaskDescriptorId){ return
0482: * this.concreteTaskDescriptorDao.getConcreteTaskDescriptorName(_concreteTaskDescriptorId); }
0483: */
0484:
0485: /**
0486: * Getter of taskDescriptorDao.
0487: *
0488: * @return the taskDescriptorDao.
0489: */
0490: public ConcreteTaskDescriptorDao getConcreteTaskDescriptorDao() {
0491: return this .concreteTaskDescriptorDao;
0492: }
0493:
0494: /**
0495: * Setter of concreteTaskDescriptorDao.
0496: *
0497: * @param _concreteTaskDescriptorDao
0498: */
0499: public void setConcreteTaskDescriptorDao(
0500: ConcreteTaskDescriptorDao _concreteTaskDescriptorDao) {
0501: this .concreteTaskDescriptorDao = _concreteTaskDescriptorDao;
0502: }
0503:
0504: /**
0505: * Allows to get the roleDescriptorService
0506: *
0507: * @return the roleDescriptorService
0508: */
0509: public RoleDescriptorService getRoleDescriptorService() {
0510: return roleDescriptorService;
0511: }
0512:
0513: /**
0514: * Allows to set the roleDecriptorService
0515: *
0516: * @param roleDescriptorService
0517: */
0518: public void setRoleDescriptorService(
0519: RoleDescriptorService roleDescriptorService) {
0520: this .roleDescriptorService = roleDescriptorService;
0521: }
0522:
0523: /**
0524: * Allows to get the taskDescriptorService
0525: *
0526: * @return the taskDescriptorService
0527: */
0528: public TaskDescriptorService getTaskDescriptorService() {
0529: return taskDescriptorService;
0530: }
0531:
0532: /**
0533: * Allows to set the taskDescriptorService
0534: *
0535: * @param taskDescriptorService
0536: */
0537: public void setTaskDescriptorService(
0538: TaskDescriptorService taskDescriptorService) {
0539: this .taskDescriptorService = taskDescriptorService;
0540: }
0541:
0542: /**
0543: * Allows to get the concreteRoleDescriptorService
0544: *
0545: * @return the concreteRoleDescriptorService
0546: */
0547: public ConcreteRoleDescriptorService getConcreteRoleDescriptorService() {
0548: return concreteRoleDescriptorService;
0549: }
0550:
0551: /**
0552: * Allows to set the concreteRoleDescriptorService
0553: *
0554: * @param concreteRoleDescriptorService
0555: */
0556: public void setConcreteRoleDescriptorService(
0557: ConcreteRoleDescriptorService concreteRoleDescriptorService) {
0558: this .concreteRoleDescriptorService = concreteRoleDescriptorService;
0559: }
0560:
0561: /**
0562: * Allows to get the concreteActivityDao
0563: *
0564: * @return the concreteActivityDao
0565: */
0566: public ConcreteActivityDao getConcreteActivityDao() {
0567: return concreteActivityDao;
0568: }
0569:
0570: /**
0571: * Allows to set the concreteActivityDao
0572: *
0573: * @param concreteActivityDao
0574: */
0575: public void setConcreteActivityDao(
0576: ConcreteActivityDao concreteActivityDao) {
0577: this .concreteActivityDao = concreteActivityDao;
0578: }
0579:
0580: /**
0581: * Allows to get the concreteWorkOrderService
0582: *
0583: * @return the concreteWorkOrderService
0584: */
0585: public ConcreteWorkOrderService getConcreteWorkOrderService() {
0586: return concreteWorkOrderService;
0587: }
0588:
0589: /**
0590: * Allows to set the concreteWorkOrderService
0591: *
0592: * @param concreteWorkOrderService
0593: */
0594: public void setConcreteWorkOrderService(
0595: ConcreteWorkOrderService concreteWorkOrderService) {
0596: this .concreteWorkOrderService = concreteWorkOrderService;
0597: }
0598:
0599: /**
0600: * Allows to get the concreteActivityService
0601: *
0602: * @return the concreteActivityService
0603: */
0604: public ConcreteActivityService getConcreteActivityService() {
0605: return this .concreteActivityService;
0606: }
0607:
0608: /**
0609: * Allows to set the concreteActivityService
0610: *
0611: * @param _concreteActivityService
0612: */
0613: public void setConcreteActivityService(
0614: ConcreteActivityService _concreteActivityService) {
0615: this .concreteActivityService = _concreteActivityService;
0616: }
0617:
0618: /*
0619: * public ConcreteWorkOrderDao getConcreteWorkOrderDao() { return
0620: * concreteWorkOrderDao; }
0621: *
0622: * public void setConcreteWorkOrderDao( ConcreteWorkOrderDao
0623: * concreteWorkOrderDao) { this.concreteWorkOrderDao = concreteWorkOrderDao; }
0624: */
0625:
0626: /**
0627: * Allows to get a super concreteActivity for a concreteTaskDescriptor
0628: *
0629: * @param _concreteTaskDescriptor
0630: * @return concreteActivity
0631: */
0632: public ConcreteActivity getSuperConcreteActivityFromConcreteTaskDescriptor(
0633: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0634: this .concreteTaskDescriptorDao.getSessionFactory()
0635: .getCurrentSession().saveOrUpdate(
0636: _concreteTaskDescriptor);
0637: return _concreteTaskDescriptor.getSuperConcreteActivity();
0638: }
0639:
0640: /**
0641: * Allows to get the daily remaining time for a concreteTaskDescriptor
0642: *
0643: * @param _ctd
0644: * @return the daily remaining time
0645: */
0646: public DailyRemainingTime getDailyRemainingTime(
0647: ConcreteTaskDescriptor _ctd) {
0648: Set<DailyRemainingTime> setDailyRemainingTimes = new HashSet<DailyRemainingTime>();
0649: Calendar cal = Calendar.getInstance();
0650: Calendar cal2 = Calendar.getInstance();
0651: Boolean verif = false;
0652: DailyRemainingTime tempDrt = new DailyRemainingTime();
0653: Iterator ite;
0654:
0655: this .concreteTaskDescriptorDao.getSessionFactory()
0656: .getCurrentSession().saveOrUpdate(_ctd);
0657:
0658: cal2.setTime(new Date());
0659: cal2 = this .initCalendar(cal2);
0660:
0661: setDailyRemainingTimes = _ctd.getDailyRemainingTimes();
0662: if (setDailyRemainingTimes != null) {
0663: ite = setDailyRemainingTimes.iterator();
0664: while (ite.hasNext() && !verif) {
0665: tempDrt = (DailyRemainingTime) ite.next();
0666: cal.setTime(tempDrt.getDate());
0667: cal = this .initCalendar(cal);
0668: if (cal.equals(cal2)) {
0669: verif = true;
0670: }
0671: }
0672: ite = null;
0673: }
0674: if (verif) {
0675: return tempDrt;
0676: } else {
0677: return null;
0678: }
0679: }
0680:
0681: /**
0682: * Allows to initialize a calendar
0683: *
0684: * @param _cal
0685: * @return the initialized calendar
0686: */
0687: public Calendar initCalendar(Calendar _cal) {
0688: Calendar cal = _cal;
0689: cal.set(Calendar.HOUR_OF_DAY, 0);
0690: cal.set(Calendar.MINUTE, 0);
0691: cal.set(Calendar.SECOND, 0);
0692: cal.set(Calendar.MILLISECOND, 0);
0693: return cal;
0694: }
0695:
0696: /**
0697: * Allows to create a planning for a concreteTaskDescriptor
0698: *
0699: * @param _ctd
0700: * @return an hashMap planning
0701: */
0702: public HashMap<String, Object> getCreateDate(
0703: ConcreteTaskDescriptor _ctd) {
0704: HashMap<String, Object> tmpHashMap = new HashMap<String, Object>();
0705: Project project = new Project();
0706:
0707: this .concreteTaskDescriptorDao.getSessionFactory()
0708: .getCurrentSession().saveOrUpdate(_ctd);
0709:
0710: project = _ctd.getProject();
0711: tmpHashMap.put("createDate", project.getCreationDate());
0712: tmpHashMap.put("finishingDate", project
0713: .getPlannedFinishingDate());
0714: tmpHashMap.put("plannedTime", (float) project.getPlannedTime());
0715: return tmpHashMap;
0716: }
0717:
0718: /**
0719: * Allows to get the concreteWorkBreakdownElementService
0720: *
0721: * @return the concreteWorkBreakdownElementService
0722: */
0723: public ConcreteWorkBreakdownElementService getConcreteWorkBreakdownElementService() {
0724: return this .concreteWorkBreakdownElementService;
0725: }
0726:
0727: /**
0728: * Allows to set the concreteWorkBreakdownElementService
0729: *
0730: * @param _concreteWorkBreakdownElementService
0731: */
0732: public void setConcreteWorkBreakdownElementService(
0733: ConcreteWorkBreakdownElementService _concreteWorkBreakdownElementService) {
0734: this .concreteWorkBreakdownElementService = _concreteWorkBreakdownElementService;
0735: }
0736:
0737: /**
0738: * Allows to get the service's state
0739: *
0740: * @return the stateService
0741: */
0742: public StateService getStateService() {
0743: return this .stateService;
0744: }
0745:
0746: /**
0747: * Allows to set the service's state
0748: *
0749: * @param _stateService
0750: */
0751: public void setStateService(StateService _stateService) {
0752: this .stateService = _stateService;
0753: }
0754:
0755: /**
0756: * Allows to check if there is at least one concreteTaskDescriptor for each
0757: * mandatory input workProductDescriptors of a task
0758: *
0759: * @param _concreteTaskDescriptor
0760: * @return true if there is at least one concrete, false in the other case
0761: */
0762: public boolean atLeastOneConcreteForEachMandatoryInputWorkProductOfATask(
0763: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0764: this .concreteTaskDescriptorDao.getSessionFactory()
0765: .getCurrentSession().saveOrUpdate(
0766: _concreteTaskDescriptor);
0767: boolean b = true;
0768: Set<WorkProductDescriptor> wpds = _concreteTaskDescriptor
0769: .getTaskDescriptor()
0770: .getMandatoryInputWorkProductDescriptors();
0771: for (WorkProductDescriptor wpd : wpds) {
0772: if (!this
0773: .atLeastOneConcreteForAMandatoryInputWorkProductOfATask(
0774: _concreteTaskDescriptor, wpd)) {
0775: b = false;
0776: }
0777: }
0778: return b;
0779: }
0780:
0781: /**
0782: * Allows to check if there is at least one concreteTaskDescriptor for each
0783: * mandatory output workProductDescriptors of a task
0784: *
0785: * @param _concreteTaskDescriptor
0786: * @return true if there is at least one concrete, false in the other case
0787: */
0788: public boolean atLeastOneConcreteForEachOutputWorkProductOfATask(
0789: ConcreteTaskDescriptor _concreteTaskDescriptor) {
0790: this .concreteTaskDescriptorDao.getSessionFactory()
0791: .getCurrentSession().saveOrUpdate(
0792: _concreteTaskDescriptor);
0793: boolean b = true;
0794: Set<WorkProductDescriptor> wpds = _concreteTaskDescriptor
0795: .getTaskDescriptor().getOutputWorkProductDescriptors();
0796: for (WorkProductDescriptor wpd : wpds) {
0797: if (!this .atLeastOneConcreteForAOutputWorkProductOfATask(
0798: _concreteTaskDescriptor, wpd)) {
0799: b = false;
0800: }
0801: }
0802: return b;
0803: }
0804:
0805: // TODO Wilos3 Method to clean
0806: /**
0807: * Allows to get the list of workProducts for a concreteTask
0808: *
0809: * @param _concreteTaskDescriptor
0810: * @param _considerState
0811: * @return the list of workProducts by hashMap
0812: */
0813: public List<HashMap<String, Object>> getWorkProductsForAConcreteTask(
0814: ConcreteTaskDescriptor _concreteTaskDescriptor,
0815: boolean _considerState) {
0816:
0817: TaskDescriptor _td = _concreteTaskDescriptor
0818: .getTaskDescriptor();
0819:
0820: List<HashMap<String, Object>> _workProducts = new ArrayList<HashMap<String, Object>>();
0821:
0822: for (WorkProductDescriptor outputwpd : this .taskDescriptorService
0823: .getOutputWorkProducts(_td)) {
0824: HashMap<String, Object> hm = new HashMap<String, Object>();
0825: hm.put("checked", CHECKED);
0826: hm.put("readyManda", UNCHECKED);
0827: hm.put("readyOutput", UNCHECKED);
0828:
0829: if (_workProducts.size() == 0) {
0830: hm.put("id", outputwpd.getId());
0831: hm.put("isOutput", true);
0832: String s = outputwpd.getActivityExitState();
0833: if (s.equals("")) {
0834: s = "Aucun";
0835: }
0836: hm.put("desiredOutputState", s);
0837: hm.put("isOptionalInput", false);
0838: hm.put("isMandatoryInput", false);
0839: hm.put("concretename", outputwpd.getPresentationName());
0840:
0841: if (_considerState) {
0842: // checking if there is at least one concrete created for
0843: // outputwpd and if all concrete output of outputwpd
0844: // are in the good
0845: // state in order to know if we can finish the task
0846: /*
0847: * boolean bool = ((this
0848: * .checkOutputWorkProductState(_concreteTaskDescriptor)) &&
0849: * (outputwpd .getConcreteWorkProductDescriptors().size() >
0850: * 0));
0851: */
0852:
0853: boolean bool = ((this
0854: .checkOutputWorkProductState(_concreteTaskDescriptor)) && (this
0855: .atLeastOneConcreteForAOutputWorkProductOfATask(
0856: _concreteTaskDescriptor, outputwpd)));
0857:
0858: if (bool) {
0859: hm.put("readyOutput", CHECKED);
0860: } else {
0861: hm.put("readyOutput", UNCHECKED);
0862: }
0863: } else {
0864: // checking if there is at least one concrete created for
0865: // outputwpd in order to know if we can finish the task
0866: if (this
0867: .atLeastOneConcreteForAOutputWorkProductOfATask(
0868: _concreteTaskDescriptor, outputwpd)) {
0869: hm.put("readyOutput", CHECKED);
0870: }
0871: }
0872:
0873: _workProducts.add(hm);
0874:
0875: } else {
0876: // checking if the product "outputwpd" is not already in the
0877: // list
0878:
0879: boolean b = false;
0880: // the variable "i" is use in order to know the position of the
0881: // object to remove in the list
0882: int i = 0;
0883: HashMap<String, Object> hm2 = new HashMap<String, Object>();
0884: for (HashMap<String, Object> h : _workProducts) {
0885: if ((h.get("id").equals(outputwpd.getId()))) {
0886: b = true;
0887: hm2 = h;
0888: break;
0889: }
0890: i++;
0891: }
0892:
0893: if (!b) {
0894: hm.put("id", outputwpd.getId());
0895: hm.put("isOutput", true);
0896: String s = outputwpd.getActivityExitState();
0897: if (s.equals("")) {
0898: s = "Aucun";
0899: }
0900: hm.put("desiredOutputState", s);
0901: hm.put("isOptionalInput", false);
0902: hm.put("isMandatoryInput", false);
0903: hm.put("concretename", outputwpd
0904: .getPresentationName());
0905: if (_considerState) {
0906: // checking if there is at least one concrete created
0907: // for
0908: // outputwpd and if all concrete mandatories of
0909: // outputwpd
0910: // are in the good
0911: // state in order to know if we can start the task
0912: /*
0913: * boolean bool = ((this
0914: * .checkOutputWorkProductState(_concreteTaskDescriptor)) &&
0915: * (outputwpd
0916: * .getConcreteWorkProductDescriptors().size() > 0));
0917: */
0918:
0919: boolean bool = ((this
0920: .checkOutputWorkProductState(_concreteTaskDescriptor)) && (this
0921: .atLeastOneConcreteForAOutputWorkProductOfATask(
0922: _concreteTaskDescriptor,
0923: outputwpd)));
0924:
0925: if (bool) {
0926: hm.put("readyOutput", CHECKED);
0927: } else {
0928: hm.put("readyOutput", UNCHECKED);
0929: }
0930: } else {
0931: // checking if there is at least one concrete created
0932: // for
0933: // outputwpd in order to know if we can start the task
0934: if (this
0935: .atLeastOneConcreteForAOutputWorkProductOfATask(
0936: _concreteTaskDescriptor,
0937: outputwpd)) {
0938: hm.put("readyOutput", CHECKED);
0939: }
0940: }
0941: _workProducts.add(hm);
0942: } else {
0943: _workProducts.remove(_workProducts.get(i));
0944: hm2.remove("isOutput");
0945: hm2.put("isOutput", true);
0946: String s = outputwpd.getActivityExitState();
0947: if (s.equals("")) {
0948: s = "Aucun";
0949: }
0950: hm2.put("desiredOutputState", s);
0951: if (_considerState) {
0952: // checking if there is at least one concrete created
0953: // for
0954: // outputwpd and if all concrete mandatories of
0955: // outputwpd
0956: // are in the good
0957: // state in order to know if we can start the task
0958: /*
0959: * boolean bool = ((this
0960: * .checkOutputWorkProductState(_concreteTaskDescriptor)) &&
0961: * (outputwpd
0962: * .getConcreteWorkProductDescriptors().size() > 0));
0963: */
0964:
0965: boolean bool = ((this
0966: .checkOutputWorkProductState(_concreteTaskDescriptor)) && (this
0967: .atLeastOneConcreteForAOutputWorkProductOfATask(
0968: _concreteTaskDescriptor,
0969: outputwpd)));
0970:
0971: if (bool) {
0972: hm2.put("readyOutput", CHECKED);
0973: } else {
0974: hm2.put("readyOutput", UNCHECKED);
0975: }
0976: } else {
0977: // checking if there is at least one concrete created
0978: // for
0979: // outputwpd in order to know if we can start the task
0980: if (this
0981: .atLeastOneConcreteForAOutputWorkProductOfATask(
0982: _concreteTaskDescriptor,
0983: outputwpd)) {
0984: hm2.put("readyOutput", CHECKED);
0985: }
0986: }
0987: _workProducts.add(hm2);
0988: }
0989: }
0990: }
0991:
0992: for (WorkProductDescriptor optionalinputwpd : this .taskDescriptorService
0993: .getOptionalInputWorkProducts(_td)) {
0994: HashMap<String, Object> hm = new HashMap<String, Object>();
0995: hm.put("checked", CHECKED);
0996:
0997: if (_workProducts.size() == 0) {
0998: hm.put("id", optionalinputwpd.getId());
0999: hm.put("isOutput", true);
1000: hm.put("isOptionalInput", false);
1001: hm.put("isMandatoryInput", false);
1002: hm.put("concretename", optionalinputwpd
1003: .getPresentationName());
1004: _workProducts.add(hm);
1005: } else {
1006: // checking if the product "optionalinputwpd" is not already in
1007: // the
1008: // list
1009: boolean b = false;
1010: // the variable "i" is use in order to know the position of the
1011: // object to remove in the list
1012: int i = 0;
1013: HashMap<String, Object> hm2 = new HashMap<String, Object>();
1014: for (HashMap<String, Object> h : _workProducts) {
1015: if ((h.get("id").equals(optionalinputwpd.getId()))) {
1016: b = true;
1017: hm2 = h;
1018: break;
1019: }
1020: i++;
1021: }
1022:
1023: if (!b) {
1024: hm.put("id", optionalinputwpd.getId());
1025: hm.put("isOutput", false);
1026: hm.put("isOptionalInput", true);
1027: hm.put("isMandatoryInput", false);
1028: hm.put("concretename", optionalinputwpd
1029: .getPresentationName());
1030: _workProducts.add(hm);
1031: } else {
1032: _workProducts.remove(_workProducts.get(i));
1033: hm2.remove("isOptionalInput");
1034: hm2.put("isOptionalInput", true);
1035: _workProducts.add(hm2);
1036:
1037: }
1038: }
1039: }
1040:
1041: for (WorkProductDescriptor mandatoryinputwpd : this .taskDescriptorService
1042: .getMandatoryInputWorkProducts(_td)) {
1043: HashMap<String, Object> hm = new HashMap<String, Object>();
1044: hm.put("readyManda", UNCHECKED);
1045: hm.put("readyOutput", UNCHECKED);
1046: hm.put("checked", CHECKED);
1047:
1048: if (_workProducts.size() == 0) {
1049: hm.put("id", mandatoryinputwpd.getId());
1050: hm.put("isOutput", false);
1051: hm.put("isOptionalInput", false);
1052: hm.put("isMandatoryInput", true);
1053: String s = mandatoryinputwpd.getActivityEntryState();
1054: if (s.equals("")) {
1055: s = "Aucun";
1056: }
1057: hm.put("desiredMandaState", s);
1058: hm.put("concretename", mandatoryinputwpd
1059: .getPresentationName());
1060: if (_considerState) {
1061: // checking if there is at least one concrete created
1062: // for
1063: // mandatoryinputwpd and if all concrete mandatories of
1064: // mandatoryinputwpd
1065: // are in the good
1066: // state in order to know if we can start the task
1067: /*
1068: * boolean bool = ((this
1069: * .checkMandatoryWorkProductState(mandatoryinputwpd
1070: * .getConcreteWorkProductDescriptors())) &&
1071: * (mandatoryinputwpd
1072: * .getConcreteWorkProductDescriptors().size() > 0));
1073: */
1074:
1075: boolean bool = ((this
1076: .checkMandatoryWorkProductState(_concreteTaskDescriptor)) && (this
1077: .atLeastOneConcreteForAMandatoryInputWorkProductOfATask(
1078: _concreteTaskDescriptor,
1079: mandatoryinputwpd)));
1080:
1081: if (bool) {
1082: hm.put("readyManda", CHECKED);
1083: } else {
1084: hm.put("readyManda", UNCHECKED);
1085: }
1086: } else {
1087: // checking if there is at least one concrete created
1088: // for
1089: // mandatoryinputwpd in order to know if we can start the
1090: // task
1091: if (this
1092: .atLeastOneConcreteForAMandatoryInputWorkProductOfATask(
1093: _concreteTaskDescriptor,
1094: mandatoryinputwpd)) {
1095: hm.put("readyManda", CHECKED);
1096: }
1097: }
1098: _workProducts.add(hm);
1099:
1100: } else {
1101: // checking if the product "mandatoryinputwpd" is not already in
1102: // the
1103: // list
1104:
1105: boolean b = false;
1106: // the variable "i" is use in order to know the position of the
1107: // object to remove in the list
1108: int i = 0;
1109: HashMap<String, Object> hm2 = new HashMap<String, Object>();
1110:
1111: for (HashMap<String, Object> h : _workProducts) {
1112: if ((h.get("id").equals(mandatoryinputwpd.getId()))) {
1113: b = true;
1114: hm2 = h;
1115: break;
1116: }
1117: i++;
1118:
1119: }
1120:
1121: if (!b) {
1122: hm.put("id", mandatoryinputwpd.getId());
1123: hm.put("isOutput", false);
1124: hm.put("isOptionalInput", false);
1125: hm.put("isMandatoryInput", true);
1126: String s = mandatoryinputwpd
1127: .getActivityEntryState();
1128: if (s.equals("")) {
1129: s = "Aucun";
1130: }
1131: hm.put("desiredMandaState", s);
1132: hm.put("concretename", mandatoryinputwpd
1133: .getPresentationName());
1134:
1135: if (_considerState) {
1136: // checking if there is at least one concrete created
1137: // for
1138: // mandatoryinputwpd and if all concrete mandatories of
1139: // mandatoryinputwpd
1140: // are in the good
1141: // state in order to know if we can start the task
1142: /*
1143: * boolean bool = ((this
1144: * .checkMandatoryWorkProductState(mandatoryinputwpd
1145: * .getConcreteWorkProductDescriptors())) &&
1146: * (mandatoryinputwpd
1147: * .getConcreteWorkProductDescriptors().size() > 0));
1148: */
1149:
1150: boolean bool = ((this
1151: .checkMandatoryWorkProductState(_concreteTaskDescriptor)) && (this
1152: .atLeastOneConcreteForAMandatoryInputWorkProductOfATask(
1153: _concreteTaskDescriptor,
1154: mandatoryinputwpd)));
1155:
1156: if (bool) {
1157: hm.put("readyManda", CHECKED);
1158: } else {
1159: hm.put("readyManda", UNCHECKED);
1160: }
1161: } else {
1162: // checking if there is at least one concrete created
1163: // for
1164: // mandatoryinputwpd in order to know if we can start
1165: // the task
1166: if (this
1167: .atLeastOneConcreteForAMandatoryInputWorkProductOfATask(
1168: _concreteTaskDescriptor,
1169: mandatoryinputwpd)) {
1170: hm.put("readyManda", CHECKED);
1171: }
1172: }
1173: _workProducts.add(hm);
1174:
1175: } else {
1176: _workProducts.remove(_workProducts.get(i));
1177: hm2.remove("isMandatoryInput");
1178: hm2.put("isMandatoryInput", true);
1179: String s = mandatoryinputwpd
1180: .getActivityEntryState();
1181: if (s.equals("")) {
1182: s = "Aucun";
1183: }
1184: hm2.put("desiredMandaState", s);
1185: if (_considerState) {
1186: // checking if there is at least one concrete created
1187: // for
1188: // mandatoryinputwpd and if all concrete mandatories of
1189: // mandatoryinputwpd
1190: // are in the good
1191: // state in order to know if we can start the task
1192: /*
1193: * boolean bool = ((this
1194: * .checkMandatoryWorkProductState(mandatoryinputwpd
1195: * .getConcreteWorkProductDescriptors())) &&
1196: * (mandatoryinputwpd
1197: * .getConcreteWorkProductDescriptors().size() > 0));
1198: */
1199:
1200: boolean bool = ((this
1201: .checkMandatoryWorkProductState(_concreteTaskDescriptor)) && (this
1202: .atLeastOneConcreteForAMandatoryInputWorkProductOfATask(
1203: _concreteTaskDescriptor,
1204: mandatoryinputwpd)));
1205:
1206: if (bool) {
1207: hm2.put("readyManda", CHECKED);
1208: } else {
1209: hm2.put("readyManda", UNCHECKED);
1210: }
1211:
1212: } else {
1213: // checking if there is at least one concrete created
1214: // for
1215: // mandatoryinputwpd in order to know if we can start
1216: // the task
1217: if (this
1218: .atLeastOneConcreteForAMandatoryInputWorkProductOfATask(
1219: _concreteTaskDescriptor,
1220: mandatoryinputwpd)) {
1221: hm2.put("readyManda", CHECKED);
1222: }
1223: }
1224: _workProducts.add(hm2);
1225: }
1226:
1227: // _workProducts.addAll(tmpWorkProducts);
1228: }
1229: }
1230: return _workProducts;
1231: }
1232:
1233: /**
1234: * Allows to check the mandatory state of a workProduct for a
1235: * concreteTaskDescriptor
1236: *
1237: * @param _concreteWorkProductDescriptors
1238: * @return true if it's right, false in the other case
1239: *
1240: */
1241: public boolean checkMandatoryWorkProductState(
1242: ConcreteTaskDescriptor _concreteTaskDescriptor) {
1243: this .concreteTaskDescriptorDao.getSessionFactory()
1244: .getCurrentSession().saveOrUpdate(
1245: _concreteTaskDescriptor);
1246: Set<ConcreteWorkProductDescriptor> _concreteWorkProductDescriptors = _concreteTaskDescriptor
1247: .getMandatoryInputConcreteWorkProductDescriptors();
1248: boolean goodEntryState = true;
1249: for (ConcreteWorkProductDescriptor cwpd : _concreteWorkProductDescriptors) {
1250: String cwpdState = cwpd.getState();
1251: String cwpdAcitvityEntryState = cwpd
1252: .getWorkProductDescriptor().getActivityEntryState();
1253: if (!(cwpdAcitvityEntryState.equals("") || cwpdState
1254: .equals(cwpdAcitvityEntryState))) {
1255: goodEntryState = false;
1256: }
1257: }
1258:
1259: return goodEntryState;
1260: }
1261:
1262: /**
1263: * Allows to check the output workProduct state
1264: *
1265: * @param _concreteWorkProductDescriptors
1266: * @return true if it's right, false in the other case
1267: *
1268: */
1269: public boolean checkOutputWorkProductState(
1270: ConcreteTaskDescriptor _concreteTaskDescriptor) {
1271: this .concreteTaskDescriptorDao.getSessionFactory()
1272: .getCurrentSession().saveOrUpdate(
1273: _concreteTaskDescriptor);
1274: Set<ConcreteWorkProductDescriptor> cwpds = _concreteTaskDescriptor
1275: .getOutputConcreteWorkProductDescriptors();
1276: boolean goodExitState = true;
1277: for (ConcreteWorkProductDescriptor cwpd : cwpds) {
1278: String cwpdState = cwpd.getState();
1279: String cwpdActivityExitState = cwpd
1280: .getWorkProductDescriptor().getActivityExitState();
1281: if (!(cwpdActivityExitState.equals("") || cwpdState
1282: .equals(cwpdActivityExitState))) {
1283: goodExitState = false;
1284: }
1285: }
1286:
1287: return goodExitState;
1288: }
1289:
1290: /**
1291: * Allows to reload a conreteTaskDescriptor
1292: *
1293: * @param _ctd
1294: * @return the new hashMap
1295: */
1296: public HashMap<String, Object> reloadCtd(ConcreteTaskDescriptor _ctd) {
1297: HashMap<String, Object> hashmap = new HashMap<String, Object>();
1298:
1299: this .saveConcreteTaskDescriptor(_ctd);
1300: hashmap.put("Finishing", _ctd.getRealFinishingDate());
1301: hashmap.put("Starting", _ctd.getRealStartingDate());
1302: return hashmap;
1303: }
1304:
1305: /**
1306: * Allows to check if there is at least one concreteTaskDescriptor for an
1307: * input workProductDescriptors of a task
1308: *
1309: * @param _concreteTaskDescriptor
1310: * @return true if there is at least one concrete, false in the other case
1311: */
1312: public boolean atLeastOneConcreteForAMandatoryInputWorkProductOfATask(
1313: ConcreteTaskDescriptor _concreteTaskDescriptor,
1314: WorkProductDescriptor _workProductDescriptor) {
1315: this .concreteTaskDescriptorDao.getSessionFactory()
1316: .getCurrentSession().saveOrUpdate(
1317: _concreteTaskDescriptor);
1318: this .workProductDescriptorDao.getSessionFactory()
1319: .getCurrentSession().saveOrUpdate(
1320: _workProductDescriptor);
1321:
1322: boolean b = false;
1323: Set<ConcreteWorkProductDescriptor> cwpds = _workProductDescriptor
1324: .getConcreteWorkProductDescriptors();
1325: for (ConcreteWorkProductDescriptor cwpd : cwpds) {
1326: for (ConcreteTaskDescriptor ctd : cwpd
1327: .getMandatoryUserConcreteTasks()) {
1328: if (ctd.getId().equals(_concreteTaskDescriptor.getId())) {
1329: b = true;
1330: }
1331: }
1332: }
1333: return b;
1334: }
1335:
1336: /**
1337: * Allows to check if there is at least one concreteTaskDescriptor for an
1338: * output workProductDescriptors of a task
1339: *
1340: * @param _concreteTaskDescriptor
1341: * @return true if there is at least one concrete, false in the other case
1342: */
1343: public boolean atLeastOneConcreteForAOutputWorkProductOfATask(
1344: ConcreteTaskDescriptor _concreteTaskDescriptor,
1345: WorkProductDescriptor _workProductDescriptor) {
1346: this .concreteTaskDescriptorDao.getSessionFactory()
1347: .getCurrentSession().saveOrUpdate(
1348: _concreteTaskDescriptor);
1349: this .workProductDescriptorDao.getSessionFactory()
1350: .getCurrentSession().saveOrUpdate(
1351: _workProductDescriptor);
1352: boolean b = false;
1353: Set<ConcreteWorkProductDescriptor> cwpds = _workProductDescriptor
1354: .getConcreteWorkProductDescriptors();
1355: for (ConcreteWorkProductDescriptor cwpd : cwpds) {
1356: for (ConcreteTaskDescriptor ctd : cwpd
1357: .getProducerConcreteTasks()) {
1358: if (ctd.getId().equals(_concreteTaskDescriptor.getId())) {
1359: b = true;
1360: }
1361: }
1362: }
1363: return b;
1364: }
1365:
1366: /**
1367: * Allows to get the workProductDescriptorDao
1368: *
1369: * @return the workProductDescriptorDao
1370: */
1371: public WorkProductDescriptorDao getWorkProductDescriptorDao() {
1372: return this .workProductDescriptorDao;
1373: }
1374:
1375: /**
1376: * Allows to set the workProductDescriptorDao
1377: *
1378: * @param _workProductDescriptorDao
1379: */
1380: public void setWorkProductDescriptorDao(
1381: WorkProductDescriptorDao _workProductDescriptorDao) {
1382: this.workProductDescriptorDao = _workProductDescriptorDao;
1383: }
1384: }
|