KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > project > Project


1 /*********************************************************************************
2  * The contents of this file are subject to the OpenI Public License Version 1.0
3  * ("License"); You may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.openi.org/docs/LICENSE.txt
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is: OpenI Open Source
12  *
13  * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
14  * Portions created by Loyalty Matrix, Inc. are
15  * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
16  *
17  * Contributor(s): ______________________________________.
18  *
19  ********************************************************************************/

20 package org.openi.project;
21
22 import org.openi.menu.MenuItem;
23 import org.openi.util.*;
24 import java.io.*;
25 import java.util.*;
26
27
28 /**
29  * configuration file for Project
30  */

31 public class Project implements Serializable {
32     private String JavaDoc projectId;
33     private String JavaDoc projectName;
34     private String JavaDoc externalUrl;
35     private String JavaDoc cssName;
36     private String JavaDoc logoUrl; // i.e. - images/openidemo.jpg
37
private String JavaDoc splashImageUrl; //if splashPage is null, use this image as splash page.
38
private String JavaDoc splashPage = "splash.htm"; //link, notice this functionality is changed, it is now just a link
39
private List modules;
40     private Map dataSourceMap;
41     private String JavaDoc category;
42     private String JavaDoc message; // used in place of date in header i.e. - "data loaded as of 7/22/2005"
43
private Map menuConfig;
44
45     /**
46      * keys - name of color palette
47      * value - List of Paint objects representing a palette
48      */

49     private Map colorPaletteMap;
50     private String JavaDoc defaultPaletteName;
51
52     /**
53      * comma separated list of Project Admins
54      */

55     private String JavaDoc projectAdmins;
56
57     /**
58      * comma separated list of Project Users
59      */

60     private String JavaDoc projectUsers;
61     
62     /**
63      * comma separated list of Project read only Users
64      */

65     private String JavaDoc projectReadOnlyUsers;
66
67     /**
68      * header footer used by print servlet
69      */

70     private Map jdbcMap;
71
72     // private String reportHeader;
73
//private String reportFooter;
74
private boolean writeImageMap = true;
75     
76     /**
77      * Map of overviews
78      * key: title
79      * value: Overview, which contains a list of links (e.g. - public/Samples/MSAS/HR_Employees.analysis)
80      */

81     private Map overviews = new HashMap();
82     
83
84     // TODO: protect to allow centralized caching?
85
public Project() {
86     }
87
88     /**
89      * @return Returns the cssName.
90      */

91     public String JavaDoc getCssName() {
92         return cssName;
93     }
94
95     /**
96      * @param cssName The cssName to set.
97      */

98     public void setCssName(String JavaDoc cssName) {
99         this.cssName = cssName;
100     }
101
102     /**
103      * @return Returns the externalUrl.
104      */

105     public String JavaDoc getExternalUrl() {
106         return externalUrl;
107     }
108
109     /**
110      * @param externalUrl The externalUrl to set.
111      */

112     public void setExternalUrl(String JavaDoc externalUrl) {
113         this.externalUrl = externalUrl;
114     }
115
116     /**
117      * @return Returns the projectHomeDir.
118      */

119
120     /**
121      * @return Returns the projectId.
122      */

123     public String JavaDoc getProjectId() {
124         return projectId;
125     }
126
127     /**
128      * @param projectId The projectId to set.
129      */

130     public void setProjectId(String JavaDoc projectId) {
131         this.projectId = projectId;
132     }
133
134     /**
135      * @return Returns the projectName.
136      */

137     public String JavaDoc getProjectName() {
138         return projectName;
139     }
140
141     /**
142      * @param projectName The projectName to set.
143      */

144     public void setProjectName(String JavaDoc projectName) {
145         this.projectName = projectName;
146     }
147
148     /**
149      * @return Returns the modules.
150      */

151     public List getModules() {
152         return modules;
153     }
154
155     /**
156      * @param modules The modules to set.
157      */

158     public void setModules(List modules) {
159         this.modules = modules;
160     }
161
162     /**
163      * @return Returns the logoUrl.
164      */

165     public String JavaDoc getLogoUrl() {
166         return logoUrl;
167     }
168
169     /**
170      * @param logoUrl The logoUrl to set.
171      */

172     public void setLogoUrl(String JavaDoc logoUrl) {
173         this.logoUrl = logoUrl;
174     }
175
176     /**
177      * @return Returns the splashImageUrl.
178      */

179     public String JavaDoc getSplashImageUrl() {
180         return splashImageUrl;
181     }
182
183     /**
184      *
185      * @return Map of dataSource
186      */

187     public Map getDataSourceMap() {
188         return dataSourceMap;
189     }
190
191     /**
192      *
193      * @param splashImageUrl The splashImageUrl to set.
194      */

195     public void setSplashImageUrl(String JavaDoc splashImageUrl) {
196         this.splashImageUrl = splashImageUrl;
197     }
198
199     /**
200      *
201      * @param dataSource Map
202      */

203     public void setDataSourceMap(Map dataSource) {
204         this.dataSourceMap = dataSource;
205     }
206
207     /**
208      * @return Returns the colorPaletteMap.
209      */

210     public Map getColorPaletteMap() {
211         // return colorPaletteMap;
212
/*
213            colorPaletteMap = new HashMap();
214            List monochrome = new ArrayList();
215            monochrome.add(new Color(249, 219, 224));
216            monochrome.add(new Color(167, 70, 97));
217            monochrome.add(new Color(189, 117, 137));
218            monochrome.add(new Color(212, 163, 177));
219            monochrome.add(new Color(233, 209, 215));
220            monochrome.add(new Color(142, 60, 82));
221            monochrome.add(new Color(125, 53, 73));
222            monochrome.add(new Color(84, 35, 49));
223            colorPaletteMap.put("monochrome", monochrome);
224            List nemo = new ArrayList();
225            nemo.add(new Color( 255, 140, 0));
226            nemo.add(new Color( 0, 0, 205));
227            nemo.add(new Color( 135, 206, 250));
228            nemo.add(new Color( 153, 50, 204));
229            nemo.add(new Color( 0, 153, 102));
230            nemo.add(new Color( 255, 255, 102));
231            colorPaletteMap.put("nemo", nemo);
232          */

233         return this.colorPaletteMap;
234     }
235
236     /**
237      *
238      * @return String
239      */

240     public String JavaDoc getProjectUsers() {
241         return projectUsers;
242     }
243
244     /**
245      *
246      * @return String
247      */

248     public String JavaDoc getProjectAdmins() {
249         return projectAdmins;
250     }
251     
252     /**
253     *
254     * @return String
255     */

256     public String JavaDoc getProjectReadOnlyUsers() {
257        return projectReadOnlyUsers;
258     }
259    
260     /**
261      * @param colorPaletteMap The colorPaletteMap to set.
262      */

263     public void setColorPaletteMap(Map colorPaletteMap) {
264         this.colorPaletteMap = colorPaletteMap;
265     }
266
267     public void setProjectUsers(String JavaDoc projectUsers) {
268         this.projectUsers = projectUsers;
269     }
270
271     public void setProjectAdmins(String JavaDoc pojectAdmins) {
272         this.projectAdmins = pojectAdmins;
273     }
274     
275     public void setProjectReadOnlyUsers(String JavaDoc projectReadOnlyUsers) {
276         this.projectReadOnlyUsers = projectReadOnlyUsers;
277     }
278     
279     public List getColorPalette(String JavaDoc colorPaletteName) {
280         List palette = null;
281
282         if (colorPaletteName != null) {
283             palette = (List) this.getColorPaletteMap().get(colorPaletteName);
284         }
285
286         return palette;
287     }
288
289     /**
290      * @return Returns the defaultPaletteName.
291      */

292     public String JavaDoc getDefaultPaletteName() {
293         return defaultPaletteName;
294     }
295
296     /**
297      * @param defaultPaletteName The defaultPaletteName to set.
298      */

299     public void setDefaultPaletteName(String JavaDoc defaultPaletteName) {
300         this.defaultPaletteName = defaultPaletteName;
301     }
302
303     /**
304      * Checks whether the user is in comma separated list of project users.
305      * @param userName String
306      * @return boolean
307      */

308     public boolean validateUser(String JavaDoc userName) {
309         return Util.isItemInList(userName, projectUsers)
310             || Util.isItemInList(userName, projectReadOnlyUsers);
311     }
312
313     /**
314      * Checks whether the user is in comma separated list of project admins.
315      * @param userName String
316      * @return boolean
317      */

318     public boolean validateAdmin(String JavaDoc userName) {
319         return Util.isItemInList(userName, projectAdmins);
320     }
321
322     /**
323      * @return Returns the category.
324      */

325     public String JavaDoc getCategory() {
326         return category;
327     }
328
329     public String JavaDoc getSplashPage() {
330         return splashPage;
331     }
332
333     /**
334      * @param category The category to set.
335      */

336     public void setCategory(String JavaDoc category) {
337         this.category = category;
338     }
339
340     public void setSplashPage(String JavaDoc splashPage) {
341         this.splashPage = splashPage;
342     }
343
344     /**
345      * @return Returns the message.
346      */

347     public String JavaDoc getMessage() {
348         return message;
349     }
350
351     /**
352      * @param message The message to set.
353      */

354     public void setMessage(String JavaDoc message) {
355         this.message = message;
356     }
357
358     /**
359      * @return Returns the writeImageMap.
360      */

361     public boolean getWriteImageMap() {
362         return writeImageMap;
363     }
364
365     /**
366      * @param writeImageMap The writeImageMap to set.
367      */

368     public void setWriteImageMap(boolean writeImageMap) {
369         this.writeImageMap = writeImageMap;
370     }
371
372     public Map getMenuConfig() {
373         if (menuConfig == null) {
374             this.menuConfig = this.createDefaultAdminMenuConfig();
375         }
376
377         return menuConfig;
378     }
379
380     public void setMenuConfig(Map menuConfig) {
381         this.menuConfig = menuConfig;
382     }
383
384     public Map getJdbcMap() {
385         return this.jdbcMap;
386     }
387
388     public void setJdbcMap(Map jdbcMap) {
389         this.jdbcMap = jdbcMap;
390     }
391
392     /**
393      * extract and move to configuration
394      * @return
395      */

396     private Map createDefaultAdminMenuConfig() {
397         Map config = new HashMap();
398
399         List appAdminList = new LinkedList();
400         appAdminList.add(new MenuItem("Manage Application",
401                 "editapplication.htm"));
402         config.put("appAdminList", appAdminList);
403
404         List projectAdminList = new LinkedList();
405         projectAdminList.add(new MenuItem("Manage Project", "editproject.htm"));
406         projectAdminList.add(new MenuItem("Configure Datasource",
407                 "datasource.htm"));
408
409         projectAdminList.add(new MenuItem("Manage R Functions", "managerfunction.htm"));
410
411         config.put("projectAdminList", projectAdminList);
412
413         List projectUserList = new LinkedList();
414         projectUserList.add(new MenuItem("Manage Files", "managefiles.htm"));
415         projectUserList.add(new MenuItem("Upload File", "uploadfile.htm"));
416         projectUserList.add(new MenuItem("Create New Analysis",
417                 "newanalysis.htm"));
418
419         config.put("projectUserList", projectUserList);
420
421         return config;
422     }
423     public Map getOverviews() {
424         return overviews;
425     }
426     public void setOverviews(Map overviews) {
427         this.overviews = overviews;
428     }
429     public Overview getOverview(String JavaDoc key){
430         return (Overview)this.overviews.get(key);
431     }
432
433     public void removeOverview(String JavaDoc overviewKey) {
434         this.overviews.remove(overviewKey);
435         
436     }
437 }
438
Popular Tags