1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.index.tree.internal.nestedpages; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
import java.util.Locale; |
25 |
|
|
26 |
|
import javax.inject.Inject; |
27 |
|
import javax.inject.Named; |
28 |
|
import javax.inject.Provider; |
29 |
|
|
30 |
|
import org.xwiki.component.annotation.Component; |
31 |
|
import org.xwiki.component.annotation.InstantiationStrategy; |
32 |
|
import org.xwiki.component.descriptor.ComponentInstantiationStrategy; |
33 |
|
import org.xwiki.model.reference.DocumentReference; |
34 |
|
|
35 |
|
import com.xpn.xwiki.XWikiContext; |
36 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@version |
42 |
|
@since |
43 |
|
@since |
44 |
|
|
45 |
|
@Component |
46 |
|
@Named("translations") |
47 |
|
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP) |
|
|
| 40% |
Uncovered Elements: 9 (15) |
Complexity: 3 |
Complexity Density: 0.25 |
|
48 |
|
public class TranslationsTreeNode extends AbstractDocumentTreeNode |
49 |
|
{ |
50 |
|
@Inject |
51 |
|
private Provider<XWikiContext> xcontextProvider; |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
128 |
public TranslationsTreeNode()... |
57 |
|
{ |
58 |
128 |
super("translations"); |
59 |
|
} |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
61 |
0 |
@Override... |
62 |
|
protected List<String> getChildren(DocumentReference documentReference, int offset, int limit) throws Exception |
63 |
|
{ |
64 |
0 |
XWikiContext xcontext = this.xcontextProvider.get(); |
65 |
0 |
XWikiDocument document = xcontext.getWiki().getDocument(documentReference, xcontext); |
66 |
0 |
String serializedDocRef = this.defaultEntityReferenceSerializer.serialize(documentReference); |
67 |
0 |
List<Locale> locales = document.getTranslationLocales(xcontext); |
68 |
0 |
List<String> children = new ArrayList<String>(); |
69 |
0 |
for (Locale locale : subList(locales, offset, limit)) { |
70 |
0 |
children.add("translation:" + serializedDocRef + '/' + locale); |
71 |
|
} |
72 |
0 |
return children; |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
75 |
24 |
@Override... |
76 |
|
protected int getChildCount(DocumentReference documentReference) throws Exception |
77 |
|
{ |
78 |
24 |
XWikiContext xcontext = this.xcontextProvider.get(); |
79 |
24 |
XWikiDocument document = xcontext.getWiki().getDocument(documentReference, xcontext); |
80 |
24 |
return document.getTranslationLocales(xcontext).size(); |
81 |
|
} |
82 |
|
} |