001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter; 004import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; 005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter; 006import gov.nist.secauto.metaschema.core.model.IBoundObject; 007import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 008import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; 009import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; 010import gov.nist.secauto.metaschema.core.util.ObjectUtils; 011import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue; 012import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues; 013import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly; 014import gov.nist.secauto.metaschema.databind.model.annotations.BoundField; 015import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 016import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs; 017import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 018import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints; 019import java.lang.Override; 020import java.lang.String; 021import java.util.LinkedList; 022import java.util.List; 023import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 024import org.apache.commons.lang3.builder.ToStringStyle; 025 026/** 027 * 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. 028 */ 029@MetaschemaAssembly( 030 formalName = "Subject of Assessment", 031 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.", 032 name = "assessment-subject", 033 moduleClass = OscalAssessmentCommonModule.class, 034 remarks = "Processing of an include/exclude pair starts with processing the include, then removing matching entries in the exclude." 035) 036public class AssessmentSubject implements IBoundObject { 037 private final IMetaschemaData __metaschemaData; 038 039 /** 040 * "Indicates the type of assessment subject, such as a component, inventory, item, location, or party represented by this selection statement." 041 */ 042 @BoundFlag( 043 formalName = "Subject Type", 044 description = "Indicates the type of assessment subject, such as a component, inventory, item, location, or party represented by this selection statement.", 045 name = "type", 046 required = true, 047 typeAdapter = TokenAdapter.class, 048 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "component", description = "The referenced assessment subject is a component defined in the SSP, or in the `local-definitions` of an Assessment Plan or Assessment Results."), @AllowedValue(value = "inventory-item", description = "The referenced assessment subject is a inventory item defined in the SSP, or in the `local-definitions` of an Assessment Plan or Assessment Results."), @AllowedValue(value = "location", description = "The referenced assessment subject is a `location` defined in the `metadata` of the SSP, Assessment Plan, or Assessment Results."), @AllowedValue(value = "party", description = "The referenced assessment subject is a person or team to interview, who is defined as a `party` in the `metadata` of the SSP, Assessment Plan, or Assessment Results."), @AllowedValue(value = "user", description = "The referenced assessment subject is a `user` defined in the SSP, or in the `local-definitions` of an Assessment Plan or Assessment Results.")})) 049 ) 050 private String _type; 051 052 @BoundField( 053 formalName = "Include Subjects Description", 054 description = "A human-readable description of the collection of subjects being included in this assessment.", 055 useName = "description", 056 typeAdapter = MarkupMultilineAdapter.class 057 ) 058 private MarkupMultiline _description; 059 060 @BoundAssembly( 061 formalName = "Property", 062 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 063 useName = "prop", 064 maxOccurs = -1, 065 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 066 ) 067 private List<Property> _props; 068 069 @BoundAssembly( 070 formalName = "Link", 071 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 072 useName = "link", 073 maxOccurs = -1, 074 groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST) 075 ) 076 private List<Link> _links; 077 078 @BoundAssembly( 079 formalName = "Include All", 080 description = "Include all controls from the imported catalog or profile resources.", 081 useName = "include-all", 082 minOccurs = 1 083 ) 084 private IncludeAll _includeAll; 085 086 @BoundAssembly( 087 formalName = "Select Assessment Subject", 088 description = "Identifies a set of assessment subjects to include/exclude by UUID.", 089 useName = "include-subject", 090 minOccurs = 1, 091 maxOccurs = -1, 092 groupAs = @GroupAs(name = "include-subjects", inJson = JsonGroupAsBehavior.LIST) 093 ) 094 private List<SelectSubjectById> _includeSubjects; 095 096 @BoundAssembly( 097 formalName = "Select Assessment Subject", 098 description = "Identifies a set of assessment subjects to include/exclude by UUID.", 099 useName = "exclude-subject", 100 maxOccurs = -1, 101 groupAs = @GroupAs(name = "exclude-subjects", inJson = JsonGroupAsBehavior.LIST) 102 ) 103 private List<SelectSubjectById> _excludeSubjects; 104 105 @BoundField( 106 formalName = "Remarks", 107 description = "Additional commentary about the containing object.", 108 useName = "remarks", 109 typeAdapter = MarkupMultilineAdapter.class 110 ) 111 private MarkupMultiline _remarks; 112 113 public AssessmentSubject() { 114 this(null); 115 } 116 117 public AssessmentSubject(IMetaschemaData data) { 118 this.__metaschemaData = data; 119 } 120 121 @Override 122 public IMetaschemaData getMetaschemaData() { 123 return __metaschemaData; 124 } 125 126 public String getType() { 127 return _type; 128 } 129 130 public void setType(String value) { 131 _type = value; 132 } 133 134 public MarkupMultiline getDescription() { 135 return _description; 136 } 137 138 public void setDescription(MarkupMultiline value) { 139 _description = value; 140 } 141 142 public List<Property> getProps() { 143 return _props; 144 } 145 146 public void setProps(List<Property> value) { 147 _props = value; 148 } 149 150 /** 151 * Add a new {@link Property} item to the underlying collection. 152 * @param item the item to add 153 * @return {@code true} 154 */ 155 public boolean addProp(Property item) { 156 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 157 if (_props == null) { 158 _props = new LinkedList<>(); 159 } 160 return _props.add(value); 161 } 162 163 /** 164 * Remove the first matching {@link Property} item from the underlying collection. 165 * @param item the item to remove 166 * @return {@code true} if the item was removed or {@code false} otherwise 167 */ 168 public boolean removeProp(Property item) { 169 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 170 return _props != null && _props.remove(value); 171 } 172 173 public List<Link> getLinks() { 174 return _links; 175 } 176 177 public void setLinks(List<Link> value) { 178 _links = value; 179 } 180 181 /** 182 * Add a new {@link Link} item to the underlying collection. 183 * @param item the item to add 184 * @return {@code true} 185 */ 186 public boolean addLink(Link item) { 187 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 188 if (_links == null) { 189 _links = new LinkedList<>(); 190 } 191 return _links.add(value); 192 } 193 194 /** 195 * Remove the first matching {@link Link} item from the underlying collection. 196 * @param item the item to remove 197 * @return {@code true} if the item was removed or {@code false} otherwise 198 */ 199 public boolean removeLink(Link item) { 200 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 201 return _links != null && _links.remove(value); 202 } 203 204 public IncludeAll getIncludeAll() { 205 return _includeAll; 206 } 207 208 public void setIncludeAll(IncludeAll value) { 209 _includeAll = value; 210 } 211 212 public List<SelectSubjectById> getIncludeSubjects() { 213 return _includeSubjects; 214 } 215 216 public void setIncludeSubjects(List<SelectSubjectById> value) { 217 _includeSubjects = value; 218 } 219 220 /** 221 * Add a new {@link SelectSubjectById} item to the underlying collection. 222 * @param item the item to add 223 * @return {@code true} 224 */ 225 public boolean addIncludeSubject(SelectSubjectById item) { 226 SelectSubjectById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 227 if (_includeSubjects == null) { 228 _includeSubjects = new LinkedList<>(); 229 } 230 return _includeSubjects.add(value); 231 } 232 233 /** 234 * Remove the first matching {@link SelectSubjectById} item from the underlying collection. 235 * @param item the item to remove 236 * @return {@code true} if the item was removed or {@code false} otherwise 237 */ 238 public boolean removeIncludeSubject(SelectSubjectById item) { 239 SelectSubjectById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 240 return _includeSubjects != null && _includeSubjects.remove(value); 241 } 242 243 public List<SelectSubjectById> getExcludeSubjects() { 244 return _excludeSubjects; 245 } 246 247 public void setExcludeSubjects(List<SelectSubjectById> value) { 248 _excludeSubjects = value; 249 } 250 251 /** 252 * Add a new {@link SelectSubjectById} item to the underlying collection. 253 * @param item the item to add 254 * @return {@code true} 255 */ 256 public boolean addExcludeSubject(SelectSubjectById item) { 257 SelectSubjectById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 258 if (_excludeSubjects == null) { 259 _excludeSubjects = new LinkedList<>(); 260 } 261 return _excludeSubjects.add(value); 262 } 263 264 /** 265 * Remove the first matching {@link SelectSubjectById} item from the underlying collection. 266 * @param item the item to remove 267 * @return {@code true} if the item was removed or {@code false} otherwise 268 */ 269 public boolean removeExcludeSubject(SelectSubjectById item) { 270 SelectSubjectById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 271 return _excludeSubjects != null && _excludeSubjects.remove(value); 272 } 273 274 public MarkupMultiline getRemarks() { 275 return _remarks; 276 } 277 278 public void setRemarks(MarkupMultiline value) { 279 _remarks = value; 280 } 281 282 @Override 283 public String toString() { 284 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 285 } 286}