1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.extension.xar

File XWikiDocumentMergerConfiguration.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
41% of files have more coverage

Code metrics

2
12
10
1
130
57
11
0.92
1.2
10
1.1

Classes

Class Line # Actions
XWikiDocumentMergerConfiguration 36 12 0% 11 3
0.87587.5%
 

Contributing tests

This file is covered by 32 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 org.xwiki.extension.xar;
21   
22    import java.util.EnumMap;
23    import java.util.Map;
24   
25    import org.xwiki.extension.xar.question.ConflictQuestion.ConflictType;
26    import org.xwiki.extension.xar.question.ConflictQuestion.GlobalAction;
27    import org.xwiki.model.reference.DocumentReference;
28    import org.xwiki.stability.Unstable;
29    import org.xwiki.xar.XarEntryType.UpgradeType;
30   
31    /**
32    * @version $Id: 92b0f33fdc882783a612499f46e107992c465f6c $
33    * @since 10.3
34    */
35    @Unstable
 
36    public class XWikiDocumentMergerConfiguration
37    {
38    private final Map<ConflictType, GlobalAction> conflictActions = new EnumMap<>(ConflictType.class);
39   
40    private DocumentReference authorReference;
41   
42    private UpgradeType type;
43   
44    /**
45    * Default constructor.
46    */
 
47  3363 toggle public XWikiDocumentMergerConfiguration()
48    {
49    // Default behavior
50  3363 setConflictAction(ConflictType.CURRENT_DELETED, GlobalAction.CURRENT);
51  3363 setConflictAction(ConflictType.MERGE_SUCCESS, GlobalAction.MERGED);
52    }
53   
54    /**
55    * @return the reference of the user to set as document author
56    */
 
57  40 toggle public DocumentReference getAuthorReference()
58    {
59  40 return this.authorReference;
60    }
61   
62    /**
63    * @param author the reference of the user to set as document author
64    */
 
65  3363 toggle public void setAuthorReference(DocumentReference author)
66    {
67  3363 this.authorReference = author;
68    }
69   
70    /**
71    * @param type the type of conflict
72    * @return the action associated to the passed conflict type
73    */
 
74  39 toggle public GlobalAction getConflictAction(ConflictType type)
75    {
76  39 return this.conflictActions.get(type);
77    }
78   
79    /**
80    * @param type the type of conflict
81    * @param action the action associated to the passed conflict type
82    */
 
83  6726 toggle public void setConflictAction(ConflictType type, GlobalAction action)
84    {
85  6726 setConflictAction(type, action, action);
86    }
87   
88    /**
89    * @param type the type of conflict
90    * @param action the action associated to the passed conflict type
91    * @param defaultAnswer the action associated to the passed conflict type (if {@code action} is null)
92    */
 
93  6726 toggle public void setConflictAction(ConflictType type, GlobalAction action, GlobalAction defaultAnswer)
94    {
95  6726 this.conflictActions.put(type, action != null ? action : defaultAnswer);
96    }
97   
98    /**
99    * @return the mapping between type of conflict and action
100    */
 
101  0 toggle public Map<ConflictType, GlobalAction> getConflictActions()
102    {
103  0 return this.conflictActions;
104    }
105   
106    /**
107    * @param conflictActions the mapping between type of conflict and action
108    */
 
109  3363 toggle public void setConflictActions(Map<ConflictType, GlobalAction> conflictActions)
110    {
111  3363 this.conflictActions.clear();
112  3363 this.conflictActions.putAll(conflictActions);
113    }
114   
115    /**
116    * @return the type of upgrade associated with the document
117    */
 
118  1569 toggle public UpgradeType getType()
119    {
120  1569 return this.type;
121    }
122   
123    /**
124    * @param type the type of upgrade associated with the document
125    */
 
126  3363 toggle public void setType(UpgradeType type)
127    {
128  3363 this.type = type;
129    }
130    }