View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
4   import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
5   import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
6   import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
7   import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
8   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
9   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
10  import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
11  import gov.nist.secauto.metaschema.binding.model.annotations.HasCardinality;
12  import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
13  import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
14  import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
15  import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
16  import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
17  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
18  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
19  import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
20  import java.lang.Override;
21  import java.lang.String;
22  import java.util.LinkedList;
23  import java.util.List;
24  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
25  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
26  
27  /**
28   * A local definition of a control objective for this assessment. Uses catalog syntax for control objective and assessment actions.
29   */
30  @MetaschemaAssembly(
31      formalName = "Assessment-Specific Control Objective",
32      description = "A local definition of a control objective for this assessment. Uses catalog syntax for control objective and assessment actions.",
33      name = "local-objective",
34      metaschema = OscalAssessmentCommonMetaschema.class
35  )
36  @ValueConstraints(
37      allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = {@AllowedValue(value = "objective", description = "\\*\\*(deprecated)\\*\\* Use 'assessment-objective' instead."), @AllowedValue(value = "assessment", description = "\\*\\*(deprecated)\\*\\* Use 'assessment-method' instead."), @AllowedValue(value = "assessment-objective", description = "The part defines an assessment objective."), @AllowedValue(value = "assessment-method", description = "The part defines an assessment method.")})
38  )
39  @AssemblyConstraints(
40      hasCardinality = {
41          @HasCardinality(level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('objective','assessment-objective')]", maxOccurs = 1),
42          @HasCardinality(level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('assessment','assessment-method')]/prop[has-oscal-namespace(('http://csrc.nist.gov/ns/oscal','http://csrc.nist.gov/ns/rmf')) and @name='method']", minOccurs = 1, maxOccurs = 1),
43          @HasCardinality(level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('assessment','assessment-method')]/part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('objects','assessment-objects')]", minOccurs = 1, maxOccurs = 1),
44          @HasCardinality(level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('objective','assessment-objective')]/prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name='method-id']", minOccurs = 1)
45      }
46  )
47  public class LocalObjective {
48    @BoundFlag(
49        formalName = "Control Identifier Reference",
50        description = "A reference to a control with a corresponding `id` value. When referencing an externally defined `control`, the `Control Identifier Reference` must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).",
51        useName = "control-id",
52        required = true,
53        typeAdapter = TokenAdapter.class,
54        remarks = "The specified `control-id` must be a valid value within the baseline identified by the target system's SSP via the `import-profile` statement."
55    )
56    private String _controlId;
57  
58    /**
59     * "A human-readable description of this control objective."
60     */
61    @BoundField(
62        formalName = "Objective Description",
63        description = "A human-readable description of this control objective.",
64        useName = "description"
65    )
66    @BoundFieldValue(
67        typeAdapter = MarkupMultilineAdapter.class
68    )
69    private MarkupMultiline _description;
70  
71    @BoundAssembly(
72        formalName = "Property",
73        description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
74        useName = "prop",
75        maxOccurs = -1
76    )
77    @GroupAs(
78        name = "props",
79        inJson = JsonGroupAsBehavior.LIST
80    )
81    private List<Property> _props;
82  
83    @BoundAssembly(
84        formalName = "Link",
85        description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
86        useName = "link",
87        maxOccurs = -1
88    )
89    @GroupAs(
90        name = "links",
91        inJson = JsonGroupAsBehavior.LIST
92    )
93    private List<Link> _links;
94  
95    @BoundAssembly(
96        formalName = "Part",
97        description = "An annotated, markup-based textual element of a control's or catalog group's definition, or a child of another part.",
98        useName = "part",
99        minOccurs = 1,
100       maxOccurs = -1
101   )
102   @GroupAs(
103       name = "parts",
104       inJson = JsonGroupAsBehavior.LIST
105   )
106   private List<ControlPart> _parts;
107 
108   @BoundField(
109       formalName = "Remarks",
110       description = "Additional commentary about the containing object.",
111       useName = "remarks"
112   )
113   @BoundFieldValue(
114       typeAdapter = MarkupMultilineAdapter.class
115   )
116   private MarkupMultiline _remarks;
117 
118   public LocalObjective() {
119   }
120 
121   public String getControlId() {
122     return _controlId;
123   }
124 
125   public void setControlId(String value) {
126     _controlId = value;
127   }
128 
129   public MarkupMultiline getDescription() {
130     return _description;
131   }
132 
133   public void setDescription(MarkupMultiline value) {
134     _description = value;
135   }
136 
137   public List<Property> getProps() {
138     return _props;
139   }
140 
141   public void setProps(List<Property> value) {
142     _props = value;
143   }
144 
145   /**
146    * Add a new {@link Property} item to the underlying collection.
147    * @param item the item to add
148    * @return {@code true}
149    */
150   public boolean addProp(Property item) {
151     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
152     if (_props == null) {
153       _props = new LinkedList<>();
154     }
155     return _props.add(value);
156   }
157 
158   /**
159    * Remove the first matching {@link Property} item from the underlying collection.
160    * @param item the item to remove
161    * @return {@code true} if the item was removed or {@code false} otherwise
162    */
163   public boolean removeProp(Property item) {
164     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
165     return _props == null ? false : _props.remove(value);
166   }
167 
168   public List<Link> getLinks() {
169     return _links;
170   }
171 
172   public void setLinks(List<Link> value) {
173     _links = value;
174   }
175 
176   /**
177    * Add a new {@link Link} item to the underlying collection.
178    * @param item the item to add
179    * @return {@code true}
180    */
181   public boolean addLink(Link item) {
182     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
183     if (_links == null) {
184       _links = new LinkedList<>();
185     }
186     return _links.add(value);
187   }
188 
189   /**
190    * Remove the first matching {@link Link} item from the underlying collection.
191    * @param item the item to remove
192    * @return {@code true} if the item was removed or {@code false} otherwise
193    */
194   public boolean removeLink(Link item) {
195     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
196     return _links == null ? false : _links.remove(value);
197   }
198 
199   public List<ControlPart> getParts() {
200     return _parts;
201   }
202 
203   public void setParts(List<ControlPart> value) {
204     _parts = value;
205   }
206 
207   /**
208    * Add a new {@link ControlPart} item to the underlying collection.
209    * @param item the item to add
210    * @return {@code true}
211    */
212   public boolean addPart(ControlPart item) {
213     ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
214     if (_parts == null) {
215       _parts = new LinkedList<>();
216     }
217     return _parts.add(value);
218   }
219 
220   /**
221    * Remove the first matching {@link ControlPart} item from the underlying collection.
222    * @param item the item to remove
223    * @return {@code true} if the item was removed or {@code false} otherwise
224    */
225   public boolean removePart(ControlPart item) {
226     ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
227     return _parts == null ? false : _parts.remove(value);
228   }
229 
230   public MarkupMultiline getRemarks() {
231     return _remarks;
232   }
233 
234   public void setRemarks(MarkupMultiline value) {
235     _remarks = value;
236   }
237 
238   @Override
239   public String toString() {
240     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
241   }
242 }