Salome HOME
Vasily has fixed the following bug :
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / PublicationServiceImpl.java
index 91f2c25dfed6bd9480aecee19049c3bd33d30640..5439663040c205e4316f2a9ddf9ac79c429ae2d0 100644 (file)
@@ -155,12 +155,9 @@ public class PublicationServiceImpl implements PublicationService {
                        final List<Long> docuses) throws MissedPropertyException,
                        InvalidPropertyException, MultiplyDefinedException, IOException,
                        NotApplicableException, InterruptedException, ParseException {
-               DocumentType type = getDocumentTypeService().selectType(
-                               (int) documentTypeId);
                User user = getUserService().selectUser(userId);
                File updir = getRepositoryService().getDownloadDirectory(user);
                File upfile = new File(updir.getPath() + "/" + fname);
-               String[] table = fname.split("\\x2E");
 
                // Creation of the document
                Document.Properties dprop = new Document.Properties();
@@ -169,6 +166,9 @@ public class PublicationServiceImpl implements PublicationService {
 
                if (reference.length() == 0) { // Importation of a foreign document
                        // TODO: Extract property of supported documents (DOCX, ODT...)
+                       DocumentType type = getDocumentTypeService().selectType(
+                                       (int) documentTypeId);
+                       String[] table = fname.split("\\x2E");
                        addoc = getStepService().createDocument(
                                        step,
                                        dprop.setName(doctitle).setType(type).setFormat(
@@ -210,7 +210,26 @@ public class PublicationServiceImpl implements PublicationService {
                if (docuses != null) {
                        for (Long index : docuses) {
                                Document used = getDocumentService().selectDocument(index);
+                               Publication pub = step.getDocument(index);
+                               if (pub == null) {
+                                   for (Publication doc : step.getOwner().
+                                           getDocums()) {
+                                       if (doc.value().getIndex() == index) {
+                                           pub = doc;
+                                           break;
+                                       }
+                                   }
+                               }
+                               if (pub == null) {
+                                   for (Publication doc : step.getOwnerStudy().getDocums()) {
+                        if (doc.value().getIndex() == index) {
+                            pub = doc;
+                            break;
+                        }
+                    }
+                               }
                                addoc.addDependency(used);
+                               pub.setValue(used);
                        }
                }
                return addoc;