fr.inra.refcomp.services
Class StorageServiceImpl

java.lang.Object
  extended by fr.inra.refcomp.services.StorageServiceImpl
All Implemented Interfaces:
StorageService

public class StorageServiceImpl
extends Object
implements StorageService

User: couteau Date: 30 nov. 2010


Field Summary
static String PRIVATE_GROUP
           
 
Method Summary
 AgentSkill addSkill(String agentId)
           
 EntitiesList addSkill(String agentId, List<String> skillIds, String frequencyId)
           
 EntitiesList addSkill(String agentId, Skill skill, String frequencyId)
           
 void adminCreationIfDoNotExist()
           
protected  void checkResults(Locale locale, org.nuiton.validator.NuitonValidatorResult result)
          check the validation results and throw exception with appropriate error messages.
 void clear()
           
protected  EntitiesList createAgentList(List<Agent> agents)
           
 AgentSkill createAgentSkill(String agentId)
           
protected  EntitiesList createAgentSkillList(Set<AgentSkill> skills)
           
 Cati createCati()
          Return a new cati created in database.
 Department createDepartment()
          Return a new department created in database.
 Frequency createFrequency()
          Return a new frequency created in database.
 void createPrivateGroupIfDoNotExist()
           
 Skill createSkill(String parentId)
          Return a new user created in database.
 Unit createUnit()
          Return a new unit created in database.
 User createUser()
          Return a new user created in database.
 void deleteCati(Cati cati)
          Delete a cati
 void deleteDepartment(Department department)
          Delete a department
 void deleteEntity(org.nuiton.wikitty.entities.BusinessEntity entity)
           
 void deleteFrequency(Frequency frequency, boolean force)
          Delete a frequency
 void deleteSkill(Skill skill)
          Delete a skill present in database.
 void deleteUnit(Unit unit)
          Delete a unit
 void deleteUser(User user)
          Delete a user
protected  boolean exist(Cati cati)
          Check if a cati is already present in database
protected  Boolean exist(Department department)
           
protected  Boolean exist(Frequency frequency)
           
protected  Boolean exist(Skill skill)
           
protected  Boolean exist(Unit unit)
           
protected  boolean exist(User user)
          Check if a user is already present in database
 void exportEntitiesReferentiel(Writer writer)
           
 void exportSkillsReferentiel(Writer writer)
           
 void exportUserBase(Writer writer)
           
 String getAdminEmail()
          Get the administrator email address from config
 Agent getAgent(String id)
           
 EntitiesList getAgentAndDependencies(String id)
           
 AgentSkill getAgentSkill(String skillId)
           
 List<Skill> getAllSkills()
           
 Cati getCati(String id)
          Get a cati from its id
 List<Cati> getCatis()
          Get all the catis.
 List<Skill> getChildrenSkill(String id)
           
 org.nuiton.wikitty.WikittyClient getClient()
           
 Department getDepartment(String id)
          Get a department with its id
 List<UnitDeptLink> getDepartmentLinks(Department entity)
           
 List<Department> getDepartments()
          Get all the departments.
 List<Department> getDepartments(String id)
          Get all departments for a unit
 List<Frequency> getFrequencies()
          Get all the frequencies.
 Frequency getFrequency(String id)
          Get a frequency from its id
 org.nuiton.wikitty.entities.WikittyUser getLoggedInUser()
           
 String getPath(String id)
          Get the path for a Skill
protected  org.nuiton.wikitty.entities.WikittyGroup getPrivateGroup()
           
 Map<String,Skill> getRootSkill(List<String> skills)
           
protected  Skill getRootSkill(String skill)
           
 List<Skill> getRootSkills()
           
 Skill getSkill(String id)
          Get a skill with its id
 EntitiesList getSkills(String agentId)
          Get the skills for an agent
protected  int getTimeUsed(Frequency frequency)
           
 Unit getUnit(String id)
          Get a unit with its id
 List<UnitDeptLink> getUnitLinks(Unit entity)
           
 List<Unit> getUnits()
          Get all the departments.
 List<Unit> getUnits(String id)
          Get all the units for a department
 User getUser(String id)
          Get a user from its id
 List<User> getUsers()
          Get all the users.
 void importCSV(Reader reader)
           
 boolean isAdmin()
           
 boolean isAdmin(String id)
           
 boolean isAgent()
           
