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

File WatchListJobClassDocumentInitializer.java

 

Coverage histogram

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

Code metrics

0
8
3
1
100
41
3
0.38
2.67
3
1

Classes

Class Line # Actions
WatchListJobClassDocumentInitializer 41 8 0% 3 0
1.0100%
 

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.watchlist.internal.documents;
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.XWiki;
29    import com.xpn.xwiki.doc.XWikiDocument;
30    import com.xpn.xwiki.internal.mandatory.AbstractMandatoryDocumentInitializer;
31    import com.xpn.xwiki.objects.classes.BaseClass;
32   
33    /**
34    * Document initializer for {@value #DOCUMENT_FULL_NAME}.
35    *
36    * @version $Id: ff664b5cef912b5ef3e487cebd5a0eeea7f7d4ed $
37    */
38    @Component
39    @Named(WatchListJobClassDocumentInitializer.DOCUMENT_FULL_NAME)
40    @Singleton
 
41    public class WatchListJobClassDocumentInitializer extends AbstractMandatoryDocumentInitializer
42    {
43    /**
44    * Class document name.
45    */
46    public static final String DOCUMENT_NAME = "WatchListJobClass";
47   
48    /**
49    * Class document full name.
50    */
51    public static final String DOCUMENT_FULL_NAME = XWiki.SYSTEM_SPACE + "." + DOCUMENT_NAME;
52   
53    /**
54    * Class document reference.
55    */
56    public static final LocalDocumentReference DOCUMENT_REFERENCE = new LocalDocumentReference(XWiki.SYSTEM_SPACE,
57    DOCUMENT_NAME);
58   
59    /**
60    * Email template field name.
61    */
62    public static final String TEMPLATE_FIELD = "template";
63   
64    /**
65    * Last fire time field name.
66    */
67    public static final String LAST_FIRE_TIME_FIELD = "last_fire_time";
68   
69    /**
70    * Default constructor.
71    */
 
72  1 toggle public WatchListJobClassDocumentInitializer()
73    {
74  1 super(DOCUMENT_REFERENCE);
75    }
76   
 
77  1 toggle @Override
78    protected boolean isMainWikiOnly()
79    {
80    // Main wiki document.
81  1 return true;
82    }
83   
 
84  1 toggle @Override
85    public boolean updateDocument(XWikiDocument document)
86    {
87  1 boolean needsUpdate = false;
88  1 BaseClass bclass = document.getXClass();
89   
90    // Class properties
91  1 needsUpdate |=
92    bclass.addTextField(TEMPLATE_FIELD, "Document holding the notification message template to use", 80);
93  1 needsUpdate |= bclass.addDateField(LAST_FIRE_TIME_FIELD, "Last notifier fire time", "dd/MM/yyyy HH:mm:ss", 1);
94   
95    // Handle the fields and the sheet of the document containing the class.
96  1 needsUpdate |= setClassDocumentFields(document, "XWiki WatchList Notifier Class");
97   
98  1 return needsUpdate;
99    }
100    }