001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/calendar/tags/sakai_2-4-1/calendar-summary-tool/tool/src/java/org/sakaiproject/tool/summarycalendar/ui/EventSummary.java $
003: * $Id: EventSummary.java 22167 2007-03-05 10:10:26Z nuno@ufp.pt $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2006, 2007 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.sakaiproject.tool.summarycalendar.ui;
021:
022: import java.io.Serializable;
023: import java.util.ArrayList;
024: import java.util.Iterator;
025: import java.util.List;
026:
027: import org.sakaiproject.entity.api.Reference;
028: import org.sakaiproject.entity.api.ResourceProperties;
029: import org.sakaiproject.time.api.TimeRange;
030:
031: public class EventSummary implements Serializable {
032: private static final long serialVersionUID = 4943854683550852507L;
033:
034: private final int MAX_TEXT_SIZE = 30;
035:
036: private String displayName = "";
037: private String type = "";
038: private String description = "";
039: private String date = "";
040: private String location = "";
041: private String site = "";
042: private String url = "";
043: private String calendarRef = "";
044: private String eventRef = "";
045: private String groups = "";
046: private boolean hasAttachments = false;
047: private List attachments = new ArrayList();
048: private List attachmentsWrp = new ArrayList();
049:
050: public String getDisplayName() {
051: return displayName;
052: }
053:
054: public String getTruncatedDisplayName() {
055: return getTruncated(displayName);
056: }
057:
058: public void setDisplayName(String displayName) {
059: this .displayName = displayName;
060: }
061:
062: public String getDate() {
063: return date;
064: }
065:
066: public void setDate(TimeRange range) {
067: StringBuffer tmp = new StringBuffer();
068: tmp.append(range.firstTime().toStringLocalTime());
069: tmp.append(" - ");
070: tmp.append(range.lastTime().toStringLocalTime());
071: this .date = tmp.toString();
072: }
073:
074: public String getDescription() {
075: return description;
076: }
077:
078: public String getTruncatedDescription() {
079: return getTruncated(description);
080: }
081:
082: public void setDescription(String description) {
083: this .description = description;
084: }
085:
086: public boolean getHasLocation() {
087: return !location.equals("");
088: }
089:
090: public String getLocation() {
091: return location;
092: }
093:
094: public void setLocation(String location) {
095: this .location = location;
096: }
097:
098: public String getSite() {
099: return site;
100: }
101:
102: public String getTruncatedSite() {
103: return getTruncated(site);
104: }
105:
106: public void setSite(String site) {
107: this .site = site;
108: }
109:
110: public String getType() {
111: return type;
112: }
113:
114: public void setType(String type) {
115: this .type = type;
116: }
117:
118: public String getUrl() {
119: return url;
120: }
121:
122: public void setUrl(String url) {
123: this .url = url;
124: }
125:
126: public String getGroups() {
127: return groups;
128: }
129:
130: public void setGroups(String groups) {
131: this .groups = groups;
132: }
133:
134: public boolean getShowGroups() {
135: return !groups.equals("");
136: }
137:
138: private String getTruncated(String str) {
139: if (str.length() < MAX_TEXT_SIZE)
140: return str;
141: return str.substring(0, MAX_TEXT_SIZE).concat("...");
142: }
143:
144: public String getCalendarRef() {
145: return calendarRef;
146: }
147:
148: public void setCalendarRef(String calendarRef) {
149: this .calendarRef = calendarRef;
150: }
151:
152: public String getEventRef() {
153: return eventRef;
154: }
155:
156: public void setEventRef(String eventRef) {
157: this .eventRef = eventRef;
158: }
159:
160: public List getAttachments() {
161: return attachments;
162: }
163:
164: public void setAttachments(List attachments) {
165: setHasAttachments(attachments.size() > 0);
166: this .attachments = attachments;
167: this .attachmentsWrp = new ArrayList();
168: Iterator it = attachments.iterator();
169: while (it.hasNext()) {
170: Reference ref = (Reference) it.next();
171: AttachmentWrapper aw = new AttachmentWrapper();
172: aw.setUrl(ref.getUrl());
173: aw.setDisplayName(ref.getProperties().getProperty(
174: ResourceProperties.PROP_DISPLAY_NAME));
175: attachmentsWrp.add(aw);
176: }
177: }
178:
179: public boolean getHasAttachments() {
180: return this .hasAttachments;
181: }
182:
183: public void setHasAttachments(boolean hasAttachments) {
184: this .hasAttachments = hasAttachments;
185: }
186:
187: public List getAttachmentsWrapper() {
188: return this.attachmentsWrp;
189: }
190: }
|