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