001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_mapping_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.constraint.IConstraint;
009import dev.metaschema.core.util.ObjectUtils;
010import dev.metaschema.databind.model.annotations.AssemblyConstraints;
011import dev.metaschema.databind.model.annotations.BoundAssembly;
012import dev.metaschema.databind.model.annotations.BoundFlag;
013import dev.metaschema.databind.model.annotations.GroupAs;
014import dev.metaschema.databind.model.annotations.Index;
015import dev.metaschema.databind.model.annotations.IsUnique;
016import dev.metaschema.databind.model.annotations.KeyField;
017import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
018import edu.umd.cs.findbugs.annotations.NonNull;
019import edu.umd.cs.findbugs.annotations.Nullable;
020import java.util.LinkedList;
021import java.util.List;
022import java.util.UUID;
023import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
024import org.apache.commons.lang3.builder.ToStringStyle;
025
026/**
027 * A collection of relationship-based control and/or control statement mappings.
028 */
029@MetaschemaAssembly(
030    formalName = "Mapping Collection",
031    description = "A collection of relationship-based control and/or control statement mappings.",
032    name = "mapping-collection",
033    moduleClass = OscalMappingModule.class,
034    rootName = "mapping-collection",
035    remarks = "A mapping collection affirmatively declares the relationships that exist between sets of controls and/or control statements in a source and target. It is expected that inferences can be made based on what is mapped; however, no inferences should be made based on what is not mapped, since it is impossible to quantify how complete or granular a given mapping is.",
036    modelConstraints = @AssemblyConstraints(index = {@Index(id = "oscal-mapping-collection-index-metadata-scoped-role-id", formalName = "In-Scope Role Identifiers", description = "An index of role identifiers that are in-scope for the mapping-collection model.", level = IConstraint.Level.ERROR, target = "metadata/role", name = "index-imports-metadata-role-id", keyFields = @KeyField(target = "@id")), @Index(id = "oscal-mapping-collection-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-mapping-collection-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-mapping-collection-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-mapping-collection-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.")})
037)
038public class MappingCollection extends AbstractOscalInstance implements IBoundObject {
039  private final IMetaschemaData __metaschemaData;
040
041  /**
042   * A globally unique identifier with cross-instance scope for this catalog instance. This UUID should be changed when this document is revised.
043   */
044  @BoundFlag(
045      formalName = "Mapping Collection Universally Unique Identifier",
046      description = "A globally unique identifier with cross-instance scope for this catalog instance. This UUID should be changed when this document is revised.",
047      name = "uuid",
048      required = true,
049      typeAdapter = UuidAdapter.class
050  )
051  private UUID _uuid;
052
053  /**
054   * Provides information about the containing document, and defines concepts that are shared across the document.
055   */
056  @BoundAssembly(
057      formalName = "Document Metadata",
058      description = "Provides information about the containing document, and defines concepts that are shared across the document.",
059      useName = "metadata",
060      minOccurs = 1
061  )
062  private Metadata _metadata;
063
064  /**
065   * Describes requirements, incompatibilities and gaps that are identified between a target and source in a mapping item.
066   */
067  @BoundAssembly(
068      formalName = "Mapping Provenance",
069      description = "Describes requirements, incompatibilities and gaps that are identified between a target and source in a mapping item.",
070      useName = "provenance",
071      minOccurs = 1
072  )
073  private MappingProvenance _provenance;
074
075  /**
076   * A mapping between two target resources.
077   */
078  @BoundAssembly(
079      formalName = "Control Mapping",
080      description = "A mapping between two target resources.",
081      useName = "mapping",
082      minOccurs = 1,
083      maxOccurs = -1,
084      groupAs = @GroupAs(name = "mappings")
085  )
086  private List<Mapping> _mappings;
087
088  /**
089   * A collection of resources that may be referenced from within the OSCAL document instance.
090   */
091  @BoundAssembly(
092      formalName = "Back matter",
093      description = "A collection of resources that may be referenced from within the OSCAL document instance.",
094      useName = "back-matter",
095      remarks = "Back matter including references and resources."
096  )
097  private BackMatter _backMatter;
098
099  /**
100   * Constructs a new {@code dev.metaschema.oscal.lib.model.MappingCollection} instance with no metadata.
101   */
102  public MappingCollection() {
103    this(null);
104  }
105
106  /**
107   * Constructs a new {@code dev.metaschema.oscal.lib.model.MappingCollection} instance with the specified metadata.
108   *
109   * @param data
110   *           the metaschema data, or {@code null} if none
111   */
112  public MappingCollection(IMetaschemaData data) {
113    this.__metaschemaData = data;
114  }
115
116  @Override
117  public IMetaschemaData getMetaschemaData() {
118    return __metaschemaData;
119  }
120
121  /**
122   * Get the "{@literal Mapping Collection Universally Unique Identifier}".
123   *
124   * <p>
125   * A globally unique identifier with cross-instance scope for this catalog instance. This UUID should be changed when this document is revised.
126   *
127   * @return the uuid value
128   */
129  @NonNull
130  public UUID getUuid() {
131    return _uuid;
132  }
133
134  /**
135   * Set the "{@literal Mapping Collection Universally Unique Identifier}".
136   *
137   * <p>
138   * A globally unique identifier with cross-instance scope for this catalog instance. This UUID should be changed when this document is revised.
139   *
140   * @param value
141   *           the uuid value to set
142   */
143  public void setUuid(@NonNull UUID value) {
144    _uuid = value;
145  }
146
147  /**
148   * Get the "{@literal Document Metadata}".
149   *
150   * <p>
151   * Provides information about the containing document, and defines concepts that are shared across the document.
152   *
153   * @return the metadata value
154   */
155  @NonNull
156  public Metadata getMetadata() {
157    return _metadata;
158  }
159
160  /**
161   * Set the "{@literal Document Metadata}".
162   *
163   * <p>
164   * Provides information about the containing document, and defines concepts that are shared across the document.
165   *
166   * @param value
167   *           the metadata value to set
168   */
169  public void setMetadata(@NonNull Metadata value) {
170    _metadata = value;
171  }
172
173  /**
174   * Get the "{@literal Mapping Provenance}".
175   *
176   * <p>
177   * Describes requirements, incompatibilities and gaps that are identified between a target and source in a mapping item.
178   *
179   * @return the provenance value
180   */
181  @NonNull
182  public MappingProvenance getProvenance() {
183    return _provenance;
184  }
185
186  /**
187   * Set the "{@literal Mapping Provenance}".
188   *
189   * <p>
190   * Describes requirements, incompatibilities and gaps that are identified between a target and source in a mapping item.
191   *
192   * @param value
193   *           the provenance value to set
194   */
195  public void setProvenance(@NonNull MappingProvenance value) {
196    _provenance = value;
197  }
198
199  /**
200   * Get the "{@literal Control Mapping}".
201   *
202   * <p>
203   * A mapping between two target resources.
204   *
205   * @return the mapping value
206   */
207  @NonNull
208  public List<Mapping> getMappings() {
209    if (_mappings == null) {
210      _mappings = new LinkedList<>();
211    }
212    return ObjectUtils.notNull(_mappings);
213  }
214
215  /**
216   * Set the "{@literal Control Mapping}".
217   *
218   * <p>
219   * A mapping between two target resources.
220   *
221   * @param value
222   *           the mapping value to set
223   */
224  public void setMappings(@NonNull List<Mapping> value) {
225    _mappings = value;
226  }
227
228  /**
229   * Add a new {@link Mapping} item to the underlying collection.
230   * @param item the item to add
231   * @return {@code true}
232   */
233  public boolean addMapping(Mapping item) {
234    Mapping value = ObjectUtils.requireNonNull(item,"item cannot be null");
235    if (_mappings == null) {
236      _mappings = new LinkedList<>();
237    }
238    return _mappings.add(value);
239  }
240
241  /**
242   * Remove the first matching {@link Mapping} item from the underlying collection.
243   * @param item the item to remove
244   * @return {@code true} if the item was removed or {@code false} otherwise
245   */
246  public boolean removeMapping(Mapping item) {
247    Mapping value = ObjectUtils.requireNonNull(item,"item cannot be null");
248    return _mappings != null && _mappings.remove(value);
249  }
250
251  /**
252   * Get the "{@literal Back matter}".
253   *
254   * <p>
255   * A collection of resources that may be referenced from within the OSCAL document instance.
256   *
257   * @return the back-matter value, or {@code null} if not set
258   */
259  @Nullable
260  public BackMatter getBackMatter() {
261    return _backMatter;
262  }
263
264  /**
265   * Set the "{@literal Back matter}".
266   *
267   * <p>
268   * A collection of resources that may be referenced from within the OSCAL document instance.
269   *
270   * @param value
271   *           the back-matter value to set, or {@code null} to clear
272   */
273  public void setBackMatter(@Nullable BackMatter value) {
274    _backMatter = value;
275  }
276
277  @Override
278  public String toString() {
279    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
280  }
281}