Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
3c6f6c90
by Tony Chemit at 2020-05-21T14:20:04+02:00
21 changed files:
- client-configuration/src/main/config/Client.ini
- client-configuration/src/main/i18n/getters/config.getter
- client-configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java
- client-core/src/main/java/fr/ird/observe/client/datasource/api/ObserveSwingDataSource.java
- + client-core/src/main/java/fr/ird/observe/client/util/action/ActionState.java
- client-datasource-editor-api/pom.xml
- client-datasource-editor-api/src/main/i18n/getters/java.getter
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/MainDataSourceListener.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/menu/actions/ChangeStorageAction.java
- + client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/menu/actions/FeedBackBuilder.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/menu/actions/ImportStorageFromFileAction.java
- + client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/menu/actions/LoadStorageActionSupport.java
- + client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/menu/actions/LoadingDataSourceContext.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/wizard/StorageUIHandler.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/wizard/StorageUILauncher.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/wizard/StorageUIModel.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/wizard/connexion/DataSourceSelectorModel.java
- client-runner/src/main/java/fr/ird/observe/client/RunObserve.java
- observe-i18n/src/main/i18n/translations/observe_en_GB.properties
- observe-i18n/src/main/i18n/translations/observe_es_ES.properties
- observe-i18n/src/main/i18n/translations/observe_fr_FR.properties
Changes:
| ... | ... | @@ -82,6 +82,14 @@ defaultValue = ${data.directory}/backup |
| 82 | 82 |
transient = true
|
| 83 | 83 |
final = true
|
| 84 | 84 |
|
| 85 |
+[option feedBackDirectory]
|
|
| 86 |
+description = observe.config.feedBackDirectory.description
|
|
| 87 |
+key = feedBack.directory
|
|
| 88 |
+type = file
|
|
| 89 |
+defaultValue = ${data.directory}/feedback
|
|
| 90 |
+transient = true
|
|
| 91 |
+final = true
|
|
| 92 |
+ |
|
| 85 | 93 |
[option resourcesDirectory]
|
| 86 | 94 |
description = observe.config.defaultResourcesDirectory.description
|
| 87 | 95 |
key = resources.directory
|
| ... | ... | @@ -34,6 +34,7 @@ observe.config.defaultMapDirectory.description |
| 34 | 34 |
observe.config.defaultReportDirectory.description
|
| 35 | 35 |
observe.config.defaultResourcesDirectory.description
|
| 36 | 36 |
observe.config.defaultValidationReportDirectory.description
|
| 37 |
+observe.config.feedBackDirectory.description
|
|
| 37 | 38 |
observe.config.h2.can.editReferential.description
|
| 38 | 39 |
observe.config.h2.can.migrate.description
|
| 39 | 40 |
observe.config.h2.login.description
|
| ... | ... | @@ -116,6 +116,7 @@ public class ClientConfig extends GeneratedClientConfig implements TemplateGener |
| 116 | 116 |
private static final Logger log = LogManager.getLogger(ClientConfig.class);
|
| 117 | 117 |
/** le pattern du fichier de sauvegarde d'une base locale */
|
| 118 | 118 |
private static final String BACKUP_DB_PATTERN = "observe-v%1$s-%2$tF--%2$tk-%2$tM-%2$tS.sql.gz";
|
| 119 |
+ private static final String FEED_BACK_PATTERN = "observe-v%1$s-feedback-%2$tF--%2$tk-%2$tM-%2$tS.zip";
|
|
| 119 | 120 |
private static final String APPLICATION_VERSION = "application.version";
|
| 120 | 121 |
private static final String VERSION = "version";
|
| 121 | 122 |
|
| ... | ... | @@ -539,6 +540,9 @@ public class ClientConfig extends GeneratedClientConfig implements TemplateGener |
| 539 | 540 |
public File newBackupDataFile() {
|
| 540 | 541 |
return new File(getBackupDirectory(), String.format(BACKUP_DB_PATTERN, getBuildVersion().toString().replaceAll("\\.","_"), new Date()));
|
| 541 | 542 |
}
|
| 543 |
+ public File newFeedBackFile() {
|
|
| 544 |
+ return new File(getFeedBackDirectory(), String.format(FEED_BACK_PATTERN, getBuildVersion().toString().replaceAll("\\.","_"), new Date()));
|
|
| 545 |
+ }
|
|
| 542 | 546 |
|
| 543 | 547 |
public void saveForUser() {
|
| 544 | 548 |
log.info(t("observe.message.save.configuration", get().getUserConfigFile()));
|
| ... | ... | @@ -25,9 +25,11 @@ package fr.ird.observe.client.datasource.api; |
| 25 | 25 |
import com.google.common.collect.ImmutableList;
|
| 26 | 26 |
import com.google.common.collect.ImmutableSet;
|
| 27 | 27 |
import fr.ird.observe.client.configuration.ClientConfig;
|
| 28 |
+import fr.ird.observe.client.configuration.WithClientConfig;
|
|
| 28 | 29 |
import fr.ird.observe.client.datasource.api.event.ObserveSwingDataSourceEvent;
|
| 29 | 30 |
import fr.ird.observe.client.datasource.api.event.ObserveSwingDataSourceListener;
|
| 30 | 31 |
import fr.ird.observe.client.datasource.dcp.FloatingObjectPresetsManager;
|
| 32 |
+import fr.ird.observe.client.util.UIHelper;
|
|
| 31 | 33 |
import fr.ird.observe.dto.IdDto;
|
| 32 | 34 |
import fr.ird.observe.dto.ObserveUtil;
|
| 33 | 35 |
import fr.ird.observe.dto.data.ps.dcp.FloatingObjectPreset;
|
| ... | ... | @@ -64,6 +66,8 @@ import fr.ird.observe.services.service.DatabaseOpenException; |
| 64 | 66 |
import fr.ird.observe.services.service.ObserveService;
|
| 65 | 67 |
import fr.ird.observe.services.service.referential.ObserveReferentialCache;
|
| 66 | 68 |
import fr.ird.observe.services.service.referential.ReferentialService;
|
| 69 |
+import fr.ird.observe.services.service.sql.AddSqlScriptProducerRequest;
|
|
| 70 |
+import fr.ird.observe.services.service.sql.SqlScriptProducerService;
|
|
| 67 | 71 |
import fr.ird.observe.spi.map.ImmutableSetDtoMap;
|
| 68 | 72 |
import fr.ird.observe.spi.map.ImmutableSetStringMap;
|
| 69 | 73 |
import fr.ird.observe.spi.map.ImmutableTypedMap;
|
| ... | ... | @@ -72,6 +76,7 @@ import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition; |
| 72 | 76 |
import org.apache.logging.log4j.LogManager;
|
| 73 | 77 |
import org.apache.logging.log4j.Logger;
|
| 74 | 78 |
import org.nuiton.jaxx.runtime.swing.SwingUtil;
|
| 79 |
+import org.nuiton.topia.persistence.script.TopiaSqlScript;
|
|
| 75 | 80 |
import org.nuiton.version.Version;
|
| 76 | 81 |
|
| 77 | 82 |
import javax.swing.BoundedRangeModel;
|
| ... | ... | @@ -80,10 +85,12 @@ import javax.swing.JOptionPane; |
| 80 | 85 |
import javax.swing.event.EventListenerList;
|
| 81 | 86 |
import java.io.File;
|
| 82 | 87 |
import java.io.IOException;
|
| 88 |
+import java.nio.file.Files;
|
|
| 83 | 89 |
import java.nio.file.Path;
|
| 84 | 90 |
import java.util.Iterator;
|
| 85 | 91 |
import java.util.Locale;
|
| 86 | 92 |
import java.util.Map;
|
| 93 |
+import java.util.Objects;
|
|
| 87 | 94 |
import java.util.Set;
|
| 88 | 95 |
import java.util.TreeMap;
|
| 89 | 96 |
import java.util.TreeSet;
|
| ... | ... | @@ -96,7 +103,7 @@ import static io.ultreia.java4all.i18n.I18n.t; |
| 96 | 103 |
*/
|
| 97 | 104 |
@GenerateJavaBeanDefinition
|
| 98 | 105 |
@GenerateTemplate(template = "dataSourceInformation.ftl")
|
| 99 |
-public class ObserveSwingDataSource extends ObserveServicesProviderSupport {
|
|
| 106 |
+public class ObserveSwingDataSource extends ObserveServicesProviderSupport implements WithClientConfig {
|
|
| 100 | 107 |
|
| 101 | 108 |
private static final Logger log = LogManager.getLogger(ObserveSwingDataSource.class);
|
| 102 | 109 |
|
| ... | ... | @@ -106,6 +113,7 @@ public class ObserveSwingDataSource extends ObserveServicesProviderSupport { |
| 106 | 113 |
private final ObserveReferentialCache referentialCache;
|
| 107 | 114 |
private final ObserveServicesProvider servicesProvider;
|
| 108 | 115 |
private final Icon icon;
|
| 116 |
+ private final ObserveServiceMainFactory serviceFactory;
|
|
| 109 | 117 |
private ObserveDataSourceConnection connection;
|
| 110 | 118 |
private BoundedRangeModel progressModel;
|
| 111 | 119 |
|
| ... | ... | @@ -116,7 +124,6 @@ public class ObserveSwingDataSource extends ObserveServicesProviderSupport { |
| 116 | 124 |
// indique si l'utilisateur connecté est le propriétaire de la base
|
| 117 | 125 |
private boolean owner;
|
| 118 | 126 |
private boolean superUser;
|
| 119 |
- private final ObserveServiceMainFactory serviceFactory;
|
|
| 120 | 127 |
|
| 121 | 128 |
public ObserveSwingDataSource(ClientConfig config, ObserveServiceMainFactory serviceFactory, ObserveDataSourceConfiguration configuration) {
|
| 122 | 129 |
this.config = config;
|
| ... | ... | @@ -357,14 +364,8 @@ public class ObserveSwingDataSource extends ObserveServicesProviderSupport { |
| 357 | 364 |
JOptionPane.WARNING_MESSAGE);
|
| 358 | 365 |
|
| 359 | 366 |
if (answer == JOptionPane.YES_OPTION) {
|
| 360 |
- |
|
| 361 | 367 |
DataSourceService dataSourceService = servicesProvider.getDataSourceService();
|
| 362 |
- |
|
| 363 |
- |
|
| 364 |
- if (log.isInfoEnabled()) {
|
|
| 365 |
- log.info("Migrate data source " + getLabel() + " in " + dbVersion + " to " + targetVersion);
|
|
| 366 |
- }
|
|
| 367 |
- |
|
| 368 |
+ log.info(String.format("Migrate data source %s in %s to %s", getLabel(), dbVersion, targetVersion));
|
|
| 368 | 369 |
dataSourceService.migrateData(getConfiguration());
|
| 369 | 370 |
}
|
| 370 | 371 |
}
|
| ... | ... | @@ -457,12 +458,27 @@ public class ObserveSwingDataSource extends ObserveServicesProviderSupport { |
| 457 | 458 |
this.superUser = superUser;
|
| 458 | 459 |
}
|
| 459 | 460 |
|
| 460 |
- public void addObserveSwingDataSourceListener(ObserveSwingDataSourceListener listener) {
|
|
| 461 |
- listenerList.add(ObserveSwingDataSourceListener.class, listener);
|
|
| 461 |
+ /**
|
|
| 462 |
+ * Effectue une sauvegarde de la base locale vers le fichier choisi.
|
|
| 463 |
+ *
|
|
| 464 |
+ * @param dst le fichier de sauvegarde
|
|
| 465 |
+ */
|
|
| 466 |
+ public void backupLocalDatabase(Path dst) {
|
|
| 467 |
+ Objects.requireNonNull(dst, "file where to backup can not be null");
|
|
| 468 |
+ log.info(String.format("Do backup of %s into: %s", this, dst));
|
|
| 469 |
+ try {
|
|
| 470 |
+ Files.deleteIfExists(dst);
|
|
| 471 |
+ AddSqlScriptProducerRequest request = AddSqlScriptProducerRequest.forH2(getClientConfig().getModelVersion()).addSchema().addReferential().addAllData();
|
|
| 472 |
+ SqlScriptProducerService dumpProducerService = getSqlScriptProducerService();
|
|
| 473 |
+ TopiaSqlScript dataDump = dumpProducerService.produceAddSqlScript(request);
|
|
| 474 |
+ dataDump.copy(dst);
|
|
| 475 |
+ } catch (Exception e) {
|
|
| 476 |
+ UIHelper.handlingError(e);
|
|
| 477 |
+ }
|
|
| 462 | 478 |
}
|
| 463 | 479 |
|
| 464 |
- private ObserveSwingDataSourceListener[] getObserveSwingDataSourceListener() {
|
|
| 465 |
- return listenerList.getListeners(ObserveSwingDataSourceListener.class);
|
|
| 480 |
+ public void addObserveSwingDataSourceListener(ObserveSwingDataSourceListener listener) {
|
|
| 481 |
+ listenerList.add(ObserveSwingDataSourceListener.class, listener);
|
|
| 466 | 482 |
}
|
| 467 | 483 |
|
| 468 | 484 |
public void removeObserveSwingDataSourceListener(ObserveSwingDataSourceListener listener) {
|
| ... | ... | @@ -470,6 +486,10 @@ public class ObserveSwingDataSource extends ObserveServicesProviderSupport { |
| 470 | 486 |
listenerList.remove(ObserveSwingDataSourceListener.class, listener);
|
| 471 | 487 |
}
|
| 472 | 488 |
|
| 489 |
+ private ObserveSwingDataSourceListener[] getObserveSwingDataSourceListener() {
|
|
| 490 |
+ return listenerList.getListeners(ObserveSwingDataSourceListener.class);
|
|
| 491 |
+ }
|
|
| 492 |
+ |
|
| 473 | 493 |
private void fireNewMessage(String message) {
|
| 474 | 494 |
fireNewMessage(message, ObserveSwingDataSourceEvent.MessageLevel.INFO);
|
| 475 | 495 |
}
|
| ... | ... | @@ -645,7 +665,7 @@ public class ObserveSwingDataSource extends ObserveServicesProviderSupport { |
| 645 | 665 |
missingIds.removeAll(resultIds);
|
| 646 | 666 |
log.warn(String.format("Remove preset: %s (%s id(s) not found in database).", preset.getLabel(config.getReferentialLocale()), missingIds));
|
| 647 | 667 |
}
|
| 648 |
- progressModel.setExtent(1);
|
|
| 668 |
+ progressModel.setValue(progressModel.getValue() + 1);
|
|
| 649 | 669 |
}
|
| 650 | 670 |
|
| 651 | 671 |
public void setCanMigrate(ClientConfig appConfig) {
|
| 1 |
+package fr.ird.observe.client.util.action;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client Core
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 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 |
+/**
|
|
| 26 |
+ * Describe an atomic action state.
|
|
| 27 |
+ *
|
|
| 28 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 29 |
+ * @since 8.0
|
|
| 30 |
+ */
|
|
| 31 |
+public enum ActionState {
|
|
| 32 |
+ /**
|
|
| 33 |
+ * When action is skipped.
|
|
| 34 |
+ */
|
|
| 35 |
+ SKIP,
|
|
| 36 |
+ /**
|
|
| 37 |
+ * When action is pending.
|
|
| 38 |
+ */
|
|
| 39 |
+ PENDING,
|
|
| 40 |
+ /**
|
|
| 41 |
+ * When action is done.
|
|
| 42 |
+ */
|
|
| 43 |
+ DONE,
|
|
| 44 |
+ /**
|
|
| 45 |
+ * When action has failed.
|
|
| 46 |
+ */
|
|
| 47 |
+ FAILED;
|
|
| 48 |
+ |
|
| 49 |
+ public boolean notSkip() {
|
|
| 50 |
+ return this != SKIP;
|
|
| 51 |
+ }
|
|
| 52 |
+ |
|
| 53 |
+ public boolean skip() {
|
|
| 54 |
+ return this == SKIP;
|
|
| 55 |
+ }
|
|
| 56 |
+ |
|
| 57 |
+ public boolean success() {
|
|
| 58 |
+ return this == DONE;
|
|
| 59 |
+ }
|
|
| 60 |
+ |
|
| 61 |
+ public boolean fail() {
|
|
| 62 |
+ return this == FAILED;
|
|
| 63 |
+ }
|
|
| 64 |
+ |
|
| 65 |
+ public boolean pending() {
|
|
| 66 |
+ return this == PENDING;
|
|
| 67 |
+ }
|
|
| 68 |
+ |
|
| 69 |
+ public static ActionState failIfPreviousFail(ActionState initialState, ActionState... previousStates) {
|
|
| 70 |
+ if (initialState.skip()) {
|
|
| 71 |
+ // If we are on skip state, then nothing to do, so previous states are not used
|
|
| 72 |
+ return initialState;
|
|
| 73 |
+ }
|
|
| 74 |
+ for (ActionState previousState : previousStates) {
|
|
| 75 |
+ if (previousState.fail()) {
|
|
| 76 |
+ // One of previous state has failed, so this will automatic failed
|
|
| 77 |
+ return FAILED;
|
|
| 78 |
+ }
|
|
| 79 |
+ }
|
|
| 80 |
+ // Nothing was changed from previous state
|
|
| 81 |
+ return initialState;
|
|
| 82 |
+ }
|
|
| 83 |
+ |
|
| 84 |
+ public static ActionState pendingIfPreviousFail(ActionState initialState, ActionState... previousStates) {
|
|
| 85 |
+ if (initialState.pending()) {
|
|
| 86 |
+ // If we are on pending state, then already mark to do it, so previous states are not used
|
|
| 87 |
+ return initialState;
|
|
| 88 |
+ }
|
|
| 89 |
+ for (ActionState previousState : previousStates) {
|
|
| 90 |
+ if (previousState.fail()) {
|
|
| 91 |
+ // One of previous state has failed, so this will automatic failed
|
|
| 92 |
+ return PENDING;
|
|
| 93 |
+ }
|
|
| 94 |
+ }
|
|
| 95 |
+ // Nothing was changed from previous state
|
|
| 96 |
+ return initialState;
|
|
| 97 |
+ }
|
|
| 98 |
+ |
|
| 99 |
+ |
|
| 100 |
+}
|
| ... | ... | @@ -86,6 +86,11 @@ |
| 86 | 86 |
<artifactId>persistence</artifactId>
|
| 87 | 87 |
</dependency>
|
| 88 | 88 |
|
| 89 |
+ <dependency>
|
|
| 90 |
+ <groupId>io.ultreia.java4all.config</groupId>
|
|
| 91 |
+ <artifactId>config-api</artifactId>
|
|
| 92 |
+ </dependency>
|
|
| 93 |
+ |
|
| 89 | 94 |
<dependency>
|
| 90 | 95 |
<groupId>io.ultreia.java4all</groupId>
|
| 91 | 96 |
<artifactId>application-context</artifactId>
|
| ... | ... | @@ -85,6 +85,7 @@ observe.action.test.server.tip |
| 85 | 85 |
observe.choice.cancel
|
| 86 | 86 |
observe.choice.continue
|
| 87 | 87 |
observe.choice.doNotSave
|
| 88 |
+observe.choice.generateFeedBack
|
|
| 88 | 89 |
observe.choice.quit
|
| 89 | 90 |
observe.choice.replace
|
| 90 | 91 |
observe.choice.save
|
| ... | ... | @@ -137,7 +138,10 @@ observe.entity.message.creating |
| 137 | 138 |
observe.entity.message.reading
|
| 138 | 139 |
observe.entity.message.updating
|
| 139 | 140 |
observe.error.storage.could.not.backup.unsane.local.db
|
| 141 |
+observe.error.storage.could.not.close.local.data.source.message
|
|
| 142 |
+observe.error.storage.could.not.close.local.data.source.title
|
|
| 140 | 143 |
observe.error.storage.could.not.load.local.db
|
| 144 |
+observe.error.storage.could.not.open.local.data.source.title
|
|
| 141 | 145 |
observe.menu.navigation.action.noAction
|
| 142 | 146 |
observe.message.db.closed
|
| 143 | 147 |
observe.message.db.loaded
|
| ... | ... | @@ -42,13 +42,11 @@ import static io.ultreia.java4all.i18n.I18n.t; |
| 42 | 42 |
class MainDataSourceListener extends ObserveSwingDataSourceListenerAdapter implements WithObserveDataSourcesManager, WithClientConfig, WithClientUIContext {
|
| 43 | 43 |
|
| 44 | 44 |
private final ObserveDataSourcesManager dataSourcesManager;
|
| 45 |
- private final ClientConfig config;
|
|
| 46 | 45 |
private final DataSourceEditorBodyContent bodyContent;
|
| 47 | 46 |
|
| 48 | 47 |
public MainDataSourceListener(DataSourceEditorBodyContent bodyContent) {
|
| 49 | 48 |
this.bodyContent = bodyContent;
|
| 50 | 49 |
this.dataSourcesManager = getObserveDataSourcesManager();
|
| 51 |
- this.config = getClientConfig();
|
|
| 52 | 50 |
}
|
| 53 | 51 |
|
| 54 | 52 |
@Override
|
| ... | ... | @@ -60,9 +58,6 @@ class MainDataSourceListener extends ObserveSwingDataSourceListenerAdapter imple |
| 60 | 58 |
@Override
|
| 61 | 59 |
public void onOpened(ObserveSwingDataSourceEvent event) {
|
| 62 | 60 |
ObserveSwingDataSource source = event.getSource();
|
| 63 |
- if (source.isLocal()) {
|
|
| 64 |
- config.setLocalStorageExist(true);
|
|
| 65 |
- }
|
|
| 66 | 61 |
bodyContent.setDataSource(source);
|
| 67 | 62 |
}
|
| 68 | 63 |
|
| ... | ... | @@ -23,14 +23,18 @@ package fr.ird.observe.client.datasource.editor.menu.actions; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.constants.DbMode;
|
| 26 |
-import fr.ird.observe.client.datasource.editor.menu.DataSourceEditorMenu;
|
|
| 26 |
+import fr.ird.observe.client.datasource.api.ObserveDataSourcesManagerApplicationComponent;
|
|
| 27 |
+import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
|
| 28 |
+import fr.ird.observe.client.datasource.editor.wizard.StorageStep;
|
|
| 29 |
+import fr.ird.observe.client.datasource.editor.wizard.StorageUI;
|
|
| 27 | 30 |
import fr.ird.observe.client.datasource.editor.wizard.StorageUILauncher;
|
| 31 |
+import fr.ird.observe.client.datasource.editor.wizard.StorageUIModel;
|
|
| 28 | 32 |
import fr.ird.observe.client.main.ObserveMainUI;
|
| 29 |
-import fr.ird.observe.client.main.body.NoBodyContentComponent;
|
|
| 33 |
+import org.apache.commons.collections4.CollectionUtils;
|
|
| 30 | 34 |
import org.apache.logging.log4j.LogManager;
|
| 31 | 35 |
import org.apache.logging.log4j.Logger;
|
| 32 | 36 |
|
| 33 |
-import java.awt.event.ActionEvent;
|
|
| 37 |
+import java.util.Arrays;
|
|
| 34 | 38 |
import java.util.EnumSet;
|
| 35 | 39 |
import java.util.Set;
|
| 36 | 40 |
import java.util.stream.Collectors;
|
| ... | ... | @@ -43,7 +47,7 @@ import static io.ultreia.java4all.i18n.I18n.t; |
| 43 | 47 |
* @author Tony Chemit - dev@tchemit.fr
|
| 44 | 48 |
* @since 3.13
|
| 45 | 49 |
*/
|
| 46 |
-public class ChangeStorageAction extends DataSourceEditorMenuActionSupport implements Runnable {
|
|
| 50 |
+public class ChangeStorageAction extends LoadStorageActionSupport {
|
|
| 47 | 51 |
|
| 48 | 52 |
private static final Logger log = LogManager.getLogger(ChangeStorageAction.class);
|
| 49 | 53 |
|
| ... | ... | @@ -54,12 +58,6 @@ public class ChangeStorageAction extends DataSourceEditorMenuActionSupport imple |
| 54 | 58 |
this(null, null);
|
| 55 | 59 |
}
|
| 56 | 60 |
|
| 57 |
- public ChangeStorageAction(String actionName, char keyStroke) {
|
|
| 58 |
- super(actionName, t("observe.action.change.storage"), t("observe.action.change.storage.tip"), "db-change", keyStroke);
|
|
| 59 |
- this.dbModes = EnumSet.noneOf(DbMode.class);
|
|
| 60 |
- this.title = null;
|
|
| 61 |
- }
|
|
| 62 |
- |
|
| 63 | 61 |
public ChangeStorageAction(Set<DbMode> dbModes, String title) {
|
| 64 | 62 |
super(t("observe.action.change.storage"), t("observe.action.change.storage.tip"), "db-change", 'C');
|
| 65 | 63 |
this.dbModes = dbModes == null ? EnumSet.noneOf(DbMode.class) : dbModes;
|
| ... | ... | @@ -67,21 +65,47 @@ public class ChangeStorageAction extends DataSourceEditorMenuActionSupport imple |
| 67 | 65 |
}
|
| 68 | 66 |
|
| 69 | 67 |
@Override
|
| 70 |
- protected void doActionPerformed(ActionEvent event, DataSourceEditorMenu ui) {
|
|
| 71 |
- run();
|
|
| 68 |
+ protected String getTitle() {
|
|
| 69 |
+ return t(title);
|
|
| 72 | 70 |
}
|
| 73 | 71 |
|
| 74 | 72 |
@Override
|
| 75 |
- public void run() {
|
|
| 73 |
+ protected void init(StorageUI ui) {
|
|
| 74 |
+ log.debug(String.format("Incoming db mode : %s", dbModes.stream().map(DbMode::name).collect(Collectors.joining(", "))));
|
|
| 75 |
+ StorageUIModel model = ui.getModel();
|
|
| 76 |
+ if (CollectionUtils.isNotEmpty(dbModes)) {
|
|
| 77 |
+ log.info(String.format("will use incoming mode %s", dbModes.stream().map(DbMode::name).collect(Collectors.joining(", "))));
|
|
| 78 |
+ |
|
| 79 |
+ model.setExcludeSteps(Arrays.asList(StorageStep.SELECT_DATA,
|
|
| 80 |
+ StorageStep.BACKUP,
|
|
| 81 |
+ StorageStep.CONFIG_REFERENTIAL,
|
|
| 82 |
+ StorageStep.CONFIG_DATA,
|
|
| 83 |
+ StorageStep.ROLES));
|
|
| 84 |
+ model.setCanCreateLocalService(dbModes.contains(DbMode.CREATE_LOCAL));
|
|
| 85 |
+ model.setCanUseLocalService(dbModes.contains(DbMode.USE_LOCAL));
|
|
| 86 |
+ model.setCanUseRemoteService(dbModes.contains(DbMode.USE_REMOTE));
|
|
| 87 |
+ model.setCanUseServerService(dbModes.contains(DbMode.USE_SERVER));
|
|
| 76 | 88 |
|
| 77 |
- ObserveMainUI mainUI = getClientUIContext().getMainUI();
|
|
| 78 |
- boolean canContinue = mainUI.changeBodyContent(NoBodyContentComponent.class);
|
|
| 79 |
-// boolean canContinue = getContentUIManager().closeSelectedContentUI();
|
|
| 80 |
- if (canContinue) {
|
|
| 81 |
- log.info("Start change storage with dbMode: " + dbModes.stream().map(DbMode::name).collect(Collectors.joining(", ")));
|
|
| 82 |
- StorageUILauncher.changeStorage(ui == null ? mainUI : ui, mainUI, dbModes, t(title));
|
|
| 89 |
+ model.updateUniverse();
|
|
| 90 |
+ model.setDbMode(dbModes.stream().findFirst().orElse(null));
|
|
| 83 | 91 |
|
| 92 |
+ } else {
|
|
| 93 |
+ boolean localOpened = ObserveDataSourcesManagerApplicationComponent.value().getOptionalMainDataSource().map(ObserveSwingDataSource::isLocal).orElse(false);
|
|
| 94 |
+ if (localOpened) {
|
|
| 95 |
+ log.debug("Can not use local db (already opened)");
|
|
| 96 |
+ model.setCanUseLocalService(false);
|
|
| 97 |
+ }
|
|
| 98 |
+ model.setCanCreateLocalService(true);
|
|
| 99 |
+ model.setCanUseRemoteService(true);
|
|
| 100 |
+ model.setCanUseServerService(true);
|
|
| 84 | 101 |
}
|
| 102 |
+ model.updateUniverse();
|
|
| 103 |
+ }
|
|
| 85 | 104 |
|
| 105 |
+ @Override
|
|
| 106 |
+ protected StorageUILauncher startWizard(ObserveMainUI mainUI) {
|
|
| 107 |
+ log.info(String.format("Start change storage with dbMode: %s", dbModes.stream().map(DbMode::name).collect(Collectors.joining(", "))));
|
|
| 108 |
+ return super.startWizard(mainUI);
|
|
| 86 | 109 |
}
|
| 110 |
+ |
|
| 87 | 111 |
}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.menu.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor API
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 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 fr.ird.observe.client.ClientUIContextApplicationComponent;
|
|
| 26 |
+import fr.ird.observe.client.configuration.ClientConfig;
|
|
| 27 |
+import fr.ird.observe.client.util.UIHelper;
|
|
| 28 |
+import fr.ird.observe.client.util.action.ActionState;
|
|
| 29 |
+import org.apache.commons.io.FileUtils;
|
|
| 30 |
+import org.apache.logging.log4j.LogManager;
|
|
| 31 |
+import org.apache.logging.log4j.Logger;
|
|
| 32 |
+ |
|
| 33 |
+import javax.swing.JOptionPane;
|
|
| 34 |
+import java.io.File;
|
|
| 35 |
+import java.io.FileOutputStream;
|
|
| 36 |
+import java.io.IOException;
|
|
| 37 |
+import java.nio.file.Files;
|
|
| 38 |
+import java.nio.file.Path;
|
|
| 39 |
+import java.util.Objects;
|
|
| 40 |
+import java.util.zip.ZipEntry;
|
|
| 41 |
+import java.util.zip.ZipOutputStream;
|
|
| 42 |
+ |
|
| 43 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 44 |
+ |
|
| 45 |
+public class FeedBackBuilder {
|
|
| 46 |
+ |
|
| 47 |
+ private static final Logger log = LogManager.getLogger(FeedBackBuilder.class);
|
|
| 48 |
+ |
|
| 49 |
+ private final LoadingDataSourceContext loadingContext;
|
|
| 50 |
+ private final ClientConfig config;
|
|
| 51 |
+ private final File feedBackFile;
|
|
| 52 |
+ |
|
| 53 |
+ public static void onClosingLocalDataSource(LoadingDataSourceContext loadingContext) {
|
|
| 54 |
+ new FeedBackBuilder(loadingContext).onClosingLocalDataSource();
|
|
| 55 |
+ }
|
|
| 56 |
+ |
|
| 57 |
+ public static void onLoadingLocalDataSource(LoadingDataSourceContext loadingContext) {
|
|
| 58 |
+ new FeedBackBuilder(loadingContext).onLoadingLocalDataSource();
|
|
| 59 |
+ }
|
|
| 60 |
+ |
|
| 61 |
+ public FeedBackBuilder(LoadingDataSourceContext loadingContext) {
|
|
| 62 |
+ this.loadingContext = Objects.requireNonNull(loadingContext);
|
|
| 63 |
+ this.config = loadingContext.getConfig();
|
|
| 64 |
+ this.feedBackFile = config.newFeedBackFile();
|
|
| 65 |
+ }
|
|
| 66 |
+ |
|
| 67 |
+ private void onClosingLocalDataSource() {
|
|
| 68 |
+ ActionState actionState = onLocalDataSourceError(t("observe.error.storage.could.not.close.local.data.source.title", feedBackFile));
|
|
| 69 |
+ loadingContext.setFeedBackOnClosingLocalDatasourceState(actionState);
|
|
| 70 |
+ |
|
| 71 |
+ }
|
|
| 72 |
+ |
|
| 73 |
+ private void onLoadingLocalDataSource() {
|
|
| 74 |
+ ActionState actionState = onLocalDataSourceError(t("observe.error.storage.could.not.open.local.data.source.title", feedBackFile));
|
|
| 75 |
+ loadingContext.setFeedBackOnClosingLocalDatasourceState(actionState);
|
|
| 76 |
+ |
|
| 77 |
+ }
|
|
| 78 |
+ |
|
| 79 |
+ |
|
| 80 |
+ private ActionState onLocalDataSourceError(String title) {
|
|
| 81 |
+ |
|
| 82 |
+ int response = UIHelper.askUser(ClientUIContextApplicationComponent.value().getMainUI(), title, t("observe.error.storage.could.not.close.local.data.source.message"), JOptionPane.ERROR_MESSAGE,
|
|
| 83 |
+ new Object[]{t("observe.choice.generateFeedBack"), t("observe.choice.cancel")}, 1);
|
|
| 84 |
+ |
|
| 85 |
+ |
|
| 86 |
+ switch (response) {
|
|
| 87 |
+ case JOptionPane.CLOSED_OPTION:
|
|
| 88 |
+ case 1:
|
|
| 89 |
+ // cancel operation
|
|
| 90 |
+ return ActionState.FAILED;
|
|
| 91 |
+ }
|
|
| 92 |
+ log.info(String.format("Create feed back at: %s", feedBackFile));
|
|
| 93 |
+ try {
|
|
| 94 |
+ createFeedBack();
|
|
| 95 |
+ setLocalStorageDoesNotExist();
|
|
| 96 |
+ destroyLocalDataSource();
|
|
| 97 |
+ loadingContext.setFeedBackOnLoadingLocalDatasourceState(ActionState.DONE);
|
|
| 98 |
+ } catch (IOException e) {
|
|
| 99 |
+ log.error("Could not create feed back", e);
|
|
| 100 |
+ return ActionState.FAILED;
|
|
| 101 |
+ }
|
|
| 102 |
+ return ActionState.DONE;
|
|
| 103 |
+ }
|
|
| 104 |
+ |
|
| 105 |
+ |
|
| 106 |
+ private void createFeedBack() throws IOException {
|
|
| 107 |
+ if (Files.notExists(feedBackFile.toPath())) {
|
|
| 108 |
+ Files.createDirectories(feedBackFile.toPath());
|
|
| 109 |
+ }
|
|
| 110 |
+ try (ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(feedBackFile))) {
|
|
| 111 |
+ copyDirectoryToZip(config.getDbDirectory().toPath(), outputStream);
|
|
| 112 |
+ copyDirectoryToZip(config.getResourcesDirectory().toPath(), outputStream);
|
|
| 113 |
+ Path userConfigFile = config.get().getUserConfigFile().toPath();
|
|
| 114 |
+ copyFileToZip(userConfigFile.getParent(), userConfigFile, outputStream);
|
|
| 115 |
+ }
|
|
| 116 |
+ }
|
|
| 117 |
+ |
|
| 118 |
+ private void destroyLocalDataSource() throws IOException {
|
|
| 119 |
+ File dataSourceDirectory = config.getDbDirectory();
|
|
| 120 |
+ FileUtils.cleanDirectory(dataSourceDirectory);
|
|
| 121 |
+ }
|
|
| 122 |
+ |
|
| 123 |
+ private void copyDirectoryToZip(Path rootFile, ZipOutputStream zipOutputStream) throws IOException {
|
|
| 124 |
+ Files.walk(rootFile).filter(Files::isRegularFile).forEach(p -> copyFileToZip(rootFile, p, zipOutputStream));
|
|
| 125 |
+ }
|
|
| 126 |
+ |
|
| 127 |
+ private void copyFileToZip(Path rootFile, Path file, ZipOutputStream zipOutputStream) {
|
|
| 128 |
+ |
|
| 129 |
+ String entryName = file.relativize(rootFile).toString();
|
|
| 130 |
+ try {
|
|
| 131 |
+ zipOutputStream.putNextEntry(new ZipEntry(entryName));
|
|
| 132 |
+ Files.copy(file, zipOutputStream);
|
|
| 133 |
+ } catch (IOException e) {
|
|
| 134 |
+ log.error(String.format("Could not copy file %s to zip entry %S", file, entryName));
|
|
| 135 |
+ }
|
|
| 136 |
+ |
|
| 137 |
+ }
|
|
| 138 |
+ |
|
| 139 |
+ private void setLocalStorageDoesNotExist() {
|
|
| 140 |
+ config.setLocalStorageExist(false);
|
|
| 141 |
+ config.saveForUser();
|
|
| 142 |
+ }
|
|
| 143 |
+ |
|
| 144 |
+}
|
| ... | ... | @@ -25,17 +25,14 @@ package fr.ird.observe.client.datasource.editor.menu.actions; |
| 25 | 25 |
import fr.ird.observe.client.configuration.ClientConfig;
|
| 26 | 26 |
import fr.ird.observe.client.constants.CreationMode;
|
| 27 | 27 |
import fr.ird.observe.client.constants.DbMode;
|
| 28 |
-import fr.ird.observe.client.datasource.editor.menu.DataSourceEditorMenu;
|
|
| 29 | 28 |
import fr.ird.observe.client.datasource.editor.wizard.StorageStep;
|
| 30 | 29 |
import fr.ird.observe.client.datasource.editor.wizard.StorageUI;
|
| 31 |
-import fr.ird.observe.client.datasource.editor.wizard.StorageUIHandler;
|
|
| 32 | 30 |
import fr.ird.observe.client.datasource.editor.wizard.StorageUILauncher;
|
| 33 | 31 |
import fr.ird.observe.client.datasource.editor.wizard.StorageUIModel;
|
| 34 | 32 |
import fr.ird.observe.client.main.ObserveMainUI;
|
| 35 | 33 |
import org.apache.logging.log4j.LogManager;
|
| 36 | 34 |
import org.apache.logging.log4j.Logger;
|
| 37 | 35 |
|
| 38 |
-import java.awt.event.ActionEvent;
|
|
| 39 | 36 |
import java.io.File;
|
| 40 | 37 |
|
| 41 | 38 |
import static io.ultreia.java4all.i18n.I18n.t;
|
| ... | ... | @@ -46,69 +43,55 @@ import static io.ultreia.java4all.i18n.I18n.t; |
| 46 | 43 |
* @author Tony Chemit - dev@tchemit.fr
|
| 47 | 44 |
* @since 3.13
|
| 48 | 45 |
*/
|
| 49 |
-public class ImportStorageFromFileAction extends DataSourceEditorMenuActionSupport {
|
|
| 46 |
+public class ImportStorageFromFileAction extends LoadStorageActionSupport {
|
|
| 50 | 47 |
|
| 51 | 48 |
private static final Logger log = LogManager.getLogger(ImportStorageFromFileAction.class);
|
| 49 |
+ |
|
| 52 | 50 |
public ImportStorageFromFileAction() {
|
| 53 | 51 |
super(t("observe.action.load.from.file"), t("observe.action.load.from.file.tip"), "local-import", 'I');
|
| 54 | 52 |
}
|
| 55 | 53 |
|
| 56 | 54 |
@Override
|
| 57 |
- protected void doActionPerformed(ActionEvent event, DataSourceEditorMenu ui) {
|
|
| 58 |
- |
|
| 59 |
- final ObserveMainUI mainUI = getClientUIContext().getMainUI();
|
|
| 60 |
- boolean canContinue = mainUI.canChangeBodyContent();
|
|
| 61 |
- if (canContinue) {
|
|
| 62 |
- |
|
| 63 |
- |
|
| 64 |
- if (getObserveDataSourcesManager().getOptionalMainDataSource().isPresent()) {
|
|
| 65 |
- log.info("Closing datasource...");
|
|
| 66 |
- getDataSourceEditorBodyContent().doCloseStorage();
|
|
| 67 |
- }
|
|
| 68 |
- |
|
| 69 |
- new StorageUILauncher(ui, mainUI, t("observe.title.import.localDB")) {
|
|
| 70 |
- @Override
|
|
| 71 |
- protected void init(StorageUI ui) {
|
|
| 72 |
- super.init(ui);
|
|
| 73 |
- StorageUIModel model = ui.getModel();
|
|
| 74 |
- |
|
| 75 |
- model.setDumpFile(getClientConfig().getImportDirectory());
|
|
| 76 |
- |
|
| 77 |
- model.setCanCreateLocalService(true);
|
|
| 78 |
- model.setCanUseLocalService(false);
|
|
| 79 |
- model.setCanUseRemoteService(false);
|
|
| 80 |
- model.setCanUseServerService(false);
|
|
| 81 |
- model.setDbMode(DbMode.CREATE_LOCAL);
|
|
| 82 |
- model.setCreationMode(CreationMode.IMPORT_EXTERNAL_DUMP);
|
|
| 83 |
- if (model.isLocalStorageExist()) {
|
|
| 84 |
- // sauvegarde base locale possible
|
|
| 85 |
- model.setSteps(StorageStep.CONFIG, StorageStep.BACKUP, StorageStep.CONFIRM);
|
|
| 86 |
- |
|
| 87 |
- // et requise par défaut
|
|
| 88 |
- model.setDoBackup(true);
|
|
| 89 |
- } else {
|
|
| 90 |
- model.setSteps(StorageStep.CONFIG, StorageStep.CONFIRM);
|
|
| 91 |
- }
|
|
| 92 |
- }
|
|
| 93 |
- |
|
| 94 |
- @Override
|
|
| 95 |
- public void doAction(StorageUI ui) {
|
|
| 96 |
- |
|
| 97 |
- log.info("Start importing new datasource from backup file...");
|
|
| 98 |
- |
|
| 99 |
- super.doAction(ui);
|
|
| 100 |
- StorageUIHandler handler = ui.getHandler();
|
|
| 101 |
- handler.doChangeStorage(ui.getModel());
|
|
| 102 |
- |
|
| 103 |
- File importDirectory = ui.getModel().getDumpFile().getParentFile();
|
|
| 104 |
- ClientConfig config = getClientConfig();
|
|
| 105 |
- config.setImportDirectory(importDirectory);
|
|
| 106 |
- config.saveForUser();
|
|
| 107 |
- }
|
|
| 55 |
+ protected String getTitle() {
|
|
| 56 |
+ return t("observe.title.import.localDB");
|
|
| 57 |
+ }
|
|
| 108 | 58 |
|
| 109 |
- }.start();
|
|
| 59 |
+ @Override
|
|
| 60 |
+ protected void init(StorageUI ui) {
|
|
| 61 |
+ StorageUIModel model = ui.getModel();
|
|
| 62 |
+ |
|
| 63 |
+ model.setDumpFile(getClientConfig().getImportDirectory());
|
|
| 64 |
+ |
|
| 65 |
+ model.setCanCreateLocalService(true);
|
|
| 66 |
+ model.setCanUseLocalService(false);
|
|
| 67 |
+ model.setCanUseRemoteService(false);
|
|
| 68 |
+ model.setCanUseServerService(false);
|
|
| 69 |
+ model.setDbMode(DbMode.CREATE_LOCAL);
|
|
| 70 |
+ model.setCreationMode(CreationMode.IMPORT_EXTERNAL_DUMP);
|
|
| 71 |
+ if (model.isLocalStorageExist()) {
|
|
| 72 |
+ // sauvegarde base locale possible
|
|
| 73 |
+ model.setSteps(StorageStep.CONFIG, StorageStep.BACKUP, StorageStep.CONFIRM);
|
|
| 74 |
+ |
|
| 75 |
+ // et requise par défaut
|
|
| 76 |
+ model.setDoBackup(true);
|
|
| 77 |
+ } else {
|
|
| 78 |
+ model.setSteps(StorageStep.CONFIG, StorageStep.CONFIRM);
|
|
| 110 | 79 |
}
|
| 80 |
+ }
|
|
| 111 | 81 |
|
| 82 |
+ @Override
|
|
| 83 |
+ protected StorageUILauncher startWizard(ObserveMainUI mainUI) {
|
|
| 84 |
+ if (getObserveDataSourcesManager().getOptionalMainDataSource().isPresent()) {
|
|
| 85 |
+ log.info("Closing datasource...");
|
|
| 86 |
+ getDataSourceEditorBodyContent().doCloseStorage();
|
|
| 87 |
+ }
|
|
| 88 |
+ return super.startWizard(mainUI);
|
|
| 112 | 89 |
}
|
| 113 | 90 |
|
| 91 |
+ @Override
|
|
| 92 |
+ protected void doChangeStorage(StorageUI ui) {
|
|
| 93 |
+ log.info("Start importing new datasource from backup file...");
|
|
| 94 |
+ |
|
| 95 |
+ super.doChangeStorage(ui);
|
|
| 96 |
+ }
|
|
| 114 | 97 |
}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.menu.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor API
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 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 fr.ird.observe.client.configuration.ClientConfig;
|
|
| 26 |
+import fr.ird.observe.client.constants.DbMode;
|
|
| 27 |
+import fr.ird.observe.client.datasource.api.ObserveDataSourcesManager;
|
|
| 28 |
+import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
|
| 29 |
+import fr.ird.observe.client.datasource.dcp.WithFloatingObjectPresetsManager;
|
|
| 30 |
+import fr.ird.observe.client.datasource.editor.DataSourceEditor;
|
|
| 31 |
+import fr.ird.observe.client.datasource.editor.DataSourceEditorBodyContent;
|
|
| 32 |
+import fr.ird.observe.client.datasource.editor.menu.DataSourceEditorMenu;
|
|
| 33 |
+import fr.ird.observe.client.datasource.editor.wizard.StorageUI;
|
|
| 34 |
+import fr.ird.observe.client.datasource.editor.wizard.StorageUILauncher;
|
|
| 35 |
+import fr.ird.observe.client.datasource.editor.wizard.StorageUIModel;
|
|
| 36 |
+import fr.ird.observe.client.main.ObserveMainUI;
|
|
| 37 |
+import fr.ird.observe.client.main.body.NoBodyContentComponent;
|
|
| 38 |
+import fr.ird.observe.client.util.ProgressModel;
|
|
| 39 |
+import fr.ird.observe.client.util.action.ActionState;
|
|
| 40 |
+import fr.ird.observe.dto.ObserveUtil;
|
|
| 41 |
+import fr.ird.observe.services.configuration.DataSourceCreateConfigurationDto;
|
|
| 42 |
+import fr.ird.observe.services.configuration.ObserveDataSourceInformation;
|
|
| 43 |
+import fr.ird.observe.services.configuration.topia.ObserveDataSourceConfigurationTopiaH2;
|
|
| 44 |
+import org.apache.logging.log4j.LogManager;
|
|
| 45 |
+import org.apache.logging.log4j.Logger;
|
|
| 46 |
+import org.nuiton.jaxx.runtime.JAXXContext;
|
|
| 47 |
+ |
|
| 48 |
+import java.awt.event.ActionEvent;
|
|
| 49 |
+import java.nio.file.Path;
|
|
| 50 |
+import java.util.Objects;
|
|
| 51 |
+ |
|
| 52 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 53 |
+ |
|
| 54 |
+/**
|
|
| 55 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 56 |
+ * @since 8.0
|
|
| 57 |
+ */
|
|
| 58 |
+public abstract class LoadStorageActionSupport extends DataSourceEditorMenuActionSupport implements Runnable, WithFloatingObjectPresetsManager {
|
|
| 59 |
+ |
|
| 60 |
+ private static final Logger log = LogManager.getLogger(LoadStorageActionSupport.class);
|
|
| 61 |
+ |
|
| 62 |
+ protected abstract String getTitle();
|
|
| 63 |
+ |
|
| 64 |
+ protected abstract void init(StorageUI ui);
|
|
| 65 |
+ |
|
| 66 |
+ public LoadStorageActionSupport(String label, String shortDescription, String actionIcon, char acceleratorKey) {
|
|
| 67 |
+ super(label, shortDescription, actionIcon, acceleratorKey);
|
|
| 68 |
+ }
|
|
| 69 |
+ |
|
| 70 |
+ @Override
|
|
| 71 |
+ protected void doActionPerformed(ActionEvent event, DataSourceEditorMenu ui) {
|
|
| 72 |
+ run();
|
|
| 73 |
+ }
|
|
| 74 |
+ |
|
| 75 |
+ @Override
|
|
| 76 |
+ public void run() {
|
|
| 77 |
+ |
|
| 78 |
+ ObserveMainUI mainUI = getClientUIContext().getMainUI();
|
|
| 79 |
+ boolean canContinue = mainUI.changeBodyContent(NoBodyContentComponent.class);
|
|
| 80 |
+ if (!canContinue) {
|
|
| 81 |
+ return;
|
|
| 82 |
+ }
|
|
| 83 |
+ startWizard(mainUI).start();
|
|
| 84 |
+ |
|
| 85 |
+ }
|
|
| 86 |
+ |
|
| 87 |
+ protected StorageUILauncher startWizard(ObserveMainUI mainUI) {
|
|
| 88 |
+ JAXXContext rootContext = ui == null ? mainUI : ui;
|
|
| 89 |
+ return new StorageUILauncher(rootContext, mainUI, getTitle()) {
|
|
| 90 |
+ |
|
| 91 |
+ @Override
|
|
| 92 |
+ protected void init(StorageUI ui) {
|
|
| 93 |
+ super.init(ui);
|
|
| 94 |
+ LoadStorageActionSupport.this.init(ui);
|
|
| 95 |
+ }
|
|
| 96 |
+ |
|
| 97 |
+ @Override
|
|
| 98 |
+ public void doAction(StorageUI ui) {
|
|
| 99 |
+ super.doAction(ui);
|
|
| 100 |
+ doChangeStorage(ui);
|
|
| 101 |
+ }
|
|
| 102 |
+ |
|
| 103 |
+ };
|
|
| 104 |
+ }
|
|
| 105 |
+ |
|
| 106 |
+ protected void doChangeStorage(StorageUI ui) {
|
|
| 107 |
+ |
|
| 108 |
+ StorageUIModel model = ui.getModel();
|
|
| 109 |
+ |
|
| 110 |
+ ProgressModel progressModel = model.getProgressModel();
|
|
| 111 |
+ progressModel.installUI(ui.getCONFIRM().getProgressBar());
|
|
| 112 |
+ |
|
| 113 |
+ LoadingDataSourceContext loadingContext = new LoadingDataSourceContext(model,
|
|
| 114 |
+ getClientConfig(),
|
|
| 115 |
+ getObserveDataSourcesManager().getMainDataSource(),
|
|
| 116 |
+ getFloatingObjectPresetsManager());
|
|
| 117 |
+ |
|
| 118 |
+ doOpenLocalDataSource(loadingContext);
|
|
| 119 |
+ |
|
| 120 |
+ doBackupLocalDataSource(loadingContext);
|
|
| 121 |
+ |
|
| 122 |
+ doDestroyLocalDataSource(loadingContext);
|
|
| 123 |
+ |
|
| 124 |
+ doCloseLocalDatasource(loadingContext);
|
|
| 125 |
+ |
|
| 126 |
+ doCloseCurrentDatasource(loadingContext);
|
|
| 127 |
+ |
|
| 128 |
+ doFeedBackOnLocalDataSourceClosingErrors(loadingContext);
|
|
| 129 |
+ |
|
| 130 |
+ try {
|
|
| 131 |
+ ObserveMainUI mainUI = getClientUIContext().getMainUI();
|
|
| 132 |
+ doOpenNewDataSource(mainUI, loadingContext);
|
|
| 133 |
+ mainUI.changeBodyContent(DataSourceEditor.class);
|
|
| 134 |
+ } catch (Exception e) {
|
|
| 135 |
+ doFeedBackOnLocalDataSourceOnLoadingErrors(loadingContext);
|
|
| 136 |
+ } finally {
|
|
| 137 |
+ ObserveUtil.cleanMemory();
|
|
| 138 |
+ }
|
|
| 139 |
+ |
|
| 140 |
+ }
|
|
| 141 |
+ |
|
| 142 |
+ protected void doOpenLocalDataSource(LoadingDataSourceContext loadingContext) {
|
|
| 143 |
+ |
|
| 144 |
+ ObserveSwingDataSource currentDataSource = loadingContext.getCurrentDataSource();
|
|
| 145 |
+ boolean doBackup = loadingContext.getBackupState().notSkip();
|
|
| 146 |
+ boolean destroyLocalBase = loadingContext.getDestroyLocalDatabaseState().notSkip();
|
|
| 147 |
+ |
|
| 148 |
+ ObserveSwingDataSource localDataSource = null == currentDataSource || !currentDataSource.isLocal() ? null : currentDataSource;
|
|
| 149 |
+ if (destroyLocalBase || doBackup) {
|
|
| 150 |
+ if (localDataSource == null) {
|
|
| 151 |
+ |
|
| 152 |
+ ObserveDataSourcesManager dataSourcesManager = getObserveDataSourcesManager();
|
|
| 153 |
+ |
|
| 154 |
+ ObserveDataSourceConfigurationTopiaH2 localConfiguration = dataSourcesManager.newH2DataSourceConfiguration(t("observe.runner.initStorage.label.local"));
|
|
| 155 |
+ |
|
| 156 |
+ // can't migrate datasource in this case
|
|
| 157 |
+ localConfiguration.setCanMigrate(false);
|
|
| 158 |
+ |
|
| 159 |
+ //do open local datasource
|
|
| 160 |
+ localDataSource = dataSourcesManager.newDataSource(localConfiguration);
|
|
| 161 |
+ }
|
|
| 162 |
+ |
|
| 163 |
+ Objects.requireNonNull(localDataSource);
|
|
| 164 |
+ |
|
| 165 |
+ // Let's check if the datasource is opened or not :
|
|
| 166 |
+ // we could have close the datasource through the ui
|
|
| 167 |
+ // If the datasource is closed, we try to open it
|
|
| 168 |
+ if (!localDataSource.isOpen()) {
|
|
| 169 |
+ try {
|
|
| 170 |
+ |
|
| 171 |
+ localDataSource.open();
|
|
| 172 |
+ |
|
| 173 |
+ } catch (Exception e) {
|
|
| 174 |
+ log.error(t("observe.error.storage.could.not.load.local.db", e.getMessage()), e);
|
|
| 175 |
+ |
|
| 176 |
+ // set no local data source, will then trigger some closing feedback
|
|
| 177 |
+ localDataSource = null;
|
|
| 178 |
+ }
|
|
| 179 |
+ }
|
|
| 180 |
+ }
|
|
| 181 |
+ loadingContext.incrementsProgress();
|
|
| 182 |
+ loadingContext.setLocalDataSource(localDataSource);
|
|
| 183 |
+ }
|
|
| 184 |
+ |
|
| 185 |
+ private void doBackupLocalDataSource(LoadingDataSourceContext loadingContext) {
|
|
| 186 |
+ ActionState result = loadingContext.getBackupPendingState();
|
|
| 187 |
+ if (result.pending()) {
|
|
| 188 |
+ ObserveSwingDataSource localDataSource = loadingContext.getLocalDataSource();
|
|
| 189 |
+ if (localDataSource == null) {
|
|
| 190 |
+ // local database is not sane, can't do backup
|
|
| 191 |
+ log.error(t("observe.error.storage.could.not.backup.unsane.local.db"));
|
|
| 192 |
+ result = ActionState.FAILED;
|
|
| 193 |
+ } else {
|
|
| 194 |
+ StorageUIModel model = loadingContext.getModel();
|
|
| 195 |
+ Path f = model.getBackupFile().toPath();
|
|
| 196 |
+ log.info(String.format("Do backup with %s in %s", localDataSource, f));
|
|
| 197 |
+ try {
|
|
| 198 |
+ localDataSource.backupLocalDatabase(f);
|
|
| 199 |
+ result = ActionState.DONE;
|
|
| 200 |
+ } catch (Exception e) {
|
|
| 201 |
+ result = ActionState.FAILED;
|
|
| 202 |
+ log.error("Could not backup local datasource", e);
|
|
| 203 |
+ }
|
|
| 204 |
+ }
|
|
| 205 |
+ }
|
|
| 206 |
+ loadingContext.incrementsProgress();
|
|
| 207 |
+ loadingContext.setBackupState(result);
|
|
| 208 |
+ }
|
|
| 209 |
+ |
|
| 210 |
+ private void doDestroyLocalDataSource(LoadingDataSourceContext loadingContext) {
|
|
| 211 |
+ ActionState result = loadingContext.getDestroyLocalDatabasePendingState();
|
|
| 212 |
+ if (result.pending()) {
|
|
| 213 |
+ ObserveSwingDataSource localDataSource = loadingContext.getLocalDataSource();
|
|
| 214 |
+ if (localDataSource == null) {
|
|
| 215 |
+ // could not load local data source, mark this step as failed
|
|
| 216 |
+ result = ActionState.FAILED;
|
|
| 217 |
+ } else {
|
|
| 218 |
+ log.info(String.format("Destroy local data source %s", localDataSource));
|
|
| 219 |
+ try {
|
|
| 220 |
+ localDataSource.destroy();
|
|
| 221 |
+ result = ActionState.DONE;
|
|
| 222 |
+ } catch (Exception e) {
|
|
| 223 |
+ log.error("Could not destroy local data source", e);
|
|
| 224 |
+ result = ActionState.FAILED;
|
|
| 225 |
+ }
|
|
| 226 |
+ }
|
|
| 227 |
+ }
|
|
| 228 |
+ loadingContext.incrementsProgress();
|
|
| 229 |
+ loadingContext.setDestroyLocalDatabaseState(result);
|
|
| 230 |
+ }
|
|
| 231 |
+ |
|
| 232 |
+ private void doCloseLocalDatasource(LoadingDataSourceContext loadingContext) {
|
|
| 233 |
+ loadingContext.setCloseLocalDatabaseState(doCloseDatasource(loadingContext, loadingContext.getCloseLocalDatabasePendingState(), loadingContext.getLocalDataSource()));
|
|
| 234 |
+ }
|
|
| 235 |
+ |
|
| 236 |
+ private void doCloseCurrentDatasource(LoadingDataSourceContext loadingContext) {
|
|
| 237 |
+ loadingContext.setCloseCurrentDatabaseState(doCloseDatasource(loadingContext, loadingContext.getCloseCurrentDatabasePendingState(), loadingContext.getCurrentDataSource()));
|
|
| 238 |
+ }
|
|
| 239 |
+ |
|
| 240 |
+ private void doOpenNewDataSource(ObserveMainUI mainUI, LoadingDataSourceContext loadingContext) {
|
|
| 241 |
+ if (loadingContext.getOpenDataSourcePendingState().skip()) {
|
|
| 242 |
+ loadingContext.setOpenDataSourceState(ActionState.FAILED);
|
|
| 243 |
+ }
|
|
| 244 |
+ StorageUIModel model = loadingContext.getModel();
|
|
| 245 |
+ ClientConfig config = loadingContext.getConfig();
|
|
| 246 |
+ ObserveDataSourcesManager dataSourcesManager = getObserveDataSourcesManager();
|
|
| 247 |
+ |
|
| 248 |
+ ObserveSwingDataSource newDataSource = model.initDataSourceFromModel(config, dataSourcesManager);
|
|
| 249 |
+ newDataSource.setProgressModel(loadingContext.getProgressModel());
|
|
| 250 |
+ |
|
| 251 |
+ boolean useLocalDataSource = model.getDbMode() == DbMode.USE_LOCAL;
|
|
| 252 |
+ |
|
| 253 |
+ if (useLocalDataSource) {
|
|
| 254 |
+ // try an explicit data source migration
|
|
| 255 |
+ |
|
| 256 |
+ ObserveDataSourceInformation dataSourceInformation;
|
|
| 257 |
+ try {
|
|
| 258 |
+ dataSourceInformation = newDataSource.checkCanConnect(false);
|
|
| 259 |
+ newDataSource.setOwner(dataSourceInformation.isOwner());
|
|
| 260 |
+ newDataSource.setSuperUser(dataSourceInformation.isSuperUser());
|
|
| 261 |
+ } catch (Exception e) {
|
|
| 262 |
+ log.error(String.format("could not get local data source information: %s", newDataSource), e);
|
|
| 263 |
+ loadingContext.setOpenDataSourceState(ActionState.FAILED);
|
|
| 264 |
+ return;
|
|
| 265 |
+ } finally {
|
|
| 266 |
+ loadingContext.incrementsProgress();
|
|
| 267 |
+ }
|
|
| 268 |
+ |
|
| 269 |
+ try {
|
|
| 270 |
+ newDataSource.migrateData(dataSourceInformation, config.getModelVersion());
|
|
| 271 |
+ } catch (Exception e) {
|
|
| 272 |
+ log.error(String.format("could not migrate local data source: %s", newDataSource), e);
|
|
| 273 |
+ loadingContext.setOpenDataSourceState(ActionState.FAILED);
|
|
| 274 |
+ return;
|
|
| 275 |
+ } finally {
|
|
| 276 |
+ loadingContext.incrementsProgress();
|
|
| 277 |
+ }
|
|
| 278 |
+ }
|
|
| 279 |
+ mainUI.getMainUIBodyContentManager().getBodyTyped(DataSourceEditor.class, DataSourceEditorBodyContent.class).prepareMainStorage(newDataSource, true);
|
|
| 280 |
+ |
|
| 281 |
+ boolean createLocalDataSource = model.getDbMode() == DbMode.CREATE_LOCAL;
|
|
| 282 |
+ |
|
| 283 |
+ try {
|
|
| 284 |
+ if (createLocalDataSource) {
|
|
| 285 |
+ // do create local data source
|
|
| 286 |
+ DataSourceCreateConfigurationDto creationConfigurationDto = model.getCreationConfigurationDto();
|
|
| 287 |
+ newDataSource.create(creationConfigurationDto);
|
|
| 288 |
+ } else {
|
|
| 289 |
+ // open data source
|
|
| 290 |
+ newDataSource.open();
|
|
| 291 |
+ }
|
|
| 292 |
+ log.info(String.format("Main storage opened %s", newDataSource.getLabel()));
|
|
| 293 |
+ } catch (Exception e) {
|
|
| 294 |
+ log.error(String.format("could not open data source: %s", newDataSource), e);
|
|
| 295 |
+ dataSourcesManager.setMainDataSource(null);
|
|
| 296 |
+ loadingContext.setOpenDataSourceState(ActionState.FAILED);
|
|
| 297 |
+ } finally {
|
|
| 298 |
+ loadingContext.incrementsProgress();
|
|
| 299 |
+ }
|
|
| 300 |
+ |
|
| 301 |
+ loadingContext.setOpenDataSourceState(ActionState.DONE);
|
|
| 302 |
+ }
|
|
| 303 |
+ |
|
| 304 |
+ private ActionState doCloseDatasource(LoadingDataSourceContext loadingContext, ActionState dataSourceState, ObserveSwingDataSource dataSource) {
|
|
| 305 |
+ if (dataSourceState.notSkip()) {
|
|
| 306 |
+ if (dataSource == null || !dataSource.isOpen()) {
|
|
| 307 |
+ dataSourceState = ActionState.DONE;
|
|
| 308 |
+ } else {
|
|
| 309 |
+ log.info(String.format("close data source: %s", dataSource));
|
|
| 310 |
+ try {
|
|
| 311 |
+ dataSource.close();
|
|
| 312 |
+ dataSourceState = ActionState.DONE;
|
|
| 313 |
+ } catch (Exception e) {
|
|
| 314 |
+ log.error("Could not close local data source", e);
|
|
| 315 |
+ dataSourceState = ActionState.FAILED;
|
|
| 316 |
+ }
|
|
| 317 |
+ }
|
|
| 318 |
+ }
|
|
| 319 |
+ loadingContext.incrementsProgress();
|
|
| 320 |
+ return dataSourceState;
|
|
| 321 |
+ }
|
|
| 322 |
+ |
|
| 323 |
+ private void doFeedBackOnLocalDataSourceClosingErrors(LoadingDataSourceContext loadingContext) {
|
|
| 324 |
+ ActionState result = loadingContext.getFeedBackOnClosingLocalDatasourcePendingState();
|
|
| 325 |
+ |
|
| 326 |
+ if (result.notSkip()) {
|
|
| 327 |
+ |
|
| 328 |
+ //TODO
|
|
| 329 |
+ log.info("Do feed back after errors on closing local data source.");
|
|
| 330 |
+ |
|
| 331 |
+ try {
|
|
| 332 |
+ |
|
| 333 |
+ FeedBackBuilder.onClosingLocalDataSource(loadingContext);
|
|
| 334 |
+ result = ActionState.DONE;
|
|
| 335 |
+ } catch (Exception e) {
|
|
| 336 |
+ log.error("Could not feed back", e);
|
|
| 337 |
+ result = ActionState.FAILED;
|
|
| 338 |
+ }
|
|
| 339 |
+ loadingContext.setFeedBackOnClosingLocalDatasourceState(result);
|
|
| 340 |
+ }
|
|
| 341 |
+ |
|
| 342 |
+ loadingContext.incrementsProgress();
|
|
| 343 |
+ }
|
|
| 344 |
+ |
|
| 345 |
+ protected void doFeedBackOnLocalDataSourceOnLoadingErrors(LoadingDataSourceContext loadingContext) {
|
|
| 346 |
+ |
|
| 347 |
+ ActionState result = loadingContext.getFeedBackOnLoadingLocalDatasourcePendingState();
|
|
| 348 |
+ if (result.notSkip()) {
|
|
| 349 |
+ |
|
| 350 |
+ //TODO
|
|
| 351 |
+ log.info("Do feed back after errors on opening local data source.");
|
|
| 352 |
+ |
|
| 353 |
+ loadingContext.getConfig().setLocalStorageExist(false);
|
|
| 354 |
+ loadingContext.getConfig().saveForUser();
|
|
| 355 |
+ try {
|
|
| 356 |
+ |
|
| 357 |
+ result = ActionState.DONE;
|
|
| 358 |
+ } catch (Exception e) {
|
|
| 359 |
+ log.error("Could not feed back", e);
|
|
| 360 |
+ result = ActionState.FAILED;
|
|
| 361 |
+ }
|
|
| 362 |
+ loadingContext.setFeedBackOnLoadingLocalDatasourceState(result);
|
|
| 363 |
+ }
|
|
| 364 |
+ |
|
| 365 |
+ |
|
| 366 |
+ loadingContext.incrementsProgress();
|
|
| 367 |
+ }
|
|
| 368 |
+ |
|
| 369 |
+}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.menu.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor API
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 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 fr.ird.observe.client.configuration.ClientConfig;
|
|
| 26 |
+import fr.ird.observe.client.constants.DbMode;
|
|
| 27 |
+import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
|
| 28 |
+import fr.ird.observe.client.datasource.dcp.FloatingObjectPresetsManager;
|
|
| 29 |
+import fr.ird.observe.client.datasource.editor.wizard.StorageUIModel;
|
|
| 30 |
+import fr.ird.observe.client.util.ProgressModel;
|
|
| 31 |
+import fr.ird.observe.client.util.action.ActionState;
|
|
| 32 |
+import org.apache.logging.log4j.LogManager;
|
|
| 33 |
+import org.apache.logging.log4j.Logger;
|
|
| 34 |
+ |
|
| 35 |
+/**
|
|
| 36 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 37 |
+ * @since 8.0.0
|
|
| 38 |
+ */
|
|
| 39 |
+public class LoadingDataSourceContext {
|
|
| 40 |
+ |
|
| 41 |
+ private static final Logger log = LogManager.getLogger(LoadingDataSourceContext.class);
|
|
| 42 |
+ |
|
| 43 |
+ private final StorageUIModel model;
|
|
| 44 |
+ private final ClientConfig config;
|
|
| 45 |
+ private final ObserveSwingDataSource currentDataSource;
|
|
| 46 |
+ private final ProgressModel progressModel;
|
|
| 47 |
+ private ObserveSwingDataSource localDataSource;
|
|
| 48 |
+ private ActionState backupState;
|
|
| 49 |
+ private ActionState destroyLocalDatabaseState;
|
|
| 50 |
+ private ActionState closeLocalDatabaseState;
|
|
| 51 |
+ private ActionState closeCurrentDatabaseState;
|
|
| 52 |
+ private ActionState feedBackOnClosingLocalDatasourceState;
|
|
| 53 |
+ private ActionState openDataSourceState;
|
|
| 54 |
+ private ActionState feedBackOnLoadingLocalDatasourceState;
|
|
| 55 |
+ |
|
| 56 |
+ LoadingDataSourceContext(StorageUIModel model, ClientConfig config, ObserveSwingDataSource currentDataSource, FloatingObjectPresetsManager floatingObjectPresetsManager) {
|
|
| 57 |
+ this.model = model;
|
|
| 58 |
+ this.config = config;
|
|
| 59 |
+ this.currentDataSource = currentDataSource;
|
|
| 60 |
+ boolean localStorageExist = config.isLocalStorageExist();
|
|
| 61 |
+ boolean currentDataSourceIsLocal = currentDataSource != null && currentDataSource.isLocal();
|
|
| 62 |
+ this.backupState = model.isDoBackup() ? ActionState.PENDING : ActionState.SKIP;
|
|
| 63 |
+ this.destroyLocalDatabaseState = localStorageExist && DbMode.CREATE_LOCAL == model.getDbMode() ? ActionState.PENDING : ActionState.SKIP;
|
|
| 64 |
+ |
|
| 65 |
+ log.info(String.format(" Will backup local db ? %s", backupState.notSkip()));
|
|
| 66 |
+ log.info(String.format(" Will destroy local db ? %s", destroyLocalDatabaseState.notSkip()));
|
|
| 67 |
+ |
|
| 68 |
+ this.progressModel = model.getProgressModel();
|
|
| 69 |
+ int stepsCount = computeStepCount(floatingObjectPresetsManager);
|
|
| 70 |
+ |
|
| 71 |
+ log.info(String.format("Found %d steps to load new data source.", stepsCount));
|
|
| 72 |
+ |
|
| 73 |
+ this.progressModel.setValue(0);
|
|
| 74 |
+ this.progressModel.setMaximum(stepsCount);
|
|
| 75 |
+ |
|
| 76 |
+ this.closeLocalDatabaseState = backupState.notSkip() || destroyLocalDatabaseState.notSkip() || currentDataSourceIsLocal ? ActionState.PENDING : ActionState.SKIP;
|
|
| 77 |
+ this.closeCurrentDatabaseState = currentDataSourceIsLocal ? ActionState.SKIP : ActionState.PENDING;
|
|
| 78 |
+ this.feedBackOnClosingLocalDatasourceState = ActionState.SKIP;
|
|
| 79 |
+ this.feedBackOnLoadingLocalDatasourceState = ActionState.SKIP;
|
|
| 80 |
+ this.openDataSourceState = ActionState.PENDING;
|
|
| 81 |
+ }
|
|
| 82 |
+ |
|
| 83 |
+ public ActionState getBackupPendingState() {
|
|
| 84 |
+ return backupState;
|
|
| 85 |
+ }
|
|
| 86 |
+ |
|
| 87 |
+ public ActionState getDestroyLocalDatabasePendingState() {
|
|
| 88 |
+ return ActionState.failIfPreviousFail(getDestroyLocalDatabaseState(), getBackupState());
|
|
| 89 |
+ }
|
|
| 90 |
+ |
|
| 91 |
+ public ActionState getCloseLocalDatabasePendingState() {
|
|
| 92 |
+ return ActionState.failIfPreviousFail(getCloseLocalDatabaseState(), getBackupState(), getDestroyLocalDatabaseState());
|
|
| 93 |
+ }
|
|
| 94 |
+ |
|
| 95 |
+ public ActionState getCloseCurrentDatabasePendingState() {
|
|
| 96 |
+ return getCloseCurrentDatabaseState();
|
|
| 97 |
+ }
|
|
| 98 |
+ |
|
| 99 |
+ public ActionState getFeedBackOnClosingLocalDatasourcePendingState() {
|
|
| 100 |
+ return ActionState.pendingIfPreviousFail(getFeedBackOnClosingLocalDatasourceState(), getBackupState(), getDestroyLocalDatabaseState(), getCloseCurrentDatabaseState());
|
|
| 101 |
+ }
|
|
| 102 |
+ |
|
| 103 |
+ public ActionState getFeedBackOnLoadingLocalDatasourcePendingState() {
|
|
| 104 |
+ return ActionState.pendingIfPreviousFail(getOpenDataSourceState());
|
|
| 105 |
+ }
|
|
| 106 |
+ |
|
| 107 |
+ public void incrementsProgress() {
|
|
| 108 |
+ progressModel.setValue(progressModel.getValue() + 1);
|
|
| 109 |
+ }
|
|
| 110 |
+ |
|
| 111 |
+ public StorageUIModel getModel() {
|
|
| 112 |
+ return model;
|
|
| 113 |
+ }
|
|
| 114 |
+ |
|
| 115 |
+ public ClientConfig getConfig() {
|
|
| 116 |
+ return config;
|
|
| 117 |
+ }
|
|
| 118 |
+ |
|
| 119 |
+ public ObserveSwingDataSource getCurrentDataSource() {
|
|
| 120 |
+ return currentDataSource;
|
|
| 121 |
+ }
|
|
| 122 |
+ |
|
| 123 |
+ public ActionState getBackupState() {
|
|
| 124 |
+ return backupState;
|
|
| 125 |
+ }
|
|
| 126 |
+ |
|
| 127 |
+ public ActionState getDestroyLocalDatabaseState() {
|
|
| 128 |
+ return destroyLocalDatabaseState;
|
|
| 129 |
+ }
|
|
| 130 |
+ |
|
| 131 |
+ public ProgressModel getProgressModel() {
|
|
| 132 |
+ return progressModel;
|
|
| 133 |
+ }
|
|
| 134 |
+ |
|
| 135 |
+ public ActionState getCloseLocalDatabaseState() {
|
|
| 136 |
+ return closeLocalDatabaseState;
|
|
| 137 |
+ }
|
|
| 138 |
+ |
|
| 139 |
+ public ActionState getCloseCurrentDatabaseState() {
|
|
| 140 |
+ return closeCurrentDatabaseState;
|
|
| 141 |
+ }
|
|
| 142 |
+ |
|
| 143 |
+ public ActionState getOpenDataSourceState() {
|
|
| 144 |
+ return openDataSourceState;
|
|
| 145 |
+ }
|
|
| 146 |
+ |
|
| 147 |
+ public ActionState getOpenDataSourcePendingState() {
|
|
| 148 |
+ return openDataSourceState;
|
|
| 149 |
+ }
|
|
| 150 |
+ |
|
| 151 |
+ public void setOpenDataSourceState(ActionState openDataSourceState) {
|
|
| 152 |
+ this.openDataSourceState = openDataSourceState;
|
|
| 153 |
+ }
|
|
| 154 |
+ |
|
| 155 |
+ public ObserveSwingDataSource getLocalDataSource() {
|
|
| 156 |
+ return localDataSource;
|
|
| 157 |
+ }
|
|
| 158 |
+ |
|
| 159 |
+ public void setLocalDataSource(ObserveSwingDataSource localDataSource) {
|
|
| 160 |
+ this.localDataSource = localDataSource;
|
|
| 161 |
+ }
|
|
| 162 |
+ |
|
| 163 |
+ public ActionState getFeedBackOnClosingLocalDatasourceState() {
|
|
| 164 |
+ return feedBackOnClosingLocalDatasourceState;
|
|
| 165 |
+ }
|
|
| 166 |
+ |
|
| 167 |
+ public ActionState getFeedBackOnLoadingLocalDatasourceState() {
|
|
| 168 |
+ return feedBackOnLoadingLocalDatasourceState;
|
|
| 169 |
+ }
|
|
| 170 |
+ |
|
| 171 |
+ public void setBackupState(ActionState backupState) {
|
|
| 172 |
+ this.backupState = backupState;
|
|
| 173 |
+ }
|
|
| 174 |
+ |
|
| 175 |
+ public void setCloseLocalDatabaseState(ActionState closeLocalDatabaseState) {
|
|
| 176 |
+ this.closeLocalDatabaseState = closeLocalDatabaseState;
|
|
| 177 |
+ }
|
|
| 178 |
+ |
|
| 179 |
+ public void setCloseCurrentDatabaseState(ActionState closeCurrentDatabaseState) {
|
|
| 180 |
+ this.closeCurrentDatabaseState = closeCurrentDatabaseState;
|
|
| 181 |
+ }
|
|
| 182 |
+ |
|
| 183 |
+ public void setFeedBackOnClosingLocalDatasourceState(ActionState feedBackOnClosingLocalDatasourceState) {
|
|
| 184 |
+ this.feedBackOnClosingLocalDatasourceState = feedBackOnClosingLocalDatasourceState;
|
|
| 185 |
+ }
|
|
| 186 |
+ |
|
| 187 |
+ public void setFeedBackOnLoadingLocalDatasourceState(ActionState feedBackOnLoadingLocalDatasourceState) {
|
|
| 188 |
+ this.feedBackOnLoadingLocalDatasourceState = feedBackOnLoadingLocalDatasourceState;
|
|
| 189 |
+ }
|
|
| 190 |
+ |
|
| 191 |
+ public void setDestroyLocalDatabaseState(ActionState destroyLocalDatabaseState) {
|
|
| 192 |
+ this.destroyLocalDatabaseState = destroyLocalDatabaseState;
|
|
| 193 |
+ }
|
|
| 194 |
+ |
|
| 195 |
+ private int computeStepCount(FloatingObjectPresetsManager floatingObjectPresetsManager) {
|
|
| 196 |
+ DbMode dbMode = model.getDbMode();
|
|
| 197 |
+ int stepsCount = 0;
|
|
| 198 |
+ |
|
| 199 |
+ // open local
|
|
| 200 |
+ stepsCount++;
|
|
| 201 |
+ |
|
| 202 |
+ // backup local
|
|
| 203 |
+ stepsCount++;
|
|
| 204 |
+ |
|
| 205 |
+ // destroy local
|
|
| 206 |
+ stepsCount++;
|
|
| 207 |
+ |
|
| 208 |
+ // close local
|
|
| 209 |
+ stepsCount++;
|
|
| 210 |
+ |
|
| 211 |
+ // close current
|
|
| 212 |
+ stepsCount++;
|
|
| 213 |
+ |
|
| 214 |
+ // feed back on closing
|
|
| 215 |
+ stepsCount++;
|
|
| 216 |
+ |
|
| 217 |
+ // open new data source
|
|
| 218 |
+ stepsCount++;
|
|
| 219 |
+ |
|
| 220 |
+ if (DbMode.USE_LOCAL.equals(dbMode)) {
|
|
| 221 |
+ // use local data source (requires migrate)
|
|
| 222 |
+ stepsCount += 2;
|
|
| 223 |
+ }
|
|
| 224 |
+ |
|
| 225 |
+ // feed back on loading
|
|
| 226 |
+ stepsCount++;
|
|
| 227 |
+ |
|
| 228 |
+ int openIds = config.getNavigationEditModelCount();
|
|
| 229 |
+ if (openIds > 0) {
|
|
| 230 |
+ stepsCount += 1 + openIds;
|
|
| 231 |
+ }
|
|
| 232 |
+ int selectedIds = config.getNavigationSelectModelCount();
|
|
| 233 |
+ if (selectedIds > 0) {
|
|
| 234 |
+ stepsCount += 1 + selectedIds;
|
|
| 235 |
+ }
|
|
| 236 |
+ stepsCount += floatingObjectPresetsManager.size();
|
|
| 237 |
+ return stepsCount;
|
|
| 238 |
+ }
|
|
| 239 |
+ |
|
| 240 |
+}
|
| ... | ... | @@ -299,305 +299,11 @@ public class StorageUIHandler implements UIHandler<StorageUI>, WithDecoratorServ |
| 299 | 299 |
}
|
| 300 | 300 |
}
|
| 301 | 301 |
|
| 302 |
- /**
|
|
| 303 |
- * Utiliser le storage defini dans le modèle donné.
|
|
| 304 |
- *
|
|
| 305 |
- * @param model le model du storage a creer ou utiliser
|
|
| 306 |
- */
|
|
| 307 |
- public void doChangeStorage(StorageUIModel model) {
|
|
| 308 |
- |
|
| 309 |
- ClientConfig config = getClientConfig();
|
|
| 310 |
- |
|
| 311 |
- // faut-il detruire la base locale ?
|
|
| 312 |
- boolean destroyLocalBase = config.isLocalStorageExist() && model.getDbMode() == DbMode.CREATE_LOCAL;
|
|
| 313 |
- |
|
| 314 |
- log.debug(">>> should destroy local db ? " + destroyLocalBase);
|
|
| 315 |
- |
|
| 316 |
- ObserveDataSourcesManager dataSourcesManager = getObserveDataSourcesManager();
|
|
| 317 |
- ObserveSwingDataSource currentDataSource = dataSourcesManager.getMainDataSource();
|
|
| 318 |
- |
|
| 319 |
- ObserveSwingDataSource localDataSource = null;
|
|
| 320 |
- |
|
| 321 |
- if (currentDataSource != null && currentDataSource.isLocal()) {
|
|
| 322 |
- localDataSource = currentDataSource;
|
|
| 323 |
- }
|
|
| 324 |
- |
|
| 325 |
- ProgressModel progressModel = model.getProgressModel();
|
|
| 326 |
- |
|
| 327 |
- int stepsCount = 8;
|
|
| 328 |
- |
|
| 329 |
- if (destroyLocalBase || model.isDoBackup()) {
|
|
| 330 |
- stepsCount++;
|
|
| 331 |
- }
|
|
| 332 |
- if (destroyLocalBase) {
|
|
| 333 |
- stepsCount++;
|
|
| 334 |
- }
|
|
| 335 |
- if (model.isDoBackup()) {
|
|
| 336 |
- stepsCount++;
|
|
| 337 |
- }
|
|
| 338 |
- if (currentDataSource != null && currentDataSource.isOpen()) {
|
|
| 339 |
- stepsCount++;
|
|
| 340 |
- }
|
|
| 341 |
- if (DbMode.USE_LOCAL.equals((model.getDbMode()))) {
|
|
| 342 |
- stepsCount += 2;
|
|
| 343 |
- }
|
|
| 344 |
- int openIds = config.getNavigationEditModelCount();
|
|
| 345 |
- if (openIds > 0) {
|
|
| 346 |
- stepsCount += 1 + openIds;
|
|
| 347 |
- }
|
|
| 348 |
- int selectedIds = config.getNavigationSelectModelCount();
|
|
| 349 |
- if (selectedIds > 0) {
|
|
| 350 |
- stepsCount += 1 + selectedIds;
|
|
| 351 |
- }
|
|
| 352 |
- stepsCount += getFloatingObjectPresetsManager().size();
|
|
| 353 |
- |
|
| 354 |
- progressModel.installUI(ui.getCONFIRM().getProgressBar());
|
|
| 355 |
- progressModel.setMaximum(stepsCount);
|
|
| 356 |
- log.info(String.format("Found %d steps to load new data source.", stepsCount));
|
|
| 357 |
- |
|
| 358 |
- boolean localDbIsSane = true;
|
|
| 359 |
- if (destroyLocalBase || model.isDoBackup()) {
|
|
| 360 |
- if (localDataSource == null) {
|
|
| 361 |
- |
|
| 362 |
- ObserveDataSourceConfigurationTopiaH2 localConfiguration = dataSourcesManager.newH2DataSourceConfiguration(t("observe.runner.initStorage.label.local"));
|
|
| 363 |
- |
|
| 364 |
- // la base ne doit pas etre mise a jour dans ce cas
|
|
| 365 |
- localConfiguration.setCanMigrate(false);
|
|
| 366 |
- |
|
| 367 |
- // on charge un storage sur la base locale
|
|
| 368 |
- localDataSource = dataSourcesManager.newDataSource(localConfiguration);
|
|
| 369 |
- }
|
|
| 370 |
- |
|
| 371 |
- Objects.requireNonNull(localDataSource);
|
|
| 372 |
- |
|
| 373 |
- // Let's check if the datasource is opened or not :
|
|
| 374 |
- // we could have close the datasource through the ui
|
|
| 375 |
- // If the datasource is closed, we try to open it
|
|
| 376 |
- if (!localDataSource.isOpen()) {
|
|
| 377 |
- try {
|
|
| 378 |
- |
|
| 379 |
- localDataSource.open();
|
|
| 380 |
- |
|
| 381 |
- } catch (Exception e) {
|
|
| 382 |
- // on a pas reussi à ouvrir la base locale
|
|
| 383 |
- // cela ne doit pas empécher de continuer
|
|
| 384 |
- // il faut juste supprimer physiquement le repertoire
|
|
| 385 |
- // de la base
|
|
| 386 |
- log.error(t("observe.error.storage.could.not.load.local.db", e.getMessage()), e);
|
|
| 387 |
- |
|
| 388 |
- // on conserve l'état
|
|
| 389 |
- localDbIsSane = false;
|
|
| 390 |
- |
|
| 391 |
- // pour la suite on fait comme si il n'y a pas de local storage
|
|
| 392 |
- localDataSource = null;
|
|
| 393 |
- }
|
|
| 394 |
- }
|
|
| 395 |
- |
|
| 396 |
- progressModel.setExtent(1);
|
|
| 397 |
- }
|
|
| 398 |
- |
|
| 399 |
- if (model.isDoBackup()) {
|
|
| 400 |
- if (!localDbIsSane) {
|
|
| 401 |
- |
|
| 402 |
- // la base locale n'est pas saine, on doit arrêter l'operation
|
|
| 403 |
- // de changement de base sous peine de perdre la base.
|
|
| 404 |
- Exception e = new Exception(t("observe.error.storage.could.not.backup.unsane.local.db"));
|
|
| 405 |
- UIHelper.handlingError(e);
|
|
| 406 |
- return;
|
|
| 407 |
- }
|
|
| 408 |
- |
|
| 409 |
- Objects.requireNonNull(localDataSource);
|
|
| 410 |
- |
|
| 411 |
- // effectue la backup de la base locale existante
|
|
| 412 |
- File f = model.getBackupFile();
|
|
| 413 |
- log.debug(">>> do backup with " + localDataSource + " in " + f);
|
|
| 414 |
- try {
|
|
| 415 |
- SqlScriptProducerService dumpProducerService = localDataSource.getSqlScriptProducerService();
|
|
| 416 |
- backupLocalDatabase(dumpProducerService, f);
|
|
| 417 |
- } catch (Exception e) {
|
|
| 418 |
- UIHelper.handlingError(e);
|
|
| 419 |
- return;
|
|
| 420 |
- }
|
|
| 421 |
- |
|
| 422 |
- progressModel.setExtent(1);
|
|
| 423 |
- }
|
|
| 424 |
- |
|
| 425 |
- if (destroyLocalBase) {
|
|
| 426 |
- log.debug(">>> destroy local db " + localDataSource);
|
|
| 427 |
- if (!localDbIsSane) {
|
|
| 428 |
- // la base locale n'est pas saine, on va supprimer directement
|
|
| 429 |
- // le dossier de la base
|
|
| 430 |
- File localDBDirectory = config.getLocalDBDirectory();
|
|
| 431 |
- log.info(">>> destroy local db directory " + localDBDirectory);
|
|
| 432 |
- try {
|
|
| 433 |
- FileUtils.deleteDirectory(localDBDirectory);
|
|
| 434 |
- } catch (IOException e) {
|
|
| 435 |
- UIHelper.handlingError(e);
|
|
| 436 |
- }
|
|
| 437 |
- } else {
|
|
| 438 |
- try {
|
|
| 439 |
- localDataSource.destroy();
|
|
| 440 |
- } catch (Exception e) {
|
|
| 441 |
- UIHelper.handlingError(e);
|
|
| 442 |
- return;
|
|
| 443 |
- }
|
|
| 444 |
- }
|
|
| 445 |
- |
|
| 446 |
- progressModel.setExtent(1);
|
|
| 447 |
- }
|
|
| 448 |
- |
|
| 449 |
- // suppression du storage precedent
|
|
| 450 |
- if (currentDataSource != null && currentDataSource.isOpen()) {
|
|
| 451 |
- log.debug(">>> close main storage " + currentDataSource);
|
|
| 452 |
- // on doit fermer le storage en cours d'utilisation
|
|
| 453 |
- try {
|
|
| 454 |
- currentDataSource.close();
|
|
| 455 |
- } catch (Exception e) {
|
|
| 456 |
- UIHelper.handlingError(e);
|
|
| 457 |
- }
|
|
| 458 |
- }
|
|
| 459 |
- progressModel.setExtent(1);
|
|
| 460 |
- |
|
| 461 |
- // suppression du storage local
|
|
| 462 |
- if (localDataSource != null
|
|
| 463 |
- && localDataSource.isOpen() // Si la base a été détruite précédemment, elle n'est plus ouverte
|
|
| 464 |
- && localDataSource != currentDataSource) {
|
|
| 465 |
- // ce cas peut arriver lorsque l'on fait juste une backup
|
|
| 466 |
- // sans vouloir supprimer la base locale
|
|
| 467 |
- log.debug(">>> close local storage " + localDataSource);
|
|
| 468 |
- // on doit fermer le storage local ouvert
|
|
| 469 |
- try {
|
|
| 470 |
- localDataSource.close();
|
|
| 471 |
- } catch (Exception e) {
|
|
| 472 |
- UIHelper.handlingError(e);
|
|
| 473 |
- }
|
|
| 474 |
- }
|
|
| 475 |
- |
|
| 476 |
- log.debug("Will create new storage...");
|
|
| 477 |
- |
|
| 478 |
- // preparation du nouveau storage
|
|
| 479 |
- |
|
| 480 |
- try {
|
|
| 481 |
- currentDataSource = model.initFromDataSource(config, dataSourcesManager);
|
|
| 482 |
- currentDataSource.setProgressModel(progressModel);
|
|
| 483 |
- |
|
| 484 |
- // si on utilise la base local on lance une migration de la base si necessaire
|
|
| 485 |
- if (DbMode.USE_LOCAL.equals((model.getDbMode()))) {
|
|
| 486 |
- |
|
| 487 |
- ObserveDataSourceInformation dataSourceInformation = currentDataSource.checkCanConnect(false);
|
|
| 488 |
- currentDataSource.setOwner(dataSourceInformation.isOwner());
|
|
| 489 |
- currentDataSource.setSuperUser(dataSourceInformation.isSuperUser());
|
|
| 490 |
- progressModel.setExtent(1);
|
|
| 491 |
- |
|
| 492 |
- currentDataSource.migrateData(dataSourceInformation, config.getModelVersion());
|
|
| 493 |
- |
|
| 494 |
- progressModel.setExtent(1);
|
|
| 495 |
- |
|
| 496 |
- }
|
|
| 497 |
- |
|
| 498 |
- //FIXME:BodyContent this is already done in prepareMainStorage method
|
|
| 499 |
-// dataSourcesManager.setMainDataSource(currentDataSource);
|
|
| 500 |
- ObserveMainUI mainUI = getClientUIContext().getMainUI();
|
|
| 501 |
- |
|
| 502 |
- mainUI.getMainUIBodyContentManager().getBodyTyped(DataSourceEditor.class, DataSourceEditorBodyContent.class).prepareMainStorage(currentDataSource, true);
|
|
| 503 |
- |
|
| 504 |
- if (model.getDbMode() == DbMode.CREATE_LOCAL) {
|
|
| 505 |
- |
|
| 506 |
- DataSourceCreateConfigurationDto creationConfigurationDto = model.getCreationConfigurationDto();
|
|
| 507 |
- |
|
| 508 |
- try {
|
|
| 509 |
- |
|
| 510 |
- currentDataSource.create(creationConfigurationDto);
|
|
| 511 |
- |
|
| 512 |
- } catch (Exception e) {
|
|
| 513 |
- //si il y a une erreur lor de la création de la base locla
|
|
| 514 |
- |
|
| 515 |
- // on suprimer la base
|
|
| 516 |
- File localDBDirectory = config.getLocalDBDirectory();
|
|
| 517 |
- log.info(">>> destroy local db directory " + localDBDirectory);
|
|
| 518 |
- try {
|
|
| 519 |
- FileUtils.deleteDirectory(localDBDirectory);
|
|
| 520 |
- } catch (IOException e2) {
|
|
| 521 |
- UIHelper.handlingError(e2);
|
|
| 522 |
- }
|
|
| 523 |
- |
|
| 524 |
- config.setLocalStorageExist(false);
|
|
| 525 |
- dataSourcesManager.setMainDataSource(null);
|
|
| 526 |
- |
|
| 527 |
- throw e;
|
|
| 528 |
- }
|
|
| 529 |
- } else {
|
|
| 530 |
- // ouverture du nouveau storage
|
|
| 531 |
- currentDataSource.open();
|
|
| 532 |
- }
|
|
| 533 |
- |
|
| 534 |
- progressModel.setExtent(1);
|
|
| 535 |
- |
|
| 536 |
- if (DbMode.CREATE_LOCAL.equals(model.getDbMode())
|
|
| 537 |
- && (IMPORT_REMOTE_STORAGE.equals(model.getCreationMode()) || IMPORT_SERVER_STORAGE.equals(model.getCreationMode()))
|
|
| 538 |
- && config.isLocalStorageExist()) {
|
|
| 539 |
- // si on a creer la base locale a partir d'un import d'une base
|
|
| 540 |
- // distante, on sauvegarde la base locale comme dump initial
|
|
| 541 |
- // il s'agit d'un dump du référentiel
|
|
| 542 |
- File f = config.getInitialDbDump();
|
|
| 543 |
- if (f.exists()) {
|
|
| 544 |
- // on supprime le dump sql de la base embarquée
|
|
| 545 |
- if (!f.delete()) {
|
|
| 546 |
- throw new IllegalStateException("could not delete " + f);
|
|
| 547 |
- }
|
|
| 548 |
- }
|
|
| 549 |
- log.info(">>> create initial dump with " + currentDataSource + " in " + f);
|
|
| 550 |
- try {
|
|
| 551 |
- SqlScriptProducerService dumpProducerService = currentDataSource.getSqlScriptProducerService();
|
|
| 552 |
- backupLocalDatabase(dumpProducerService, f);
|
|
| 553 |
- config.setInitialDumpExist(true);
|
|
| 554 |
- } catch (Exception e) {
|
|
| 555 |
- UIHelper.handlingError(e);
|
|
| 556 |
- }
|
|
| 557 |
- }
|
|
| 558 |
- |
|
| 559 |
- log.info(">>> main storage opened " + currentDataSource.getLabel());
|
|
| 560 |
- |
|
| 561 |
- progressModel.setExtent(1);
|
|
| 562 |
- |
|
| 563 |
- mainUI.changeBodyContent(DataSourceEditor.class);
|
|
| 564 |
- |
|
| 565 |
- } catch (Exception ex) {
|
|
| 566 |
- UIHelper.handlingError(ex);
|
|
| 567 |
- throw new RuntimeException(ex);
|
|
| 568 |
- } finally {
|
|
| 569 |
- ObserveUtil.cleanMemory();
|
|
| 570 |
- }
|
|
| 571 |
- }
|
|
| 572 |
- |
|
| 573 |
- /**
|
|
| 574 |
- * Effectue une sauvegarde de la base locale vers le fichier choisi.
|
|
| 575 |
- *
|
|
| 576 |
- * @param dumpProducerService le service de dump
|
|
| 577 |
- * @param dst le fichier de sauvegarde
|
|
| 578 |
- */
|
|
| 579 |
- private void backupLocalDatabase(SqlScriptProducerService dumpProducerService, File dst) {
|
|
| 580 |
- if (dst == null) {
|
|
| 581 |
- throw new IllegalArgumentException("file where to backup can not be null");
|
|
| 582 |
- }
|
|
| 583 |
- if (log.isDebugEnabled()) {
|
|
| 584 |
- log.debug(dst);
|
|
| 585 |
- }
|
|
| 586 |
- |
|
| 587 |
- AddSqlScriptProducerRequest request = AddSqlScriptProducerRequest.forH2(getClientConfig().getModelVersion()).addSchema().addReferential().addAllData();
|
|
| 588 |
- TopiaSqlScript dataDump = dumpProducerService.produceAddSqlScript(request);
|
|
| 589 |
- try {
|
|
| 590 |
- dataDump.copy(dst.toPath());
|
|
| 591 |
- } catch (IOException e) {
|
|
| 592 |
- UIHelper.handlingError(e);
|
|
| 593 |
- }
|
|
| 594 |
- }
|
|
| 595 |
- |
|
| 596 | 302 |
public void destroy() {
|
| 597 | 303 |
ui.getModel().destroy();
|
| 598 | 304 |
log.debug("destroy ui " + ui.getName());
|
| 599 | 305 |
UIHelper.TabbedPaneIterator<Component> itr = UIHelper.newTabbedPaneIterator(ui.getTabs());
|
| 600 |
- for (; itr.hasNext(); ) {
|
|
| 306 |
+ while (itr.hasNext()) {
|
|
| 601 | 307 |
StorageTabUI tab = (StorageTabUI) itr.next();
|
| 602 | 308 |
log.debug("destroy ui " + tab.getName());
|
| 603 | 309 |
tab.destroy();
|
| ... | ... | @@ -25,12 +25,9 @@ import fr.ird.observe.client.ClientUIContextApplicationComponent; |
| 25 | 25 |
import fr.ird.observe.client.WithClientUIContext;
|
| 26 | 26 |
import fr.ird.observe.client.configuration.WithClientConfig;
|
| 27 | 27 |
import fr.ird.observe.client.constants.DbMode;
|
| 28 |
-import fr.ird.observe.client.datasource.api.ObserveDataSourcesManagerApplicationComponent;
|
|
| 29 |
-import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
|
| 30 | 28 |
import fr.ird.observe.client.datasource.api.WithObserveDataSourcesManager;
|
| 31 | 29 |
import fr.ird.observe.client.util.UIHelper;
|
| 32 | 30 |
import fr.ird.observe.dto.ObserveUtil;
|
| 33 |
-import org.apache.commons.collections4.CollectionUtils;
|
|
| 34 | 31 |
import org.apache.logging.log4j.LogManager;
|
| 35 | 32 |
import org.apache.logging.log4j.Logger;
|
| 36 | 33 |
import org.nuiton.jaxx.runtime.JAXXContext;
|
| ... | ... | @@ -41,8 +38,6 @@ import org.nuiton.jaxx.runtime.swing.wizard.WizardUILancher; |
| 41 | 38 |
|
| 42 | 39 |
import java.awt.Window;
|
| 43 | 40 |
import java.util.Arrays;
|
| 44 |
-import java.util.Set;
|
|
| 45 |
-import java.util.stream.Collectors;
|
|
| 46 | 41 |
|
| 47 | 42 |
import static io.ultreia.java4all.i18n.I18n.t;
|
| 48 | 43 |
|
| ... | ... | @@ -68,63 +63,6 @@ public class StorageUILauncher extends WizardUILancher<StorageStep, StorageUIMod |
| 68 | 63 |
this.title = title;
|
| 69 | 64 |
}
|
| 70 | 65 |
|
| 71 |
- /**
|
|
| 72 |
- * Méthode pour lancer le changement de source de données.
|
|
| 73 |
- *
|
|
| 74 |
- * @param rootContext le context applicatif
|
|
| 75 |
- * @param mainUI main ui
|
|
| 76 |
- * @param modes les modes optionnel à utiliser
|
|
| 77 |
- * @param title le titre de la fenetre
|
|
| 78 |
- * @see StorageUIHandler
|
|
| 79 |
- * @see StorageUI
|
|
| 80 |
- */
|
|
| 81 |
- public static void changeStorage(JAXXContext rootContext, Window mainUI, Set<DbMode> modes, String title) {
|
|
| 82 |
- |
|
| 83 |
- new StorageUILauncher(rootContext, mainUI, title) {
|
|
| 84 |
- |
|
| 85 |
- @Override
|
|
| 86 |
- protected void init(StorageUI ui) {
|
|
| 87 |
- super.init(ui);
|
|
| 88 |
- log.debug("Incoming db mode : " + modes.stream().map(DbMode::name).collect(Collectors.joining(", ")));
|
|
| 89 |
- StorageUIModel model = ui.getModel();
|
|
| 90 |
- if (CollectionUtils.isNotEmpty(modes)) {
|
|
| 91 |
- log.info("will use incoming mode " + modes.stream().map(DbMode::name).collect(Collectors.joining(", ")));
|
|
| 92 |
- |
|
| 93 |
- model.setExcludeSteps(Arrays.asList(StorageStep.SELECT_DATA,
|
|
| 94 |
- StorageStep.BACKUP,
|
|
| 95 |
- StorageStep.CONFIG_REFERENTIAL,
|
|
| 96 |
- StorageStep.CONFIG_DATA,
|
|
| 97 |
- StorageStep.ROLES));
|
|
| 98 |
- model.setCanCreateLocalService(modes.contains(DbMode.CREATE_LOCAL));
|
|
| 99 |
- model.setCanUseLocalService(modes.contains(DbMode.USE_LOCAL));
|
|
| 100 |
- model.setCanUseRemoteService(modes.contains(DbMode.USE_REMOTE));
|
|
| 101 |
- model.setCanUseServerService(modes.contains(DbMode.USE_SERVER));
|
|
| 102 |
- |
|
| 103 |
- model.updateUniverse();
|
|
| 104 |
- model.setDbMode(modes.stream().findFirst().orElse(null));
|
|
| 105 |
- |
|
| 106 |
- } else {
|
|
| 107 |
- boolean localOpened = ObserveDataSourcesManagerApplicationComponent.value().getOptionalMainDataSource().map(ObserveSwingDataSource::isLocal).orElse(false);
|
|
| 108 |
- if (localOpened) {
|
|
| 109 |
- log.debug("Can not use local db (already opened)");
|
|
| 110 |
- model.setCanUseLocalService(false);
|
|
| 111 |
- }
|
|
| 112 |
- model.setCanCreateLocalService(true);
|
|
| 113 |
- model.setCanUseRemoteService(true);
|
|
| 114 |
- model.setCanUseServerService(true);
|
|
| 115 |
- }
|
|
| 116 |
- model.updateUniverse();
|
|
| 117 |
- }
|
|
| 118 |
- |
|
| 119 |
- @Override
|
|
| 120 |
- public void doAction(StorageUI ui) {
|
|
| 121 |
- super.doAction(ui);
|
|
| 122 |
- ui.getHandler().doChangeStorage(ui.getModel());
|
|
| 123 |
- }
|
|
| 124 |
- |
|
| 125 |
- }.start();
|
|
| 126 |
- }
|
|
| 127 |
- |
|
| 128 | 66 |
/**
|
| 129 | 67 |
* Méthode pour lancer l'action de connexion à une base distante.
|
| 130 | 68 |
* <p>
|
| ... | ... | @@ -79,6 +79,7 @@ import java.io.File; |
| 79 | 79 |
import java.lang.reflect.UndeclaredThrowableException;
|
| 80 | 80 |
import java.net.MalformedURLException;
|
| 81 | 81 |
import java.net.URL;
|
| 82 |
+import java.nio.file.Path;
|
|
| 82 | 83 |
import java.util.ArrayList;
|
| 83 | 84 |
import java.util.Arrays;
|
| 84 | 85 |
import java.util.List;
|
| ... | ... | @@ -444,27 +445,56 @@ public class StorageUIModel extends WizardModel<StorageStep> implements WithClie |
| 444 | 445 |
setDataSourceInformation(previousInfo);
|
| 445 | 446 |
}
|
| 446 | 447 |
|
| 447 |
- public ObserveSwingDataSource initFromDataSource(ClientConfig config, ObserveDataSourcesManager dataSourcesManager) {
|
|
| 448 |
+ public ObserveSwingDataSource initDataSourceFromModel(ClientConfig config, ObserveDataSourcesManager dataSourcesManager) {
|
|
| 448 | 449 |
|
| 449 | 450 |
ObserveSwingDataSource dataSource = null;
|
| 450 | 451 |
ObserveDataSourceConfiguration configuration;
|
| 451 | 452 |
switch (getDbMode()) {
|
| 452 | 453 |
case CREATE_LOCAL:
|
| 453 |
- case USE_LOCAL:
|
|
| 454 | 454 |
configuration = toH2StorageConfig(t("observe.runner.initStorage.label.local"));
|
| 455 | 455 |
|
| 456 | 456 |
dataSource = dataSourcesManager.newDataSource(configuration);
|
| 457 |
- |
|
| 458 | 457 |
dataSource.addObserveSwingDataSourceListener(
|
| 459 | 458 |
new ObserveSwingDataSourceListenerAdapter() {
|
| 460 | 459 |
|
| 461 | 460 |
@Override
|
| 462 | 461 |
public void onOpened(ObserveSwingDataSourceEvent event) {
|
| 463 |
- // la base locale existe desormais
|
|
| 462 |
+ ObserveSwingDataSource dataSource = event.getSource();
|
|
| 463 |
+ |
|
| 464 |
+ // local data source now exists
|
|
| 464 | 465 |
config.setLocalStorageExist(true);
|
| 466 |
+ |
|
| 467 |
+ switch (getCreationMode()) {
|
|
| 468 |
+ case IMPORT_EXTERNAL_DUMP:
|
|
| 469 |
+ // update import directory
|
|
| 470 |
+ File importDirectory = getDumpFile().getParentFile();
|
|
| 471 |
+ log.info(String.format("update import directory to: %s", importDirectory));
|
|
| 472 |
+ config.setImportDirectory(importDirectory);
|
|
| 473 |
+ break;
|
|
| 474 |
+ case IMPORT_REMOTE_STORAGE:
|
|
| 475 |
+ case IMPORT_SERVER_STORAGE:
|
|
| 476 |
+ // Let's generate again initial dump
|
|
| 477 |
+ Path f = config.getInitialDbDump().toPath();
|
|
| 478 |
+ log.info(String.format("create initial dump with %s to: %s", dataSource, f));
|
|
| 479 |
+ try {
|
|
| 480 |
+ dataSource.backupLocalDatabase(f);
|
|
| 481 |
+ config.setInitialDumpExist(true);
|
|
| 482 |
+ } catch (Exception e) {
|
|
| 483 |
+ UIHelper.handlingError(e);
|
|
| 484 |
+ //FIXME FeedBack ???
|
|
| 485 |
+ |
|
| 486 |
+ }
|
|
| 487 |
+ break;
|
|
| 488 |
+ }
|
|
| 489 |
+ config.saveForUser();
|
|
| 490 |
+ |
|
| 465 | 491 |
}
|
| 466 | 492 |
});
|
| 467 | 493 |
|
| 494 |
+ break;
|
|
| 495 |
+ case USE_LOCAL:
|
|
| 496 |
+ configuration = toH2StorageConfig(t("observe.runner.initStorage.label.local"));
|
|
| 497 |
+ dataSource = dataSourcesManager.newDataSource(configuration);
|
|
| 468 | 498 |
break;
|
| 469 | 499 |
case USE_REMOTE:
|
| 470 | 500 |
configuration = toPGStorageConfig(t("observe.storage.label.remote"));
|
| ... | ... | @@ -154,7 +154,7 @@ public class DataSourceSelectorModel extends StorageUIModel { |
| 154 | 154 |
|
| 155 | 155 |
public ObserveSwingDataSource getSafeSource(boolean open) {
|
| 156 | 156 |
if (source == null || open && !source.isOpen()) {
|
| 157 |
- source = initFromDataSource(getClientConfig(), ObserveDataSourcesManagerApplicationComponent.value());
|
|
| 157 |
+ source = initDataSourceFromModel(getClientConfig(), ObserveDataSourcesManagerApplicationComponent.value());
|
|
| 158 | 158 |
}
|
| 159 | 159 |
if (open) {
|
| 160 | 160 |
|
| ... | ... | @@ -360,6 +360,10 @@ public class RunObserve extends ApplicationRunner implements WithBackupsManager, |
| 360 | 360 |
}
|
| 361 | 361 |
}
|
| 362 | 362 |
|
| 363 |
+ //FIXME Reuse the load storage action which will soon have the logic to load back a backup and anything else
|
|
| 364 |
+ //FIXME Need to have a unified API and only one
|
|
| 365 |
+ //FIXME first try to open specified ds (here local ds)
|
|
| 366 |
+ //FIXME if can not load local ds, then feedback it and propose to load automatic backup, or to create a new local ds
|
|
| 363 | 367 |
private void initStorage(ClientConfig config, JFrame ui) {
|
| 364 | 368 |
|
| 365 | 369 |
ObserveMainUI mainUI = (ObserveMainUI) ui;
|
| ... | ... | @@ -415,10 +419,10 @@ public class RunObserve extends ApplicationRunner implements WithBackupsManager, |
| 415 | 419 |
}
|
| 416 | 420 |
|
| 417 | 421 |
|
| 418 |
- private void askToCreateLocalDatabase(ObserveMainUI mainUI,
|
|
| 419 |
- ClientConfig config,
|
|
| 420 |
- ObserveDataSourcesManager dataSourcesManager,
|
|
| 421 |
- BackupStorage lastAutomaticBackup) {
|
|
| 422 |
+ public static void askToCreateLocalDatabase(ObserveMainUI mainUI,
|
|
| 423 |
+ ClientConfig config,
|
|
| 424 |
+ ObserveDataSourcesManager dataSourcesManager,
|
|
| 425 |
+ BackupStorage lastAutomaticBackup) {
|
|
| 422 | 426 |
|
| 423 | 427 |
InitStorageModel initStorageModel = new InitStorageModel(config.getLocalDBDirectory(), lastAutomaticBackup);
|
| 424 | 428 |
|
| ... | ... | @@ -444,8 +448,7 @@ public class RunObserve extends ApplicationRunner implements WithBackupsManager, |
| 444 | 448 |
|
| 445 | 449 |
}
|
| 446 | 450 |
|
| 447 |
- JLabel label = new JLabel();
|
|
| 448 |
- label.setText(text);
|
|
| 451 |
+ JLabel label = new JLabel(text);
|
|
| 449 | 452 |
int response = askUser(
|
| 450 | 453 |
null,
|
| 451 | 454 |
t("observe.runner.initStorage.title.no.local.db.found"),
|
| ... | ... | @@ -454,7 +457,7 @@ public class RunObserve extends ApplicationRunner implements WithBackupsManager, |
| 454 | 457 |
options,
|
| 455 | 458 |
defaultOption
|
| 456 | 459 |
);
|
| 457 |
- log.debug("response : " + response);
|
|
| 460 |
+ log.debug(String.format("response : %d", response));
|
|
| 458 | 461 |
|
| 459 | 462 |
if (noAutomaticBackup) {
|
| 460 | 463 |
Set<DbMode> dbModes = EnumSet.noneOf(DbMode.class);
|
| ... | ... | @@ -510,7 +513,7 @@ public class RunObserve extends ApplicationRunner implements WithBackupsManager, |
| 510 | 513 |
|
| 511 | 514 |
}
|
| 512 | 515 |
|
| 513 |
- private void loadBackup(ObserveDataSourcesManager dataSourcesManager, ObserveMainUI mainUI, BackupStorage backupStorage) {
|
|
| 516 |
+ public static void loadBackup(ObserveDataSourcesManager dataSourcesManager, ObserveMainUI mainUI, BackupStorage backupStorage) {
|
|
| 514 | 517 |
log.info("Will load last backup: " + backupStorage.getFile());
|
| 515 | 518 |
try {
|
| 516 | 519 |
// byte[] dump = Files.readAllBytes(backupStorage.getFile().toPath());
|
| ... | ... | @@ -388,6 +388,7 @@ observe.choice.createLocalStorage=Create local storage |
| 388 | 388 |
observe.choice.dcp.default=Other opérations or objects (FOB)
|
| 389 | 389 |
observe.choice.doNotSave=Do not save
|
| 390 | 390 |
observe.choice.doNothing=Do nothing
|
| 391 |
+observe.choice.generateFeedBack=Generate
|
|
| 391 | 392 |
observe.choice.loadLastAutomaticBackup=Use last automatic backup
|
| 392 | 393 |
observe.choice.quit=Quit
|
| 393 | 394 |
observe.choice.replace=Replace
|
| ... | ... | @@ -479,6 +480,7 @@ observe.config.defaultReportDirectory.description=Default directory where to sto |
| 479 | 480 |
observe.config.defaultResourcesDirectory.description=Default user resources directory
|
| 480 | 481 |
observe.config.defaultValidationReportDirectory.description=Default validation report directory
|
| 481 | 482 |
observe.config.devMode=Dev mode
|
| 483 |
+observe.config.feedBackDirectory.description=FeedBack directory
|
|
| 482 | 484 |
observe.config.floatingObjectPresets.description=Floating Objects references
|
| 483 | 485 |
observe.config.h2.can.editReferential.description=Local database can edit referential
|
| 484 | 486 |
observe.config.h2.can.migrate.description=Flag to know if you can migrate h2 data sources
|
| ... | ... | @@ -2299,7 +2301,10 @@ observe.error.LengthLengthParameterNotFoundException=No length length relation f |
| 2299 | 2301 |
observe.error.LengthWeightParameterNotFoundException=No length weight relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s
|
| 2300 | 2302 |
observe.error.can.not.create.directory=Can't create directory %&$s\!
|
| 2301 | 2303 |
observe.error.storage.could.not.backup.unsane.local.db=Can not save an borken database
|
| 2304 |
+observe.error.storage.could.not.close.local.data.source.message=A feed back backup can be generate at %s, otherwise you can cancel.
|
|
| 2305 |
+observe.error.storage.could.not.close.local.data.source.title=An error occurs while removing previous local data source
|
|
| 2302 | 2306 |
observe.error.storage.could.not.load.local.db=Could not open local database for reason\: %s
|
| 2307 |
+observe.error.storage.could.not.open.local.data.source.title=An error occurs while creating local data source
|
|
| 2303 | 2308 |
observe.info.selected.validators=You must select at least one validator to continue.
|
| 2304 | 2309 |
observe.info.validation.credentials=To validate referentiel (resp. data), You must have rw credentials.
|
| 2305 | 2310 |
observe.init.local.db.detected=%1$s detected.
|
| ... | ... | @@ -388,6 +388,7 @@ observe.choice.createLocalStorage=Crear la base local |
| 388 | 388 |
observe.choice.dcp.default=Other opérations or objects (FOB) \#TODO
|
| 389 | 389 |
observe.choice.doNotSave=No grabar
|
| 390 | 390 |
observe.choice.doNothing=No hacer nada
|
| 391 |
+observe.choice.generateFeedBack=Generate \#TODO
|
|
| 391 | 392 |
observe.choice.loadLastAutomaticBackup=Use last automatic backup \#TODO
|
| 392 | 393 |
observe.choice.quit=Cerrar
|
| 393 | 394 |
observe.choice.replace=Reemplazar
|
| ... | ... | @@ -479,6 +480,7 @@ observe.config.defaultReportDirectory.description=Directorio por defecto de los |
| 479 | 480 |
observe.config.defaultResourcesDirectory.description=Directorio de almacenamiento de los recursos de usuario como las traducciones o la consultas de informes
|
| 480 | 481 |
observe.config.defaultValidationReportDirectory.description=Directorio por defecto de almacenamiento de los informes de validación
|
| 481 | 482 |
observe.config.devMode=Modo desarrollador
|
| 483 |
+observe.config.feedBackDirectory.description=FeedBack directory \#TODO
|
|
| 482 | 484 |
observe.config.floatingObjectPresets.description=Objetos flotantes de referencia
|
| 483 | 485 |
observe.config.h2.can.editReferential.description=Para poder editar el referencial de una base local
|
| 484 | 486 |
observe.config.h2.can.migrate.description=Autorizar la actualización de las bases locales (h2)
|
| ... | ... | @@ -2299,7 +2301,10 @@ observe.error.LengthLengthParameterNotFoundException=No length length relation f |
| 2299 | 2301 |
observe.error.LengthWeightParameterNotFoundException=No length weight relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s \#TODO
|
| 2300 | 2302 |
observe.error.can.not.create.directory=¡Imposible crear el directorio %1$s\!
|
| 2301 | 2303 |
observe.error.storage.could.not.backup.unsane.local.db=Impossible grabar una base dañada
|
| 2304 |
+observe.error.storage.could.not.close.local.data.source.message=A feed back backup can be generate at %s, otherwise you can cancel. \#TODO
|
|
| 2305 |
+observe.error.storage.could.not.close.local.data.source.title=An error occurs while removing previous local data source \#TODO
|
|
| 2302 | 2306 |
observe.error.storage.could.not.load.local.db=Impossible grabar la base local por la razón siguiente \: %s
|
| 2307 |
+observe.error.storage.could.not.open.local.data.source.title=An error occurs while creating local data source \#TODO
|
|
| 2303 | 2308 |
observe.info.selected.validators=Es necesario seleccionar un validador para continuar.
|
| 2304 | 2309 |
observe.info.validation.credentials=Para validar el referencial (resp. los datos), debe tener los derechos de lectura y escritura correspondientes.
|
| 2305 | 2310 |
observe.init.local.db.detected=%1$s detectado.
|
| ... | ... | @@ -388,6 +388,7 @@ observe.choice.createLocalStorage=Créer la base locale |
| 388 | 388 |
observe.choice.dcp.default=Autre opérations et types d'objets (FOB)
|
| 389 | 389 |
observe.choice.doNotSave=Ne pas enregistrer
|
| 390 | 390 |
observe.choice.doNothing=Ne rien faire
|
| 391 |
+observe.choice.generateFeedBack=Générer
|
|
| 391 | 392 |
observe.choice.loadLastAutomaticBackup=Charger la dernière sauvegarde automatique
|
| 392 | 393 |
observe.choice.quit=Fermer
|
| 393 | 394 |
observe.choice.replace=Remplacer
|
| ... | ... | @@ -479,6 +480,7 @@ observe.config.defaultReportDirectory.description=Répertoire par défaut des ra |
| 479 | 480 |
observe.config.defaultResourcesDirectory.description=Le répertoire où sont stockées les ressources de l'utilisateur comme les traductions ou les requêtes de rapports.
|
| 480 | 481 |
observe.config.defaultValidationReportDirectory.description=Le répertoire par défaut où sont stockés les rapports de validation
|
| 481 | 482 |
observe.config.devMode=Mode développeur
|
| 483 |
+observe.config.feedBackDirectory.description=Répertoire où sont consigner les feedback
|
|
| 482 | 484 |
observe.config.floatingObjectPresets.description=Objets flottants de référence
|
| 483 | 485 |
observe.config.h2.can.editReferential.description=Pour pouvoir éditer le référentiel d'une base locale
|
| 484 | 486 |
observe.config.h2.can.migrate.description=Autoriser la mise à jour des bases locales (H2)
|
| ... | ... | @@ -2299,7 +2301,10 @@ observe.error.LengthLengthParameterNotFoundException=Aucune relation taille-tail |
| 2299 | 2301 |
observe.error.LengthWeightParameterNotFoundException=Aucune relation taille-poids trouvée pour l'espèce\: %s, l'ocean\: %s, le sexe\: %s et la date\: %s
|
| 2300 | 2302 |
observe.error.can.not.create.directory=Création du répertoire %1$s impossible\!
|
| 2301 | 2303 |
observe.error.storage.could.not.backup.unsane.local.db=Impossible d'enregistrer une base non endommagée
|
| 2304 |
+observe.error.storage.could.not.close.local.data.source.message=Vous pouvez générer un retour d'expérience utilisateur (avec toutes les données disponibles pour comprendre le problème de puis l'archive %s), ou annuler l'opération de changement de base
|
|
| 2305 |
+observe.error.storage.could.not.close.local.data.source.title=Une erreur est survenue lors de la suppression de l'ancienne base locale
|
|
| 2302 | 2306 |
observe.error.storage.could.not.load.local.db=Impossible d'ouvrir la base locale pour la raison suivante \: %s
|
| 2307 |
+observe.error.storage.could.not.open.local.data.source.title=Une erreur est survenue lors de la création de la nouvelle base locale
|
|
| 2303 | 2308 |
observe.info.selected.validators=Il faut au moins un validateur sélectionné pour continuer.
|
| 2304 | 2309 |
observe.info.validation.credentials=Pour valider le référentiel (resp. les données), vous devez posséder les droits en lecture correspondants.
|
| 2305 | 2310 |
observe.init.local.db.detected=%1$s détectée.
|