com.jurismarches.vradi.services
Class VradiStorageServiceImpl

java.lang.Object
  extended by com.jurismarches.vradi.services.VradiStorageServiceImpl
All Implemented Interfaces:
VradiStorageService

public class VradiStorageServiceImpl
extends Object
implements VradiStorageService

Vradi storage implementation.

Author:
morin, chatellier

Field Summary
protected  BindingManager bindingManager
           
protected  ClientManager clientManager
           
protected  FormManager formManager
           
protected  FormTypeManager formTypeManager
           
protected  org.nuiton.wikitty.WikittyImportExportService importExportService
           
protected  MailingManager mailingManager
           
protected  SearchManager searchManager
           
protected  TasksManager tasksManager
           
protected  ThesaurusManager thesaurusManager
           
protected  org.nuiton.wikitty.WikittyProxy wikittyProxy
          Proxy to store and retrieve data.
 
Constructor Summary
  VradiStorageServiceImpl()
          Remote instantiation and empty constructor for hessian.
protected VradiStorageServiceImpl(org.nuiton.wikitty.WikittyProxy wikittyProxy)
          This constructor exists for local wikittyProxy instanciation.
 
Method Summary
 void archiveQueries(QueryMaker queryMaker)
          Archives the queries of a user, client or group in a RSS file.
 Session bindForms(Session session)
          Binds all queryMaker with the forms found by their queries and not already sent.
 boolean checkTemplateExist(String extensionName)
          Check if template file form extension name in param
 List<Sending> createAllSending(Session session, Group group, List<Form> formsToBind)
          Create new Sending
 List<Status> createDefaultStatuses()
          Creation of default status Warn, dont use it otherwise for vradi initialisation !!!
 Session createNewSession()
           
 Sending createSending(Session session, User user, List<Form> formsToBind)
          Create new Sending
 VradiUser createUser(VradiUser user)
          Create a VradiUser.
 void deleteClient(String clientId)
          Delete client, users associated and user groups association
 void deleteGroup(String groupId)
          Delete group
 void deleteSession(String sessionId)
          Delete session and sending associated This method return a VradiException if session to delete is not active
 boolean deleteStatus(List<String> statusIds)
          Delete status if no form is use this
 void deleteUser(String userId)
          Delete users, and groups association
 String exportAsCSV(org.nuiton.wikitty.Criteria criteria)
          Get csv export.
 String exportClientDB()
          Export all the clients, users and groups in database
 Map<Group,List<QueryBean>> findQueriesReturningForm(Form form)
          Computes a list of queries returning the specified Form.
protected  List<File> generateFilledDocumentInPDF(File template, List<Form> forms, Map<String,String> fieldBindings, boolean replace)
          Generate offer PDF form given forms with specified template.
protected  File generateFilledDocumentInPDF(TemplateManager templateManager, Form form, Map<String,String[]> fieldBindings, boolean replace)
          Generate a single pdf file for specified form.
 String generatePDF(Form form, boolean force)
          Generate pdf file for specified form.
 void generatePDFForSession(String sessionId)
          Generate all the PDFs needed to send a session.
 List<String> getAllWebHarvestScripts()
          Get all WebHarvest script name in server's WebHarvest directory.
 Map<String,String> getAssociatedFields(String extensionName, String templateName)
          Get association between template fields and extension fields.
 List<String> getDocumentFields(org.nuiton.wikitty.WikittyExtension extension, String templateName)
          Get template document fields names.
 org.nuiton.wikitty.WikittyExtension getFormType(String name)
          Returns a form type with the specified name.
 Map<String,org.nuiton.wikitty.FieldType> getFormTypeFields(String name)
          Finds fields of a form type.
 List<Group> getGroupsForUser(String userId)
          Get all the groups a user is in.
