Salome HOME
The draft of the "Copy from existing study" action is added. The YACS step is introdu...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / ImportDocumentAction.java
index a3a4de2ebebe77981383781d4ed671de829bfc4f..697f2b7d3a40b7490a05beedc8fc9630f42481b2 100644 (file)
@@ -2,12 +2,10 @@ 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.Date;
-import java.util.Iterator;
 import java.util.List;
 import java.util.ResourceBundle;
 
@@ -76,7 +74,8 @@ public class ImportDocumentAction extends BaseUploadDocumentAction {
                Step step = _mystudy.getSelectedStep();
                _documentTypes = getStepService().getValidDocumentTypes(step);
                // Set the document type by default
-               _deftype = getApplicationSettings().getDefaultDocumentType(step, filext);
+               _deftype = getApplicationSettings()
+                               .getDefaultDocumentType(step, filext);
                if (_deftype != null) {
                        setDefaultDocumentType(_deftype.getIndex());
                }
@@ -132,45 +131,45 @@ public class ImportDocumentAction extends BaseUploadDocumentAction {
                                _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);
-                               }
-                       }
+                       // 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;
        }
@@ -253,8 +252,8 @@ public class ImportDocumentAction extends BaseUploadDocumentAction {
                                }
                                Publication addoc = getPublicationService().createDoc(
                                                _mystudy.getIndex(), step, _documentType,
-                                               user.getIndex(), _fileName, _docname, _state, _reference,
-                                               getVersion(), aDate, uses);
+                                               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