001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/reports/api/src/java/org/theospi/portfolio/reports/model/ReportDefinition.java $
003: * $Id:ReportDefinition.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 org.sakaiproject.db.api.SqlService;
023: import org.sakaiproject.metaobj.shared.model.Id;
024:
025: import java.util.Iterator;
026: import java.util.List;
027: import java.util.Map;
028:
029: public class ReportDefinition {
030: private static final String DEFAULT_VIEW_LINK = "/reportxsls/default.xsl";
031:
032: /** the unique identifier for the report definition */
033: private Id reportDefId = null;
034:
035: /** the unique identifier for the report definition */
036: private String idString = null;
037:
038: private boolean usesWizard = true;
039: /** the title of the report definition */
040: private String title;
041:
042: /** the sql query for the report definition */
043: private List query;
044:
045: private Map vendorQuery;
046: /** the keyword for the report definition */
047: private String keywords;
048:
049: /** the description for the report definition */
050: private String description;
051:
052: /** the defaultXsl for the report definition */
053: private ReportXsl defaultXsl;
054:
055: /** the exportXsl for the report definition */
056: private String exportXsl;
057:
058: /** the link to the report parameters for the report definition */
059: private List reportDefinitionParams;
060:
061: /** whether or not this report uses the datawarehouse, defaults to true */
062: private Boolean usesWarehouse = Boolean.TRUE;
063:
064: /** the defaultXsl for the report definition */
065: private List xsls;
066:
067: /** the type of report defining who can view the report definition and derived data */
068: private String siteType;
069:
070: private List userRoles;
071:
072: /** list of any special result processors this report needs.
073: * These should be of type ResultProcessor
074: * @see ResultProcessor
075: */
076: private List resultProcessors;
077: private String role;
078:
079: private boolean dbLoaded = false;
080:
081: private String paramTitle;
082:
083: private String paramInstruction;
084:
085: private String vendor;
086:
087: /**
088: * when the report is finished loading the link in the report parameters
089: * needs to be set to the owning report definition
090: *
091: */
092: public void finishLoading() {
093: if (reportDefinitionParams == null)
094: return;
095: Iterator iter = reportDefinitionParams.iterator();
096:
097: while (iter.hasNext()) {
098: ReportDefinitionParam rdp = (ReportDefinitionParam) iter
099: .next();
100:
101: rdp.setReportDefinition(this );
102: }
103: }
104:
105: /**
106: * the getter for the reportDefId property
107: * @return String the unique identifier
108: */
109: public Id getReportDefId() {
110: return reportDefId;
111: }
112:
113: /**
114: * the setter for the reportDefId property. This is set by the bean
115: * and by hibernate.
116: * @param reportDefId String
117: */
118: public void setReportDefId(Id reportDefId) {
119: this .reportDefId = reportDefId;
120: }
121:
122: /**
123: * return the id as a string. return the actual id if there is one then
124: * the configured definition id if not
125: * @return String
126: */
127: public String getIdString() {
128: if (reportDefId == null)
129: return idString;
130: return reportDefId.getValue();
131: }
132:
133: public void setIdString(String idString) {
134: this .idString = idString;
135: }
136:
137: public SqlService getSqlService() {
138: return org.sakaiproject.db.cover.SqlService.getInstance();
139: }
140:
141: /**
142: * the getter for the title property
143: * @return String the title
144: */
145: public String getTitle() {
146: return title;
147: }
148:
149: /**
150: * the setter for the title property. This is set by the bean
151: * and by hibernate.
152: * @param reportDefId String
153: */
154: public void setTitle(String title) {
155: this .title = title;
156: }
157:
158: public String getVendor() {
159: return getSqlService().getVendor();
160: }
161:
162: /**
163: * the getter for the query property
164: * @return String the query
165: */
166: public List getQuery() {
167: if (getVendorQuery() != null) {
168: for (Iterator i = getVendorQuery().entrySet().iterator(); i
169: .hasNext();) {
170: Map.Entry entry = (Map.Entry) i.next();
171: String vendor = (String) entry.getKey();
172: if (vendor.equals(getVendor())) {
173: List query = (List) entry.getValue();
174: return query;
175: }
176: }
177: }
178: return this .query;
179: }
180:
181: /**
182: * the setter for the query property. This is set by the bean
183: * and by hibernate.
184: * @param query String
185: */
186: public void setQuery(List query) {
187: this .query = query;
188: }
189:
190: /**
191: * the getter for the keywords property
192: * @return String the keywords
193: */
194: public String getKeywords() {
195: return keywords;
196: }
197:
198: /**
199: * the setter for the keywords property. This is set by the bean
200: * and by hibernate.
201: * @param keywords String
202: */
203: public void setKeywords(String keywords) {
204: this .keywords = keywords;
205: }
206:
207: /**
208: * the getter for the description property
209: * @return String the description
210: */
211: public String getDescription() {
212: return description;
213: }
214:
215: /**
216: * the setter for the description property. This is set by the bean
217: * and by hibernate.
218: * @param description String
219: */
220: public void setDescription(String description) {
221: this .description = description;
222: }
223:
224: /**
225: * the getter for the defaultXsl property
226: * @return ReportXsl the defaultXsl
227: */
228: public ReportXsl getDefaultXsl() {
229: if (defaultXsl == null) {
230: defaultXsl = new ReportXsl();
231: defaultXsl.setIsExport(false);
232: defaultXsl.setReportDefinition(this );
233: defaultXsl.setXslLink(DEFAULT_VIEW_LINK);
234: }
235: return defaultXsl;
236: }
237:
238: /**
239: * the setter for the defaultXsl property. This is set by the bean
240: * and by hibernate.
241: * @param defaultXsl ReportXsl
242: */
243: public void setDefaultXsl(ReportXsl defaultXsl) {
244: this .defaultXsl = defaultXsl;
245: }
246:
247: /**
248: * the getter for the exportXsl property
249: * @return String the exportXsl
250: */
251: public String getExportXsl() {
252: return exportXsl;
253: }
254:
255: /**
256: * the setter for the exportXsl property. This is set by the bean
257: * and by hibernate.
258: * @param exportXsl List
259: */
260: public void setExportXsl(String exportXsl) {
261: this .exportXsl = exportXsl;
262: }
263:
264: /**
265: * the getter for the reportDefinitionParams property
266: * @return List of ReportDefinitionParam
267: */
268: public List getReportDefinitionParams() {
269: return reportDefinitionParams;
270: }
271:
272: /**
273: * the setter for the reportDefinitionParams property. This is set by the bean
274: * and by hibernate.
275: * @param reportDefinitionParams List
276: */
277: public void setReportDefinitionParams(List reportDefinitionParams) {
278: this .reportDefinitionParams = reportDefinitionParams;
279: }
280:
281: /**
282: * the getter for the xsls property
283: * @return List the xsls
284: */
285: public List getXsls() {
286: return xsls;
287: }
288:
289: /**
290: * the setter for the xsl property. This is set by the bean
291: * and by hibernate.
292: * @param xsl List
293: */
294: public void setXsls(List xsls) {
295: this .xsls = xsls;
296: }
297:
298: /**
299: * the getter for the type property
300: * @return String the type
301: */
302: public String getSiteType() {
303: return siteType;
304: }
305:
306: /**
307: * the setter for the type property. This is set by the bean
308: * and by hibernate.
309: * @param keywords String
310: */
311: public void setSiteType(String type) {
312: this .siteType = type;
313: }
314:
315: /** list of any special result processors this report needs.
316: * These should be of type ResultProcessor
317: * @see ResultProcessor
318: */
319: public List getResultProcessors() {
320: return resultProcessors;
321: }
322:
323: public void setResultProcessors(List resultProcessors) {
324: this .resultProcessors = resultProcessors;
325: }
326:
327: public String getRole() {
328: return role;
329: }
330:
331: public void setRole(String role) {
332: this .role = role;
333: }
334:
335: public ReportXsl findReportXsl(String link) {
336: Iterator iter = xsls.iterator();
337:
338: while (iter.hasNext()) {
339: ReportXsl xslInfo = (ReportXsl) iter.next();
340: if (xslInfo.getXslLink() != null
341: && xslInfo.getXslLink().equals(link))
342: return xslInfo;
343: }
344: return null;
345: }
346:
347: public ReportXsl findReportXslByRuntimeId(String runtimeId) {
348: Iterator iter = xsls.iterator();
349:
350: while (iter.hasNext()) {
351: ReportXsl xslInfo = (ReportXsl) iter.next();
352: if (xslInfo.getXslLink() != null
353: && xslInfo.getRuntimeId().equals(runtimeId))
354: return xslInfo;
355: }
356: return null;
357: }
358:
359: public List getUserRoles() {
360: return userRoles;
361: }
362:
363: public void setUserRoles(List userRoles) {
364: this .userRoles = userRoles;
365: }
366:
367: public boolean isUsesWizard() {
368: return usesWizard;
369: }
370:
371: public void setUsesWizard(boolean usesWizard) {
372: this .usesWizard = usesWizard;
373: }
374:
375: /**
376: * Specifies whether or not this report is keyed on the data warehouse tables
377: * @return
378: */
379: public Boolean getUsesWarehouse() {
380: return usesWarehouse;
381: }
382:
383: /**
384: * sets whether or not this report is keyed on the data warehouse tables
385: * @param usesWarehouse
386: */
387: public void setUsesWarehouse(Boolean usesWarehouse) {
388: this .usesWarehouse = usesWarehouse;
389: }
390:
391: public boolean isDbLoaded() {
392: return dbLoaded;
393: }
394:
395: public void setDbLoaded(boolean dbLoaded) {
396: this .dbLoaded = dbLoaded;
397: }
398:
399: public String getParamTitle() {
400: return paramTitle;
401: }
402:
403: public void setParamTitle(String paramTitle) {
404: this .paramTitle = paramTitle;
405: }
406:
407: public String getParamInstruction() {
408: return paramInstruction;
409: }
410:
411: public void setParamInstruction(String paramInstruction) {
412: this .paramInstruction = paramInstruction;
413: }
414:
415: public Map getVendorQuery() {
416: return vendorQuery;
417: }
418:
419: public void setVendorQuery(Map vendorQuery) {
420: this.vendorQuery = vendorQuery;
421: }
422: }
|