1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.internal.filter.input; |
21 |
|
|
22 |
|
import java.lang.reflect.ParameterizedType; |
23 |
|
import java.util.Iterator; |
24 |
|
import java.util.Map; |
25 |
|
|
26 |
|
import javax.inject.Inject; |
27 |
|
import javax.inject.Provider; |
28 |
|
import javax.inject.Singleton; |
29 |
|
|
30 |
|
import org.xwiki.component.annotation.Component; |
31 |
|
import org.xwiki.component.util.DefaultParameterizedType; |
32 |
|
import org.xwiki.filter.FilterEventParameters; |
33 |
|
import org.xwiki.filter.FilterException; |
34 |
|
import org.xwiki.filter.event.model.WikiObjectFilter; |
35 |
|
import org.xwiki.filter.instance.input.DocumentInstanceInputProperties; |
36 |
|
import org.xwiki.filter.instance.input.EntityEventGenerator; |
37 |
|
import org.xwiki.filter.instance.internal.input.AbstractBeanEntityEventGenerator; |
38 |
|
|
39 |
|
import com.xpn.xwiki.XWikiContext; |
40 |
|
import com.xpn.xwiki.internal.filter.BaseObjectFilter; |
41 |
|
import com.xpn.xwiki.objects.BaseObject; |
42 |
|
import com.xpn.xwiki.objects.BaseProperty; |
43 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
44 |
|
|
45 |
|
|
46 |
|
@version |
47 |
|
@since |
48 |
|
|
49 |
|
@Component |
50 |
|
@Singleton |
|
|
| 91.3% |
Uncovered Elements: 2 (23) |
Complexity: 5 |
Complexity Density: 0.31 |
|
51 |
|
public class BaseObjectEventGenerator |
52 |
|
extends AbstractBeanEntityEventGenerator<BaseObject, BaseObjectFilter, DocumentInstanceInputProperties> |
53 |
|
{ |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
public static final ParameterizedType ROLE = new DefaultParameterizedType(null, EntityEventGenerator.class, |
58 |
|
BaseObject.class, DocumentInstanceInputProperties.class); |
59 |
|
|
60 |
|
@Inject |
61 |
|
private Provider<XWikiContext> xcontextProvider; |
62 |
|
|
63 |
|
@Inject |
64 |
|
private EntityEventGenerator<BaseClass> classEventGenerator; |
65 |
|
|
66 |
|
@Inject |
67 |
|
private EntityEventGenerator<BaseProperty> propertyEventGenerator; |
68 |
|
|
|
|
| 90.9% |
Uncovered Elements: 2 (22) |
Complexity: 5 |
Complexity Density: 0.31 |
|
69 |
7667 |
@Override... |
70 |
|
public void write(BaseObject xobject, Object filter, BaseObjectFilter objectFilter, |
71 |
|
DocumentInstanceInputProperties properties) throws FilterException |
72 |
|
{ |
73 |
7667 |
XWikiContext xcontext = this.xcontextProvider.get(); |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
7667 |
FilterEventParameters objectParameters = new FilterEventParameters(); |
78 |
|
|
79 |
7667 |
objectParameters.put(WikiObjectFilter.PARAMETER_NAME, xobject.getName()); |
80 |
7667 |
objectParameters.put(WikiObjectFilter.PARAMETER_CLASS_REFERENCE, xobject.getClassName()); |
81 |
7667 |
objectParameters.put(WikiObjectFilter.PARAMETER_GUID, xobject.getGuid()); |
82 |
7667 |
objectParameters.put(WikiObjectFilter.PARAMETER_NUMBER, xobject.getNumber()); |
83 |
|
|
84 |
7667 |
objectFilter.beginWikiObject(xobject.getReference() != null ? xobject.getReference().getName() : null, |
85 |
|
objectParameters); |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
7667 |
BaseClass xclass = xobject.getXClass(xcontext); |
90 |
7667 |
((BaseClassEventGenerator) this.classEventGenerator).write(xclass, filter, objectFilter, properties); |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
7667 |
Iterator<BaseProperty<?>> it = xobject.getSortedIterator(); |
97 |
37401 |
while (it.hasNext()) { |
98 |
29734 |
BaseProperty<?> xproperty = it.next(); |
99 |
|
|
100 |
29734 |
String pname = xproperty.getName(); |
101 |
29734 |
if (pname != null && !pname.trim().equals("")) { |
102 |
29734 |
((BasePropertyEventGenerator) this.propertyEventGenerator).write(xproperty, filter, |
103 |
|
(Map<String, Object>) properties); |
104 |
|
} |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
7667 |
objectFilter.endWikiObject(xobject.getReference().getName(), objectParameters); |
110 |
|
} |
111 |
|
} |