protected  org.nuiton.wikitty.WikittyImportExportService getImportExportService()
          Get WikittyImportExportService singl instance.
 Session getLastCloseSession()
          Get last closed session
 Session getLastOpenSession()
          Get last opened session
 Map<Group,List<QueryBean>> getQueriesToModifyAfterThesaurusModification(String rootThesaurusName, String thesaurusName)
          Gets the query makers whose queries are potentially to modify after a thesaurus node modification
 Session getSessionOfSending(String sendingId)
          Get session contain sending
 List<Session> getSessions(Date sessionDate)
          Get all session by date
 Status getStatus(VradiConstants.FormStatus formStatus)
          Get the status passed in parameter.
 Collection<String> getTemplateFilenames(org.nuiton.wikitty.WikittyExtension extension)
          Lists the template filename (simple name) associated with the specified extension.
 String getWebHarvestPreviewURL(WebHarvestStream stream)
          Get web harvest preview url from script
 void importAsCSV(String uri)
          Import all data as CSV.
 XmlStreamImportResult importFormsFromWebHarvestStream(WebHarvestStream webHarvestStream)
          Creates and store forms from an WebHarvestStream by using the XmlStreamBinding to link xml stream field values with form fields.
 XmlStreamImportResult importFormsFromXmlStream(XmlStream xmlStream)
          Creates and store forms from an XmlStream by using the XmlStreamBinding to link xml stream field values with form fields.
 VradiUser loginUser(String login, String mp5password)
          Checks if userName and userPassword matches a valid VradiUser.
 List<Thesaurus> proposeThesaurus(Form form)
          Propose thesaurus nodes that might be in relation with a specified form
 void receiveMessages()
           
 void reindexData()
          Reindex the datas.
 List<Sending> removeAllSending(Session session, Form form, Group group)
          Remove all sending corresponding with form and group from session
 boolean removeFormsFromSession(List<Form> forms)
          Check if template file form extension name in param
 Sending removeSending(Session session, Form form, User user)
          Remove sending corresponding with form and user from session
 Sending sendMessage(String sendingId, String sessionParagraph)
           
 Sending sendMessage(String sendingId, String sessionParagraph, String email)
           
 Session sendMessages(String sessionId)
           
 void setAssociatedFields(String extensionName, String templateName, Map<String,String> fieldMap)
          Save association between template fields and extensions fields.
 Session stopSentMail(Session session)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wikittyProxy

protected org.nuiton.wikitty.WikittyProxy wikittyProxy
Proxy to store and retrieve data.


importExportService

protected org.nuiton.wikitty.WikittyImportExportService importExportService

thesaurusManager

protected ThesaurusManager thesaurusManager

bindingManager

protected BindingManager bindingManager

formManager

protected FormManager formManager

formTypeManager

protected FormTypeManager formTypeManager

clientManager

protected ClientManager clientManager

searchManager

protected SearchManager searchManager

mailingManager

protected MailingManager mailingManager

tasksManager

protected TasksManager tasksManager
Constructor Detail

VradiStorageServiceImpl

public VradiStorageServiceImpl()
Remote instantiation and empty constructor for hessian.


VradiStorageServiceImpl

protected VradiStorageServiceImpl(org.nuiton.wikitty.WikittyProxy wikittyProxy)
This constructor exists for local wikittyProxy instanciation.

Parameters:
wikittyProxy - custom wikitty proxy
Method Detail

getImportExportService

protected org.nuiton.wikitty.WikittyImportExportService getImportExportService()
Get WikittyImportExportService singl instance.

Returns:
WikittyImportExportService singleton

deleteClient

public void deleteClient(String clientId)
                  throws VradiException
Description copied from interface: VradiStorageService
Delete client, users associated and user groups association

Specified by:
deleteClient in interface VradiStorageService
Parameters:
clientId - to delete
Throws:
VradiException

deleteUser

public void deleteUser(String userId)
                throws VradiException
Description copied from interface: VradiStorageService
Delete users, and groups association

