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

Commits:

17 changed files:

Changes:

  • pom.xml
    ... ... @@ -176,7 +176,7 @@
    176 176
         <nuitonUtilsVersion>3.0-rc-18</nuitonUtilsVersion>
    
    177 177
         <nuitonConverterVersion>1.0</nuitonConverterVersion>
    
    178 178
         <nuitonVersionVersion>1.0-rc-2</nuitonVersionVersion>
    
    179
    -    <httpVersion>1.0.2</httpVersion>
    
    179
    +    <httpVersion>1.0.3-SNAPSHOT</httpVersion>
    
    180 180
         <xworkVersion>2.3.33</xworkVersion>
    
    181 181
         <flexmarkVersion>0.22.18</flexmarkVersion>
    
    182 182
         <hibernateVersion>5.1.9.Final</hibernateVersion>
    

  • server/src/main/filtered-resources/mapping
    ... ... @@ -72,8 +72,8 @@ GET /api/v1/actions/consolidate/ConsolidateDataService/newSimplifiedObjectTyp
    72 72
     POST   /api/v1/actions/report/ReportService/executeReport                                                                            v1.actions.report.ReportServiceRestApi.executeReport
    
    73 73
     POST   /api/v1/actions/report/ReportService/populateVariables                                                                        v1.actions.report.ReportServiceRestApi.populateVariables
    
    74 74
     GET    /api/v1/actions/synchro/referential/diff/ReferentialSynchronizeDiffService/getEnabledReferentialReferenceSet                  v1.actions.synchro.referential.diff.ReferentialSynchronizeDiffServiceRestApi.getEnabledReferentialReferenceSet
    
    75
    +POST   /api/v1/actions/synchro/referential/diff/ReferentialSynchronizeDiffService/getReferential                                     v1.actions.synchro.referential.diff.ReferentialSynchronizeDiffServiceRestApi.getReferential
    
    75 76
     GET    /api/v1/actions/synchro/referential/diff/ReferentialSynchronizeDiffService/getReferentialReferenceSet                         v1.actions.synchro.referential.diff.ReferentialSynchronizeDiffServiceRestApi.getReferentialReferenceSet
    
    76
    -POST   /api/v1/actions/synchro/referential/diff/ReferentialSynchronizeDiffService/getReferentials                                    v1.actions.synchro.referential.diff.ReferentialSynchronizeDiffServiceRestApi.getReferentials
    
    77 77
     GET    /api/v1/actions/synchro/referential/diff/ReferentialSynchronizeDiffService/getSourceReferentialStates                         v1.actions.synchro.referential.diff.ReferentialSynchronizeDiffServiceRestApi.getSourceReferentialStates
    
    78 78
     POST   /api/v1/actions/synchro/referential/legacy/UnidirectionalReferentialSynchronizeLocalService/applySqlRequests                  v1.actions.synchro.referential.legacy.UnidirectionalReferentialSynchronizeLocalServiceRestApi.applySqlRequests
    
    79 79
     GET    /api/v1/actions/synchro/referential/legacy/UnidirectionalReferentialSynchronizeLocalService/filterIdsUsedInLocalSource        v1.actions.synchro.referential.legacy.UnidirectionalReferentialSynchronizeLocalServiceRestApi.filterIdsUsedInLocalSource
    

  • services-topia/src/main/java/fr/ird/observe/services/topia/service/actions/synchro/referential/diff/ReferentialSynchronizeDiffServiceTopia.java
    ... ... @@ -33,7 +33,6 @@ import fr.ird.observe.services.binder.referential.ReferentialBinderSupport;
    33 33
     import fr.ird.observe.services.dto.constants.ReferentialLocale;
    
    34 34
     import fr.ird.observe.services.dto.reference.ReferentialReferenceSet;
    
    35 35
     import fr.ird.observe.services.dto.referential.ReferentialDto;
    
    36
    -import fr.ird.observe.services.dto.referential.ReferentialMultimap;
    
    37 36
     import fr.ird.observe.services.service.actions.synchro.referential.diff.ReferentialDataSourceState;
    
    38 37
     import fr.ird.observe.services.service.actions.synchro.referential.diff.ReferentialDataSourceStates;
    
    39 38
     import fr.ird.observe.services.service.actions.synchro.referential.diff.ReferentialSynchronizeDiffService;
    
    ... ... @@ -50,7 +49,8 @@ import org.nuiton.util.TimeLog;
    50 49
      * @author Tony Chemit - dev@tchemit.fr
    
    51 50
      * @since 5.0
    
    52 51
      */
    
    53
    -public class ReferentialSynchronizeDiffServiceTopia extends ObserveServiceTopia implements ReferentialSynchronizeDiffService {
    
    52
    +public class
    
    53
    +ReferentialSynchronizeDiffServiceTopia extends ObserveServiceTopia implements ReferentialSynchronizeDiffService {
    
    54 54
     
    
    55 55
         /** Logger. */
    
    56 56
         private static final Log log = LogFactory.getLog(ReferentialSynchronizeDiffServiceTopia.class);
    
    ... ... @@ -65,7 +65,6 @@ public class ReferentialSynchronizeDiffServiceTopia extends ObserveServiceTopia
    65 65
             }
    
    66 66
     
    
    67 67
             Class<? extends ObserveReferentialEntity> entityType = BinderEngine.get().getReferentialEntityType(referentialName);
    
    68
    -        ObserveEntityEnum entityEnum = ObserveEntityEnum.valueOf(entityType);
    
    69 68
             return getEnabledReferenceSet0(entityType, referentialName);
    
    70 69
         }
    
    71 70
     
    
    ... ... @@ -76,23 +75,22 @@ public class ReferentialSynchronizeDiffServiceTopia extends ObserveServiceTopia
    76 75
                 log.trace("getReferentialReferenceSet(" + referentialName + ", " + ids.size() + " element(s)");
    
    77 76
             }
    
    78 77
             Class<? extends ObserveReferentialEntity> entityType = BinderEngine.get().getReferentialEntityType(referentialName);
    
    79
    -        ObserveEntityEnum entityEnum = ObserveEntityEnum.valueOf(entityType);
    
    80 78
             return getReferenceSet0(entityType, referentialName, ids);
    
    81 79
         }
    
    82 80
     
    
    83 81
         @Override
    
    84
    -    public <R extends ReferentialDto> ReferentialMultimap<R> getReferentials(Class<R> referentialName, ImmutableSet<String> ids) {
    
    82
    +    public <R extends ReferentialDto> ImmutableSet<R> getReferential(Class<R> referentialName, ImmutableSet<String> ids) {
    
    85 83
             Class<? extends ObserveReferentialEntity> entityType = BinderEngine.get().getReferentialEntityType(referentialName);
    
    86
    -        return getReferentials0(referentialName, entityType, ids);
    
    84
    +        return getReferential0(referentialName, entityType, ids);
    
    87 85
         }
    
    88 86
     
    
    89
    -    private <E extends ObserveReferentialEntity, R extends ReferentialDto> ReferentialMultimap<R> getReferentials0(Class<R> dtoType, Class<E> entityType, ImmutableSet<String> ids) {
    
    90
    -        ReferentialMultimap.Builder<R> result = ReferentialMultimap.builder();
    
    87
    +    private <E extends ObserveReferentialEntity, R extends ReferentialDto> ImmutableSet<R> getReferential0(Class<R> dtoType, Class<E> entityType, ImmutableSet<String> ids) {
    
    88
    +        ImmutableSet.Builder<R> result = ImmutableSet.builder();
    
    91 89
             ReferentialLocale referentialLocale = getReferentialLocale();
    
    92 90
             List<E> entities = loadEntities(entityType, ids);
    
    93 91
             for (E entity : entities) {
    
    94 92
                 ReferentialBinderSupport<ObserveReferentialEntity, R> binder = BinderEngine.get().getReferentialBinder(dtoType);
    
    95
    -            result.put(dtoType, binder.toDto(referentialLocale, entity));
    
    93
    +            result.add(binder.toDto(referentialLocale, entity));
    
    96 94
             }
    
    97 95
     
    
    98 96
             return result.build();
    
    ... ... @@ -110,8 +108,9 @@ public class ReferentialSynchronizeDiffServiceTopia extends ObserveServiceTopia
    110 108
                 if (ObserveEntityEnum.LastUpdateDate.equals(referenceEntity)) {
    
    111 109
                     continue;
    
    112 110
                 }
    
    113
    -            Class entityType = referenceEntity.getContract();
    
    114
    -            Class dtoType = BinderEngine.get().getReferentialDtoType(entityType);
    
    111
    +            //noinspection unchecked
    
    112
    +            Class<? extends ObserveReferentialEntity> entityType = (Class) referenceEntity.getContract();
    
    113
    +            Class<? extends ReferentialDto> dtoType = BinderEngine.get().getReferentialDtoType(entityType);
    
    115 114
                 getLocalSourceReferentialVersions0(dtoType, entityType, referentialStates);
    
    116 115
             }
    
    117 116
             return referentialStates;
    

  • services-topia/src/main/java/fr/ird/observe/services/topia/service/actions/synchro/referential/legacy/UnidirectionalReferentialSynchronizeLocalServiceTopia.java
    ... ... @@ -29,6 +29,7 @@ import fr.ird.observe.persistence.ObserveEntityEnum;
    29 29
     import fr.ird.observe.services.binder.BinderEngine;
    
    30 30
     import fr.ird.observe.services.binder.referential.ReferentialBinderSupport;
    
    31 31
     import fr.ird.observe.services.dto.reference.ReferentialReference;
    
    32
    +import fr.ird.observe.services.dto.reference.ReferentialReferenceSet;
    
    32 33
     import fr.ird.observe.services.dto.referential.GearCaracteristicDto;
    
    33 34
     import fr.ird.observe.services.dto.referential.GearDto;
    
    34 35
     import fr.ird.observe.services.dto.referential.OceanDto;
    
    ... ... @@ -96,7 +97,7 @@ public class UnidirectionalReferentialSynchronizeLocalServiceTopia extends Obser
    96 97
         }
    
    97 98
     
    
    98 99
         @Override
    
    99
    -    public <R extends ReferentialDto> ImmutableSet<ReferentialReference<R>> getLocalSourceReferentialToDelete(Class<R> referentialName, ImmutableSet<String> ids) {
    
    100
    +    public <R extends ReferentialDto> ReferentialReferenceSet<R> getLocalSourceReferentialToDelete(Class<R> referentialName, ImmutableSet<String> ids) {
    
    100 101
     
    
    101 102
             Class<? extends ObserveReferentialEntity> entityType = BinderEngine.get().getReferentialEntityType(referentialName);
    
    102 103
             return getLocalSourceReferentialToDelete0(entityType, referentialName, ids);
    
    ... ... @@ -126,7 +127,8 @@ public class UnidirectionalReferentialSynchronizeLocalServiceTopia extends Obser
    126 127
                 if (ObjectMaterialDto.class.equals(dtoType)) {
    
    127 128
     
    
    128 129
                     // must reorder to be sure to insert parent before sons
    
    129
    -                referentialToAdd = (ImmutableSet) ObjectMaterialHelper.reorder((ImmutableSet) referentialToAdd);
    
    130
    +                //noinspection unchecked
    
    131
    +                referentialToAdd = ObjectMaterialHelper.reorder((ImmutableSet) referentialToAdd);
    
    130 132
     
    
    131 133
                 }
    
    132 134
                 for (R referentialDto : referentialToAdd) {
    
    ... ... @@ -223,17 +225,17 @@ public class UnidirectionalReferentialSynchronizeLocalServiceTopia extends Obser
    223 225
     
    
    224 226
         }
    
    225 227
     
    
    226
    -    private <E extends ObserveReferentialEntity, R extends ReferentialDto> ImmutableSet<ReferentialReference<R>> getLocalSourceReferentialToDelete0(Class<E> entityType, Class<R> dtoType, ImmutableSet<String> ids) {
    
    228
    +    private <E extends ObserveReferentialEntity, R extends ReferentialDto> ReferentialReferenceSet<R> getLocalSourceReferentialToDelete0(Class<E> entityType, Class<R> dtoType, ImmutableSet<String> ids) {
    
    227 229
     
    
    228 230
             TopiaDao<E> dao = getTopiaPersistenceContext().getDao(entityType);
    
    229 231
             List<E> entities = dao.forTopiaIdIn(ids).findAll();
    
    230 232
             ReferentialBinderSupport<E, R> referentialBinder = BinderEngine.get().getReferentialBinder(dtoType);
    
    231
    -        Set<ReferentialReference<R>> result = new LinkedHashSet<>();
    
    233
    +        ImmutableSet.Builder<ReferentialReference<R>> result = ImmutableSet.builder();
    
    232 234
             for (E entity : entities) {
    
    233 235
                 ReferentialReference<R> rReferentialReference = referentialBinder.toReferentialReference(getReferentialLocale(), entity);
    
    234 236
                 result.add(rReferentialReference);
    
    235 237
             }
    
    236
    -        return ImmutableSet.copyOf(result);
    
    238
    +        return ReferentialReferenceSet.of(dtoType, result.build(), null);
    
    237 239
     
    
    238 240
         }
    
    239 241
     
    

  • services/src/main/java/fr/ird/observe/services/dto/referential/ReferentialMultimap.java deleted
    1
    -package fr.ird.observe.services.dto.referential;
    
    2
    -
    
    3
    -/*
    
    4
    - * #%L
    
    5
    - * ObServe :: Services
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 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.ImmutableMap;
    
    26
    -import com.google.common.collect.ImmutableSet;
    
    27
    -import com.google.common.collect.ImmutableSetMultimap;
    
    28
    -import com.google.common.collect.Multimap;
    
    29
    -import com.google.common.collect.Multiset;
    
    30
    -import java.util.Collection;
    
    31
    -import java.util.Objects;
    
    32
    -
    
    33
    -/**
    
    34
    - * @author smaisonneuve
    
    35
    - * Created on 17/08/16.
    
    36
    - */
    
    37
    -public class ReferentialMultimap<K extends ReferentialDto> {
    
    38
    -
    
    39
    -    private ImmutableSetMultimap<Class<K>, K> immutableSetMultimap;
    
    40
    -
    
    41
    -    public static <K extends ReferentialDto, V> ReferentialMultimap<K> of() {
    
    42
    -        return new ReferentialMultimap<>();
    
    43
    -    }
    
    44
    -
    
    45
    -    public static <K extends ReferentialDto> ReferentialMultimap<K> of(Class<K> k1, K v1) {
    
    46
    -        return new ReferentialMultimap<>(k1, v1);
    
    47
    -    }
    
    48
    -
    
    49
    -    public static <K extends ReferentialDto> ReferentialMultimap<K> copyOf(Multimap<Class<K>, K> multimap) {
    
    50
    -        return new ReferentialMultimap<>(multimap);
    
    51
    -    }
    
    52
    -
    
    53
    -    public static <K extends ReferentialDto> Builder<K> builder() {
    
    54
    -        return new Builder<>();
    
    55
    -    }
    
    56
    -
    
    57
    -    public static class Builder<K extends ReferentialDto> {
    
    58
    -        private final ImmutableSetMultimap.Builder<Class<K>, K> builder = ImmutableSetMultimap.builder();
    
    59
    -
    
    60
    -        public Builder<K> add(K referentialDto) {
    
    61
    -            Objects.requireNonNull(referentialDto, "Can't add a null object in ReferentialMultimap");
    
    62
    -            builder.put((Class) referentialDto.getClass(), referentialDto);
    
    63
    -            return this;
    
    64
    -        }
    
    65
    -
    
    66
    -        public Builder put(Class<K> dtoType, K referentialDto) {
    
    67
    -            builder.putAll(dtoType, referentialDto);
    
    68
    -            return this;
    
    69
    -        }
    
    70
    -
    
    71
    -        public Builder putAll(Class<K> dtoType, Collection<K> values) {
    
    72
    -            builder.putAll(dtoType, values);
    
    73
    -            return this;
    
    74
    -        }
    
    75
    -
    
    76
    -        public ReferentialMultimap<K> build() {
    
    77
    -            return copyOf(builder.build());
    
    78
    -        }
    
    79
    -    }
    
    80
    -
    
    81
    -    private ReferentialMultimap() {
    
    82
    -        immutableSetMultimap = ImmutableSetMultimap.<Class<K>, K>builder().build();
    
    83
    -    }
    
    84
    -
    
    85
    -    private ReferentialMultimap(Class<K> k1, K v1) {
    
    86
    -        immutableSetMultimap = ImmutableSetMultimap.of(k1, v1);
    
    87
    -    }
    
    88
    -
    
    89
    -    private ReferentialMultimap(Multimap<Class<K>, K> multimap) {
    
    90
    -        immutableSetMultimap = ImmutableSetMultimap.copyOf(multimap);
    
    91
    -    }
    
    92
    -
    
    93
    -    public ImmutableSet<K> get(Class<K> key) {
    
    94
    -        return immutableSetMultimap.get(key);
    
    95
    -    }
    
    96
    -
    
    97
    -    //    @Override
    
    98
    -//    public ImmutableSet<Class<K>> keySet() {
    
    99
    -//        return immutableSetMultimap.keySet();
    
    100
    -//    }
    
    101
    -//
    
    102
    -    public Multiset<Class<K>> keys() {
    
    103
    -        return immutableSetMultimap.keys();
    
    104
    -    }
    
    105
    -
    
    106
    -    //    @Override
    
    107
    -//    public Collection<K> values() {
    
    108
    -//        return immutableSetMultimap.values();
    
    109
    -//    }
    
    110
    -//
    
    111
    -//    @Override
    
    112
    -//    public ImmutableSet<K> removeAll(Object key) {
    
    113
    -//        return immutableSetMultimap.removeAll(key);
    
    114
    -//    }
    
    115
    -//
    
    116
    -//    @Override
    
    117
    -//    public void clear() {
    
    118
    -//        immutableSetMultimap.clear();
    
    119
    -//    }
    
    120
    -//
    
    121
    -    public int size() {
    
    122
    -        return immutableSetMultimap.size();
    
    123
    -    }
    
    124
    -
    
    125
    -    public boolean isEmpty() {
    
    126
    -        return immutableSetMultimap.isEmpty();
    
    127
    -    }
    
    128
    -
    
    129
    -    //
    
    130
    -//    @Override
    
    131
    -//    public boolean containsKey(Object key) {
    
    132
    -//        return immutableSetMultimap.containsKey(key);
    
    133
    -//    }
    
    134
    -//
    
    135
    -//    @Override
    
    136
    -//    public boolean containsValue(Object value) {
    
    137
    -//        return immutableSetMultimap.containsValue(value);
    
    138
    -//    }
    
    139
    -//
    
    140
    -//    @Override
    
    141
    -//    public boolean containsEntry(Object key, Object value) {
    
    142
    -//        return immutableSetMultimap.containsEntry(key, value);
    
    143
    -//    }
    
    144
    -//
    
    145
    -//    @Override
    
    146
    -//    public boolean put(Class<K> key, K value) {
    
    147
    -//        return immutableSetMultimap.put(key, value);
    
    148
    -//    }
    
    149
    -//
    
    150
    -//    @Override
    
    151
    -//    public boolean remove(Object key, Object value) {
    
    152
    -//        return immutableSetMultimap.remove(key, value);
    
    153
    -//    }
    
    154
    -//
    
    155
    -//    @Override
    
    156
    -//    public boolean putAll(Class<K> key, Iterable<? extends K> values) {
    
    157
    -//        return immutableSetMultimap.putAll(key, values);
    
    158
    -//    }
    
    159
    -//
    
    160
    -//    @Override
    
    161
    -//    public boolean putAll(Multimap<? extends Class<K>, ? extends K> multimap) {
    
    162
    -//        return immutableSetMultimap.putAll(multimap);
    
    163
    -//    }
    
    164
    -//
    
    165
    -//    @Override
    
    166
    -//    public ImmutableSet<K> replaceValues(Class<K> key, Iterable<? extends K> values) {
    
    167
    -//        return immutableSetMultimap.replaceValues(key, values);
    
    168
    -//    }
    
    169
    -//
    
    170
    -//    @Override
    
    171
    -//    public ImmutableSet<Map.Entry<Class<K>, K>> entries() {
    
    172
    -//        return immutableSetMultimap.entries();
    
    173
    -//    }
    
    174
    -//
    
    175
    -    public ImmutableMap<Class<K>, Collection<K>> asMap() {
    
    176
    -        return immutableSetMultimap.asMap();
    
    177
    -    }
    
    178
    -}

  • services/src/main/java/fr/ird/observe/services/gson/ObserveDtoGsonSupplier.java
    ... ... @@ -40,7 +40,6 @@ import fr.ird.observe.services.dto.reference.DataReferenceList;
    40 40
     import fr.ird.observe.services.dto.reference.DataReferenceSet;
    
    41 41
     import fr.ird.observe.services.dto.reference.ReferentialReference;
    
    42 42
     import fr.ird.observe.services.dto.reference.ReferentialReferenceSet;
    
    43
    -import fr.ird.observe.services.dto.referential.ReferentialMultimap;
    
    44 43
     import fr.ird.observe.services.gson.reference.DataReferenceAdapter;
    
    45 44
     import fr.ird.observe.services.gson.reference.DataReferenceListAdapter;
    
    46 45
     import fr.ird.observe.services.gson.reference.DataReferenceSetAdapter;
    
    ... ... @@ -58,20 +57,17 @@ import java.util.function.Supplier;
    58 57
     import org.nuiton.version.Version;
    
    59 58
     
    
    60 59
     /**
    
    61
    - * @author Arnaud Thimel - thimel@codelutin.com
    
    62 60
      * @author Tony Chemit - dev@tchemit.fr
    
    63 61
      */
    
    64 62
     public class ObserveDtoGsonSupplier implements Supplier<Gson> {
    
    65 63
     
    
    66
    -    public static final Supplier<Gson> DEFAULT_GSON_SUPPLIER = () -> new ObserveDtoGsonSupplier().get();
    
    64
    +    private final boolean prettyPrint;
    
    67 65
     
    
    68
    -    protected final boolean prettyPrint;
    
    66
    +    private GsonBuilder gsonBuilder;
    
    69 67
     
    
    70
    -    protected GsonBuilder gsonBuilder;
    
    68
    +    private Gson gson;
    
    71 69
     
    
    72
    -    protected Gson gson;
    
    73
    -
    
    74
    -    public ObserveDtoGsonSupplier() {
    
    70
    +    protected ObserveDtoGsonSupplier() {
    
    75 71
             this(false);
    
    76 72
         }
    
    77 73
     
    
    ... ... @@ -79,7 +75,7 @@ public class ObserveDtoGsonSupplier implements Supplier<Gson> {
    79 75
             this.prettyPrint = prettyPrint;
    
    80 76
         }
    
    81 77
     
    
    82
    -    public static <K, V> TypeToken<Map<K, V>> mapOf(TypeToken<K> keyType, TypeToken<V> valueType) {
    
    78
    +    static <K, V> TypeToken<Map<K, V>> mapOf(TypeToken<K> keyType, TypeToken<V> valueType) {
    
    83 79
             return new TypeToken<Map<K, V>>() {
    
    84 80
             }
    
    85 81
                     .where(new TypeParameter<K>() {
    
    ... ... @@ -88,7 +84,7 @@ public class ObserveDtoGsonSupplier implements Supplier<Gson> {
    88 84
                     }, valueType);
    
    89 85
         }
    
    90 86
     
    
    91
    -    public static <K, V> TypeToken<Map<K, Collection<V>>> multimapOf(TypeToken<K> keyType, TypeToken<V> valueType) {
    
    87
    +    static <K, V> TypeToken<Map<K, Collection<V>>> multimapOf(TypeToken<K> keyType, TypeToken<V> valueType) {
    
    92 88
             return new TypeToken<Map<K, Collection<V>>>() {
    
    93 89
             }
    
    94 90
                     .where(new TypeParameter<K>() {
    
    ... ... @@ -131,7 +127,6 @@ public class ObserveDtoGsonSupplier implements Supplier<Gson> {
    131 127
                 gsonBuilder.registerTypeAdapter(ImmutableMultimap.class, new ImmutableMultimapAdapter());
    
    132 128
                 gsonBuilder.registerTypeAdapter(SetMultimap.class, new SetMultimapAdapter());
    
    133 129
                 gsonBuilder.registerTypeAdapter(ArrayListMultimap.class, new ArrayListMultimapAdapter());
    
    134
    -            gsonBuilder.registerTypeAdapter(ReferentialMultimap.class, new ReferentialMultimapAdapter());
    
    135 130
     
    
    136 131
                 gsonBuilder.registerTypeAdapter(ObserveBlobsContainer.class, new ObserveBlobsContainerAdapter());
    
    137 132
     
    

  • services/src/main/java/fr/ird/observe/services/gson/ReferentialMultimapAdapter.java deleted
    1
    -package fr.ird.observe.services.gson;
    
    2
    -
    
    3
    -/*
    
    4
    - * #%L
    
    5
    - * ObServe :: Services
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 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.reflect.TypeParameter;
    
    26
    -import com.google.common.reflect.TypeToken;
    
    27
    -import com.google.gson.JsonDeserializationContext;
    
    28
    -import com.google.gson.JsonDeserializer;
    
    29
    -import com.google.gson.JsonElement;
    
    30
    -import com.google.gson.JsonObject;
    
    31
    -import com.google.gson.JsonParseException;
    
    32
    -import com.google.gson.JsonSerializationContext;
    
    33
    -import com.google.gson.JsonSerializer;
    
    34
    -import fr.ird.observe.services.dto.referential.ReferentialMultimap;
    
    35
    -import java.lang.reflect.Type;
    
    36
    -import java.util.Collection;
    
    37
    -import java.util.Map;
    
    38
    -import java.util.Set;
    
    39
    -
    
    40
    -/**
    
    41
    - * @author Samuel Maisonneuve - maisonneuve@codelutin.com
    
    42
    - */
    
    43
    -public class ReferentialMultimapAdapter implements JsonSerializer<ReferentialMultimap>, JsonDeserializer<ReferentialMultimap> {
    
    44
    -
    
    45
    -
    
    46
    -    @Override
    
    47
    -    public JsonElement serialize(ReferentialMultimap src, Type typeOfSrc, JsonSerializationContext context) {
    
    48
    -        return context.serialize(src.asMap());
    
    49
    -    }
    
    50
    -
    
    51
    -    @Override
    
    52
    -    public ReferentialMultimap deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
    
    53
    -
    
    54
    -        ReferentialMultimap.Builder builder = ReferentialMultimap.builder();
    
    55
    -
    
    56
    -        Set<Map.Entry<String, JsonElement>> entries = json.getAsJsonObject().entrySet();
    
    57
    -        for (Map.Entry<String, JsonElement> entry : entries) {
    
    58
    -            String keyEntry = entry.getKey();
    
    59
    -            JsonObject keyObject = new JsonObject();
    
    60
    -            keyObject.addProperty("key", keyEntry);
    
    61
    -
    
    62
    -            // Deserialize the key
    
    63
    -            Class key = context.deserialize(keyObject.getAsJsonPrimitive("key"), Class.class);
    
    64
    -
    
    65
    -            // Deserialize the collection associated to the key
    
    66
    -            Type typeToken = collectionOf(key).getType();
    
    67
    -            Collection values = context.deserialize(entry.getValue(), typeToken);
    
    68
    -
    
    69
    -            // Add the key/values to the multimap
    
    70
    -            builder.putAll(key, values);
    
    71
    -        }
    
    72
    -
    
    73
    -        return builder.build();
    
    74
    -
    
    75
    -    }
    
    76
    -
    
    77
    -    static <E> TypeToken<Collection<E>> collectionOf(Class<E> subType) {
    
    78
    -        return new TypeToken<Collection<E>>() {
    
    79
    -        }
    
    80
    -                .where(new TypeParameter<E>() {
    
    81
    -                }, subType);
    
    82
    -    }
    
    83
    -}

  • services/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/diff/ReferentialDataSourceStates.java
    ... ... @@ -23,6 +23,7 @@ package fr.ird.observe.services.service.actions.synchro.referential.diff;
    23 23
      */
    
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26
    +import fr.ird.observe.services.dto.ObserveDto;
    
    26 27
     import fr.ird.observe.services.dto.referential.ReferentialDto;
    
    27 28
     import java.util.LinkedHashMap;
    
    28 29
     import java.util.Map;
    
    ... ... @@ -33,7 +34,7 @@ import java.util.Map;
    33 34
      * @author Tony Chemit - dev@tchemit.fr
    
    34 35
      * @since 5.0
    
    35 36
      */
    
    36
    -public class ReferentialDataSourceStates {
    
    37
    +public class ReferentialDataSourceStates implements ObserveDto {
    
    37 38
     
    
    38 39
         /**
    
    39 40
          * Contient pour chaque type de référentiel la version de chaque référentiel indexé par son nom.
    
    ... ... @@ -48,7 +49,8 @@ public class ReferentialDataSourceStates {
    48 49
          * @param referentialName le nom de référentiel
    
    49 50
          * @return la collection des versions de référentiel du nom demandé.
    
    50 51
          */
    
    51
    -    public <R extends ReferentialDto> ReferentialDataSourceState<R> getReferentialVersions(Class<R> referentialName) {
    
    52
    +    <R extends ReferentialDto> ReferentialDataSourceState<R> getReferentialVersions(Class<R> referentialName) {
    
    53
    +        //noinspection unchecked
    
    52 54
             return diffStatesByType.get(referentialName);
    
    53 55
         }
    
    54 56
     
    

  • services/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/diff/ReferentialSynchronizeDiffService.java
    ... ... @@ -25,7 +25,6 @@ package fr.ird.observe.services.service.actions.synchro.referential.diff;
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import fr.ird.observe.services.dto.reference.ReferentialReferenceSet;
    
    27 27
     import fr.ird.observe.services.dto.referential.ReferentialDto;
    
    28
    -import fr.ird.observe.services.dto.referential.ReferentialMultimap;
    
    29 28
     import fr.ird.observe.services.service.ObserveService;
    
    30 29
     import fr.ird.observe.services.spi.ReadReferentialPermission;
    
    31 30
     import io.ultreia.java4all.http.spi.Get;
    
    ... ... @@ -47,9 +46,10 @@ public interface ReferentialSynchronizeDiffService extends ObserveService {
    47 46
         @ReadReferentialPermission
    
    48 47
         <R extends ReferentialDto> ReferentialReferenceSet<R> getReferentialReferenceSet(Class<R> referentialName, ImmutableSet<String> ids);
    
    49 48
     
    
    49
    +    //FIXME On doit juste retourner un ReferentialReferenceSet, le dictionnaire ne sert à rien (tous les résultats doivent être du même type...)
    
    50 50
         @Post
    
    51 51
         @ReadReferentialPermission
    
    52
    -    <R extends ReferentialDto> ReferentialMultimap<R> getReferentials(Class<R> referentialName, ImmutableSet<String> ids);
    
    52
    +    <R extends ReferentialDto> ImmutableSet<R> getReferential(Class<R> referentialName, ImmutableSet<String> ids);
    
    53 53
     
    
    54 54
         /**
    
    55 55
          * Récupération sur la source à synchroniser des versions de ses référentiels.
    

  • services/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/diff/ReferentialSynchronizeDiffsEngine.java
    ... ... @@ -26,7 +26,6 @@ import com.google.common.collect.ImmutableMap;
    26 26
     import com.google.common.collect.ImmutableSet;
    
    27 27
     import fr.ird.observe.services.dto.reference.ReferentialReferenceSet;
    
    28 28
     import fr.ird.observe.services.dto.referential.ReferentialDto;
    
    29
    -import fr.ird.observe.services.dto.referential.ReferentialMultimap;
    
    30 29
     import java.util.Set;
    
    31 30
     import java.util.stream.Collectors;
    
    32 31
     
    
    ... ... @@ -60,6 +59,7 @@ public class ReferentialSynchronizeDiffsEngine {
    60 59
     
    
    61 60
             for (Class referentialType : allReferentialTypes) {
    
    62 61
     
    
    62
    +            //noinspection unchecked
    
    63 63
                 build0(referentialType, result, leftSourceReferentialStates.getReferentialVersions(referentialType), rightSourceReferentialStates.getReferentialVersions(referentialType));
    
    64 64
             }
    
    65 65
     
    
    ... ... @@ -76,16 +76,14 @@ public class ReferentialSynchronizeDiffsEngine {
    76 76
             return rightDiffService.getReferentialReferenceSet(referentialName, ImmutableSet.copyOf(ids));
    
    77 77
         }
    
    78 78
     
    
    79
    -    public <R extends ReferentialDto> ImmutableSet<R> getLeftReferentials(Class<R> referentialName, ImmutableSet<ReferentialSynchronizeDiffState> diffStates) {
    
    79
    +    public <R extends ReferentialDto> ImmutableSet<R> getLeftReferential(Class<R> referentialName, ImmutableSet<ReferentialSynchronizeDiffState> diffStates) {
    
    80 80
             Set<String> ids = diffStates.stream().map(ReferentialSynchronizeDiffState::getId).collect(Collectors.toSet());
    
    81
    -        ReferentialMultimap<R> referentials = leftDiffService.getReferentials(referentialName, ImmutableSet.copyOf(ids));
    
    82
    -        return referentials.get(referentialName);
    
    81
    +        return leftDiffService.getReferential(referentialName, ImmutableSet.copyOf(ids));
    
    83 82
         }
    
    84 83
     
    
    85
    -    public <R extends ReferentialDto> ImmutableSet<R> getRightReferentials(Class<R> referentialName, ImmutableSet<ReferentialSynchronizeDiffState> diffStates) {
    
    84
    +    public <R extends ReferentialDto> ImmutableSet<R> getRightReferential(Class<R> referentialName, ImmutableSet<ReferentialSynchronizeDiffState> diffStates) {
    
    86 85
             Set<String> ids = diffStates.stream().map(ReferentialSynchronizeDiffState::getId).collect(Collectors.toSet());
    
    87
    -        ReferentialMultimap<R> referentials = rightDiffService.getReferentials(referentialName, ImmutableSet.copyOf(ids));
    
    88
    -        return referentials.get(referentialName);
    
    86
    +        return rightDiffService.getReferential(referentialName, ImmutableSet.copyOf(ids));
    
    89 87
         }
    
    90 88
     
    
    91 89
         public <R extends ReferentialDto> ReferentialReferenceSet<R> getLeftEnabledReferentialReferenceSet(Class<R> referentialName) {
    

  • services/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/legacy/UnidirectionalReferentialSynchronizeContext.java
    ... ... @@ -37,13 +37,13 @@ public class UnidirectionalReferentialSynchronizeContext {
    37 37
         private final UnidirectionalReferentialSynchronizeCallbackRequests callbackRequests;
    
    38 38
         private Set<String> sqlRequests;
    
    39 39
     
    
    40
    -    public UnidirectionalReferentialSynchronizeContext(ImmutableSet<UnidirectionalReferentialSynchronizeRequest.Builder<?>> referentialSynchronizeRequestBuilders, UnidirectionalReferentialSynchronizeCallbackRequests callbackRequests) {
    
    40
    +    UnidirectionalReferentialSynchronizeContext(ImmutableSet<UnidirectionalReferentialSynchronizeRequest.Builder<?>> referentialSynchronizeRequestBuilders, UnidirectionalReferentialSynchronizeCallbackRequests callbackRequests) {
    
    41 41
             this.referentialSynchronizeRequestBuilders = referentialSynchronizeRequestBuilders;
    
    42 42
             this.callbackRequests = callbackRequests;
    
    43 43
         }
    
    44 44
     
    
    45 45
     
    
    46
    -    public ImmutableSet<UnidirectionalReferentialSynchronizeRequest.Builder<?>> getReferentialSynchronizeRequestBuilders() {
    
    46
    +    ImmutableSet<UnidirectionalReferentialSynchronizeRequest.Builder<?>> getReferentialSynchronizeRequestBuilders() {
    
    47 47
             return referentialSynchronizeRequestBuilders;
    
    48 48
         }
    
    49 49
     
    
    ... ... @@ -55,11 +55,11 @@ public class UnidirectionalReferentialSynchronizeContext {
    55 55
             return callbackRequests.isNotEmpty();
    
    56 56
         }
    
    57 57
     
    
    58
    -    public void setSqlRequests(Set<String> sqlRequests) {
    
    58
    +    void setSqlRequests(Set<String> sqlRequests) {
    
    59 59
             this.sqlRequests = sqlRequests;
    
    60 60
         }
    
    61 61
     
    
    62
    -    public Set<String> getSqlRequests() {
    
    62
    +    Set<String> getSqlRequests() {
    
    63 63
             return sqlRequests;
    
    64 64
         }
    
    65 65
     }

  • services/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/legacy/UnidirectionalReferentialSynchronizeEngine.java
    ... ... @@ -116,8 +116,8 @@ public class UnidirectionalReferentialSynchronizeEngine {
    116 116
     
    
    117 117
                 result.flushRequest(referentialSynchronizeRequest);
    
    118 118
     
    
    119
    -            Set<String> sqlRequestsforReferential = localService.generateSqlRequests(referentialSynchronizeRequest);
    
    120
    -            for (String sqlStatement : sqlRequestsforReferential) {
    
    119
    +            Set<String> generatedSqlRequests = localService.generateSqlRequests(referentialSynchronizeRequest);
    
    120
    +            for (String sqlStatement : generatedSqlRequests) {
    
    121 121
     
    
    122 122
                     if (sqlStatement.startsWith("INSERT")) {
    
    123 123
                         insertSqlRequests.add(sqlStatement);
    
    ... ... @@ -160,7 +160,7 @@ public class UnidirectionalReferentialSynchronizeEngine {
    160 160
             if (optionalAddDiffStates.isPresent()) {
    
    161 161
     
    
    162 162
                 ImmutableSet<ReferentialSynchronizeDiffState> referentialSynchronizeDiffStates = optionalAddDiffStates.get();
    
    163
    -            ImmutableSet<R> referentials = diffsEngine.getRightReferentials(referentialName, referentialSynchronizeDiffStates);
    
    163
    +            ImmutableSet<R> referentials = diffsEngine.getRightReferential(referentialName, referentialSynchronizeDiffStates);
    
    164 164
                 referentials.forEach(builder::entityToAdd);
    
    165 165
             }
    
    166 166
     
    
    ... ... @@ -169,7 +169,7 @@ public class UnidirectionalReferentialSynchronizeEngine {
    169 169
             if (optionalUpdateDiffStates.isPresent()) {
    
    170 170
     
    
    171 171
                 ImmutableSet<ReferentialSynchronizeDiffState> referentialSynchronizeDiffStates = optionalUpdateDiffStates.get();
    
    172
    -            ImmutableSet<R> referentials = diffsEngine.getRightReferentials(referentialName, referentialSynchronizeDiffStates);
    
    172
    +            ImmutableSet<R> referentials = diffsEngine.getRightReferential(referentialName, referentialSynchronizeDiffStates);
    
    173 173
                 referentials.forEach(builder::entityToUpdate);
    
    174 174
             }
    
    175 175
     
    
    ... ... @@ -203,9 +203,9 @@ public class UnidirectionalReferentialSynchronizeEngine {
    203 203
                     ReferentialReferenceSet<R> availableReferenceSet = diffsEngine.getRightEnabledReferentialReferenceSet(referentialName);
    
    204 204
                     Set<ReferentialReference<R>> availableReferentials = availableReferenceSet.getReferences();
    
    205 205
     
    
    206
    -                Set<ReferentialReference<R>> blockingReferentialsToRemove = localService.getLocalSourceReferentialToDelete(referentialName, ImmutableSet.copyOf(blockingIdsToRemove));
    
    206
    +                ReferentialReferenceSet<R> blockingReferentialsToRemove = localService.getLocalSourceReferentialToDelete(referentialName, ImmutableSet.copyOf(blockingIdsToRemove));
    
    207 207
     
    
    208
    -                callbackRequests.addCallbackRequest(referentialName, blockingReferentialsToRemove, availableReferentials);
    
    208
    +                callbackRequests.addCallbackRequest(referentialName, blockingReferentialsToRemove.getReferences(), availableReferentials);
    
    209 209
     
    
    210 210
                 }
    
    211 211
     
    

  • services/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/legacy/UnidirectionalReferentialSynchronizeLocalService.java
    ... ... @@ -23,7 +23,7 @@ package fr.ird.observe.services.service.actions.synchro.referential.legacy;
    23 23
      */
    
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26
    -import fr.ird.observe.services.dto.reference.ReferentialReference;
    
    26
    +import fr.ird.observe.services.dto.reference.ReferentialReferenceSet;
    
    27 27
     import fr.ird.observe.services.dto.referential.ReferentialDto;
    
    28 28
     import fr.ird.observe.services.service.ObserveService;
    
    29 29
     import fr.ird.observe.services.spi.ReadReferentialPermission;
    
    ... ... @@ -64,7 +64,7 @@ public interface UnidirectionalReferentialSynchronizeLocalService extends Observ
    64 64
          */
    
    65 65
         @ReadReferentialPermission
    
    66 66
         @Get
    
    67
    -    <R extends ReferentialDto> ImmutableSet<ReferentialReference<R>> getLocalSourceReferentialToDelete(Class<R> referentialName, ImmutableSet<String> ids);
    
    67
    +    <R extends ReferentialDto> ReferentialReferenceSet<R> getLocalSourceReferentialToDelete(Class<R> referentialName, ImmutableSet<String> ids);
    
    68 68
     
    
    69 69
         /**
    
    70 70
          * Pour produire le code sql à partir de la demande pour un référentiel donné.
    

  • services/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/legacy/UnidirectionalReferentialSynchronizeRequest.java
    ... ... @@ -25,10 +25,8 @@ package fr.ird.observe.services.service.actions.synchro.referential.legacy;
    25 25
     import com.google.common.base.MoreObjects;
    
    26 26
     import com.google.common.collect.ImmutableMap;
    
    27 27
     import com.google.common.collect.ImmutableSet;
    
    28
    -import com.google.common.collect.Multiset;
    
    29 28
     import fr.ird.observe.services.dto.ObserveDto;
    
    30 29
     import fr.ird.observe.services.dto.referential.ReferentialDto;
    
    31
    -import fr.ird.observe.services.dto.referential.ReferentialMultimap;
    
    32 30
     import java.util.Objects;
    
    33 31
     
    
    34 32
     /**
    
    ... ... @@ -44,13 +42,13 @@ import java.util.Objects;
    44 42
     public class UnidirectionalReferentialSynchronizeRequest<R extends ReferentialDto> implements ObserveDto {
    
    45 43
     
    
    46 44
         public static <R extends ReferentialDto> Builder<R> builder(Class<R> referentialName) {
    
    47
    -        Objects.nonNull(referentialName);
    
    45
    +        Objects.requireNonNull(referentialName);
    
    48 46
             return new Builder<>(referentialName);
    
    49 47
         }
    
    50 48
     
    
    51 49
         private final Class<R> referentialName;
    
    52
    -    private final ReferentialMultimap<R> referentialToAdd;
    
    53
    -    private final ReferentialMultimap<R> referentialToUpdate;
    
    50
    +    private final ImmutableSet<R> referentialToAdd;
    
    51
    +    private final ImmutableSet<R> referentialToUpdate;
    
    54 52
         private final ImmutableSet<String> referentialToRemove;
    
    55 53
         private final ImmutableMap<String, String> referentialToReplace;
    
    56 54
     
    
    ... ... @@ -59,25 +57,11 @@ public class UnidirectionalReferentialSynchronizeRequest<R extends ReferentialDt
    59 57
         }
    
    60 58
     
    
    61 59
         public ImmutableSet<R> getReferentialToAdd() {
    
    62
    -        ImmutableSet<R> result = ImmutableSet.of();
    
    63
    -
    
    64
    -        Multiset<Class<R>> entries = referentialToAdd.keys();
    
    65
    -        if (!entries.isEmpty()) {
    
    66
    -            result = referentialToAdd.get(entries.iterator().next());
    
    67
    -        }
    
    68
    -
    
    69
    -        return result;
    
    60
    +        return referentialToAdd;
    
    70 61
         }
    
    71 62
     
    
    72 63
         public ImmutableSet<R> getReferentialToUpdate() {
    
    73
    -        ImmutableSet<R> result = ImmutableSet.of();
    
    74
    -
    
    75
    -        Multiset<Class<R>> entries = referentialToUpdate.keys();
    
    76
    -        if (!entries.isEmpty()) {
    
    77
    -            result = referentialToUpdate.get(entries.iterator().next());
    
    78
    -        }
    
    79
    -
    
    80
    -        return result;
    
    64
    +        return referentialToUpdate;
    
    81 65
         }
    
    82 66
     
    
    83 67
         public ImmutableSet<String> getReferentialToRemove() {
    
    ... ... @@ -116,8 +100,8 @@ public class UnidirectionalReferentialSynchronizeRequest<R extends ReferentialDt
    116 100
         }
    
    117 101
     
    
    118 102
         private UnidirectionalReferentialSynchronizeRequest(Class<R> referentialName,
    
    119
    -                                                        ReferentialMultimap<R> referentialToAdd,
    
    120
    -                                                        ReferentialMultimap<R> referentialToUpdate,
    
    103
    +                                                        ImmutableSet<R> referentialToAdd,
    
    104
    +                                                        ImmutableSet<R> referentialToUpdate,
    
    121 105
                                                             ImmutableSet<String> referentialToRemove,
    
    122 106
                                                             ImmutableMap<String, String> toReplace) {
    
    123 107
             this.referentialName = referentialName;
    
    ... ... @@ -130,27 +114,27 @@ public class UnidirectionalReferentialSynchronizeRequest<R extends ReferentialDt
    130 114
         public static class Builder<R extends ReferentialDto> {
    
    131 115
     
    
    132 116
             private final Class<R> referentialName;
    
    133
    -        private final ReferentialMultimap.Builder<R> toAddBuilder = ReferentialMultimap.builder();
    
    134
    -        private final ReferentialMultimap.Builder<R> toUpdateBuilder = ReferentialMultimap.builder();
    
    117
    +        private final ImmutableSet.Builder<R> toAddBuilder = ImmutableSet.builder();
    
    118
    +        private final ImmutableSet.Builder<R> toUpdateBuilder = ImmutableSet.builder();
    
    135 119
             private final ImmutableSet.Builder<String> toRemoveBuilder = ImmutableSet.builder();
    
    136 120
             private final ImmutableMap.Builder<String, String> toReplaceBuilder = ImmutableMap.builder();
    
    137 121
     
    
    138
    -        public Builder entityToAdd(R referentialDto) {
    
    122
    +        Builder entityToAdd(R referentialDto) {
    
    139 123
                 toAddBuilder.add(referentialDto);
    
    140 124
                 return this;
    
    141 125
             }
    
    142 126
     
    
    143
    -        public Builder entityToUpdate(R referentialDto) {
    
    127
    +        Builder entityToUpdate(R referentialDto) {
    
    144 128
                 toUpdateBuilder.add(referentialDto);
    
    145 129
                 return this;
    
    146 130
             }
    
    147 131
     
    
    148
    -        public Builder entityToRemove(String id) {
    
    132
    +        Builder entityToRemove(String id) {
    
    149 133
                 toRemoveBuilder.add(id);
    
    150 134
                 return this;
    
    151 135
             }
    
    152 136
     
    
    153
    -        public Builder entityToReplace(String sourceId, String targetId) {
    
    137
    +        Builder entityToReplace(String sourceId, String targetId) {
    
    154 138
                 toReplaceBuilder.put(sourceId, targetId);
    
    155 139
                 return this;
    
    156 140
             }
    

  • services/src/main/java/fr/ird/observe/services/service/sql/AddSqlScriptProducerRequest.java
    ... ... @@ -27,6 +27,7 @@ import com.google.common.collect.ArrayListMultimap;
    27 27
     import com.google.common.collect.ImmutableSet;
    
    28 28
     import com.google.common.collect.ListMultimap;
    
    29 29
     import com.google.common.collect.Multimaps;
    
    30
    +import fr.ird.observe.services.dto.ObserveDto;
    
    30 31
     import fr.ird.observe.services.dto.referential.ReferentialDto;
    
    31 32
     import java.util.Set;
    
    32 33
     import java.util.stream.Collectors;
    
    ... ... @@ -36,15 +37,15 @@ import java.util.stream.Collectors;
    36 37
      *
    
    37 38
      * @author Tony Chemit - dev@tchemit.fr
    
    38 39
      */
    
    39
    -public class AddSqlScriptProducerRequest {
    
    40
    -
    
    41
    -    protected final boolean postgres;
    
    42
    -    protected boolean addSchema;
    
    43
    -    protected boolean addReferential;
    
    44
    -    protected boolean addSomeReferential;
    
    45
    -    protected boolean addData;
    
    46
    -    protected ImmutableSet<String> dataIds;
    
    47
    -    protected final ArrayListMultimap<Class<? extends ReferentialDto>, String> referentialIds = ArrayListMultimap.create();
    
    40
    +public class AddSqlScriptProducerRequest implements ObserveDto {
    
    41
    +
    
    42
    +    private final boolean postgres;
    
    43
    +    private boolean addSchema;
    
    44
    +    private boolean addReferential;
    
    45
    +    private boolean addSomeReferential;
    
    46
    +    private boolean addData;
    
    47
    +    private ImmutableSet<String> dataIds;
    
    48
    +    private final ArrayListMultimap<Class<? extends ReferentialDto>, String> referentialIds = ArrayListMultimap.create();
    
    48 49
     
    
    49 50
         public static AddSqlScriptProducerRequest forH2() {
    
    50 51
             return new AddSqlScriptProducerRequest(false);
    

  • services/src/main/java/fr/ird/observe/services/service/sql/AddSqlScriptProducerResult.java
    ... ... @@ -24,13 +24,14 @@ package fr.ird.observe.services.service.sql;
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import fr.ird.observe.services.dto.ObserveBlobsContainer;
    
    27
    +import fr.ird.observe.services.dto.ObserveDto;
    
    27 28
     
    
    28 29
     /**
    
    29 30
      * Created on 24/08/16.
    
    30 31
      *
    
    31 32
      * @author Tony Chemit - dev@tchemit.fr
    
    32 33
      */
    
    33
    -public class AddSqlScriptProducerResult {
    
    34
    +public class AddSqlScriptProducerResult implements ObserveDto{
    
    34 35
     
    
    35 36
         private final byte[] sqlCode;
    
    36 37
     
    

  • services/src/main/java/fr/ird/observe/services/service/sql/DeleteSqlScriptProducerRequest.java
    ... ... @@ -24,6 +24,8 @@ package fr.ird.observe.services.service.sql;
    24 24
     
    
    25 25
     import com.google.common.base.MoreObjects;
    
    26 26
     import com.google.common.collect.ImmutableSet;
    
    27
    +import fr.ird.observe.services.dto.ObserveDto;
    
    28
    +import java.util.Objects;
    
    27 29
     import java.util.stream.Collectors;
    
    28 30
     
    
    29 31
     /**
    
    ... ... @@ -31,7 +33,7 @@ import java.util.stream.Collectors;
    31 33
      *
    
    32 34
      * @author Tony Chemit - dev@tchemit.fr
    
    33 35
      */
    
    34
    -public class DeleteSqlScriptProducerRequest {
    
    36
    +public class DeleteSqlScriptProducerRequest implements ObserveDto {
    
    35 37
     
    
    36 38
         protected boolean deleteData;
    
    37 39
         protected ImmutableSet<String> dataIds;
    
    ... ... @@ -40,26 +42,14 @@ public class DeleteSqlScriptProducerRequest {
    40 42
             return new DeleteSqlScriptProducerRequest();
    
    41 43
         }
    
    42 44
     
    
    43
    -    public static DeleteSqlScriptProducerRequest forH2() {
    
    44
    -        return new DeleteSqlScriptProducerRequest();
    
    45
    -    }
    
    46
    -
    
    47
    -    public static DeleteSqlScriptProducerRequest forPostgres() {
    
    48
    -        return new DeleteSqlScriptProducerRequest();
    
    49
    -    }
    
    50
    -
    
    51
    -    public DeleteSqlScriptProducerRequest deleteAllData() {
    
    52
    -        deleteData = true;
    
    53
    -        return this;
    
    54
    -    }
    
    55
    -
    
    56 45
         public DeleteSqlScriptProducerRequest dataIdsToDelete(ImmutableSet<String> dataIds) {
    
    57
    -        deleteData = true;
    
    46
    +        Objects.requireNonNull(dataIds);
    
    47
    +        this.deleteData = true;
    
    58 48
             this.dataIds = dataIds;
    
    59 49
             return this;
    
    60 50
         }
    
    61 51
     
    
    62
    -    protected DeleteSqlScriptProducerRequest() {
    
    52
    +    private DeleteSqlScriptProducerRequest() {
    
    63 53
         }
    
    64 54
     
    
    65 55
         public boolean isDeleteData() {