1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.wiki.user.internal

File WikiCandidateMemberClassInitializer.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

4
19
2
1
200
66
4
0.21
9.5
2
2

Classes

Class Line # Actions
WikiCandidateMemberClassInitializer 41 19 0% 4 2
0.9292%
 

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.wiki.user.internal;
21   
22    import javax.inject.Named;
23    import javax.inject.Singleton;
24   
25    import org.xwiki.component.annotation.Component;
26    import org.xwiki.model.reference.LocalDocumentReference;
27   
28    import com.xpn.xwiki.doc.XWikiDocument;
29    import com.xpn.xwiki.internal.mandatory.AbstractMandatoryDocumentInitializer;
30    import com.xpn.xwiki.objects.classes.BaseClass;
31   
32    /**
33    * Update the WikiManager.WikiCandidateMemberClass document with all required information.
34    *
35    * @since 5.3RC1
36    * @version $Id: 9fffe1c15653962e0067df08991cea4e9bc01978 $
37    */
38    @Component
39    @Named("WikiManager.WikiCandidateMemberClass")
40    @Singleton
 
41    public class WikiCandidateMemberClassInitializer extends AbstractMandatoryDocumentInitializer
42    {
43    /**
44    * The name of the mandatory document.
45    */
46    public static final String DOCUMENT_NAME = "WikiCandidateMemberClass";
47   
48    /**
49    * The space of the mandatory document.
50    */
51    public static final String DOCUMENT_SPACE = "WikiManager";
52   
53    /**
54    * The local reference of the class.
55    */
56    public static final LocalDocumentReference REFERENCE = new LocalDocumentReference(DOCUMENT_SPACE, DOCUMENT_NAME);
57   
58    /**
59    * Name of field <code>userName</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
60    */
61    public static final String FIELD_USER = "userName";
62   
63    /**
64    * Pretty name of field <code>userName</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
65    */
66    public static final String FIELDPN_USERNAME = "User Name";
67   
68    /**
69    * Name of field <code>date</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
70    */
71    public static final String FIELD_DATE_OF_CREATION = "date";
72   
73    /**
74    * Pretty name of field <code>date</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
75    */
76    public static final String FIELDPN_DATE = "Date";
77   
78    /**
79    * Name of field <code>userComment</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
80    */
81    public static final String FIELD_USER_COMMENT = "userComment";
82   
83    /**
84    * Pretty name of field <code>userComment</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
85    */
86    public static final String FIELDPN_USERCOMMENT = "User Comment";
87   
88    /**
89    * Name of field <code>status</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
90    */
91    public static final String FIELD_STATUS = "status";
92   
93    /**
94    * Pretty name of field <code>status</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
95    */
96    public static final String FIELDPN_STATUS = "Status";
97   
98    /**
99    * List of possible values for <code>status</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
100    */
101    public static final String FIELDL_STATUS = "pending=Pending|accepted=Accepted|rejected=Rejected";
102   
103    /**
104    * Name of field <code>resolutionDate</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
105    */
106    public static final String FIELD_DATE_OF_CLOSURE = "resolutionDate";
107   
108    /**
109    * Pretty name of field <code>resolutionDate</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
110    */
111    public static final String FIELDPN_RESOLUTIONDATE = "Resolution Date";
112   
113    /**
114    * Name of field <code>reviewer</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
115    */
116    public static final String FIELD_ADMIN = "reviewer";
117   
118    /**
119    * Pretty name of field <code>reviewer</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
120    */
121    public static final String FIELDPN_REVIEWER = "Reviewer";
122   
123    /**
124    * Name of field <code>reviewerComment</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
125    */
126    public static final String FIELD_ADMIN_COMMENT = "reviewerComment";
127   
128    /**
129    * Pretty name of field <code>reviewerComment</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
130    */
131    public static final String FIELDPN_REVIEWERCOMMENT = "Reviewer's Comment";
132   
133    /**
134    * Name of field <code>reviewerPrivateComment</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
135    */
136    public static final String FIELD_ADMIN_PRIVATE_COMMENT = "reviewerPrivateComment";
137   
138    /**
139    * Pretty name of field <code>reviewerPrivateComment</code> for the XWiki class
140    * WikiManager.WikiCandidateMemberClass.
141    */
142    public static final String FIELDPN_REVIEWERPRIVATECOMMENT = "Reviewer's Private Reason";
143   
144    /**
145    * Name of field <code>type</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
146    */
147    public static final String FIELD_TYPE = "type";
148   
149    /**
150    * Pretty name of field <code>type</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
151    */
152    public static final String FIELDPN_TYPE = "Type";
153   
154    /**
155    * List of possible values for <code>type</code> for the XWiki class WikiManager.WikiCandidateMemberClass.
156    */
157    public static final String FIELDL_TYPE = "request=Request|invitation=Invitation";
158   
159    /**
160    * Constructor.
161    */
 
162  2 toggle public WikiCandidateMemberClassInitializer()
163    {
164  2 super(REFERENCE);
165    }
166   
 
167  6 toggle @Override
168    public boolean updateDocument(XWikiDocument document)
169    {
170  6 boolean needsUpdate = false;
171   
172    // Add missing class fields
173  6 BaseClass baseClass = document.getXClass();
174   
175  6 needsUpdate |= baseClass.addTextField(FIELD_USER, FIELDPN_USERNAME, 30);
176  6 needsUpdate |= baseClass.addDateField(FIELD_DATE_OF_CREATION, FIELDPN_DATE);
177  6 needsUpdate |= baseClass.addTextAreaField(FIELD_USER_COMMENT, FIELDPN_USERCOMMENT, 40, 3);
178  6 needsUpdate |= baseClass.addStaticListField(FIELD_STATUS, FIELDPN_STATUS, FIELDL_STATUS);
179  6 needsUpdate |= baseClass.addDateField(FIELD_DATE_OF_CLOSURE, FIELDPN_RESOLUTIONDATE);
180  6 needsUpdate |= baseClass.addTextField(FIELD_ADMIN, FIELDPN_REVIEWER, 30);
181  6 needsUpdate |= baseClass.addTextAreaField(FIELD_ADMIN_COMMENT, FIELDPN_REVIEWERCOMMENT, 40, 3);
182  6 needsUpdate |= baseClass.addTextAreaField(FIELD_ADMIN_PRIVATE_COMMENT, FIELDPN_REVIEWERPRIVATECOMMENT, 40, 3);
183  6 needsUpdate |= baseClass.addStaticListField(FIELD_TYPE, FIELDPN_TYPE, FIELDL_TYPE);
184   
185    // Check if the document is hidden
186  6 if (!document.isHidden()) {
187  6 document.setHidden(true);
188  6 needsUpdate = true;
189    }
190   
191    // Mark this document as Wiki Class.
192  6 if (document.isNew()) {
193  6 needsUpdate |= setClassDocumentFields(document, "Wiki Candidate Member Class");
194  6 document.setContent(document.getContent() + "\n\nClass that represents a candidacy to become a member "
195    + "of the wiki.");
196    }
197   
198  6 return needsUpdate;
199    }
200    }