[pollen] branch feature/1112 updated (a955a64 -> 68590fb)
This is an automated email from the git hooks/post-receive script. New change to branch feature/1112 in repository pollen. See http://git.chorem.org/pollen.git from a955a64 refs #1112 : complete Export service new 68590fb refs #1110 introduce admin action The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 68590fb4e6c9b196c4ea0dd85eaedcff7e16d787 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Sep 22 10:41:58 2014 +0200 refs #1110 introduce admin action Summary of changes: .../pollen/ui/actions/admin/ExportDatabase.java | 86 ++++++++++++++++++++++ .../ui/actions/admin/ExportDatabaseInput.java | 64 ++++++++++++++++ .../src/main/resources/config/struts-admin.xml | 34 +++++++++ .../i18n/pollen-ui-struts2_en_GB.properties | 9 ++- .../i18n/pollen-ui-struts2_fr_FR.properties | 7 ++ .../webapp/WEB-INF/decorators/layout-default.jsp | 5 ++ .../exportDatabase-wait.jsp} | 28 +++++-- .../exportDatabase.jsp} | 44 +++++------ 8 files changed, 248 insertions(+), 29 deletions(-) create mode 100644 pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ExportDatabase.java create mode 100644 pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ExportDatabaseInput.java copy pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/{poll/displayVote_CHECKBOX.jsp => admin/exportDatabase-wait.jsp} (64%) copy pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/{poll/displayPollComment.jsp => admin/exportDatabase.jsp} (57%) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1112 in repository pollen. See http://git.chorem.org/pollen.git commit 68590fb4e6c9b196c4ea0dd85eaedcff7e16d787 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Sep 22 10:41:58 2014 +0200 refs #1110 introduce admin action --- .../pollen/ui/actions/admin/ExportDatabase.java | 86 ++++++++++++++++++++++ .../ui/actions/admin/ExportDatabaseInput.java | 64 ++++++++++++++++ .../src/main/resources/config/struts-admin.xml | 34 +++++++++ .../i18n/pollen-ui-struts2_en_GB.properties | 9 ++- .../i18n/pollen-ui-struts2_fr_FR.properties | 7 ++ .../webapp/WEB-INF/decorators/layout-default.jsp | 5 ++ .../WEB-INF/jsp/admin/exportDatabase-wait.jsp | 43 +++++++++++ .../webapp/WEB-INF/jsp/admin/exportDatabase.jsp | 45 +++++++++++ 8 files changed, 292 insertions(+), 1 deletion(-) diff --git a/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ExportDatabase.java b/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ExportDatabase.java new file mode 100644 index 0000000..7fcbf92 --- /dev/null +++ b/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ExportDatabase.java @@ -0,0 +1,86 @@ +package org.chorem.pollen.ui.actions.admin; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.Preparable; +import org.chorem.pollen.PollenTechnicalException; +import org.chorem.pollen.services.impl.PollenExportService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.UUID; + +/** + * Created on 9/21/14. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.6 + */ +public class ExportDatabase extends PollenActionSupport implements Preparable { + + private static final long serialVersionUID = 1L; + + protected String filename; + + protected File exportFile; + + + /** Shared actionContext to reuse all invocation of this same action. */ + private ActionContext actionContext; + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + public InputStream getInputStream() { + + try { + + return new FileInputStream(exportFile); + + } catch (FileNotFoundException e) { + throw new PollenTechnicalException("Could not find export file: " + exportFile, e); + } + + } + + @Override + public String execute() throws Exception { + + // having the action context here means we already came here, + // now we need to propagate it + ActionContext.setContext(actionContext); + + exportFile = new File(getServiceContext().getConfiguration().getTemporaryDirectory(), UUID.randomUUID().toString()); + exportFile.deleteOnExit(); + getService(PollenExportService.class).exportData(exportFile); + + return SUCCESS; + + } + + @Override + public void prepare() throws Exception { + + if (actionContext == null) { + + // keep it since exec and wait then use another thread + actionContext = ActionContext.getContext(); + + } else { + + // having the action context here means we already came here, + // now we need to propagate it + ActionContext.setContext(actionContext); + + } + + + } +} diff --git a/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ExportDatabaseInput.java b/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ExportDatabaseInput.java new file mode 100644 index 0000000..62a6571 --- /dev/null +++ b/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ExportDatabaseInput.java @@ -0,0 +1,64 @@ +package org.chorem.pollen.ui.actions.admin; + +import org.apache.commons.lang3.StringUtils; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +import java.text.SimpleDateFormat; + +/** + * Created on 9/21/14. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.6 + */ +public class ExportDatabaseInput extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected String filename; + + private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy"); + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + @Override + public String input() throws Exception { + + if (filename == null) { + + filename = String.format("pollen-%s.zip", simpleDateFormat.format(getServiceContext().getCurrentTime())); + } + + return INPUT; + + } + + @Override + public String execute() throws Exception { + + return SUCCESS; + + } + + @Override + public void validate() { + + if (StringUtils.isBlank(filename)) { + addFieldError("filename", _("pollen.error.exportFilename.required")); + } + + } + +// @Override +// public void prepare() throws Exception { +// +// filename = String.format("pollen-%s.zip", simpleDateFormat.format(getServiceContext().getCurrentTime())); +// +// } +} diff --git a/pollen-ui-struts2/src/main/resources/config/struts-admin.xml b/pollen-ui-struts2/src/main/resources/config/struts-admin.xml index 537f458..5878236 100644 --- a/pollen-ui-struts2/src/main/resources/config/struts-admin.xml +++ b/pollen-ui-struts2/src/main/resources/config/struts-admin.xml @@ -71,6 +71,40 @@ <result type="redirect2"/> </action> + <!-- export Database Input --> + <action name="exportDatabaseInput" method="input" + class="org.chorem.pollen.ui.actions.admin.ExportDatabaseInput"> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> + <result name="input">/WEB-INF/jsp/admin/exportDatabase.jsp</result> + </action> + + <!-- export Database --> + <action name="exportDatabase" method="execute" + class="org.chorem.pollen.ui.actions.admin.ExportDatabaseInput"> + <interceptor-ref name="pollenParamsPrepareParamsStack"/> + <result name="input">/WEB-INF/jsp/admin/exportDatabase.jsp</result> + <result name="success" type="redirectAction"> + <param name="namespace">/admin</param> + <param name="actionName">exportDatabaseAction</param> + <param name="filename">${filename}</param> + </result> + </action> + + <!-- export Database (do export) --> + <action name="exportDatabaseAction" method="execute" + class="org.chorem.pollen.ui.actions.admin.ExportDatabase"> + <interceptor-ref name="pollenBasicStack"/> + <interceptor-ref name="execAndWait"> + <param name="delay">2000</param> + </interceptor-ref> + <result name="wait">/WEB-INF/jsp/admin/exportDatabase-wait.jsp</result> + <result name="success" type="stream"> + <param name="contentType">application/zip</param> + <param name="contentDisposition">attachment; filename=${filename}</param> + <param name="contentLength">${fileLength}</param> + </result> + </action> + </package> diff --git a/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties b/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties index 8381488..34757a7 100644 --- a/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties +++ b/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties @@ -32,7 +32,8 @@ pollen.action.editPoll=Edit the poll pollen.action.editPoll.help=Edit this poll pollen.action.editPollAccount=Edit selected member pollen.action.editUser=Edit selected user -pollen.action.editVote=Modifier le vote +pollen.action.editVote=Edit vote +pollen.action.export=Export pollen.action.exportPoll.help=Export this poll (xml format) pollen.action.importPersonListToExistingVotingList=Add selected voting list pollen.action.importPersonListToNewVotingList=Create a new group from the selected voting list @@ -95,6 +96,7 @@ pollen.common.editAction=Edit pollen.common.email=Em@il pollen.common.endChoiceDate=End choice date pollen.common.endDate=End date +pollen.common.exportFilename=Nom du fichier pollen.common.favoriteList.csvImport.help=The file to upload is a text file that contains one row per participant.<br/><br/>Each line must begin by the email of voter.<br/><br/>It can be followed by the voter Id (precede by a space).<br/><br/>If no voterId is given, then the email will be used.<br/><br/>Here is an example\: pollen.common.firstName=First name pollen.common.functions=Functions @@ -177,6 +179,7 @@ pollen.error.comment.text.empty=Comment text mandatory pollen.error.date.format=Date does not match pattern MM/dd/yyyy [hh\:mm] (example 12/31/2000 12\:59) pollen.error.email.invalid=The email doesn't have the good format pollen.error.email.required=You must provide an email +pollen.error.exportFilename.required=Export filename mandatory pollen.error.favoriteList.already.used=List name already used pollen.error.favoriteList.import.participantExists=The email '<strong>%s</strong>' is already used in the list pollen.error.favoriteList.not.found=Favorite list not found @@ -244,6 +247,7 @@ pollen.fieldset.choice.options.help=Configure choices of the poll pollen.fieldset.connexionInformation=Connexion informations pollen.fieldset.creator.options=You pollen.fieldset.creator.options.help=To fill some informations about the creator of this poll +pollen.fieldset.exportDatabase=Configuration pollen.fieldset.login=Login pollen.fieldset.notification.options=Notifications pollen.fieldset.notification.options.help=Configure notifications of this poll @@ -333,6 +337,7 @@ pollen.legend.select.personList.to.create.votingList=Sélectionner la liste des pollen.link.lostPassword=Forget password ? pollen.menu.admin=Administration pollen.menu.createPoll=Create a poll +pollen.menu.exportDatabase=Export Database pollen.menu.home=Home pollen.menu.login=Log in pollen.menu.logout=Log out @@ -367,6 +372,8 @@ pollen.title.delete.pollComment=Delete a poll comment pollen.title.delete.pollVote=Delete a poll vote pollen.title.editFavoriteList=Edit a favorite list pollen.title.editPoll=Edit a poll +pollen.title.exportDatabase=Export Database +pollen.title.exportDatabase.in.progress=Export in progress. pollen.title.favoriteLists=Your favorite lists pollen.title.myAccount=My account pollen.title.pollsCreatedList=Polls created diff --git a/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties b/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties index 0452761..6e049a9 100644 --- a/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties +++ b/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties @@ -33,6 +33,7 @@ pollen.action.editPoll.help=Éditer ce sondage pollen.action.editPollAccount=Editer le membre sélectionné pollen.action.editUser=Editer un utilisateur sélectionné pollen.action.editVote=Modifier le vote +pollen.action.export=Exporter pollen.action.exportPoll.help=Exporter ce sondage au format xml pollen.action.importPersonListToExistingVotingList=Ajouter la liste sélectionnée de votants pollen.action.importPersonListToNewVotingList=Créer un groupe à partir de la liste sélectionnée @@ -96,6 +97,7 @@ pollen.common.editAction=Editer pollen.common.email=Em@il pollen.common.endChoiceDate=Date de fin des choix pollen.common.endDate=Date de fin +pollen.common.exportFilename=Nom du fichier d'export pollen.common.favoriteList.csvImport.help=Le fichier à importer doit être un fichier texte contenant une ligne par participant.<br/><br/>Chaque ligne doit commencer par le courriel du votant.<br/><br/>On peut ensuite ajouter à la suite un nom de votant (précédé d'un espace).<br/><br/>Si le nom du votant n'est pas renseigné alors le courreil sera utilisé.<br/><br/>Voici un exemple \: pollen.common.firstName=Prénom pollen.common.functions=Fonctions @@ -179,6 +181,7 @@ pollen.error.comment.text.empty=Texte du commentaire obligatoire pollen.error.date.format=La date doit être au format jj/MM/aaaa [hh\:mm] (exemple 31/12/2000 23\:59) pollen.error.email.invalid=Email non valide pollen.error.email.required=Email obligatoire +pollen.error.exportFilename.required=Nom du fichier obligatoire pollen.error.favoriteList.already.used=Nom de liste déjà utilisé pollen.error.favoriteList.import.participantExists=L'email '%1$s' est déjà utilisé dans la liste pollen.error.favoriteList.not.found=Liste non trouvée @@ -246,6 +249,7 @@ pollen.fieldset.choice.options.help=Configurer les choix du sondage pollen.fieldset.connexionInformation=Information de connexion pollen.fieldset.creator.options=Vous pollen.fieldset.creator.options.help=Renseigner les informations sur le créateur du sondage +pollen.fieldset.exportDatabase=Configuration pollen.fieldset.login=Connexion pollen.fieldset.notification.options=Notifications pollen.fieldset.notification.options.help=Configurer les notifications du sondage @@ -335,6 +339,7 @@ pollen.legend.select.personList.to.create.votingList=Sélectionner la liste des pollen.link.lostPassword=Mot de passe oublié ? pollen.menu.admin=Administration pollen.menu.createPoll=Créer un sondage +pollen.menu.exportDatabase=Exporter toutes les données pollen.menu.home=Accueil pollen.menu.login=Identifiez-vous pollen.menu.logout=Déconnexion @@ -369,6 +374,8 @@ pollen.title.delete.pollComment=Suppression d'un commentaire pollen.title.delete.pollVote=Suppression d'un vote pollen.title.editFavoriteList=Edition de la liste des favoris pollen.title.editPoll=Modifier un sondage +pollen.title.exportDatabase=Exporter les données +pollen.title.exportDatabase.in.progress=L'export est en cours, merci de patentier. pollen.title.favoriteLists=Vos listes de votants pollen.title.myAccount=Mon compte pollen.title.pollsCreatedList=Sondages créés diff --git a/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp b/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp index 29a367f..da2ed96 100644 --- a/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp +++ b/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp @@ -264,6 +264,11 @@ <s:text name="pollen.menu.manageUsers"/> </s:a> </li> + <li> + <s:a action="exportDatabaseInput" namespace="/admin"> + <s:text name="pollen.menu.exportDatabase"/> + </s:a> + </li> </ul> </div> </li> diff --git a/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/exportDatabase-wait.jsp b/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/exportDatabase-wait.jsp new file mode 100644 index 0000000..b49df5b --- /dev/null +++ b/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/exportDatabase-wait.jsp @@ -0,0 +1,43 @@ +<%-- + #%L + Pollen :: UI (struts2) + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --%> +<%@page contentType="text/html" pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sj" uri="/struts-jquery-tags" %> + +<head> + <meta http-equiv="refresh" content="5;url=<s:url includeParams="all" />"/> +</head> + +<title><s:text name="pollen.title.exportDatabase"/></title> + +<h1 class="title<s:property value='%{pageLogo}'/>"> + <s:text name="pollen.title.exportDatabase"/> +</h1> + +<p> + <s:text name="pollen.title.exportDatabase.in.progress"/> +</p> + + + + diff --git a/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/exportDatabase.jsp b/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/exportDatabase.jsp new file mode 100644 index 0000000..4aa74ad --- /dev/null +++ b/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/exportDatabase.jsp @@ -0,0 +1,45 @@ +<%-- + #%L + Pollen :: UI (struts2) + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --%> +<%@page contentType="text/html" pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sj" uri="/struts-jquery-tags" %> + +<title><s:text name="pollen.title.exportDatabase"/></title> + +<h1 class="title<s:property value='%{pageLogo}'/>"> + <s:text name="pollen.title.exportDatabase"/> +</h1> + +<s:form id='createForm' method="POST" namespace="/admin"> + + <fieldset> + <legend><s:text name="pollen.fieldset.exportDatabase"/></legend> + <s:textfield key="filename" requiredLabel="true" size="40" + label="%{getText('pollen.common.exportFilename')}"/> + </fieldset> + <br/> + <s:submit action="exportDatabase" key="pollen.action.export" align="center"/> +</s:form> + + + -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm