/
AssignmentPath.java
117 lines (95 loc) · 4.21 KB
/
AssignmentPath.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* Copyright (c) 2010-2017 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.model.api.context;
import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.model.api.util.AssignmentPathUtil;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.ShortDumpable;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrderConstraintsType;
import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* Path from the source object (focus) to the ultimate assignment that is being processed or referenced.
* The path consists of a chain (list) of segments. Each segment corresponds to a single assignment or inducement.
* The source of the first segment is the focus. Source of each following segment (i.e. assignment) is the target
* of previous segment (i.e. assignment).
*
* @author semancik
* @author mederly
*/
public interface AssignmentPath extends DebugDumpable, ShortDumpable, Cloneable, Serializable {
List<? extends AssignmentPathSegment> getSegments();
/**
* Returns segment specified by index. Negative indexes work in reverse direction.
*/
AssignmentPathSegment getSegment(int index);
AssignmentPathSegment first();
boolean isEmpty();
int size();
AssignmentPathSegment last();
// beforeLast(0) means last()
// beforeLast(1) means one before last()
AssignmentPathSegment beforeLast(int n);
int countTargetOccurrences(ObjectType target);
/**
* Returns a "user understandable" part of this path. I.e. only those objects that are of "order 1" above the focal object.
* E.g. from chain of
*
* jack =(a)=> Engineer =(i)=> Employee =(a)=> PersonMetarole =(i2)=> Person =(i)=> Entity
*
* the result would be
*
* Engineer -> Employee -> Person -> Entity
*
* TODO find a better name
*/
@NotNull
List<ObjectType> getFirstOrderChain();
/**
* In the context of meta-roles this is the role that the currently-processed inducement "applies to".
* I.e. the role that would contain this inducement in case that meta-roles were not used.
* Technically, this is the last element in the "first order chain" or roles.
*
* Note: proto- is the opposite of meta-
*/
ObjectType getProtoRole();
/**
* Shallow clone.
*/
AssignmentPath clone();
AssignmentPath cloneFirst(int n);
AssignmentPathType toAssignmentPathType(boolean includeAssignmentsContent);
ExtensionType collectExtensions(int startAt) throws SchemaException;
static ExtensionType collectExtensions(AssignmentPathType path, int startAt, ModelService modelService, Task task, OperationResult result)
throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException,
ConfigurationException, ExpressionEvaluationException {
return AssignmentPathUtil.collectExtensions(path, startAt, modelService, task, result);
}
// Groovy [] operator
default AssignmentPathSegment getAt(int index) {
return getSegment(index);
}
/**
* Returns true if the path matches specified order constraints. All of them must match.
* Although there are some defaults, it is recommended to specify constraints explicitly.
* Currently not supported on empty paths.
*
* Not all parts of OrderConstraintsType are supported. Namely, resetOrder item has no meaning here.
*/
boolean matches(@NotNull List<OrderConstraintsType> orderConstraints);
/**
* Preliminary (limited) implementation. To be used to compare paths pointing to the same target object. Use with care.
*/
boolean equivalent(AssignmentPath other);
}