1 4 5 package org.enhydra.shark.appmappersistence; 6 7 import java.io.Serializable ; 8 import java.util.Iterator ; 9 10 import net.sf.hibernate.CallbackException; 11 import net.sf.hibernate.Interceptor; 12 import net.sf.hibernate.type.Type; 13 14 import org.enhydra.shark.utilities.hibernate.HibernateUtilities; 15 16 17 23 public class AppMappingsInterceptor implements Interceptor, Serializable { 24 25 public boolean onLoad(Object entity,Serializable id,Object [] state,String [] propertyNames,Type[] types) throws CallbackException { 26 if ( entity instanceof HibernateApplicationMap ) { 27 for ( int i=0; i<propertyNames.length; i++ ) { 28 if (("processDefId".equals( propertyNames[i])) && (((String )state[i]).equals(HibernateUtilities.NULL_VALUE_FOR_PROCID))) { 29 state[i] = null; 30 return true; 31 } 32 } 33 } 34 return false; 35 } 36 37 public boolean onFlushDirty(Object entity,Serializable id,Object [] currentState,Object [] previousState,String [] propertyNames,Type[] types) throws CallbackException { 38 if ( entity instanceof HibernateApplicationMap ) { 39 for ( int i=0; i<propertyNames.length; i++ ) { 40 if (("processDefId".equals( propertyNames[i])) && (((String )currentState[i] == null) || ((String )currentState[i]).trim().equals("")) ) { 41 currentState[i] = HibernateUtilities.NULL_VALUE_FOR_PROCID; 42 return true; 43 } 44 } 45 } 46 return false; 47 } 48 49 50 public boolean onSave(Object entity,Serializable id,Object [] state,String [] propertyNames,Type[] types) throws CallbackException { 51 if ( entity instanceof HibernateApplicationMap ) { 52 for ( int i=0; i<propertyNames.length; i++ ) { 53 if (("processDefId".equals( propertyNames[i])) && (((String )state[i] == null) || ((String )state[i]).trim().equals("")) ) { 54 state[i] = HibernateUtilities.NULL_VALUE_FOR_PROCID; 55 return true; 56 } 57 } 58 } 59 return false; 60 } 61 62 63 public void onDelete(Object arg0, Serializable arg1, Object [] arg2, String [] arg3, Type[] arg4) throws CallbackException { 64 } 65 66 67 public Boolean isUnsaved(Object arg0) { 68 return null; 69 } 70 71 72 public int[] findDirty(Object arg0, Serializable arg1, Object [] arg2, Object [] arg3, String [] arg4, Type[] arg5) { 73 return null; 74 } 75 76 77 public Object instantiate(Class arg0, Serializable arg1) throws CallbackException { 78 return null; 79 } 80 81 82 public void preFlush(Iterator arg0) throws CallbackException { 83 } 84 85 public void postFlush(Iterator arg0) throws CallbackException { 86 } 87 88 } 89 | Popular Tags |