001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
004import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter;
006import gov.nist.secauto.metaschema.core.model.IBoundObject;
007import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
008import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
009import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
010import gov.nist.secauto.metaschema.core.util.ObjectUtils;
011import gov.nist.secauto.metaschema.databind.model.annotations.AssemblyConstraints;
012import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
013import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
014import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
015import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
016import gov.nist.secauto.metaschema.databind.model.annotations.IsUnique;
017import gov.nist.secauto.metaschema.databind.model.annotations.KeyField;
018import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
019import java.lang.Override;
020import java.lang.String;
021import java.util.LinkedList;
022import java.util.List;
023import java.util.UUID;
024import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
025import org.apache.commons.lang3.builder.ToStringStyle;
026
027/**
028 * Identifies an individual task for which the containing object is a consequence of.
029 */
030@MetaschemaAssembly(
031    formalName = "Task Reference",
032    description = "Identifies an individual task for which the containing object is a consequence of.",
033    name = "related-task",
034    moduleClass = OscalAssessmentCommonModule.class,
035    modelConstraints = @AssemblyConstraints(unique = @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."))
036)
037public class RelatedTask implements IBoundObject {
038  private final IMetaschemaData __metaschemaData;
039
040  /**
041   * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented\">machine-oriented</a> identifier reference to a unique task."
042   */
043  @BoundFlag(
044      formalName = "Task Universally Unique Identifier Reference",
045      description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a unique task.",
046      name = "task-uuid",
047      required = true,
048      typeAdapter = UuidAdapter.class
049  )
050  private UUID _taskUuid;
051
052  @BoundAssembly(
053      formalName = "Property",
054      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
055      useName = "prop",
056      maxOccurs = -1,
057      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
058  )
059  private List<Property> _props;
060
061  @BoundAssembly(
062      formalName = "Link",
063      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
064      useName = "link",
065      maxOccurs = -1,
066      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
067  )
068  private List<Link> _links;
069
070  @BoundAssembly(
071      formalName = "Responsible Party",
072      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.",
073      useName = "responsible-party",
074      remarks = "Identifies the person or organization responsible for performing a specific role defined by the activity.",
075      maxOccurs = -1,
076      groupAs = @GroupAs(name = "responsible-parties", inJson = JsonGroupAsBehavior.LIST)
077  )
078  private List<ResponsibleParty> _responsibleParties;
079
080  @BoundAssembly(
081      formalName = "Subject of Assessment",
082      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.",
083      useName = "subject",
084      remarks = "The assessment subjects that the task was performed against.",
085      maxOccurs = -1,
086      groupAs = @GroupAs(name = "subjects", inJson = JsonGroupAsBehavior.LIST)
087  )
088  private List<AssessmentSubject> _subjects;
089
090  @BoundAssembly(
091      formalName = "Identified Subject",
092      description = "Used to detail assessment subjects that were identfied by this task.",
093      useName = "identified-subject"
094  )
095  private IdentifiedSubject _identifiedSubject;
096
097  @BoundField(
098      formalName = "Remarks",
099      description = "Additional commentary about the containing object.",
100      useName = "remarks",
101      typeAdapter = MarkupMultilineAdapter.class
102  )
103  private MarkupMultiline _remarks;
104
105  public RelatedTask() {
106    this(null);
107  }
108
109  public RelatedTask(IMetaschemaData data) {
110    this.__metaschemaData = data;
111  }
112
113  @Override
114  public IMetaschemaData getMetaschemaData() {
115    return __metaschemaData;
116  }
117
118  public UUID getTaskUuid() {
119    return _taskUuid;
120  }
121
122  public void setTaskUuid(UUID value) {
123    _taskUuid = value;
124  }
125
126  public List<Property> getProps() {
127    return _props;
128  }
129
130  public void setProps(List<Property> value) {
131    _props = value;
132  }
133
134  /**
135   * Add a new {@link Property} item to the underlying collection.
136   * @param item the item to add
137   * @return {@code true}
138   */
139  public boolean addProp(Property item) {
140    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
141    if (_props == null) {
142      _props = new LinkedList<>();
143    }
144    return _props.add(value);
145  }
146
147  /**
148   * Remove the first matching {@link Property} item from the underlying collection.
149   * @param item the item to remove
150   * @return {@code true} if the item was removed or {@code false} otherwise
151   */
152  public boolean removeProp(Property item) {
153    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
154    return _props != null && _props.remove(value);
155  }
156
157  public List<Link> getLinks() {
158    return _links;
159  }
160
161  public void setLinks(List<Link> value) {
162    _links = value;
163  }
164
165  /**
166   * Add a new {@link Link} item to the underlying collection.
167   * @param item the item to add
168   * @return {@code true}
169   */
170  public boolean addLink(Link item) {
171    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
172    if (_links == null) {
173      _links = new LinkedList<>();
174    }
175    return _links.add(value);
176  }
177
178  /**
179   * Remove the first matching {@link Link} item from the underlying collection.
180   * @param item the item to remove
181   * @return {@code true} if the item was removed or {@code false} otherwise
182   */
183  public boolean removeLink(Link item) {
184    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
185    return _links != null && _links.remove(value);
186  }
187
188  public List<ResponsibleParty> getResponsibleParties() {
189    return _responsibleParties;
190  }
191
192  public void setResponsibleParties(List<ResponsibleParty> value) {
193    _responsibleParties = value;
194  }
195
196  /**
197   * Add a new {@link ResponsibleParty} item to the underlying collection.
198   * @param item the item to add
199   * @return {@code true}
200   */
201  public boolean addResponsibleParty(ResponsibleParty item) {
202    ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null");
203    if (_responsibleParties == null) {
204      _responsibleParties = new LinkedList<>();
205    }
206    return _responsibleParties.add(value);
207  }
208
209  /**
210   * Remove the first matching {@link ResponsibleParty} item from the underlying collection.
211   * @param item the item to remove
212   * @return {@code true} if the item was removed or {@code false} otherwise
213   */
214  public boolean removeResponsibleParty(ResponsibleParty item) {
215    ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null");
216    return _responsibleParties != null && _responsibleParties.remove(value);
217  }
218
219  public List<AssessmentSubject> getSubjects() {
220    return _subjects;
221  }
222
223  public void setSubjects(List<AssessmentSubject> value) {
224    _subjects = value;
225  }
226
227  /**
228   * Add a new {@link AssessmentSubject} item to the underlying collection.
229   * @param item the item to add
230   * @return {@code true}
231   */
232  public boolean addSubject(AssessmentSubject item) {
233    AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
234    if (_subjects == null) {
235      _subjects = new LinkedList<>();
236    }
237    return _subjects.add(value);
238  }
239
240  /**
241   * Remove the first matching {@link AssessmentSubject} item from the underlying collection.
242   * @param item the item to remove
243   * @return {@code true} if the item was removed or {@code false} otherwise
244   */
245  public boolean removeSubject(AssessmentSubject item) {
246    AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
247    return _subjects != null && _subjects.remove(value);
248  }
249
250  public IdentifiedSubject getIdentifiedSubject() {
251    return _identifiedSubject;
252  }
253
254  public void setIdentifiedSubject(IdentifiedSubject value) {
255    _identifiedSubject = value;
256  }
257
258  public MarkupMultiline getRemarks() {
259    return _remarks;
260  }
261
262  public void setRemarks(MarkupMultiline value) {
263    _remarks = value;
264  }
265
266  @Override
267  public String toString() {
268    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
269  }
270
271  /**
272   * Used to detail assessment subjects that were identfied by this task.
273   */
274  @MetaschemaAssembly(
275      formalName = "Identified Subject",
276      description = "Used to detail assessment subjects that were identfied by this task.",
277      name = "identified-subject",
278      moduleClass = OscalAssessmentCommonModule.class
279  )
280  public static class IdentifiedSubject implements IBoundObject {
281    private final IMetaschemaData __metaschemaData;
282
283    /**
284     * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented\">machine-oriented</a> identifier reference to a unique assessment subject placeholder defined by this task."
285     */
286    @BoundFlag(
287        formalName = "Assessment Subject Placeholder Universally Unique Identifier Reference",
288        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.",
289        name = "subject-placeholder-uuid",
290        required = true,
291        typeAdapter = UuidAdapter.class
292    )
293    private UUID _subjectPlaceholderUuid;
294
295    @BoundAssembly(
296        formalName = "Subject of Assessment",
297        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.",
298        useName = "subject",
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        minOccurs = 1,
301        maxOccurs = -1,
302        groupAs = @GroupAs(name = "subjects", inJson = JsonGroupAsBehavior.LIST)
303    )
304    private List<AssessmentSubject> _subjects;
305
306    public IdentifiedSubject() {
307      this(null);
308    }
309
310    public IdentifiedSubject(IMetaschemaData data) {
311      this.__metaschemaData = data;
312    }
313
314    @Override
315    public IMetaschemaData getMetaschemaData() {
316      return __metaschemaData;
317    }
318
319    public UUID getSubjectPlaceholderUuid() {
320      return _subjectPlaceholderUuid;
321    }
322
323    public void setSubjectPlaceholderUuid(UUID value) {
324      _subjectPlaceholderUuid = value;
325    }
326
327    public List<AssessmentSubject> getSubjects() {
328      return _subjects;
329    }
330
331    public void setSubjects(List<AssessmentSubject> value) {
332      _subjects = value;
333    }
334
335    /**
336     * Add a new {@link AssessmentSubject} item to the underlying collection.
337     * @param item the item to add
338     * @return {@code true}
339     */
340    public boolean addSubject(AssessmentSubject item) {
341      AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
342      if (_subjects == null) {
343        _subjects = new LinkedList<>();
344      }
345      return _subjects.add(value);
346    }
347
348    /**
349     * Remove the first matching {@link AssessmentSubject} item from the underlying collection.
350     * @param item the item to remove
351     * @return {@code true} if the item was removed or {@code false} otherwise
352     */
353    public boolean removeSubject(AssessmentSubject item) {
354      AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null");
355      return _subjects != null && _subjects.remove(value);
356    }
357
358    @Override
359    public String toString() {
360      return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
361    }
362  }
363}