1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.refactoring.job

File MoveRequest.java

 

Coverage histogram

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

Code metrics

0
10
10
1
168
51
10
1
1
10
1

Classes

Class Line # Actions
MoveRequest 31 10 0% 10 0
1.0100%
 

Contributing tests

This file is covered by 23 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.refactoring.job;
21   
22    import org.xwiki.model.reference.EntityReference;
23   
24    /**
25    * A job request that can be used to move a collection of entities to a specified destination. This request can also be
26    * used to rename an entity.
27    *
28    * @version $Id: 8a106e9f3d6fae4735b7a7ae475ced727d45bf19 $
29    * @since 7.2M1
30    */
 
31    public class MoveRequest extends EntityRequest
32    {
33    /**
34    * Serialization identifier.
35    */
36    private static final long serialVersionUID = 1L;
37   
38    /**
39    * @see #getDestination()
40    */
41    private static final String PROPERTY_DESTINATION = "destination";
42   
43    /**
44    * @see #isDeleteSource()
45    */
46    private static final String PROPERTY_DELETE_SOURCE = "deleteSource";
47   
48    /**
49    * @see #isUpdateLinks()
50    */
51    private static final String PROPERTY_UPDATE_LINKS = "updateLinks";
52   
53    /**
54    * @see #isAutoRedirect()
55    */
56    private static final String PROPERTY_AUTO_REDIRECT = "autoRedirect";
57   
58    /**
59    * @see #isUpdateParentField()
60    */
61    private static final String PROPERTY_UPDATE_PARENT_FIELD = "updateParentField";
62   
63    /**
64    * @return the destination entity, where to move the entities specified by {@link #getEntityReferences()}
65    */
 
66  79 toggle public EntityReference getDestination()
67    {
68  79 return getProperty(PROPERTY_DESTINATION);
69    }
70   
71    /**
72    * Sets the destination entity, where to move the entities specified by {@link #getEntityReferences()}.
73    *
74    * @param destination the destination entity
75    */
 
76  27 toggle public void setDestination(EntityReference destination)
77    {
78  27 setProperty(PROPERTY_DESTINATION, destination);
79    }
80   
81    /**
82    * @return {@code true} if the source entities specified by {@link #getEntityReferences()} should be deleted,
83    * {@code false} otherwise; in a standard move operation the source is deleted but sometimes you may want to
84    * keep the source as a backup; this option can also be used to perform a copy instead of a move; note that
85    * the difference between a copy and a standard move without delete is that the back-links are not updated
86    */
 
87  32 toggle public boolean isDeleteSource()
88    {
89  32 return getProperty(PROPERTY_DELETE_SOURCE, true);
90    }
91   
92    /**
93    * Sets whether the source entities specified by {@link #getEntityReferences()} should be deleted or not.
94    *
95    * @param deleteSource {@code true} to delete the source, {@code false} to keep it as a backup
96    */
 
97  3 toggle public void setDeleteSource(boolean deleteSource)
98    {
99  3 setProperty(PROPERTY_DELETE_SOURCE, deleteSource);
100    }
101   
102    /**
103    * @return {@code true} if the links that target the old entity reference (before the move) should be updated to
104    * target the new reference (after the move), {@code false} to preserve the old link target
105    */
 
106  9 toggle public boolean isUpdateLinks()
107    {
108  9 return getProperty(PROPERTY_UPDATE_LINKS, true);
109    }
110   
111    /**
112    * Sets whether the links that target the old entity reference (before the move) should be updated to target the new
113    * reference (after the move) or not.
114    *
115    * @param updateLinks {@code true} to update the links, {@code false} to preserve the old link target
116    */
 
117  10 toggle public void setUpdateLinks(boolean updateLinks)
118    {
119  10 setProperty(PROPERTY_UPDATE_LINKS, updateLinks);
120    }
121   
122    /**
123    * @return {@code true} if the original pages should be redirected automatically to the new location when accessed
124    * by the user, in order to preserve external links, {@code false} otherwise
125    */
 
126  8 toggle public boolean isAutoRedirect()
127    {
128  8 return getProperty(PROPERTY_AUTO_REDIRECT, true);
129    }
130   
131    /**
132    * Sets whether the original pages should be redirected automatically to the new location when accessed by the user,
133    * in order to preserve external links.
134    *
135    * @param autoRedirect {@code true} to automatically redirect the old pages to the new location, {@code false}
136    * otherwise
137    */
 
138  10 toggle public void setAutoRedirect(boolean autoRedirect)
139    {
140  10 setProperty(PROPERTY_AUTO_REDIRECT, autoRedirect);
141    }
142   
143    /**
144    * @return {@code true} if the parent-child relationship should be preserved by updating the {@code parent} field of
145    * the {@code source}'s child pages to use the {@code destination} as parent instead; {@code false}
146    * otherwise
147    * @since 8.0M2
148    * @since 7.4.2
149    */
 
150  6 toggle public boolean isUpdateParentField()
151    {
152  6 return getProperty(PROPERTY_UPDATE_PARENT_FIELD, true);
153    }
154   
155    /**
156    * Sets whether the parent-child relationship should be preserved by updating the {@code parent} field of the
157    * {@code source}'s child pages to use the {@code destination} as parent instead; {@code false} otherwise.
158    *
159    * @param updateParentField {@code true} to update the parent field of the {@code source}'s child pages and use the
160    * {@code destination} as parent instead, {@code false} otherwise
161    * @since 8.0M2
162    * @since 7.4.2
163    */
 
164  10 toggle public void setUpdateParentField(boolean updateParentField)
165    {
166  10 setProperty(PROPERTY_UPDATE_PARENT_FIELD, updateParentField);
167    }
168    }