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  org.nuiton.util.ApplicationConfig config
           
protected  FileService fileService
           
protected  FormManager formManager
           
protected  FormTypeManager formTypeManager
           
protected  org.nuiton.wikitty.addons.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.util.ApplicationConfig config, 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(String sessionId, Group group, List<String> formsIdsToBind)
          Create new Sending
 List<Status> createDefaultStatuses()
          Create all default status.
 Session createNewSession()
           
 Sending createSending(String sessionId, User user, List<String> formsIdsToBind)
          Create new Sending
 VradiUser createUser(VradiUser user)
          Create a VradiUser.
 void deleteSession(String sessionId)
          Delete session and sending associated This method return a VradiException if session to delete is not active
 String exportAsCSV(org.nuiton.wikitty.search.Criteria criteria)
          Get csv export.
 String exportClientDB()
          Export all the clients, users and groups in database
 String exportThesaurusAsCSV()
          Export thesaurus as csv
protected  String formatSessionLog(List<String> logs)
           
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(String formId, boolean force)
          Generate pdf file for specified form.
 void generatePDFForSession(String sessionId)
          Generate all the PDFs needed to send a session.
 Map<String,String> getAssociatedFields(String extensionName, String templateName)
          Get association between template fields and extension fields.
 List<String> getDocumentFields(org.nuiton.wikitty.entities.WikittyExtension extension, String templateName)
          Get template document fields names.
 List<Group> getGroupsForUser(String userId)
          Get all the groups a user is in.
protected  org.nuiton.wikitty.addons.WikittyImportExportService getImportExportService()
          Get WikittyImportExportService singl instance.
 Collection<String> getTemplateFilenames(org.nuiton.wikitty.entities.WikittyExtension extension)
          Lists the template filename (simple name) associated with the specified extension.
 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.
 void receiveMessages()
           
 void reindexData()
          Reindex the datas.
 List<Sending> removeAllSending(String sessionId, List<String> formsIds, Group group)
          Remove all sending corresponding with form and group from session
 boolean removeFormsFromSession(String sessionId, List<String> formsIds)
          Check if template file form extension name in param
 Sending removeSending(String sessionId, List<String> formsIds, User user)
          Remove sending corresponding with form and user from session
 Sending revertDeletion(String sendingId, List<String> formsIdsToUpdate)
          Method call to revert froms deleted in sending
 List<Sending> revertGroupDeletion(String sessionId, String groupId, String formId)
          Revert forms deleted for group
 Sending revertUserDeletion(String sessionId, String userId, String formId)
          Revert forms deleted for user
 String sendMessage(String sendingId, String sessionParagraph)
          Send sending pass in param to sending user email
 String sendMessage(String sendingId, String sessionParagraph, String email)
          Send sending pass in param to specific email
 String sendMessage(String sendingId, String sessionParagraph, String email, boolean reSend)
           
 String sendMessages(String sessionId)
          Send session pass in param
 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

config

protected org.nuiton.util.ApplicationConfig config

wikittyProxy

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


importExportService

protected org.nuiton.wikitty.addons.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

fileService

protected FileService fileService
Constructor Detail

VradiStorageServiceImpl

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


VradiStorageServiceImpl

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

Parameters:
config - vradi config
wikittyProxy - custom wikitty proxy
Method Detail

getImportExportService

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

Returns:
WikittyImportExportService singleton

createDefaultStatuses

public List<Status> createDefaultStatuses()
                                   throws VradiException
Create all default status.

Specified by:
createDefaultStatuses in interface VradiStorageService
Returns:
all status created
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(String sessionId,
                                      Group group,
                                      List<String> formsIdsToBind)
                               throws VradiException
Description copied from interface: VradiStorageService
Create new Sending

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

createSending

public Sending createSending(String sessionId,
                             User user,
                             List<String> formsIdsToBind)
                      throws VradiException
Description copied from interface: VradiStorageService
Create new Sending

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

removeAllSending

