1 package gov.nist.secauto.oscal.lib.model;
2
3 import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
4 import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
5 import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
6 import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
7 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
8 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
9 import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
10 import gov.nist.secauto.metaschema.binding.model.annotations.IndexHasKey;
11 import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
12 import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
13 import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
14 import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
15 import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
16 import gov.nist.secauto.metaschema.model.common.datatype.adapter.DateTimeWithTZAdapter;
17 import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
18 import gov.nist.secauto.metaschema.model.common.datatype.adapter.UriAdapter;
19 import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
20 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
21 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
22 import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
23 import java.lang.Override;
24 import java.lang.String;
25 import java.net.URI;
26 import java.time.ZonedDateTime;
27 import java.util.LinkedList;
28 import java.util.List;
29 import java.util.UUID;
30 import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
31 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
32
33
34
35
36 @MetaschemaAssembly(
37 formalName = "Action",
38 description = "An action applied by a role within a given party to the content.",
39 name = "action",
40 metaschema = OscalMetadataMetaschema.class
41 )
42 @ValueConstraints(
43 allowedValues = {
44 @AllowedValues(level = IConstraint.Level.ERROR, target = "./system/@value", allowOthers = true, values = @AllowedValue(value = "http://csrc.nist.gov/ns/oscal", description = "This value identifies action types defined in the NIST OSCAL namespace.")),
45 @AllowedValues(level = IConstraint.Level.ERROR, target = "./type[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@value", values = {@AllowedValue(value = "approval", description = "An approval of a document instance's content."), @AllowedValue(value = "request-changes", description = "A request from the responisble party or parties to change the content.")})
46 },
47 indexHasKey = {
48 @IndexHasKey(level = IConstraint.Level.ERROR, target = "responsible-party", indexName = "index-metadata-role-id", keyFields = @KeyField(target = "@role-id")),
49 @IndexHasKey(level = IConstraint.Level.ERROR, target = "responsible-party", indexName = "index-metadata-party-uuid", keyFields = @KeyField(target = "party-uuid"))
50 }
51 )
52 public class Action {
53 @BoundFlag(
54 formalName = "Action Universally Unique Identifier",
55 description = "A unique identifier that can be used to reference this defined action elsewhere in an OSCAL document. A UUID should be consistently used for a given location across revisions of the document.",
56 useName = "uuid",
57 required = true,
58 typeAdapter = UuidAdapter.class
59 )
60 private UUID _uuid;
61
62 @BoundFlag(
63 formalName = "Action Occurrence Date",
64 description = "The date and time when the action occurred.",
65 useName = "date",
66 typeAdapter = DateTimeWithTZAdapter.class
67 )
68 private ZonedDateTime _date;
69
70 @BoundFlag(
71 formalName = "Action Type",
72 description = "The type of action documented by the assembly, such as an approval.",
73 useName = "type",
74 required = true,
75 typeAdapter = TokenAdapter.class
76 )
77 private String _type;
78
79 @BoundFlag(
80 formalName = "Action Type System",
81 description = "Specifies the action type system used.",
82 useName = "system",
83 required = true,
84 typeAdapter = UriAdapter.class,
85 remarks = "Provides a means to segment the value space for the `type`, so that different organizations and individuals can assert control over the allowed `action`'s `type`. This allows the semantics associated with a given `type` to be defined on an organization-by-organization basis.\n"
86 + "\n"
87 + "An organization MUST use a URI that they have control over. e.g., a domain registered to the organization in a URI, a registered uniform resource names (URN) namespace."
88 )
89 private URI _system;
90
91 @BoundAssembly(
92 formalName = "Property",
93 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
94 useName = "prop",
95 maxOccurs = -1
96 )
97 @GroupAs(
98 name = "props",
99 inJson = JsonGroupAsBehavior.LIST
100 )
101 private List<Property> _props;
102
103 @BoundAssembly(
104 formalName = "Link",
105 description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
106 useName = "link",
107 maxOccurs = -1
108 )
109 @GroupAs(
110 name = "links",
111 inJson = JsonGroupAsBehavior.LIST
112 )
113 private List<Link> _links;
114
115 @BoundAssembly(
116 formalName = "Responsible Party",
117 description = "A reference to a set of persons and/or organizations that have responsibility for performing the referenced role in the context of the containing object.",
118 useName = "responsible-party",
119 maxOccurs = -1
120 )
121 @GroupAs(
122 name = "responsible-parties",
123 inJson = JsonGroupAsBehavior.LIST
124 )
125 private List<ResponsibleParty> _responsibleParties;
126
127 @BoundField(
128 formalName = "Remarks",
129 description = "Additional commentary about the containing object.",
130 useName = "remarks"
131 )
132 @BoundFieldValue(
133 typeAdapter = MarkupMultilineAdapter.class
134 )
135 private MarkupMultiline _remarks;
136
137 public Action() {
138 }
139
140 public UUID getUuid() {
141 return _uuid;
142 }
143
144 public void setUuid(UUID value) {
145 _uuid = value;
146 }
147
148 public ZonedDateTime getDate() {
149 return _date;
150 }
151
152 public void setDate(ZonedDateTime value) {
153 _date = value;
154 }
155
156 public String getType() {
157 return _type;
158 }
159
160 public void setType(String value) {
161 _type = value;
162 }
163
164 public URI getSystem() {
165 return _system;
166 }
167
168 public void setSystem(URI value) {
169 _system = value;
170 }
171
172 public List<Property> getProps() {
173 return _props;
174 }
175
176 public void setProps(List<Property> value) {
177 _props = value;
178 }
179
180
181
182
183
184
185 public boolean addProp(Property item) {
186 Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
187 if (_props == null) {
188 _props = new LinkedList<>();
189 }
190 return _props.add(value);
191 }
192
193
194
195
196
197
198 public boolean removeProp(Property item) {
199 Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
200 return _props == null ? false : _props.remove(value);
201 }
202
203 public List<Link> getLinks() {
204 return _links;
205 }
206
207 public void setLinks(List<Link> value) {
208 _links = value;
209 }
210
211
212
213
214
215
216 public boolean addLink(Link item) {
217 Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
218 if (_links == null) {
219 _links = new LinkedList<>();
220 }
221 return _links.add(value);
222 }
223
224
225
226
227
228
229 public boolean removeLink(Link item) {
230 Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
231 return _links == null ? false : _links.remove(value);
232 }
233
234 public List<ResponsibleParty> getResponsibleParties() {
235 return _responsibleParties;
236 }
237
238 public void setResponsibleParties(List<ResponsibleParty> value) {
239 _responsibleParties = value;
240 }
241
242
243
244
245
246
247 public boolean addResponsibleParty(ResponsibleParty item) {
248 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null");
249 if (_responsibleParties == null) {
250 _responsibleParties = new LinkedList<>();
251 }
252 return _responsibleParties.add(value);
253 }
254
255
256
257
258
259
260 public boolean removeResponsibleParty(ResponsibleParty item) {
261 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null");
262 return _responsibleParties == null ? false : _responsibleParties.remove(value);
263 }
264
265 public MarkupMultiline getRemarks() {
266 return _remarks;
267 }
268
269 public void setRemarks(MarkupMultiline value) {
270 _remarks = value;
271 }
272
273 @Override
274 public String toString() {
275 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
276 }
277 }