001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
004import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
005import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
006import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
007import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
008import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique;
009import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
010import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
011import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
012import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
013import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
014import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
015import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
016import java.lang.Override;
017import java.lang.String;
018import java.util.LinkedList;
019import java.util.List;
020import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
021import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
022
023/**
024 * A description of the logical flow of information within the system and across its boundaries, optionally supplemented by diagrams that illustrate these flows.
025 */
026@MetaschemaAssembly(
027    formalName = "Data Flow",
028    description = "A description of the logical flow of information within the system and across its boundaries, optionally supplemented by diagrams that illustrate these flows.",
029    name = "data-flow",
030    metaschema = OscalSspMetaschema.class
031)
032@AssemblyConstraints(
033    isUnique = @IsUnique(id = "unique-ssp-data-flow-diagram", level = IConstraint.Level.ERROR, target = "diagram", keyFields = @KeyField(target = "@uuid"), remarks = "A given `uuid` must be assigned only once to a diagram.")
034)
035public class DataFlow {
036  /**
037   * "A summary of the system's data flow."
038   */
039  @BoundField(
040      formalName = "Data Flow Description",
041      description = "A summary of the system's data flow.",
042      useName = "description",
043      minOccurs = 1
044  )
045  @BoundFieldValue(
046      typeAdapter = MarkupMultilineAdapter.class
047  )
048  private MarkupMultiline _description;
049
050  @BoundAssembly(
051      formalName = "Property",
052      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
053      useName = "prop",
054      maxOccurs = -1
055  )
056  @GroupAs(
057      name = "props",
058      inJson = JsonGroupAsBehavior.LIST
059  )
060  private List<Property> _props;
061
062  @BoundAssembly(
063      formalName = "Link",
064      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
065      useName = "link",
066      maxOccurs = -1
067  )
068  @GroupAs(
069      name = "links",
070      inJson = JsonGroupAsBehavior.LIST
071  )
072  private List<Link> _links;
073
074  @BoundAssembly(
075      formalName = "Diagram",
076      description = "A graphic that provides a visual representation the system, or some aspect of it.",
077      useName = "diagram",
078      maxOccurs = -1
079  )
080  @GroupAs(
081      name = "diagrams",
082      inJson = JsonGroupAsBehavior.LIST
083  )
084  private List<Diagram> _diagrams;
085
086  @BoundField(
087      formalName = "Remarks",
088      description = "Additional commentary about the containing object.",
089      useName = "remarks"
090  )
091  @BoundFieldValue(
092      typeAdapter = MarkupMultilineAdapter.class
093  )
094  private MarkupMultiline _remarks;
095
096  public DataFlow() {
097  }
098
099  public MarkupMultiline getDescription() {
100    return _description;
101  }
102
103  public void setDescription(MarkupMultiline value) {
104    _description = value;
105  }
106
107  public List<Property> getProps() {
108    return _props;
109  }
110
111  public void setProps(List<Property> value) {
112    _props = value;
113  }
114
115  /**
116   * Add a new {@link Property} item to the underlying collection.
117   * @param item the item to add
118   * @return {@code true}
119   */
120  public boolean addProp(Property item) {
121    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
122    if (_props == null) {
123      _props = new LinkedList<>();
124    }
125    return _props.add(value);
126  }
127
128  /**
129   * Remove the first matching {@link Property} item from the underlying collection.
130   * @param item the item to remove
131   * @return {@code true} if the item was removed or {@code false} otherwise
132   */
133  public boolean removeProp(Property item) {
134    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
135    return _props == null ? false : _props.remove(value);
136  }
137
138  public List<Link> getLinks() {
139    return _links;
140  }
141
142  public void setLinks(List<Link> value) {
143    _links = value;
144  }
145
146  /**
147   * Add a new {@link Link} item to the underlying collection.
148   * @param item the item to add
149   * @return {@code true}
150   */
151  public boolean addLink(Link item) {
152    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
153    if (_links == null) {
154      _links = new LinkedList<>();
155    }
156    return _links.add(value);
157  }
158
159  /**
160   * Remove the first matching {@link Link} item from the underlying collection.
161   * @param item the item to remove
162   * @return {@code true} if the item was removed or {@code false} otherwise
163   */
164  public boolean removeLink(Link item) {
165    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
166    return _links == null ? false : _links.remove(value);
167  }
168
169  public List<Diagram> getDiagrams() {
170    return _diagrams;
171  }
172
173  public void setDiagrams(List<Diagram> value) {
174    _diagrams = value;
175  }
176
177  /**
178   * Add a new {@link Diagram} item to the underlying collection.
179   * @param item the item to add
180   * @return {@code true}
181   */
182  public boolean addDiagram(Diagram item) {
183    Diagram value = ObjectUtils.requireNonNull(item,"item cannot be null");
184    if (_diagrams == null) {
185      _diagrams = new LinkedList<>();
186    }
187    return _diagrams.add(value);
188  }
189
190  /**
191   * Remove the first matching {@link Diagram} item from the underlying collection.
192   * @param item the item to remove
193   * @return {@code true} if the item was removed or {@code false} otherwise
194   */
195  public boolean removeDiagram(Diagram item) {
196    Diagram value = ObjectUtils.requireNonNull(item,"item cannot be null");
197    return _diagrams == null ? false : _diagrams.remove(value);
198  }
199
200  public MarkupMultiline getRemarks() {
201    return _remarks;
202  }
203
204  public void setRemarks(MarkupMultiline value) {
205    _remarks = value;
206  }
207
208  @Override
209  public String toString() {
210    return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
211  }
212}