001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_profile_metaschema.xml
002// Do not edit - changes will be lost when regenerated.
003package dev.metaschema.oscal.lib.model;
004
005import dev.metaschema.core.datatype.adapter.UriReferenceAdapter;
006import dev.metaschema.core.model.IBoundObject;
007import dev.metaschema.core.model.IMetaschemaData;
008import dev.metaschema.core.model.JsonGroupAsBehavior;
009import dev.metaschema.core.model.constraint.IConstraint;
010import dev.metaschema.core.util.ObjectUtils;
011import dev.metaschema.databind.model.annotations.AssemblyConstraints;
012import dev.metaschema.databind.model.annotations.BoundAssembly;
013import dev.metaschema.databind.model.annotations.BoundChoice;
014import dev.metaschema.databind.model.annotations.BoundFlag;
015import dev.metaschema.databind.model.annotations.GroupAs;
016import dev.metaschema.databind.model.annotations.Index;
017import dev.metaschema.databind.model.annotations.IndexHasKey;
018import dev.metaschema.databind.model.annotations.KeyField;
019import dev.metaschema.databind.model.annotations.Let;
020import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
021import dev.metaschema.databind.model.annotations.ValueConstraints;
022import edu.umd.cs.findbugs.annotations.NonNull;
023import edu.umd.cs.findbugs.annotations.Nullable;
024import java.net.URI;
025import java.util.LinkedList;
026import java.util.List;
027import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
028import org.apache.commons.lang3.builder.ToStringStyle;
029
030/**
031 * Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.
032 */
033@MetaschemaAssembly(
034    formalName = "Import Resource",
035    description = "Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.",
036    name = "import",
037    moduleClass = OscalProfileModule.class,
038    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).",
039    valueConstraints = @ValueConstraints(lets = @Let(name = "resolved-profile-import", target = ".[@href] ! resolve-profile(doc(resolve-uri(Q{http://csrc.nist.gov/ns/oscal/1.0}resolve-reference(@href))))/catalog"), indexHasKey = @IndexHasKey(id = "oscal-profile-import-has-key-include-exclude-control-id", level = IConstraint.Level.ERROR, target = "(include-controls|exclude-controls)/with-id", indexName = "profile-import-index-control-id", keyFields = @KeyField)),
040    modelConstraints = @AssemblyConstraints(index = @Index(id = "oscal-profile-import-index-control-id", formalName = "In-Scope Control Identifiers", description = "An index of control identifiers that are in-scope for selection in the profile import.", level = IConstraint.Level.ERROR, target = "$resolved-profile-import//control", name = "profile-import-index-control-id", keyFields = @KeyField(target = "@id")))
041)
042public class ProfileImport implements IBoundObject {
043  private final IMetaschemaData __metaschemaData;
044
045  /**
046   * A resolvable URL reference to the base catalog or profile that this profile is tailoring.
047   */
048  @BoundFlag(
049      formalName = "Catalog or Profile Reference",
050      description = "A resolvable URL reference to the base catalog or profile that this profile is tailoring.",
051      name = "href",
052      required = true,
053      typeAdapter = UriReferenceAdapter.class,
054      remarks = "This value may be one of:\n"
055              + "\n"
056              + "1. an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that points to a network resolvable resource,\n"
057              + "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"
058              + "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))."
059  )
060  private URI _href;
061
062  /**
063   * Include all controls from the imported catalog or profile resources.
064   */
065  @BoundAssembly(
066      formalName = "Include All",
067      description = "Include all controls from the imported catalog or profile resources.",
068      useName = "include-all",
069      remarks = "Identifies that all controls are to be included from the imported catalog or profile.",
070      minOccurs = 1
071  )
072  @BoundChoice(
073      choiceId = "choice-1"
074  )
075  private IncludeAll _includeAll;
076
077  /**
078   * Select a control or controls from an imported control set.
079   */
080  @BoundAssembly(
081      formalName = "Select Control",
082      description = "Select a control or controls from an imported control set.",
083      useName = "include-controls",
084      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.",
085      minOccurs = 1,
086      maxOccurs = -1,
087      groupAs = @GroupAs(name = "include-controls", inJson = JsonGroupAsBehavior.LIST)
088  )
089  @BoundChoice(
090      choiceId = "choice-1"
091  )
092  private List<ProfileSelectControlById> _includeControls;
093
094  /**
095   * Select a control or controls from an imported control set.
096   */
097  @BoundAssembly(
098      formalName = "Select Control",
099      description = "Select a control or controls from an imported control set.",
100      useName = "exclude-controls",
101      remarks = "Identifies which controls to exclude, or eliminate, from the set of included controls by control identifier or match pattern.",
102      maxOccurs = -1,
103      groupAs = @GroupAs(name = "exclude-controls", inJson = JsonGroupAsBehavior.LIST)
104  )
105  private List<ProfileSelectControlById> _excludeControls;
106
107  /**
108   * Constructs a new {@code dev.metaschema.oscal.lib.model.ProfileImport} instance with no metadata.
109   */
110  public ProfileImport() {
111    this(null);
112  }
113
114  /**
115   * Constructs a new {@code dev.metaschema.oscal.lib.model.ProfileImport} instance with the specified metadata.
116   *
117   * @param data
118   *           the metaschema data, or {@code null} if none
119   */
120  public ProfileImport(IMetaschemaData data) {
121    this.__metaschemaData = data;
122  }
123
124  @Override
125  public IMetaschemaData getMetaschemaData() {
126    return __metaschemaData;
127  }
128
129  /**
130   * Get the "{@literal Catalog or Profile Reference}".
131   *
132   * <p>
133   * A resolvable URL reference to the base catalog or profile that this profile is tailoring.
134   *
135   * @return the href value
136   */
137  @NonNull
138  public URI getHref() {
139    return _href;
140  }
141
142  /**
143   * Set the "{@literal Catalog or Profile Reference}".
144   *
145   * <p>
146   * A resolvable URL reference to the base catalog or profile that this profile is tailoring.
147   *
148   * @param value
149   *           the href value to set
150   */
151  public void setHref(@NonNull URI value) {
152    _href = value;
153  }
154
155  /**
156   * Get the "{@literal Include All}".
157   *
158   * <p>
159   * Include all controls from the imported catalog or profile resources.
160   *
161   * @return the include-all value, or {@code null} if not set
162   */
163  @Nullable
164  public IncludeAll getIncludeAll() {
165    return _includeAll;
166  }
167
168  /**
169   * Set the "{@literal Include All}".
170   *
171   * <p>
172   * Include all controls from the imported catalog or profile resources.
173   *
174   * @param value
175   *           the include-all value to set, or {@code null} to clear
176   */
177  public void setIncludeAll(@Nullable IncludeAll value) {
178    _includeAll = value;
179  }
180
181  /**
182   * Get the "{@literal Select Control}".
183   *
184   * <p>
185   * Select a control or controls from an imported control set.
186   *
187   * @return the include-controls value
188   */
189  @NonNull
190  public List<ProfileSelectControlById> getIncludeControls() {
191    if (_includeControls == null) {
192      _includeControls = new LinkedList<>();
193    }
194    return ObjectUtils.notNull(_includeControls);
195  }
196
197  /**
198   * Set the "{@literal Select Control}".
199   *
200   * <p>
201   * Select a control or controls from an imported control set.
202   *
203   * @param value
204   *           the include-controls value to set
205   */
206  public void setIncludeControls(@NonNull List<ProfileSelectControlById> value) {
207    _includeControls = value;
208  }
209
210  /**
211   * Add a new {@link ProfileSelectControlById} item to the underlying collection.
212   * @param item the item to add
213   * @return {@code true}
214   */
215  public boolean addIncludeControls(ProfileSelectControlById item) {
216    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
217    if (_includeControls == null) {
218      _includeControls = new LinkedList<>();
219    }
220    return _includeControls.add(value);
221  }
222
223  /**
224   * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection.
225   * @param item the item to remove
226   * @return {@code true} if the item was removed or {@code false} otherwise
227   */
228  public boolean removeIncludeControls(ProfileSelectControlById item) {
229    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
230    return _includeControls != null && _includeControls.remove(value);
231  }
232
233  /**
234   * Get the "{@literal Select Control}".
235   *
236   * <p>
237   * Select a control or controls from an imported control set.
238   *
239   * @return the exclude-controls value
240   */
241  @NonNull
242  public List<ProfileSelectControlById> getExcludeControls() {
243    if (_excludeControls == null) {
244      _excludeControls = new LinkedList<>();
245    }
246    return ObjectUtils.notNull(_excludeControls);
247  }
248
249  /**
250   * Set the "{@literal Select Control}".
251   *
252   * <p>
253   * Select a control or controls from an imported control set.
254   *
255   * @param value
256   *           the exclude-controls value to set
257   */
258  public void setExcludeControls(@NonNull List<ProfileSelectControlById> value) {
259    _excludeControls = value;
260  }
261
262  /**
263   * Add a new {@link ProfileSelectControlById} item to the underlying collection.
264   * @param item the item to add
265   * @return {@code true}
266   */
267  public boolean addExcludeControls(ProfileSelectControlById item) {
268    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
269    if (_excludeControls == null) {
270      _excludeControls = new LinkedList<>();
271    }
272    return _excludeControls.add(value);
273  }
274
275  /**
276   * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection.
277   * @param item the item to remove
278   * @return {@code true} if the item was removed or {@code false} otherwise
279   */
280  public boolean removeExcludeControls(ProfileSelectControlById item) {
281    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
282    return _excludeControls != null && _excludeControls.remove(value);
283  }
284
285  @Override
286  public String toString() {
287    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
288  }
289}