1 package org.tigris.scarab.om; 2 3 48 49 import org.apache.commons.lang.ObjectUtils; 50 import org.apache.torque.om.Persistent; 51 import org.tigris.scarab.util.word.IssueSearch; 52 import org.tigris.scarab.util.word.IssueSearchFactory; 53 import org.tigris.scarab.util.word.MaxConcurrentSearchException; 54 55 61 public class MITListItem 62 extends org.tigris.scarab.om.BaseMITListItem 63 implements Persistent 64 { 65 static final Integer MULTIPLE_KEY = new Integer (0); 66 67 78 public int getIssueCount(ScarabUser user) 79 throws Exception 80 { 81 IssueSearch is = null; 82 int count = 0; 83 try 84 { 85 is = IssueSearchFactory.INSTANCE 86 .getInstance(getModule(), getIssueType(), user); 87 count = is.getIssueCount(); 88 } 89 catch (MaxConcurrentSearchException e) 90 { 91 count = -1; 92 } 93 finally 94 { 95 IssueSearchFactory.INSTANCE.notifyDone(); 96 } 97 return count; 98 } 99 100 public boolean isSingleModuleIssueType() 101 { 102 boolean single = true; 103 if (MULTIPLE_KEY.equals(getModuleId()) 104 || MULTIPLE_KEY.equals(getIssueTypeId())) 105 { 106 single = false; 107 } 108 return single; 109 } 110 111 public boolean isSingleModule() 112 { 113 return !MULTIPLE_KEY.equals(getModuleId()); 114 } 115 116 public boolean isSingleIssueType() 117 { 118 return !MULTIPLE_KEY.equals(getIssueTypeId()); 119 } 120 121 public boolean isUseCurrentModule() 122 { 123 return getModuleId() == null; 124 } 125 126 public String getQueryKey() 127 { 128 String key = super.getQueryKey(); 129 if (key == null || key.length() == 0) 130 { 131 StringBuffer sb = new StringBuffer (); 132 if (getModuleId() != null) 133 { 134 sb.append(getModuleId()); 135 } 136 sb.append(':'); 137 if (getIssueTypeId() != null) 138 { 139 sb.append(getIssueTypeId()); 140 } 141 key = sb.toString(); 142 } 143 return key; 144 } 145 146 public int hashCode() 147 { 148 int hashCode = 10; 149 if (getModuleId() != null) 150 { 151 hashCode += getModuleId().hashCode(); 152 } 153 if (getIssueTypeId() != null) 154 { 155 hashCode += getIssueTypeId().hashCode(); 156 } 157 return hashCode; 158 } 159 160 public boolean equals(Object obj) 161 { 162 boolean isEqual = false; 163 if (obj instanceof MITListItem) 164 { 165 MITListItem item = (MITListItem)obj; 166 isEqual = ObjectUtils.equals(this.getModuleId(), item.getModuleId()); 167 isEqual &= ObjectUtils.equals(this.getIssueTypeId(), 168 item.getIssueTypeId()); 169 } 170 return isEqual; 171 } 172 173 public String toString() 174 { 175 StringBuffer sb = new StringBuffer (50); 176 sb.append('{').append(super.toString()).append('('); 177 if (getModuleId() != null) 178 { 179 sb.append(getModuleId()); 180 } 181 sb.append(':'); 182 if (getIssueTypeId() != null) 183 { 184 sb.append(getIssueTypeId()); 185 } 186 sb.append(")}"); 187 188 return sb.toString(); 189 } 190 } 191 | Popular Tags |