001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
004import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
005import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
006import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
007import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
008import gov.nist.secauto.metaschema.model.common.datatype.adapter.UriReferenceAdapter;
009import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
010import java.lang.Override;
011import java.lang.String;
012import java.net.URI;
013import java.util.LinkedList;
014import java.util.List;
015import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
016import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
017
018/**
019 * Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.
020 */
021@MetaschemaAssembly(
022    formalName = "Import Resource",
023    description = "Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.",
024    name = "import",
025    metaschema = OscalProfileMetaschema.class,
026    remarks = "The contents of the `import` element indicate which controls from the source will be included. Controls from the source catalog or profile may be either selected, using the `include-all` or `include-controls` directives, or de-selected (using an `exclude-controls` directive)."
027)
028public class ProfileImport {
029  @BoundFlag(
030      formalName = "Catalog or Profile Reference",
031      description = "A resolvable URL reference to the base catalog or profile that this profile is tailoring.",
032      useName = "href",
033      required = true,
034      typeAdapter = UriReferenceAdapter.class,
035      remarks = "This value may be one of:\n"
036              + "\n"
037              + "1. an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that points to a network resolvable resource,\n"
038              + "2. a [relative reference](https://pages.nist.gov/OSCAL/concepts/uri-use/#relative-reference) pointing to a network resolvable resource whose base URI is the URI of the containing document, or\n"
039              + "3. a bare URI fragment (i.e., \\`#uuid\\`) pointing to a `back-matter` resource in this or an imported document (see [linking to another OSCAL object](https://pages.nist.gov/OSCAL/concepts/uri-use/#linking-to-another-oscal-object))."
040  )
041  private URI _href;
042
043  @BoundAssembly(
044      formalName = "Include All",
045      description = "Include all controls from the imported catalog or profile resources.",
046      useName = "include-all",
047      minOccurs = 1,
048      remarks = "Identifies that all controls are to be included from the imported catalog or profile."
049  )
050  private IncludeAll _includeAll;
051
052  @BoundAssembly(
053      formalName = "Select Control",
054      description = "Select a control or controls from an imported control set.",
055      useName = "include-controls",
056      minOccurs = 1,
057      maxOccurs = -1,
058      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."
059  )
060  @GroupAs(
061      name = "include-controls",
062      inJson = JsonGroupAsBehavior.LIST
063  )
064  private List<ProfileSelectControlById> _includeControls;
065
066  @BoundAssembly(
067      formalName = "Select Control",
068      description = "Select a control or controls from an imported control set.",
069      useName = "exclude-controls",
070      maxOccurs = -1,
071      remarks = "Identifies which controls to exclude, or eliminate, from the set of included controls by control identifier or match pattern."
072  )
073  @GroupAs(
074      name = "exclude-controls",
075      inJson = JsonGroupAsBehavior.LIST
076  )
077  private List<ProfileSelectControlById> _excludeControls;
078
079  public ProfileImport() {
080  }
081
082  public URI getHref() {
083    return _href;
084  }
085
086  public void setHref(URI value) {
087    _href = value;
088  }
089
090  public IncludeAll getIncludeAll() {
091    return _includeAll;
092  }
093
094  public void setIncludeAll(IncludeAll value) {
095    _includeAll = value;
096  }
097
098  public List<ProfileSelectControlById> getIncludeControls() {
099    return _includeControls;
100  }
101
102  public void setIncludeControls(List<ProfileSelectControlById> value) {
103    _includeControls = value;
104  }
105
106  /**
107   * Add a new {@link ProfileSelectControlById} item to the underlying collection.
108   * @param item the item to add
109   * @return {@code true}
110   */
111  public boolean addIncludeControls(ProfileSelectControlById item) {
112    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
113    if (_includeControls == null) {
114      _includeControls = new LinkedList<>();
115    }
116    return _includeControls.add(value);
117  }
118
119  /**
120   * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection.
121   * @param item the item to remove
122   * @return {@code true} if the item was removed or {@code false} otherwise
123   */
124  public boolean removeIncludeControls(ProfileSelectControlById item) {
125    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
126    return _includeControls == null ? false : _includeControls.remove(value);
127  }
128
129  public List<ProfileSelectControlById> getExcludeControls() {
130    return _excludeControls;
131  }
132
133  public void setExcludeControls(List<ProfileSelectControlById> value) {
134    _excludeControls = value;
135  }
136
137  /**
138   * Add a new {@link ProfileSelectControlById} item to the underlying collection.
139   * @param item the item to add
140   * @return {@code true}
141   */
142  public boolean addExcludeControls(ProfileSelectControlById item) {
143    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
144    if (_excludeControls == null) {
145      _excludeControls = new LinkedList<>();
146    }
147    return _excludeControls.add(value);
148  }
149
150  /**
151   * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection.
152   * @param item the item to remove
153   * @return {@code true} if the item was removed or {@code false} otherwise
154   */
155  public boolean removeExcludeControls(ProfileSelectControlById item) {
156    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
157    return _excludeControls == null ? false : _excludeControls.remove(value);
158  }
159
160  @Override
161  public String toString() {
162    return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
163  }
164}