1 package org.splat.simer;
3 import java.util.Iterator;
7 import org.splat.dal.bo.som.Document;
8 import org.splat.dal.bo.som.DocumentType;
9 import org.splat.dal.bo.som.ProgressState;
10 import org.splat.dal.bo.som.Publication;
11 import org.splat.som.Step;
14 public abstract class UploadBaseNextAction extends Action {
16 protected OpenStudy mystudy = null;
17 protected String filename = null; // Uploaded file name
18 protected DocumentType deftype = null;
19 protected List<Document> defuses = null;
20 protected String docname = null;
21 protected ProgressState state = null;
22 protected String docuses = null;
23 protected ToDo action = null;
25 private static final long serialVersionUID = -6925961099244461039L;
27 protected enum ToDo { cancel, save };
29 // ==============================================================================================================================
30 // Getters and setters
31 // ==============================================================================================================================
33 public DocumentType getDefaultDocumentType () {
34 // ---------------------------------------------
37 public List<Document> getDefaultDocumentUses () {
38 // -----------------------------------------------
41 public String getDocumentName () {
42 // --------------------------------
45 public String getDocumentState () {
46 // ---------------------------------
47 return state.toString();
49 public String getFileName () {
50 // ----------------------------
54 public void setCancel (boolean cancel) {
55 // --------------------------------------
56 this.action = ToDo.cancel;
58 public void setDocumentState (String state) {
59 // -------------------------------------------
60 this.state = ProgressState.valueOf(state);
62 public void setFileName (String path) {
63 // -------------------------------------
66 public void setUses (String list) {
67 // ---------------------------------
70 public void setSave (boolean save) {
71 // ----------------------------------
72 this.action = ToDo.save;
74 // ==============================================================================================================================
76 // ==============================================================================================================================
78 protected void setupDefaultUses (DocumentType type) {
79 // -------------------------------------------------
80 Set<DocumentType> uses = type.getDefaultUses();
82 for (Iterator<DocumentType> i=uses.iterator(); i.hasNext();) {
83 DocumentType usetype = i.next();
84 List<Document> usedoc = mystudy.collectInvolvedDocuments(usetype);
85 if (usedoc.isEmpty()) setupDefaultUses(usetype);
86 else defuses.addAll(usedoc);
90 protected Publication getPublication (int index) {
91 // ------------------------------------------------
92 List<Step> steps = mystudy.getInvolvedSteps();
94 for (Iterator<Step> i=steps.iterator(); i.hasNext(); ) {
95 List<Publication> published = i.next().getAllDocuments();
96 for (Iterator<Publication> j=published.iterator(); j.hasNext();) {
97 Publication found = j.next(); // In a given study step,
98 if (found.value().getIndex() == index) return found; // there is only one publication of a given document