1 package gov.nist.secauto.oscal.lib.model;
2
3 import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
4 import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
5 import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
6 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
7 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
8 import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
9 import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique;
10 import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
11 import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
12 import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
13 import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
14 import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
15 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
16 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
17 import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
18 import java.lang.Override;
19 import java.lang.String;
20 import java.util.LinkedList;
21 import java.util.List;
22 import java.util.UUID;
23 import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
24 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
25
26
27
28
29 @MetaschemaAssembly(
30 formalName = "Task Reference",
31 description = "Identifies an individual task for which the containing object is a consequence of.",
32 name = "related-task",
33 metaschema = OscalAssessmentCommonMetaschema.class
34 )
35 @AssemblyConstraints(
36 isUnique = @IsUnique(id = "unique-ssp-related-task-responsible-party", level = IConstraint.Level.ERROR, target = "responsible-party", keyFields = @KeyField(target = "@role-id"), remarks = "Since `responsible-party` associates multiple `party-uuid` entries with a single `role-id`, each role-id must be referenced only once.")
37 )
38 public class RelatedTask {
39 @BoundFlag(
40 formalName = "Task Universally Unique Identifier Reference",
41 description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a unique task.",
42 useName = "task-uuid",
43 required = true,
44 typeAdapter = UuidAdapter.class
45 )
46 private UUID _taskUuid;
47
48 @BoundAssembly(
49 formalName = "Property",
50 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
51 useName = "prop",
52 maxOccurs = -1
53 )
54 @GroupAs(
55 name = "props",
56 inJson = JsonGroupAsBehavior.LIST
57 )
58 private List<Property> _props;
59
60 @BoundAssembly(
61 formalName = "Link",
62 description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
63 useName = "link",
64 maxOccurs = -1
65 )
66 @GroupAs(
67 name = "links",
68 inJson = JsonGroupAsBehavior.LIST
69 )
70 private List<Link> _links;
71
72 @BoundAssembly(
73 formalName = "Responsible Party",
74 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.",
75 useName = "responsible-party",
76 maxOccurs = -1,
77 remarks = "Identifies the person or organization responsible for performing a specific role defined by the activity."
78 )
79 @GroupAs(
80 name = "responsible-parties",
81 inJson = JsonGroupAsBehavior.LIST
82 )
83 private List<ResponsibleParty> _responsibleParties;
84
85 @BoundAssembly(
86 formalName = "Subject of Assessment",
87 description = "Identifies system elements being assessed, such as components, inventory items, and locations. In the assessment plan, this identifies a planned assessment subject. In the assessment results this is an actual assessment subject, and reflects any changes from the plan. exactly what will be the focus of this assessment. Any subjects not identified in this way are out-of-scope.",
88 useName = "subject",
89 maxOccurs = -1,
90 remarks = "The assessment subjects that the task was performed against."
91 )
92 @GroupAs(
93 name = "subjects",
94 inJson = JsonGroupAsBehavior.LIST
95 )
96 private List<AssessmentSubject> _subjects;
97
98
99
100
101 @BoundAssembly(
102 formalName = "Identified Subject",
103 description = "Used to detail assessment subjects that were identfied by this task.",
104 useName = "identified-subject"
105 )
106 private IdentifiedSubject _identifiedSubject;
107
108 @BoundField(
109 formalName = "Remarks",
110 description = "Additional commentary about the containing object.",
111 useName = "remarks"
112 )
113 @BoundFieldValue(
114 typeAdapter = MarkupMultilineAdapter.class
115 )
116 private MarkupMultiline _remarks;
117
118 public RelatedTask() {
119 }
120
121 public UUID getTaskUuid() {
122 return _taskUuid;
123 }
124
125 public void setTaskUuid(UUID value) {
126 _taskUuid = value;
127 }
128
129 public List<Property> getProps() {
130 return _props;
131 }
132
133 public void setProps(List<Property> value) {
134 _props = value;
135 }
136
137
138
139
140
141
142 public boolean addProp(Property item) {
143 Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
144 if (_props == null) {
145 _props = new LinkedList<>();
146 }
147 return _props.add(value);
148 }
149
150
151
152
153
154
155 public boolean removeProp(Property item) {
156 Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
157 return _props == null ? false : _props.remove(value);
158 }
159
160 public List<Link> getLinks() {
161 return _links;
162 }
163
164 public void setLinks(List<Link> value) {
165 _links = value;
166 }
167
168
169
170
171
172
173 public boolean addLink(Link item) {
174 Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
175 if (_links == null) {
176 _links = new LinkedList<>();
177 }
178 return _links.add(value);
179 }
180
181
182
183
184
185
186 public boolean removeLink(Link item) {
187 Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
188 return _links == null ? false : _links.remove(value);
189 }
190
191 public List<ResponsibleParty> getResponsibleParties() {
192 return _responsibleParties;
193 }
194
195 public void setResponsibleParties(List<ResponsibleParty> value) {
196 _responsibleParties = value;
197 }
198
199
200
201
202
203
204 public boolean addResponsibleParty(ResponsibleParty item) {
205 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null");
206 if (_responsibleParties == null) {
207 _responsibleParties = new LinkedList<>();
208 }
209 return _responsibleParties.add(value);
210 }
211
212
213
214
215
216
217 public boolean removeResponsibleParty(ResponsibleParty item) {
218 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null");
219 return _responsibleParties == null ? false : _responsibleParties.remove(value);
220 }
221
222 public List<AssessmentSubject> getSubjects() {
223 return _subjects;
224 }
225
226 public void setSubjects(List<AssessmentSubject> value) {
227 _subjects = value;
228 }
229
230
231
232
233
234
235 public boolean addSubject(AssessmentSubject item) {
236 AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
237 if (_subjects == null) {
238 _subjects = new LinkedList<>();
239 }
240 return _subjects.add(value);
241 }
242
243
244
245
246
247
248 public boolean removeSubject(AssessmentSubject item) {
249 AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
250 return _subjects == null ? false : _subjects.remove(value);
251 }
252
253 public IdentifiedSubject getIdentifiedSubject() {
254 return _identifiedSubject;
255 }
256
257 public void setIdentifiedSubject(IdentifiedSubject value) {
258 _identifiedSubject = value;
259 }
260
261 public MarkupMultiline getRemarks() {
262 return _remarks;
263 }
264
265 public void setRemarks(MarkupMultiline value) {
266 _remarks = value;
267 }
268
269 @Override
270 public String toString() {
271 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
272 }
273
274
275
276
277 @MetaschemaAssembly(
278 formalName = "Identified Subject",
279 description = "Used to detail assessment subjects that were identfied by this task.",
280 name = "identified-subject",
281 metaschema = OscalAssessmentCommonMetaschema.class
282 )
283 public static class IdentifiedSubject {
284 @BoundFlag(
285 formalName = "Assessment Subject Placeholder Universally Unique Identifier Reference",
286 description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a unique assessment subject placeholder defined by this task.",
287 useName = "subject-placeholder-uuid",
288 required = true,
289 typeAdapter = UuidAdapter.class
290 )
291 private UUID _subjectPlaceholderUuid;
292
293 @BoundAssembly(
294 formalName = "Subject of Assessment",
295 description = "Identifies system elements being assessed, such as components, inventory items, and locations. In the assessment plan, this identifies a planned assessment subject. In the assessment results this is an actual assessment subject, and reflects any changes from the plan. exactly what will be the focus of this assessment. Any subjects not identified in this way are out-of-scope.",
296 useName = "subject",
297 minOccurs = 1,
298 maxOccurs = -1,
299 remarks = "The assessment subjects that the task identified, which will be used by another task through a subject-placeholder reference. Such a task will \"consume\" these subjects."
300 )
301 @GroupAs(
302 name = "subjects",
303 inJson = JsonGroupAsBehavior.LIST
304 )
305 private List<AssessmentSubject> _subjects;
306
307 public IdentifiedSubject() {
308 }
309
310 public UUID getSubjectPlaceholderUuid() {
311 return _subjectPlaceholderUuid;
312 }
313
314 public void setSubjectPlaceholderUuid(UUID value) {
315 _subjectPlaceholderUuid = value;
316 }
317
318 public List<AssessmentSubject> getSubjects() {
319 return _subjects;
320 }
321
322 public void setSubjects(List<AssessmentSubject> value) {
323 _subjects = value;
324 }
325
326
327
328
329
330
331 public boolean addSubject(AssessmentSubject item) {
332 AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
333 if (_subjects == null) {
334 _subjects = new LinkedList<>();
335 }
336 return _subjects.add(value);
337 }
338
339
340
341
342
343
344 public boolean removeSubject(AssessmentSubject item) {
345 AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
346 return _subjects == null ? false : _subjects.remove(value);
347 }
348
349 @Override
350 public String toString() {
351 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
352 }
353 }
354 }