Salome HOME
Cancel operation work correctly in the case of empty title of the document on the...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / ImportDocumentAction.java
index d6af46bcf4a4608bd413a62f5ad6a2ec153559f3..77713cbf5a4e1d1e42c5d5ef121d62ff2bccc5f0 100644 (file)
@@ -2,57 +2,54 @@ package org.splat.simer;
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
+import java.util.Date;
 import java.util.List;
 import java.util.ResourceBundle;
-import java.util.Vector;
 
 import org.splat.dal.bo.kernel.User;
-import org.splat.manox.Reader;
-import org.splat.manox.Toolbox;
 import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.Publication;
+import org.splat.dal.bo.som.ValidationCycle;
+import org.splat.dal.bo.som.ValidationStep;
+import org.splat.manox.Reader;
+import org.splat.manox.Toolbox;
 import org.splat.service.DocumentService;
 import org.splat.service.DocumentTypeService;
-import org.splat.service.PublicationService;
-import org.splat.service.StepService;
-import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.RepositoryService;
-import org.splat.dal.bo.som.Publication;
-import org.splat.dal.bo.som.DocumentType;
 import org.splat.som.Revision;
 import org.splat.som.Step;
+import org.splat.wapp.Constants;
 
 /**
  * Action for adding a document into a study step.
  */
