001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints; 004import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly; 005import gov.nist.secauto.metaschema.binding.model.annotations.BoundField; 006import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue; 007import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag; 008import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 009import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique; 010import gov.nist.secauto.metaschema.binding.model.annotations.KeyField; 011import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 012import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior; 013import gov.nist.secauto.metaschema.model.common.constraint.IConstraint; 014import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter; 015import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline; 016import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter; 017import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 018import java.lang.Override; 019import java.lang.String; 020import java.util.LinkedList; 021import java.util.List; 022import java.util.UUID; 023import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 024import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 025 026/** 027 * Identifies an individual task for which the containing object is a consequence of. 028 */ 029@MetaschemaAssembly( 030 formalName = "Task Reference", 031 description = "Identifies an individual task for which the containing object is a consequence of.", 032 name = "related-task", 033 metaschema = OscalAssessmentCommonMetaschema.class 034) 035@AssemblyConstraints( 036 isUnique = @IsUnique(id = "unique-ssp-related-task-responsible-party", level = IConstraint.Level.ERROR, target = "responsible-party", keyFields = @KeyField(target = "@role-id"), remarks = "Since `responsible-party` associates multiple `party-uuid` entries with a single `role-id`, each role-id must be referenced only once.") 037) 038public class RelatedTask { 039 @BoundFlag( 040 formalName = "Task Universally Unique Identifier Reference", 041 description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a unique task.", 042 useName = "task-uuid", 043 required = true, 044 typeAdapter = UuidAdapter.class 045 ) 046 private UUID _taskUuid; 047 048 @BoundAssembly( 049 formalName = "Property", 050 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 051 useName = "prop", 052 maxOccurs = -1 053 ) 054 @GroupAs( 055 name = "props", 056 inJson = JsonGroupAsBehavior.LIST 057 ) 058 private List<Property> _props; 059 060 @BoundAssembly( 061 formalName = "Link", 062 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 063 useName = "link", 064 maxOccurs = -1 065 ) 066 @GroupAs( 067 name = "links", 068 inJson = JsonGroupAsBehavior.LIST 069 ) 070 private List<Link> _links; 071 072 @BoundAssembly( 073 formalName = "Responsible Party", 074 description = "A reference to a set of persons and/or organizations that have responsibility for performing the referenced role in the context of the containing object.", 075 useName = "responsible-party", 076 maxOccurs = -1, 077 remarks = "Identifies the person or organization responsible for performing a specific role defined by the activity." 078 ) 079 @GroupAs( 080 name = "responsible-parties", 081 inJson = JsonGroupAsBehavior.LIST 082 ) 083 private List<ResponsibleParty> _responsibleParties; 084 085 @BoundAssembly( 086 formalName = "Subject of Assessment", 087 description = "Identifies system elements being assessed, such as components, inventory items, and locations. In the assessment plan, this identifies a planned assessment subject. In the assessment results this is an actual assessment subject, and reflects any changes from the plan. exactly what will be the focus of this assessment. Any subjects not identified in this way are out-of-scope.", 088 useName = "subject", 089 maxOccurs = -1, 090 remarks = "The assessment subjects that the task was performed against." 091 ) 092 @GroupAs( 093 name = "subjects", 094 inJson = JsonGroupAsBehavior.LIST 095 ) 096 private List<AssessmentSubject> _subjects; 097 098 /** 099 * "Used to detail assessment subjects that were identfied by this task." 100 */ 101 @BoundAssembly( 102 formalName = "Identified Subject", 103 description = "Used to detail assessment subjects that were identfied by this task.", 104 useName = "identified-subject" 105 ) 106 private IdentifiedSubject _identifiedSubject; 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 RelatedTask() { 119 } 120 121 public UUID getTaskUuid() { 122 return _taskUuid; 123 } 124 125 public void setTaskUuid(UUID value) { 126 _taskUuid = value; 127 } 128 129 public List<Property> getProps() { 130 return _props; 131 } 132 133 public void setProps(List<Property> value) { 134 _props = value; 135 } 136 137 /** 138 * Add a new {@link Property} item to the underlying collection. 139 * @param item the item to add 140 * @return {@code true} 141 */ 142 public boolean addProp(Property item) { 143 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 144 if (_props == null) { 145 _props = new LinkedList<>(); 146 } 147 return _props.add(value); 148 } 149 150 /** 151 * Remove the first matching {@link Property} item from the underlying collection. 152 * @param item the item to remove 153 * @return {@code true} if the item was removed or {@code false} otherwise 154 */ 155 public boolean removeProp(Property item) { 156 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 157 return _props == null ? false : _props.remove(value); 158 } 159 160 public List<Link> getLinks() { 161 return _links; 162 } 163 164 public void setLinks(List<Link> value) { 165 _links = value; 166 } 167 168 /** 169 * Add a new {@link Link} item to the underlying collection. 170 * @param item the item to add 171 * @return {@code true} 172 */ 173 public boolean addLink(Link item) { 174 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 175 if (_links == null) { 176 _links = new LinkedList<>(); 177 } 178 return _links.add(value); 179 } 180 181 /** 182 * Remove the first matching {@link Link} item from the underlying collection. 183 * @param item the item to remove 184 * @return {@code true} if the item was removed or {@code false} otherwise 185 */ 186 public boolean removeLink(Link item) { 187 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 188 return _links == null ? false : _links.remove(value); 189 } 190 191 public List<ResponsibleParty> getResponsibleParties() { 192 return _responsibleParties; 193 } 194 195 public void setResponsibleParties(List<ResponsibleParty> value) { 196 _responsibleParties = value; 197 } 198 199 /** 200 * Add a new {@link ResponsibleParty} item to the underlying collection. 201 * @param item the item to add 202 * @return {@code true} 203 */ 204 public boolean addResponsibleParty(ResponsibleParty item) { 205 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null"); 206 if (_responsibleParties == null) { 207 _responsibleParties = new LinkedList<>(); 208 } 209 return _responsibleParties.add(value); 210 } 211 212 /** 213 * Remove the first matching {@link ResponsibleParty} item from the underlying collection. 214 * @param item the item to remove 215 * @return {@code true} if the item was removed or {@code false} otherwise 216 */ 217 public boolean removeResponsibleParty(ResponsibleParty item) { 218 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null"); 219 return _responsibleParties == null ? false : _responsibleParties.remove(value); 220 } 221 222 public List<AssessmentSubject> getSubjects() { 223 return _subjects; 224 } 225 226 public void setSubjects(List<AssessmentSubject> value) { 227 _subjects = value; 228 } 229 230 /** 231 * Add a new {@link AssessmentSubject} item to the underlying collection. 232 * @param item the item to add 233 * @return {@code true} 234 */ 235 public boolean addSubject(AssessmentSubject item) { 236 AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null"); 237 if (_subjects == null) { 238 _subjects = new LinkedList<>(); 239 } 240 return _subjects.add(value); 241 } 242 243 /** 244 * Remove the first matching {@link AssessmentSubject} item from the underlying collection. 245 * @param item the item to remove 246 * @return {@code true} if the item was removed or {@code false} otherwise 247 */ 248 public boolean removeSubject(AssessmentSubject item) { 249 AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null"); 250 return _subjects == null ? false : _subjects.remove(value); 251 } 252 253 public IdentifiedSubject getIdentifiedSubject() { 254 return _identifiedSubject; 255 } 256 257 public void setIdentifiedSubject(IdentifiedSubject value) { 258 _identifiedSubject = value; 259 } 260 261 public MarkupMultiline getRemarks() { 262 return _remarks; 263 } 264 265 public void setRemarks(MarkupMultiline value) { 266 _remarks = value; 267 } 268 269 @Override 270 public String toString() { 271 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 272 } 273 274 /** 275 * Used to detail assessment subjects that were identfied by this task. 276 */ 277 @MetaschemaAssembly( 278 formalName = "Identified Subject", 279 description = "Used to detail assessment subjects that were identfied by this task.", 280 name = "identified-subject", 281 metaschema = OscalAssessmentCommonMetaschema.class 282 ) 283 public static class IdentifiedSubject { 284 @BoundFlag( 285 formalName = "Assessment Subject Placeholder Universally Unique Identifier Reference", 286 description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a unique assessment subject placeholder defined by this task.", 287 useName = "subject-placeholder-uuid", 288 required = true, 289 typeAdapter = UuidAdapter.class 290 ) 291 private UUID _subjectPlaceholderUuid; 292 293 @BoundAssembly( 294 formalName = "Subject of Assessment", 295 description = "Identifies system elements being assessed, such as components, inventory items, and locations. In the assessment plan, this identifies a planned assessment subject. In the assessment results this is an actual assessment subject, and reflects any changes from the plan. exactly what will be the focus of this assessment. Any subjects not identified in this way are out-of-scope.", 296 useName = "subject", 297 minOccurs = 1, 298 maxOccurs = -1, 299 remarks = "The assessment subjects that the task identified, which will be used by another task through a subject-placeholder reference. Such a task will \"consume\" these subjects." 300 ) 301 @GroupAs( 302 name = "subjects", 303 inJson = JsonGroupAsBehavior.LIST 304 ) 305 private List<AssessmentSubject> _subjects; 306 307 public IdentifiedSubject() { 308 } 309 310 public UUID getSubjectPlaceholderUuid() { 311 return _subjectPlaceholderUuid; 312 } 313 314 public void setSubjectPlaceholderUuid(UUID value) { 315 _subjectPlaceholderUuid = value; 316 } 317 318 public List<AssessmentSubject> getSubjects() { 319 return _subjects; 320 } 321 322 public void setSubjects(List<AssessmentSubject> value) { 323 _subjects = value; 324 } 325 326 /** 327 * Add a new {@link AssessmentSubject} item to the underlying collection. 328 * @param item the item to add 329 * @return {@code true} 330 */ 331 public boolean addSubject(AssessmentSubject item) { 332 AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null"); 333 if (_subjects == null) { 334 _subjects = new LinkedList<>(); 335 } 336 return _subjects.add(value); 337 } 338 339 /** 340 * Remove the first matching {@link AssessmentSubject} item from the underlying collection. 341 * @param item the item to remove 342 * @return {@code true} if the item was removed or {@code false} otherwise 343 */ 344 public boolean removeSubject(AssessmentSubject item) { 345 AssessmentSubject value = ObjectUtils.requireNonNull(item,"item cannot be null"); 346 return _subjects == null ? false : _subjects.remove(value); 347 } 348 349 @Override 350 public String toString() { 351 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 352 } 353 } 354}