001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
004import gov.nist.secauto.metaschema.core.model.IBoundObject;
005import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
006import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
007import gov.nist.secauto.metaschema.core.util.ObjectUtils;
008import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
009import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
010import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
011import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
012import java.lang.Override;
013import java.lang.String;
014import java.util.LinkedList;
015import java.util.List;
016import java.util.UUID;
017import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
018import org.apache.commons.lang3.builder.ToStringStyle;
019
020/**
021 * A <em>by-id</em> collection of all controls that were not mapped at all in this <code> mapping-collection</code>. If a control is partially mapped, the parts of the control are not mappable, the gap and discrepancies should be documented in the <code> relationship-gal</code>.
022 */
023@MetaschemaAssembly(
024    formalName = "Gap Summary",
025    description = "A *by-id* collection of all controls that were not mapped at all in this ` mapping-collection`. If a control is partially mapped, the parts of the control are not mappable, the gap and discrepancies should be documented in the ` relationship-gal`.",
026    name = "gap-summary",
027    moduleClass = OscalMappingCommonModule.class
028)
029public class GapSummary implements IBoundObject {
030  private final IMetaschemaData __metaschemaData;
031
032  /**
033   * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented\">machine-oriented</a>, <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique\">globally unique</a> identifier with <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance\">cross-instance</a> scope that can be used to reference this mapping gap summary elsewhere in <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#ssp-identifiers\">this or other OSCAL instances</a>. The locally defined <em>UUID</em> of the <code>SSP</code> can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance).This UUID should be assigned <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#consistency\">per-subject</a>, which means it should be consistently used to identify the same subject across revisions of the document."
034   */
035  @BoundFlag(
036      formalName = "Gap Summary Universally Unique Identifier",
037      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 mapping gap summary elsewhere in [this or other OSCAL instances](https://pages.nist.gov/OSCAL/concepts/identifier-use/#ssp-identifiers). The locally defined *UUID* of the `SSP` 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.",
038      name = "uuid",
039      required = true,
040      typeAdapter = UuidAdapter.class
041  )
042  private UUID _uuid;
043
044  @BoundAssembly(
045      formalName = "Select Control",
046      description = "Select a control or controls from an imported control set.",
047      useName = "unmapped-controls",
048      remarks = "If `with-child-controls` is \"yes\" on the call to a control, any controls appearing within it (child controls) will be selected, with no additional `call` directives required. This flag provides a way to include controls with all their dependent controls (enhancements) without having to call them individually.",
049      minOccurs = 1,
050      maxOccurs = -1,
051      groupAs = @GroupAs(name = "unmapped-controls", inJson = JsonGroupAsBehavior.LIST)
052  )
053  private List<SelectControlById> _unmappedControls;
054
055  public GapSummary() {
056    this(null);
057  }
058
059  public GapSummary(IMetaschemaData data) {
060    this.__metaschemaData = data;
061  }
062
063  @Override
064  public IMetaschemaData getMetaschemaData() {
065    return __metaschemaData;
066  }
067
068  public UUID getUuid() {
069    return _uuid;
070  }
071
072  public void setUuid(UUID value) {
073    _uuid = value;
074  }
075
076  public List<SelectControlById> getUnmappedControls() {
077    return _unmappedControls;
078  }
079
080  public void setUnmappedControls(List<SelectControlById> value) {
081    _unmappedControls = value;
082  }
083
084  /**
085   * Add a new {@link SelectControlById} item to the underlying collection.
086   * @param item the item to add
087   * @return {@code true}
088   */
089  public boolean addUnmappedControls(SelectControlById item) {
090    SelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
091    if (_unmappedControls == null) {
092      _unmappedControls = new LinkedList<>();
093    }
094    return _unmappedControls.add(value);
095  }
096
097  /**
098   * Remove the first matching {@link SelectControlById} item from the underlying collection.
099   * @param item the item to remove
100   * @return {@code true} if the item was removed or {@code false} otherwise
101   */
102  public boolean removeUnmappedControls(SelectControlById item) {
103    SelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
104    return _unmappedControls != null && _unmappedControls.remove(value);
105  }
106
107  @Override
108  public String toString() {
109    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
110  }
111}