1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.edit.internal; |
21 |
|
|
22 |
|
import java.util.Collections; |
23 |
|
import java.util.List; |
24 |
|
import java.util.Objects; |
25 |
|
|
26 |
|
import org.apache.commons.lang3.StringUtils; |
27 |
|
import org.xwiki.configuration.internal.AbstractDocumentConfigurationSource; |
28 |
|
import org.xwiki.model.reference.DocumentReference; |
29 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
30 |
|
|
31 |
|
import com.xpn.xwiki.XWikiContext; |
32 |
|
import com.xpn.xwiki.XWikiException; |
33 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
34 |
|
import com.xpn.xwiki.objects.BaseObject; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
|
|
| 60.7% |
Uncovered Elements: 11 (28) |
Complexity: 8 |
Complexity Density: 0.47 |
|
42 |
|
public abstract class AbstractEditorBindingsSource extends AbstractDocumentConfigurationSource |
43 |
|
{ |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
private static final LocalDocumentReference CLASS_REFERENCE = new LocalDocumentReference("XWiki", |
48 |
|
"EditorBindingClass"); |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
211 |
@Override... |
51 |
|
protected LocalDocumentReference getClassReference() |
52 |
|
{ |
53 |
211 |
return CLASS_REFERENCE; |
54 |
|
} |
55 |
|
|
|
|
| 18.2% |
Uncovered Elements: 9 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
56 |
160 |
@Override... |
57 |
|
protected Object getBaseProperty(String propertyName, boolean text) throws XWikiException |
58 |
|
{ |
59 |
160 |
for (BaseObject baseObject : getBaseObjects()) { |
60 |
0 |
String dataType = baseObject.getStringValue("dataType"); |
61 |
0 |
if (Objects.equals(dataType, propertyName)) { |
62 |
0 |
String roleHint = baseObject.getStringValue("roleHint"); |
63 |
0 |
if (!StringUtils.isEmpty(roleHint)) { |
64 |
0 |
return roleHint; |
65 |
|
} |
66 |
|
} |
67 |
|
} |
68 |
160 |
return null; |
69 |
|
} |
70 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
71 |
160 |
private List<BaseObject> getBaseObjects() throws XWikiException... |
72 |
|
{ |
73 |
160 |
DocumentReference documentReference = getFailsafeDocumentReference(); |
74 |
160 |
LocalDocumentReference classReference = getFailsafeClassReference(); |
75 |
|
|
76 |
160 |
if (documentReference != null && classReference != null) { |
77 |
156 |
XWikiContext xcontext = this.xcontextProvider.get(); |
78 |
156 |
XWikiDocument document = xcontext.getWiki().getDocument(getDocumentReference(), xcontext); |
79 |
156 |
List<BaseObject> objects = document.getXObjects(classReference); |
80 |
156 |
if (objects != null) { |
81 |
0 |
return objects; |
82 |
|
} |
83 |
|
} |
84 |
|
|
85 |
160 |
return Collections.emptyList(); |
86 |
|
} |
87 |
|
} |