1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.internal.filter.input

File BaseClassEventGenerator.java

 

Coverage histogram

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

Code metrics

2
15
1
1
94
48
2
0.13
15
1
2

Classes

Class Line # Actions
BaseClassEventGenerator 47 15 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 4 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.input;
21   
22    import java.lang.reflect.ParameterizedType;
23    import java.util.Iterator;
24   
25    import javax.inject.Inject;
26    import javax.inject.Singleton;
27   
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.component.util.DefaultParameterizedType;
30    import org.xwiki.filter.FilterEventParameters;
31    import org.xwiki.filter.FilterException;
32    import org.xwiki.filter.event.model.WikiClassFilter;
33    import org.xwiki.filter.instance.input.DocumentInstanceInputProperties;
34    import org.xwiki.filter.instance.input.EntityEventGenerator;
35    import org.xwiki.filter.instance.internal.input.AbstractBeanEntityEventGenerator;
36   
37    import com.xpn.xwiki.internal.filter.BaseClassFilter;
38    import com.xpn.xwiki.objects.classes.BaseClass;
39    import com.xpn.xwiki.objects.classes.PropertyClass;
40   
41    /**
42    * @version $Id: e812064d129a9cf907578833936f2455a4f51bc6 $
43    * @since 6.2M1
44    */
45    @Component
46    @Singleton
 
47    public class BaseClassEventGenerator
48    extends AbstractBeanEntityEventGenerator<BaseClass, BaseClassFilter, DocumentInstanceInputProperties>
49    {
50    /**
51    * The role of this component.
52    */
53    public static final ParameterizedType ROLE = new DefaultParameterizedType(null, EntityEventGenerator.class,
54    BaseClass.class, DocumentInstanceInputProperties.class);
55   
56    @Inject
57    private EntityEventGenerator<PropertyClass> propertyEventGenerator;
58   
 
59  10521 toggle @Override
60    public void write(BaseClass xclass, Object filter, BaseClassFilter xclassFilter,
61    DocumentInstanceInputProperties properties) throws FilterException
62    {
63    // WikiClass
64   
65  10521 FilterEventParameters classParameters = new FilterEventParameters();
66   
67  10521 classParameters.put(WikiClassFilter.PARAMETER_NAME, xclass.getName());
68  10521 classParameters.put(WikiClassFilter.PARAMETER_CUSTOMCLASS, xclass.getCustomClass());
69  10521 classParameters.put(WikiClassFilter.PARAMETER_CUSTOMMAPPING, xclass.getCustomMapping());
70  10521 classParameters.put(WikiClassFilter.PARAMETER_DEFAULTSPACE, xclass.getDefaultWeb());
71  10521 classParameters.put(WikiClassFilter.PARAMETER_NAMEFIELD, xclass.getNameField());
72  10521 classParameters.put(WikiClassFilter.PARAMETER_SHEET_DEFAULTEDIT, xclass.getDefaultEditSheet());
73  10521 classParameters.put(WikiClassFilter.PARAMETER_SHEET_DEFAULTVIEW, xclass.getDefaultViewSheet());
74  10521 classParameters.put(WikiClassFilter.PARAMETER_VALIDATIONSCRIPT, xclass.getValidationScript());
75   
76  10521 xclassFilter.beginWikiClass(classParameters);
77   
78    // Properties
79   
80    // Iterate over values sorted by field name so that the values are
81    // exported to XML in a consistent order.
82  10521 Iterator<PropertyClass> it = xclass.getSortedIterator();
83  78864 while (it.hasNext()) {
84  68343 PropertyClass xclassProperty = it.next();
85   
86  68343 ((PropertyClassEventGenerator) this.propertyEventGenerator).write(xclassProperty, filter, xclassFilter,
87    properties);
88    }
89   
90    // /WikiClass
91   
92  10521 xclassFilter.endWikiClass(classParameters);
93    }
94    }