public List<Sending> removeAllSending(String sessionId,
                                      List<String> formsIds,
                                      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
formsIds - concerned
Returns:
List of sending after deletion
Throws:
VradiException

removeSending

public Sending removeSending(String sessionId,
                             List<String> formsIds,
                             User user)
                      throws VradiException
Description copied from interface: VradiStorageService
Remove sending corresponding with form and user from session

Specified by:
removeSending in interface VradiStorageService
formsIds - concerned
Returns:
sending after deletion
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.search.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

exportThesaurusAsCSV

public String exportThesaurusAsCSV()
                            throws VradiException
Description copied from interface: VradiStorageService
Export thesaurus as csv

Specified by:
exportThesaurusAsCSV in interface VradiStorageService
Returns:
thesaurus 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

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

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(String formId,
                          boolean force)
                   throws VradiException
Description copied from interface: VradiStorageService
Generate pdf file for specified form.

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

getTemplateFilenames

public Collection<String> getTemplateFilenames(org.nuiton.wikitty.entities.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:

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

getDocumentFields

public List<String> getDocumentFields(org.nuiton.wikitty.entities.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 - for various possible errors

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 - for various possible errors

sendMessages

public String sendMessages(String sessionId)
                    throws VradiException
Description copied from interface: VradiStorageService
Send session pass in param

Specified by:
sendMessages in interface VradiStorageService
Parameters:
sessionId - session id concerned
Returns:
Logged messages
Throws:
VradiException - exception is occured

sendMessage

public String sendMessage(String sendingId,
                          String sessionParagraph)
                   throws VradiException
Description copied from interface: VradiStorageService
Send sending pass in param to sending user email

Specified by:
sendMessage in interface VradiStorageService
Parameters:
sendingId - sending id concerned
sessionParagraph - paragraph to send
Returns:
Logged messages
Throws:
VradiException - exception is occured

sendMessage

public String sendMessage(String sendingId,
                          String sessionParagraph,
                          String email)
                   throws VradiException
Description copied from interface: VradiStorageService
Send sending pass in param to specific email

Specified by:
sendMessage in interface VradiStorageService
Parameters:
sendingId - sending id concerned
sessionParagraph - paragraph to send
email - specific
Returns:
Logged messages
Throws:
VradiException - exception is occured

sendMessage

public String sendMessage(String sendingId,
                          String sessionParagraph,
                          String email,
                          boolean reSend)
                   throws VradiException
Throws:
VradiException

formatSessionLog

protected String formatSessionLog(List<String> logs)

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

generatePDFForSession

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

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

getGroupsForUser

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

Parameters:
userId - the user we want the groups of
Returns:
the group for our user
Throws:
VradiException - for various possible errors

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

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

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(String sessionId,
                                      List<String> formsIds)
                               throws VradiException
Description copied from interface: VradiStorageService
Check if template file form extension name in param

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

revertDeletion

public Sending revertDeletion(String sendingId,
                              List<String> formsIdsToUpdate)
Description copied from interface: VradiStorageService
Method call to revert froms deleted in sending

Specified by:
revertDeletion in interface VradiStorageService
Parameters:
sendingId - to update
formsIdsToUpdate - deleted to revert
Returns:
updated sending

revertUserDeletion

public Sending revertUserDeletion(String sessionId,
                                  String userId,
                                  String formId)
Description copied from interface: VradiStorageService
Revert forms deleted for user

Specified by:
revertUserDeletion in interface VradiStorageService
Parameters:
sessionId - session concerned
userId - user concerned
formId - form to revert
Returns:
sending impacted

revertGroupDeletion

public List<Sending> revertGroupDeletion(String sessionId,
                                         String groupId,
                                         String formId)
Description copied from interface: VradiStorageService
Revert forms deleted for group

Specified by:
revertGroupDeletion in interface VradiStorageService
Parameters:
sessionId - session concerned
groupId - user concerned
formId - form to revert
Returns:
sending impacted


Copyright © 2009-2010 JurisMarches. All Rights Reserved.