001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/presentation/api/src/java/org/theospi/portfolio/presentation/model/PresentationTemplate.java $
003: * $Id:PresentationTemplate.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.theospi.portfolio.presentation.model;
021:
022: import java.io.Serializable;
023: import java.util.Collection;
024: import java.util.Date;
025: import java.util.HashSet;
026: import java.util.Iterator;
027: import java.util.Set;
028: import java.util.TreeSet;
029:
030: import org.sakaiproject.metaobj.shared.model.Agent;
031: import org.sakaiproject.metaobj.shared.model.Id;
032: import org.sakaiproject.metaobj.shared.model.IdentifiableObject;
033: import org.theospi.portfolio.shared.model.Node;
034:
035: public class PresentationTemplate extends IdentifiableObject implements
036: Serializable {
037: private String name;
038: private String description;
039: private Date created;
040: private Date modified;
041: private transient Agent owner;
042: private Id renderer;
043: private Id propertyPage;
044: private String documentRoot;
045: private boolean active;
046: private boolean includeHeaderAndFooter;
047: private Set items = new TreeSet(new PresentationItemComparator());
048: private Set files = new HashSet();
049: private boolean published = false;
050: private String markup;
051: private String siteId;
052: private Id propertyFormType;
053: transient private Set deletedItems = new HashSet();
054: transient private boolean validate = true;
055: transient private boolean newObject = false;
056:
057: /**
058: * used in web form
059: */
060: private PresentationItemDefinition item = new PresentationItemDefinition();
061:
062: /**
063: * used in web form
064: */
065: private TemplateFileRef fileRef = new TemplateFileRef();
066:
067: transient private String rendererName;
068: transient private String propertyPageName;
069:
070: static final long serialVersionUID = -6220810277272518156l;
071:
072: public TemplateFileRef getFileRef() {
073: return fileRef;
074: }
075:
076: public void setFileRef(TemplateFileRef fileRef) {
077: this .fileRef = fileRef;
078: }
079:
080: public PresentationItemDefinition getItem() {
081: return item;
082: }
083:
084: public void setItem(PresentationItemDefinition item) {
085: this .item = item;
086: }
087:
088: public String getSiteId() {
089: return siteId;
090: }
091:
092: public void setSiteId(String siteId) {
093: this .siteId = siteId;
094: }
095:
096: public String getName() {
097: return name;
098: }
099:
100: public String getDescription() {
101: return description;
102: }
103:
104: public Date getCreated() {
105: return created;
106: }
107:
108: public Date getModified() {
109: return modified;
110: }
111:
112: public Agent getOwner() {
113: return owner;
114: }
115:
116: public Id getRenderer() {
117: return renderer;
118: }
119:
120: public Id getPropertyPage() {
121: return propertyPage;
122: }
123:
124: public String getDocumentRoot() {
125: return documentRoot;
126: }
127:
128: public boolean isActive() {
129: return active;
130: }
131:
132: public boolean getIncludeHeaderAndFooter() {
133: return isIncludeHeaderAndFooter();
134: }
135:
136: public void setName(String name) {
137: this .name = name;
138: }
139:
140: public void setDescription(String description) {
141: this .description = description;
142: }
143:
144: public void setCreated(Date created) {
145: this .created = created;
146: }
147:
148: public void setModified(Date modified) {
149: this .modified = modified;
150: }
151:
152: public void setOwner(Agent owner) {
153: this .owner = owner;
154: }
155:
156: public void setRenderer(Id renderer) {
157: this .renderer = renderer;
158: }
159:
160: public void setPropertyPage(Id propertyPage) {
161: this .propertyPage = propertyPage;
162: }
163:
164: public void setDocumentRoot(String documentRoot) {
165: this .documentRoot = documentRoot;
166: }
167:
168: public void setActive(boolean active) {
169: this .active = active;
170: }
171:
172: public boolean isIncludeHeaderAndFooter() {
173: return includeHeaderAndFooter;
174: }
175:
176: public void setIncludeHeaderAndFooter(boolean includeHeaderAndFooter) {
177: this .includeHeaderAndFooter = includeHeaderAndFooter;
178: }
179:
180: public Collection getItemDefinitions() {
181: return items;
182: }
183:
184: public void orderItemDefs() {
185: Set ordered = getSortedItems();
186: int index = 1;
187: for (Iterator i = ordered.iterator(); i.hasNext();) {
188: PresentationItemDefinition item = (PresentationItemDefinition) i
189: .next();
190: item.setSequence(index);
191: index++;
192: }
193: }
194:
195: public Set getItems() {
196: return items;
197: }
198:
199: public void setItems(Set items) {
200: this .items = items;
201: }
202:
203: public Set getSortedItems() {
204: Set returned = new TreeSet(new PresentationItemComparator());
205: returned.addAll(items);
206: return returned;
207: }
208:
209: public Set getFiles() {
210: return files;
211: }
212:
213: public void setFiles(Set files) {
214: this .files = files;
215: }
216:
217: public boolean isPublished() {
218: return published;
219: }
220:
221: public void setPublished(boolean published) {
222: this .published = published;
223: }
224:
225: public String getMarkup() {
226: return markup;
227: }
228:
229: public void setMarkup(String markup) {
230: this .markup = markup;
231: }
232:
233: public void setPropertyPageNode(Node propertyPageNode) {
234: this .propertyPageName = propertyPageNode.getDisplayName();
235: }
236:
237: public void setRendererNode(Node rendererNode) {
238: this .rendererName = rendererNode.getDisplayName();
239: }
240:
241: public String getPropertyPageName() {
242: return propertyPageName;
243: }
244:
245: public void setPropertyPageName(String propertyPageName) {
246: this .propertyPageName = propertyPageName;
247: }
248:
249: public String getRendererName() {
250: return rendererName;
251: }
252:
253: public void setRendererName(String rendererName) {
254: this .rendererName = rendererName;
255: }
256:
257: public void setItemSequence(String[] itemSequence) {
258: int index = 0;
259: Set items = getSortedItems();
260: for (Iterator i = items.iterator(); i.hasNext();) {
261: PresentationItemDefinition item = (PresentationItemDefinition) i
262: .next();
263: if (index < itemSequence.length) {
264: item.setNewSequence(Integer
265: .valueOf(itemSequence[index]).intValue());
266: }
267: index++;
268: }
269: orderItemDefs();
270: }
271:
272: public Set getDeletedItems() {
273: return deletedItems;
274: }
275:
276: public void setDeletedItems(Set deletedItems) {
277: this .deletedItems = deletedItems;
278: }
279:
280: public boolean isValidate() {
281: return validate;
282: }
283:
284: public void setValidate(boolean validate) {
285: this .validate = validate;
286: }
287:
288: public boolean isNewObject() {
289: return newObject;
290: }
291:
292: public void setNewObject(boolean newObject) {
293: this .newObject = newObject;
294: }
295:
296: /**
297: * @return the propertyFormType
298: */
299: public Id getPropertyFormType() {
300: return propertyFormType;
301: }
302:
303: /**
304: * @param propertyFormType the propertyFormType to set
305: */
306: public void setPropertyFormType(Id propertyFormType) {
307: this.propertyFormType = propertyFormType;
308: }
309: }
|