]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java
Salome HOME
Mapping is fixed. Relation in the mapping is inherited from Persistent now. Versionin...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / VersionDocumentAction.java
index 529d48aa84a351f007dd0819f2bff18ac769d3ff..0af6bc1da7f3949f48110cb6942a53f66e06d4c5 100644 (file)
@@ -4,6 +4,7 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -35,7 +36,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
 
        private String index = null; // Versioned document index
        private List<Publication> usedby = null;
-       private String docusedby = null;
+       private long[] docusedby = null;
        private String summary = null; // Summary of changes in the new version
        private String docver = ""; // Version number extracted from the imported file, if exist
        private String date = ""; // Date extracted from the imported file, if exist
@@ -166,14 +167,28 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                if (action == ToDo.cancel)
                        return "cancel";
 
-               Session connex = Database.getCurSession();
-               Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
                        mystudy = getOpenStudy();
                        User user = getConnectedUser();
                        Step step = mystudy.getSelectedStep();
-                       File updir = getRepositoryService().getDownloadDirectory(user);
+//                     List<Step> steps = mystudy.getInvolvedSteps();
+                       Date aDate = null;
+                       if (date.length() > 0) {
+                               ResourceBundle locale = ResourceBundle.getBundle("som",
+                                               ApplicationSettings.getCurrentLocale());
+                               SimpleDateFormat get = new SimpleDateFormat(
+                                               locale.getString("date.format"));
+                               aDate = get.parse(date);
+                       }
+                       
+                       String[] listDocuses = null;
+                       if (docuses != null) {
+                               listDocuses = docuses.split(",");
+                       }
+                       getPublicationService().versionDocument(step, user, filename, Integer.valueOf(index), docver, 
+                                       summary, state, aDate, listDocuses, docusedby/*, steps*/);
+                       /*                      File updir = getRepositoryService().getDownloadDirectory(user);
                        File upfile = new File(updir.getPath() + "/" + filename);
 
                        // Versioning of the document
@@ -246,11 +261,11 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                                if (!compatible.contains(using.getIndex()))
                                        getPublicationService().outdate(using);
                        }
+*/
                        // Update of the open study
                        mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
                        // TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
 
-                       transax.commit();
                        return SUCCESS;
                } catch (FileNotFoundException error) {
                        logger.error("Reason:", error);
@@ -259,14 +274,6 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                        logger.error("Reason:", error);
                        setErrorCode("internal");
                }
-               if (transax != null && transax.isActive()) {
-                       // Second try-catch as the rollback could fail as well
-                       try {
-                               transax.rollback();
-                       } catch (HibernateException backerror) {
-                               logger.debug("Error rolling back transaction", backerror);
-                       }
-               }
                return ERROR;
        }
 
@@ -320,7 +327,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                this.index = index;
        }
 
-       public void setUsedBy(String list) {
+       public void setUsedBy(long[] list) {
                // -----------------------------------
                this.docusedby = list;
        }