]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
Salome HOME
Refactoring of Database, replacing SQL by DAOs calls. Methods for search by criteria...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / ImportDocumentAction.java
index 6508745562dde7e78c4204f4a5e51cd7dc32deb9..47957e5b3622163054cbe745801dada692ee2eb7 100644 (file)
@@ -19,9 +19,11 @@ import org.splat.manox.Toolbox;
 import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.ProgressState;
+import org.splat.service.DocumentService;
 import org.splat.service.PublicationService;
 import org.splat.service.StepService;
 import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.RepositoryService;
 import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.som.Revision;
@@ -29,27 +31,52 @@ import org.splat.som.Step;
 
 public class ImportDocumentAction extends UploadBaseNextAction {
 
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = 2587822564883588556L;
+
        private List<DocumentType> doctypes = null;
        private long doctype = 0;
        private String docref = null; // Reference extracted from the imported file, if exist
        private String docver = ""; // Version number extracted from the imported file, if exist
        private String date = ""; // Date extracted from the imported file, if exist
+       /**
+        * Injected project settings service.
+        */
        private ProjectSettingsService _projectSettingsService;
+       /**
+        * Injected publication service.
+        */
        private PublicationService _publicationService;
+       /**
+        * Injected step service.
+        */
        private StepService _stepService;
+       /**
+        * Injected document service.
+        */
+       private DocumentService _documentService;
 
-       private static final long serialVersionUID = 2587822564883588556L;
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
 
        // ==============================================================================================================================
        // Action methods
        // ==============================================================================================================================
 
+       /**
+        * Initialize the operation.
+        * @return SUCCESS in success, otherwise - ERROR
+        */
        public String doInitialize() {
                // -----------------------------
                Session connex = Database.getSession();
                Transaction transax = connex.beginTransaction();
                User user = getConnectedUser();
-               File updir = Database.getDownloadDirectory(user);
+               File updir = getRepositoryService().getDownloadDirectory(user);
                File upfile = new File(updir.getPath() + "/" + filename);
                String[] table = filename.split("\\x2E");
                String filext = table[table.length - 1].toLowerCase();
@@ -75,7 +102,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                                break;
                        }
                        if (fileref != null) {
-                               Document slot = Database.selectDocument(fileref,
+                               Document slot = getDocumentService().selectDocument(fileref,
                                                new Revision().toString());
                                if (slot == null) {
                                        setErrorCode("reference.undefined");
@@ -139,6 +166,10 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                return SUCCESS;
        }
 
+       /**
+        * Perform import of a document.
+        * @return SUCCESS if ok, "cancel" - if canceled, ERROR - if error
+        */
        public String doImport() {
                // -------------------------
                if (action == ToDo.cancel)
@@ -155,7 +186,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                        User user = getConnectedUser();
                        Step step = mystudy.getSelectedStep();
                        DocumentType type = Document.selectType((int)doctype);
-                       File updir = Database.getDownloadDirectory(user);
+                       File updir = getRepositoryService().getDownloadDirectory(user);
                        File upfile = new File(updir.getPath() + "/" + filename);
                        String[] table = filename.split("\\x2E");
 
@@ -375,4 +406,36 @@ public class ImportDocumentAction extends UploadBaseNextAction {
        public void setStepService(StepService stepService) {
                _stepService = stepService;
        }
+
+       /**
+        * Get the documentService.
+        * @return the documentService
+        */
+       public DocumentService getDocumentService() {
+               return _documentService;
+       }
+
+       /**
+        * Set the documentService.
+        * @param documentService the documentService to set
+        */
+       public void setDocumentService(DocumentService documentService) {
+               _documentService = documentService;
+       }
+
+       /**
+        * Get the repositoryService.
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * @param repositoryService the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
 }
\ No newline at end of file