001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/reports/tool/src/java/org/theospi/portfolio/reports/tool/DecoratedReport.java $
003: * $Id:DecoratedReport.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.tool;
021:
022: import org.theospi.portfolio.reports.model.Report;
023: import org.theospi.portfolio.reports.model.ReportParam;
024:
025: import java.util.ArrayList;
026: import java.util.Date;
027: import java.util.Iterator;
028: import java.util.List;
029:
030: /**
031: * This class allows the Report to interact with the view
032: *
033: */
034: public class DecoratedReport implements DecoratedAbstractResult {
035:
036: /** The link to the main tool */
037: private ReportsTool reportsTool = null;
038:
039: /** The report to decorate */
040: private Report report = null;
041:
042: /** The decorated report parameters */
043: private List reportParams = null;
044:
045: /** for telling the interface when a parameter is not correct */
046: private String paramErrorMsgs = "";
047:
048: /** informs the interface if the title is not proper */
049: private boolean invalidTitle = false;
050:
051: private boolean isOwner = true;
052:
053: public DecoratedReport(Report report, ReportsTool reportsTool) {
054: this .report = report;
055: this .reportsTool = reportsTool;
056: }
057:
058: public Report getReport() {
059: return report;
060: }
061:
062: public List getReportParams() {
063: if (reportParams == null) {
064: reportParams = new ArrayList();
065: if (report.getReportParams() != null) {
066: Iterator iter = report.getReportParams().iterator();
067: while (iter.hasNext()) {
068: ReportParam rp = (ReportParam) iter.next();
069:
070: DecoratedReportParam drp = new DecoratedReportParam(
071: rp, reportsTool);
072: drp.setIndex(reportParams.size());
073: reportParams.add(drp);
074: }
075: }
076: }
077: return reportParams;
078: }
079:
080: public boolean getInvalidTitle() {
081: return invalidTitle;
082: }
083:
084: public boolean getIsSaved() {
085: return report.getIsSaved();
086: }
087:
088: public boolean testInvalidateTitle() {
089: // reset all the vars
090: invalidTitle = false;
091:
092: // if no title, then error
093: if (report.getTitle() == null
094: || report.getTitle().trim().equals(""))
095: invalidTitle = true;
096:
097: return invalidTitle;
098: }
099:
100: /**
101: * this function loads the full report result and the report
102: * sets these in the tool
103: * @return String which page to go to next
104: */
105: public String processSelectReportResult() {
106: return reportsTool.processSelectLiveReport(this );
107: }
108:
109: public String processScheduleReport() {
110: return reportsTool.processScheduleReport(this );
111: }
112:
113: /**
114: * this function deletes the full report result and the report
115: * sets these in the tool
116: * @return String which page to go to next
117: */
118: public String processDelete() {
119: return reportsTool.processDeleteLiveReport(this );
120: }
121:
122: /**
123: * this function loads the full report result and the report
124: * sets these in the tool, it then puts the user on an edit page
125: * @return String which page to go to next
126: */
127: public String processEditReport() {
128: return reportsTool.processEditLiveReport(this );
129: }
130:
131: public String getResultType() {
132: return DecoratedAbstractResult.REPORT;
133: }
134:
135: public String getTitle() {
136: return report.getTitle();
137: }
138:
139: public Date getCreationDate() {
140: return report.getCreationDate();
141: }
142:
143: public boolean getIsLive() {
144: return report.getIsLive();
145: }
146:
147: public boolean getParamsAreValid() {
148: boolean isGood = true;
149:
150: paramErrorMsgs = "";
151:
152: for (Iterator iter = reportParams.iterator(); iter.hasNext();) {
153: DecoratedReportParam drp = (DecoratedReportParam) iter
154: .next();
155:
156: isGood &= drp.getIsValid();
157: }
158: return isGood;
159: }
160:
161: public void setParamErrorMessages(String paramErrorMsgs) {
162: this .paramErrorMsgs = paramErrorMsgs;
163: }
164:
165: public String getParamErrorMessages() {
166: return paramErrorMsgs;
167: }
168:
169: public boolean getIsOwner() {
170: return isOwner;
171: }
172:
173: public void setOwner(boolean owner) {
174: isOwner = owner;
175: }
176:
177: }
|