1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.index.tree.internal.nestedpages

File TranslationsTreeNode.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart4.png
78% of files have more coverage

Code metrics

0
12
3
1
82
45
3
0.25
4
3
1

Classes

Class Line # Actions
TranslationsTreeNode 48 12 0% 3 9
0.440%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * The translations tree node.
40    *
41    * @version $Id: 6a0bcb3e7c8480188ff779449d360b197643ffd8 $
42    * @since 8.3M2
43    * @since 7.4.5
44    */
45    @Component
46    @Named("translations")
47    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
48    public class TranslationsTreeNode extends AbstractDocumentTreeNode
49    {
50    @Inject
51    private Provider<XWikiContext> xcontextProvider;
52   
53    /**
54    * Default constructor.
55    */
 
56  128 toggle public TranslationsTreeNode()
57    {
58  128 super("translations");
59    }
60   
 
61  0 toggle @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   
 
75  24 toggle @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    }