Salome HOME
Creation of a new study from an existing one is implemented.
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / Document.java
index aa9b6ddaaa031542e36cdf696eedadae92a4d608..79bf7ca212eba6c41e21e56516c7a9305a634287 100644 (file)
@@ -53,7 +53,6 @@ public class Document extends Entity {
         * Fields initialization class.
         */
        public static class Properties extends Persistent.Properties {
-               // ------------------------------------------------------------
                private DocumentType type = null;
                private String did = null; // Only for searching from a given reference
                private ProjectElement owner = null; // Only for constructing a document
@@ -303,6 +302,7 @@ public class Document extends Entity {
 
                /**
                 * Get the format.
+                * 
                 * @return the format
                 */
                public String getFormat() {
@@ -319,6 +319,7 @@ public class Document extends Entity {
 
        /**
         * Initialization constructor.
+        * 
         * @param dprop
         * @throws MissedPropertyException
         * @throws InvalidPropertyException
@@ -327,7 +328,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;
@@ -352,16 +353,24 @@ public class Document extends Entity {
        // Public member functions
        // ==============================================================================================================================
 
+       /**
+        * Get the attached file of the given format.
+        * 
+        * @param format
+        *            the file format
+        * @return the attached file or null if not found
+        */
        public File getAttachedFile(final String format) {
                List<Relation> exports = getRelations(ConvertsRelation.class);
-
-               for (Iterator<Relation> i = exports.iterator(); i.hasNext();) {
-                       File export = (File) i.next().getTo();
+               File res = null;
+               for (Relation rel : exports) {
+                       File export = (File) rel.getTo();
                        if (export.getFormat().equals(format)) {
-                               return export;
+                               res = export;
+                               break;
                        }
                }
-               return null;
+               return res;
        }
 
        public User getAuthor() {