r609 - in trunk: . echobase-domain echobase-domain/src/main/java/fr/ifremer/echobase echobase-domain/src/main/java/fr/ifremer/echobase/persistence echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb echobase-domain/src/main/java/fr/ifremer/echobase/services echobase-domain/src/main/resources echobase-domain
Author: tchemit Date: 2012-09-04 08:14:33 +0200 (Tue, 04 Sep 2012) New Revision: 609 Url: http://forge.codelutin.com/repositories/revision/echobase/609 Log: - introduce topia migration service for both db - prepare a embedded zip and war with no more usage of a jdk but just a jre Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/EchoBaseMigrationCallBackResolver.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallBackForVersion.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallback.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallback.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_1.java trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.internalDb.MigrationCallBackForVersion trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion trunk/echobase-ui/src/main/assembly/ trunk/echobase-ui/src/main/assembly/bin.xml trunk/echobase-ui/src/main/assembly/dist/ trunk/echobase-ui/src/main/assembly/dist/README.txt trunk/echobase-ui/src/main/assembly/dist/echobase.properties trunk/echobase-ui/src/main/assembly/dist/startEchobase.bat trunk/echobase-ui/src/main/assembly/dist/startEchobase.sh Modified: trunk/echobase-domain/pom.xml trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBaseDbMeta.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBaseEntityHelper.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBasePersistenceHelper.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/JdbcConfiguration.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/ServiceFactoryAware.java trunk/echobase-domain/src/main/resources/echobase-internaldb.properties trunk/echobase-domain/src/main/resources/echobase-workingdb.properties trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/embeddedapplication/EmbeddedApplicationService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/workingDb/WorkingDbConfigurationService.java trunk/echobase-services/src/main/resources/embedded/echobase.properties trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/AbstractToolTest.java trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/TestHelper.java trunk/echobase-ui/pom.xml 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/workingDb/Connect.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/DownloadDriver.java trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/information.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/manage.jsp trunk/pom.xml Modified: trunk/echobase-domain/pom.xml =================================================================== --- trunk/echobase-domain/pom.xml 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/pom.xml 2012-09-04 06:14:33 UTC (rev 609) @@ -146,11 +146,6 @@ <artifactId>nuiton-csv</artifactId> </dependency> - <!--dependency> - <groupId>fr.ird</groupId> - <artifactId>msaccess-importer</artifactId> - </dependency--> - <!-- comons dependencies --> <dependency> @@ -191,6 +186,11 @@ </dependency> <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-service-migration</artifactId> + </dependency> + + <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency> Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2012-09-04 06:14:33 UTC (rev 609) @@ -27,7 +27,6 @@ import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.topia.TopiaContextFactory; import org.nuiton.util.ApplicationConfig; import org.nuiton.util.ArgumentsParserException; import org.nuiton.util.FileUtil; @@ -111,7 +110,7 @@ createDirectory(EchoBaseConfigurationOption.DATA_DIRECTORY); try { - FileUtils.forceMkdir(getWarDirectory()); +// FileUtils.forceMkdir(getWarDirectory()); FileUtils.forceMkdir(getLibDirectory()); } catch (IOException e) { throw new EchoBaseTechnicalException(e); @@ -153,12 +152,12 @@ return file; } - public File getWarDirectory() { - File file = applicationConfig.getOptionAsFile( - EchoBaseConfigurationOption.WAR_DIRECTORY.key); - Preconditions.checkNotNull(file); - return file; - } +// public File getWarDirectory() { +// File file = applicationConfig.getOptionAsFile( +// EchoBaseConfigurationOption.WAR_DIRECTORY.key); +// Preconditions.checkNotNull(file); +// return file; +// } public File getWarLocation() { File file = applicationConfig.getOptionAsFile( @@ -195,16 +194,10 @@ return v; } - public Class<?> getDriverClass() { - Class<?> klass = applicationConfig.getOptionAsClass( - TopiaContextFactory.CONFIG_DRIVER); - Preconditions.checkNotNull(klass); - return klass; - } - public boolean isEmbedded() { - Class<?> driverClass = getDriverClass(); - return driverClass.getName().toLowerCase().contains("h2"); + Boolean result = applicationConfig.getOptionAsBoolean( + EchoBaseConfigurationOption.EMBEDDED.key); + return result != null && result; } public boolean getOptionAsBoolean(String propertyName) { Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2012-09-04 06:14:33 UTC (rev 609) @@ -61,12 +61,9 @@ CSV_SEPARATOR("echobase.csv.separator", n_("echobase.config.csv.separator.description"), ";", char.class), - WAR_DIRECTORY("echobase.war.directory", - n_("echobase.config.war.directory.description"), - "${echobase.data.directory}/war", File.class), WAR_LOCATION("echobase.war.location", n_("echobase.config.war.location.description"), - "${echobase.war.directory}/echobase-ui-${echobase.version}.war", + "${echobase.data.directory}/war/echobase-ui-${echobase.version}-embedded.war", File.class); /** Configuration key. */ Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2012-09-04 06:14:33 UTC (rev 609) @@ -54,7 +54,6 @@ import fr.ifremer.echobase.entities.references.Strata; import fr.ifremer.echobase.entities.references.Vessel; import fr.ifremer.echobase.entities.references.VesselType; -import org.nuiton.topia.persistence.TopiaEntity; import java.io.File; import java.util.Map; Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBaseDbMeta.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBaseDbMeta.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBaseDbMeta.java 2012-09-04 06:14:33 UTC (rev 609) @@ -32,8 +32,6 @@ import java.util.Arrays; import java.util.List; -import static org.nuiton.i18n.I18n.n_; - /** * TODO * @@ -222,64 +220,4 @@ public EchoBasePersistenceHelper getPersistenceHelper() { return (EchoBasePersistenceHelper) super.getPersistenceHelper(); } - - /** - * - * I18n definition (we need it for generic dbeditor, but we don't want - * ToPIA to generate all keys for all property) - * @since 1.1 - */ - static { - n_("echobase.common.admin"); - n_("echobase.common.areaOfOperation"); - n_("echobase.common.author"); - n_("echobase.common.authorEmail"); - n_("echobase.common.calibration"); - n_("echobase.common.cell"); - n_("echobase.common.data"); - n_("echobase.common.dataAcquisition"); - n_("echobase.common.dataCentre"); - n_("echobase.common.dataCentreEmail"); - n_("echobase.common.dataProcessing"); - n_("echobase.common.dataQuality"); - n_("echobase.common.datum"); - n_("echobase.common.depthStratum"); - n_("echobase.common.description"); - n_("echobase.common.distributionStatement"); - n_("echobase.common.echoBaseUser"); - n_("echobase.common.email"); - n_("echobase.common.entityId"); - n_("echobase.common.entityModificationLog"); - n_("echobase.common.entityType"); - n_("echobase.common.exportQuery"); - n_("echobase.common.id"); - n_("echobase.common.institution"); - n_("echobase.common.keywords"); - n_("echobase.common.lastModifiedDate"); - n_("echobase.common.lastModifiedUser"); - n_("echobase.common.litteratureReferences"); - n_("echobase.common.metadata"); - n_("echobase.common.mission"); - n_("echobase.common.missionAbstract"); - n_("echobase.common.modificationDate"); - n_("echobase.common.modificationText"); - n_("echobase.common.modificationUser"); - n_("echobase.common.name"); - n_("echobase.common.organisationLevelAcknowledgements"); - n_("echobase.common.organisationReferences"); - n_("echobase.common.password"); - n_("echobase.common.platform"); - n_("echobase.common.principalInvestigator"); - n_("echobase.common.principalInvestigatorEmail"); - n_("echobase.common.project"); - n_("echobase.common.referenceDatum"); - n_("echobase.common.source"); - n_("echobase.common.species"); - n_("echobase.common.sqlQuery"); - n_("echobase.common.transect"); - n_("echobase.common.transit"); - n_("echobase.common.vessel"); - n_("echobase.common.voyage"); - n_("echobase.config.data.directory.description"); - } } Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBaseEntityHelper.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBaseEntityHelper.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBaseEntityHelper.java 2012-09-04 06:14:33 UTC (rev 609) @@ -23,6 +23,8 @@ * #L% */ +import fr.ifremer.echobase.entities.EchoBaseUserImpl; +import fr.ifremer.echobase.entities.data.VoyageImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Transaction; @@ -135,4 +137,36 @@ } } } + + /** + * Tests if the internal database schema created. + * + * @param tx transaction + * @return {@code true} if the schema is already created, {@code false} + * otherwise + * @throws TopiaException if something was wrong while requesting database + */ + public static boolean isInternalSchemaCreated(TopiaContext tx) throws TopiaException { + + boolean schemaFound = + ((TopiaContextImplementor) tx).isSchemaExist(EchoBaseUserImpl.class); + + return schemaFound; + } + + /** + * Tests if the working database schema created. + * + * @param tx transaction + * @return {@code true} if the schema is already created, {@code false} + * otherwise + * @throws TopiaException if something was wrong while requesting database + */ + public static boolean isWorkingDbSchemaCreated(TopiaContext tx) throws TopiaException { + + boolean schemaFound = + ((TopiaContextImplementor) tx).isSchemaExist(VoyageImpl.class); + + return schemaFound; + } } Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBasePersistenceHelper.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBasePersistenceHelper.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchoBasePersistenceHelper.java 2012-09-04 06:14:33 UTC (rev 609) @@ -25,19 +25,18 @@ import fr.ifremer.echobase.entities.EchoBaseDAOHelper; import fr.ifremer.echobase.entities.EchoBaseEntityEnum; -import fr.ifremer.echobase.entities.EchoBaseUserImpl; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaRuntimeException; -import org.nuiton.topia.framework.TopiaContextImplementor; import org.nuiton.topia.persistence.TopiaDAO; import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.TopiaPersistenceHelper; /** - * TODO + * Persistence helper for working db. * * @author tchemit <chemit@codelutin.com> + * @see TopiaPersistenceHelper * @since 1.1 */ public class EchoBasePersistenceHelper implements TopiaPersistenceHelper<EchoBaseEntityEnum> { @@ -61,19 +60,4 @@ return (TopiaDAO<E>) getDAO(tx, type.getContract()); } - /** - * Tests if the internal database schema created. - * - * @param tx transaction - * @return {@code true} if the schema is already created, {@code false} - * otherwise - * @throws TopiaException if something was wrong while requesting database - */ - public boolean isInternalSchemaCreated(TopiaContext tx) throws TopiaException { - - boolean schemaFound = - ((TopiaContextImplementor) tx).isSchemaExist(EchoBaseUserImpl.class); - - return schemaFound; - } } Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java 2012-09-04 06:14:33 UTC (rev 609) @@ -25,6 +25,7 @@ import com.google.common.base.Charsets; import fr.ifremer.echobase.EchoBaseConfigurationOption; +import fr.ifremer.echobase.EchoBaseTechnicalException; import fr.ifremer.echobase.entities.DriverType; import fr.ifremer.echobase.entities.EchoBaseDAOHelper; import fr.ifremer.echobase.entities.EchoBaseInternalDAOHelper; @@ -32,9 +33,9 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; +import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; import org.nuiton.topia.TopiaRuntimeException; -import org.nuiton.topia.framework.TopiaContextImplementor; import org.nuiton.util.RecursiveProperties; import java.io.File; @@ -111,8 +112,22 @@ */ public static TopiaContext newWorkingDb(JdbcConfiguration jdbcConfiguration) { - Properties result = loadWorkingDbConfiguration(jdbcConfiguration); - return newDb(result); + Properties properties = loadWorkingDbConfiguration(jdbcConfiguration); + TopiaContext result = newDb(properties); + + try { + if (!EchoBaseEntityHelper.isWorkingDbSchemaCreated(result)) { + + if (log.isInfoEnabled()) { + log.info("Will create schema for " + + jdbcConfiguration.getUrl()); + } + result.createSchema(); + } + } catch (TopiaException e) { + throw new EchoBaseTechnicalException("Could not create db schema", e); + } + return result; } /** @@ -166,20 +181,18 @@ configuration.get(TopiaContextFactory.CONFIG_URL)); } TopiaContext result = TopiaContextFactory.getContext(configuration); + return result; } catch (TopiaNotFoundException e) { throw new TopiaRuntimeException("Could not init db", e); } } - public static void reloadProperty(Properties properties, String propertyName, String propertyNameToRemove) { + public static void reloadProperty(Properties properties, + String propertyName, + String propertyNameToRemove) { Object o = properties.getProperty(propertyName); properties.put(propertyName, o); properties.remove(propertyNameToRemove); } - - public static String getDbUrl(TopiaContext rootContext) { - String result = (String) ((TopiaContextImplementor) rootContext).getConfig().get(TopiaContextFactory.CONFIG_URL); - return result; - } } Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/JdbcConfiguration.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/JdbcConfiguration.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/JdbcConfiguration.java 2012-09-04 06:14:33 UTC (rev 609) @@ -29,15 +29,15 @@ public class JdbcConfiguration implements Serializable { - public static JdbcConfiguration newConfig(String url, + public static JdbcConfiguration newConfig(DriverType driverType, + String url, String login, - String password, - DriverType driverType) { + String password) { JdbcConfiguration result = new JdbcConfiguration(); + result.setDriverType(driverType); result.setUrl(url); result.setLogin(login); result.setPassword(password); - result.setDriverType(driverType); return result; } @@ -48,7 +48,7 @@ String databaseAbsolutePath = databaseFile.getAbsolutePath(); String url = "jdbc:h2:file:" + databaseAbsolutePath + "/echobase;LOG=0;CACHE_SIZE=65536;LOCK_MODE=0;UNDO_LOG=0"; - JdbcConfiguration result = newConfig(url, "sa", "sa", DriverType.H2); + JdbcConfiguration result = newConfig(DriverType.H2, url, "sa", "sa"); return result; } Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/EchoBaseMigrationCallBackResolver.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/EchoBaseMigrationCallBackResolver.java (rev 0) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/EchoBaseMigrationCallBackResolver.java 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,79 @@ +package fr.ifremer.echobase.persistence.migration; + +/* + * #%L + * EchoBase :: Domain + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 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% + */ + +import com.google.common.collect.Maps; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG; +import org.nuiton.util.Version; +import org.nuiton.util.VersionUtil; + +import java.util.Map; +import java.util.ServiceLoader; +import java.util.Set; + +/** + * Migration callBack resolver using service loader to discover version to + * apply and using also a generic migration call back. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.1 + */ +public class EchoBaseMigrationCallBackResolver<C extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion> implements TopiaMigrationCallbackByClassNG.MigrationCallBackForVersionResolver { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(EchoBaseMigrationCallBackResolver.class); + + public static <C extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion> EchoBaseMigrationCallBackResolver<C> newResolver(Class<C> resolverType) { + return new EchoBaseMigrationCallBackResolver<C>(resolverType); + } + + protected final Map<Version, C> versionMigrationMapping; + + protected EchoBaseMigrationCallBackResolver(Class<C> migrationType) { + this.versionMigrationMapping = Maps.newTreeMap( + new VersionUtil.VersionComparator()); + for (C callBackForVersion : ServiceLoader.load(migrationType)) { + Version version = callBackForVersion.getVersion(); + if (log.isInfoEnabled()) { + log.info("Detects migration version " + version + " [" + + callBackForVersion + "]"); + } + versionMigrationMapping.put(version, callBackForVersion); + } + } + + @Override + public C getCallBack(Version version) { + return versionMigrationMapping.get(version); + } + + @Override + public Set<Version> getAllVersions() { + return versionMigrationMapping.keySet(); + } + +} \ No newline at end of file Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/EchoBaseMigrationCallBackResolver.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallBackForVersion.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallBackForVersion.java (rev 0) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallBackForVersion.java 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,44 @@ +package fr.ifremer.echobase.persistence.migration.internalDb; + +/* + * #%L + * EchoBase :: Domain + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 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% + */ + +import org.hibernate.dialect.Dialect; +import org.nuiton.topia.TopiaNotFoundException; +import org.nuiton.topia.framework.TopiaContextImplementor; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG; + +/** + * Base migration support for a internal db. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.1 + */ +public abstract class MigrationCallBackForVersion extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion { + + protected Dialect getDialect(TopiaContextImplementor tx) throws TopiaNotFoundException { + Dialect dialect = + Dialect.getDialect(tx.getHibernateConfiguration().getProperties()); + return dialect; + } +} Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallBackForVersion.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallback.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallback.java (rev 0) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallback.java 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,56 @@ +package fr.ifremer.echobase.persistence.migration.internalDb; + +/* + * #%L + * EchoBase :: Domain + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 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% + */ + +import fr.ifremer.echobase.entities.EchoBaseInternalDAOHelper; +import fr.ifremer.echobase.persistence.migration.EchoBaseMigrationCallBackResolver; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG; +import org.nuiton.util.Version; +import org.nuiton.util.VersionUtil; + +import java.util.List; + +/** + * EchoBase Migration callback for internal db. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.1 + */ +public class MigrationCallback extends TopiaMigrationCallbackByClassNG { + + public MigrationCallback() { + super(EchoBaseMigrationCallBackResolver.newResolver( + fr.ifremer.echobase.persistence.migration.internalDb.MigrationCallBackForVersion.class)); + } + + @Override + public Version getApplicationVersion() { + return VersionUtil.valueOf(EchoBaseInternalDAOHelper.getModelVersion()); + } + + @Override + public boolean askUser(Version version, List<Version> versions) { + return true; + } +} Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallback.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java (rev 0) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,44 @@ +package fr.ifremer.echobase.persistence.migration.workingDb; + +/* + * #%L + * EchoBase :: Domain + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 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% + */ + +import org.hibernate.dialect.Dialect; +import org.nuiton.topia.TopiaNotFoundException; +import org.nuiton.topia.framework.TopiaContextImplementor; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG; + +/** + * Base migration support for a working db. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.1 + */ +public abstract class MigrationCallBackForVersion extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion { + + protected Dialect getDialect(TopiaContextImplementor tx) throws TopiaNotFoundException { + Dialect dialect = + Dialect.getDialect(tx.getHibernateConfiguration().getProperties()); + return dialect; + } +} Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallback.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallback.java (rev 0) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallback.java 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,56 @@ +package fr.ifremer.echobase.persistence.migration.workingDb; + +/* + * #%L + * EchoBase :: Domain + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 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% + */ + +import fr.ifremer.echobase.entities.EchoBaseDAOHelper; +import fr.ifremer.echobase.persistence.migration.EchoBaseMigrationCallBackResolver; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG; +import org.nuiton.util.Version; +import org.nuiton.util.VersionUtil; + +import java.util.List; + +/** + * EchoBase Migration callback for working db. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.3 + */ +public class MigrationCallback extends TopiaMigrationCallbackByClassNG { + + public MigrationCallback() { + super(EchoBaseMigrationCallBackResolver.newResolver( + fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion.class)); + } + + @Override + public Version getApplicationVersion() { + return VersionUtil.valueOf(EchoBaseDAOHelper.getModelVersion()); + } + + @Override + public boolean askUser(Version version, List<Version> versions) { + return true; + } +} Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallback.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_1.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_1.java (rev 0) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_1.java 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,61 @@ +package fr.ifremer.echobase.persistence.migration.workingDb; + +/* + * #%L + * EchoBase :: Domain + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 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% + */ + +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.framework.TopiaContextImplementor; +import org.nuiton.util.Version; +import org.nuiton.util.VersionUtil; + +import java.util.Arrays; +import java.util.List; + +/** + * Migration for version {@code 1.1}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.1 + */ +public class MigrationCallbackV1_1 extends MigrationCallBackForVersion { + + @Override + public Version getVersion() { + return VersionUtil.valueOf("1.1"); + } + + @Override + protected void prepareMigrationScript(TopiaContextImplementor tx, + List<String> queries, + boolean showSql, + boolean showProgression) throws TopiaException { + + String[] sqls = new String[]{ + "DROP TABLE echobaseuser;", + "DROP TABLE exportquery;" + }; + + queries.addAll(Arrays.asList(sqls)); + + } +} Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_1.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-04 06:14:33 UTC (rev 609) @@ -26,9 +26,9 @@ import fr.ifremer.echobase.EchoBaseConfiguration; import fr.ifremer.echobase.EchoBaseTechnicalException; import fr.ifremer.echobase.entities.EchoBaseDAOHelper; -import fr.ifremer.echobase.persistence.EchoBaseDbMeta; import fr.ifremer.echobase.entities.EchoBaseInternalDAOHelper; import fr.ifremer.echobase.entities.EchobaseInternalEntity; +import fr.ifremer.echobase.persistence.EchoBaseDbMeta; import org.apache.commons.lang3.StringUtils; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/ServiceFactoryAware.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/ServiceFactoryAware.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/ServiceFactoryAware.java 2012-09-04 06:14:33 UTC (rev 609) @@ -29,7 +29,7 @@ * @author tchemit <chemit@codelutin.com> * @since 1.1 */ -public interface ServiceFactoryAware { +public interface ServiceFactoryAware { <S extends EchoBaseService> S getService(Class<S> serviceClass); Property changes on: trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.internalDb.MigrationCallBackForVersion ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion =================================================================== --- trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion (rev 0) +++ trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1 @@ +fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallbackV1_1 \ No newline at end of file Property changes on: trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-domain/src/main/resources/echobase-internaldb.properties =================================================================== --- trunk/echobase-domain/src/main/resources/echobase-internaldb.properties 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/resources/echobase-internaldb.properties 2012-09-04 06:14:33 UTC (rev 609) @@ -20,9 +20,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # #L% ### -hibernate.hbm2ddl.auto=update -hibernate.show_sql=false +# Database basic configuration hibernate.dialect=org.hibernate.dialect.H2Dialect hibernate.connection.provider_class=org.nuiton.topia.framework.TopiaConnectionProvider hibernate.connection.username=sa @@ -30,3 +29,16 @@ hibernate.connection.driver_class=org.h2.Driver hibernate.connection.url=jdbc:h2:file:${echobase.internal.db.directory}/echobase-user +# Never create/update schema (will do it by logic) +hibernate.hbm2ddl.auto=none + +# To custom sql in logger +hibernate.show_sql=false +hibernate.format_sql=false +hibernate.use_sql_comments=false + +# Database migration configuration +topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine +topia.service.migration.callback=fr.ifremer.echobase.persistence.migration.internalDb.MigrationCallback +topia.service.migration.showSql=true + Modified: trunk/echobase-domain/src/main/resources/echobase-workingdb.properties =================================================================== --- trunk/echobase-domain/src/main/resources/echobase-workingdb.properties 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/resources/echobase-workingdb.properties 2012-09-04 06:14:33 UTC (rev 609) @@ -20,11 +20,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # #L% ### -# DB configuration -hibernate.show_sql=false -hibernate.format_sql=false -hibernate.use_sql_comments=false -hibernate.hbm2ddl.auto=none + +# Database basic configuration hibernate.connection.username=${configuration.login} hibernate.connection.password=${configuration.password} hibernate.connection.url=${configuration.url} @@ -32,8 +29,16 @@ hibernate.dialect=${configuration.dialect} hibernate.connection.provider_class=org.nuiton.topia.framework.TopiaConnectionProvider -# Migration configuration -#topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine -#topia.service.migration.callback=fr.ird.t3.services.migration.T3MigrationCallback -#topia.service.migration.showSql=true +# Never create/update schema (will do it by logic) +hibernate.hbm2ddl.auto=none +# To custom sql in logger +hibernate.show_sql=false +hibernate.format_sql=false +hibernate.use_sql_comments=false + +# Database migration configuration +topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine +topia.service.migration.callback=fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallback +topia.service.migration.showSql=true + Modified: trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties =================================================================== --- trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties 2012-09-04 06:14:33 UTC (rev 609) @@ -1,55 +1,5 @@ -echobase.common.admin= -echobase.common.areaOfOperation= -echobase.common.author= -echobase.common.authorEmail= -echobase.common.calibration= -echobase.common.cell= -echobase.common.data= -echobase.common.dataAcquisition= -echobase.common.dataCentre= -echobase.common.dataCentreEmail= -echobase.common.dataProcessing= -echobase.common.dataQuality= -echobase.common.datum= -echobase.common.depthStratum= -echobase.common.description= -echobase.common.distributionStatement= echobase.common.driverType.h2= echobase.common.driverType.postgres= -echobase.common.echoBaseUser= -echobase.common.email= -echobase.common.entityId= -echobase.common.entityModificationLog= -echobase.common.entityType= -echobase.common.exportQuery= -echobase.common.id= -echobase.common.institution= -echobase.common.keywords= -echobase.common.lastModifiedDate= -echobase.common.lastModifiedUser= -echobase.common.litteratureReferences= -echobase.common.metadata= -echobase.common.mission= -echobase.common.missionAbstract= -echobase.common.modificationDate= -echobase.common.modificationText= -echobase.common.modificationUser= -echobase.common.name= -echobase.common.organisationLevelAcknowledgements= -echobase.common.organisationReferences= -echobase.common.password= -echobase.common.platform= -echobase.common.principalInvestigator= -echobase.common.principalInvestigatorEmail= -echobase.common.project= -echobase.common.referenceDatum= -echobase.common.source= -echobase.common.species= -echobase.common.sqlQuery= -echobase.common.transect= -echobase.common.transit= -echobase.common.vessel= -echobase.common.voyage= echobase.config.csv.separator.description= echobase.config.data.directory.description= echobase.config.embedded.description= @@ -57,6 +7,5 @@ echobase.config.internal.db.directory.description= echobase.config.postgresqlVersion.description= echobase.config.version.description= -echobase.config.war.directory.description= echobase.config.war.location.description= -echobase.configuration.description=Configuration d'EchoBase +echobase.configuration.description=EchoBase configuration Modified: trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties =================================================================== --- trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties 2012-09-04 06:14:33 UTC (rev 609) @@ -1,62 +1,11 @@ -echobase.common.admin=Administrateur -echobase.common.areaOfOperation=AreaOfOperation -echobase.common.author=Auteur -echobase.common.authorEmail=Courriel de l'auteur -echobase.common.calibration=Calibration -echobase.common.cell=Cell -echobase.common.data=Data -echobase.common.dataAcquisition=DataAcquisition -echobase.common.dataCentre=Centre de données -echobase.common.dataCentreEmail=Courriel du centre de données -echobase.common.dataProcessing=DataProcessing -echobase.common.dataQuality=DataQuality -echobase.common.datum=Datum -echobase.common.depthStratum=DepthStratum -echobase.common.description=Description -echobase.common.distributionStatement=distributionStatement echobase.common.driverType.h2=Base H2 echobase.common.driverType.postgres=Base Postgresql -echobase.common.echoBaseUser=Utilisateur -echobase.common.email=Courriel -echobase.common.entityId=Identifiant de l'entité -echobase.common.entityModificationLog=Journal des modifications -echobase.common.entityType=Type de l'entité -echobase.common.exportQuery=Requête d'export -echobase.common.id=Identifiant -echobase.common.institution=Institution -echobase.common.keywords=Môts clefs -echobase.common.lastModifiedDate=Date de dernière modification -echobase.common.lastModifiedUser=Utilisateur de dernière modification -echobase.common.litteratureReferences=Références -echobase.common.metadata=Metadata -echobase.common.mission=Mission -echobase.common.missionAbstract=Résumé de la mission -echobase.common.modificationDate=Date de modification -echobase.common.modificationText=Modification -echobase.common.modificationUser=Utilisateur -echobase.common.name=Nom -echobase.common.organisationLevelAcknowledgements=organisationLevelAcknowledgements -echobase.common.organisationReferences=Références organisation -echobase.common.password=Mot de passe -echobase.common.platform=Platform -echobase.common.principalInvestigator=Chercheur -echobase.common.principalInvestigatorEmail=Courriel du chercheur -echobase.common.project=Projet -echobase.common.referenceDatum=ReferenceDatum -echobase.common.source=Source -echobase.common.species=Espèce -echobase.common.sqlQuery=Requête SQL -echobase.common.transect=Transect -echobase.common.transit=Transit -echobase.common.vessel=Navire -echobase.common.voyage=Campagne -echobase.config.csv.separator.description= +echobase.config.csv.separator.description=Caractère séparateur pour les fichiers csv echobase.config.data.directory.description=Répertoire des données de l'application -echobase.config.embedded.description= +echobase.config.embedded.description=Pour créer au démarrage une configuration vers la base h2 embarquée (uniquement pour les applications embarquées) echobase.config.h2Version.description=Version du pilote jdbc H2 echobase.config.internal.db.directory.description=Répertoire de la base interne echobase.config.postgresqlVersion.description=Version du pilote jdbc Postgresql echobase.config.version.description=Version de l'application -echobase.config.war.directory.description=Répertoire où sont accessibles les wars -echobase.config.war.location.description=chemin d'accèss au war embarqué à utiliser pour créer des applications embarquées +echobase.config.war.location.description=Chemin d'accèss au war embarqué à utiliser pour créer des applications embarquées echobase.configuration.description=Configuration d'EchoBase Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/embeddedapplication/EmbeddedApplicationService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/embeddedapplication/EmbeddedApplicationService.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/embeddedapplication/EmbeddedApplicationService.java 2012-09-04 06:14:33 UTC (rev 609) @@ -26,7 +26,6 @@ import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import fr.ifremer.echobase.EchoBaseTechnicalException; -import fr.ifremer.echobase.entities.DriverType; import fr.ifremer.echobase.entities.EchoBaseUser; import fr.ifremer.echobase.entities.ExportQuery; import fr.ifremer.echobase.entities.WorkingDbConfiguration; @@ -45,7 +44,6 @@ import fr.ifremer.echobase.services.importdb.ImportDbConfiguration; import fr.ifremer.echobase.services.importdb.ImportDbService; import fr.ifremer.echobase.services.workingDb.WorkingDbConfigurationAlreadyExistException; -import fr.ifremer.echobase.services.workingDb.WorkingDbConfigurationService; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; @@ -189,8 +187,6 @@ model.incrementsProgression(); // get all working db configuration from application - WorkingDbConfigurationService workingDbConfigurationService = - newServiceContext.getService(WorkingDbConfigurationService.class); List<WorkingDbConfiguration> confs = getEntities(WorkingDbConfiguration.class); @@ -199,16 +195,6 @@ getInternalTransaction().replicateEntities( newServiceContext.getInternalTransaction(), confs); - // add a new configuration to the embedded working db - WorkingDbConfiguration conf = - workingDbConfigurationService.newConfiguration(); - conf.setDriverType(DriverType.H2); - conf.setLogin("sa"); - conf.setDescription("Embedded working db"); - conf.setUrl("jdbc:h2:file:${echobase.data.directory}/db/echobase;CACHE_SIZE=65536;AUTO_SERVER=TRUE"); - - workingDbConfigurationService.create(conf); - model.incrementsProgression(); return admin; @@ -226,10 +212,9 @@ EchoBaseUser admin) throws IOException, TopiaException { JdbcConfiguration dbConf = JdbcConfiguration.newEmbeddedConfig(dir); - TopiaContext rootContext = EchobaseTopiaContexts.newWorkingDb(dbConf); + TopiaContext rootContext = EchobaseTopiaContexts.newWorkingDb( + dbConf); try { - // create db schema - rootContext.createSchema(); // inject a new transaction in service context newServiceContext.setTransaction(rootContext.beginTransaction()); Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/workingDb/WorkingDbConfigurationService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/workingDb/WorkingDbConfigurationService.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/workingDb/WorkingDbConfigurationService.java 2012-09-04 06:14:33 UTC (rev 609) @@ -24,6 +24,7 @@ */ import fr.ifremer.echobase.EchoBaseTechnicalException; +import fr.ifremer.echobase.entities.DriverType; import fr.ifremer.echobase.entities.WorkingDbConfiguration; import fr.ifremer.echobase.entities.WorkingDbConfigurationDAO; import fr.ifremer.echobase.services.EchoBaseServiceSupport; @@ -112,6 +113,23 @@ } } + public void createEmbeddedWorkingDbConfiguration() { + + String url = "jdbc:h2:file:${echobase.data.directory}/db/echobase;CACHE_SIZE=65536;AUTO_SERVER=TRUE"; + if (!isUrlAlreadyUsed(url)) { + WorkingDbConfiguration conf = newConfiguration(); + conf.setDriverType(DriverType.H2); + conf.setLogin("sa"); + conf.setDescription("Embedded working db"); + conf.setUrl(url); + try { + create(conf); + } catch (WorkingDbConfigurationAlreadyExistException e) { + // can not happen + } + } + } + protected WorkingDbConfiguration getExistingConf(String id) throws WorkingDbConfigurationNotFoundException { WorkingDbConfiguration entity = getEntityById(WorkingDbConfiguration.class, id); Modified: trunk/echobase-services/src/main/resources/embedded/echobase.properties =================================================================== --- trunk/echobase-services/src/main/resources/embedded/echobase.properties 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-services/src/main/resources/embedded/echobase.properties 2012-09-04 06:14:33 UTC (rev 609) @@ -25,5 +25,8 @@ # Where to find data echobase.data.directory=. -# where to find war -echobase.war.directory=${echobase.data.directory} +# Where to find war +echobase.war.location=${echobase.data.directory}/echobase-ui-${echobase.version}-embedded.war + +# To create embedded working db +echobase.embedded=true Modified: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/AbstractToolTest.java =================================================================== --- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/AbstractToolTest.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/AbstractToolTest.java 2012-09-04 06:14:33 UTC (rev 609) @@ -94,7 +94,8 @@ JdbcConfiguration dbConf = JdbcConfiguration.newEmbeddedConfig(testdir); - topiaContext = EchobaseTopiaContexts.newWorkingDb(dbConf); + topiaContext = EchobaseTopiaContexts.newWorkingDb( + dbConf); serviceContext = DefaultEchoBaseServiceContext.newContext( Locale.getDefault(), Modified: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/TestHelper.java =================================================================== --- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/TestHelper.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/TestHelper.java 2012-09-04 06:14:33 UTC (rev 609) @@ -23,23 +23,16 @@ */ package fr.ifremer.echobase.tools; -import fr.ifremer.echobase.persistence.EchobaseTopiaContexts; -import fr.ifremer.echobase.persistence.JdbcConfiguration; -import fr.ifremer.echobase.entities.EchoBaseEntityEnum; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assume; import org.junit.Ignore; import org.junit.rules.TestName; -import org.nuiton.topia.TopiaContext; -import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.util.FileUtil; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; /** * Utility methods for tests @@ -98,32 +91,32 @@ FileUtil.createDirectoryIfNecessary(result); return result; } +// +// public static TopiaContext getRootContext(File dbDir) { +// +// JdbcConfiguration dbConf = JdbcConfiguration.newEmbeddedConfig(dbDir); +// TopiaContext context = EchobaseTopiaContexts.newWorkingDb(persistenceHelper, dbConf); +// return context; +// } - public static TopiaContext getRootContext(File dbDir) { +// /** +// * Used to get all contract of a package +// * +// * @param entitiesPackage package contening desired entities +// * @return contracts contained in entitiesPackage +// */ +// public static EchoBaseEntityEnum[] getContractsOf(Package entitiesPackage) { +// EchoBaseEntityEnum[] echoBaseEntityEnums = EchoBaseEntityEnum.values(); +// List<EchoBaseEntityEnum> refClasses = new ArrayList<EchoBaseEntityEnum>(); +// for (EchoBaseEntityEnum echoBaseEntityEnum : echoBaseEntityEnums) { +// +// // Get all entities in package fr.ifremer.echobase.entities.references +// Class<? extends TopiaEntity> contract = echoBaseEntityEnum.getContract(); +// if (entitiesPackage.equals(contract.getPackage())) { +// refClasses.add(echoBaseEntityEnum); +// } +// } +// return refClasses.toArray(new EchoBaseEntityEnum[refClasses.size()]); +// } - JdbcConfiguration dbConf = JdbcConfiguration.newEmbeddedConfig(dbDir); - TopiaContext context = EchobaseTopiaContexts.newWorkingDb(dbConf); - return context; - } - - /** - * Used to get all contract of a package - * - * @param entitiesPackage package contening desired entities - * @return contracts contained in entitiesPackage - */ - public static EchoBaseEntityEnum[] getContractsOf(Package entitiesPackage) { - EchoBaseEntityEnum[] echoBaseEntityEnums = EchoBaseEntityEnum.values(); - List<EchoBaseEntityEnum> refClasses = new ArrayList<EchoBaseEntityEnum>(); - for (EchoBaseEntityEnum echoBaseEntityEnum : echoBaseEntityEnums) { - - // Get all entities in package fr.ifremer.echobase.entities.references - Class<? extends TopiaEntity> contract = echoBaseEntityEnum.getContract(); - if (entitiesPackage.equals(contract.getPackage())) { - refClasses.add(echoBaseEntityEnum); - } - } - return refClasses.toArray(new EchoBaseEntityEnum[refClasses.size()]); - } - } Modified: trunk/echobase-ui/pom.xml =================================================================== --- trunk/echobase-ui/pom.xml 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-ui/pom.xml 2012-09-04 06:14:33 UTC (rev 609) @@ -31,11 +31,14 @@ <env>dev</env> <redmine.releaseFiles> - ${basedir}/target/${project.build.finalName}.war + ${project.build.directory}/${project.build.finalName}.war, + ${project.build.directory}/${project.build.finalName}-embedded.war + ${project.build.directory}/${project.build.finalName}-embedded.zip </redmine.releaseFiles> <deployFiles> - ${basedir}/target/${project.build.finalName}.war + ${project.build.directory}/${project.build.finalName}.war, + ${project.build.directory}/${project.build.finalName}-embedded.war </deployFiles> </properties> @@ -62,7 +65,6 @@ <directory>src/main/env/${env}/resources</directory> <includes> <include>*.properties</include> - <include>*.xml</include> </includes> </resource> </resources> @@ -147,32 +149,6 @@ </configuration> </plugin> - <plugin> - <artifactId>maven-war-plugin</artifactId> - <configuration> - <archive> - <manifest> - <mainClass>org.nuiton.web.war.JettyLauncher</mainClass> - </manifest> - </archive> - <overlays> - <overlay> - <groupId>org.nuiton.web</groupId> - <artifactId>nuiton-web</artifactId> - <type>jar</type> - <includes> - <include>**/war/Jetty*</include> - </includes> - </overlay> - <overlay> - <groupId>org.mortbay.jetty</groupId> - <artifactId>jetty-runner</artifactId> - <type>jar</type> - </overlay> - </overlays> - </configuration> - </plugin> - </plugins> </pluginManagement> </build> @@ -347,6 +323,165 @@ <profiles> <profile> + <id>assembly</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + <properties> + <embeddedWarDir> + ${project.build.directory}/echobase-embedded-${project.version} + </embeddedWarDir> + </properties> + <build> + <defaultGoal>verify</defaultGoal> + <plugins> + + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>generate-temp-workdir</id> + <phase>generate-resources</phase> + <configuration> + <target> + <mkdir dir="${embeddedWarDir}/WEB-INF/classes"/> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + + <!-- Compile jsp for embedded war --> + + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-jspc-maven-plugin</artifactId> + <version>${jettyPluginVersion}</version> + <executions> + <execution> + <id>jspc</id> + <goals> + <goal>jspc</goal> + </goals> + <configuration> + <generatedClasses> + ${embeddedWarDir}/WEB-INF/classes + </generatedClasses> + <webXmlFragment> + ${embeddedWarDir}/WEB-INF/webfrag.xml + </webXmlFragment> + <packageRoot>org.apache.jsp</packageRoot> + + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.apache.struts</groupId> + <artifactId>struts2-core</artifactId> + <version>${struts2Version}</version> + </dependency> + <dependency> + <groupId>com.jgeppert.struts2.jquery</groupId> + <artifactId>struts2-jquery-plugin</artifactId> + <version>${jqueryPluginVersion}</version> + </dependency> + <dependency> + <groupId>com.jgeppert.struts2.jquery</groupId> + <artifactId>struts2-jquery-grid-plugin</artifactId> + <version>${jqueryPluginVersion}</version> + </dependency> + <dependency> + <groupId>org.apache.struts</groupId> + <artifactId>struts2-sitemesh-plugin</artifactId> + <version>${struts2Version}</version> + </dependency> + </dependencies> + </plugin> + + <!-- Build embedded war --> + + <plugin> + <artifactId>maven-war-plugin</artifactId> + <executions> + <execution> + <id>pack-embedded-war</id> + <goals> + <goal>war</goal> + </goals> + <configuration> + <primaryArtifact>false</primaryArtifact> + <webappDirectory>${embeddedWarDir}</webappDirectory> + <archive> + <manifest> + <mainClass>org.nuiton.web.war.JettyLauncher</mainClass> + </manifest> + </archive> + <warName>echobase-ui-${project.version}-embedded</warName> + <webResources> + <webResource> + <directory>${embeddedWarDir}</directory> + <includes> + <include>**/*</include> + </includes> + <excludes> + <exclude>**/webfrag.xml</exclude> + </excludes> + </webResource> + </webResources> + <overlays> + <overlay> + <groupId>org.nuiton.web</groupId> + <artifactId>nuiton-web</artifactId> + <type>jar</type> + <includes> + <include>**/war/Jetty*</include> + </includes> + </overlay> + <overlay> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-runner</artifactId> + <type>jar</type> + </overlay> + </overlays> + </configuration> + </execution> + </executions> + </plugin> + + <!-- Build embedded zip --> + + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptors> + <descriptor>src/main/assembly/bin.xml</descriptor> + </descriptors> + <attach>false</attach> + <finalName>echobase-ui-${project.version}-embedded</finalName> + <appendAssemblyId>false</appendAssemblyId> + </configuration> + <executions> + <execution> + <id>create-assemblies</id> + <phase>verify</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + + <profile> <id>add-log-to-jetty</id> <activation> <file> Added: trunk/echobase-ui/src/main/assembly/bin.xml =================================================================== --- trunk/echobase-ui/src/main/assembly/bin.xml (rev 0) +++ trunk/echobase-ui/src/main/assembly/bin.xml 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,69 @@ +<!-- + #%L + EchoBase :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 - 2012 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% + --> +<assembly> + <id>bin</id> + <formats> + <format>zip</format> + </formats> + + <fileSets> + + <fileSet> + <directory>target</directory> + <outputDirectory>/</outputDirectory> + <fileMode>0755</fileMode> + <includes> + <include>echobase-ui-${project.version}-embedded.war</include> + </includes> + </fileSet> + + <fileSet> + <directory>target/classes</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>THIRD-PARTY.txt</include> + <include>LICENSE.txt</include> + </includes> + </fileSet> + + <fileSet> + <directory>src/main/assembly/dist</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>**/*.properties</include> + <include>**/*.txt</include> + </includes> + </fileSet> + + <fileSet> + <directory>src/main/assembly/dist</directory> + <outputDirectory>/</outputDirectory> + <fileMode>0755</fileMode> + <filtered>true</filtered> + <includes> + <include>**/*.sh</include> + <include>**/*.bat</include> + </includes> + </fileSet> + </fileSets> +</assembly> Property changes on: trunk/echobase-ui/src/main/assembly/bin.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/assembly/dist/README.txt =================================================================== --- trunk/echobase-ui/src/main/assembly/dist/README.txt (rev 0) +++ trunk/echobase-ui/src/main/assembly/dist/README.txt 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,20 @@ +============================= +EchoBase - ${project.version} +============================= + +Premier démarrage +----------------- + +Pour démarrer EchoBase : + +- Il faut avoir une JDK d'installer sur la machine cible. + +- la variable JDK_HOME doit être positionnée dans les variables d'environements. + +En suite on lance + +./startEchobase.sh (sous linux) + +ou + +startEchobase.bat (sous windows) Property changes on: trunk/echobase-ui/src/main/assembly/dist/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/assembly/dist/echobase.properties =================================================================== --- trunk/echobase-ui/src/main/assembly/dist/echobase.properties (rev 0) +++ trunk/echobase-ui/src/main/assembly/dist/echobase.properties 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,37 @@ +### +# #%L +# EchoBase :: UI +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2011 - 2012 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% +### +# +# Pollen - v ${project.version} Configuration +# +# See README.txt for more informations about howto custmize Pollen. +# + +# Where to find data +echobase.data.directory=. + +# Where to find war +echobase.war.location=${echobase.data.directory}/echobase-ui-${echobase.version}-embedded.war + +# To create embedded working db +echobase.embedded=true + Property changes on: trunk/echobase-ui/src/main/assembly/dist/echobase.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/assembly/dist/startEchobase.bat =================================================================== --- trunk/echobase-ui/src/main/assembly/dist/startEchobase.bat (rev 0) +++ trunk/echobase-ui/src/main/assembly/dist/startEchobase.bat 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,48 @@ +@REM ---------------------------------------------------------------------------- +@REM EchoBase Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM ---------------------------------------------------------------------------- +@echo off + +if not "%JDK_HOME%" == "" goto OkJHome + +echo. +echo ERROR: JDK_HOME not found in your environment. +echo Please set the JDK_HOME variable in your environment to match the +echo location of your Java installation +echo. +goto error + +:OkJHome +echo JDK_HOME defined to %JDK_HOME% + +if exist "%JDK_HOME%\bin\java.exe" goto doit + +echo. +echo ERROR: JDK_HOME is set to an invalid directory. +echo JDK_HOME = "%JDK_HOME%" +echo Please set the JDK_HOME variable in your environment to match the +echo location of your Java installation +echo. +goto error + +:error +set ERROR_CODE=1 +goto end + +:doit +set JAVA_COMMAND="%JDK_HOME%\bin\java.exe" +echo java.exe defined to %JAVA_COMMAND% + +set ECHOBASE_OPTS="-Xms512m -Xmx1024m -Dechobase.log.dir=./logs" +echo java options used : %ECHOBASE_OPTS% + +%JAVA_COMMAND% "%ECHOBASE_OPTS%" -jar echobase-ui-${project.version}-embedded.war +goto end + +:end + +pause +cmd /C exit /B %ERROR_CODE% Property changes on: trunk/echobase-ui/src/main/assembly/dist/startEchobase.bat ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/assembly/dist/startEchobase.sh =================================================================== --- trunk/echobase-ui/src/main/assembly/dist/startEchobase.sh (rev 0) +++ trunk/echobase-ui/src/main/assembly/dist/startEchobase.sh 2012-09-04 06:14:33 UTC (rev 609) @@ -0,0 +1,16 @@ +#!/bin/sh + +if [ ! -e $JDK_HOME/bin/java ]; then + echo "Do not find $JDK_HOME/bin/java, please add JDK_HOME environnement variable" + exit 1 +fi + +JAVA_EXEC=$JDK_HOME/bin/java + +OLDPWD=`pwd` +cd `dirname $0` +CURRENTPWD=`pwd` +ECHOBASE_OPTS="$JAVA_OPTS -Xms512m -Xmx10242m -Dechobase.log.dir=$CURRENTPWD/logs" +$JAVA_EXEC $ECHOBASE_OPTS -jar echobase-ui-${project.version}-embedded.war $* +cd "$OLDPWD" + Property changes on: trunk/echobase-ui/src/main/assembly/dist/startEchobase.sh ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native 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 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2012-09-04 06:14:33 UTC (rev 609) @@ -34,6 +34,7 @@ import fr.ifremer.echobase.services.EchoBaseServiceContext; import fr.ifremer.echobase.services.UserService; import fr.ifremer.echobase.services.embeddedapplication.EmbeddedApplicationService; +import fr.ifremer.echobase.services.workingDb.WorkingDbConfigurationService; import fr.ird.converter.FloatConverter; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.Converter; @@ -193,7 +194,8 @@ TopiaContext rootContext = context.getInternalRootContext(); Preconditions.checkNotNull(rootContext); - boolean schemaExist = dbMeta.getPersistenceHelper().isInternalSchemaCreated(rootContext); + boolean schemaExist = + EchoBaseEntityHelper.isInternalSchemaCreated(rootContext); if (schemaExist) { @@ -228,6 +230,17 @@ service.createDefaultUsers(); } + + if (configuration.isEmbedded()) { + + if (log.isInfoEnabled()) { + log.info("Will try t create default working db " + + "configuration for embedded db."); + } + // try to create a default embedded working db configuration + serviceContext.getService(WorkingDbConfigurationService.class). + createEmbeddedWorkingDbConfiguration(); + } } finally { serviceContext.setInternalTransaction(null); EchoBaseEntityHelper.closeConnection(tx); 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 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2012-09-04 06:14:33 UTC (rev 609) @@ -167,7 +167,8 @@ // creates a new topia root context from configuration TopiaContext rootContext = - EchobaseTopiaContexts.newWorkingDb(jdbcConfiguration); + EchobaseTopiaContexts.newWorkingDb( + jdbcConfiguration); // keep configuration is session set(PROPERTY_WORKING_DB_CONFIGURATION, jdbcConfiguration); Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/Connect.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/Connect.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/Connect.java 2012-09-04 06:14:33 UTC (rev 609) @@ -24,8 +24,10 @@ */ import com.opensymphony.xwork2.interceptor.annotations.InputConfig; +import fr.ifremer.echobase.entities.DriverType; import fr.ifremer.echobase.persistence.EchoBaseEntityHelper; import fr.ifremer.echobase.persistence.JdbcConfiguration; +import org.apache.commons.lang.StringUtils; import java.sql.SQLException; @@ -61,7 +63,7 @@ EchoBaseEntityHelper.checkJDBCConnection(jdbcConf); getEchoBaseSession().initWorkingDb(jdbcConf); addFlashMessage(_("echobase.info.workingDbconfiguration.connected", - conf.getUrl())); + conf.getUrl())); result = SUCCESS; } catch (SQLException e) { @@ -79,11 +81,8 @@ public void validate() { jdbcConf = JdbcConfiguration.newConfig( - getConf().getUrl(), - getConf().getLogin(), - password, - getConf().getDriverType() - ); + getConf().getDriverType(), getConf().getUrl(), + getConf().getLogin(), password); // check connexion is ok try { @@ -95,6 +94,19 @@ _("echobase.error.workingDbConfiguration.couldNotConnect", e.getMessage())); } + } + @Override + public void prepare() throws Exception { + + super.prepare(); + + if (DriverType.H2.equals(conf.getDriverType()) && + StringUtils.isBlank(getPassword())) { + + // use a default h2 password + setPassword("sa"); + } + } } Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/DownloadDriver.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/DownloadDriver.java 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/DownloadDriver.java 2012-09-04 06:14:33 UTC (rev 609) @@ -1,5 +1,28 @@ package fr.ifremer.echobase.ui.actions.workingDb; +/* + * #%L + * EchoBase :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 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% + */ + import fr.ifremer.echobase.EchoBaseConfiguration; import fr.ifremer.echobase.persistence.JdbcConfiguration; import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/DownloadDriver.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties =================================================================== --- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2012-09-04 06:14:33 UTC (rev 609) @@ -154,6 +154,7 @@ echobase.error.workingDbConfiguration.url.already.exists= echobase.error.workingDbConfiguration.url.required= echobase.header.request.result= +echobase.info.click.to.select=Vous pouvez sélectionner la valeur en un simple click puis la copier (Ctrl-C) echobase.info.dbeditor.propertyDiffsResult= echobase.info.downloadEchoBase=Téléchargement de l'application et des fichiers d'import echobase.info.echoBaseForge=Gestion du projet 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 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2012-09-04 06:14:33 UTC (rev 609) @@ -32,8 +32,8 @@ echobase.action.show.import.documentation=Accéder à la documentation de l'import echobase.action.toEnglish=Utiliser la version anglaise echobase.action.toFrench=Utiliser la version française -echobase.action.usingEnglish=Version anglaise utilisé -echobase.action.usingFrench=Version française utilisé +echobase.action.usingEnglish=Version anglaise utilisée +echobase.action.usingFrench=Version française utilisée echobase.action.workingDbconfiguration.connect=Sélectionner une base de travail echobase.action.workingDbconfiguration.disconnect=Se déconnecter echobase.action.workingDbconfiguration.downloadDriver=Télécharger le pilote jdbc @@ -42,32 +42,32 @@ echobase.common.acquisitionSoftwareVersionME70=acquisitionSoftwareVersion (ME70 instrument) echobase.common.addDataAcquisition=Toujours créer des DataAcqusitions echobase.common.admin=Administrateur -echobase.common.areaOfOperation= -echobase.common.author= -echobase.common.authorEmail= +echobase.common.areaOfOperation=AreaOfOperation +echobase.common.author=Auteur +echobase.common.authorEmail=Courriel de l'auteur echobase.common.biometrySampleFile= echobase.common.cellMapsFile= echobase.common.cellPositionReference=cellPositionReference echobase.common.cellRegionAssociationFile= echobase.common.cellRegionResultFile= echobase.common.cellRegionsFile= -echobase.common.dataCentre= -echobase.common.dataCentreEmail= -echobase.common.dataProcessing= +echobase.common.dataCentre=Centre de données +echobase.common.dataCentreEmail=Courriel du centre de données +echobase.common.dataProcessing=DataProcessing echobase.common.dataProcessingNotes=dataProcessingNotes -echobase.common.datum= +echobase.common.datum=Datum echobase.common.digitThreshold=digitThreshold -echobase.common.distributionStatement= +echobase.common.distributionStatement=distributionStatement echobase.common.echotypeFile= -echobase.common.email=Email -echobase.common.entityId= -echobase.common.entityType=Type d'entité +echobase.common.email=Courriel +echobase.common.entityId=Identifiant de l'entité +echobase.common.entityType=Type de l'entité echobase.common.esduByEchotypeAndSpeciesCategoryFile= echobase.common.esduByEchotypeFile= echobase.common.esduBySpeciesAndAgeCategoryFile= echobase.common.esduBySpeciesAndSizeCategoryFile= echobase.common.gearMetadataFile= -echobase.common.id= +echobase.common.id=Identifiant echobase.common.importDataMode=Type d'import echobase.common.importDbFile= echobase.common.importError=Un erreur est survenue pendant l'import \: @@ -80,44 +80,44 @@ echobase.common.importNotes=Remarques sur l'import echobase.common.importResult=Résultat de l'import echobase.common.inProgress=en cours... -echobase.common.institution= +echobase.common.institution=Institution echobase.common.jdbcDriver=Nom du pilote jdbc echobase.common.jdbcLogin=Login de connexion echobase.common.jdbcPassword=Mot de passe echobase.common.jdbcUrl=Url de connexion -echobase.common.keywords= -echobase.common.lastModifiedDate= -echobase.common.lastModifiedUser= +echobase.common.keywords=Môts clefs +echobase.common.lastModifiedDate=Date de dernière modification +echobase.common.lastModifiedUser=Utilisateur de dernière modification echobase.common.lengthAgeKeyFile= echobase.common.lengthWeightKeyFile= -echobase.common.litteratureReferences= +echobase.common.litteratureReferences=Références echobase.common.loggedDataDatatype=loggedDataDatatype echobase.common.loggedDataFormat=loggedDataFormat -echobase.common.mission= -echobase.common.missionAbstract= -echobase.common.modificationDate= -echobase.common.modificationText= -echobase.common.modificationUser= +echobase.common.mission=Mission +echobase.common.missionAbstract=Résumé de la mission +echobase.common.modificationDate=Date de modification +echobase.common.modificationText=Modification +echobase.common.modificationUser=Utilisateur echobase.common.moviesFile= -echobase.common.name= +echobase.common.name=Nom echobase.common.operationFile= echobase.common.operationMetadataFile= -echobase.common.organisationLevelAcknowledgements= -echobase.common.organisationReferences= +echobase.common.organisationLevelAcknowledgements=organisationLevelAcknowledgements +echobase.common.organisationReferences=Références organisation echobase.common.password=Mot de passe echobase.common.pilotVersion=Version du pilote jdbc echobase.common.pingDutyCycle=pingDutyCycle -echobase.common.platform= -echobase.common.principalInvestigator= -echobase.common.principalInvestigatorEmail= +echobase.common.platform=Platform +echobase.common.principalInvestigator=Chercheur +echobase.common.principalInvestigatorEmail=Courriel du chercheur echobase.common.processingDescription=processingDescription echobase.common.processingTemplate=processingTemplate -echobase.common.project= +echobase.common.project=Projet echobase.common.resultLabel=Result label echobase.common.soundSpeedCalculationsER60=soundSpeedCalculations (ER60 instrument) echobase.common.soundSpeedCalculationsME70=soundSpeedCalculations (ME70 instrument) echobase.common.sounderConstant=sounderConstant -echobase.common.source= +echobase.common.source=Source echobase.common.subSampleFile= echobase.common.tableDatas= echobase.common.totalSampleFile= @@ -129,8 +129,8 @@ echobase.common.transitFile= echobase.common.transitRelatedActivity=RelatedActivity (transit) echobase.common.user=Utilisateur -echobase.common.vessel= -echobase.common.voyage= +echobase.common.vessel=Navire +echobase.common.voyage=Campagne echobase.common.voyageDescription=Description echobase.common.voyageFile= echobase.confirm.delete.query=Confirmer la suppression de la requète suivante @@ -154,6 +154,7 @@ echobase.error.workingDbConfiguration.url.already.exists=Une connexion existe déjà avec cette url echobase.error.workingDbConfiguration.url.required=Url obligatoire echobase.header.request.result=Résultat de la requète sql +echobase.info.click.to.select=Vous pouvez sélectionner la valeur en un simple click puis la copier (Ctrl-C) echobase.info.dbeditor.propertyDiffsResult=Résultat d'import de données echobase.info.downloadEchoBase=Téléchargement de l'application et des fichiers d'import echobase.info.echoBaseForge=Gestion du projet Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/information.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/information.jsp 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/information.jsp 2012-09-04 06:14:33 UTC (rev 609) @@ -58,15 +58,21 @@ <fieldset> <legend><s:text name="echobase.legend.connectionToDb.detail"/></legend> <s:label key="dbConfiguration.url" - label='%{getText("echobase.common.jdbcUrl")}'/> + label='%{getText("echobase.common.jdbcUrl")} (*)'/> <s:label key="dbConfiguration.login" - label='%{getText("echobase.common.jdbcLogin")}'/> + label='%{getText("echobase.common.jdbcLogin")} (*)'/> <s:label key="dbConfiguration.password" - label='%{getText("echobase.common.jdbcPassword")}'/> + label='%{getText("echobase.common.jdbcPassword")} (*)'/> <s:label key="dbConfiguration.driverType.driverClass.name" - label='%{getText("echobase.common.jdbcDriver")}'/> - <s:label key="pilotVersion" id='dbConfiguration_pilotVersion' + label='%{getText("echobase.common.jdbcDriver")} (*)'/> + <s:label key="pilotVersion" label='%{getText("echobase.common.pilotVersion")}'/> + <br/> + <div class="cleanBoth help"> + <label> + (*) <s:text name="echobase.info.click.to.select"/> + </label> + </div> </fieldset> <br/> @@ -84,9 +90,6 @@ </ul> </s:form> -<%--<s:a namespace="/workingDb" action="downloadDriver">--%> -<%--<s:text name="echobase.action.workingDb.downloadDriver"/>--%> -<%--</s:a>--%> Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/manage.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/manage.jsp 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/manage.jsp 2012-09-04 06:14:33 UTC (rev 609) @@ -86,14 +86,14 @@ readonly="%{confExists}" label="%{getText('echobase.label.workingDbConfiguration.url')}"/> + <s:textarea key="conf.description" required="true" cols="160" rows="4" + readonly="%{confExists}" + label="%{getText('echobase.label.workingDbConfiguration.description')}"/> + <s:textfield key="conf.login" required="true" size="80" readonly="%{confExists}" label="%{getText('echobase.label.workingDbConfiguration.login')}"/> - <s:textarea key="conf.description" required="true" cols="160" rows="4" - readonly="%{confExists}" - label="%{getText('echobase.label.workingDbConfiguration.description')}"/> - <s:if test="confExists"> <s:password key="password" required="true" size="80" label="%{getText('echobase.label.workingDbConfiguration.password')}"/> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-09-03 20:17:30 UTC (rev 608) +++ trunk/pom.xml 2012-09-04 06:14:33 UTC (rev 609) @@ -65,6 +65,19 @@ </developers> + <contributors> + <contributor> + <name>Mathieu Doray</name> + <email>mathieu dot doray at ifremer dot fr</email> + <organization>Ifremer</organization> + <organizationUrl>http://ifremer.fr</organizationUrl> + <roles> + <role>document writer</role> + </roles> + <timezone>Europe/Paris</timezone> + </contributor> + </contributors> + <scm> <url>http://svn.forge.codelutin.com/svn/echobase/trunk</url> <connection>
participants (1)
-
tchemit@users.forge.codelutin.com