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;
28 private static final long serialVersionUID = -6925961099244461039L;
30 protected enum ToDo { cancel, save };
32 // ==============================================================================================================================
33 // Getters and setters
34 // ==============================================================================================================================
36 public DocumentType getDefaultDocumentType () {
37 // ---------------------------------------------
40 public List<Document> getDefaultDocumentUses () {
41 // -----------------------------------------------
44 public String getDocumentName () {
45 // --------------------------------
48 public String getDocumentState () {
49 // ---------------------------------
50 return state.toString();
52 public String getFileName () {
53 // ----------------------------
57 public void setCancel (boolean cancel) {
58 // --------------------------------------
59 this.action = ToDo.cancel;
61 public void setDocumentState (String state) {
62 // -------------------------------------------
63 this.state = ProgressState.valueOf(state);
65 public void setFileName (String path) {
66 // -------------------------------------
69 public void setUses (String list) {
70 // ---------------------------------
73 public void setSave (boolean save) {
74 // ----------------------------------
75 this.action = ToDo.save;
77 // ==============================================================================================================================
79 // ==============================================================================================================================
81 protected void setupDefaultUses (DocumentType type) {
82 // -------------------------------------------------
83 Set<DocumentType> uses = type.getDefaultUses();
85 for (Iterator<DocumentType> i=uses.iterator(); i.hasNext();) {
86 DocumentType usetype = i.next();
87 List<Document> usedoc = mystudy.collectInvolvedDocuments(usetype);
88 if (usedoc.isEmpty()) setupDefaultUses(usetype);
89 else defuses.addAll(usedoc);
93 protected Publication getPublication (int index) {
94 // ------------------------------------------------
95 List<Step> steps = mystudy.getInvolvedSteps();
97 for (Iterator<Step> i=steps.iterator(); i.hasNext(); ) {
98 List<Publication> published = i.next().getAllDocuments();
99 for (Iterator<Publication> j=published.iterator(); j.hasNext();) {
100 Publication found = j.next(); // In a given study step,
101 if (found.value().getIndex() == index) return found; // there is only one publication of a given document