fr.paris.lutece.plugins.unittree.service.unit
Interface IUnitService

All Known Implementing Classes:
UnitService

public interface IUnitService

IUnitService


Field Summary
static java.lang.String BEAN_UNIT_SERVICE
           
 
Method Summary
 boolean canCreateSubUnit(int nIdUnit)
          Check if the given id unit, we can create sub unit.
 int createUnit(Unit unit)
          Create a unit
 java.util.List<Unit> findBySectorId(long lIdSector)
          Return all the Unit of the Sector
 java.util.List<Unit> getAllUnits(boolean bGetIdsSector)
          Get all units
 java.util.List<IAction> getListActions(java.lang.String strActionType, java.util.Locale locale, Unit unit, fr.paris.lutece.portal.business.user.AdminUser user)
          Get the list of actions
 Unit getRootUnit(boolean bGetIdsSector)
          Get the root unit
 java.util.List<Unit> getSubUnits(int nIdUnit, boolean bGetIdsSector)
          Get the sub units from a given id unit
 fr.paris.lutece.util.ReferenceList getSubUnitsAsReferenceList(int nIdUnit, java.util.Locale locale)
          Get the sub units as a ReferenceList
 javax.xml.transform.Source getTreeXsl()
          Get the XSL of the tree
 Unit getUnit(int nIdUnit, boolean bGetIdsSector)
          Get the unit
 Unit getUnitByIdUser(int nIdUser, boolean bGetSectors)
          Get the unit by id user
 java.util.List<Unit> getUnitsFirstLevel(boolean bGetIdsSector)
          Get the units first level
 java.lang.String getXMLUnits()
          Get the XML units
 boolean hasSubUnits(int nIdUnit)
          Check if the given id unit has sub units
 boolean isAuthorized(java.lang.String strIdResource, java.lang.String strPermission, fr.paris.lutece.portal.business.user.AdminUser user)
          See isAuthorized(Unit, String, AdminUser)
 boolean isAuthorized(Unit unit, java.lang.String strPermission, fr.paris.lutece.portal.business.user.AdminUser user)
          Check if the given user is authorized to do the action for a given unit.
 boolean isParent(Unit unitParent, Unit unitRef)
          Check if the first unit in parameter is parent of the second unit in parameter
 void removeUnit(int nIdUnit)
          Remove the unit only if the unit does not have sub units
 void updateUnit(Unit unit)
          Update the unit
 

Field Detail

BEAN_UNIT_SERVICE

static final java.lang.String BEAN_UNIT_SERVICE
See Also:
Constant Field Values
Method Detail

getUnit

Unit getUnit(int nIdUnit,
             boolean bGetIdsSector)
Get the unit

Parameters:
nIdUnit - the id unit
bGetIdsSector - true if it must get the ids sector
Returns:
an instance of Unit

getRootUnit

Unit getRootUnit(boolean bGetIdsSector)
Get the root unit

Parameters:
bGetIdsSector - true if it must get the ids sector
Returns:
an instance of Unit

getUnitByIdUser

Unit getUnitByIdUser(int nIdUser,
                     boolean bGetSectors)
Get the unit by id user

Parameters:
nIdUser - the id user
bGetSectors - true if it must get the ids sector
Returns:
an instance of Unit

getAllUnits

java.util.List<Unit> getAllUnits(boolean bGetIdsSector)
Get all units

Parameters:
bGetIdsSector - true if it must get the ids sector
Returns:
a list of Unit

getUnitsFirstLevel

java.util.List<Unit> getUnitsFirstLevel(boolean bGetIdsSector)
Get the units first level

Parameters:
bGetIdsSector - true if it must get the ids sector
Returns:
a list of Unit

getSubUnits

java.util.List<Unit> getSubUnits(int nIdUnit,
                                 boolean bGetIdsSector)
Get the sub units from a given id unit

Parameters:
nIdUnit - the id unit
bGetIdsSector - true if it must get the ids sector
Returns:
a list of Unit

getListActions

java.util.List<IAction> getListActions(java.lang.String strActionType,
                                       java.util.Locale locale,
                                       Unit unit,
                                       fr.paris.lutece.portal.business.user.AdminUser user)
Get the list of actions

Parameters:
strActionType - the action type
locale - the locale
unit - the unit
user - the user
Returns:
a list of IAction

getSubUnitsAsReferenceList

fr.paris.lutece.util.ReferenceList getSubUnitsAsReferenceList(int nIdUnit,
                                                              java.util.Locale locale)
Get the sub units as a ReferenceList

Parameters:
nIdUnit - the id unit
locale - the locale
Returns:
a ReferenceList

getXMLUnits

java.lang.String getXMLUnits()
Get the XML units

Returns:
an XML

getTreeXsl

javax.xml.transform.Source getTreeXsl()
Get the XSL of the tree

Returns:
the XSL

hasSubUnits

boolean hasSubUnits(int nIdUnit)
Check if the given id unit has sub units

Parameters:
nIdUnit - the id unit
Returns:
true if the unit has sub units, false otherwise

isParent

boolean isParent(Unit unitParent,
                 Unit unitRef)
Check if the first unit in parameter is parent of the second unit in parameter

Parameters:
unitParent - the unit parent ?
unitRef - of the unit ?
Returns:
true if there is a parent link between those two units

canCreateSubUnit

boolean canCreateSubUnit(int nIdUnit)
Check if the given id unit, we can create sub unit.
Return false if the unit does not have sub units and has sectors

Parameters:
nIdUnit - the id unit
Returns:
true if we can create sub unit, false otherwise

isAuthorized

boolean isAuthorized(Unit unit,
                     java.lang.String strPermission,
                     fr.paris.lutece.portal.business.user.AdminUser user)
Check if the given user is authorized to do the action for a given unit.
This method calls the service RBACService to check the permission. However, the resource on which the permission must be checked is not necessarily the given unit. It may be a parent unit of the given unit.
There are 5 cases to handle :

Parameters:
unit - the unit
strPermission - the permission
user - the user
Returns:
true if he is authorized, false otherwise

isAuthorized

boolean isAuthorized(java.lang.String strIdResource,
                     java.lang.String strPermission,
                     fr.paris.lutece.portal.business.user.AdminUser user)
See isAuthorized(Unit, String, AdminUser)

Parameters:
strResourceType - the resource type
strIdResource - the id resource
strPermission - the permission
user - the user
Returns:
true if he is authorized, false otherwise

createUnit

@Transactional(value="unittree.transactionManager")
int createUnit(Unit unit)
Create a unit

Parameters:
unit - the unit
Returns:
the id unit

updateUnit

@Transactional(value="unittree.transactionManager")
void updateUnit(Unit unit)
Update the unit

Parameters:
unit - the unit

removeUnit

@Transactional(value="unittree.transactionManager")
void removeUnit(int nIdUnit)
Remove the unit only if the unit does not have sub units

Parameters:
nIdUnit - the id unit

findBySectorId

java.util.List<Unit> findBySectorId(long lIdSector)
Return all the Unit of the Sector

Parameters:
lIdSector - id sector
Returns:
all the Unit of the Sector


Copyright © 2012 Mairie de Paris. All Rights Reserved.