1 package org.tigris.scarab.om; 2 3 48 import java.util.List ; 50 51 import org.apache.torque.om.Persistent; 53 import org.apache.torque.util.Criteria; 54 import org.apache.torque.TorqueException; 55 56 import org.tigris.scarab.tools.localization.L10NKeySet; 58 import org.tigris.scarab.util.ScarabException; 59 import org.tigris.scarab.services.cache.ScarabCache; 60 61 67 public class AttributeType 68 extends BaseAttributeType 69 implements Persistent 70 { 71 private static final String ATTRIBUTETYPE = 73 "AttributeType"; 74 private static final String GET_INSTANCE = 75 "getInstance"; 76 private static final String GET_ATTRIBUTE_CLASS = "getAttributeClass"; 77 78 100 101 119 120 124 public AttributeClass getAttributeClass() 125 throws TorqueException 126 { 127 AttributeClass result = null; 128 Object obj = ScarabCache.get(this, GET_ATTRIBUTE_CLASS); 129 if (obj == null) 130 { 131 result = super.getAttributeClass(); 132 ScarabCache.put(result, this, GET_ATTRIBUTE_CLASS); 133 } 134 else 135 { 136 result = (AttributeClass)obj; 137 } 138 return result; 139 } 140 141 public static AttributeType getInstance(String attributeTypeName) 142 throws Exception 143 { 144 AttributeType result = null; 145 Object obj = ScarabCache.get(ATTRIBUTETYPE, GET_INSTANCE, 146 attributeTypeName); 147 if (obj == null) 148 { 149 Criteria crit = new Criteria(); 150 crit.add(AttributeTypePeer.ATTRIBUTE_TYPE_NAME, attributeTypeName); 151 List attributeTypes = AttributeTypePeer.doSelect(crit); 152 if(attributeTypes.size() > 1) 153 { 154 throw new ScarabException(L10NKeySet.ExceptionDuplicateAttributeTypeName, 155 attributeTypeName); 156 } 157 result = (AttributeType)attributeTypes.get(0); 158 ScarabCache.put(result, ATTRIBUTETYPE, GET_INSTANCE, 159 attributeTypeName); 160 } 161 else 162 { 163 result = (AttributeType)obj; 164 } 165 return result; 166 } 167 } 168 169 170 171 | Popular Tags |