Class DerivatedRelatedResourceGroup<I extends Instance>

java.lang.Object
org.gcube.resourcemanagement.resource.DerivatedRelatedResourceGroup<I>
Type Parameters:
I - the type of instances contained in the resource group, which extends the Instance class.
All Implemented Interfaces:
Comparable<DerivatedRelatedResourceGroup<I>>

public class DerivatedRelatedResourceGroup<I extends Instance> extends Object implements Comparable<DerivatedRelatedResourceGroup<I>>
Author:
Luca Frosini (ISTI - CNR) Represents a group of related resources that are derived from a common ancestor. This class implements the Comparable interface to allow comparison based on the name of the resource group.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.gcube.informationsystem.model.reference.entities.Resource
    The ancestor resource from which this group is derived.
    protected String
    The description of the resource group.
    protected final Class<I>
    The class type of the instances contained in the resource group.
    protected Set<I>
    The list of instances contained in the resource group.
    protected final org.gcube.com.fasterxml.jackson.databind.ObjectMapper
    The ObjectMapper used for JSON serialization and deserialization.
    protected Integer
    The maximum number of instances in the resource group.
    protected int
    The minimum number of instances in the resource group.
    protected String
    The name of the resource group.
    protected List<org.gcube.informationsystem.model.reference.entities.Resource>
    The list of related resources associated with this resource group.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new DerivatedRelatedResourceGroup with the specified instance class type.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addInstance(I instance)
     
    void
     
    int
    Compare two DerivatedRelatedResourceGroup by name
    boolean
     
    org.gcube.informationsystem.model.reference.entities.Resource
    Returns the ancestor resource from which this group is derived.
    Returns the description of the resource group.
    Returns the class type of the instances contained in the resource group.
    Returns the list of instances contained in the resource group.
    Returns the maximum number of instances in the resource group.
    int
    Returns the minimum number of instances in the resource group.
    Returns the name of the resource group.
    List<org.gcube.informationsystem.model.reference.entities.Resource>
    Returns the list of related resources associated with this resource group.
    int
    Returns the hash code of the DerivatedRelatedResourceGroup based on the name.
    void
    setAncestor(org.gcube.informationsystem.model.reference.entities.Resource ancestor)
    Sets the ancestor resource from which this group is derived.
    void
    setDescription(String description)
    Sets the description of the resource group.
    void
    setInstances(Set<I> instances)
     
    void
    Sets the maximum number of instances in the resource group.
    void
    setMin(int min)
    Sets the minimum number of instances in the resource group.
    void
    Sets the name of the resource group.
    void
    setRelatedResources(List<org.gcube.informationsystem.model.reference.entities.Resource> relatedResources)
    Sets the list of related resources associated with this resource group.
    Returns a JSON representation of the DerivatedRelatedResourceGroup.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ancestor

      protected org.gcube.informationsystem.model.reference.entities.Resource ancestor
      The ancestor resource from which this group is derived.
    • mapper

      protected final org.gcube.com.fasterxml.jackson.databind.ObjectMapper mapper
      The ObjectMapper used for JSON serialization and deserialization.
    • instanceClass

      protected final Class<I extends Instance> instanceClass
      The class type of the instances contained in the resource group.
    • name

      protected String name
      The name of the resource group.
    • description

      protected String description
      The description of the resource group.
    • min

      protected int min
      The minimum number of instances in the resource group.
    • max

      protected Integer max
      The maximum number of instances in the resource group.
    • instances

      protected Set<I extends Instance> instances
      The list of instances contained in the resource group.
    • relatedResources

      protected List<org.gcube.informationsystem.model.reference.entities.Resource> relatedResources
      The list of related resources associated with this resource group.
  • Constructor Details

    • DerivatedRelatedResourceGroup

      public DerivatedRelatedResourceGroup(Class<I> instanceClass)
      Constructs a new DerivatedRelatedResourceGroup with the specified instance class type.
      Parameters:
      instanceClass - the class type of the instances contained in the resource group
  • Method Details

    • getInstanceClass

      public Class<I> getInstanceClass()
      Returns the class type of the instances contained in the resource group.
      Returns:
      the class type of the instances
    • getAncestor

      public org.gcube.informationsystem.model.reference.entities.Resource getAncestor()
      Returns the ancestor resource from which this group is derived.
      Returns:
      the ancestor resource
    • setAncestor

      public void setAncestor(org.gcube.informationsystem.model.reference.entities.Resource ancestor)
      Sets the ancestor resource from which this group is derived.
      Parameters:
      ancestor - the ancestor resource
    • getName

      public String getName()
      Returns the name of the resource group.
      Returns:
      the name of the resource group
    • setName

      public void setName(String name)
      Sets the name of the resource group.
      Parameters:
      name - the name of the resource group
    • getDescription

      public String getDescription()
      Returns the description of the resource group.
      Returns:
      the description of the resource group
    • setDescription

      public void setDescription(String description)
      Sets the description of the resource group.
      Parameters:
      description - the description of the resource group
    • getMin

      public int getMin()
      Returns the minimum number of instances in the resource group.
      Returns:
      the minimum number of instances
    • setMin

      public void setMin(int min)
      Sets the minimum number of instances in the resource group.
      Parameters:
      min - the minimum number of instances
    • getMax

      public Integer getMax()
      Returns the maximum number of instances in the resource group.
      Returns:
      the maximum number of instances
    • setMax

      public void setMax(Integer max)
      Sets the maximum number of instances in the resource group.
      Parameters:
      max - the maximum number of instances
    • getRelatedResources

      public List<org.gcube.informationsystem.model.reference.entities.Resource> getRelatedResources()
      Returns the list of related resources associated with this resource group.
      Returns:
      the list of related resources
    • setRelatedResources

      public void setRelatedResources(List<org.gcube.informationsystem.model.reference.entities.Resource> relatedResources)
      Sets the list of related resources associated with this resource group.
      Parameters:
      relatedResources - the list of related resources
    • getInstances

      public Set<I> getInstances() throws jakarta.ws.rs.WebApplicationException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Returns the list of instances contained in the resource group. If the instances are not already initialized, they are derived from the related resources. Please note that Instance is a format to represent the summary of a resource, so the instances are just a minimal representation of the related resources. In other words, the instances and related resources are two sides of the same coin.
      Returns:
      the list of instances
      Throws:
      jakarta.ws.rs.WebApplicationException - if there is an error during the web application process
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if there is an error with the resource registry
    • setInstances

      public void setInstances(Set<I> instances)
    • addInstance

      public void addInstance(I instance)
    • addInstances

      public void addInstances(Collection<I> instances)
    • toString

      public String toString()
      Returns a JSON representation of the DerivatedRelatedResourceGroup.
      Overrides:
      toString in class Object
      Returns:
      the JSON representation
    • compareTo

      public int compareTo(DerivatedRelatedResourceGroup<I> o)
      Compare two DerivatedRelatedResourceGroup by name
      Specified by:
      compareTo in interface Comparable<I extends Instance>
      Parameters:
      o -
      Returns:
      the comparison result
    • hashCode

      public int hashCode()
      Returns the hash code of the DerivatedRelatedResourceGroup based on the name.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object