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.BoundFlag;
8 import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
9 import gov.nist.secauto.metaschema.binding.model.annotations.Index;
10 import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
11 import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
12 import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
13 import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
14 import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
15 import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
16 import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
17 import gov.nist.secauto.oscal.lib.model.control.catalog.AbstractCatalog;
18 import java.lang.Override;
19 import java.lang.String;
20 import java.util.LinkedList;
21 import java.util.List;
22 import java.util.UUID;
23 import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
24 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
25
26
27
28
29 @MetaschemaAssembly(
30 formalName = "Catalog",
31 description = "A structured, [organized collection](https://pages.nist.gov/OSCAL/concepts/terminology/#catalog) of control information.",
32 name = "catalog",
33 metaschema = OscalCatalogMetaschema.class,
34 rootName = "catalog",
35 remarks = "Catalogs may use one or more `group` objects to subdivide the control contents of a catalog."
36 )
37 @ValueConstraints(
38 allowedValues = {
39 @AllowedValues(level = IConstraint.Level.ERROR, target = "metadata/prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = {@AllowedValue(value = "resolution-tool", description = "The tool used to produce a resolved profile."), @AllowedValue(value = "source-profile-uuid", description = "The document-level `uuid` of the source profile from which the catalog was produced by [profile resolution](https://pages.nist.gov/OSCAL/concepts/processing/profile-resolution/).")}),
40 @AllowedValues(level = IConstraint.Level.ERROR, target = "metadata/link/@rel", allowOthers = true, values = {@AllowedValue(value = "source-profile", description = "The profile from which the catalog was produced by [profile resolution](https://pages.nist.gov/OSCAL/concepts/processing/profile-resolution/)."), @AllowedValue(value = "source-profile-uuid", description = "The document-level `uuid` of the profile from which the catalog was produced by [profile resolution](https://pages.nist.gov/OSCAL/concepts/processing/profile-resolution/).")})
41 }
42 )
43 @AssemblyConstraints(
44 index = {
45 @Index(level = IConstraint.Level.ERROR, target = "//part", name = "catalog-parts", keyFields = @KeyField(target = "@id")),
46 @Index(level = IConstraint.Level.ERROR, target = "//prop", name = "catalog-props", keyFields = @KeyField(target = "@uuid")),
47 @Index(level = IConstraint.Level.ERROR, target = "//(control|group|part)", name = "catalog-groups-controls-parts", keyFields = @KeyField(target = "@id")),
48 @Index(level = IConstraint.Level.ERROR, target = "//control", name = "catalog-controls", keyFields = @KeyField(target = "@id")),
49 @Index(level = IConstraint.Level.ERROR, target = "//param", name = "catalog-params", keyFields = @KeyField(target = "@id")),
50 @Index(level = IConstraint.Level.ERROR, target = "//group", name = "catalog-groups", keyFields = @KeyField(target = "@id"))
51 }
52 )
53 public class Catalog extends AbstractCatalog {
54 @BoundFlag(
55 formalName = "Catalog Universally Unique Identifier",
56 description = "Provides a globally unique means to identify a given catalog instance.",
57 useName = "uuid",
58 required = true,
59 typeAdapter = UuidAdapter.class
60 )
61 private UUID _uuid;
62
63 @BoundAssembly(
64 formalName = "Document Metadata",
65 description = "Provides information about the containing document, and defines concepts that are shared across the document.",
66 useName = "metadata",
67 minOccurs = 1
68 )
69 private Metadata _metadata;
70
71 @BoundAssembly(
72 formalName = "Parameter",
73 description = "Parameters provide a mechanism for the dynamic assignment of value(s) in a control.",
74 useName = "param",
75 maxOccurs = -1
76 )
77 @GroupAs(
78 name = "params",
79 inJson = JsonGroupAsBehavior.LIST
80 )
81 private List<Parameter> _params;
82
83 @BoundAssembly(
84 formalName = "Control",
85 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.",
86 useName = "control",
87 maxOccurs = -1
88 )
89 @GroupAs(
90 name = "controls",
91 inJson = JsonGroupAsBehavior.LIST
92 )
93 private List<Control> _controls;
94
95 @BoundAssembly(
96 formalName = "Control Group",
97 description = "A group of controls, or of groups of controls.",
98 useName = "group",
99 maxOccurs = -1
100 )
101 @GroupAs(
102 name = "groups",
103 inJson = JsonGroupAsBehavior.LIST
104 )
105 private List<CatalogGroup> _groups;
106
107 @BoundAssembly(
108 formalName = "Back matter",
109 description = "A collection of resources that may be referenced from within the OSCAL document instance.",
110 useName = "back-matter",
111 remarks = "Back matter including references and resources."
112 )
113 private BackMatter _backMatter;
114
115 public Catalog() {
116 }
117
118 public UUID getUuid() {
119 return _uuid;
120 }
121
122 public void setUuid(UUID value) {
123 _uuid = value;
124 }
125
126 public Metadata getMetadata() {
127 return _metadata;
128 }
129
130 public void setMetadata(Metadata value) {
131 _metadata = value;
132 }
133
134 public List<Parameter> getParams() {
135 return _params;
136 }
137
138 public void setParams(List<Parameter> value) {
139 _params = value;
140 }
141
142
143
144
145
146
147 public boolean addParam(Parameter item) {
148 Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
149 if (_params == null) {
150 _params = new LinkedList<>();
151 }
152 return _params.add(value);
153 }
154
155
156
157
158
159
160 public boolean removeParam(Parameter item) {
161 Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
162 return _params == null ? false : _params.remove(value);
163 }
164
165 public List<Control> getControls() {
166 return _controls;
167 }
168
169 public void setControls(List<Control> value) {
170 _controls = value;
171 }
172
173
174
175
176
177
178 public boolean addControl(Control item) {
179 Control value = ObjectUtils.requireNonNull(item,"item cannot be null");
180 if (_controls == null) {
181 _controls = new LinkedList<>();
182 }
183 return _controls.add(value);
184 }
185
186
187
188
189
190
191 public boolean removeControl(Control item) {
192 Control value = ObjectUtils.requireNonNull(item,"item cannot be null");
193 return _controls == null ? false : _controls.remove(value);
194 }
195
196 public List<CatalogGroup> getGroups() {
197 return _groups;
198 }
199
200 public void setGroups(List<CatalogGroup> value) {
201 _groups = value;
202 }
203
204
205
206
207
208
209 public boolean addGroup(CatalogGroup item) {
210 CatalogGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
211 if (_groups == null) {
212 _groups = new LinkedList<>();
213 }
214 return _groups.add(value);
215 }
216
217
218
219
220
221
222 public boolean removeGroup(CatalogGroup item) {
223 CatalogGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
224 return _groups == null ? false : _groups.remove(value);
225 }
226
227 public BackMatter getBackMatter() {
228 return _backMatter;
229 }
230
231 public void setBackMatter(BackMatter value) {
232 _backMatter = value;
233 }
234
235 @Override
236 public String toString() {
237 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
238 }
239 }