/
Definition.java
175 lines (152 loc) · 6.15 KB
/
Definition.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.prism;
import com.evolveum.midpoint.prism.schema.SchemaRegistry;
import com.evolveum.midpoint.util.DebugDumpable;
import org.jetbrains.annotations.NotNull;
import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.IdentityHashMap;
/**
* @author mederly
*/
public interface Definition extends Serializable, DebugDumpable, Revivable {
/**
* Returns a name of the type for this definition.
*
* The type can be part of the compile-time schema or it can be defined at run time.
*
* Examples of the former case are types like c:UserType, xsd:string, or even flexible
* ones like c:ExtensionType or c:ShadowAttributesType.
*
* Examples of the latter case are types used in
* - custom extensions, like ext:LocationsType (where ext = e.g. http://example.com/extension),
* - resource schema, like ri:inetOrgPerson (ri = http://.../resource/instance-3),
* - connector schema, like TODO
*
* In XML representation that corresponds to the name of the XSD type. Although beware, the
* run-time types do not have statically defined structure. And the resource and connector-related
* types may even represent different kinds of objects within different contexts (e.g. two
* distinct resources both with ri:AccountObjectClass types).
*
* Also note that for complex type definitions, the type name serves as a unique identifier.
* On the other hand, for item definitions, it is just one of its attributes; primary key
* is item name in that case.
*
* The type name should be fully qualified. (TODO reconsider this)
*
* @return the type name
*/
@NotNull
QName getTypeName();
/**
* This means that the entities described by this schema (items, complex types) or their content
* is not defined by fixed (compile-time) schema. I.e. it is known only at run time.
*
* Some examples for "false" value:
* - c:user, c:UserType - statically defined type with statically defined content.
*
* Some examples for "true" value:
* - c:extension, c:ExtensionType - although the entity itself (item, type) are defined in
* the static schema, their content is not known at compile time;
* - c:attributes, c:ShadowAttributeType - the same as extension/ExtensionType;
* - ext:weapon (of type xsd:string) - even if the content is statically defined,
* the definition of the item itself is not known at compile time;
* - ri:inetOrgPerson, ext:LocationsType, ext:locations - both the entity
* and their content are known at run time only.
*
* TODO clarify the third point; provide some tests for the 3rd and 4th point
*/
boolean isRuntimeSchema();
/**
* Item definition that has this flag set should be ignored by any processing.
* The ignored item is still part of the schema. Item instances may appear in
* the serialized data formats (e.g. XML) or data store and the parser should
* not raise an error if it encounters them. But any high-level processing code
* should ignore presence of this item. E.g. it should not be displayed to the user,
* should not be present in transformed data structures, etc.
*
* Note that the same item can be ignored at higher layer (e.g. presentation)
* but not ignored at lower layer (e.g. model). This works by presenting different
* item definitions for these layers (see LayerRefinedAttributeDefinition).
*
* Semantics of this flag for complex type definitions is to be defined yet.
*/
boolean isIgnored();
boolean isAbstract();
boolean isDeprecated();
String getDeprecatedSince();
/**
* True for definitions that are more important than others and that should be emphasized
* during presentation. E.g. the emphasized definitions will always be displayed in the user
* interfaces (even if they are empty), they will always be included in the dumps, etc.
*/
boolean isEmphasized();
/**
* Returns display name.
*
* Specifies the printable name of the object class or attribute. It must
* contain a printable string. It may also contain a key to catalog file.
*
* Returns null if no display name is set.
*
* Corresponds to "displayName" XSD annotation.
*
* @return display name string or catalog key
*/
String getDisplayName();
/**
* Specifies an order in which the item should be displayed relative to other items
* at the same level. The items will be displayed by sorting them by the
* values of displayOrder annotation (ascending). Items that do not have
* any displayOrder annotation will be displayed last. The ordering of
* values with the same displayOrder is undefined and it may be arbitrary.
*/
Integer getDisplayOrder();
/**
* Returns help string.
*
* Specifies the help text or a key to catalog file for a help text. The
* help text may be displayed in any suitable way by the GUI. It should
* explain the meaning of an attribute or object class.
*
* Returns null if no help string is set.
*
* Corresponds to "help" XSD annotation.
*
* @return help string or catalog key
*/
String getHelp();
String getDocumentation();
/**
* Returns only a first sentence of documentation.
*/
String getDocumentationPreview();
PrismContext getPrismContext();
default SchemaRegistry getSchemaRegistry() {
PrismContext prismContext = getPrismContext();
return prismContext != null ? prismContext.getSchemaRegistry() : null;
}
// TODO fix this!
Class getTypeClassIfKnown();
// todo suspicious, please investigate and document
Class getTypeClass();
@NotNull
Definition clone();
default String debugDump(int indent, IdentityHashMap<Definition,Object> seen) {
return debugDump(indent);
}
}