001: /*
002: Copyright (C) 2003 Know Gate S.L. All rights reserved.
003: C/Oņa, 107 1š2 28050 Madrid (Spain)
004:
005: Redistribution and use in source and binary forms, with or without
006: modification, are permitted provided that the following conditions
007: are met:
008:
009: 1. Redistributions of source code must retain the above copyright
010: notice, this list of conditions and the following disclaimer.
011:
012: 2. The end-user documentation included with the redistribution,
013: if any, must include the following acknowledgment:
014: "This product includes software parts from hipergate
015: (http://www.hipergate.org/)."
016: Alternately, this acknowledgment may appear in the software itself,
017: if and wherever such third-party acknowledgments normally appear.
018:
019: 3. The name hipergate must not be used to endorse or promote products
020: derived from this software without prior written permission.
021: Products derived from this software may not be called hipergate,
022: nor may hipergate appear in their name, without prior written
023: permission.
024:
025: This library is distributed in the hope that it will be useful,
026: but WITHOUT ANY WARRANTY; without even the implied warranty of
027: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029: You should have received a copy of hipergate License with this code;
030: if not, visit http://www.hipergate.org or mail to info@hipergate.org
031: */
032:
033: package com.knowgate.lucene;
034:
035: import java.util.Date;
036: import java.util.Comparator;
037: import java.text.SimpleDateFormat;
038:
039: /**
040: * @author Sergio Montoro Ten
041: * @version 3.0
042: */
043: public class BugRecord {
044:
045: public static class CompareAuthor implements Comparator {
046: public int compare(Object o1, Object o2) {
047: if (((BugRecord) o1).getAuthor() == null)
048: return -1;
049: return ((BugRecord) o1).getAuthor().compareTo(
050: ((BugRecord) o2).getAuthor());
051: }
052: }
053:
054: public static class CompareTitle implements Comparator {
055: public int compare(Object o1, Object o2) {
056: if (((BugRecord) o1).getTitle() == null)
057: return -1;
058: return ((BugRecord) o1).getTitle().compareTo(
059: ((BugRecord) o2).getTitle());
060: }
061: }
062:
063: public static class CompareDate implements Comparator {
064: public int compare(Object o1, Object o2) {
065: if (((BugRecord) o1).getDate() == null)
066: return -1;
067: return ((BugRecord) o1).getDate().compareTo(
068: ((BugRecord) o2).getDate());
069: }
070: }
071:
072: public static class ComparePriority implements Comparator {
073: public int compare(Object o1, Object o2) {
074: if (((BugRecord) o1).getPriority() == null)
075: return -1;
076: return ((BugRecord) o1).getPriority().compareTo(
077: ((BugRecord) o2).getPriority());
078: }
079: }
080:
081: public static class CompareSeverity implements Comparator {
082: public int compare(Object o1, Object o2) {
083: if (((BugRecord) o1).getSeverity() == null)
084: return -1;
085: return ((BugRecord) o1).getSeverity().compareTo(
086: ((BugRecord) o2).getSeverity());
087: }
088: }
089:
090: private static SimpleDateFormat fmt = new SimpleDateFormat(
091: "yyyy-MM-dd HH:mm:ss");
092: private int number;
093: private String guid;
094: private String project;
095: private String title;
096: private String author;
097: private Date created;
098: private String type;
099: private String status;
100: private Short priority;
101: private Short severity;
102: private String abstrct;
103:
104: public BugRecord() {
105: }
106:
107: public BugRecord(int iNumber, String sGuid, String sProject,
108: String sTitle, String sReportedBy, String sDate,
109: String sType, String sStatus, String sPriority,
110: String sSeverity, String sAbstract) {
111: number = iNumber;
112: guid = sGuid;
113: project = sProject;
114: title = sTitle;
115: author = sReportedBy;
116: try {
117: created = fmt.parse(sDate);
118: } catch (Exception ignore) {
119: }
120: type = sType;
121: if (null != sPriority)
122: priority = new Short(sPriority);
123: else
124: priority = null;
125: if (null != sSeverity)
126: severity = new Short(sSeverity);
127: else
128: severity = null;
129: abstrct = sAbstract;
130: }
131:
132: public String getProject() {
133: return project;
134: }
135:
136: public int getNumber() throws NumberFormatException {
137: return number;
138: }
139:
140: public String getGuid() {
141: return guid;
142: }
143:
144: public String getTitle() {
145: return title;
146: }
147:
148: public String getAuthor() {
149: return author;
150: }
151:
152: public Date getDate() {
153: return created;
154: }
155:
156: public String getDateAsString() {
157: return fmt.format(created);
158: }
159:
160: public Short getPriority() {
161: return priority;
162: }
163:
164: public Short getSeverity() {
165: return severity;
166: }
167:
168: public String getStatus() {
169: return status;
170: }
171:
172: public String getType() {
173: return type;
174: }
175:
176: public void setProject(String sProjectGUID) {
177: project = sProjectGUID;
178: }
179:
180: public void setGuid(String sGuid) {
181: guid = sGuid;
182: }
183:
184: public void setTitle(String sTitle) {
185: title = sTitle;
186: }
187:
188: public void setAuthor(String sAuthor) {
189: author = sAuthor;
190: }
191:
192: public void setDate(Date oDtCreated) {
193: created = oDtCreated;
194: }
195:
196: public void setPriority(Short oPriority) {
197: priority = oPriority;
198: }
199:
200: public void setSeverity(Short oSeverity) {
201: severity = oSeverity;
202: }
203:
204: public void setType(String sType) {
205: type = sType;
206: }
207:
208: public void setStatus(String sStatus) {
209: status = sStatus;
210: }
211:
212: }
|