1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service.impl;
17
18 import org.kuali.rice.krad.data.provider.annotation.SerializationContext;
19 import org.kuali.rice.krad.data.provider.annotation.Serialized;
20 import org.kuali.rice.krad.service.BusinessObjectSerializerService;
21 import org.kuali.rice.krad.util.documentserializer.PropertySerializabilityEvaluator;
22 import org.kuali.rice.krad.util.documentserializer.PropertySerializabilityEvaluatorBase;
23 import org.kuali.rice.krad.util.documentserializer.SerializationState;
24
25 import javax.persistence.Transient;
26 import java.lang.reflect.Field;
27
28
29
30
31 public class DataObjectSerializerServiceImpl extends SerializerServiceBase implements BusinessObjectSerializerService {
32
33
34
35
36 @Override
37 public PropertySerializabilityEvaluator getPropertySerizabilityEvaluator(Object businessObject) {
38
39
40 PropertySerializabilityEvaluator evaluator = new PropertySerializabilityEvaluatorBase() {
41 @Override
42 public boolean isPropertySerializable(SerializationState state, Object containingObject,
43 String childPropertyName, Object childPropertyValue) {
44 return true;
45 }
46 };
47
48 return evaluator;
49 }
50
51
52
53
54
55
56 @Override
57 protected boolean ignoreField(Field field) {
58 Serialized serialized = field.getAnnotation(Serialized.class);
59
60
61 if (serialized != null && SerializationContext.MAINTENANCE.matches(serialized.forContexts())) {
62 return !serialized.enabled();
63 }
64
65
66 if (field.getAnnotation(Transient.class) != null) {
67 return true;
68 }
69
70
71 return false;
72 }
73 }