001: /*
002: * Created by IntelliJ IDEA.
003: * User: sg426575
004: * Date: Mar 31, 2005
005: * Time: 8:55:31 PM
006: */
007: package com.technoetic.xplanner.forms;
008:
009: import javax.servlet.http.HttpServletRequest;
010:
011: import org.apache.commons.lang.StringUtils;
012: import org.apache.struts.action.*;
013:
014: public class ImportStoriesForm extends ImportForm {
015:
016: private String worksheetName = null;
017: private String estimateColumn = null;
018: private String statusColumn = null;
019: private String titleColumn = null;
020: private String endDateColumn = null;
021: private String priorityColumn = null;
022: private boolean onlyIncomplete = false;
023: private String completedStatus = null;
024:
025: private static final String NO_WORKSHEET_NAME_KEY = "import.status.worksheet_name";
026: public static final String NO_TITLE_COLUMN_KEY = "import.status.no_title_column";
027: public static final String NO_END_DATE_COLUMN_KEY = "import.status.no_end_date_column";
028: public static final String NO_PRIORITY_COLUMN_KEY = "import.status.no_priority_column";
029: private static final String NO_COMPLETED_STORY_STATUS = "import.status.no_completed_story_status";
030:
031: public void reset(ActionMapping mapping, HttpServletRequest request) {
032: super .reset(mapping, request);
033: onlyIncomplete = false;
034: }
035:
036: public ActionErrors validate(ActionMapping mapping,
037: HttpServletRequest request) {
038: ActionErrors errors = super .validate(mapping, request);
039: if (isSubmitted()) {
040: validate(isNotEmpty(worksheetName), errors,
041: NO_WORKSHEET_NAME_KEY);
042: validate(isNotEmpty(titleColumn), errors,
043: NO_TITLE_COLUMN_KEY);
044: validate(isNotEmpty(endDateColumn), errors,
045: NO_END_DATE_COLUMN_KEY);
046: validate(isNotEmpty(priorityColumn), errors,
047: NO_PRIORITY_COLUMN_KEY);
048: validate(onlyIncomplete && isNotEmpty(completedStatus),
049: errors, ImportStoriesForm.NO_COMPLETED_STORY_STATUS);
050: }
051: return errors;
052: }
053:
054: private boolean isNotEmpty(String worksheetName) {
055: return StringUtils.isEmpty(worksheetName);
056: }
057:
058: private void validate(boolean condition, ActionErrors errors,
059: String key) {
060: if (condition) {
061: errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(key));
062: }
063: }
064:
065: public String getTitleColumn() {
066: return titleColumn;
067: }
068:
069: public void setTitleColumn(String titleColumn) {
070: this .titleColumn = titleColumn;
071: }
072:
073: public String getEstimateColumn() {
074: return estimateColumn;
075: }
076:
077: public void setEstimateColumn(String estimateColumn) {
078: this .estimateColumn = estimateColumn;
079: }
080:
081: public String getEndDateColumn() {
082: return endDateColumn;
083: }
084:
085: public void setEndDateColumn(String endDateColumn) {
086: this .endDateColumn = endDateColumn;
087: }
088:
089: public String getPriorityColumn() {
090: return priorityColumn;
091: }
092:
093: public void setPriorityColumn(String priorityColumn) {
094: this .priorityColumn = priorityColumn;
095: }
096:
097: public String getStatusColumn() {
098: return statusColumn;
099: }
100:
101: public void setStatusColumn(String statusColumn) {
102: this .statusColumn = statusColumn;
103: }
104:
105: public boolean isOnlyIncomplete() {
106: return onlyIncomplete;
107: }
108:
109: public void setOnlyIncomplete(boolean onlyIncomplete) {
110: this .onlyIncomplete = onlyIncomplete;
111: }
112:
113: public String getCompletedStatus() {
114: return completedStatus;
115: }
116:
117: public void setCompletedStatus(String completedStatus) {
118: this .completedStatus = completedStatus;
119: }
120:
121: public void setWorksheetName(String worksheetName) {
122: this .worksheetName = worksheetName;
123: }
124:
125: public String getWorksheetName() {
126: return worksheetName;
127: }
128: }
|