]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Study reindexing action is simplified.
authorrkv <rkv@opencascade.com>
Tue, 23 Oct 2012 04:54:00 +0000 (04:54 +0000)
committerrkv <rkv@opencascade.com>
Tue, 23 Oct 2012 04:54:00 +0000 (04:54 +0000)
12 files changed:
Workspace/Siman-Common/src/org/splat/dal/dao/som/Database.java
Workspace/Siman-Common/src/org/splat/service/SearchService.java
Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/dto/ImportedStudyDTO.java [new file with mode: 0644]
Workspace/Siman-Common/src/spring/businessServiceContext.xml
Workspace/Siman/src/org/splat/module/SaveDocumentAction.java
Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java
Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java
Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java
Workspace/Siman/src/org/splat/simer/admin/ImportUserAction.java
Workspace/Siman/src/org/splat/simer/admin/ImportedStudy.java [deleted file]
Workspace/Siman/src/spring/applicationContext.xml

index 649b2f50f1c9f313da68bc817c98264d6d6d8c68..4a206b93ecb49c3bf446621a971bc24254796fa6 100644 (file)
@@ -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
index b61b2f9fcf04ed80cec61f99471d8e3d143821a6..cda12a1a07ab28edb54beeeba977477b8f88fc21 100644 (file)
 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 <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public interface SearchService {
 
+       /**
+        * Get a list of studies which are currently not presented in the lucene index.
+        * 
+        * @return list of ImportedStudy DTO
+        */
+       public List<ImportedStudyDTO> 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<Proxy> 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<Proxy> 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);
 }
index ad113b60d7d84709f2981b7ff143889475fbd16c..d58620a5368b5545a0375c534a8fd14fc84150f7 100644 (file)
@@ -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<ImportedStudyDTO> selectStudies() {
+               List<ImportedStudyDTO> table = new ArrayList<ImportedStudyDTO>();
+               Study.Properties sprop = new Study.Properties();
+               List<Study> 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<Proxy> 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<KnowledgeElement> 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 (file)
index 0000000..98ac862
--- /dev/null
@@ -0,0 +1,78 @@
+package org.splat.service.dto;
+
+/**
+ * DTO for a study in the reindexing form.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+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
index 51146ad2083c68709a57044da5d7d69a4e6a1f95..054bb16e6d71eae0f9390f30d36446830f8d335a 100644 (file)
@@ -87,6 +87,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                <property name="indexService" ref="indexService" />
         <property name="repositoryService" ref="repositoryService" />
         <property name="studyService" ref="studyService" />
+        <property name="studyDAO" ref="studyDAO" />
        </bean>
 
        <bean id="stepService" class="org.splat.service.StepServiceImpl">
index 611e58444be6c5a915ecf72b9881ed782a7932b9..878975b33dfe3db0c9905bf78078d31624482284 100644 (file)
@@ -365,7 +365,6 @@ public class SaveDocumentAction extends Action {
        // ==============================================================================================================================
 
        private void setupDefaultUses(DocumentType type) {
-               // -------------------------------------------------
                Set<DocumentType> uses = type.getDefaultUses();
 
                for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
index a300c3d0142b43fb43bf95ab76d08eb58ef9bcca..eb21c3d845e43b2373e4b7d80b37da5373c1f4ef 100644 (file)
@@ -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<DocumentFacade> getDocuments () {
-//  --------------------------------------------
-      return myknelm.getDisplayedDocuments();
-    }
-    public List<OpenObject.KnowledgeIterator> getKnowledges () {
-//  ----------------------------------------------------------
-      return myknelm.getDisplayedKnowledges();
-    }
-    public List<SimulationContextFacade> 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<DocumentFacade> getDocuments() {
+               return myknelm.getDisplayedDocuments();
+       }
+
+       public List<OpenObject.KnowledgeIterator> getKnowledges() {
+               return myknelm.getDisplayedKnowledges();
+       }
+
+       public List<SimulationContextFacade> 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) {
index ab478c7eaa38d8c4a3deb686c6a58f52750cc51e..a7cf86a6e4ecb976ea4ff015d21a3190f7f6f8cd 100644 (file)
@@ -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<DocumentFacade> getDocuments () {
-//  -------------------------------------------
-      return mystudy.getDisplayedDocuments();
-    }
-    public List<OpenObject.KnowledgeIterator> getKnowledges () {
-//  ----------------------------------------------------------
-      return mystudy.getDisplayedKnowledges();
-    }
-    public List<SimulationContextFacade> 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<DocumentFacade> getDocuments() {
+               return mystudy.getDisplayedDocuments();
+       }
+
+       public List<OpenObject.KnowledgeIterator> getKnowledges() {
+               return mystudy.getDisplayedKnowledges();
+       }
+
+       public List<SimulationContextFacade> 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
index f862a1406f80b3a941d55fd15db26e88c1ee6c37..0cdec2426423b065696bb1afcd59213b3c9585b1 100644 (file)
@@ -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<ImportedStudy> newstudies;
+       /**
+        * New studies which are not yet indexed by lucene.
+        */
+       private List<ImportedStudyDTO> 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<ImportedStudy> getNewStudies() {
-               // -------------------------------------------
+       public List<ImportedStudyDTO> 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
index ee82a22e2be03ceaf92063336630ae8c2c987c86..14f772ddaf7fc0aa4a463439eb3fc675dbb03de3 100644 (file)
@@ -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 (file)
index 837a9c5..0000000
+++ /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<ImportedStudy> table = new ArrayList<ImportedStudy>();
-
-      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<ImportedStudy> 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<ImportedStudy> 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
index c7f34a55ecfb26c90725e2eaf70923668bf7d15d..e23007a57e4c9bd09148bbfe40d8447a7813a36d 100644 (file)
@@ -39,11 +39,6 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="documentTypeService" ref="documentTypeService" />
        </bean>
 
-       <bean id="importedStudy" class="org.splat.simer.admin.ImportedStudy"
-               scope="prototype">
-               <property name="searchService" ref="searchService" />
-       </bean>
-
        <bean id="slidMenu" scope="session" abstract="true">
                <property name="projectElementService"
                        ref="projectElementService" />
@@ -237,7 +232,6 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <bean id="databaseIndexingAction"
                class="org.splat.simer.admin.DatabaseIndexingAction"
                scope="prototype">
-               <property name="importedStudy" ref="importedStudy" />
                <property name="searchService" ref="searchService" />
        </bean>