1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.refactoring.internal.job; |
21 |
|
|
22 |
|
import java.util.Collection; |
23 |
|
|
24 |
|
import javax.inject.Named; |
25 |
|
|
26 |
|
import org.xwiki.component.annotation.Component; |
27 |
|
import org.xwiki.model.reference.DocumentReference; |
28 |
|
import org.xwiki.model.reference.EntityReference; |
29 |
|
import org.xwiki.model.reference.SpaceReference; |
30 |
|
import org.xwiki.refactoring.job.RefactoringJobs; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
38 |
|
@Component |
39 |
|
@Named(RefactoringJobs.RENAME) |
|
|
| 100% |
Uncovered Elements: 0 (28) |
Complexity: 10 |
Complexity Density: 0.67 |
|
40 |
|
public class RenameJob extends MoveJob |
41 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
40 |
@Override... |
43 |
|
public String getType() |
44 |
|
{ |
45 |
40 |
return RefactoringJobs.RENAME; |
46 |
|
} |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
48 |
8 |
@Override... |
49 |
|
protected void process(Collection<EntityReference> entityReferences) |
50 |
|
{ |
51 |
8 |
if (entityReferences.size() == 1) { |
52 |
7 |
process(entityReferences.iterator().next()); |
53 |
|
} |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
56 |
7 |
@Override... |
57 |
|
protected void process(EntityReference source) |
58 |
|
{ |
59 |
|
|
60 |
|
|
61 |
7 |
EntityReference destination = this.request.getDestination(); |
62 |
7 |
if (source.getType() != destination.getType()) { |
63 |
1 |
this.logger.error("You cannot change the entity type (from [{}] to [{}]).", source.getType(), |
64 |
|
destination.getType()); |
65 |
1 |
return; |
66 |
|
} |
67 |
|
|
68 |
6 |
super.process(source); |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
71 |
5 |
@Override... |
72 |
|
protected void process(DocumentReference source, EntityReference destination) |
73 |
|
{ |
74 |
|
|
75 |
5 |
DocumentReference destinationDocumentReference = new DocumentReference(destination); |
76 |
5 |
if (this.request.isDeep() && isSpaceHomeReference(source)) { |
77 |
3 |
if (isSpaceHomeReference(destinationDocumentReference)) { |
78 |
|
|
79 |
2 |
process(source.getLastSpaceReference(), destinationDocumentReference.getLastSpaceReference()); |
80 |
|
} else { |
81 |
1 |
this.logger.error("You cannot transform a non-terminal document [{}] into a terminal document [{}]" |
82 |
|
+ " and preserve its child documents at the same time.", source, destinationDocumentReference); |
83 |
|
} |
84 |
|
} else { |
85 |
2 |
maybeMove(source, destinationDocumentReference); |
86 |
|
} |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
1 |
@Override... |
90 |
|
protected void process(SpaceReference source, EntityReference destination) |
91 |
|
{ |
92 |
|
|
93 |
1 |
process(source, new SpaceReference(destination)); |
94 |
|
} |
95 |
|
} |