1 package org.tigris.scarab.om; 2 3 48 49 import java.util.List ; 50 import java.util.LinkedList ; 51 import java.util.HashMap ; 52 import java.io.Serializable ; 53 54 import org.apache.torque.TorqueException; 55 import org.apache.torque.om.Persistent; 56 import org.apache.torque.manager.CacheListener; 57 58 import org.tigris.scarab.util.Log; 59 60 66 public class AttributeGroupManager 67 extends BaseAttributeGroupManager 68 implements CacheListener 69 { 70 75 public AttributeGroupManager() 76 throws TorqueException 77 { 78 super(); 79 setRegion(getClassName().replace('.', '_')); 80 validFields = new HashMap (); 81 validFields.put(AttributeGroupPeer.MODULE_ID, null); 82 } 83 84 protected Persistent putInstanceImpl(Persistent om) 85 throws TorqueException 86 { 87 Persistent oldOm = super.putInstanceImpl(om); 88 List listeners = (List )listenersMap.get(AttributeGroupPeer.MODULE_ID); 89 notifyListeners(listeners, oldOm, om); 90 return oldOm; 91 } 92 93 protected AttributeGroup getInstanceImpl() 94 { 95 return new AttributeGroup(); 96 } 97 98 101 protected void registerAsListener() 102 { 103 RAttributeAttributeGroupManager.addCacheListener(this); 104 AttributeManager.addCacheListener(this); 105 } 106 107 110 public void addedObject(Persistent om) 111 { 112 if (om instanceof RAttributeAttributeGroup) 113 { 114 RAttributeAttributeGroup castom = (RAttributeAttributeGroup)om; 115 Integer key = castom.getGroupId(); 116 try 117 { 118 Serializable obj = getInstance(key); 119 if (obj != null) 120 { 121 getMethodResult().remove(obj, AttributeGroup.GET_ATTRIBUTES); 122 } 123 } 124 catch(TorqueException e) 125 { 126 Log.get().warn("Invalid AttributeGroup id ", e); 127 } 128 } 129 else if (om instanceof Attribute) 130 { 131 getMethodResult().clear(); 132 } 133 } 134 135 public void refreshedObject(Persistent om) 136 { 137 addedObject(om); 138 } 139 140 141 public List getInterestedFields() 142 { 143 List interestedCacheFields = new LinkedList (); 144 interestedCacheFields.add(RAttributeAttributeGroupPeer.GROUP_ID); 145 interestedCacheFields.add(AttributePeer.ATTRIBUTE_ID); 146 interestedCacheFields.add(AttributeGroupPeer.ATTRIBUTE_GROUP_ID); 147 return interestedCacheFields; 148 } 149 } 150 | Popular Tags |