1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.internal.filter.output

File BaseClassOutputFilterStream.java

 

Coverage histogram

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

Code metrics

8
21
5
1
99
63
9
0.43
4.2
5
1.8

Classes

Class Line # Actions
BaseClassOutputFilterStream 42 21 0% 9 0
1.0100%
 

Contributing tests

This file is covered by 47 tests. .

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 com.xpn.xwiki.internal.filter.output;
21   
22    import javax.inject.Inject;
23   
24    import org.xwiki.component.annotation.Component;
25    import org.xwiki.component.annotation.InstantiationStrategy;
26    import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
27    import org.xwiki.component.phase.Initializable;
28    import org.xwiki.component.phase.InitializationException;
29    import org.xwiki.filter.FilterEventParameters;
30    import org.xwiki.filter.FilterException;
31    import org.xwiki.filter.event.model.WikiClassFilter;
32   
33    import com.xpn.xwiki.objects.classes.BaseClass;
34    import com.xpn.xwiki.objects.classes.PropertyClass;
35   
36    /**
37    * @version $Id: 14177deed1ad3197d9264d99e01bd30d5fccf1a4 $
38    * @since 9.0RC1
39    */
40    @Component
41    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
42    public class BaseClassOutputFilterStream extends AbstractEntityOutputFilterStream<BaseClass> implements Initializable
43    {
44    @Inject
45    private EntityOutputFilterStream<PropertyClass> propertyFilter;
46   
 
47  20302 toggle @Override
48    public void initialize() throws InitializationException
49    {
50  20302 initialize(this.propertyFilter);
51    }
52   
 
53  337086 toggle private PropertyClassOutputFilterStream getPropertyClassOutputFilterStream()
54    {
55  337086 return (PropertyClassOutputFilterStream) this.propertyFilter;
56    }
57   
58    // Events
59   
 
60  21100 toggle @Override
61    public void beginWikiClass(FilterEventParameters parameters) throws FilterException
62    {
63  21100 if (this.enabled) {
64  13049 if (this.entity == null) {
65  7370 this.entity = new BaseClass();
66    }
67   
68  13049 this.entity.setDocumentReference(getDocumentReference(WikiClassFilter.PARAMETER_NAME, parameters, null));
69  13049 this.entity.setCustomClass(getString(WikiClassFilter.PARAMETER_CUSTOMCLASS, parameters, null));
70  13049 this.entity.setCustomMapping(getString(WikiClassFilter.PARAMETER_CUSTOMMAPPING, parameters, null));
71  13049 this.entity.setDefaultViewSheet(getString(WikiClassFilter.PARAMETER_SHEET_DEFAULTVIEW, parameters, null));
72  13049 this.entity.setDefaultEditSheet(getString(WikiClassFilter.PARAMETER_SHEET_DEFAULTEDIT, parameters, null));
73  13049 this.entity.setDefaultWeb(getString(WikiClassFilter.PARAMETER_DEFAULTSPACE, parameters, null));
74  13049 this.entity.setNameField(getString(WikiClassFilter.PARAMETER_NAMEFIELD, parameters, null));
75  13049 this.entity.setValidationScript(getString(WikiClassFilter.PARAMETER_VALIDATIONSCRIPT, parameters, null));
76   
77  13049 getPropertyClassOutputFilterStream().setCurrentXClass(this.entity);
78  13049 getPropertyClassOutputFilterStream().enable();
79    }
80    }
81   
 
82  137352 toggle @Override
83    public void endWikiClassProperty(String name, String type, FilterEventParameters parameters) throws FilterException
84    {
85  137351 if (this.enabled) {
86  89597 if (getPropertyClassOutputFilterStream().getEntity() != null) {
87  89596 this.entity.safeput(name, getPropertyClassOutputFilterStream().getEntity());
88  89594 getPropertyClassOutputFilterStream().setEntity(null);
89    }
90    }
91    }
92   
 
93  21100 toggle @Override
94    public void endWikiClass(FilterEventParameters parameters) throws FilterException
95    {
96  21100 getPropertyClassOutputFilterStream().setCurrentXClass(null);
97  21100 getPropertyClassOutputFilterStream().disable();
98    }
99    }