Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
-
a122771a
by Tony CHEMIT at 2017-04-10T13:31:27+02:00
27 changed files:
- pom.xml
- t3-actions/pom.xml
- t3-domain/pom.xml
- t3-domain/src/main/java/fr/ird/t3/T3Config.java
- t3-domain/src/main/java/fr/ird/t3/T3SqlScriptsImporter.java
- t3-domain/src/main/java/fr/ird/t3/entities/CountAndWeight.java
- t3-domain/src/main/java/fr/ird/t3/entities/T3JdbcH2Helper.java → t3-domain/src/main/java/fr/ird/t3/entities/T3JdbcHelper.java
- t3-domain/src/main/java/fr/ird/t3/entities/T3ScriptHelper.java
- t3-domain/src/main/java/fr/ird/t3/entities/T3TopiaApplicationContext.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/RfUsageStatus.java
- t3-domain/src/main/java/fr/ird/t3/entities/reference/WeightCategories.java
- t3-domain/src/main/java/fr/ird/t3/services/UserService.java
- t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackSupport.java
- t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_0.java
- t3-domain/src/main/resources/t3-datadb.properties
- t3-input-avdthv33/pom.xml
- t3-input-avdthv35/pom.xml
- t3-input-avdthv36/pom.xml
- t3-installer/pom.xml
- + t3-installer/src/main/assembly/dist/debug.sh
- t3-installer/src/main/java/fr/ird/t3/tools/T3ApplicationInstaller.java
- t3-installer/src/main/resources/log4j.properties
- t3-output-balbayav32/pom.xml
- t3-test/pom.xml
- t3-web/pom.xml
- t3-web/src/main/java/fr/ird/t3/web/T3ApplicationListener.java
- t3-web/src/main/resources/i18n/t3-web_fr_FR.properties
Changes:
| ... | ... | @@ -114,7 +114,7 @@ |
| 114 | 114 |
<struts2Version>2.3.14</struts2Version>
|
| 115 | 115 |
<jqueryPluginVersion>3.5.1</jqueryPluginVersion>
|
| 116 | 116 |
<h2Version>1.3.176</h2Version>
|
| 117 |
- <postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion>
|
|
| 117 |
+ <postgresqlVersion>9.4.1212.jre7</postgresqlVersion>
|
|
| 118 | 118 |
<xworkVersion>2.3.31</xworkVersion>
|
| 119 | 119 |
<hibernateVersion>5.1.3.Final</hibernateVersion>
|
| 120 | 120 |
<slf4jVersion>1.7.25</slf4jVersion>
|
| ... | ... | @@ -274,7 +274,7 @@ |
| 274 | 274 |
<!-- base postgres -->
|
| 275 | 275 |
|
| 276 | 276 |
<dependency>
|
| 277 |
- <groupId>postgresql</groupId>
|
|
| 277 |
+ <groupId>org.postgresql</groupId>
|
|
| 278 | 278 |
<artifactId>postgresql</artifactId>
|
| 279 | 279 |
<version>${postgresqlVersion}</version>
|
| 280 | 280 |
</dependency>
|
| ... | ... | @@ -120,7 +120,7 @@ |
| 120 | 120 |
</dependency>
|
| 121 | 121 |
|
| 122 | 122 |
<dependency>
|
| 123 |
- <groupId>postgresql</groupId>
|
|
| 123 |
+ <groupId>org.postgresql</groupId>
|
|
| 124 | 124 |
<artifactId>postgresql</artifactId>
|
| 125 | 125 |
<scope>test</scope>
|
| 126 | 126 |
</dependency>
|
| ... | ... | @@ -161,7 +161,7 @@ |
| 161 | 161 |
</dependency>
|
| 162 | 162 |
|
| 163 | 163 |
<dependency>
|
| 164 |
- <groupId>postgresql</groupId>
|
|
| 164 |
+ <groupId>org.postgresql</groupId>
|
|
| 165 | 165 |
<artifactId>postgresql</artifactId>
|
| 166 | 166 |
<scope>test</scope>
|
| 167 | 167 |
</dependency>
|
| ... | ... | @@ -28,7 +28,6 @@ import java.io.BufferedReader; |
| 28 | 28 |
import java.io.File;
|
| 29 | 29 |
import java.io.IOException;
|
| 30 | 30 |
import java.nio.file.Files;
|
| 31 |
-import java.util.Arrays;
|
|
| 32 | 31 |
import java.util.List;
|
| 33 | 32 |
import java.util.Map;
|
| 34 | 33 |
import java.util.Properties;
|
| ... | ... | @@ -145,11 +144,11 @@ public class T3Config extends GeneratedT3Config { |
| 145 | 144 |
}
|
| 146 | 145 |
|
| 147 | 146 |
public List<Integer> getLevel2DefaultSpeciesAsList() {
|
| 148 |
- return Arrays.asList(getLevel2DefaultSpecies());
|
|
| 147 |
+ return get().getOptionAsList(T3ConfigOption.LEVEL2_DEFAULT_SPECIES.getKey()).getOptionAsInt();
|
|
| 149 | 148 |
}
|
| 150 | 149 |
|
| 151 | 150 |
public List<Integer> getLevel3DefaultSpeciesAsList() {
|
| 152 |
- return Arrays.asList(getLevel3DefaultSpecies());
|
|
| 151 |
+ return get().getOptionAsList(T3ConfigOption.LEVEL3_DEFAULT_SPECIES.getKey()).getOptionAsInt();
|
|
| 153 | 152 |
}
|
| 154 | 153 |
|
| 155 | 154 |
public boolean isUpdateSchema() {
|
| ... | ... | @@ -22,17 +22,16 @@ package fr.ird.t3; |
| 22 | 22 |
*/
|
| 23 | 23 |
|
| 24 | 24 |
import com.google.common.base.Preconditions;
|
| 25 |
-import com.google.common.base.Predicate;
|
|
| 26 | 25 |
import com.google.common.collect.ImmutableSet;
|
| 27 | 26 |
import com.google.common.collect.Lists;
|
| 28 | 27 |
import fr.ird.t3.entities.T3ScriptHelper;
|
| 29 | 28 |
import fr.ird.t3.services.T3ServiceContext;
|
| 30 | 29 |
import java.io.File;
|
| 31 |
-import java.io.FilenameFilter;
|
|
| 32 | 30 |
import java.io.IOException;
|
| 33 | 31 |
import java.nio.file.Paths;
|
| 34 | 32 |
import java.util.Collections;
|
| 35 | 33 |
import java.util.List;
|
| 34 |
+import java.util.function.Predicate;
|
|
| 36 | 35 |
import org.apache.commons.logging.Log;
|
| 37 | 36 |
import org.apache.commons.logging.LogFactory;
|
| 38 | 37 |
import org.nuiton.topia.persistence.TopiaException;
|
| ... | ... | @@ -44,7 +43,7 @@ import org.nuiton.version.Version; |
| 44 | 43 |
* <p>
|
| 45 | 44 |
* Created on 30/01/16.
|
| 46 | 45 |
*
|
| 47 |
- * @author Tony Chemit - chemit@codelutin.com
|
|
| 46 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 48 | 47 |
* @since 2.0
|
| 49 | 48 |
*/
|
| 50 | 49 |
public class T3SqlScriptsImporter {
|
| ... | ... | @@ -56,12 +55,7 @@ public class T3SqlScriptsImporter { |
| 56 | 55 |
|
| 57 | 56 |
protected ImmutableSet<File> scriptsFile;
|
| 58 | 57 |
|
| 59 |
- public static final Predicate<File> SKIP_SPECIES_LENGTH_STEP_FILE = new Predicate<File>() {
|
|
| 60 |
- @Override
|
|
| 61 |
- public boolean apply(File input) {
|
|
| 62 |
- return !input.getName().toLowerCase().contains("specieslengthstep.sql");
|
|
| 63 |
- }
|
|
| 64 |
- };
|
|
| 58 |
+ public static final Predicate<File> SKIP_SPECIES_LENGTH_STEP_FILE = input -> !input.getName().toLowerCase().contains("specieslengthstep.sql");
|
|
| 65 | 59 |
|
| 66 | 60 |
public static void importReferential(File buildRootDirectory, T3ServiceContext serviceContext, Predicate<File> filePredicate) throws IOException, TopiaException {
|
| 67 | 61 |
|
| ... | ... | @@ -98,12 +92,7 @@ public class T3SqlScriptsImporter { |
| 98 | 92 |
|
| 99 | 93 |
public void prepare() {
|
| 100 | 94 |
|
| 101 |
- List<String> scriptsName = Lists.newArrayList(scriptsDirectory.list(new FilenameFilter() {
|
|
| 102 |
- @Override
|
|
| 103 |
- public boolean accept(File dir, String name) {
|
|
| 104 |
- return name.endsWith(".sql");
|
|
| 105 |
- }
|
|
| 106 |
- }));
|
|
| 95 |
+ List<String> scriptsName = Lists.newArrayList(scriptsDirectory.list((dir, name) -> name.endsWith(".sql")));
|
|
| 107 | 96 |
Collections.sort(scriptsName);
|
| 108 | 97 |
ImmutableSet.Builder<File> filesBuilder = ImmutableSet.builder();
|
| 109 | 98 |
|
| ... | ... | @@ -117,20 +106,20 @@ public class T3SqlScriptsImporter { |
| 117 | 106 |
return scriptsFile;
|
| 118 | 107 |
}
|
| 119 | 108 |
|
| 120 |
- public void importScripts(T3ServiceContext serviceContext, Predicate<File> filePredicate) throws IOException, TopiaException {
|
|
| 109 |
+ public void importScripts(T3ServiceContext serviceContext, Predicate<File> filePredicate) throws IOException {
|
|
| 121 | 110 |
|
| 122 | 111 |
for (File scriptFile : scriptsFile) {
|
| 123 | 112 |
if (log.isInfoEnabled()) {
|
| 124 | 113 |
log.info(" o Loading sql script ...(" + scriptFile.getName() + ")");
|
| 125 | 114 |
}
|
| 126 |
- if (filePredicate.apply(scriptFile)) {
|
|
| 115 |
+ if (filePredicate.test(scriptFile)) {
|
|
| 127 | 116 |
loadScript(serviceContext, scriptFile);
|
| 128 | 117 |
}
|
| 129 | 118 |
}
|
| 130 | 119 |
|
| 131 | 120 |
}
|
| 132 | 121 |
|
| 133 |
- protected void loadScript(T3ServiceContext serviceContext, File script) throws TopiaException, IOException {
|
|
| 122 |
+ protected void loadScript(T3ServiceContext serviceContext, File script) throws IOException {
|
|
| 134 | 123 |
|
| 135 | 124 |
T3ScriptHelper.loadScript(serviceContext.getApplicationContext(), script);
|
| 136 | 125 |
}
|
| ... | ... | @@ -24,7 +24,7 @@ package fr.ird.t3.entities; |
| 24 | 24 |
/**
|
| 25 | 25 |
* Created on 26/01/16.
|
| 26 | 26 |
*
|
| 27 |
- * @author Tony Chemit - chemit@codelutin.com
|
|
| 27 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 28 | 28 |
* @since 2.0
|
| 29 | 29 |
*/
|
| 30 | 30 |
public class CountAndWeight {
|
| ... | ... | @@ -22,21 +22,33 @@ package fr.ird.t3.entities; |
| 22 | 22 |
*/
|
| 23 | 23 |
|
| 24 | 24 |
import java.io.File;
|
| 25 |
+import java.sql.Connection;
|
|
| 26 |
+import java.sql.PreparedStatement;
|
|
| 27 |
+import java.sql.SQLException;
|
|
| 25 | 28 |
import org.nuiton.topia.persistence.jdbc.JdbcConfiguration;
|
| 26 |
-import org.nuiton.topia.persistence.jdbc.JdbcH2Helper;
|
|
| 29 |
+import org.nuiton.topia.persistence.jdbc.JdbcHelper;
|
|
| 27 | 30 |
|
| 28 | 31 |
/**
|
| 29 | 32 |
* Created by tchemit on 03/04/17.
|
| 30 | 33 |
*
|
| 31 | 34 |
* @author Tony Chemit - dev@tchemit.fr
|
| 32 | 35 |
*/
|
| 33 |
-public class T3JdbcH2Helper extends JdbcH2Helper {
|
|
| 36 |
+public class T3JdbcHelper extends JdbcHelper {
|
|
| 34 | 37 |
|
| 35 |
- public T3JdbcH2Helper(JdbcConfiguration jdbcConfiguration) {
|
|
| 38 |
+ public T3JdbcHelper(JdbcConfiguration jdbcConfiguration) {
|
|
| 36 | 39 |
super(jdbcConfiguration);
|
| 37 | 40 |
}
|
| 38 | 41 |
|
| 39 |
- @Override
|
|
| 42 |
+ public void executeSql(String sql) {
|
|
| 43 |
+ try (Connection connection = openConnection()) {
|
|
| 44 |
+ try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
|
| 45 |
+ preparedStatement.execute();
|
|
| 46 |
+ }
|
|
| 47 |
+ } catch (SQLException e) {
|
|
| 48 |
+ throw new RuntimeException(e);
|
|
| 49 |
+ }
|
|
| 50 |
+ }
|
|
| 51 |
+ |
|
| 40 | 52 |
public void backup(File file, boolean compress) {
|
| 41 | 53 |
String options = "";
|
| 42 | 54 |
if (compress) {
|
| ... | ... | @@ -44,4 +56,5 @@ public class T3JdbcH2Helper extends JdbcH2Helper { |
| 44 | 56 |
}
|
| 45 | 57 |
runSelectOnString("SCRIPT TO '" + file.getAbsolutePath() + "'" + options);
|
| 46 | 58 |
}
|
| 59 |
+ |
|
| 47 | 60 |
}
|
| ... | ... | @@ -35,10 +35,7 @@ import java.sql.Statement; |
| 35 | 35 |
import org.apache.commons.io.IOUtils;
|
| 36 | 36 |
import org.apache.commons.logging.Log;
|
| 37 | 37 |
import org.apache.commons.logging.LogFactory;
|
| 38 |
-import org.nuiton.topia.persistence.TopiaApplicationContext;
|
|
| 39 | 38 |
import org.nuiton.topia.persistence.TopiaException;
|
| 40 |
-import org.nuiton.topia.persistence.jdbc.JdbcH2Helper;
|
|
| 41 |
-import org.nuiton.topia.persistence.jdbc.JdbcHelper;
|
|
| 42 | 39 |
import org.nuiton.topia.persistence.support.TopiaSqlWork;
|
| 43 | 40 |
import org.nuiton.util.sql.SqlFileReader;
|
| 44 | 41 |
|
| ... | ... | @@ -58,38 +55,35 @@ public class T3ScriptHelper { |
| 58 | 55 |
if (log.isInfoEnabled()) {
|
| 59 | 56 |
log.info("Export database to file " + outputFile);
|
| 60 | 57 |
}
|
| 61 |
- new T3JdbcH2Helper(rootTx.getConfiguration()).backup(outputFile, false);
|
|
| 58 |
+ rootTx.newJdbcHelper().backup(outputFile, false);
|
|
| 62 | 59 |
}
|
| 63 | 60 |
|
| 64 |
- public static void loadReferentiel(TopiaApplicationContext tx, String location) throws IOException, TopiaException {
|
|
| 61 |
+ public static void loadReferentiel(T3TopiaApplicationContext tx, String location) throws IOException, TopiaException {
|
|
| 65 | 62 |
try (InputStream resourceAsStream = T3EntityHelper.class.getResourceAsStream(location)) {
|
| 66 | 63 |
loadScript(tx, resourceAsStream);
|
| 67 | 64 |
}
|
| 68 | 65 |
}
|
| 69 | 66 |
|
| 70 |
- public static void loadScript(TopiaApplicationContext tx, InputStream resourceAsStream) throws IOException, TopiaException {
|
|
| 67 |
+ public static void loadScript(T3TopiaApplicationContext tx, InputStream resourceAsStream) throws IOException, TopiaException {
|
|
| 71 | 68 |
|
| 72 | 69 |
String script = IOUtils.toString(resourceAsStream, Charsets.UTF_8.name());
|
| 73 |
- new JdbcHelper(tx.getConfiguration()).runUpdate(script);
|
|
| 74 | 70 |
|
| 75 |
- }
|
|
| 71 |
+ tx.newJdbcHelper().executeSql(script);
|
|
| 76 | 72 |
|
| 77 |
- public static void loadScript(TopiaApplicationContext tx, File file) throws IOException, TopiaException {
|
|
| 73 |
+ }
|
|
| 78 | 74 |
|
| 79 |
- InputStream resourceAsStream = new FileInputStream(file);
|
|
| 75 |
+ public static void loadScript(T3TopiaApplicationContext tx, File file) throws IOException, TopiaException {
|
|
| 80 | 76 |
|
| 81 |
- try {
|
|
| 77 |
+ try (InputStream resourceAsStream = new FileInputStream(file)) {
|
|
| 82 | 78 |
loadScript(tx, resourceAsStream);
|
| 83 |
- } finally {
|
|
| 84 |
- resourceAsStream.close();
|
|
| 85 | 79 |
}
|
| 86 | 80 |
}
|
| 87 | 81 |
|
| 88 |
- public static void loadScriptLineByLine(TopiaApplicationContext tx, File script, PropertyChangeListener listener) throws TopiaException, IOException {
|
|
| 82 |
+ public static void loadScriptLineByLine(T3TopiaApplicationContext tx, File script, PropertyChangeListener listener) throws TopiaException, IOException {
|
|
| 89 | 83 |
|
| 90 | 84 |
try (BufferedReader stream = new BufferedReader(new InputStreamReader(new FileInputStream(script), Charsets.UTF_8))) {
|
| 91 | 85 |
|
| 92 |
- try (T3TopiaPersistenceContext persistenceContext = (T3TopiaPersistenceContext) tx.newPersistenceContext()) {
|
|
| 86 |
+ try (T3TopiaPersistenceContext persistenceContext = tx.newPersistenceContext()) {
|
|
| 93 | 87 |
|
| 94 | 88 |
persistenceContext.getSqlSupport().doSqlWork(new TopiaSqlWork() {
|
| 95 | 89 |
|
| ... | ... | @@ -106,6 +106,10 @@ public class T3TopiaApplicationContext extends AbstractT3TopiaApplicationContext |
| 106 | 106 |
return new T3TopiaApplicationContext(topiaConfiguration);
|
| 107 | 107 |
}
|
| 108 | 108 |
|
| 109 |
+ public T3JdbcHelper newJdbcHelper() {
|
|
| 110 |
+ return new T3JdbcHelper(getConfiguration());
|
|
| 111 |
+ }
|
|
| 112 |
+ |
|
| 109 | 113 |
private T3TopiaApplicationContext(TopiaConfiguration topiaConfiguration) {
|
| 110 | 114 |
super(topiaConfiguration);
|
| 111 | 115 |
}
|
| ... | ... | @@ -26,7 +26,7 @@ package fr.ird.t3.entities.data; |
| 26 | 26 |
* <p>
|
| 27 | 27 |
* Created on 01/02/16.
|
| 28 | 28 |
*
|
| 29 |
- * @author Tony Chemit - chemit@codelutin.com
|
|
| 29 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 30 | 30 |
* @see SampleWell#getRfMinus10UsageStatus()
|
| 31 | 31 |
* @see SampleWell#getRfPlus10UsageStatus() ()
|
| 32 | 32 |
* @since 2.0
|
| ... | ... | @@ -29,7 +29,7 @@ import java.util.List; |
| 29 | 29 |
/**
|
| 30 | 30 |
* Created on 25/01/16.
|
| 31 | 31 |
*
|
| 32 |
- * @author Tony Chemit - chemit@codelutin.com
|
|
| 32 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 33 | 33 |
*/
|
| 34 | 34 |
public class WeightCategories {
|
| 35 | 35 |
|
| ... | ... | @@ -68,7 +68,7 @@ public class UserService extends T3ServiceSupport implements T3UserTopiaPersiste |
| 68 | 68 |
user.setPassword(newPassword);
|
| 69 | 69 |
T3User userToSave = userDAO.create(user);
|
| 70 | 70 |
userDAO.update(userToSave);
|
| 71 |
- getT3TopiaPersistenceContext().get().commit();
|
|
| 71 |
+ commit();
|
|
| 72 | 72 |
}
|
| 73 | 73 |
|
| 74 | 74 |
public void updateUser(T3User user) throws Exception {
|
| ... | ... | @@ -84,7 +84,7 @@ public class UserService extends T3ServiceSupport implements T3UserTopiaPersiste |
| 84 | 84 |
userToSave.setPassword(encodePassword(user.getPassword()));
|
| 85 | 85 |
}
|
| 86 | 86 |
userDAO.update(userToSave);
|
| 87 |
- getT3TopiaPersistenceContext().get().commit();
|
|
| 87 |
+ commit();
|
|
| 88 | 88 |
}
|
| 89 | 89 |
|
| 90 | 90 |
public void deleteUser(String userId) throws Exception {
|
| ... | ... | @@ -93,18 +93,17 @@ public class UserService extends T3ServiceSupport implements T3UserTopiaPersiste |
| 93 | 93 |
throw new IllegalArgumentException("Could not find user with id : " + userId);
|
| 94 | 94 |
}
|
| 95 | 95 |
userDAO.delete(user);
|
| 96 |
- getT3TopiaPersistenceContext().get().commit();
|
|
| 96 |
+ commit();
|
|
| 97 | 97 |
}
|
| 98 | 98 |
|
| 99 |
- public void addUserT3Database(String userId,
|
|
| 100 |
- UserT3Database dbConfiguration) throws Exception {
|
|
| 99 |
+ public void addUserT3Database(String userId, UserT3Database dbConfiguration) throws Exception {
|
|
| 101 | 100 |
T3User user = getUserById(userId);
|
| 102 | 101 |
Preconditions.checkNotNull(user,
|
| 103 | 102 |
"Could not find user with id : " + userId);
|
| 104 | 103 |
UserT3Database dbConfigurationtoSave = userT3DatabaseDAODAO.create(dbConfiguration);
|
| 105 | 104 |
user.addUserT3Database(dbConfigurationtoSave);
|
| 106 | 105 |
userDAO.update(user);
|
| 107 |
- getT3TopiaPersistenceContext().get().commit();
|
|
| 106 |
+ commit();
|
|
| 108 | 107 |
}
|
| 109 | 108 |
|
| 110 | 109 |
public void updateUserT3Database(UserT3Database dbConfiguration) throws Exception {
|
| ... | ... | @@ -113,11 +112,10 @@ public class UserService extends T3ServiceSupport implements T3UserTopiaPersiste |
| 113 | 112 |
UserT3Database dbConfigurationtoSave = getUserT3Database(dbconfigurationId);
|
| 114 | 113 |
updateDatabaseConfiguration(dbConfiguration, dbConfigurationtoSave);
|
| 115 | 114 |
userT3DatabaseDAODAO.update(dbConfigurationtoSave);
|
| 116 |
- getT3TopiaPersistenceContext().get().commit();
|
|
| 115 |
+ commit();
|
|
| 117 | 116 |
}
|
| 118 | 117 |
|
| 119 |
- public void removeUserT3Database(String userId,
|
|
| 120 |
- String dbconfigurationId) throws Exception {
|
|
| 118 |
+ public void removeUserT3Database(String userId, String dbconfigurationId) throws Exception {
|
|
| 121 | 119 |
T3User user = getUserById(userId);
|
| 122 | 120 |
Preconditions.checkNotNull(user,
|
| 123 | 121 |
"Could not find user with id : " + userId);
|
| ... | ... | @@ -126,11 +124,10 @@ public class UserService extends T3ServiceSupport implements T3UserTopiaPersiste |
| 126 | 124 |
getUserT3Database(dbconfigurationId);
|
| 127 | 125 |
user.removeUserT3Database(dbConfigurationtoSave);
|
| 128 | 126 |
userDAO.update(user);
|
| 129 |
- getT3TopiaPersistenceContext().get().commit();
|
|
| 127 |
+ commit();
|
|
| 130 | 128 |
}
|
| 131 | 129 |
|
| 132 |
- public void addOutputDatabase(String userId,
|
|
| 133 |
- UserOutputDatabase dbConfiguration) throws Exception {
|
|
| 130 |
+ public void addOutputDatabase(String userId, UserOutputDatabase dbConfiguration) throws Exception {
|
|
| 134 | 131 |
T3User user = getUserById(userId);
|
| 135 | 132 |
Preconditions.checkNotNull(user,
|
| 136 | 133 |
"Could not find user with id : " + userId);
|
| ... | ... | @@ -138,7 +135,7 @@ public class UserService extends T3ServiceSupport implements T3UserTopiaPersiste |
| 138 | 135 |
userOutputDatabaseDAO.create(dbConfiguration);
|
| 139 | 136 |
user.addUserOutputDatabase(dbConfigurationtoSave);
|
| 140 | 137 |
userDAO.update(user);
|
| 141 |
- getT3UserTopiaPersistenceContext().get().commit();
|
|
| 138 |
+ commit();
|
|
| 142 | 139 |
}
|
| 143 | 140 |
|
| 144 | 141 |
public void updateUserOuputDatabase(
|
| ... | ... | @@ -149,11 +146,10 @@ public class UserService extends T3ServiceSupport implements T3UserTopiaPersiste |
| 149 | 146 |
getUserOutputDatabase(dbconfigurationId);
|
| 150 | 147 |
updateDatabaseConfiguration(dbConfiguration, dbConfigurationtoSave);
|
| 151 | 148 |
userOutputDatabaseDAO.update(dbConfigurationtoSave);
|
| 152 |
- getT3TopiaPersistenceContext().get().commit();
|
|
| 149 |
+ commit();
|
|
| 153 | 150 |
}
|
| 154 | 151 |
|
| 155 |
- public void removeOutputDatabaseConfiguration(String userId,
|
|
| 156 |
- String dbconfigurationId) throws Exception {
|
|
| 152 |
+ public void removeOutputDatabaseConfiguration(String userId, String dbconfigurationId) throws Exception {
|
|
| 157 | 153 |
T3User user = getUserById(userId);
|
| 158 | 154 |
Preconditions.checkNotNull(user,
|
| 159 | 155 |
"Could not find user with id : " + userId);
|
| ... | ... | @@ -163,7 +159,7 @@ public class UserService extends T3ServiceSupport implements T3UserTopiaPersiste |
| 163 | 159 |
user.removeUserOutputDatabase(dbConfigurationtoSave);
|
| 164 | 160 |
userDAO.update(user);
|
| 165 | 161 |
|
| 166 |
- getT3UserTopiaPersistenceContext().get().commit();
|
|
| 162 |
+ commit();
|
|
| 167 | 163 |
}
|
| 168 | 164 |
|
| 169 | 165 |
public UserT3Database getUserT3Database(String dbconfigurationId) throws TopiaException {
|
| ... | ... | @@ -186,21 +182,23 @@ public class UserService extends T3ServiceSupport implements T3UserTopiaPersiste |
| 186 | 182 |
return dbConfigurationtoSave;
|
| 187 | 183 |
}
|
| 188 | 184 |
|
| 189 |
- public boolean checkPassword(T3User user,
|
|
| 190 |
- String password) throws Exception {
|
|
| 185 |
+ public boolean checkPassword(T3User user, String password) throws Exception {
|
|
| 191 | 186 |
String s = encodePassword(password);
|
| 192 | 187 |
return s.equals(user.getPassword());
|
| 193 | 188 |
}
|
| 194 | 189 |
|
| 195 |
- public static String encodePassword(String password) {
|
|
| 190 |
+ private static String encodePassword(String password) {
|
|
| 196 | 191 |
return StringUtil.encodeMD5(password);
|
| 197 | 192 |
}
|
| 198 | 193 |
|
| 199 |
- protected void updateDatabaseConfiguration(UserDatabase dbConfiguration,
|
|
| 200 |
- UserDatabase dbConfigurationtoSave) throws TopiaException {
|
|
| 194 |
+ private void updateDatabaseConfiguration(UserDatabase dbConfiguration, UserDatabase dbConfigurationtoSave) {
|
|
| 201 | 195 |
dbConfigurationtoSave.setDescription(dbConfiguration.getDescription());
|
| 202 | 196 |
dbConfigurationtoSave.setUrl(dbConfiguration.getUrl());
|
| 203 | 197 |
dbConfigurationtoSave.setLogin(dbConfiguration.getLogin());
|
| 204 | 198 |
}
|
| 205 | 199 |
|
| 200 |
+ private void commit() {
|
|
| 201 |
+ getT3UserTopiaPersistenceContext().get().commit();
|
|
| 202 |
+ }
|
|
| 203 |
+ |
|
| 206 | 204 |
}
|
| ... | ... | @@ -36,7 +36,7 @@ import org.nuiton.version.Version; |
| 36 | 36 |
/**
|
| 37 | 37 |
* Created on 25/01/16.
|
| 38 | 38 |
*
|
| 39 |
- * @author Tony Chemit - chemit@codelutin.com
|
|
| 39 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 40 | 40 |
* @since 2.0
|
| 41 | 41 |
*/
|
| 42 | 42 |
public abstract class T3MigrationCallbackSupport extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
|
| ... | ... | @@ -29,7 +29,7 @@ import org.nuiton.version.Versions; |
| 29 | 29 |
/**
|
| 30 | 30 |
* Created on 25/01/16.
|
| 31 | 31 |
*
|
| 32 |
- * @author Tony Chemit - chemit@codelutin.com
|
|
| 32 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 33 | 33 |
* @since 2.0
|
| 34 | 34 |
*/
|
| 35 | 35 |
public class T3MigrationCallbackV2_0 extends T3MigrationCallbackSupport {
|
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 |
# #L%
|
| 20 | 20 |
###
|
| 21 | 21 |
# DB configuration
|
| 22 |
-hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
|
| 22 |
+hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
|
|
| 23 | 23 |
hibernate.connection.driver_class=org.postgresql.Driver
|
| 24 | 24 |
hibernate.connection.provider_class=org.hibernate.hikaricp.internal.HikariCPConnectionProvider
|
| 25 | 25 |
hibernate.show_sql=false
|
| ... | ... | @@ -131,7 +131,7 @@ |
| 131 | 131 |
</dependency>
|
| 132 | 132 |
|
| 133 | 133 |
<dependency>
|
| 134 |
- <groupId>postgresql</groupId>
|
|
| 134 |
+ <groupId>org.postgresql</groupId>
|
|
| 135 | 135 |
<artifactId>postgresql</artifactId>
|
| 136 | 136 |
<scope>test</scope>
|
| 137 | 137 |
</dependency>
|
| ... | ... | @@ -132,7 +132,7 @@ |
| 132 | 132 |
</dependency>
|
| 133 | 133 |
|
| 134 | 134 |
<dependency>
|
| 135 |
- <groupId>postgresql</groupId>
|
|
| 135 |
+ <groupId>org.postgresql</groupId>
|
|
| 136 | 136 |
<artifactId>postgresql</artifactId>
|
| 137 | 137 |
<scope>test</scope>
|
| 138 | 138 |
</dependency>
|
| ... | ... | @@ -132,7 +132,7 @@ |
| 132 | 132 |
</dependency>
|
| 133 | 133 |
|
| 134 | 134 |
<dependency>
|
| 135 |
- <groupId>postgresql</groupId>
|
|
| 135 |
+ <groupId>org.postgresql</groupId>
|
|
| 136 | 136 |
<artifactId>postgresql</artifactId>
|
| 137 | 137 |
<scope>test</scope>
|
| 138 | 138 |
</dependency>
|
| ... | ... | @@ -75,7 +75,7 @@ |
| 75 | 75 |
</dependency>
|
| 76 | 76 |
|
| 77 | 77 |
<dependency>
|
| 78 |
- <groupId>postgresql</groupId>
|
|
| 78 |
+ <groupId>org.postgresql</groupId>
|
|
| 79 | 79 |
<artifactId>postgresql</artifactId>
|
| 80 | 80 |
<scope>runtime</scope>
|
| 81 | 81 |
</dependency>
|
| 1 |
+#!/bin/sh
|
|
| 2 |
+ |
|
| 3 |
+java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 -Xmx1024M -Xms512M -jar ${project.build.finalName}.jar "db.properties" "scripts/ddl" "scripts/referential" "scripts/zones"
|
| ... | ... | @@ -24,7 +24,6 @@ |
| 24 | 24 |
package fr.ird.t3.tools;
|
| 25 | 25 |
|
| 26 | 26 |
import com.google.common.base.Preconditions;
|
| 27 |
-import com.google.common.base.Predicates;
|
|
| 28 | 27 |
import fr.ird.t3.T3Config;
|
| 29 | 28 |
import fr.ird.t3.T3SqlScriptsImporter;
|
| 30 | 29 |
import fr.ird.t3.entities.T3EntityHelper;
|
| ... | ... | @@ -158,7 +157,7 @@ public class T3ApplicationInstaller { |
| 158 | 157 |
log.info("4/6 - Loading ddl from " + dllScriptsImporter.getScriptsFile().size() + " scripts.");
|
| 159 | 158 |
}
|
| 160 | 159 |
|
| 161 |
- dllScriptsImporter.importScripts(serviceContext, Predicates.<File>alwaysTrue());
|
|
| 160 |
+ dllScriptsImporter.importScripts(serviceContext, file -> true);
|
|
| 162 | 161 |
|
| 163 | 162 |
T3SqlScriptsImporter referentialScriptsImporter = new T3SqlScriptsImporter(referentialScriptsDirectory);
|
| 164 | 163 |
referentialScriptsImporter.prepare();
|
| ... | ... | @@ -167,7 +166,7 @@ public class T3ApplicationInstaller { |
| 167 | 166 |
if (log.isInfoEnabled()) {
|
| 168 | 167 |
log.info("5/6 - Load referential from " + referentialScriptsImporter.getScriptsFile().size() + " scripts.");
|
| 169 | 168 |
}
|
| 170 |
- referentialScriptsImporter.importScripts(serviceContext, Predicates.<File>alwaysTrue());
|
|
| 169 |
+ referentialScriptsImporter.importScripts(serviceContext, file -> true);
|
|
| 171 | 170 |
|
| 172 | 171 |
File unzipDirectory = createUnzipDirectory("postgis-data");
|
| 173 | 172 |
|
| ... | ... | @@ -39,3 +39,5 @@ log4j.appender.file.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss} %5p [%t] ( |
| 39 | 39 |
# levels
|
| 40 | 40 |
|
| 41 | 41 |
log4j.logger.org.hibernate=WARN
|
| 42 |
+log4j.logger.org.hibernate.orm.deprecation=ERROR
|
|
| 43 |
+log4j.logger.com.zaxxer.hikari.HikariDataSource=ERROR
|
| ... | ... | @@ -106,7 +106,7 @@ |
| 106 | 106 |
</dependency>
|
| 107 | 107 |
|
| 108 | 108 |
<dependency>
|
| 109 |
- <groupId>postgresql</groupId>
|
|
| 109 |
+ <groupId>org.postgresql</groupId>
|
|
| 110 | 110 |
<artifactId>postgresql</artifactId>
|
| 111 | 111 |
<scope>test</scope>
|
| 112 | 112 |
</dependency>
|
| ... | ... | @@ -84,7 +84,7 @@ |
| 84 | 84 |
</dependency>
|
| 85 | 85 |
|
| 86 | 86 |
<dependency>
|
| 87 |
- <groupId>postgresql</groupId>
|
|
| 87 |
+ <groupId>org.postgresql</groupId>
|
|
| 88 | 88 |
<artifactId>postgresql</artifactId>
|
| 89 | 89 |
<scope>runtime</scope>
|
| 90 | 90 |
</dependency>
|
| ... | ... | @@ -164,7 +164,7 @@ |
| 164 | 164 |
</dependency>
|
| 165 | 165 |
|
| 166 | 166 |
<dependency>
|
| 167 |
- <groupId>postgresql</groupId>
|
|
| 167 |
+ <groupId>org.postgresql</groupId>
|
|
| 168 | 168 |
<artifactId>postgresql</artifactId>
|
| 169 | 169 |
<scope>runtime</scope>
|
| 170 | 170 |
</dependency>
|
| ... | ... | @@ -107,9 +107,7 @@ public class T3ApplicationListener implements ServletContextListener { |
| 107 | 107 |
log.info("Configuration initialized.");
|
| 108 | 108 |
|
| 109 | 109 |
T3ApplicationContext applicationContext = new T3ApplicationContext();
|
| 110 |
- T3ApplicationContext.setT3ApplicationContext(
|
|
| 111 |
- sce.getServletContext(), applicationContext
|
|
| 112 |
- );
|
|
| 110 |
+ T3ApplicationContext.setT3ApplicationContext(sce.getServletContext(), applicationContext);
|
|
| 113 | 111 |
|
| 114 | 112 |
// initialize configuration
|
| 115 | 113 |
applicationContext.setConfiguration(configuration);
|
| ... | ... | @@ -138,8 +136,7 @@ public class T3ApplicationListener implements ServletContextListener { |
| 138 | 136 |
);
|
| 139 | 137 |
|
| 140 | 138 |
// init database (and create minimal admin user if required)
|
| 141 |
- initInternalDatabase(applicationContext,
|
|
| 142 |
- serviceContext);
|
|
| 139 |
+ initInternalDatabase(applicationContext, serviceContext);
|
|
| 143 | 140 |
}
|
| 144 | 141 |
|
| 145 | 142 |
@Override
|
| ... | ... | @@ -216,9 +213,7 @@ public class T3ApplicationListener implements ServletContextListener { |
| 216 | 213 |
applicationContext.setInternalRootContext(internalRootContext);
|
| 217 | 214 |
|
| 218 | 215 |
|
| 219 |
- boolean schemaNeedUpdate =
|
|
| 220 |
- !isInternalSchemaCreated(internalRootContext) ||
|
|
| 221 |
- configuration.isUpdateSchema();
|
|
| 216 |
+ boolean schemaNeedUpdate = !isInternalSchemaCreated(internalRootContext) || configuration.isUpdateSchema();
|
|
| 222 | 217 |
|
| 223 | 218 |
if (schemaNeedUpdate) {
|
| 224 | 219 |
|
| ... | ... | @@ -230,8 +225,7 @@ public class T3ApplicationListener implements ServletContextListener { |
| 230 | 225 |
}
|
| 231 | 226 |
|
| 232 | 227 |
try {
|
| 233 |
- createAdminUser(serviceContext,
|
|
| 234 |
- applicationContext.getInternalRootContext());
|
|
| 228 |
+ createAdminUser(serviceContext, applicationContext.getInternalRootContext());
|
|
| 235 | 229 |
|
| 236 | 230 |
} catch (Exception e) {
|
| 237 | 231 |
throw new IllegalStateException(
|
| ... | ... | @@ -75,7 +75,7 @@ t3.common.currentDirection=Direction du courant |
| 75 | 75 |
t3.common.currentVelocity=Vitesse du courant
|
| 76 | 76 |
t3.common.database.general.caracteristics=Statistiques générales
|
| 77 | 77 |
t3.common.database.ocean.caracteristics=Statistiques de l'océan
|
| 78 |
-t3.common.database.tripsWithAllData=Marées avec totues les données calculées (%s / %s)
|
|
| 78 |
+t3.common.database.tripsWithAllData=Marées avec toutes les données calculées (%s / %s)
|
|
| 79 | 79 |
t3.common.database.tripsWithNoData=Marées avec aucune donnée calculée (%s / %s)
|
| 80 | 80 |
t3.common.database.tripsWithSomeData=Marées avec une partie des données calculées (%s / %s)
|
| 81 | 81 |
t3.common.date=Date
|