| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
package net.smartlab.web.history; |
| 25 |
|
|
| 26 |
|
import java.io.Serializable; |
| 27 |
|
import java.sql.Timestamp; |
| 28 |
|
import java.util.Iterator; |
| 29 |
|
|
| 30 |
|
import org.apache.commons.logging.Log; |
| 31 |
|
import org.apache.commons.logging.LogFactory; |
| 32 |
|
import org.hibernate.EntityMode; |
| 33 |
|
import org.hibernate.HibernateException; |
| 34 |
|
import org.hibernate.MappingException; |
| 35 |
|
import org.hibernate.Transaction; |
| 36 |
|
import org.hibernate.property.PropertyAccessor; |
| 37 |
|
import org.hibernate.property.PropertyAccessorFactory; |
| 38 |
|
import org.hibernate.property.Setter; |
| 39 |
|
import org.hibernate.type.Type; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@author |
| 45 |
|
|
|
|
|
| 0% |
Uncovered Elements: 54 (54) |
Complexity: 26 |
Complexity Density: 1,08 |
|
| 46 |
|
public class Interceptor implements org.hibernate.Interceptor { |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
protected final Log logger = LogFactory.getLog(Interceptor.class); |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@see |
| 55 |
|
|
| 56 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 57 |
0
|
public boolean onLoad(Object arg0, Serializable arg1, Object[] arg2, String[] arg3, org.hibernate.type.Type[] arg4) throws org.hibernate.CallbackException {... |
| 58 |
|
|
| 59 |
0
|
return false; |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
|
| 63 |
|
@see |
| 64 |
|
|
| 65 |
|
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 9 |
Complexity Density: 0,56 |
|
| 66 |
0
|
public boolean onFlushDirty(Object entity, Serializable key, Object[] current, Object[] previous, String[] properties, Type[] types) throws org.hibernate.CallbackException {... |
| 67 |
0
|
if (logger.isDebugEnabled()) { |
| 68 |
0
|
logger.debug("onFlushDirty(entity = " + entity + ", key = " + key + ", current = " + current + ", previous = " + previous |
| 69 |
|
+ ", properties = " + properties + ", types = " + types + ") - start"); |
| 70 |
|
} |
| 71 |
0
|
boolean modified = false; |
| 72 |
0
|
if (entity instanceof HistoricizableBusinessObject) { |
| 73 |
|
|
| 74 |
0
|
HistorizedBusinessObject historized = ((HistoricizableBusinessObject)entity).getHistorized(); |
| 75 |
0
|
historized.setLastModified(new Timestamp(System.currentTimeMillis())); |
| 76 |
0
|
try { |
| 77 |
|
|
| 78 |
0
|
PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(null); |
| 79 |
0
|
for (int i = 0; i < properties.length; i++) { |
| 80 |
0
|
if (!current[i].equals(previous[i])) { |
| 81 |
0
|
modified = true; |
| 82 |
0
|
Setter setter = accessor.getSetter(historized.getClass(), properties[i]); |
| 83 |
|
|
| 84 |
|
|
| 85 |
0
|
} else if (!(historized instanceof DifferenciallyHistorizedBusinessObject)) { |
| 86 |
0
|
Setter setter = accessor.getSetter(historized.getClass(), properties[i]); |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
} |
| 90 |
|
} |
| 91 |
0
|
if (modified) { |
| 92 |
|
|
| 93 |
|
} |
| 94 |
|
} catch (MappingException me) { |
| 95 |
|
logger.error("onFlushDirty(entity = " + entity + ", key = " + key + ", current = " + current + ", previous = " + previous |
| 96 |
|
+ ", properties = " + properties + ", types = " + types + ") - error", me); |
| 97 |
|
|
| 98 |
|
} catch (HibernateException he) { |
| 99 |
|
logger.error("onFlushDirty(entity = " + entity + ", key = " + key + ", current = " + current + ", previous = " + previous |
| 100 |
|
+ ", properties = " + properties + ", types = " + types + ") - error", he); |
| 101 |
|
} |
| 102 |
|
} |
| 103 |
0
|
return modified; |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
@see |
| 108 |
|
|
| 109 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
0
|
public boolean onSave(Object arg0, Serializable arg1, Object[] arg2, String[] arg3, org.hibernate.type.Type[] arg4) throws org.hibernate.CallbackException {... |
| 111 |
|
|
| 112 |
0
|
return false; |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
|
| 116 |
|
@see |
| 117 |
|
|
| 118 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 119 |
0
|
public void onDelete(Object arg0, Serializable arg1, Object[] arg2, String[] arg3, org.hibernate.type.Type[] arg4) throws org.hibernate.CallbackException {... |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
@see |
| 126 |
|
|
| 127 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 128 |
0
|
public void onCollectionRecreate(Object arg0, Serializable arg1) throws org.hibernate.CallbackException {... |
| 129 |
|
|
| 130 |
|
|
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
@see |
| 135 |
|
|
| 136 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 137 |
0
|
public void onCollectionRemove(Object arg0, Serializable arg1) throws org.hibernate.CallbackException {... |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
@see |
| 144 |
|
|
| 145 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 146 |
0
|
public void onCollectionUpdate(Object arg0, Serializable arg1) throws org.hibernate.CallbackException {... |
| 147 |
|
|
| 148 |
|
|
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
|
| 152 |
|
@see |
| 153 |
|
|
| 154 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 155 |
0
|
public void preFlush(Iterator arg0) throws org.hibernate.CallbackException {... |
| 156 |
|
|
| 157 |
|
|
| 158 |
|
} |
| 159 |
|
|
| 160 |
|
|
| 161 |
|
@see |
| 162 |
|
|
| 163 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 164 |
0
|
public void postFlush(Iterator arg0) throws org.hibernate.CallbackException {... |
| 165 |
|
|
| 166 |
|
|
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
|
| 170 |
|
@see |
| 171 |
|
|
| 172 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 173 |
0
|
public Boolean isTransient(Object arg0) {... |
| 174 |
|
|
| 175 |
0
|
return null; |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
|
| 179 |
|
@see |
| 180 |
|
|
| 181 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 182 |
0
|
public int[] findDirty(Object arg0, Serializable arg1, Object[] arg2, Object[] arg3, String[] arg4, org.hibernate.type.Type[] arg5) {... |
| 183 |
|
|
| 184 |
0
|
return null; |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
|
| 188 |
|
@see |
| 189 |
|
|
| 190 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 191 |
0
|
public Object instantiate(String arg0, EntityMode arg1, Serializable arg2) throws org.hibernate.CallbackException {... |
| 192 |
|
|
| 193 |
0
|
return null; |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
|
| 197 |
|
@see |
| 198 |
|
|
| 199 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 200 |
0
|
public String getEntityName(Object arg0) throws org.hibernate.CallbackException {... |
| 201 |
|
|
| 202 |
0
|
return null; |
| 203 |
|
} |
| 204 |
|
|
| 205 |
|
|
| 206 |
|
@see |
| 207 |
|
|
| 208 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 209 |
0
|
public Object getEntity(String arg0, Serializable arg1) throws org.hibernate.CallbackException {... |
| 210 |
|
|
| 211 |
0
|
return null; |
| 212 |
|
} |
| 213 |
|
|
| 214 |
|
|
| 215 |
|
@see |
| 216 |
|
|
| 217 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 218 |
0
|
public void afterTransactionBegin(Transaction arg0) {... |
| 219 |
|
|
| 220 |
|
|
| 221 |
|
} |
| 222 |
|
|
| 223 |
|
|
| 224 |
|
@see |
| 225 |
|
|
| 226 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 227 |
0
|
public void beforeTransactionCompletion(Transaction arg0) {... |
| 228 |
|
|
| 229 |
|
|
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
|
| 233 |
|
@see |
| 234 |
|
|
| 235 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 236 |
0
|
public void afterTransactionCompletion(Transaction arg0) {... |
| 237 |
|
|
| 238 |
|
|
| 239 |
|
} |
| 240 |
|
|
| 241 |
|
|
| 242 |
|
@see |
| 243 |
|
|
| 244 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 245 |
0
|
public String onPrepareStatement(String arg0) {... |
| 246 |
|
|
| 247 |
0
|
return null; |
| 248 |
|
} |
| 249 |
|
} |