diff --git a/doc/sphinx-guides/source/_static/admin/ejb-jar.xml b/doc/sphinx-guides/source/_static/admin/ejb-jar.xml new file mode 100644 index 00000000000..5ea6330753a --- /dev/null +++ b/doc/sphinx-guides/source/_static/admin/ejb-jar.xml @@ -0,0 +1,23 @@ + + + + + SavedSearchServiceBean + edu.harvard.iq.dataverse.search.savedsearch.SavedSearchServiceBean + Stateless + + + 30 + 14 + 2 + + + makeLinksForAllSavedSearchesTimer + + + + + diff --git a/doc/sphinx-guides/source/admin/timers.rst b/doc/sphinx-guides/source/admin/timers.rst index 733dd7fbc1c..2b607dfe9ec 100644 --- a/doc/sphinx-guides/source/admin/timers.rst +++ b/doc/sphinx-guides/source/admin/timers.rst @@ -46,6 +46,26 @@ This daily job will also update all the harvestable OAI sets configured on your This job is automatically scheduled to run at 2AM local time every night. If really necessary, it is possible (for an advanced user) to change that time by directly editing the EJB timer application table in the database. +Saved Searches Links Timer +-------------------------- + +This timer is created automatically from an @Schedule annotation on the makeLinksForAllSavedSearchesTimer method of the SavedSearchServiceBean when the bean is deployed. + +This timer runs a weekly job to create links for any saved searches that haven't been linked yet yet. + +This job is automatically scheduled to run once a week at 12:30AM local time on Sunday. If really necessary, it is possible to change that time by deploying the application war file with an ejb-jar.xml file in the WEB-INF directory of the war file. A sample file is included in doc/sphinx-guides/source/_static/admin/ejb-jar.xml - the sample would run the job every Tuesday at 2:30PM. The schedule can be modified to your choice by editing the fields in the session section. If other EJBs require some form of configuration using an ejb-jar file, there should be one ejb-jar file for the entire application, which can have different sections for each EJB. Below are instructions for the simple case of adding the ejb-jar,xml for the first time and making a custom schedule for the saved search timer. + +* Create or edit dataverse/src/main/webapp/WEB-INF/ejb-jar.xml, following the example provided in dataverse/sphinx-guides/source/_static/admin/ejb-jar.xml + +* Edit the parameters in the section ejb-jar file in the WEB-INF directory to suit your preferred schedule + + * the provided parameters in the sample file are , , and ; additional parameters are available + + * For a complete reference for calendar expressions that can be used to schedule Timer services see: https://docs.oracle.com/javaee/7/tutorial/ejb-basicexamples004.htm + +* Build and deploy the application + + Known Issues ------------ diff --git a/src/main/java/edu/harvard/iq/dataverse/search/savedsearch/SavedSearchServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/search/savedsearch/SavedSearchServiceBean.java index e55ac67247e..3dc7642655d 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/savedsearch/SavedSearchServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/savedsearch/SavedSearchServiceBean.java @@ -20,6 +20,7 @@ import edu.harvard.iq.dataverse.search.SearchException; import edu.harvard.iq.dataverse.search.SearchFields; import edu.harvard.iq.dataverse.search.SortBy; +import edu.harvard.iq.dataverse.util.SystemConfig; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -54,6 +55,8 @@ public class SavedSearchServiceBean { DataverseLinkingServiceBean dataverseLinkingService; @EJB EjbDataverseEngine commandEngine; + @EJB + SystemConfig systemConfig; private final String resultString = "result"; @@ -126,13 +129,15 @@ public SavedSearch save(SavedSearch savedSearch) { } - @Schedule(dayOfWeek="Sun", hour="0",minute="30") - public void makeLinksForAllSavedSearchesTimer(){ - logger.info("Linking saved searches"); - try { - JsonObjectBuilder makeLinksForAllSavedSearches = makeLinksForAllSavedSearches(false); - } catch (SearchException | CommandException ex) { - Logger.getLogger(SavedSearchServiceBean.class.getName()).log(Level.SEVERE, null, ex); + @Schedule(dayOfWeek="0", hour="0",minute="30") + public void makeLinksForAllSavedSearchesTimer() { + if (systemConfig.isTimerServer()) { + logger.info("Linking saved searches"); + try { + JsonObjectBuilder makeLinksForAllSavedSearches = makeLinksForAllSavedSearches(false); + } catch (SearchException | CommandException ex) { + Logger.getLogger(SavedSearchServiceBean.class.getName()).log(Level.SEVERE, null, ex); + } } }