1 package org.tigris.scarab.om; 2 3 48 49 import org.apache.torque.util.Criteria; 50 import org.apache.torque.TorqueException; 51 import org.tigris.scarab.util.Log; 52 53 import java.util.List ; 54 55 58 public class TransitionPeer extends org.tigris.scarab.om.BaseTransitionPeer 59 { 60 public static List getAllTransitions(Attribute attribute) 61 { 62 63 Integer attribId = attribute.getAttributeId(); 64 List transitions = null; 65 try 66 { 67 Criteria crit = new Criteria(); 68 crit.add(ATTRIBUTE_ID, attribId); 69 transitions = doSelect(crit); 70 } 71 catch (TorqueException te) 72 { 73 te.printStackTrace(); 74 } 75 return transitions; 76 } 77 85 public static List getTransitions(AttributeOption fromOption, 86 AttributeOption toOption) 87 { 88 89 Integer attribId = toOption.getAttributeId(); 90 Integer fromOptionId = fromOption.getOptionId(); 91 Integer toOptionId = toOption.getOptionId(); 92 List transitions = null; 93 try 94 { Criteria crit = new Criteria(); 96 crit.add(ATTRIBUTE_ID, attribId); 97 crit.add(FROM_OPTION_ID, (Object ) "FROM_OPTION_ID IS NULL", 98 Criteria.CUSTOM); 99 crit.add(TO_OPTION_ID, (Object ) "TO_OPTION_ID IS NULL", 100 Criteria.CUSTOM); 101 transitions = doSelect(crit); 102 } 103 catch (TorqueException te) 104 { 105 Log.get(TransitionPeer.class.getName()).error( 106 "getTransitions(): " + te); 107 } 108 try 109 { Criteria crit = new Criteria(); 111 crit.add(ATTRIBUTE_ID, attribId); 112 crit.add(FROM_OPTION_ID, fromOptionId); 113 crit.add(TO_OPTION_ID, toOptionId); 114 transitions.addAll(doSelect(crit)); 115 } 116 catch (TorqueException te) 117 { 118 Log.get(TransitionPeer.class.getName()).error( 119 "getTransitions(): " + te); 120 } 121 try 122 { Criteria crit = new Criteria(); 124 crit.add(ATTRIBUTE_ID, attribId); 125 crit.add(TO_OPTION_ID, toOptionId); 126 crit.add(FROM_OPTION_ID, (Object ) "FROM_OPTION_ID IS NULL", 127 Criteria.CUSTOM); 128 transitions.addAll(doSelect(crit)); 129 } 130 catch (TorqueException te) 131 { 132 Log.get(TransitionPeer.class.getName()).error( 133 "getTransitions(): Looking for nulls fromOption: " + te); 134 } 135 try 136 { Criteria crit = new Criteria(); 138 crit.add(ATTRIBUTE_ID, attribId); 139 crit.add(FROM_OPTION_ID, fromOptionId); 140 crit.add(TO_OPTION_ID, (Object ) "TO_OPTION_ID IS NULL", 141 Criteria.CUSTOM); 142 transitions.addAll(doSelect(crit)); 143 } 144 catch (TorqueException te) 145 { 146 Log.get(TransitionPeer.class.getName()).error( 147 "getTransitions(): Looking for nulls toOption: " + te); 148 } 149 return transitions; 150 } 151 159 public static boolean hasDefinedTransitions(Attribute attribute) 160 { 161 boolean result = false; 162 try 163 { 164 Criteria crit = new Criteria(); 165 crit.add(ATTRIBUTE_ID, attribute.getAttributeId()); 166 List attributeTransitions = doSelect(crit); 167 result = (attributeTransitions.size() > 0); 168 } 169 catch (TorqueException te) 170 { 171 Log.get(TransitionPeer.class.getName()).error( 172 "hasDefinedTransitions(): " + te); 173 } 174 return result; 175 } 176 177 public static void doDelete(Transition tran) throws TorqueException 178 { 179 Criteria crit = new Criteria(); 180 crit.add(ConditionPeer.TRANSITION_ID, tran.getTransitionId()); 181 ConditionPeer.doDelete(crit); 182 BaseTransitionPeer.doDelete(tran); 183 } 184 } 185 186 | Popular Tags |