001/**
002 * Copyright 2005-2017 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.routelog.web;
017
018import org.kuali.rice.core.api.config.property.ConfigContext;
019import org.kuali.rice.kew.actionrequest.ActionRequestValue;
020import org.kuali.rice.kns.web.struts.form.KualiForm;
021import org.kuali.rice.krad.util.UrlFactory;
022
023import java.util.ArrayList;
024import java.util.List;
025import java.util.Properties;
026
027
028/**
029 * The Struts ActionForm used with {@link RouteLogAction} to display the routelog.
030 *
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033public class RouteLogForm extends KualiForm {
034
035    private static final long serialVersionUID = -3997667167734868281L;
036    private String methodToCall = "";
037    private String documentId;
038    private List rootRequests = new ArrayList();
039    private int pendingActionRequestCount;
040    private List<ActionRequestValue> futureRootRequests = new ArrayList<ActionRequestValue>();
041    private int futureActionRequestCount;
042    private boolean showFuture;
043    private String showFutureError;
044    private boolean removeHeader;
045    private boolean lookFuture;
046    private boolean showNotes;
047    private String docId;
048    private String returnUrlLocation = null;
049    private boolean showCloseButton = false;
050    private String newRouteLogActionMessage;
051    private boolean enableLogAction = false;
052    private boolean showBackButton;
053    private int internalNavCount;
054
055    public boolean isShowCloseButton() {
056        return showCloseButton;
057    }
058    public void setShowCloseButton(boolean showCloseButton) {
059        this.showCloseButton = showCloseButton;
060    }
061    public String getReturnUrlLocation() {
062        return returnUrlLocation;
063    }
064    public void setReturnUrlLocation(String returnUrlLocation) {
065        this.returnUrlLocation = returnUrlLocation;
066    }
067    public String getDocId() {
068        return docId;
069    }
070    public void setDocId(String docId) {
071        this.docId = docId;
072    }
073    public boolean isShowFutureHasError() {
074        return !org.apache.commons.lang.StringUtils.isEmpty(getShowFutureError());
075    }
076    public String getShowFutureError() {
077        return showFutureError;
078    }
079    public void setShowFutureError(String showFutureError) {
080        this.showFutureError = showFutureError;
081    }
082    public boolean isShowFuture() {
083        return showFuture;
084    }
085    public void setShowFuture(boolean showReportURL) {
086        this.showFuture = showReportURL;
087    }
088    public String getMethodToCall() {
089        return methodToCall;
090    }
091    public void setMethodToCall(String methodToCall) {
092        this.methodToCall = methodToCall;
093    }
094    public String getDocumentId() {
095        return documentId;
096    }
097    public void setDocumentId(String documentId) {
098        this.documentId = documentId;
099    }
100
101    public int getPendingActionRequestCount() {
102        return pendingActionRequestCount;
103    }
104
105    public void setPendingActionRequestCount(int pendingActionRequestCount) {
106        this.pendingActionRequestCount = pendingActionRequestCount;
107    }
108
109    public List getRootRequests() {
110        return rootRequests;
111    }
112    public void setRootRequests(List rootRequests) {
113        this.rootRequests = rootRequests;
114    }
115    public int getFutureActionRequestCount() {
116        return futureActionRequestCount;
117    }
118    public void setFutureActionRequestCount(int futureActionRequestCount) {
119        this.futureActionRequestCount = futureActionRequestCount;
120    }
121    public List getFutureRootRequests() {
122        return futureRootRequests;
123    }
124    public void setFutureRootRequests(List futureRootRequests) {
125        this.futureRootRequests = futureRootRequests;
126    }
127    public boolean isRemoveHeader() {
128        return removeHeader;
129    }
130    public void setRemoveHeader(boolean removeBar) {
131        this.removeHeader = removeBar;
132    }
133    public boolean isLookFuture() {
134        return lookFuture;
135    }
136    public void setLookFuture(boolean showFutureLink) {
137        this.lookFuture = showFutureLink;
138    }
139    public boolean isShowNotes() {
140        return showNotes;
141    }
142    public void setShowNotes(boolean showNotes) {
143        this.showNotes = showNotes;
144    }
145
146    public String getNewRouteLogActionMessage() {
147        return this.newRouteLogActionMessage;
148    }
149
150    public void setNewRouteLogActionMessage(String newRouteLogActionMessage) {
151        this.newRouteLogActionMessage = newRouteLogActionMessage;
152    }
153
154    public boolean isEnableLogAction() {
155        return this.enableLogAction;
156    }
157
158    public void setEnableLogAction(boolean enableLogAction) {
159        this.enableLogAction = enableLogAction;
160    }
161
162    public boolean isShowBackButton() {
163        return showBackButton;
164    }
165
166    public void setShowBackButton(boolean showBackButton) {
167        this.showBackButton = showBackButton;
168    }
169
170    public int getInternalNavCount() {
171        return internalNavCount;
172    }
173
174    public void setInternalNavCount(int internalNavCount) {
175        this.internalNavCount = internalNavCount;
176    }
177
178    public int getNextNavCount() {
179        return getInternalNavCount() + 1;
180    }
181
182    public int getBackCount() {
183        return - getNextNavCount();
184    }
185
186    public String getHeaderMenuBar() {
187        Properties parameters = new Properties();
188        parameters.put("showFuture", Boolean.toString(isShowFuture()));
189        parameters.put("showNotes", Boolean.toString(isShowNotes()));
190        parameters.put("showBackButton", Boolean.toString(isShowBackButton()));
191        parameters.put("internalNavCount", Integer.toString(getNextNavCount()));
192        if (getDocumentId() != null) {
193            parameters.put("documentId", getDocumentId());
194        }
195        if (getDocId() != null) {
196            parameters.put("docId", getDocId());
197        }
198        if (getReturnUrlLocation() != null) {
199            parameters.put("backUrl", getReturnUrlLocation());
200        }
201        String url = UrlFactory.parameterizeUrl("RouteLog.do", parameters);
202        String krBaseUrl = ConfigContext.getCurrentContextConfig().getKRBaseURL();
203        url = "<div class=\"lookupcreatenew\" title=\"Refresh\"><a href=\"" + url + "\"><img src=\""+krBaseUrl+"/images/tinybutton-refresh.gif\" alt=\"refresh\"></a></div>";
204        return url;
205    }
206}