001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/reports/api/src/java/org/theospi/portfolio/reports/model/Report.java $
003: * $Id:Report.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.reports.model;
021:
022: import java.util.Date;
023: import java.util.Iterator;
024: import java.util.List;
025:
026: import org.sakaiproject.metaobj.shared.model.Id;
027: import org.theospi.portfolio.shared.model.OspException;
028:
029: /**
030: * After loading a report from the database you must call connectToDefinition
031: * to connect to one of a list of report definitions or setReportDefinition for a specific
032: * Report Definition. These are good for setting report definitions from the config file and
033: * from the database, respectively.
034: * @author andersjb
035: *
036: */
037: public class Report {
038: /** the unique identifier for the report */
039: private Id reportId;
040:
041: /** the link to the report definition */
042: private ReportDefinition reportDefinition = null;
043:
044: private ReportDefinitionXmlFile reportDefitionXmlFile = null;
045: /** the database link to the report definition */
046: private String reportDefIdMark = null;
047:
048: /** the owner of the report */
049: private String userId;
050:
051: /** the title of the report */
052: private String title;
053:
054: /** the keyword for the report */
055: private String keywords;
056:
057: /** the description for the report */
058: private String description;
059:
060: /** the parameters for the query in the report */
061: private boolean isLive;
062:
063: private ReportResult liveResult = null;
064:
065: /** the defaultXsl for the report */
066: private Date creationDate;
067:
068: /** the type of report */
069: private String type;
070:
071: /** the list of report parameters for the report */
072: private List reportParams;
073:
074: /** when the report is live it matters if the report is saved or not */
075: private boolean isSaved = false;
076:
077: /** when the report is active can show up in the list of live reports */
078: private boolean display = true;
079:
080: /**
081: * the getter for the reportId property
082: */
083: public Report() {
084:
085: }
086:
087: /**
088: * the getter for the reportId property
089: */
090:
091: public Report(ReportDefinition reportDefinition) {
092: setReportDefinition(reportDefinition);
093: }
094:
095: public ReportDefinitionXmlFile getReportDefitionXmlFile() {
096: return reportDefitionXmlFile;
097: }
098:
099: public void setReportDefitionXmlFile(
100: ReportDefinitionXmlFile reportDefitionXmlFile) {
101: this .reportDefitionXmlFile = reportDefitionXmlFile;
102: }
103:
104: /**
105: * the getter for the reportId property
106: * @return String the unique identifier
107: */
108: public Id getReportId() {
109: return reportId;
110: }
111:
112: /**
113: * the setter for the reportId property. This is set by the bean
114: * and by hibernate.
115: * @param reportId String
116: */
117: public void setReportId(Id reportId) {
118: this .reportId = reportId;
119: }
120:
121: /**
122: * the getter for the reportDefinition property
123: * @return ReportDefinition the unique identifier
124: */
125: public ReportDefinition getReportDefinition() {
126: return reportDefinition;
127: }
128:
129: /**
130: * the setter for the reportDefinition property. This is set by the bean
131: * and by hibernate.
132: * @param reportDefinition String
133: */
134: public void setReportDefinition(ReportDefinition reportDefinition) {
135: if (this .reportDefinition != null
136: && reportDefinition != this .reportDefinition)
137: throw new OspException(
138: "A report cannot change it's report definition");
139:
140: this .reportDefinition = reportDefinition;
141: type = reportDefinition.getSiteType();
142: }
143:
144: /**
145: * This is a way of separating the report definition from the report in the database
146: * this is a temp solution while the report definitions aren't being stored in the database
147: * @return String
148: */
149: public String getReportDefIdMark() {
150: if (reportDefinition == null)
151: return reportDefIdMark;
152: return reportDefinition.getIdString();
153: }
154:
155: /**
156: * this is the link to report definition
157: * @param reportDefIdMark String
158: */
159: public void setReportDefIdMark(String reportDefIdMark) {
160: if (reportDefinition != null)
161: if (!reportDefIdMark.equals(reportDefinition.getIdString()))
162: reportDefinition = null;
163: this .reportDefIdMark = reportDefIdMark;
164: }
165:
166: /**
167: * this is links this report to the report definition.
168: * It searches for the definition and if found it then links the
169: * report parameters to the report definition parameters
170: * @param reportDefIdMark String
171: */
172: public void connectToDefinition(List reportDefs) {
173: reportParams.size();
174: if (reportDefIdMark != null && reportDefinition == null) {
175: Iterator iter = reportDefs.iterator();
176:
177: while (iter.hasNext()) {
178: ReportDefinition rd = (ReportDefinition) iter.next();
179: if (rd.getIdString().equals(reportDefIdMark)) {
180: reportDefinition = rd;
181: break;
182: }
183: }
184: if (reportDefinition != null) {
185: iter = this .getReportParams().iterator();
186: while (iter.hasNext()) {
187: ReportParam rp = (ReportParam) iter.next();
188:
189: Iterator defIter = reportDefinition
190: .getReportDefinitionParams().iterator();
191: while (defIter.hasNext()) {
192: ReportDefinitionParam rdp = (ReportDefinitionParam) defIter
193: .next();
194: if (rp.getReportDefParamIdMark().equals(
195: rdp.getIdString())) {
196: rp.setReportDefinitionParam(rdp);
197: rp.setReport(this );
198: break;
199: }
200: }
201: }// end while(looping through report params)
202: }
203: }
204: }
205:
206: /**
207: * the getter for the userId property
208: * @return String the userId
209: */
210: public String getUserId() {
211: return userId;
212: }
213:
214: /**
215: * the setter for the userId property. This is set by the bean
216: * and by hibernate.
217: * @param userId String
218: */
219: public void setUserId(String userId) {
220: this .userId = userId;
221: }
222:
223: /**
224: * the getter for the title property
225: * @return String the title
226: */
227: public String getTitle() {
228: return title;
229: }
230:
231: /**
232: * the setter for the title property. This is set by the bean
233: * and by hibernate.
234: * @param title String
235: */
236: public void setTitle(String title) {
237: this .title = title;
238: }
239:
240: /**
241: * the getter for the keywords property
242: * @return String the keywords
243: */
244: public String getKeywords() {
245: return keywords;
246: }
247:
248: /**
249: * the setter for the keywords property. This is set by the bean
250: * and by hibernate.
251: * @param keywords String
252: */
253: public void setKeywords(String keywords) {
254: this .keywords = keywords;
255: }
256:
257: /**
258: * the getter for the description property
259: * @return String the description
260: */
261: public String getDescription() {
262: return description;
263: }
264:
265: /**
266: * the setter for the description property. This is set by the bean
267: * and by hibernate.
268: * @param description String
269: */
270: public void setDescription(String description) {
271: this .description = description;
272: }
273:
274: /**
275: * the getter for the isLive property
276: * @return String the isLive
277: */
278: public boolean getIsLive() {
279: return isLive;
280: }
281:
282: /**
283: * the setter for the isLive property. This is set by the bean
284: * and by hibernate.
285: * @param isLive List
286: */
287: public void setIsLive(boolean isLive) {
288: this .isLive = isLive;
289: }
290:
291: /**
292: * the getter for the creationDate property
293: * @return Date the creationDate
294: */
295: public Date getCreationDate() {
296: return creationDate;
297: }
298:
299: /**
300: * the setter for the creationDate property. This is set by the bean
301: * and by hibernate.
302: * @param params Date
303: */
304: public void setCreationDate(Date creationDate) {
305: this .creationDate = creationDate;
306: }
307:
308: /**
309: * the getter for the type property
310: * @return String the type
311: */
312: public String getType() {
313: return type;
314: }
315:
316: /**
317: * the setter for the type property. This is set by the bean
318: * and by hibernate.
319: * @param keywords String
320: */
321: public void setType(String type) {
322: this .type = type;
323: }
324:
325: /**
326: * the getter for the reportParams property
327: * @return List the reportParams
328: */
329: public List getReportParams() {
330: return reportParams;
331: }
332:
333: /**
334: * the setter for the reportParams property. This is set by hibernate.
335: * @param reportParams List
336: */
337: public void setReportParams(List reportParams) {
338: this .reportParams = reportParams;
339: }
340:
341: /**
342: * the getter for the isSaved property
343: * @return boolean the isSaved
344: */
345: public boolean getIsSaved() {
346: return isSaved;
347: }
348:
349: /**
350: * the setter for the isSaved property. This is set by the bean
351: * and by hibernate.
352: * @param isSaved boolean
353: */
354: public void setIsSaved(boolean isSaved) {
355: this .isSaved = isSaved;
356: }
357:
358: /**
359: * the getter for the active property
360: * @return String the active
361: */
362: public boolean getDisplay() {
363: return display;
364: }
365:
366: /**
367: * the setter for the active property. This is set by hibernate.
368: * @param active boolean
369: */
370: public void setDisplay(boolean display) {
371: this.display = display;
372: }
373: }
|