Author: tchemit Date: 2011-11-08 10:03:06 +0100 (Tue, 08 Nov 2011) New Revision: 21 Url: http://forge.codelutin.com/repositories/revision/echobase/21 Log: change chemit to tchemit + begin of dbeditor ui Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp Removed: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java trunk/echobase-ui/src/main/resources/struts.xml trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java 2011-11-08 09:03:06 UTC (rev 21) @@ -1,255 +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; - -import com.google.common.base.Supplier; -import fr.ifremer.echobase.EchoBaseConfiguration; -import fr.ifremer.echobase.EchoBaseTechnicalException; -import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory; -import fr.ifremer.echobase.entities.EchoBaseUser; -import fr.ifremer.echobase.entities.EchoBaseUserDTO; -import fr.ifremer.echobase.entities.EchoBaseUserDTOImpl; -import fr.ifremer.echobase.entities.EchoBaseUserImpl; -import fr.ifremer.echobase.services.EchoBaseServiceContext; -import fr.ifremer.echobase.services.EchoBaseServiceContextImpl; -import fr.ifremer.echobase.services.EchoBaseServiceFactory; -import fr.ifremer.echobase.services.UserService; -import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; -import fr.ird.converter.FloatConverter; -import org.apache.commons.beanutils.ConvertUtils; -import org.apache.commons.beanutils.Converter; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.i18n.I18n; -import org.nuiton.i18n.init.DefaultI18nInitializer; -import org.nuiton.topia.TopiaContext; -import org.nuiton.topia.TopiaException; -import org.nuiton.topia.framework.TopiaContextImplementor; -import org.nuiton.topia.framework.TopiaUtil; -import org.nuiton.util.converter.ConverterUtil; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.Properties; - -/** - * To listen start or end of the application. - * <p/> - * On start we will load the configuration and check connection to internal - * database, creates schema and create an admin user in none found in database. - * <p/> - * On stop, just release the application configuration. - * - * @author chemit <chemit@codelutin.com> - * @since 0.1 - */ -public class ApplicationListener implements ServletContextListener { - - /** Logger. */ - protected static final Log log = - LogFactory.getLog(ApplicationListener.class); - - private Supplier<TopiaContext> rootContextSupplier; - - @Override - public void contextInitialized(ServletContextEvent sce) { - - if (log.isInfoEnabled()) { - log.info("Application starting at " + new Date() + "..."); - } - - // init I18n - DefaultI18nInitializer i18nInitializer = - new DefaultI18nInitializer("echobase-i18n"); - i18nInitializer.setMissingKeyReturnNull(true); - I18n.init(i18nInitializer, Locale.getDefault()); - - EchoBaseApplicationContext applicationContext = new EchoBaseApplicationContext(); - sce.getServletContext().setAttribute(EchoBaseActionSupport.APPLICATION_CONTEXT_PARAMETER, applicationContext); - - // initialize configuration - EchoBaseConfiguration configuration = new EchoBaseConfiguration(); - applicationContext.setConfiguration(configuration); - - if (log.isInfoEnabled()) { - log.info("Initializing RootContextSupplier..."); - } - EchoBaseTopiaRootContextSupplierFactory factory = - new EchoBaseTopiaRootContextSupplierFactory(); - rootContextSupplier = factory.newDatabaseFromConfig(configuration); - applicationContext.setRootContextSupplier(rootContextSupplier); - - // register our not locale dependant converter - Converter converter = ConverterUtil.getConverter(Float.class); - if (converter != null) { - ConvertUtils.deregister(Float.class); - } - ConvertUtils.register(new FloatConverter(), Float.class); - - // init database (and create minimal admin user if required) - try { - boolean schemaExist = isSchemaCreated(); - if (!schemaExist) { - - updateSchema(configuration); - } - - createAdminUser(configuration); - } catch (TopiaException e) { - throw new EchoBaseTechnicalException("Could not init db", e); - } - } - - @Override - public void contextDestroyed(ServletContextEvent sce) { - - if (log.isInfoEnabled()) { - log.info("Application is ending at " + new Date() + "..."); - } - if (rootContextSupplier != null) { - if (log.isInfoEnabled()) { - log.info("Shuting down RootContextSupplier..."); - } - TopiaContext rootContext = rootContextSupplier.get(); - if (!rootContext.isClosed()) { - try { - rootContext.closeContext(); - } catch (TopiaException te) { - if (log.isErrorEnabled()) { - log.error("Could not close rootContext", te); - } - } - } - } - } - - protected void updateSchema(EchoBaseConfiguration configuration) throws TopiaException { - if (log.isInfoEnabled()) { - log.info("Will create or update schema for db."); - } - // must create the schema - - Properties dbConf = configuration.getProperties(); - - dbConf.put("hibernate.hbm2ddl.auto", "update"); - - EchoBaseTopiaRootContextSupplierFactory factory = - new EchoBaseTopiaRootContextSupplierFactory(); - Supplier<TopiaContext> topiaContextSupplier = - factory.newDatabaseFromProperties(dbConf); - - // start a connexion to load schema - TopiaContext tx = null; - - try { - tx = topiaContextSupplier.get().beginTransaction(); - - } finally { - - // no more update of schema... - dbConf.put("hibernate.hbm2ddl.auto", "none"); - - closeTransaction(tx); - } - } - - /** - * Creates the adminsitrator ({@code admin/admin}) on the internal - * database. - * - * @param configuration EchoBase configuration - * @throws TopiaException if could not create the user. - */ - protected void createAdminUser(EchoBaseConfiguration configuration) throws TopiaException { - - EchoBaseServiceFactory serviceFactory = - new EchoBaseServiceFactory(); - TopiaContext transaction = rootContextSupplier.get().beginTransaction(); - - try { - EchoBaseServiceContext serviceContext = new EchoBaseServiceContextImpl( - transaction, - configuration, - serviceFactory - ); - - UserService service = serviceFactory.newService(UserService.class, serviceContext); - - List<EchoBaseUser> users = service.getUsers(); - - if (CollectionUtils.isEmpty(users)) { - - // no users in database create the admin user - if (log.isInfoEnabled()) { - log.info("No user in database, will create default " + - "admin user (password admin)."); - } - - EchoBaseUserDTO userDTO = new EchoBaseUserDTOImpl(); - userDTO.setEmail("admin"); - userDTO.setPassword("admin"); - userDTO.setAdmin(true); - service.createOrUpdate(userDTO); - } - } finally { - transaction.closeContext(); - } - - } - - protected boolean isSchemaCreated() throws TopiaException { - - TopiaContextImplementor tx = - (TopiaContextImplementor) - rootContextSupplier.get(); - try { - boolean schemaFound = TopiaUtil.isSchemaExist( - tx.getHibernateConfiguration(), - EchoBaseUserImpl.class.getName() - ); - - return schemaFound; - - } finally { - closeTransaction(tx); - } - } - - /** - * Try to close the given transaction. - * - * @param tx the transaction to close - * @throws TopiaException if could not close the transaction - */ - protected void closeTransaction(TopiaContext tx) throws TopiaException { - if (tx != null && !tx.isClosed()) { - tx.closeContext(); - } - } - -} Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java 2011-11-08 09:03:06 UTC (rev 21) @@ -28,7 +28,7 @@ import org.nuiton.topia.TopiaContext; /** - * @author chemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com> * @since 0.1 */ public class EchoBaseApplicationContext { Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-08 09:03:06 UTC (rev 21) @@ -65,7 +65,7 @@ * <p/> * On stop, just release the application configuration. * - * @author chemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com> * @since 0.1 */ public class EchoBaseApplicationListener implements ServletContextListener { @@ -198,7 +198,8 @@ serviceFactory ); - UserService service = serviceFactory.newService(UserService.class, serviceContext); + UserService service = + serviceFactory.newService(UserService.class, serviceContext); List<EchoBaseUser> users = service.getUsers(); @@ -215,11 +216,18 @@ userDTO.setPassword("admin"); userDTO.setAdmin(true); service.createOrUpdate(userDTO); + + for (int i = 0; i < 1000; i++) { + + userDTO.setEmail("admin" + i); + userDTO.setPassword("admin"); + userDTO.setAdmin(true); + service.createOrUpdate(userDTO); + } } } finally { transaction.closeContext(); } - } protected boolean isSchemaCreated() throws TopiaException { 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-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-08 09:03:06 UTC (rev 21) @@ -33,7 +33,7 @@ /** * The session object of EchoBase to put in servlet session. * - * @author chemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com> * @since 0.1 */ public class EchoBaseSession { Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-08 09:03:06 UTC (rev 21) @@ -47,7 +47,7 @@ * we do NOT want this behaviour in gui, prefer to return the marked * untranslated key. * - * @author chemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com> * @since 0.1 */ public class EchoBaseActionSupport extends BaseAction implements TopiaTransactionAware { Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java 2011-11-08 09:03:06 UTC (rev 21) @@ -26,7 +26,7 @@ /** * Operations possible for a simple CRUD. * - * @author chemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com> * @since 0.1 */ public enum EditActionEnum { Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-08 09:03:06 UTC (rev 21) @@ -38,7 +38,7 @@ /** * Login and Logout action. * - * @author chemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com> * @since 0.1 */ public class LoginAction extends EchoBaseActionSupport implements SessionAware { Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java 2011-11-08 09:03:06 UTC (rev 21) @@ -0,0 +1,67 @@ +package fr.ifremer.echobase.ui.actions.dbeditor; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import fr.ifremer.echobase.entities.EchoBaseDAOHelper; +import fr.ifremer.echobase.entities.EchoBaseUser; +import fr.ifremer.echobase.entities.ExportQuery; +import fr.ifremer.echobase.services.DbEditorService; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.persistence.TopiaEntity; + +import java.beans.Introspector; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import static org.nuiton.i18n.I18n._; + +/** + * Helper for the db editor. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class DbEditorUtil { + + protected static Map<String, String> tableNames; + + public static Map<String, String> getTableNames() { + + if (tableNames == null) { + tableNames = Maps.newTreeMap(); + Class<? extends TopiaEntity>[] contractClasses = + EchoBaseDAOHelper.getContractClasses(); + for (Class<? extends TopiaEntity> contractClass : contractClasses) { + tableNames.put(contractClass.getName(), _("echobase.common." + Introspector.decapitalize(contractClass.getSimpleName()))); + } + } + return tableNames; + } + + public static List<DbEditorService.TableMeta> getTableMeta(String tableName, TopiaContext transaction) { + + List<DbEditorService.TableMeta> result = Lists.newLinkedList(); + if (EchoBaseUser.class.getName().equals(tableName)) { +// result.add(newMeta(EchoBaseUser.TOPIA_ID, String.class)); + result.add(DbEditorService.newMeta(EchoBaseUser.PROPERTY_EMAIL, String.class)); + result.add(DbEditorService.newMeta(EchoBaseUser.PROPERTY_ADMIN, boolean.class)); + } + + if (ExportQuery.class.getName().equals(tableName)) { + +// result.add(newMeta(ExportQuery.TOPIA_ID, String.class)); + result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_NAME, String.class)); + result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_DESCRIPTION, String.class)); + result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_SQL_QUERY, String.class)); + result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_LAST_MODIFIED_DATE, Date.class)); + result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_LAST_MODIFIED_USER, EchoBaseUser.class)); + } + return result; + } + + protected DbEditorUtil() { + // helper classes, avoid constructor + } + +} Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java 2011-11-08 09:03:06 UTC (rev 21) @@ -0,0 +1,37 @@ +package fr.ifremer.echobase.ui.actions.dbeditor; + +import com.google.common.collect.Lists; +import fr.ifremer.echobase.services.DbEditorService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; + +import java.util.List; + +/** + * To obtain the data for the given request. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class GetTableDatas extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Name of the table to load. */ + protected String tableName; + + /** Metas of the table */ + protected List<DbEditorService.TableMeta> tableMetas; + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + @Override + public String execute() throws Exception { + tableMetas = Lists.newLinkedList(); + tableMetas.addAll(DbEditorUtil.getTableMeta(tableName)); + return SUCCESS; + } + + +} Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java 2011-11-08 09:03:06 UTC (rev 21) @@ -0,0 +1,84 @@ +package fr.ifremer.echobase.ui.actions.dbeditor; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import fr.ifremer.echobase.entities.EchoBaseEntityEnum; +import fr.ifremer.echobase.services.DbEditorService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.lang.StringUtils; +import org.hibernate.cfg.Configuration; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Table; +import org.nuiton.topia.framework.TopiaContextImplementor; +import org.nuiton.topia.persistence.TopiaEntity; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * To load the db editor page.s + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class LoadTablePage extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Name of the table to load. */ + protected String tableName; + + /** All tables availables */ + protected Map<String, String> tableNames; + + /** Metas of the table */ + protected List<DbEditorService.TableMeta> tableMetas; + + public String getTableName() { + return tableName; + } + + public Map<String, String> getTableNames() { + return tableNames; + } + + public List<DbEditorService.TableMeta> getTableMetas() { + return tableMetas; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + @Override + public String input() throws Exception { + tableNames = Maps.newTreeMap(); + tableNames.putAll(DbEditorUtil.getTableNames()); + if (StringUtils.isNotEmpty(tableName)) { + + // load also table metas + EchoBaseEntityEnum entityEnum = EchoBaseEntityEnum.valueOf(tableName); + Preconditions.checkNotNull(entityEnum); + String implementationFQN = entityEnum.getImplementationFQN(); + TopiaContextImplementor tx = (TopiaContextImplementor) getTransaction(); + Configuration hibernateConfiguration = tx.getHibernateConfiguration(); + PersistentClass classMapping = hibernateConfiguration.getClassMapping(implementationFQN); + Table table = classMapping.getTable(); + Iterator<?> columnIterator = table.getColumnIterator(); + while (columnIterator.hasNext()) { + Column column = (Column) columnIterator.next(); + String name = column.getName(); + if (TopiaEntity.TOPIA_CREATE_DATE.equals(name)) { + + // skip it + } + } + tableMetas = Lists.newLinkedList(); + tableMetas.addAll(DbEditorUtil.getTableMeta(tableName, getTransaction())); + } + return INPUT; + } +} Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java 2011-11-08 09:03:06 UTC (rev 21) @@ -41,7 +41,7 @@ private static final long serialVersionUID = 1L; - protected transient UserService service; +// protected transient UserService service; protected List<EchoBaseUserDTO> users; @@ -49,17 +49,18 @@ return users; } - protected UserService getUserService() { - if (service == null) { - service = newService(UserService.class); - } - return service; - } +// protected UserService getUserService() { +// if (service == null) { +// service = newService(UserService.class); +// } +// return service; +// } @Override public String execute() throws Exception { - List<EchoBaseUser> allUsers = getUserService().getUsers(); +// List<EchoBaseUser> allUsers = getUserService().getUsers(); + List<EchoBaseUser> allUsers = newService(UserService.class).getUsers(); users = new ArrayList<EchoBaseUserDTO>(allUsers.size()); for (EchoBaseUser user : allUsers) { Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java 2011-11-08 09:03:06 UTC (rev 21) @@ -38,7 +38,7 @@ /** * To check if some data are in the user session. * - * @author chemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com> * @see EchoBaseSession * @since 0.1 */ Added: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml =================================================================== --- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-08 09:03:06 UTC (rev 21) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!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="dbeditor" extends="loggued" namespace="/dbeditor"> + + <action name="dbeditor" method="input" + class="fr.ifremer.echobase.ui.actions.dbeditor.LoadTablePage"> + <interceptor-ref name="basicStackLoggued"/> + <result name="input">/WEB-INF/jsp/dbeditor/dbeditor.jsp</result> + </action> + + <action name="getTableDatas" + class="fr.ifremer.echobase.ui.actions.dbeditor.GetTableDatas"> + <interceptor-ref name="basicStackLoggued"/> + <result type="json"/> + </action> + + </package> + +</struts> + Modified: trunk/echobase-ui/src/main/resources/struts.xml =================================================================== --- trunk/echobase-ui/src/main/resources/struts.xml 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/resources/struts.xml 2011-11-08 09:03:06 UTC (rev 21) @@ -141,6 +141,7 @@ </package> + <include file="config/struts-dbeditor.xml"/> <include file="config/struts-json.xml"/> <include file="config/struts-user.xml"/> Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp (rev 0) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-08 09:03:06 UTC (rev 21) @@ -0,0 +1,89 @@ +<%-- + #%L + EchoBase :: UI + + $Id: export.jsp 17 2011-11-07 10:57:50Z tchemit $ + $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-ui/src/main/webap... $ + %% + 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:url id="reloadUrl" action="dbeditor" namespace="/dbeditor"/> + +<title><s:text name="echobase.title.dbEditor"/></title> + +<script type="text/javascript"> + + jQuery(document).ready(function () { + + $('[name="tableName"]').change(function(event) { + + var url = "${reloadUrl}?" + $.param({ tableName:this.value}); + window.location = url; + }); + }); +</script> + +<div> +<s:select key="tableName" href='%{getTableNamesUrl}' + label='%{getText("echobase.common.tableName")}' + + list="tableNames" headerKey="" headerValue=""/> + + </div> +<br/> + +<s:if test="tableName == ''"> + <p>Aucune table sélectionnée</p> +</s:if> +<s:else> + + <s:url id="loadUrl" action="getTableDatas" namespace="/dbeditor" + escapeAmp="false"> + <s:param name="tableName" value="%{tableName}"/> + </s:url> + + <sjg:grid id="tableDatas" + caption="%{getText('echobase.common.tableDatas', tableNames[tableName])}" + dataType="json" href="%{loadUrl}" gridModel="trips" + pager="true" pagerButtons="false" pagerInput="false" + navigator="true" autowidth="true" rownumbers="false" + navigatorEdit="true" + navigatorDelete="false" + navigatorSearch="true" + navigatorRefresh="true" + navigatorAdd="false" + resizable="true" editinline="false"> + + <sjg:gridColumn name="id" title="id" hidden="true"/> + + <s:iterator value="tableMetas" var="meta" status="status"> + + <sjg:gridColumn name="%{#meta.name}" title="%{#meta.label}" + edittype="%{#meta.columnType}" + sortable="false" editable="true"/> + + </s:iterator> + + </sjg:grid> + +</s:else> + Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-11-08 09:01:17 UTC (rev 20) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-11-08 09:03:06 UTC (rev 21) @@ -28,4 +28,5 @@ <h2><s:text name="echobase.label.welcome"/></h2> +<s:a action="dbeditor" namespace="/dbeditor">Modification du référentiel</s:a> <hr/> \ No newline at end of file