Salome HOME
Fix for the file naming strategy "asis".
authorrkv <rkv@opencascade.com>
Fri, 18 Jan 2013 11:06:52 +0000 (11:06 +0000)
committerrkv <rkv@opencascade.com>
Fri, 18 Jan 2013 11:06:52 +0000 (11:06 +0000)
Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java
Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
Workspace/Siman/WebContent/study/upload.jsp

index aa9b6ddaaa031542e36cdf696eedadae92a4d608..8975ad6754b0ef1686f1655d236eb71eb39ca751 100644 (file)
@@ -327,7 +327,7 @@ public class Document extends Entity {
        public Document(final Properties dprop) throws MissedPropertyException,
                        InvalidPropertyException, MultiplyDefinedException {
                super(dprop); // Throws one of the above exception if not valid
-               myfile = new File(null, dprop.format, dprop.date); // The path is initialized below
+               myfile = new File(dprop.getLocalPath(), dprop.format, dprop.date); // The path is initialized below
                type = dprop.type;
                step = dprop.step.getNumber();
                name = dprop.name;
index c8494b13e70cf1fcd931b082cd3b4ca9ba3152ab..06455e4f9324d3b702f8ea0b08ba5b0b2276e1f0 100644 (file)
@@ -167,7 +167,7 @@ public class DocumentServiceImpl implements DocumentService {
                        encoding.append(scope.getReference()).append("_").append(
                                        tostring.format(number));
                } else { // title and (temporarily) asis
-                       encoding.append("_").append(tostring.format(number)).append(
+                       encoding.append(tostring.format(number)).append("_").append(
                                        aDoc.getFile().getName());
                }
                return encoding.toString();
@@ -184,12 +184,15 @@ public class DocumentServiceImpl implements DocumentService {
         */
        private String getEncodedRootName(final Document aDoc, final Study scope) {
                FileNaming scheme = getProjectSettings().getFileNamingScheme();
-
+               String res;
                if (scheme == FileNaming.encoded) {
-                       return scope.getReference();
+                       res = scope.getReference();
+               }else if (scheme == FileNaming.asis) {
+                       res = aDoc.getFile().getName();
                } else {
-                       return aDoc.getTitle();
+                       res = aDoc.getTitle();
                }
+               return res;
        }
 
        /**
index 98b0ef7ea6ca3fb36a7119dd7fda7f7d48a7a467..21ad0888b99e72b6cb2a2117b73dd8d7d10e5bee 100644 (file)
@@ -149,6 +149,7 @@ public class PublicationServiceImpl implements PublicationService {
 
                // Creation of the document
                Document.Properties dprop = new Document.Properties();
+               dprop.setLocalPath(upfile.getPath());
                Publication addoc;
 
                if (reference.length() == 0) { // Importation of a foreign document
@@ -229,6 +230,7 @@ public class PublicationServiceImpl implements PublicationService {
 
                // Versioning of the document
                Document.Properties dprop = new Document.Properties();
+               dprop.setLocalPath(upfile.getPath());
                Publication current = step.getDocument(docIndex);
                Publication next;
 
index 55f75248b302d0b55e2ab19f165559a8a08cfcec..6365f7e57e70fd0cc7cf5164cfdf58b403c65cdc 100644 (file)
@@ -563,6 +563,7 @@ public class ScenarioServiceImpl implements ScenarioService {
                        Document.Properties dprop = new Document.Properties();
                        // NOTE: Process only the first attached file for each document
                        FileDTO file = doc.getFiles().get(0);
+                       dprop.setLocalPath(file.getPath());
 
                        // Get document title as the file name
                        java.io.File upfile = new java.io.File(file.getPath());
index b5ad4006c19f91726685ab1312f76d6a6dbafdb9..425381eea67525a38a7c4a20efd2a2f89c58b525 100644 (file)
@@ -81,7 +81,7 @@ public class StudyServiceImpl implements StudyService {
        /**
         * Injected project service.
         */
-       private ProjectSettingsService _projectSettingsService;
+       private ProjectSettingsService _projectSettings;
 
        /**
         * Injected project element service.
@@ -1033,7 +1033,7 @@ public class StudyServiceImpl implements StudyService {
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+               return _projectSettings;
        }
 
        /**
@@ -1044,7 +1044,7 @@ public class StudyServiceImpl implements StudyService {
         */
        public void setProjectSettings(
                        final ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+               _projectSettings = projectSettingsService;
        }
 
        /**
index 8e1c84720541af1a11e9cf4150ef0c280c04f562..3bc423466913e401d54eaf4a26e4c0d609a6cd11 100644 (file)
@@ -2,44 +2,32 @@
     pageEncoding="ISO-8859-1"
 %>
 <%@taglib prefix="s" uri="/struts-tags"%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-
-  <head>
-    <link href=<s:url value="/skin/default.css"/> rel="stylesheet" type="text/css">
-    <script language="JavaScript">
-  
+<script language="JavaScript">
     function enableUpload () {
-//  ------------------------
       upform.doIt.disabled = false;
     }
-    </script>
-  </head>
-  <body>
-
+</script>
 <!-- Updload dialog
      =============================================================================================================================
   -->
-      <div id=article-box>
-        <div id=section><s:text name="title.%{nextAction}"/></div>
-        <div id=article-body class=text>
-          <form name="upform" enctype="multipart/form-data" action="upload" method="post">
-            <table>
-              <tr height=10><td></td></tr>
-              <s:hidden name="nextAction" value="%{nextAction}" />
-              <s:hidden name="index"      value="%{index}" />
-              <s:file   name="upload" key="field.upload" onchange="enableUpload()" />
-              <tr height=10><td></td></tr>
-              <tr>
-                <td></td>
-                <td align=right>
-                    <s:submit theme="simple" name="cancel" key="button.cancel"/>
-                    <s:submit theme="simple" name="doIt" key="button.upload" disabled="true"/>
-                </td>
-              </tr>
-            </table>
-          </form>
-        </div>
-      </div>
-  </body>
-</html>
\ No newline at end of file
+<div id=article-box>
+  <div id=section><s:text name="title.%{nextAction}"/></div>
+  <div id=article-body class=text>
+    <form name="upform" enctype="multipart/form-data" action="upload" method="post">
+      <table>
+        <tr height=10><td></td></tr>
+        <s:hidden name="nextAction" value="%{nextAction}" />
+        <s:hidden name="index"      value="%{index}" />
+        <s:file   name="upload" key="field.upload" onchange="enableUpload()" />
+        <tr height=10><td></td></tr>
+        <tr>
+          <td></td>
+          <td align=right>
+              <s:submit theme="simple" name="cancel" key="button.cancel"/>
+              <s:submit theme="simple" name="doIt" key="button.upload" disabled="true"/>
+          </td>
+        </tr>
+      </table>
+    </form>
+  </div>
+</div>