-public class ImportDocumentAction extends UploadBaseNextAction {
+public class ImportDocumentAction extends BaseUploadDocumentAction {
 
        /**
         * Serial version ID.
         */
        private static final long serialVersionUID = 2587822564883588556L;
 
-       private List<DocumentType> doctypes = null;
-       private long doctype = 0;
-       private String docref = null; // Reference extracted from the imported file, if exist
-       private String docver = ""; // Version number extracted from the imported file, if exist
-       private String date = ""; // Date extracted from the imported file, if exist
        /**
-        * Injected project settings service.
+        * Sorted list of document types for the selected study step.
+        */
+       private transient List<DocumentType> _documentTypes = null;
+       /**
+        * Sorted list of document types for the selected study step.
         */
-       private ProjectSettingsService _projectSettingsService;
+       private transient final List<Boolean> _reviewable = new ArrayList<Boolean>();
        /**
-        * Injected publication service.
+        * The selected document type.
         */
-       private PublicationService _publicationService;
+       private long _documentType = 0;
        /**
-        * Injected step service.
+        * Reference extracted from the imported file, if exist.
         */
-       private StepService _stepService;
+       private String _reference = null;
        /**
         * Injected document service.
         */
@@ -61,407 +58,336 @@ public class ImportDocumentAction extends UploadBaseNextAction {
         * Injected document type service.
         */
        private DocumentTypeService _documentTypeService;
-       /**
-        * Injected repository service.
-        */
-       private RepositoryService _repositoryService;   
-       /**
-        * Value of the menu property. 
-        * It can be: none, create, open, study, knowledge, sysadmin, help.
-        */
-       private String _menuProperty;
-       
-       /**
-        * Value of the title bar property. 
-        * It can be: study, knowledge.
-        */
-       private String _titleProperty;
-       
-       /**
-        * Value of the tool bar property. 
-        * It can be: none, standard, study, back.
-        */
-       private String _toolProperty;
-       
-       /**
-        * Property that indicates whether the current open study is editable or not.
-        * On the screen it looks like pen on the status icon, pop-up menu also can be called.
-        * It is necessary for correct building the title bar.
-        */
-       private String _editDisabledProperty = "false";
-
-       // ==============================================================================================================================
-       // Action methods
-       // ==============================================================================================================================
 
        /**
         * Initialize the operation.
+        * 
         * @return SUCCESS in success, otherwise - ERROR
         */
        public String doInitialize() {
-               
-               setMenuProperty("study");
-               setTitleProperty("study");
-               setEditDisabledProperty("true");
-               if ("true".equals(getWriteAccess())) {
-                       setToolProperty("study");
-               } else {
-                       setToolProperty("none");
-               }
-        initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-             
-               User user = getConnectedUser();
-               File updir = getRepositoryService().getDownloadDirectory(user);
-               File upfile = new File(updir.getPath() + "/" + filename);
-               String[] table = filename.split("\\x2E");
-               String filext = table[table.length - 1].toLowerCase();
 
-               mystudy = getOpenStudy();
-               Step step = mystudy.getSelectedStep();
-               doctypes = getStepService().getValidDocumentTypes(step);
-               deftype = getApplicationSettings().getDefaultDocumentType(step, filext);
-               defuses = new Vector<Document>();
-               state = ProgressState.inWORK;
+               File upfile = commonInitialize(Constants.FALSE);
+               String[] table = _fileName.split("\\x2E");
+               String filext = table[table.length - 1].toLowerCase();
 
-               Reader tool = Toolbox.getReader(upfile);
-               if (tool != null) {
-                       String fileref = tool.extractProperty("reference");
-                       String filever = tool.extractProperty("version"); // Property kept even if the file is not referenced
-                       String filetype = tool.extractProperty("type"); // Property kept even if the file is not referenced
-                       for (Iterator<DocumentType> i = doctypes.iterator(); i.hasNext();) {
-                               DocumentType type = i.next();
-                               if (!type.getName().equals(filetype))
-                                       continue;
-                               deftype = type;
-                               doctype = type.getIndex(); // Disables the document type field
-                               break;
-                       }
-                       if (fileref != null) {
-                               Document slot = getDocumentService().selectDocument(fileref,
-                                               new Revision().toString());
-                               if (slot == null) {
-                                       setErrorCode("reference.undefined");
-                                       
-                                       setToolProperty("none");
-                                       initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-                                       
-                                       return ERROR;
-                               } else {
-                                       if (!slot.isUndefined()) {
-                                               setErrorCode("reference.duplicate");
-                                               
-                                               setToolProperty("none");
-                                               initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-                                               
-                                               return ERROR;
-                                       }
-                                       docref = fileref; // Disables document name and state fields
-                                       deftype = slot.getType(); // Just in case
-                                       doctype = deftype.getIndex(); // Disables the document type field
+               _mystudy = getOpenStudy();
+               Step step = _mystudy.getSelectedStep();
+               _documentTypes = getStepService().getValidDocumentTypes(step);
+               // Set the document type by default
+               _deftype = getApplicationSettings()
+                               .getDefaultDocumentType(step, filext);
+               if (_deftype != null) {
+                       setDefaultDocumentType(_deftype.getIndex());
+               }
+               _defuses = new ArrayList<Document>();
+               _state = ProgressState.inWORK;
+
+               String res = ERROR;
+               if (extractProperties(upfile, filext)) {
+                       if (_docname == null) {
+                               _docname = table[0];
+                               for (int i = 1; i < table.length - 1; i++) {
+                                       _docname = _docname + "." + table[i];
                                }
                        }
-                       if (filever != null)
-                               try {
-                                       Revision.Format get = new Revision.Format(
-                                                       getProjectSettings().getRevisionPattern());
-                                       Revision version = get.parse(filever);
-                                       if (version.isNull())
-                                               throw new ParseException(filever, filever.length() - 1);
-                                       if (!version.isMinor())
-                                               state = ProgressState.inCHECK;
-                                       docver = version.toString();
-                               } catch (ParseException e) {
-                                       setErrorCode("format.version");
-                                       
-                                       setToolProperty("none");
-                                       initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-                                       
-                                       return ERROR;
-                               }
-                       docname = tool.extractProperty("title"); // Property kept even if the file is not referenced
-                       date = tool.extractProperty("date");
-                       if (date != null) {
-                               ResourceBundle locale = ResourceBundle.getBundle("som",
-                                               getApplicationSettings().getCurrentLocale());
-                               SimpleDateFormat check = new SimpleDateFormat(
-                                               locale.getString("date.format"));
-                               try {
-                                       check.parse(date);
-                               } catch (ParseException e) {
-                                       setErrorCode("format.date");
-                                       
-                                       setToolProperty("none");
-                                       initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-                                       
-                                       return ERROR;
-                               }
-                       } else
-                               date = "";
-               } else if (filext.equals("pdf"))
-                       state = ProgressState.EXTERN; // TODO: Should external extensions be configurable ?
-               if (docname == null) {
-                       docname = table[0];
-                       for (int i = 1; i < table.length - 1; i++)
-                               docname = docname + "." + table[i];
+                       if (_deftype != null) {
+                               setupDefaultUses(_deftype);
+                       }
+
+                       DocumentType[] types = _documentTypes
+                                       .toArray(new DocumentType[_documentTypes.size()]);
+                       DocumentTypeComparator compare = new DocumentTypeComparator();
+                       Arrays.sort(types, compare);
+                       _documentTypes = Arrays.asList(types);
+                       res = SUCCESS;
                }
-               if (deftype != null)
-                       setupDefaultUses(deftype);
 
-               DocumentType[] types = doctypes.toArray(new DocumentType[doctypes
-                               .size()]);
-               DocumentTypeComparator compare = new DocumentTypeComparator();
-               Arrays.sort(types, compare);
-               doctypes = Arrays.asList(types);
+               // Initialize isReviewable: if a type has review state or not
+               ValidationCycle cycle;
+               boolean hasReview;
+               for (DocumentType dtype : _documentTypes) {
+                       cycle = getStudyService().getValidationCycleOf(
+                                       _mystudy.getMystudy(), dtype);
+                       hasReview = (cycle != null) && cycle.enables(ValidationStep.REVIEW);
+                       _reviewable.add(hasReview);
+               }
+               return res;
+       }
+
+       /**
+        * Extract properties from the uploaded file.
+        * 
+        * @param upfile
+        *            the file to parse
+        * @param filext
+        *            the file extension
+        * @return true if succeeded, false if error
+        */
+       private boolean extractProperties(final File upfile, final String filext) {
+               boolean isOk = true;
+               Reader tool = Toolbox.getReader(upfile);
+               if (tool == null) {
+                       if ("pdf".equals(filext)) {
+                               _state = ProgressState.EXTERN; // TODO: Should external extensions be configurable ?
+                       }
+               } else {
+                       // String fileref = tool.extractProperty("reference");
+                       // String filever = tool.extractProperty("version"); // Property kept even if the file is not referenced
+                       // String filetype = tool.extractProperty("type"); // Property kept even if the file is not referenced
+                       // for (Iterator<DocumentType> i = _documentTypes.iterator(); i
+                       // .hasNext();) {
+                       // DocumentType type = i.next();
+                       // if (type.getName().equals(filetype)) {
+                       // _deftype = type;
+                       // _documentType = type.getIndex(); // Disables the document type field
+                       // break;
+                       // }
+                       // }
+                       // if (fileref != null) {
+                       // isOk = findTypeByDocRef(fileref);
+                       // }
+                       // if (isOk) {
+                       // if (filever != null) {
+                       // try {
+                       // Revision.Format get = new Revision.Format(
+                       // getProjectSettings().getRevisionPattern());
+                       // Revision version = get.parse(filever);
+                       // if (version.isNull()) {
+                       // throw new ParseException(filever,
+                       // filever.length() - 1);
+                       // }
+                       // if (!version.isMinor()) {
+                       // _state = ProgressState.inCHECK;
+                       // }
+                       // setVersion(version.toString());
+                       // } catch (ParseException e) {
+                       // setErrorCode("message.error.format.version");
+                       // isOk = false;
+                       // }
+                       // }
+                       // if (isOk) {
+                       // _docname = tool.extractProperty("title"); // Property kept even if the file is not referenced
+                       // isOk = extractDate(tool);
+                       // }
+                       // }
+               }
+               return isOk;
+       }
 
-               return SUCCESS;
+       /**
+        * Find document type by document reference.
+        * 
+        * @param fileref
+        *            the document reference
+        * @return true if succeeded, false if error
+        */
+       private boolean findTypeByDocRef(final String fileref) {
+               boolean isOk = true;
+               Document slot = getDocumentService().selectDocument(fileref,
+                               new Revision().toString());
+               if (slot == null) {
+                       setError("message.error.reference.undefined");
+                       isOk = false;
+               } else {
+                       if (slot.isUndefined()) {
+                               _reference = fileref; // Disables document name and state fields
+                               _deftype = slot.getType(); // Just in case
+                               _documentType = _deftype.getIndex(); // Disables the document type field
+                       } else {
+                               setError("message.error.reference.duplicate");
+                               isOk = false;
+                       }
+               }
+               return isOk;
        }
 
        /**
         * Perform import of a document.
+        * 
         * @return SUCCESS if ok, "cancel" - if canceled, ERROR - if error
         */
        public String doImport() {
-               // -------------------------
-               
-               setMenuProperty("study");
-               setTitleProperty("study");
-               setEditDisabledProperty("true");
-        initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
-           
-               if (action == ToDo.cancel)
-                       return "cancel";
-               if (doctype == 0) {
-                       setErrorCode("import.type");
-                       
-                       setToolProperty("none");
-                       initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-                       
-                       return ERROR;
-               }
-               try {
-                       // Getting user inputs
-                       mystudy = getOpenStudy();
-                       User user = getConnectedUser();
-                       Step step = mystudy.getSelectedStep();
-                       DocumentType type = getDocumentTypeService().selectType((int)doctype);
-                       File updir = getRepositoryService().getDownloadDirectory(user);
-                       File upfile = new File(updir.getPath() + "/" + filename);
-                       String[] table = filename.split("\\x2E");
-
-                       // Creation of the document
-                       Document.Properties dprop = new Document.Properties();
-                       Publication addoc;
-
-                       if (docref.length() == 0) { // Importation of a foreign document
-                       // TODO: Extract property of supported documents (DOCX, ODT...)
-                               addoc = getStepService().createDocument(step, dprop.setName(docname)
-                                               .setType(type).setFormat(table[table.length - 1])
-                                               .setAuthor(user));
-                               updir = addoc.getSourceFile().asFile();
-                               if (logger.isInfoEnabled())
-                                       logger.info("Moving \"" + upfile.getName() + "\" to \""
-                                                       + updir.getPath() + "\".");
-                               upfile.renameTo(updir);
-                               try {
-                                       getPublicationService().saveAs(addoc, state); // May throw FileNotFound if rename was not done
-                               } catch (FileNotFoundException saverror) {
-                                       Thread.sleep(1000);
-                                       logger.info("Waiting for the file.");
-                                       upfile.renameTo(updir);
-                                       getPublicationService().saveAs(addoc, state); // Forget it if throw again FileNotFound
-                               }
-                       } else { // Importation of a previously created template-based document
-                               if (date.length() > 0) {
+               String res = ERROR;
+
+               initializationScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU,
+                               Constants.TRUE);
+
+               if (_documentType == 0) {
+                       setErrorCode("message.error.import.type");
+
+                       initializationFullScreenContext(Constants.STUDY_MENU,
+                                       Constants.STUDY_MENU, Constants.TRUE, Constants.NONE,
+                                       Constants.STUDY_MENU);
+               } else {
+                       try {
+                               // Getting user inputs
+                               _mystudy = getOpenStudy();
+                               User user = getConnectedUser();
+                               Step step = _mystudy.getSelectedStep();
+                               Date aDate = null;
+                               if (getDocumentDate().length() > 0) {
                                        ResourceBundle locale = ResourceBundle.getBundle("som",
                                                        getApplicationSettings().getCurrentLocale());
-                                       SimpleDateFormat get = new SimpleDateFormat(
-                                                       locale.getString("date.format"));
-                                       dprop.setDate(get.parse(date));
+                                       SimpleDateFormat get = new SimpleDateFormat(locale
+                                                       .getString("date.format"), getApplicationSettings()
+                                                       .getCurrentLocale());
+                                       aDate = get.parse(getDocumentDate());
                                }
-                               addoc = getStepService().assignDocument(step, dprop.setReference(docref).setName(
-                                               docname));
-                               updir = addoc.getSourceFile().asFile();
-                               if (logger.isInfoEnabled())
-                                       logger.info("Moving \"" + upfile.getName() + "\" to \""
-                                                       + updir.getPath() + "\".");
-                               upfile.renameTo(updir);
-                               try {
-                                       if (docver.length() > 0)
-                                               getPublicationService().saveAs(addoc,
-                                                               new Revision(docver));
-                                       else
-                                               getPublicationService().saveAs(addoc, state);
-                               } catch (FileNotFoundException saverror) {
-                                       Thread.sleep(1000);
-                                       logger.info("Waiting for the file.");
-                                       upfile.renameTo(updir);
-                                       if (docver.length() > 0)
-                                               getPublicationService().saveAs(addoc,
-                                                               new Revision(docver));
-                                       else
-                                               getPublicationService().saveAs(addoc, state);
+                               // Creation of uses relations
+                               List<Long> uses = new ArrayList<Long>();
+                               if (_docuses != null) {
+                                       String[] list = _docuses.split(",");
+                                       for (int i = 0; i < list.length; i++) {
+                                               uses.add(Long.valueOf(list[i].trim()));
+                                       }
                                }
-                               mystudy.updateSimulationContexts(); // In case of simulation contexts extracted from the imported document
-                       }
-                       // Creation of uses relations
-                       if (docuses != null) {
-                               String[] list = docuses.split(",");
-                               for (int i = 0; i < list.length; i++) {
-                                       Integer index = Integer.valueOf(list[i].trim());
-                                       Publication used = getPublication(index);
-                                       addoc.addDependency(used);
+                               if (LOG.isDebugEnabled()) {
+                                       LOG
+                                                       .debug("Document to be imported uses documents with following ids:");
+                                       for (Long usesId : uses) {
+                                               LOG.debug("#" + usesId);
+                                       }
                                }
+                               Publication addoc = getPublicationService().createDoc(
+                                               _mystudy.getIndex(), step, _documentType,
+                                               user.getIndex(), _fileName, _docname, _state,
+                                               _reference, getVersion(), aDate, uses);
+
+                               if (_reference.length() > 0) { // Importation of a not foreign document
+                                       _mystudy.updateSimulationContexts(); // In case of simulation contexts extracted from the imported document
+                               }
+
+                               // Creation of derived the document formats
+                               // Document ndoc = addoc.value();
+                               // Converter send = getApplicationSettings().getConverter(ndoc.getType(), ndoc.getFormat());
+                               //
+                               // if (send != null) send.converts(addoc); // Asynchronous process
+
+                               if (uses.isEmpty()) {
+                                       _mystudy.add(addoc); // Updates the presentation
+                               } else {
+                                       // Re-opening (refreshing) the currently open study
+                                       refreshStudy();
+                               }
+                               res = SUCCESS;
+                       } catch (FileNotFoundException error) {
+                               LOG.error("Reason:", error);
+                               setErrorCode("message.error.import.file");
+                       } catch (Exception error) {
+                               LOG.error("Reason:", error);
+                               setErrorCode("message.error.internal");
+                       }
+
+                       if (!SUCCESS.equals(res)) {
+                               initializationFullScreenContext(Constants.STUDY_MENU,
+                                               Constants.STUDY_MENU, Constants.TRUE, Constants.NONE,
+                                               Constants.STUDY_MENU);
                        }
-                       // Creation of derived the document formats
-                       // Document ndoc = addoc.value();
-                       // Converter send = getApplicationSettings().getConverter(ndoc.getType(), ndoc.getFormat());
-                       //
-                       // if (send != null) send.converts(addoc); // Asynchronous process
-
-                       mystudy.add(addoc); // Updates the presentation
-                       return SUCCESS;
-               } catch (FileNotFoundException error) {
-                       logger.error("Reason:", error);
-                       setErrorCode("import.file");
-               } catch (Exception error) {
-                       logger.error("Reason:", error);
-                       setErrorCode("internal");
                }
-               
-               setToolProperty("none");
-               initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-               
-               return ERROR;
+
+               return res;
        }
 
        // ==============================================================================================================================
        // Getters and setters
        // ==============================================================================================================================
 
-       public String getDocumentDate() {
-               // --------------------------------
-               return date;
-       }
-
+       /**
+        * Get sorted list of document types valid for the selected study step.
+        * 
+        * @return sorted list of document types
+        */
        public List<DocumentType> getDocumentTypes() {
-               // ---------------------------------------------
-               return doctypes;
+               return _documentTypes;
        }
 
+       /**
+        * Get document type id.
+        * 
+        * @return document type id
+        */
        public long getDocumentType() {
-               // -----------------------------
-               return doctype;
+               return _documentType;
        }
 
+       /**
+        * Get reference extracted from the imported file, if exist.
+        * 
+        * @return the document reference
+        */
        public String getReference() {
-               // -----------------------------
-               return docref;
-       }
-
-       public String getVersion() {
-               // ---------------------------
-               return docver;
-       }
-
-       public void setDocumentDate(String date) {
-               // -----------------------------------------
-               this.date = date;
-       }
-
-       public void setDocumentName(String name) {
-               // -----------------------------------------
-               this.docname = name; // Name entered by the user if enabled
-       }
-
-       public void setDocumentTitle(String name) { // Called even if DocumentName is enabled
-       // -----------------------------------------
-               if (this.docname == null)
-                       this.docname = name;
-       }
-
-       public void setDocumentType(String value) {
-               // ------------------------------------------
-               this.doctype = Integer.valueOf(value);
-       }
-
-       public void setDefaultDocumentState(String state) { // Called even if DocumentState is enabled
-       // --------------------------------------------------
-               if (this.state == null)
-                       this.state = ProgressState.valueOf(state);
-       }
-
-       public void setDefaultDocumentType(String value) { // Called even if DocumentType is enabled
-       // --------------------------------------------------
-               if (this.doctype == 0)
-                       this.doctype = Integer.valueOf(value);
-       }
-
-       public void setReference(String value) {
-               // ---------------------------------------
-               this.docref = value;
-       }
-
-       public void setVersion(String value) {
-               // -------------------------------------
-               this.docver = value;
+               return _reference;
        }
 
        /**
-        * Get project settings.
+        * Set document name entered by the user if enabled.
         * 
-        * @return Project settings service
+        * @param name
+        *            the document name
         */
-       private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+       public void setDocumentName(final String name) {
+               this._docname = name; // Name entered by the user if enabled
        }
 
        /**
-        * Set project settings service.
+        * Set the default title if no title was defined.
         * 
-        * @param projectSettingsService
-        *            project settings service
+        * @param name
+        *            the default document title
         */
-       public void setProjectSettings(ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+       public void setDocumentTitle(final String name) { // Called even if DocumentName is enabled
+               if (this._docname == null) {
+                       this._docname = name;
+               }
        }
 
        /**
-        * Get the publicationService.
+        * Set document type id.
         * 
-        * @return the publicationService
+        * @param value
+        *            the id as string
         */
-       public PublicationService getPublicationService() {
-               return _publicationService;
+       public void setDocumentType(final Long value) {
+               this._documentType = value;
        }
 
        /**
-        * Set the publicationService.
+        * Set the default state if no state was selected.
         * 
-        * @param publicationService
-        *            the publicationService to set
+        * @param state
+        *            the default state
         */
-       public void setPublicationService(PublicationService publicationService) {
-               _publicationService = publicationService;
+       public void setDefaultDocumentState(final String state) { // Called even if DocumentState is enabled
+               if (this._state == null) {
+                       this._state = ProgressState.valueOf(state);
+               }
        }
 
        /**
-        * Get the stepService.
-        * @return the stepService
+        * Set the default type if no type was selected.
+        * 
+        * @param value
+        *            the default document type id
         */
-       public StepService getStepService() {
-               return _stepService;
+       public void setDefaultDocumentType(final Long value) { // Called even if DocumentType is enabled
+               if (this._documentType == 0) {
+                       this._documentType = value;
+               }
        }
 
        /**
-        * Set the stepService.
-        * @param stepService the stepService to set
+        * Set document reference extracted from the imported file, if exist.
+        * 
+        * @param value
+        *            the reference
         */
-       public void setStepService(StepService stepService) {
-               _stepService = stepService;
+       public void setReference(final String value) {
+               this._reference = value;
        }
 
        /**
         * Get the documentService.
+        * 
         * @return the documentService
         */
        public DocumentService getDocumentService() {
@@ -470,30 +396,17 @@ public class ImportDocumentAction extends UploadBaseNextAction {
 
        /**
         * Set the documentService.
-        * @param documentService the documentService to set
+        * 
+        * @param documentService
+        *            the documentService to set
         */
-       public void setDocumentService(DocumentService documentService) {
+       public void setDocumentService(final DocumentService documentService) {
                _documentService = documentService;
        }
 
-       /**
-        * Get the repositoryService.
-        * @return the repositoryService
-        */
-       public RepositoryService getRepositoryService() {
-               return _repositoryService;
-       }
-
-       /**
-        * Set the repositoryService.
-        * @param repositoryService the repositoryService to set
-        */
-       public void setRepositoryService(RepositoryService repositoryService) {
-               _repositoryService = repositoryService;
-       }
-
        /**
         * Get the documentTypeService.
+        * 
         * @return the documentTypeService
         */
        public DocumentTypeService getDocumentTypeService() {
@@ -502,73 +415,34 @@ public class ImportDocumentAction extends UploadBaseNextAction {
 
        /**
         * Set the documentTypeService.
-        * @param documentTypeService the documentTypeService to set
+        * 
+        * @param documentTypeService
+        *            the documentTypeService to set
         */
-       public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+       public void setDocumentTypeService(
+                       final DocumentTypeService documentTypeService) {
                _documentTypeService = documentTypeService;
        }
-       
-       /**
-        * Get the menuProperty.
-        * @return the menuProperty
-        */
-       public String getMenuProperty() {
-               return _menuProperty;
-       }
 
        /**
-        * Set the menuProperty.
-        * @param menuProperty the menuProperty to set
-        */
-       public void setMenuProperty(String menuProperty) {
-               this._menuProperty = menuProperty;
-       }
-       
-       /**
-        * Get the _titleProperty.
-        * @return the _titleProperty
-        */
-       public String getTitleProperty() {
-               return _titleProperty;
-       }
-
-       /**
-        * Set the _titleProperty.
-        * @param _titleProperty the titleProperty to set
-        */
-       public void setTitleProperty(String titleProperty) {
-               _titleProperty = titleProperty;
-       }
-
-       /**
-        * Get the editDisabledProperty.
-        * @return the editDisabledProperty
-        */
-       public final String getEditDisabledProperty() {
-               return _editDisabledProperty;
-       }
-
-       /**
-        * Set the editDisabledProperty.
-        * @param editDisabledProperty the editDisabledProperty to set
-        */
-       public final void setEditDisabledProperty(String editDisabledProperty) {
-               _editDisabledProperty = editDisabledProperty;
-       }
-
-       /**
-        * Get the toolProperty.
-        * @return the toolProperty
+        * Get sorted list of available document states.
+        * 
+        * @return the documentStates
         */
-       public String getToolProperty() {
-               return _toolProperty;
+       public List<ProgressState> getDocumentStates() {
+               List<ProgressState> states = new ArrayList<ProgressState>();
+               states.add(ProgressState.inWORK);
+               states.add(ProgressState.inDRAFT);
+               states.add(ProgressState.EXTERN);
+               return states;
        }
 
        /**
-        * Set the toolProperty.
-        * @param toolProperty the toolProperty to set
+        * Get the isReviewable.
+        * 
+        * @return the isReviewable
         */
-       public void setToolProperty(final String toolProperty) {
-               _toolProperty = toolProperty;
+       public List<Boolean> getReviewable() {
+               return _reviewable;
        }
 }
\ No newline at end of file