<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
-<script>
+
+<script language="JavaScript">
+// Flags whether a validation cycle of a document type has Review state.
+var hasReview = new Array();
+<s:iterator value="reviewable" status="stat">
+hasReview[<s:property value="#stat.index"/>]=<s:property />;
+</s:iterator>
+
$(document).ready(function () {
$("#bring input[name='documentName']").focus();
- <s:if test="%{reference != null}">
+ <s:if test="%{reference == null}">
// if versioning then the document name and state can not be modified.
- $("#bring input[name='documentName']").attr("disabled","disabled");
- $("#bring input[name='documentState']").attr("disabled","disabled");
+ $("#bring input[name='documentName']").prop("disabled", false);
+ $("#bring input[name='documentState']").prop("disabled", false);
</s:if>
+ $("#bring #documentType").change(function () {
+ // Hide or show inDraft according to the selected document type
+ if (hasReview[document.bring.documentType.selectedIndex]) {
+ // Show inDraft
+ $("#bring #documentState option[value='inDRAFT']").show();
+ } else {
+ // Deselect inDraft if it is selected
+ if (document.bring.documentState.value == 'inDRAFT') {
+ document.bring.documentState.selectedIndex = 0;
+ }
+ // Hide inDraft
+ $("#bring #documentState option[value='inDRAFT']").hide();
+ }
+ }).change();
});
</script>
<!-- Import dialog
- =============================================================================================================================
+ ===========================================================================
-->
<div id="article-box">
<div id="section"><s:text name="title.import" /></div>
</tr>
<tr>
<td><s:select theme="simple" name="documentType"
- list="documentTypes" listKey="index"
+ id="documentType" list="documentTypes" listKey="index"
listValue="%{getText('type.document.' + getName())}" /> </td>
- <td><s:if test="%{reference != null}">
- <s:textfield theme="simple" id="documentName" name="documentName"
- disabled="" />
- </s:if> <s:else>
- <s:textfield theme="simple" id="documentName" name="documentName" />
- </s:else></td>
+ <td><s:textfield theme="simple" id="documentName"
+ name="documentName" disabled="true" /></td>
</tr>
<s:if test="defaultDocumentUses.size > 0">
<tr>
<td align="left"><s:submit theme="simple" name="save"
key="button.import" /> <s:select theme="simple" id="documentState"
name="documentState" list="documentStates" listKey="value"
- listValue="%{getText(key)}">
- </s:select></td>
+ listValue="%{getText(key)}" disabled="" /></td>
</tr>
</table>
</form>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"
-%>
-<%@
- taglib prefix="s" uri="/struts-tags"
-%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-
- <head>
- <link href=<s:url value="/skin/default.css"/> rel="stylesheet" type="text/css">
- <script language="JavaScript">
-
- function initialize () {
-// ----------------------
- version.description.focus();
- }
- </script>
- </head>
- <body onLoad="initialize()">
+ pageEncoding="ISO-8859-1"%>
+<%@taglib prefix="s" uri="/struts-tags"%>
+<script language="JavaScript">
+$(document).ready(function () {
+ $("#version input[name='description']").focus();
+ <s:if test="%{version == ''}">
+ // if versioning then the document name and state can not be modified.
+ $("#version input[name='documentState']").prop("disabled", false);
+ </s:if>
+ <s:if test="%{description == null}">
+ $("#version input[name='description']").prop("disabled", false);
+ </s:if>
+});
+</script>
<!-- Import dialog
- =============================================================================================================================
+ ===========================================================================
-->
- <div id=article-box>
- <div id=section><s:text name="title.version"/></div>
- <div id=article-body class=text>
- <table width=100% cellpadding=0 cellspacing=0 border=0 class=text>
- <tr height=25 valign=middle>
- <td>
- <s:text name="message.upload">
- <s:param><s:property value="%{fileName}"/></s:param>
- </s:text>
- </td>
- </tr>
- <tr height=1 bgcolor=#AAAAAA><td></td></tr>
- </table>
+<div id="article-box">
+<div id="section"><s:text name="title.version" /></div>
+<div id="article-body" class="text">
+<table width="100%" cellpadding="0" cellspacing="0" border="0"
+ class="text">
+ <tr height="25" valign="middle">
+ <td><s:text name="message.upload">
+ <s:param>
+ <s:property value="%{fileName}" />
+ </s:param>
+ </s:text></td>
+ </tr>
+ <tr height="1" bgcolor="#AAAAAA">
+ <td></td>
+ </tr>
+</table>
- <form name="version" action="valid-version" method="post">
- <s:hidden name="fileName" value="%{fileName}" />
- <s:hidden name="index" value="%{index}" />
- <s:hidden name="version" value="%{version}" />
- <s:hidden name="date" value="%{date}" />
- <s:hidden name="defaultDescription" value="%{description}" />
- <table cellpadding=0 cellspacing=0 border=0 class=text>
- <tr height=15><td></td></tr>
- <tr>
- <td align=right><s:text name="field.documentype"/> </td>
- <td align=left> <s:text name="field.documentitle"/></td>
- </tr>
- <tr>
- <td align=right>
- <select name="documentType" disabled="disabled">
- <option selected value="<s:property value="defaultDocumentType.index"/>"> <s:text name="type.document.%{defaultDocumentType.name}"/></option>
- </select>
- </td>
- <td align=left>
- <input type="text" name="documentName" disabled="disabled" size="60" value="<s:property value="documentName"/>" />
- </td>
- </tr>
- <s:if test="defaultDocumentUses.size > 0">
- <tr><td align=right><s:text name="label.uses"/>:</td></tr>
- <s:iterator value="defaultDocumentUses">
- <tr>
- <td align=right><input type="checkbox" name="uses" value="<s:property value="index"/>" checked></td>
- <td><s:property value="title"/></td>
- </tr>
- </s:iterator>
- </s:if>
- <tr height=10><td></td></tr>
- <tr>
- <td align=right><s:text name="label.modifications"/>:</td>
- <td>
- <s:set var="sethistory" value="%{''}"/>
- <s:if test="%{description != null}">
- <s:set var="sethistory" value="%{'disabled'}"/>
- </s:if>
- <input type="text" name="description" size="60" value="<s:property value="description"/>" <s:property value="%{#sethistory}"/> />
- </td>
- </tr>
- <s:if test="dependencies.size > 0">
- <tr height=10><td></td></tr>
- <tr height=10 class=warning>
- <td colspan=2><b><s:text name="label.warning"/>:</b><br><s:text name="message.dependencies"/></td>
- </tr>
- <tr height=5><td></td></tr>
- <s:iterator value="dependencies">
- <tr>
- <td align=right><input type="checkbox" name="usedBy" value="<s:property value="index"/>"></td>
- <td><s:property value="value().title"/></td>
- </tr>
- </s:iterator>
- <tr>
- <tr>
- </s:if>
- <tr height=10><td></td></tr>
- <tr>
- <td align=right>
- <input type="submit" name="cancel" value="<s:text name="button.cancel"/>"/>
- </td>
- <td align=left>
- <s:set var="setstate" value="%{''}"/>
- <s:if test="%{version != ''}">
- <s:set var="setstate" value="%{'disabled'}"/>
- </s:if>
- <input type="submit" name="save" value="<s:text name="button.import"/>"/>
- <select name="documentState" <s:property value="%{#setstate}"/>>
- <s:if test="documentState == 'inDRAFT'">
- <option value="inWORK"><s:text name="label.inWORK"/></option>
- <option value="inDRAFT" selected><s:text name="label.inDRAFT"/></option>
- </s:if><s:else>
- <option value="inWORK" selected><s:text name="label.inWORK"/></option>
- <option value="inDRAFT"><s:text name="label.inDRAFT"/></option>
- </s:else>
- </select>
- </td>
- </tr>
- </table>
- </form>
- </div>
- </div>
- </body>
-</html>
\ No newline at end of file
+<form name="version" id="version" action="valid-version" method="post"><s:hidden
+ name="fileName" /> <s:hidden name="index" /> <s:hidden name="version" />
+<s:hidden name="documentDate" /> <s:hidden name="defaultDescription"
+ value="%{description}" />
+<table cellpadding="0" cellspacing="0" border="0" class="text">
+ <tr height="15">
+ <td></td>
+ </tr>
+ <tr>
+ <td align="right"><s:text name="field.documentype" /> </td>
+ <td align="left"> <s:text name="field.documentitle" /></td>
+ </tr>
+ <tr>
+ <td align="right"><select name="documentType" disabled="">
+ <option selected
+ value="<s:property value="defaultDocumentType.index"/>"> <s:text
+ name="type.document.%{defaultDocumentType.name}" /></option>
+ </select> </td>
+ <td align="left"><s:textfield theme="simple" id="documentName"
+ name="documentName" disabled="true" size="60" /></td>
+ </tr>
+ <s:if test="defaultDocumentUses.size > 0">
+ <tr>
+ <td align="right"><s:text name="label.uses" />:</td>
+ </tr>
+ <s:iterator value="defaultDocumentUses">
+ <tr>
+ <td align="right"><input type="checkbox" name="uses"
+ value="<s:property value="index"/>" checked></td>
+ <td><s:property value="title" /></td>
+ </tr>
+ </s:iterator>
+ </s:if>
+ <tr height="10">
+ <td></td>
+ </tr>
+ <tr>
+ <td align="right"><s:text name="label.modifications" />:</td>
+ <td><s:textfield theme="simple" id="description"
+ name="description" disabled="true" size="60" /></td>
+ </tr>
+ <s:if test="dependencies.size > 0">
+ <tr height="10">
+ <td></td>
+ </tr>
+ <tr height="10" class="warning">
+ <td colspan="2"><b><s:text name="label.warning" />:</b><br>
+ <s:text name="message.dependencies" /></td>
+ </tr>
+ <tr height="5">
+ <td></td>
+ </tr>
+ <s:iterator value="dependencies">
+ <tr>
+ <td align="right"><input type="checkbox" name="usedBy"
+ value="<s:property value="index"/>"></td>
+ <td><s:property value="value().title" /></td>
+ </tr>
+ </s:iterator>
+ <tr>
+ <tr>
+ </s:if>
+ <tr height="10">
+ <td></td>
+ </tr>
+ <tr>
+ <td align="right"><s:submit theme="simple" name="cancel"
+ key="button.cancel" /> </td>
+ <td align="left"><s:submit theme="simple" name="save"
+ key="button.import" /> <s:select theme="simple" id="documentState"
+ name="documentState" list="documentStates" listKey="value"
+ listValue="%{getText(key)}" disabled="" /></td>
+ </tr>
+</table>
+</form>
+</div>
+</div>
--- /dev/null
+package org.splat.simer;
+
+import org.splat.service.technical.RepositoryService;
+
+/**
+ * Abstract action just after uploading a file.
+ */
+public abstract class AbstractUploadNextAction extends Action {
+
+ /**
+ * Uploaded file name.
+ */
+ protected String _fileName = null;
+ /**
+ * Next action.
+ */
+ protected transient ToDo _action = null;
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
+
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = -6925961099244461039L;
+
+ /**
+ * Possible next action.
+ */
+ protected enum ToDo {
+ /**
+ * Cancel uploading.
+ */
+ cancel,
+ /**
+ * Save uploaded data.
+ */
+ save
+ };
+
+ // ==============================================================================================================================
+ // Getters and setters
+ // ==============================================================================================================================
+
+ /**
+ * Get uploaded file name.
+ *
+ * @return uploaded file name
+ */
+ public String getFileName() {
+ return _fileName;
+ }
+
+ public void setCancel(final boolean cancel) {
+ this._action = ToDo.cancel;
+ }
+
+ /**
+ * Set uploaded file name.
+ *
+ * @param path
+ * uploaded file name
+ */
+ public void setFileName(final String path) {
+ this._fileName = path;
+ }
+
+ public void setSave(final boolean save) {
+ this._action = ToDo.save;
+ }
+
+ // ==============================================================================================================================
+ // Protected services
+ // ==============================================================================================================================
+
+ /**
+ * Get the repositoryService.
+ *
+ * @return the repositoryService
+ */
+ public RepositoryService getRepositoryService() {
+ return _repositoryService;
+ }
+
+ /**
+ * Set the repositoryService.
+ *
+ * @param repositoryService
+ * the repositoryService to set
+ */
+ public void setRepositoryService(final RepositoryService repositoryService) {
+ _repositoryService = repositoryService;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.splat.simer;
+
+import java.io.File;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import org.splat.dal.bo.kernel.User;
+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.manox.Reader;
+import org.splat.service.PublicationService;
+import org.splat.service.StepService;
+import org.splat.service.StudyService;
+import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.Step;
+import org.splat.wapp.Constants;
+
+/**
+ * Base action for adding a document into a study step.
+ */
+public class BaseUploadDocumentAction extends AbstractUploadNextAction {
+
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 7920982168638437486L;
+ /**
+ * Version number extracted from the imported file, if exist.
+ */
+ private String _version = "";
+ /**
+ * Date extracted from the imported file, if exist.
+ */
+ private String _documentDate = "";
+ /**
+ * Injected project settings service.
+ */
+ private ProjectSettingsService _projectSettings;
+ /**
+ * Injected publication service.
+ */
+ private PublicationService _publicationService;
+ /**
+ * Injected step service.
+ */
+ private StepService _stepService;
+ /**
+ * Injected study service.
+ */
+ private StudyService _studyService;
+ protected DocumentType _deftype = null;
+ protected List<Document> _defuses = null;
+ protected String _docname = null;
+ protected String _docuses = null;
+ protected OpenStudy _mystudy = null;
+ protected ProgressState _state = null;
+
+ /**
+ * Common initialization of the action form.
+ *
+ * @param editDisabled
+ * if the study editable or not
+ * @return downloaded file
+ */
+ protected File commonInitialize(final String editDisabled) {
+
+ if (Constants.TRUE.equals(getWriteAccess())) {
+ setToolProperty(Constants.STUDY_MENU);
+ } else {
+ setToolProperty(Constants.NONE);
+ }
+ initializationFullScreenContext(Constants.STUDY_MENU,
+ Constants.STUDY_MENU, editDisabled, getToolProperty(),
+ Constants.STUDY_MENU);
+
+ User user = getConnectedUser();
+ File updir = getRepositoryService().getDownloadDirectory(user);
+ File upfile = new File(updir.getPath() + "/" + _fileName);
+
+ _mystudy = getOpenStudy();
+ _defuses = new ArrayList<Document>();
+ return upfile;
+ }
+
+ /**
+ * Extract document date.
+ *
+ * @param tool
+ * file reader
+ * @return true if ok, false if error
+ */
+ protected boolean extractDate(final Reader tool) {
+ boolean isOk = true;
+ setDocumentDate(tool.extractProperty("date"));
+ if (getDocumentDate() == null) {
+ setDocumentDate("");
+ } else {
+ ResourceBundle locale = ResourceBundle.getBundle("som",
+ getApplicationSettings().getCurrentLocale());
+ SimpleDateFormat check = new SimpleDateFormat(locale
+ .getString("date.format"), getApplicationSettings()
+ .getCurrentLocale());
+ try {
+ check.parse(getDocumentDate());
+ } catch (ParseException e) {
+ setErrorCode("message.error.format.date");
+ isOk = false;
+ }
+ }
+ return isOk;
+ }
+
+ /**
+ * Set error message and menus.
+ *
+ * @param errorCode
+ * error message key
+ */
+ protected void setError(final String errorCode) {
+ setErrorCode(errorCode);
+
+ initializationFullScreenContext(Constants.STUDY_MENU,
+ Constants.STUDY_MENU, Constants.FALSE, Constants.NONE,
+ Constants.STUDY_MENU);
+ }
+
+ /**
+ * Date extracted from the imported file, if exist.
+ *
+ * @return the file date
+ */
+ public String getDocumentDate() {
+ return _documentDate;
+ }
+
+ /**
+ * Get version number extracted from the imported file, if exist.
+ *
+ * @return the document version
+ */
+ public String getVersion() {
+ return _version;
+ }
+
+ /**
+ * Set date extracted from the imported file.
+ *
+ * @param date
+ * the date to set
+ */
+ public void setDocumentDate(final String date) {
+ this._documentDate = date;
+ }
+
+ /**
+ * Set version number extracted from the imported file, if exist.
+ *
+ * @param value
+ * the version
+ */
+ public void setVersion(final String value) {
+ this._version = value;
+ }
+
+ /**
+ * Get project settings.
+ *
+ * @return Project settings service
+ */
+ protected ProjectSettingsService getProjectSettings() {
+ return _projectSettings;
+ }
+
+ /**
+ * Set project settings service.
+ *
+ * @param projectSettingsService
+ * project settings service
+ */
+ public void setProjectSettings(
+ final ProjectSettingsService projectSettingsService) {
+ _projectSettings = projectSettingsService;
+ }
+
+ /**
+ * Get the publicationService.
+ *
+ * @return the publicationService
+ */
+ public PublicationService getPublicationService() {
+ return _publicationService;
+ }
+
+ /**
+ * Set the publicationService.
+ *
+ * @param publicationService
+ * the publicationService to set
+ */
+ public void setPublicationService(
+ final PublicationService publicationService) {
+ _publicationService = publicationService;
+ }
+
+ /**
+ * Get the stepService.
+ *
+ * @return the stepService
+ */
+ public StepService getStepService() {
+ return _stepService;
+ }
+
+ /**
+ * Set the stepService.
+ *
+ * @param stepService
+ * the stepService to set
+ */
+ public void setStepService(final StepService stepService) {
+ _stepService = stepService;
+ }
+
+ /**
+ * Get the studyService.
+ *
+ * @return the studyService
+ */
+ public StudyService getStudyService() {
+ return _studyService;
+ }
+
+ /**
+ * Set the studyService.
+ *
+ * @param studyService
+ * the studyService to set
+ */
+ public void setStudyService(final StudyService studyService) {
+ _studyService = studyService;
+ }
+
+ // ==============================================================================================================================
+ // Getters and setters
+ // ==============================================================================================================================
+
+ public DocumentType getDefaultDocumentType() {
+ return _deftype;
+ }
+
+ public List<Document> getDefaultDocumentUses() {
+ return _defuses;
+ }
+
+ public String getDocumentName() {
+ return _docname;
+ }
+
+ public String getDocumentState() {
+ return _state.toString();
+ }
+
+ protected Publication getPublication(final int index) {
+ List<Step> steps = _mystudy.getInvolvedSteps();
+ Publication found = null, pub;
+ for (Iterator<Step> i = steps.iterator(); i.hasNext();) {
+ List<Publication> published = i.next().getAllDocuments();
+ for (Iterator<Publication> j = published.iterator(); j.hasNext();) {
+ pub = j.next(); // In a given study step,
+ if (pub.value().getIndex() == index) {
+ found = pub; // there is only one publication of a given document
+ break;
+ }
+ }
+ }
+ return found;
+ }
+
+ public void setDocumentState(final String state) {
+ this._state = ProgressState.valueOf(state);
+ }
+
+ // ==============================================================================================================================
+ // Protected services
+ // ==============================================================================================================================
+
+ protected void setupDefaultUses(final DocumentType type) {
+ Set<DocumentType> uses = type.getDefaultUses();
+
+ for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
+ DocumentType usetype = i.next();
+ List<Document> usedoc = _mystudy.collectInvolvedDocuments(usetype);
+ if (usedoc.isEmpty() && (!usetype.equals(type))) {
+ setupDefaultUses(usetype);
+ } else {
+ _defuses.addAll(usedoc);
+ }
+ }
+ }
+
+ public void setUses(final String list) {
+ this._docuses = list;
+ }
+
+ public String getWriteAccess() {
+ Boolean res = (_mystudy != null);
+ if (res) {
+ res = _mystudy.isOpenForWriting();
+ }
+ return res.toString();
+ }
+}
\ No newline at end of file
import org.splat.som.StepRights;
import org.splat.wapp.Constants;
+/**
+ * Action for scenario properties modification.
+ */
public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
/**
private transient Scenario _myscenario;
private transient String _lasdate;
private transient String _subject;
-
+
/**
* Title of the selected scenario.
*/
ResourceBundle custom = ResourceBundle.getBundle("som",
getApplicationSettings().getCurrentLocale());
SimpleDateFormat datstring = new SimpleDateFormat(custom
- .getString("date.format")); // Locale date display format
+ .getString("date.format"), getApplicationSettings()
+ .getCurrentLocale()); // Locale date display format
Step step;
_openStudy = getOpenStudy();
/**
* Rename the scenario functionality.
+ *
* @return SUCCESS
*/
public String doEditScenarioTitle() {
Iterator<Scenario> iter = scenarios.iterator();
for (; iter.hasNext();) {
Scenario scenario = iter.next();
- if (openStudy.getSelectedScenarioId().equals(String.valueOf(scenario.getIndex()))) {
- scenario.setTitle(getSelectedScenarioTitle());
+ if (openStudy.getSelectedScenarioId().equals(
+ String.valueOf(scenario.getIndex()))) {
+ scenario.setTitle(getSelectedScenarioTitle());
_scenarioService.renameScenario(scenario);
}
}
return SUCCESS;
}
-
+
// ==============================================================================================================================
// Getters
// ==============================================================================================================================
return _subject;
}
-
public boolean isCheckedout() {
return _myscenario.isCheckedout();
}
-
-
/**
* Get the selectedScenarioTitle.
+ *
* @return the selectedScenarioTitle
*/
public String getSelectedScenarioTitle() {
/**
* Set the selectedScenarioTitle.
- * @param selectedScenarioTitle the selectedScenarioTitle to set
+ *
+ * @param selectedScenarioTitle
+ * the selectedScenarioTitle to set
*/
public void setSelectedScenarioTitle(final String selectedScenarioTitle) {
_selectedScenarioTitle = selectedScenarioTitle;
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.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.
* 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 transient final List<Boolean> _reviewable = new ArrayList<Boolean>();
/**
* The selected document type.
*/
* Reference extracted from the imported file, if exist.
*/
private String _reference = null;
- /**
- * Version number extracted from the imported file, if exist.
- */
- private String _version = "";
- /**
- * Date extracted from the imported file, if exist.
- */
- private String _documentDate = "";
- /**
- * Injected project settings service.
- */
- private ProjectSettingsService _projectSettings;
- /**
- * Injected publication service.
- */
- private PublicationService _publicationService;
- /**
- * Injected step service.
- */
- private StepService _stepService;
/**
* Injected document service.
*/
* Injected document type service.
*/
private DocumentTypeService _documentTypeService;
- /**
- * Injected repository service.
- */
- private RepositoryService _repositoryService;
-
- // ==============================================================================================================================
- // Action methods
- // ==============================================================================================================================
/**
* Initialize the operation.
*/
public String doInitialize() {
- if (Constants.TRUE.equals(getWriteAccess())) {
- setToolProperty(Constants.STUDY_MENU);
- } else {
- setToolProperty(Constants.NONE);
- }
- initializationFullScreenContext(Constants.STUDY_MENU,
- Constants.STUDY_MENU, Constants.FALSE, getToolProperty(),
- Constants.STUDY_MENU);
-
- User user = getConnectedUser();
- File updir = getRepositoryService().getDownloadDirectory(user);
- File upfile = new File(updir.getPath() + "/" + filename);
- String[] table = filename.split("\\x2E");
+ File upfile = commonInitialize(Constants.FALSE);
+ String[] table = _fileName.split("\\x2E");
String filext = table[table.length - 1].toLowerCase();
- mystudy = getOpenStudy();
- Step step = mystudy.getSelectedStep();
+ _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());
+ _deftype = getApplicationSettings().getDefaultDocumentType(step, filext);
+ if (_deftype != null) {
+ setDefaultDocumentType(_deftype.getIndex());
}
- defuses = new ArrayList<Document>();
- state = ProgressState.inWORK;
+ _defuses = new ArrayList<Document>();
+ _state = ProgressState.inWORK;
String res = ERROR;
if (extractProperties(upfile, filext)) {
- if (docname == null) {
- docname = table[0];
+ if (_docname == null) {
+ _docname = table[0];
for (int i = 1; i < table.length - 1; i++) {
- docname = docname + "." + table[i];
+ _docname = _docname + "." + table[i];
}
}
- if (deftype != null) {
- setupDefaultUses(deftype);
+ if (_deftype != null) {
+ setupDefaultUses(_deftype);
}
DocumentType[] types = _documentTypes
_documentTypes = Arrays.asList(types);
res = SUCCESS;
}
+
+ // 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;
}
Reader tool = Toolbox.getReader(upfile);
if (tool == null) {
if ("pdf".equals(filext)) {
- state = ProgressState.EXTERN; // TODO: Should external extensions be configurable ?
+ _state = ProgressState.EXTERN; // TODO: Should external extensions be configurable ?
}
} else {
String fileref = tool.extractProperty("reference");
.hasNext();) {
DocumentType type = i.next();
if (type.getName().equals(filetype)) {
- deftype = type;
+ _deftype = type;
_documentType = type.getIndex(); // Disables the document type field
break;
}
filever.length() - 1);
}
if (!version.isMinor()) {
- state = ProgressState.inCHECK;
+ _state = ProgressState.inCHECK;
}
- _version = version.toString();
+ setVersion(version.toString());
} catch (ParseException e) {
- setError("message.error.format.version");
+ setErrorCode("message.error.format.version");
isOk = false;
}
}
if (isOk) {
- docname = tool.extractProperty("title"); // Property kept even if the file is not referenced
- _documentDate = tool.extractProperty("date");
- if (_documentDate == null) {
- _documentDate = "";
- } else {
- ResourceBundle locale = ResourceBundle.getBundle("som",
- getApplicationSettings().getCurrentLocale());
- SimpleDateFormat check = new SimpleDateFormat(locale
- .getString("date.format"),
- getApplicationSettings().getCurrentLocale());
- try {
- check.parse(_documentDate);
- } catch (ParseException e) {
- setError("message.error.format.date");
- isOk = false;
- }
- }
+ _docname = tool.extractProperty("title"); // Property kept even if the file is not referenced
+ isOk = extractDate(tool);
}
}
}
} 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
+ _deftype = slot.getType(); // Just in case
+ _documentType = _deftype.getIndex(); // Disables the document type field
} else {
setError("message.error.reference.duplicate");
isOk = false;
return isOk;
}
- /**
- * Set error message and menus.
- *
- * @param errorCode
- * error message key
- */
- private void setError(final String errorCode) {
- setErrorCode(errorCode);
-
- initializationFullScreenContext(Constants.STUDY_MENU,
- Constants.STUDY_MENU, Constants.FALSE, Constants.NONE,
- Constants.STUDY_MENU);
- }
-
/**
* Perform import of a document.
*
* @return SUCCESS if ok, "cancel" - if canceled, ERROR - if error
*/
public String doImport() {
- String result = ERROR;
+ String res = ERROR;
initializationScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU,
Constants.TRUE);
- if (action == ToDo.cancel) {
- result = "cancel";
+ if (_action == ToDo.cancel) {
+ res = "cancel";
} else if (_documentType == 0) {
setErrorCode("message.error.import.type");
} else {
try {
// Getting user inputs
- mystudy = getOpenStudy();
+ _mystudy = getOpenStudy();
User user = getConnectedUser();
- Step step = mystudy.getSelectedStep();
- Date docdate = null;
- if (_documentDate.length() > 0) {
+ 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"), getApplicationSettings()
.getCurrentLocale());
- docdate = get.parse(_documentDate);
+ aDate = get.parse(getDocumentDate());
}
// Creation of uses relations
List<Long> uses = new ArrayList<Long>();
- if (docuses != null) {
- String[] list = docuses.split(",");
+ if (_docuses != null) {
+ String[] list = _docuses.split(",");
for (int i = 0; i < list.length; i++) {
uses.add(Long.valueOf(list[i].trim()));
}
}
}
Publication addoc = getPublicationService().createDoc(
- mystudy.getIndex(), step, _documentType,
- user.getIndex(), filename, docname, state, _reference,
- _version, docdate, uses);
+ _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
+ _mystudy.updateSimulationContexts(); // In case of simulation contexts extracted from the imported document
}
// Creation of derived the document formats
//
// if (send != null) send.converts(addoc); // Asynchronous process
- mystudy.add(addoc); // Updates the presentation
- result = SUCCESS;
+ _mystudy.add(addoc); // Updates the presentation
+ res = SUCCESS;
} catch (FileNotFoundException error) {
LOG.error("Reason:", error);
setErrorCode("message.error.import.file");
setErrorCode("message.error.internal");
}
- if (!SUCCESS.equals(result)) {
+ if (!SUCCESS.equals(res)) {
initializationFullScreenContext(Constants.STUDY_MENU,
Constants.STUDY_MENU, Constants.TRUE, Constants.NONE,
Constants.STUDY_MENU);
}
}
- return result;
+ return res;
}
// ==============================================================================================================================
// Getters and setters
// ==============================================================================================================================
- /**
- * Date extracted from the imported file, if exist.
- *
- * @return the file date
- */
- public String getDocumentDate() {
- return _documentDate;
- }
-
/**
* Get sorted list of document types valid for the selected study step.
*
return _reference;
}
- /**
- * Get version number extracted from the imported file, if exist.
- *
- * @return the document version
- */
- public String getVersion() {
- return _version;
- }
-
- /**
- * Set date extracted from the imported file.
- *
- * @param date
- * the date to set
- */
- public void setDocumentDate(final String date) {
- this._documentDate = date;
- }
-
/**
* Set document name entered by the user if enabled.
*
* the document name
*/
public void setDocumentName(final String name) {
- this.docname = name; // Name entered by the user if enabled
+ this._docname = name; // Name entered by the user if enabled
}
/**
* the default document title
*/
public void setDocumentTitle(final String name) { // Called even if DocumentName is enabled
- if (this.docname == null) {
- this.docname = name;
+ if (this._docname == null) {
+ this._docname = name;
}
}
* the default state
*/
public void setDefaultDocumentState(final String state) { // Called even if DocumentState is enabled
- if (this.state == null) {
- this.state = ProgressState.valueOf(state);
+ if (this._state == null) {
+ this._state = ProgressState.valueOf(state);
}
}
this._reference = value;
}
- /**
- * Set version number extracted from the imported file, if exist.
- *
- * @param value
- * the version
- */
- public void setVersion(final String value) {
- this._version = value;
- }
-
- /**
- * Get project settings.
- *
- * @return Project settings service
- */
- private ProjectSettingsService getProjectSettings() {
- return _projectSettings;
- }
-
- /**
- * Set project settings service.
- *
- * @param projectSettingsService
- * project settings service
- */
- public void setProjectSettings(
- final ProjectSettingsService projectSettingsService) {
- _projectSettings = projectSettingsService;
- }
-
- /**
- * Get the publicationService.
- *
- * @return the publicationService
- */
- public PublicationService getPublicationService() {
- return _publicationService;
- }
-
- /**
- * Set the publicationService.
- *
- * @param publicationService
- * the publicationService to set
- */
- public void setPublicationService(
- final PublicationService publicationService) {
- _publicationService = publicationService;
- }
-
- /**
- * Get the stepService.
- *
- * @return the stepService
- */
- public StepService getStepService() {
- return _stepService;
- }
-
- /**
- * Set the stepService.
- *
- * @param stepService
- * the stepService to set
- */
- public void setStepService(final StepService stepService) {
- _stepService = stepService;
- }
-
/**
* Get the 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(final RepositoryService repositoryService) {
- _repositoryService = repositoryService;
- }
-
/**
* Get the documentTypeService.
*
states.add(ProgressState.EXTERN);
return states;
}
+
+ /**
+ * Get the isReviewable.
+ *
+ * @return the isReviewable
+ */
+ public List<Boolean> getReviewable() {
+ return _reviewable;
+ }
}
\ No newline at end of file
+++ /dev/null
-package org.splat.simer;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-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.som.Step;
-
-public abstract class UploadBaseNextAction extends Action {
-
- protected OpenStudy mystudy = null;
- protected String filename = null; // Uploaded file name
- protected DocumentType deftype = null;
- protected List<Document> defuses = null;
- protected String docname = null;
- protected ProgressState state = null;
- protected String docuses = null;
- protected ToDo action = null;
-
- /**
- * Serial version ID.
- */
- private static final long serialVersionUID = -6925961099244461039L;
-
- protected enum ToDo {
- cancel, save
- };
-
- // ==============================================================================================================================
- // Getters and setters
- // ==============================================================================================================================
-
- public DocumentType getDefaultDocumentType() {
- return deftype;
- }
-
- public List<Document> getDefaultDocumentUses() {
- return defuses;
- }
-
- public String getDocumentName() {
- return docname;
- }
-
- public String getDocumentState() {
- return state.toString();
- }
-
- public String getFileName() {
- return filename;
- }
-
- public void setCancel(final boolean cancel) {
- this.action = ToDo.cancel;
- }
-
- public void setDocumentState(final String state) {
- this.state = ProgressState.valueOf(state);
- }
-
- public void setFileName(final String path) {
- this.filename = path;
- }
-
- public void setUses(final String list) {
- this.docuses = list;
- }
-
- public void setSave(final boolean save) {
- this.action = ToDo.save;
- }
-
- public String getWriteAccess() {
- Boolean res = (mystudy != null);
- if (res) {
- res = mystudy.isOpenForWriting();
- }
- return res.toString();
- }
-
- // ==============================================================================================================================
- // Protected services
- // ==============================================================================================================================
-
- protected void setupDefaultUses(final DocumentType type) {
- Set<DocumentType> uses = type.getDefaultUses();
-
- for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
- DocumentType usetype = i.next();
- List<Document> usedoc = mystudy.collectInvolvedDocuments(usetype);
- if (usedoc.isEmpty() && (!usetype.equals(type))) {
- setupDefaultUses(usetype);
- } else {
- defuses.addAll(usedoc);
- }
- }
- }
-
- protected Publication getPublication(final int index) {
- List<Step> steps = mystudy.getInvolvedSteps();
- Publication found = null, pub;
- for (Iterator<Step> i = steps.iterator(); i.hasNext();) {
- List<Publication> published = i.next().getAllDocuments();
- for (Iterator<Publication> j = published.iterator(); j.hasNext();) {
- pub = j.next(); // In a given study step,
- if (pub.value().getIndex() == index) {
- found = pub; // there is only one publication of a given document
- break;
- }
- }
- }
- return found;
- }
-}
\ No newline at end of file
import java.io.File;
import java.io.FileNotFoundException;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.UsedByRelation;
import org.splat.dal.bo.som.UsesRelation;
+import org.splat.dal.bo.som.ValidationCycle;
+import org.splat.dal.bo.som.ValidationStep;
import org.splat.kernel.InvalidPropertyException;
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
-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.som.Revision;
import org.splat.som.Step;
import org.splat.wapp.Constants;
/**
* Action for creating a new version of a document.
*/
-public class VersionDocumentAction extends UploadBaseNextAction {
+public class VersionDocumentAction extends BaseUploadDocumentAction {
/**
* Serial version ID.
*/
private String _description = null;
/**
- * Version number extracted from the imported file, if exist.
+ * Applicable document states.
*/
- private String _version = "";
- /**
- * Date extracted from the imported file, if exist.
- */
- private String _date = "";
- /**
- * Injected project settings service.
- */
- private ProjectSettingsService _projectSettings;
- /**
- * Injected publication service.
- */
- private PublicationService _publicationService;
- /**
- * Injected step service.
- */
- private StepService _stepService;
- /**
- * Injected repository service.
- */
- private RepositoryService _repositoryService;
-
- // ==============================================================================================================================
- // Action methods
- // ==============================================================================================================================
+ private transient final List<ProgressState> _documentStates = new ArrayList<ProgressState>();
/**
* Initialize the action form.
* @return SUCCESS if succeeded, ERROR if uploaded file is XML and we can't extract properties from it
*/
public String doInitialize() {
+ File upfile = commonInitialize(Constants.TRUE);
- if ("true".equals(getWriteAccess())) {
- setToolProperty(Constants.STUDY_MENU);
- } else {
- setToolProperty(Constants.NONE);
- }
- initializationFullScreenContext(Constants.STUDY_MENU,
- Constants.STUDY_MENU, Constants.TRUE, getToolProperty(),
- Constants.STUDY_MENU);
-
- User user = getConnectedUser();
- File updir = getRepositoryService().getDownloadDirectory(user);
- File upfile = new File(updir.getPath() + "/" + filename);
-
- mystudy = getOpenStudy();
+ _mystudy = getOpenStudy();
+ _defuses = new ArrayList<Document>();
- Publication tag = mystudy.getSelectedStep().getDocument(
+ Publication tag = _mystudy.getSelectedStep().getDocument(
Integer.valueOf(_index));
Document doc = tag.value();
- deftype = doc.getType();
- docname = doc.getTitle();
- defuses = new ArrayList<Document>();
+ _deftype = doc.getType();
+ _docname = doc.getTitle();
_usedby = new ArrayList<Publication>();
String res = SUCCESS;
if (extractProperties(upfile, doc)) {
- setupDefaultUses(deftype);
+ if (_deftype != null) {
+ setupDefaultUses(_deftype);
+ }
// Add additional documents used by the current version
- List<Relation> uses = doc.getRelations(UsesRelation.class);
- for (Iterator<Relation> i = uses.iterator(); i.hasNext();) {
- Document used = (Document) i.next().getTo();
- if (!defuses.contains(used)) {
- defuses.add(used);
+ for (Relation usesRel: doc.getRelations(UsesRelation.class)) {
+ Document used = (Document) usesRel.getTo();
+ if (!_defuses.contains(used)) {
+ _defuses.add(used);
}
}
+ // Avoid recursive using of the document
+ if (_defuses.contains(doc)) {
+ _defuses.remove(doc);
+ }
// Setup dependencies
_usedby.addAll(tag.getRelations(UsedByRelation.class));
+
+ // Initialize applicable states list
+ _documentStates.add(ProgressState.inWORK);
+ if (_deftype != null) {
+ // Check if the validation cycle of the document type can has a review state
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ _mystudy.getMystudy(), _deftype);
+ if ((cycle != null) && cycle.enables(ValidationStep.REVIEW)) {
+ _documentStates.add(ProgressState.inDRAFT);
+ }
+ }
+
} else {
if (!(Constants.NONE.equals(getToolProperty()))) {
initializationFullScreenContext(Constants.STUDY_MENU,
throw new InvalidPropertyException("version");
}
if (newver.isMinor()) {
- state = ProgressState.inWORK;
+ _state = ProgressState.inWORK;
} else {
- state = ProgressState.inDRAFT;
+ _state = ProgressState.inDRAFT;
}
- _version = newver.toString();
+ setVersion(newver.toString());
} catch (Exception e) {
setErrorCode("message.error.version.mismatch");
res = false;
}
if (res) {
_description = tool.extractProperty("history");
- _date = tool.extractProperty("date");
- if (_date == null) {
- _date = "";
- } else {
- ResourceBundle locale = ResourceBundle.getBundle("som",
- getApplicationSettings().getCurrentLocale());
- SimpleDateFormat check = new SimpleDateFormat(locale
- .getString("date.format"));
- try {
- check.parse(_date);
- } catch (ParseException e) {
- setErrorCode("message.error.format.date");
- res = false;
- }
- }
+ res = extractDate(tool);
}
} else {
setErrorCode("message.error.reference.mismatch");
initializationScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU,
Constants.TRUE);
- if (action == ToDo.cancel) {
+ if (_action == ToDo.cancel) {
res = "cancel";
} else {
try {
// Getting user inputs
- mystudy = getOpenStudy();
+ _mystudy = getOpenStudy();
User user = getConnectedUser();
- Step step = mystudy.getSelectedStep();
+ Step step = _mystudy.getSelectedStep();
Date aDate = null;
- if (_date.length() > 0) {
+ if (getDocumentDate().length() > 0) {
ResourceBundle locale = ResourceBundle.getBundle("som",
getApplicationSettings().getCurrentLocale());
SimpleDateFormat get = new SimpleDateFormat(locale
- .getString("date.format"));
- aDate = get.parse(_date);
+ .getString("date.format"), getApplicationSettings()
+ .getCurrentLocale());
+ aDate = get.parse(getDocumentDate());
}
String[] listDocuses = null;
- if (docuses != null) {
- listDocuses = docuses.split(",");
+ if (_docuses != null) {
+ listDocuses = _docuses.split(",");
}
- getPublicationService().versionDocument(step, user, filename,
- Integer.valueOf(_index), _version, _description, state,
- aDate, listDocuses, _docusedby);
+ getPublicationService().versionDocument(step, user, _fileName,
+ Integer.valueOf(_index), getVersion(), _description,
+ _state, aDate, listDocuses, _docusedby);
// Update of the open study
- mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
+ _mystudy.setSelection(_mystudy.getSelection()); // Rebuilds the presentation
// TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
res = SUCCESS;
// Getters and setters
// ==============================================================================================================================
- public String getDate() {
- return _date;
- }
-
public List<Publication> getDependencies() {
return _usedby;
}
return _index;
}
- public String getVersion() {
- return _version;
- }
-
- public void setDate(final String date) {
- this._date = date;
- }
-
public void setDefaultDescription(final String summary) {
if (this._description == null) {
this._description = summary;
this._docusedby = list;
}
- public void setVersion(final String value) {
- this._version = value;
- }
-
- /**
- * Get project settings.
- *
- * @return Project settings service
- */
- private ProjectSettingsService getProjectSettings() {
- return _projectSettings;
- }
-
- /**
- * Set project settings service.
- *
- * @param projectSettingsService
- * project settings service
- */
- public void setProjectSettings(
- final ProjectSettingsService projectSettingsService) {
- _projectSettings = projectSettingsService;
- }
-
- /**
- * Get the publicationService.
- *
- * @return the publicationService
- */
- public PublicationService getPublicationService() {
- return _publicationService;
- }
-
- /**
- * Set the publicationService.
- *
- * @param publicationService
- * the publicationService to set
- */
- public void setPublicationService(
- final PublicationService publicationService) {
- _publicationService = publicationService;
- }
-
- /**
- * Get the stepService.
- *
- * @return the stepService
- */
- public StepService getStepService() {
- return _stepService;
- }
-
- /**
- * Set the stepService.
- *
- * @param stepService
- * the stepService to set
- */
- public void setStepService(final StepService stepService) {
- _stepService = stepService;
- }
-
- /**
- * Get the repositoryService.
- *
- * @return the repositoryService
- */
- public RepositoryService getRepositoryService() {
- return _repositoryService;
- }
-
/**
- * Set the repositoryService.
+ * Get the documentStates.
*
- * @param repositoryService
- * the repositoryService to set
+ * @return the documentStates
*/
- public void setRepositoryService(final RepositoryService repositoryService) {
- _repositoryService = repositoryService;
+ public List<ProgressState> getDocumentStates() {
+ return _documentStates;
}
}
\ No newline at end of file
import org.splat.dal.bo.kernel.User;
import org.splat.service.UserService;
-import org.splat.service.technical.RepositoryService;
-import org.splat.simer.UploadBaseNextAction;
+import org.splat.simer.AbstractUploadNextAction;
-
-public class ImportUserAction extends UploadBaseNextAction {
+/**
+ * Action for importing users from file to the database.
+ */
+public class ImportUserAction extends AbstractUploadNextAction {
/**
* Serial version ID.
*/
- private static final long serialVersionUID = 1516715800624817965L;
+ private static final long serialVersionUID = 1516715800624817965L;
- private transient List<User> _users;
- private transient Set<User> _newsers;
/**
- * Injected repository service.
+ * All users in the database.
*/
- private RepositoryService _repositoryService;
-
+ private transient List<User> _users;
+ /**
+ * New just imported users which were not in the database before.
+ */
+ private transient Set<User> _newsers;
/**
* Injected user service.
*/
private UserService _userService;
-
-// ==============================================================================================================================
-// Action methods
-// ==============================================================================================================================
- public String doImport () {
- String res = SUCCESS;
- try {
- User user = getConnectedUser(); // The database administrator
- File updir = getRepositoryService().getDownloadDirectory(user);
- File upfile = new File(updir.getPath() + "/" + filename);
+ // ==============================================================================================================================
+ // Action methods
+ // ==============================================================================================================================
- _newsers = getUserService().importUsers(upfile);
- _users = getUserService().selectAllUsers();
- for (Iterator<User> i=_users.iterator(); i.hasNext(); ) {
- User next = i.next();
- if (!next.equals(user)) {
- continue;
- }
- i.remove(); // Just for not showing the corresponding reserved username
- break;
- }
-
- initializationFullScreenContext("sysadmin", "none", "open");
- }
- catch (Exception error) {
- res = ERROR;
- }
- return res;
- }
-
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
+ /**
+ * Import users from file into the database.
+ *
+ * @return SUCCESS if ok, otherwise - ERROR
+ */
+ public String doImport() {
+ String res = SUCCESS;
+ try {
+ User user = getConnectedUser(); // The database administrator
+ File updir = getRepositoryService().getDownloadDirectory(user);
+ File upfile = new File(updir.getPath() + "/" + _fileName);
+
+ _newsers = getUserService().importUsers(upfile);
+ _users = getUserService().selectAllUsers();
+ for (Iterator<User> i = _users.iterator(); i.hasNext();) {
+ User next = i.next();
+ if (next.equals(user)) {
+ i.remove(); // Just for not showing the corresponding reserved username
+ break;
+ }
+ }
- public List<User> getUsers () {
-// -----------------------------
- return _users;
- }
+ initializationFullScreenContext("sysadmin", "none", "open");
+ } catch (Exception error) {
+ res = ERROR;
+ }
+ return res;
+ }
- public boolean isNew (final User user) {
-// --------------------------------
- return _newsers.contains(user);
- }
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
/**
- * Get the repositoryService.
- * @return the repositoryService
+ * Get all users from the database.
+ *
+ * @return list of all users from the database
*/
- public RepositoryService getRepositoryService() {
- return _repositoryService;
+ public List<User> getUsers() {
+ return _users;
}
/**
- * Set the repositoryService.
- * @param repositoryService the repositoryService to set
+ * Check if the user is a new one that is it was not in the database before.
+ *
+ * @param user
+ * the user to check
+ * @return true if the user is new
*/
- public void setRepositoryService(final RepositoryService repositoryService) {
- _repositoryService = repositoryService;
+ public boolean isNew(final User user) {
+ return _newsers.contains(user);
}
/**
* Get the userService.
+ *
* @return the userService
*/
public UserService getUserService() {
/**
* Set the userService.
- * @param userService the userService to set
+ *
+ * @param userService
+ * the userService to set
*/
public void setUserService(final UserService userService) {
_userService = userService;
<bean id="importDocumentAction"
class="org.splat.simer.ImportDocumentAction" scope="prototype"
parent="baseAction">
+ <property name="studyService" ref="studyService" />
<property name="stepService" ref="stepService" />
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
<bean id="versionDocumentAction"
class="org.splat.simer.VersionDocumentAction" scope="prototype"
parent="baseAction">
+ <property name="studyService" ref="studyService" />
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
<property name="stepService" ref="stepService" />