001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter; 004import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter; 005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; 006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter; 007import gov.nist.secauto.metaschema.core.model.IBoundObject; 008import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 009import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; 010import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; 011import gov.nist.secauto.metaschema.core.util.ObjectUtils; 012import gov.nist.secauto.metaschema.databind.model.annotations.AssemblyConstraints; 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.IsUnique; 018import gov.nist.secauto.metaschema.databind.model.annotations.KeyField; 019import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 020import java.lang.Override; 021import java.lang.String; 022import java.util.LinkedList; 023import java.util.List; 024import java.util.UUID; 025import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 026import org.apache.commons.lang3.builder.ToStringStyle; 027 028/** 029 * Identifies which statements within a control are addressed. 030 */ 031@MetaschemaAssembly( 032 formalName = "Control Statement Implementation", 033 description = "Identifies which statements within a control are addressed.", 034 name = "statement", 035 moduleClass = OscalComponentDefinitionModule.class, 036 modelConstraints = @AssemblyConstraints(unique = @IsUnique(id = "unique-component-definition-statement-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.")) 037) 038public class ComponentStatement implements IBoundObject { 039 private final IMetaschemaData __metaschemaData; 040 041 /** 042 * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented\">human-oriented</a> identifier reference to a <code>control statement</code>." 043 */ 044 @BoundFlag( 045 formalName = "Control Statement Reference", 046 description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) identifier reference to a `control statement`.", 047 name = "statement-id", 048 required = true, 049 typeAdapter = TokenAdapter.class, 050 remarks = "A reference to the specific implemented statement associated with a control." 051 ) 052 private String _statementId; 053 054 /** 055 * "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 control statement elsewhere in <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#component-definition-identifiers\">this or other OSCAL instances</a>. The <em>UUID</em> of the <code>control statement</code> in the source OSCAL instance is sufficient to reference the data item locally or globally (e.g., in an imported OSCAL instance)." 056 */ 057 @BoundFlag( 058 formalName = "Control Statement Reference Universally Unique Identifier", 059 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 control statement elsewhere in [this or other OSCAL instances](https://pages.nist.gov/OSCAL/concepts/identifier-use/#component-definition-identifiers). The *UUID* of the `control statement` in the source OSCAL instance is sufficient to reference the data item locally or globally (e.g., in an imported OSCAL instance).", 060 name = "uuid", 061 required = true, 062 typeAdapter = UuidAdapter.class 063 ) 064 private UUID _uuid; 065 066 @BoundField( 067 formalName = "Statement Implementation Description", 068 description = "A summary of how the containing control statement is implemented by the component or capability.", 069 useName = "description", 070 minOccurs = 1, 071 typeAdapter = MarkupMultilineAdapter.class 072 ) 073 private MarkupMultiline _description; 074 075 @BoundAssembly( 076 formalName = "Property", 077 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 078 useName = "prop", 079 maxOccurs = -1, 080 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 081 ) 082 private List<Property> _props; 083 084 @BoundAssembly( 085 formalName = "Link", 086 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 087 useName = "link", 088 maxOccurs = -1, 089 groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST) 090 ) 091 private List<Link> _links; 092 093 @BoundAssembly( 094 formalName = "Responsible Role", 095 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.", 096 useName = "responsible-role", 097 maxOccurs = -1, 098 groupAs = @GroupAs(name = "responsible-roles", inJson = JsonGroupAsBehavior.LIST) 099 ) 100 private List<ResponsibleRole> _responsibleRoles; 101 102 @BoundField( 103 formalName = "Remarks", 104 description = "Additional commentary about the containing object.", 105 useName = "remarks", 106 typeAdapter = MarkupMultilineAdapter.class 107 ) 108 private MarkupMultiline _remarks; 109 110 public ComponentStatement() { 111 this(null); 112 } 113 114 public ComponentStatement(IMetaschemaData data) { 115 this.__metaschemaData = data; 116 } 117 118 @Override 119 public IMetaschemaData getMetaschemaData() { 120 return __metaschemaData; 121 } 122 123 public String getStatementId() { 124 return _statementId; 125 } 126 127 public void setStatementId(String value) { 128 _statementId = value; 129 } 130 131 public UUID getUuid() { 132 return _uuid; 133 } 134 135 public void setUuid(UUID value) { 136 _uuid = value; 137 } 138 139 public MarkupMultiline getDescription() { 140 return _description; 141 } 142 143 public void setDescription(MarkupMultiline value) { 144 _description = value; 145 } 146 147 public List<Property> getProps() { 148 return _props; 149 } 150 151 public void setProps(List<Property> value) { 152 _props = value; 153 } 154 155 /** 156 * Add a new {@link Property} item to the underlying collection. 157 * @param item the item to add 158 * @return {@code true} 159 */ 160 public boolean addProp(Property item) { 161 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 162 if (_props == null) { 163 _props = new LinkedList<>(); 164 } 165 return _props.add(value); 166 } 167 168 /** 169 * Remove the first matching {@link Property} item from the underlying collection. 170 * @param item the item to remove 171 * @return {@code true} if the item was removed or {@code false} otherwise 172 */ 173 public boolean removeProp(Property item) { 174 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 175 return _props != null && _props.remove(value); 176 } 177 178 public List<Link> getLinks() { 179 return _links; 180 } 181 182 public void setLinks(List<Link> value) { 183 _links = value; 184 } 185 186 /** 187 * Add a new {@link Link} item to the underlying collection. 188 * @param item the item to add 189 * @return {@code true} 190 */ 191 public boolean addLink(Link item) { 192 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 193 if (_links == null) { 194 _links = new LinkedList<>(); 195 } 196 return _links.add(value); 197 } 198 199 /** 200 * Remove the first matching {@link Link} item from the underlying collection. 201 * @param item the item to remove 202 * @return {@code true} if the item was removed or {@code false} otherwise 203 */ 204 public boolean removeLink(Link item) { 205 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 206 return _links != null && _links.remove(value); 207 } 208 209 public List<ResponsibleRole> getResponsibleRoles() { 210 return _responsibleRoles; 211 } 212 213 public void setResponsibleRoles(List<ResponsibleRole> value) { 214 _responsibleRoles = value; 215 } 216 217 /** 218 * Add a new {@link ResponsibleRole} item to the underlying collection. 219 * @param item the item to add 220 * @return {@code true} 221 */ 222 public boolean addResponsibleRole(ResponsibleRole item) { 223 ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null"); 224 if (_responsibleRoles == null) { 225 _responsibleRoles = new LinkedList<>(); 226 } 227 return _responsibleRoles.add(value); 228 } 229 230 /** 231 * Remove the first matching {@link ResponsibleRole} item from the underlying collection. 232 * @param item the item to remove 233 * @return {@code true} if the item was removed or {@code false} otherwise 234 */ 235 public boolean removeResponsibleRole(ResponsibleRole item) { 236 ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null"); 237 return _responsibleRoles != null && _responsibleRoles.remove(value); 238 } 239 240 public MarkupMultiline getRemarks() { 241 return _remarks; 242 } 243 244 public void setRemarks(MarkupMultiline value) { 245 _remarks = value; 246 } 247 248 @Override 249 public String toString() { 250 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 251 } 252}