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.web;
017
018import org.apache.commons.lang.StringUtils;
019import org.kuali.rice.kew.impl.stuck.StuckDocumentIncident;
020import org.kuali.rice.kns.web.struts.form.KualiForm;
021
022import javax.servlet.http.HttpServletRequest;
023import java.util.ArrayList;
024import java.util.List;
025
026public class StuckDocumentsForm extends KualiForm {
027
028    private String notificationEnabled;
029    private String notificationCronExpression;
030    private String notificationFrom;
031    private String notificationTo;
032    private String notificationSubject;
033
034    private String autofixEnabled;
035    private String autofixCronExpression;
036    private String autofixQuietPeriod;
037    private String autofixMaxAttempts;
038    private String autofixNotificationEnabled;
039    private String autofixNotificationSubject;
040
041    private List<Status> statuses;
042
043    public StuckDocumentsForm() {
044        this.statuses = new ArrayList<Status>();
045        this.statuses.add(new Status("All", false));
046        for (StuckDocumentIncident.Status status : StuckDocumentIncident.Status.values()) {
047            this.statuses.add(new Status(status.name(), false));
048        }
049    }
050
051    @Override
052    public void populate(HttpServletRequest request) {
053        super.populate(request);
054        // determine if they set the status filter
055        String statusFilter = request.getParameter("statusFilter");
056        if (!StringUtils.isBlank(statusFilter)) {
057            for (Status status : this.statuses) {
058                if (status.getValue().equals(statusFilter)) {
059                    status.setSelected(true);
060                    break;
061                }
062            }
063        }
064    }
065
066    public String getNotificationEnabled() {
067        return notificationEnabled;
068    }
069
070    public void setNotificationEnabled(String notificationEnabled) {
071        this.notificationEnabled = notificationEnabled;
072    }
073
074    public String getNotificationCronExpression() {
075        return notificationCronExpression;
076    }
077
078    public void setNotificationCronExpression(String notificationCronExpression) {
079        this.notificationCronExpression = notificationCronExpression;
080    }
081
082    public String getNotificationFrom() {
083        return notificationFrom;
084    }
085
086    public void setNotificationFrom(String notificationFrom) {
087        this.notificationFrom = notificationFrom;
088    }
089
090    public String getNotificationTo() {
091        return notificationTo;
092    }
093
094    public void setNotificationTo(String notificationTo) {
095        this.notificationTo = notificationTo;
096    }
097
098    public String getNotificationSubject() {
099        return notificationSubject;
100    }
101
102    public void setNotificationSubject(String notificationSubject) {
103        this.notificationSubject = notificationSubject;
104    }
105
106    public String getAutofixEnabled() {
107        return autofixEnabled;
108    }
109
110    public void setAutofixEnabled(String autofixEnabled) {
111        this.autofixEnabled = autofixEnabled;
112    }
113
114    public String getAutofixCronExpression() {
115        return autofixCronExpression;
116    }
117
118    public void setAutofixCronExpression(String autofixCronExpression) {
119        this.autofixCronExpression = autofixCronExpression;
120    }
121
122    public String getAutofixQuietPeriod() {
123        return autofixQuietPeriod;
124    }
125
126    public void setAutofixQuietPeriod(String autofixQuietPeriod) {
127        this.autofixQuietPeriod = autofixQuietPeriod;
128    }
129
130    public String getAutofixMaxAttempts() {
131        return autofixMaxAttempts;
132    }
133
134    public void setAutofixMaxAttempts(String autofixMaxAttempts) {
135        this.autofixMaxAttempts = autofixMaxAttempts;
136    }
137
138    public String getAutofixNotificationEnabled() {
139        return autofixNotificationEnabled;
140    }
141
142    public void setAutofixNotificationEnabled(String autofixNotificationEnabled) {
143        this.autofixNotificationEnabled = autofixNotificationEnabled;
144    }
145
146    public String getAutofixNotificationSubject() {
147        return autofixNotificationSubject;
148    }
149
150    public void setAutofixNotificationSubject(String autofixNotificationSubject) {
151        this.autofixNotificationSubject = autofixNotificationSubject;
152    }
153
154    public List<Status> getStatuses() {
155        return statuses;
156    }
157
158    public void setStatuses(List<Status> statuses) {
159        this.statuses = statuses;
160    }
161
162    public Status getSelectedStatus() {
163        for (Status status : statuses) {
164            if (status.isSelected()) {
165                return status;
166            }
167        }
168        return null;
169    }
170
171    public static class Status {
172        private String value;
173        private boolean selected;
174        public Status(String value, boolean selected) {
175            this.value = value;
176            this.selected = selected;
177        }
178
179        public String getValue() {
180            return value;
181        }
182
183        public void setValue(String value) {
184            this.value = value;
185        }
186
187        public boolean isSelected() {
188            return selected;
189        }
190
191        public void setSelected(boolean selected) {
192            this.selected = selected;
193        }
194    }
195
196}