com.jurismarches.vradi.services
Class VradiStorageServiceImpl

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

public class VradiStorageServiceImpl
extends java.lang.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  java.util.Timer mailCronTask
          Mail cron task to check mails every 10 minutes.
protected  MailingManager mailingManager
           
protected  SearchManager searchManager
           
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.
 void autoLoadFormsFromXmlStreams(java.lang.String intervalUnit, int intervalValue, java.lang.Integer hour, java.lang.Integer minute)
          Regularly retrieves the information from all the xml streams and create new forms
 Session bindForms(Session session)
          Binds all queryMaker with the forms found by their queries and not already sent.
 java.util.List<Status> createDefaultStatuses()
          Creation of default status Warn, dont use it otherwise for vradi initialisation !!!
 Session createNewSession()
           
 java.util.List<Sending> createSending(Session session, QueryMaker queryMaker, java.util.List<Form> formsToBind)
          Create new Sending
 VradiUser createUser(VradiUser user)
          Create a VradiUser.
 java.lang.String exportAsCSV(org.nuiton.wikitty.Criteria criteria)
          Get csv export.
 java.lang.String exportClientDB()
          Export all the clients, users and groups in database
 java.util.Map<QueryMaker,java.util.List<QueryBean>> findQueriesReturningForm(Form form)
          Computes a list of queries returning the specified Form.
protected  java.util.List<java.io.File> generateFilledDocumentInPDF(java.io.File template, java.util.List<Form> forms, java.util.Map<java.lang.String,java.lang.String> fieldBindings, boolean replace)
          Generate offer PDF form given forms with specified template.
protected  java.io.File generateFilledDocumentInPDF(TemplateManager templateManager, Form form, java.util.Map<java.lang.String,java.lang.String[]> fieldBindings, boolean replace)
          Generate a single pdf file for specified form.
 java.lang.String generatePDF(Form form, boolean force)
          Generate pdf file for specified form.
 void generatePDFForSession(java.lang.String sessionId)
          Generate all the PDFs needed to send a session.
 java.util.List<java.lang.String> getAllWebHarvestScripts()
          Get all WebHarvest script name in server's WebHarvest directory.
 java.util.Map<java.lang.String,java.lang.String> getAssociatedFields(java.lang.String extensionName, java.lang.String templateName)
          Get association between template fields and extension fields.
 java.util.List<java.lang.String> getDocumentFields(org.nuiton.wikitty.WikittyExtension extension, java.lang.String templateName)
          Get template document fields names.
 int[] getFormsFromWebHarvestStream(WebHarvestStream webHarvestStream)
          Creates and store forms from an WebHarvestXmlStream by using the XmlStreamBinding to link xml stream field values with form fields.
 int[] getFormsFromXmlStream(XmlStream xmlStream)
          Creates and store forms from an XmlStream by using the XmlStreamBinding to link xml stream field values with form fields.
 org.nuiton.wikitty.WikittyExtension getFormType(java.lang.String name)
          Returns a form type with the specified name.
 java.util.Map<java.lang.String,org.nuiton.wikitty.FieldType> getFormTypeFields(java.lang.String name)
          Finds fields of a form type.
 java.util.List<Group> getGroupsForUser(java.lang.String userId)
          Get all the groups a user is in.
protected  org.nuiton.wikitty.WikittyImportExportService getImportExportService()
           
 Session getLastCloseSession()
          Get last closed session
 Session getLastOpenSession()
          Get last opened session
 java.util.Map<Group,java.util.List<QueryBean>> getQueriesToModifyAfterThesaurusModification(java.lang.String rootThesaurusName, java.lang.String thesaurusName)
          Gets the query makers whose queries are potentially to modify after a thesaurus node modification
 java.util.List<Session> getSessions(java.util.Date sessionDate)
          Get all session by date
 Status getStatus(VradiConstants.FormStatus formStatus)
          Get the status passed in parameter.
 java.util.Collection<java.lang.String> getTemplateFilenames(org.nuiton.wikitty.WikittyExtension extension)
          Lists the template filename (simple name) associated with the specified extension.
 java.lang.String getWebHarvestPreviewURL(WebHarvestStream stream)
          Get web harvest preview url from script
 java.lang.String[] getXmlStreamConfig()
           
 void importAsCSV(java.lang.String uri)
          Import all data as CSV.
protected static org.nuiton.wikitty.WikittyService initLocalWikittyService(org.nuiton.wikitty.WikittyService wikittyServiceRemote)
          Create a new wikitty service with cache support that use provided WikittyService for non cached data.
 VradiUser loginUser(java.lang.String login, java.lang.String mp5password)
          Checks if userName and userPassword matches a valid VradiUser.
 java.util.List<Thesaurus> proposeThesaurus(Form form)
          Propose thesaurus nodes that might be in relation with a specified form
 void receiveMessages()
           
 void reindexData()
          Reindex the datas.
 java.util.List<Sending> removeAllSending(Session session, Form form, QueryMaker queryMaker)
          Remove all sending corresponding with form and query maker from session
 Sending sendMessage(java.lang.String sendingId, java.lang.String sessionParagraph)
           
 Sending sendMessage(java.lang.String sendingId, java.lang.String sessionParagraph, java.lang.String email)
           
 Session sendMessages(java.lang.String sessionId)
           
 void setAssociatedFields(java.lang.String extensionName, java.lang.String templateName, java.util.Map<java.lang.String,java.lang.String> fieldMap)
          Save association between template fields and extensions fields.
