001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly; 004import gov.nist.secauto.metaschema.binding.model.annotations.BoundField; 005import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue; 006import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag; 007import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 008import gov.nist.secauto.metaschema.binding.model.annotations.IndexHasKey; 009import gov.nist.secauto.metaschema.binding.model.annotations.KeyField; 010import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 011import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints; 012import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior; 013import gov.nist.secauto.metaschema.model.common.constraint.IConstraint; 014import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter; 015import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter; 016import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline; 017import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter; 018import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 019import java.lang.Override; 020import java.lang.String; 021import java.util.LinkedList; 022import java.util.List; 023import java.util.UUID; 024import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 025import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 026 027/** 028 * A reference to a set of persons and/or organizations that have responsibility for performing the referenced role in the context of the containing object. 029 */ 030@MetaschemaAssembly( 031 formalName = "Responsible Party", 032 description = "A reference to a set of persons and/or organizations that have responsibility for performing the referenced role in the context of the containing object.", 033 name = "responsible-party", 034 metaschema = OscalMetadataMetaschema.class, 035 remarks = "A `responsible-party` requires one or more `party-uuid` references creating a strong relationship arc between the referenced `role-id` and the reference parties. This differs in semantics from `responsible-role` which doesn't require that a `party-uuid` is referenced.\n" 036 + "\n" 037 + "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." 038) 039@ValueConstraints( 040 indexHasKey = @IndexHasKey(level = IConstraint.Level.ERROR, indexName = "index-metadata-role-id", keyFields = @KeyField(target = "@role-id")) 041) 042public class ResponsibleParty { 043 @BoundFlag( 044 formalName = "Responsible Role", 045 description = "A reference to a `role` performed by a `party`.", 046 useName = "role-id", 047 required = true, 048 typeAdapter = TokenAdapter.class 049 ) 050 private String _roleId; 051 052 /** 053 * "Specifies one or more parties responsible for performing the associated <code>role</code>." 054 */ 055 @BoundField( 056 formalName = "Party Universally Unique Identifier Reference", 057 description = "Specifies one or more parties responsible for performing the associated `role`.", 058 useName = "party-uuid", 059 minOccurs = 1, 060 maxOccurs = -1 061 ) 062 @BoundFieldValue( 063 typeAdapter = UuidAdapter.class 064 ) 065 @ValueConstraints( 066 indexHasKey = @IndexHasKey(level = IConstraint.Level.ERROR, indexName = "index-metadata-party-uuid", keyFields = @KeyField) 067 ) 068 @GroupAs( 069 name = "party-uuids", 070 inJson = JsonGroupAsBehavior.LIST 071 ) 072 private List<UUID> _partyUuids; 073 074 @BoundAssembly( 075 formalName = "Property", 076 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 077 useName = "prop", 078 maxOccurs = -1 079 ) 080 @GroupAs( 081 name = "props", 082 inJson = JsonGroupAsBehavior.LIST 083 ) 084 private List<Property> _props; 085 086 @BoundAssembly( 087 formalName = "Link", 088 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 089 useName = "link", 090 maxOccurs = -1 091 ) 092 @GroupAs( 093 name = "links", 094 inJson = JsonGroupAsBehavior.LIST 095 ) 096 private List<Link> _links; 097 098 @BoundField( 099 formalName = "Remarks", 100 description = "Additional commentary about the containing object.", 101 useName = "remarks" 102 ) 103 @BoundFieldValue( 104 typeAdapter = MarkupMultilineAdapter.class 105 ) 106 private MarkupMultiline _remarks; 107 108 public ResponsibleParty() { 109 } 110 111 public String getRoleId() { 112 return _roleId; 113 } 114 115 public void setRoleId(String value) { 116 _roleId = value; 117 } 118 119 public List<UUID> getPartyUuids() { 120 return _partyUuids; 121 } 122 123 public void setPartyUuids(List<UUID> value) { 124 _partyUuids = value; 125 } 126 127 /** 128 * Add a new {@link UUID} item to the underlying collection. 129 * @param item the item to add 130 * @return {@code true} 131 */ 132 public boolean addPartyUuid(UUID item) { 133 UUID value = ObjectUtils.requireNonNull(item,"item cannot be null"); 134 if (_partyUuids == null) { 135 _partyUuids = new LinkedList<>(); 136 } 137 return _partyUuids.add(value); 138 } 139 140 /** 141 * Remove the first matching {@link UUID} item from the underlying collection. 142 * @param item the item to remove 143 * @return {@code true} if the item was removed or {@code false} otherwise 144 */ 145 public boolean removePartyUuid(UUID item) { 146 UUID value = ObjectUtils.requireNonNull(item,"item cannot be null"); 147 return _partyUuids == null ? false : _partyUuids.remove(value); 148 } 149 150 public List<Property> getProps() { 151 return _props; 152 } 153 154 public void setProps(List<Property> value) { 155 _props = value; 156 } 157 158 /** 159 * Add a new {@link Property} item to the underlying collection. 160 * @param item the item to add 161 * @return {@code true} 162 */ 163 public boolean addProp(Property item) { 164 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 165 if (_props == null) { 166 _props = new LinkedList<>(); 167 } 168 return _props.add(value); 169 } 170 171 /** 172 * Remove the first matching {@link Property} item from the underlying collection. 173 * @param item the item to remove 174 * @return {@code true} if the item was removed or {@code false} otherwise 175 */ 176 public boolean removeProp(Property item) { 177 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 178 return _props == null ? false : _props.remove(value); 179 } 180 181 public List<Link> getLinks() { 182 return _links; 183 } 184 185 public void setLinks(List<Link> value) { 186 _links = value; 187 } 188 189 /** 190 * Add a new {@link Link} item to the underlying collection. 191 * @param item the item to add 192 * @return {@code true} 193 */ 194 public boolean addLink(Link item) { 195 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 196 if (_links == null) { 197 _links = new LinkedList<>(); 198 } 199 return _links.add(value); 200 } 201 202 /** 203 * Remove the first matching {@link Link} item from the underlying collection. 204 * @param item the item to remove 205 * @return {@code true} if the item was removed or {@code false} otherwise 206 */ 207 public boolean removeLink(Link item) { 208 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 209 return _links == null ? false : _links.remove(value); 210 } 211 212 public MarkupMultiline getRemarks() { 213 return _remarks; 214 } 215 216 public void setRemarks(MarkupMultiline value) { 217 _remarks = value; 218 } 219 220 @Override 221 public String toString() { 222 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 223 } 224}