Source Code Cross Referenced for ProjectAdvancementWorkProductBean.java in  » Workflow-Engines » wilos » wilos » presentation » web » project » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » wilos » wilos.presentation.web.project 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         *
0005:         * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
0006:         * General Public License as published by the Free Software Foundation; either version 2 of the License,
0007:         * or (at your option) any later version.
0008:         *
0009:         * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
0010:         * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0011:         * GNU General Public License for more details.
0012:         *
0013:         * You should have received a copy of the GNU General Public License along with this program; if not,
0014:         * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 
0015:         */
0016:
0017:        package wilos.presentation.web.project;
0018:
0019:        import java.util.ArrayList;
0020:        import java.util.Date;
0021:        import java.util.HashMap;
0022:        import java.util.Iterator;
0023:        import java.util.List;
0024:        import java.util.Map;
0025:        import java.util.ResourceBundle;
0026:        import java.util.SortedSet;
0027:
0028:        import javax.faces.context.FacesContext;
0029:        import javax.faces.event.ActionEvent;
0030:        import javax.faces.event.ValueChangeEvent;
0031:        import javax.faces.model.SelectItem;
0032:
0033:        import org.apache.commons.logging.Log;
0034:        import org.apache.commons.logging.LogFactory;
0035:
0036:        import wilos.business.services.misc.concreteactivity.ConcreteActivityService;
0037:        import wilos.business.services.misc.concretebreakdownelement.ConcreteBreakdownElementService;
0038:        import wilos.business.services.misc.concreterole.ConcreteRoleDescriptorService;
0039:        import wilos.business.services.misc.concretetask.ConcreteTaskDescriptorService;
0040:        import wilos.business.services.misc.concreteworkproduct.ConcreteWorkProductDescriptorService;
0041:        import wilos.business.services.misc.project.ProjectService;
0042:        import wilos.business.services.misc.wilosuser.ParticipantService;
0043:        import wilos.business.services.spem2.role.RoleDescriptorService;
0044:        import wilos.business.services.spem2.task.TaskDescriptorService;
0045:        import wilos.business.services.spem2.workproduct.WorkProductDescriptorService;
0046:        import wilos.model.misc.concreteactivity.ConcreteActivity;
0047:        import wilos.model.misc.concretebreakdownelement.ConcreteBreakdownElement;
0048:        import wilos.model.misc.concretemilestone.ConcreteMilestone;
0049:        import wilos.model.misc.concreterole.ConcreteRoleDescriptor;
0050:        import wilos.model.misc.concretetask.ConcreteTaskDescriptor;
0051:        import wilos.model.misc.concreteworkbreakdownelement.ConcreteWorkBreakdownElement;
0052:        import wilos.model.misc.concreteworkproduct.ConcreteWorkProductDescriptor;
0053:        import wilos.model.misc.project.Project;
0054:        import wilos.model.misc.wilosuser.Participant;
0055:        import wilos.model.spem2.role.RoleDescriptor;
0056:        import wilos.model.spem2.task.TaskDescriptor;
0057:        import wilos.model.spem2.workproduct.WorkProductDescriptor;
0058:        import wilos.presentation.web.tree.TreeBean;
0059:        import wilos.presentation.web.utils.WebCommonService;
0060:        import wilos.presentation.web.utils.WebSessionService;
0061:        import wilos.resources.WilosBundle;
0062:
0063:        public class ProjectAdvancementWorkProductBean {
0064:
0065:            public static final String EXPAND_TABLE_ARROW = "images/expandableTable/expand.gif";
0066:
0067:            public static final String CONTRACT_TABLE_ARROW = "images/expandableTable/contract.gif";
0068:
0069:            public static final String TABLE_LEAF = "images/expandableTable/leaf.gif";
0070:
0071:            public static final String INDENTATION_STRING = "- - - ";
0072:
0073:            private ProjectService projectService;
0074:
0075:            private ConcreteActivityService concreteActivityService;
0076:
0077:            private ParticipantService participantService;
0078:
0079:            private Project project;
0080:
0081:            private String projectViewedId;
0082:
0083:            private ArrayList<HashMap<String, Object>> displayContent;
0084:
0085:            private HashMap<String, String> indentationContent;
0086:
0087:            private boolean needIndentation = false;
0088:
0089:            protected HashMap<String, Boolean> isExpanded = new HashMap<String, Boolean>();
0090:
0091:            private boolean selectedProjectAdvancementView;
0092:
0093:            private boolean projectModified;
0094:
0095:            private String projectInstanciated;
0096:
0097:            protected final Log logger = LogFactory.getLog(this .getClass());
0098:
0099:            private int pos = 0;
0100:
0101:            private ConcreteTaskDescriptorService concreteTaskDescriptor;
0102:
0103:            private ConcreteBreakdownElementService concreteBreakdownElementService;
0104:
0105:            private ConcreteWorkProductDescriptorService concreteWorkProductDescriptorService;
0106:
0107:            private WorkProductDescriptorService workProductDescriptorService;
0108:
0109:            public static final String MY_WP_MODE = "myWorkProductMode";
0110:
0111:            public static final String ALL_WP_MODE = "allWorkProductMode";
0112:
0113:            private String selectedMode = ALL_WP_MODE;
0114:
0115:            /**
0116:             * Constructor.
0117:             * 
0118:             */
0119:            public ProjectAdvancementWorkProductBean() {
0120:                this .project = new Project();
0121:                this .displayContent = new ArrayList<HashMap<String, Object>>();
0122:                this .indentationContent = new HashMap<String, String>();
0123:            }
0124:
0125:            /**
0126:             * Getter of concreteBreakdownElementService.
0127:             * 
0128:             * @return the concreteBreakdownElementService.
0129:             */
0130:            public ConcreteBreakdownElementService getConcreteBreakdownElementService() {
0131:                return concreteBreakdownElementService;
0132:            }
0133:
0134:            /**
0135:             * Setter of concreteBreakdownElementService.
0136:             * 
0137:             * @param the
0138:             *                concreteBreakdownElementService.
0139:             */
0140:            public void setConcreteBreakdownElementService(
0141:                    ConcreteBreakdownElementService _concreteBreakdownElementService) {
0142:                concreteBreakdownElementService = _concreteBreakdownElementService;
0143:            }
0144:
0145:            /**
0146:             * Getter of concreteTaskDescriptor.
0147:             * 
0148:             * @return the concreteTaskDescriptor.
0149:             */
0150:            public ConcreteTaskDescriptorService getConcreteTaskDescriptor() {
0151:                return concreteTaskDescriptor;
0152:            }
0153:
0154:            /**
0155:             * Setter of concreteTaskDescriptor.
0156:             * 
0157:             * @param the
0158:             *                concreteTaskDescriptor.
0159:             */
0160:            public void setConcreteTaskDescriptor(
0161:                    ConcreteTaskDescriptorService _concreteTaskDescriptor) {
0162:                concreteTaskDescriptor = _concreteTaskDescriptor;
0163:            }
0164:
0165:            /**
0166:             * Getter of displayContent.
0167:             * 
0168:             * @return the displayContent.
0169:             */
0170:            public ArrayList<HashMap<String, Object>> getDisplayContent() {
0171:                String projectId = (String) WebSessionService
0172:                        .getAttribute(WebSessionService.PROJECT_ID);
0173:
0174:                if (projectId != null) {
0175:                    this .project = this .projectService.getProject(projectId);
0176:                    this .pos = 0;
0177:                    // if the project is another then the last selected or if it has
0178:                    // been
0179:                    // modified
0180:                    if (this .projectViewedId == null
0181:                            || !(this .projectViewedId.equals(projectId))
0182:                            || this .projectModified) {
0183:                        // reseting the table parameters
0184:                        projectViewedId = projectId;
0185:                        this .displayContent.clear();
0186:                        this .indentationContent.clear();
0187:                        this .isExpanded.clear();
0188:                        this .needIndentation = false;
0189:                        if (this .retrieveHierarchicalItems(this .project) != null) {
0190:                            this .displayContent.addAll(this 
0191:                                    .retrieveHierarchicalItems(this .project));
0192:                        } else {
0193:                            this .displayContent.clear();
0194:                        }
0195:                    }
0196:                } else
0197:                    this .displayContent.clear();
0198:                this .projectModified = false;
0199:                return this .displayContent;
0200:            }
0201:
0202:            /**
0203:             * put the attribut project modified to true which force the project table
0204:             * to be recalculated
0205:             * 
0206:             */
0207:            public void refreshProjectTable() {
0208:                this .projectModified = true;
0209:            }
0210:
0211:            /**
0212:             * Toggles the expanded state of this ConcreteBreakDownElement.
0213:             * 
0214:             * @param event
0215:             */
0216:            public void toggleSubGroupAction(ActionEvent event) {
0217:                FacesContext context = FacesContext.getCurrentInstance();
0218:                Map map = context.getExternalContext().getRequestParameterMap();
0219:                String elementId = (String) map.get("elementId");
0220:
0221:                // toggle expanded state
0222:                Boolean b = isExpanded.get(elementId);
0223:                if (b == null) {
0224:                    isExpanded.put(elementId, false);
0225:                    b = isExpanded.get(elementId);
0226:                }
0227:                b = !b;
0228:                isExpanded.put(elementId, b);
0229:
0230:                // add sub elements to list
0231:                if (b) {
0232:                    expandNodeAction();
0233:                }
0234:                // remove items from list
0235:                else {
0236:                    contractNodeAction();
0237:                }
0238:            }
0239:
0240:            /**
0241:             * Utility method to add all child nodes to the parent dataTable list.
0242:             */
0243:            @SuppressWarnings("unchecked")
0244:            private void expandNodeAction() {
0245:                FacesContext context = FacesContext.getCurrentInstance();
0246:                Map map = context.getExternalContext().getRequestParameterMap();
0247:                String elementId = (String) map.get("elementId");
0248:
0249:                // the table will be expanded so, indentation string
0250:                this .needIndentation = true;
0251:
0252:                ArrayList<Object> tmp = new ArrayList<Object>();
0253:                tmp.addAll(this .displayContent);
0254:                int index;
0255:
0256:                for (Iterator iter = tmp.iterator(); iter.hasNext();) {
0257:                    HashMap<String, Object> hm = new HashMap<String, Object>();
0258:                    hm = (HashMap<String, Object>) iter.next();
0259:
0260:                    if (hm.get("id").equals(elementId)) {
0261:                        if (hm.get("nodeType").equals("node")) {
0262:                            hm.put("expansionImage", EXPAND_TABLE_ARROW);
0263:                            ConcreteActivity ca = this .concreteActivityService
0264:                                    .getConcreteActivity((String) hm.get("id"));
0265:                            index = this .displayContent.indexOf(hm);
0266:                            this .displayContent.addAll(index + 1, this 
0267:                                    .retrieveHierarchicalItems(ca));
0268:                            return;
0269:                        }
0270:                    }
0271:                }
0272:            }
0273:
0274:            /**
0275:             * Utility method to remove all child nodes from the parent dataTable list.
0276:             */
0277:            private void contractNodeAction() {
0278:                FacesContext context = FacesContext.getCurrentInstance();
0279:                Map map = context.getExternalContext().getRequestParameterMap();
0280:                String elementId = (String) map.get("elementId");
0281:
0282:                ArrayList<HashMap<String, Object>> parentList = new ArrayList<HashMap<String, Object>>();
0283:                parentList.addAll(this .displayContent);
0284:
0285:                /* Removes element which we want to contract from the parent list */
0286:                for (HashMap<String, Object> currentElement : this .displayContent) {
0287:
0288:                    if (currentElement.get("id").equals(elementId)
0289:                            && currentElement.get("nodeType").equals("node")) {
0290:                        currentElement.put("expansionImage",
0291:                                ProjectAdvancementBean.CONTRACT_TABLE_ARROW);
0292:                        parentList.remove(currentElement);
0293:                    }
0294:                }
0295:                this .deleteChildren(elementId, parentList);
0296:            }
0297:
0298:            /**
0299:             * Hides children for a specific row of the expandable table Used to
0300:             * simulate contraction behaviour
0301:             * 
0302:             * @param _parentId
0303:             *                identifier of current row
0304:             * @param parentList
0305:             *                parent children
0306:             */
0307:            public void deleteChildren(String _parentId,
0308:                    ArrayList<HashMap<String, Object>> parentList) {
0309:                for (HashMap<String, Object> child : parentList) {
0310:                    if (child.get("parentId").equals(_parentId)) {
0311:                        this .displayContent.remove(child);
0312:                        deleteChildren((String) child.get("id"), parentList);
0313:                    }
0314:                    if (child.get("id").equals(_parentId)) {
0315:                        child.put("expansionImage",
0316:                                ProjectAdvancementBean.CONTRACT_TABLE_ARROW);
0317:                        this .isExpanded.put((String) child.get("id"), false);
0318:                    }
0319:                }
0320:            }
0321:
0322:            /**
0323:             * Recursive method returning a hashmap data model which contains the
0324:             * elements required to display the project advancement table Give a
0325:             * ConcreteActivity to this method, return its firs hierarchical childs
0326:             * described into the hashmap
0327:             * 
0328:             */
0329:            private List<HashMap<String, Object>> retrieveHierarchicalItems(
0330:                    ConcreteActivity _concreteActivity) {
0331:                Double currentAdvancedTime;
0332:                String indentationString = "";
0333:                String affected = "";
0334:                boolean b = false;
0335:                boolean screen = false;
0336:
0337:                List<HashMap<String, Object>> subConcretesContent = new ArrayList<HashMap<String, Object>>();
0338:                ResourceBundle bundle = ResourceBundle.getBundle(
0339:                        "wilos.resources.messages", FacesContext
0340:                                .getCurrentInstance().getApplication()
0341:                                .getDefaultLocale());
0342:                String projectID = (String) WebSessionService
0343:                        .getAttribute(WebSessionService.PROJECT_ID);
0344:                String userId = (String) WebSessionService
0345:                        .getAttribute(WebSessionService.WILOS_USER_ID);
0346:                Participant parti = this .getParticipantService()
0347:                        .getParticipant(userId);
0348:                // for every child of the activity
0349:
0350:                if (_concreteActivity == null) {
0351:                    return null;
0352:                }
0353:                SortedSet<ConcreteBreakdownElement> concreteBDE = this .concreteActivityService
0354:                        .getConcreteBreakdownElements(_concreteActivity);
0355:
0356:                for (ConcreteBreakdownElement concreteBreakdownElement : concreteBDE) {
0357:                    HashMap<String, Object> hm = new HashMap<String, Object>();
0358:
0359:                    screen = false;
0360:                    if (!(concreteBreakdownElement instanceof  ConcreteMilestone)
0361:                            && !(concreteBreakdownElement instanceof  ConcreteRoleDescriptor)
0362:                            && !(concreteBreakdownElement instanceof  ConcreteTaskDescriptor)) {
0363:
0364:                        if (concreteBreakdownElement instanceof  ConcreteWorkProductDescriptor) {// workProduct
0365:                            // !!!!!
0366:
0367:                            ConcreteWorkProductDescriptor cwpd = (ConcreteWorkProductDescriptor) concreteBreakdownElement;
0368:                            Participant responsible = this .concreteWorkProductDescriptorService
0369:                                    .getParticipant(cwpd);
0370:
0371:                            if (responsible != null) {
0372:                                hm.put("isAffected", true);
0373:                                if (this .getSelectedMode().equals(ALL_WP_MODE)
0374:                                        || (this .getSelectedMode().equals(
0375:                                                MY_WP_MODE) && (responsible
0376:                                                .getId().equals(parti.getId())))) {
0377:
0378:                                    screen = true;
0379:                                    // the workproduct is affected
0380:                                    String responsibleID = responsible.getId();
0381:
0382:                                    hm.put("responsible",
0383:                                            this .participantService
0384:                                                    .getParticipant(
0385:                                                            responsibleID)
0386:                                                    .getName());
0387:
0388:                                    // hm.put("workProductName",
0389:                                    // cwpd.getConcreteName());
0390:                                    hm.put("workProductID", cwpd.getId());
0391:                                    WorkProductDescriptor work = this .concreteWorkProductDescriptorService
0392:                                            .getWorkProductDescriptor(cwpd);
0393:
0394:                                    String requiredRole = this .workProductDescriptorService
0395:                                            .getNameRequiredRoleWorkProductDescriptor(work);
0396:                                    if (requiredRole != null) {
0397:                                        hm.put("requiredRole", requiredRole);
0398:                                    } else {
0399:                                        hm
0400:                                                .put(
0401:                                                        "requiredRole",
0402:                                                        WilosBundle
0403:                                                                .getText("tabAffectWorkProduct.noRequieredRole"));
0404:                                    }
0405:
0406:                                    if (responsibleID.equals(parti.getId())) {
0407:                                        // workproduct is affected to the current
0408:                                        // participant
0409:
0410:                                        hm.put("enabled", false);
0411:                                    } else {
0412:                                        // the workproduct is affected to an another
0413:                                        // participant
0414:                                        hm.put("enabled", true);
0415:
0416:                                    }
0417:                                    hm.put("visibleCheckbox", true);
0418:                                    hm.put("nodeType", "leaf");
0419:                                    hm.put("expansionImage", TABLE_LEAF);
0420:
0421:                                }
0422:                            } else if (this .getSelectedMode().equals(
0423:                                    ALL_WP_MODE)
0424:                                    && responsible == null) {
0425:
0426:                                screen = true;
0427:                                // the workproduct is not affected
0428:                                hm
0429:                                        .put(
0430:                                                "responsible",
0431:                                                WilosBundle
0432:                                                        .getText("tabAffectWorkProduct.noResponsible"));
0433:
0434:                                hm.put("workProductID", cwpd.getId());
0435:                                WorkProductDescriptor work = this .concreteWorkProductDescriptorService
0436:                                        .getWorkProductDescriptor(cwpd);
0437:
0438:                                String requiredRole = this .workProductDescriptorService
0439:                                        .getNameRequiredRoleWorkProductDescriptor(work);
0440:                                if (requiredRole != null) {
0441:                                    hm.put("requiredRole", requiredRole);
0442:
0443:                                    // verify if the current participant have the
0444:                                    // required role
0445:                                    RoleDescriptor rd = this .workProductDescriptorService
0446:                                            .getRequiredRoleWorkProductDescriptor(work);
0447:
0448:                                    if (this .participantHaveRole(parti,
0449:                                            projectID, rd)) {// the
0450:                                        // participant
0451:                                        // have
0452:                                        // the
0453:                                        // required
0454:                                        // role
0455:                                        hm.put("enabled", false);
0456:                                    } else {// the participant haven't the required role
0457:                                        hm.put("enabled", true);
0458:                                    }
0459:                                } else {
0460:                                    hm
0461:                                            .put(
0462:                                                    "requiredRole",
0463:                                                    WilosBundle
0464:                                                            .getText("tabAffectWorkProduct.noRequieredRole"));
0465:                                    hm.put("enabled", false);
0466:                                }
0467:
0468:                                hm.put("visibleCheckbox", true);
0469:
0470:                                hm.put("nodeType", "leaf");
0471:                                hm.put("expansionImage", TABLE_LEAF);
0472:                                hm.put("isAffected", false);
0473:                            } else {
0474:                                hm.put("isAffected", false);
0475:                            }
0476:
0477:                        }
0478:                        // if this is not a task -> display a leaf
0479:                        else {
0480:                            screen = true;
0481:                            hm.put("visibleCheckbox", false);
0482:                            hm.put("nodeType", "node");
0483:                            hm.put("expansionImage", CONTRACT_TABLE_ARROW);
0484:                        }
0485:
0486:                        hm.put("id", concreteBreakdownElement.getId());
0487:
0488:                        hm.put("concreteName", concreteBreakdownElement
0489:                                .getConcreteName());
0490:
0491:                        hm.put("parentId", _concreteActivity.getId());
0492:
0493:                        // if this is not the root node -> needIndentation == true
0494:                        if (needIndentation) {
0495:                            if (this .indentationContent.get(_concreteActivity
0496:                                    .getId()) != null) {
0497:                                indentationString = this .indentationContent
0498:                                        .get(_concreteActivity.getId());
0499:                            }
0500:                            this .indentationContent
0501:                                    .put(
0502:                                            (String) hm.get("id"),
0503:                                            indentationString
0504:                                                    .concat(ProjectAdvancementBean.INDENTATION_STRING));
0505:                        }
0506:                        if (screen) {
0507:                            subConcretesContent.add(hm);
0508:                        }
0509:
0510:                        // }
0511:                    }
0512:                }
0513:                return subConcretesContent;
0514:            }
0515:
0516:            /**
0517:             * Return the advancement in percents of a Concrete breakdown element
0518:             * 
0519:             * @param cbe
0520:             * @return
0521:             */
0522:            public Double activityAdvancementCalculation(
0523:                    ConcreteBreakdownElement cbe) {
0524:                Double result = 0.0;
0525:                HashMap<String, Double> couple = this 
0526:                        .taskAdvancementCalculation(cbe);
0527:                double advancementRatio = couple.get("advancementRatio");
0528:                if (advancementRatio > 0) {
0529:                    result = advancementRatio * 100;
0530:
0531:                    if (cbe instanceof  ConcreteActivity) {
0532:                        ConcreteActivity ca = (ConcreteActivity) cbe;
0533:                        int i = 0;
0534:                        for (ConcreteBreakdownElement concreteBreakdownElement : this .concreteActivityService
0535:                                .getConcreteBreakdownElements(ca)) {
0536:                            if (concreteBreakdownElement instanceof  ConcreteTaskDescriptor) {
0537:                                i++;
0538:                            }
0539:                        }
0540:                        result = result / i;
0541:                    }
0542:                } else {
0543:                    result = null;
0544:                }
0545:                return result;
0546:            }
0547:
0548:            /**
0549:             * Know if a participant have a role
0550:             * 
0551:             * @param _parti
0552:             * @param _projectId
0553:             * @param _rd
0554:             * @return
0555:             */
0556:            private boolean participantHaveRole(Participant _parti,
0557:                    String _projectId, RoleDescriptor _rd) {
0558:                for (ConcreteRoleDescriptor crd : this .participantService
0559:                        .getConcreteRoleDescriptorsForAParticipantAndForAProject(
0560:                                _parti.getId(), _projectId)) {
0561:                    if (crd.getRoleDescriptor().getName().equals(_rd.getName())) {
0562:                        return true;
0563:                    }
0564:                }
0565:                return false;
0566:            }
0567:
0568:            /**
0569:             * Save affectation of workproducts
0570:             */
0571:            public void saveAffectWorkProduct() {
0572:                boolean modif = false;
0573:                String wilosUserId = (String) WebSessionService
0574:                        .getAttribute(WebSessionService.WILOS_USER_ID);
0575:                ParticipantService pService = this .getParticipantService();
0576:                Participant parti = pService.getParticipant(wilosUserId);
0577:
0578:                ConcreteWorkProductDescriptorService cwpdService = this .concreteWorkProductDescriptorService;
0579:
0580:                for (HashMap<String, Object> ligne : this .getDisplayContent()) {
0581:
0582:                    if ((Boolean) ligne.get("visibleCheckbox")) {
0583:                        if (!(Boolean) ligne.get("enabled")) {
0584:
0585:                            /*
0586:                             * ConcreteWorkProductDescriptor cwpd =
0587:                             * (ConcreteWorkProductDescriptor) ligne
0588:                             * .get("workPProduct");
0589:                             */
0590:
0591:                            ConcreteWorkProductDescriptor cwpd = this .concreteWorkProductDescriptorService
0592:                                    .getConcreteWorkProductDescriptor(ligne
0593:                                            .get("workProductID").toString());
0594:
0595:                            cwpdService.getConcreteWorkProductDescriptorDao()
0596:                                    .saveOrUpdateConcreteWorkProductDescriptor(
0597:                                            cwpd);
0598:
0599:                            if (cwpd != null) {
0600:                                if ((Boolean) ligne.get("isAffected")) {
0601:
0602:                                    cwpdService
0603:                                            .affectedConcreteWorkProductDescriptor(
0604:                                                    cwpd, parti);
0605:
0606:                                    cwpdService
0607:                                            .saveConcreteWorkProductDescriptor(cwpd);
0608:
0609:                                    modif = true;
0610:                                } else if (!(Boolean) ligne.get("isAffected")) {
0611:
0612:                                    cwpdService
0613:                                            .dissociateConcreteWorkProductDescriptor(
0614:                                                    cwpd, parti);
0615:
0616:                                    cwpdService
0617:                                            .saveConcreteWorkProductDescriptor(cwpd);
0618:
0619:                                    modif = true;
0620:                                }
0621:                            }
0622:                        }
0623:                    }
0624:                }
0625:
0626:                if (modif) {
0627:                    WebCommonService.addInfoMessage(WilosBundle
0628:                            .getText("tabAffectWorkProduct.updateAffected"));
0629:                    TreeBean tb = (TreeBean) WebCommonService
0630:                            .getBean("TreeBean");
0631:                    tb.setSelectedMode(tb.WORKPRODUCTS_MODE);
0632:                    tb.refreshProjectTree();
0633:
0634:                }
0635:
0636:            }
0637:
0638:            /**
0639:             * Return the consomme in percents of a Concrete breakdown element
0640:             * 
0641:             * @param cbe
0642:             * @return
0643:             */
0644:            public Double activityConsommeCalculation(ConcreteTaskDescriptor ctd) {
0645:                Double result = 0.0;
0646:                double EstimateTimes = 0.0;
0647:                double accomplishedTimes = 0.0;
0648:                accomplishedTimes = ctd.getAccomplishedTime();
0649:                EstimateTimes = ctd.getPlannedTime();
0650:
0651:                if (EstimateTimes == 0.0) {
0652:                    result = 0.0;
0653:                } else {
0654:                    result = accomplishedTimes / EstimateTimes;
0655:                    result = result * 100;
0656:                }
0657:                return result;
0658:            }
0659:
0660:            /**
0661:             * Sub recursive method used for the Concrete breakdown element advancement
0662:             * calculation
0663:             * 
0664:             * @param ctd
0665:             * @return
0666:             */
0667:            private HashMap<String, Double> taskAdvancementCalculation(
0668:                    ConcreteBreakdownElement cbe) {
0669:                HashMap<String, Double> coupletmp = new HashMap<String, Double>();
0670:                HashMap<String, Double> couple = new HashMap<String, Double>();
0671:                couple.put("advancementRatio", 0.0);
0672:
0673:                // if the current element is an activity, parse the sub concrete
0674:                // breakdown elements
0675:                if (cbe instanceof  ConcreteActivity) {
0676:                    ConcreteActivity ca = (ConcreteActivity) cbe;
0677:
0678:                    for (ConcreteBreakdownElement concreteBreakdownElement : this .concreteActivityService
0679:                            .getConcreteBreakdownElements(ca)) {
0680:                        coupletmp = this 
0681:                                .taskAdvancementCalculation(concreteBreakdownElement);
0682:                        couple.put("advancementRatio", couple
0683:                                .get("advancementRatio")
0684:                                + coupletmp.get("advancementRatio"));
0685:                    }
0686:                }
0687:                // else if it's a concrete task get the values
0688:                else {
0689:                    if (cbe instanceof  ConcreteTaskDescriptor) {
0690:                        ConcreteTaskDescriptor ctd = (ConcreteTaskDescriptor) cbe;
0691:                        if (ctd.getRemainingTime() != 0
0692:                                || ctd.getAccomplishedTime() != 0) {
0693:                            couple.put("advancementRatio", (double) (ctd
0694:                                    .getAccomplishedTime() / (ctd
0695:                                    .getRemainingTime() + ctd
0696:                                    .getAccomplishedTime())));
0697:                        }
0698:                    }
0699:                }
0700:                return couple;
0701:            }
0702:
0703:            /**
0704:             * Setter of displayContent.
0705:             * 
0706:             * @param _displayContent
0707:             *                The displayContent to set.
0708:             */
0709:            public void setDisplayContent(
0710:                    ArrayList<HashMap<String, Object>> _displayContent) {
0711:                this .displayContent = _displayContent;
0712:            }
0713:
0714:            /**
0715:             * @return the isExpanded
0716:             */
0717:            public HashMap<String, Boolean> getIsExpanded() {
0718:                return this .isExpanded;
0719:            }
0720:
0721:            /**
0722:             * Setter of isExpanded.
0723:             * 
0724:             * @param _isExpanded
0725:             *                The isExpanded to set.
0726:             */
0727:            public void setIsExpanded(HashMap<String, Boolean> _isExpanded) {
0728:                this .isExpanded = _isExpanded;
0729:            }
0730:
0731:            /**
0732:             * @return the project
0733:             */
0734:            public Project getProject() {
0735:                return this .project;
0736:            }
0737:
0738:            /**
0739:             * Setter of project.
0740:             * 
0741:             * @param _project
0742:             *                The project to set.
0743:             */
0744:            public void setProject(Project _project) {
0745:                this .project = _project;
0746:            }
0747:
0748:            /**
0749:             * @return the projectService
0750:             */
0751:            public ProjectService getProjectService() {
0752:                return this .projectService;
0753:            }
0754:
0755:            /**
0756:             * Setter of projectService.
0757:             * 
0758:             * @param _projectService
0759:             *                The projectService to set.
0760:             */
0761:            public void setProjectService(ProjectService _projectService) {
0762:                this .projectService = _projectService;
0763:            }
0764:
0765:            /**
0766:             * getter of projectService String attribute
0767:             * 
0768:             * @return the projectViewedId
0769:             */
0770:            public String getProjectViewedId() {
0771:                return this .projectViewedId;
0772:            }
0773:
0774:            /**
0775:             * Setter of projectViewedId.
0776:             * 
0777:             * @param _projectViewedId
0778:             *                The projectViewedId to set.
0779:             */
0780:            public void setProjectViewedId(String _projectViewedId) {
0781:                this .projectViewedId = _projectViewedId;
0782:            }
0783:
0784:            /**
0785:             * getter of identationContent HashMap attribute
0786:             * 
0787:             * @return the indentationContent
0788:             */
0789:            public HashMap<String, String> getIndentationContent() {
0790:                return this .indentationContent;
0791:            }
0792:
0793:            /**
0794:             * Setter of indentationContent.
0795:             * 
0796:             * @param _indentationContent
0797:             *                The indentationContent to set.
0798:             */
0799:            public void setIndentationContent(
0800:                    HashMap<String, String> _indentationContent) {
0801:                this .indentationContent = _indentationContent;
0802:            }
0803:
0804:            /**
0805:             * Getter of concreteActivityService.
0806:             * 
0807:             * @return the concreteActivityService.
0808:             */
0809:            public ConcreteActivityService getConcreteActivityService() {
0810:                return this .concreteActivityService;
0811:            }
0812:
0813:            /**
0814:             * Setter of concreteActivityService.
0815:             * 
0816:             * @param _concreteActivityService
0817:             *                The concreteActivityService to set.
0818:             */
0819:            public void setConcreteActivityService(
0820:                    ConcreteActivityService _concreteActivityService) {
0821:                this .concreteActivityService = _concreteActivityService;
0822:            }
0823:
0824:            /**
0825:             * getter of selectedProjectAdvancementView boolean attribute
0826:             * 
0827:             * @return the selectedProjectAdvancementView
0828:             */
0829:            public boolean getSelectedProjectAdvancementView() {
0830:                String user_id = (String) WebSessionService
0831:                        .getAttribute(WebSessionService.WILOS_USER_ID);
0832:
0833:                String projectId = (String) WebSessionService
0834:                        .getAttribute(WebSessionService.PROJECT_ID);
0835:
0836:                String role = (String) WebSessionService
0837:                        .getAttribute(WebSessionService.ROLE_TYPE);
0838:
0839:                if (projectId == null) {
0840:                    this .selectedProjectAdvancementView = false;
0841:                    return this .selectedProjectAdvancementView;
0842:                }
0843:
0844:                this .project = this .projectService.getProject(projectId);
0845:                if (project == null) {
0846:                    this .selectedProjectAdvancementView = false;
0847:                    return this .selectedProjectAdvancementView;
0848:                }
0849:
0850:                this .selectedProjectAdvancementView = false;
0851:                if (this .project.getProjectManager() != null) {
0852:                    if (this .project.getProjectManager().getId()
0853:                            .equals(user_id)) {
0854:                        this .selectedProjectAdvancementView = true;
0855:                    }
0856:                    if (role.equals("projectDirector")) {
0857:                        this .selectedProjectAdvancementView = true;
0858:                    }
0859:                }
0860:
0861:                return this .selectedProjectAdvancementView;
0862:            }
0863:
0864:            /**
0865:             * Setter of selectedProjectAdvancementView.
0866:             * 
0867:             * @param _selectedProjectAdvancementView
0868:             *                The selectedProjectAdvancementView to set.
0869:             */
0870:            public void setSelectedProjectAdvancementView(
0871:                    boolean _selectedProjectAdvancementView) {
0872:                this .selectedProjectAdvancementView = _selectedProjectAdvancementView;
0873:            }
0874:
0875:            /**
0876:             * The method return information to know if a project is instanciated or
0877:             * not.
0878:             * 
0879:             * @return String
0880:             */
0881:            public String getProjectInstanciated() {
0882:                if (this .project == null)
0883:                    this .projectInstanciated = "projectNotSelected";
0884:                else if (this .project.getProcess() == null) {
0885:                    this .projectInstanciated = "projectNotInstanciated";
0886:                } else {
0887:                    this .projectInstanciated = "projectInstanciated";
0888:                }
0889:                return this .projectInstanciated;
0890:            }
0891:
0892:            /**
0893:             * setter of projectInstanciated String attribute
0894:             * 
0895:             * @param projectInstanciated
0896:             */
0897:            public void setProjectInstanciated(String projectInstanciated) {
0898:                this .projectInstanciated = projectInstanciated;
0899:            }
0900:
0901:            /**
0902:             * 
0903:             * Editing an estimate
0904:             * 
0905:             * @param e
0906:             *                event received when a user clicks on edit button in the
0907:             *                datatable
0908:             */
0909:            public void editEstimate(ActionEvent e) {
0910:                String taskPosition = (String) FacesContext
0911:                        .getCurrentInstance().getExternalContext()
0912:                        .getRequestParameterMap().get("taskPosition");
0913:                this .displayContent.get(Integer.parseInt(taskPosition)).put(
0914:                        "isEditable", true);
0915:            }
0916:
0917:            public int getIndentationPosition() {
0918:                int tmppos = this .pos;
0919:                this .pos = this .pos + 1;
0920:                return tmppos;
0921:            }
0922:
0923:            /**
0924:             * methods who return a boolean. this method allow to now if a task is
0925:             * already started or not in order to blocking edit of estimate
0926:             * 
0927:             * @param _concreteBreakdownElement
0928:             * @return boolean
0929:             */
0930:
0931:            public boolean isConcreteBreakdownElementStarted(
0932:                    ConcreteBreakdownElement _concreteBreakdownElement) {
0933:                ConcreteTaskDescriptor ctd = new ConcreteTaskDescriptor();
0934:                ConcreteActivity ca = new ConcreteActivity();
0935:                if (_concreteBreakdownElement instanceof  ConcreteTaskDescriptor) {
0936:                    ctd = (ConcreteTaskDescriptor) _concreteBreakdownElement;
0937:                    System.out.println("nom de la tache : "
0938:                            + ctd.getConcreteName() + "\n");
0939:                    System.out.println("etat : ");
0940:                    if ((ctd.getState().equals("Created"))
0941:                            || (ctd.getState().equals("Ready"))) {
0942:                        System.out.println("creer ou en cours \n");
0943:                        return false;
0944:                    } else {
0945:                        System.out.println("pas commencer ou fini \n");
0946:                        return true;
0947:                    }
0948:                }
0949:                if (_concreteBreakdownElement instanceof  ConcreteActivity) {
0950:                    ca = (ConcreteActivity) _concreteBreakdownElement;
0951:                    System.out.println("nom de la tache : "
0952:                            + ca.getConcreteName() + "\n");
0953:                    System.out.println("etat : ");
0954:                    if (ca.getState().equals("Finished")) {
0955:                        System.out.println("fini \n");
0956:                        return true;
0957:                    } else {
0958:                        System.out
0959:                                .println("pas commencer, creer ou en cours \n");
0960:                        return false;
0961:                    }
0962:                }
0963:                System.out.println("etat : probleme");
0964:                return false;
0965:            }
0966:
0967:            /**
0968:             * 
0969:             * method returning a formated string to apply a specific style in an
0970:             * ice:outputText tag
0971:             * 
0972:             * @param _consomme
0973:             * @return String
0974:             */
0975:
0976:            public String outputStyleForConsomme(Double _consomme) {
0977:                String result = "";
0978:                if (_consomme > 100) {
0979:                    result = "color:red;font-weight: bold;";
0980:                } else {
0981:                    result = "";
0982:                }
0983:                return result;
0984:            }
0985:
0986:            /**
0987:             * 
0988:             * Save an estimate
0989:             * 
0990:             * @param e
0991:             *                event received when a user clicks on save button in the
0992:             *                datatable
0993:             */
0994:            public void saveEstimate(ActionEvent e) {
0995:                int position = 0;
0996:                String taskPosition = (String) FacesContext
0997:                        .getCurrentInstance().getExternalContext()
0998:                        .getRequestParameterMap().get("taskPosition");
0999:
1000:                ConcreteActivity ca = new ConcreteActivity();
1001:                ConcreteWorkBreakdownElement cz = new ConcreteWorkBreakdownElement();
1002:                ConcreteTaskDescriptor ctd = new ConcreteTaskDescriptor();
1003:
1004:                List<ConcreteBreakdownElement> concreteBDE = this .concreteBreakdownElementService
1005:                        .getConcreteBreakdownElementDao()
1006:                        .getAllConcreteBreakdownElements();
1007:
1008:                while (!concreteBDE.get(position).getId().equals(
1009:                        this .displayContent.get(Integer.parseInt(taskPosition))
1010:                                .get("id"))) {
1011:                    position = position + 1;
1012:                }
1013:                cz = (ConcreteWorkBreakdownElement) concreteBDE.get(position);
1014:                if (cz instanceof  ConcreteTaskDescriptor) {
1015:
1016:                    ctd = (ConcreteTaskDescriptor) cz;
1017:                    ctd.setPlannedFinishingDate((Date) this .displayContent.get(
1018:                            Integer.parseInt(taskPosition)).get(
1019:                            "plannedFinishingDate"));
1020:                    ctd.setPlannedStartingDate((Date) this .displayContent.get(
1021:                            Integer.parseInt(taskPosition)).get(
1022:                            "plannedStartingDate"));
1023:                    ctd.setPlannedTime((Float) this .displayContent.get(
1024:                            Integer.parseInt(taskPosition)).get("plannedTime"));
1025:
1026:                    this .concreteTaskDescriptor.saveConcreteTaskDescriptor(ctd);
1027:
1028:                }
1029:                if (cz instanceof  ConcreteActivity) {
1030:                    ca = (ConcreteActivity) cz;
1031:                    ca.setPlannedFinishingDate((Date) this .displayContent.get(
1032:                            Integer.parseInt(taskPosition)).get(
1033:                            "plannedFinishingDate"));
1034:                    ca.setPlannedStartingDate((Date) this .displayContent.get(
1035:                            Integer.parseInt(taskPosition)).get(
1036:                            "plannedStartingDate"));
1037:                    ca.setPlannedTime((Float) this .displayContent.get(
1038:                            Integer.parseInt(taskPosition)).get("plannedTime"));
1039:                    this .concreteActivityService.saveConcreteActivity(ca);
1040:                    System.out.println(ca.getId() + "\n");
1041:                }
1042:
1043:                this .displayContent.get(Integer.parseInt(taskPosition)).put(
1044:                        "isEditable", false);
1045:                WebCommonService
1046:                        .addInfoMessage(WilosBundle
1047:                                .getText("component.project.projectEstimate.updateAffected"));
1048:
1049:            }
1050:
1051:            /**
1052:             * this method return a concreteRoledescriptor link to the given 
1053:             * concreteTaskDescriptor
1054:             * 
1055:             * @param _ctd the given concreteTaskDescriptor
1056:             * @return the wanted ConcreteRoleDescriptor
1057:             */
1058:            // public List<HashMap<String, Object>> getAllRoleForTask(
1059:            public ConcreteRoleDescriptor getRoleForTask(
1060:                    ConcreteTaskDescriptor _ctd) {
1061:                if (_ctd != null) {
1062:                    // List<HashMap<String, Object>> listHashMapRoleForTask = new
1063:                    // ArrayList<HashMap<String, Object>>();
1064:
1065:                    ConcreteTaskDescriptorService ctdService = this 
1066:                            .getConcreteTaskDescriptor();
1067:                    TaskDescriptorService tdService = ctdService
1068:                            .getTaskDescriptorService();
1069:                    RoleDescriptorService rdService = ctdService
1070:                            .getRoleDescriptorService();
1071:                    ConcreteRoleDescriptorService crdService = ctdService
1072:                            .getConcreteRoleDescriptorService();
1073:
1074:                    TaskDescriptor tmp = _ctd.getTaskDescriptor();
1075:                    RoleDescriptor tmpRoleDescriptor;
1076:                    TaskDescriptor tmp2 = tdService.getTaskDescriptorById(tmp
1077:                            .getId());
1078:
1079:                    tmpRoleDescriptor = tmp2.getMainRole();
1080:
1081:                    if (tmpRoleDescriptor != null) {
1082:                        RoleDescriptor rd = rdService
1083:                                .getRoleDescriptor(tmpRoleDescriptor.getId());
1084:                        List<ConcreteRoleDescriptor> listeRd = crdService
1085:                                .getAllConcreteRoleDescriptorForARoleDescriptor(rd
1086:                                        .getId());
1087:                        if (listeRd.size() > 0) {
1088:                            Iterator<ConcreteRoleDescriptor> ite = listeRd
1089:                                    .iterator();
1090:                            ConcreteRoleDescriptor crd = ite.next();
1091:                            // if(crd==null)
1092:                            while (crd == null || ite.hasNext()) {
1093:                                crd = ite.next();
1094:                                // HashMap<String, Object> hashMapRd = new
1095:                                // HashMap<String, Object>();
1096:                                // hashMapRd.put("roleName", crd.getConcreteName());
1097:                                // hashMapRd.put("roleId", crd.getId());
1098:                                // hashMapRd.put("roleDescriptor", crd);
1099:                                // listHashMapRoleForTask.add(hashMapRd);
1100:                                // return crd;
1101:
1102:                            }
1103:                            return crd;
1104:
1105:                            // return listHashMapRoleForTask;
1106:                        } else {
1107:                            // return listHashMapRoleForTask;
1108:                            return new ConcreteRoleDescriptor();
1109:                        }
1110:                    } else {
1111:                        // return listHashMapRoleForTask;
1112:                        return new ConcreteRoleDescriptor();
1113:                    }
1114:
1115:                } else {
1116:                    // return new ArrayList<HashMap<String, Object>>();
1117:                    return new ConcreteRoleDescriptor();
1118:                }
1119:            }
1120:
1121:            /**
1122:             * this method allow to return a string.
1123:             * the string indicate if the given participant is already affected or not 
1124:             * to the given concreteRoleDescriptor
1125:             * this method also indicate if another participant 
1126:             * than the given participant is affected to the given concreteRoleDescriptor
1127:             * 
1128:             * @param _parti
1129:             * @param _concreteRoleDescriptor
1130:             * @return String
1131:             */
1132:            public String isAffected(Participant _parti,
1133:                    ConcreteRoleDescriptor _concreteRoleDescriptor) {
1134:                ConcreteTaskDescriptorService ctdService = this 
1135:                        .getConcreteTaskDescriptor();
1136:                ConcreteRoleDescriptorService crdService = ctdService
1137:                        .getConcreteRoleDescriptorService();
1138:                Participant parti = crdService
1139:                        .getParticipant(_concreteRoleDescriptor);
1140:                if (parti != null) {
1141:                    if (parti.getId().equals(_parti.getId())) {
1142:                        return "Affected";
1143:                    } else {
1144:                        return "OtherAffected";
1145:                    }
1146:
1147:                } else {
1148:                    return "NotAffected";
1149:                }
1150:
1151:            }
1152:
1153:            /**
1154:             * this method allow to return the current instance of
1155:             * participantService
1156:             * 
1157:             * @return ParticipantService
1158:             */
1159:            public ParticipantService getParticipantService() {
1160:                return participantService;
1161:            }
1162:
1163:            /**
1164:             * this method allow to set the current instance of 
1165:             * participantService
1166:             * 
1167:             * @param _participantService
1168:             */
1169:            public void setParticipantService(
1170:                    ParticipantService _participantService) {
1171:                participantService = _participantService;
1172:            }
1173:
1174:            /**
1175:             * this method allow to save the current user role affectation through 
1176:             * the role affectation panel
1177:             */
1178:            public void saveAffectRole() {
1179:                boolean modif = false;
1180:                String wilosUserId = (String) WebSessionService
1181:                        .getAttribute(WebSessionService.WILOS_USER_ID);
1182:                ParticipantService pService = this .getParticipantService();
1183:                Participant parti = pService.getParticipant(wilosUserId);
1184:                ConcreteTaskDescriptorService ctdService = this 
1185:                        .getConcreteTaskDescriptor();
1186:                ConcreteRoleDescriptorService crdService = ctdService
1187:                        .getConcreteRoleDescriptorService();
1188:                for (HashMap<String, Object> ligne : this .displayContent) {
1189:                    if ((Boolean) ligne.get("visibleCheckbox")) {
1190:                        if (!(Boolean) ligne.get("enabled")) {
1191:                            ConcreteRoleDescriptor crd = (ConcreteRoleDescriptor) ligne
1192:                                    .get("role");
1193:
1194:                            if (crd != null) {
1195:                                if ((Boolean) ligne.get("isAffected")
1196:                                        && !(Boolean) ligne.get("flagAffect")) {
1197:                                    crd.setParticipant(parti);
1198:                                    crdService
1199:                                            .getConcreteRoleDescriptorDao()
1200:                                            .saveOrUpdateConcreteRoleDescriptor(
1201:                                                    crd);
1202:                                    modif = true;
1203:                                } else if (!(Boolean) ligne.get("isAffected")
1204:                                        && (Boolean) ligne.get("flagAffect")) {
1205:                                    crd.setParticipant(null);
1206:                                    crdService
1207:                                            .getConcreteRoleDescriptorDao()
1208:                                            .saveOrUpdateConcreteRoleDescriptor(
1209:                                                    crd);
1210:                                    modif = true;
1211:                                }
1212:                            }
1213:                        }
1214:                    }
1215:                }
1216:                if (modif) {
1217:                    WebCommonService.addInfoMessage(WilosBundle
1218:                            .getText("tabAffectRole.updateAffected"));
1219:                    TreeBean tb = (TreeBean) WebCommonService
1220:                            .getBean("TreeBean");
1221:                    tb.setSelectedMode(tb.ROLES_MODE);
1222:                    tb.refreshProjectTree();
1223:
1224:                }
1225:                this .refreshProjectTable();
1226:
1227:            }
1228:
1229:            /**
1230:             * getter of projectSelected boolean attribute
1231:             * 
1232:             * @return boolean
1233:             */
1234:            public boolean getProjectSelected() {
1235:                String projectid = (String) WebSessionService
1236:                        .getAttribute(WebSessionService.PROJECT_ID);
1237:                if (projectid == null || projectid.equals("default")) {
1238:                    return false;
1239:                } else {
1240:                    return true;
1241:                }
1242:            }
1243:
1244:            /**
1245:             * this method allow to change the concreteName font style of the given 
1246:             * concreteTaskDescriptor for the given mode parameter
1247:             * 
1248:             * @param _ctd
1249:             * @param _mode
1250:             * @return String
1251:             */
1252:            public String getStyle(ConcreteTaskDescriptor _ctd, String _mode) {
1253:                Date ladate = new Date();
1254:                String style = "";
1255:                if (_mode.equals("Start")) {
1256:                    if ((_ctd.getState().equals("Created"))
1257:                            || (_ctd.getState().equals("Ready"))) {
1258:                        if (_ctd.getPlannedStartingDate() != null) {
1259:                            if (_ctd.getPlannedStartingDate().before(ladate)) {
1260:                                style = "color:red;font-weight: bold;";
1261:                            } else {
1262:                                style = "color:green;font-weight: bold;";
1263:                            }
1264:                        } else {
1265:                            style = "";
1266:                        }
1267:                    } else {
1268:                        style = "";
1269:                    }
1270:                } else {
1271:                    if ((_ctd.getState().equals("Created"))
1272:                            || (_ctd.getState().equals("Ready"))
1273:                            || (_ctd.getState().equals("Started"))) {
1274:                        if (_ctd.getPlannedFinishingDate() != null) {
1275:                            if (_ctd.getPlannedFinishingDate().before(ladate)) {
1276:                                style = "color:red;font-weight: bold;";
1277:                            } else {
1278:                                style = "";
1279:                            }
1280:                        } else {
1281:                            style = "";
1282:                        }
1283:                    } else if (_ctd.getState().equals("Finished")) {
1284:                        if (_ctd.getPlannedFinishingDate() != null) {
1285:                            if (_ctd.getPlannedFinishingDate().before(
1286:                                    _ctd.getRealFinishingDate())) {
1287:                                style = "color:red;font-weight: bold;";
1288:                            } else {
1289:                                style = "foncolor:green;font-weight: bold;";
1290:                            }
1291:                        } else {
1292:                            style = "";
1293:                        }
1294:                    }
1295:                }
1296:                return style;
1297:            }
1298:
1299:            /**
1300:             * this method allow to return the Advancement percent column font style
1301:             * 
1302:             * @param _ctd the given concreteTaskDescriptor
1303:             * @return String 
1304:             */
1305:            public String getStyleAdvancement(ConcreteTaskDescriptor _ctd) {
1306:                String couleur = new String();
1307:                if (_ctd.getState().equals("Created")) {
1308:                    couleur = "color:black;font-weight: bold;";
1309:                } else if (_ctd.getState().equals("Finished")) {
1310:                    couleur = "color:orange;font-weight: bold;";
1311:                }
1312:                return couleur;
1313:            }
1314:
1315:            /**
1316:             * this method allow to return the current instance of 
1317:             * WorkProductDescriptorService
1318:             * 
1319:             * @return WorkProductDescriptorService
1320:             */
1321:            public WorkProductDescriptorService getWorkProductDescriptorService() {
1322:                return workProductDescriptorService;
1323:            }
1324:
1325:            /**
1326:             * this method allow to set the current instance of 
1327:             * WorkProductDescriptorService
1328:             * 
1329:             * @param workProductDescriptorService
1330:             */
1331:            public void setWorkProductDescriptorService(
1332:                    WorkProductDescriptorService workProductDescriptorService) {
1333:                this .workProductDescriptorService = workProductDescriptorService;
1334:            }
1335:
1336:            /**
1337:             * this method allow to return the current instance of
1338:             * ConcreteWorkProductDescriptorService 
1339:             * 
1340:             * @return ConcreteWorkProductDescriptorService
1341:             */
1342:            public ConcreteWorkProductDescriptorService getConcreteWorkProductDescriptorService() {
1343:                return concreteWorkProductDescriptorService;
1344:            }
1345:
1346:            /**
1347:             * this method allow to set the current instance of 
1348:             * ConcreteWorkProductDescriptorService
1349:             * 
1350:             * @param concreteWorkProductDescriptorService
1351:             */
1352:            public void setConcreteWorkProductDescriptorService(
1353:                    ConcreteWorkProductDescriptorService concreteWorkProductDescriptorService) {
1354:                this .concreteWorkProductDescriptorService = concreteWorkProductDescriptorService;
1355:            }
1356:
1357:            /**
1358:             * this method allow to return all the available mode for the workProduct
1359:             * 
1360:             * @return List<SelectItem> of mode
1361:             */
1362:            public List<SelectItem> getModesList() {
1363:                ArrayList<SelectItem> modesList = new ArrayList<SelectItem>();
1364:
1365:                modesList
1366:                        .add(new SelectItem(
1367:                                ALL_WP_MODE,
1368:                                WilosBundle
1369:                                        .getText("tabAffectWorkProduct.checkboxlabel.allWorkProduct")));
1370:                modesList
1371:                        .add(new SelectItem(
1372:                                MY_WP_MODE,
1373:                                WilosBundle
1374:                                        .getText("tabAffectWorkProduct.checkboxlabel.myWorkProduct")));
1375:
1376:                return modesList;
1377:            }
1378:
1379:            /**
1380:             * this method allow to change the current concreteWorkProduct mode
1381:             * 
1382:             * @param evt
1383:             */
1384:            public void changeModeActionListener(ValueChangeEvent evt) {
1385:
1386:                this .selectedMode = (String) evt.getNewValue();
1387:                if (this .selectedMode.equals(ALL_WP_MODE)) {
1388:                    WebSessionService.setAttribute(WebSessionService.TREE_MODE,
1389:                            ALL_WP_MODE);
1390:                    refreshProjectTable();
1391:                } else {
1392:                    WebSessionService.setAttribute(WebSessionService.TREE_MODE,
1393:                            MY_WP_MODE);
1394:                    refreshProjectTable();
1395:                }
1396:            }
1397:
1398:            /**
1399:             * getter of selectedMode String attribute 
1400:             * 
1401:             * @return String
1402:             */
1403:            public String getSelectedMode() {
1404:                return selectedMode;
1405:            }
1406:
1407:            /**
1408:             * setter of selectedMode String attribute 
1409:             * 
1410:             * @param selectedMode
1411:             */
1412:            public void setSelectedMode(String selectedMode) {
1413:                this.selectedMode = selectedMode;
1414:            }
1415:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.