1 package org.tigris.scarab.om; 2 3 import java.util.List ; 4 5 import org.apache.torque.TorqueException; 7 import org.apache.torque.om.ObjectKey; 8 import org.apache.torque.util.Criteria; 9 10 import org.tigris.scarab.services.cache.ScarabCache; 12 import org.tigris.scarab.tools.localization.L10NKeySet; 13 import org.tigris.scarab.util.ScarabException; 14 15 16 21 public class ReportPeer 22 extends org.tigris.scarab.om.BaseReportPeer 23 { 24 private static final String REPORT_PEER = 25 "ReportPeer"; 26 private static final String RETRIEVE_BY_PK = 27 "retrieveByPK"; 28 29 35 public static boolean exists(String name) 36 throws Exception 37 { 38 return retrieveByName(name) != null; 39 } 40 41 48 public static Report retrieveByName(String name) 49 throws Exception 50 { 51 Report report = null; 52 Criteria crit = new Criteria() 53 .add(NAME, name) 54 .add(DELETED, false); 55 List reports = doSelect(crit); 56 if (reports.size() == 1) 57 { 58 report = (Report)reports.get(0); 59 } 60 else if (reports.size() > 1) 61 { 62 throw new ScarabException(L10NKeySet.ExceptionMultipleReports, 63 name); 64 } 65 66 return report; 67 } 68 69 74 public static Report retrieveByPK(ObjectKey pk) 75 throws TorqueException 76 { 77 Report result = null; 78 Object obj = ScarabCache.get(REPORT_PEER, RETRIEVE_BY_PK, pk); 79 if (obj == null) 80 { 81 result = BaseReportPeer.retrieveByPK(pk); 82 ScarabCache.put(result, REPORT_PEER, RETRIEVE_BY_PK, pk); 83 } 84 else 85 { 86 result = (Report)obj; 87 } 88 return result; 89 } 90 } 91 | Popular Tags |