001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.UriReferenceAdapter; 004import gov.nist.secauto.metaschema.core.model.IBoundObject; 005import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 006import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; 007import gov.nist.secauto.metaschema.core.util.ObjectUtils; 008import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly; 009import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 010import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs; 011import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 012import java.lang.Override; 013import java.lang.String; 014import java.net.URI; 015import java.util.LinkedList; 016import java.util.List; 017import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 018import org.apache.commons.lang3.builder.ToStringStyle; 019 020/** 021 * Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline. 022 */ 023@MetaschemaAssembly( 024 formalName = "Import Resource", 025 description = "Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.", 026 name = "import", 027 moduleClass = OscalProfileModule.class, 028 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)." 029) 030public class ProfileImport implements IBoundObject { 031 private final IMetaschemaData __metaschemaData; 032 033 /** 034 * "A resolvable URL reference to the base catalog or profile that this profile is tailoring." 035 */ 036 @BoundFlag( 037 formalName = "Catalog or Profile Reference", 038 description = "A resolvable URL reference to the base catalog or profile that this profile is tailoring.", 039 name = "href", 040 required = true, 041 typeAdapter = UriReferenceAdapter.class, 042 remarks = "This value may be one of:\n" 043 + "\n" 044 + "1. an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that points to a network resolvable resource,\n" 045 + "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" 046 + "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))." 047 ) 048 private URI _href; 049 050 @BoundAssembly( 051 formalName = "Include All", 052 description = "Include all controls from the imported catalog or profile resources.", 053 useName = "include-all", 054 remarks = "Identifies that all controls are to be included from the imported catalog or profile.", 055 minOccurs = 1 056 ) 057 private IncludeAll _includeAll; 058 059 @BoundAssembly( 060 formalName = "Select Control", 061 description = "Select a control or controls from an imported control set.", 062 useName = "include-controls", 063 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.", 064 minOccurs = 1, 065 maxOccurs = -1, 066 groupAs = @GroupAs(name = "include-controls", inJson = JsonGroupAsBehavior.LIST) 067 ) 068 private List<ProfileSelectControlById> _includeControls; 069 070 @BoundAssembly( 071 formalName = "Select Control", 072 description = "Select a control or controls from an imported control set.", 073 useName = "exclude-controls", 074 remarks = "Identifies which controls to exclude, or eliminate, from the set of included controls by control identifier or match pattern.", 075 maxOccurs = -1, 076 groupAs = @GroupAs(name = "exclude-controls", inJson = JsonGroupAsBehavior.LIST) 077 ) 078 private List<ProfileSelectControlById> _excludeControls; 079 080 public ProfileImport() { 081 this(null); 082 } 083 084 public ProfileImport(IMetaschemaData data) { 085 this.__metaschemaData = data; 086 } 087 088 @Override 089 public IMetaschemaData getMetaschemaData() { 090 return __metaschemaData; 091 } 092 093 public URI getHref() { 094 return _href; 095 } 096 097 public void setHref(URI value) { 098 _href = value; 099 } 100 101 public IncludeAll getIncludeAll() { 102 return _includeAll; 103 } 104 105 public void setIncludeAll(IncludeAll value) { 106 _includeAll = value; 107 } 108 109 public List<ProfileSelectControlById> getIncludeControls() { 110 return _includeControls; 111 } 112 113 public void setIncludeControls(List<ProfileSelectControlById> value) { 114 _includeControls = value; 115 } 116 117 /** 118 * Add a new {@link ProfileSelectControlById} item to the underlying collection. 119 * @param item the item to add 120 * @return {@code true} 121 */ 122 public boolean addIncludeControls(ProfileSelectControlById item) { 123 ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 124 if (_includeControls == null) { 125 _includeControls = new LinkedList<>(); 126 } 127 return _includeControls.add(value); 128 } 129 130 /** 131 * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection. 132 * @param item the item to remove 133 * @return {@code true} if the item was removed or {@code false} otherwise 134 */ 135 public boolean removeIncludeControls(ProfileSelectControlById item) { 136 ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 137 return _includeControls != null && _includeControls.remove(value); 138 } 139 140 public List<ProfileSelectControlById> getExcludeControls() { 141 return _excludeControls; 142 } 143 144 public void setExcludeControls(List<ProfileSelectControlById> value) { 145 _excludeControls = value; 146 } 147 148 /** 149 * Add a new {@link ProfileSelectControlById} item to the underlying collection. 150 * @param item the item to add 151 * @return {@code true} 152 */ 153 public boolean addExcludeControls(ProfileSelectControlById item) { 154 ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 155 if (_excludeControls == null) { 156 _excludeControls = new LinkedList<>(); 157 } 158 return _excludeControls.add(value); 159 } 160 161 /** 162 * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection. 163 * @param item the item to remove 164 * @return {@code true} if the item was removed or {@code false} otherwise 165 */ 166 public boolean removeExcludeControls(ProfileSelectControlById item) { 167 ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 168 return _excludeControls != null && _excludeControls.remove(value); 169 } 170 171 @Override 172 public String toString() { 173 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 174 } 175}