AssessmentResults.java

package gov.nist.secauto.oscal.lib.model;

import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import java.lang.Override;
import java.lang.String;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * Security assessment results, such as those provided by a FedRAMP assessor in the FedRAMP Security Assessment Report.
 */
@MetaschemaAssembly(
    formalName = "Security Assessment Results (SAR)",
    description = "Security assessment results, such as those provided by a FedRAMP assessor in the FedRAMP Security Assessment Report.",
    name = "assessment-results",
    metaschema = OscalArMetaschema.class,
    rootName = "assessment-results"
)
public class AssessmentResults {
  @BoundFlag(
      formalName = "Assessment Results Universally Unique Identifier",
      description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented), [globally unique](https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique) identifier with [cross-instance](https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance) scope that can be used to reference this assessment results instance in [this or other OSCAL instances](https://pages.nist.gov/OSCAL/concepts/identifier-use/#ar-identifiers). The locally defined *UUID* of the `assessment result` can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned [per-subject](https://pages.nist.gov/OSCAL/concepts/identifier-use/#consistency), which means it should be consistently used to identify the same subject across revisions of the document.",
      useName = "uuid",
      required = true,
      typeAdapter = UuidAdapter.class
  )
  private UUID _uuid;

  @BoundAssembly(
      formalName = "Document Metadata",
      description = "Provides information about the containing document, and defines concepts that are shared across the document.",
      useName = "metadata",
      minOccurs = 1
  )
  private Metadata _metadata;

  @BoundAssembly(
      formalName = "Import Assessment Plan",
      description = "Used by assessment-results to import information about the original plan for assessing the system.",
      useName = "import-ap",
      minOccurs = 1,
      remarks = "Used by the SAR to import information about the original plan for assessing the system."
  )
  private ImportAp _importAp;

  /**
   * "Used to define data objects that are used in the assessment plan, that do not appear in the referenced SSP."
   */
  @BoundAssembly(
      formalName = "Local Definitions",
      description = "Used to define data objects that are used in the assessment plan, that do not appear in the referenced SSP.",
      useName = "local-definitions"
  )
  private LocalDefinitions _localDefinitions;

  @BoundAssembly(
      formalName = "Assessment Result",
      description = "Used by the assessment results and POA\\&M. In the assessment results, this identifies all of the assessment observations and findings, initial and residual risks, deviations, and disposition. In the POA\\&M, this identifies initial and residual risks, deviations, and disposition.",
      useName = "result",
      minOccurs = 1,
      maxOccurs = -1
  )
  @GroupAs(
      name = "results",
      inJson = JsonGroupAsBehavior.LIST
  )
  private List<Result> _results;

  @BoundAssembly(
      formalName = "Back matter",
      description = "A collection of resources that may be referenced from within the OSCAL document instance.",
      useName = "back-matter"
  )
  private BackMatter _backMatter;

  public AssessmentResults() {
  }

  public UUID getUuid() {
    return _uuid;
  }

  public void setUuid(UUID value) {
    _uuid = value;
  }

  public Metadata getMetadata() {
    return _metadata;
  }

  public void setMetadata(Metadata value) {
    _metadata = value;
  }

  public ImportAp getImportAp() {
    return _importAp;
  }

  public void setImportAp(ImportAp value) {
    _importAp = value;
  }

  public LocalDefinitions getLocalDefinitions() {
    return _localDefinitions;
  }

  public void setLocalDefinitions(LocalDefinitions value) {
    _localDefinitions = value;
  }

  public List<Result> getResults() {
    return _results;
  }

  public void setResults(List<Result> value) {
    _results = value;
  }

  /**
   * Add a new {@link Result} item to the underlying collection.
   * @param item the item to add
   * @return {@code true}
   */
  public boolean addResult(Result item) {
    Result value = ObjectUtils.requireNonNull(item,"item cannot be null");
    if (_results == null) {
      _results = new LinkedList<>();
    }
    return _results.add(value);
  }

