From 1705f95f3921cc48eaf02ff2c608cedb0767277f Mon Sep 17 00:00:00 2001 From: rkv Date: Fri, 18 Jan 2013 11:06:52 +0000 Subject: [PATCH] Fix for the file naming strategy "asis". --- .../src/org/splat/dal/bo/som/Document.java | 2 +- .../splat/service/DocumentServiceImpl.java | 11 ++-- .../splat/service/PublicationServiceImpl.java | 2 + .../splat/service/ScenarioServiceImpl.java | 1 + .../org/splat/service/StudyServiceImpl.java | 6 +- Workspace/Siman/WebContent/study/upload.jsp | 58 ++++++++----------- 6 files changed, 37 insertions(+), 43 deletions(-) diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java index aa9b6dd..8975ad6 100644 --- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java +++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java @@ -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; diff --git a/Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java index c8494b1..06455e4 100644 --- a/Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java @@ -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; } /** diff --git a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java index 98b0ef7..21ad088 100644 --- a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java @@ -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; diff --git a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java index 55f7524..6365f7e 100644 --- a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java @@ -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()); diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java index b5ad400..425381e 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java @@ -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; } /** diff --git a/Workspace/Siman/WebContent/study/upload.jsp b/Workspace/Siman/WebContent/study/upload.jsp index 8e1c847..3bc4234 100644 --- a/Workspace/Siman/WebContent/study/upload.jsp +++ b/Workspace/Siman/WebContent/study/upload.jsp @@ -2,44 +2,32 @@ pageEncoding="ISO-8859-1" %> <%@taglib prefix="s" uri="/struts-tags"%> - - - - - rel="stylesheet" type="text/css"> - - - - + -
-
-
-
- - - - - - - - - - -
- - -
-
-
-
- - \ No newline at end of file +
+
+
+
+ + + + + + + + + + +
+ + +
+
+
+
-- 2.39.2