protected  void startTimerTasks()
          Start server side cron tasks.
 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

mailCronTask

protected java.util.Timer mailCronTask
Mail cron task to check mails every 10 minutes.

Constructor Detail

VradiStorageServiceImpl

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

Parameters:
wikittyProxy - custom wikitty proxy

VradiStorageServiceImpl

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

Method Detail

initLocalWikittyService

protected static org.nuiton.wikitty.WikittyService initLocalWikittyService(org.nuiton.wikitty.WikittyService wikittyServiceRemote)
Create a new wikitty service with cache support that use provided WikittyService for non cached data.

Parameters:
wikittyServiceRemote - remote wikitty service

getImportExportService

protected org.nuiton.wikitty.WikittyImportExportService getImportExportService()

startTimerTasks

protected void startTimerTasks()
Start server side cron tasks. Currently starts :


createDefaultStatuses

public java.util.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 java.util.Map<QueryMaker,java.util.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(java.lang.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 java.util.Map<java.lang.String,org.nuiton.wikitty.FieldType> getFormTypeFields(java.lang.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

createSending

public java.util.List<Sending> createSending(Session session,
                                             QueryMaker queryMaker,
                                             java.util.List<Form> formsToBind)
                                      throws VradiException
Description copied from interface: VradiStorageService
Create new Sending

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

removeAllSending

public java.util.List<Sending> removeAllSending(Session session,
                                                Form form,
                                                QueryMaker queryMaker)
                                         throws VradiException
Description copied from interface: VradiStorageService
Remove all sending corresponding with form and query maker from session

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

getSessions

public java.util.List<Session> getSessions(java.util.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 java.lang.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

getFormsFromWebHarvestStream

public int[] getFormsFromWebHarvestStream(WebHarvestStream webHarvestStream)
                                   throws VradiException
Description copied from interface: VradiStorageService
Creates and store forms from an WebHarvestXmlStream by using the XmlStreamBinding to link xml stream field values with form fields.

Specified by:
getFormsFromWebHarvestStream in interface VradiStorageService
Parameters:
webHarvestStream - the web harvest xml stream to execute
Returns:
an array containing : - the number of created forms - the number of already existing forms (non created) - the number of forms created with date parsing error - the number of forms created with number parsing error TODO EC-20100428 return a serializable structure (easier to use)
Throws:
VradiException - for various possible errors

getFormsFromXmlStream

public int[] getFormsFromXmlStream(XmlStream xmlStream)
                            throws VradiException
Description copied from interface: VradiStorageService
Creates and store forms from an XmlStream by using the XmlStreamBinding to link xml stream field values with form fields.

Specified by:
getFormsFromXmlStream in interface VradiStorageService
Parameters:
xmlStream - the xml stream to read
Returns:
an array containing : - the number of created forms - the number of already existing forms (non created) - the number of forms created with date parsing error - the number of forms created with number parsing error TODO EC-20100428 return a serializable structure (easier to use)
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(java.lang.String login,
                           java.lang.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(java.lang.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 java.lang.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 java.util.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

autoLoadFormsFromXmlStreams

public void autoLoadFormsFromXmlStreams(java.lang.String intervalUnit,
                                        int intervalValue,
                                        java.lang.Integer hour,
                                        java.lang.Integer minute)
                                 throws VradiException
Description copied from interface: VradiStorageService
Regularly retrieves the information from all the xml streams and create new forms

Specified by:
autoLoadFormsFromXmlStreams in interface VradiStorageService
Parameters:
intervalUnit - unit of te interval between 2 retrievings (minute, hour or day)
intervalValue - interval value between two retrievings
hour - hour of the retrieving if the unit is day
minute - of the retrieving if the unit is day or hour
Throws:
VradiException

getTemplateFilenames

public java.util.Collection<java.lang.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(java.lang.String extensionName,
                                java.lang.String templateName,
                                java.util.Map<java.lang.String,java.lang.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 java.lang.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 java.util.Map<java.lang.String,java.lang.String> getAssociatedFields(java.lang.String extensionName,
                                                                            java.lang.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 java.util.Map<Group,java.util.List<QueryBean>> getQueriesToModifyAfterThesaurusModification(java.lang.String rootThesaurusName,
                                                                                                   java.lang.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 java.util.List<java.lang.String> getDocumentFields(org.nuiton.wikitty.WikittyExtension extension,
                                                          java.lang.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 java.util.List<java.io.File> generateFilledDocumentInPDF(java.io.File template,
                                                                   java.util.List<Form> forms,
                                                                   java.util.Map<java.lang.String,java.lang.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 java.io.File generateFilledDocumentInPDF(TemplateManager templateManager,
                                                   Form form,
                                                   java.util.Map<java.lang.String,java.lang.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(java.lang.String sessionId)
                     throws VradiException
Specified by:
sendMessages in interface VradiStorageService
Throws:
VradiException

sendMessage

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

sendMessage

public Sending sendMessage(java.lang.String sendingId,
                           java.lang.String sessionParagraph,
                           java.lang.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

getXmlStreamConfig

public java.lang.String[] getXmlStreamConfig()
Specified by:
getXmlStreamConfig in interface VradiStorageService

getAllWebHarvestScripts

public java.util.List<java.lang.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(java.lang.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 java.util.List<Group> getGroupsForUser(java.lang.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 java.lang.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


Copyright © 2009-2010 JurisMarches. All Rights Reserved.