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

File ObjectsTreeNode.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart2.png
81% of files have more coverage

Code metrics

0
15
3
1
86
49
3
0.2
5
3
1

Classes

Class Line # Actions
ObjectsTreeNode 48 15 0% 3 16
0.1111111111.1%
 

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.Collections;
24    import java.util.List;
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 objects tree node.
40    *
41    * @version $Id: 9d80126e2c472382d1690e1d432fabe0fc527fd3 $
42    * @since 8.3M2
43    * @since 7.4.5
44    */
45    @Component
46    @Named("objects")
47    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
48    public class ObjectsTreeNode extends AbstractDocumentTreeNode
49    {
50    @Inject
51    private Provider<XWikiContext> xcontextProvider;
52   
53    /**
54    * Default constructor.
55    */
 
56  128 toggle public ObjectsTreeNode()
57    {
58  128 super("objects");
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<String> classNames = new ArrayList<String>();
68  0 for (DocumentReference classReference : document.getXObjects().keySet()) {
69  0 classNames.add(this.defaultEntityReferenceSerializer.serialize(classReference));
70    }
71  0 Collections.sort(classNames);
72  0 List<String> children = new ArrayList<String>();
73  0 for (String className : subList(classNames, offset, limit)) {
74  0 children.add("objectsOfType:" + serializedDocRef + "/" + className);
75    }
76  0 return children;
77    }
78   
 
79  0 toggle @Override
80    protected int getChildCount(DocumentReference documentReference) throws Exception
81    {
82  0 XWikiContext xcontext = this.xcontextProvider.get();
83  0 XWikiDocument document = xcontext.getWiki().getDocument(documentReference, xcontext);
84  0 return document.getXObjects().size();
85    }
86    }