1 19 20 package za.org.coefficient.core; 21 22 import za.org.coefficient.authentication.CoefficientUser; 23 import za.org.coefficient.authentication.ProjectMember; 24 import za.org.coefficient.authentication.Role; 25 import za.org.coefficient.statistics.data.ProjectStatistics; 26 import za.org.coefficient.util.ejb.SecurityUtil; 27 28 import java.io.Serializable ; 29 30 import java.util.ArrayList ; 31 import java.util.Date ; 32 import java.util.Iterator ; 33 import java.util.List ; 34 35 39 public class Project implements Serializable { 40 42 private Date registrationDate; 43 private List attributeData = new ArrayList (); 44 private List attributes = new ArrayList (); 45 private List categories = new ArrayList (); 46 private List members = new ArrayList (); 47 private List membersPending = new ArrayList (); 48 private List modules = new ArrayList (); 49 private List versions = new ArrayList (); 50 private List components = new ArrayList (); 51 private Long id; 52 private ProjectStatistics statistics; 53 private ProjectVersion currentVersion; 54 private String description; 55 private String homePage; 56 private String name; 57 private boolean active; 58 private long version; 59 private boolean isPublic; 60 private boolean isWorkflow; 61 private String themeName = null; 62 private String shortName = null; 63 64 66 public Project() { 67 registrationDate = new Date (System.currentTimeMillis()); 68 isPublic = true; 69 isWorkflow = false; 70 } 71 72 74 79 public void setActive(boolean active) { 80 this.active = active; 81 } 82 83 91 public boolean getActive() { 92 return this.active; 93 } 94 95 100 public void setIsPublic(boolean isPublic) { 101 this.isPublic = isPublic; 102 } 103 104 112 public boolean getIsPublic() { 113 return this.isPublic; 114 } 115 116 121 public void setIsWorkflow(boolean isWorkflow) { 122 this.isWorkflow = isWorkflow; 123 } 124 125 133 public boolean getIsWorkflow() { 134 return this.isWorkflow; 135 } 136 137 142 public void setAttributeData(List argAttributeData) { 143 this.attributeData = argAttributeData; 144 } 145 146 160 public List getAttributeData() { 161 return this.attributeData; 162 } 163 164 169 public void setAttributes(List argAttributes) { 170 this.attributes = argAttributes; 171 } 172 173 188 public List getAttributes() { 189 return this.attributes; 190 } 191 192 197 public void setCategories(List argCategories) { 198 this.categories = argCategories; 199 } 200 201 215 public List getCategories() { 216 return this.categories; 217 } 218 219 222 public List getChampionsAsMembers() { 223 List champs = new ArrayList (); 224 List members = getMembers(); 225 ProjectMember member; 226 Role role; 227 String st; 228 229 int i; 230 231 for (i = 0; i < members.size(); i++) { 232 try { 233 member = (ProjectMember) (members.get(i)); 234 role = member.getProjectRole(); 235 st = role.getDescription(); 236 if (st.equals(SecurityUtil.PROJECT_CHAMPION_ROLE_DESC)) { 237 champs.add(member); 238 } 239 } catch (Throwable t) { 240 System.err.println("getChampionsAsMembers throws " + t); 241 } 242 } 243 244 return champs; 245 } 246 247 public List getChampionsAsUsers() { 248 List champUsers = new ArrayList (); 249 List champMembers = getChampionsAsMembers(); 250 ProjectMember champ; 251 CoefficientUser user; 252 253 int i; 254 255 for (i = 0; i < champMembers.size(); i++) { 256 try { 257 champ = (ProjectMember) (champMembers.get(i)); 258 user = champ.getCoefficientUser(); 259 champUsers.add(user); 260 } catch (Throwable t) { 261 System.err.println("getChampionsAsUsers throws " + t); 262 } 263 } 264 265 return champUsers; 266 } 267 268 273 public void setCurrentVersion(ProjectVersion currentVersion) { 274 this.currentVersion = currentVersion; 275 } 276 277 284 public ProjectVersion getCurrentVersion() { 285 return this.currentVersion; 286 } 287 288 293 public void setDescription(String description) { 294 this.description = description; 295 } 296 297 305 public String getDescription() { 306 return this.description; 307 } 308 309 316 public void setThemeName(String themeName) { 317 this.themeName = themeName; 318 } 319 320 328 public String getThemeName() { 329 return this.themeName; 330 } 331 332 337 public void setHomePage(String homePage) { 338 this.homePage = homePage; 339 } 340 341 348 public String getHomePage() { 349 return this.homePage; 350 } 351 352 357 public void setId(Long argId) { 358 this.id = argId; 359 } 360 361 368 public Long getId() { 369 return this.id; 370 } 371 372 377 public void setMembers(List argMembers) { 378 this.members = argMembers; 379 } 380 381 397 public List getMembers() { 398 return this.members; 399 } 400 401 406 public void setMembersPending(List argMembers) { 407 this.membersPending = argMembers; 408 } 409 410 426 public List getMembersPending() { 427 return this.membersPending; 428 } 429 430 435 public void setModules(List modules) { 436 this.modules = modules; 437 } 438 439 454 public List getModules() { 455 return this.modules; 456 } 457 458 463 public void setVersions(List versions) { 464 this.versions = versions; 465 } 466 467 482 public List getVersions() { 483 return this.versions; 484 } 485 486 491 public void setComponents(List components) { 492 this.components = components; 493 } 494 495 510 public List getComponents() { 511 return this.components; 512 } 513 514 519 public void setName(String name) { 520 this.name = name; 521 } 522 523 530 public String getName() { 531 return this.name; 532 } 533 534 537 public List getNonChampionsAsMembers() { 538 List nonchamps = new ArrayList (); 539 540 for (Iterator it = getMembers() 541 .iterator(); it.hasNext();) { 542 ProjectMember member = (ProjectMember) it.next(); 543 if (member.getProjectRole() 544 .getRoleValue() != SecurityUtil.PROJECT_CHAMPION_ROLE_VAL) { 545 nonchamps.add(member); 546 } 547 } 548 549 return nonchamps; 550 } 551 552 public List getNonChampionsAsUsers() { 553 List nonchampUsers = new ArrayList (); 554 555 for (Iterator it = getNonChampionsAsMembers() 556 .iterator(); it.hasNext();) { 557 ProjectMember nonchamp = (ProjectMember) it.next(); 558 nonchampUsers.add(nonchamp.getCoefficientUser()); 559 } 560 561 return nonchampUsers; 562 } 563 564 569 public void setRegistrationDate(Date registrationDate) { 570 this.registrationDate = registrationDate; 571 } 572 573 580 public Date getRegistrationDate() { 581 return this.registrationDate; 582 } 583 584 589 public void setStatistics(ProjectStatistics statistics) { 590 this.statistics = statistics; 591 } 592 593 602 public ProjectStatistics getStatistics() { 603 return this.statistics; 604 } 605 606 611 public void setVersion(long version) { 612 this.version = version; 613 } 614 615 623 public long getVersion() { 624 return this.version; 625 } 626 627 632 public void addAttribute(ProjectAttribute attribute) { 633 System.out.println("adding attribute " + attribute.getName() 634 + " to project "); 635 this.attributes.add(attribute.getId()); 636 637 } 639 640 645 public void addAttributeData(ProjectAttributeData pad) { 646 this.attributeData.add(pad); 647 } 648 649 654 public void addCategory(Category cat) { 655 this.categories.add(cat); 656 } 657 658 public void addComponent(ProjectComponent component) { 659 this.components.add(component); 660 } 661 662 667 public void addMember(ProjectMember member) { 668 this.members.add(member); 669 } 670 671 public void addModule(String moduleName) { 672 this.modules.add(moduleName); 673 } 674 675 public void addVersion(ProjectVersion version) { 676 this.versions.add(version); 677 } 678 679 public boolean containsMember(ProjectMember member) { 680 return members.contains(member); 681 } 682 683 public boolean containsUser(CoefficientUser user) { 684 boolean retVal = false; 685 for (Iterator it = members.iterator(); it.hasNext();) { 686 ProjectMember pm = (ProjectMember) it.next(); 687 if (pm.getCoefficientUser() 688 .equals(user)) { 689 retVal = true; 690 691 break; 692 } 693 } 694 695 return retVal; 696 } 697 698 703 public void deleteAttribute(ProjectAttribute attribute) { 704 int idx = this.attributes.indexOf(attribute.getName()); 705 if (idx != -1) { 706 this.attributes.remove(idx); 707 } 708 } 709 710 715 public void deleteAttributeData(ProjectAttributeData pad) { 716 int idx = this.attributeData.indexOf(pad); 717 if (idx != -1) { 718 this.attributeData.remove(idx); 719 } 720 } 721 722 727 public void deleteCategory(Category cat) { 728 int idx = this.categories.indexOf(cat); 729 if (idx != -1) { 730 this.categories.remove(idx); 731 } 732 } 733 734 739 public void deleteMember(ProjectMember member) { 740 int idx = this.members.indexOf(member); 741 if (idx != -1) { 742 this.members.remove(idx); 743 } 744 } 745 746 public void deleteModule(String moduleName) { 747 int idx = this.modules.indexOf(moduleName); 748 if (idx != -1) { 749 this.modules.remove(idx); 750 } 751 } 752 753 public void deleteVersion(ProjectVersion version) { 754 int idx = this.versions.indexOf(version); 755 if (idx != -1) { 756 this.versions.remove(idx); 757 } 758 } 759 760 public void updateVersion(ProjectVersion version) { 761 int idx = this.versions.indexOf(version); 762 if (idx != -1) { 763 this.versions.set(idx, version); 764 } 765 } 766 767 public void deleteComponent(ProjectComponent component) { 768 int idx = this.components.indexOf(component); 769 if (idx != -1) { 770 this.components.remove(idx); 771 } 772 } 773 774 public void updateComponent(ProjectComponent component) { 775 int idx = this.components.indexOf(component); 776 if (idx != -1) { 777 this.components.set(idx, component); 778 } 779 } 780 781 790 public String getShortName() { 791 return shortName; 792 } 793 794 public void setShortName(String string) { 795 shortName = string; 796 } 797 798 } 799 | Popular Tags |