01: package com.technoetic.xplanner.importer.spreadsheet;
02:
03: import org.apache.poi.hssf.usermodel.HSSFSheet;
04:
05: import com.technoetic.xplanner.importer.MissingColumnHeaderSpreadsheetImporterException;
06:
07: /**
08: * Created by IntelliJ IDEA.
09: * User: tkmower
10: * Date: Apr 1, 2005
11: * Time: 12:17:53 AM
12: */
13: public class SpreadsheetHeaderConfiguration {
14: private SpreadsheetHeaderReader headerReader;
15:
16: public static final String DEFAULT_WORKSHEET_NAME = "Features";
17:
18: private String titleHeader;
19: private String endDateHeader;
20: private String priorityHeader;
21: private String statusHeader;
22: private String estimateHeader;
23: private String worksheetName = DEFAULT_WORKSHEET_NAME;
24:
25: public SpreadsheetHeaderConfiguration() {
26: super ();
27: }
28:
29: public SpreadsheetHeaderConfiguration(String titleHeader,
30: String endDateHeader, String priorityHeader,
31: String statusHeader, String estimateHeader) {
32: this .titleHeader = titleHeader;
33: this .endDateHeader = endDateHeader;
34: this .priorityHeader = priorityHeader;
35: this .statusHeader = statusHeader;
36: this .estimateHeader = estimateHeader;
37: }
38:
39: public void setTitleHeader(String titleHeader) {
40: this .titleHeader = titleHeader;
41: }
42:
43: public void setEndDateHeader(String endDateHeader) {
44: this .endDateHeader = endDateHeader;
45: }
46:
47: public void setPriorityHeader(String priorityHeader) {
48: this .priorityHeader = priorityHeader;
49: }
50:
51: public void setStatusHeader(String statusHeader) {
52: this .statusHeader = statusHeader;
53: }
54:
55: public void setEstimateHeader(String estimateHeader) {
56: this .estimateHeader = estimateHeader;
57: }
58:
59: public int getStoryTitleColumnIndex() {
60: return getRequiredColumnIndex(titleHeader);
61: }
62:
63: public int getStoryEstimateColumnIndex() {
64: return headerReader.getColumnIndex(estimateHeader);
65: }
66:
67: public int getStoryEndDateColumnIndex() {
68: return getRequiredColumnIndex(endDateHeader);
69: }
70:
71: public int getStoryPriorityColumnIndex() {
72: return getRequiredColumnIndex(priorityHeader);
73: }
74:
75: public int getStoryStatusColumnIndex() {
76: return headerReader.getColumnIndex(statusHeader);
77: }
78:
79: public void setWorksheet(HSSFSheet worksheet) {
80: headerReader = new SpreadsheetHeaderReader();
81: headerReader.setWorksheet(worksheet);
82: }
83:
84: private int getRequiredColumnIndex(String header) {
85: int columnIndex = headerReader.getColumnIndex(header);
86: if (columnIndex == -1)
87: throw new MissingColumnHeaderSpreadsheetImporterException(
88: header);
89: return columnIndex;
90: }
91:
92: public void setWorksheetName(String worksheetName) {
93: this .worksheetName = worksheetName;
94: }
95:
96: public String getWorksheetName() {
97: return worksheetName;
98: }
99: }
|