001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter; 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 * Describes requirements, incompatibilities and gaps that are identified between a target and source in a mapping item. 028 */ 029@MetaschemaAssembly( 030 formalName = "Mapping Provenance", 031 description = "Describes requirements, incompatibilities and gaps that are identified between a target and source in a mapping item.", 032 name = "mapping-provenance", 033 moduleClass = OscalMappingCommonModule.class 034) 035public class MappingProvenance implements IBoundObject { 036 private final IMetaschemaData __metaschemaData; 037 038 /** 039 * "The method used to complete the overall mapping." 040 */ 041 @BoundFlag( 042 formalName = "Method", 043 description = "The method used to complete the overall mapping.", 044 name = "method", 045 required = true, 046 typeAdapter = StringAdapter.class, 047 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "human", description = "Human"), @AllowedValue(value = "automation", description = "Automation"), @AllowedValue(value = "hybrid", description = "Hybrid")})) 048 ) 049 private String _method; 050 051 /** 052 * "The method used for relating controls within the mapping. The supported methods are aligned with the <a href=\"https://doi.org/10.6028/NIST.IR.8477\">NIST Interagency Report (IR) 8477</a>, Section 4.3 Set Theory Relationship Mapping." 053 */ 054 @BoundFlag( 055 formalName = "Matching", 056 description = "The method used for relating controls within the mapping. The supported methods are aligned with the [NIST Interagency Report (IR) 8477](https://doi.org/10.6028/NIST.IR.8477), Section 4.3 Set Theory Relationship Mapping.", 057 name = "matching-rationale", 058 required = true, 059 typeAdapter = StringAdapter.class, 060 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "syntactic", description = "Syntactic: How similar is the *wording* that expresses the two concepts. This is a word-for-word analysis of the relationship, not an interpretation of the language."), @AllowedValue(value = "semantic", description = "Semantic: How similar are the *meanings* of the two concepts? This involves some interpretation of each concept’s language."), @AllowedValue(value = "functional", description = "Functional: How similar are the *results* of executing the two concepts? This involves understanding what will happen if the two concepts are implemented, performed, or otherwise executed.")})) 061 ) 062 private String _matchingRationale; 063 064 /** 065 * "The current status of this mapping document." 066 */ 067 @BoundFlag( 068 formalName = "Status", 069 description = "The current status of this mapping document.", 070 name = "status", 071 required = true, 072 typeAdapter = StringAdapter.class, 073 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "complete", description = "Complete"), @AllowedValue(value = "not-complete", description = "Not Complete"), @AllowedValue(value = "draft", description = "Draft"), @AllowedValue(value = "deprecated", description = "Deprecated"), @AllowedValue(value = "superseded", description = "Superseded")})) 074 ) 075 private String _status; 076 077 @BoundField( 078 formalName = "Confidence Score", 079 description = "This records either a string category or a decimal value from 0-1 representing a percentage. Both of these values describe an estimation of the author's confidence that this mapping is correct and accurate.", 080 useName = "confidence-score" 081 ) 082 private ConfidenceScore _confidenceScore; 083 084 @BoundField( 085 formalName = "Coverage", 086 description = "A decimal value from 0-1, representing the percentage coverage of the targets by the sources.", 087 useName = "coverage" 088 ) 089 private Coverage _coverage; 090 091 @BoundField( 092 formalName = "Mapping Description", 093 description = "Description of the context and intended use of the mapping set.", 094 useName = "mapping-description", 095 minOccurs = 1, 096 typeAdapter = MarkupMultilineAdapter.class 097 ) 098 private MarkupMultiline _mappingDescription; 099 100 @BoundAssembly( 101 formalName = "Responsible Party", 102 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.", 103 useName = "responsible-party", 104 maxOccurs = -1, 105 groupAs = @GroupAs(name = "responsible-parties", inJson = JsonGroupAsBehavior.LIST) 106 ) 107 private List<ResponsibleParty> _responsibleParties; 108 109 @BoundAssembly( 110 formalName = "Property", 111 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 112 useName = "prop", 113 maxOccurs = -1, 114 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 115 ) 116 private List<Property> _props; 117 118 @BoundAssembly( 119 formalName = "Link", 120 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 121 useName = "link", 122 maxOccurs = -1, 123 groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST) 124 ) 125 private List<Link> _links; 126 127 @BoundField( 128 formalName = "Remarks", 129 description = "Additional commentary about the containing object.", 130 useName = "remarks", 131 typeAdapter = MarkupMultilineAdapter.class 132 ) 133 private MarkupMultiline _remarks; 134 135 public MappingProvenance() { 136 this(null); 137 } 138 139 public MappingProvenance(IMetaschemaData data) { 140 this.__metaschemaData = data; 141 } 142 143 @Override 144 public IMetaschemaData getMetaschemaData() { 145 return __metaschemaData; 146 } 147 148 public String getMethod() { 149 return _method; 150 } 151 152 public void setMethod(String value) { 153 _method = value; 154 } 155 156 public String getMatchingRationale() { 157 return _matchingRationale; 158 } 159 160 public void setMatchingRationale(String value) { 161 _matchingRationale = value; 162 } 163 164 public String getStatus() { 165 return _status; 166 } 167 168 public void setStatus(String value) { 169 _status = value; 170 } 171 172 public ConfidenceScore getConfidenceScore() { 173 return _confidenceScore; 174 } 175 176 public void setConfidenceScore(ConfidenceScore value) { 177 _confidenceScore = value; 178 } 179 180 public Coverage getCoverage() { 181 return _coverage; 182 } 183 184 public void setCoverage(Coverage value) { 185 _coverage = value; 186 } 187 188 public MarkupMultiline getMappingDescription() { 189 return _mappingDescription; 190 } 191 192 public void setMappingDescription(MarkupMultiline value) { 193 _mappingDescription = value; 194 } 195 196 public List<ResponsibleParty> getResponsibleParties() { 197 return _responsibleParties; 198 } 199 200 public void setResponsibleParties(List<ResponsibleParty> value) { 201 _responsibleParties = value; 202 } 203 204 /** 205 * Add a new {@link ResponsibleParty} item to the underlying collection. 206 * @param item the item to add 207 * @return {@code true} 208 */ 209 public boolean addResponsibleParty(ResponsibleParty item) { 210 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null"); 211 if (_responsibleParties == null) { 212 _responsibleParties = new LinkedList<>(); 213 } 214 return _responsibleParties.add(value); 215 } 216 217 /** 218 * Remove the first matching {@link ResponsibleParty} item from the underlying collection. 219 * @param item the item to remove 220 * @return {@code true} if the item was removed or {@code false} otherwise 221 */ 222 public boolean removeResponsibleParty(ResponsibleParty item) { 223 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null"); 224 return _responsibleParties != null && _responsibleParties.remove(value); 225 } 226 227 public List<Property> getProps() { 228 return _props; 229 } 230 231 public void setProps(List<Property> value) { 232 _props = value; 233 } 234 235 /** 236 * Add a new {@link Property} item to the underlying collection. 237 * @param item the item to add 238 * @return {@code true} 239 */ 240 public boolean addProp(Property item) { 241 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 242 if (_props == null) { 243 _props = new LinkedList<>(); 244 } 245 return _props.add(value); 246 } 247 248 /** 249 * Remove the first matching {@link Property} item from the underlying collection. 250 * @param item the item to remove 251 * @return {@code true} if the item was removed or {@code false} otherwise 252 */ 253 public boolean removeProp(Property item) { 254 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 255 return _props != null && _props.remove(value); 256 } 257 258 public List<Link> getLinks() { 259 return _links; 260 } 261 262 public void setLinks(List<Link> value) { 263 _links = value; 264 } 265 266 /** 267 * Add a new {@link Link} item to the underlying collection. 268 * @param item the item to add 269 * @return {@code true} 270 */ 271 public boolean addLink(Link item) { 272 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 273 if (_links == null) { 274 _links = new LinkedList<>(); 275 } 276 return _links.add(value); 277 } 278 279 /** 280 * Remove the first matching {@link Link} item from the underlying collection. 281 * @param item the item to remove 282 * @return {@code true} if the item was removed or {@code false} otherwise 283 */ 284 public boolean removeLink(Link item) { 285 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 286 return _links != null && _links.remove(value); 287 } 288 289 public MarkupMultiline getRemarks() { 290 return _remarks; 291 } 292 293 public void setRemarks(MarkupMultiline value) { 294 _remarks = value; 295 } 296 297 @Override 298 public String toString() { 299 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 300 } 301}