Specified by:
deleteUser in interface VradiStorageService
Parameters:
userId - to delete
Throws:
VradiException

deleteGroup

public void deleteGroup(String groupId)
                 throws VradiException
Description copied from interface: VradiStorageService
Delete group

Specified by:
deleteGroup in interface VradiStorageService
Parameters:
groupId - to delete
Throws:
VradiException

createDefaultStatuses

public List<Status> createDefaultStatuses()
                                   throws VradiException
Description copied from interface: VradiStorageService
Creation of default status Warn, dont use it otherwise for vradi initialisation !!!

Specified by:
createDefaultStatuses in interface VradiStorageService
Returns:
list of defautl status created
Throws:
VradiException

findQueriesReturningForm

public Map<Group,List<QueryBean>> findQueriesReturningForm(Form form)
                                                    throws VradiException
Description copied from interface: VradiStorageService
Computes a list of queries returning the specified Form.

Specified by:
findQueriesReturningForm in interface VradiStorageService
Parameters:
form - the form which match queries
Returns:
a list of queries
Throws:
VradiException

getFormType

public org.nuiton.wikitty.WikittyExtension getFormType(String name)
                                                throws VradiException
Description copied from interface: VradiStorageService
Returns a form type with the specified name.

Specified by:
getFormType in interface VradiStorageService
Parameters:
name - the name of the form type
Returns:
a WikittyExtension
Throws:
VradiException

getFormTypeFields

public Map<String,org.nuiton.wikitty.FieldType> getFormTypeFields(String name)
                                                           throws VradiException
Description copied from interface: VradiStorageService
Finds fields of a form type.

Specified by:
getFormTypeFields in interface VradiStorageService
Parameters:
name - the name of the form type
Returns:
a map containing the names of the fields and their type
Throws:
VradiException

createNewSession

public Session createNewSession()
                         throws VradiException
Specified by:
createNewSession in interface VradiStorageService
Throws:
VradiException

bindForms

public Session bindForms(Session session)
                  throws VradiException
Description copied from interface: VradiStorageService
Binds all queryMaker with the forms found by their queries and not already sent.

Specified by:
bindForms in interface VradiStorageService
Throws:
VradiException

createAllSending

public List<Sending> createAllSending(Session session,
                                      Group group,
                                      List<Form> formsToBind)
                               throws VradiException
Description copied from interface: VradiStorageService
Create new Sending

Specified by:
createAllSending in interface VradiStorageService
Returns:
Throws:
VradiException

createSending

public Sending createSending(Session session,
                             User user,
                             List<Form> formsToBind)
                      throws VradiException
Description copied from interface: VradiStorageService
Create new Sending

Specified by:
createSending in interface VradiStorageService
Returns:
Throws:
VradiException

removeAllSending

public List<Sending> removeAllSending(Session session,
                                      Form form,
                                      Group group)
                               throws VradiException
Description copied from interface: VradiStorageService
Remove all sending corresponding with form and group from session

Specified by:
removeAllSending in interface VradiStorageService
Parameters:
session - concerned
form - concerned
Returns:
List of sending after deletion
Throws:
VradiException

removeSending

public Sending removeSending(Session session,
                             Form form,
                             User user)
                      throws VradiException
Description copied from interface: VradiStorageService
Remove sending corresponding with form and user from session

Specified by:
removeSending in interface VradiStorageService
Parameters:
session - concerned
form - concerned
Returns:
sending after deletion
Throws:
VradiException

getSessions

public List<Session> getSessions(Date sessionDate)
                          throws VradiException
Description copied from interface: VradiStorageService
Get all session by date

Specified by:
getSessions in interface VradiStorageService
Parameters:
sessionDate - Date concerned
Returns:
a list of VradiSessionDTO
Throws:
VradiException

getLastCloseSession

public Session getLastCloseSession()
                            throws VradiException
Description copied from interface: VradiStorageService
Get last closed session

