1 package org.tigris.scarab.om; 2 3 48 49 import java.util.Map ; 50 import java.util.HashMap ; 51 52 import com.workingdogs.village.Record; 54 import com.workingdogs.village.DataSetException; 55 56 import org.apache.torque.TorqueException; 58 import org.apache.torque.util.Criteria; 59 60 68 public class AttributeValuePeer 69 extends BaseAttributeValuePeer 70 { 71 private static Map classMap = new HashMap (); 72 73 private static final String COUNT = 74 "count(" + VALUE_ID + ')'; 75 private static final String COUNT_DISTINCT = 76 "count(DISTINCT " + VALUE_ID + ')'; 77 78 90 public static int count(Criteria crit) 91 throws TorqueException, DataSetException 92 { 93 crit.addSelectColumn(COUNT); 94 return ((Record)AttributeValuePeer.doSelectVillageRecords(crit).get(0)) 95 .getValue(1).asInt(); 96 } 97 98 108 public static int countDistinct(Criteria crit) 109 throws TorqueException, DataSetException 110 { 111 crit.addSelectColumn(COUNT_DISTINCT); 112 return ((Record)AttributeValuePeer.doSelectVillageRecords(crit).get(0)) 113 .getValue(1).asInt(); 114 } 115 116 117 121 public static Class getOMClass(Record record, int offset) 122 throws TorqueException 123 { 124 Class c = null; 125 try 126 { 127 Integer attId = new Integer (record.getValue(offset-1 + 3) 128 .asString()); 129 Attribute attribute = AttributeManager.getInstance(attId); 130 String className = attribute.getAttributeType().getJavaClassName(); 131 132 c = (Class )classMap.get(className); 133 if (c == null) 134 { 135 c = Class.forName(className); 136 classMap.put(className, c); 137 } 138 } 139 catch (Exception e) 140 { 141 throw new TorqueException(e); } 143 144 return c; 145 } 146 } 147 148 | Popular Tags |