001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_profile_metaschema.xml 002// Do not edit - changes will be lost when regenerated. 003package dev.metaschema.oscal.lib.model; 004 005import dev.metaschema.core.datatype.adapter.UriReferenceAdapter; 006import dev.metaschema.core.model.IBoundObject; 007import dev.metaschema.core.model.IMetaschemaData; 008import dev.metaschema.core.model.JsonGroupAsBehavior; 009import dev.metaschema.core.model.constraint.IConstraint; 010import dev.metaschema.core.util.ObjectUtils; 011import dev.metaschema.databind.model.annotations.BoundAssembly; 012import dev.metaschema.databind.model.annotations.BoundChoice; 013import dev.metaschema.databind.model.annotations.BoundFlag; 014import dev.metaschema.databind.model.annotations.Expect; 015import dev.metaschema.databind.model.annotations.GroupAs; 016import dev.metaschema.databind.model.annotations.Let; 017import dev.metaschema.databind.model.annotations.MetaschemaAssembly; 018import dev.metaschema.databind.model.annotations.ValueConstraints; 019import edu.umd.cs.findbugs.annotations.NonNull; 020import edu.umd.cs.findbugs.annotations.Nullable; 021import java.net.URI; 022import java.util.LinkedList; 023import java.util.List; 024import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 025import org.apache.commons.lang3.builder.ToStringStyle; 026 027/** 028 * Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline. 029 */ 030@MetaschemaAssembly( 031 formalName = "Import Resource", 032 description = "Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.", 033 name = "import", 034 moduleClass = OscalProfileModule.class, 035 remarks = "The contents of the `import` element indicate which controls from the source will be included. Controls from the source catalog or profile may be either selected, using the `include-all` or `include-controls` directives, or de-selected (using an `exclude-controls` directive).", 036 valueConstraints = @ValueConstraints(lets = @Let(name = "resolved-profile-import", target = ".[@href] ! resolve-profile(doc(resolve-uri(Q{http://csrc.nist.gov/ns/oscal/1.0}resolve-reference(@href))))/catalog"), expect = @Expect(id = "oscal-profile-import-include-exclude-control-id-in-imported-catalog", formalName = "In-Scope Control Identifier", description = "Each referenced control identifier must match a control in the catalog resolved by the surrounding profile import.", level = IConstraint.Level.ERROR, target = "(include-controls|exclude-controls)/with-id", test = "let $id := . return exists($resolved-profile-import//control[@id = $id])", message = "Control identifier '{ . }' was not found in the imported catalog.")) 037) 038public class ProfileImport implements IBoundObject { 039 private final IMetaschemaData __metaschemaData; 040 041 /** 042 * A resolvable URL reference to the base catalog or profile that this profile is tailoring. 043 */ 044 @BoundFlag( 045 formalName = "Catalog or Profile Reference", 046 description = "A resolvable URL reference to the base catalog or profile that this profile is tailoring.", 047 name = "href", 048 required = true, 049 typeAdapter = UriReferenceAdapter.class, 050 remarks = "This value may be one of:\n" 051 + "\n" 052 + "1. an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that points to a network resolvable resource,\n" 053 + "2. a [relative reference](https://pages.nist.gov/OSCAL/concepts/uri-use/#relative-reference) pointing to a network resolvable resource whose base URI is the URI of the containing document, or\n" 054 + "3. a bare URI fragment (i.e., \\`#uuid\\`) pointing to a `back-matter` resource in this or an imported document (see [linking to another OSCAL object](https://pages.nist.gov/OSCAL/concepts/uri-use/#linking-to-another-oscal-object))." 055 ) 056 private URI _href; 057 058 /** 059 * Include all controls from the imported catalog or profile resources. 060 */ 061 @BoundAssembly( 062 formalName = "Include All", 063 description = "Include all controls from the imported catalog or profile resources.", 064 useName = "include-all", 065 remarks = "Identifies that all controls are to be included from the imported catalog or profile.", 066 minOccurs = 1 067 ) 068 @BoundChoice( 069 choiceId = "choice-1" 070 ) 071 private IncludeAll _includeAll; 072 073 /** 074 * Select a control or controls from an imported control set. 075 */ 076 @BoundAssembly( 077 formalName = "Select Control", 078 description = "Select a control or controls from an imported control set.", 079 useName = "include-controls", 080 remarks = "If `with-child-controls` is \"yes\" on the call to a control, any controls appearing within it (child controls) will be selected, with no additional `call` directives required. This flag provides a way to include controls with all their dependent controls (enhancements) without having to call them individually.", 081 minOccurs = 1, 082 maxOccurs = -1, 083 groupAs = @GroupAs(name = "include-controls", inJson = JsonGroupAsBehavior.LIST) 084 ) 085 @BoundChoice( 086 choiceId = "choice-1" 087 ) 088 private List<ControlCommonSelectControlById> _includeControls; 089 090 /** 091 * Select a control or controls from an imported control set. 092 */ 093 @BoundAssembly( 094 formalName = "Select Control", 095 description = "Select a control or controls from an imported control set.", 096 useName = "exclude-controls", 097 remarks = "Identifies which controls to exclude, or eliminate, from the set of included controls by control identifier or match pattern.", 098 maxOccurs = -1, 099 groupAs = @GroupAs(name = "exclude-controls", inJson = JsonGroupAsBehavior.LIST) 100 ) 101 private List<ControlCommonSelectControlById> _excludeControls; 102 103 /** 104 * Constructs a new {@code dev.metaschema.oscal.lib.model.ProfileImport} instance with no metadata. 105 */ 106 public ProfileImport() { 107 this(null); 108 } 109 110 /** 111 * Constructs a new {@code dev.metaschema.oscal.lib.model.ProfileImport} instance with the specified metadata. 112 * 113 * @param data 114 * the metaschema data, or {@code null} if none 115 */ 116 public ProfileImport(IMetaschemaData data) { 117 this.__metaschemaData = data; 118 } 119 120 @Override 121 public IMetaschemaData getMetaschemaData() { 122 return __metaschemaData; 123 } 124 125 /** 126 * Get the "{@literal Catalog or Profile Reference}". 127 * 128 * <p> 129 * A resolvable URL reference to the base catalog or profile that this profile is tailoring. 130 * 131 * @return the href value 132 */ 133 @NonNull 134 public URI getHref() { 135 return _href; 136 } 137 138 /** 139 * Set the "{@literal Catalog or Profile Reference}". 140 * 141 * <p> 142 * A resolvable URL reference to the base catalog or profile that this profile is tailoring. 143 * 144 * @param value 145 * the href value to set 146 */ 147 public void setHref(@NonNull URI value) { 148 _href = value; 149 } 150 151 /** 152 * Get the "{@literal Include All}". 153 * 154 * <p> 155 * Include all controls from the imported catalog or profile resources. 156 * 157 * @return the include-all value, or {@code null} if not set 158 */ 159 @Nullable 160 public IncludeAll getIncludeAll() { 161 return _includeAll; 162 } 163 164 /** 165 * Set the "{@literal Include All}". 166 * 167 * <p> 168 * Include all controls from the imported catalog or profile resources. 169 * 170 * @param value 171 * the include-all value to set, or {@code null} to clear 172 */ 173 public void setIncludeAll(@Nullable IncludeAll value) { 174 _includeAll = value; 175 } 176 177 /** 178 * Get the "{@literal Select Control}". 179 * 180 * <p> 181 * Select a control or controls from an imported control set. 182 * 183 * @return the include-controls value 184 */ 185 @NonNull 186 public List<ControlCommonSelectControlById> getIncludeControls() { 187 if (_includeControls == null) { 188 _includeControls = new LinkedList<>(); 189 } 190 return ObjectUtils.notNull(_includeControls); 191 } 192 193 /** 194 * Set the "{@literal Select Control}". 195 * 196 * <p> 197 * Select a control or controls from an imported control set. 198 * 199 * @param value 200 * the include-controls value to set 201 */ 202 public void setIncludeControls(@NonNull List<ControlCommonSelectControlById> value) { 203 _includeControls = value; 204 } 205 206 /** 207 * Add a new {@link ControlCommonSelectControlById} item to the underlying collection. 208 * @param item the item to add 209 * @return {@code true} 210 */ 211 public boolean addIncludeControls(ControlCommonSelectControlById item) { 212 ControlCommonSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 213 if (_includeControls == null) { 214 _includeControls = new LinkedList<>(); 215 } 216 return _includeControls.add(value); 217 } 218 219 /** 220 * Remove the first matching {@link ControlCommonSelectControlById} item from the underlying collection. 221 * @param item the item to remove 222 * @return {@code true} if the item was removed or {@code false} otherwise 223 */ 224 public boolean removeIncludeControls(ControlCommonSelectControlById item) { 225 ControlCommonSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 226 return _includeControls != null && _includeControls.remove(value); 227 } 228 229 /** 230 * Get the "{@literal Select Control}". 231 * 232 * <p> 233 * Select a control or controls from an imported control set. 234 * 235 * @return the exclude-controls value 236 */ 237 @NonNull 238 public List<ControlCommonSelectControlById> getExcludeControls() { 239 if (_excludeControls == null) { 240 _excludeControls = new LinkedList<>(); 241 } 242 return ObjectUtils.notNull(_excludeControls); 243 } 244 245 /** 246 * Set the "{@literal Select Control}". 247 * 248 * <p> 249 * Select a control or controls from an imported control set. 250 * 251 * @param value 252 * the exclude-controls value to set 253 */ 254 public void setExcludeControls(@NonNull List<ControlCommonSelectControlById> value) { 255 _excludeControls = value; 256 } 257 258 /** 259 * Add a new {@link ControlCommonSelectControlById} item to the underlying collection. 260 * @param item the item to add 261 * @return {@code true} 262 */ 263 public boolean addExcludeControls(ControlCommonSelectControlById item) { 264 ControlCommonSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 265 if (_excludeControls == null) { 266 _excludeControls = new LinkedList<>(); 267 } 268 return _excludeControls.add(value); 269 } 270 271 /** 272 * Remove the first matching {@link ControlCommonSelectControlById} item from the underlying collection. 273 * @param item the item to remove 274 * @return {@code true} if the item was removed or {@code false} otherwise 275 */ 276 public boolean removeExcludeControls(ControlCommonSelectControlById item) { 277 ControlCommonSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 278 return _excludeControls != null && _excludeControls.remove(value); 279 } 280 281 @Override 282 public String toString() { 283 return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString()); 284 } 285}