fr.paris.lutece.plugins.unittree.service.unit
Class UnitService

java.lang.Object
  extended by fr.paris.lutece.plugins.unittree.service.unit.UnitService
All Implemented Interfaces:
IUnitService

public class UnitService
extends java.lang.Object
implements IUnitService

UnitService


Field Summary
 
Fields inherited from interface fr.paris.lutece.plugins.unittree.service.unit.IUnitService
BEAN_UNIT_SERVICE
 
Constructor Summary
UnitService()
           
 
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)
          Find by sector id
 java.util.List<Unit> getAllUnits(boolean bGetSectors)
          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 bGetSectors)
          Get the root unit
 java.util.List<Unit> getSubUnits(int nIdUnit, boolean bGetSectors)
          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()
          Gets the XSL to display user spaces tree
 Unit getUnit(int nIdUnit, boolean bGetSectors)
          Get the unit
 Unit getUnitByIdUser(int nIdUser, boolean bGetSectors)
          Get the unit by id user
 java.util.List<Unit> getUnitsFirstLevel(boolean bGetSectors)
          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 strIdUnit, java.lang.String strPermission, fr.paris.lutece.portal.business.user.AdminUser user)
          See IUnitService.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnitService

public UnitService()
Method Detail

getUnit

public Unit getUnit(int nIdUnit,
                    boolean bGetSectors)
Get the unit

Specified by:
getUnit in interface IUnitService
Parameters:
nIdUnit - the id unit
bGetSectors - true if it must get the ids sector
Returns:
an instance of Unit

getRootUnit

public Unit getRootUnit(boolean bGetSectors)
Get the root unit

Specified by:
getRootUnit in interface IUnitService
Parameters:
bGetSectors - true if it must get the ids sector
Returns:
an instance of Unit

getUnitByIdUser

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

Specified by:
getUnitByIdUser in interface IUnitService
Parameters:
nIdUser - the id user
bGetSectors - true if it must get the ids sector
Returns:
an instance of Unit

getAllUnits

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

Specified by:
getAllUnits in interface IUnitService
Parameters:
bGetSectors - true if it must get the ids sector
Returns:
a list of Unit

getUnitsFirstLevel

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

Specified by:
getUnitsFirstLevel in interface IUnitService
Parameters:
bGetSectors - true if it must get the ids sector
Returns:
a list of Unit

getSubUnits

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

Specified by:
getSubUnits in interface IUnitService
Parameters:
nIdUnit - the id unit
bGetSectors - true if it must get the ids sector
Returns:
a list of Unit

getListActions

public 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

Specified by:
getListActions in interface IUnitService
Parameters:
strActionType - the action type
locale - the locale
unit - the unit
user - the user
Returns:
a list of IAction

getSubUnitsAsReferenceList

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

Specified by:
getSubUnitsAsReferenceList in interface IUnitService
Parameters:
nIdUnit - the id unit
locale - the locale
Returns:
a ReferenceList

getXMLUnits

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

Specified by:
getXMLUnits in interface IUnitService
Returns:
an XML

getTreeXsl

public javax.xml.transform.Source getTreeXsl()
Gets the XSL to display user spaces tree

Specified by:
getTreeXsl in interface IUnitService
Returns:
The XSL to display user spaces tree

hasSubUnits

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

Specified by:
hasSubUnits in interface IUnitService
Parameters:
nIdUnit - the id unit
Returns:
true if the unit has sub units, false otherwise

isParent

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

Specified by:
isParent in interface IUnitService
Parameters:
unitParent - the unit parent ?
unitRef - of the unit ?
Returns:
true if there is a parent link between those two units

canCreateSubUnit

public 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

Specified by:
canCreateSubUnit in interface IUnitService
Parameters:
nIdUnit - the id unit
Returns:
true if we can create sub unit, false otherwise

isAuthorized

public 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 :

Specified by:
isAuthorized in interface IUnitService
Parameters:
unit - the unit
strPermission - the permission
user - the user
Returns:
true if he is authorized, false otherwise

isAuthorized

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

Specified by:
isAuthorized in interface IUnitService
Parameters:
strIdUnit - the id resource
strPermission - the permission
user - the user
Returns:
true if he is authorized, false otherwise

createUnit

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

Specified by:
createUnit in interface IUnitService
Parameters:
unit - the unit
Returns:
the id unit

removeUnit

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

Specified by:
removeUnit in interface IUnitService
Parameters:
nIdUnit - the id unit

updateUnit

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

Specified by:
updateUnit in interface IUnitService
Parameters:
unit - the unit

findBySectorId

public java.util.List<Unit> findBySectorId(long lIdSector)
Find by sector id

Specified by:
findBySectorId in interface IUnitService
Parameters:
lIdSector - id sector Unit list found
Returns:
all the Unit of the Sector


Copyright © 2012 Mairie de Paris. All Rights Reserved.