1 | package org.apache.pluto.driver.services.portal; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.Collection; |
5 | import java.util.Iterator; |
6 | import java.util.List; |
7 | |
8 | import org.apache.pluto.driver.services.impl.resource.OneStartResourceConfigReader; |
9 | |
10 | import edu.iu.uis.sit.portal.portlet.attribute.PortletAttribute; |
11 | import edu.iu.uis.sit.portal.portlet.attribute.PortletAttributeManager; |
12 | |
13 | public class OneStartPageConfig extends PageConfig { |
14 | |
15 | private List columnOnePortletIds; |
16 | private List columnTwoPortletIds; |
17 | private List columnThreePortletIds; |
18 | private List subtabs; |
19 | private List portletAttributes; |
20 | |
21 | private String title; |
22 | |
23 | public OneStartPageConfig() { |
24 | columnOnePortletIds = new ArrayList(); |
25 | columnTwoPortletIds = new ArrayList(); |
26 | columnThreePortletIds = new ArrayList(); |
27 | subtabs = new ArrayList(); |
28 | portletAttributes = new ArrayList(); |
29 | } |
30 | |
31 | public void addSubtab(OneStartSubtab subtab) { |
32 | subtabs.add(subtab.getOrder() - 1, subtab); |
33 | } |
34 | |
35 | public void addPortletAttribute(PortletAttribute portletAttribute) { |
36 | portletAttributes.add(portletAttribute); |
37 | } |
38 | |
39 | public void addPortlet(String contextPath, String portletName, String portletId, String column, String columnOrder) { |
40 | int col = new Integer(column); |
41 | int order = new Integer(columnOrder); |
42 | |
43 | String id = PortletWindowConfig.createPortletId(contextPath, portletName, portletId); |
44 | |
45 | if (col == 1) { |
46 | columnOnePortletIds.add(order - 1, id); |
47 | } else if (col == 2) { |
48 | columnTwoPortletIds.add(order - 1, id); |
49 | } else if (col == 2) { |
50 | columnThreePortletIds.add(order - 1, id); |
51 | } |
52 | |
53 | // keep the superclass in synch -- be nice to remove this requirement |
54 | addPortlet(contextPath, portletName, portletId); |
55 | |
56 | // need to get the portlet just added and add the attributes to it |
57 | PortletAttributeManager.getInstance().setAttributes(id, portletAttributes); |
58 | |
59 | // get ready for the next portlet attributes |
60 | portletAttributes.clear(); |
61 | } |
62 | |
63 | public Collection getAllPortletIds() { |
64 | Collection allPortletIds = new ArrayList(getColumnOnePortletIds()); |
65 | allPortletIds.addAll(getColumnTwoPortletIds()); |
66 | allPortletIds.addAll(getColumnThreePortletIds()); |
67 | return allPortletIds; |
68 | } |
69 | |
70 | public Collection getColumnOnePortletIds() { |
71 | return columnOnePortletIds; |
72 | } |
73 | |
74 | public void setColumnOnePortletIds(List columnOnePortletIds) { |
75 | this.columnOnePortletIds = columnOnePortletIds; |
76 | } |
77 | |
78 | public List getColumnThreePortletIds() { |
79 | return columnThreePortletIds; |
80 | } |
81 | |
82 | public void setColumnThreePortletIds(List columnThreePortletIds) { |
83 | this.columnThreePortletIds = columnThreePortletIds; |
84 | } |
85 | |
86 | public List getColumnTwoPortletIds() { |
87 | return columnTwoPortletIds; |
88 | } |
89 | |
90 | public void setColumnTwoPortletIds(List columnTwoPortletIds) { |
91 | this.columnTwoPortletIds = columnTwoPortletIds; |
92 | } |
93 | |
94 | public List getSubtabs() { |
95 | List pageConfigs = new ArrayList(); |
96 | for (Iterator iter = subtabs.iterator(); iter.hasNext();) { |
97 | OneStartSubtab subtab = (OneStartSubtab) iter.next(); |
98 | pageConfigs.add(subtab.getOrder() - 1, OneStartResourceConfigReader.getFactory().getResourceConfig().getRenderConfig().getPageConfig(subtab.getPageName())); |
99 | } |
100 | return pageConfigs; |
101 | } |
102 | |
103 | public String getTitle() { |
104 | return title; |
105 | } |
106 | |
107 | public void setTitle(String title) { |
108 | this.title = title; |
109 | } |
110 | |
111 | |
112 | // Bit of a Hack: Pluto mades these package level and |
113 | // we need them for doing personalization. This hack |
114 | // keeps us from needing to modify their source as long |
115 | // as we keep this class in the same package :( |
116 | public void setOrderNumber(int number) { |
117 | super.setOrderNumber(number); |
118 | } |
119 | |
120 | public int getOrderNumber() { |
121 | return super.getOrderNumber(); |
122 | } |
123 | |
124 | } |