Specified by:
getLastCloseSession in interface VradiStorageService
Returns:
last opened session
Throws:
VradiException

getLastOpenSession

public Session getLastOpenSession()
                           throws VradiException
Description copied from interface: VradiStorageService
Get last opened session

Specified by:
getLastOpenSession in interface VradiStorageService
Returns:
last opened session
Throws:
VradiException

getWebHarvestPreviewURL

public String getWebHarvestPreviewURL(WebHarvestStream stream)
                               throws VradiException
Description copied from interface: VradiStorageService
Get web harvest preview url from script

Specified by:
getWebHarvestPreviewURL in interface VradiStorageService
Returns:
url of preview file
Throws:
VradiException

importFormsFromWebHarvestStream

public XmlStreamImportResult importFormsFromWebHarvestStream(WebHarvestStream webHarvestStream)
                                                      throws VradiException
Creates and store forms from an WebHarvestStream by using the XmlStreamBinding to link xml stream field values with form fields. Input xmlStream is modified by this method (wikitty obselete).

Specified by:
importFormsFromWebHarvestStream in interface VradiStorageService
Parameters:
webHarvestStream - stream to import
Returns:
a structure containing : - the number of created forms - the number of already existing forms - the number of forms created with date parsing error - the number of forms created with number parsing error
Throws:
VradiException - for various possible errors

importFormsFromXmlStream

public XmlStreamImportResult importFormsFromXmlStream(XmlStream xmlStream)
                                               throws VradiException
Creates and store forms from an XmlStream by using the XmlStreamBinding to link xml stream field values with form fields. Input xmlStream is modified by this method (wikitty obselete).

Specified by:
importFormsFromXmlStream in interface VradiStorageService
Parameters:
xmlStream - stream to import
Returns:
a structure containing : - the number of created forms - the number of already existing forms - the number of forms created with date parsing error - the number of forms created with number parsing error
Throws:
VradiException - for various possible errors

createUser

public VradiUser createUser(VradiUser user)
                     throws VradiException
Description copied from interface: VradiStorageService
Create a VradiUser.

Specified by:
createUser in interface VradiStorageService
Parameters:
user - the user to create
Returns:
the vradiUser updated or null if user can't be created (already exists)
Throws:
VradiException

loginUser

public VradiUser loginUser(String login,
                           String mp5password)
Description copied from interface: VradiStorageService
Checks if userName and userPassword matches a valid VradiUser.

Specified by:
loginUser in interface VradiStorageService
Parameters:
login - the login of a WikittyUser
mp5password - the password of a WikittyUser (md5 encoded)
Returns:
a WikittyUser or null if either userName or userPassword don't match

importAsCSV

public void importAsCSV(String uri)
                 throws VradiException
Description copied from interface: VradiStorageService
Import all data as CSV. FIXME EC-20100415 will not work in remote mode (or uri maybe be valid for remote server too)

Specified by:
importAsCSV in interface VradiStorageService
Parameters:
uri - uri used to read input stream
Throws:
VradiException - if any error happen during import

exportAsCSV

public String exportAsCSV(org.nuiton.wikitty.Criteria criteria)
                   throws VradiException
Description copied from interface: VradiStorageService
Get csv export.

Specified by:
exportAsCSV in interface VradiStorageService
Parameters:
criteria - export criteria
Returns:
csv export
Throws:
VradiException - if any error happen during export

reindexData

public void reindexData()
Description copied from interface: VradiStorageService
Reindex the datas.

Specified by:
reindexData in interface VradiStorageService

proposeThesaurus

public List<Thesaurus> proposeThesaurus(Form form)
                                 throws VradiException
Description copied from interface: VradiStorageService
Propose thesaurus nodes that might be in relation with a specified form

Specified by:
proposeThesaurus in interface VradiStorageService
Parameters:
form - the Form containing the information needed to search the thesaurus nodes
Returns:
a list of Thesaurus
Throws:
VradiException

