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

File ClassPropertiesTreeNode.java

 

Coverage histogram

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

Code metrics

0
12
3
1
83
46
3
0.25
4
3
1

Classes

Class Line # Actions
ClassPropertiesTreeNode 49 12 0% 3 13
0.1333333413.3%
 

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.ClassPropertyReference;
34    import org.xwiki.model.reference.DocumentReference;
35   
36    import com.xpn.xwiki.XWikiContext;
37    import com.xpn.xwiki.doc.XWikiDocument;
38   
39    /**
40    * The class properties tree node.
41    *
42    * @version $Id: d2ea721bec013f77bda2bca52cbe3f8ff33d2206 $
43    * @since 8.3M2
44    * @since 7.4.5
45    */
46    @Component
47    @Named("classProperties")
48    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
49    public class ClassPropertiesTreeNode extends AbstractDocumentTreeNode
50    {
51    @Inject
52    private Provider<XWikiContext> xcontextProvider;
53   
54    /**
55    * Default constructor.
56    */
 
57  128 toggle public ClassPropertiesTreeNode()
58    {
59  128 super("classProperties");
60    }
61   
 
62  0 toggle @Override
63    protected List<String> getChildren(DocumentReference documentReference, int offset, int limit) throws Exception
64    {
65  0 XWikiContext xcontext = this.xcontextProvider.get();
66  0 XWikiDocument document = xcontext.getWiki().getDocument(documentReference, xcontext);
67  0 List<String> properties = new ArrayList<String>(document.getXClass().getPropertyList());
68  0 Collections.sort(properties);
69  0 List<String> children = new ArrayList<String>();
70  0 for (String property : subList(properties, offset, limit)) {
71  0 children.add(serialize(new ClassPropertyReference(property, documentReference)));
72    }
73  0 return children;
74    }
75   
 
76  0 toggle @Override
77    protected int getChildCount(DocumentReference documentReference) throws Exception
78    {
79  0 XWikiContext xcontext = this.xcontextProvider.get();
80  0 XWikiDocument document = xcontext.getWiki().getDocument(documentReference, xcontext);
81  0 return document.getXClass().getPropertyList().size();
82    }
83    }