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.BoundAssembly;
6 import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
7 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
8 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
9 import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
10 import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
11 import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
12 import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
13 import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
14 import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
15 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLine;
16 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLineAdapter;
17 import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
18 import gov.nist.secauto.oscal.lib.model.control.catalog.AbstractCatalogGroup;
19 import java.lang.Override;
20 import java.lang.String;
21 import java.util.LinkedList;
22 import java.util.List;
23 import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
24 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
25
26
27
28
29 @MetaschemaAssembly(
30 formalName = "Control Group",
31 description = "A group of controls, or of groups of controls.",
32 name = "group",
33 metaschema = OscalCatalogMetaschema.class,
34 remarks = "Catalogs can use the catalog `group` construct to organize related controls into a single grouping, such as a family of controls or other logical organizational structure.\n"
35 + "\n"
36 + "A `group` may have its own properties, statements, parameters, and references, which are inherited by all controls of that are a member of the group."
37 )
38 @ValueConstraints(
39 allowedValues = {
40 @AllowedValues(level = IConstraint.Level.ERROR, target = "prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = {@AllowedValue(value = "label", description = "A human-readable label for the parent context, which may be rendered in place of the actual identifier for some use cases."), @AllowedValue(value = "sort-id", description = "An alternative identifier, whose value is easily sortable among other such values in the document."), @AllowedValue(value = "alt-identifier", description = "An alternate or aliased identifier for the parent context.")}),
41 @AllowedValues(level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = {@AllowedValue(value = "overview", description = "An introduction to a control or a group of controls."), @AllowedValue(value = "instruction", description = "Information providing directions for a control or a group of controls.")})
42 }
43 )
44 public class CatalogGroup extends AbstractCatalogGroup {
45 @BoundFlag(
46 formalName = "Group Identifier",
47 description = "Identifies the group for the purpose of cross-linking within the defining instance or from other instances that reference the catalog.",
48 useName = "id",
49 typeAdapter = TokenAdapter.class
50 )
51 private String _id;
52
53 @BoundFlag(
54 formalName = "Group Class",
55 description = "A textual label that provides a sub-type or characterization of the group.",
56 useName = "class",
57 typeAdapter = TokenAdapter.class,
58 remarks = "A `class` can be used in validation rules to express extra constraints over named items of a specific `class` value.\n"
59 + "\n"
60 + "A `class` can also be used in an OSCAL profile as a means to target an alteration to control content."
61 )
62 private String _clazz;
63
64
65
66
67 @BoundField(
68 formalName = "Group Title",
69 description = "A name given to the group, which may be used by a tool for display and navigation.",
70 useName = "title",
71 minOccurs = 1
72 )
73 @BoundFieldValue(
74 typeAdapter = MarkupLineAdapter.class
75 )
76 private MarkupLine _title;
77
78 @BoundAssembly(
79 formalName = "Parameter",
80 description = "Parameters provide a mechanism for the dynamic assignment of value(s) in a control.",
81 useName = "param",
82 maxOccurs = -1
83 )
84 @GroupAs(
85 name = "params",
86 inJson = JsonGroupAsBehavior.LIST
87 )
88 private List<Parameter> _params;
89
90 @BoundAssembly(
91 formalName = "Property",
92 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
93 useName = "prop",
94 maxOccurs = -1
95 )
96 @GroupAs(
97 name = "props",
98 inJson = JsonGroupAsBehavior.LIST
99 )
100 private List<Property> _props;
101
102 @BoundAssembly(
103 formalName = "Link",
104 description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
105 useName = "link",
106 maxOccurs = -1
107 )
108 @GroupAs(
109 name = "links",
110 inJson = JsonGroupAsBehavior.LIST
111 )
112 private List<Link> _links;
113
114 @BoundAssembly(
115 formalName = "Part",
116 description = "An annotated, markup-based textual element of a control's or catalog group's definition, or a child of another part.",
117 useName = "part",
118 maxOccurs = -1
119 )
120 @GroupAs(
121 name = "parts",
122 inJson = JsonGroupAsBehavior.LIST
123 )
124 private List<ControlPart> _parts;
125
126 @BoundAssembly(
127 formalName = "Control Group",
128 description = "A group of controls, or of groups of controls.",
129 useName = "group",
130 maxOccurs = -1
131 )
132 @GroupAs(
133 name = "groups",
134 inJson = JsonGroupAsBehavior.LIST
135 )
136 private List<CatalogGroup> _groups;
137
138 @BoundAssembly(
139 formalName = "Control",
140 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.",
141 useName = "control",
142 maxOccurs = -1
143 )
144 @GroupAs(
145 name = "controls",
146 inJson = JsonGroupAsBehavior.LIST
147 )
148 private List<Control> _controls;
149
150 public CatalogGroup() {
151 }
152
153 public String getId() {
154 return _id;
155 }
156
157 public void setId(String value) {
158 _id = value;
159 }
160
161 public String getClazz() {
162 return _clazz;
163 }
164
165 public void setClazz(String value) {
166 _clazz = value;
167 }
168
169 public MarkupLine getTitle() {
170 return _title;
171 }
172
173 public void setTitle(MarkupLine value) {
174 _title = value;
175 }
176
177 public List<Parameter> getParams() {
178 return _params;
179 }
180
181 public void setParams(List<Parameter> value) {
182 _params = value;
183 }
184
185
186
187
188
189
190 public boolean addParam(Parameter item) {
191 Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
192 if (_params == null) {
193 _params = new LinkedList<>();
194 }
195 return _params.add(value);
196 }
197
198
199
200
201
202
203 public boolean removeParam(Parameter item) {
204 Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
205 return _params == null ? false : _params.remove(value);
206 }
207
208 public List<Property> getProps() {
209 return _props;
210 }
211
212 public void setProps(List<Property> value) {
213 _props = value;
214 }
215
216
217
218
219
220
221 public boolean addProp(Property item) {
222 Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
223 if (_props == null) {
224 _props = new LinkedList<>();
225 }
226 return _props.add(value);
227 }
228
229
230
231
232
233
234 public boolean removeProp(Property item) {
235 Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
236 return _props == null ? false : _props.remove(value);
237 }
238
239 public List<Link> getLinks() {
240 return _links;
241 }
242
243 public void setLinks(List<Link> value) {
244 _links = value;
245 }
246
247
248
249
250
251
252 public boolean addLink(Link item) {
253 Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
254 if (_links == null) {
255 _links = new LinkedList<>();
256 }
257 return _links.add(value);
258 }
259
260
261
262
263
264
265 public boolean removeLink(Link item) {
266 Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
267 return _links == null ? false : _links.remove(value);
268 }
269
270 public List<ControlPart> getParts() {
271 return _parts;
272 }
273
274 public void setParts(List<ControlPart> value) {
275 _parts = value;
276 }
277
278
279
280
281
282
283 public boolean addPart(ControlPart item) {
284 ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
285 if (_parts == null) {
286 _parts = new LinkedList<>();
287 }
288 return _parts.add(value);
289 }
290
291
292
293
294
295
296 public boolean removePart(ControlPart item) {
297 ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
298 return _parts == null ? false : _parts.remove(value);
299 }
300
301 public List<CatalogGroup> getGroups() {
302 return _groups;
303 }
304
305 public void setGroups(List<CatalogGroup> value) {
306 _groups = value;
307 }
308
309
310
311
312
313
314 public boolean addGroup(CatalogGroup item) {
315 CatalogGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
316 if (_groups == null) {
317 _groups = new LinkedList<>();
318 }
319 return _groups.add(value);
320 }
321
322
323
324
325
326
327 public boolean removeGroup(CatalogGroup item) {
328 CatalogGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
329 return _groups == null ? false : _groups.remove(value);
330 }
331
332 public List<Control> getControls() {
333 return _controls;
334 }
335
336 public void setControls(List<Control> value) {
337 _controls = value;
338 }
339
340
341
342
343
344
345 public boolean addControl(Control item) {
346 Control value = ObjectUtils.requireNonNull(item,"item cannot be null");
347 if (_controls == null) {
348 _controls = new LinkedList<>();
349 }
350 return _controls.add(value);
351 }
352
353
354
355
356
357
358 public boolean removeControl(Control item) {
359 Control value = ObjectUtils.requireNonNull(item,"item cannot be null");
360 return _controls == null ? false : _controls.remove(value);
361 }
362
363 @Override
364 public String toString() {
365 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
366 }
367 }