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.BoundAssembly; 013import gov.nist.secauto.metaschema.databind.model.annotations.BoundField; 014import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 015import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs; 016import gov.nist.secauto.metaschema.databind.model.annotations.IndexHasKey; 017import gov.nist.secauto.metaschema.databind.model.annotations.KeyField; 018import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 019import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints; 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 * 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. 030 */ 031@MetaschemaAssembly( 032 formalName = "Responsible Role", 033 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.", 034 name = "responsible-role", 035 moduleClass = OscalMetadataModule.class, 036 remarks = "A `responsible-role` allows zero or more `party-uuid` references, each of which creates a relationship arc between the referenced `role-id` and the referenced party. This differs in semantics from `responsible-party`, which requires that at least one `party-uuid` is referenced.\n" 037 + "\n" 038 + "The scope of use of this object determines if the responsibility has been performed or will be performed in the future. The containing object will describe the intent." 039) 040public class ResponsibleRole implements IBoundObject { 041 private final IMetaschemaData __metaschemaData; 042 043 /** 044 * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented\">human-oriented</a> identifier reference to a <code>role</code> performed." 045 */ 046 @BoundFlag( 047 formalName = "Responsible Role ID", 048 description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) identifier reference to a `role` performed.", 049 name = "role-id", 050 required = true, 051 typeAdapter = TokenAdapter.class 052 ) 053 private String _roleId; 054 055 @BoundAssembly( 056 formalName = "Property", 057 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 058 useName = "prop", 059 maxOccurs = -1, 060 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 061 ) 062 private List<Property> _props; 063 064 @BoundAssembly( 065 formalName = "Link", 066 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 067 useName = "link", 068 maxOccurs = -1, 069 groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST) 070 ) 071 private List<Link> _links; 072 073 @BoundField( 074 formalName = "Party Universally Unique Identifier Reference", 075 description = "Specifies zero or more parties responsible for performing the associated `role`.", 076 useName = "party-uuid", 077 maxOccurs = -1, 078 groupAs = @GroupAs(name = "party-uuids", inJson = JsonGroupAsBehavior.LIST), 079 typeAdapter = UuidAdapter.class, 080 valueConstraints = @ValueConstraints(indexHasKey = @IndexHasKey(level = IConstraint.Level.ERROR, indexName = "index-metadata-party-uuid", keyFields = @KeyField)) 081 ) 082 private List<UUID> _partyUuids; 083 084 @BoundField( 085 formalName = "Remarks", 086 description = "Additional commentary about the containing object.", 087 useName = "remarks", 088 typeAdapter = MarkupMultilineAdapter.class 089 ) 090 private MarkupMultiline _remarks; 091 092 public ResponsibleRole() { 093 this(null); 094 } 095 096 public ResponsibleRole(IMetaschemaData data) { 097 this.__metaschemaData = data; 098 } 099 100 @Override 101 public IMetaschemaData getMetaschemaData() { 102 return __metaschemaData; 103 } 104 105 public String getRoleId() { 106 return _roleId; 107 } 108 109 public void setRoleId(String value) { 110 _roleId = value; 111 } 112 113 public List<Property> getProps() { 114 return _props; 115 } 116 117 public void setProps(List<Property> value) { 118 _props = value; 119 } 120 121 /** 122 * Add a new {@link Property} item to the underlying collection. 123 * @param item the item to add 124 * @return {@code true} 125 */ 126 public boolean addProp(Property item) { 127 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 128 if (_props == null) { 129 _props = new LinkedList<>(); 130 } 131 return _props.add(value); 132 } 133 134 /** 135 * Remove the first matching {@link Property} item from the underlying collection. 136 * @param item the item to remove 137 * @return {@code true} if the item was removed or {@code false} otherwise 138 */ 139 public boolean removeProp(Property item) { 140 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 141 return _props != null && _props.remove(value); 142 } 143 144 public List<Link> getLinks() { 145 return _links; 146 } 147 148 public void setLinks(List<Link> value) { 149 _links = value; 150 } 151 152 /** 153 * Add a new {@link Link} item to the underlying collection. 154 * @param item the item to add 155 * @return {@code true} 156 */ 157 public boolean addLink(Link item) { 158 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 159 if (_links == null) { 160 _links = new LinkedList<>(); 161 } 162 return _links.add(value); 163 } 164 165 /** 166 * Remove the first matching {@link Link} item from the underlying collection. 167 * @param item the item to remove 168 * @return {@code true} if the item was removed or {@code false} otherwise 169 */ 170 public boolean removeLink(Link item) { 171 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 172 return _links != null && _links.remove(value); 173 } 174 175 public List<UUID> getPartyUuids() { 176 return _partyUuids; 177 } 178 179 public void setPartyUuids(List<UUID> value) { 180 _partyUuids = value; 181 } 182 183 /** 184 * Add a new {@link UUID} item to the underlying collection. 185 * @param item the item to add 186 * @return {@code true} 187 */ 188 public boolean addPartyUuid(UUID item) { 189 UUID value = ObjectUtils.requireNonNull(item,"item cannot be null"); 190 if (_partyUuids == null) { 191 _partyUuids = new LinkedList<>(); 192 } 193 return _partyUuids.add(value); 194 } 195 196 /** 197 * Remove the first matching {@link UUID} item from the underlying collection. 198 * @param item the item to remove 199 * @return {@code true} if the item was removed or {@code false} otherwise 200 */ 201 public boolean removePartyUuid(UUID item) { 202 UUID value = ObjectUtils.requireNonNull(item,"item cannot be null"); 203 return _partyUuids != null && _partyUuids.remove(value); 204 } 205 206 public MarkupMultiline getRemarks() { 207 return _remarks; 208 } 209 210 public void setRemarks(MarkupMultiline value) { 211 _remarks = value; 212 } 213 214 @Override 215 public String toString() { 216 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 217 } 218}