protected  boolean isChildren(String parent, String children, boolean recursive)
           
 Boolean isLoggedIn()
           
protected  boolean isSkillUsed(Skill skill)
          Check if a skill is used by users in their skills description
 Boolean login(String login, String password)
          Log the user in
 void logout()
           
 boolean moveSkill(String destination, String node)
          Move a skill in the tree skill
 void removeSkill(String skillId)
           
 Agent saveAgent(Locale locale, String context, Agent agent)
          Save an agent in database.
 void saveAgentSkill(Locale locale, AgentSkill skill)
           
 Cati saveCati(Locale locale, Cati cati)
          Save a cati in database.
 Department saveDepartment(Locale locale, Department department)
          Save a department in database.
 Department saveDepartment(Locale locale, Department department, List<String> units)
          Save a department in database.
 void saveEntity(org.nuiton.wikitty.entities.BusinessEntity entity)
           
 Frequency saveFrequency(Locale locale, Frequency frequency)
          Save a frequency in database.
 EntitiesList saveMySkills(Locale locale, List<AgentSkill> skills)
           
 Skill saveSkill(Locale locale, Skill skill)
          Save a skill in database.
 Unit saveUnit(Locale locale, Unit unit)
          Save a unit in database.
 Unit saveUnit(Locale locale, Unit unit, List<String> departments)
          Save a unit in database.
 User saveUser(Locale locale, String context, User user)
          Save a user in database.
 EntitiesList searchSkill(String search, String cati, String department, String unit, String frequency)
           
 EntitiesList searchUser(String search, String cati, String department, String unit, String frequency)
           
 boolean sendPassword(Locale locale, String userId)
           
 void setAdmin(String agentId, boolean admin)
           
 Agent setAgent(User user)
           
 void setClient(org.nuiton.wikitty.WikittyClient client)
           
 void setPrivateSkills(List<String> ids)
           
 void setPublicSkills(List<String> ids)
           
 void unsetAgent(String id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIVATE_GROUP

public static final String PRIVATE_GROUP
See Also:
Constant Field Values
Method Detail

getClient

public org.nuiton.wikitty.WikittyClient getClient()
Specified by:
getClient in interface StorageService

setClient

public void setClient(org.nuiton.wikitty.WikittyClient client)
Specified by:
setClient in interface StorageService

getCatis

public List<Cati> getCatis()
Get all the catis.

Specified by:
getCatis in interface StorageService
Returns:
a list containing all the catis.

saveCati

public Cati saveCati(Locale locale,
                     Cati cati)
              throws InvalidEntityException
Save a cati in database.

Specified by:
saveCati in interface StorageService
Parameters:
cati - the cati to save
Returns:
the saved cati
Throws:
InvalidEntityException - if the cati is not valid and cannot be saved

createCati

public Cati createCati()
Return a new cati created in database.

Specified by:
createCati in interface StorageService
Returns:
the new cati

deleteCati

public void deleteCati(Cati cati)
Delete a cati

Specified by:
deleteCati in interface StorageService
Parameters:
cati - the cati to delete

getCati

public Cati getCati(String id)
Get a cati from its id

Specified by:
getCati in interface StorageService
Parameters:
id - the cati id
Returns:
the cati

getFrequencies

public List<Frequency> getFrequencies()
                               throws SecurityException
Get all the frequencies.

Specified by:
getFrequencies in interface StorageService
Returns:
a list containing all the frequencies.
Throws:
SecurityException

saveFrequency

public Frequency saveFrequency(Locale locale,
                               Frequency frequency)
                        throws InvalidEntityException
Save a frequency in database.

Specified by:
saveFrequency in interface StorageService
Parameters:
frequency - the frequency to save
Returns:
the saved frequency
Throws:
InvalidEntityException

createFrequency

public Frequency createFrequency()
Return a new frequency created in database.

Specified by:
createFrequency in interface StorageService
Returns:
the new frequency

deleteFrequency

public void deleteFrequency(Frequency frequency,
                            boolean force)
                     throws UsedException
Delete a frequency

Specified by:
deleteFrequency in interface StorageService
Parameters:
frequency - the frequency to delete
force - true to force the deletion even if used
Throws:
UsedException - if not forcing deletion and frequency still used in skills

getTimeUsed

protected int getTimeUsed(Frequency frequency)

getFrequency

public Frequency getFrequency(String id)
Get a frequency from its id

Specified by:
getFrequency in interface StorageService
Parameters:
id - the frequency id
Returns:
the frequency

getUsers

public List<User> getUsers()
Get all the users.

Specified by:
getUsers in interface StorageService
Returns:
a list containing all the users.

saveUser

public User saveUser(Locale locale,
                     String context,
                     User user)
              throws InvalidEntityException
Save a user in database.

Specified by:
saveUser in interface StorageService
Parameters:
user - the user to save
Returns:
the saved user
Throws:
InvalidEntityException

createUser

public User createUser()
Return a new user created in database.

Specified by:
createUser in interface StorageService
Returns:
the new user

deleteUser

public void deleteUser(User user)
Delete a user

Specified by:
deleteUser in interface StorageService
Parameters:
user - the user to delete

getUser

public User getUser(String id)
Get a user from its id

Specified by:
getUser in interface StorageService
Parameters:
id - the user id
Returns:
the user

getAgent

public Agent getAgent(String id)
Specified by:
getAgent in interface StorageService

getAgentAndDependencies

public EntitiesList getAgentAndDependencies(String id)
Specified by:
getAgentAndDependencies in interface StorageService

setAgent

public Agent setAgent(User user)
Specified by:
setAgent in interface StorageService

unsetAgent

public void unsetAgent(String id)
Specified by:
unsetAgent in interface StorageService

saveAgent

public Agent saveAgent(Locale locale,
                       String context,
                       Agent agent)
                throws InvalidEntityException
Description copied from interface: StorageService
Save an agent in database.

Specified by:
saveAgent in interface StorageService
agent - the agent to save
Returns:
the saved agent
Throws:
InvalidEntityException

saveSkill

public Skill saveSkill(Locale locale,
                       Skill skill)
                throws InvalidEntityException
Description copied from interface: StorageService
Save a skill in database.

Specified by:
saveSkill in interface StorageService
Parameters:
locale - the user locale for error messages
skill - the skill to save
Returns:
the saved user
Throws:
InvalidEntityException - if the skill is not valid

createSkill

public Skill createSkill(String parentId)
Description copied from interface: StorageService
Return a new user created in database.

Specified by:
createSkill in interface StorageService
Parameters:
parentId - the parent skill wikitty Id
Returns:
the new user

deleteSkill

public void deleteSkill(Skill skill)
                 throws UsedException
Delete a skill present in database. Check if the skill is used before deleting. If the skill is used, throw an exception.

Specified by:
deleteSkill in interface StorageService
Parameters:
skill - the skill to delete
Throws:
UsedException - If the skill is used and we cannot delete the skill

isSkillUsed

protected boolean isSkillUsed(Skill skill)
Check if a skill is used by users in their skills description

Parameters:
skill - the skill to check
Returns:
true if it is used

getSkill

public Skill getSkill(String id)
Description copied from interface: StorageService
Get a skill with its id

Specified by:
getSkill in interface StorageService
Parameters:
id - the skill to get's id
Returns:
the skill

exist

protected Boolean exist(Skill skill)

exist

protected boolean exist(User user)
Check if a user is already present in database

Parameters:
user - the user to check
Returns:
true is exist, false otherwise

exist

protected Boolean exist(Frequency frequency)

exist

protected boolean exist(Cati cati)
Check if a cati is already present in database

Parameters:
cati - the cati to check
Returns:
true is exist, false otherwise

login

public Boolean login(String login,
                     String password)
Description copied from interface: StorageService
Log the user in

Specified by:
login in interface StorageService
Parameters:
login - the user login
password - the user password
Returns:
true if logged in, false otherwise

logout

public void logout()
Specified by:
logout in interface StorageService

getChildrenSkill

public List<Skill> getChildrenSkill(String id)
Specified by:
getChildrenSkill in interface StorageService

saveDepartment

public Department saveDepartment(Locale locale,
                                 Department department)
                          throws InvalidEntityException
Description copied from interface: StorageService
Save a department in database.

Specified by:
saveDepartment in interface StorageService
department - the department to save
Returns:
the saved department
Throws:
InvalidEntityException

saveDepartment

public Department saveDepartment(Locale locale,
                                 Department department,
                                 List<String> units)
                          throws InvalidEntityException
Description copied from interface: StorageService
Save a department in database.

Specified by:
saveDepartment in interface StorageService
department - the department to save
units - the units linked to the department
Returns:
the saved department
Throws:
InvalidEntityException

getDepartmentLinks

public List<UnitDeptLink> getDepartmentLinks(Department entity)

createDepartment

public Department createDepartment()
Description copied from interface: StorageService
Return a new department created in database.

Specified by:
createDepartment in interface StorageService
Returns:
the new department

deleteDepartment

public void deleteDepartment(Department department)
Description copied from interface: StorageService
Delete a department

Specified by:
deleteDepartment in interface StorageService
Parameters:
department - the department to delete

getDepartment

public Department getDepartment(String id)
Description copied from interface: StorageService
Get a department with its id

Specified by:
getDepartment in interface StorageService
Parameters:
id - the department to get's id
Returns:
the department

getDepartments

public List<Department> getDepartments()
Get all the departments.

Specified by:
getDepartments in interface StorageService
Returns:
a list containing all the departments.

getDepartments

public List<Department> getDepartments(String id)
Description copied from interface: StorageService
Get all departments for a unit

Specified by:
getDepartments in interface StorageService
Parameters:
id - the unit id
Returns:
the departments

exist

protected Boolean exist(Department department)

saveUnit

public Unit saveUnit(Locale locale,
                     Unit unit)
              throws InvalidEntityException
Description copied from interface: StorageService
Save a unit in database.

Specified by:
saveUnit in interface StorageService
unit - the unit to save
Returns:
the saved unit
Throws:
InvalidEntityException

saveUnit

public Unit saveUnit(Locale locale,
                     Unit unit,
                     List<String> departments)
              throws InvalidEntityException
Description copied from interface: StorageService
Save a unit in database.

Specified by:
saveUnit in interface StorageService
unit - the unit to save
departments - the departments that got the unit
Returns:
the saved unit
Throws:
InvalidEntityException

getUnitLinks

public List<UnitDeptLink> getUnitLinks(Unit entity)

createUnit

public Unit createUnit()
Description copied from interface: StorageService
Return a new unit created in database.

Specified by:
createUnit in interface StorageService
Returns:
the new unit

deleteUnit

public void deleteUnit(Unit unit)
Description copied from interface: StorageService
Delete a unit

Specified by:
deleteUnit in interface StorageService
Parameters:
unit - the unit to delete

getUnit

public Unit getUnit(String id)
Description copied from interface: StorageService
Get a unit with its id

Specified by:
getUnit in interface StorageService
Parameters:
id - the unit to get's id
Returns:
the unit

getUnits

public List<Unit> getUnits(String id)
Description copied from interface: StorageService
Get all the units for a department

Specified by:
getUnits in interface StorageService
Parameters:
id - the department id
Returns:
the list of units

getUnits

public List<Unit> getUnits()
Get all the departments.

Specified by:
getUnits in interface StorageService
Returns:
a list containing all the departments.

saveEntity

public void saveEntity(org.nuiton.wikitty.entities.BusinessEntity entity)
Specified by:
saveEntity in interface StorageService

deleteEntity

public void deleteEntity(org.nuiton.wikitty.entities.BusinessEntity entity)
Specified by:
deleteEntity in interface StorageService

getAdminEmail

public String getAdminEmail()
Description copied from interface: StorageService
Get the administrator email address from config

Specified by:
getAdminEmail in interface StorageService
Returns:
the admin email address

createAgentSkill

public AgentSkill createAgentSkill(String agentId)
Specified by:
createAgentSkill in interface StorageService

saveAgentSkill

public void saveAgentSkill(Locale locale,
                           AgentSkill skill)
                    throws InvalidEntityException
Specified by:
saveAgentSkill in interface StorageService
Throws:
InvalidEntityException

getPrivateGroup

protected org.nuiton.wikitty.entities.WikittyGroup getPrivateGroup()

exist

protected Boolean exist(Unit unit)

isAdmin

public boolean isAdmin()
Specified by:
isAdmin in interface StorageService

isAdmin

public boolean isAdmin(String id)
Specified by:
isAdmin in interface StorageService

isAgent

public boolean isAgent()
Specified by:
isAgent in interface StorageService

isLoggedIn

public Boolean isLoggedIn()
Specified by:
isLoggedIn in interface StorageService

adminCreationIfDoNotExist

public void adminCreationIfDoNotExist()
Specified by:
adminCreationIfDoNotExist in interface StorageService

createPrivateGroupIfDoNotExist

public void createPrivateGroupIfDoNotExist()
Specified by:
createPrivateGroupIfDoNotExist in interface StorageService

setPrivateSkills

public void setPrivateSkills(List<String> ids)
Specified by:
setPrivateSkills in interface StorageService

setPublicSkills

public void setPublicSkills(List<String> ids)
Specified by:
setPublicSkills in interface StorageService

clear

public void clear()
Specified by:
clear in interface StorageService

getSkills

public EntitiesList getSkills(String agentId)
Description copied from interface: StorageService
Get the skills for an agent

Specified by:
getSkills in interface StorageService
Parameters:
agentId - the wikittyId of the agent to get the skills of
Returns:
the agent skills and its dependencies

addSkill

public AgentSkill addSkill(String agentId)
Specified by:
addSkill in interface StorageService

addSkill

public EntitiesList addSkill(String agentId,
                             Skill skill,
                             String frequencyId)
Specified by:
addSkill in interface StorageService

addSkill

public EntitiesList addSkill(String agentId,
                             List<String> skillIds,
                             String frequencyId)
Specified by:
addSkill in interface StorageService

removeSkill

public void removeSkill(String skillId)
Specified by:
removeSkill in interface StorageService

getLoggedInUser

public org.nuiton.wikitty.entities.WikittyUser getLoggedInUser()
Specified by:
getLoggedInUser in interface StorageService

saveMySkills

public EntitiesList saveMySkills(Locale locale,
                                 List<AgentSkill> skills)
                          throws InvalidEntityException
Specified by:
saveMySkills in interface StorageService
Throws:
InvalidEntityException

getAgentSkill

public AgentSkill getAgentSkill(String skillId)
Specified by:
getAgentSkill in interface StorageService

searchUser

public EntitiesList searchUser(String search,
                               String cati,
                               String department,
                               String unit,
                               String frequency)
Specified by:
searchUser in interface StorageService

searchSkill

public EntitiesList searchSkill(String search,
                                String cati,
                                String department,
                                String unit,
                                String frequency)
Specified by:
searchSkill in interface StorageService

setAdmin

public void setAdmin(String agentId,
                     boolean admin)
Specified by:
setAdmin in interface StorageService

createAgentSkillList

protected EntitiesList createAgentSkillList(Set<AgentSkill> skills)

createAgentList

protected EntitiesList createAgentList(List<Agent> agents)

importCSV

public void importCSV(Reader reader)
Specified by:
importCSV in interface StorageService

exportSkillsReferentiel

public void exportSkillsReferentiel(Writer writer)
Specified by:
exportSkillsReferentiel in interface StorageService

exportEntitiesReferentiel

public void exportEntitiesReferentiel(Writer writer)
Specified by:
exportEntitiesReferentiel in interface StorageService

exportUserBase

public void exportUserBase(Writer writer)
Specified by:
exportUserBase in interface StorageService

getPath

public String getPath(String id)
Get the path for a Skill

Specified by:
getPath in interface StorageService
Parameters:
id - the skill id

checkResults

protected void checkResults(Locale locale,
                            org.nuiton.validator.NuitonValidatorResult result)
                     throws InvalidEntityException
check the validation results and throw exception with appropriate error messages.

Parameters:
locale - the user locale for error messages
result - the validation result
Throws:
InvalidEntityException - if the validation gets errors

moveSkill

public boolean moveSkill(String destination,
                         String node)
Move a skill in the tree skill

Specified by:
moveSkill in interface StorageService
Returns:
true if move is ok, false if cannot move (moving inside itself)

sendPassword

public boolean sendPassword(Locale locale,
                            String userId)
Specified by:
sendPassword in interface StorageService

getRootSkill

public Map<String,Skill> getRootSkill(List<String> skills)
Specified by:
getRootSkill in interface StorageService

getRootSkills

public List<Skill> getRootSkills()
Specified by:
getRootSkills in interface StorageService

getAllSkills

public List<Skill> getAllSkills()
Specified by:
getAllSkills in interface StorageService

getRootSkill

protected Skill getRootSkill(String skill)

isChildren

protected boolean isChildren(String parent,
                             String children,
                             boolean recursive)


Copyright © 2010-2012 Code Lutin. All Rights Reserved.