001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_catalog_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.UuidAdapter;
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.AllowedValue;
012import dev.metaschema.databind.model.annotations.AllowedValues;
013import dev.metaschema.databind.model.annotations.AssemblyConstraints;
014import dev.metaschema.databind.model.annotations.BoundAssembly;
015import dev.metaschema.databind.model.annotations.BoundFlag;
016import dev.metaschema.databind.model.annotations.GroupAs;
017import dev.metaschema.databind.model.annotations.Index;
018import dev.metaschema.databind.model.annotations.IsUnique;
019import dev.metaschema.databind.model.annotations.KeyField;
020import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
021import dev.metaschema.databind.model.annotations.ValueConstraints;
022import dev.metaschema.oscal.lib.model.control.catalog.AbstractCatalog;
023import edu.umd.cs.findbugs.annotations.NonNull;
024import edu.umd.cs.findbugs.annotations.Nullable;
025import java.util.LinkedList;
026import java.util.List;
027import java.util.UUID;
028import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
029import org.apache.commons.lang3.builder.ToStringStyle;
030
031/**
032 * A structured, <a href="https://pages.nist.gov/OSCAL/concepts/terminology/#catalog">organized collection</a> of control information.
033 */
034@MetaschemaAssembly(
035    formalName = "Catalog",
036    description = "A structured, [organized collection](https://pages.nist.gov/OSCAL/concepts/terminology/#catalog) of control information.",
037    name = "catalog",
038    moduleClass = OscalCatalogModule.class,
039    rootName = "catalog",
040    remarks = "Catalogs may use one or more `group` objects to subdivide the control contents of a catalog.",
041    valueConstraints = @ValueConstraints(allowedValues = {@AllowedValues(id = "oscal-catalog-metadata-prop-name", level = IConstraint.Level.ERROR, target = "metadata/prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = {@AllowedValue(value = "resolution-tool", description = "The tool used to produce a resolved profile."), @AllowedValue(value = "source-profile-uuid", description = "The document-level `uuid` of the source profile from which the catalog was produced by [profile resolution](https://pages.nist.gov/OSCAL/concepts/processing/profile-resolution/).")}), @AllowedValues(id = "oscal-catalog-metadata-link-rel-type", level = IConstraint.Level.ERROR, target = "metadata/link/@rel", allowOthers = true, values = {@AllowedValue(value = "source-profile", description = "The profile from which the catalog was produced by [profile resolution](https://pages.nist.gov/OSCAL/concepts/processing/profile-resolution/)."), @AllowedValue(value = "source-profile-uuid", description = "The document-level `uuid` of the profile from which the catalog was produced by [profile resolution](https://pages.nist.gov/OSCAL/concepts/processing/profile-resolution/).")})}),
042    modelConstraints = @AssemblyConstraints(index = {@Index(id = "oscal-catalog-parts", level = IConstraint.Level.ERROR, target = "//part", name = "catalog-parts", keyFields = @KeyField(target = "@id")), @Index(id = "oscal-catalog-props", level = IConstraint.Level.ERROR, target = "//prop", name = "catalog-props", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-catalog-groups-controls-parts", level = IConstraint.Level.ERROR, target = "//(control|group|part)", name = "catalog-groups-controls-parts", keyFields = @KeyField(target = "@id")), @Index(id = "oscal-catalog-controls", level = IConstraint.Level.ERROR, target = "//control", name = "catalog-controls", keyFields = @KeyField(target = "@id")), @Index(id = "oscal-catalog-params", level = IConstraint.Level.ERROR, target = "//param", name = "catalog-params", keyFields = @KeyField(target = "@id")), @Index(id = "oscal-catalog-groups", level = IConstraint.Level.ERROR, target = "//group", name = "catalog-groups", keyFields = @KeyField(target = "@id")), @Index(id = "oscal-catalog-index-metadata-scoped-metadata-role-id", formalName = "In-Scope Role Identifiers", description = "An index of role identifiers that are in-scope for the catalog model.", level = IConstraint.Level.ERROR, target = "metadata/role", name = "index-imports-metadata-role-id", keyFields = @KeyField(target = "@id")), @Index(id = "oscal-catalog-index-metadata-scoped-location-uuid", level = IConstraint.Level.ERROR, target = "metadata/location", name = "index-imports-metadata-location-uuid", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-catalog-index-metadata-scoped-party-uuid", level = IConstraint.Level.ERROR, target = "metadata/party", name = "index-imports-metadata-party-uuid", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-catalog-index-metadata-scoped-party-organization-uuid", level = IConstraint.Level.ERROR, target = "metadata/party[@type='organization']", name = "index-imports-metadata-party-organization-uuid", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-catalog-index-metadata-scoped-property-uuid", level = IConstraint.Level.ERROR, target = ".//prop[@uuid]", name = "index-imports-metadata-property-uuid", keyFields = @KeyField(target = "@uuid"))}, unique = {@IsUnique(id = "oscal-unique-document-id", formalName = "Unique Document Identifier", description = "Ensure all document identifiers have a unique combination of @scheme and value.", level = IConstraint.Level.ERROR, target = "document-id", keyFields = {@KeyField(target = "@scheme"), @KeyField}), @IsUnique(id = "oscal-unique-property-in-context-location", formalName = "Unique Properties", description = "Ensure all properties are unique for a given location using a unique combination of @ns, @name, @class. @group. and @value.", level = IConstraint.Level.ERROR, target = ".//prop", keyFields = {@KeyField(target = "path(..)"), @KeyField(target = "@name"), @KeyField(target = "@ns"), @KeyField(target = "@class"), @KeyField(target = "@group"), @KeyField(target = "@value")}), @IsUnique(id = "oscal-unique-link-in-context-location", formalName = "Unique Links", description = "Ensure all links are unique for a given location using a unique combination of @href, @rel, and @media-type.", level = IConstraint.Level.ERROR, target = ".//link", keyFields = {@KeyField(target = "path(..)"), @KeyField(target = "@href"), @KeyField(target = "@rel"), @KeyField(target = "@media-type"), @KeyField(target = "@resource-fragment")}), @IsUnique(id = "oscal-unique-responsibility-in-context-location", formalName = "Unique Responsibilities", description = "Ensure all responsible-roles and responsible-parties are unique for a given location using a unique combination of @role-id and the combination of @party-uuid values.", level = IConstraint.Level.ERROR, target = ".//(responsible-party|responsible-role)", keyFields = {@KeyField(target = "path(..)"), @KeyField(target = "@role-id"), @KeyField(target = "@party-uuid")}, remarks = "Since `responsible-party` and `responsible-role` associate multiple `party-uuid` entries with a single `role-id`, each role-id must be referenced only once.")})
043)
044public class Catalog extends AbstractCatalog implements IBoundObject {
045  private final IMetaschemaData __metaschemaData;
046
047  /**
048   * Provides a globally unique means to identify a given catalog instance.
049   */
050  @BoundFlag(
051      formalName = "Catalog Universally Unique Identifier",
052      description = "Provides a globally unique means to identify a given catalog instance.",
053      name = "uuid",
054      required = true,
055      typeAdapter = UuidAdapter.class
056  )
057  private UUID _uuid;
058
059  /**
060   * Provides information about the containing document, and defines concepts that are shared across the document.
061   */
062  @BoundAssembly(
063      formalName = "Document Metadata",
064      description = "Provides information about the containing document, and defines concepts that are shared across the document.",
065      useName = "metadata",
066      minOccurs = 1
067  )
068  private Metadata _metadata;
069
070  /**
071   * Parameters provide a mechanism for the dynamic assignment of value(s) in a control.
072   */
073  @BoundAssembly(
074      formalName = "Parameter",
075      description = "Parameters provide a mechanism for the dynamic assignment of value(s) in a control.",
076      useName = "param",
077      maxOccurs = -1,
078      groupAs = @GroupAs(name = "params", inJson = JsonGroupAsBehavior.LIST)
079  )
080  private List<Parameter> _params;
081
082  /**
083   * A <a href="https://pages.nist.gov/OSCAL/concepts/terminology/#control">structured object</a> representing a requirement or guideline, which when implemented will reduce an aspect of risk related to an information system and its information.
084   */
085  @BoundAssembly(
086      formalName = "Control",
087      description = "A [structured object](https://pages.nist.gov/OSCAL/concepts/terminology/#control) representing a requirement or guideline, which when implemented will reduce an aspect of risk related to an information system and its information.",
088      useName = "control",
089      maxOccurs = -1,
090      groupAs = @GroupAs(name = "controls", inJson = JsonGroupAsBehavior.LIST)
091  )
092  private List<Control> _controls;
093
094  /**
095   * A group of controls, or of groups of controls.
096   */
097  @BoundAssembly(
098      formalName = "Control Group",
099      description = "A group of controls, or of groups of controls.",
100      useName = "group",
101      maxOccurs = -1,
102      groupAs = @GroupAs(name = "groups", inJson = JsonGroupAsBehavior.LIST)
103  )
104  private List<CatalogGroup> _groups;
105
106  /**
107   * A collection of resources that may be referenced from within the OSCAL document instance.
108   */
109  @BoundAssembly(
110      formalName = "Back matter",
111      description = "A collection of resources that may be referenced from within the OSCAL document instance.",
112      useName = "back-matter",
113      remarks = "Back matter including references and resources."
114  )
115  private BackMatter _backMatter;
116
117  /**
118   * Constructs a new {@code dev.metaschema.oscal.lib.model.Catalog} instance with no metadata.
119   */
120  public Catalog() {
121    this(null);
122  }
123
124  /**
125   * Constructs a new {@code dev.metaschema.oscal.lib.model.Catalog} instance with the specified metadata.
126   *
127   * @param data
128   *           the metaschema data, or {@code null} if none
129   */
130  public Catalog(IMetaschemaData data) {
131    this.__metaschemaData = data;
132  }
133
134  @Override
135  public IMetaschemaData getMetaschemaData() {
136    return __metaschemaData;
137  }
138
139  /**
140   * Get the "{@literal Catalog Universally Unique Identifier}".
141   *
142   * <p>
143   * Provides a globally unique means to identify a given catalog instance.
144   *
145   * @return the uuid value
146   */
147  @NonNull
148  public UUID getUuid() {
149    return _uuid;
150  }
151
152  /**
153   * Set the "{@literal Catalog Universally Unique Identifier}".
154   *
155   * <p>
156   * Provides a globally unique means to identify a given catalog instance.
157   *
158   * @param value
159   *           the uuid value to set
160   */
161  public void setUuid(@NonNull UUID value) {
162    _uuid = value;
163  }
164
165  /**
166   * Get the "{@literal Document Metadata}".
167   *
168   * <p>
169   * Provides information about the containing document, and defines concepts that are shared across the document.
170   *
171   * @return the metadata value
172   */
173  @NonNull
174  public Metadata getMetadata() {
175    return _metadata;
176  }
177
178  /**
179   * Set the "{@literal Document Metadata}".
180   *
181   * <p>
182   * Provides information about the containing document, and defines concepts that are shared across the document.
183   *
184   * @param value
185   *           the metadata value to set
186   */
187  public void setMetadata(@NonNull Metadata value) {
188    _metadata = value;
189  }
190
191  /**
192   * Get the "{@literal Parameter}".
193   *
194   * <p>
195   * Parameters provide a mechanism for the dynamic assignment of value(s) in a control.
196   *
197   * @return the param value
198   */
199  @NonNull
200  public List<Parameter> getParams() {
201    if (_params == null) {
202      _params = new LinkedList<>();
203    }
204    return ObjectUtils.notNull(_params);
205  }
206
207  /**
208   * Set the "{@literal Parameter}".
209   *
210   * <p>
211   * Parameters provide a mechanism for the dynamic assignment of value(s) in a control.
212   *
213   * @param value
214   *           the param value to set
215   */
216  public void setParams(@NonNull List<Parameter> value) {
217    _params = value;
218  }
219
220  /**
221   * Add a new {@link Parameter} item to the underlying collection.
222   * @param item the item to add
223   * @return {@code true}
224   */
225  public boolean addParam(Parameter item) {
226    Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
227    if (_params == null) {
228      _params = new LinkedList<>();
229    }
230    return _params.add(value);
231  }
232
233  /**
234   * Remove the first matching {@link Parameter} item from the underlying collection.
235   * @param item the item to remove
236   * @return {@code true} if the item was removed or {@code false} otherwise
237   */
238  public boolean removeParam(Parameter item) {
239    Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
240    return _params != null && _params.remove(value);
241  }
242
243  /**
244   * Get the "{@literal Control}".
245   *
246   * <p>
247   * A <a href="https://pages.nist.gov/OSCAL/concepts/terminology/#control">structured object</a> representing a requirement or guideline, which when implemented will reduce an aspect of risk related to an information system and its information.
248   *
249   * @return the control value
250   */
251  @NonNull
252  public List<Control> getControls() {
253    if (_controls == null) {
254      _controls = new LinkedList<>();
255    }
256    return ObjectUtils.notNull(_controls);
257  }
258
259  /**
260   * Set the "{@literal Control}".
261   *
262   * <p>
263   * A <a href="https://pages.nist.gov/OSCAL/concepts/terminology/#control">structured object</a> representing a requirement or guideline, which when implemented will reduce an aspect of risk related to an information system and its information.
264   *
265   * @param value
266   *           the control value to set
267   */
268  public void setControls(@NonNull List<Control> value) {
269    _controls = value;
270  }
271
272  /**
273   * Add a new {@link Control} item to the underlying collection.
274   * @param item the item to add
275   * @return {@code true}
276   */
277  public boolean addControl(Control item) {
278    Control value = ObjectUtils.requireNonNull(item,"item cannot be null");
279    if (_controls == null) {
280      _controls = new LinkedList<>();
281    }
282    return _controls.add(value);
283  }
284
285  /**
286   * Remove the first matching {@link Control} item from the underlying collection.
287   * @param item the item to remove
288   * @return {@code true} if the item was removed or {@code false} otherwise
289   */
290  public boolean removeControl(Control item) {
291    Control value = ObjectUtils.requireNonNull(item,"item cannot be null");
292    return _controls != null && _controls.remove(value);
293  }
294
295  /**
296   * Get the "{@literal Control Group}".
297   *
298   * <p>
299   * A group of controls, or of groups of controls.
300   *
301   * @return the group value
302   */
303  @NonNull
304  public List<CatalogGroup> getGroups() {
305    if (_groups == null) {
306      _groups = new LinkedList<>();
307    }
308    return ObjectUtils.notNull(_groups);
309  }
310
311  /**
312   * Set the "{@literal Control Group}".
313   *
314   * <p>
315   * A group of controls, or of groups of controls.
316   *
317   * @param value
318   *           the group value to set
319   */
320  public void setGroups(@NonNull List<CatalogGroup> value) {
321    _groups = value;
322  }
323
324  /**
325   * Add a new {@link CatalogGroup} item to the underlying collection.
326   * @param item the item to add
327   * @return {@code true}
328   */
329  public boolean addGroup(CatalogGroup item) {
330    CatalogGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
331    if (_groups == null) {
332      _groups = new LinkedList<>();
333    }
334    return _groups.add(value);
335  }
336
337  /**
338   * Remove the first matching {@link CatalogGroup} item from the underlying collection.
339   * @param item the item to remove
340   * @return {@code true} if the item was removed or {@code false} otherwise
341   */
342  public boolean removeGroup(CatalogGroup item) {
343    CatalogGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
344    return _groups != null && _groups.remove(value);
345  }
346
347  /**
348   * Get the "{@literal Back matter}".
349   *
350   * <p>
351   * A collection of resources that may be referenced from within the OSCAL document instance.
352   *
353   * @return the back-matter value, or {@code null} if not set
354   */
355  @Nullable
356  public BackMatter getBackMatter() {
357    return _backMatter;
358  }
359
360  /**
361   * Set the "{@literal Back matter}".
362   *
363   * <p>
364   * A collection of resources that may be referenced from within the OSCAL document instance.
365   *
366   * @param value
367   *           the back-matter value to set, or {@code null} to clear
368   */
369  public void setBackMatter(@Nullable BackMatter value) {
370    _backMatter = value;
371  }
372
373  @Override
374  public String toString() {
375    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
376  }
377}