Interface RelationshipService

    • Method Detail

      • findByItem

        List<Relationship> findByItem​(Context context,
                                      Item item)
                               throws SQLException
        Retrieves the list of Relationships currently in the system for which the given Item is either a leftItem or a rightItem object
        Parameters:
        context - The relevant DSpace context
        item - The Item that has to be the left or right item for the relationship to be included in the list
        Returns:
        The list of relationships for which each relationship adheres to the above listed constraint
        Throws:
        SQLException - If something goes wrong
      • findByItem

        List<Relationship> findByItem​(Context context,
                                      Item item,
                                      Integer limit,
                                      Integer offset)
                               throws SQLException
        Retrieves the list of Relationships currently in the system for which the given Item is either a leftItem or a rightItem object
        Parameters:
        context - The relevant DSpace context
        item - The Item that has to be the left or right item for the relationship to be included in the list
        limit - paging limit
        offset - paging offset
        Returns:
        The list of relationships for which each relationship adheres to the above listed constraint
        Throws:
        SQLException - If something goes wrong
      • findAll

        List<Relationship> findAll​(Context context)
                            throws SQLException
        Retrieves the full list of relationships currently in the system
        Parameters:
        context - The relevant DSpace context
        Returns:
        The list of all relationships currently in the system
        Throws:
        SQLException - If something goes wrong
      • findAll

        List<Relationship> findAll​(Context context,
                                   Integer limit,
                                   Integer offset)
                            throws SQLException
        Retrieves the full list of relationships currently in the system
        Parameters:
        context - The relevant DSpace context
        limit - paging limit
        offset - paging offset
        Returns:
        The list of all relationships currently in the system
        Throws:
        SQLException - If something goes wrong
      • create

        Relationship create​(Context context,
                            Relationship relationship)
                     throws SQLException,
                            AuthorizeException
        This method creates a relationship object in the database equal to the given relationship param if this is a valid relationship
        Parameters:
        context - The relevant DSpace context
        relationship - The relationship that will be created in the database if it is valid
        Returns:
        The created relationship with updated place variables
        Throws:
        SQLException - If something goes wrong
        AuthorizeException - If something goes wrong with authorizations
      • findNextLeftPlaceByLeftItem

        int findNextLeftPlaceByLeftItem​(Context context,
                                        Item item)
                                 throws SQLException
        This method returns the next leftplace integer to use for a relationship with this item as the leftItem
        Parameters:
        context - The relevant DSpace context
        item - The item that has to be the leftItem of a relationship for it to qualify
        Returns:
        The next integer to be used for the leftplace of a relationship with the given item as a left item
        Throws:
        SQLException - If something goes wrong
      • findNextRightPlaceByRightItem

        int findNextRightPlaceByRightItem​(Context context,
                                          Item item)
                                   throws SQLException
        This method returns the next rightplace integer to use for a relationship with this item as the rightItem
        Parameters:
        context - The relevant DSpace context
        item - The item that has to be the rightitem of a relationship for it to qualify
        Returns:
        The next integer to be used for the rightplace of a relationship with the given item as a right item
        Throws:
        SQLException - If something goes wrong
      • findByItemAndRelationshipType

        List<Relationship> findByItemAndRelationshipType​(Context context,
                                                         Item item,
                                                         RelationshipType relationshipType)
                                                  throws SQLException
        This method returns a list of Relationships for which the leftItem or rightItem is equal to the given Item object and for which the RelationshipType object is equal to the relationshipType property
        Parameters:
        context - The relevant DSpace context
        item - The Item object to be matched on the leftItem or rightItem for the relationship
        relationshipType - The RelationshipType object that will be used to check the Relationship on
        Returns:
        The list of Relationship objects that have the given Item object as leftItem or rightItem and for which the relationshipType property is equal to the given RelationshipType
        Throws:
        SQLException - If something goes wrong
      • findByItemAndRelationshipType

        List<Relationship> findByItemAndRelationshipType​(Context context,
                                                         Item item,
                                                         RelationshipType relationshipType,
                                                         int limit,
                                                         int offset)
                                                  throws SQLException
        This method returns a list of Relationships for which the leftItem or rightItem is equal to the given Item object and for which the RelationshipType object is equal to the relationshipType property
        Parameters:
        context - The relevant DSpace context
        item - The Item object to be matched on the leftItem or rightItem for the relationship
        relationshipType - The RelationshipType object that will be used to check the Relationship on
        Returns:
        The list of Relationship objects that have the given Item object as leftItem or rightItem and for which the relationshipType property is equal to the given RelationshipType
        Throws:
        SQLException - If something goes wrong
      • findByItemAndRelationshipType

        List<Relationship> findByItemAndRelationshipType​(Context context,
                                                         Item item,
                                                         RelationshipType relationshipType,
                                                         boolean isLeft,
                                                         int limit,
                                                         int offset)
                                                  throws SQLException
        This method returns a list of Relationships for which the leftItem or rightItem is equal to the given Item object and for which the RelationshipType object is equal to the relationshipType property
        Parameters:
        context - The relevant DSpace context
        item - The Item object to be matched on the leftItem or rightItem for the relationship
        relationshipType - The RelationshipType object that will be used to check the Relationship on
        isLeft - Is the item left or right
        Returns:
        The list of Relationship objects that have the given Item object as leftItem or rightItem and for which the relationshipType property is equal to the given RelationshipType
        Throws:
        SQLException - If something goes wrong
      • updatePlaceInRelationship

        void updatePlaceInRelationship​(Context context,
                                       Relationship relationship)
                                throws SQLException,
                                       AuthorizeException
        This method will update the place for the Relationship and all other relationships found by the items and relationship type of the given Relationship. It will give this Relationship the last place in both the left and right place determined by querying for the list of leftRelationships and rightRelationships by the leftItem, rightItem and relationshipType of the given Relationship.
        Parameters:
        context - The relevant DSpace context
        relationship - The Relationship object that will have it's place updated and that will be used to retrieve the other relationships whose place might need to be updated
        Throws:
        SQLException - If something goes wrong
        AuthorizeException
      • updateItem

        void updateItem​(Context context,
                        Item relatedItem)
                 throws SQLException,
                        AuthorizeException
        This method will update the given item's metadata order. If the relationships for the item have been modified and will calculate the place based on a metadata field, this function will ensure the place is calculated.
        Parameters:
        context - The relevant DSpace context
        relatedItem - The Item for which the list of Relationship location is calculated based on a metadata field
        Throws:
        SQLException - If something goes wrong
        AuthorizeException - If the user is not authorized to update the item
      • findByRelationshipType

        List<Relationship> findByRelationshipType​(Context context,
                                                  RelationshipType relationshipType)
                                           throws SQLException
        This method returns a list of Relationship objects for which the relationshipType property is equal to the given RelationshipType object
        Parameters:
        context - The relevant DSpace context
        relationshipType - The RelationshipType object that will be used to check the Relationship on
        Returns:
        The list of Relationship objects for which the given RelationshipType object is equal to the relationshipType property
        Throws:
        SQLException - If something goes wrong
      • findByRelationshipType

        List<Relationship> findByRelationshipType​(Context context,
                                                  RelationshipType relationshipType,
                                                  Integer limit,
                                                  Integer offset)
                                           throws SQLException
        This method returns a list of Relationship objets for which the relationshipType property is equal to the given RelationshipType object
        Parameters:
        context - The relevant DSpace context
        relationshipType - The RelationshipType object that will be used to check the Relationship on
        limit - paging limit
        offset - paging offset
        Returns:
        The list of Relationship objects for which the given RelationshipType object is equal to the relationshipType property
        Throws:
        SQLException - If something goes wrong
      • create

        Relationship create​(Context c,
                            Item leftItem,
                            Item rightItem,
                            RelationshipType relationshipType,
                            int leftPlace,
                            int rightPlace,
                            String leftwardValue,
                            String rightwardValue)
                     throws AuthorizeException,
                            SQLException
        This method is used to construct a Relationship object with all it's variables
        Parameters:
        c - The relevant DSpace context
        leftItem - The leftItem Item object for the relationship
        rightItem - The rightItem Item object for the relationship
        relationshipType - The RelationshipType object for the relationship
        leftPlace - The leftPlace integer for the relationship
        rightPlace - The rightPlace integer for the relationship
        leftwardValue - The leftwardValue string for the relationship
        rightwardValue - The rightwardValue string for the relationship
        Returns:
        The created Relationship object with the given properties
        Throws:
        AuthorizeException - If something goes wrong
        SQLException - If something goes wrong
      • create

        Relationship create​(Context c,
                            Item leftItem,
                            Item rightItem,
                            RelationshipType relationshipType,
                            int leftPlace,
                            int rightPlace)
                     throws AuthorizeException,
                            SQLException
        This method is used to construct a Relationship object with all it's variables, except the leftward and rightward labels
        Parameters:
        c - The relevant DSpace context
        leftItem - The leftItem Item object for the relationship
        rightItem - The rightItem Item object for the relationship
        relationshipType - The RelationshipType object for the relationship
        leftPlace - The leftPlace integer for the relationship
        rightPlace - The rightPlace integer for the relationship
        Returns:
        The created Relationship object with the given properties
        Throws:
        AuthorizeException - If something goes wrong
        SQLException - If something goes wrong
      • findByTypeName

        List<Relationship> findByTypeName​(Context context,
                                          String typeName)
                                   throws SQLException
        This method returns a list of Relationship objects for the given typeName
        Parameters:
        context - The relevant DSpace context
        typeName - The leftward or rightward typeName of the relationship type
        Returns:
        A list of Relationship objects that have the given RelationshipType object as the relationshipType property
        Throws:
        SQLException - If something goes wrong
      • findByTypeName

        List<Relationship> findByTypeName​(Context context,
                                          String typeName,
                                          Integer limit,
                                          Integer offset)
                                   throws SQLException
        This method returns a list of Relationship objects for the given typeName
        Parameters:
        context - The relevant DSpace context
        typeName - The leftward or rightward typeName of the relationship type
        limit - paging limit
        offset - paging offset
        Returns:
        A list of Relationship objects that have the given RelationshipType object as the relationshipType property
        Throws:
        SQLException - If something goes wrong
      • countTotal

        int countTotal​(Context context)
                throws SQLException
        counts all relationships
        Parameters:
        context - DSpace context object
        Returns:
        total relationships
        Throws:
        SQLException - if database error
      • countByRelationshipType

        int countByRelationshipType​(Context context,
                                    RelationshipType relationshipType)
                             throws SQLException
        Count total number of relationships (rows in relationship table) by a relationship type
        Parameters:
        context - context
        relationshipType - relationship type to filter by
        Returns:
        total count
        Throws:
        SQLException - if database error
      • countByItem

        int countByItem​(Context context,
                        Item item)
                 throws SQLException
        This method returns a count of Relationship objects that have the given Item object as a leftItem or a rightItem
        Parameters:
        context - The relevant DSpace context
        item - The item that should be either a leftItem or a rightItem of all the Relationship objects in the returned list
        Returns:
        The list of Relationship objects that contain either a left or a right item that is equal to the given item
        Throws:
        SQLException - If something goes wrong
      • countByItemAndRelationshipType

        int countByItemAndRelationshipType​(Context context,
                                           Item item,
                                           RelationshipType relationshipType)
                                    throws SQLException
        Count total number of relationships (rows in relationship table) by a relationship type
        Parameters:
        context - context
        relationshipType - relationship type to filter by
        Returns:
        total count
        Throws:
        SQLException - if database error
      • countByTypeName

        int countByTypeName​(Context context,
                            String typeName)
                     throws SQLException
        Count total number of relationships (rows in relationship table) by a relationship leftward or rightward typeName
        Parameters:
        context - context
        typeName - typeName of relationship
        Returns:
        total count
        Throws:
        SQLException - if database error
      • delete

        void delete​(Context context,
                    Relationship relationship,
                    boolean copyToLeftItem,
                    boolean copyToRightItem)
             throws SQLException,
                    AuthorizeException
        This method is used to delete a Relationship whilst given the possibility to copy the Virtual Metadata created by this relationship to the left and/or right item
        Parameters:
        context - The relevant DSpace context
        relationship - The relationship to be deleted
        copyToLeftItem - A boolean indicating whether we should copy metadata to the left item or not
        copyToRightItem - A boolean indicating whether we should copy metadata to the right item or not
        Throws:
        SQLException
        AuthorizeException