001: /*
002: * (C) Copyright 2000 - 2006 Nabh Information Systems, Inc.
003: *
004: * This program is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU General Public License
006: * as published by the Free Software Foundation; either version 2
007: * of the License, or (at your option) any later version.
008: *
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: *
018: */
019: package com.nabhinc.portal.model;
020:
021: import java.util.HashMap;
022: import java.util.Iterator;
023:
024: import javax.xml.bind.Unmarshaller;
025: import javax.xml.bind.annotation.XmlAttribute;
026: import javax.xml.bind.annotation.XmlElement;
027: import javax.xml.bind.annotation.XmlElements;
028: import javax.xml.bind.annotation.XmlRootElement;
029: import javax.xml.bind.annotation.XmlTransient;
030:
031: import com.nabhinc.core.Ownable;
032:
033: /**
034: *
035: *
036: * @author Padmanabh Dabke
037: * (c) 2006 Nabh Information Systems, Inc. All Rights Reserved.
038: */
039: @XmlRootElement(name="page")
040: public class PortalPage extends BaseProtectable implements Ownable,
041: Protectable {
042:
043: @XmlAttribute(name="name")
044: private String ppName = null;
045:
046: @XmlAttribute(name="index")
047: private int ppIndex = -1;
048:
049: @XmlElements({@XmlElement(name="renderable-map",type=RenderableMap.class),@XmlElement(name="portlet-window",type=PortletWindow.class),@XmlElement(name="renderable-list",type=RenderableList.class),@XmlElement(name="menu",type=MenuLayout.class),@XmlElement(name="tree",type=TreeLayout.class),@XmlElement(name="tabbed-panel",type=TabLayout.class),@XmlElement(name="horizontal-menu",type=HorizontalMenuLayout.class),@XmlElement(name="solo",type=SoloLayout.class),@XmlElement(name="cascading-menu",type=CascadingMenuLayout.class)})
050: private CompositeRenderable ppRenderable = null;
051:
052: @XmlTransient
053: private HashMap<String, Renderable> ppRenderableMap = new HashMap<String, Renderable>();
054:
055: private transient PortalApplication ppParentApplication = null;
056:
057: @XmlTransient
058: public String getName() {
059: return this .ppName;
060: }
061:
062: public void setName(String n) {
063: this .ppName = n;
064: }
065:
066: @XmlTransient
067: public int getIndex() {
068: return ppIndex;
069: }
070:
071: public void setIndex(int index) {
072: this .ppIndex = index;
073: }
074:
075: @XmlTransient
076: public CompositeRenderable getRenderable() {
077: return this .ppRenderable;
078: }
079:
080: public void setRenderable(CompositeRenderable r) {
081: this .ppRenderable = r;
082: r.setPortalPage(this );
083: }
084:
085: public Renderable getRenderable(String windowId) {
086: return this .ppRenderableMap.get(windowId);
087: }
088:
089: @XmlTransient
090: public PortalApplication getPortalApplication() {
091: return this .ppParentApplication;
092: }
093:
094: public void setPortalApplication(PortalApplication parent) {
095: this .ppParentApplication = parent;
096: if (this .ppIndex == -1)
097: this .ppIndex = parent.getNextPageID();
098: if (this .ppRenderable != null)
099: this .ppRenderable.setPortalPage(this );
100: }
101:
102: public int getMaxId() {
103: Iterator<Renderable> winIter = this .ppRenderableMap.values()
104: .iterator();
105: int maxId = -1;
106: while (winIter.hasNext()) {
107: int id = winIter.next().getNumericId();
108: if (id > maxId)
109: maxId = id;
110: }
111: return maxId;
112: }
113:
114: public void afterUnmarshal(Unmarshaller um, Object parent) {
115: super .afterUnmarshal(um, parent);
116: if (this .ppRenderable != null)
117: this .ppRenderable.setPortalPage(this );
118: }
119:
120: protected void addRenderable(Renderable pw) {
121: this .ppRenderableMap.put(Integer.toString(pw.getNumericId()),
122: pw);
123: }
124:
125: public PortletWindow getPortletWindow(String pwId) {
126: return (PortletWindow) getRenderable(pwId);
127: }
128:
129: public PortletWindow removePortletWindow(String pwId) {
130: PortletWindow pw = (PortletWindow) ppRenderableMap.remove(pwId);
131: if (ppRenderable != null) {
132: ppRenderable.removePortletWindow(pw);
133: }
134: return pw;
135: }
136:
137: public PortletWindow getDefaultPortletWindow() {
138: return this .ppRenderable.getDefaultPortletWindow();
139: }
140:
141: public long getOwnerId() {
142: return this .ppParentApplication.getOwnerId();
143: }
144:
145: public String getOwnerName() {
146: return this .ppParentApplication.getOwnerName();
147: }
148:
149: protected void setIdPrefix(String prefix) {
150: if (this .ppRenderable != null)
151: this .ppRenderable.setIdPrefix(prefix);
152:
153: }
154:
155: public boolean isMemberOf(String userName) {
156: return this.ppParentApplication.isMemberOf(userName);
157: }
158:
159: }
|