Class AbstractRecord

java.lang.Object
org.gcube.documentstore.records.implementation.AbstractRecord
All Implemented Interfaces:
Serializable, Comparable<Record>, Record

public abstract class AbstractRecord extends Object implements Record
Author:
Luca Frosini (ISTI - CNR)
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getAllFields

      protected static Set<Field> getAllFields(Class<?> type)
    • initializeValidation

      protected void initializeValidation()
    • getQuerableKeys

      public SortedSet<String> getQuerableKeys() throws Exception
      Specified by:
      getQuerableKeys in interface Record
      Returns:
      Querable Keys as SortedSet
      Throws:
      Exception
    • cleanExtraFields

      protected void cleanExtraFields()
    • init

      protected void init()
      Initialize variable
    • getRequiredFields

      public Set<String> getRequiredFields()
      Specified by:
      getRequiredFields in interface Record
      Returns:
      a Set containing the keys of required fields The returned Set MUST be a copy of the internal representation. Any modification to the returned Set MUST not affect the object
    • getComputedFields

      public Set<String> getComputedFields()
      Specified by:
      getComputedFields in interface Record
      Returns:
      a Set containing the keys of computed fields The returned Set MUST be a copy of the internal representation. Any modification to the returned Set MUST not affect the object
    • getAggregatedFields

      public Set<String> getAggregatedFields()
    • getId

      public String getId()
      Return the unique id for this Record
      Specified by:
      getId in interface Record
      Returns:
      Record Unique ID
    • setId

      public void setId(String id) throws InvalidValueException
      The ID SHOULD be automatically created by the implementation Class. Set the ID only if you really know what you are going to do. Set the unique id for this Record
      Specified by:
      setId in interface Record
      Parameters:
      id - Unique ID
      Throws:
      InvalidValueException
    • timestampToCalendar

      public static Calendar timestampToCalendar(long millis)
    • getCreationTime

      public Calendar getCreationTime()
      Return the instant when this Record was created.
      Specified by:
      getCreationTime in interface Record
      Returns:
      the creation time for this Record
    • setCreationTime

      public void setCreationTime(Calendar creationTime) throws InvalidValueException
      The CreationTime is automatically created by the implementation Class. Set the CreationTime only if you really know what you are going to do. Set the instant when this Record was created.
      Specified by:
      setCreationTime in interface Record
      Parameters:
      creationTime - Creation Time
      Throws:
      InvalidValueException
    • getResourceProperties

      public Map<String,Serializable> getResourceProperties()
      Return all resource-specific properties. The returned Map is a copy of the internal representation. Any modification to the returned Map MUST not affect the object
      Specified by:
      getResourceProperties in interface Record
      Returns:
      a Map containing the properties
    • setResourceProperties

      public void setResourceProperties(Map<String,? extends Serializable> properties) throws InvalidValueException
      Set all resource-specific properties, replacing existing ones
      Specified by:
      setResourceProperties in interface Record
      Throws:
      InvalidValueException
    • getResourceProperty

      public Serializable getResourceProperty(String key)
      Return the value of the given resource property.
      Specified by:
      getResourceProperty in interface Record
      Parameters:
      key - the key of the requested property
      Returns:
      the value of the given resource property
    • removeResourceProperty

      public void removeResourceProperty(String key)
      Description copied from interface: Record
      Remove a property from Record. This API is intended for intern use only.
      Specified by:
      removeResourceProperty in interface Record
      Parameters:
      key - the key of the requested property to remove
    • setResourceProperty

      public void setResourceProperty(String key, Serializable value) throws InvalidValueException
      Set the value of the given resource property. If the key has the value of one of the predefined property, the value is validated.
      Specified by:
      setResourceProperty in interface Record
      Parameters:
      key - the key of the requested property
      value - the value of the given resource property
      Throws:
      InvalidValueException
    • setEndTime

      protected void setEndTime(Calendar endTime) throws InvalidValueException
      Set the right end of the time interval covered by this Record
      Parameters:
      endTime - End Time
      Throws:
      InvalidValueException
    • getEndTimeInMillis

      protected long getEndTimeInMillis()
      Return the right end of the time interval covered by this Record
      Returns:
      End Time
    • getEndTimeAsCalendar

      protected Calendar getEndTimeAsCalendar()
      Return the right end of the time interval covered by this Record
      Returns:
      End Time
    • getOperationCount

      protected int getOperationCount()
    • setOperationCount

      protected void setOperationCount(int operationCount) throws InvalidValueException
      Throws:
      InvalidValueException
    • getStartTimeInMillis

      protected long getStartTimeInMillis()
      Return the left end of the time interval covered by this Record
      Returns:
      Start Time
    • getStartTimeAsCalendar

      protected Calendar getStartTimeAsCalendar()
      Return the left end of the time interval covered by this Record
      Returns:
      Start Time
    • setStartTime

      protected void setStartTime(Calendar startTime) throws InvalidValueException
      Set the left end of the time interval covered by this Record
      Parameters:
      startTime - Start Time
      Throws:
      InvalidValueException
    • setAggregated

      protected void setAggregated(Boolean aggregate) throws InvalidValueException
      Set the boolean aggregate by this Record
      Parameters:
      aggregate -
      Throws:
      InvalidValueException
    • isAggregated

      protected Boolean isAggregated()
    • validateField

      protected Serializable validateField(String key, Serializable value) throws InvalidValueException
      Throws:
      InvalidValueException
    • computeField

      protected void computeField(String key) throws InvalidValueException
      Throws:
      InvalidValueException
    • validateProperties

      protected Map<String,? extends Serializable> validateProperties(Map<String,? extends Serializable> properties) throws InvalidValueException
      Throws:
      InvalidValueException
    • validate

      public void validate() throws InvalidValueException
      Validate the Resource Record. The validation check if all the Required Field are set and has valid value.
      Specified by:
      validate in interface Record
      Throws:
      InvalidValueException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(Record record)
      Compare this Record instance with the one provided as argument
      Specified by:
      compareTo in interface Comparable<Record>
      Parameters:
      record - the Record to compare
      Returns:
      0 is and only if the Record provided as parameter contains all and ONLY the parameters contained in this instance. If the number of parameters differs, the methods return the difference between the number of parameter in this instance and the ones in the Record provided as parameter. If the size is the same but the Record provided as parameter does not contains all parameters in this instance, -1 is returned.