  /**
   * Remove the first matching {@link Result} item from the underlying collection.
   * @param item the item to remove
   * @return {@code true} if the item was removed or {@code false} otherwise
   */
  public boolean removeResult(Result item) {
    Result value = ObjectUtils.requireNonNull(item,"item cannot be null");
    return _results == null ? false : _results.remove(value);
  }

  public BackMatter getBackMatter() {
    return _backMatter;
  }

  public void setBackMatter(BackMatter value) {
    _backMatter = value;
  }

  @Override
  public String toString() {
    return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
  }

  /**
   * Used to define data objects that are used in the assessment plan, that do not appear in the referenced SSP.
   */
  @MetaschemaAssembly(
      formalName = "Local Definitions",
      description = "Used to define data objects that are used in the assessment plan, that do not appear in the referenced SSP.",
      name = "local-definitions",
      metaschema = OscalArMetaschema.class
  )
  public static class LocalDefinitions {
    @BoundAssembly(
        formalName = "Assessment-Specific Control Objective",
        description = "A local definition of a control objective for this assessment. Uses catalog syntax for control objective and assessment actions.",
        useName = "objectives-and-methods",
        maxOccurs = -1
    )
    @GroupAs(
        name = "objectives-and-methods",
        inJson = JsonGroupAsBehavior.LIST
    )
    private List<LocalObjective> _objectivesAndMethods;

    @BoundAssembly(
        formalName = "Activity",
        description = "Identifies an assessment or related process that can be performed. In the assessment plan, this is an intended activity which may be associated with an assessment task. In the assessment results, this an activity that was actually performed as part of an assessment.",
        useName = "activity",
        maxOccurs = -1
    )
    @GroupAs(
        name = "activities",
        inJson = JsonGroupAsBehavior.LIST
    )
    private List<Activity> _activities;

    @BoundField(
        formalName = "Remarks",
        description = "Additional commentary about the containing object.",
        useName = "remarks"
    )
    @BoundFieldValue(
        typeAdapter = MarkupMultilineAdapter.class
    )
    private MarkupMultiline _remarks;

    public LocalDefinitions() {
    }

    public List<LocalObjective> getObjectivesAndMethods() {
      return _objectivesAndMethods;
    }

    public void setObjectivesAndMethods(List<LocalObjective> value) {
      _objectivesAndMethods = value;
    }

    /**
     * Add a new {@link LocalObjective} item to the underlying collection.
     * @param item the item to add
     * @return {@code true}
     */
    public boolean addObjectivesAndMethods(LocalObjective item) {
      LocalObjective value = ObjectUtils.requireNonNull(item,"item cannot be null");
      if (_objectivesAndMethods == null) {
        _objectivesAndMethods = new LinkedList<>();
      }
      return _objectivesAndMethods.add(value);
    }

    /**
     * Remove the first matching {@link LocalObjective} item from the underlying collection.
     * @param item the item to remove
     * @return {@code true} if the item was removed or {@code false} otherwise
     */
    public boolean removeObjectivesAndMethods(LocalObjective item) {
      LocalObjective value = ObjectUtils.requireNonNull(item,"item cannot be null");
      return _objectivesAndMethods == null ? false : _objectivesAndMethods.remove(value);
    }

    public List<Activity> getActivities() {
      return _activities;
    }

    public void setActivities(List<Activity> value) {
      _activities = value;
    }

    /**
     * Add a new {@link Activity} item to the underlying collection.
     * @param item the item to add
     * @return {@code true}
     */
    public boolean addActivity(Activity item) {
      Activity value = ObjectUtils.requireNonNull(item,"item cannot be null");
      if (_activities == null) {
        _activities = new LinkedList<>();
      }
      return _activities.add(value);
    }

    /**
     * Remove the first matching {@link Activity} item from the underlying collection.
     * @param item the item to remove
     * @return {@code true} if the item was removed or {@code false} otherwise
     */
    public boolean removeActivity(Activity item) {
      Activity value = ObjectUtils.requireNonNull(item,"item cannot be null");
      return _activities == null ? false : _activities.remove(value);
    }

    public MarkupMultiline getRemarks() {
      return _remarks;
    }

    public void setRemarks(MarkupMultiline value) {
      _remarks = value;
    }

    @Override
    public String toString() {
      return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
    }
  }
}