import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.service.DocumentService;
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;
public class ImportDocumentAction extends UploadBaseNextAction {
+ /**
+ * 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.
+ */
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected publication service.
+ */
private PublicationService _publicationService;
+ /**
+ * Injected step service.
+ */
private StepService _stepService;
+ /**
+ * Injected document service.
+ */
+ private DocumentService _documentService;
- private static final long serialVersionUID = 2587822564883588556L;
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
// ==============================================================================================================================
// Action methods
// ==============================================================================================================================
+ /**
+ * Initialize the operation.
+ * @return SUCCESS in success, otherwise - ERROR
+ */
public String doInitialize() {
// -----------------------------
Session connex = Database.getSession();
Transaction transax = connex.beginTransaction();
User user = getConnectedUser();
- File updir = Database.getDownloadDirectory(user);
+ File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
String[] table = filename.split("\\x2E");
String filext = table[table.length - 1].toLowerCase();
break;
}
if (fileref != null) {
- Document slot = Database.selectDocument(fileref,
+ Document slot = getDocumentService().selectDocument(fileref,
new Revision().toString());
if (slot == null) {
setErrorCode("reference.undefined");
return SUCCESS;
}
+ /**
+ * Perform import of a document.
+ * @return SUCCESS if ok, "cancel" - if canceled, ERROR - if error
+ */
public String doImport() {
// -------------------------
if (action == ToDo.cancel)
User user = getConnectedUser();
Step step = mystudy.getSelectedStep();
DocumentType type = Document.selectType((int)doctype);
- File updir = Database.getDownloadDirectory(user);
+ File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
String[] table = filename.split("\\x2E");
public void setStepService(StepService stepService) {
_stepService = stepService;
}
+
+ /**
+ * Get the documentService.
+ * @return the documentService
+ */
+ public DocumentService getDocumentService() {
+ return _documentService;
+ }
+
+ /**
+ * Set the documentService.
+ * @param documentService the documentService to set
+ */
+ public void setDocumentService(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;
+ }
}
\ No newline at end of file