Author: tchemit Date: 2011-12-26 20:47:00 +0100 (Mon, 26 Dec 2011) New Revision: 217 Url: http://forge.codelutin.com/repositories/revision/echobase/217 Log: create exportQuery namespace implements exportDb Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/Configure.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/DownloadExport.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/LaunchExport.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DownloadExportQueryResult.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ExportQueryResult.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/GetExportQueryResult.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ManageExportQuery.java trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml trunk/echobase-ui/src/main/resources/config/struts-exportQuery.xml trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/configure.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/progress.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/result.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQuery.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQueryResult.jsp Removed: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/DownloadExportSqlResult.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSqlResult.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/GetSqlResult.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/LaunchImport.java trunk/echobase-ui/src/main/resources/config/struts-export.xml trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties trunk/echobase-ui/src/main/resources/struts.xml trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-12-26 19:47:00 UTC (rev 217) @@ -24,6 +24,7 @@ package fr.ifremer.echobase.ui; import fr.ifremer.echobase.entities.EchoBaseUser; +import fr.ifremer.echobase.services.ExportDbConfiguration; import fr.ifremer.echobase.services.ImportDataConfiguration; import fr.ifremer.echobase.services.ImportDbConfiguration; import org.apache.commons.logging.Log; @@ -52,6 +53,9 @@ /** Key to keep import db configuration in this session. */ protected static final String PROPERTY_IMPORT_DB_CONFIGURATION = "importDbConfiguration"; + /** Key to keep export db configuration in this session. */ + protected static final String PROPERTY_EXPORT_DB_CONFIGURATION = "exportDbConfiguration"; + /** To store all properties in this session. */ protected Map<String, Object> store; @@ -89,6 +93,14 @@ set(PROPERTY_IMPORT_DB_CONFIGURATION, configuration); } + public ExportDbConfiguration getExportDbConfiguration() { + return get(PROPERTY_EXPORT_DB_CONFIGURATION, ExportDbConfiguration.class); + } + + public void setExportDbConfiguration(ExportDbConfiguration configuration) { + set(PROPERTY_EXPORT_DB_CONFIGURATION, configuration); + } + /** * Remove form this session, the object from his given key and returns it. * @@ -133,7 +145,7 @@ if (o != null && !type.isInstance(o)) { throw new ClassCastException( "parameter " + key + " should be of type " + - type.getName() + " but was " + o.getClass().getName()); + type.getName() + " but was " + o.getClass().getName()); } return (T) o; } Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/DownloadExportSqlResult.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/DownloadExportSqlResult.java 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/DownloadExportSqlResult.java 2011-12-26 19:47:00 UTC (rev 217) @@ -1,93 +0,0 @@ -/* - * #%L - * EchoBase :: UI - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * 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% - */ -package fr.ifremer.echobase.ui.actions.export; - -import fr.ifremer.echobase.services.ExportSqlService; -import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -/** - * Download the result of sql request in csv format. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class DownloadExportSqlResult extends EchoBaseActionSupport { - - private static final long serialVersionUID = 1L; - - /** Sql request to execute. */ - protected String sql; - - /** Input stream of the file to download. */ - protected transient InputStream inputStream; - - /** File name of the download. */ - protected String fileName; - - /** Length of the file to download. */ - protected int contentLength; - - /** Content type of the file to download. */ - protected String contentType; - - public void setSql(String sql) { - this.sql = sql; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public InputStream getInputStream() { - return inputStream; - } - - public String getFileName() { - return fileName; - } - - public int getContentLength() { - return contentLength; - } - - public String getContentType() { - return contentType; - } - - @Override - public String execute() throws Exception { - - ExportSqlService service = newService(ExportSqlService.class); - - contentType = "text/csv"; - String content = service.createCsvFileContent(sql); - contentLength = content.length(); - inputStream = new ByteArrayInputStream(content.getBytes()); - - return SUCCESS; - } -} Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSqlResult.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSqlResult.java 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSqlResult.java 2011-12-26 19:47:00 UTC (rev 217) @@ -1,83 +0,0 @@ -/* - * #%L - * EchoBase :: UI - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * 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% - */ -package fr.ifremer.echobase.ui.actions.export; - -import fr.ifremer.echobase.EchoBaseTechnicalException; -import fr.ifremer.echobase.services.ExportSqlService; -import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; - -/** - * Load export sql result fragment page. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class ExportSqlResult extends EchoBaseActionSupport { - - private static final long serialVersionUID = 1L; - - /** Sql request to execute. */ - protected String sql; - - /** Default file name for export. */ - protected String fileName; - - /** names of columns from the executed sql request. */ - protected String[] columnNames; - - public String getSql() { - return sql; - } - - public String[] getColumnNames() { - return columnNames; - } - - public String getFileName() { - return fileName; - } - - public void setSql(String sql) { - this.sql = sql; - } - - @Override - public String execute() throws Exception { - - // obtain columNames from the request - ExportSqlService service = newService(ExportSqlService.class); - - try { - columnNames = service.getColumnNames(sql); - } catch (EchoBaseTechnicalException e) { - //TODO add a real nice message - addActionError(e.getMessage()); - } - - // create default file name - - fileName = "export.csv"; - return SUCCESS; - } -} Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/GetSqlResult.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/GetSqlResult.java 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/GetSqlResult.java 2011-12-26 19:47:00 UTC (rev 217) @@ -1,81 +0,0 @@ -/* - * #%L - * EchoBase :: UI - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * 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% - */ -package fr.ifremer.echobase.ui.actions.export; - -import fr.ifremer.echobase.services.ExportSqlService; -import fr.ifremer.echobase.ui.actions.AbstractJSONPaginedAction; - -import java.util.Map; - -/** - * Obtains result of a sql query. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class GetSqlResult extends AbstractJSONPaginedAction { - - private static final long serialVersionUID = 1L; - - /** Sql request to execute. */ - protected String sql; - - /** Datas of the given table. */ - protected Map<?, ?>[] datas; - - public void setSql(String sql) { - this.sql = sql; - } - - public Map<?, ?>[] getDatas() { - return datas; - } - - @Override - public Integer getRows() { - return pager.getPageSize(); - } - - @Override - public Integer getPage() { - return pager.getPageNumber(); - } - - @Override - public Integer getTotal() { - return pager.getPageCount(); - } - - @Override - public Integer getRecords() { - return pager.getRecords(); - } - - @Override - public String execute() throws Exception { - ExportSqlService service = newService(ExportSqlService.class); - datas = service.executeSql(sql, pager); - return SUCCESS; - } -} Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-12-26 19:47:00 UTC (rev 217) @@ -1,125 +0,0 @@ -/* - * #%L - * EchoBase :: UI - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * 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% - */ -package fr.ifremer.echobase.ui.actions.export; - -import com.opensymphony.xwork2.Preparable; -import fr.ifremer.echobase.entities.ExportQuery; -import fr.ifremer.echobase.entities.ExportQueryImpl; -import fr.ifremer.echobase.services.ExportSqlService; -import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; -import org.apache.commons.lang3.StringUtils; - -import java.util.Collection; -import java.util.Map; - -/** - * To manage {@link ExportQuery}. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class ManageExportQuery extends EchoBaseActionSupport implements Preparable { - - private static final long serialVersionUID = 1L; - - /** All available queries from database. */ - protected Map<String, String> queries; - - /** Selected query loaded from database if his id is not empty. */ - protected ExportQuery query; - - public ExportQuery getQuery() { - if (query == null) { - query = new ExportQueryImpl(); - } - return query; - } - - public Map<String, String> getQueries() { - return queries; - } - - public Map<String, String> getTableNames() { - return queries; - } - - public String saveQuery() throws Exception { - - //TODO : do validation - ExportSqlService service = newService(ExportSqlService.class); - - query = service.createOrUpdate(getQuery(), - getEchoBaseSession().getEchoBaseUser() - ); - return SUCCESS; - } - - public String cloneQuery() throws Exception { - - //TODO : do validation - ExportSqlService service = newService(ExportSqlService.class); - - getQuery().setTopiaId(null); - query = service.createOrUpdate(getQuery(), - getEchoBaseSession().getEchoBaseUser() - ); - return SUCCESS; - } - - public String deleteQuery() throws Exception { - - //TODO : do validation - ExportSqlService service = newService(ExportSqlService.class); - service.delete(getQuery().getTopiaId()); - query = null; - return SUCCESS; - } - - @Override - public void prepare() throws Exception { - ExportSqlService service = newService(ExportSqlService.class); - - Collection<ExportQuery> sqlQueries = - service.getEntities(ExportQuery.class); - queries = sortAndDecorate(sqlQueries, null); - - if (sqlQueries.isEmpty()) { - // no query saved - addActionMessage(_("echobase.info.no.sqlQuery.saved")); - } else { - - String selectedQueryId = getQuery().getTopiaId(); - - if (StringUtils.isEmpty(selectedQueryId)) { - - // no query selected - addActionMessage(_("echobase.info.no.sqlQuery.selected")); - } else { - - // load query from database - query = service.getEntityById(ExportQuery.class, selectedQueryId); - } - } - } -} \ No newline at end of file Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/Configure.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/Configure.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/Configure.java 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,89 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * 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% + */ +package fr.ifremer.echobase.ui.actions.exportDb; + +import fr.ifremer.echobase.services.ExportDbConfiguration; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.FileUtil; + +import java.io.File; + +/** + * Configure the complete db export. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class Configure extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = LogFactory.getLog(Configure.class); + + protected ExportDbConfiguration model; + + public ExportDbConfiguration getModel() { + if (model == null) { + model = new ExportDbConfiguration(); + model.setFileName("echobase"); + } + return model; + } + + public void setFileName(String fileName) { + getModel().setFileName(fileName); + } + + @Override + public String input() throws Exception { + + // always remove configuration from session anytime coming here + getEchoBaseSession().setExportDbConfiguration(null); + return INPUT; + } + + @Override + public String execute() throws Exception { + + ExportDbConfiguration configuration = getModel(); + + File tempDirectory = FileUtils.getTempDirectory(); + File dataDirectory = new File( + tempDirectory, + "echobase-exportDb-" + System.currentTimeMillis()); + FileUtil.createDirectoryIfNecessary(dataDirectory); + configuration.setWorkingDirectory(dataDirectory); + if (log.isInfoEnabled()) { + log.info("Temporary directory to use : " + dataDirectory); + } + + // store configuration in session + getEchoBaseSession().setExportDbConfiguration(configuration); + return SUCCESS; + } +} \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/Configure.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/DownloadExport.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/DownloadExport.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/DownloadExport.java 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,96 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * 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% + */ +package fr.ifremer.echobase.ui.actions.exportDb; + +import fr.ifremer.echobase.services.ExportDbConfiguration; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +/** + * Download the result of the complete db export. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class DownloadExport extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Input stream of the file to download. */ + protected transient InputStream inputStream; + + /** File name of the download. */ + protected String fileName; + + /** Length of the file to download. */ + protected long contentLength; + + /** Content type of the file to download. */ + protected String contentType; + + public InputStream getInputStream() { + return inputStream; + } + + public String getFileName() { + return fileName; + } + + public long getContentLength() { + return contentLength; + } + + public String getContentType() { + return contentType; + } + + @Override + public String execute() throws Exception { + + ExportDbConfiguration model = + getEchoBaseSession().getExportDbConfiguration(); + + if (model == null) { + addActionError(_("echobase.error.no.dbExport.configurationFound")); + return ERROR; + } + + File exportFile = model.getExportFile(); + if (exportFile == null) { + addActionError(_("echobase.error.no.dbExport.exportFileFound")); + return ERROR; + } + + fileName = exportFile.getName(); + contentType = "zip"; + contentLength = exportFile.length(); + inputStream = new BufferedInputStream(new FileInputStream(exportFile)); + + return SUCCESS; + } +} \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/DownloadExport.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/LaunchExport.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/LaunchExport.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/LaunchExport.java 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,125 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * 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% + */ +package fr.ifremer.echobase.ui.actions.exportDb; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.Preparable; +import fr.ifremer.echobase.services.CsvImportResult; +import fr.ifremer.echobase.services.DbExportService; +import fr.ifremer.echobase.services.ExportDbConfiguration; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.framework.TopiaContextImplementor; + +import java.util.Date; + +/** + * Launch the complete db export. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class LaunchExport extends EchoBaseActionSupport implements Preparable { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = LogFactory.getLog(LaunchExport.class); + + /** Configuration of the export action. */ + protected ExportDbConfiguration model; + + /** Result of import. */ + protected CsvImportResult importResult; + + /** service to execute the export. */ + protected transient DbExportService service; + + /** Shared actionContext to reuse all invocation of this same action. */ + protected ActionContext actionContext; + + public ExportDbConfiguration getModel() { + return model; + } + + @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); + } + model = getEchoBaseSession().getExportDbConfiguration(); + + service = newService(DbExportService.class); + } + + @Override + public String execute() throws Exception { + + model.setStartTime(new Date()); + + // having the action context here means we already came here, + // now we need to propagate it + ActionContext.setContext(actionContext); + + // we must use a standalone transaction since it will pass through + // in more than one request + + TopiaContextImplementor tx = + (TopiaContextImplementor) serviceContext.getTransaction(); + TopiaContextImplementor rootContext = tx.getRootContext(); + TopiaContext topiaContext = rootContext.beginTransaction(); + serviceContext.setTransaction(topiaContext); + try { + + if (log.isInfoEnabled()) { + log.info("Start export to file " + model.getFileName()); + } + + service.exportDb(model); + model.setEndTime(new Date()); + + return SUCCESS; + } finally { + + topiaContext.closeContext(); + +// // clean configuration +// model.destroy(); + + // remove configuration from session +// getEchoBaseSession().setExportDbConfiguration(null); + } + } + +} \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportDb/LaunchExport.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DownloadExportQueryResult.java (from rev 211, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/DownloadExportSqlResult.java) =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DownloadExportQueryResult.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DownloadExportQueryResult.java 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,93 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * 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% + */ +package fr.ifremer.echobase.ui.actions.exportQuery; + +import fr.ifremer.echobase.services.ExportQueryService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +/** + * Download the result of sql request in csv format. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class DownloadExportQueryResult extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Sql request to execute. */ + protected String sql; + + /** Input stream of the file to download. */ + protected transient InputStream inputStream; + + /** File name of the download. */ + protected String fileName; + + /** Length of the file to download. */ + protected int contentLength; + + /** Content type of the file to download. */ + protected String contentType; + + public void setSql(String sql) { + this.sql = sql; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public InputStream getInputStream() { + return inputStream; + } + + public String getFileName() { + return fileName; + } + + public int getContentLength() { + return contentLength; + } + + public String getContentType() { + return contentType; + } + + @Override + public String execute() throws Exception { + + ExportQueryService service = newService(ExportQueryService.class); + + contentType = "text/csv"; + String content = service.createCsvFileContent(sql); + contentLength = content.length(); + inputStream = new ByteArrayInputStream(content.getBytes()); + + return SUCCESS; + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DownloadExportQueryResult.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ExportQueryResult.java (from rev 211, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSqlResult.java) =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ExportQueryResult.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ExportQueryResult.java 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,91 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * 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% + */ +package fr.ifremer.echobase.ui.actions.exportQuery; + +import fr.ifremer.echobase.EchoBaseTechnicalException; +import fr.ifremer.echobase.services.ExportQueryService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Load export sql result fragment page. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class ExportQueryResult extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = LogFactory.getLog(ExportQueryResult.class); + + /** Sql request to execute. */ + protected String sql; + + /** Default file name for export. */ + protected String fileName; + + /** names of columns from the executed sql request. */ + protected String[] columnNames; + + public String getSql() { + return sql; + } + + public String[] getColumnNames() { + return columnNames; + } + + public String getFileName() { + return fileName; + } + + public void setSql(String sql) { + this.sql = sql; + } + + @Override + public String execute() throws Exception { + + // obtain columNames from the request + ExportQueryService service = newService(ExportQueryService.class); + + try { + columnNames = service.getColumnNames(sql); + } catch (EchoBaseTechnicalException e) { + //TODO add a real nice message + addActionError(e.getMessage()); + if (log.isErrorEnabled()) { + log.error("coudl not execute query " + sql, e); + } + } + + // create default file name + + fileName = "export.csv"; + return SUCCESS; + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ExportQueryResult.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/GetExportQueryResult.java (from rev 211, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/GetSqlResult.java) =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/GetExportQueryResult.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/GetExportQueryResult.java 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,81 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * 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% + */ +package fr.ifremer.echobase.ui.actions.exportQuery; + +import fr.ifremer.echobase.services.ExportQueryService; +import fr.ifremer.echobase.ui.actions.AbstractJSONPaginedAction; + +import java.util.Map; + +/** + * Obtains result of a sql query. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class GetExportQueryResult extends AbstractJSONPaginedAction { + + private static final long serialVersionUID = 1L; + + /** Sql request to execute. */ + protected String sql; + + /** Datas of the given table. */ + protected Map<?, ?>[] datas; + + public void setSql(String sql) { + this.sql = sql; + } + + public Map<?, ?>[] getDatas() { + return datas; + } + + @Override + public Integer getRows() { + return pager.getPageSize(); + } + + @Override + public Integer getPage() { + return pager.getPageNumber(); + } + + @Override + public Integer getTotal() { + return pager.getPageCount(); + } + + @Override + public Integer getRecords() { + return pager.getRecords(); + } + + @Override + public String execute() throws Exception { + ExportQueryService service = newService(ExportQueryService.class); + datas = service.executeSql(sql, pager); + return SUCCESS; + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/GetExportQueryResult.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ManageExportQuery.java (from rev 211, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java) =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ManageExportQuery.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ManageExportQuery.java 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,125 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * 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% + */ +package fr.ifremer.echobase.ui.actions.exportQuery; + +import com.opensymphony.xwork2.Preparable; +import fr.ifremer.echobase.entities.ExportQuery; +import fr.ifremer.echobase.entities.ExportQueryImpl; +import fr.ifremer.echobase.services.ExportQueryService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collection; +import java.util.Map; + +/** + * To manage {@link ExportQuery}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class ManageExportQuery extends EchoBaseActionSupport implements Preparable { + + private static final long serialVersionUID = 1L; + + /** All available queries from database. */ + protected Map<String, String> queries; + + /** Selected query loaded from database if his id is not empty. */ + protected ExportQuery query; + + public ExportQuery getQuery() { + if (query == null) { + query = new ExportQueryImpl(); + } + return query; + } + + public Map<String, String> getQueries() { + return queries; + } + + public Map<String, String> getTableNames() { + return queries; + } + + public String saveQuery() throws Exception { + + //TODO : do validation + ExportQueryService service = newService(ExportQueryService.class); + + query = service.createOrUpdate(getQuery(), + getEchoBaseSession().getEchoBaseUser() + ); + return SUCCESS; + } + + public String cloneQuery() throws Exception { + + //TODO : do validation + ExportQueryService service = newService(ExportQueryService.class); + + getQuery().setTopiaId(null); + query = service.createOrUpdate(getQuery(), + getEchoBaseSession().getEchoBaseUser() + ); + return SUCCESS; + } + + public String deleteQuery() throws Exception { + + //TODO : do validation + ExportQueryService service = newService(ExportQueryService.class); + service.delete(getQuery().getTopiaId()); + query = null; + return SUCCESS; + } + + @Override + public void prepare() throws Exception { + ExportQueryService service = newService(ExportQueryService.class); + + Collection<ExportQuery> sqlQueries = + service.getEntities(ExportQuery.class); + queries = sortAndDecorate(sqlQueries, null); + + if (sqlQueries.isEmpty()) { + // no query saved + addActionMessage(_("echobase.info.no.sqlQuery.saved")); + } else { + + String selectedQueryId = getQuery().getTopiaId(); + + if (StringUtils.isEmpty(selectedQueryId)) { + + // no query selected + addActionMessage(_("echobase.info.no.sqlQuery.selected")); + } else { + + // load query from database + query = service.getExportQuery(selectedQueryId); + } + } + } +} \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ManageExportQuery.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/LaunchImport.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/LaunchImport.java 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/LaunchImport.java 2011-12-26 19:47:00 UTC (rev 217) @@ -34,6 +34,8 @@ import org.nuiton.topia.TopiaContext; import org.nuiton.topia.framework.TopiaContextImplementor; +import java.util.Date; + /** * Start the import db. * @@ -71,7 +73,7 @@ actionContext = ActionContext.getContext(); } else { - // having the action cotnext here means we laready came here, + // having the action context here means we already came here, // now we need to propagate it ActionContext.setContext(actionContext); } @@ -83,7 +85,9 @@ @Override public String execute() throws Exception { - // having the action cotnext here means we laready came here, + model.setStartTime(new Date()); + + // having the action context here means we already came here, // now we need to propagate it ActionContext.setContext(actionContext); @@ -103,6 +107,7 @@ } service.importDb(model, getEchoBaseSession().getEchoBaseUser()); + model.setEndTime(new Date()); return SUCCESS; } finally { topiaContext.closeContext(); Modified: trunk/echobase-ui/src/main/resources/config/struts-export.xml =================================================================== --- trunk/echobase-ui/src/main/resources/config/struts-export.xml 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/resources/config/struts-export.xml 2011-12-26 19:47:00 UTC (rev 217) @@ -31,76 +31,12 @@ <package name="export" extends="loggued" namespace="/export"> - <result-types> - <result-type name="redirectExportSql" - class="org.apache.struts2.dispatcher.ServletActionRedirectResult"> - <param name="actionName">exportSql</param> - <param name="namespace">export</param> - <param name="query.topiaId">${query.topiaId}</param> - </result-type> - - </result-types> - - <!-- Display export sql main page --> - <action name="exportSql" method="input" - class="fr.ifremer.echobase.ui.actions.export.ManageExportQuery"> - <interceptor-ref name="paramsPrepareParamsStackLoggued"/> - <result name="input">/WEB-INF/jsp/export/exportSql.jsp</result> - </action> - - <!-- Display the result of the sql query execution --> - <action name="exportSqlResult" - class="fr.ifremer.echobase.ui.actions.export.ExportSqlResult"> - <result>/WEB-INF/jsp/export/exportSqlResult.jsp</result> - </action> - <!-- Display the create embedded application main page --> <action name="createEmbeddedApplication" class="fr.ifremer.echobase.ui.actions.export.CreateEmbeddedApplication"> <result>/WEB-INF/jsp/export/createEmbeddedApplication.jsp</result> </action> - <!-- Get result of the sql query execution --> - <action name="getExportSqlResult" - class="fr.ifremer.echobase.ui.actions.export.GetSqlResult"> - <result type="json"/> - </action> - - <!-- Clone the sql query --> - <action name="cloneExportQuery" method="cloneQuery" - class="fr.ifremer.echobase.ui.actions.export.ManageExportQuery"> - <interceptor-ref name="paramsPrepareParamsStackLoggued"/> - <result name="input">/WEB-INF/jsp/export/exportSql.jsp</result> - <result type="redirectExportSql"/> - </action> - - <!-- Save the sql query --> - <action name="saveExportQuery" method="saveQuery" - class="fr.ifremer.echobase.ui.actions.export.ManageExportQuery"> - <interceptor-ref name="paramsPrepareParamsStackLoggued"/> - <result name="input">/WEB-INF/jsp/export/exportSql.jsp</result> - <result type="redirectExportSql"/> - </action> - - <!-- Delete the sql query --> - <action name="deleteExportQuery" method="deleteQuery" - class="fr.ifremer.echobase.ui.actions.export.ManageExportQuery"> - <interceptor-ref name="paramsPrepareParamsStackLoggued"/> - <result name="input">/WEB-INF/jsp/export/exportSql.jsp</result> - <result type="redirectExportSql"/> - </action> - - <!-- Download the sql query csv file --> - <action name="downloadExportSqlResult" - class="fr.ifremer.echobase.ui.actions.export.DownloadExportSqlResult"> - <interceptor-ref name="paramsPrepareParamsStackLoggued"/> - <result type="stream"> - <param name="contentType">${contentType}</param> - <param name="contentLength">${contentLength}</param> - <param name="contentDisposition">filename="${fileName}"</param> - </result> - </action> - <!-- Download the embedded application zip file --> <action name="downloadEmbeddedApplication" class="fr.ifremer.echobase.ui.actions.export.DownloadEmbeddedApplication"> Added: trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml =================================================================== --- trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + 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% + --> +<!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" + "http://struts.apache.org/dtds/struts-2.1.7.dtd"> + +<struts> + + <package name="exportDb" extends="loggued" namespace="/exportDb"> + + <!-- Configure export --> + <action name="configureExport" + class="fr.ifremer.echobase.ui.actions.exportDb.Configure"> + <interceptor-ref name="paramsPrepareParamsStackLoggued"/> + <result name="input">/WEB-INF/jsp/exportDb/configure.jsp</result> + <result type="redirectAction"> + <param name="namespace">/exportDb</param> + <param name="actionName">doExport</param> + </result> + </action> + + <!-- Starts export --> + <action name="doExport" + class="fr.ifremer.echobase.ui.actions.exportDb.LaunchExport" + method="execute"> + <interceptor-ref name="basicStackLoggued"/> + <interceptor-ref name="execAndWait"/> + <result name="wait">/WEB-INF/jsp/exportDb/progress.jsp</result> + <result>/WEB-INF/jsp/exportDb/result.jsp</result> + </action> + + <!-- Download the export --> + <action name="downloadExport" + class="fr.ifremer.echobase.ui.actions.exportDb.DownloadExport"> + <interceptor-ref name="paramsPrepareParamsStackLoggued"/> + <result type="stream"> + <param name="contentType">${contentType}</param> + <param name="contentLength">${contentLength}</param> + <param name="contentDisposition">filename="${fileName}"</param> + </result> + </action> + + </package> + +</struts> + Property changes on: trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/resources/config/struts-exportQuery.xml =================================================================== --- trunk/echobase-ui/src/main/resources/config/struts-exportQuery.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/config/struts-exportQuery.xml 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + 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% + --> + +<!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" + "http://struts.apache.org/dtds/struts-2.1.7.dtd"> + +<struts> + + <package name="exportQuery" extends="loggued" namespace="/exportQuery"> + + <result-types> + <result-type name="redirectExportQuery" + class="org.apache.struts2.dispatcher.ServletActionRedirectResult"> + <param name="actionName">manageExportQuery</param> + <param name="namespace">export</param> + <param name="query.topiaId">${query.topiaId}</param> + </result-type> + + </result-types> + + <!-- Display export query main page --> + <action name="manageExportQuery" method="input" + class="fr.ifremer.echobase.ui.actions.exportQuery.ManageExportQuery"> + <interceptor-ref name="paramsPrepareParamsStackLoggued"/> + <result name="input">/WEB-INF/jsp/exportQuery/exportQuery.jsp</result> + </action> + + <!-- Display the result of the export query execution --> + <action name="exportQueryResult" + class="fr.ifremer.echobase.ui.actions.exportQuery.ExportQueryResult"> + <result>/WEB-INF/jsp/exportQuery/exportQueryResult.jsp</result> + </action> + + <!-- Get result of the export query execution --> + <action name="getExportQueryResult" + class="fr.ifremer.echobase.ui.actions.exportQuery.GetExportQueryResult"> + <result type="json"/> + </action> + + <!-- Clone the export query --> + <action name="cloneExportQuery" method="cloneQuery" + class="fr.ifremer.echobase.ui.actions.exportQuery.ManageExportQuery"> + <interceptor-ref name="paramsPrepareParamsStackLoggued"/> + <result name="input">/WEB-INF/jsp/exportQuery/exportQuery.jsp</result> + <result type="redirectExportQuery"/> + </action> + + <!-- Save the export query --> + <action name="saveExportQuery" method="saveQuery" + class="fr.ifremer.echobase.ui.actions.exportQuery.ManageExportQuery"> + <interceptor-ref name="paramsPrepareParamsStackLoggued"/> + <result name="input">/WEB-INF/jsp/exportQuery/exportQuery.jsp</result> + <result type="redirectExportQuery"/> + </action> + + <!-- Delete the export query --> + <action name="deleteExportQuery" method="deleteQuery" + class="fr.ifremer.echobase.ui.actions.exportQuery.ManageExportQuery"> + <interceptor-ref name="paramsPrepareParamsStackLoggued"/> + <result name="input">/WEB-INF/jsp/exportQuery/exportQuery.jsp</result> + <result type="redirectExportQuery"/> + </action> + + <!-- Download the sql query csv file --> + <action name="downloadExportQueryResult" + class="fr.ifremer.echobase.ui.actions.exportQuery.DownloadExportQueryResult"> + <interceptor-ref name="paramsPrepareParamsStackLoggued"/> + <result type="stream"> + <param name="contentType">${contentType}</param> + <param name="contentLength">${contentLength}</param> + <param name="contentDisposition">filename="${fileName}"</param> + </result> + </action> + + </package> + +</struts> + Property changes on: trunk/echobase-ui/src/main/resources/config/struts-exportQuery.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties =================================================================== --- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-12-26 19:47:00 UTC (rev 217) @@ -5,6 +5,8 @@ echobase.action.createEmbeddedApplication=Créer l'application echobase.action.delete=Suppression echobase.action.deleteSqlQuery=Supprimer la requête +echobase.action.downloadExportDbFile=Télécharger le fichier d'export de la base complête +echobase.action.export=Exporter echobase.action.exportSqlData=Exporter les données echobase.action.exportTable=Exporter echobase.action.import=Importer @@ -50,6 +52,8 @@ echobase.error.login.password.requiredstring=Le mot de passe est obligatoire echobase.error.login.unknown=Utilisateur inconnu echobase.error.login.wrongLogin=Le login est déjà utilisé +echobase.error.no.dbExport.configurationFound= +echobase.error.no.dbExport.exportFileFound= echobase.error.required.email=L'email est obligatoire echobase.error.required.password=Le mot de passe est obligatoire echobase.error.warlocation.notFound=L'application n'a pas été trouvé à l'emplacement suivant %s @@ -63,6 +67,7 @@ echobase.label.createIfNotFound=Créer les entités non trouvées en base echobase.label.embeddedApplicationFileName=Nom de l'archive à télécharger echobase.label.embeddedWarFileName=Nom du war à utiliser +echobase.label.exportDbFileName=Nom du fichier d'export echobase.label.exportFileName=Nom du fichier d'export echobase.label.import.access=Base access echobase.label.import.accoustique=Fichier accoustique @@ -86,6 +91,7 @@ echobase.label.voyageToSelect=Voyage à exporter echobase.legend.dbeditor.edit=Edition de '%s' echobase.legend.embeddedApplication.configuration=Configuration de l'application embarquée +echobase.legend.exportDb.configuration.files=Configuration de l'export echobase.legend.importData.configuration.files=Choix des fichiers d'import echobase.legend.importData.configuration.mission=Configurer la mission echobase.legend.importData.configuration.mission.resume=Résumé de la mission à utiliser @@ -97,6 +103,7 @@ echobase.menu.createEmbeddedApplication=Créer une application embarquée echobase.menu.dbeditor=Modifier les données echobase.menu.export=Exporter des données +echobase.menu.exportDb=Exporter une base complête echobase.menu.importData=Importer des données echobase.menu.importDb=Importer une base complête echobase.menu.logs=Visualiser les modifications @@ -105,6 +112,7 @@ echobase.message.modified.property=Propriété '%s', ancienne valeur \: %s, nouvelle valeur \: %s echobase.message.no.row.selected=Aucune donnée sélectionnée echobase.message.noEntrySelection=Aucune entrée sélectionnée +echobase.message.warnExportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de l'export. echobase.message.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de l'import. echobase.title.admin.user.create=Création d'un utilisateur echobase.title.admin.user.delete=Suppression d'un utilisateur @@ -115,6 +123,9 @@ echobase.title.dbEditor=Modification de la base echobase.title.entityModificationLogs=Journal des modifications echobase.title.export=Export +echobase.title.exportDb=Export complet de la base +echobase.title.exportDbProgress=Export complêt de la base de données en cours +echobase.title.exportDbResult=Résultat de l'export complêt de la base de données echobase.title.exportTable=Exporter une table echobase.title.importData=Import de données echobase.title.importData.configuration=Configuration d'un import de données Modified: trunk/echobase-ui/src/main/resources/struts.xml =================================================================== --- trunk/echobase-ui/src/main/resources/struts.xml 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/resources/struts.xml 2011-12-26 19:47:00 UTC (rev 217) @@ -132,8 +132,11 @@ <include file="config/struts-dbeditor.xml"/> <include file="config/struts-user.xml"/> <include file="config/struts-importData.xml"/> - <include file="config/struts-importDb.xml"/> <include file="config/struts-export.xml"/> + <include file="config/struts-exportQuery.xml"/> + <include file="config/struts-importDb.xml"/> + <include file="config/struts-exportDb.xml"/> + </struts> Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2011-12-26 19:47:00 UTC (rev 217) @@ -31,7 +31,7 @@ <pattern>/index*</pattern> <pattern>/dbeditor/getForeignEntities*</pattern> <pattern>/dbeditor/doExport*</pattern> - <pattern>/export/exportSqlResult*</pattern> + <pattern>/exportQuery/exportQueryResult*</pattern> </excludes> <decorator name="layout-default" page="layout-default.jsp"> Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -59,13 +59,17 @@ <s:a action="configureImport" namespace="/importDb" method="input"> <s:text name="echobase.menu.importDb"/></s:a> </li> + <li> + <s:a action="configureExport" namespace="/exportDb" method="input"> + <s:text name="echobase.menu.exportDb"/></s:a> + </li> </s:if> <li> <s:a action="configureMission" namespace="/importData" method="input"> <s:text name="echobase.menu.importData"/></s:a> </li> <li> - <s:a action="exportSql" namespace="/export"> + <s:a action="manageExportQuery" namespace="/exportQuery"> <s:text name="echobase.menu.export"/> </s:a> </li> Deleted: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -1,136 +0,0 @@ -<%-- - #%L - EchoBase :: UI - - $Id$ - $HeadURL$ - %% - Copyright (C) 2011 Ifremer, Codelutin - %% - 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" %> - -<s:url id="reloadUrl" action='exportSql' namespace='/export'/> -<s:url id="exportSqlResultUrl" action="exportSqlResult" namespace="/export"/> -<s:set var="noError" value="!hasErrors()"/> -<script type="text/javascript"> - - function reloadQuery() { - var queryId = $('[name="query.topiaId"]').val(); - var url = "${reloadUrl}?" + $.param({ 'query.topiaId':queryId}); - window.location = url; - return false; - } - - function loadGridData() { - // get sql query - var sqlQuery = "${exportSqlResultUrl}?" + - $.param({ sql :$('[name="query.sqlQuery"]').val()}); - - $.ajax(sqlQuery, { - success: function(data, textStatus, jqXHR) { - $('#resultGrid').html(data); - } - }); - return false; - } - - jQuery(document).ready(function () { - - $('[name="query.topiaId"]').change(function(event) { - var url = "${reloadUrl}?" + $.param({ 'query.topiaId':this.value}); - window.location = url; - }); - - var queryId = $('[name="query.topiaId"]').val(); - if (queryId && ${noError}) { - // auto launch query - loadGridData(); - } - - }); - - -</script> - -<title><s:text name="echobase.title.export"/></title> - -<s:set var="queryExists" value="query.topiaId != null && query.topiaId != ''"/> - -<s:form id="exportQueryForm" namespace="/export"> - - <s:select key="query.topiaId" label="%{getText('echobase.label.sqlQueries')}" - list="queries" headerKey="" headerValue=""/> - - <br/> - - <fieldset> - <legend><s:text name="echobase.legend.sqlQuery.configuration"/></legend> - - <s:textarea key="query.name" required="true" cols="160" rows="1" - label="%{getText('echobase.label.query.name')}"/> - - <s:textarea key="query.description" required="true" cols="160" rows="2" - label="%{getText('echobase.label.query.description')}"/> - - <s:textarea key="query.sqlQuery" required="true" cols="160" rows="4" - label="%{getText('echobase.label.query.sql')}"/> - - <s:if test="queryExists"> - - <s:label value="%{query.lastModifiedDate}" readonly="true" - label="%{getText('echobase.common.lastModifiedDate')}"/> - - <s:label value="%{query.lastModifiedUser}" readonly="true" - label="%{getText('echobase.common.lastModifiedUser')}"/> - - </s:if> - - - <ul class="toolbar floatRight"> - <s:if test="queryExists"> - <li> - <s:submit onclick="return reloadQuery();" theme="simple" - key="echobase.action.reloadSqlQuery"/> - </li> - <li> - <s:submit action="cloneExportQuery" theme="simple" - key="echobase.action.cloneSqlQuery"/> - </li> - <li> - <s:submit action="deleteExportQuery" theme="simple" - key="echobase.action.deleteSqlQuery"/> - </li> - </s:if> - <li> - <s:submit action="saveExportQuery" theme="simple" - key="echobase.action.saveSqlQuery"/> - </li> - <li> - <s:submit key="echobase.action.applySqlQuery" theme="simple" - onclick="return loadGridData();"/> - </li> - </ul> - </fieldset> -</s:form> - -<br/> - -<div id="resultGrid" class="cleanBoth"></div> - - Deleted: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -1,72 +0,0 @@ -<%-- - #%L - EchoBase :: UI - - $Id$ - $HeadURL$ - %% - Copyright (C) 2011 Ifremer, Codelutin - %% - 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" %> -<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %> - -<s:if test="hasActionErrors()"> - <div class="info_error"> - <s:actionerror/> - </div> -</s:if> -<s:else> - <s:url id="loadUrl" action="getExportSqlResult" namespace="/export" - escapeAmp="false"> - <s:param name="sql" value="%{sql}"/> - </s:url> - - <s:form action="downloadExportSqlResult" namespace="/export"> - - <fieldset> - <legend><s:text name="echobase.legend.sqlQuery.result"/></legend> - - <s:hidden key="sql" label=""/> - <s:textfield key="fileName" required="true" size="100" - label="%{getText('echobase.label.exportFileName')}"/> - <s:submit value="%{getText('echobase.action.exportSqlData')}" align="left"/> - <br/> - <sjg:grid id="rows" caption="%{getText('echobase.header.request.result')}" - dataType="json" href="%{loadUrl}" gridModel="datas" - pager="true" pagerButtons="true" pagerInput="true" - navigator="true" autowidth="true" rownumbers="false" - navigatorEdit="false" navigatorDelete="false" - navigatorSearch="false" navigatorRefresh="false" - navigatorAdd="false" rowList="10,15,20,50" rowNum="10" - viewrecords="true"> - - <s:iterator value="columnNames" var="name" status="status"> - - <sjg:gridColumn name="%{#name}" title="%{#name}" sortable="false"/> - - </s:iterator> - - </sjg:grid> - </fieldset> - </s:form> -</s:else> - - - - Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/configure.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/configure.jsp (rev 0) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/configure.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,47 @@ +<%-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + 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" %> + +<title><s:text name="echobase.title.exportDb"/></title> + +<s:form namespace="/exportDb" method="POST"> + + <fieldset> + <legend> + <s:text name="echobase.legend.exportDb.configuration.files"/> + </legend> + + <s:textfield key="model.fileName" required="true" size="100" + label="%{getText('echobase.label.exportDbFileName')} (*)"/> + + </fieldset> + <br/> + <s:submit action="configureExport" + value='%{getText("echobase.action.export")}'/> + + <div>(*) Il s'agit du nom de l'archive, l'extension <strong>.zip</strong> + sera automatiquement rajoutée.</div> + +</s:form> \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/configure.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/progress.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/progress.jsp (rev 0) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/progress.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,40 @@ +<%-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + 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" %> + +<s:url id="url" action="doExport" namespace="/exportDb"/> +<meta http-equiv="refresh" content="5;url=${url}"/> + +<title><s:text name="echobase.title.exportDbProgress"/></title> + +<%-- TODO letellier 20111104 : Add warn icon --%> +<p><s:text name="echobase.message.warnExportInProgress"/></p> + +<br/> + +<div> + <sj:progressbar value="%{model.progression}"/> +</div> \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/progress.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/result.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/result.jsp (rev 0) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/result.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,39 @@ +<%-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + 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" %> + +<title><s:text name="echobase.title.exportDbResult"/></title> + +<div> + L'export de la base complête a réussi en <s:property value="model.actionTime"/>. + Vous pouvez désormais télécharger l'archive le contenant. +</div> + +<br/> + +<s:a namespace="/exportDb" action="downloadExport"> + <s:text name="echobase.action.downloadExportDbFile"/> +</s:a> + Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportDb/result.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQuery.jsp (from rev 211, trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp) =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQuery.jsp (rev 0) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQuery.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,136 @@ +<%-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + 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" %> + +<s:url id="reloadUrl" action='manageExportQuery' namespace='/exportQuery'/> +<s:url id="exportSqlResultUrl" action="exportQueryResult" namespace="/exportQuery"/> +<s:set var="noError" value="!hasErrors()"/> +<script type="text/javascript"> + + function reloadQuery() { + var queryId = $('[name="query.topiaId"]').val(); + var url = "${reloadUrl}?" + $.param({ 'query.topiaId':queryId}); + window.location = url; + return false; + } + + function loadGridData() { + // get sql query + var sqlQuery = "${exportSqlResultUrl}?" + + $.param({ sql :$('[name="query.sqlQuery"]').val()}); + + $.ajax(sqlQuery, { + success: function(data, textStatus, jqXHR) { + $('#resultGrid').html(data); + } + }); + return false; + } + + jQuery(document).ready(function () { + + $('[name="query.topiaId"]').change(function(event) { + var url = "${reloadUrl}?" + $.param({ 'query.topiaId':this.value}); + window.location = url; + }); + + var queryId = $('[name="query.topiaId"]').val(); + if (queryId && ${noError}) { + // auto launch query + loadGridData(); + } + + }); + + +</script> + +<title><s:text name="echobase.title.export"/></title> + +<s:set var="queryExists" value="query.topiaId != null && query.topiaId != ''"/> + +<s:form id="exportQueryForm" namespace="/export"> + + <s:select key="query.topiaId" label="%{getText('echobase.label.sqlQueries')}" + list="queries" headerKey="" headerValue=""/> + + <br/> + + <fieldset> + <legend><s:text name="echobase.legend.sqlQuery.configuration"/></legend> + + <s:textarea key="query.name" required="true" cols="160" rows="1" + label="%{getText('echobase.label.query.name')}"/> + + <s:textarea key="query.description" required="true" cols="160" rows="2" + label="%{getText('echobase.label.query.description')}"/> + + <s:textarea key="query.sqlQuery" required="true" cols="160" rows="4" + label="%{getText('echobase.label.query.sql')}"/> + + <s:if test="queryExists"> + + <s:label value="%{query.lastModifiedDate}" readonly="true" + label="%{getText('echobase.common.lastModifiedDate')}"/> + + <s:label value="%{query.lastModifiedUser}" readonly="true" + label="%{getText('echobase.common.lastModifiedUser')}"/> + + </s:if> + + + <ul class="toolbar floatRight"> + <s:if test="queryExists"> + <li> + <s:submit onclick="return reloadQuery();" theme="simple" + key="echobase.action.reloadSqlQuery"/> + </li> + <li> + <s:submit action="cloneExportQuery" theme="simple" + key="echobase.action.cloneSqlQuery"/> + </li> + <li> + <s:submit action="deleteExportQuery" theme="simple" + key="echobase.action.deleteSqlQuery"/> + </li> + </s:if> + <li> + <s:submit action="saveExportQuery" theme="simple" + key="echobase.action.saveSqlQuery"/> + </li> + <li> + <s:submit key="echobase.action.applySqlQuery" theme="simple" + onclick="return loadGridData();"/> + </li> + </ul> + </fieldset> +</s:form> + +<br/> + +<div id="resultGrid" class="cleanBoth"></div> + + Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQuery.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQueryResult.jsp (from rev 211, trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp) =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQueryResult.jsp (rev 0) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQueryResult.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -0,0 +1,72 @@ +<%-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + 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" %> +<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %> + +<s:if test="hasActionErrors()"> + <div class="info_error"> + <s:actionerror/> + </div> +</s:if> +<s:else> + <s:url id="loadUrl" action="getExportQueryResult" namespace="/exportQuery" + escapeAmp="false"> + <s:param name="sql" value="%{sql}"/> + </s:url> + + <s:form action="downloadExportQueryResult" namespace="/exportQuery"> + + <fieldset> + <legend><s:text name="echobase.legend.sqlQuery.result"/></legend> + + <s:hidden key="sql" label=""/> + <s:textfield key="fileName" required="true" size="100" + label="%{getText('echobase.label.exportFileName')}"/> + <s:submit value="%{getText('echobase.action.exportSqlData')}" align="left"/> + <br/> + <sjg:grid id="rows" caption="%{getText('echobase.header.request.result')}" + dataType="json" href="%{loadUrl}" gridModel="datas" + pager="true" pagerButtons="true" pagerInput="true" + navigator="true" autowidth="true" rownumbers="false" + navigatorEdit="false" navigatorDelete="false" + navigatorSearch="false" navigatorRefresh="false" + navigatorAdd="false" rowList="10,15,20,50" rowNum="10" + viewrecords="true"> + + <s:iterator value="columnNames" var="name" status="status"> + + <sjg:gridColumn name="%{#name}" title="%{#name}" sortable="false"/> + + </s:iterator> + + </sjg:grid> + </fieldset> + </s:form> +</s:else> + + + + Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/exportQuery/exportQueryResult.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -26,7 +26,7 @@ <%@ taglib prefix="sj" uri="/struts-jquery-tags" %> <s:url id="url" action="doImport" namespace="/importDb"/> -<meta http-equiv="refresh" content="5;url=${url};"/> +<meta http-equiv="refresh" content="5;url=${url}"/> <title><s:text name="echobase.title.importDbProgress"/></title> Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp 2011-12-26 19:07:07 UTC (rev 216) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp 2011-12-26 19:47:00 UTC (rev 217) @@ -26,18 +26,14 @@ <title><s:text name="echobase.title.importDbResult"/></title> -<fieldset> - <legend> - <s:text name="echobase.legend.importFileResult"> - <s:param><strong><s:property - value="%{model.input.label}"/></strong></s:param> - </s:text> - </legend> +<div> + L'import de la base complête a réussi en <s:property + value="model.actionTime"/>. +</div> +<div> + EchoBase possède désormais un référentiel et les campagnes contenues dans + la sauvegarde importée. +</div> - <s:label value="%{model.input.fileName}" - label="%{getText('echobase.label.importFile')}"/> - -</fieldset> - <div>TODO</div>