Action.java
package gov.nist.secauto.oscal.lib.model;
import gov.nist.secauto.metaschema.core.datatype.adapter.DateTimeWithTZAdapter;
import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
import gov.nist.secauto.metaschema.core.datatype.adapter.UriAdapter;
import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter;
import gov.nist.secauto.metaschema.core.model.IBoundObject;
import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.databind.model.annotations.IndexHasKey;
import gov.nist.secauto.metaschema.databind.model.annotations.KeyField;
import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
import java.lang.Override;
import java.lang.String;
import java.net.URI;
import java.time.ZonedDateTime;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* An action applied by a role within a given party to the content.
*/
@MetaschemaAssembly(
formalName = "Action",
description = "An action applied by a role within a given party to the content.",
name = "action",
moduleClass = OscalMetadataModule.class,
valueConstraints = @ValueConstraints(allowedValues = {@AllowedValues(level = IConstraint.Level.ERROR, target = "./system/@value", allowOthers = true, values = @AllowedValue(value = "http://csrc.nist.gov/ns/oscal", description = "This value identifies action types defined in the NIST OSCAL namespace.")), @AllowedValues(level = IConstraint.Level.ERROR, target = "./type[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@value", values = {@AllowedValue(value = "approval", description = "An approval of a document instance's content."), @AllowedValue(value = "request-changes", description = "A request from the responisble party or parties to change the content.")})}, indexHasKey = {@IndexHasKey(level = IConstraint.Level.ERROR, target = "responsible-party", indexName = "index-metadata-role-id", keyFields = @KeyField(target = "@role-id")), @IndexHasKey(level = IConstraint.Level.ERROR, target = "responsible-party", indexName = "index-metadata-party-uuid", keyFields = @KeyField(target = "party-uuid"))})
)
public class Action implements IBoundObject {
private final IMetaschemaData __metaschemaData;
/**
* "A unique identifier that can be used to reference this defined action elsewhere in an OSCAL document. A UUID should be consistently used for a given location across revisions of the document."
*/
@BoundFlag(
formalName = "Action Universally Unique Identifier",
description = "A unique identifier that can be used to reference this defined action elsewhere in an OSCAL document. A UUID should be consistently used for a given location across revisions of the document.",
name = "uuid",
required = true,
typeAdapter = UuidAdapter.class
)
private UUID _uuid;
/**
* "The date and time when the action occurred."
*/
@BoundFlag(
formalName = "Action Occurrence Date",
description = "The date and time when the action occurred.",
name = "date",
typeAdapter = DateTimeWithTZAdapter.class
)
private ZonedDateTime _date;
/**
* "The type of action documented by the assembly, such as an approval."
*/
@BoundFlag(
formalName = "Action Type",
description = "The type of action documented by the assembly, such as an approval.",
name = "type",
required = true,
typeAdapter = TokenAdapter.class
)
private String _type;
/**
* "Specifies the action type system used."
*/
@BoundFlag(
formalName = "Action Type System",
description = "Specifies the action type system used.",
name = "system",
required = true,
typeAdapter = UriAdapter.class,
remarks = "Provides a means to segment the value space for the `type`, so that different organizations and individuals can assert control over the allowed `action`'s `type`. This allows the semantics associated with a given `type` to be defined on an organization-by-organization basis.\n"
+ "\n"
+ "An organization MUST use a URI that they have control over. e.g., a domain registered to the organization in a URI, a registered uniform resource names (URN) namespace."
)
private URI _system;
@BoundAssembly(
formalName = "Property",
description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
useName = "prop",
maxOccurs = -1,
groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
)
private List<Property> _props;
@BoundAssembly(
formalName = "Link",
description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
useName = "link",
maxOccurs = -1,
groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
)
private List<Link> _links;
@BoundAssembly(
formalName = "Responsible Party",
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.",
useName = "responsible-party",
maxOccurs = -1,
groupAs = @GroupAs(name = "responsible-parties", inJson = JsonGroupAsBehavior.LIST)
)
private List<ResponsibleParty> _responsibleParties;
@BoundField(
formalName = "Remarks",
description = "Additional commentary about the containing object.",
useName = "remarks",
typeAdapter = MarkupMultilineAdapter.class
)
private MarkupMultiline _remarks;
public Action() {
this(null);
}
public Action(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
public UUID getUuid() {
return _uuid;
}
public void setUuid(UUID value) {
_uuid = value;
}
public ZonedDateTime getDate() {
return _date;
}
public void setDate(ZonedDateTime value) {
_date = value;
}
public String getType() {
return _type;
}
public void setType(String value) {
_type = value;
}
public URI getSystem() {
return _system;
}
public void setSystem(URI value) {
_system = value;
}
public List<Property> getProps() {
return _props;
}
public void setProps(List<Property> value) {
_props = value;
}
/**
* Add a new {@link Property} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addProp(Property item) {
Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_props == null) {
_props = new LinkedList<>();
}
return _props.add(value);
}
/**
* Remove the first matching {@link Property} item from the underlying collection.
* @param item the item to remove
* @return {@code true} if the item was removed or {@code false} otherwise
*/
public boolean removeProp(Property item) {
Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _props != null && _props.remove(value);
}
public List<Link> getLinks() {
return _links;
}
public void setLinks(List<Link> value) {
_links = value;
}
/**
* Add a new {@link Link} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addLink(Link item) {
Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_links == null) {
_links = new LinkedList<>();
}
return _links.add(value);
}
/**
* Remove the first matching {@link Link} item from the underlying collection.
* @param item the item to remove
* @return {@code true} if the item was removed or {@code false} otherwise
*/
public boolean removeLink(Link item) {
Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _links != null && _links.remove(value);
}
public List<ResponsibleParty> getResponsibleParties() {
return _responsibleParties;
}
public void setResponsibleParties(List<ResponsibleParty> value) {
_responsibleParties = value;
}
/**
* Add a new {@link ResponsibleParty} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addResponsibleParty(ResponsibleParty item) {
ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_responsibleParties == null) {
_responsibleParties = new LinkedList<>();
}
return _responsibleParties.add(value);
}
/**
* Remove the first matching {@link ResponsibleParty} item from the underlying collection.
* @param item the item to remove
* @return {@code true} if the item was removed or {@code false} otherwise
*/
public boolean removeResponsibleParty(ResponsibleParty item) {
ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _responsibleParties != null && _responsibleParties.remove(value);
}
public MarkupMultiline getRemarks() {
return _remarks;
}
public void setRemarks(MarkupMultiline value) {
_remarks = value;
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
}