From b33bd47480e70dc4b56641369ca2ba67c08d52aa Mon Sep 17 00:00:00 2001 From: rkv Date: Tue, 23 Oct 2012 04:54:00 +0000 Subject: [PATCH] Study reindexing action is simplified. --- .../src/org/splat/dal/dao/som/Database.java | 6 - .../src/org/splat/service/SearchService.java | 22 +- .../org/splat/service/SearchServiceImpl.java | 74 ++++- .../splat/service/dto/ImportedStudyDTO.java | 78 +++++ .../src/spring/businessServiceContext.xml | 1 + .../org/splat/module/SaveDocumentAction.java | 1 - .../splat/simer/DisplayKnowledgeAction.java | 216 +++++++------ .../splat/simer/DisplayStudyStepAction.java | 305 +++++++++--------- .../simer/admin/DatabaseIndexingAction.java | 34 +- .../splat/simer/admin/ImportUserAction.java | 4 - .../org/splat/simer/admin/ImportedStudy.java | 110 ------- .../Siman/src/spring/applicationContext.xml | 6 - 12 files changed, 434 insertions(+), 423 deletions(-) create mode 100644 Workspace/Siman-Common/src/org/splat/service/dto/ImportedStudyDTO.java delete mode 100644 Workspace/Siman/src/org/splat/simer/admin/ImportedStudy.java diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/Database.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/Database.java index 649b2f5..4a206b9 100644 --- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/Database.java +++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/Database.java @@ -71,12 +71,10 @@ public class Database extends org.splat.dal.dao.kernel.Database { } public static Session getCurSession() { - // ----------------------------------- return getInstance().getSession(); } public Database getCheckedDB() { - // ------------------------------- if (my == null) try { my = this; @@ -103,12 +101,10 @@ public class Database extends org.splat.dal.dao.kernel.Database { // ============================================================================================================================== public boolean isInitialized() { - // ------------------------------- return (uplevel >= 0); } public void initialize() throws IOException, SQLException { - // ------------------------- logger.info("Creation of the database."); // Creation of the Lucene index @@ -127,14 +123,12 @@ public class Database extends org.splat.dal.dao.kernel.Database { // ============================================================================================================================== public void configure(Properties reprop) throws IOException { - // -------------------------------------------- String basepath = reprop.getProperty("repository"); getRepositoryService().setBasepath(basepath); getIndexService().configure(); } protected void populate() { - // -------------------------- try { // Initialization of the schema version this.setSchemaVersion("D0.3"); // TODO: Get the version name from the configuration file diff --git a/Workspace/Siman-Common/src/org/splat/service/SearchService.java b/Workspace/Siman-Common/src/org/splat/service/SearchService.java index b61b2f9..cda12a1 100644 --- a/Workspace/Siman-Common/src/org/splat/service/SearchService.java +++ b/Workspace/Siman-Common/src/org/splat/service/SearchService.java @@ -10,17 +10,25 @@ package org.splat.service; import java.util.List; - import org.splat.dal.bo.som.KnowledgeElement; import org.splat.dal.bo.som.Study; +import org.splat.service.dto.ImportedStudyDTO; import org.splat.service.dto.Proxy; /** * Search service interface. + * * @author Roman Kozlov (RKV) */ public interface SearchService { + /** + * Get a list of studies which are currently not presented in the lucene index. + * + * @return list of ImportedStudy DTO + */ + public List selectStudies(); + /** * Refresh lucene index for studies. * @@ -31,7 +39,9 @@ public interface SearchService { /** * Find knowledge elements with given properties. - * @param kprop search filter parameters + * + * @param kprop + * search filter parameters * @return the list of found knowledge elements as proxiy results of lucene search */ public List selectKnowledgeElementsWhere( @@ -39,14 +49,18 @@ public interface SearchService { /** * Find studies with given properties. - * @param sprop search filter parameters + * + * @param sprop + * search filter parameters * @return the list of found studies as proxiy results of lucene search */ public List selectStudiesWhere(Study.Properties... sprop); /** * Refresh lucene index for a study. - * @param study the study to reindex + * + * @param study + * the study to reindex */ public void indexStudy(Study study); } diff --git a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java index ad113b6..d58620a 100644 --- a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java @@ -38,10 +38,13 @@ import org.splat.dal.bo.som.Scenario; import org.splat.dal.bo.som.SimulationContext; import org.splat.dal.bo.som.Study; import org.splat.dal.bo.som.Visibility; +import org.splat.dal.dao.som.StudyDAO; import org.splat.service.dto.Proxy; import org.splat.service.technical.IndexService; import org.splat.service.technical.IndexServiceImpl; import org.splat.service.technical.RepositoryService; +import org.splat.service.dto.ImportedStudyDTO; +import org.splat.util.BeanHelper; import org.springframework.transaction.annotation.Transactional; /** @@ -65,11 +68,43 @@ public class SearchServiceImpl implements SearchService { * Injected index service. */ private IndexService _indexService; - /** * Injected study service. */ private StudyService _studyService; + /** + * Injected study DAO. + */ + private StudyDAO _studyDAO; + + /** + * Get a list of studies which are currently not presented in the lucene index. + * @return list of ImportedStudy DTO + */ + @Transactional(readOnly=true) + public List selectStudies() { + List table = new ArrayList(); + Study.Properties sprop = new Study.Properties(); + List dbStudies = getStudyDAO().getAll(); + + for (Study aStudy : dbStudies) { + try { + sprop.clear(); + if (selectStudiesWhere( + sprop.setReference(aStudy.getReference())).size() != 0) { + // If this study was already indexed and found in the lucene index + // then skip it to avoid adding to the index it again. + continue; + } + } catch (Exception error) { + continue; + } + // Add the study to the list of studies which are + // currently not presented in the lucene index. + table.add(BeanHelper.copyBean(aStudy, ImportedStudyDTO.class)); + } + return table; + } /** * Refresh lucene index for studies. @@ -347,7 +382,8 @@ public class SearchServiceImpl implements SearchService { * @see org.splat.service.SearchService#indexStudy(org.splat.dal.bo.som.Study) */ public void indexStudy(Study study) { - logger.debug("Index study: id=" + study.getRid() + "; reference=" + study.getReference()); + logger.debug("Index study: id=" + study.getRid() + "; reference=" + + study.getReference()); try { Study.Properties sprop = new Study.Properties(); List index = selectStudiesWhere(sprop.setReference(study @@ -361,7 +397,8 @@ public class SearchServiceImpl implements SearchService { IndexService lucin = getIndex(); Scenario[] scenes = study.getScenarii(); - logger.debug("Number of study " + study.getReference() + " actors: " + study.getActor().size()); + logger.debug("Number of study " + study.getReference() + + " actors: " + study.getActor().size()); lucin.add(study); if (study.getProgressState() != ProgressState.inWORK) for (int i = 0; i < scenes.length; i++) { @@ -370,12 +407,13 @@ public class SearchServiceImpl implements SearchService { for (Iterator j = list.iterator(); j .hasNext();) { lucin.add(j.next()); - logger.debug("Knowlegge added: id=" + j.next().getIndex()); + logger.debug("Knowlegge added: id=" + + j.next().getIndex()); } } } catch (Exception error) { - logger.error("Unable to index the study '" - + study.getIndex() + "', reason:", error); + logger.error("Unable to index the study '" + study.getIndex() + + "', reason:", error); } } @@ -433,6 +471,7 @@ public class SearchServiceImpl implements SearchService { /** * Get the studyService. + * * @return the studyService */ public StudyService getStudyService() { @@ -441,9 +480,30 @@ public class SearchServiceImpl implements SearchService { /** * Set the studyService. - * @param studyService the studyService to set + * + * @param studyService + * the studyService to set */ public void setStudyService(StudyService studyService) { _studyService = studyService; } + + /** + * Get the studyDAO. + * + * @return the studyDAO + */ + public StudyDAO getStudyDAO() { + return _studyDAO; + } + + /** + * Set the studyDAO. + * + * @param studyDAO + * the studyDAO to set + */ + public void setStudyDAO(StudyDAO studyDAO) { + _studyDAO = studyDAO; + } } diff --git a/Workspace/Siman-Common/src/org/splat/service/dto/ImportedStudyDTO.java b/Workspace/Siman-Common/src/org/splat/service/dto/ImportedStudyDTO.java new file mode 100644 index 0000000..98ac862 --- /dev/null +++ b/Workspace/Siman-Common/src/org/splat/service/dto/ImportedStudyDTO.java @@ -0,0 +1,78 @@ +package org.splat.service.dto; + +/** + * DTO for a study in the reindexing form. + * + * @author Roman Kozlov (RKV) + */ +public class ImportedStudyDTO { + + /** + * DB primary key. + */ + private long rid; + /** + * Study reference. + */ + private String sid; + /** + * Study title. + */ + private String title; + + /** + * Get the rid. + * @return the rid + */ + public long getIndex() { + return rid; + } + + /** + * Get the rid. + * @return the rid + */ + public long getRid() { + return rid; + } + + /** + * Set the rid. + * @param rid the rid to set + */ + public void setRid(long rid) { + this.rid = rid; + } + + /** + * Get the sid. + * @return the sid + */ + public String getReference() { + return sid; + } + + /** + * Set the sid. + * @param sid the sid to set + */ + public void setReference(String sid) { + this.sid = sid; + } + + /** + * Get the title. + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Set the title. + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } +} \ No newline at end of file diff --git a/Workspace/Siman-Common/src/spring/businessServiceContext.xml b/Workspace/Siman-Common/src/spring/businessServiceContext.xml index 51146ad..054bb16 100644 --- a/Workspace/Siman-Common/src/spring/businessServiceContext.xml +++ b/Workspace/Siman-Common/src/spring/businessServiceContext.xml @@ -87,6 +87,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> + diff --git a/Workspace/Siman/src/org/splat/module/SaveDocumentAction.java b/Workspace/Siman/src/org/splat/module/SaveDocumentAction.java index 611e584..878975b 100644 --- a/Workspace/Siman/src/org/splat/module/SaveDocumentAction.java +++ b/Workspace/Siman/src/org/splat/module/SaveDocumentAction.java @@ -365,7 +365,6 @@ public class SaveDocumentAction extends Action { // ============================================================================================================================== private void setupDefaultUses(DocumentType type) { - // ------------------------------------------------- Set uses = type.getDefaultUses(); for (Iterator i = uses.iterator(); i.hasNext();) { diff --git a/Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java b/Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java index a300c3d..eb21c3d 100644 --- a/Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java +++ b/Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java @@ -2,124 +2,124 @@ package org.splat.simer; import java.util.List; -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.splat.dal.dao.som.Database; import org.splat.dal.bo.som.KnowledgeElement; import org.splat.service.KnowledgeElementService; import org.splat.som.Step; - public class DisplayKnowledgeAction extends DisplayBaseAction { - protected OpenKnowledge myknelm = null; // Knowledge Element details + /** + * Serial version ID. + */ + private static final long serialVersionUID = 8473504456981431762L; + + /** + * Current knowledge element details. + */ + protected OpenKnowledge myknelm = null; + /** + * Injected knowledge element service. + */ private KnowledgeElementService _knowledgeElementService; - - private static final long serialVersionUID = 8473504456981431762L; -// ============================================================================================================================== -// Action methods -// ============================================================================================================================== - - public String doOpen () { -// ----------------------- - Session connex = Database.getCurSession(); - Transaction transax = connex.beginTransaction(); - - myknelm = getOpenKnowledge(); - if (myindex != null) try { // Opening a knowledge from the search result - int index = Integer.valueOf(myindex); - if (myknelm != null && myknelm.getIndex() == index) { // - The selected knowledge is currently open - selection = myknelm.getSelection(); // Current selection - } else { // - The selected knowledge is new - KnowledgeElement kelm = getKnowledgeElementService().selectKnowledgeElement(index); - myknelm = open(kelm); - selection = myknelm.getSelection(); // Default selection - } - } - catch (Exception error) { - logger.error("Reason:", error); - return ERROR; - } - else if (selection != null) { // Re-opening (refreshing) the currently open knowledge - KnowledgeElement kelm = getKnowledgeElementService().selectKnowledgeElement(myknelm.getIndex()); - myknelm = open(kelm); // Closes the previously open knowledge - myknelm.setSelection(selection); - } - getSession().put("menu.knowledge", myknelm.getMenu()); - - transax.commit(); - return SUCCESS; - } - - public String doSelectStep () { -// ----------------------------- - Session connex = Database.getCurSession(); - Transaction transax = connex.beginTransaction(); - - myknelm = getOpenKnowledge(); - - if (selection == null) { // Switch back to the current study - selection = myknelm.getSelection(); - } else { // Selection of a step of current study - myknelm.setSelection(selection); - } - transax.commit(); - return SUCCESS; - } - - public String doSelectDocument () { -// --------------------------------- - Execute todo = Execute.valueOf(action); - myknelm = getOpenKnowledge(); - if (todo == Execute.develop) myknelm.developDocument(myindex); - else if (todo == Execute.reduce) myknelm.reduceHistory(myindex); - else if (todo == Execute.reduceall) myknelm.reduceDocument(myindex); - return SUCCESS; - } - - public String doSelectKnowledge () { -// ---------------------------------- - Execute todo = Execute.valueOf(action); - myknelm = getOpenKnowledge(); - if (todo == Execute.develop) myknelm.developKnowledge(myindex); - else if (todo == Execute.reduce) myknelm.reduceKnowledge(myindex); - return SUCCESS; - } - - public String doClose () { -// ------------------------ - closeKnowledge(); - return SUCCESS; - } -// ============================================================================================================================== -// Getters -// ============================================================================================================================== - - public List getDocuments () { -// -------------------------------------------- - return myknelm.getDisplayedDocuments(); - } - public List getKnowledges () { -// ---------------------------------------------------------- - return myknelm.getDisplayedKnowledges(); - } - public List getSimulationContexts () { -// ------------------------------------------------------------- - return myknelm.getDisplayedSimulationContexts(); - } - public Step getSelectedStep () { -// ------------------------------ - return myknelm.getSelectedStep(); - } - public String getWriteAccess () { -// ------------------------------- - return "false"; - } + // ============================================================================================================================== + // Action methods + // ============================================================================================================================== + + public String doOpen() { + myknelm = getOpenKnowledge(); + if (myindex != null) + try { // Opening a knowledge from the search result + int index = Integer.valueOf(myindex); + if (myknelm != null && myknelm.getIndex() == index) { // - The selected knowledge is currently open + selection = myknelm.getSelection(); // Current selection + } else { // - The selected knowledge is new + KnowledgeElement kelm = getKnowledgeElementService() + .selectKnowledgeElement(index); + myknelm = open(kelm); + selection = myknelm.getSelection(); // Default selection + } + } catch (Exception error) { + logger.error("Reason:", error); + return ERROR; + } + else if (selection != null) { // Re-opening (refreshing) the currently open knowledge + KnowledgeElement kelm = getKnowledgeElementService() + .selectKnowledgeElement(myknelm.getIndex()); + myknelm = open(kelm); // Closes the previously open knowledge + myknelm.setSelection(selection); + } + getSession().put("menu.knowledge", myknelm.getMenu()); + + return SUCCESS; + } + + public String doSelectStep() { + myknelm = getOpenKnowledge(); + + if (selection == null) { // Switch back to the current study + selection = myknelm.getSelection(); + } else { // Selection of a step of current study + myknelm.setSelection(selection); + } + return SUCCESS; + } + + public String doSelectDocument() { + Execute todo = Execute.valueOf(action); + myknelm = getOpenKnowledge(); + if (todo == Execute.develop) + myknelm.developDocument(myindex); + else if (todo == Execute.reduce) + myknelm.reduceHistory(myindex); + else if (todo == Execute.reduceall) + myknelm.reduceDocument(myindex); + return SUCCESS; + } + + public String doSelectKnowledge() { + Execute todo = Execute.valueOf(action); + myknelm = getOpenKnowledge(); + if (todo == Execute.develop) + myknelm.developKnowledge(myindex); + else if (todo == Execute.reduce) + myknelm.reduceKnowledge(myindex); + return SUCCESS; + } + + public String doClose() { + closeKnowledge(); + return SUCCESS; + } + + // ============================================================================================================================== + // Getters + // ============================================================================================================================== + + public List getDocuments() { + return myknelm.getDisplayedDocuments(); + } + + public List getKnowledges() { + return myknelm.getDisplayedKnowledges(); + } + + public List getSimulationContexts() { + return myknelm.getDisplayedSimulationContexts(); + } + + public Step getSelectedStep() { + return myknelm.getSelectedStep(); + } + + public String getWriteAccess() { + return "false"; + } /** * Get the knowledgeElementService. + * * @return the knowledgeElementService */ public KnowledgeElementService getKnowledgeElementService() { @@ -128,7 +128,9 @@ public class DisplayKnowledgeAction extends DisplayBaseAction { /** * Set the knowledgeElementService. - * @param knowledgeElementService the knowledgeElementService to set + * + * @param knowledgeElementService + * the knowledgeElementService to set */ public void setKnowledgeElementService( KnowledgeElementService knowledgeElementService) { diff --git a/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java b/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java index ab478c7..a7cf86a 100644 --- a/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java +++ b/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java @@ -2,9 +2,6 @@ package org.splat.simer; import java.util.List; -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.splat.dal.dao.som.Database; import org.splat.dal.bo.som.ProjectElement; import org.splat.dal.bo.som.Scenario; import org.splat.service.StudyService; @@ -13,162 +10,161 @@ import org.splat.dal.bo.som.Study; import org.splat.wapp.PopupMenu; import org.splat.wapp.SimpleMenu; - public class DisplayStudyStepAction extends DisplayBaseAction { - protected OpenStudy mystudy = null; // Presented study + /** + * Serial version ID. + */ + private static final long serialVersionUID = 6467920934724352021L; + + /** + * Presented study. + */ + protected OpenStudy mystudy = null; + /** + * Injected study service. + */ private StudyService _studyService; - private static final long serialVersionUID = 6467920934724352021L; + // ============================================================================================================================== + // Action methods + // ============================================================================================================================== + + public String doOpen() { + Study study; + mystudy = getOpenStudy(); + if (myindex != null) + try { // Opening a study from the search result + int index = Integer.valueOf(myindex); + if (mystudy != null && mystudy.getStudyObject() != null + && mystudy.getIndex() == index) { // - The selected study is currently open + selection = mystudy.getSelection(); // Current selection + study = mystudy.getStudyObject(); // Current Study object + // RKV:BEGIN: put in session if necessary + if (!getSession().containsKey("study.open")) { + open(study); + } + // RKV:END + } else { // - The selected study is new + study = getStudyService().selectStudy(index); + mystudy = open(study); + selection = mystudy.getSelection(); // Default selection + } + } catch (Exception error) { + logger.error("Reason:", error); + return ERROR; + } + else if (selection == null) { // Opening a study just newed + selection = mystudy.getSelection(); // Default selection + study = mystudy.getStudyObject(); + } else { // Re-opening (refreshing) the currently open study + study = getStudyService().selectStudy(mystudy.getIndex()); + mystudy = open(study); // Closes the previously open study + mystudy.setSelection(selection); + } + // Initialization of menus + ProjectElement owner = mystudy.getSelectedStep().getOwner(); + SimpleMenu menu = ApplicationSettings.getMenu("configuration"); + if (owner instanceof Scenario) { + menu.enables("prop-scenario"); + menu.selects("prop-scenario"); + } else { + menu.disables("prop-scenario"); + menu.selects("prop-general"); + } + getSession().put("menu.study", mystudy.getMenu()); + + return SUCCESS; + } + + public String doSelectStep() { + + mystudy = getOpenStudy(); + if (selection == null) { // Switch back to the current study + selection = mystudy.getSelection(); + } else { // Selection of a step of current study + mystudy.setSelection(selection); + } + // Re-initialization of the properties menu according to the selected step + ProjectElement owner = mystudy.getSelectedStep().getOwner(); + SimpleMenu menu = ApplicationSettings.getMenu("configuration"); + if (owner instanceof Scenario) { + menu.enables("prop-scenario"); + menu.selects("prop-scenario"); + } else { + menu.disables("prop-scenario"); + menu.selects("prop-general"); + } + return SUCCESS; + } + + public String doSelectDocument() { + mystudy = getOpenStudy(); + Execute todo = Execute.valueOf(action); + if (todo == Execute.develop) + mystudy.developDocument(myindex); + else if (todo == Execute.reduce) + mystudy.reduceHistory(myindex); + else if (todo == Execute.reduceall) + mystudy.reduceDocument(myindex); + return SUCCESS; + } -// ============================================================================================================================== -// Action methods -// ============================================================================================================================== - - public String doOpen () { -// ----------------------- - Session connex = Database.getCurSession(); - Transaction transax = connex.beginTransaction(); - Study study; - - mystudy = getOpenStudy(); - if (myindex != null) try { // Opening a study from the search result - int index = Integer.valueOf(myindex); - if (mystudy != null && mystudy.getStudyObject() != null && mystudy.getIndex() == index) { // - The selected study is currently open - selection = mystudy.getSelection(); // Current selection - study = mystudy.getStudyObject(); // Current Study object - //RKV:BEGIN: put in session if necessary - if (!getSession().containsKey("study.open")) { - open(study); - } - //RKV:END - } else { // - The selected study is new - study = getStudyService().selectStudy(index); - mystudy = open(study); - selection = mystudy.getSelection(); // Default selection - } - } - catch (Exception error) { - logger.error("Reason:", error); - return ERROR; - } - else if (selection == null) { // Opening a study just newed - selection = mystudy.getSelection(); // Default selection - study = mystudy.getStudyObject(); - } - else { // Re-opening (refreshing) the currently open study - study = getStudyService().selectStudy(mystudy.getIndex()); - mystudy = open(study); // Closes the previously open study - mystudy.setSelection(selection); - } -// Initialization of menus - ProjectElement owner = mystudy.getSelectedStep().getOwner(); - SimpleMenu menu = ApplicationSettings.getMenu("configuration"); - if (owner instanceof Scenario) { - menu.enables("prop-scenario"); - menu.selects("prop-scenario"); - } else { - menu.disables("prop-scenario"); - menu.selects("prop-general"); - } - getSession().put("menu.study", mystudy.getMenu()); - - transax.commit(); - return SUCCESS; - } - - public String doSelectStep () { -// ----------------------------- - Session connex = Database.getCurSession(); - Transaction transax = connex.beginTransaction(); - - mystudy = getOpenStudy(); - if (selection == null) { // Switch back to the current study - selection = mystudy.getSelection(); - } else { // Selection of a step of current study - mystudy.setSelection(selection); - } -// Re-initialization of the properties menu according to the selected step - ProjectElement owner = mystudy.getSelectedStep().getOwner(); - SimpleMenu menu = ApplicationSettings.getMenu("configuration"); - if (owner instanceof Scenario) { - menu.enables("prop-scenario"); - menu.selects("prop-scenario"); - } else { - menu.disables("prop-scenario"); - menu.selects("prop-general"); - } - transax.commit(); - return SUCCESS; - } - - public String doSelectDocument () { -// --------------------------------- - mystudy = getOpenStudy(); - - Execute todo = Execute.valueOf(action); - if (todo == Execute.develop) mystudy.developDocument(myindex); - else if (todo == Execute.reduce) mystudy.reduceHistory(myindex); - else if (todo == Execute.reduceall) mystudy.reduceDocument(myindex); - return SUCCESS; - } - - public String doSelectKnowledge () { -// ---------------------------------- - mystudy = getOpenStudy(); - - Execute todo = Execute.valueOf(action); - if (todo == Execute.develop) mystudy.developKnowledge(myindex); - else if (todo == Execute.reduce) mystudy.reduceKnowledge(myindex); - return SUCCESS; - } - - public String doClose () { -// ------------------------ - closeStudy(); - return SUCCESS; - } -// ============================================================================================================================== -// Getters -// ============================================================================================================================== - - public String getAction () { -// -------------------------- - return action; - } - public List getDocuments () { -// ------------------------------------------- - return mystudy.getDisplayedDocuments(); - } - public List getKnowledges () { -// ---------------------------------------------------------- - return mystudy.getDisplayedKnowledges(); - } - public List getSimulationContexts () { -// ------------------------------------------------------------- - return mystudy.getDisplayedSimulationContexts(); - } - public PopupMenu getPopup () { -// ---------------------------- - return mystudy.getPopup(); - } - public int getStepNumber () { -// --------------------------- - return mystudy.getSelectedStep().getNumber(); - } - public String getStepEnabled () { -// ------------------------------- - return String.valueOf(mystudy.isStepEnabled()); - } - public StepRights getUserRights () { -// ---------------------------------- - return mystudy.getSelectedStepRights(); - } - public String getWriteAccess () { -// ------------------------------- - return String.valueOf(mystudy.isOpenForWriting()); - } + public String doSelectKnowledge() { + mystudy = getOpenStudy(); + Execute todo = Execute.valueOf(action); + if (todo == Execute.develop) + mystudy.developKnowledge(myindex); + else if (todo == Execute.reduce) + mystudy.reduceKnowledge(myindex); + return SUCCESS; + } + + public String doClose() { + closeStudy(); + return SUCCESS; + } + + // ============================================================================================================================== + // Getters + // ============================================================================================================================== + + public String getAction() { + return action; + } + + public List getDocuments() { + return mystudy.getDisplayedDocuments(); + } + + public List getKnowledges() { + return mystudy.getDisplayedKnowledges(); + } + + public List getSimulationContexts() { + return mystudy.getDisplayedSimulationContexts(); + } + + public PopupMenu getPopup() { + return mystudy.getPopup(); + } + + public int getStepNumber() { + return mystudy.getSelectedStep().getNumber(); + } + + public String getStepEnabled() { + return String.valueOf(mystudy.isStepEnabled()); + } + + public StepRights getUserRights() { + return mystudy.getSelectedStepRights(); + } + + public String getWriteAccess() { + return String.valueOf(mystudy.isOpenForWriting()); + } /** * Get the studyService. @@ -189,8 +185,9 @@ public class DisplayStudyStepAction extends DisplayBaseAction { _studyService = studyService; } - /** + /** * {@inheritDoc} + * * @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy) */ @Override diff --git a/Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java b/Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java index f862a14..0cdec24 100644 --- a/Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java +++ b/Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; import org.splat.service.SearchService; +import org.splat.service.dto.ImportedStudyDTO; import org.splat.simer.Action; /** @@ -18,9 +19,14 @@ public class DatabaseIndexingAction extends Action { */ private static final long serialVersionUID = 4194268823457749655L; - private List newstudies; + /** + * New studies which are not yet indexed by lucene. + */ + private List newstudies; + /** + * Id's of studies to reindex. + */ private String indices; - private ImportedStudy _importedStudy; /** * Injected search service. */ @@ -35,7 +41,7 @@ public class DatabaseIndexingAction extends Action { * @return SUCCESS */ public String doInitialize() { - newstudies = getImportedStudy().selectAll(); + newstudies = getSearchService().selectStudies(); indices = ""; return SUCCESS; } @@ -64,30 +70,10 @@ public class DatabaseIndexingAction extends Action { * * @return the new studies */ - public List getNewStudies() { - // ------------------------------------------- + public List getNewStudies() { return newstudies; } - /** - * Get the importedStudy. - * - * @return the importedStudy - */ - public ImportedStudy getImportedStudy() { - return _importedStudy; - } - - /** - * Set the importedStudy. - * - * @param importedStudy - * the importedStudy to set - */ - public void setImportedStudy(ImportedStudy importedStudy) { - _importedStudy = importedStudy; - } - /** * Get the indices. * @return the indices diff --git a/Workspace/Siman/src/org/splat/simer/admin/ImportUserAction.java b/Workspace/Siman/src/org/splat/simer/admin/ImportUserAction.java index ee82a22..14f772d 100644 --- a/Workspace/Siman/src/org/splat/simer/admin/ImportUserAction.java +++ b/Workspace/Siman/src/org/splat/simer/admin/ImportUserAction.java @@ -38,9 +38,6 @@ public class ImportUserAction extends UploadBaseNextAction { // ============================================================================================================================== public String doImport () { -// ------------------------- - Session connex = Database.getCurSession(); - Transaction transax = connex.beginTransaction(); try { User user = getConnectedUser(); // The database administrator File updir = getRepositoryService().getDownloadDirectory(user); @@ -54,7 +51,6 @@ public class ImportUserAction extends UploadBaseNextAction { i.remove(); // Just for not showing the corresponding reserved username break; } - transax.commit(); return SUCCESS; } catch (Exception error) { diff --git a/Workspace/Siman/src/org/splat/simer/admin/ImportedStudy.java b/Workspace/Siman/src/org/splat/simer/admin/ImportedStudy.java deleted file mode 100644 index 837a9c5..0000000 --- a/Workspace/Siman/src/org/splat/simer/admin/ImportedStudy.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.splat.simer.admin; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; - -import org.hibernate.Session; -import org.hibernate.jdbc.Work; -import org.splat.dal.dao.som.Database; -import org.splat.dal.bo.som.Study; -import org.splat.service.SearchService; - - -public class ImportedStudy { - - private SearchService _searchService; - private int rid; - private String sid; - private String title; - - protected class SelectStudies implements Work { -// ---------------------------------------------------- - - private List table = new ArrayList(); - - protected SelectStudies(SearchService searchService) { - } - - public void execute (Connection connex) throws SQLException - { - Statement request = connex.createStatement(); - String select = "SELECT rid,sid,title FROM study"; - ResultSet result = request.executeQuery(select); - Study.Properties sprop = new Study.Properties(); - - while (result.next()) { - int rid = result.getInt("rid"); - String sid = result.getString("sid"); - String title = result.getString("title"); - try { - sprop.clear(); - if (getSearchService().selectStudiesWhere(sprop.setReference(sid)).size() != 0) continue; - } catch (Exception error) { - continue; - } - table.add( new ImportedStudy(rid, sid, title) ); - } - } - - public List getResult () - { - return table; - } - } - -// ============================================================================================================================== -// Constructor -// ============================================================================================================================== - - public ImportedStudy () { - } - - public ImportedStudy (int rid, String sid, String title) { - // -------------------------------------------------------- - this.rid = rid; - this.sid = sid; - this.title = title; - } - -// ============================================================================================================================== -// Public member functions -// ============================================================================================================================== - - public int getIndex () { -// ---------------------- - return rid; - } - public String getReference () { -// ----------------------------- - return sid; - } - public String getTitle () { -// ------------------------- - return title; - } - -// ============================================================================================================================== -// Public services -// ============================================================================================================================== - - public List selectAll () { -// ---------------------------------------------- - Session session = Database.getCurSession(); - SelectStudies query = new SelectStudies(getSearchService()); - session.doWork(query); - - return query.getResult(); - } - - public org.splat.service.SearchService getSearchService() { - return _searchService; - } - - public void setSearchService(SearchService searchService) { - _searchService = searchService; - } -} \ No newline at end of file diff --git a/Workspace/Siman/src/spring/applicationContext.xml b/Workspace/Siman/src/spring/applicationContext.xml index c7f34a5..e23007a 100644 --- a/Workspace/Siman/src/spring/applicationContext.xml +++ b/Workspace/Siman/src/spring/applicationContext.xml @@ -39,11 +39,6 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - - - - @@ -237,7 +232,6 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - -- 2.39.2