archiveQueries

public void archiveQueries(QueryMaker queryMaker)
                    throws VradiException
Description copied from interface: VradiStorageService
Archives the queries of a user, client or group in a RSS file.

Specified by:
archiveQueries in interface VradiStorageService
Parameters:
queryMaker - the query maker whose queries are archived
Throws:
VradiException

getTemplateFilenames

public Collection<String> getTemplateFilenames(org.nuiton.wikitty.WikittyExtension extension)
Description copied from interface: VradiStorageService
Lists the template filename (simple name) associated with the specified extension. This need to be called by a WS because an WikittyExtension doesn't have a files fields.

Specified by:
getTemplateFilenames in interface VradiStorageService
Returns:

setAssociatedFields

public void setAssociatedFields(String extensionName,
                                String templateName,
                                Map<String,String> fieldMap)
                         throws VradiException
Description copied from interface: VradiStorageService
Save association between template fields and extensions fields.

Specified by:
setAssociatedFields in interface VradiStorageService
Throws:
VradiException

generatePDF

public String generatePDF(Form form,
                          boolean force)
                   throws VradiException
Description copied from interface: VradiStorageService
Generate pdf file for specified form.

Specified by:
generatePDF in interface VradiStorageService
Parameters:
form - form to generate pdf
force - force regeneration
Returns:
uri to download file
Throws:
VradiException

getAssociatedFields

public Map<String,String> getAssociatedFields(String extensionName,
                                              String templateName)
                                       throws VradiException
Description copied from interface: VradiStorageService
Get association between template fields and extension fields.

Specified by:
getAssociatedFields in interface VradiStorageService
Returns:
association map or null is there is no association yet
Throws:
VradiException

getQueriesToModifyAfterThesaurusModification

public Map<Group,List<QueryBean>> getQueriesToModifyAfterThesaurusModification(String rootThesaurusName,
                                                                               String thesaurusName)
Description copied from interface: VradiStorageService
Gets the query makers whose queries are potentially to modify after a thesaurus node modification

Specified by:
getQueriesToModifyAfterThesaurusModification in interface VradiStorageService
Parameters:
rootThesaurusName - the modified root thesaurus name node
thesaurusName - the modified thesaurus name node
Returns:
a map containing the query makers and their queries which contains the thesaurus node name

getDocumentFields

public List<String> getDocumentFields(org.nuiton.wikitty.WikittyExtension extension,
                                      String templateName)
                               throws VradiException
Description copied from interface: VradiStorageService
Get template document fields names.

Specified by:
getDocumentFields in interface VradiStorageService
Parameters:
extension - extension
templateName - template name
Returns:
field names
Throws:
VradiException

generateFilledDocumentInPDF

protected List<File> generateFilledDocumentInPDF(File template,
                                                 List<Form> forms,
                                                 Map<String,String> fieldBindings,
                                                 boolean replace)
                                          throws VradiException
Generate offer PDF form given forms with specified template.

Parameters:
template - template to use to generate PDF
forms - to to generate
fieldBindings - map between template field name and form fields names
replace - replace already existing generated forms
Returns:
generated pdf files
Throws:
VradiException

generateFilledDocumentInPDF

protected File generateFilledDocumentInPDF(TemplateManager templateManager,
                                           Form form,
                                           Map<String,String[]> fieldBindings,
                                           boolean replace)
                                    throws VradiException
Generate a single pdf file for specified form.

Parameters:
templateManager - pdf template manager
form - form to get pdf
fieldBindings - association between field name and form fields (couple extension name, extension field)
replace - replace already existing pdf
Returns:
the pdf file associated with pdf
Throws:
VradiException

sendMessages

public Session sendMessages(String sessionId)
                     throws VradiException
Specified by:
sendMessages in interface VradiStorageService
Throws:
VradiException

sendMessage

