Class ResearchObject


  • @Entity
    public class ResearchObject
    extends java.lang.Object
    A representation of a RO produced by the composer. Links to a ResearchObjectProfile using "profile_name" as the foreign key, which links to the profile's "name". Has JSON "content" which is stored in a Postgres "jsonb" field.
    • Constructor Detail

      • ResearchObject

        public ResearchObject()
      • ResearchObject

        public ResearchObject​(ResearchObjectProfile profile)
        Create an RO with the given profile. Initializes the content to the skeleton template.
        Parameters:
        profile -
    • Method Detail

      • getId

        public long getId()
      • getFriendlyId

        public java.lang.String getFriendlyId()
      • getProfileName

        public java.lang.String getProfileName()
      • setProfile

        public void setProfile​(ResearchObjectProfile profile)
        Set the profile of the RO. This will reset the RO's content to the profile's template.
        Parameters:
        profile -
      • getContent

        public com.fasterxml.jackson.databind.node.ObjectNode getContent()
      • setContent

        public void setContent​(com.fasterxml.jackson.databind.node.ObjectNode content)
        Replace RO content without validating first.
        Parameters:
        content -
      • getContentSha256

        public java.lang.String getContentSha256()
      • computeContentSha256

        public java.lang.String computeContentSha256()
                                              throws java.security.NoSuchAlgorithmException,
                                                     com.fasterxml.jackson.core.JsonProcessingException
        Compute a SHA-256 checksum of the RO's JSON content.
        Returns:
        The SHA-256 digest as a hex string.
        Throws:
        java.security.NoSuchAlgorithmException
        com.fasterxml.jackson.core.JsonProcessingException
      • updateContentSha256

        public void updateContentSha256()
        Compute and update the SHA-256 checksum of the content.
      • contentHasChanged

        public boolean contentHasChanged()
      • getField

        public com.fasterxml.jackson.databind.JsonNode getField​(java.lang.String name)
        Get a specific field from the JSON content.
        Parameters:
        name - The name of the field to get.
        Returns:
      • appendToField

        public void appendToField​(java.lang.String field,
                                  com.fasterxml.jackson.databind.JsonNode value)
                           throws ProfileValidationException
        Append the given value to the given list field.
        Parameters:
        field -
        value -
        Throws:
        ProfileValidationException
      • clearField

        public void clearField​(java.lang.String field)
        Reset the given field to its initial value (from the template).
        Parameters:
        field -
      • patchContent

        public void patchContent​(com.fasterxml.jackson.databind.JsonNode jsonPatch)
                          throws java.io.IOException,
                                 com.github.fge.jsonpatch.JsonPatchException
        Apply a JSON patch to the content.
        Parameters:
        jsonPatch -
        Throws:
        java.io.IOException
        com.github.fge.jsonpatch.JsonPatchException
      • supportsAppend

        public boolean supportsAppend​(java.lang.String field)
        Can this field be appended to? (Is it a list?)
        Parameters:
        field -
        Returns:
      • getDepositionUrl

        public java.net.URI getDepositionUrl()
      • setDepositionUrl

        public void setDepositionUrl​(java.net.URI depositionUrl)
      • isMutable

        public boolean isMutable()
      • getCreatedAt

        public java.util.Date getCreatedAt()
      • getModifiedAt

        public java.util.Date getModifiedAt()
      • getDepositedAt

        public java.util.Date getDepositedAt()
      • onCreate

        protected void onCreate()
      • onUpdate

        protected void onUpdate()