1 16 17 package info.jtrac.domain; 18 19 import org.apache.lucene.document.Document; 20 21 27 public class History extends AbstractItem { 28 29 private Integer type; 30 private String comment; 31 private Double actualEffort; 32 private Attachment attachment; 33 34 public History() { 35 } 37 38 public History(Item item) { 39 setStatus(item.getStatus()); 40 setSummary(item.getSummary()); 41 setDetail(item.getDetail()); 42 setLoggedBy(item.getLoggedBy()); 43 setAssignedTo(item.getAssignedTo()); 44 setPlannedEffort(item.getPlannedEffort()); 46 for(Field.Name fieldName : Field.Name.values()) { 48 setValue(fieldName, item.getValue(fieldName)); 49 } 50 } 51 52 55 public Document createDocument() { 56 Document d = new Document(); 57 d.add(org.apache.lucene.document.Field.UnIndexed("id", getId() + "")); 58 d.add(org.apache.lucene.document.Field.UnIndexed("itemId", getParent().getId() + "")); 59 d.add(org.apache.lucene.document.Field.UnIndexed("type", "history")); 60 StringBuffer sb = new StringBuffer (); 61 if (getSummary() != null) { 62 sb.append(getSummary()); 63 } 64 if (getDetail() != null) { 65 if (sb.length() > 0) { 66 sb.append(" | "); 67 } 68 sb.append(getDetail()); 69 } 70 if (comment != null) { 71 if (sb.length() > 0) { 72 sb.append(" | "); 73 } 74 sb.append(comment); 75 } 76 d.add(org.apache.lucene.document.Field.UnStored("text", sb.toString())); 77 return d; 78 } 79 80 @Override 81 public String getRefId() { 82 return getParent().getRefId(); 83 } 84 85 @Override 86 public Space getSpace() { 87 return getParent().getSpace(); 88 } 89 90 public Integer getType() { 91 return type; 92 } 93 94 public void setType(Integer type) { 95 this.type = type; 96 } 97 98 public String getComment() { 99 return comment; 100 } 101 102 public void setComment(String comment) { 103 this.comment = comment; 104 } 105 106 public Attachment getAttachment() { 107 return attachment; 108 } 109 110 public void setAttachment(Attachment attachment) { 111 this.attachment = attachment; 112 } 113 114 public Double getActualEffort() { 115 return actualEffort; 116 } 117 118 public void setActualEffort(Double actualEffort) { 119 this.actualEffort = actualEffort; 120 } 121 122 @Override 123 public String toString() { 124 StringBuffer sb = new StringBuffer (); 125 sb.append(super.toString()); 126 sb.append("; comment [").append(comment); 127 sb.append("]; actualEffort [").append(actualEffort); 128 sb.append("]; attachment [").append(attachment); 129 sb.append("]"); 130 return sb.toString(); 131 } 132 133 } 134 | Popular Tags |