001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.glm.ldm.plan;
028:
029: import java.beans.PropertyChangeListener;
030: import java.beans.PropertyChangeSupport;
031: import java.util.Date;
032: import java.util.Hashtable;
033:
034: import org.cougaar.core.util.OwnedUniqueObject;
035: import org.cougaar.core.util.UID;
036: import org.cougaar.core.util.UniqueObject;
037: import org.cougaar.planning.ldm.plan.Transferable;
038:
039: public class CasRepImpl extends OwnedUniqueObject implements CasRep,
040: NewCasRep, Transferable, UniqueObject {
041: private UID uid;
042: private String casRepNumber;
043: private String displayDate;
044: private long timeStamp;
045: private String ticketNumber;
046: private String operator;
047: private String machine;
048: private String serialNumber;
049: private String space;
050: private String symptoms;
051: private String remarks;
052: private boolean missionCritical;
053: private String status;
054: private String brokenPart;
055: private String brokenPartDesc;
056: private String brokenPartStatus;
057: private boolean casRep;
058: private boolean newCasRep;
059: private String version = "";
060: private String from;
061: private String fromCluster;
062: private String to;
063: private String info;
064: private String classification;
065: private String criticalityCode = "C2";
066: private Object brokenMEI;
067: private String data;
068: private Hashtable misc = new Hashtable();
069:
070: public CasRepImpl() {
071: misc.put("PROBLEM_DESC", "");
072: misc.put("MISSION_IMPACT", "");
073: }
074:
075: //SETTERS
076: public void setUID(UID u) {
077: uid = u;
078: String param = u.toString();
079: int i = param.indexOf("/");
080: String paddedNumber = param.substring(i + 1);
081: String year = new Date().toString();
082: year = year.substring(year.length() - 2);
083: while (paddedNumber.length() < 3) {
084: paddedNumber = "0" + paddedNumber;
085: }
086: casRepNumber = param.substring(0, i) + "/" + year
087: + paddedNumber;
088: }
089:
090: public void setDisplayDate(String param) {
091: displayDate = param;
092: }
093:
094: public void setDate(Date param) {
095: String date = param.toString();
096: String hours = date.substring(11, 13);
097: String minutes = date.substring(14, 16);
098: String dom = date.substring(8, 10);
099: String month = date.substring(4, 7).toUpperCase();
100: String year = date.substring(date.length() - 2);
101: displayDate = dom + hours + minutes + "Z" + month + year;
102: }
103:
104: public String formatDate(Date param) {
105: String date = param.toString();
106: String hours = date.substring(11, 13);
107: String minutes = date.substring(14, 16);
108: String dom = date.substring(8, 10);
109: String month = date.substring(4, 7).toUpperCase();
110: String year = date.substring(date.length() - 2);
111: return dom + hours + minutes + "Z" + month + year;
112: }
113:
114: public String formatShortDate(Date param) {
115: String date = param.toString();
116: String hours = date.substring(11, 13);
117: String minutes = date.substring(14, 16);
118: String dom = date.substring(8, 10);
119: String month = date.substring(4, 7).toUpperCase();
120: String year = date.substring(date.length() - 2);
121: return dom + month + year;
122: }
123:
124: public void setTimeStamp(long param) {
125: timeStamp = param;
126: }
127:
128: public void setTicketNumber(String param) {
129: ticketNumber = param;
130: }
131:
132: public void setOperator(String param) {
133: operator = param;
134: }
135:
136: public void setMachine(String param) {
137: machine = param;
138: }
139:
140: public void setSerialNumber(String param) {
141: serialNumber = param;
142: }
143:
144: public void setSpace(String param) {
145: space = param;
146: }
147:
148: public void setSymptoms(String param) {
149: symptoms = param;
150: }
151:
152: public void setRemarks(String param) {
153: remarks = param;
154: }
155:
156: public void setMissionCritical(boolean param) {
157: missionCritical = param;
158: }
159:
160: public void setStatus(String param) {
161: status = param;
162: }
163:
164: public void setBrokenPart(String param) {
165: brokenPart = param;
166: }
167:
168: public void setBrokenPartDesc(String param) {
169: brokenPartDesc = param;
170: }
171:
172: public void setBrokenPartStatus(String param) {
173: brokenPartStatus = param;
174: }
175:
176: public void setCasRep(boolean param) {
177: casRep = param;
178: }
179:
180: public void setNewCasRep(boolean param) {
181: newCasRep = param;
182: }
183:
184: public void setVersion(String param) {
185: version = param;
186: }
187:
188: public void setFrom(String param) {
189: from = param;
190: }
191:
192: public void setFromCluster(String param) {
193: fromCluster = param;
194: }
195:
196: public void setTo(String param) {
197: to = param;
198: }
199:
200: public void setInfo(String param) {
201: info = param;
202: }
203:
204: public void setClassification(String param) {
205: classification = param;
206: }
207:
208: public void setCriticalityCode(String param) {
209: criticalityCode = param;
210: }
211:
212: public void setBrokenMEI(Object param) {
213: brokenMEI = param;
214: }
215:
216: public void setData(String param) {
217: data = param;
218: }
219:
220: //GETTERS
221: public UID getUID() {
222: return uid;
223: }
224:
225: public String getDisplayDate() {
226: return displayDate;
227: }
228:
229: public long getTimeStamp() {
230: return timeStamp;
231: }
232:
233: public String getTicketNumber() {
234: return ticketNumber;
235: }
236:
237: public String getOperator() {
238: return operator;
239: }
240:
241: public String getMachine() {
242: return machine;
243: }
244:
245: public String getSerialNumber() {
246: return serialNumber;
247: }
248:
249: public String getSpace() {
250: return space;
251: }
252:
253: public String getSymptoms() {
254: return symptoms;
255: }
256:
257: public String getRemarks() {
258: return remarks;
259: }
260:
261: public boolean isMissionCritical() {
262: return missionCritical;
263: }
264:
265: public String getStatus() {
266: return status;
267: }
268:
269: public String getBrokenPart() {
270: return brokenPart;
271: }
272:
273: public String getBrokenPartDesc() {
274: return brokenPartDesc;
275: }
276:
277: public String getBrokenPartStatus() {
278: return brokenPartStatus;
279: }
280:
281: public boolean isCasRep() {
282: return casRep;
283: }
284:
285: public boolean isNewCasRep() {
286: return newCasRep;
287: }
288:
289: public String getVersion() {
290: return version;
291: }
292:
293: public String getNextVersion() {
294: if (!isCasRep()) {
295: return "";
296: } else if (version == null || version.equals("")) {
297: return "A";
298: }
299: char c = (char) (version.charAt(0) + 1);
300:
301: return new Character(c).toString();
302: }
303:
304: public String getFrom() {
305: return from;
306: }
307:
308: public String getFromCluster() {
309: return fromCluster;
310: }
311:
312: public String getTo() {
313: return to;
314: }
315:
316: public String getInfo() {
317: return info;
318: }
319:
320: public String getClassification() {
321: return classification;
322: }
323:
324: public String getCriticalityCode() {
325: return criticalityCode;
326: }
327:
328: public Object getBrokenMEI() {
329: return brokenMEI;
330: }
331:
332: public String getData() {
333: return data;
334: }
335:
336: public String getCode() {
337: if (status.equals(TICKET_COMPLETED)
338: || status.equals(REPAIR_COMPLETED)) {
339: return "G";
340: } else if (isCasRep()) {
341: return "R";
342: } else {
343: if (isMissionCritical()) {
344: return "Y";
345: } else {
346: return "W";
347: }
348: }
349: }
350:
351: public Hashtable getMisc() {
352: return misc;
353: }
354:
355: public String getCasRepNumber() {
356: return (casRepNumber + version).toUpperCase();
357: }
358:
359: public String getOnShipCasRepNumber() {
360: int i = casRepNumber.indexOf("/");
361: return casRepNumber.substring(i + 1) + version;
362: }
363:
364: public String getNextOnShipCasRepNumber() {
365: System.out.println(getUID());
366: int i = casRepNumber.indexOf("/");
367: return casRepNumber.substring(i + 1) + getNextVersion();
368: }
369:
370: public boolean same(Transferable other) {
371:
372: return false;
373: }//same
374:
375: public Object clone() {
376: CasRepImpl casrep = new CasRepImpl();
377: casrep.setUID(uid);
378: casrep.setDisplayDate(displayDate);
379: casrep.setTimeStamp(timeStamp);
380: casrep.setTicketNumber(ticketNumber);
381: casrep.setOperator(operator);
382: casrep.setMachine(machine);
383: casrep.setSerialNumber(serialNumber);
384: casrep.setSpace(space);
385: casrep.setSymptoms(symptoms);
386: casrep.setRemarks(remarks);
387: casrep.setMissionCritical(missionCritical);
388: casrep.setStatus(status);
389: casrep.setBrokenPart(brokenPart);
390: casrep.setCasRep(casRep);
391: casrep.setVersion(version);
392: casrep.setFrom(from);
393: casrep.setFromCluster(fromCluster);
394: casrep.setTo(to);
395: casrep.setInfo(info);
396: casrep.setClassification(classification);
397: casrep.setCriticalityCode(criticalityCode);
398: casrep.setBrokenMEI(brokenMEI);
399: casrep.setData(data);
400: return casrep;
401: }// clone
402:
403: public void setAll(Transferable other) {
404: }// setAll
405:
406: //dummy PropertyChangeSupport for the Jess Interpreter.
407: protected transient PropertyChangeSupport pcs = new PropertyChangeSupport(
408: this );
409:
410: public void addPropertyChangeListener(PropertyChangeListener pcl) {
411: pcs.addPropertyChangeListener(pcl);
412: }
413:
414: public void removePropertyChangeListener(PropertyChangeListener pcl) {
415: pcs.removePropertyChangeListener(pcl);
416: }
417:
418: }//CasRepImpl
|