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