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;
13 public abstract class UploadBaseNextAction extends Action {
15 protected OpenStudy mystudy = null;
16 protected String filename = null; // Uploaded file name
17 protected DocumentType deftype = null;
18 protected List<Document> defuses = null;
19 protected String docname = null;
20 protected ProgressState state = null;
21 protected String docuses = null;
22 protected ToDo action = null;
27 private static final long serialVersionUID = -6925961099244461039L;
33 // ==============================================================================================================================
34 // Getters and setters
35 // ==============================================================================================================================
37 public DocumentType getDefaultDocumentType() {
41 public List<Document> getDefaultDocumentUses() {
45 public String getDocumentName() {
49 public String getDocumentState() {
50 return state.toString();
53 public String getFileName() {
57 public void setCancel(final boolean cancel) {
58 this.action = ToDo.cancel;
61 public void setDocumentState(final String state) {
62 this.state = ProgressState.valueOf(state);
65 public void setFileName(final String path) {
69 public void setUses(final String list) {
73 public void setSave(final boolean save) {
74 this.action = ToDo.save;
77 public String getWriteAccess() {
78 Boolean res = (mystudy != null);
80 res = mystudy.isOpenForWriting();
82 return res.toString();
85 // ==============================================================================================================================
87 // ==============================================================================================================================
89 protected void setupDefaultUses(final DocumentType type) {
90 Set<DocumentType> uses = type.getDefaultUses();
92 for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
93 DocumentType usetype = i.next();
94 List<Document> usedoc = mystudy.collectInvolvedDocuments(usetype);
95 if (usedoc.isEmpty()) {
96 setupDefaultUses(usetype);
98 defuses.addAll(usedoc);
103 protected Publication getPublication(final int index) {
104 List<Step> steps = mystudy.getInvolvedSteps();
105 Publication found = null, pub;
106 for (Iterator<Step> i = steps.iterator(); i.hasNext();) {
107 List<Publication> published = i.next().getAllDocuments();
108 for (Iterator<Publication> j = published.iterator(); j.hasNext();) {
109 pub = j.next(); // In a given study step,
110 if (pub.value().getIndex() == index) {
111 found = pub; // there is only one publication of a given document