]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/UploadBaseNextAction.java
Salome HOME
Default document types mappings are moved from application settings (my.xml) to proje...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / UploadBaseNextAction.java
index f3e1b96af3c0be37a9ee528729b435dbe6047dcb..bdea14f849f55080380a821d0186c089ffffd784 100644 (file)
@@ -10,104 +10,109 @@ import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.Publication;
 import org.splat.som.Step;
 
-
 public abstract class UploadBaseNextAction extends Action {
 
-    protected OpenStudy      mystudy  = null;
-    protected String         filename = null;   // Uploaded file name
-    protected DocumentType   deftype  = null;
-    protected List<Document> defuses  = null;
-    protected String         docname  = null;
-    protected ProgressState  state    = null;
-    protected String         docuses  = null;
-    protected ToDo           action   = null;
+       protected OpenStudy mystudy = null;
+       protected String filename = null; // Uploaded file name
+       protected DocumentType deftype = null;
+       protected List<Document> defuses = null;
+       protected String docname = null;
+       protected ProgressState state = null;
+       protected String docuses = null;
+       protected ToDo action = null;
 
        /**
         * Serial version ID.
         */
-    private static final long serialVersionUID = -6925961099244461039L;
-
-    protected enum  ToDo { cancel, save };
-
-//  ==============================================================================================================================
-//  Getters and setters
-//  ==============================================================================================================================
-
-    public DocumentType getDefaultDocumentType () {
-//  ---------------------------------------------
-      return deftype;
-    }
-    public List<Document> getDefaultDocumentUses () {
-//  -----------------------------------------------
-      return defuses;
-    }
-    public String getDocumentName () {
-//  --------------------------------
-      return docname;
-    }
-    public String getDocumentState () {
-//  ---------------------------------
-      return state.toString();
-    }
-    public String getFileName () {
-//  ----------------------------
-      return filename;
-    }
-
-    public void setCancel (boolean cancel) {
-//  --------------------------------------
-      this.action = ToDo.cancel;
-    }
-    public void setDocumentState (String state) {
-//  -------------------------------------------
-      this.state = ProgressState.valueOf(state);
-    }
-    public void setFileName (String path) {
-//  -------------------------------------
-      this.filename = path;
-    }
-    public void setUses (String list) {
-//  ---------------------------------
-      this.docuses = list;
-    }
-    public void setSave (boolean save) {
-//  ----------------------------------
-      this.action = ToDo.save;
-    }
-    
-    public String getWriteAccess() {
-       if (mystudy == null) {
-               return "false";
-       }
-               return String.valueOf(mystudy.isOpenForWriting());
+       private static final long serialVersionUID = -6925961099244461039L;
+
+       protected enum ToDo {
+               cancel, save
+       };
+
+       // ==============================================================================================================================
+       // Getters and setters
+       // ==============================================================================================================================
+
+       public DocumentType getDefaultDocumentType() {
+               return deftype;
+       }
+
+       public List<Document> getDefaultDocumentUses() {
+               return defuses;
+       }
+
+       public String getDocumentName() {
+               return docname;
+       }
+
+       public String getDocumentState() {
+               return state.toString();
+       }
+
+       public String getFileName() {
+               return filename;
+       }
+
+       public void setCancel(final boolean cancel) {
+               this.action = ToDo.cancel;
+       }
+
+       public void setDocumentState(final String state) {
+               this.state = ProgressState.valueOf(state);
+       }
+
+       public void setFileName(final String path) {
+               this.filename = path;
+       }
+
+       public void setUses(final String list) {
+               this.docuses = list;
+       }
+
+       public void setSave(final boolean save) {
+               this.action = ToDo.save;
+       }
+
+       public String getWriteAccess() {
+               Boolean res = (mystudy != null);
+               if (res) {
+                       res = mystudy.isOpenForWriting();
+               }
+               return res.toString();
+       }
+
+       // ==============================================================================================================================
+       // Protected services
+       // ==============================================================================================================================
+
+       protected 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()) {
+                               setupDefaultUses(usetype);
+                       } else {
+                               defuses.addAll(usedoc);
+                       }
+               }
+       }
+
+       protected Publication getPublication(final int index) {
+               List<Step> steps = mystudy.getInvolvedSteps();
+               Publication found = null, pub;
+               for (Iterator<Step> i = steps.iterator(); i.hasNext();) {
+                       List<Publication> published = i.next().getAllDocuments();
+                       for (Iterator<Publication> j = published.iterator(); j.hasNext();) {
+                               pub = j.next(); // In a given study step,
+                               if (pub.value().getIndex() == index) {
+                                       found = pub; // there is only one publication of a given document
+                                       break;
+                               }
+                       }
+               }
+               return found;
        }
-//  ==============================================================================================================================
-//  Protected services
-//  ==============================================================================================================================
-
-    protected void setupDefaultUses (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()) setupDefaultUses(usetype);
-       else                  defuses.addAll(usedoc);
-      }
-    }
-
-    protected Publication getPublication (int index) {
-//  ------------------------------------------------
-      List<Step> steps = mystudy.getInvolvedSteps();
-      
-      for (Iterator<Step> i=steps.iterator(); i.hasNext(); ) {
-        List<Publication> published = i.next().getAllDocuments();
-        for (Iterator<Publication> j=published.iterator(); j.hasNext();) {
-          Publication found = j.next();                          // In a given study step,
-          if (found.value().getIndex() == index) return found;   // there is only one publication of a given document
-        }
-      }
-      return null;
-    }
 }
\ No newline at end of file