KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > ejb > beans > entity > ProjectBean


1 /*
2  * This software was designed and created by Jason Carroll.
3  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4  * The author can be reached at jcarroll@cowsultants.com
5  * ITracker website: http://www.cowsultants.com
6  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it only under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  */

18
19 package cowsultants.itracker.ejb.beans.entity;
20
21 import java.util.*;
22 import java.sql.Timestamp JavaDoc;
23
24 import cowsultants.itracker.ejb.client.models.ComponentModel;
25 import cowsultants.itracker.ejb.client.models.CustomFieldModel;
26 import cowsultants.itracker.ejb.client.models.ProjectModel;
27 import cowsultants.itracker.ejb.client.models.UserModel;
28 import cowsultants.itracker.ejb.client.models.VersionModel;
29
30 public abstract class ProjectBean extends GenericBean {
31
32     public abstract String JavaDoc getName();
33     public abstract void setName(String JavaDoc value);
34
35     public abstract String JavaDoc getDescription();
36     public abstract void setDescription(String JavaDoc value);
37
38     public abstract int getStatus();
39     public abstract void setStatus(int value);
40
41     public abstract int getOptions();
42     public abstract void setOptions(int value);
43
44     public abstract Collection getCustomFields();
45     public abstract void setCustomFields(Collection customFields);
46
47     public abstract Collection getComponents();
48     public abstract void setComponents(Collection components);
49
50     public abstract Collection getVersions();
51     public abstract void setVersions(Collection versions);
52
53     public abstract Collection getIssues();
54     public abstract void setIssues(Collection issues);
55
56     public abstract Collection getPermissions();
57     public abstract void setPermissions(Collection permissions);
58
59     public abstract Collection getOwners();
60     public abstract void setOwners(Collection owners);
61
62     public int getTotalNumberIssues() {
63         return getIssues().size();
64     }
65
66     public ProjectModel getModel() {
67         ProjectModel model = new ProjectModel();
68         model.setId(this.getId());
69         model.setName(this.getName());
70         model.setStatus(this.getStatus());
71         model.setOptions(this.getOptions());
72         model.setDescription(this.getDescription());
73         model.setLastModifiedDate(this.getLastModifiedDate());
74         model.setCreateDate(this.getCreateDate());
75
76         int i = 0;
77         Collection users = this.getOwners();
78         UserModel[] usersArray = new UserModel[users.size()];
79         for(Iterator iterator = users.iterator(); iterator.hasNext(); i++) {
80             usersArray[i] = ((UserLocal) iterator.next()).getModel();
81         }
82         model.setOwners(usersArray);
83
84         i = 0;
85         Collection components = this.getComponents();
86         ComponentModel[] componentsArray = new ComponentModel[components.size()];
87         for(Iterator iterator = components.iterator(); iterator.hasNext(); i++) {
88             componentsArray[i] = ((ComponentLocal) iterator.next()).getModel();
89         }
90         model.setComponents(componentsArray);
91
92         i = 0;
93         Collection customFields = this.getCustomFields();
94         CustomFieldModel[] customFieldsArray = new CustomFieldModel[customFields.size()];
95         for(Iterator iterator = customFields.iterator(); iterator.hasNext(); i++) {
96             customFieldsArray[i] = ((CustomFieldLocal) iterator.next()).getModel();
97         }
98         model.setCustomFields(customFieldsArray);
99
100         i = 0;
101         Collection versions = this.getVersions();
102         VersionModel[] versionsArray = new VersionModel[versions.size()];
103         for(Iterator iterator = versions.iterator(); iterator.hasNext(); i++) {
104             versionsArray[i] = ((VersionLocal) iterator.next()).getModel();
105         }
106         model.setVersions(versionsArray);
107
108         return model;
109     }
110
111     public void setModel(ProjectModel model) {
112         this.setName(model.getName());
113         this.setDescription(model.getDescription());
114         this.setStatus(model.getStatus());
115         this.setOptions(model.getOptions());
116         this.setLastModifiedDate(new Timestamp JavaDoc(new Date().getTime()));
117     }
118
119 }
120
Popular Tags