1. Project Clover database Tue Dec 20 2016 21:24:09 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 44 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  6819 toggle @Override
48    public void initialize() throws InitializationException
49    {
50  6819 initialize(this.propertyFilter);
51    }
52   
 
53  139207 toggle private PropertyClassOutputFilterStream getPropertyClassOutputFilterStream()
54    {
55  139204 return (PropertyClassOutputFilterStream) this.propertyFilter;
56    }
57   
58    // Events
59   
 
60  8295 toggle @Override
61    public void beginWikiClass(FilterEventParameters parameters) throws FilterException
62    {
63  8295 if (this.enabled) {
64  5019 if (this.entity == null) {
65  2949 this.entity = new BaseClass();
66    }
67   
68  5019 this.entity.setDocumentReference(getDocumentReference(WikiClassFilter.PARAMETER_NAME, parameters, null));
69  5019 this.entity.setCustomClass(getString(WikiClassFilter.PARAMETER_CUSTOMCLASS, parameters, null));
70  5020 this.entity.setCustomMapping(getString(WikiClassFilter.PARAMETER_CUSTOMMAPPING, parameters, null));
71  5017 this.entity.setDefaultViewSheet(getString(WikiClassFilter.PARAMETER_SHEET_DEFAULTVIEW, parameters, null));
72  5018 this.entity.setDefaultEditSheet(getString(WikiClassFilter.PARAMETER_SHEET_DEFAULTEDIT, parameters, null));
73  5019 this.entity.setDefaultWeb(getString(WikiClassFilter.PARAMETER_DEFAULTSPACE, parameters, null));
74  5018 this.entity.setNameField(getString(WikiClassFilter.PARAMETER_NAMEFIELD, parameters, null));
75  5015 this.entity.setValidationScript(getString(WikiClassFilter.PARAMETER_VALIDATIONSCRIPT, parameters, null));
76   
77  5019 getPropertyClassOutputFilterStream().setCurrentXClass(this.entity);
78  5019 getPropertyClassOutputFilterStream().enable();
79    }
80    }
81   
 
82  51891 toggle @Override
83    public void endWikiClassProperty(String name, String type, FilterEventParameters parameters) throws FilterException
84    {
85  51891 if (this.enabled) {
86  37529 if (getPropertyClassOutputFilterStream().getEntity() != null) {
87  37530 this.entity.safeput(name, getPropertyClassOutputFilterStream().getEntity());
88  37530 getPropertyClassOutputFilterStream().setEntity(null);
89    }
90    }
91    }
92   
 
93  8294 toggle @Override
94    public void endWikiClass(FilterEventParameters parameters) throws FilterException
95    {
96  8294 getPropertyClassOutputFilterStream().setCurrentXClass(null);
97  8294 getPropertyClassOutputFilterStream().disable();
98    }
99    }