001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter; 004import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; 005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter; 006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; 007import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter; 008import gov.nist.secauto.metaschema.core.model.IBoundObject; 009import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 010import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; 011import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; 012import gov.nist.secauto.metaschema.core.util.ObjectUtils; 013import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue; 014import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues; 015import gov.nist.secauto.metaschema.databind.model.annotations.AssemblyConstraints; 016import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly; 017import gov.nist.secauto.metaschema.databind.model.annotations.BoundField; 018import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 019import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs; 020import gov.nist.secauto.metaschema.databind.model.annotations.HasCardinality; 021import gov.nist.secauto.metaschema.databind.model.annotations.IsUnique; 022import gov.nist.secauto.metaschema.databind.model.annotations.KeyField; 023import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 024import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints; 025import java.lang.Override; 026import java.lang.String; 027import java.util.LinkedList; 028import java.util.List; 029import java.util.UUID; 030import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 031import org.apache.commons.lang3.builder.ToStringStyle; 032 033/** 034 * Identifies an assessment or related process that can be performed. In the assessment plan, this is an intended activity which may be associated with an assessment task. In the assessment results, this an activity that was actually performed as part of an assessment. 035 */ 036@MetaschemaAssembly( 037 formalName = "Activity", 038 description = "Identifies an assessment or related process that can be performed. In the assessment plan, this is an intended activity which may be associated with an assessment task. In the assessment results, this an activity that was actually performed as part of an assessment.", 039 name = "activity", 040 moduleClass = OscalAssessmentCommonModule.class, 041 valueConstraints = @ValueConstraints(allowedValues = {@AllowedValues(level = IConstraint.Level.ERROR, target = "prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = @AllowedValue(value = "method", description = "The assessment method to use. This typically appears on parts with the name \"assessment\".")), @AllowedValues(level = IConstraint.Level.ERROR, target = "prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name='method']/@value", values = {@AllowedValue(value = "INTERVIEW", description = "The process of holding discussions with individuals or groups of individuals within an organization to once again, facilitate assessor understanding, achieve clarification, or obtain evidence."), @AllowedValue(value = "EXAMINE", description = "The process of reviewing, inspecting, observing, studying, or analyzing one or more assessment objects (i.e., specifications, mechanisms, or activities)."), @AllowedValue(value = "TEST", description = "The process of exercising one or more assessment objects (i.e., activities or mechanisms) under specified conditions to compare actual with expected behavior.")})}), 042 modelConstraints = @AssemblyConstraints(unique = @IsUnique(id = "unique-activity-responsible-role", level = IConstraint.Level.ERROR, target = "responsible-role", keyFields = @KeyField(target = "@role-id"), remarks = "Since `responsible-role` associates multiple `party-uuid` entries with a single `role-id`, each role-id must be referenced only once."), cardinality = @HasCardinality(level = IConstraint.Level.ERROR, target = "prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name='method']", minOccurs = 1)) 043) 044public class Activity implements IBoundObject { 045 private final IMetaschemaData __metaschemaData; 046 047 /** 048 * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented\">machine-oriented</a>, <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique\">globally unique</a> identifier with <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance\">cross-instance</a> scope that can be used to reference this assessment activity elsewhere in <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#scope\">this or other OSCAL instances</a>. The locally defined <em>UUID</em> of the <code>activity</code> can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#consistency\">per-subject</a>, which means it should be consistently used to identify the same subject across revisions of the document." 049 */ 050 @BoundFlag( 051 formalName = "Assessment Activity Universally Unique Identifier", 052 description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented), [globally unique](https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique) identifier with [cross-instance](https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance) scope that can be used to reference this assessment activity elsewhere in [this or other OSCAL instances](https://pages.nist.gov/OSCAL/concepts/identifier-use/#scope). The locally defined *UUID* of the `activity` can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned [per-subject](https://pages.nist.gov/OSCAL/concepts/identifier-use/#consistency), which means it should be consistently used to identify the same subject across revisions of the document.", 053 name = "uuid", 054 required = true, 055 typeAdapter = UuidAdapter.class 056 ) 057 private UUID _uuid; 058 059 @BoundField( 060 formalName = "Included Activity Title", 061 description = "The title for this included activity.", 062 useName = "title", 063 typeAdapter = MarkupLineAdapter.class 064 ) 065 private MarkupLine _title; 066 067 @BoundField( 068 formalName = "Included Activity Description", 069 description = "A human-readable description of this included activity.", 070 useName = "description", 071 minOccurs = 1, 072 typeAdapter = MarkupMultilineAdapter.class 073 ) 074 private MarkupMultiline _description; 075 076 @BoundAssembly( 077 formalName = "Property", 078 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 079 useName = "prop", 080 maxOccurs = -1, 081 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 082 ) 083 private List<Property> _props; 084 085 @BoundAssembly( 086 formalName = "Link", 087 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 088 useName = "link", 089 maxOccurs = -1, 090 groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST) 091 ) 092 private List<Link> _links; 093 094 @BoundAssembly( 095 formalName = "Step", 096 description = "Identifies an individual step in a series of steps related to an activity, such as an assessment test or examination procedure.", 097 useName = "step", 098 maxOccurs = -1, 099 groupAs = @GroupAs(name = "steps", inJson = JsonGroupAsBehavior.LIST) 100 ) 101 private List<Step> _steps; 102 103 @BoundAssembly( 104 formalName = "Reviewed Controls and Control Objectives", 105 description = "Identifies the controls being assessed and their control objectives.", 106 useName = "related-controls", 107 remarks = "This can be optionally used to define the set of controls and control objectives that are assessed or remediated by this activity." 108 ) 109 private ReviewedControls _relatedControls; 110 111 @BoundAssembly( 112 formalName = "Responsible Role", 113 description = "A reference to a role with responsibility for performing a function relative to the containing object, optionally associated with a set of persons and/or organizations that perform that role.", 114 useName = "responsible-role", 115 remarks = "Since `responsible-role` associates multiple `party-uuid` entries with a single `role-id`, each role-id must be referenced only once.", 116 maxOccurs = -1, 117 groupAs = @GroupAs(name = "responsible-roles", inJson = JsonGroupAsBehavior.LIST) 118 ) 119 private List<ResponsibleRole> _responsibleRoles; 120 121 @BoundField( 122 formalName = "Remarks", 123 description = "Additional commentary about the containing object.", 124 useName = "remarks", 125 typeAdapter = MarkupMultilineAdapter.class 126 ) 127 private MarkupMultiline _remarks; 128 129 public Activity() { 130 this(null); 131 } 132 133 public Activity(IMetaschemaData data) { 134 this.__metaschemaData = data; 135 } 136 137 @Override 138 public IMetaschemaData getMetaschemaData() { 139 return __metaschemaData; 140 } 141 142 public UUID getUuid() { 143 return _uuid; 144 } 145 146 public void setUuid(UUID value) { 147 _uuid = value; 148 } 149 150 public MarkupLine getTitle() { 151 return _title; 152 } 153 154 public void setTitle(MarkupLine value) { 155 _title = value; 156 } 157 158 public MarkupMultiline getDescription() { 159 return _description; 160 } 161 162 public void setDescription(MarkupMultiline value) { 163 _description = value; 164 } 165 166 public List<Property> getProps() { 167 return _props; 168 } 169 170 public void setProps(List<Property> value) { 171 _props = value; 172 } 173 174 /** 175 * Add a new {@link Property} item to the underlying collection. 176 * @param item the item to add 177 * @return {@code true} 178 */ 179 public boolean addProp(Property item) { 180 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 181 if (_props == null) { 182 _props = new LinkedList<>(); 183 } 184 return _props.add(value); 185 } 186 187 /** 188 * Remove the first matching {@link Property} item from the underlying collection. 189 * @param item the item to remove 190 * @return {@code true} if the item was removed or {@code false} otherwise 191 */ 192 public boolean removeProp(Property item) { 193 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 194 return _props != null && _props.remove(value); 195 } 196 197 public List<Link> getLinks() { 198 return _links; 199 } 200 201 public void setLinks(List<Link> value) { 202 _links = value; 203 } 204 205 /** 206 * Add a new {@link Link} item to the underlying collection. 207 * @param item the item to add 208 * @return {@code true} 209 */ 210 public boolean addLink(Link item) { 211 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 212 if (_links == null) { 213 _links = new LinkedList<>(); 214 } 215 return _links.add(value); 216 } 217 218 /** 219 * Remove the first matching {@link Link} item from the underlying collection. 220 * @param item the item to remove 221 * @return {@code true} if the item was removed or {@code false} otherwise 222 */ 223 public boolean removeLink(Link item) { 224 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 225 return _links != null && _links.remove(value); 226 } 227 228 public List<Step> getSteps() { 229 return _steps; 230 } 231 232 public void setSteps(List<Step> value) { 233 _steps = value; 234 } 235 236 /** 237 * Add a new {@link Step} item to the underlying collection. 238 * @param item the item to add 239 * @return {@code true} 240 */ 241 public boolean addStep(Step item) { 242 Step value = ObjectUtils.requireNonNull(item,"item cannot be null"); 243 if (_steps == null) { 244 _steps = new LinkedList<>(); 245 } 246 return _steps.add(value); 247 } 248 249 /** 250 * Remove the first matching {@link Step} item from the underlying collection. 251 * @param item the item to remove 252 * @return {@code true} if the item was removed or {@code false} otherwise 253 */ 254 public boolean removeStep(Step item) { 255 Step value = ObjectUtils.requireNonNull(item,"item cannot be null"); 256 return _steps != null && _steps.remove(value); 257 } 258 259 public ReviewedControls getRelatedControls() { 260 return _relatedControls; 261 } 262 263 public void setRelatedControls(ReviewedControls value) { 264 _relatedControls = value; 265 } 266 267 public List<ResponsibleRole> getResponsibleRoles() { 268 return _responsibleRoles; 269 } 270 271 public void setResponsibleRoles(List<ResponsibleRole> value) { 272 _responsibleRoles = value; 273 } 274 275 /** 276 * Add a new {@link ResponsibleRole} item to the underlying collection. 277 * @param item the item to add 278 * @return {@code true} 279 */ 280 public boolean addResponsibleRole(ResponsibleRole item) { 281 ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null"); 282 if (_responsibleRoles == null) { 283 _responsibleRoles = new LinkedList<>(); 284 } 285 return _responsibleRoles.add(value); 286 } 287 288 /** 289 * Remove the first matching {@link ResponsibleRole} item from the underlying collection. 290 * @param item the item to remove 291 * @return {@code true} if the item was removed or {@code false} otherwise 292 */ 293 public boolean removeResponsibleRole(ResponsibleRole item) { 294 ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null"); 295 return _responsibleRoles != null && _responsibleRoles.remove(value); 296 } 297 298 public MarkupMultiline getRemarks() { 299 return _remarks; 300 } 301 302 public void setRemarks(MarkupMultiline value) { 303 _remarks = value; 304 } 305 306 @Override 307 public String toString() { 308 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 309 } 310 311 /** 312 * Identifies an individual step in a series of steps related to an activity, such as an assessment test or examination procedure. 313 */ 314 @MetaschemaAssembly( 315 formalName = "Step", 316 description = "Identifies an individual step in a series of steps related to an activity, such as an assessment test or examination procedure.", 317 name = "step", 318 moduleClass = OscalAssessmentCommonModule.class, 319 modelConstraints = @AssemblyConstraints(unique = @IsUnique(id = "unique-step-responsible-role", level = IConstraint.Level.ERROR, target = "responsible-role", keyFields = @KeyField(target = "@role-id"), remarks = "Since multiple `party-uuid` entries can be provided, each role-id must be referenced only once.")) 320 ) 321 public static class Step implements IBoundObject { 322 private final IMetaschemaData __metaschemaData; 323 324 /** 325 * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented\">machine-oriented</a>, <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique\">globally unique</a> identifier with <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance\">cross-instance</a> scope that can be used to reference this step elsewhere in <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#scope\">this or other OSCAL instances</a>. The locally defined <em>UUID</em> of the <code>step</code> (in a series of steps) can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#consistency\">per-subject</a>, which means it should be consistently used to identify the same subject across revisions of the document." 326 */ 327 @BoundFlag( 328 formalName = "Step Universally Unique Identifier", 329 description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented), [globally unique](https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique) identifier with [cross-instance](https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance) scope that can be used to reference this step elsewhere in [this or other OSCAL instances](https://pages.nist.gov/OSCAL/concepts/identifier-use/#scope). The locally defined *UUID* of the `step` (in a series of steps) can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned [per-subject](https://pages.nist.gov/OSCAL/concepts/identifier-use/#consistency), which means it should be consistently used to identify the same subject across revisions of the document.", 330 name = "uuid", 331 required = true, 332 typeAdapter = UuidAdapter.class 333 ) 334 private UUID _uuid; 335 336 @BoundField( 337 formalName = "Step Title", 338 description = "The title for this step.", 339 useName = "title", 340 typeAdapter = MarkupLineAdapter.class 341 ) 342 private MarkupLine _title; 343 344 @BoundField( 345 formalName = "Step Description", 346 description = "A human-readable description of this step.", 347 useName = "description", 348 minOccurs = 1, 349 typeAdapter = MarkupMultilineAdapter.class 350 ) 351 private MarkupMultiline _description; 352 353 @BoundAssembly( 354 formalName = "Property", 355 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 356 useName = "prop", 357 maxOccurs = -1, 358 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 359 ) 360 private List<Property> _props; 361 362 @BoundAssembly( 363 formalName = "Link", 364 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 365 useName = "link", 366 maxOccurs = -1, 367 groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST) 368 ) 369 private List<Link> _links; 370 371 @BoundAssembly( 372 formalName = "Reviewed Controls and Control Objectives", 373 description = "Identifies the controls being assessed and their control objectives.", 374 useName = "reviewed-controls", 375 remarks = "This can be optionally used to define the set of controls and control objectives that are assessed by this step." 376 ) 377 private ReviewedControls _reviewedControls; 378 379 @BoundAssembly( 380 formalName = "Responsible Role", 381 description = "A reference to a role with responsibility for performing a function relative to the containing object, optionally associated with a set of persons and/or organizations that perform that role.", 382 useName = "responsible-role", 383 remarks = "Identifies the roles, and optionally the parties, associated with this step that is part of an assessment activity.", 384 maxOccurs = -1, 385 groupAs = @GroupAs(name = "responsible-roles", inJson = JsonGroupAsBehavior.LIST) 386 ) 387 private List<ResponsibleRole> _responsibleRoles; 388 389 @BoundField( 390 formalName = "Remarks", 391 description = "Additional commentary about the containing object.", 392 useName = "remarks", 393 typeAdapter = MarkupMultilineAdapter.class 394 ) 395 private MarkupMultiline _remarks; 396 397 public Step() { 398 this(null); 399 } 400 401 public Step(IMetaschemaData data) { 402 this.__metaschemaData = data; 403 } 404 405 @Override 406 public IMetaschemaData getMetaschemaData() { 407 return __metaschemaData; 408 } 409 410 public UUID getUuid() { 411 return _uuid; 412 } 413 414 public void setUuid(UUID value) { 415 _uuid = value; 416 } 417 418 public MarkupLine getTitle() { 419 return _title; 420 } 421 422 public void setTitle(MarkupLine value) { 423 _title = value; 424 } 425 426 public MarkupMultiline getDescription() { 427 return _description; 428 } 429 430 public void setDescription(MarkupMultiline value) { 431 _description = value; 432 } 433 434 public List<Property> getProps() { 435 return _props; 436 } 437 438 public void setProps(List<Property> value) { 439 _props = value; 440 } 441 442 /** 443 * Add a new {@link Property} item to the underlying collection. 444 * @param item the item to add 445 * @return {@code true} 446 */ 447 public boolean addProp(Property item) { 448 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 449 if (_props == null) { 450 _props = new LinkedList<>(); 451 } 452 return _props.add(value); 453 } 454 455 /** 456 * Remove the first matching {@link Property} item from the underlying collection. 457 * @param item the item to remove 458 * @return {@code true} if the item was removed or {@code false} otherwise 459 */ 460 public boolean removeProp(Property item) { 461 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 462 return _props != null && _props.remove(value); 463 } 464 465 public List<Link> getLinks() { 466 return _links; 467 } 468 469 public void setLinks(List<Link> value) { 470 _links = value; 471 } 472 473 /** 474 * Add a new {@link Link} item to the underlying collection. 475 * @param item the item to add 476 * @return {@code true} 477 */ 478 public boolean addLink(Link item) { 479 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 480 if (_links == null) { 481 _links = new LinkedList<>(); 482 } 483 return _links.add(value); 484 } 485 486 /** 487 * Remove the first matching {@link Link} item from the underlying collection. 488 * @param item the item to remove 489 * @return {@code true} if the item was removed or {@code false} otherwise 490 */ 491 public boolean removeLink(Link item) { 492 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 493 return _links != null && _links.remove(value); 494 } 495 496 public ReviewedControls getReviewedControls() { 497 return _reviewedControls; 498 } 499 500 public void setReviewedControls(ReviewedControls value) { 501 _reviewedControls = value; 502 } 503 504 public List<ResponsibleRole> getResponsibleRoles() { 505 return _responsibleRoles; 506 } 507 508 public void setResponsibleRoles(List<ResponsibleRole> value) { 509 _responsibleRoles = value; 510 } 511 512 /** 513 * Add a new {@link ResponsibleRole} item to the underlying collection. 514 * @param item the item to add 515 * @return {@code true} 516 */ 517 public boolean addResponsibleRole(ResponsibleRole item) { 518 ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null"); 519 if (_responsibleRoles == null) { 520 _responsibleRoles = new LinkedList<>(); 521 } 522 return _responsibleRoles.add(value); 523 } 524 525 /** 526 * Remove the first matching {@link ResponsibleRole} item from the underlying collection. 527 * @param item the item to remove 528 * @return {@code true} if the item was removed or {@code false} otherwise 529 */ 530 public boolean removeResponsibleRole(ResponsibleRole item) { 531 ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null"); 532 return _responsibleRoles != null && _responsibleRoles.remove(value); 533 } 534 535 public MarkupMultiline getRemarks() { 536 return _remarks; 537 } 538 539 public void setRemarks(MarkupMultiline value) { 540 _remarks = value; 541 } 542 543 @Override 544 public String toString() { 545 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 546 } 547 } 548}