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

Commits:

4 changed files:

Changes:

  • client-configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java
    ... ... @@ -30,6 +30,7 @@ import fr.ird.observe.dto.FloatingObjectPreset;
    30 30
     import fr.ird.observe.dto.presets.RemoteDataSourceConfiguration;
    
    31 31
     import fr.ird.observe.dto.presets.ServerDataSourceConfiguration;
    
    32 32
     import fr.ird.observe.services.service.CleanTemporaryFilesTaskConfiguration;
    
    33
    +import fr.ird.observe.services.service.actions.consolidate.dcp.SimplifiedObjectTypeSpecializedRules;
    
    33 34
     import io.ultreia.java4all.config.ApplicationConfig;
    
    34 35
     import io.ultreia.java4all.config.ApplicationConfigInit;
    
    35 36
     import io.ultreia.java4all.config.ApplicationConfigScope;
    
    ... ... @@ -44,6 +45,8 @@ import org.nuiton.version.Version;
    44 45
     import org.nuiton.version.Versions;
    
    45 46
     
    
    46 47
     import java.io.File;
    
    48
    +import java.io.IOException;
    
    49
    +import java.net.URI;
    
    47 50
     import java.nio.charset.StandardCharsets;
    
    48 51
     import java.text.ParseException;
    
    49 52
     import java.text.SimpleDateFormat;
    
    ... ... @@ -80,29 +83,19 @@ public class ClientConfig extends GeneratedClientConfig implements NavigationTre
    80 83
                 ClientConfigOption.MAP_LAYER8,
    
    81 84
                 ClientConfigOption.MAP_LAYER9,
    
    82 85
                 ClientConfigOption.MAP_LAYER10);
    
    83
    -    /** le pattern du fichier de sauvegarde d'une base locale */
    
    86
    +    /**
    
    87
    +     * le pattern du fichier de sauvegarde d'une base locale
    
    88
    +     */
    
    84 89
         private static final String BACKUP_DB_PATTERN = "observe-v%1$s-%2$tF--%2$tk-%2$tM-%2$tS.sql.gz";
    
    85 90
         private static final String APPLICATION_VERSION = "application.version";
    
    86 91
         private static final String VERSION = "version";
    
    87
    -    private static final String PROPERTY_LOCAL_STORAGE_EXIST = "localStorageExist";
    
    88
    -    private static final String PROPERTY_INITIAL_DUMP_EXIST = "initialDumpExist";
    
    89
    -    private static final String PROPERTY_MAIN_STORAGE_OPENED = "mainStorageOpened";
    
    90
    -    /** Logger */
    
    91 92
         private static final Logger log = LogManager.getLogger(ClientConfig.class);
    
    92 93
         private static final String DEFAULT_OBSERVE_SWING_CONFIGURATION_FILENAME = "observe-client.conf";
    
    93
    -    /**
    
    94
    -     * Liste des options qu'on ne peut pas sauvegarder (les mots de passes,
    
    95
    -     * les options d'admin pour les simples utilisateurs,...).
    
    96
    -     *
    
    97
    -     * @since 1.5
    
    98
    -     */
    
    99
    -    private final String[] unsavables = new String[]{
    
    100
    -//            ClientConfigOption.OBSTUNA_PASSWORD.getKey(),
    
    94
    +    private final String[] skipSaveProperties = new String[]{
    
    101 95
                 ClientConfigOption.H2_PASSWORD.getKey(),
    
    102 96
                 ClientConfigOption.OBSTUNA_CAN_MIGRATE.getKey(),
    
    103 97
         };
    
    104
    -    //FIXME
    
    105
    -    private final ImmutableSet<String> longlinVesselTypeIds = ImmutableSet.copyOf(
    
    98
    +    private final ImmutableSet<String> longlineVesselTypeIds = ImmutableSet.copyOf(
    
    106 99
                 ImmutableSet.of("fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.044156847891821505",
    
    107 100
                                 "fr.ird.observe.entities.referentiel.VesselType#1239832675736#0.8708229847859869",
    
    108 101
                                 "fr.ird.observe.entities.referentiel.VesselType#1239832686137#0.1"));
    
    ... ... @@ -118,14 +111,18 @@ public class ClientConfig extends GeneratedClientConfig implements NavigationTre
    118 111
          * valeur peut être programmées lors des actions.
    
    119 112
          */
    
    120 113
         private boolean displayMainUI = true;
    
    121
    -    /** drapeau pour savoir si une base locale existe */
    
    114
    +    /**
    
    115
    +     * drapeau pour savoir si une base locale existe
    
    116
    +     */
    
    122 117
         private boolean localStorageExist;
    
    123 118
         /**
    
    124 119
          * drapeau pour savoir si le dump initial a ete chargée depuis la base
    
    125 120
          * centrale
    
    126 121
          */
    
    127 122
         private boolean initialDumpExist;
    
    128
    -    /** drapeau pour savoir si une source de données est ouverte */
    
    123
    +    /**
    
    124
    +     * drapeau pour savoir si une source de données est ouverte
    
    125
    +     */
    
    129 126
         private boolean mainStorageOpened;
    
    130 127
         /**
    
    131 128
          * drapeau pour savoir si la source ouverte est locale (attention, lorsqu'il
    
    ... ... @@ -140,13 +137,19 @@ public class ClientConfig extends GeneratedClientConfig implements NavigationTre
    140 137
          * trouvé.
    
    141 138
          */
    
    142 139
         private boolean canUseUI = true;
    
    143
    -    /** La version de l'application */
    
    140
    +    /**
    
    141
    +     * La version de l'application
    
    142
    +     */
    
    144 143
         private Version version;
    
    145
    -    /** Texte du copyright (calculé dynamiquement). */
    
    144
    +    /**
    
    145
    +     * Texte du copyright (calculé dynamiquement).
    
    146
    +     */
    
    146 147
         private String copyrightText;
    
    147 148
         private ImmutableList<ServerDataSourceConfiguration> serverDataSourceConfigurationList;
    
    148 149
         private ImmutableList<RemoteDataSourceConfiguration> remoteDataSourceConfigurationList;
    
    149 150
     
    
    151
    +    private SimplifiedObjectTypeSpecializedRules simplifiedObjectTypeSpecializedRules;
    
    152
    +
    
    150 153
         public ClientConfig() {
    
    151 154
             this(DEFAULT_OBSERVE_SWING_CONFIGURATION_FILENAME);
    
    152 155
         }
    
    ... ... @@ -372,41 +375,10 @@ public class ClientConfig extends GeneratedClientConfig implements NavigationTre
    372 375
     
    
    373 376
         public void saveForUser() {
    
    374 377
             log.info(t("observe.message.save.configuration", get().getUserConfigFile()));
    
    375
    -        get().saveForUser(unsavables);
    
    378
    +        get().saveForUser(skipSaveProperties);
    
    376 379
         }
    
    377 380
     
    
    378 381
         public void removeJaxxPropertyChangeListener() {
    
    379
    -//        pcs.getPropertyChangeListeners();
    
    380
    -//        List<String> tmp = new ArrayList<>();
    
    381
    -//        for (ClientConfigOption option : ClientConfigOption.values()) {
    
    382
    -//            String propertyName = option.getPropertyKey();
    
    383
    -//            if (propertyName != null) {
    
    384
    -//                tmp.add(propertyName);
    
    385
    -//            }
    
    386
    -//        }
    
    387
    -//        if (log.isDebugEnabled()) {
    
    388
    -//            log.debug("property names to seek for options : " + tmp);
    
    389
    -//        }
    
    390
    -//        String[] propertyNames = tmp.toArray(
    
    391
    -//                new String[tmp.size()]);
    
    392
    -//
    
    393
    -//        PropertyChangeListener[] toRemove =
    
    394
    -//                SwingUtil.findJaxxPropertyChangeListener(
    
    395
    -//                        propertyNames,
    
    396
    -//                        getPropertyChangeListeners());
    
    397
    -//        if (toRemove == null || toRemove.length == 0) {
    
    398
    -//            return;
    
    399
    -//        }
    
    400
    -//        if (log.isDebugEnabled()) {
    
    401
    -//            log.debug("before remove : " + pcs.getPropertyChangeListeners().length);
    
    402
    -////            log.debug("toRemove : " + toRemove.length);
    
    403
    -//        }
    
    404
    -//        for (PropertyChangeListener listener : pcs.getPropertyChangeListeners()) {
    
    405
    -//            removePropertyChangeListener(listener);
    
    406
    -//        }
    
    407
    -//        if (log.isDebugEnabled()) {
    
    408
    -//            log.debug("after remove : " + pcs.getPropertyChangeListeners().length);
    
    409
    -//        }
    
    410 382
         }
    
    411 383
     
    
    412 384
         public Set<String> getSeineVesselTypeIds() {
    
    ... ... @@ -414,7 +386,20 @@ public class ClientConfig extends GeneratedClientConfig implements NavigationTre
    414 386
         }
    
    415 387
     
    
    416 388
         public Set<String> getLonglineVesselTypeIds() {
    
    417
    -        return longlinVesselTypeIds;
    
    389
    +        return longlineVesselTypeIds;
    
    390
    +    }
    
    391
    +
    
    392
    +
    
    393
    +    public SimplifiedObjectTypeSpecializedRules getSimplifiedObjectTypeSpecializedRules() {
    
    394
    +        if (simplifiedObjectTypeSpecializedRules == null) {
    
    395
    +            URI uri = getSimplifiedObjectTypeSpecializedRulesFile().toURI();
    
    396
    +            try {
    
    397
    +                simplifiedObjectTypeSpecializedRules = new SimplifiedObjectTypeSpecializedRules(uri.toURL());
    
    398
    +            } catch (IOException e) {
    
    399
    +                throw new RuntimeException(String.format("Can't load simplifiedObjectTypeSpecializedRules from %s", uri), e);
    
    400
    +            }
    
    401
    +        }
    
    402
    +        return simplifiedObjectTypeSpecializedRules;
    
    418 403
         }
    
    419 404
     
    
    420 405
         @Override
    

  • client-core/src/main/java/fr/ird/observe/client/ui/admin/consolidate/ConsolidateUIHandler.java
    ... ... @@ -40,9 +40,6 @@ import org.apache.logging.log4j.Logger;
    40 40
     import org.nuiton.jaxx.runtime.spi.UIHandler;
    
    41 41
     import org.nuiton.jaxx.runtime.swing.wizard.ext.WizardState;
    
    42 42
     
    
    43
    -import java.io.File;
    
    44
    -import java.io.IOException;
    
    45
    -import java.net.URL;
    
    46 43
     import java.util.Date;
    
    47 44
     import java.util.Set;
    
    48 45
     import java.util.stream.Collectors;
    
    ... ... @@ -57,7 +54,6 @@ import static io.ultreia.java4all.i18n.I18n.t;
    57 54
      */
    
    58 55
     public class ConsolidateUIHandler extends AdminTabUIHandler<ConsolidateUI> implements UIHandler<ConsolidateUI> {
    
    59 56
     
    
    60
    -    /** Logger */
    
    61 57
         private static final Logger log = LogManager.getLogger(ConsolidateUIHandler.class);
    
    62 58
     
    
    63 59
         @Override
    
    ... ... @@ -86,8 +82,8 @@ public class ConsolidateUIHandler extends AdminTabUIHandler<ConsolidateUI> imple
    86 82
     
    
    87 83
             Set<DataDtoReference<?, ?>> trips = getModel().getSelectDataModel().getSelectionDataModel().getSelectedData();
    
    88 84
             ImmutableSet<String> tripIds = ImmutableSet.copyOf(trips.stream()
    
    89
    -                                                                   .filter(input -> IdHelper.isTripSeineId(input.getId()))
    
    90 85
                                                                        .map(DataDtoReference::getId)
    
    86
    +                                                                   .filter(IdHelper::isTripSeineId)
    
    91 87
                                                                        .collect(Collectors.toSet()));
    
    92 88
     
    
    93 89
             ProgressModel progressModel = getStepModel().getProgressModel();
    
    ... ... @@ -110,13 +106,7 @@ public class ConsolidateUIHandler extends AdminTabUIHandler<ConsolidateUI> imple
    110 106
                     request.setTripSeineId(tripId);
    
    111 107
                     request.setFailIfLengthWeightParameterNotFound(false);
    
    112 108
     
    
    113
    -                SimplifiedObjectTypeSpecializedRules simplifiedObjectTypeSpecializedRules;
    
    114
    -                try {
    
    115
    -                    File definition = ObserveSwingApplicationContext.get().getConfig().getSimplifiedObjectTypeSpecializedRulesFile();
    
    116
    -                    simplifiedObjectTypeSpecializedRules = new SimplifiedObjectTypeSpecializedRules(definition.toURI().toURL());
    
    117
    -                } catch (IOException e) {
    
    118
    -                    throw new RuntimeException(e);
    
    119
    -                }
    
    109
    +                SimplifiedObjectTypeSpecializedRules simplifiedObjectTypeSpecializedRules = ObserveSwingApplicationContext.get().getConfig().getSimplifiedObjectTypeSpecializedRules();
    
    120 110
                     ConsolidateTripSeineDataResult result = consolidateDataService.consolidateTripSeine(simplifiedObjectTypeSpecializedRules, request);
    
    121 111
                     if (result != null) {
    
    122 112
     
    

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java
    ... ... @@ -71,8 +71,6 @@ import javax.swing.SwingUtilities;
    71 71
     import javax.swing.event.TableModelListener;
    
    72 72
     import java.awt.Component;
    
    73 73
     import java.awt.Container;
    
    74
    -import java.io.File;
    
    75
    -import java.io.IOException;
    
    76 74
     import java.util.ArrayList;
    
    77 75
     import java.util.Collection;
    
    78 76
     import java.util.HashSet;
    
    ... ... @@ -401,13 +399,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    401 399
     
    
    402 400
         private void recomputeComputedValues() {
    
    403 401
     
    
    404
    -        SimplifiedObjectTypeSpecializedRules simplifiedObjectTypeSpecializedRules;
    
    405
    -        try {
    
    406
    -            File definition = ObserveSwingApplicationContext.get().getConfig().getSimplifiedObjectTypeSpecializedRulesFile();
    
    407
    -            simplifiedObjectTypeSpecializedRules = new SimplifiedObjectTypeSpecializedRules(definition.toURI().toURL());
    
    408
    -        } catch (IOException e) {
    
    409
    -            throw new RuntimeException(e);
    
    410
    -        }
    
    402
    +        SimplifiedObjectTypeSpecializedRules simplifiedObjectTypeSpecializedRules = ObserveSwingApplicationContext.get().getConfig().getSimplifiedObjectTypeSpecializedRules();
    
    411 403
             ConsolidateFloatingObjectResult result = getConsolidateDataService().consolidateFloatingObject(simplifiedObjectTypeSpecializedRules, new ConsolidateFloatingObjectRequest(getBean(), getModel().toParts()));
    
    412 404
             if (result != null) {
    
    413 405
                 log.info("Flush consolidate dcp changes...");
    

  • services-local/src/test/java/fr/ird/observe/services/local/service/actions/consolidate/dcp/SimplifiedObjectTypeManagerTest.java
    ... ... @@ -45,11 +45,12 @@ import java.util.stream.Collectors;
    45 45
      *
    
    46 46
      * @author Tony Chemit - dev@tchemit.fr
    
    47 47
      */
    
    48
    +@SuppressWarnings("SpellCheckingInspection")
    
    48 49
     @DatabaseNameConfiguration(DatabaseName.referentiel)
    
    49 50
     public class SimplifiedObjectTypeManagerTest extends ServiceLocalTestSupport {
    
    50 51
     
    
    51 52
         /**
    
    52
    -     * From https://gitlab.com/ultreiaio/ird-observe/issues/1412 (specific cases)
    
    53
    +     * From <a href="https://gitlab.com/ultreiaio/ird-observe/issues/1412">specific cases</a>
    
    53 54
          */
    
    54 55
         @Test
    
    55 56
         public void getSpecializedStandardCode() throws DatabaseNotFoundException, BabModelVersionException, DatabaseConnexionNotAuthorizedException, IOException {
    
    ... ... @@ -57,7 +58,7 @@ public class SimplifiedObjectTypeManagerTest extends ServiceLocalTestSupport {
    57 58
             URL definition = getClass().getResource("/observe-specialized-fad-rules.properties");
    
    58 59
             SimplifiedObjectTypeManager simplifiedObjectTypeManager = localTestMethodResource.newService(ConsolidateDataService.class).newSimplifiedObjectTypeManager(new SimplifiedObjectTypeSpecializedRules(definition));
    
    59 60
     
    
    60
    -        SimplifiedObjectTypeNode fob = simplifiedObjectTypeManager.getNodeForStandardCode("FOB");
    
    61
    +//        SimplifiedObjectTypeNode fob = simplifiedObjectTypeManager.getNodeForStandardCode("FOB");
    
    61 62
             SimplifiedObjectTypeNode fad = simplifiedObjectTypeManager.getNodeForStandardCode("FAD");
    
    62 63
             SimplifiedObjectTypeNode dfad = simplifiedObjectTypeManager.getNodeForStandardCode("DFAD");
    
    63 64
             SimplifiedObjectTypeNode afad = simplifiedObjectTypeManager.getNodeForStandardCode("AFAD");