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