Class UnitHome


  • public final class UnitHome
    extends java.lang.Object
    UnitHome
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addUserToUnit​(int nIdUnit, int nIdUser)
      Add the user to the unit
      static int create​(Unit unit)
      Insert a new unit
      static java.util.List<Unit> findAll()
      Select all units
      static java.util.List<java.lang.Integer> findAllIdsUsers()
      Find all ids users
      static Unit findByCode​(java.lang.String strCode)
      Load the unit
      static java.util.List<Unit> findByFilter​(UnitFilter uFilter)
      Find the units by filter
      static java.util.List<Unit> findByIdUser​(int nIdUser)
      Load an unit by id user
      static Unit findByPrimaryKey​(int nIdUnit)
      Load the unit
      static java.util.List<java.lang.Integer> findIdsUser​(int nIdUnit)
      Find the ids user
      static java.util.Set<java.lang.Integer> getAllSubUnitsId​(int nIdUnit)
      Retrieve Set of all children units id
      static java.util.List<Unit> getDirectSubUnits​(int nIdUnit)
      Retrieve list of direct children units
      static java.util.List<Unit> getUnitWithNoChildren()
      Return all the Unit with no children (level 0)
      static boolean hasSubUnits​(int nIdUnit)
      Check if the given id unit has sub units
      static boolean isUserInUnit​(int nIdUser, int nIdUnit)
      Check if the user is in a given unit
      static void remove​(int nIdUnit)
      Remove a unit
      static void removeUserFromUnit​(int nIdUser, int nIdUnit)
      Remove a user from a unit
      static void removeUsersFromUnit​(int nIdUnit)
      Remove an unit from a given id unit
      static void update​(Unit unit)
      Update a unit
      static void updateParent​(int nIdUnitToMove, int nIdNewParent)
      Update the parent of a unit
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • findByPrimaryKey

        public static Unit findByPrimaryKey​(int nIdUnit)
        Load the unit
        Parameters:
        nIdUnit - the id unit
        Returns:
        an instance of Unit
      • findByCode

        public static Unit findByCode​(java.lang.String strCode)
        Load the unit
        Parameters:
        strCode - the code
        Returns:
        an instance of Unit
      • findByIdUser

        public static java.util.List<Unit> findByIdUser​(int nIdUser)
        Load an unit by id user
        Parameters:
        nIdUser - the id user
        Returns:
        an instance of Unit
      • findByFilter

        public static java.util.List<Unit> findByFilter​(UnitFilter uFilter)
        Find the units by filter
        Parameters:
        uFilter - the filter
        Returns:
        a list of Unit
      • findAll

        public static java.util.List<Unit> findAll()
        Select all units
        Returns:
        a list of Unit
      • findAllIdsUsers

        public static java.util.List<java.lang.Integer> findAllIdsUsers()
        Find all ids users
        Returns:
        a list of ids user
      • findIdsUser

        public static java.util.List<java.lang.Integer> findIdsUser​(int nIdUnit)
        Find the ids user
        Parameters:
        nIdUnit - the id unit
        Returns:
        the list of ids user
      • create

        public static int create​(Unit unit)
        Insert a new unit
        Parameters:
        unit - the unit
        Returns:
        the new primary key
      • remove

        public static void remove​(int nIdUnit)
        Remove a unit
        Parameters:
        nIdUnit - the id unit
      • hasSubUnits

        public static boolean hasSubUnits​(int nIdUnit)
        Check if the given id unit has sub units
        Parameters:
        nIdUnit - the id unit
        Returns:
        true if it has sub units, false otherwise
      • getDirectSubUnits

        public static java.util.List<Unit> getDirectSubUnits​(int nIdUnit)
        Retrieve list of direct children units
        Parameters:
        nIdUnit - the id unit
        Returns:
        List of children units
      • getAllSubUnitsId

        public static java.util.Set<java.lang.Integer> getAllSubUnitsId​(int nIdUnit)
        Retrieve Set of all children units id
        Parameters:
        nIdUnit - the id unit
        Returns:
        Set of all children unit id
      • removeUserFromUnit

        public static void removeUserFromUnit​(int nIdUser,
                                              int nIdUnit)
        Remove a user from a unit
        Parameters:
        nIdUser - the id user
        nIdUnit - The id of the unit
      • removeUsersFromUnit

        public static void removeUsersFromUnit​(int nIdUnit)
        Remove an unit from a given id unit
        Parameters:
        nIdUnit - the id unit
      • update

        public static void update​(Unit unit)
        Update a unit
        Parameters:
        unit - the unit
      • addUserToUnit

        public static void addUserToUnit​(int nIdUnit,
                                         int nIdUser)
        Add the user to the unit
        Parameters:
        nIdUnit - the id unit
        nIdUser - the id user
      • isUserInUnit

        public static boolean isUserInUnit​(int nIdUser,
                                           int nIdUnit)
        Check if the user is in a given unit
        Parameters:
        nIdUser - the id user
        nIdUnit - The id of the unit
        Returns:
        true if the user is in the unit, false otherwise
      • getUnitWithNoChildren

        public static java.util.List<Unit> getUnitWithNoChildren()
        Return all the Unit with no children (level 0)
        Returns:
        all the Unit with no children (level 0)
      • updateParent

        public static void updateParent​(int nIdUnitToMove,
                                        int nIdNewParent)
        Update the parent of a unit
        Parameters:
        nIdUnitToMove - The id of the unit to change the parent of.
        nIdNewParent - The id of the new parent of the unit.