Class PublicationFatherDAO


  • public class PublicationFatherDAO
    extends Object
    This is the Publication Father Data Access Object.
    Author:
    Nicolas Eysseric
    • Method Detail

      • deleteComponentInstanceData

        public static void deleteComponentInstanceData​(String componentInstanceId)
                                                throws SQLException
        Deletes all locations of publications linked to the component instance represented by the given identifier.
        Parameters:
        componentInstanceId - the identifier of the component instance for which the resources must be deleted.
        Throws:
        SQLException - if an error occurs while requesting the data source.
      • addFather

        public static void addFather​(Connection con,
                                     PublicationPK pubPK,
                                     NodePK fatherPK)
                              throws SQLException
        Adds a new father to this publication.
        Parameters:
        con - Connection to the database
        pubPK - the persistence identifier of the publication.
        fatherPK - the father the persistence identifier of the new father of the publication.
        Throws:
        SQLException - if an error occurs while requesting the data source.
        See Also:
        NodePK, PublicationPK
      • updateOrder

        public static void updateOrder​(Connection con,
                                       PublicationPK pubPK,
                                       NodePK fatherPK,
                                       int order)
                                throws SQLException
        Updates the order of the publication among the children of the specified father with the given order value.
        Parameters:
        con - the connection to the data source
        pubPK - the identifier of the publication in the data source.
        fatherPK - the identifier of the father in the data source.
        order - the new order of the publication.
        Throws:
        SQLException - if an error occurs while requesting the data source.
      • resetOrder

        public static void resetOrder​(Connection con,
                                      NodePK fatherPK)
                               throws SQLException
        Reset the order of the publications of the specified father.
        Parameters:
        con - the connection to the data source
        fatherPK - the identifier of the father in the data source.
        Throws:
        SQLException - if an error occurs while requesting the data source.
      • addAlias

        public static void addAlias​(Connection con,
                                    PublicationPK pubPK,
                                    Location location)
                             throws SQLException
        Adds a new alias to the specified publication. If the given location isn't an alias, then an IllegalArgumentException exception is thrown.
        Parameters:
        con - the connection to the data source.
        pubPK - the identifier of the publication in the data source.
        location - the new location of the publication as alias.
        Throws:
        SQLException - if an error occurs while requesting the data source.
      • removeAlias

        public static void removeAlias​(Connection con,
                                       PublicationPK pubPK,
                                       Location location)
                                throws SQLException
        Removes the specified alias among the aliases of the given publication. If the given location isn't an alias, then an IllegalArgumentException exception is thrown.
        Parameters:
        con - the connection to the data source.
        pubPK - the unique identifier of the publication in the data source.
        location - the alias to remove.
        Throws:
        SQLException - if an error occurs while requesting the data source.
      • getAllLocationsByPublicationIds

        public static Map<String,​List<Location>> getAllLocationsByPublicationIds​(Connection con,
                                                                                       Collection<String> pubIds)
                                                                                throws SQLException
        Selects massively simple data about all locations (main or aliases).

        This method is designed for process performance needs.

        Parameters:
        con - the database connection.
        pubIds - the publication ids which are aimed.
        Returns:
        a list of Location instances.
        Throws:
        SQLException - on database error.
      • getLocations

        public static List<Location> getLocations​(Connection con,
                                                  PublicationPK pubPK)
                                           throws SQLException
        Gets all the locations (the original one and the aliases) of the specified publication.
        Parameters:
        con - a connection to the data source.
        pubPK - the unique identifying key of the publication.
        Returns:
        a collection of the locations of the publication.
        Throws:
        SQLException - if an error occurs while executing the SQL request.
      • getLocations

        public static List<Location> getLocations​(Connection con,
                                                  PublicationPK pubPK,
                                                  String compoId)
                                           throws SQLException
        Gets the locations of the specified publication in the given component instance.
        Parameters:
        con - a connection to the data source.
        pubPK - the unique identifying key of the publication.
        compoId - the unique identifier of a component instance.
        Returns:
        a collection of the locations of the publication in the component instance.
        Throws:
        SQLException - if an error occurs while executing the SQL request.
      • getMainLocation

        public static Location getMainLocation​(Connection con,
                                               PublicationPK pubPK)
                                        throws SQLException
        Gets the main location of the specified publication.
        Parameters:
        con - a connection to the data source.
        pubPK - the unique identifying key of the publication.
        Returns:
        the main location of the specified publication or null.
        Throws:
        SQLException - if an error occurs while requesting the data source.
      • removeFather

        public static void removeFather​(Connection con,
                                        PublicationPK pubPK,
                                        NodePK fatherPK)
                                 throws SQLException
        Removes a father of this publication.
        Parameters:
        con - Connection to database
        pubPK - the unique identifier of the publication in the data source.
        fatherPK - the unique identifier of the father to delete in the data source.
        Throws:
        SQLException - if an error occurs while requesting the data source.
        See Also:
        NodePK, PublicationPK
      • removeAllFathers

        public static void removeAllFathers​(Connection con,
                                            PublicationPK pubPK)
                                     throws SQLException
        Deletes all the fathers of this publication. The publication will be then orphaned.
        Parameters:
        con - connection to the database
        pubPK - the unique identifier of the publication.
        Throws:
        SQLException - if an error occurs while requesting the database.
        See Also:
        PublicationPK
      • getAllFatherPKInSamePublicationComponentInstance

        public static List<NodePK> getAllFatherPKInSamePublicationComponentInstance​(Connection con,
                                                                                    PublicationPK pubPK)
                                                                             throws SQLException
        Gets the identifiers of all the fathers of the specified publication and that are in the same component instance the publication is.
        Parameters:
        con - the connection to the database
        pubPK - the unique identifier of the publication.
        Returns:
        a collection of all of the persistence identifiers of the publication's fathers.
        Throws:
        SQLException - if an error occurs while requesting the data source.
        See Also:
        NodePK, PublicationPK
      • getPubPKsInFatherPK

        public static Collection<PublicationPK> getPubPKsInFatherPK​(Connection con,
                                                                    NodePK fatherPK)
                                                             throws SQLException
        Gets the identifiers of all of the publications that have as father at least one of the specified ones.
        Parameters:
        con - the connection to the data source.
        fatherPK - the unique identifier of the fathers in the data source.
        Returns:
        a collection of the publication's identifiers in the data source.
        Throws:
        SQLException - if an error occurs while requesting the data source.
      • getAliases

        public static List<Location> getAliases​(Connection con,
                                                PublicationPK pubPK)
                                         throws SQLException
        Gets all the aliases of the specified publication.
        Parameters:
        con - a connection to the data source.
        pubPK - the unique identifying key of the publication.
        Returns:
        a collection of the aliases of the publication, each of them being a location.
        Throws:
        SQLException - if an error occurs while executing the SQL request.