Salome HOME
PMD plugin is refreshed. Some code is modified to respect PMD rules. Ant build proced...
[tools/siman.git] / Workspace / Siman / src / org / splat / module / SaveDocumentAction.java
index 878975b33dfe3db0c9905bf78078d31624482284..332d9209aa0838d5f5f772b0b2eb1f5ffdd92a68 100644 (file)
@@ -9,18 +9,8 @@ import java.util.Vector;
 import org.hibernate.HibernateException;
 import org.hibernate.Session;
 import org.hibernate.Transaction;
-import org.splat.kernel.Do;
 import org.splat.dal.bo.kernel.User;
-import org.splat.service.DocumentTypeService;
-import org.splat.service.PublicationService;
-import org.splat.service.ScenarioService;
-import org.splat.service.SimulationContextService;
-import org.splat.service.StepService;
-import org.splat.service.technical.RepositoryService;
-import org.splat.simer.Action;
-import org.splat.simer.OpenStudy;
 import org.splat.dal.bo.som.ConvertsRelation;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.ProgressState;
@@ -28,6 +18,16 @@ import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.dal.dao.som.Database;
+import org.splat.kernel.Do;
+import org.splat.service.DocumentTypeService;
+import org.splat.service.PublicationService;
+import org.splat.service.ScenarioService;
+import org.splat.service.SimulationContextService;
+import org.splat.service.StepService;
+import org.splat.service.technical.RepositoryService;
+import org.splat.simer.Action;
+import org.splat.simer.OpenStudy;
 import org.splat.som.Step;
 
 public class SaveDocumentAction extends Action {
@@ -105,8 +105,9 @@ public class SaveDocumentAction extends Action {
                                                        .setAuthor(user));
                        // Writing the uploaded file into the created document
                        File target = credoc.getSourceFile().asFile();
-                       if (target.exists())
+                       if (target.exists()) {
                                target.delete();
+                       }
                        Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use
                        // upfile.renameTo(target);
 
@@ -129,8 +130,9 @@ public class SaveDocumentAction extends Action {
                                                credoc, "brep");
 
                                target = export.getTo().asFile();
-                               if (target.exists())
+                               if (target.exists()) {
                                        target.delete();
+                               }
                                Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use
                        }
                        // 2. Addition of simulation contexts
@@ -200,7 +202,7 @@ public class SaveDocumentAction extends Action {
         * @param publicationService
         *            the publicationService to set
         */
-       public void setPublicationService(PublicationService publicationService) {
+       public void setPublicationService(final PublicationService publicationService) {
                _publicationService = publicationService;
        }
 
@@ -219,7 +221,7 @@ public class SaveDocumentAction extends Action {
         * @param scenarioService
         *            the scenarioService to set
         */
-       public void setScenarioService(ScenarioService scenarioService) {
+       public void setScenarioService(final ScenarioService scenarioService) {
                _scenarioService = scenarioService;
        }
 
@@ -238,7 +240,7 @@ public class SaveDocumentAction extends Action {
         * @param stepService
         *            the stepService to set
         */
-       public void setStepService(StepService stepService) {
+       public void setStepService(final StepService stepService) {
                _stepService = stepService;
        }
 
@@ -268,16 +270,18 @@ public class SaveDocumentAction extends Action {
                        Publication current = mystudy.getSelectedDocument();
                        Document.Properties dprop = new Document.Properties();
                        dprop.setAuthor(user);
-                       if (summary.length() > 0)
+                       if (summary.length() > 0) {
                                dprop.setDescription(summary);
+                       }
 
                        Publication next = getStepService().versionDocument(step, current,
                                        dprop);
 
                        // Writing the uploaded file into the created document
                        File target = next.getSourceFile().asFile();
-                       if (target.exists())
+                       if (target.exists()) {
                                target.delete();
+                       }
                        Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use
                        // upfile.renameTo(target);
 
@@ -301,8 +305,9 @@ public class SaveDocumentAction extends Action {
                                                "brep");
                                String fname = table[0];
 
-                               for (int i = 1; i < table.length - 1; i++)
+                               for (int i = 1; i < table.length - 1; i++) {
                                        fname = fname + table[i];
+                               }
                                upfile = new File(upath + fname + ".brep");
                                upfile.renameTo(export.getTo().asFile());
                        }
@@ -335,27 +340,27 @@ public class SaveDocumentAction extends Action {
                return summary;
        }
 
-       public void setDescription(String summary) {
+       public void setDescription(final String summary) {
                // -------------------------------------------
                this.summary = summary;
        }
 
-       public void setDocumentName(String name) {
+       public void setDocumentName(final String name) {
                // -----------------------------------------
                this.docname = name;
        }
 
-       public void setDocumentState(String state) {
+       public void setDocumentState(final String state) {
                // -------------------------------------------
                this.state = ProgressState.valueOf(state);
        }
 
-       public void setDocumentType(String value) {
+       public void setDocumentType(final String value) {
                // ------------------------------------------
                this.doctype = Integer.valueOf(value);
        }
 
-       public void setFileName(String name) {
+       public void setFileName(final String name) {
                // -------------------------------------
                this.filename = name;
        }
@@ -364,16 +369,17 @@ public class SaveDocumentAction extends Action {
        // Private service
        // ==============================================================================================================================
 
-       private void setupDefaultUses(DocumentType type) {
+       private void setupDefaultUses(final DocumentType type) {
                Set<DocumentType> uses = type.getDefaultUses();
 
                for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
                        DocumentType usetype = i.next();
                        List<Document> usedoc = mystudy.collectInvolvedDocuments(usetype);
-                       if (usedoc.isEmpty())
+                       if (usedoc.isEmpty()) {
                                setupDefaultUses(usetype);
-                       else
+                       } else {
                                defuses.addAll(usedoc);
+                       }
                }
        }
 
@@ -392,7 +398,7 @@ public class SaveDocumentAction extends Action {
         * @param repositoryService
         *            the repositoryService to set
         */
-       public void setRepositoryService(RepositoryService repositoryService) {
+       public void setRepositoryService(final RepositoryService repositoryService) {
                _repositoryService = repositoryService;
        }
 
@@ -412,7 +418,7 @@ public class SaveDocumentAction extends Action {
         *            the simulationContextService to set
         */
        public void setSimulationContextService(
-                       SimulationContextService simulationContextService) {
+                       final SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
 
@@ -431,7 +437,7 @@ public class SaveDocumentAction extends Action {
         * @param documentTypeService
         *            the documentTypeService to set
         */
-       public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+       public void setDocumentTypeService(final DocumentTypeService documentTypeService) {
                _documentTypeService = documentTypeService;
        }
 }
\ No newline at end of file