| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.wiki.template.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.EntityType; |
| 27 |
|
import org.xwiki.model.reference.EntityReference; |
| 28 |
|
|
| 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 |
|
|
| 35 |
|
|
| 36 |
|
@since |
| 37 |
|
@version |
| 38 |
|
|
| 39 |
|
@Component |
| 40 |
|
@Named("WikiManagerCode.WikiTemplateClass") |
| 41 |
|
@Singleton |
| |
|
| 90% |
Uncovered Elements: 2 (20) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 42 |
|
public class WikiTemplateClassDocumentInitializer extends AbstractMandatoryDocumentInitializer |
| 43 |
|
{ |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
public static final String DOCUMENT_NAME = "WikiTemplateClass"; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
public static final String DOCUMENT_SPACE = "WikiManager"; |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
public static final EntityReference SERVER_CLASS = new EntityReference(DOCUMENT_NAME, EntityType.DOCUMENT, |
| 58 |
|
new EntityReference(DOCUMENT_SPACE, EntityType.SPACE)); |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
public static final String FIELD_ISWIKITEMPLATE = "iswikitemplate"; |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
public static final String FIELDPN_ISWIKITEMPLATE = "Template"; |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
public static final String FIELDDT_ISWIKITEMPLATE = "checkbox"; |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
public static final Boolean DEFAULT_ISWIKITEMPLATE = Boolean.FALSE; |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 83 |
1 |
public WikiTemplateClassDocumentInitializer()... |
| 84 |
|
{ |
| 85 |
|
|
| 86 |
|
|
| 87 |
1 |
super(DOCUMENT_SPACE, DOCUMENT_NAME); |
| 88 |
|
} |
| 89 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 90 |
1 |
@Override... |
| 91 |
|
protected boolean isMainWikiOnly() |
| 92 |
|
{ |
| 93 |
|
|
| 94 |
1 |
return true; |
| 95 |
|
} |
| 96 |
|
|
| |
|
| 86.7% |
Uncovered Elements: 2 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 97 |
1 |
@Override... |
| 98 |
|
public boolean updateDocument(XWikiDocument document) |
| 99 |
|
{ |
| 100 |
1 |
boolean needsUpdate = false; |
| 101 |
|
|
| 102 |
|
|
| 103 |
1 |
BaseClass baseClass = document.getXClass(); |
| 104 |
|
|
| 105 |
1 |
needsUpdate |= baseClass.addBooleanField(FIELD_ISWIKITEMPLATE, FIELDPN_ISWIKITEMPLATE, FIELDDT_ISWIKITEMPLATE); |
| 106 |
1 |
needsUpdate |= updateBooleanClassDefaultValue(baseClass, FIELD_ISWIKITEMPLATE, DEFAULT_ISWIKITEMPLATE); |
| 107 |
|
|
| 108 |
|
|
| 109 |
1 |
if (!document.isHidden()) { |
| 110 |
1 |
document.setHidden(true); |
| 111 |
1 |
needsUpdate = true; |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
|
| 115 |
1 |
if (document.isNew()) { |
| 116 |
1 |
needsUpdate |= setClassDocumentFields(document, "Wiki Template Class"); |
| 117 |
1 |
document.setContent(document.getContent() + "\n\nClass that represents the wiki descriptor property group" |
| 118 |
|
+ " for the template feature."); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
1 |
return needsUpdate; |
| 122 |
|
} |
| 123 |
|
} |