1 package org.tigris.scarab.om; 2 3 48 49 import org.apache.torque.om.Persistent; 51 import org.apache.torque.TorqueException; 52 import org.apache.fulcrum.localization.Localization; 53 54 import org.tigris.scarab.om.Module; 56 import org.tigris.scarab.tools.localization.L10NKeySet; 57 import org.tigris.scarab.util.ScarabException; 58 59 67 public class Depend 68 extends BaseDepend 69 implements Persistent 70 { 71 72 75 private Module defaultModule = null; 76 77 80 private String observerUniqueId = null; 81 82 85 private String description = null; 86 87 91 public static Depend getInstance() 92 throws TorqueException 93 { 94 return DependManager.getInstance(); 95 } 96 97 100 public void setDefaultModule(Module me) 101 { 102 this.defaultModule = me; 103 } 104 105 108 public Module getDefaultModule() 109 { 110 return defaultModule; 111 } 112 113 119 public Attachment getDescriptionAsAttachment(ScarabUser user, Issue issue) 120 throws Exception 121 { 122 if (description == null || description.length() == 0) 123 { 124 return null; 125 } 126 Attachment comment = AttachmentManager.getInstance(); 127 comment.setTextFields(user, issue, Attachment.MODIFICATION__PK); 128 comment.setData(getDescription()); 129 comment.setName("modification"); 130 comment.save(); 131 return comment; 132 } 133 134 139 public String getDescription() 140 { 141 return this.description; 142 } 143 144 149 public void setDescription(String description) 150 { 151 this.description = description; 152 } 153 154 157 public String getObserverUniqueId() 158 throws Exception 159 { 160 return observerUniqueId; 161 } 162 163 public void setDependType(String type) 164 throws TorqueException 165 { 166 super.setDependType(DependTypeManager.getInstance(type)); 167 } 168 169 172 public void setObserverUniqueId(String uniqueId) 173 throws Exception 174 { 175 if (getDefaultModule() == null) 176 { 177 throw new ScarabException( L10NKeySet.ExceptionDependInternalWorkflow, 178 "setDefaultModule()", 179 "setObserverUniqueId()"); 180 } 181 Issue childIssue = null; 182 childIssue = IssueManager.getIssueById(uniqueId.trim()); 183 if (childIssue == null) 184 { 185 String code = getDefaultModule().getCode(); 186 uniqueId = code + uniqueId; 187 childIssue = IssueManager.getIssueById(uniqueId); 188 } 189 super.setObserverId(childIssue.getIssueId()); 190 } 191 192 196 public void setProperties(Depend depend) 197 throws TorqueException 198 { 199 this.setObservedId(depend.getObservedId()); 200 this.setObserverId(depend.getObserverId()); 201 this.setTypeId(depend.getTypeId()); 202 } 203 204 207 public String getAction() 208 { 209 Integer typeId = getTypeId(); 210 String action = null; 211 if (typeId.equals(DependTypePeer.BLOCKING__PK)) 212 { 213 action = Localization.getString("depend_blocking"); 214 } 215 else if (typeId.equals(DependTypePeer.DUPLICATE__PK)) 216 { 217 action = Localization.getString("depend_duplicate"); 218 } 219 else 220 { 221 action = Localization.getString("depend_nonblocking"); 222 } 223 return action; 224 } 225 226 } 227 | Popular Tags |