1 package org.tigris.scarab.om; 2 3 48 49 import java.util.List ; 50 51 import org.apache.torque.TorqueException; 52 import org.apache.torque.om.Persistent; 53 import org.apache.torque.util.Criteria; 54 55 import org.tigris.scarab.services.cache.ScarabCache; 56 57 65 public class DependTypeManager 66 extends BaseDependTypeManager 67 { 68 private static final String GET_ALL = 70 "getAll"; 71 72 private static final String DEPENDTYPE = 73 "DependType"; 74 private static final String FIND_DEPENDTYPE_BY_NAME = 75 "findDependTypeByName"; 76 77 82 public DependTypeManager() 83 throws TorqueException 84 { 85 super(); 86 setRegion(getClassName().replace('.', '_')); 87 } 88 89 94 public static DependType getInstance(String dependTypeName) 95 throws TorqueException 96 { 97 DependType result = null; 98 Object obj = ScarabCache.get(DEPENDTYPE, FIND_DEPENDTYPE_BY_NAME, 99 dependTypeName); 100 if (obj == null) 101 { 102 Criteria crit = new Criteria(); 103 crit.add(DependTypePeer.DEPEND_TYPE_NAME, dependTypeName); 104 List dependTypes = DependTypePeer.doSelect(crit); 105 if (dependTypes == null || dependTypes.size() == 0) 106 { 107 throw new TorqueException("Invalid issue depend type: " + 108 dependTypeName); } 110 result = (DependType)dependTypes.get(0); 111 ScarabCache.put(result, DEPENDTYPE, FIND_DEPENDTYPE_BY_NAME, 112 dependTypeName); 113 } 114 else 115 { 116 result = (DependType)obj; 117 } 118 return result; 119 } 120 121 public static List getAll() 122 throws TorqueException 123 { 124 return getManager().getAllImpl(); 125 } 126 127 public List getAllImpl() 128 throws TorqueException 129 { 130 List result = null; 131 Object obj = getMethodResult().get(this.toString(), GET_ALL); 132 if (obj == null) 133 { 134 result = DependTypePeer.doSelect(new Criteria()); 135 getMethodResult().put(result, this.toString(), GET_ALL); 136 } 137 else 138 { 139 result = (List )obj; 140 } 141 return result; 142 } 143 144 protected Persistent putInstanceImpl(Persistent om) 145 throws TorqueException 146 { 147 Persistent oldOm = super.putInstanceImpl(om); 148 getMethodResult().remove(this, GET_ALL); 149 return oldOm; 150 } 151 } 152 | Popular Tags |