001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter;
004import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;
006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter;
007import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
008import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter;
009import gov.nist.secauto.metaschema.core.model.IBoundObject;
010import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
011import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
012import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
013import gov.nist.secauto.metaschema.core.util.ObjectUtils;
014import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
015import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
016import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
017import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
018import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
019import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
020import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
021import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
022import java.lang.Override;
023import java.lang.String;
024import java.util.LinkedList;
025import java.util.List;
026import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
027import org.apache.commons.lang3.builder.ToStringStyle;
028
029/**
030 * Captures an assessor's conclusions regarding the degree to which an objective is satisfied.
031 */
032@MetaschemaAssembly(
033    formalName = "Objective Status",
034    description = "Captures an assessor's conclusions regarding the degree to which an objective is satisfied.",
035    name = "finding-target",
036    moduleClass = OscalAssessmentCommonModule.class
037)
038public class FindingTarget implements IBoundObject {
039  private final IMetaschemaData __metaschemaData;
040
041  /**
042   * "Identifies the type of the target."
043   */
044  @BoundFlag(
045      formalName = "Finding Target Type",
046      description = "Identifies the type of the target.",
047      name = "type",
048      required = true,
049      typeAdapter = StringAdapter.class,
050      remarks = "The target will always be a reference to: 1) a control statement, or 2) a control objective. In the former case, there is always a single top-level statement within a control. Thus, if the entire control is targeted, this statement identifier can be used.",
051      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "statement-id", description = "A reference to a control statement identifier within a control."), @AllowedValue(value = "objective-id", description = "A reference to a control objective identifier within a control.")}))
052  )
053  private String _type;
054
055  /**
056   * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented\">machine-oriented</a> identifier reference for a specific target qualified by the <code>type</code>."
057   */
058  @BoundFlag(
059      formalName = "Finding Target Identifier Reference",
060      description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference for a specific target qualified by the `type`.",
061      name = "target-id",
062      required = true,
063      typeAdapter = TokenAdapter.class
064  )
065  private String _targetId;
066
067  @BoundField(
068      formalName = "Objective Status Title",
069      description = "The title for this objective status.",
070      useName = "title",
071      typeAdapter = MarkupLineAdapter.class
072  )
073  private MarkupLine _title;
074
075  @BoundField(
076      formalName = "Objective Status Description",
077      description = "A human-readable description of the assessor's conclusions regarding the degree to which an objective is satisfied.",
078      useName = "description",
079      typeAdapter = MarkupMultilineAdapter.class
080  )
081  private MarkupMultiline _description;
082
083  @BoundAssembly(
084      formalName = "Property",
085      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
086      useName = "prop",
087      maxOccurs = -1,
088      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
089  )
090  private List<Property> _props;
091
092  @BoundAssembly(
093      formalName = "Link",
094      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
095      useName = "link",
096      maxOccurs = -1,
097      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
098  )
099  private List<Link> _links;
100
101  @BoundAssembly(
102      formalName = "Objective Status",
103      description = "A determination of if the objective is satisfied or not within a given system.",
104      useName = "status",
105      minOccurs = 1
106  )
107  private Status _status;
108
109  @BoundAssembly(
110      formalName = "Implementation Status",
111      description = "Indicates the degree to which the a given control is implemented.",
112      useName = "implementation-status",
113      remarks = "The `implementation-status` is used to qualify the `status` value to indicate the degree to which the control was found to be implemented."
114  )
115  private ImplementationStatus _implementationStatus;
116
117  @BoundField(
118      formalName = "Remarks",
119      description = "Additional commentary about the containing object.",
120      useName = "remarks",
121      typeAdapter = MarkupMultilineAdapter.class
122  )
123  private MarkupMultiline _remarks;
124
125  public FindingTarget() {
126    this(null);
127  }
128
129  public FindingTarget(IMetaschemaData data) {
130    this.__metaschemaData = data;
131  }
132
133  @Override
134  public IMetaschemaData getMetaschemaData() {
135    return __metaschemaData;
136  }
137
138  public String getType() {
139    return _type;
140  }
141
142  public void setType(String value) {
143    _type = value;
144  }
145
146  public String getTargetId() {
147    return _targetId;
148  }
149
150  public void setTargetId(String value) {
151    _targetId = value;
152  }
153
154  public MarkupLine getTitle() {
155    return _title;
156  }
157
158  public void setTitle(MarkupLine value) {
159    _title = value;
160  }
161
162  public MarkupMultiline getDescription() {
163    return _description;
164  }
165
166  public void setDescription(MarkupMultiline value) {
167    _description = value;
168  }
169
170  public List<Property> getProps() {
171    return _props;
172  }
173
174  public void setProps(List<Property> value) {
175    _props = value;
176  }
177
178  /**
179   * Add a new {@link Property} item to the underlying collection.
180   * @param item the item to add
181   * @return {@code true}
182   */
183  public boolean addProp(Property item) {
184    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
185    if (_props == null) {
186      _props = new LinkedList<>();
187    }
188    return _props.add(value);
189  }
190
191  /**
192   * Remove the first matching {@link Property} item from the underlying collection.
193   * @param item the item to remove
194   * @return {@code true} if the item was removed or {@code false} otherwise
195   */
196  public boolean removeProp(Property item) {
197    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
198    return _props != null && _props.remove(value);
199  }
200
201  public List<Link> getLinks() {
202    return _links;
203  }
204
205  public void setLinks(List<Link> value) {
206    _links = value;
207  }
208
209  /**
210   * Add a new {@link Link} item to the underlying collection.
211   * @param item the item to add
212   * @return {@code true}
213   */
214  public boolean addLink(Link item) {
215    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
216    if (_links == null) {
217      _links = new LinkedList<>();
218    }
219    return _links.add(value);
220  }
221
222  /**
223   * Remove the first matching {@link Link} item from the underlying collection.
224   * @param item the item to remove
225   * @return {@code true} if the item was removed or {@code false} otherwise
226   */
227  public boolean removeLink(Link item) {
228    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
229    return _links != null && _links.remove(value);
230  }
231
232  public Status getStatus() {
233    return _status;
234  }
235
236  public void setStatus(Status value) {
237    _status = value;
238  }
239
240  public ImplementationStatus getImplementationStatus() {
241    return _implementationStatus;
242  }
243
244  public void setImplementationStatus(ImplementationStatus value) {
245    _implementationStatus = value;
246  }
247
248  public MarkupMultiline getRemarks() {
249    return _remarks;
250  }
251
252  public void setRemarks(MarkupMultiline value) {
253    _remarks = value;
254  }
255
256  @Override
257  public String toString() {
258    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
259  }
260
261  /**
262   * A determination of if the objective is satisfied or not within a given system.
263   */
264  @MetaschemaAssembly(
265      formalName = "Objective Status",
266      description = "A determination of if the objective is satisfied or not within a given system.",
267      name = "status",
268      moduleClass = OscalAssessmentCommonModule.class
269  )
270  public static class Status implements IBoundObject {
271    private final IMetaschemaData __metaschemaData;
272
273    /**
274     * "An indication as to whether the objective is satisfied or not."
275     */
276    @BoundFlag(
277        formalName = "Objective Status State",
278        description = "An indication as to whether the objective is satisfied or not.",
279        name = "state",
280        required = true,
281        typeAdapter = TokenAdapter.class,
282        valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "satisfied", description = "The objective has been completely satisfied."), @AllowedValue(value = "not-satisfied", description = "The objective has not been completely satisfied, but may be partially satisfied.")}))
283    )
284    private String _state;
285
286    /**
287     * "The reason the objective was given it's status."
288     */
289    @BoundFlag(
290        formalName = "Objective Status Reason",
291        description = "The reason the objective was given it's status.",
292        name = "reason",
293        typeAdapter = TokenAdapter.class,
294        remarks = "Reason may contain any value, and should be used to communicate additional information regarding the status.",
295        valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "pass", description = "The target system or system component satisfied all the conditions."), @AllowedValue(value = "fail", description = "The target system or system component did not satisfy all the conditions."), @AllowedValue(value = "other", description = "Some other event took place that is not a pass or a fail.")}))
296    )
297    private String _reason;
298
299    @BoundField(
300        formalName = "Remarks",
301        description = "Additional commentary about the containing object.",
302        useName = "remarks",
303        typeAdapter = MarkupMultilineAdapter.class
304    )
305    private MarkupMultiline _remarks;
306
307    public Status() {
308      this(null);
309    }
310
311    public Status(IMetaschemaData data) {
312      this.__metaschemaData = data;
313    }
314
315    @Override
316    public IMetaschemaData getMetaschemaData() {
317      return __metaschemaData;
318    }
319
320    public String getState() {
321      return _state;
322    }
323
324    public void setState(String value) {
325      _state = value;
326    }
327
328    public String getReason() {
329      return _reason;
330    }
331
332    public void setReason(String value) {
333      _reason = value;
334    }
335
336    public MarkupMultiline getRemarks() {
337      return _remarks;
338    }
339
340    public void setRemarks(MarkupMultiline value) {
341      _remarks = value;
342    }
343
344    @Override
345    public String toString() {
346      return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
347    }
348  }
349}