public Sending sendMessage(String sendingId,
                           String sessionParagraph)
                    throws VradiException
Specified by:
sendMessage in interface VradiStorageService
Throws:
VradiException

sendMessage

public Sending sendMessage(String sendingId,
                           String sessionParagraph,
                           String email)
                    throws VradiException
Specified by:
sendMessage in interface VradiStorageService
Throws:
VradiException

receiveMessages

public void receiveMessages()
                     throws VradiException
Specified by:
receiveMessages in interface VradiStorageService
Throws:
VradiException

stopSentMail

public Session stopSentMail(Session session)
                     throws VradiException
Specified by:
stopSentMail in interface VradiStorageService
Throws:
VradiException

getAllWebHarvestScripts

public List<String> getAllWebHarvestScripts()
Description copied from interface: VradiStorageService
Get all WebHarvest script name in server's WebHarvest directory. All filename doesn't contains "/".

Specified by:
getAllWebHarvestScripts in interface VradiStorageService
Returns:
script file names

generatePDFForSession

public void generatePDFForSession(String sessionId)
Generate all the PDFs needed to send a session.

Specified by:
generatePDFForSession in interface VradiStorageService
Parameters:
sessionId - the session wikitty id

getGroupsForUser

public List<Group> getGroupsForUser(String userId)
                             throws VradiException
Get all the groups a user is in.

Specified by:
getGroupsForUser in interface VradiStorageService
Parameters:
userId - the user we want the groups of
Returns:
the group for our user
Throws:
VradiException

exportClientDB

public String exportClientDB()
                      throws VradiException
Description copied from interface: VradiStorageService
Export all the clients, users and groups in database

Specified by:
exportClientDB in interface VradiStorageService
Returns:
the csv export as a String
Throws:
VradiException - if any error happen during export

getStatus

public Status getStatus(VradiConstants.FormStatus formStatus)
                 throws VradiException
Get the status passed in parameter. Init status if it have not been done already

Specified by:
getStatus in interface VradiStorageService
Parameters:
formStatus - the status from enum
Returns:
the Status object
Throws:
VradiException - if an error occur during statuses initialisation

getSessionOfSending

public Session getSessionOfSending(String sendingId)
                            throws VradiException
Description copied from interface: VradiStorageService
Get session contain sending

Specified by:
getSessionOfSending in interface VradiStorageService
Parameters:
sendingId - concerned
Returns:
session found
Throws:
VradiException - if an error occur

deleteSession

public void deleteSession(String sessionId)
                   throws VradiException
Description copied from interface: VradiStorageService
Delete session and sending associated This method return a VradiException if session to delete is not active

Specified by:
deleteSession in interface VradiStorageService
Parameters:
sessionId - to delete
Throws:
VradiException - if an error occur during session deletion

deleteStatus

public boolean deleteStatus(List<String> statusIds)
                     throws VradiException
Description copied from interface: VradiStorageService
Delete status if no form is use this

Specified by:
deleteStatus in interface VradiStorageService
Parameters:
statusIds - to delete
Returns:
false if not deleted (is in use)
Throws:
VradiException - is occured if status deletion is aborded

checkTemplateExist

public boolean checkTemplateExist(String extensionName)
                           throws VradiException
Description copied from interface: VradiStorageService
Check if template file form extension name in param

Specified by:
checkTemplateExist in interface VradiStorageService
Parameters:
extensionName - to check
Returns:
true if file exist
Throws:
VradiException - if an error occur during checking template

removeFormsFromSession

public boolean removeFormsFromSession(List<Form> forms)
                               throws VradiException
Description copied from interface: VradiStorageService
Check if template file form extension name in param

Specified by:
removeFormsFromSession in interface VradiStorageService
Parameters:
forms - to update
Returns:
false if no session opened found
Throws:
VradiException - if an error occur during checking template


Copyright © 2009-2010 JurisMarches. All Rights Reserved.