View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
4   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
5   import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
6   import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
7   import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
8   import gov.nist.secauto.metaschema.model.common.datatype.adapter.UriReferenceAdapter;
9   import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
10  import java.lang.Override;
11  import java.lang.String;
12  import java.net.URI;
13  import java.util.LinkedList;
14  import java.util.List;
15  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
16  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
17  
18  /**
19   * Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.
20   */
21  @MetaschemaAssembly(
22      formalName = "Import Resource",
23      description = "Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.",
24      name = "import",
25      metaschema = OscalProfileMetaschema.class,
26      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)."
27  )
28  public class ProfileImport {
29    @BoundFlag(
30        formalName = "Catalog or Profile Reference",
31        description = "A resolvable URL reference to the base catalog or profile that this profile is tailoring.",
32        useName = "href",
33        required = true,
34        typeAdapter = UriReferenceAdapter.class,
35        remarks = "This value may be one of:\n"
36                + "\n"
37                + "1. an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that points to a network resolvable resource,\n"
38                + "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"
39                + "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))."
40    )
41    private URI _href;
42  
43    @BoundAssembly(
44        formalName = "Include All",
45        description = "Include all controls from the imported catalog or profile resources.",
46        useName = "include-all",
47        minOccurs = 1,
48        remarks = "Identifies that all controls are to be included from the imported catalog or profile."
49    )
50    private IncludeAll _includeAll;
51  
52    @BoundAssembly(
53        formalName = "Select Control",
54        description = "Select a control or controls from an imported control set.",
55        useName = "include-controls",
56        minOccurs = 1,
57        maxOccurs = -1,
58        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."
59    )
60    @GroupAs(
61        name = "include-controls",
62        inJson = JsonGroupAsBehavior.LIST
63    )
64    private List<ProfileSelectControlById> _includeControls;
65  
66    @BoundAssembly(
67        formalName = "Select Control",
68        description = "Select a control or controls from an imported control set.",
69        useName = "exclude-controls",
70        maxOccurs = -1,
71        remarks = "Identifies which controls to exclude, or eliminate, from the set of included controls by control identifier or match pattern."
72    )
73    @GroupAs(
74        name = "exclude-controls",
75        inJson = JsonGroupAsBehavior.LIST
76    )
77    private List<ProfileSelectControlById> _excludeControls;
78  
79    public ProfileImport() {
80    }
81  
82    public URI getHref() {
83      return _href;
84    }
85  
86    public void setHref(URI value) {
87      _href = value;
88    }
89  
90    public IncludeAll getIncludeAll() {
91      return _includeAll;
92    }
93  
94    public void setIncludeAll(IncludeAll value) {
95      _includeAll = value;
96    }
97  
98    public List<ProfileSelectControlById> getIncludeControls() {
99      return _includeControls;
100   }
101 
102   public void setIncludeControls(List<ProfileSelectControlById> value) {
103     _includeControls = value;
104   }
105 
106   /**
107    * Add a new {@link ProfileSelectControlById} item to the underlying collection.
108    * @param item the item to add
109    * @return {@code true}
110    */
111   public boolean addIncludeControls(ProfileSelectControlById item) {
112     ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
113     if (_includeControls == null) {
114       _includeControls = new LinkedList<>();
115     }
116     return _includeControls.add(value);
117   }
118 
119   /**
120    * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection.
121    * @param item the item to remove
122    * @return {@code true} if the item was removed or {@code false} otherwise
123    */
124   public boolean removeIncludeControls(ProfileSelectControlById item) {
125     ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
126     return _includeControls == null ? false : _includeControls.remove(value);
127   }
128 
129   public List<ProfileSelectControlById> getExcludeControls() {
130     return _excludeControls;
131   }
132 
133   public void setExcludeControls(List<ProfileSelectControlById> value) {
134     _excludeControls = value;
135   }
136 
137   /**
138    * Add a new {@link ProfileSelectControlById} item to the underlying collection.
139    * @param item the item to add
140    * @return {@code true}
141    */
142   public boolean addExcludeControls(ProfileSelectControlById item) {
143     ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
144     if (_excludeControls == null) {
145       _excludeControls = new LinkedList<>();
146     }
147     return _excludeControls.add(value);
148   }
149 
150   /**
151    * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection.
152    * @param item the item to remove
153    * @return {@code true} if the item was removed or {@code false} otherwise
154    */
155   public boolean removeExcludeControls(ProfileSelectControlById item) {
156     ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
157     return _excludeControls == null ? false : _excludeControls.remove(value);
158   }
159 
160   @Override
161   public String toString() {
162     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
163   }
164 }