Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

19 changed files:

Changes:

  • client-configuration/src/license/THIRD-PARTY.properties
    ... ... @@ -3,8 +3,17 @@
    3 3
     # Already used licenses in project :
    
    4 4
     # - Apache 2.0
    
    5 5
     # - Apache License 2.0
    
    6
    +# - Apache License, version 2.0
    
    6 7
     # - BSD License
    
    7 8
     # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
    
    9
    +# - Common Development and Distribution License
    
    10
    +# - Eclipse Distribution License (EDL), Version 1.0
    
    11
    +# - Eclipse Public License (EPL), Version 1.0
    
    12
    +# - Eclipse Public License 1.0
    
    13
    +# - Eclipse Public License, Version 1.0
    
    14
    +# - GNU General Public License, Version 2 with the Classpath Exception
    
    15
    +# - GNU General Public License, version 2 (GPL2), with the classpath exception
    
    16
    +# - GNU Lesser General Public License, Version 2.1
    
    8 17
     # - General Public License (GPL)
    
    9 18
     # - Indiana University Extreme! Lab Software License, version 1.1.1
    
    10 19
     # - Lesser General Public License (LGPL)
    
    ... ... @@ -13,13 +22,14 @@
    13 22
     # - Lesser General Public License (LPGL) v 2.1
    
    14 23
     # - MIT License
    
    15 24
     # - MPL 1.1
    
    25
    +# - New BSD License
    
    16 26
     # - The Apache Software License, Version 2.0
    
    17 27
     # - The MIT License
    
    18
    -# - The New BSD License
    
    19
    -# - WTFPL
    
    28
    +# - The PostgreSQL License
    
    20 29
     #-------------------------------------------------------------------------------
    
    21 30
     # Please fill the missing licenses for dependencies :
    
    22 31
     #
    
    23 32
     #
    
    24
    -#Thu Aug 17 16:45:44 CEST 2017
    
    33
    +#Fri May 11 14:26:25 CEST 2018
    
    25 34
     commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
    
    35
    +dom4j--dom4j--1.6.1=BSD License

  • persistence/src/main/java/fr/ird/observe/persistence/ObserveTopiaPersistenceContext.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.observe.persistence;
    10 10
      * it under the terms of the GNU General Public License as
    
    11 11
      * published by the Free Software Foundation, either version 3 of the
    
    12 12
      * License, or (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU General Public
    
    20 20
      * License along with this program.  If not, see
    
    21 21
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -32,6 +32,7 @@ import org.apache.commons.logging.LogFactory;
    32 32
     import org.nuiton.topia.persistence.TopiaDao;
    
    33 33
     import org.nuiton.topia.persistence.internal.AbstractTopiaPersistenceContextConstructorParameter;
    
    34 34
     import org.nuiton.topia.persistence.support.TopiaSqlQuery;
    
    35
    +import org.nuiton.topia.persistence.util.SqlScriptConsumer;
    
    35 36
     
    
    36 37
     import java.sql.Connection;
    
    37 38
     import java.sql.PreparedStatement;
    
    ... ... @@ -129,14 +130,14 @@ public class ObserveTopiaPersistenceContext extends AbstractObserveTopiaPersiste
    129 130
     
    
    130 131
         }
    
    131 132
     
    
    132
    -    public void setShowSql(boolean showSql) {
    
    133
    -        this.showSql = showSql;
    
    134
    -    }
    
    135
    -
    
    136 133
         public boolean isShowSql() {
    
    137 134
             return showSql;
    
    138 135
         }
    
    139 136
     
    
    137
    +    public void setShowSql(boolean showSql) {
    
    138
    +        this.showSql = showSql;
    
    139
    +    }
    
    140
    +
    
    140 141
         public <E extends ObserveEntity> E newEntity(Class<E> entityType) {
    
    141 142
             TopiaDao<E> dao = getDao(entityType);
    
    142 143
             return dao.newInstance();
    
    ... ... @@ -167,6 +168,16 @@ public class ObserveTopiaPersistenceContext extends AbstractObserveTopiaPersiste
    167 168
     
    
    168 169
         }
    
    169 170
     
    
    171
    +    public void executeSqlScript(byte... content) {
    
    172
    +        getSqlSupport().doSqlWork(SqlScriptConsumer.builder(content).batchSize(1000).build());
    
    173
    +    }
    
    174
    +
    
    175
    +    public void executeSqlScripts(byte[]... contents) {
    
    176
    +        for (byte[] content : contents) {
    
    177
    +            executeSqlScript(content);
    
    178
    +        }
    
    179
    +    }
    
    180
    +
    
    170 181
         protected class CountTableSqlWork extends TopiaSqlQuery<Long> {
    
    171 182
     
    
    172 183
             private final String fullyTableName;
    
    ... ... @@ -189,14 +200,4 @@ public class ObserveTopiaPersistenceContext extends AbstractObserveTopiaPersiste
    189 200
                 return set.getLong(1);
    
    190 201
             }
    
    191 202
         }
    
    192
    -
    
    193
    -    public void executeSqlScript(byte... content) {
    
    194
    -
    
    195
    -        getSqlSupport().doSqlWork(new RunScriptTopiaSqlWork(1000, showSql, content));
    
    196
    -    }
    
    197
    -
    
    198
    -    public void executeSqlScripts(byte[]... contents) {
    
    199
    -
    
    200
    -        getSqlSupport().doSqlWork(new RunScriptsTopiaSqlWork(1000, showSql, contents));
    
    201
    -    }
    
    202 203
     }

  • persistence/src/main/java/fr/ird/observe/persistence/RunScriptTopiaSqlWork.java deleted
    1
    -package fr.ird.observe.persistence;
    
    2
    -
    
    3
    -/*-
    
    4
    - * #%L
    
    5
    - * ObServe :: Persistence
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import org.apache.commons.logging.Log;
    
    26
    -import org.apache.commons.logging.LogFactory;
    
    27
    -import org.nuiton.topia.persistence.TopiaException;
    
    28
    -import org.nuiton.topia.persistence.support.TopiaSqlWork;
    
    29
    -import org.nuiton.util.GZUtil;
    
    30
    -import org.nuiton.util.sql.SqlFileReader;
    
    31
    -
    
    32
    -import java.io.BufferedInputStream;
    
    33
    -import java.io.BufferedReader;
    
    34
    -import java.io.ByteArrayInputStream;
    
    35
    -import java.io.IOException;
    
    36
    -import java.io.InputStreamReader;
    
    37
    -import java.sql.Connection;
    
    38
    -import java.sql.SQLException;
    
    39
    -import java.sql.Statement;
    
    40
    -import java.util.zip.GZIPInputStream;
    
    41
    -
    
    42
    -/**
    
    43
    - * TODO Move this in ToPIA.
    
    44
    - * <p>
    
    45
    - * Created on 09/01/16.
    
    46
    - *
    
    47
    - * @author Tony Chemit - dev@tchemit.fr
    
    48
    - */
    
    49
    -public class RunScriptTopiaSqlWork implements TopiaSqlWork {
    
    50
    -
    
    51
    -    /** Logger. */
    
    52
    -    private static final Log log = LogFactory.getLog(RunScriptTopiaSqlWork.class);
    
    53
    -
    
    54
    -    protected final byte[] content;
    
    55
    -    protected final boolean gzip;
    
    56
    -    protected final int batchSize;
    
    57
    -    protected final boolean showSql;
    
    58
    -
    
    59
    -    public RunScriptTopiaSqlWork(int batchSize, boolean showSql, byte[] content) {
    
    60
    -        this.batchSize = batchSize;
    
    61
    -        this.showSql = showSql;
    
    62
    -        this.content = content;
    
    63
    -
    
    64
    -        if (content == null || content.length == 0) {
    
    65
    -            gzip = false;
    
    66
    -        } else {
    
    67
    -            try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content)) {
    
    68
    -                gzip = GZUtil.isGzipStream(byteArrayInputStream);
    
    69
    -            } catch (IOException e) {
    
    70
    -                throw new TopiaException(e);
    
    71
    -            }
    
    72
    -        }
    
    73
    -    }
    
    74
    -
    
    75
    -    @Override
    
    76
    -    public void execute(Connection connection) throws SQLException {
    
    77
    -
    
    78
    -        boolean autoCommit = connection.getAutoCommit();
    
    79
    -
    
    80
    -        try {
    
    81
    -            connection.setAutoCommit(false);
    
    82
    -
    
    83
    -            execute0(connection);
    
    84
    -        } finally {
    
    85
    -            connection.setAutoCommit(autoCommit);
    
    86
    -        }
    
    87
    -    }
    
    88
    -
    
    89
    -    protected void execute0(Connection connection) throws SQLException {
    
    90
    -        try (BufferedReader reader = createReader()) {
    
    91
    -
    
    92
    -            try (Statement statement = connection.createStatement()) {
    
    93
    -
    
    94
    -                int batchSize = 0;
    
    95
    -
    
    96
    -                for (String statementStr : new SqlFileReader(reader)) {
    
    97
    -
    
    98
    -                    String trimLine = statementStr.trim();
    
    99
    -
    
    100
    -                    if (trimLine.isEmpty() || trimLine.startsWith("--")) {
    
    101
    -                        continue;
    
    102
    -                    }
    
    103
    -                    if (showSql || log.isDebugEnabled()) {
    
    104
    -                        log.info(trimLine);
    
    105
    -                    }
    
    106
    -                    statement.addBatch(trimLine);
    
    107
    -                    batchSize++;
    
    108
    -
    
    109
    -                    if (batchSize % this.batchSize == 0) {
    
    110
    -                        flushStatement(statement);
    
    111
    -                    }
    
    112
    -
    
    113
    -                }
    
    114
    -
    
    115
    -                flushStatement(statement);
    
    116
    -            }
    
    117
    -
    
    118
    -        } catch (IOException e) {
    
    119
    -            throw new TopiaException(e);
    
    120
    -        }
    
    121
    -    }
    
    122
    -
    
    123
    -    protected void flushStatement(Statement statement) throws SQLException {
    
    124
    -
    
    125
    -        statement.executeBatch();
    
    126
    -        statement.clearBatch();
    
    127
    -
    
    128
    -    }
    
    129
    -
    
    130
    -    private BufferedReader createReader() {
    
    131
    -        try {
    
    132
    -            return new BufferedReader(new InputStreamReader(new BufferedInputStream(gzip ? new GZIPInputStream(new ByteArrayInputStream(content)) : new ByteArrayInputStream(content))));
    
    133
    -        } catch (IOException e) {
    
    134
    -            throw new TopiaException(e);
    
    135
    -        }
    
    136
    -    }
    
    137
    -}

  • persistence/src/main/java/fr/ird/observe/persistence/RunScriptsTopiaSqlWork.java deleted
    1
    -package fr.ird.observe.persistence;
    
    2
    -
    
    3
    -/*-
    
    4
    - * #%L
    
    5
    - * ObServe :: Persistence
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import java.sql.Connection;
    
    26
    -import java.sql.SQLException;
    
    27
    -
    
    28
    -/**
    
    29
    - * TODO Move this in ToPIA.
    
    30
    - * <p>
    
    31
    - * Created on 09/01/16.
    
    32
    - *
    
    33
    - * @author Tony Chemit - dev@tchemit.fr
    
    34
    - */
    
    35
    -public class RunScriptsTopiaSqlWork extends RunScriptTopiaSqlWork {
    
    36
    -
    
    37
    -    protected final byte[][] contents;
    
    38
    -
    
    39
    -    public RunScriptsTopiaSqlWork(int batchSize, boolean showSql, byte[][] contents) {
    
    40
    -        super(batchSize, showSql, null);
    
    41
    -        this.contents = contents;
    
    42
    -    }
    
    43
    -
    
    44
    -    @Override
    
    45
    -    protected void execute0(Connection connection) throws SQLException {
    
    46
    -
    
    47
    -        for (byte[] content : contents) {
    
    48
    -            new RunScriptTopiaSqlWork(batchSize, showSql, content).execute0(connection);
    
    49
    -        }
    
    50
    -
    
    51
    -    }
    
    52
    -
    
    53
    -}

  • persistence/src/main/java/fr/ird/observe/persistence/migration/MigrationVersion.java deleted
    1
    -package fr.ird.observe.persistence.migration;
    
    2
    -
    
    3
    -/*-
    
    4
    - * #%L
    
    5
    - * ObServe :: Persistence
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - *
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - *
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import java.lang.annotation.ElementType;
    
    26
    -import java.lang.annotation.Retention;
    
    27
    -import java.lang.annotation.RetentionPolicy;
    
    28
    -import java.lang.annotation.Target;
    
    29
    -
    
    30
    -/**
    
    31
    - * Created on 04/11/16.
    
    32
    - *
    
    33
    - * @author Tony Chemit - dev@tchemit.fr
    
    34
    - * @since 6.0
    
    35
    - */
    
    36
    -@Target(ElementType.TYPE)
    
    37
    -@Retention(RetentionPolicy.RUNTIME)
    
    38
    -public @interface MigrationVersion {
    
    39
    -
    
    40
    -    String version();
    
    41
    -
    
    42
    -}

  • persistence/src/main/java/fr/ird/observe/persistence/migration/ObserveTopiaMigrationServiceAskUserToMigrate.java
    ... ... @@ -46,6 +46,9 @@ public class ObserveTopiaMigrationServiceAskUserToMigrate implements TopiaMigrat
    46 46
         @Override
    
    47 47
         public boolean canIMigrate(Version dbVersion, List<Version> versions) {
    
    48 48
             // on autorise les migrations dès quelles sont demandée pour une version égale ou superieur à la V3.0.
    
    49
    +        //FIXME On devrait peut-être à ce niveau demander réellement à l'utilisateur, car dans le cas de création
    
    50
    +        //FIXME d'une base via un script, la migration est effectuée sans demande, mais d'un autre côté si on charge une
    
    51
    +        //FIXME backup, alors la source n'est pas altérée donc une migration automatique est possible...
    
    49 52
             return dbVersion.afterOrEquals(getMinimumVersion());
    
    50 53
     //        boolean headless = GraphicsEnvironment.isHeadless();
    
    51 54
     //
    

  • pom.xml
    ... ... @@ -152,7 +152,7 @@
    152 152
         <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format>
    
    153 153
         <buildDate>${maven.build.timestamp}</buildDate>
    
    154 154
     
    
    155
    -    <observeToolkitVersion>3.3</observeToolkitVersion>
    
    155
    +    <observeToolkitVersion>3.4-SNAPSHOT</observeToolkitVersion>
    
    156 156
     
    
    157 157
         <!--<lib.version.java4all.jaxx>3.0-alpha-31</lib.version.java4all.jaxx>-->
    
    158 158
         <!--<lib.version.nuiton.topia>3.4.2-SNAPSHOT</lib.version.nuiton.topia>-->
    

  • server-configuration/src/license/THIRD-PARTY.properties
    ... ... @@ -3,8 +3,17 @@
    3 3
     # Already used licenses in project :
    
    4 4
     # - Apache 2.0
    
    5 5
     # - Apache License 2.0
    
    6
    +# - Apache License, version 2.0
    
    6 7
     # - BSD License
    
    7 8
     # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
    
    9
    +# - Common Development and Distribution License
    
    10
    +# - Eclipse Distribution License (EDL), Version 1.0
    
    11
    +# - Eclipse Public License (EPL), Version 1.0
    
    12
    +# - Eclipse Public License 1.0
    
    13
    +# - Eclipse Public License, Version 1.0
    
    14
    +# - GNU General Public License, Version 2 with the Classpath Exception
    
    15
    +# - GNU General Public License, version 2 (GPL2), with the classpath exception
    
    16
    +# - GNU Lesser General Public License, Version 2.1
    
    8 17
     # - General Public License (GPL)
    
    9 18
     # - Indiana University Extreme! Lab Software License, version 1.1.1
    
    10 19
     # - Lesser General Public License (LGPL)
    
    ... ... @@ -16,11 +25,11 @@
    16 25
     # - New BSD License
    
    17 26
     # - The Apache Software License, Version 2.0
    
    18 27
     # - The MIT License
    
    19
    -# - The New BSD License
    
    20
    -# - WTFPL
    
    28
    +# - The PostgreSQL License
    
    21 29
     #-------------------------------------------------------------------------------
    
    22 30
     # Please fill the missing licenses for dependencies :
    
    23 31
     #
    
    24 32
     #
    
    25
    -#Thu Aug 17 16:45:41 CEST 2017
    
    33
    +#Fri May 11 14:26:13 CEST 2018
    
    26 34
     commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
    
    35
    +dom4j--dom4j--1.6.1=BSD License

  • services-client/src/license/THIRD-PARTY.properties
    ... ... @@ -2,9 +2,18 @@
    2 2
     #-------------------------------------------------------------------------------
    
    3 3
     # Already used licenses in project :
    
    4 4
     # - Apache 2.0
    
    5
    +# - Apache License 2.0
    
    6
    +# - Apache License, version 2.0
    
    5 7
     # - BSD License
    
    6 8
     # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
    
    9
    +# - Common Development and Distribution License
    
    10
    +# - Eclipse Distribution License (EDL), Version 1.0
    
    11
    +# - Eclipse Public License (EPL), Version 1.0
    
    7 12
     # - Eclipse Public License 1.0
    
    13
    +# - Eclipse Public License, Version 1.0
    
    14
    +# - GNU General Public License, Version 2 with the Classpath Exception
    
    15
    +# - GNU General Public License, version 2 (GPL2), with the classpath exception
    
    16
    +# - GNU Lesser General Public License, Version 2.1
    
    8 17
     # - General Public License (GPL)
    
    9 18
     # - Indiana University Extreme! Lab Software License, version 1.1.1
    
    10 19
     # - Lesser General Public License (LGPL)
    
    ... ... @@ -12,12 +21,15 @@
    12 21
     # - Lesser General Public License (LPGL)
    
    13 22
     # - Lesser General Public License (LPGL) v 2.1
    
    14 23
     # - MIT License
    
    24
    +# - MPL 1.1
    
    15 25
     # - New BSD License
    
    16 26
     # - The Apache Software License, Version 2.0
    
    17 27
     # - The MIT License
    
    28
    +# - The PostgreSQL License
    
    18 29
     #-------------------------------------------------------------------------------
    
    19 30
     # Please fill the missing licenses for dependencies :
    
    20 31
     #
    
    21 32
     #
    
    22
    -#Mon Sep 04 00:38:17 CEST 2017
    
    33
    +#Fri May 11 14:26:07 CEST 2018
    
    23 34
     commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
    
    35
    +dom4j--dom4j--1.6.1=BSD License

  • services-local/src/main/java/fr/ird/observe/services/local/service/data/ImportTripScriptTopiaSqlWork.java deleted
    1
    -package fr.ird.observe.services.local.service.data;
    
    2
    -
    
    3
    -/*-
    
    4
    - * #%L
    
    5
    - * ObServe :: Services local implementation
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import com.google.common.collect.ImmutableSet;
    
    26
    -import fr.ird.observe.dto.db.ObserveBlobsContainer;
    
    27
    -import fr.ird.observe.persistence.RunScriptTopiaSqlWork;
    
    28
    -import org.apache.commons.logging.Log;
    
    29
    -import org.apache.commons.logging.LogFactory;
    
    30
    -
    
    31
    -import javax.sql.rowset.serial.SerialBlob;
    
    32
    -import java.sql.Connection;
    
    33
    -import java.sql.PreparedStatement;
    
    34
    -import java.sql.SQLException;
    
    35
    -import java.util.Map;
    
    36
    -
    
    37
    -/**
    
    38
    - * Created on 24/08/16.
    
    39
    - *
    
    40
    - * @author Tony Chemit - dev@tchemit.fr
    
    41
    - */
    
    42
    -public class ImportTripScriptTopiaSqlWork extends RunScriptTopiaSqlWork {
    
    43
    -
    
    44
    -    /** Logger */
    
    45
    -    private static final Log log = LogFactory.getLog(ImportTripScriptTopiaSqlWork.class);
    
    46
    -
    
    47
    -    private final ImmutableSet<ObserveBlobsContainer> blobsContainers;
    
    48
    -
    
    49
    -    public ImportTripScriptTopiaSqlWork(int batchSize, boolean showSql, byte[] content, ImmutableSet<ObserveBlobsContainer> blobsContainers) {
    
    50
    -        super(batchSize, showSql, content);
    
    51
    -        this.blobsContainers = blobsContainers;
    
    52
    -    }
    
    53
    -
    
    54
    -    @Override
    
    55
    -    public void execute(Connection connection) throws SQLException {
    
    56
    -        super.execute(connection);
    
    57
    -
    
    58
    -        for (ObserveBlobsContainer blobsContainer : blobsContainers) {
    
    59
    -
    
    60
    -            String tableName = blobsContainer.getTableName();
    
    61
    -            String columnName = blobsContainer.getColumnName();
    
    62
    -            int batchSize = 0;
    
    63
    -
    
    64
    -            String sql = String.format("update %s SET %s = ? WHERE topiaId= ?", tableName, columnName);
    
    65
    -            if (showSql) {
    
    66
    -                if (log.isInfoEnabled()) {
    
    67
    -                    log.info(sql);
    
    68
    -                }
    
    69
    -            }
    
    70
    -            try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
    
    71
    -
    
    72
    -                for (Map.Entry<String, byte[]> containerEntry : blobsContainer.getBlobsById().entrySet()) {
    
    73
    -
    
    74
    -                    String topiaId = containerEntry.getKey();
    
    75
    -                    byte[] content = containerEntry.getValue();
    
    76
    -
    
    77
    -                    preparedStatement.clearParameters();
    
    78
    -                    preparedStatement.setBlob(1, new SerialBlob(content));
    
    79
    -                    preparedStatement.setString(2, topiaId);
    
    80
    -                    preparedStatement.addBatch();
    
    81
    -
    
    82
    -                    batchSize++;
    
    83
    -
    
    84
    -                    if (batchSize % this.batchSize == 0) {
    
    85
    -                        flushStatement(preparedStatement);
    
    86
    -                    }
    
    87
    -
    
    88
    -                }
    
    89
    -
    
    90
    -
    
    91
    -                flushStatement(preparedStatement);
    
    92
    -
    
    93
    -            }
    
    94
    -
    
    95
    -        }
    
    96
    -
    
    97
    -
    
    98
    -    }
    
    99
    -
    
    100
    -}

  • services-local/src/main/java/fr/ird/observe/services/local/service/data/TripManagementServiceLocal.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.observe.services.local.service.data;
    10 10
      * it under the terms of the GNU General Public License as
    
    11 11
      * published by the Free Software Foundation, either version 3 of the
    
    12 12
      * License, or (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU General Public
    
    20 20
      * License along with this program.  If not, see
    
    21 21
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -24,7 +24,6 @@ package fr.ird.observe.services.local.service.data;
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import fr.ird.observe.dto.IdHelper;
    
    27
    -import fr.ird.observe.dto.db.ObserveBlobsContainer;
    
    28 27
     import fr.ird.observe.persistence.ObserveTopiaPersistenceContext;
    
    29 28
     import fr.ird.observe.services.local.ObserveServiceContextLocal;
    
    30 29
     import fr.ird.observe.services.local.service.ObserveServiceLocal;
    
    ... ... @@ -41,6 +40,8 @@ import fr.ird.observe.services.service.sql.DeleteSqlScriptProducerRequest;
    41 40
     import fr.ird.observe.services.service.sql.SqlScriptProducerService;
    
    42 41
     import org.apache.commons.logging.Log;
    
    43 42
     import org.apache.commons.logging.LogFactory;
    
    43
    +import org.nuiton.topia.persistence.util.SqlScriptConsumer;
    
    44
    +import org.nuiton.topia.persistence.util.TopiaBlobsContainer;
    
    44 45
     import org.nuiton.util.StringUtil;
    
    45 46
     import org.nuiton.version.Version;
    
    46 47
     
    
    ... ... @@ -84,7 +85,7 @@ public class TripManagementServiceLocal extends ObserveServiceLocal implements T
    84 85
                     .dataIdsToAdd(ImmutableSet.of(tripId));
    
    85 86
             AddSqlScriptProducerResult producerResult = sqlScriptProducerService.produceAddSqlScript(request);
    
    86 87
             byte[] tripContent = producerResult.getSqlCode();
    
    87
    -        ImmutableSet<ObserveBlobsContainer> blobsContainers = producerResult.getBlobsContainers();
    
    88
    +        ImmutableSet<TopiaBlobsContainer> blobsContainers = producerResult.getBlobsContainers();
    
    88 89
     
    
    89 90
             long time = System.nanoTime() - t0;
    
    90 91
     
    
    ... ... @@ -151,18 +152,13 @@ public class TripManagementServiceLocal extends ObserveServiceLocal implements T
    151 152
                 log.info("Start import of trip: " + request.getTripId());
    
    152 153
             }
    
    153 154
     
    
    154
    -        ImmutableSet<ObserveBlobsContainer> blobsContainers = request.getBlobsContainers();
    
    155
    -
    
    156
    -        if (blobsContainers.isEmpty()) {
    
    157
    -
    
    158
    -            persistenceContext.executeSqlScript(request.getSqlContent());
    
    159
    -
    
    160
    -        } else {
    
    161
    -
    
    162
    -            boolean showSql = serviceContext.getTopiaApplicationContext().getConfiguration().isShowSql();
    
    163
    -            persistenceContext.getSqlSupport().doSqlWork(new ImportTripScriptTopiaSqlWork(1000, showSql, request.getSqlContent(), blobsContainers));
    
    155
    +        ImmutableSet<TopiaBlobsContainer> blobsContainers = request.getBlobsContainers();
    
    164 156
     
    
    157
    +        SqlScriptConsumer.Builder consumerBuilder = SqlScriptConsumer.builder(request.getSqlContent()).batchSize(1000);
    
    158
    +        if (!blobsContainers.isEmpty()) {
    
    159
    +            consumerBuilder.blobs(blobsContainers);
    
    165 160
             }
    
    161
    +        persistenceContext.getSqlSupport().doSqlWork(consumerBuilder.build());
    
    166 162
     
    
    167 163
             persistenceContext.commit();
    
    168 164
     
    

  • services-local/src/main/java/fr/ird/observe/services/local/service/sql/SqlScriptProducerServiceLocal.java
    ... ... @@ -24,7 +24,7 @@ package fr.ird.observe.services.local.service.sql;
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import com.google.common.collect.ListMultimap;
    
    27
    -import fr.ird.observe.dto.db.ObserveBlobsContainer;
    
    27
    +import org.nuiton.topia.persistence.util.TopiaBlobsContainer;
    
    28 28
     import fr.ird.observe.dto.reference.ReferentialDtoReference;
    
    29 29
     import fr.ird.observe.persistence.Entities;
    
    30 30
     import fr.ird.observe.persistence.ObserveEntityEnum;
    
    ... ... @@ -75,7 +75,7 @@ public class SqlScriptProducerServiceLocal extends ObserveServiceLocal implement
    75 75
             }
    
    76 76
             try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
    
    77 77
     
    
    78
    -            ImmutableSet.Builder<ObserveBlobsContainer> observeBlobContainers = ImmutableSet.builder();
    
    78
    +            ImmutableSet.Builder<TopiaBlobsContainer> observeBlobContainers = ImmutableSet.builder();
    
    79 79
                 try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(out), StandardCharsets.UTF_8)) {
    
    80 80
     
    
    81 81
                     TopiaSqlBatchService sqlBatchService = serviceContext.getTopiaApplicationContext().getSqlBatchService();
    
    ... ... @@ -85,7 +85,7 @@ public class SqlScriptProducerServiceLocal extends ObserveServiceLocal implement
    85 85
                     SqlResult sqlResult = sqlBatchService.execute(sqlRequests);
    
    86 86
                     ImmutableSet<BlobsContainer> blobsContainers = sqlResult.getBlobsContainers();
    
    87 87
                     for (BlobsContainer blobsContainer : blobsContainers) {
    
    88
    -                    observeBlobContainers.add(new ObserveBlobsContainer(blobsContainer.getTableName(),
    
    88
    +                    observeBlobContainers.add(new TopiaBlobsContainer(blobsContainer.getTableName(),
    
    89 89
                                                                             blobsContainer.getColumnName(),
    
    90 90
                                                                             blobsContainer.getBlobsById()));
    
    91 91
                     }
    

  • services/pom.xml
    ... ... @@ -58,6 +58,10 @@
    58 58
           <groupId>fr.ird.observe.toolkit</groupId>
    
    59 59
           <artifactId>common-service</artifactId>
    
    60 60
         </dependency>
    
    61
    +    <dependency>
    
    62
    +      <groupId>fr.ird.observe.toolkit</groupId>
    
    63
    +      <artifactId>topia-extension</artifactId>
    
    64
    +    </dependency>
    
    61 65
     
    
    62 66
         <!-- nuiton dependencies -->
    
    63 67
         <dependency>
    

  • services/src/license/THIRD-PARTY.properties
    1 1
     # Generated by org.codehaus.mojo.license.AddThirdPartyMojo
    
    2 2
     #-------------------------------------------------------------------------------
    
    3 3
     # Already used licenses in project :
    
    4
    +# - Apache 2.0
    
    4 5
     # - Apache License 2.0
    
    6
    +# - Apache License, version 2.0
    
    5 7
     # - BSD License
    
    6 8
     # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
    
    9
    +# - Common Development and Distribution License
    
    10
    +# - Eclipse Distribution License (EDL), Version 1.0
    
    11
    +# - Eclipse Public License (EPL), Version 1.0
    
    7 12
     # - Eclipse Public License 1.0
    
    13
    +# - Eclipse Public License, Version 1.0
    
    14
    +# - GNU General Public License, Version 2 with the Classpath Exception
    
    15
    +# - GNU General Public License, version 2 (GPL2), with the classpath exception
    
    16
    +# - GNU Lesser General Public License, Version 2.1
    
    8 17
     # - General Public License (GPL)
    
    9
    -# - Indiana University Extreme! Lab Software License, vesion 1.1.1
    
    18
    +# - Indiana University Extreme! Lab Software License, version 1.1.1
    
    10 19
     # - Lesser General Public License (LGPL)
    
    11 20
     # - Lesser General Public License (LGPL) v 3.0
    
    12 21
     # - Lesser General Public License (LPGL)
    
    ... ... @@ -15,9 +24,12 @@
    15 24
     # - MPL 1.1
    
    16 25
     # - New BSD License
    
    17 26
     # - The Apache Software License, Version 2.0
    
    27
    +# - The MIT License
    
    28
    +# - The PostgreSQL License
    
    18 29
     #-------------------------------------------------------------------------------
    
    19 30
     # Please fill the missing licenses for dependencies :
    
    20 31
     #
    
    21 32
     #
    
    22
    -#Mon Sep 07 10:22:53 CEST 2015
    
    33
    +#Fri May 11 14:22:56 CEST 2018
    
    23 34
     commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
    
    35
    +dom4j--dom4j--1.6.1=BSD License

  • services/src/main/java/fr/ird/observe/services/service/data/ExportTripResult.java
    ... ... @@ -24,7 +24,7 @@ package fr.ird.observe.services.service.data;
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import fr.ird.observe.dto.ObserveDto;
    
    27
    -import fr.ird.observe.dto.db.ObserveBlobsContainer;
    
    27
    +import org.nuiton.topia.persistence.util.TopiaBlobsContainer;
    
    28 28
     
    
    29 29
     /**
    
    30 30
      * Created on 27/08/16.
    
    ... ... @@ -37,12 +37,12 @@ public class ExportTripResult implements ObserveDto {
    37 37
         private final String programId;
    
    38 38
         private final String tripId;
    
    39 39
         private final byte[] sqlContent;
    
    40
    -    private final ImmutableSet<ObserveBlobsContainer> blobsContainers;
    
    40
    +    private final ImmutableSet<TopiaBlobsContainer> blobsContainers;
    
    41 41
         private final long time;
    
    42 42
     
    
    43 43
         public ExportTripResult(ExportTripRequest request,
    
    44 44
                                 byte[] sqlContent,
    
    45
    -                            ImmutableSet<ObserveBlobsContainer> blobsContainers,
    
    45
    +                            ImmutableSet<TopiaBlobsContainer> blobsContainers,
    
    46 46
                                 long time) {
    
    47 47
             this.programId = request.getProgramId();
    
    48 48
             this.tripId = request.getTripId();
    
    ... ... @@ -63,7 +63,7 @@ public class ExportTripResult implements ObserveDto {
    63 63
             return sqlContent;
    
    64 64
         }
    
    65 65
     
    
    66
    -    public ImmutableSet<ObserveBlobsContainer> getBlobsContainers() {
    
    66
    +    public ImmutableSet<TopiaBlobsContainer> getBlobsContainers() {
    
    67 67
             return blobsContainers;
    
    68 68
         }
    
    69 69
     
    

  • services/src/main/java/fr/ird/observe/services/service/data/ImportTripRequest.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.observe.services.service.data;
    10 10
      * it under the terms of the GNU General Public License as
    
    11 11
      * published by the Free Software Foundation, either version 3 of the
    
    12 12
      * License, or (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU General Public
    
    20 20
      * License along with this program.  If not, see
    
    21 21
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -24,7 +24,7 @@ package fr.ird.observe.services.service.data;
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import fr.ird.observe.dto.ObserveDto;
    
    27
    -import fr.ird.observe.dto.db.ObserveBlobsContainer;
    
    27
    +import org.nuiton.topia.persistence.util.TopiaBlobsContainer;
    
    28 28
     
    
    29 29
     /**
    
    30 30
      * Created on 27/08/16.
    
    ... ... @@ -37,7 +37,7 @@ public class ImportTripRequest implements ObserveDto {
    37 37
         private final String programId;
    
    38 38
         private final String tripId;
    
    39 39
         private final byte[] sqlContent;
    
    40
    -    private final ImmutableSet<ObserveBlobsContainer> blobsContainers;
    
    40
    +    private final ImmutableSet<TopiaBlobsContainer> blobsContainers;
    
    41 41
     
    
    42 42
         public ImportTripRequest(ExportTripResult exportTripResult) {
    
    43 43
             this.programId = exportTripResult.getProgramId();
    
    ... ... @@ -58,7 +58,7 @@ public class ImportTripRequest implements ObserveDto {
    58 58
             return sqlContent;
    
    59 59
         }
    
    60 60
     
    
    61
    -    public ImmutableSet<ObserveBlobsContainer> getBlobsContainers() {
    
    61
    +    public ImmutableSet<TopiaBlobsContainer> getBlobsContainers() {
    
    62 62
             return blobsContainers;
    
    63 63
         }
    
    64 64
     
    

  • services/src/main/java/fr/ird/observe/services/service/sql/AddSqlScriptProducerResult.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.observe.services.service.sql;
    10 10
      * it under the terms of the GNU General Public License as
    
    11 11
      * published by the Free Software Foundation, either version 3 of the
    
    12 12
      * License, or (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU General Public
    
    20 20
      * License along with this program.  If not, see
    
    21 21
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -24,7 +24,7 @@ package fr.ird.observe.services.service.sql;
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import fr.ird.observe.dto.ObserveDto;
    
    27
    -import fr.ird.observe.dto.db.ObserveBlobsContainer;
    
    27
    +import org.nuiton.topia.persistence.util.TopiaBlobsContainer;
    
    28 28
     
    
    29 29
     /**
    
    30 30
      * Created on 24/08/16.
    
    ... ... @@ -35,9 +35,9 @@ public class AddSqlScriptProducerResult implements ObserveDto {
    35 35
     
    
    36 36
         private final byte[] sqlCode;
    
    37 37
     
    
    38
    -    private final ImmutableSet<ObserveBlobsContainer> blobsContainers;
    
    38
    +    private final ImmutableSet<TopiaBlobsContainer> blobsContainers;
    
    39 39
     
    
    40
    -    public AddSqlScriptProducerResult(byte[] sqlCode, ImmutableSet<ObserveBlobsContainer> blobsContainers) {
    
    40
    +    public AddSqlScriptProducerResult(byte[] sqlCode, ImmutableSet<TopiaBlobsContainer> blobsContainers) {
    
    41 41
             this.sqlCode = sqlCode;
    
    42 42
             this.blobsContainers = blobsContainers;
    
    43 43
         }
    
    ... ... @@ -46,7 +46,7 @@ public class AddSqlScriptProducerResult implements ObserveDto {
    46 46
             return sqlCode;
    
    47 47
         }
    
    48 48
     
    
    49
    -    public ImmutableSet<ObserveBlobsContainer> getBlobsContainers() {
    
    49
    +    public ImmutableSet<TopiaBlobsContainer> getBlobsContainers() {
    
    50 50
             return blobsContainers;
    
    51 51
         }
    
    52 52
     }

  • test/src/main/resources/log4j.properties
    ... ... @@ -26,7 +26,6 @@ log4j.appender.stdout.layout=org.apache.log4j.EnhancedPatternLayout
    26 26
     log4j.appender.stdout.layout.ConversionPattern=%-5p %d{ISO8601} [%t] %40C{1} :%4L - %m%n
    
    27 27
     
    
    28 28
     log4j.logger.fr.ird.observe=INFO
    
    29
    -#log4j.logger.fr.ird.observe.persistence.RunScriptTopiaSqlWork=DEBUG
    
    30 29
     log4j.logger.org.nuiton.topia=INFO
    
    31 30
     #log4j.logger.org.nuiton.topia.service.sql=DEBUG
    
    32 31
     #log4j.logger.fr.ird.observe.client.validators=WARN
    

  • validation/src/license/THIRD-PARTY.properties
    ... ... @@ -3,11 +3,19 @@
    3 3
     # Already used licenses in project :
    
    4 4
     # - Apache 2.0
    
    5 5
     # - Apache License 2.0
    
    6
    +# - Apache License, version 2.0
    
    6 7
     # - BSD License
    
    7 8
     # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
    
    9
    +# - Common Development and Distribution License
    
    10
    +# - Eclipse Distribution License (EDL), Version 1.0
    
    11
    +# - Eclipse Public License (EPL), Version 1.0
    
    8 12
     # - Eclipse Public License 1.0
    
    13
    +# - Eclipse Public License, Version 1.0
    
    14
    +# - GNU General Public License, Version 2 with the Classpath Exception
    
    15
    +# - GNU General Public License, version 2 (GPL2), with the classpath exception
    
    16
    +# - GNU Lesser General Public License, Version 2.1
    
    9 17
     # - General Public License (GPL)
    
    10
    -# - Indiana University Extreme! Lab Software License, vesion 1.1.1
    
    18
    +# - Indiana University Extreme! Lab Software License, version 1.1.1
    
    11 19
     # - Lesser General Public License (LGPL)
    
    12 20
     # - Lesser General Public License (LGPL) v 3.0
    
    13 21
     # - Lesser General Public License (LPGL)
    
    ... ... @@ -16,9 +24,12 @@
    16 24
     # - MPL 1.1
    
    17 25
     # - New BSD License
    
    18 26
     # - The Apache Software License, Version 2.0
    
    27
    +# - The MIT License
    
    28
    +# - The PostgreSQL License
    
    19 29
     #-------------------------------------------------------------------------------
    
    20 30
     # Please fill the missing licenses for dependencies :
    
    21 31
     #
    
    22 32
     #
    
    23
    -#Mon Aug 01 17:25:22 CEST 2016
    
    33
    +#Fri May 11 14:23:09 CEST 2018
    
    24 34
     commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
    
    35
    +dom4j--dom4j--1.6.1=BSD License