Sammoa-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- 446 discussions
13 Aug '12
Author: tchemit
Date: 2012-08-14 00:19:52 +0200 (Tue, 14 Aug 2012)
New Revision: 415
Url: http://forge.codelutin.com/repositories/revision/sammoa/415
Log:
add missing license header, svn properties + move more classes to io package + remove obsolete packages
Added:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/CsvImporter.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/UIImporter.java
Removed:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/CsvImporter.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUIHandler.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,4 +1,27 @@
package fr.ulr.sammoa.application.io;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
import com.google.common.base.Charsets;
import com.google.common.base.Function;
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,4 +1,27 @@
package fr.ulr.sammoa.application.io;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
import fr.ulr.sammoa.application.SammoaConfig;
import org.apache.commons.io.FileUtils;
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,4 +1,27 @@
package fr.ulr.sammoa.application.io;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
import com.google.common.base.Charsets;
import com.google.common.io.Files;
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,4 +1,27 @@
package fr.ulr.sammoa.application.io;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
import org.apache.commons.io.FileUtils;
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,4 +1,27 @@
package fr.ulr.sammoa.application.io.input.csv;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
import com.google.common.base.Preconditions;
import com.google.common.io.Files;
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,4 +1,27 @@
package fr.ulr.sammoa.application.io.input.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,4 +1,27 @@
package fr.ulr.sammoa.application.io.input.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
import com.google.common.io.Files;
import fr.ulr.sammoa.application.io.CampaignStorage;
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java
===================================================================
--- trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,4 +1,27 @@
package fr.ulr.sammoa.application.io.input.csv;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
import fr.ulr.sammoa.application.SammoaConfig;
import fr.ulr.sammoa.application.SammoaContext;
Property changes on: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUIHandler.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUIHandler.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -40,9 +40,9 @@
import fr.ulr.sammoa.ui.swing.SammoaUIHandler;
import fr.ulr.sammoa.ui.swing.region.RegionUI;
import fr.ulr.sammoa.ui.swing.region.RegionUIModel;
-import fr.ulr.sammoa.ui.swing.util.CsvImporter;
+import fr.ulr.sammoa.ui.swing.io.input.CsvImporter;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
-import fr.ulr.sammoa.ui.swing.util.UIImporter;
+import fr.ulr.sammoa.ui.swing.io.input.UIImporter;
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/CsvImporter.java (from rev 414, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/CsvImporter.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/CsvImporter.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/CsvImporter.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -0,0 +1,38 @@
+package fr.ulr.sammoa.ui.swing.io.input;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Created: 17/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public abstract class CsvImporter {
+
+ public abstract String importCsvFile(File file) throws IOException;
+
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/CsvImporter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/UIImporter.java (from rev 414, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/UIImporter.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/UIImporter.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -0,0 +1,115 @@
+package fr.ulr.sammoa.ui.swing.io.input;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.application.io.CampaignStorage;
+import fr.ulr.sammoa.application.io.input.map.ShpImporter;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import org.nuiton.util.csv.ImportRuntimeException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import java.awt.Component;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class UIImporter {
+
+ /** Logger. */
+ private static final Logger logger =
+ LoggerFactory.getLogger(UIImporter.class);
+
+ protected final Component ui;
+
+ public UIImporter(Component ui) {
+ this.ui = ui;
+ }
+
+ public boolean importShape(ShpImporter<?> importer, File file, CampaignStorage storage) {
+ boolean result = false;
+
+ try {
+
+ SammoaUtil.updateBusyState(ui, true);
+
+ String successMessage = importer.importShape(file, storage);
+
+ SammoaUtil.updateBusyState(ui, false);
+
+ JOptionPane.showMessageDialog(ui, successMessage);
+
+ result = true;
+
+ } catch (ImportRuntimeException e) {
+ showError(file, e);
+
+ } catch (IOException e) {
+ showError(file, e);
+ }
+ return result;
+ }
+
+ public boolean importCvs(CsvImporter importer, File file) {
+ boolean result = false;
+
+ try {
+
+ SammoaUtil.updateBusyState(ui, true);
+
+ String successMessage = importer.importCsvFile(file);
+
+ SammoaUtil.updateBusyState(ui, false);
+
+ JOptionPane.showMessageDialog(ui, successMessage);
+
+ result = true;
+
+ } catch (ImportRuntimeException e) {
+ showError(file, e);
+
+ } catch (IOException e) {
+ showError(file, e);
+ }
+ return result;
+ }
+
+ protected void showError(File file, Exception e) {
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Import error from file '" + file.getAbsolutePath() + "'", e);
+ }
+ JOptionPane.showMessageDialog(
+ ui, e.getMessage(), "Error",
+ JOptionPane.ERROR_MESSAGE, UIManager.getIcon("error"));
+ }
+
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/UIImporter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -3,7 +3,7 @@
* #%L
* SAMMOA :: UI Swing
* $Id$
- * $HeadURL: http://svn.forge.codelutin.com/svn/sammoa/trunk/sammoa-ui-swing/src/main/ja… $
+ * $HeadURL$
* %%
* Copyright (C) 2012 UMS 3462, Code Lutin
* %%
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUIHandler.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUIHandler.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -30,9 +30,9 @@
import fr.ulr.sammoa.ui.swing.SammoaDecoratorProvider;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import fr.ulr.sammoa.ui.swing.SammoaUIHandler;
-import fr.ulr.sammoa.ui.swing.util.CsvImporter;
+import fr.ulr.sammoa.ui.swing.io.input.CsvImporter;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
-import fr.ulr.sammoa.ui.swing.util.UIImporter;
+import fr.ulr.sammoa.ui.swing.io.input.UIImporter;
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/CsvImporter.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/CsvImporter.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/CsvImporter.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,38 +0,0 @@
-package fr.ulr.sammoa.ui.swing.util;
-/*
- * #%L
- * SAMMOA :: UI Swing
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Created: 17/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public abstract class CsvImporter {
-
- public abstract String importCsvFile(File file) throws IOException;
-
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java 2012-08-13 22:12:51 UTC (rev 414)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java 2012-08-13 22:19:52 UTC (rev 415)
@@ -1,91 +0,0 @@
-package fr.ulr.sammoa.ui.swing.util;
-
-import fr.ulr.sammoa.application.io.CampaignStorage;
-import fr.ulr.sammoa.application.io.input.map.ShpImporter;
-import org.nuiton.util.csv.ImportRuntimeException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.swing.JOptionPane;
-import javax.swing.UIManager;
-import java.awt.Component;
-import java.io.File;
-import java.io.IOException;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.6
- */
-public class UIImporter {
-
- /** Logger. */
- private static final Logger logger =
- LoggerFactory.getLogger(UIImporter.class);
-
- protected final Component ui;
-
- public UIImporter(Component ui) {
- this.ui = ui;
- }
-
- public boolean importShape(ShpImporter<?> importer, File file, CampaignStorage storage) {
- boolean result = false;
-
- try {
-
- SammoaUtil.updateBusyState(ui, true);
-
- String successMessage = importer.importShape(file, storage);
-
- SammoaUtil.updateBusyState(ui, false);
-
- JOptionPane.showMessageDialog(ui, successMessage);
-
- result = true;
-
- } catch (ImportRuntimeException e) {
- showError(file, e);
-
- } catch (IOException e) {
- showError(file, e);
- }
- return result;
- }
-
- public boolean importCvs(CsvImporter importer, File file) {
- boolean result = false;
-
- try {
-
- SammoaUtil.updateBusyState(ui, true);
-
- String successMessage = importer.importCsvFile(file);
-
- SammoaUtil.updateBusyState(ui, false);
-
- JOptionPane.showMessageDialog(ui, successMessage);
-
- result = true;
-
- } catch (ImportRuntimeException e) {
- showError(file, e);
-
- } catch (IOException e) {
- showError(file, e);
- }
- return result;
- }
-
- protected void showError(File file, Exception e) {
-
- if (logger.isInfoEnabled()) {
- logger.info("Import error from file '" + file.getAbsolutePath() + "'", e);
- }
- JOptionPane.showMessageDialog(
- ui, e.getMessage(), "Error",
- JOptionPane.ERROR_MESSAGE, UIManager.getIcon("error"));
- }
-
-}
1
0
13 Aug '12
Author: tchemit
Date: 2012-08-14 00:12:51 +0200 (Tue, 14 Aug 2012)
New Revision: 414
Url: http://forge.codelutin.com/repositories/revision/sammoa/414
Log:
refs #1201: Export format application
refactor input - output packages
Added:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ObserverImportModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/SpeciesImportModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/DoubleToIntegerValueParser.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateImportModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateTypeValueParser.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/TransectImportModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/sammoa/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfColumnModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfImport.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTableModelBuilder.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTimestampConverter.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/LegStatus.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationCallbackMode.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationService.java
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/DbfTimestampConverterTest.java
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/ExportMapServiceTest.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/sammoa/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java
Removed:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/DoubleToIntegerValueParser.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/ObserverImportModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/SpeciesImportModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateImportModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateTypeValueParser.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/TransectImportModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfColumnModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfImport.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTableModelBuilder.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTimestampConverter.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/LegStatus.java
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/ReferentialServiceTest.java
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/map/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/importApplication/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/Importer.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ShpImporter.java
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaTechnicalException.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceManager.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceState.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceTechnicalException.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorder.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderDefault.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderMock.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsConfig.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandler.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandlerGpsylon.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsLocationListener.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerListener.java
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/FlightServiceTest.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/transect/TransectUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/CsvImporter.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -29,6 +29,9 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
+import fr.ulr.sammoa.application.io.CampaignStorage;
+import fr.ulr.sammoa.application.io.CampaignStorages;
+import fr.ulr.sammoa.application.io.FlightStorages;
import fr.ulr.sammoa.persistence.AutoSaveListener;
import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.Flight;
@@ -63,6 +66,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -257,6 +261,18 @@
} finally {
persistence.endTransaction(transaction);
}
+
+ // create flight storage
+ CampaignStorage campaignStorage = CampaignStorages.getStorage(
+ config, campaign.getTopiaId());
+
+ try {
+ FlightStorages.createStorage(campaignStorage, result.getTopiaId());
+ } catch (IOException e) {
+ throw new SammoaTechnicalException(
+ "Could not create flight storage", e);
+ }
+
return result;
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -25,9 +25,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ulr.sammoa.application.csv.ObserverImportModel;
-import fr.ulr.sammoa.application.csv.SpeciesImportModel;
+import fr.ulr.sammoa.application.io.CampaignStorages;
import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.CampaignDAO;
import fr.ulr.sammoa.persistence.Observer;
@@ -37,31 +35,20 @@
import fr.ulr.sammoa.persistence.RegionDAO;
import fr.ulr.sammoa.persistence.SammoaDAOHelper;
import fr.ulr.sammoa.persistence.SammoaPersistence;
-import fr.ulr.sammoa.persistence.Sector;
-import fr.ulr.sammoa.persistence.SectorDAO;
-import fr.ulr.sammoa.persistence.Sectors;
import fr.ulr.sammoa.persistence.Species;
import fr.ulr.sammoa.persistence.SpeciesDAO;
import fr.ulr.sammoa.persistence.Strate;
import fr.ulr.sammoa.persistence.StrateDAO;
-import fr.ulr.sammoa.persistence.StrateType;
-import fr.ulr.sammoa.persistence.Strates;
import fr.ulr.sammoa.persistence.Transect;
import fr.ulr.sammoa.persistence.TransectDAO;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaRuntimeException;
-import org.nuiton.util.csv.Import;
-import org.nuiton.util.csv.ImportRuntimeException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.io.Reader;
+import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
/**
* Created: 18/06/12
@@ -70,8 +57,6 @@
*/
public class ReferentialService {
- private static final Logger logger = LoggerFactory.getLogger(ReferentialService.class);
-
protected SammoaContext context;
protected SammoaConfig config;
@@ -152,71 +137,81 @@
return result;
}
- public int importSpecies(String regionId, Reader reader) {
+// public int importSpecies(String regionId, File file) throws IOException {
+//
+// Reader reader = Files.newReader(file, Charsets.UTF_8);
+//
+// try {
+// int result = 0;
+//
+// TopiaContext transaction = persistence.beginTransaction();
+// try {
+//
+// Region region = SammoaDAOHelper.getRegionDAO(transaction).findByTopiaId(regionId);
+// Preconditions.checkNotNull(region);
+//
+// SpeciesDAO dao =
+// SammoaDAOHelper.getSpeciesDAO(transaction);
+//
+// SpeciesImportModel model = new SpeciesImportModel(region);
+//
+// Import<Species> importCsv = Import.newImport(model, reader);
+//
+// for (Species species : importCsv) {
+//
+// // while importing a species, it does become valid
+// species.setLocalCreation(false);
+//
+// Species speciesExists =
+// dao.findByNaturalId(species.getCode(),
+// species.getRegion());
+//
+// if (speciesExists == null) {
+//
+// dao.create(species);
+//
+// result++;
+//
+// if (logger.isDebugEnabled()) {
+// logger.debug(String.format("Create new species %1$s " +
+// "for region %2$s",
+// species.getCode(),
+// region.getCode()));
+// }
+//
+// } else {
+//
+// speciesExists.setCommonName(species.getCommonName());
+// speciesExists.setLatinName(species.getLatinName());
+// speciesExists.setGroupName(species.getGroupName());
+// speciesExists.setFamily(species.getFamily());
+// speciesExists.setType(species.getType());
+// dao.update(speciesExists);
+//
+// if (logger.isInfoEnabled()) {
+// logger.info(String.format("The species %1$s already " +
+// "exists and is updated",
+// species.getCode()));
+// }
+// }
+// }
+//
+// transaction.commitTransaction();
+//
+// } catch (TopiaException e) {
+// throw new TopiaRuntimeException(e);
+//
+// } finally {
+// persistence.endTransaction(transaction);
+// }
+// reader.close();
+//
+// return result;
+// } finally {
+// IOUtils.closeQuietly(reader);
+// }
+// }
- TopiaContext transaction = persistence.beginTransaction();
- int result = 0;
- try {
-
- Region region = SammoaDAOHelper.getRegionDAO(transaction).findByTopiaId(regionId);
- Preconditions.checkNotNull(region);
-
- SpeciesDAO dao =
- SammoaDAOHelper.getSpeciesDAO(transaction);
-
- SpeciesImportModel model = new SpeciesImportModel(region);
-
- Import<Species> importCsv = Import.newImport(model, reader);
-
- for (Species species : importCsv) {
-
- // while importing a species, it does become valid
- species.setLocalCreation(false);
-
- Species speciesExists =
- dao.findByNaturalId(species.getCode(), species.getRegion());
-
- if (speciesExists == null) {
-
- dao.create(species);
-
- result++;
-
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Create new species %1$s " +
- "for region %2$s",
- species.getCode(),
- region.getCode()));
- }
-
- } else {
-
- speciesExists.setCommonName(species.getCommonName());
- speciesExists.setLatinName(species.getLatinName());
- speciesExists.setGroupName(species.getGroupName());
- speciesExists.setFamily(species.getFamily());
- speciesExists.setType(species.getType());
- dao.update(speciesExists);
-
- if (logger.isInfoEnabled()) {
- logger.info(String.format("The species %1$s already " +
- "exists and is updated",
- species.getCode()));
- }
- }
- }
-
- transaction.commitTransaction();
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- return result;
- }
-
public List<Campaign> getCampaigns() {
List<Campaign> result;
@@ -245,6 +240,8 @@
Preconditions.checkArgument(campaign.getCode() != null);
Preconditions.checkArgument(campaign.getRegion() != null);
+ boolean createCampaign = campaign.getTopiaId() == null;
+
String result;
TopiaContext transaction = persistence.beginTransaction();
@@ -252,7 +249,7 @@
CampaignDAO dao = SammoaDAOHelper.getCampaignDAO(transaction);
- if (campaign.getTopiaId() == null) {
+ if (createCampaign) {
Campaign existCampaign = dao.findByNaturalId(campaign.getCode(), campaign.getRegion());
Preconditions.checkArgument(existCampaign == null);
@@ -284,6 +281,18 @@
} finally {
persistence.endTransaction(transaction);
}
+
+ if (createCampaign) {
+
+ // creates the campaign storage
+ try {
+ CampaignStorages.createStorage(config, result);
+ } catch (IOException e) {
+ throw new SammoaTechnicalException(
+ "Could not create campaign storage", e);
+ }
+ }
+
return result;
}
@@ -366,8 +375,7 @@
SpeciesDAO dao = SammoaDAOHelper.getSpeciesDAO(transaction);
- Collection<Species> result =
- dao.findAllByLocalCreation(false);
+ Collection<Species> result = dao.findAllByLocalCreation(false);
return result;
} catch (TopiaException e) {
@@ -378,101 +386,101 @@
}
}
- public int importTransects(String campaignId, Iterable<Transect> transects) {
+// public int importTransects(String campaignId, Iterable<Transect> transects) {
+//
+// int result = 0;
+//
+// TopiaContext transaction = persistence.beginTransaction();
+// try {
+//
+// CampaignDAO campaignDAO =
+// SammoaDAOHelper.getCampaignDAO(transaction);
+//
+// Campaign campaign = campaignDAO.findByTopiaId(campaignId);
+// Preconditions.checkArgument(campaign != null,
+// "The topiaId : " + campaignId + " doesn't match any existing campaign");
+//
+// StrateDAO strateDAO = SammoaDAOHelper.getStrateDAO(transaction);
+// TransectDAO transectDAO = SammoaDAOHelper.getTransectDAO(transaction);
+//
+// // Retrieve directly all strates to avoid multiple select queries to find strates
+// List<Strate> strates = strateDAO.findAllByCampaignOrderedByCode(campaign);
+// Map<String, Strate> strateMap =
+// Maps.uniqueIndex(strates, Strates.toCode());
+//
+// int rowIndex = 0;
+// for (Transect transect : transects) {
+//
+// // This is the link with the source shape file that contains graphic elements
+// int graphicIndex = rowIndex;
+//
+// rowIndex++;
+//
+// String strateCode = Strates.getCode(transect.getStrate());
+//
+// // We check the strate, it must exist
+// // We can't do that in TransectImportModel during parsing because
+// // we need two params : sectorNumber and strateType to create the
+// // strateCode and check the existence. It must be done after parsing
+// Strate existStrate = strateMap.get(strateCode);
+// if (existStrate == null) {
+// throw new ImportRuntimeException(String.format(
+// "Unable to read line %1$d : The strate %2$s doesn't exist",
+// rowIndex,
+// strateCode)
+// );
+// }
+//
+// Transect existTransect = transectDAO.findByNaturalId(transect.getName(), existStrate);
+//
+// // If the existing strate is null, create it otherwise ignore
+// if (existTransect == null) {
+//
+// Transect newTransect = transectDAO.createByNaturalId(transect.getName(), existStrate);
+// newTransect.setLength(transect.getLength());
+// newTransect.setStartX(transect.getStartX());
+// newTransect.setStartY(transect.getStartY());
+// newTransect.setEndX(transect.getEndX());
+// newTransect.setEndY(transect.getEndY());
+// newTransect.setNbTimes(transect.getNbTimes());
+// newTransect.setGraphicIndex(graphicIndex);
+//
+// result++;
+//
+// if (logger.isDebugEnabled()) {
+// logger.debug(String.format("Create new transect %1$s" +
+// "(graphicIndex = %2$d)",
+// newTransect.getName(),
+// graphicIndex)
+// );
+// }
+//
+// } else {
+//
+// existTransect.setGraphicIndex(graphicIndex);
+//
+// if (logger.isWarnEnabled()) {
+// logger.warn(String.format("The transect %1$s already " +
+// "exists and will be ignored " +
+// "(graphicIndex = %2$d)",
+// existTransect.getName(),
+// graphicIndex)
+// );
+// }
+// }
+// }
+//
+// transaction.commitTransaction();
+//
+// } catch (TopiaException e) {
+// throw new TopiaRuntimeException(e);
+//
+// } finally {
+// persistence.endTransaction(transaction);
+// }
+// return result;
+// }
- int result = 0;
-
- TopiaContext transaction = persistence.beginTransaction();
- try {
-
- CampaignDAO campaignDAO =
- SammoaDAOHelper.getCampaignDAO(transaction);
-
- Campaign campaign = campaignDAO.findByTopiaId(campaignId);
- Preconditions.checkArgument(campaign != null,
- "The topiaId : " + campaignId + " doesn't match any existing campaign");
-
- StrateDAO strateDAO = SammoaDAOHelper.getStrateDAO(transaction);
- TransectDAO transectDAO = SammoaDAOHelper.getTransectDAO(transaction);
-
- // Retrieve directly all strates to avoid multiple select queries to find strates
- List<Strate> strates = strateDAO.findAllByCampaignOrderedByCode(campaign);
- Map<String, Strate> strateMap =
- Maps.uniqueIndex(strates, Strates.toCode());
-
- int rowIndex = 0;
- for (Transect transect : transects) {
-
- // This is the link with the source shape file that contains graphic elements
- int graphicIndex = rowIndex;
-
- rowIndex++;
-
- String strateCode = Strates.getCode(transect.getStrate());
-
- // We check the strate, it must exist
- // We can't do that in TransectImportModel during parsing because
- // we need two params : sectorNumber and strateType to create the
- // strateCode and check the existence. It must be done after parsing
- Strate existStrate = strateMap.get(strateCode);
- if (existStrate == null) {
- throw new ImportRuntimeException(String.format(
- "Unable to read line %1$d : The strate %2$s doesn't exist",
- rowIndex,
- strateCode)
- );
- }
-
- Transect existTransect = transectDAO.findByNaturalId(transect.getName(), existStrate);
-
- // If the existing strate is null, create it otherwise ignore
- if (existTransect == null) {
-
- Transect newTransect = transectDAO.createByNaturalId(transect.getName(), existStrate);
- newTransect.setLength(transect.getLength());
- newTransect.setStartX(transect.getStartX());
- newTransect.setStartY(transect.getStartY());
- newTransect.setEndX(transect.getEndX());
- newTransect.setEndY(transect.getEndY());
- newTransect.setNbTimes(transect.getNbTimes());
- newTransect.setGraphicIndex(graphicIndex);
-
- result++;
-
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Create new transect %1$s" +
- "(graphicIndex = %2$d)",
- newTransect.getName(),
- graphicIndex)
- );
- }
-
- } else {
-
- existTransect.setGraphicIndex(graphicIndex);
-
- if (logger.isWarnEnabled()) {
- logger.warn(String.format("The transect %1$s already " +
- "exists and will be ignored " +
- "(graphicIndex = %2$d)",
- existTransect.getName(),
- graphicIndex)
- );
- }
- }
- }
-
- transaction.commitTransaction();
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- return result;
- }
-
public String createTransect(Transect transect) {
Preconditions.checkArgument(transect != null);
@@ -525,88 +533,88 @@
return result;
}
- public int importStrates(String campaignId, Iterable<Strate> strates) {
+// public int importStrates(String campaignId, Iterable<Strate> strates) {
+//
+// int result = 0;
+//
+// TopiaContext transaction = persistence.beginTransaction();
+// try {
+//
+// CampaignDAO campaignDAO =
+// SammoaDAOHelper.getCampaignDAO(transaction);
+//
+// Campaign campaign = campaignDAO.findByTopiaId(campaignId);
+// Preconditions.checkArgument(campaign != null,
+// "The topiaId : " + campaignId + " doesn't match any existing campaign");
+//
+// StrateDAO strateDAO = SammoaDAOHelper.getStrateDAO(transaction);
+// SectorDAO sectorDAO = SammoaDAOHelper.getSectorDAO(transaction);
+//
+// // Retrieve directly all sectors to avoid multiple select queries to find sectors
+// List<Sector> sectors = sectorDAO.findAllByCampaign(campaign);
+// Map<Integer, Sector> sectorMap =
+// Maps.newHashMap(Maps.uniqueIndex(sectors, Sectors.toSectorNumber()));
+//
+// for (Strate strate : strates) {
+//
+// StrateType strateType = strate.getStrateType();
+// Sector sector = strate.getSector();
+// int sectorNumber = sector.getSectorNumber();
+//
+// Strate existStrate;
+//
+// // Create sector if necessary
+// Sector existSector = sectorMap.get(sectorNumber);
+// if (existSector == null) {
+//
+// existSector = sectorDAO.createByNaturalId(sectorNumber, campaign);
+// existSector.setName(sector.getName());
+// sectorMap.put(sectorNumber, existSector);
+//
+// existStrate = null;
+//
+// } else {
+//
+// // Find existing strate only if sector is not created
+// existStrate = strateDAO.findByNaturalId(strateType, existSector);
+// }
+//
+// // If the existing strate is null, create it otherwise ignore
+// if (existStrate == null) {
+//
+// Strate newStrate = strateDAO.createByNaturalId(strateType, existSector);
+// newStrate.setCode(Strates.getCode(newStrate));
+// newStrate.setName(strate.getName());
+//
+// result++;
+//
+// if (logger.isDebugEnabled()) {
+// logger.debug(String.format("Create new strate %1$s",
+// newStrate.getCode())
+// );
+// }
+//
+// } else {
+//
+// if (logger.isWarnEnabled()) {
+// logger.warn(String.format("The strate %1$s already " +
+// "exists and will be ignored",
+// existStrate.getCode()));
+// }
+// }
+// }
+//
+// transaction.commitTransaction();
+//
+// } catch (TopiaException e) {
+// throw new TopiaRuntimeException(e);
+//
+// } finally {
+// persistence.endTransaction(transaction);
+// }
+// return result;
+// }
- int result = 0;
-
- TopiaContext transaction = persistence.beginTransaction();
- try {
-
- CampaignDAO campaignDAO =
- SammoaDAOHelper.getCampaignDAO(transaction);
-
- Campaign campaign = campaignDAO.findByTopiaId(campaignId);
- Preconditions.checkArgument(campaign != null,
- "The topiaId : " + campaignId + " doesn't match any existing campaign");
-
- StrateDAO strateDAO = SammoaDAOHelper.getStrateDAO(transaction);
- SectorDAO sectorDAO = SammoaDAOHelper.getSectorDAO(transaction);
-
- // Retrieve directly all sectors to avoid multiple select queries to find sectors
- List<Sector> sectors = sectorDAO.findAllByCampaign(campaign);
- Map<Integer, Sector> sectorMap =
- Maps.newHashMap(Maps.uniqueIndex(sectors, Sectors.toSectorNumber()));
-
- for (Strate strate : strates) {
-
- StrateType strateType = strate.getStrateType();
- Sector sector = strate.getSector();
- int sectorNumber = sector.getSectorNumber();
-
- Strate existStrate;
-
- // Create sector if necessary
- Sector existSector = sectorMap.get(sectorNumber);
- if (existSector == null) {
-
- existSector = sectorDAO.createByNaturalId(sectorNumber, campaign);
- existSector.setName(sector.getName());
- sectorMap.put(sectorNumber, existSector);
-
- existStrate = null;
-
- } else {
-
- // Find existing strate only if sector is not created
- existStrate = strateDAO.findByNaturalId(strateType, existSector);
- }
-
- // If the existing strate is null, create it otherwise ignore
- if (existStrate == null) {
-
- Strate newStrate = strateDAO.createByNaturalId(strateType, existSector);
- newStrate.setCode(Strates.getCode(newStrate));
- newStrate.setName(strate.getName());
-
- result++;
-
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Create new strate %1$s",
- newStrate.getCode())
- );
- }
-
- } else {
-
- if (logger.isWarnEnabled()) {
- logger.warn(String.format("The strate %1$s already " +
- "exists and will be ignored",
- existStrate.getCode()));
- }
- }
- }
-
- transaction.commitTransaction();
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- return result;
- }
-
public List<Observer> getAllObservers(Campaign campaign) {
List<Observer> result;
@@ -632,70 +640,76 @@
return result;
}
- public int importObservers(String campaignId, Reader reader) {
-
- TopiaContext transaction = persistence.beginTransaction();
- int result = 0;
- try {
-
- Campaign campaign = SammoaDAOHelper.getCampaignDAO(transaction).findByTopiaId(campaignId);
- Preconditions.checkNotNull(campaign);
-
- ObserverDAO observerDAO =
- SammoaDAOHelper.getObserverDAO(transaction);
-
- ObserverImportModel model = new ObserverImportModel(campaign);
-
- Import<Observer> importCsv = Import.newImport(model, reader);
-
- Iterator<Observer> it = importCsv.iterator();
- while (it.hasNext()) {
-
- Observer observer;
-
- observer = it.next();
-
- Observer observerExists =
- observerDAO.findByNaturalId(observer.getInitials(), observer.getCampaign());
-
- if (observerExists == null) {
-
- observerDAO.create(observer);
-
- result++;
-
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Create new observer %1$s " +
- "for campaign %2$s",
- observer.getInitials(),
- campaign.getCode()));
- }
-
- } else {
-
- observerExists.setEmail(observer.getEmail());
- observerExists.setFirstName(observer.getFirstName());
- observerExists.setLastName(observer.getLastName());
- observerExists.setOrganization(observer.getOrganization());
- observerExists.setPilot(observer.isPilot());
- observerDAO.update(observerExists);
-
- if (logger.isInfoEnabled()) {
- logger.info(String.format("The observer %1$s already " +
- "exists and is updated",
- observer.getInitials()));
- }
- }
- }
-
- transaction.commitTransaction();
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- return result;
- }
+// public int importObservers(String campaignId, File file) throws IOException {
+//
+// Reader reader = Files.newReader(file, Charsets.UTF_8);
+//
+// try {
+// int result = 0;
+// TopiaContext transaction = persistence.beginTransaction();
+// try {
+//
+// Campaign campaign = SammoaDAOHelper.getCampaignDAO(transaction).findByTopiaId(campaignId);
+// Preconditions.checkNotNull(campaign);
+//
+// ObserverDAO observerDAO =
+// SammoaDAOHelper.getObserverDAO(transaction);
+//
+// ObserverImportModel model = new ObserverImportModel(campaign);
+//
+// Import<Observer> importCsv = Import.newImport(model, reader);
+//
+// for (Observer anImportCsv : importCsv) {
+//
+// Observer observer;
+//
+// observer = anImportCsv;
+//
+// Observer observerExists =
+// observerDAO.findByNaturalId(observer.getInitials(), observer.getCampaign());
+//
+// if (observerExists == null) {
+//
+// observerDAO.create(observer);
+//
+// result++;
+//
+// if (logger.isDebugEnabled()) {
+// logger.debug(String.format("Create new observer %1$s " +
+// "for campaign %2$s",
+// observer.getInitials(),
+// campaign.getCode()));
+// }
+//
+// } else {
+//
+// observerExists.setEmail(observer.getEmail());
+// observerExists.setFirstName(observer.getFirstName());
+// observerExists.setLastName(observer.getLastName());
+// observerExists.setOrganization(observer.getOrganization());
+// observerExists.setPilot(observer.isPilot());
+// observerDAO.update(observerExists);
+//
+// if (logger.isInfoEnabled()) {
+// logger.info(String.format("The observer %1$s already " +
+// "exists and is updated",
+// observer.getInitials()));
+// }
+// }
+// }
+//
+// transaction.commitTransaction();
+//
+// } catch (TopiaException e) {
+// throw new TopiaRuntimeException(e);
+//
+// } finally {
+// persistence.endTransaction(transaction);
+// }
+// reader.close();
+// return result;
+// } finally {
+// IOUtils.closeQuietly(reader);
+// }
+// }
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -37,7 +37,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.swing.*;
+import javax.swing.KeyStroke;
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -54,9 +54,7 @@
*/
public class SammoaConfig implements Supplier<ApplicationConfig> {
- /**
- * Logger.
- */
+ /** Logger. */
private static final Logger logger = LoggerFactory.getLogger(SammoaConfig.class);
public static final String PROPERTY_START = "start";
@@ -81,9 +79,7 @@
public static final String PROPERTY_GPS_CONFIG = "gpsConfig";
- /**
- * Delegate application config object containing configuration.
- */
+ /** Delegate application config object containing configuration. */
protected final ApplicationConfig applicationConfig;
protected GpsConfig gpsConfig;
@@ -164,37 +160,27 @@
// return url;
// }
- /**
- * @return {@link SammoaConfigOption#LOG_FILE} value
- */
+ /** @return {@link SammoaConfigOption#LOG_FILE} value */
public File getLogFile() {
return applicationConfig.getOptionAsFile(SammoaConfigOption.LOG_FILE.key);
}
- /**
- * @return {@link SammoaConfigOption#UI_CONFIG_FILE} value
- */
+ /** @return {@link SammoaConfigOption#UI_CONFIG_FILE} value */
public File getUIConfigFile() {
return applicationConfig.getOptionAsFile(SammoaConfigOption.UI_CONFIG_FILE.key);
}
- /**
- * @return {@link SammoaConfigOption#VERSION} value
- */
+ /** @return {@link SammoaConfigOption#VERSION} value */
public Version getVersion() {
return applicationConfig.getOptionAsVersion(SammoaConfigOption.VERSION.key);
}
- /**
- * @return {@link SammoaConfigOption#SITE_URL} value
- */
+ /** @return {@link SammoaConfigOption#SITE_URL} value */
public URL getSiteUrl() {
return applicationConfig.getOptionAsURL(SammoaConfigOption.SITE_URL.key);
}
- /**
- * @return {@link SammoaConfigOption#LOCALE} value
- */
+ /** @return {@link SammoaConfigOption#LOCALE} value */
public Locale getLocale() {
return applicationConfig.getOption(Locale.class, SammoaConfigOption.LOCALE.key);
}
@@ -207,41 +193,31 @@
return _("sammoa.copyright.text", getVersion());
}
- /**
- * @return {@link SammoaConfigOption#DATA_DIRECTORY} value
- */
+ /** @return {@link SammoaConfigOption#DATA_DIRECTORY} value */
public File getDataDirectory() {
File result = getOrCreateDirectory(SammoaConfigOption.DATA_DIRECTORY);
return result;
}
- /**
- * @return {@link SammoaConfigOption#AUDIO_DIRECTORY} value
- */
+ /** @return {@link SammoaConfigOption#AUDIO_DIRECTORY} value */
public File getAudioDirectory() {
File result = getOrCreateDirectory(SammoaConfigOption.AUDIO_DIRECTORY);
return result;
}
- /**
- * @return {@link SammoaConfigOption#SYSTEM_ID} value
- */
+ /** @return {@link SammoaConfigOption#SYSTEM_ID} value */
public String getSystemId() {
String result = applicationConfig.getOption(SammoaConfigOption.SYSTEM_ID.key);
return result;
}
- /**
- * @return {@link SammoaConfigOption#FLIGHT_NUMBER} value
- */
+ /** @return {@link SammoaConfigOption#FLIGHT_NUMBER} value */
public Integer getFlightNumber() {
int result = applicationConfig.getOptionAsInt(SammoaConfigOption.FLIGHT_NUMBER.key);
return result;
}
- /**
- * @return {@link SammoaConfigOption#BACKGROUND_SHAPE_FILE} value
- */
+ /** @return {@link SammoaConfigOption#BACKGROUND_SHAPE_FILE} value */
public File getBackgroundShapeFile() {
File result = applicationConfig.getOptionAsFile(SammoaConfigOption.BACKGROUND_SHAPE_FILE.key);
// Preconditions.checkArgument(result.exists(), "File " + result.getAbsolutePath() + " doesn't exist");
@@ -273,17 +249,13 @@
// applicationConfig.setOption(SammoaConfigOption.BACKGROUND_SHAPE_FILE.key, String.valueOf(mapBaseShapeFile));
// }
- /**
- * @return {@link SammoaConfigOption#AUTO_COMMIT_DELAY} value
- */
+ /** @return {@link SammoaConfigOption#AUTO_COMMIT_DELAY} value */
public Long getAutoCommitDelay() {
long result = applicationConfig.getOptionAsLong(SammoaConfigOption.AUTO_COMMIT_DELAY.key);
return result;
}
- /**
- * @return {@link SammoaConfigOption#FLY_MODE} value
- */
+ /** @return {@link SammoaConfigOption#FLY_MODE} value */
public boolean isFlyMode() {
boolean result = applicationConfig.getOptionAsBoolean(SammoaConfigOption.FLY_MODE.key);
return result;
@@ -310,7 +282,7 @@
* Creates a directory given the configuration {@code option}.
*
* @param option the configuration option key which contains the location of
- * the directory to create
+ * the directory to create
* @return the created directory
*/
protected File getOrCreateDirectory(SammoaConfigOption option) {
@@ -335,6 +307,10 @@
return directory;
}
+ public File getCampaignDirectory() {
+ return new File(getDataDirectory(), "campaign");
+ }
+
/**
* All Sammoa configuration options.
*
@@ -401,9 +377,9 @@
),
/** The backgroud shape file to display the world */
BACKGROUND_SHAPE_FILE("background.shape.file",
- n_("sammoa.config.background.shape.file"),
- "shape/vmap_area_thin.shp",
- File.class
+ n_("sammoa.config.background.shape.file"),
+ "shape/vmap_area_thin.shp",
+ File.class
),
// /** The strates shape file */
// STRATE_SHAPE_FILE("strate.shape.file",
@@ -440,11 +416,11 @@
),
KEY_START("ui." + PROPERTY_START,
- _("sammoa.config.ui.start"),
- "ctrl pressed A",
- KeyStroke.class,
- false,
- false),
+ _("sammoa.config.ui.start"),
+ "ctrl pressed A",
+ KeyStroke.class,
+ false,
+ false),
KEY_STOP("ui." + PROPERTY_STOP,
_("sammoa.config.ui.stop"),
@@ -454,18 +430,18 @@
false),
KEY_BEGIN("ui." + PROPERTY_BEGIN,
- _("sammoa.config.ui.begin"),
- "pressed F5",
- KeyStroke.class,
- false,
- false),
+ _("sammoa.config.ui.begin"),
+ "pressed F5",
+ KeyStroke.class,
+ false,
+ false),
KEY_END("ui." + PROPERTY_END,
- _("sammoa.config.ui.end"),
- "pressed F9",
- KeyStroke.class,
- false,
- false),
+ _("sammoa.config.ui.end"),
+ "pressed F9",
+ KeyStroke.class,
+ false,
+ false),
KEY_NEXT("ui." + PROPERTY_NEXT,
_("sammoa.config.ui.next"),
@@ -475,39 +451,39 @@
false),
KEY_ADD("ui." + PROPERTY_ADD,
- _("sammoa.config.ui.add"),
- "pressed F7",
- KeyStroke.class,
- false,
- false),
+ _("sammoa.config.ui.add"),
+ "pressed F7",
+ KeyStroke.class,
+ false,
+ false),
KEY_LEFT_OBSERVATION("ui." + PROPERTY_LEFT_OBSERVATION,
- _("sammoa.config.ui.leftObservation"),
- "pressed F1",
- KeyStroke.class,
- false,
- false),
+ _("sammoa.config.ui.leftObservation"),
+ "pressed F1",
+ KeyStroke.class,
+ false,
+ false),
KEY_CENTER_OBSERVATION("ui." + PROPERTY_CENTER_OBSERVATION,
- _("sammoa.config.ui.centerObservation"),
- "pressed F3",
- KeyStroke.class,
- false,
- false),
+ _("sammoa.config.ui.centerObservation"),
+ "pressed F3",
+ KeyStroke.class,
+ false,
+ false),
KEY_RIGHT_OBSERVATION("ui." + PROPERTY_RIGHT_OBSERVATION,
- _("sammoa.config.ui.rightObservation"),
- "pressed F12",
- KeyStroke.class,
- false,
- false),
+ _("sammoa.config.ui.rightObservation"),
+ "pressed F12",
+ KeyStroke.class,
+ false,
+ false),
KEY_CIRCLE_BACK("ui." + PROPERTY_CIRCLE_BACK,
- _("sammoa.config.ui.circleBack"),
- "pressed F11",
- KeyStroke.class,
- false,
- false);
+ _("sammoa.config.ui.circleBack"),
+ "pressed F11",
+ KeyStroke.class,
+ false,
+ false);
/** Configuration key. */
private final String key;
@@ -547,6 +523,7 @@
Class<?> type) {
this(key, description, defaultValue, type, false, false);
}
+
@Override
public String getKey() {
return key;
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -24,8 +24,8 @@
*/
package fr.ulr.sammoa.application;
-import fr.ulr.sammoa.application.io.exportApplication.ExportApplicationService;
-import fr.ulr.sammoa.application.map.ExportMapService;
+import fr.ulr.sammoa.application.io.output.sammoa.ExportApplicationService;
+import fr.ulr.sammoa.application.io.output.map.ExportMapService;
import fr.ulr.sammoa.persistence.SammoaPersistence;
/**
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaTechnicalException.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaTechnicalException.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaTechnicalException.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -24,9 +24,7 @@
*/
package fr.ulr.sammoa.application;
-/**
- * @author sletellier <letellier(a)codelutin.com>
- */
+/** @author sletellier <letellier(a)codelutin.com> */
public class SammoaTechnicalException extends RuntimeException {
private static final long serialVersionUID = 1L;
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/DoubleToIntegerValueParser.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/DoubleToIntegerValueParser.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/DoubleToIntegerValueParser.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,42 +0,0 @@
-package fr.ulr.sammoa.application.csv;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import org.nuiton.util.csv.ValueParser;
-
-import java.text.ParseException;
-
-/**
- * Created: 26/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class DoubleToIntegerValueParser implements ValueParser<Integer> {
-
- @Override
- public Integer parse(String s) throws ParseException {
- Double value = Double.parseDouble(s);
- return value.intValue();
- }
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/ObserverImportModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/ObserverImportModel.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/ObserverImportModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,92 +0,0 @@
-package fr.ulr.sammoa.application.csv;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ulr.sammoa.persistence.Campaign;
-import fr.ulr.sammoa.persistence.Observer;
-import fr.ulr.sammoa.persistence.ObserverImpl;
-import org.nuiton.util.csv.Common;
-import org.nuiton.util.csv.ImportModel;
-import org.nuiton.util.csv.ImportableColumn;
-import org.nuiton.util.csv.ModelBuilder;
-import org.nuiton.util.csv.ValueParser;
-
-import java.text.ParseException;
-import java.util.List;
-
-/**
- * Created: 09/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class ObserverImportModel implements ImportModel<Observer> {
-
- protected Campaign campaign;
-
- public ObserverImportModel(Campaign campaign) {
- this.campaign = campaign;
- }
-
- @Override
- public char getSeparator() {
- return ';';
- }
-
- @Override
- public void pushCsvHeaderNames(List<String> strings) {
- }
-
- @Override
- public Observer newEmptyInstance() {
- return new ObserverImpl();
- }
-
- @Override
- public Iterable<ImportableColumn<Observer, Object>> getColumnsForImport() {
- ModelBuilder builder = new ModelBuilder();
- builder.newMandatoryColumn("CAMPAIGN", Observer.PROPERTY_CAMPAIGN, CAMPAIGN_VALUE_PARSER);
- builder.newMandatoryColumn("INITIALS", Observer.PROPERTY_INITIALS);
- builder.newMandatoryColumn("FIRST_NAME", Observer.PROPERTY_FIRST_NAME);
- builder.newMandatoryColumn("LAST_NAME", Observer.PROPERTY_LAST_NAME);
- builder.newMandatoryColumn("ORGANIZATION", Observer.PROPERTY_ORGANIZATION);
- builder.newMandatoryColumn("EMAIL", Observer.PROPERTY_EMAIL);
- builder.newMandatoryColumn("PILOT", Observer.PROPERTY_PILOT, Common.BOOLEAN);
- return builder.getColumnsForImport();
- }
-
- protected ValueParser<Campaign> CAMPAIGN_VALUE_PARSER = new ValueParser<Campaign>() {
-
- @Override
- public Campaign parse(String s) throws ParseException {
- Campaign result;
- if (s.equals(campaign.getCode())) {
- result = campaign;
- } else {
- throw new IllegalArgumentException(
- String.format("The current campaign is %1$s and not %2$s", campaign.getCode(), s));
- }
- return result;
- }
- };
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/SpeciesImportModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/SpeciesImportModel.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/SpeciesImportModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,91 +0,0 @@
-package fr.ulr.sammoa.application.csv;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ulr.sammoa.persistence.Region;
-import fr.ulr.sammoa.persistence.Species;
-import fr.ulr.sammoa.persistence.SpeciesImpl;
-import org.nuiton.util.csv.ImportModel;
-import org.nuiton.util.csv.ImportableColumn;
-import org.nuiton.util.csv.ModelBuilder;
-import org.nuiton.util.csv.ValueParser;
-
-import java.text.ParseException;
-import java.util.List;
-
-/**
- * Created: 17/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class SpeciesImportModel implements ImportModel<Species> {
-
- protected Region region;
-
- public SpeciesImportModel(Region region) {
- this.region = region;
- }
-
- @Override
- public char getSeparator() {
- return ';';
- }
-
- @Override
- public void pushCsvHeaderNames(List<String> strings) {
- }
-
- @Override
- public Species newEmptyInstance() {
- return new SpeciesImpl();
- }
-
- @Override
- public Iterable<ImportableColumn<Species, Object>> getColumnsForImport() {
- ModelBuilder builder = new ModelBuilder();
- builder.newMandatoryColumn("REGION", Species.PROPERTY_REGION, REGION_VALUE_PARSER);
- builder.newMandatoryColumn("CODE", Species.PROPERTY_CODE);
- builder.newMandatoryColumn("NOM_COMM", Species.PROPERTY_COMMON_NAME);
- builder.newMandatoryColumn("NOM_LATIN", Species.PROPERTY_LATIN_NAME);
- builder.newMandatoryColumn("TYPE", Species.PROPERTY_TYPE);
- builder.newMandatoryColumn("FAMILLE", Species.PROPERTY_FAMILY);
- builder.newMandatoryColumn("GROUPE", Species.PROPERTY_GROUP_NAME);
- return builder.getColumnsForImport();
- }
-
- protected ValueParser<Region> REGION_VALUE_PARSER = new ValueParser<Region>() {
-
- @Override
- public Region parse(String s) throws ParseException {
- Region result;
- if (s.equals(region.getCode())) {
- result = region;
- } else {
- throw new IllegalArgumentException(
- String.format("The current region is %1$s and not %2$s", region.getCode(), s));
- }
- return result;
- }
- };
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateImportModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateImportModel.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateImportModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,91 +0,0 @@
-package fr.ulr.sammoa.application.csv;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ulr.sammoa.persistence.Sector;
-import fr.ulr.sammoa.persistence.SectorImpl;
-import fr.ulr.sammoa.persistence.Strate;
-import fr.ulr.sammoa.persistence.StrateImpl;
-import org.nuiton.util.csv.ImportModel;
-import org.nuiton.util.csv.ImportableColumn;
-import org.nuiton.util.csv.ModelBuilder;
-
-import java.util.List;
-
-/**
- * Created: 25/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class StrateImportModel implements ImportModel<Strate> {
-
- // 0 : Nom
- // 1 : Area (not used)
- // 2 : Shape_Leng (not used)
- // 3 : Shape_Area (not used)
- // 4 : Secteur (name)
- // 5 : type_strat (string) for StrateType (code match)
- // 6 : ID_Secteur (double)
-
- @Override
- public char getSeparator() {
- return ' ';
- }
-
- @Override
- public void pushCsvHeaderNames(List<String> strings) {
- }
-
- @Override
- public Strate newEmptyInstance() {
- Strate result = new StrateImpl();
- result.setSector(new SectorImpl());
- return result;
- }
-
- @Override
- public Iterable<ImportableColumn<Strate, Object>> getColumnsForImport() {
- ModelBuilder builder = new ModelBuilder();
- builder.newMandatoryColumn("Nom",
- Strate.PROPERTY_NAME
- );
- builder.newMandatoryColumn("Secteur",
- Strate.PROPERTY_SECTOR
- + "." + Sector.PROPERTY_NAME
- );
- builder.newMandatoryColumn("type_strat",
- Strate.PROPERTY_STRATE_TYPE,
- new StrateTypeValueParser()
- );
- builder.newMandatoryColumn("ID_Secteur",
- Strate.PROPERTY_SECTOR
- + "." + Sector.PROPERTY_SECTOR_NUMBER,
- new DoubleToIntegerValueParser()
- );
- builder.newIgnoredColumn("Area");
- builder.newIgnoredColumn("Shape_Area");
- builder.newIgnoredColumn("Shape_Leng");
- return builder.getColumnsForImport();
- }
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateTypeValueParser.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateTypeValueParser.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateTypeValueParser.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,44 +0,0 @@
-package fr.ulr.sammoa.application.csv;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ulr.sammoa.persistence.StrateType;
-import org.nuiton.util.csv.ValueParser;
-
-import java.text.ParseException;
-
-/**
- * Created: 26/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class StrateTypeValueParser implements ValueParser<StrateType> {
-
- @Override
- public StrateType parse(String s) throws ParseException {
- char strateCode = s.charAt(0);
- StrateType result = StrateType.valueOfCode(strateCode);
- return result;
- }
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/TransectImportModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/TransectImportModel.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/TransectImportModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,119 +0,0 @@
-package fr.ulr.sammoa.application.csv;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ulr.sammoa.persistence.Sector;
-import fr.ulr.sammoa.persistence.SectorImpl;
-import fr.ulr.sammoa.persistence.Strate;
-import fr.ulr.sammoa.persistence.StrateImpl;
-import fr.ulr.sammoa.persistence.Transect;
-import fr.ulr.sammoa.persistence.TransectImpl;
-import org.nuiton.util.csv.Common;
-import org.nuiton.util.csv.ImportModel;
-import org.nuiton.util.csv.ImportableColumn;
-import org.nuiton.util.csv.ModelBuilder;
-
-import java.util.List;
-
-/**
- * Created: 25/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class TransectImportModel implements ImportModel<Transect> {
-
- // 0 : Length
- // 1 : TR_ID used as name
- // 2 : Xstart
- // 3 : Ystart
- // 4 : Xend
- // 5 : Yend
- // 6 : Passage (double) used for nbTimes
- // 7 : SECTEUR (double) use as sectorNumber
- // 8 : STRATE (string) for StrateType (code match)
- // 9 : Shape_Leng (not used)
-
- @Override
- public char getSeparator() {
- return ' ';
- }
-
- @Override
- public void pushCsvHeaderNames(List<String> strings) {
- }
-
- @Override
- public Transect newEmptyInstance() {
- Transect result = new TransectImpl();
- Strate strate = new StrateImpl();
- result.setStrate(strate);
- strate.setSector(new SectorImpl());
- return result;
- }
-
- @Override
- public Iterable<ImportableColumn<Transect, Object>> getColumnsForImport() {
- ModelBuilder builder = new ModelBuilder();
- builder.newMandatoryColumn("Length",
- Transect.PROPERTY_LENGTH,
- Common.DOUBLE_PRIMITIVE
- );
- builder.newMandatoryColumn("TR_ID",
- Transect.PROPERTY_NAME)
- ;
- builder.newMandatoryColumn("Xstart",
- Transect.PROPERTY_START_X,
- Common.DOUBLE_PRIMITIVE
- );
- builder.newMandatoryColumn("Ystart",
- Transect.PROPERTY_START_Y,
- Common.DOUBLE_PRIMITIVE
- );
- builder.newMandatoryColumn("Xend",
- Transect.PROPERTY_END_X,
- Common.DOUBLE_PRIMITIVE
- );
- builder.newMandatoryColumn("Yend",
- Transect.PROPERTY_END_Y,
- Common.DOUBLE_PRIMITIVE
- );
- builder.newMandatoryColumn("SECTEUR",
- Transect.PROPERTY_STRATE + "."
- + Strate.PROPERTY_SECTOR + "."
- + Sector.PROPERTY_SECTOR_NUMBER,
- new DoubleToIntegerValueParser()
- );
- builder.newMandatoryColumn("STRATE",
- Transect.PROPERTY_STRATE + "."
- + Strate.PROPERTY_STRATE_TYPE,
- new StrateTypeValueParser()
- );
- builder.newMandatoryColumn("Passage",
- Transect.PROPERTY_NB_TIMES,
- new DoubleToIntegerValueParser()
- );
- builder.newIgnoredColumn("Shape_Leng");
- return builder.getColumnsForImport();
- }
-}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceManager.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceManager.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceManager.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -45,9 +45,7 @@
*/
void start();
- /**
- * Stop the device session
- */
+ /** Stop the device session */
void stop();
/**
@@ -57,24 +55,16 @@
*/
void close() throws DeviceTechnicalException;
- /**
- * @return the DeviceState
- */
+ /** @return the DeviceState */
DeviceState getState();
- /**
- * @param listener DeviceStateListener to add
- */
+ /** @param listener DeviceStateListener to add */
void addDeviceStateListener(DeviceStateListener listener);
- /**
- * @param listener DeviceStateListener to remove
- */
+ /** @param listener DeviceStateListener to remove */
void removeDeviceStateListener(DeviceStateListener listener);
- /**
- * @return all the listeners
- */
+ /** @return all the listeners */
Set<DeviceStateListener> getDeviceStateListeners();
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceState.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceState.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceState.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -26,7 +26,7 @@
/**
* Enumeration to represent device (gps, audio) state.
- *
+ *
* @author echatellier
*/
public enum DeviceState {
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceTechnicalException.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceTechnicalException.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/DeviceTechnicalException.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -24,9 +24,7 @@
*/
package fr.ulr.sammoa.application.device;
-/**
- * @author fdesbois <fdesbois(a)codelutin.com>
- */
+/** @author fdesbois <fdesbois(a)codelutin.com> */
public class DeviceTechnicalException extends RuntimeException {
private static final long serialVersionUID = 1L;
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorder.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorder.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorder.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -38,9 +38,7 @@
*/
public interface AudioRecorder extends DeviceManager {
- /**
- * @return the {@link AudioFileFormat.Type} used (default is WAV)
- */
+ /** @return the {@link AudioFileFormat.Type} used (default is WAV) */
AudioFileFormat.Type getOutputType();
/**
@@ -48,7 +46,7 @@
* previous recording will be stopped in {@code delaySeconds}. The delay is
* useful to avoid recording lost or too quick between two files.
*
- * @param outputFile File to record
+ * @param outputFile File to record
* @param delaySeconds Delay for previous recording
*/
void record(File outputFile, long delaySeconds);
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderDefault.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderDefault.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderDefault.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -97,9 +97,9 @@
// // For debug purpose
// private int count;
-
+
protected DeviceState state;
-
+
protected Set<DeviceStateListener> listeners;
public AudioRecorderDefault() {
@@ -168,7 +168,7 @@
logger.info("Open the audio line");
}
- DataLine.Info info = new DataLine.Info(TargetDataLine.class, audioFormat);
+ DataLine.Info info = new DataLine.Info(TargetDataLine.class, audioFormat);
try {
dataLine = (TargetDataLine) AudioSystem.getLine(info);
dataLine.open(audioFormat);
@@ -190,7 +190,7 @@
setState(DeviceState.NO_DEVICE, null);
throw new DeviceTechnicalException(this, "Can't open audio device", e);
- } catch (SecurityException e) {
+ } catch (SecurityException e) {
setState(DeviceState.NO_DEVICE, null);
throw new DeviceTechnicalException(this, "Can't open audio device", e);
@@ -253,7 +253,7 @@
currentRecorder = recorder2;
// Stop recorder2 if recording and start recorder1
- } else if (currentRecorder == recorder2) {
+ } else if (currentRecorder == recorder2) {
if (recorder2.isRecording()) {
recorder2.stop(delaySeconds);
@@ -393,7 +393,7 @@
save();
}
}
-
+
protected class StopTask extends TimerTask {
@Override
@@ -512,8 +512,8 @@
} catch (IOException e) {
logger.error("Can't record file {}", outputFilePath, e);
audioRecorder.setState(DeviceState.ERROR,
- new DeviceTechnicalException(audioRecorder,
- "Error on saving file " + outputFilePath, e));
+ new DeviceTechnicalException(audioRecorder,
+ "Error on saving file " + outputFilePath, e));
} finally {
try {
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderMock.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderMock.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderMock.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -40,7 +40,7 @@
* @author fdesbois <desbois(a)codelutin.com>
*/
public class AudioRecorderMock implements AudioRecorder {
-
+
@Override
public DeviceState getState() {
return DeviceState.NO_DEVICE;
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -44,19 +44,20 @@
* will be called on start if state is still {@link DeviceState#NO_DEVICE}.
* The method {@link #getCurrentLocation()} must return null if the location doesn't
* change or the GPS is down.
- *
+ * <p/>
* Created: 02/07/12
*
* @author fdesbois <desbois(a)codelutin.com>
- * @since 0.2
* @see FakeGpsHandler
* @see GpsHandlerGpsylon
+ * @since 0.2
*/
public abstract class BaseGpsHandler implements GpsHandler {
private static final Logger logger = LoggerFactory.getLogger(BaseGpsHandler.class);
protected Set<DeviceStateListener> deviceStateListeners;
+
protected Set<GpsLocationListener> gpsLocationListeners;
/** To test if connection to device is effective. */
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -39,19 +39,19 @@
* à partir du point 0, 0.
*/
public class FakeGpsHandler extends BaseGpsHandler {
-
+
private static final Logger logger = LoggerFactory.getLogger(FakeGpsHandler.class);
-
+
public static final int MAX_POINTS = 100;
-
+
protected GeoPoint startingPoint;
protected GeoPoint currentLocation;
-
+
protected Thread thread;
public FakeGpsHandler(GpsConfig config) {
- this(config, new GeoPointImpl(46.164139,-1.150503));
+ this(config, new GeoPointImpl(46.164139, -1.150503));
}
public FakeGpsHandler(GpsConfig config, GeoPoint origin) {
@@ -118,7 +118,7 @@
@Override
protected void finalize() throws Throwable {
-
+
if (thread != null) {
thread.interrupt();
thread = null;
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsConfig.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsConfig.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsConfig.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -45,13 +45,11 @@
this.applicationConfig.loadDefaultOptions(GpsConfigOption.values());
}
- /**
- * @return {@link GpsConfigOption#GPS_HANDLER} value
- */
+ /** @return {@link GpsConfigOption#GPS_HANDLER} value */
public Class<? extends GpsHandler> getGpsHandlerClass() {
Class<?> result = applicationConfig.getOptionAsClass(GpsConfigOption.GPS_HANDLER.key);
Preconditions.checkArgument(GpsHandler.class.isAssignableFrom(result),
- "The class " + result.getSimpleName() + " is not a GpsHandler implementation");
+ "The class " + result.getSimpleName() + " is not a GpsHandler implementation");
return (Class<? extends GpsHandler>) result;
}
@@ -65,33 +63,25 @@
newValue.getName());
}
- /**
- * @return {@link GpsConfigOption#GPS_CHECK_PERIOD} value
- */
+ /** @return {@link GpsConfigOption#GPS_CHECK_PERIOD} value */
public int getCheckPeriod() {
int result = applicationConfig.getOptionAsInt(GpsConfigOption.GPS_CHECK_PERIOD.key);
return result;
}
- /**
- * @return {@link GpsConfigOption#GPS_TIMEOUT} value
- */
+ /** @return {@link GpsConfigOption#GPS_TIMEOUT} value */
public int getTimeout() {
int result = applicationConfig.getOptionAsInt(GpsConfigOption.GPS_TIMEOUT.key);
return result;
}
- /**
- * @return {@link GpsConfigOption#GPS_DEVICE} value
- */
+ /** @return {@link GpsConfigOption#GPS_DEVICE} value */
public String getDevice() {
String result = applicationConfig.getOption(GpsConfigOption.GPS_DEVICE.key);
return result;
}
- /**
- * @return {@link GpsConfigOption#GPS_SPEED} value
- */
+ /** @return {@link GpsConfigOption#GPS_SPEED} value */
public int getSpeed() {
int result = applicationConfig.getOptionAsInt(GpsConfigOption.GPS_SPEED.key);
return result;
@@ -101,33 +91,33 @@
/** Implementation class for GpsHandler */
GPS_HANDLER("gps.handler",
- n_("sammoa.config.gps.handler"),
- GpsHandlerGpsylon.class.getName(),
- Class.class
+ n_("sammoa.config.gps.handler"),
+ GpsHandlerGpsylon.class.getName(),
+ Class.class
),
/** Period time in seconds for each check of the gps to update location */
GPS_CHECK_PERIOD("gps.check.period",
- n_("sammoa.config.gps.check.period"),
- "2",
- Integer.class
+ n_("sammoa.config.gps.check.period"),
+ "2",
+ Integer.class
),
/** Time in seconds before timeout (ERROR, NO_DEVICE) */
GPS_TIMEOUT("gps.timeout",
- n_("sammoa.config.gps.timeout"),
- "10",
- Integer.class
+ n_("sammoa.config.gps.timeout"),
+ "10",
+ Integer.class
),
/** GPS Device name ex: /dev/ttyUSB0 or /dev/ttyS1 or COM5 */
GPS_DEVICE("gps.device",
- n_("sammoa.config.gps.device"),
- "COM1",
- String.class
+ n_("sammoa.config.gps.device"),
+ "COM1",
+ String.class
),
/** GPS data speed */
GPS_SPEED("gps.speed",
- n_("sammoa.config.gps.speed"),
- "4800",
- Integer.class
+ n_("sammoa.config.gps.speed"),
+ "4800",
+ Integer.class
);
/** Configuration key. */
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandler.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandler.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandler.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -29,31 +29,23 @@
import java.util.Set;
-/**
- * Représente l'accès à un périphérique GPS.
- */
+/** Représente l'accès à un périphérique GPS. */
public interface GpsHandler extends DeviceManager {
/**
* Retourne la position courante du GPS.
- *
+ *
* @return la position courante selon le GPS ou {@code null} si elle ne peut
- * pas être obtenue
+ * pas être obtenue
*/
GeoPoint getCurrentLocation();
- /**
- * @param gpsLocationListener GpsLocationListener to add
- */
+ /** @param gpsLocationListener GpsLocationListener to add */
void addGpsLocationListener(GpsLocationListener gpsLocationListener);
- /**
- * @param gpsLocationListener GpsLocationListener to remove
- */
+ /** @param gpsLocationListener GpsLocationListener to remove */
void removeGpsLocationListener(GpsLocationListener gpsLocationListener);
- /**
- * @return all GpsLocationListener
- */
+ /** @return all GpsLocationListener */
Set<GpsLocationListener> getGpsLocationListeners();
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandlerGpsylon.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandlerGpsylon.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandlerGpsylon.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -31,7 +31,11 @@
import fr.ulr.sammoa.persistence.GeoPointImpl;
import fr.ulr.sammoa.persistence.GeoPoints;
import gnu.io.CommPortIdentifier;
-import org.dinopolis.gpstool.gpsinput.*;
+import org.dinopolis.gpstool.gpsinput.GPSDataProcessor;
+import org.dinopolis.gpstool.gpsinput.GPSDevice;
+import org.dinopolis.gpstool.gpsinput.GPSException;
+import org.dinopolis.gpstool.gpsinput.GPSPosition;
+import org.dinopolis.gpstool.gpsinput.GPSSerialDevice;
import org.dinopolis.gpstool.gpsinput.nmea.SafeGPSNmeaDataProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -169,9 +173,9 @@
// }
double latitude = lastPosition != null
- ? lastPosition.getLatitude() : GeoPoints.EMPTY_COORDINATE;
+ ? lastPosition.getLatitude() : GeoPoints.EMPTY_COORDINATE;
double longitude = lastPosition != null
- ? lastPosition.getLongitude() : GeoPoints.EMPTY_COORDINATE;
+ ? lastPosition.getLongitude() : GeoPoints.EMPTY_COORDINATE;
GeoPoint result = new GeoPointImpl(latitude, longitude);
result.setAltitude(lastAltitude);
@@ -211,17 +215,17 @@
if (GeoPoints.isCoordinatesEmpty(location)) {
result = new DeviceTechnicalException(this,
- "GPS is not ready, turn it on or wait for it to find satellites");
+ "GPS is not ready, turn it on or wait for it to find satellites");
} else {
if (lastNumberSatellites == 0) {
result = new DeviceTechnicalException(this,
- "GPS signal lost, there is no available satellite found");
+ "GPS signal lost, there is no available satellite found");
} else {
result = new DeviceTechnicalException(this,
- "GPS signal lost, please check the connection port");
+ "GPS signal lost, please check the connection port");
}
}
}
@@ -255,7 +259,7 @@
* Si l'on recoit des evenements, c'est que le gps fonctionne.
* Il sont envoyé par le traitement des flux NMEA et propagé par le
* {@code GPSDataChangeListener}.
- *
+ * <p/>
* Properties available:
* <ul>
* <li>LOCATION: the value is a GPSPosition object
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsLocationListener.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsLocationListener.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsLocationListener.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -24,14 +24,12 @@
*/
package fr.ulr.sammoa.application.device.gps;
-/**
- * DP Observateur.
- */
+/** DP Observateur. */
public interface GpsLocationListener {
/**
* Update GPS location.
- *
+ *
* @param event new event
*/
void locationChanged(GpsLocationEvent event);
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -49,41 +49,32 @@
*/
public interface FlightController {
- /**
- * @return the {@link FlightState}
- */
+ /** @return the {@link FlightState} */
FlightState getState();
- /**
- * @return the {@link AudioRecorderDefault} used to save audio files
- */
+ /** @return the {@link AudioRecorderDefault} used to save audio files */
AudioRecorder getAudioRecorder();
/**
* @return the {@link GpsHandler} used to retrieve GPS {@link GeoPoint} and
- * save them.
+ * save them.
*/
GpsHandler getGpsHandler();
/**
* @param config GpsConfig to initialize the Gps
- * @exception fr.ulr.sammoa.application.device.DeviceTechnicalException if the gps device can't be opened properly
+ * @throws fr.ulr.sammoa.application.device.DeviceTechnicalException
+ * if the gps device can't be opened properly
*/
void openGpsDevice(GpsConfig config) throws DeviceTechnicalException;
- /**
- * @exception DeviceTechnicalException if the audio device can't be opened properly
- */
+ /** @throws DeviceTechnicalException if the audio device can't be opened properly */
void openAudioDevice() throws DeviceTechnicalException;
- /**
- * @return The current {@link Route}
- */
+ /** @return The current {@link Route} */
Route getCurrentRoute();
- /**
- * @return The next {@link TransectFlight}
- */
+ /** @return The next {@link TransectFlight} */
TransectFlight getNextTransect();
/**
@@ -97,18 +88,18 @@
/**
* Start operation. This will set the {@code beginDate} of the flight, then
- * a new {@link RouteType#TRANSIT} route is created. The state is now
- * {@link FlightState#OFF_EFFORT}.
+ * a new {@link RouteType#TRANSIT} route is created. The state is now
+ * {@link FlightState#OFF_EFFORT}.
* <p/>
- * This operation is called when the plane take off, for the moment no
- * observation is done and the audio is not recording. The GPS is enabled
+ * This operation is called when the plane take off, for the moment no
+ * observation is done and the audio is not recording. The GPS is enabled
* and will send data to display the plane tracking.
* <p/>
* After a start(), you can call :
- * <ul>
- * <li>{@link #begin()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #stop()}</li>
+ * <ul>
+ * <li>{@link #begin()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #stop()}</li>
* </ul>
*/
void start();
@@ -116,35 +107,35 @@
/**
* Select a {@code nextTransect} to use for the next {@link RouteType#LEG}
* when {@link #begin()} method is called.
- *
+ *
* @param nextTransect the TransectFlight to use as next one
*/
void setNextTransect(TransectFlight nextTransect);
/**
* Begin operation. A new {@link RouteType#LEG} is created based on GPS
- * current date and next transect that becomes the current one. The state
+ * current date and next transect that becomes the current one. The state
* is now {@link FlightState#ON_EFFORT}.
* <p/>
* This operation is called when the plane arrives on a transect and observation
* need to begin. Conditions could be set on the currentRoute (TRANSIT) and
- * will be copied on the new LEG. This operation is also called when a
+ * will be copied on the new LEG. This operation is also called when a
* CIRCLE_BACK is finished to resume effort on the current transect.
* <p/>
* After a begin(), you can call :
* <ul>
- * <li>{@link #add()}</li>
- * <li>{@link #circleBack(Observation)}</li>
- * <li>{@link #next()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #end()}</li>
- * <li>{@link #stop()}</li>
+ * <li>{@link #add()}</li>
+ * <li>{@link #circleBack(Observation)}</li>
+ * <li>{@link #next()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #end()}</li>
+ * <li>{@link #stop()}</li>
* </ul>
*/
void begin();
/**
- * Circle Back operation. A new {@link RouteType#CIRCLE_BACK} is created
+ * Circle Back operation. A new {@link RouteType#CIRCLE_BACK} is created
* based on GPS current date and attached to the {@code observation}. The
* next transect will be the current one to allow begin() to not change the
* transect. The state is now {@link FlightState#OFF_EFFORT}.
@@ -153,17 +144,17 @@
* the plane will do a circle back. In this case, we are not on effort
* anymore, but we can continue creating observations with the appropriate
* status. The {@code observation} is marked as {@link ObservationStatus#CIRCLE_BACK}.
- * After the circle back, we use {@link #begin()} operation to continue effort
- * with a new LEG.
+ * After the circle back, we use {@link #begin()} operation to continue effort
+ * with a new LEG.
* <p/>
* After a circleBack(), you can call :
* <ul>
- * <li>circleBack(Observation)</li>
- * <li>{@link #begin()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #stop()}</li>
+ * <li>circleBack(Observation)</li>
+ * <li>{@link #begin()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #stop()}</li>
* </ul>
- *
+ *
* @param observation The observation cause of the circle back
* @see ObservationStatus
*/
@@ -173,17 +164,17 @@
* Add operation. A new {@link RouteType#LEG} is created based on GPS current
* date and current transect. The next transect and state doesn't change.
* <p/>
- * This operation is called when the observation conditions has changed,
+ * This operation is called when the observation conditions has changed,
* to mark this, a LEG is created with a GPS point and a new audio file. *
* <p/>
* After a add(), you can call :
* <ul>
- * <li>add()</li>
- * <li>{@link #circleBack(Observation)}</li>
- * <li>{@link #next()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #end()}</li>
- * <li>{@link #stop()}</li>
+ * <li>add()</li>
+ * <li>{@link #circleBack(Observation)}</li>
+ * <li>{@link #next()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #end()}</li>
+ * <li>{@link #stop()}</li>
* </ul>
*/
void add();
@@ -191,42 +182,42 @@
/**
* Next operation. It's a shortcut to end the previous effort and begin the
* next one on the next transect. This will call {@link #end()} if necessary
- * and then {@link #begin()}.
+ * and then {@link #begin()}.
* <p/>
* After a next(), you can call :
* <ul>
- * <li>add()</li>
- * <li>{@link #circleBack(Observation)}</li>
- * <li>{@link #next()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #end()}</li>
- * <li>{@link #stop()}</li>
+ * <li>add()</li>
+ * <li>{@link #circleBack(Observation)}</li>
+ * <li>{@link #next()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #end()}</li>
+ * <li>{@link #stop()}</li>
* </ul>
*/
void next();
/**
* Observation operation. It's the creation of an observation for the
- * given {@code position}. The observer will be retrieved from the
- * current route and the time is synchronized with the GPS or with the
+ * given {@code position}. The observer will be retrieved from the
+ * current route and the time is synchronized with the GPS or with the
* system if not responding.
- *
+ *
* @param position Position of the observer that make the observation
*/
void observation(Position position);
/**
* End operation. This will create a new {@link RouteType#TRANSIT} route and
- * put the next transect depends on the plane list. The audio is still
+ * put the next transect depends on the plane list. The audio is still
* recording for a few minutes and the state becomes {@link FlightState#OFF_EFFORT}
* <p/>
- * This operation is called when an effort/transect is finished.
+ * This operation is called when an effort/transect is finished.
* <p/>
* After a end(), you can call :
- * <ul>
- * <li>{@link #begin()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #stop()}</li>
+ * <ul>
+ * <li>{@link #begin()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #stop()}</li>
* </ul>
*/
void end();
@@ -248,38 +239,24 @@
*/
void close();
- /**
- * @return true if {@link FlightState#WAITING}
- */
+ /** @return true if {@link FlightState#WAITING} */
boolean isWaiting();
- /**
- * @return true if {@link FlightState#ENDED}
- */
+ /** @return true if {@link FlightState#ENDED} */
boolean isEnded();
- /**
- * @return true if {@link FlightState#ON_EFFORT}
- */
+ /** @return true if {@link FlightState#ON_EFFORT} */
boolean isOnEffort();
- /**
- * @return true if {@link FlightState#OFF_EFFORT}
- */
+ /** @return true if {@link FlightState#OFF_EFFORT} */
boolean isOffEffort();
- /**
- * @return true if {@link FlightState#OFF_EFFORT} or {@link FlightState#ON_EFFORT}
- */
+ /** @return true if {@link FlightState#OFF_EFFORT} or {@link FlightState#ON_EFFORT} */
boolean isRunning();
- /**
- * @param listener FlightControllerListener to add
- */
+ /** @param listener FlightControllerListener to add */
void addListener(FlightControllerListener listener);
- /**
- * @param listener FlightControllerListener to remove
- */
+ /** @param listener FlightControllerListener to remove */
void removeListener(FlightControllerListener listener);
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -39,6 +39,10 @@
import fr.ulr.sammoa.application.device.gps.GpsHandler;
import fr.ulr.sammoa.application.device.gps.GpsLocationEvent;
import fr.ulr.sammoa.application.device.gps.GpsLocationListener;
+import fr.ulr.sammoa.application.io.CampaignStorage;
+import fr.ulr.sammoa.application.io.CampaignStorages;
+import fr.ulr.sammoa.application.io.FlightStorage;
+import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.FlightDAO;
import fr.ulr.sammoa.persistence.GeoPoint;
@@ -54,7 +58,6 @@
import fr.ulr.sammoa.persistence.SammoaDAOHelper;
import fr.ulr.sammoa.persistence.SammoaPersistence;
import fr.ulr.sammoa.persistence.TransectFlight;
-import org.apache.commons.lang3.time.DateUtils;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaRuntimeException;
@@ -103,10 +106,11 @@
protected Set<FlightControllerListener> listeners;
+ protected FlightStorage flightStorage;
+
// protected GeoPoint lastLocation;
- public FlightControllerDefault(SammoaContext context,
- Flight flight) {
+ public FlightControllerDefault(SammoaContext context, Flight flight) {
this.context = context;
this.flight = flight;
@@ -117,6 +121,11 @@
this.currentRoute = service.getLastRoute(flight);
this.lastTransect = service.getLastTransectDone(flight);
this.listeners = Sets.newHashSet();
+
+ Campaign campaign = flight.getCampaign();
+ CampaignStorage campaignStorage = CampaignStorages.getStorage(
+ context.getConfig(), campaign.getTopiaId());
+ flightStorage = campaignStorage.getFlightStorage(flight.getTopiaId());
}
@Override
@@ -256,10 +265,10 @@
public void init() {
Preconditions.checkState(gpsHandler != null,
- "The GpsHandler must be created using #openGpsDevice");
+ "The GpsHandler must be created using #openGpsDevice");
Preconditions.checkState(audioRecorder != null,
- "The AudioRecorder must be created using #openAudioDevice");
+ "The AudioRecorder must be created using #openAudioDevice");
if (initialized) {
if (logger.isWarnEnabled()) {
@@ -277,13 +286,13 @@
// Note that a flight can't finished by a leg, so effort not null
// implies that the flight is started and not ended
if (currentRoute != null
- && currentRoute.getRouteType() == RouteType.LEG) {
+ && currentRoute.getRouteType() == RouteType.LEG) {
state = FlightState.ON_EFFORT;
} else if (currentRoute != null
- && flight.getBeginDate() != null
- && flight.getEndDate() == null) {
+ && flight.getBeginDate() != null
+ && flight.getEndDate() == null) {
state = FlightState.OFF_EFFORT;
@@ -311,7 +320,7 @@
// Restart recording audio if onEffort or circleBack
if (state == FlightState.ON_EFFORT
- || currentRoute.getRouteType() == RouteType.CIRCLE_BACK) {
+ || currentRoute.getRouteType() == RouteType.CIRCLE_BACK) {
saveAudio(0);
}
@@ -324,7 +333,7 @@
long startTime = TimeLog.getTime();
Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
+ "The controller must be initialized before calling any action");
Preconditions.checkState(
isWaiting(), "You can call start() only if flight is waiting (not started, not ended)");
@@ -380,13 +389,13 @@
long startTime = TimeLog.getTime();
Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
+ "The controller must be initialized before calling any action");
Preconditions.checkState(
nextTransect == null || !nextTransect.isDeleted(), "You can't use a deleted transect as next value");
-
+
this.nextTransect = nextTransect;
-
+
// Fire transect changed
fireNextTransectChanged(nextTransect);
@@ -399,7 +408,7 @@
long startTime = TimeLog.getTime();
Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
+ "The controller must be initialized before calling any action");
Preconditions.checkState(
isOffEffort(), "You can call begin() only if flight is running (started, not ended, not on effort)");
@@ -409,13 +418,13 @@
"Call setNextTransect() method first");
TopiaContext transaction = persistence.beginTransaction();
- try {
-
+ try {
+
Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
-
+
// The next transect becomes the last one (or current in this case)
lastTransect = nextTransect;
-
+
// Create new LEG route
if (logger.isInfoEnabled()) {
logger.info(String.format("Create LEG [BEGIN] at %1$tH:%1$tM:%1$tS", currentDate));
@@ -440,12 +449,12 @@
fireStateChanged(state);
timeLog.log(startTime, "begin()", "Fired");
-
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
-
+
} finally {
- persistence.endTransaction(transaction);
+ persistence.endTransaction(transaction);
}
}
@@ -455,7 +464,7 @@
long startTime = TimeLog.getTime();
Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
+ "The controller must be initialized before calling any action");
Preconditions.checkState(
currentRoute != null
@@ -465,7 +474,7 @@
TopiaContext transaction = persistence.beginTransaction();
try {
-
+
Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
setObservationStatus(transaction, observation, ObservationStatus.CIRCLE_BACK);
@@ -494,10 +503,10 @@
fireStateChanged(state);
timeLog.log(startTime, "circleBack()", "Fired");
-
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
-
+
} finally {
persistence.endTransaction(transaction);
}
@@ -509,7 +518,7 @@
long startTime = TimeLog.getTime();
Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
+ "The controller must be initialized before calling any action");
Preconditions.checkState(
isOnEffort(), "You can call add() only if flight is on effort (started, not ended, on effort)");
@@ -535,10 +544,10 @@
fireRouteAdded(currentRoute);
timeLog.log(startTime, "add()", "Fired");
-
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
-
+
} finally {
persistence.endTransaction(transaction);
}
@@ -564,7 +573,7 @@
long startTime = TimeLog.getTime();
Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
+ "The controller must be initialized before calling any action");
Preconditions.checkState(
isRunning(), "You can call observation() only if flight is running (started, not ended)");
@@ -572,7 +581,7 @@
TopiaContext transaction = persistence.beginTransaction();
try {
GeoPoint location = gpsHandler.getCurrentLocation();
-
+
Date currentDate = saveGPS(transaction, location, flight);
ObserverPosition observer;
@@ -594,7 +603,7 @@
);
}
Observation observation = service.createObservation(transaction, flight, currentDate, observer);
-
+
transaction.commitTransaction();
startTime = timeLog.log(startTime, "observation()", "Commited");
@@ -602,12 +611,12 @@
fireObservationAdded(observation, location);
timeLog.log(startTime, "observation()", "Fired");
-
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
-
+
} finally {
- persistence.endTransaction(transaction);
+ persistence.endTransaction(transaction);
}
}
@@ -628,7 +637,7 @@
long startTime = TimeLog.getTime();
Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
+ "The controller must be initialized before calling any action");
Preconditions.checkState(
isOffEffort(), "You can call stop() only if flight is running (started, not ended, not on effort)");
@@ -656,7 +665,7 @@
nextTransect = null;
state = FlightState.ENDED;
-
+
transaction.commitTransaction();
startTime = timeLog.log(startTime, "stop()", "Commited");
@@ -667,15 +676,15 @@
fireStateChanged(state);
timeLog.log(startTime, "stop()", "Fired");
-
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
-
+
} finally {
persistence.endTransaction(transaction);
}
}
-
+
@Override
public void close() {
@@ -691,7 +700,7 @@
protected void doEndWithAudioDelay(long audioDelay) {
Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
+ "The controller must be initialized before calling any action");
Preconditions.checkState(
isOnEffort(), "You can call end() only if flight is on effort (started, not ended, on effort)");
@@ -716,7 +725,7 @@
fireRouteAdded(currentRoute);
fireNextTransectChanged(nextTransect);
fireStateChanged(state);
-
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
@@ -775,7 +784,7 @@
observation.setObservationStatus(status);
observationDAO.update(observation);
}
-
+
protected void saveAudio(long delay) {
String fileName = String.format(
@@ -785,16 +794,14 @@
getAudioRecorder().getOutputType().getExtension()
);
- File audioDir = context.getConfig().getAudioDirectory();
+ File audioFile = flightStorage.getAudioFile(fileName);
- File audioFile = new File(audioDir, fileName);
-
getAudioRecorder().record(audioFile, delay);
}
protected Date saveGPS(TopiaContext transaction,
- GeoPoint geoPoint,
- Flight flight)
+ GeoPoint geoPoint,
+ Flight flight)
throws TopiaException {
Date result;
@@ -804,7 +811,7 @@
if (logger.isWarnEnabled()) {
logger.warn("No GPS point at {}", result);
}
-
+
} else {
// lastLocation = geoPoint;
@@ -829,13 +836,13 @@
listener.onObservationAdded(new ObservationEvent(this, observation, location));
}
}
-
+
protected void fireStateChanged(FlightState state) {
for (FlightControllerListener listener : listeners) {
listener.onStateChanged(state);
}
}
-
+
protected void fireRouteAdded(Route route) {
for (FlightControllerListener listener : listeners) {
listener.onRouteAdded(route);
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerListener.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerListener.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerListener.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -28,7 +28,7 @@
/**
* Listener for all change of data in the {@link FlightController}
- *
+ * <p/>
* Created: 12/07/12
*
* @author fdesbois <desbois(a)codelutin.com>
@@ -47,7 +47,7 @@
* Fired when the next transect has been updated.
*
* @param nextTransect The next transect that will be used on
- * {@link FlightController#begin()} action
+ * {@link FlightController#begin()} action
*/
void onNextTransectChanged(TransectFlight nextTransect);
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,97 @@
+package fr.ulr.sammoa.application.io;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.io.Files;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Storage for a campaign.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class CampaignStorage {
+
+ public static final Function<File, FlightStorage> FILE_FLIGHT_STORAGE_FUNCTION = new Function<File, FlightStorage>() {
+ @Override
+ public FlightStorage apply(File input) {
+ return new FlightStorage(input.getParentFile(),
+ input.getName());
+ }
+ };
+
+ /** Root directory for this storage. */
+ protected final File directory;
+
+ /** Id of the campaign. */
+ protected final String campaignId;
+
+ /** Properties of the campaign. */
+ protected final Properties properties;
+
+
+ public CampaignStorage(File dataDirectory, String campaignId) {
+ this.directory = new File(dataDirectory, campaignId);
+ this.campaignId = campaignId;
+ this.properties = new Properties();
+ }
+
+ public String getCampaignId() {
+ return campaignId;
+ }
+
+ public File getDirectory() {
+ return directory;
+ }
+
+ public File getMapDirectory() {
+ return new File(directory, "map");
+ }
+
+ public File getFlightDirectory() {
+ return new File(directory, "flight");
+ }
+
+ public File getCsvDirectory() {
+ return new File(directory, "csv");
+ }
+
+ public File getPropertiesFile() {
+ return new File(directory, "campaign.properties");
+ }
+
+ public Properties getProperties() throws IOException {
+ return properties;
+ }
+
+ public void loadProperties() throws IOException {
+ BufferedReader reader =
+ Files.newReader(getPropertiesFile(), Charsets.UTF_8);
+ try {
+ properties.load(reader);
+ reader.close();
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+ public FlightStorage getFlightStorage(String flightId) {
+ File flightStorageDirectory = new File(getFlightDirectory(), flightId);
+ return FILE_FLIGHT_STORAGE_FUNCTION.apply(flightStorageDirectory);
+ }
+
+ public Iterable<FlightStorage> getFlightStorages() {
+ File[] files = getFlightDirectory().listFiles((FileFilter) DirectoryFileFilter.DIRECTORY);
+ return Iterables.transform(Lists.newArrayList(files), FILE_FLIGHT_STORAGE_FUNCTION);
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,58 @@
+package fr.ulr.sammoa.application.io;
+
+import fr.ulr.sammoa.application.SammoaConfig;
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Useful methods around {@link CampaignStorage}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class CampaignStorages {
+
+
+ public static CampaignStorage getStorage(SammoaConfig config,
+ String campaignId) {
+ File directory = config.getCampaignDirectory();
+ CampaignStorage result = new CampaignStorage(directory, campaignId);
+ return result;
+ }
+
+ public static CampaignStorage createStorage(SammoaConfig config,
+ String campaignId) throws IOException {
+ File directory = config.getCampaignDirectory();
+ CampaignStorage result = new CampaignStorage(directory, campaignId);
+ createEmptyStructure(result);
+ return result;
+ }
+
+ public static CampaignStorage copyStorage(CampaignStorage source,
+ File targetDirectory,
+ String... flightIds) throws IOException {
+
+ CampaignStorage target = new CampaignStorage(targetDirectory, source.getCampaignId());
+
+ createEmptyStructure(target);
+ FileUtils.copyDirectory(source.getMapDirectory(), target.getMapDirectory());
+ if (source.getCsvDirectory().exists()) {
+ FileUtils.forceMkdir(target.getCsvDirectory());
+ FileUtils.copyDirectory(source.getCsvDirectory(), target.getCsvDirectory());
+ }
+ for (String flightId : flightIds) {
+ FlightStorage flightStorage = source.getFlightStorage(flightId);
+ FlightStorages.copyStorage(flightStorage, target);
+ }
+ return target;
+ }
+
+ protected static void createEmptyStructure(CampaignStorage storage) throws IOException {
+ FileUtils.forceMkdir(storage.getDirectory());
+ FileUtils.forceMkdir(storage.getFlightDirectory());
+ FileUtils.forceMkdir(storage.getMapDirectory());
+ }
+
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/CampaignStorages.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,69 @@
+package fr.ulr.sammoa.application.io;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+import org.apache.commons.io.IOUtils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Storage for a flight.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class FlightStorage {
+
+ /** Root directory for this storage. */
+ protected final File directory;
+
+ /** Id of the flight. */
+ protected final String flightId;
+
+ /** Properties of the flight. */
+ protected final Properties properties;
+
+ public FlightStorage(File dataDirectory, String flightId) {
+ this.directory = new File(dataDirectory, flightId);
+ this.flightId = flightId;
+ this.properties = new Properties();
+ }
+
+ public String getFlightId() {
+ return flightId;
+ }
+
+ public File getDirectory() {
+ return directory;
+ }
+
+ public File getAudioDirectory() {
+ return new File(directory, "audio");
+ }
+
+ public File getAudioFile(String filename) {
+ return new File(getAudioDirectory(), filename);
+ }
+ public File getPropertiesFile() {
+ return new File(directory, "flight.properties");
+ }
+
+ public Properties getProperties() throws IOException {
+ return properties;
+ }
+
+ public void loadProperties() throws IOException {
+ BufferedReader reader =
+ Files.newReader(getPropertiesFile(), Charsets.UTF_8);
+ try {
+ properties.load(reader);
+ reader.close();
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,35 @@
+package fr.ulr.sammoa.application.io;
+
+import org.apache.commons.io.FileUtils;
+
+import java.io.IOException;
+
+/**
+ * Useful methods around {@link FlightStorage}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class FlightStorages {
+
+ public static FlightStorage createStorage(CampaignStorage source,
+ String flightId) throws IOException {
+ FlightStorage result = source.getFlightStorage(flightId);
+ createEmptyFlightStructure(result);
+ return result;
+ }
+
+ public static FlightStorage copyStorage(FlightStorage source,
+ CampaignStorage target) throws IOException {
+
+ FlightStorage result = target.getFlightStorage(source.getFlightId());
+ FileUtils.copyDirectory(source.getDirectory(), result.getDirectory());
+ return result;
+ }
+
+ protected static void createEmptyFlightStructure(FlightStorage storage) throws IOException {
+ FileUtils.forceMkdir(storage.getDirectory());
+ FileUtils.forceMkdir(storage.getAudioDirectory());
+ }
+
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorages.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,191 @@
+package fr.ulr.sammoa.application.io.input.csv;
+
+import com.google.common.base.Preconditions;
+import com.google.common.io.Files;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Observer;
+import fr.ulr.sammoa.persistence.ObserverDAO;
+import fr.ulr.sammoa.persistence.Region;
+import fr.ulr.sammoa.persistence.SammoaDAOHelper;
+import fr.ulr.sammoa.persistence.SammoaPersistence;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.SpeciesDAO;
+import org.apache.commons.io.Charsets;
+import org.apache.commons.io.IOUtils;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaRuntimeException;
+import org.nuiton.util.csv.Import;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * To do csv imports.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ImportCsvService {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ImportCsvService.class);
+
+ protected SammoaPersistence persistence;
+
+ public ImportCsvService(SammoaContext context) {
+ this.persistence = context.getPersistence();
+ }
+
+ public int importSpecies(String regionId, File file) throws IOException {
+
+ Reader reader = Files.newReader(file, Charsets.UTF_8);
+
+ try {
+ int result = 0;
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ Region region = SammoaDAOHelper.getRegionDAO(transaction).findByTopiaId(regionId);
+ Preconditions.checkNotNull(region);
+
+ SpeciesDAO dao =
+ SammoaDAOHelper.getSpeciesDAO(transaction);
+
+ SpeciesImportModel model = new SpeciesImportModel(region);
+
+ Import<Species> importCsv = Import.newImport(model, reader);
+
+ for (Species species : importCsv) {
+
+ // while importing a species, it does become valid
+ species.setLocalCreation(false);
+
+ Species speciesExists =
+ dao.findByNaturalId(species.getCode(),
+ species.getRegion());
+
+ if (speciesExists == null) {
+
+ dao.create(species);
+
+ result++;
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Create new species %1$s " +
+ "for region %2$s",
+ species.getCode(),
+ region.getCode()));
+ }
+
+ } else {
+
+ speciesExists.setCommonName(species.getCommonName());
+ speciesExists.setLatinName(species.getLatinName());
+ speciesExists.setGroupName(species.getGroupName());
+ speciesExists.setFamily(species.getFamily());
+ speciesExists.setType(species.getType());
+ dao.update(speciesExists);
+
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("The species %1$s already " +
+ "exists and is updated",
+ species.getCode()));
+ }
+ }
+ }
+
+ transaction.commitTransaction();
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ reader.close();
+
+ return result;
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+ public int importObservers(String campaignId, File file) throws IOException {
+
+ Reader reader = Files.newReader(file, Charsets.UTF_8);
+
+ try {
+ int result = 0;
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ Campaign campaign = SammoaDAOHelper.getCampaignDAO(transaction).findByTopiaId(campaignId);
+ Preconditions.checkNotNull(campaign);
+
+ ObserverDAO observerDAO =
+ SammoaDAOHelper.getObserverDAO(transaction);
+
+ ObserverImportModel model = new ObserverImportModel(campaign);
+
+ Import<Observer> importCsv = Import.newImport(model, reader);
+
+ for (Observer anImportCsv : importCsv) {
+
+ Observer observer;
+
+ observer = anImportCsv;
+
+ Observer observerExists =
+ observerDAO.findByNaturalId(observer.getInitials(), observer.getCampaign());
+
+ if (observerExists == null) {
+
+ observerDAO.create(observer);
+
+ result++;
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Create new observer %1$s " +
+ "for campaign %2$s",
+ observer.getInitials(),
+ campaign.getCode()));
+ }
+
+ } else {
+
+ observerExists.setEmail(observer.getEmail());
+ observerExists.setFirstName(observer.getFirstName());
+ observerExists.setLastName(observer.getLastName());
+ observerExists.setOrganization(observer.getOrganization());
+ observerExists.setPilot(observer.isPilot());
+ observerDAO.update(observerExists);
+
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("The observer %1$s already " +
+ "exists and is updated",
+ observer.getInitials()));
+ }
+ }
+ }
+
+ transaction.commitTransaction();
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ reader.close();
+ return result;
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ObserverImportModel.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/ObserverImportModel.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ObserverImportModel.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ObserverImportModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,92 @@
+package fr.ulr.sammoa.application.io.input.csv;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Observer;
+import fr.ulr.sammoa.persistence.ObserverImpl;
+import org.nuiton.util.csv.Common;
+import org.nuiton.util.csv.ImportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+import org.nuiton.util.csv.ValueParser;
+
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * Created: 09/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class ObserverImportModel implements ImportModel<Observer> {
+
+ protected Campaign campaign;
+
+ public ObserverImportModel(Campaign campaign) {
+ this.campaign = campaign;
+ }
+
+ @Override
+ public char getSeparator() {
+ return ';';
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> strings) {
+ }
+
+ @Override
+ public Observer newEmptyInstance() {
+ return new ObserverImpl();
+ }
+
+ @Override
+ public Iterable<ImportableColumn<Observer, Object>> getColumnsForImport() {
+ ModelBuilder builder = new ModelBuilder();
+ builder.newMandatoryColumn("CAMPAIGN", Observer.PROPERTY_CAMPAIGN, CAMPAIGN_VALUE_PARSER);
+ builder.newMandatoryColumn("INITIALS", Observer.PROPERTY_INITIALS);
+ builder.newMandatoryColumn("FIRST_NAME", Observer.PROPERTY_FIRST_NAME);
+ builder.newMandatoryColumn("LAST_NAME", Observer.PROPERTY_LAST_NAME);
+ builder.newMandatoryColumn("ORGANIZATION", Observer.PROPERTY_ORGANIZATION);
+ builder.newMandatoryColumn("EMAIL", Observer.PROPERTY_EMAIL);
+ builder.newMandatoryColumn("PILOT", Observer.PROPERTY_PILOT, Common.BOOLEAN);
+ return builder.getColumnsForImport();
+ }
+
+ protected ValueParser<Campaign> CAMPAIGN_VALUE_PARSER = new ValueParser<Campaign>() {
+
+ @Override
+ public Campaign parse(String s) throws ParseException {
+ Campaign result;
+ if (s.equals(campaign.getCode())) {
+ result = campaign;
+ } else {
+ throw new IllegalArgumentException(
+ String.format("The current campaign is %1$s and not %2$s", campaign.getCode(), s));
+ }
+ return result;
+ }
+ };
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/ObserverImportModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/SpeciesImportModel.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/SpeciesImportModel.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/SpeciesImportModel.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/SpeciesImportModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,91 @@
+package fr.ulr.sammoa.application.io.input.csv;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.Region;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.SpeciesImpl;
+import org.nuiton.util.csv.ImportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+import org.nuiton.util.csv.ValueParser;
+
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * Created: 17/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class SpeciesImportModel implements ImportModel<Species> {
+
+ protected Region region;
+
+ public SpeciesImportModel(Region region) {
+ this.region = region;
+ }
+
+ @Override
+ public char getSeparator() {
+ return ';';
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> strings) {
+ }
+
+ @Override
+ public Species newEmptyInstance() {
+ return new SpeciesImpl();
+ }
+
+ @Override
+ public Iterable<ImportableColumn<Species, Object>> getColumnsForImport() {
+ ModelBuilder builder = new ModelBuilder();
+ builder.newMandatoryColumn("REGION", Species.PROPERTY_REGION, REGION_VALUE_PARSER);
+ builder.newMandatoryColumn("CODE", Species.PROPERTY_CODE);
+ builder.newMandatoryColumn("NOM_COMM", Species.PROPERTY_COMMON_NAME);
+ builder.newMandatoryColumn("NOM_LATIN", Species.PROPERTY_LATIN_NAME);
+ builder.newMandatoryColumn("TYPE", Species.PROPERTY_TYPE);
+ builder.newMandatoryColumn("FAMILLE", Species.PROPERTY_FAMILY);
+ builder.newMandatoryColumn("GROUPE", Species.PROPERTY_GROUP_NAME);
+ return builder.getColumnsForImport();
+ }
+
+ protected ValueParser<Region> REGION_VALUE_PARSER = new ValueParser<Region>() {
+
+ @Override
+ public Region parse(String s) throws ParseException {
+ Region result;
+ if (s.equals(region.getCode())) {
+ result = region;
+ } else {
+ throw new IllegalArgumentException(
+ String.format("The current region is %1$s and not %2$s", region.getCode(), s));
+ }
+ return result;
+ }
+ };
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/csv/SpeciesImportModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/DoubleToIntegerValueParser.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/DoubleToIntegerValueParser.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/DoubleToIntegerValueParser.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/DoubleToIntegerValueParser.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,42 @@
+package fr.ulr.sammoa.application.io.input.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import org.nuiton.util.csv.ValueParser;
+
+import java.text.ParseException;
+
+/**
+ * Created: 26/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class DoubleToIntegerValueParser implements ValueParser<Integer> {
+
+ @Override
+ public Integer parse(String s) throws ParseException {
+ Double value = Double.parseDouble(s);
+ return value.intValue();
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/DoubleToIntegerValueParser.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,223 @@
+package fr.ulr.sammoa.application.io.input.map;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.CampaignDAO;
+import fr.ulr.sammoa.persistence.SammoaDAOHelper;
+import fr.ulr.sammoa.persistence.SammoaPersistence;
+import fr.ulr.sammoa.persistence.Sector;
+import fr.ulr.sammoa.persistence.SectorDAO;
+import fr.ulr.sammoa.persistence.Sectors;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StrateDAO;
+import fr.ulr.sammoa.persistence.StrateType;
+import fr.ulr.sammoa.persistence.Strates;
+import fr.ulr.sammoa.persistence.Transect;
+import fr.ulr.sammoa.persistence.TransectDAO;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaRuntimeException;
+import org.nuiton.util.csv.ImportRuntimeException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * To import map.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ImportMapService {
+
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ImportMapService.class);
+
+ protected SammoaPersistence persistence;
+
+ public ImportMapService(SammoaContext context) {
+ this.persistence = context.getPersistence();
+ }
+
+ public int importTransects(String campaignId, Iterable<Transect> transects) {
+
+ int result = 0;
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ CampaignDAO campaignDAO =
+ SammoaDAOHelper.getCampaignDAO(transaction);
+
+ Campaign campaign = campaignDAO.findByTopiaId(campaignId);
+ Preconditions.checkArgument(campaign != null,
+ "The topiaId : " + campaignId + " doesn't match any existing campaign");
+
+ StrateDAO strateDAO = SammoaDAOHelper.getStrateDAO(transaction);
+ TransectDAO transectDAO = SammoaDAOHelper.getTransectDAO(transaction);
+
+ // Retrieve directly all strates to avoid multiple select queries to find strates
+ List<Strate> strates = strateDAO.findAllByCampaignOrderedByCode(campaign);
+ Map<String, Strate> strateMap =
+ Maps.uniqueIndex(strates, Strates.toCode());
+
+ int rowIndex = 0;
+ for (Transect transect : transects) {
+
+ // This is the link with the source shape file that contains graphic elements
+ int graphicIndex = rowIndex;
+
+ rowIndex++;
+
+ String strateCode = Strates.getCode(transect.getStrate());
+
+ // We check the strate, it must exist
+ // We can't do that in TransectImportModel during parsing because
+ // we need two params : sectorNumber and strateType to create the
+ // strateCode and check the existence. It must be done after parsing
+ Strate existStrate = strateMap.get(strateCode);
+ if (existStrate == null) {
+ throw new ImportRuntimeException(String.format(
+ "Unable to read line %1$d : The strate %2$s doesn't exist",
+ rowIndex,
+ strateCode)
+ );
+ }
+
+ Transect existTransect = transectDAO.findByNaturalId(transect.getName(), existStrate);
+
+ // If the existing strate is null, create it otherwise ignore
+ if (existTransect == null) {
+
+ Transect newTransect = transectDAO.createByNaturalId(transect.getName(), existStrate);
+ newTransect.setLength(transect.getLength());
+ newTransect.setStartX(transect.getStartX());
+ newTransect.setStartY(transect.getStartY());
+ newTransect.setEndX(transect.getEndX());
+ newTransect.setEndY(transect.getEndY());
+ newTransect.setNbTimes(transect.getNbTimes());
+ newTransect.setGraphicIndex(graphicIndex);
+
+ result++;
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Create new transect %1$s" +
+ "(graphicIndex = %2$d)",
+ newTransect.getName(),
+ graphicIndex)
+ );
+ }
+
+ } else {
+
+ existTransect.setGraphicIndex(graphicIndex);
+
+ if (logger.isWarnEnabled()) {
+ logger.warn(String.format("The transect %1$s already " +
+ "exists and will be ignored " +
+ "(graphicIndex = %2$d)",
+ existTransect.getName(),
+ graphicIndex)
+ );
+ }
+ }
+ }
+
+ transaction.commitTransaction();
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ return result;
+ }
+
+ public int importStrates(String campaignId, Iterable<Strate> strates) {
+
+ int result = 0;
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ CampaignDAO campaignDAO =
+ SammoaDAOHelper.getCampaignDAO(transaction);
+
+ Campaign campaign = campaignDAO.findByTopiaId(campaignId);
+ Preconditions.checkArgument(campaign != null,
+ "The topiaId : " + campaignId + " doesn't match any existing campaign");
+
+ StrateDAO strateDAO = SammoaDAOHelper.getStrateDAO(transaction);
+ SectorDAO sectorDAO = SammoaDAOHelper.getSectorDAO(transaction);
+
+ // Retrieve directly all sectors to avoid multiple select queries to find sectors
+ List<Sector> sectors = sectorDAO.findAllByCampaign(campaign);
+ Map<Integer, Sector> sectorMap =
+ Maps.newHashMap(Maps.uniqueIndex(sectors, Sectors.toSectorNumber()));
+
+ for (Strate strate : strates) {
+
+ StrateType strateType = strate.getStrateType();
+ Sector sector = strate.getSector();
+ int sectorNumber = sector.getSectorNumber();
+
+ Strate existStrate;
+
+ // Create sector if necessary
+ Sector existSector = sectorMap.get(sectorNumber);
+ if (existSector == null) {
+
+ existSector = sectorDAO.createByNaturalId(sectorNumber, campaign);
+ existSector.setName(sector.getName());
+ sectorMap.put(sectorNumber, existSector);
+
+ existStrate = null;
+
+ } else {
+
+ // Find existing strate only if sector is not created
+ existStrate = strateDAO.findByNaturalId(strateType, existSector);
+ }
+
+ // If the existing strate is null, create it otherwise ignore
+ if (existStrate == null) {
+
+ Strate newStrate = strateDAO.createByNaturalId(strateType, existSector);
+ newStrate.setCode(Strates.getCode(newStrate));
+ newStrate.setName(strate.getName());
+
+ result++;
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Create new strate %1$s",
+ newStrate.getCode())
+ );
+ }
+
+ } else {
+
+ if (logger.isWarnEnabled()) {
+ logger.warn(String.format("The strate %1$s already " +
+ "exists and will be ignored",
+ existStrate.getCode()));
+ }
+ }
+ }
+
+ transaction.commitTransaction();
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ return result;
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ImportMapService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,104 @@
+package fr.ulr.sammoa.application.io.input.map;
+
+import com.google.common.io.Files;
+import fr.ulr.sammoa.application.io.CampaignStorage;
+import fr.ulr.sammoa.application.io.output.map.DbfImport;
+import org.apache.commons.io.FileUtils;
+import org.nuiton.util.csv.ImportModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.IOException;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public abstract class ShpImporter<E> {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ShpImporter.class);
+
+ protected abstract String onDbfLoaded(Iterable<E> elements,
+ CampaignStorage storage);
+
+ protected abstract ImportModel<E> getModel();
+
+ protected abstract String getCopyFileName();
+
+ public String importShape(File file, CampaignStorage storage) throws IOException {
+
+ File dbfFile;
+ String fileName = file.getName();
+ File sourceDirectory = file.getParentFile();
+
+ String ext = Files.getFileExtension(fileName);
+ int extIndex = fileName.lastIndexOf(ext);
+ final String fileNameWithoutExt = fileName.substring(0, extIndex);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Source directory '" + sourceDirectory.getAbsolutePath() + "' and fileName '" + fileNameWithoutExt + "'");
+ }
+
+ if (!ext.equals("dbf")) {
+
+ fileName = fileNameWithoutExt + "dbf";
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Use dbfFile %s for import", fileName));
+ }
+
+ dbfFile = new File(sourceDirectory, fileName);
+
+ if (!dbfFile.exists()) {
+ throw new FileNotFoundException("Can't found dbf file '" + dbfFile.getAbsolutePath() + "' for import");
+ }
+
+ } else {
+ dbfFile = file;
+ }
+
+ DbfImport<E> importer = new DbfImport<E>(getModel(), dbfFile.toURI().toURL());
+
+ String result = onDbfLoaded(importer, storage);
+
+ String[] files = sourceDirectory.list(new FilenameFilter() {
+
+ @Override
+ public boolean accept(File dir, String fullName) {
+ String extension = Files.getFileExtension(fullName);
+ int extIndex = fullName.lastIndexOf(extension);
+ String name = fullName.substring(0, extIndex);
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Read file : %s [ext = %s] -> check equals for %s",
+ fullName,
+ extension,
+ name)
+ );
+ }
+ return fileNameWithoutExt.equals(name);
+ }
+ });
+
+ for (String name : files) {
+ String extension = Files.getFileExtension(name);
+ File sourceFile = new File(sourceDirectory, name);
+ File targetFile = new File(storage.getMapDirectory(), getCopyFileName() + "." + extension);
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("Copy file '%1$s' to '%2$s'",
+ sourceFile.getAbsolutePath(),
+ targetFile.getAbsolutePath())
+ );
+ }
+ FileUtils.copyFile(sourceFile, targetFile);
+ }
+ return result;
+ }
+
+
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/ShpImporter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateImportModel.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateImportModel.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateImportModel.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateImportModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,91 @@
+package fr.ulr.sammoa.application.io.input.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.Sector;
+import fr.ulr.sammoa.persistence.SectorImpl;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StrateImpl;
+import org.nuiton.util.csv.ImportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+
+import java.util.List;
+
+/**
+ * Created: 25/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class StrateImportModel implements ImportModel<Strate> {
+
+ // 0 : Nom
+ // 1 : Area (not used)
+ // 2 : Shape_Leng (not used)
+ // 3 : Shape_Area (not used)
+ // 4 : Secteur (name)
+ // 5 : type_strat (string) for StrateType (code match)
+ // 6 : ID_Secteur (double)
+
+ @Override
+ public char getSeparator() {
+ return ' ';
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> strings) {
+ }
+
+ @Override
+ public Strate newEmptyInstance() {
+ Strate result = new StrateImpl();
+ result.setSector(new SectorImpl());
+ return result;
+ }
+
+ @Override
+ public Iterable<ImportableColumn<Strate, Object>> getColumnsForImport() {
+ ModelBuilder builder = new ModelBuilder();
+ builder.newMandatoryColumn("Nom",
+ Strate.PROPERTY_NAME
+ );
+ builder.newMandatoryColumn("Secteur",
+ Strate.PROPERTY_SECTOR
+ + "." + Sector.PROPERTY_NAME
+ );
+ builder.newMandatoryColumn("type_strat",
+ Strate.PROPERTY_STRATE_TYPE,
+ new StrateTypeValueParser()
+ );
+ builder.newMandatoryColumn("ID_Secteur",
+ Strate.PROPERTY_SECTOR
+ + "." + Sector.PROPERTY_SECTOR_NUMBER,
+ new DoubleToIntegerValueParser()
+ );
+ builder.newIgnoredColumn("Area");
+ builder.newIgnoredColumn("Shape_Area");
+ builder.newIgnoredColumn("Shape_Leng");
+ return builder.getColumnsForImport();
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateImportModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateTypeValueParser.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/StrateTypeValueParser.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateTypeValueParser.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateTypeValueParser.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,44 @@
+package fr.ulr.sammoa.application.io.input.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.StrateType;
+import org.nuiton.util.csv.ValueParser;
+
+import java.text.ParseException;
+
+/**
+ * Created: 26/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class StrateTypeValueParser implements ValueParser<StrateType> {
+
+ @Override
+ public StrateType parse(String s) throws ParseException {
+ char strateCode = s.charAt(0);
+ StrateType result = StrateType.valueOfCode(strateCode);
+ return result;
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateTypeValueParser.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/TransectImportModel.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/csv/TransectImportModel.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/TransectImportModel.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/TransectImportModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,119 @@
+package fr.ulr.sammoa.application.io.input.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.Sector;
+import fr.ulr.sammoa.persistence.SectorImpl;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StrateImpl;
+import fr.ulr.sammoa.persistence.Transect;
+import fr.ulr.sammoa.persistence.TransectImpl;
+import org.nuiton.util.csv.Common;
+import org.nuiton.util.csv.ImportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+
+import java.util.List;
+
+/**
+ * Created: 25/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class TransectImportModel implements ImportModel<Transect> {
+
+ // 0 : Length
+ // 1 : TR_ID used as name
+ // 2 : Xstart
+ // 3 : Ystart
+ // 4 : Xend
+ // 5 : Yend
+ // 6 : Passage (double) used for nbTimes
+ // 7 : SECTEUR (double) use as sectorNumber
+ // 8 : STRATE (string) for StrateType (code match)
+ // 9 : Shape_Leng (not used)
+
+ @Override
+ public char getSeparator() {
+ return ' ';
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> strings) {
+ }
+
+ @Override
+ public Transect newEmptyInstance() {
+ Transect result = new TransectImpl();
+ Strate strate = new StrateImpl();
+ result.setStrate(strate);
+ strate.setSector(new SectorImpl());
+ return result;
+ }
+
+ @Override
+ public Iterable<ImportableColumn<Transect, Object>> getColumnsForImport() {
+ ModelBuilder builder = new ModelBuilder();
+ builder.newMandatoryColumn("Length",
+ Transect.PROPERTY_LENGTH,
+ Common.DOUBLE_PRIMITIVE
+ );
+ builder.newMandatoryColumn("TR_ID",
+ Transect.PROPERTY_NAME)
+ ;
+ builder.newMandatoryColumn("Xstart",
+ Transect.PROPERTY_START_X,
+ Common.DOUBLE_PRIMITIVE
+ );
+ builder.newMandatoryColumn("Ystart",
+ Transect.PROPERTY_START_Y,
+ Common.DOUBLE_PRIMITIVE
+ );
+ builder.newMandatoryColumn("Xend",
+ Transect.PROPERTY_END_X,
+ Common.DOUBLE_PRIMITIVE
+ );
+ builder.newMandatoryColumn("Yend",
+ Transect.PROPERTY_END_Y,
+ Common.DOUBLE_PRIMITIVE
+ );
+ builder.newMandatoryColumn("SECTEUR",
+ Transect.PROPERTY_STRATE + "."
+ + Strate.PROPERTY_SECTOR + "."
+ + Sector.PROPERTY_SECTOR_NUMBER,
+ new DoubleToIntegerValueParser()
+ );
+ builder.newMandatoryColumn("STRATE",
+ Transect.PROPERTY_STRATE + "."
+ + Strate.PROPERTY_STRATE_TYPE,
+ new StrateTypeValueParser()
+ );
+ builder.newMandatoryColumn("Passage",
+ Transect.PROPERTY_NB_TIMES,
+ new DoubleToIntegerValueParser()
+ );
+ builder.newIgnoredColumn("Shape_Leng");
+ return builder.getColumnsForImport();
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/TransectImportModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfColumnModel.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfColumnModel.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfColumnModel.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfColumnModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,83 @@
+package fr.ulr.sammoa.application.io.output.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * Note: there is an existing {@link com.bbn.openmap.dataAccess.shape.DbfTableModelFactory.Column}
+ * class.
+ * <p/>
+ * Created: 07/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class DbfColumnModel {
+
+ protected String name;
+
+ protected byte type;
+
+ protected int length;
+
+ protected byte decimalCount;
+
+ protected int index;
+
+ public DbfColumnModel(String name, byte type) {
+ this.name = name;
+ this.type = type;
+ this.index = -1;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public byte getType() {
+ return type;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public void setLength(int length) {
+ this.length = length;
+ }
+
+ public int getDecimalCount() {
+ return decimalCount;
+ }
+
+ public void setDecimalCount(int decimalCount) {
+ this.decimalCount = (byte) decimalCount;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfColumnModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfImport.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfImport.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfImport.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfImport.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,129 @@
+package fr.ulr.sammoa.application.io.output.map;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.bbn.openmap.dataAccess.shape.DbfTableModel;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
+import org.nuiton.util.csv.Import;
+import org.nuiton.util.csv.ImportModel;
+import org.nuiton.util.csv.ImportRuntimeException;
+import org.nuiton.util.csv.ImportableColumn;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 25/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class DbfImport<E> extends Import<E> {
+
+ private static final Logger logger = LoggerFactory.getLogger(DbfImport.class);
+
+ protected DbfTableModel source;
+
+ protected Iterator<List<Object>> records;
+
+ protected List<Object> record;
+
+ public DbfImport(ImportModel<E> model, URL fileUrl) {
+ // Use dummy reader for superclass Import that manage by default csv files
+ super(model, new Reader() {
+
+ @Override
+ public int read(char[] cbuf, int off, int len) throws IOException {
+ return -1;
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+ });
+
+ try {
+ // FIXME-fdesbois-2012-07-26 : there is an issue with encoding, don't know how to customize it
+ this.source = DbfTableModel.read(fileUrl);
+
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ this.records = source.getRecords();
+ }
+
+ @Override
+ protected <T> String readValue(ImportableColumn<E, T> field, int lineNumber) {
+ try {
+
+ int columnNumber = source.getColumnIndexForName(field.getHeaderName());
+
+ String value = String.valueOf(record.get(columnNumber));
+
+ return value;
+
+ } catch (Exception e) {
+ throw new ImportRuntimeException(
+ _("csv.import.error.unableToReadField",
+ field.getHeaderName(), lineNumber), e);
+ }
+ }
+
+ @Override
+ public void close() {
+ // nothing to do
+ }
+
+ @Override
+ protected boolean readRow() throws ImportRuntimeException {
+ boolean result;
+ if (records.hasNext()) {
+ record = records.next();
+ if (logger.isTraceEnabled()) {
+ logger.trace("Read record {}", record);
+ }
+ result = true;
+
+ } else {
+ result = false;
+ }
+ return result;
+ }
+
+ @Override
+ protected String[] getHeaders() throws ImportRuntimeException {
+ List<String> list = Lists.newArrayList();
+ for (int index = 0; index < source.getColumnCount(); index++) {
+ list.add(source.getColumnName(index));
+ }
+ return list.toArray(new String[list.size()]);
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfImport.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTableModelBuilder.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTableModelBuilder.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTableModelBuilder.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTableModelBuilder.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,229 @@
+package fr.ulr.sammoa.application.io.output.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.bbn.openmap.dataAccess.shape.DbfTableModel;
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created: 07/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class DbfTableModelBuilder {
+
+ /** Logger. */
+ private static final Logger logger =
+ LoggerFactory.getLogger(DbfTableModelBuilder.class);
+
+ public static final int DEFAULT_STRING_LENGTH = 64;
+
+ public static final int DEFAULT_INTEGER_LENGTH = 8;
+
+ public static final String DATE_FORMAT_PATTERN = "yyyyMMdd";
+
+ public static final DateFormat DATE_FORMAT = new SimpleDateFormat(DATE_FORMAT_PATTERN);
+
+ protected List<DbfColumnModel> columns;
+
+ protected Map<String, DbfColumnModel> columnMap;
+
+ protected DbfTableModel model;
+
+ public DbfTableModelBuilder() {
+ columns = Lists.newArrayList();
+ }
+
+ public DbfTableModelBuilder dbfColumn(DbfColumnModel column) {
+ if (column.getIndex() != -1) {
+ columns.add(column.getIndex(), column);
+ } else {
+ column.setIndex(columns.size());
+ columns.add(column);
+ }
+ return this;
+ }
+
+ public DbfColumnModel newStringColumn(String name) {
+ DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_CHARACTER);
+ result.setLength(DEFAULT_STRING_LENGTH);
+ return result;
+ }
+
+ public DbfColumnModel newIntegerColumn(String name) {
+ DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_NUMERIC);
+ result.setLength(DEFAULT_INTEGER_LENGTH);
+ return result;
+ }
+
+ public DbfColumnModel newDoubleColumn(String name, int length, int decimalCount) {
+ DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_NUMERIC);
+ result.setLength(length);
+ result.setDecimalCount(decimalCount);
+ return result;
+ }
+
+ public DbfColumnModel newTimestampColumn(String name) {
+ DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_TIMESTAMP);
+ return result;
+ }
+
+ public DbfColumnModel newDateColumn(String name) {
+ DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_DATE);
+ result.setLength(DATE_FORMAT_PATTERN.length());
+ return result;
+ }
+
+ public DbfColumnModel newBooleanColumn(String name) {
+ DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_LOGICAL);
+ result.setLength(1);
+ return result;
+ }
+
+ public DbfTableModelBuilder stringColumn(String name) {
+ return dbfColumn(newStringColumn(name));
+ }
+
+ public DbfTableModelBuilder booleanColumn(String name) {
+ return dbfColumn(newBooleanColumn(name));
+ }
+
+ public DbfTableModelBuilder integerColumn(String name) {
+ return dbfColumn(newIntegerColumn(name));
+ }
+
+ public DbfTableModelBuilder doubleColumn(String name, int length, int decimalCount) {
+ return dbfColumn(newDoubleColumn(name, length, decimalCount));
+ }
+
+ public DbfTableModelBuilder timestampColumn(String name) {
+ return dbfColumn(newTimestampColumn(name));
+ }
+
+ public DbfTableModelBuilder dateColumn(String name) {
+ return dbfColumn(newDateColumn(name));
+ }
+
+ public DbfTableModelBuilder build() {
+ model = new DbfTableModel(columns.size());
+ model.setWritable(true);
+
+ for (int i = 0; i < columns.size(); i++) {
+ DbfColumnModel columnModel = columns.get(i);
+ model.setColumnName(i, columnModel.getName());
+ model.setType(i, columnModel.getType());
+ model.setLength(i, columnModel.getLength());
+ model.setDecimalCount(i, (byte) columnModel.getDecimalCount());
+ }
+ columnMap = Maps.uniqueIndex(columns,
+ new Function<DbfColumnModel, String>() {
+
+ @Override
+ public String apply(DbfColumnModel input) {
+ return input.getName();
+ }
+ });
+ return this;
+ }
+
+ public DbfTableModel getModel() {
+ return model;
+ }
+
+ public void setValue(int rowIndex, String columnName, Object value) {
+ Preconditions.checkState(model != null, "Model must be built before setting values");
+
+ DbfColumnModel column = columnMap.get(columnName);
+
+ int columnIndex = column.getIndex();
+ value = cleanValue(value, column.getType());
+ model.setValueAt(value, rowIndex, columnIndex);
+ }
+
+ public int addValues(Map<String, Object> values) {
+ Preconditions.checkState(model != null, "Model must be built before adding values");
+
+ model.addBlankRecord();
+ int rowIndex = model.getRowCount() - 1;
+ for (Map.Entry<String, Object> entry : values.entrySet()) {
+ setValue(rowIndex, entry.getKey(), entry.getValue());
+ }
+ return rowIndex;
+ }
+
+ protected Object cleanValue(Object value, byte type) {
+
+ Object result = value;
+ if (DbfTableModel.isNumericalType(type)) {
+
+ // FIX for Integer Format error in DbfTableModel#getStringForType
+ if (value instanceof Integer) {
+ result = Double.valueOf(String.valueOf(value));
+ }
+ } else if (DbfTableModel.TYPE_TIMESTAMP == type) {
+
+ // FIX for Date : no format is done
+ if (value instanceof Date) {
+ Date date = (Date) value;
+
+ result = DbfTimestampConverter.toString(date);
+ }
+ } else if (DbfTableModel.TYPE_DATE == type) {
+
+ // FIX for Date : no format is done
+ if (value instanceof Date) {
+ Date date = (Date) value;
+
+ result = DATE_FORMAT.format(date);
+ }
+ } else if (DbfTableModel.TYPE_LOGICAL == type) {
+ result = ((Boolean) value) ? "T" : "F";
+ } else if (value instanceof Enum) {
+ result = ((Enum) value).name();
+ } else if (value instanceof Character) {
+ result = String.valueOf(value);
+ }
+
+ if (result != null &&
+ !(result instanceof String) &&
+ !(result instanceof Double)) {
+ if (logger.isWarnEnabled()) {
+ logger.warn("Incompatible data value {} (type {})", result, type);
+ }
+ }
+ return result;
+ }
+
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTableModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTimestampConverter.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTimestampConverter.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTimestampConverter.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTimestampConverter.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,117 @@
+package fr.ulr.sammoa.application.io.output.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import org.nuiton.util.DateUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+/**
+ * Created: 08/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public final class DbfTimestampConverter {
+
+ protected static final Long HOUR_MULT = 3600000L;
+
+ protected static final Long MINUTE_MULT = 60000L;
+
+ protected static final Long SECOND_MULT = 1000L;
+
+
+ private static final Logger logger = LoggerFactory.getLogger(DbfTimestampConverter.class);
+
+ private DbfTimestampConverter() {
+ // static class
+ }
+
+ public static String toString(Date date) {
+
+ Calendar calendar = new GregorianCalendar();
+ calendar.setTime(date);
+
+ Calendar refCalendar = getReferenceCalendar();
+
+ long dateValue = DateUtil.getDifferenceInDays(refCalendar.getTime(), date);
+ long timeValue = calendar.get(Calendar.HOUR_OF_DAY) * HOUR_MULT
+ + calendar.get(Calendar.MINUTE) * MINUTE_MULT
+ + calendar.get(Calendar.SECOND) * SECOND_MULT;
+
+ String result = dateValue + " " + timeValue;
+ return result;
+ }
+
+ public static Date toDate(String timestamp) {
+ Preconditions.checkArgument(Strings.nullToEmpty(timestamp).trim().contains(" "),
+ "A space is missing between the date and time values");
+
+ String[] values = timestamp.split(" ");
+
+ Long dateValue = Long.parseLong(values[0]);
+ Long timeValue = Long.parseLong(values[1]);
+
+ Calendar refCalendar = getReferenceCalendar();
+
+ Calendar resultCalendar = new GregorianCalendar();
+ resultCalendar.setTime(refCalendar.getTime());
+
+ resultCalendar.add(Calendar.DATE, dateValue.intValue());
+
+ Long hours = timeValue / HOUR_MULT;
+ Long timeWithoutHours = timeValue - hours * HOUR_MULT;
+ Long minutes = timeWithoutHours / MINUTE_MULT;
+ Long seconds = (timeWithoutHours - minutes * MINUTE_MULT) / SECOND_MULT;
+
+ resultCalendar.set(Calendar.HOUR_OF_DAY, hours.intValue());
+ resultCalendar.set(Calendar.MINUTE, minutes.intValue());
+ resultCalendar.set(Calendar.SECOND, seconds.intValue());
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("DateValue=%d, TimeValue=%d, Hours=%d, Minutes=%d, Seconds=%d, Result=%s",
+ dateValue,
+ timeValue,
+ hours,
+ minutes,
+ seconds,
+ resultCalendar)
+ );
+ }
+
+ return resultCalendar.getTime();
+ }
+
+ private static Calendar getReferenceCalendar() {
+ Calendar result = new GregorianCalendar(4713, 0, 1);
+ result.set(Calendar.ERA, GregorianCalendar.BC);
+ return result;
+ }
+
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/DbfTimestampConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapModel.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapModel.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,124 @@
+package fr.ulr.sammoa.application.io.output.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.Strate;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Model of export map.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class ExportMapModel implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static ExportMapModel newModel(File exportDirectory,
+ String exportFilename,
+ Campaign campaign,
+ Date beginDate,
+ Date endDate,
+ List<Strate> strates,
+ List<RouteType> routeTypes,
+ List<Species> species) {
+ ExportMapModel result = new ExportMapModel();
+ result.exportDirectory = exportDirectory;
+ result.exportFilename = exportFilename;
+ result.campaign = campaign;
+ result.beginDate = beginDate;
+ result.endDate = endDate;
+ result.strates = strates;
+ result.routeTypes = routeTypes;
+ result.species = species;
+ return result;
+ }
+
+ protected Campaign campaign;
+
+ protected Date beginDate;
+
+ protected Date endDate;
+
+ protected List<Strate> strates;
+
+ protected List<RouteType> routeTypes;
+
+ protected List<Species> species;
+
+ protected File exportDirectory;
+
+ protected String exportFilename;
+
+ public File getExportDirectory() {
+ return exportDirectory;
+ }
+
+ public String getExportFilename() {
+ return exportFilename;
+ }
+
+ public Campaign getCampaign() {
+ return campaign;
+ }
+
+ public Date getBeginDate() {
+ return beginDate;
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public List<Strate> getStrates() {
+ if (strates == null) {
+ strates = Lists.newArrayList();
+ }
+ return strates;
+ }
+
+ public List<RouteType> getRouteTypes() {
+ if (routeTypes == null) {
+ routeTypes = Lists.newArrayList();
+ }
+ return routeTypes;
+ }
+
+ public List<Species> getSpecies() {
+ if (species == null) {
+ species = Lists.newArrayList();
+ }
+ return species;
+ }
+
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,799 @@
+package fr.ulr.sammoa.application.io.output.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.bbn.openmap.dataAccess.shape.DbfTableModel;
+import com.bbn.openmap.dataAccess.shape.EsriGraphicList;
+import com.bbn.openmap.dataAccess.shape.EsriPointList;
+import com.bbn.openmap.dataAccess.shape.EsriShapeExport;
+import com.bbn.openmap.omGraphics.OMGraphic;
+import com.bbn.openmap.omGraphics.OMPoint;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import fr.ulr.sammoa.application.FlightService;
+import fr.ulr.sammoa.application.SammoaConfig;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.persistence.GeoPoint;
+import fr.ulr.sammoa.persistence.GeoPoints;
+import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.Observations;
+import fr.ulr.sammoa.persistence.ObserverPosition;
+import fr.ulr.sammoa.persistence.Position;
+import fr.ulr.sammoa.persistence.Region;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.Routes;
+import fr.ulr.sammoa.persistence.SammoaPersistence;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.Transect;
+import fr.ulr.sammoa.persistence.TransectFlight;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.util.PeriodDates;
+import org.nuiton.util.TimeLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Export map service
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class ExportMapService {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ExportMapService.class);
+
+ private static final TimeLog timeLog = new TimeLog(ExportMapService.class);
+
+ protected SammoaContext context;
+
+ protected SammoaConfig config;
+
+ protected SammoaPersistence persistence;
+
+ protected DateFormat timeFormat;
+
+ public ExportMapService(SammoaContext context) {
+ this.context = context;
+ this.persistence = context.getPersistence();
+ this.config = context.getConfig();
+ this.timeFormat = new SimpleDateFormat("HHmmss");
+ }
+
+ public void exportEffortsMap(ExportMapModel dataModel) {
+ Preconditions.checkNotNull(dataModel.getCampaign());
+ Preconditions.checkNotNull(dataModel.getBeginDate());
+ Preconditions.checkNotNull(dataModel.getEndDate());
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Start EffortsMap export to {} :: {}",
+ dataModel.getExportDirectory(),
+ dataModel.getExportFilename());
+ }
+
+ long startTime = TimeLog.getTime();
+
+
+ // * uniquement pour un parcours de type LEG, sinon la cellule sera vide
+ // ** uniquement pour un parcours de type CIRCLE_BACK, sinon la cellule sera vide
+ DbfTableModelBuilder builder = new DbfTableModelBuilder()
+ .stringColumn("REGION") // (region.code)
+ .stringColumn("CAMPAIGN") // (campaign.code)
+ .integerColumn("SECTOR") // * (route.transectFlight.transect.strate.sector.sectorNumber)
+ .stringColumn("STRATE_TYPE") // * (route.transectFlight.transect.strate.strateType.code)
+ .stringColumn("STRATE") // * (route.transectFlight.transect.strate.code)
+ .stringColumn("TRANSECT") // * (route.transectFlight.transect.name)
+ .integerColumn("PASSAGE") // * (route.transectFlight.crossingNumber)
+ .integerColumn("FLIGHT") // (route.flight.flightNumber)
+ .stringColumn("COMPUTER") // (route.flight.systemId)
+ .stringColumn("ROUTE_TYPE") // (route.routeType.name)
+ .stringColumn("EFFORT_GROUP") // * (voir doc)
+ .stringColumn("EFFORT") // * (voir doc)
+ .stringColumn("STATUS") // * (voir doc)
+ .dateColumn("DATE") // (route.beginTime)
+ .stringColumn("HHMMSS") // (format(route.beginTime, "HHmmss"))
+ .integerColumn("SEA_STATE") // (route.seaState)
+ .integerColumn("SWELL") // (route.swell)
+ .integerColumn("TURBIDITY") // (route.turbidity)
+ .integerColumn("SKY_GLINT") // (route.skyGlint)
+ .stringColumn("GLARE_FROM") // (route.glareFrom)
+ .stringColumn("GLARE_TO") // (route.glareTo)
+ .integerColumn("GLARE_SEVERITY") // (route.glareSeverity)
+ .booleanColumn("GLARE_UNDER") // (route.glareUnder)
+ .integerColumn("CLOUD_COVER") // (route.cloudCover)
+ .stringColumn("SUBJECTIVE") // (route.subjectiveConditions)
+ .stringColumn("UNEXP_LEFT") // (route.unexpectedLeft)
+ .stringColumn("UNEXP_RIGHT") // (route.unexpectedRight)
+ .stringColumn("LEFT_REAR") // (route.observerPosition[FRONT_LEFT].observer.initials)
+ .stringColumn("RIGHT_REAR") // (route.observerPosition[FRONT_RIGHT].observer.initials)
+ .stringColumn("CENTER") // (route.observerPosition[NAVIGATOR].observer.initials)
+ .stringColumn("CB_CAUSE") // ** ()
+ .doubleColumn("LAT", 19, 11) // (geoPoint.latitude)
+ .doubleColumn("LON", 19, 11) // (geoPoint.longitude)
+ .doubleColumn("SPEED", 19, 11) // (geoPoint.speed)
+ .doubleColumn("ALTITUDE", 19, 11) // (geoPoint.altitude)
+ .stringColumn("GPS_TIME") // (format(geoPoint.recordTime, "HHmmss"))
+ .stringColumn("AIRCRAFT") // (route.flight.immatriculation)
+ .stringColumn("COMMENT") // (route.comment)
+ .build();
+
+ EsriGraphicList graphicList = new EsriPointList();
+
+ FlightService flightService = context.getFlightService();
+
+ Campaign campaign = dataModel.getCampaign();
+ Region region = campaign.getRegion();
+
+ List<RouteType> routeTypes = dataModel.getRouteTypes();
+ List<Strate> strates = dataModel.getStrates();
+
+ TopiaContext tx = context.getPersistence().beginTransaction();
+
+ try {
+ // get flights for campaign (and between begin - end date)
+ Iterable<Flight> flights = flightService.getFlights(
+ tx,
+ campaign,
+ dataModel.getBeginDate(),
+ dataModel.getEndDate());
+
+ // Export for each flight
+ for (Flight flight : flights) {
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Export Efforts from flight {} - {} - {} - {}",
+ new Object[]{flight.getFlightNumber(),
+ flight.getSystemId(),
+ campaign.getCode(),
+ region.getCode()}
+ );
+ }
+
+ // common properties for the flight
+ Map<String, Object> commonRecord = Maps.newHashMap();
+ fillFlightRecord(campaign, region, flight, commonRecord);
+
+ // get all routes of this flight
+ List<Route> routes = flightService.getRoutes(tx, flight);
+
+ // get all geo points for this flight
+ List<GeoPoint> geoPoints = flightService.getFlightGeoPoints(tx, flight);
+
+ // get best geo points for each route
+ Iterable<GeoPoint> routeGeoPoints =
+ GeoPoints.getClosestPoints(geoPoints, Routes.toDates(routes));
+
+ // to iterate on geoPoints
+ Iterator<GeoPoint> geoPointIterator = routeGeoPoints.iterator();
+
+ // to keep current effort group identifier
+ String effortGroup = null;
+
+ Route previousRoute = null;
+ for (Route route : routes) {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Export Efforts from route {} - {}",
+ new Object[]{route.getBeginTime(),
+ route.getRouteType()}
+ );
+ }
+
+ // get geoPoint associated with this route
+ GeoPoint geoPoint = geoPointIterator.next();
+
+ // is current route a leg ?
+ boolean routeIsLeg = Routes.isRouteLeg(route);
+
+ if (!routeIsLeg) {
+
+ if (effortGroup != null) {
+
+ // previous route was a leg
+ // need to create a end row (to close the group)
+
+ Map<String, Object> record = Maps.newHashMap();
+ record.putAll(commonRecord);
+
+ // add route data
+ fillRouteRecord(flight,
+ previousRoute,
+ effortGroup,
+ LegStatus.END,
+ record);
+
+ // add geoPoint data and flush
+ fillGeoPointRecordAndFlush(geoPoint,
+ record,
+ builder,
+ graphicList);
+ }
+
+ // reset effort group
+ // will be recomputed by first next leg route
+ effortGroup = null;
+ }
+
+ boolean routeIsValid = Routes.isRouteAccepted(route,
+ routeTypes,
+ strates);
+
+ if (routeIsValid) {
+
+ // selected route = one row on dbf
+
+ Map<String, Object> record = Maps.newHashMap();
+ record.putAll(commonRecord);
+
+ LegStatus legStatus = null;
+
+ if (routeIsLeg) {
+
+ if (effortGroup == null) {
+
+ // this is the first route of the leg group
+ legStatus = LegStatus.BEGIN;
+
+ // compute the unique effortGroup for this group
+ effortGroup = computeEffortGroup(flight, route);
+ } else {
+
+ // group already began, just add a route to it
+ legStatus = LegStatus.ADD;
+ }
+
+ }
+
+ // add route data
+ fillRouteRecord(flight,
+ route,
+ effortGroup,
+ legStatus,
+ record);
+
+
+ // add geoPoint data and flush
+ fillGeoPointRecordAndFlush(geoPoint,
+ record,
+ builder,
+ graphicList);
+ }
+
+ // keep current route as previousroute
+ previousRoute = route;
+ }
+ }
+
+ startTime = timeLog.log(
+ startTime,
+ "exportEffortsMap",
+ "after building EsriGraphicList and DbfTableModel");
+
+ flushExport(builder, dataModel, graphicList);
+
+ timeLog.log(startTime, "exportEffortsMap", "after EsriShapeExport execution");
+ } finally {
+ context.getPersistence().endTransaction(tx);
+ }
+ }
+
+ public void exportObservationsMap(ExportMapModel dataModel) {
+ Preconditions.checkNotNull(dataModel.getCampaign());
+ Preconditions.checkNotNull(dataModel.getBeginDate());
+ Preconditions.checkNotNull(dataModel.getEndDate());
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Start ObservationsMap export to {} :: {}",
+ dataModel.getExportDirectory(),
+ dataModel.getExportFilename());
+ }
+ long startTime = TimeLog.getTime();
+
+ // * uniquement pour un parcours de type LEG, sinon la cellule sera vide
+ DbfTableModelBuilder builder = new DbfTableModelBuilder()
+ .stringColumn("REGION") // (campaign.region.code)
+ .stringColumn("CAMPAIGN") // (campaign.code)
+ .integerColumn("SECTOR") // * (route.transectFlight.transect.strate.sector.sectorNumber)
+ .stringColumn("STRATE_TYPE") // * (route.transectFlight.transect.strate.strateType.code)
+ .stringColumn("STRATE") // * (route.transectFlight.transect.strate.code)
+ .stringColumn("TRANSECT") // * (route.transectFlight.transect.name)
+ .integerColumn("PASSAGE") // * (route.transectFlight.crossingNumber)
+ .integerColumn("FLIGHT") // (route.flight.flightNumber)
+ .stringColumn("COMPUTER") // (route.flight.systemId)
+ .stringColumn("ROUTE_TYPE") // (route.routeType.name)
+ .stringColumn("EFFORT_GROUP") // * (voir doc)
+ .stringColumn("EFFORT") // * (voir doc)
+ .stringColumn("OBSERVATION") // (voir doc)
+ .dateColumn("DATE") // (observation.beginTime)
+ .stringColumn("HHMMSS") // (format(observation.beginTime, "HHmmss"))
+ .stringColumn("TAXON") // (observation.species.type)
+ .stringColumn("GROUP") // (observation.species.groupName)
+ .stringColumn("FAMILY") // (observation.species.family)
+ .stringColumn("SPECIES") // (observation.species.code)
+ .stringColumn("SPECIES_NAME") // (observation.species.commonName)
+ .stringColumn("SPECIES_LATIN") // (observation.species.latinName)
+ .integerColumn("POD_SIZE") // (observation.podSize)
+ .stringColumn("AGE") // (observation.age)
+ .integerColumn("DEC_ANGLE") // (observation.decAngle)
+ .stringColumn("CUE") // (observation.cue)
+ .stringColumn("BEHAVIOUR") // (observation.behaviour)
+ .integerColumn("SWIM_DIR") // (observation.swimDir)
+ .stringColumn("CALVES") // (observation.calves)
+ .booleanColumn("PHOTO") // (observation.photo)
+ .stringColumn("OBSERVER") // (observation.observerPosition.observer.initials)
+ .stringColumn("SIDE") // (observation.observerPosition.observer.position.name)
+ .stringColumn("STATUS") // (observation.observationStatus.name)
+ .stringColumn("CB_CAUSE") // ** ()
+ .doubleColumn("LAT", 19, 11) // (geoPoint.latitude)
+ .doubleColumn("LON", 19, 11) // (geoPoint.longitude)
+ .doubleColumn("SPEED", 19, 11) // (geoPoint.speed)
+ .doubleColumn("ALTITUDE", 19, 11) // (geoPoint.altitude)
+ .stringColumn("GPS_TIME") // (format(geoPoint.recordTime, "HHmmss"))
+ .stringColumn("AIRCRAFT") // (flight.immatriculation)
+ .stringColumn("COMMENT") // (observation.comment)
+ .build();
+
+ EsriGraphicList graphicList = new EsriPointList();
+
+ Campaign campaign = dataModel.getCampaign();
+ Region region = campaign.getRegion();
+ List<RouteType> routeTypes = dataModel.getRouteTypes();
+ List<Strate> strates = dataModel.getStrates();
+
+ TopiaContext tx = context.getPersistence().beginTransaction();
+
+ try {
+ FlightService flightService = context.getFlightService();
+
+ // get flights for campaign (and between begin - end date)
+ Iterable<Flight> flights = flightService.getFlights(
+ tx,
+ campaign,
+ dataModel.getBeginDate(),
+ dataModel.getEndDate());
+
+ // Export for each flight
+
+ for (Flight flight : flights) {
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Export Observations from flight {} - {} - {} - {}",
+ new Object[]{flight.getFlightNumber(),
+ flight.getSystemId(),
+ campaign.getCode(),
+ region.getCode()}
+ );
+ }
+
+ // get all observations for this flight
+ List<Observation> observations =
+ flightService.getObservations(tx, flight);
+
+ // apply species filter
+ Observations.removeOtherSpecies(observations,
+ dataModel.getSpecies());
+
+ // get all routes of this flight
+ List<Route> routes = flightService.getRoutes(tx, flight);
+
+ // get all geo points for this flight
+ List<GeoPoint> routeGeoPoints =
+ flightService.getFlightGeoPoints(tx, flight);
+
+ Map<String, Object> flightRecord = Maps.newHashMap();
+ fillFlightRecord(campaign, region, flight, flightRecord);
+
+ int nextRouteIndex = 0;
+ int nbRoutes = routes.size();
+ String effortGroup = null;
+
+ for (Route route : routes) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Export Observations from route {} - {} (flight end time {})",
+ new Object[]{route.getBeginTime(),
+ route.getRouteType(),
+ flight.getEndDate()}
+ );
+ }
+ nextRouteIndex++;
+
+ boolean routeIsLeg = Routes.isRouteLeg(route);
+
+ if (!routeIsLeg) {
+
+ // new group will be computed at next leg route
+ effortGroup = null;
+ }
+
+ // compute route period
+ Date beginTime = route.getBeginTime();
+ Date routeEndTime;
+
+ if (nextRouteIndex < nbRoutes) {
+
+ // use next route begin time
+ Route nextRoute = routes.get(nextRouteIndex);
+ routeEndTime = nextRoute.getBeginTime();
+ } else {
+
+ // use flight end date
+ routeEndTime = flight.getEndDate();
+ }
+ if (routeEndTime != null) {
+ Preconditions.checkState(routeEndTime.after(beginTime),
+ String.format("Route debut de route %s - fin de route %s", beginTime, routeEndTime));
+ }
+
+ PeriodDates routePeriod =
+ new PeriodDates(beginTime, routeEndTime);
+
+ // Get observations for this route
+ List<Observation> routeObservations =
+ Observations.retainsObservations(observations,
+ routePeriod);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Export Observations from route {} [{}-{}] nb observations {}",
+ new Object[]{beginTime,
+ routeEndTime,
+ routeObservations.size()}
+ );
+ }
+ if (!Routes.isRouteAccepted(route, routeTypes, strates)) {
+
+ // not selected route
+ continue;
+ }
+
+ Map<String, Object> routeRecord = Maps.newHashMap();
+ routeRecord.putAll(flightRecord);
+
+ if (routeIsLeg && effortGroup == null) {
+
+ // compute effort group id
+ effortGroup = computeEffortGroup(flight, route);
+ }
+
+ fillRouteTypeRecord(flight, route, effortGroup, routeRecord);
+
+ // get best geo points for each observation
+ Iterable<GeoPoint> observationGeoPoints =
+ GeoPoints.getClosestPoints(
+ routeGeoPoints,
+ Observations.toDates(routeObservations));
+
+ // to iterate on geoPoints
+ Iterator<GeoPoint> geoPointIterator =
+ observationGeoPoints.iterator();
+
+ for (Observation observation : routeObservations) {
+
+ Map<String, Object> record = Maps.newHashMap();
+ record.putAll(routeRecord);
+
+ String observationId = computeObservationId(flight, observation);
+ record.put("OBSERVATION", observationId);
+
+ fillDateRecord(observation.getObservationTime(), record);
+
+ Species species = observation.getSpecies();
+ if (species != null) {
+ record.put("TAXON", species.getType());
+ record.put("GROUP", species.getGroupName());
+ record.put("FAMILY", species.getFamily());
+ record.put("SPECIES", species.getCode());
+ record.put("SPECIES_NAME", species.getCommonName());
+ record.put("SPECIES_LATIN", species.getLatinName());
+ }
+ record.put("POD_SIZE", observation.getPodSize());
+ record.put("AGE", observation.getAge());
+ record.put("DEC_ANGLE", observation.getDecAngle());
+ record.put("CUE", observation.getCue());
+ record.put("BEHAVIOUR", observation.getBehaviour());
+ record.put("SWIM_DIR", observation.getSwimDir());
+ record.put("CALVES", observation.getCalves());
+ record.put("PHOTO", observation.isPhoto());
+ record.put("OBSERVER", observation.getObserverPosition().getObserver().getInitials());
+ record.put("SIDE", observation.getObserverPosition().getPosition());
+ record.put("STATUS", observation.getObservationStatus());
+ record.put("COMMENT", observation.getComment());
+
+ GeoPoint geoPoint = geoPointIterator.next();
+
+ // add geoPoint data and flush
+ fillGeoPointRecordAndFlush(geoPoint,
+ record,
+ builder,
+ graphicList);
+
+ }
+ }
+ }
+
+ startTime = timeLog.log(startTime, "exportObservationsMap", "after building EsriGraphicList and DbfTableModel");
+
+ flushExport(builder, dataModel, graphicList);
+
+ timeLog.log(startTime, "exportObservationsMap", "after EsriShapeExport execution");
+ } finally {
+ context.getPersistence().endTransaction(tx);
+ }
+ }
+
+ public void exportGeoPointsMap(ExportMapModel dataModel) {
+
+ Preconditions.checkNotNull(dataModel.getCampaign());
+ Preconditions.checkNotNull(dataModel.getBeginDate());
+ Preconditions.checkNotNull(dataModel.getEndDate());
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Start GeoPointsMap export to {} :: {}",
+ dataModel.getExportDirectory(),
+ dataModel.getExportFilename());
+ }
+
+ long startTime = TimeLog.getTime();
+
+ DbfTableModelBuilder builder = new DbfTableModelBuilder()
+ .stringColumn("REGION")
+ .stringColumn("CAMPAIGN")
+ .integerColumn("FLIGHT")
+ .stringColumn("COMPUTER")
+ .stringColumn("AIRCRAFT")
+ .dateColumn("DATE")
+ .stringColumn("HHMMSS")
+ .doubleColumn("LAT", 19, 11)
+ .doubleColumn("LON", 19, 11)
+ .doubleColumn("SPEED", 19, 11)
+ .doubleColumn("ALTITUDE", 19, 11)
+ .build();
+
+ Campaign campaign = dataModel.getCampaign();
+ Region region = campaign.getRegion();
+
+ FlightService flightService = context.getFlightService();
+
+ // get flights for campaign (and between begin - end date)
+ Iterable<Flight> flights = flightService.getFlights(campaign,
+ dataModel.getBeginDate(),
+ dataModel.getEndDate());
+
+ EsriGraphicList graphicList = new EsriPointList();
+
+ // Export for each flight
+ for (Flight flight : flights) {
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Export GeoPoints from flight {} - {} - {} - {}",
+ new Object[]{flight.getFlightNumber(),
+ flight.getSystemId(),
+ campaign.getCode(),
+ region.getCode()}
+ );
+ }
+
+ List<GeoPoint> geoPoints =
+ flightService.getFlightGeoPoints(flight);
+
+ Map<String, Object> commonRecord = Maps.newHashMap();
+ fillFlightRecord(campaign, region, flight, commonRecord);
+
+ // One record by GeoPoint
+ for (GeoPoint geoPoint : geoPoints) {
+
+ Map<String, Object> record = Maps.newHashMap();
+ record.putAll(commonRecord);
+
+ fillDateRecord(geoPoint.getRecordTime(), record);
+
+ // add geoPoint data and flush
+ fillGeoPointRecordAndFlush(geoPoint,
+ record,
+ builder,
+ graphicList);
+ }
+ }
+
+ startTime = timeLog.log(startTime, "exportGeoPointsMap",
+ "after building EsriGraphicList and DbfTableModel");
+
+ flushExport(builder, dataModel, graphicList);
+
+ timeLog.log(startTime, "exportGeoPointsMap",
+ "after EsriShapeExport execution");
+ }
+
+ protected void flushExport(DbfTableModelBuilder builder,
+ ExportMapModel dataModel,
+ EsriGraphicList graphicList) {
+
+ DbfTableModel tableModel = builder.getModel();
+ String pathFile = new File(dataModel.getExportDirectory(),
+ dataModel.getExportFilename()).getAbsolutePath();
+ EsriShapeExport shapeExport = new EsriShapeExport(graphicList, tableModel, pathFile);
+ shapeExport.export();
+ }
+
+ protected void fillDateRecord(Date date, Map<String, Object> record) {
+ record.put("DATE", date);
+ record.put("HHMMSS", timeFormat.format(date));
+ }
+
+ protected void fillGeoPointRecordAndFlush(GeoPoint geoPoint,
+ Map<String, Object> record,
+ DbfTableModelBuilder builder,
+ EsriGraphicList graphicList) {
+
+ record.put("LAT", geoPoint.getLatitude());
+ record.put("LON", geoPoint.getLongitude());
+ record.put("SPEED", geoPoint.getSpeed());
+ record.put("ALTITUDE", geoPoint.getAltitude());
+
+ builder.addValues(record);
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Record={}", record);
+ }
+
+ OMGraphic graphic = new OMPoint(geoPoint.getLatitude(),
+ geoPoint.getLongitude());
+ graphicList.add(graphic);
+ }
+
+ protected void fillFlightRecord(Campaign campaign,
+ Region region,
+ Flight flight,
+ Map<String, Object> record) {
+
+ record.put("REGION", region.getCode());
+ record.put("CAMPAIGN", campaign.getCode());
+ record.put("FLIGHT", flight.getFlightNumber());
+ record.put("AIRCRAFT", flight.getImmatriculation());
+ record.put("COMPUTER", flight.getSystemId());
+ }
+
+ protected void fillRouteRecord(Flight flight,
+ Route route,
+ String effortGroup,
+ LegStatus legStatus,
+ Map<String, Object> record) {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Create Route record for route {} - {}",
+ new Object[]{route.getBeginTime(),
+ route.getRouteType()}
+ );
+ }
+
+ fillDateRecord(route.getBeginTime(), record);
+ fillRouteTypeRecord(flight, route, effortGroup, record);
+
+ if (legStatus != null) {
+ record.put("STATUS", legStatus);
+ }
+ record.put("COMMENT", route.getComment());
+ record.put("SEA_STATE", route.getSeaState());
+ record.put("SWELL", route.getSwell());
+ record.put("TURBIDITY", route.getTurbidity());
+ record.put("SKY_GLINT", route.getSkyGlint());
+ if (route.getGlareFrom() != null) {
+ record.put("GLARE_FROM", String.valueOf(route.getGlareFrom()));
+ }
+ if (route.getGlareTo() != null) {
+ record.put("GLARE_TO", String.valueOf(route.getGlareTo()));
+ }
+ record.put("GLARE_SEVERITY", route.getGlareSeverity());
+ record.put("GLARE_UNDER", route.isGlareUnder());
+ record.put("CLOUD_COVER", route.getCloudCover());
+ record.put("SUBJECTIVE", route.getSubjectiveConditions());
+ record.put("UNEXP_LEFT", route.getUnexpectedLeft());
+ record.put("UNEXP_RIGHT", route.getUnexpectedRight());
+
+ ObserverPosition observerPositionByPosition =
+ route.getObserverPositionByPosition(Position.FRONT_LEFT);
+ if (observerPositionByPosition != null && observerPositionByPosition.getObserver() != null) {
+ record.put("LEFT_REAR", observerPositionByPosition.getObserver().getInitials());
+ }
+ observerPositionByPosition =
+ route.getObserverPositionByPosition(Position.FRONT_RIGHT);
+ if (observerPositionByPosition != null && observerPositionByPosition.getObserver() != null) {
+ record.put("RIGHT_REAR", observerPositionByPosition.getObserver().getInitials());
+ }
+ observerPositionByPosition =
+ route.getObserverPositionByPosition(Position.NAVIGATOR);
+ if (observerPositionByPosition != null && observerPositionByPosition.getObserver() != null) {
+ record.put("CENTER", observerPositionByPosition.getObserver().getInitials());
+ }
+ }
+
+ protected void fillRouteTypeRecord(Flight flight,
+ Route route,
+ String effortGroup,
+ Map<String, Object> record) {
+
+ record.put("ROUTE_TYPE", route.getRouteType());
+ if (Routes.isRouteLeg(route)) {
+ fillLegRouteRecord(route, effortGroup, record);
+ }
+
+ if (Routes.isRouteCircleBack(route)) {
+
+ // compute circle back cause
+ String circleBackCause = computeObservationId(flight, route.getCircleBackCause());
+ record.put("CB_CAUSE", circleBackCause);
+ }
+ }
+
+ protected void fillLegRouteRecord(Route route,
+ String effortGroup,
+ Map<String, Object> record) {
+
+ TransectFlight transectFlight = route.getTransectFlight();
+ Transect transect = transectFlight.getTransect();
+ Strate strate = transect.getStrate();
+
+ String effort = computeEffort(route);
+
+ record.put("SECTOR", strate.getSector().getSectorNumber());
+ record.put("STRATE_TYPE", strate.getStrateType().getCode());
+ record.put("STRATE", strate.getCode());
+ record.put("TRANSECT", transect.getName());
+ record.put("PASSAGE", transectFlight.getCrossingNumber());
+ record.put("EFFORT_GROUP", effortGroup);
+ record.put("EFFORT", effort);
+ }
+
+ protected String computeEffort(Route route) {
+ String result = "L" + route.getEffortNumber() + "-" +
+ route.getFlight().getFlightNumber() + "-" +
+ route.getFlight().getSystemId();
+ return result;
+ }
+
+ protected String computeEffortGroup(Flight flight, Route route) {
+ String result = "G" + route.getEffortNumber() + "-" +
+ flight.getFlightNumber() + "-" +
+ flight.getSystemId();
+ return result;
+ }
+
+ protected String computeObservationId(Flight flight, Observation observation) {
+ return "O" + observation.getObservationNumber() + "-" +
+ flight.getFlightNumber() + "-" +
+ flight.getSystemId();
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/LegStatus.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/LegStatus.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/LegStatus.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/LegStatus.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,39 @@
+package fr.ulr.sammoa.application.io.output.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public enum LegStatus {
+ BEGIN,
+ ADD, END;
+
+ public String getName() {
+ return name();
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/LegStatus.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationCallbackMode.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationCallbackMode.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationCallbackMode.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationCallbackMode.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,51 @@
+package fr.ulr.sammoa.application.io.output.sammoa;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * What to do after a application export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public enum ExportApplicationCallbackMode {
+ /**
+ * Do nothing.
+ * <p/>
+ * Says after this every thing stay in place.
+ */
+ NOTHING,
+ /**
+ * Remove flight data.
+ * <p/>
+ * Says after this referential are still there (Region, Campaign, Strate, Observer, Species).
+ */
+ REMOVE_FLIGHTS,
+ /**
+ * Remove campaign data.
+ * <p/>
+ * Says after this, there is no more stuff in db.
+ */
+ REMOVE_ALL
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationCallbackMode.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationModel.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationModel.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationModel.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,85 @@
+package fr.ulr.sammoa.application.io.output.sammoa;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Flight;
+
+import java.io.File;
+import java.io.Serializable;
+
+/**
+ * Model of export application.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ExportApplicationModel implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static ExportApplicationModel newModel(File exportDirectory,
+ String exportFilename,
+ Campaign campaign,
+ Flight flight,
+ ExportApplicationCallbackMode callback) {
+ ExportApplicationModel result = new ExportApplicationModel();
+ result.exportDirectory = exportDirectory;
+ result.exportFilename = exportFilename;
+ result.campaign = campaign;
+ result.flight = flight;
+ result.callback = callback;
+ return result;
+ }
+
+ protected Campaign campaign;
+
+ protected Flight flight;
+
+ protected File exportDirectory;
+
+ protected String exportFilename;
+
+ protected ExportApplicationCallbackMode callback;
+
+ public File getExportDirectory() {
+ return exportDirectory;
+ }
+
+ public String getExportFilename() {
+ return exportFilename;
+ }
+
+ public Campaign getCampaign() {
+ return campaign;
+ }
+
+ public Flight getFlight() {
+ return flight;
+ }
+
+ public ExportApplicationCallbackMode getCallback() {
+ return callback;
+ }
+}
\ No newline at end of file
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationService.java (from rev 413, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationService.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationService.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationService.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,119 @@
+package fr.ulr.sammoa.application.io.output.sammoa;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.application.SammoaConfig;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.application.io.CampaignStorage;
+import fr.ulr.sammoa.application.io.CampaignStorages;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.SammoaPersistence;
+import org.nuiton.util.TimeLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * To export application as a {@code sammoa} file.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ExportApplicationService {
+
+ /** Logger. */
+ private static final Logger logger =
+ LoggerFactory.getLogger(ExportApplicationService.class);
+
+
+ private static final TimeLog timeLog =
+ new TimeLog(ExportApplicationService.class);
+
+ protected final SammoaContext context;
+
+ protected final SammoaConfig config;
+
+ protected final SammoaPersistence persistence;
+
+ public ExportApplicationService(SammoaContext context) {
+ this.context = context;
+ this.persistence = context.getPersistence();
+ this.config = context.getConfig();
+ }
+
+ public void exportApplication(ExportApplicationModel model) {
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Start Application export to {} :: {}",
+ model.getExportDirectory(),
+ model.getExportFilename());
+ }
+
+ long startTime = TimeLog.getTime();
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ //BOUH!
+ }
+
+ Campaign campaign = model.getCampaign();
+
+ CampaignStorage storage = CampaignStorages.getStorage(
+ config, campaign.getTopiaId());
+
+ //TODO
+
+ startTime = timeLog.log(startTime, "exportApplication",
+ "after Export execution");
+
+ switch (model.getCallback()) {
+
+ case NOTHING:
+ // nothing to do
+ break;
+ case REMOVE_FLIGHTS:
+ removeFlightData(model);
+ break;
+ case REMOVE_ALL:
+ removeAllData();
+ break;
+ }
+
+ timeLog.log(startTime, "exportApplication", "after Callback execution");
+
+ }
+
+ protected void removeFlightData(ExportApplicationModel model) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Will remove flight data for campaign {}",
+ model.getCampaign().getCode());
+ }
+ }
+
+ protected void removeAllData() {
+ if (logger.isInfoEnabled()) {
+ logger.info("Will remove all data from current db (create a new db...)");
+ }
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/sammoa/ExportApplicationService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfColumnModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfColumnModel.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfColumnModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,83 +0,0 @@
-package fr.ulr.sammoa.application.map;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-/**
- * Note: there is an existing {@link com.bbn.openmap.dataAccess.shape.DbfTableModelFactory.Column}
- * class.
- * <p/>
- * Created: 07/08/12
- *
- * @author fdesbois <florian.desbois(a)codelutin.com>
- */
-public class DbfColumnModel {
-
- protected String name;
-
- protected byte type;
-
- protected int length;
-
- protected byte decimalCount;
-
- protected int index;
-
- public DbfColumnModel(String name, byte type) {
- this.name = name;
- this.type = type;
- this.index = -1;
- }
-
- public String getName() {
- return name;
- }
-
- public byte getType() {
- return type;
- }
-
- public int getLength() {
- return length;
- }
-
- public void setLength(int length) {
- this.length = length;
- }
-
- public int getDecimalCount() {
- return decimalCount;
- }
-
- public void setDecimalCount(int decimalCount) {
- this.decimalCount = (byte) decimalCount;
- }
-
- public int getIndex() {
- return index;
- }
-
- public void setIndex(int index) {
- this.index = index;
- }
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfImport.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfImport.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfImport.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,129 +0,0 @@
-package fr.ulr.sammoa.application.map;
-/*
- * #%L
- * SAMMOA :: UI Swing
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.bbn.openmap.dataAccess.shape.DbfTableModel;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Lists;
-import org.nuiton.util.csv.Import;
-import org.nuiton.util.csv.ImportModel;
-import org.nuiton.util.csv.ImportRuntimeException;
-import org.nuiton.util.csv.ImportableColumn;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Created: 25/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class DbfImport<E> extends Import<E> {
-
- private static final Logger logger = LoggerFactory.getLogger(DbfImport.class);
-
- protected DbfTableModel source;
-
- protected Iterator<List<Object>> records;
-
- protected List<Object> record;
-
- public DbfImport(ImportModel<E> model, URL fileUrl) {
- // Use dummy reader for superclass Import that manage by default csv files
- super(model, new Reader() {
-
- @Override
- public int read(char[] cbuf, int off, int len) throws IOException {
- return -1;
- }
-
- @Override
- public void close() throws IOException {
- }
- });
-
- try {
- // FIXME-fdesbois-2012-07-26 : there is an issue with encoding, don't know how to customize it
- this.source = DbfTableModel.read(fileUrl);
-
- } catch (Exception e) {
- throw Throwables.propagate(e);
- }
- this.records = source.getRecords();
- }
-
- @Override
- protected <T> String readValue(ImportableColumn<E, T> field, int lineNumber) {
- try {
-
- int columnNumber = source.getColumnIndexForName(field.getHeaderName());
-
- String value = String.valueOf(record.get(columnNumber));
-
- return value;
-
- } catch (Exception e) {
- throw new ImportRuntimeException(
- _("csv.import.error.unableToReadField",
- field.getHeaderName(), lineNumber), e);
- }
- }
-
- @Override
- public void close() {
- // nothing to do
- }
-
- @Override
- protected boolean readRow() throws ImportRuntimeException {
- boolean result;
- if (records.hasNext()) {
- record = records.next();
- if (logger.isTraceEnabled()) {
- logger.trace("Read record {}", record);
- }
- result = true;
-
- } else {
- result = false;
- }
- return result;
- }
-
- @Override
- protected String[] getHeaders() throws ImportRuntimeException {
- List<String> list = Lists.newArrayList();
- for (int index = 0; index < source.getColumnCount(); index++) {
- list.add(source.getColumnName(index));
- }
- return list.toArray(new String[list.size()]);
- }
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTableModelBuilder.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTableModelBuilder.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTableModelBuilder.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,229 +0,0 @@
-package fr.ulr.sammoa.application.map;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.bbn.openmap.dataAccess.shape.DbfTableModel;
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created: 07/08/12
- *
- * @author fdesbois <florian.desbois(a)codelutin.com>
- */
-public class DbfTableModelBuilder {
-
- /** Logger. */
- private static final Logger logger =
- LoggerFactory.getLogger(DbfTableModelBuilder.class);
-
- public static final int DEFAULT_STRING_LENGTH = 64;
-
- public static final int DEFAULT_INTEGER_LENGTH = 8;
-
- public static final String DATE_FORMAT_PATTERN = "yyyyMMdd";
-
- public static final DateFormat DATE_FORMAT = new SimpleDateFormat(DATE_FORMAT_PATTERN);
-
- protected List<DbfColumnModel> columns;
-
- protected Map<String, DbfColumnModel> columnMap;
-
- protected DbfTableModel model;
-
- public DbfTableModelBuilder() {
- columns = Lists.newArrayList();
- }
-
- public DbfTableModelBuilder dbfColumn(DbfColumnModel column) {
- if (column.getIndex() != -1) {
- columns.add(column.getIndex(), column);
- } else {
- column.setIndex(columns.size());
- columns.add(column);
- }
- return this;
- }
-
- public DbfColumnModel newStringColumn(String name) {
- DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_CHARACTER);
- result.setLength(DEFAULT_STRING_LENGTH);
- return result;
- }
-
- public DbfColumnModel newIntegerColumn(String name) {
- DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_NUMERIC);
- result.setLength(DEFAULT_INTEGER_LENGTH);
- return result;
- }
-
- public DbfColumnModel newDoubleColumn(String name, int length, int decimalCount) {
- DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_NUMERIC);
- result.setLength(length);
- result.setDecimalCount(decimalCount);
- return result;
- }
-
- public DbfColumnModel newTimestampColumn(String name) {
- DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_TIMESTAMP);
- return result;
- }
-
- public DbfColumnModel newDateColumn(String name) {
- DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_DATE);
- result.setLength(DATE_FORMAT_PATTERN.length());
- return result;
- }
-
- public DbfColumnModel newBooleanColumn(String name) {
- DbfColumnModel result = new DbfColumnModel(name, DbfTableModel.TYPE_LOGICAL);
- result.setLength(1);
- return result;
- }
-
- public DbfTableModelBuilder stringColumn(String name) {
- return dbfColumn(newStringColumn(name));
- }
-
- public DbfTableModelBuilder booleanColumn(String name) {
- return dbfColumn(newBooleanColumn(name));
- }
-
- public DbfTableModelBuilder integerColumn(String name) {
- return dbfColumn(newIntegerColumn(name));
- }
-
- public DbfTableModelBuilder doubleColumn(String name, int length, int decimalCount) {
- return dbfColumn(newDoubleColumn(name, length, decimalCount));
- }
-
- public DbfTableModelBuilder timestampColumn(String name) {
- return dbfColumn(newTimestampColumn(name));
- }
-
- public DbfTableModelBuilder dateColumn(String name) {
- return dbfColumn(newDateColumn(name));
- }
-
- public DbfTableModelBuilder build() {
- model = new DbfTableModel(columns.size());
- model.setWritable(true);
-
- for (int i = 0; i < columns.size(); i++) {
- DbfColumnModel columnModel = columns.get(i);
- model.setColumnName(i, columnModel.getName());
- model.setType(i, columnModel.getType());
- model.setLength(i, columnModel.getLength());
- model.setDecimalCount(i, (byte) columnModel.getDecimalCount());
- }
- columnMap = Maps.uniqueIndex(columns,
- new Function<DbfColumnModel, String>() {
-
- @Override
- public String apply(DbfColumnModel input) {
- return input.getName();
- }
- });
- return this;
- }
-
- public DbfTableModel getModel() {
- return model;
- }
-
- public void setValue(int rowIndex, String columnName, Object value) {
- Preconditions.checkState(model != null, "Model must be built before setting values");
-
- DbfColumnModel column = columnMap.get(columnName);
-
- int columnIndex = column.getIndex();
- value = cleanValue(value, column.getType());
- model.setValueAt(value, rowIndex, columnIndex);
- }
-
- public int addValues(Map<String, Object> values) {
- Preconditions.checkState(model != null, "Model must be built before adding values");
-
- model.addBlankRecord();
- int rowIndex = model.getRowCount() - 1;
- for (Map.Entry<String, Object> entry : values.entrySet()) {
- setValue(rowIndex, entry.getKey(), entry.getValue());
- }
- return rowIndex;
- }
-
- protected Object cleanValue(Object value, byte type) {
-
- Object result = value;
- if (DbfTableModel.isNumericalType(type)) {
-
- // FIX for Integer Format error in DbfTableModel#getStringForType
- if (value instanceof Integer) {
- result = Double.valueOf(String.valueOf(value));
- }
- } else if (DbfTableModel.TYPE_TIMESTAMP == type) {
-
- // FIX for Date : no format is done
- if (value instanceof Date) {
- Date date = (Date) value;
-
- result = DbfTimestampConverter.toString(date);
- }
- } else if (DbfTableModel.TYPE_DATE == type) {
-
- // FIX for Date : no format is done
- if (value instanceof Date) {
- Date date = (Date) value;
-
- result = DATE_FORMAT.format(date);
- }
- } else if (DbfTableModel.TYPE_LOGICAL == type) {
- result = ((Boolean) value) ? "T" : "F";
- } else if (value instanceof Enum) {
- result = ((Enum) value).name();
- } else if (value instanceof Character) {
- result = String.valueOf(value);
- }
-
- if (result != null &&
- !(result instanceof String) &&
- !(result instanceof Double)) {
- if (logger.isWarnEnabled()) {
- logger.warn("Incompatible data value {} (type {})", result, type);
- }
- }
- return result;
- }
-
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTimestampConverter.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTimestampConverter.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/DbfTimestampConverter.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,115 +0,0 @@
-package fr.ulr.sammoa.application.map;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import org.nuiton.util.DateUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-/**
- * Created: 08/08/12
- *
- * @author fdesbois <florian.desbois(a)codelutin.com>
- */
-public final class DbfTimestampConverter {
-
- protected static final Long HOUR_MULT = 3600000L;
- protected static final Long MINUTE_MULT = 60000L;
- protected static final Long SECOND_MULT = 1000L;
-
-
- private static final Logger logger = LoggerFactory.getLogger(DbfTimestampConverter.class);
-
- private DbfTimestampConverter() {
- // static class
- }
-
- public static String toString(Date date) {
-
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(date);
-
- Calendar refCalendar = getReferenceCalendar();
-
- long dateValue = DateUtil.getDifferenceInDays(refCalendar.getTime(), date);
- long timeValue = calendar.get(Calendar.HOUR_OF_DAY) * HOUR_MULT
- + calendar.get(Calendar.MINUTE) * MINUTE_MULT
- + calendar.get(Calendar.SECOND) * SECOND_MULT;
-
- String result = dateValue + " " + timeValue;
- return result;
- }
-
- public static Date toDate(String timestamp) {
- Preconditions.checkArgument(Strings.nullToEmpty(timestamp).trim().contains(" "),
- "A space is missing between the date and time values");
-
- String[] values = timestamp.split(" ");
-
- Long dateValue = Long.parseLong(values[0]);
- Long timeValue = Long.parseLong(values[1]);
-
- Calendar refCalendar = getReferenceCalendar();
-
- Calendar resultCalendar = new GregorianCalendar();
- resultCalendar.setTime(refCalendar.getTime());
-
- resultCalendar.add(Calendar.DATE, dateValue.intValue());
-
- Long hours = timeValue / HOUR_MULT;
- Long timeWithoutHours = timeValue - hours * HOUR_MULT;
- Long minutes = timeWithoutHours / MINUTE_MULT;
- Long seconds = (timeWithoutHours - minutes * MINUTE_MULT) / SECOND_MULT;
-
- resultCalendar.set(Calendar.HOUR_OF_DAY, hours.intValue());
- resultCalendar.set(Calendar.MINUTE, minutes.intValue());
- resultCalendar.set(Calendar.SECOND, seconds.intValue());
-
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("DateValue=%d, TimeValue=%d, Hours=%d, Minutes=%d, Seconds=%d, Result=%s",
- dateValue,
- timeValue,
- hours,
- minutes,
- seconds,
- resultCalendar)
- );
- }
-
- return resultCalendar.getTime();
- }
-
- private static Calendar getReferenceCalendar() {
- Calendar result = new GregorianCalendar(4713, 0, 1);
- result.set(Calendar.ERA, GregorianCalendar.BC);
- return result;
- }
-
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,124 +0,0 @@
-package fr.ulr.sammoa.application.map;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import fr.ulr.sammoa.persistence.Campaign;
-import fr.ulr.sammoa.persistence.RouteType;
-import fr.ulr.sammoa.persistence.Species;
-import fr.ulr.sammoa.persistence.Strate;
-
-import java.io.File;
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Model of export map.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.5
- */
-public class ExportMapModel implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static ExportMapModel newModel(File exportDirectory,
- String exportFilename,
- Campaign campaign,
- Date beginDate,
- Date endDate,
- List<Strate> strates,
- List<RouteType> routeTypes,
- List<Species> species) {
- ExportMapModel result = new ExportMapModel();
- result.exportDirectory=exportDirectory;
- result.exportFilename=exportFilename;
- result.campaign = campaign;
- result.beginDate = beginDate;
- result.endDate = endDate;
- result.strates = strates;
- result.routeTypes = routeTypes;
- result.species = species;
- return result;
- }
-
- protected Campaign campaign;
-
- protected Date beginDate;
-
- protected Date endDate;
-
- protected List<Strate> strates;
-
- protected List<RouteType> routeTypes;
-
- protected List<Species> species;
-
- protected File exportDirectory;
-
- protected String exportFilename;
-
- public File getExportDirectory() {
- return exportDirectory;
- }
-
- public String getExportFilename() {
- return exportFilename;
- }
-
- public Campaign getCampaign() {
- return campaign;
- }
-
- public Date getBeginDate() {
- return beginDate;
- }
-
- public Date getEndDate() {
- return endDate;
- }
-
- public List<Strate> getStrates() {
- if (strates == null) {
- strates = Lists.newArrayList();
- }
- return strates;
- }
-
- public List<RouteType> getRouteTypes() {
- if (routeTypes == null) {
- routeTypes = Lists.newArrayList();
- }
- return routeTypes;
- }
-
- public List<Species> getSpecies() {
- if (species == null) {
- species = Lists.newArrayList();
- }
- return species;
- }
-
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,799 +0,0 @@
-package fr.ulr.sammoa.application.map;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.bbn.openmap.dataAccess.shape.DbfTableModel;
-import com.bbn.openmap.dataAccess.shape.EsriGraphicList;
-import com.bbn.openmap.dataAccess.shape.EsriPointList;
-import com.bbn.openmap.dataAccess.shape.EsriShapeExport;
-import com.bbn.openmap.omGraphics.OMGraphic;
-import com.bbn.openmap.omGraphics.OMPoint;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
-import fr.ulr.sammoa.application.FlightService;
-import fr.ulr.sammoa.application.SammoaConfig;
-import fr.ulr.sammoa.application.SammoaContext;
-import fr.ulr.sammoa.persistence.Campaign;
-import fr.ulr.sammoa.persistence.Flight;
-import fr.ulr.sammoa.persistence.GeoPoint;
-import fr.ulr.sammoa.persistence.GeoPoints;
-import fr.ulr.sammoa.persistence.Observation;
-import fr.ulr.sammoa.persistence.Observations;
-import fr.ulr.sammoa.persistence.ObserverPosition;
-import fr.ulr.sammoa.persistence.Position;
-import fr.ulr.sammoa.persistence.Region;
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.persistence.RouteType;
-import fr.ulr.sammoa.persistence.Routes;
-import fr.ulr.sammoa.persistence.SammoaPersistence;
-import fr.ulr.sammoa.persistence.Species;
-import fr.ulr.sammoa.persistence.Strate;
-import fr.ulr.sammoa.persistence.Transect;
-import fr.ulr.sammoa.persistence.TransectFlight;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.util.PeriodDates;
-import org.nuiton.util.TimeLog;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Export map service
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.5
- */
-public class ExportMapService {
-
- private static final Logger logger =
- LoggerFactory.getLogger(ExportMapService.class);
-
- private static final TimeLog timeLog = new TimeLog(ExportMapService.class);
-
- protected SammoaContext context;
-
- protected SammoaConfig config;
-
- protected SammoaPersistence persistence;
-
- protected DateFormat timeFormat;
-
- public ExportMapService(SammoaContext context) {
- this.context = context;
- this.persistence = context.getPersistence();
- this.config = context.getConfig();
- this.timeFormat = new SimpleDateFormat("HHmmss");
- }
-
- public void exportEffortsMap(ExportMapModel dataModel) {
- Preconditions.checkNotNull(dataModel.getCampaign());
- Preconditions.checkNotNull(dataModel.getBeginDate());
- Preconditions.checkNotNull(dataModel.getEndDate());
-
- if (logger.isInfoEnabled()) {
- logger.info("Start EffortsMap export to {} :: {}",
- dataModel.getExportDirectory(),
- dataModel.getExportFilename());
- }
-
- long startTime = TimeLog.getTime();
-
-
- // * uniquement pour un parcours de type LEG, sinon la cellule sera vide
- // ** uniquement pour un parcours de type CIRCLE_BACK, sinon la cellule sera vide
- DbfTableModelBuilder builder = new DbfTableModelBuilder()
- .stringColumn("REGION") // (region.code)
- .stringColumn("CAMPAIGN") // (campaign.code)
- .integerColumn("SECTOR") // * (route.transectFlight.transect.strate.sector.sectorNumber)
- .stringColumn("STRATE_TYPE") // * (route.transectFlight.transect.strate.strateType.code)
- .stringColumn("STRATE") // * (route.transectFlight.transect.strate.code)
- .stringColumn("TRANSECT") // * (route.transectFlight.transect.name)
- .integerColumn("PASSAGE") // * (route.transectFlight.crossingNumber)
- .integerColumn("FLIGHT") // (route.flight.flightNumber)
- .stringColumn("COMPUTER") // (route.flight.systemId)
- .stringColumn("ROUTE_TYPE") // (route.routeType.name)
- .stringColumn("EFFORT_GROUP") // * (voir doc)
- .stringColumn("EFFORT") // * (voir doc)
- .stringColumn("STATUS") // * (voir doc)
- .dateColumn("DATE") // (route.beginTime)
- .stringColumn("HHMMSS") // (format(route.beginTime, "HHmmss"))
- .integerColumn("SEA_STATE") // (route.seaState)
- .integerColumn("SWELL") // (route.swell)
- .integerColumn("TURBIDITY") // (route.turbidity)
- .integerColumn("SKY_GLINT") // (route.skyGlint)
- .stringColumn("GLARE_FROM") // (route.glareFrom)
- .stringColumn("GLARE_TO") // (route.glareTo)
- .integerColumn("GLARE_SEVERITY") // (route.glareSeverity)
- .booleanColumn("GLARE_UNDER") // (route.glareUnder)
- .integerColumn("CLOUD_COVER") // (route.cloudCover)
- .stringColumn("SUBJECTIVE") // (route.subjectiveConditions)
- .stringColumn("UNEXP_LEFT") // (route.unexpectedLeft)
- .stringColumn("UNEXP_RIGHT") // (route.unexpectedRight)
- .stringColumn("LEFT_REAR") // (route.observerPosition[FRONT_LEFT].observer.initials)
- .stringColumn("RIGHT_REAR") // (route.observerPosition[FRONT_RIGHT].observer.initials)
- .stringColumn("CENTER") // (route.observerPosition[NAVIGATOR].observer.initials)
- .stringColumn("CB_CAUSE") // ** ()
- .doubleColumn("LAT", 19, 11) // (geoPoint.latitude)
- .doubleColumn("LON", 19, 11) // (geoPoint.longitude)
- .doubleColumn("SPEED", 19, 11) // (geoPoint.speed)
- .doubleColumn("ALTITUDE", 19, 11) // (geoPoint.altitude)
- .stringColumn("GPS_TIME") // (format(geoPoint.recordTime, "HHmmss"))
- .stringColumn("AIRCRAFT") // (route.flight.immatriculation)
- .stringColumn("COMMENT") // (route.comment)
- .build();
-
- EsriGraphicList graphicList = new EsriPointList();
-
- FlightService flightService = context.getFlightService();
-
- Campaign campaign = dataModel.getCampaign();
- Region region = campaign.getRegion();
-
- List<RouteType> routeTypes = dataModel.getRouteTypes();
- List<Strate> strates = dataModel.getStrates();
-
- TopiaContext tx = context.getPersistence().beginTransaction();
-
- try {
- // get flights for campaign (and between begin - end date)
- Iterable<Flight> flights = flightService.getFlights(
- tx,
- campaign,
- dataModel.getBeginDate(),
- dataModel.getEndDate());
-
- // Export for each flight
- for (Flight flight : flights) {
-
- if (logger.isInfoEnabled()) {
- logger.info("Export Efforts from flight {} - {} - {} - {}",
- new Object[]{flight.getFlightNumber(),
- flight.getSystemId(),
- campaign.getCode(),
- region.getCode()}
- );
- }
-
- // common properties for the flight
- Map<String, Object> commonRecord = Maps.newHashMap();
- fillFlightRecord(campaign, region, flight, commonRecord);
-
- // get all routes of this flight
- List<Route> routes = flightService.getRoutes(tx, flight);
-
- // get all geo points for this flight
- List<GeoPoint> geoPoints = flightService.getFlightGeoPoints(tx, flight);
-
- // get best geo points for each route
- Iterable<GeoPoint> routeGeoPoints =
- GeoPoints.getClosestPoints(geoPoints, Routes.toDates(routes));
-
- // to iterate on geoPoints
- Iterator<GeoPoint> geoPointIterator = routeGeoPoints.iterator();
-
- // to keep current effort group identifier
- String effortGroup = null;
-
- Route previousRoute = null;
- for (Route route : routes) {
-
- if (logger.isTraceEnabled()) {
- logger.trace("Export Efforts from route {} - {}",
- new Object[]{route.getBeginTime(),
- route.getRouteType()}
- );
- }
-
- // get geoPoint associated with this route
- GeoPoint geoPoint = geoPointIterator.next();
-
- // is current route a leg ?
- boolean routeIsLeg = Routes.isRouteLeg(route);
-
- if (!routeIsLeg) {
-
- if (effortGroup != null) {
-
- // previous route was a leg
- // need to create a end row (to close the group)
-
- Map<String, Object> record = Maps.newHashMap();
- record.putAll(commonRecord);
-
- // add route data
- fillRouteRecord(flight,
- previousRoute,
- effortGroup,
- LegStatus.END,
- record);
-
- // add geoPoint data and flush
- fillGeoPointRecordAndFlush(geoPoint,
- record,
- builder,
- graphicList);
- }
-
- // reset effort group
- // will be recomputed by first next leg route
- effortGroup = null;
- }
-
- boolean routeIsValid = Routes.isRouteAccepted(route,
- routeTypes,
- strates);
-
- if (routeIsValid) {
-
- // selected route = one row on dbf
-
- Map<String, Object> record = Maps.newHashMap();
- record.putAll(commonRecord);
-
- LegStatus legStatus = null;
-
- if (routeIsLeg) {
-
- if (effortGroup == null) {
-
- // this is the first route of the leg group
- legStatus = LegStatus.BEGIN;
-
- // compute the unique effortGroup for this group
- effortGroup = computeEffortGroup(flight, route);
- } else {
-
- // group already began, just add a route to it
- legStatus = LegStatus.ADD;
- }
-
- }
-
- // add route data
- fillRouteRecord(flight,
- route,
- effortGroup,
- legStatus,
- record);
-
-
- // add geoPoint data and flush
- fillGeoPointRecordAndFlush(geoPoint,
- record,
- builder,
- graphicList);
- }
-
- // keep current route as previousroute
- previousRoute = route;
- }
- }
-
- startTime = timeLog.log(
- startTime,
- "exportEffortsMap",
- "after building EsriGraphicList and DbfTableModel");
-
- flushExport(builder, dataModel, graphicList);
-
- timeLog.log(startTime, "exportEffortsMap", "after EsriShapeExport execution");
- } finally {
- context.getPersistence().endTransaction(tx);
- }
- }
-
- public void exportObservationsMap(ExportMapModel dataModel) {
- Preconditions.checkNotNull(dataModel.getCampaign());
- Preconditions.checkNotNull(dataModel.getBeginDate());
- Preconditions.checkNotNull(dataModel.getEndDate());
-
- if (logger.isInfoEnabled()) {
- logger.info("Start ObservationsMap export to {} :: {}",
- dataModel.getExportDirectory(),
- dataModel.getExportFilename());
- }
- long startTime = TimeLog.getTime();
-
- // * uniquement pour un parcours de type LEG, sinon la cellule sera vide
- DbfTableModelBuilder builder = new DbfTableModelBuilder()
- .stringColumn("REGION") // (campaign.region.code)
- .stringColumn("CAMPAIGN") // (campaign.code)
- .integerColumn("SECTOR") // * (route.transectFlight.transect.strate.sector.sectorNumber)
- .stringColumn("STRATE_TYPE") // * (route.transectFlight.transect.strate.strateType.code)
- .stringColumn("STRATE") // * (route.transectFlight.transect.strate.code)
- .stringColumn("TRANSECT") // * (route.transectFlight.transect.name)
- .integerColumn("PASSAGE") // * (route.transectFlight.crossingNumber)
- .integerColumn("FLIGHT") // (route.flight.flightNumber)
- .stringColumn("COMPUTER") // (route.flight.systemId)
- .stringColumn("ROUTE_TYPE") // (route.routeType.name)
- .stringColumn("EFFORT_GROUP") // * (voir doc)
- .stringColumn("EFFORT") // * (voir doc)
- .stringColumn("OBSERVATION") // (voir doc)
- .dateColumn("DATE") // (observation.beginTime)
- .stringColumn("HHMMSS") // (format(observation.beginTime, "HHmmss"))
- .stringColumn("TAXON") // (observation.species.type)
- .stringColumn("GROUP") // (observation.species.groupName)
- .stringColumn("FAMILY") // (observation.species.family)
- .stringColumn("SPECIES") // (observation.species.code)
- .stringColumn("SPECIES_NAME") // (observation.species.commonName)
- .stringColumn("SPECIES_LATIN") // (observation.species.latinName)
- .integerColumn("POD_SIZE") // (observation.podSize)
- .stringColumn("AGE") // (observation.age)
- .integerColumn("DEC_ANGLE") // (observation.decAngle)
- .stringColumn("CUE") // (observation.cue)
- .stringColumn("BEHAVIOUR") // (observation.behaviour)
- .integerColumn("SWIM_DIR") // (observation.swimDir)
- .stringColumn("CALVES") // (observation.calves)
- .booleanColumn("PHOTO") // (observation.photo)
- .stringColumn("OBSERVER") // (observation.observerPosition.observer.initials)
- .stringColumn("SIDE") // (observation.observerPosition.observer.position.name)
- .stringColumn("STATUS") // (observation.observationStatus.name)
- .stringColumn("CB_CAUSE") // ** ()
- .doubleColumn("LAT", 19, 11) // (geoPoint.latitude)
- .doubleColumn("LON", 19, 11) // (geoPoint.longitude)
- .doubleColumn("SPEED", 19, 11) // (geoPoint.speed)
- .doubleColumn("ALTITUDE", 19, 11) // (geoPoint.altitude)
- .stringColumn("GPS_TIME") // (format(geoPoint.recordTime, "HHmmss"))
- .stringColumn("AIRCRAFT") // (flight.immatriculation)
- .stringColumn("COMMENT") // (observation.comment)
- .build();
-
- EsriGraphicList graphicList = new EsriPointList();
-
- Campaign campaign = dataModel.getCampaign();
- Region region = campaign.getRegion();
- List<RouteType> routeTypes = dataModel.getRouteTypes();
- List<Strate> strates = dataModel.getStrates();
-
- TopiaContext tx = context.getPersistence().beginTransaction();
-
- try {
- FlightService flightService = context.getFlightService();
-
- // get flights for campaign (and between begin - end date)
- Iterable<Flight> flights = flightService.getFlights(
- tx,
- campaign,
- dataModel.getBeginDate(),
- dataModel.getEndDate());
-
- // Export for each flight
-
- for (Flight flight : flights) {
-
- if (logger.isInfoEnabled()) {
- logger.info("Export Observations from flight {} - {} - {} - {}",
- new Object[]{flight.getFlightNumber(),
- flight.getSystemId(),
- campaign.getCode(),
- region.getCode()}
- );
- }
-
- // get all observations for this flight
- List<Observation> observations =
- flightService.getObservations(tx, flight);
-
- // apply species filter
- Observations.removeOtherSpecies(observations,
- dataModel.getSpecies());
-
- // get all routes of this flight
- List<Route> routes = flightService.getRoutes(tx, flight);
-
- // get all geo points for this flight
- List<GeoPoint> routeGeoPoints =
- flightService.getFlightGeoPoints(tx, flight);
-
- Map<String, Object> flightRecord = Maps.newHashMap();
- fillFlightRecord(campaign, region, flight, flightRecord);
-
- int nextRouteIndex = 0;
- int nbRoutes = routes.size();
- String effortGroup = null;
-
- for (Route route : routes) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Export Observations from route {} - {} (flight end time {})",
- new Object[]{route.getBeginTime(),
- route.getRouteType(),
- flight.getEndDate()}
- );
- }
- nextRouteIndex++;
-
- boolean routeIsLeg = Routes.isRouteLeg(route);
-
- if (!routeIsLeg) {
-
- // new group will be computed at next leg route
- effortGroup = null;
- }
-
- // compute route period
- Date beginTime = route.getBeginTime();
- Date routeEndTime;
-
- if (nextRouteIndex < nbRoutes) {
-
- // use next route begin time
- Route nextRoute = routes.get(nextRouteIndex);
- routeEndTime = nextRoute.getBeginTime();
- } else {
-
- // use flight end date
- routeEndTime = flight.getEndDate();
- }
- if (routeEndTime != null) {
- Preconditions.checkState(routeEndTime.after(beginTime),
- String.format("Route debut de route %s - fin de route %s", beginTime, routeEndTime));
- }
-
- PeriodDates routePeriod =
- new PeriodDates(beginTime, routeEndTime);
-
- // Get observations for this route
- List<Observation> routeObservations =
- Observations.retainsObservations(observations,
- routePeriod);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Export Observations from route {} [{}-{}] nb observations {}",
- new Object[]{beginTime,
- routeEndTime,
- routeObservations.size()}
- );
- }
- if (!Routes.isRouteAccepted(route, routeTypes, strates)) {
-
- // not selected route
- continue;
- }
-
- Map<String, Object> routeRecord = Maps.newHashMap();
- routeRecord.putAll(flightRecord);
-
- if (routeIsLeg && effortGroup == null) {
-
- // compute effort group id
- effortGroup = computeEffortGroup(flight, route);
- }
-
- fillRouteTypeRecord(flight, route, effortGroup, routeRecord);
-
- // get best geo points for each observation
- Iterable<GeoPoint> observationGeoPoints =
- GeoPoints.getClosestPoints(
- routeGeoPoints,
- Observations.toDates(routeObservations));
-
- // to iterate on geoPoints
- Iterator<GeoPoint> geoPointIterator =
- observationGeoPoints.iterator();
-
- for (Observation observation : routeObservations) {
-
- Map<String, Object> record = Maps.newHashMap();
- record.putAll(routeRecord);
-
- String observationId = computeObservationId(flight, observation);
- record.put("OBSERVATION", observationId);
-
- fillDateRecord(observation.getObservationTime(), record);
-
- Species species = observation.getSpecies();
- if (species != null) {
- record.put("TAXON", species.getType());
- record.put("GROUP", species.getGroupName());
- record.put("FAMILY", species.getFamily());
- record.put("SPECIES", species.getCode());
- record.put("SPECIES_NAME", species.getCommonName());
- record.put("SPECIES_LATIN", species.getLatinName());
- }
- record.put("POD_SIZE", observation.getPodSize());
- record.put("AGE", observation.getAge());
- record.put("DEC_ANGLE", observation.getDecAngle());
- record.put("CUE", observation.getCue());
- record.put("BEHAVIOUR", observation.getBehaviour());
- record.put("SWIM_DIR", observation.getSwimDir());
- record.put("CALVES", observation.getCalves());
- record.put("PHOTO", observation.isPhoto());
- record.put("OBSERVER", observation.getObserverPosition().getObserver().getInitials());
- record.put("SIDE", observation.getObserverPosition().getPosition());
- record.put("STATUS", observation.getObservationStatus());
- record.put("COMMENT", observation.getComment());
-
- GeoPoint geoPoint = geoPointIterator.next();
-
- // add geoPoint data and flush
- fillGeoPointRecordAndFlush(geoPoint,
- record,
- builder,
- graphicList);
-
- }
- }
- }
-
- startTime = timeLog.log(startTime, "exportObservationsMap", "after building EsriGraphicList and DbfTableModel");
-
- flushExport(builder, dataModel, graphicList);
-
- timeLog.log(startTime, "exportObservationsMap", "after EsriShapeExport execution");
- } finally {
- context.getPersistence().endTransaction(tx);
- }
- }
-
- public void exportGeoPointsMap(ExportMapModel dataModel) {
-
- Preconditions.checkNotNull(dataModel.getCampaign());
- Preconditions.checkNotNull(dataModel.getBeginDate());
- Preconditions.checkNotNull(dataModel.getEndDate());
-
- if (logger.isInfoEnabled()) {
- logger.info("Start GeoPointsMap export to {} :: {}",
- dataModel.getExportDirectory(),
- dataModel.getExportFilename());
- }
-
- long startTime = TimeLog.getTime();
-
- DbfTableModelBuilder builder = new DbfTableModelBuilder()
- .stringColumn("REGION")
- .stringColumn("CAMPAIGN")
- .integerColumn("FLIGHT")
- .stringColumn("COMPUTER")
- .stringColumn("AIRCRAFT")
- .dateColumn("DATE")
- .stringColumn("HHMMSS")
- .doubleColumn("LAT", 19, 11)
- .doubleColumn("LON", 19, 11)
- .doubleColumn("SPEED", 19, 11)
- .doubleColumn("ALTITUDE", 19, 11)
- .build();
-
- Campaign campaign = dataModel.getCampaign();
- Region region = campaign.getRegion();
-
- FlightService flightService = context.getFlightService();
-
- // get flights for campaign (and between begin - end date)
- Iterable<Flight> flights = flightService.getFlights(campaign,
- dataModel.getBeginDate(),
- dataModel.getEndDate());
-
- EsriGraphicList graphicList = new EsriPointList();
-
- // Export for each flight
- for (Flight flight : flights) {
-
- if (logger.isInfoEnabled()) {
- logger.info("Export GeoPoints from flight {} - {} - {} - {}",
- new Object[]{flight.getFlightNumber(),
- flight.getSystemId(),
- campaign.getCode(),
- region.getCode()}
- );
- }
-
- List<GeoPoint> geoPoints =
- flightService.getFlightGeoPoints(flight);
-
- Map<String, Object> commonRecord = Maps.newHashMap();
- fillFlightRecord(campaign, region, flight, commonRecord);
-
- // One record by GeoPoint
- for (GeoPoint geoPoint : geoPoints) {
-
- Map<String, Object> record = Maps.newHashMap();
- record.putAll(commonRecord);
-
- fillDateRecord(geoPoint.getRecordTime(), record);
-
- // add geoPoint data and flush
- fillGeoPointRecordAndFlush(geoPoint,
- record,
- builder,
- graphicList);
- }
- }
-
- startTime = timeLog.log(startTime, "exportGeoPointsMap",
- "after building EsriGraphicList and DbfTableModel");
-
- flushExport(builder, dataModel, graphicList);
-
- timeLog.log(startTime, "exportGeoPointsMap",
- "after EsriShapeExport execution");
- }
-
- protected void flushExport(DbfTableModelBuilder builder,
- ExportMapModel dataModel,
- EsriGraphicList graphicList) {
-
- DbfTableModel tableModel = builder.getModel();
- String pathFile = new File(dataModel.getExportDirectory(),
- dataModel.getExportFilename()).getAbsolutePath();
- EsriShapeExport shapeExport = new EsriShapeExport(graphicList, tableModel, pathFile);
- shapeExport.export();
- }
-
- protected void fillDateRecord(Date date, Map<String, Object> record) {
- record.put("DATE", date);
- record.put("HHMMSS", timeFormat.format(date));
- }
-
- protected void fillGeoPointRecordAndFlush(GeoPoint geoPoint,
- Map<String, Object> record,
- DbfTableModelBuilder builder,
- EsriGraphicList graphicList) {
-
- record.put("LAT", geoPoint.getLatitude());
- record.put("LON", geoPoint.getLongitude());
- record.put("SPEED", geoPoint.getSpeed());
- record.put("ALTITUDE", geoPoint.getAltitude());
-
- builder.addValues(record);
-
- if (logger.isTraceEnabled()) {
- logger.trace("Record={}", record);
- }
-
- OMGraphic graphic = new OMPoint(geoPoint.getLatitude(),
- geoPoint.getLongitude());
- graphicList.add(graphic);
- }
-
- protected void fillFlightRecord(Campaign campaign,
- Region region,
- Flight flight,
- Map<String, Object> record) {
-
- record.put("REGION", region.getCode());
- record.put("CAMPAIGN", campaign.getCode());
- record.put("FLIGHT", flight.getFlightNumber());
- record.put("AIRCRAFT", flight.getImmatriculation());
- record.put("COMPUTER", flight.getSystemId());
- }
-
- protected void fillRouteRecord(Flight flight,
- Route route,
- String effortGroup,
- LegStatus legStatus,
- Map<String, Object> record) {
-
- if (logger.isTraceEnabled()) {
- logger.trace("Create Route record for route {} - {}",
- new Object[]{route.getBeginTime(),
- route.getRouteType()}
- );
- }
-
- fillDateRecord(route.getBeginTime(), record);
- fillRouteTypeRecord(flight, route, effortGroup, record);
-
- if (legStatus != null) {
- record.put("STATUS", legStatus);
- }
- record.put("COMMENT", route.getComment());
- record.put("SEA_STATE", route.getSeaState());
- record.put("SWELL", route.getSwell());
- record.put("TURBIDITY", route.getTurbidity());
- record.put("SKY_GLINT", route.getSkyGlint());
- if (route.getGlareFrom() != null) {
- record.put("GLARE_FROM", String.valueOf(route.getGlareFrom()));
- }
- if (route.getGlareTo() != null) {
- record.put("GLARE_TO", String.valueOf(route.getGlareTo()));
- }
- record.put("GLARE_SEVERITY", route.getGlareSeverity());
- record.put("GLARE_UNDER", route.isGlareUnder());
- record.put("CLOUD_COVER", route.getCloudCover());
- record.put("SUBJECTIVE", route.getSubjectiveConditions());
- record.put("UNEXP_LEFT", route.getUnexpectedLeft());
- record.put("UNEXP_RIGHT", route.getUnexpectedRight());
-
- ObserverPosition observerPositionByPosition =
- route.getObserverPositionByPosition(Position.FRONT_LEFT);
- if (observerPositionByPosition != null && observerPositionByPosition.getObserver() != null) {
- record.put("LEFT_REAR", observerPositionByPosition.getObserver().getInitials());
- }
- observerPositionByPosition =
- route.getObserverPositionByPosition(Position.FRONT_RIGHT);
- if (observerPositionByPosition != null && observerPositionByPosition.getObserver() != null) {
- record.put("RIGHT_REAR", observerPositionByPosition.getObserver().getInitials());
- }
- observerPositionByPosition =
- route.getObserverPositionByPosition(Position.NAVIGATOR);
- if (observerPositionByPosition != null && observerPositionByPosition.getObserver() != null) {
- record.put("CENTER", observerPositionByPosition.getObserver().getInitials());
- }
- }
-
- protected void fillRouteTypeRecord(Flight flight,
- Route route,
- String effortGroup,
- Map<String, Object> record) {
-
- record.put("ROUTE_TYPE", route.getRouteType());
- if (Routes.isRouteLeg(route)) {
- fillLegRouteRecord(route, effortGroup, record);
- }
-
- if (Routes.isRouteCircleBack(route)) {
-
- // compute circle back cause
- String circleBackCause = computeObservationId(flight, route.getCircleBackCause());
- record.put("CB_CAUSE", circleBackCause);
- }
- }
-
- protected void fillLegRouteRecord(Route route,
- String effortGroup,
- Map<String, Object> record) {
-
- TransectFlight transectFlight = route.getTransectFlight();
- Transect transect = transectFlight.getTransect();
- Strate strate = transect.getStrate();
-
- String effort = computeEffort(route);
-
- record.put("SECTOR", strate.getSector().getSectorNumber());
- record.put("STRATE_TYPE", strate.getStrateType().getCode());
- record.put("STRATE", strate.getCode());
- record.put("TRANSECT", transect.getName());
- record.put("PASSAGE", transectFlight.getCrossingNumber());
- record.put("EFFORT_GROUP", effortGroup);
- record.put("EFFORT", effort);
- }
-
- protected String computeEffort(Route route) {
- String result = "L" + route.getEffortNumber() + "-" +
- route.getFlight().getFlightNumber() + "-" +
- route.getFlight().getSystemId();
- return result;
- }
-
- protected String computeEffortGroup(Flight flight, Route route) {
- String result = "G" + route.getEffortNumber() + "-" +
- flight.getFlightNumber() + "-" +
- flight.getSystemId();
- return result;
- }
-
- protected String computeObservationId(Flight flight, Observation observation) {
- return "O" + observation.getObservationNumber() + "-" +
- flight.getFlightNumber() + "-" +
- flight.getSystemId();
- }
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/LegStatus.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/LegStatus.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/LegStatus.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,39 +0,0 @@
-package fr.ulr.sammoa.application.map;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.5
- */
-public enum LegStatus {
- BEGIN,
- ADD, END;
-
- public String getName() {
- return name();
- }
-}
Modified: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/FlightServiceTest.java
===================================================================
--- trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/FlightServiceTest.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/FlightServiceTest.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -25,7 +25,20 @@
package fr.ulr.sammoa.application;
import com.google.common.collect.Lists;
-import fr.ulr.sammoa.persistence.*;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.persistence.Observer;
+import fr.ulr.sammoa.persistence.ObserverDAO;
+import fr.ulr.sammoa.persistence.SammoaDAOHelper;
+import fr.ulr.sammoa.persistence.SammoaDatabase;
+import fr.ulr.sammoa.persistence.Sector;
+import fr.ulr.sammoa.persistence.SectorDAO;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StrateDAO;
+import fr.ulr.sammoa.persistence.StrateType;
+import fr.ulr.sammoa.persistence.Transect;
+import fr.ulr.sammoa.persistence.TransectDAO;
+import fr.ulr.sammoa.persistence.TransectFlight;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@@ -34,23 +47,23 @@
/**
* Created: 08/06/12
- *
+ * <p/>
* FIXME-fdesbois-2012-07-03 : This test is ignored, waiting for a more stable AutoCommitSaver
*
* @author fdesbois <desbois(a)codelutin.com>
*/
public class FlightServiceTest {
-
+
public SammoaConfig config =
new SammoaConfig("sammoa-test.properties");
-
+
@Rule
public SammoaDatabase database = new SammoaDatabase("/" +
- config.getApplicationConfig().getConfigFileName(), config.getAutoCommitDelay());
+ config.getApplicationConfig().getConfigFileName(), config.getAutoCommitDelay());
@Test
public void testCreateFlight() throws Exception {
-
+
SammoaContext context = new SammoaContext(config, database.getPersistence());
FlightService service = new FlightService(context);
@@ -64,12 +77,12 @@
Assert.assertEquals(18, flight1.getFlightNumber());
}
-
+
@Test
public void testAddTransects() throws Exception {
SammoaContext context = new SammoaContext(config, database.getPersistence());
-
+
FlightService service = new FlightService(context);
ReferentialService referential = new ReferentialService(context);
@@ -77,7 +90,7 @@
// Create the strate
Strate strate = createStrate(campaign, 1, StrateType.COAST);
-
+
Flight flight = service.createFlight(campaign);
// add 4 observers in flight
@@ -93,7 +106,7 @@
Iterable<Transect> transects = Lists.newArrayList(transect1, transect2);
service.addTransects(flight, 0, transects);
-
+
Assert.assertEquals(2, flight.getTransectFlight().size());
TransectFlight transectFlight1 = flight.getTransectFlight().get(0);
Assert.assertEquals(transect1, transectFlight1.getTransect());
Deleted: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/ReferentialServiceTest.java
===================================================================
--- trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/ReferentialServiceTest.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/ReferentialServiceTest.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,76 +0,0 @@
-package fr.ulr.sammoa.application;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ulr.sammoa.persistence.Campaign;
-import fr.ulr.sammoa.persistence.Observer;
-import fr.ulr.sammoa.persistence.ObserverDAO;
-import fr.ulr.sammoa.persistence.SammoaDAOHelper;
-import fr.ulr.sammoa.persistence.SammoaDatabase;
-import org.junit.Rule;
-import org.junit.Test;
-import org.nuiton.topia.TopiaContext;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Collection;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Created: 09/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class ReferentialServiceTest {
-
- public SammoaConfig config =
- new SammoaConfig("sammoa-test.properties");
-
- @Rule
- public SammoaDatabase database = new SammoaDatabase("/" +
- config.getApplicationConfig().getConfigFileName(), config.getAutoCommitDelay());
-
- @Test
- public void testImportObservers() throws Exception {
-
- SammoaContext context = new SammoaContext(config, database.getPersistence());
-
- ReferentialService instance = new ReferentialService(context);
-
- Campaign campaign = database.createCampaign("PACOMM-2012", "FRANCE");
-
- InputStream stream = getClass().getResourceAsStream("/observers.csv");
-
- int result = instance.importObservers(campaign.getTopiaId(), new InputStreamReader(stream));
-
- TopiaContext transaction = database.beginTransaction();
- ObserverDAO dao = SammoaDAOHelper.getObserverDAO(transaction);
- Collection<Observer> observers = dao.findAll();
- database.endTransaction(transaction);
-
- assertEquals(7, result);
- assertEquals(result, observers.size());
- }
-}
Added: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java
===================================================================
--- trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java (rev 0)
+++ trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,59 @@
+package fr.ulr.sammoa.application.io.input.csv;
+
+import fr.ulr.sammoa.application.SammoaConfig;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.application.io.input.csv.ImportCsvService;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Observer;
+import fr.ulr.sammoa.persistence.ObserverDAO;
+import fr.ulr.sammoa.persistence.SammoaDAOHelper;
+import fr.ulr.sammoa.persistence.SammoaDatabase;
+import org.junit.Rule;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * To test {@link ImportCsvService}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ImportCsvServiceTest {
+
+ public SammoaConfig config =
+ new SammoaConfig("sammoa-test.properties");
+
+ @Rule
+ public SammoaDatabase database = new SammoaDatabase(
+ "/" + config.getApplicationConfig().getConfigFileName(),
+ config.getAutoCommitDelay());
+
+ @Test
+ public void importObservers() throws Exception {
+
+ SammoaContext context = new SammoaContext(config, database.getPersistence());
+
+ ImportCsvService instance = new ImportCsvService(context);
+
+ Campaign campaign = database.createCampaign("PACOMM-2012", "FRANCE");
+
+ URL stream = getClass().getResource("/observers.csv");
+
+ int result = instance.importObservers(campaign.getTopiaId(),
+ new File(stream.toURI()));
+
+ TopiaContext transaction = database.beginTransaction();
+ ObserverDAO dao = SammoaDAOHelper.getObserverDAO(transaction);
+ Collection<Observer> observers = dao.findAll();
+ database.endTransaction(transaction);
+
+ assertEquals(7, result);
+ assertEquals(result, observers.size());
+ }
+}
Property changes on: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/io/input/csv/ImportCsvServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/DbfTimestampConverterTest.java (from rev 413, trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/map/DbfTimestampConverterTest.java)
===================================================================
--- trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/DbfTimestampConverterTest.java (rev 0)
+++ trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/DbfTimestampConverterTest.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,56 @@
+package fr.ulr.sammoa.application.output.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.application.io.output.map.DbfTimestampConverter;
+import junit.framework.Assert;
+import org.junit.Test;
+import org.nuiton.util.DateUtil;
+
+import java.util.Date;
+
+/**
+ * Created: 08/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class DbfTimestampConverterTest {
+
+ @Test
+ public void testToString() throws Exception {
+
+ Date date = DateUtil.createDate(52, 2, 19, 5, 3, 2007);
+ String result = DbfTimestampConverter.toString(date);
+// Assert.assertEquals(result, "2454488 68572000");
+ Assert.assertEquals(result, "2454165 68572000");
+ }
+
+ @Test
+ public void testToDate() throws Exception {
+
+ Date expected = DateUtil.createDate(52, 2, 19, 5, 3, 2007);
+ Date result = DbfTimestampConverter.toDate("2454165 68572000");
+ Assert.assertEquals(expected, result);
+ }
+}
Property changes on: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/DbfTimestampConverterTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/ExportMapServiceTest.java (from rev 413, trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/map/ExportMapServiceTest.java)
===================================================================
--- trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/ExportMapServiceTest.java (rev 0)
+++ trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/ExportMapServiceTest.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,250 @@
+package fr.ulr.sammoa.application.output.map;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ulr.sammoa.application.FlightService;
+import fr.ulr.sammoa.application.SammoaConfig;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.application.io.input.map.DoubleToIntegerValueParser;
+import fr.ulr.sammoa.application.io.output.map.DbfImport;
+import fr.ulr.sammoa.application.io.output.map.DbfTableModelBuilder;
+import fr.ulr.sammoa.application.io.output.map.ExportMapModel;
+import fr.ulr.sammoa.application.io.output.map.ExportMapService;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.CampaignImpl;
+import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.persistence.FlightImpl;
+import fr.ulr.sammoa.persistence.GeoPoint;
+import fr.ulr.sammoa.persistence.GeoPointDAO;
+import fr.ulr.sammoa.persistence.GeoPointImpl;
+import fr.ulr.sammoa.persistence.Region;
+import fr.ulr.sammoa.persistence.RegionImpl;
+import fr.ulr.sammoa.persistence.SammoaDAOHelper;
+import fr.ulr.sammoa.persistence.SammoaDatabase;
+import junit.framework.Assert;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.util.DateUtil;
+import org.nuiton.util.csv.Common;
+import org.nuiton.util.csv.ImportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+import org.nuiton.util.csv.ValueSetter;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created: 08/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class ExportMapServiceTest {
+
+ public SammoaConfig config =
+ new SammoaConfig("sammoa-test.properties");
+
+ @Rule
+ public SammoaDatabase database = new SammoaDatabase("/" +
+ config.getApplicationConfig().getConfigFileName(), config.getAutoCommitDelay());
+
+ protected TopiaContext transaction;
+
+ @Before
+ public void setUp() throws TopiaException {
+ transaction = database.beginTransaction();
+ }
+
+ @After
+ public void tearDown() throws TopiaException {
+ database.endTransaction(transaction);
+ }
+
+ @Test
+ public void testExportGeoPointsMap() throws Exception {
+
+ SammoaContext context = new SammoaContext(config, database.getPersistence());
+
+ Campaign campaign = database.createCampaign("PACOMM", "FRANCE");
+ campaign.setBeginDate(DateUtil.createDate(1, 1, 2012));
+ campaign.setEndDate(DateUtil.createDate(31, 12, 2012));
+
+ FlightService flightService = new FlightService(context);
+ Flight flight = flightService.createFlight(campaign);
+
+ flight.setBeginDate(DateUtil.createDate(18, 0, 12, 18, 7, 2012));
+
+ createGeoPoint(DateUtil.createDate(30, 15, 12, 18, 7, 2012), 1, 2, flight);
+ createGeoPoint(DateUtil.createDate(39, 18, 12, 18, 7, 2012), 3, 4, flight);
+
+ transaction.commitTransaction();
+
+ ExportMapService exportMapService = new ExportMapService(context);
+
+ File exportDirectory = database.getTestBasedir();
+
+ ExportMapModel exportMapModel = ExportMapModel.newModel(
+ exportDirectory,
+ "export-geoPoints.shp",
+ campaign,
+ campaign.getBeginDate(),
+ campaign.getEndDate(),
+ null,
+ null,
+ null
+ );
+
+ exportMapService.exportGeoPointsMap(exportMapModel);
+
+ Assert.assertTrue(new File(exportDirectory, "export-geoPoints.shp").exists());
+ Assert.assertTrue(new File(exportDirectory, "export-geoPoints.dbf").exists());
+ Assert.assertTrue(new File(exportDirectory, "export-geoPoints.shx").exists());
+
+ URL fileUrl = new File(exportDirectory, "export-geoPoints.dbf").toURI().toURL();
+ DbfImport<GeoPoint> dbfImport = new DbfImport<GeoPoint>(new GeoPointImportModel(), fileUrl);
+
+ List<GeoPoint> results = Lists.newArrayList(dbfImport);
+
+ Assert.assertEquals(2, results.size());
+ {
+ GeoPoint result = results.get(0);
+ Flight resultFlight = result.getFlight();
+ Campaign resultCampaign = resultFlight.getCampaign();
+ Region resultRegion = resultCampaign.getRegion();
+ Assert.assertEquals("FRANCE", resultRegion.getCode());
+ Assert.assertEquals("PACOMM", resultCampaign.getCode());
+ Assert.assertEquals(1, resultFlight.getFlightNumber());
+ Assert.assertEquals("A", resultFlight.getSystemId());
+ Assert.assertEquals(DateUtil.createDate(30, 15, 12, 18, 7, 2012), result.getRecordTime());
+ Assert.assertEquals(1., result.getLatitude());
+ Assert.assertEquals(2., result.getLongitude());
+ Assert.assertEquals(0., result.getAltitude());
+ Assert.assertEquals(0., result.getSpeed());
+ }
+ {
+ GeoPoint result = results.get(1);
+ Flight resultFlight = result.getFlight();
+ Campaign resultCampaign = resultFlight.getCampaign();
+ Region resultRegion = resultCampaign.getRegion();
+ Assert.assertEquals("FRANCE", resultRegion.getCode());
+ Assert.assertEquals("PACOMM", resultCampaign.getCode());
+ Assert.assertEquals(1, resultFlight.getFlightNumber());
+ Assert.assertEquals("A", resultFlight.getSystemId());
+ Assert.assertEquals(DateUtil.createDate(39, 18, 12, 18, 7, 2012), result.getRecordTime());
+ Assert.assertEquals(3., result.getLatitude());
+ Assert.assertEquals(4., result.getLongitude());
+ Assert.assertEquals(0., result.getAltitude());
+ Assert.assertEquals(0., result.getSpeed());
+ }
+ }
+
+ protected GeoPoint createGeoPoint(Date date,
+ double latitude,
+ double longitude,
+ Flight flight)
+ throws TopiaException {
+
+ GeoPointDAO transectDAO = SammoaDAOHelper.getGeoPointDAO(transaction);
+ GeoPoint result = transectDAO.create();
+ result.setRecordTime(date);
+ result.setLatitude(latitude);
+ result.setLongitude(longitude);
+ result.setFlight(flight);
+
+ return result;
+ }
+
+ protected class GeoPointImportModel implements ImportModel<GeoPoint> {
+
+ @Override
+ public char getSeparator() {
+ return ' ';
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> headerNames) {
+ }
+
+ @Override
+ public GeoPoint newEmptyInstance() {
+ Region region = new RegionImpl();
+ Campaign campaign = new CampaignImpl();
+ campaign.setRegion(region);
+ Flight flight = new FlightImpl();
+ flight.setCampaign(campaign);
+ GeoPoint result = new GeoPointImpl();
+ result.setFlight(flight);
+ return result;
+ }
+
+ @Override
+ public Iterable<ImportableColumn<GeoPoint, Object>> getColumnsForImport() {
+ ModelBuilder builder = new ModelBuilder();
+ builder.newMandatoryColumn("REGION", "flight.campaign.region.code");
+ builder.newMandatoryColumn("AIRCRAFT", "flight.immatriculation");
+ builder.newMandatoryColumn("CAMPAIGN", "flight.campaign.code");
+ builder.newMandatoryColumn("FLIGHT", "flight.flightNumber", new DoubleToIntegerValueParser());
+ builder.newMandatoryColumn("COMPUTER", "flight.systemId");
+ builder.newMandatoryColumn("DATE", "recordTime", new Common.DateValue(DbfTableModelBuilder.DATE_FORMAT_PATTERN));
+ builder.newMandatoryColumn("HHMMSS", new Common.DateValue("HHmmss"), new GeoPointTimeValueSetter());
+ builder.newMandatoryColumn("LAT", "latitude", Common.DOUBLE_PRIMITIVE);
+ builder.newMandatoryColumn("LON", "longitude", Common.DOUBLE_PRIMITIVE);
+ builder.newMandatoryColumn("SPEED", "speed", Common.DOUBLE_PRIMITIVE);
+ builder.newMandatoryColumn("ALTITUDE", "altitude", Common.DOUBLE_PRIMITIVE);
+ return builder.getColumnsForImport();
+ }
+ }
+
+ protected class GeoPointTimeValueSetter implements ValueSetter<GeoPoint, Date> {
+
+ @Override
+ public void set(GeoPoint object, Date value) throws Exception {
+ Date recordTime = object.getRecordTime();
+// if (recordTime != null) {
+ Calendar resultCalendar = Calendar.getInstance();
+ resultCalendar.setTime(recordTime);
+
+ Calendar valueCalendar = Calendar.getInstance();
+ valueCalendar.setTime(value);
+ resultCalendar.set(Calendar.HOUR_OF_DAY, valueCalendar.get(Calendar.HOUR_OF_DAY));
+ resultCalendar.set(Calendar.MINUTE, valueCalendar.get(Calendar.MINUTE));
+ resultCalendar.set(Calendar.SECOND, valueCalendar.get(Calendar.SECOND));
+
+ object.setRecordTime(resultCalendar.getTime());
+
+// } else {
+// object.setRecordTime(value);
+// }
+ }
+
+ }
+}
Property changes on: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/output/map/ExportMapServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -35,8 +35,8 @@
import fr.ulr.sammoa.ui.swing.flight.FlightUI;
import fr.ulr.sammoa.ui.swing.flight.FlightUIHandler;
import fr.ulr.sammoa.ui.swing.home.HomeUI;
-import fr.ulr.sammoa.ui.swing.io.exportApplication.ExportApplicationUI;
-import fr.ulr.sammoa.ui.swing.io.exportMap.ExportMapUI;
+import fr.ulr.sammoa.ui.swing.io.output.sammoa.ExportApplicationUI;
+import fr.ulr.sammoa.ui.swing.io.output.map.ExportMapUI;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.AboutPanel;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUIHandler.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUIHandler.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -24,8 +24,13 @@
package fr.ulr.sammoa.ui.swing.campaign;
import fr.ulr.sammoa.application.ReferentialService;
-import fr.ulr.sammoa.application.csv.StrateImportModel;
-import fr.ulr.sammoa.application.csv.TransectImportModel;
+import fr.ulr.sammoa.application.io.CampaignStorage;
+import fr.ulr.sammoa.application.io.CampaignStorages;
+import fr.ulr.sammoa.application.io.input.csv.ImportCsvService;
+import fr.ulr.sammoa.application.io.input.map.ImportMapService;
+import fr.ulr.sammoa.application.io.input.map.ShpImporter;
+import fr.ulr.sammoa.application.io.input.map.StrateImportModel;
+import fr.ulr.sammoa.application.io.input.map.TransectImportModel;
import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.Region;
import fr.ulr.sammoa.persistence.Strate;
@@ -36,9 +41,8 @@
import fr.ulr.sammoa.ui.swing.region.RegionUI;
import fr.ulr.sammoa.ui.swing.region.RegionUIModel;
import fr.ulr.sammoa.ui.swing.util.CsvImporter;
-import fr.ulr.sammoa.ui.swing.util.Importer;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
-import fr.ulr.sammoa.ui.swing.util.ShpImporter;
+import fr.ulr.sammoa.ui.swing.util.UIImporter;
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
@@ -49,7 +53,7 @@
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.io.File;
-import java.io.Reader;
+import java.io.IOException;
import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -63,27 +67,30 @@
public class CampaignUIHandler implements SammoaUIHandler {
private static final Logger logger = LoggerFactory.getLogger(CampaignUIHandler.class);
-
+
protected SammoaUIContext context;
protected CampaignUI ui;
-
+
protected RegionUI regionUi;
-
+
+ protected final UIImporter uiImporter;
+
public CampaignUIHandler(SammoaUIContext context,
CampaignUI ui) {
this.context = context;
this.ui = ui;
+ this.uiImporter = new UIImporter(this.ui);
}
public SammoaUIContext getContext() {
return context;
}
-
+
public CampaignUIModel getModel() {
return ui.getModel();
}
-
+
public RegionUI getRegionUI() {
return regionUi;
}
@@ -96,14 +103,15 @@
return context.getAppContext().getReferentialService();
}
+
@Override
public void beforeInitUI() {
-
+
CampaignUIModel model = new CampaignUIModel();
List<Region> regions = getReferentialService().getRegions();
model.setRegionReferential(regions);
-
+
String campaignId = context.getCampaignId();
if (campaignId == null) {
@@ -114,7 +122,7 @@
Campaign campaign = getReferentialService().getCampaign(campaignId);
model.prepareUpdate(campaign);
}
-
+
ui.setContextValue(model);
}
@@ -163,17 +171,20 @@
}
public void saveCampaign() {
-
+
try {
boolean success = true;
-
+
Campaign campaign = getModel().newBean();
SammoaUtil.updateBusyState(ui, true);
String campaignId = getReferentialService().saveCampaign(campaign);
getModel().setId(campaignId);
-
+
+ CampaignStorage campaignStorage = CampaignStorages.getStorage(
+ getContext().getConfig(), campaignId);
+
File strateFile = ui.getStrateFileEditor().getSelectedFile();
if (strateFile != null && strateFile.exists()) {
@@ -183,7 +194,7 @@
);
}
- success &= strateImporter.readFile(ui, strateFile);
+ success &= uiImporter.importShape(strateImporter, strateFile, campaignStorage);
}
File transectFile = ui.getTransectFileEditor().getSelectedFile();
@@ -195,10 +206,12 @@
);
}
- success &= transectImporter.readFile(ui, transectFile);
+ success &= uiImporter.importShape(transectImporter,
+ transectFile,
+ campaignStorage);
}
- File observerFile = ui.getObserverFileEditor().getSelectedFile();
+ final File observerFile = ui.getObserverFileEditor().getSelectedFile();
if (observerFile != null && observerFile.exists()) {
if (logger.isInfoEnabled()) {
@@ -207,7 +220,7 @@
);
}
- success &= observerImporter.readFile(ui, observerFile);
+ success &= uiImporter.importCvs(observerImporter, observerFile);
}
SammoaUtil.updateBusyState(ui, false);
@@ -216,7 +229,7 @@
context.setCampaignId(campaignId);
close();
}
-
+
} catch (Exception e) {
ErrorDialogUI.showError(e);
}
@@ -225,7 +238,7 @@
public void close() {
context.setHomeScreen();
}
-
+
protected ComponentListener regionUIListener = new ComponentListener() {
@Override
@@ -260,9 +273,9 @@
}
List<Region> regions = getModel().getRegionReferential();
-
+
Region regionSaved = getRegionUI().getModel().newBean();
-
+
if (regions.contains(regionSaved)) {
// nothing to do, the element exist in the list
@@ -275,11 +288,21 @@
}
};
- protected Importer strateImporter = new ShpImporter<Strate>() {
+ protected CsvImporter observerImporter = new CsvImporter() {
@Override
- protected String onActionPerformed(Iterable<Strate> elements) {
- int nbImported = getReferentialService().importStrates(getCampaignId(), elements);
+ public String importCsvFile(File file) throws IOException {
+ ImportCsvService service = new ImportCsvService(context.getAppContext());
+ int nbImported = service.importObservers(getModel().getId(), file);
+ return _("sammoa.messageDialog.observers.import.success", nbImported);
+ }
+ };
+
+ protected ShpImporter<Strate> strateImporter = new ShpImporter<Strate>() {
+
+ protected String onDbfLoaded(Iterable<Strate> elements, CampaignStorage storage) {
+ ImportMapService service = new ImportMapService(context.getAppContext());
+ int nbImported = service.importStrates(storage.getCampaignId(), elements);
return _("sammoa.messageDialog.strates.import.success", nbImported);
}
@@ -293,22 +316,14 @@
return "strates";
}
- @Override
- protected File getCopyDirectory() {
- File dataDirectory = context.getConfig().getDataDirectory();
- return new File(new File(new File(dataDirectory, "campaign"), getCampaignId()), "map");
- }
-
- protected String getCampaignId() {
- return CampaignUIHandler.this.getModel().getId();
- }
};
- protected Importer transectImporter = new ShpImporter<Transect>() {
+ protected ShpImporter<Transect> transectImporter = new ShpImporter<Transect>() {
@Override
- protected String onActionPerformed(Iterable<Transect> elements) {
- int nbImported = getReferentialService().importTransects(getCampaignId(), elements);
+ protected String onDbfLoaded(Iterable<Transect> elements, CampaignStorage storage) {
+ ImportMapService service = new ImportMapService(context.getAppContext());
+ int nbImported = service.importTransects(storage.getCampaignId(), elements);
return _("sammoa.messageDialog.transects.import.success", nbImported);
}
@@ -322,23 +337,6 @@
return "transects";
}
- @Override
- protected File getCopyDirectory() {
- File dataDirectory = context.getConfig().getDataDirectory();
- return new File(new File(new File(dataDirectory, "campaign"), getCampaignId()), "map");
- }
-
- protected String getCampaignId() {
- return CampaignUIHandler.this.getModel().getId();
- }
};
- protected Importer observerImporter = new CsvImporter() {
-
- @Override
- protected String onActionPerformed(Reader reader) {
- int nbImported = getReferentialService().importObservers(getModel().getId(), reader);
- return _("sammoa.messageDialog.observers.import.success", nbImported);
- }
- };
}
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.css (from rev 413, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapLauncherUI.css)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.css (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.css 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,43 @@
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+#exportMapDirectoryFileChooseAction {
+ actionIcon:"fileChooser";
+}
+
+#exportMapDirectoryLbl {
+ text:"sammoa.label.exportMapDirectory";
+}
+
+#exportMapDirectory {
+ text:{model.getExportDirectory().getAbsolutePath()};
+}
+
+#exportMapFilenameLbl {
+ text:"sammoa.label.exportMapFilename";
+}
+
+#exportMapFilename {
+ text:{model.getExportFilename()};
+}
+
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.jaxx (from rev 413, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapLauncherUI.jaxx)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.jaxx (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.jaxx 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,83 @@
+<!--
+ #%L
+ SAMMOA :: UI Swing
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 UMS 3462, Code Lutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JPanel layout='{new BorderLayout()}'>
+
+ <import>
+
+ java.awt.BorderLayout
+ java.io.File
+
+ jaxx.runtime.swing.BlockingLayerUI
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+ public ExportMapLauncherUI(ExportMapUIHandler handler) {
+ setContextValue(handler);
+ setContextValue(handler.getModel());
+ }
+ ]]></script>
+
+ <ExportMapUIModel id='model'
+ initializer='getContextValue(ExportMapUIModel.class)'/>
+
+ <ExportMapUIHandler id='handler'
+ initializer='getContextValue(ExportMapUIHandler.class)'/>
+
+ <Table id='body' fill='both' constraints='BorderLayout.CENTER' decorator='boxed'>
+ <!-- export directory-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='exportMapDirectoryLbl'/>
+ </cell>
+ <cell weightx='1' fill="horizontal">
+ <JTextField id='exportMapDirectory'
+ onKeyReleased='getModel().setExportDirectory(new File(((JTextField)event.getSource()).getText()))'/>
+ </cell>
+ <cell anchor="east">
+ <JButton id="exportMapDirectoryFileChooseAction"
+ onActionPerformed="getHandler().chooseEffortDirectory()"/>
+ </cell>
+ </row>
+ <row>
+ <cell anchor='west'>
+ <JLabel id='exportMapFilenameLbl'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0' columns='2'>
+ <JTextField id='exportMapFilename'
+ onKeyReleased='model.setExportFilename(((JTextField)event.getSource()).getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell columns='3' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='cancel'/>
+ <JButton id='start'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</JPanel>
\ No newline at end of file
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapLauncherUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.css (from rev 413, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.css)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.css (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.css 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,107 @@
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+BeanListHeader {
+ i18nPrefix: "sammoa.common.";
+}
+
+#campaignLabel {
+ text: "sammoa.label.campaign";
+}
+
+#campaignCombobox {
+ renderer: {new DecoratorProviderListCellRenderer(getHandler().getDecoratorProvider())};
+}
+
+#campainPeriodFilter {
+ border:{new TitledBorder(_("sammoa.label.campaign.period.filter"))};
+}
+
+#campaignBeginDateLabel {
+ text:"sammoa.label.campaign.beginDate";
+}
+
+#beginDatePicker {
+ patternLayout:{_("sammoa.datePattern")};
+ date:{getModel().getBeginDate()};
+}
+
+#campaignEndDateLabel {
+ text:"sammoa.label.campaign.endDate";
+}
+
+#endDatePicker {
+ patternLayout:{_("sammoa.datePattern")};
+ date:{getModel().getEndDate()};
+}
+
+#strateFilterListHeader {
+ beanType:{Strate.class};
+ showReset:true;
+ list:{strateFilter};
+ labelText:{_("sammoa.label.strateFilter")};
+}
+
+#routeTypeFilterListHeader {
+ beanType:{RouteType.class};
+ showReset:true;
+ list:{routeTypeFilter};
+ labelText:{_("sammoa.label.routeTypeFilter")};
+}
+
+#speciesTypeFilterListHeader {
+ beanType:{StringRef.class};
+ showReset:true;
+ list:{speciesTypeFilter};
+ labelText:{_("sammoa.label.speciesTypeFilter")};
+}
+
+#speciesFilterListHeader {
+ beanType:{Species.class};
+ showReset:true;
+ list:{speciesFilter};
+ labelText:{_("sammoa.label.speciesFilter")};
+}
+
+#quitButton {
+ text:"sammoa.action.quitExportMaps";
+}
+
+#exportEfforts {
+ text:"sammoa.action.exportEffortsMap";
+}
+
+#exportObservations {
+ text:"sammoa.action.exportObservationsMap";
+}
+#exportGeoPoints {
+ text:"sammoa.action.exportGeoPointsMap";
+}
+
+#exportDirectoryFileChooseAction {
+ actionIcon:"fileChooser";
+}
+
+#exportDirectoryLbl {
+ text:"sammoa.label.exportDirectory";
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.jaxx (from rev 413, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.jaxx)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.jaxx (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.jaxx 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,152 @@
+<!--
+ #%L
+ SAMMOA :: UI Swing
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 UMS 3462, Code Lutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JPanel id='exportMapUI' layout='{new BorderLayout()}'
+ implements='fr.ulr.sammoa.ui.swing.SammoaUI<ExportMapUIHandler>'>
+
+ <import>
+ fr.ulr.sammoa.application.flightController.FlightState
+ fr.ulr.sammoa.persistence.Campaign
+ fr.ulr.sammoa.persistence.RouteType
+ fr.ulr.sammoa.persistence.Strate
+ fr.ulr.sammoa.persistence.Species
+ fr.ulr.sammoa.persistence.StringRef
+ fr.ulr.sammoa.ui.swing.SammoaUIContext
+
+ jaxx.runtime.swing.editor.bean.BeanListHeader
+ jaxx.runtime.swing.JAXXDatePicker
+ jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer
+
+ java.awt.BorderLayout
+ java.awt.event.ItemEvent
+ java.io.File
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+ public ExportMapUI(SammoaUIContext context) {
+ ExportMapUIHandler handler = new ExportMapUIHandler(context, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+ }
+
+ protected void $afterCompleteSetup() {
+ getHandler().afterInitUI();
+ }
+ ]]></script>
+
+ <ExportMapUIModel id='model'
+ initializer='getContextValue(ExportMapUIModel.class)'/>
+
+ <ExportMapUIHandler id='handler'
+ initializer='getContextValue(ExportMapUIHandler.class)'/>
+
+ <Table fill='both' constraints='BorderLayout.CENTER'>
+ <!-- Campaign filter -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='campaignLabel'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0'>
+ <JComboBox id='campaignCombobox'
+ onItemStateChanged='if (ItemEvent.SELECTED == event.getStateChange()) { getModel().setSelectedCampaign((Campaign)event.getItem()); } else { getModel().setSelectedCampaign(null); }'/>
+ </cell>
+ </row>
+ <!-- Campaign Period filter -->
+ <row>
+ <cell weightx='1.0' columns='5'>
+ <JPanel id='campainPeriodFilter' layout='{new GridLayout(1,0)}'>
+ <JAXXDatePicker id='beginDatePicker'
+ onActionPerformed='getModel().setBeginDate(beginDatePicker.getDate())'/>
+ <JAXXDatePicker id='endDatePicker'
+ onActionPerformed='getModel().setEndDate(endDatePicker.getDate())'/>
+ </JPanel>
+ </cell>
+ </row>
+ <!-- Strate filter (Multi-selection)-->
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='5'>
+ <JScrollPane id='strateFilterScrollPane'
+ columnHeaderView='{strateFilterListHeader}'>
+ <JList id='strateFilter' />
+ <BeanListHeader id='strateFilterListHeader' genericType='Strate'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <!-- Status filter (Multi-selection)-->
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='5'>
+ <JScrollPane id='routeTypeFilterScrollPane'
+ columnHeaderView='{routeTypeFilterListHeader}'>
+ <JList id='routeTypeFilter' />
+ <BeanListHeader id='routeTypeFilterListHeader' genericType='RouteType'/>
+ </JScrollPane>
+ </cell>
+ </row>
+
+ <!-- export efforts / geoPoints -->
+ <row>
+ <cell columns='5' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='exportGeoPoints' constraints='BorderLayout.CENTER'
+ onActionPerformed='getHandler().exportGeoPoints()'/>
+ <JButton id='exportEfforts'
+ onActionPerformed='getHandler().exportEfforts()'/>
+ </JPanel>
+ </cell>
+ </row>
+
+ <!-- Species type filter (Multi-selection)-->
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='5'>
+ <JScrollPane id='speciesTypeFilterScrollPane'
+ columnHeaderView='{speciesTypeFilterListHeader}'>
+ <JList id='speciesTypeFilter'/>
+ <BeanListHeader id='speciesTypeFilterListHeader' genericType='StringRef'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <!-- Species filter (Multi-selection)-->
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='5'>
+ <JScrollPane id='speciesFilterScrollPane'
+ columnHeaderView='{speciesFilterListHeader}'>
+ <JList id='speciesFilter'/>
+ <BeanListHeader id='speciesFilterListHeader' genericType='Species'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <!--export observations -->
+ <row>
+ <cell columns='5' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='quitButton' onActionPerformed='getHandler().close()'/>
+ <JButton id='exportObservations'
+ onActionPerformed='getHandler().exportObservations()'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</JPanel>
\ No newline at end of file
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIHandler.java (from rev 413, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIHandler.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIHandler.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,469 @@
+package fr.ulr.sammoa.ui.swing.io.output.map;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ulr.sammoa.application.ReferentialService;
+import fr.ulr.sammoa.application.io.output.map.ExportMapModel;
+import fr.ulr.sammoa.application.io.output.map.ExportMapService;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.Species2;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StringRef;
+import fr.ulr.sammoa.persistence.StringRefs;
+import fr.ulr.sammoa.ui.swing.SammoaDecoratorProvider;
+import fr.ulr.sammoa.ui.swing.SammoaUIContext;
+import fr.ulr.sammoa.ui.swing.SammoaUIHandler;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.OneClicListSelectionModel;
+import jaxx.runtime.swing.editor.bean.BeanListHeader;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.decorator.Decorator;
+import org.nuiton.util.decorator.DecoratorUtil;
+import org.nuiton.util.decorator.JXPathDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Handler of {@link ExportMapUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class ExportMapUIHandler implements SammoaUIHandler {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ExportMapUIHandler.class);
+
+ private final ExportMapUI ui;
+
+ protected SammoaUIContext context;
+
+ public ExportMapUIHandler(SammoaUIContext context,
+ ExportMapUI ui) {
+ this.context = context;
+ this.ui = ui;
+ }
+
+ protected ReferentialService getReferentialService() {
+ return context.getAppContext().getReferentialService();
+ }
+
+ protected ExportMapService getExportMapService() {
+ return context.getAppContext().getExportMapService();
+ }
+
+ public SammoaDecoratorProvider getDecoratorProvider() {
+ return context.getDecoratorProvider();
+ }
+
+ @Override
+ public void beforeInitUI() {
+
+ //-- create model --//
+
+ ExportMapUIModel model = new ExportMapUIModel();
+
+ List<Campaign> campaigns = getReferentialService().getCampaigns();
+ //TODO-tchemit-2012-08-03 add an null campaign (for test purpose, should be removed...)
+ campaigns.add(0, null);
+ model.setCampaigns(campaigns);
+ model.setRouteTypes(Lists.newArrayList(RouteType.values()));
+
+ String campaignId = context.getCampaignId();
+
+ if (campaignId != null) {
+
+ Campaign campaign = getReferentialService().getCampaign(campaignId);
+
+ // selected cam
+ model.setSelectedCampaign(campaign);
+ }
+
+ //-- share model and handler in jaxx context --//
+ ui.setContextValue(this);
+ ui.setContextValue(model);
+
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ if (ExportMapUIModel.PROPERTY_SELECTED_CAMPAIGN.equals(evt.getPropertyName())) {
+ Campaign newValue = (Campaign) evt.getNewValue();
+ onSelectedCampaignChanged(newValue);
+ } else if (ExportMapUIModel.PROPERTY_STRATES.equals(evt.getPropertyName())) {
+ List<Strate> newValue = (List<Strate>) evt.getNewValue();
+ onStratesChanged(newValue);
+ } else if (ExportMapUIModel.PROPERTY_SPECIES.equals(evt.getPropertyName())) {
+ List<Species> newValue = (List<Species>) evt.getNewValue();
+ onSpeciesChanged(newValue);
+ } else if (ExportMapUIModel.PROPERTY_SPECIES_TYPES.equals(evt.getPropertyName())) {
+ List<StringRef> newValue = (List<StringRef>) evt.getNewValue();
+ onSpeciesTypesChanged(newValue);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void afterInitUI() {
+ ExportMapUIModel model = getModel();
+
+ model.setExportEffortsFilename("Efforts");
+ model.setExportObservationsFilename("Observations");
+ model.setExportGeoPointsFilename("GeoPoints");
+
+ File currentDirectory = FileUtil.getCurrentDirectory();
+ String absolutePath = currentDirectory.getAbsolutePath();
+ if (absolutePath.endsWith(File.separator + ".")) {
+ currentDirectory = new File(absolutePath.substring(0, absolutePath.length() - 2));
+ }
+ if (logger.isInfoEnabled()) {
+ logger.info("Current directory to use: {}", currentDirectory);
+ }
+ model.setExportDirectory(currentDirectory);
+
+ SwingUtil.fillComboBox(ui.getCampaignCombobox(),
+ model.getCampaigns(),
+ model.getSelectedCampaign());
+
+ prepareList(ui.getStrateFilterListHeader(), model.getStrates());
+ prepareList(ui.getRouteTypeFilterListHeader(), model.getRouteTypes());
+ prepareList(ui.getSpeciesTypeFilterListHeader(), model.getSpeciesTypes());
+ prepareList(ui.getSpeciesFilterListHeader(), model.getSpecies());
+
+ onSelectedCampaignChanged(model.getSelectedCampaign());
+ }
+
+ protected void onStratesChanged(List<Strate> newValue) {
+ if (logger.isInfoEnabled()) {
+ logger.info("New strates to use: {}", newValue.size());
+ }
+ ui.getStrateFilterListHeader().setData(newValue);
+ }
+
+ protected void onSpeciesChanged(List<Species> newValue) {
+ if (logger.isInfoEnabled()) {
+ logger.info("New species to use: {}", newValue.size());
+ }
+ ui.getSpeciesFilterListHeader().setData(newValue);
+ }
+
+ protected void onSpeciesTypesChanged(List<StringRef> newValue) {
+ if (logger.isInfoEnabled()) {
+ logger.info("New species types to use: {}", newValue.size());
+ }
+ ui.getSpeciesTypeFilterListHeader().setData(newValue);
+ }
+
+ protected void onSelectedCampaignChanged(Campaign newCampaign) {
+
+ // reset strates,...
+ if (logger.isInfoEnabled()) {
+ Decorator<Campaign> decorator = getDecoratorProvider().getDecoratorByType(Campaign.class);
+ logger.info("New selected campain: {}", decorator.toString(newCampaign));
+ }
+
+ ExportMapUIModel model = getModel();
+
+ model.setSelectedStrates(Collections.<Strate>emptyList());
+ model.setSelectedSpecies(Collections.<Species>emptyList());
+ model.setSelectedSpeciesTypes(Collections.<StringRef>emptyList());
+
+ List<Strate> strates;
+ if (newCampaign == null) {
+ strates = Collections.emptyList();
+ } else {
+ strates = getReferentialService().getAllStrates(newCampaign);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("New strates: {}", strates.size());
+ }
+ model.setStrates(strates);
+
+ List<Species> species;
+ List<StringRef> speciesTypes;
+
+ if (newCampaign == null) {
+ species = Collections.emptyList();
+ speciesTypes = Collections.emptyList();
+
+ } else {
+ species = getReferentialService().getAllSpecies(newCampaign);
+ speciesTypes = StringRefs.toRefs(Species2.toSpeciesTypes(species));
+ }
+ model.setSpecies(species);
+ model.setSpeciesTypes(speciesTypes);
+ }
+
+ public void close() {
+ context.setHomeScreen();
+ }
+
+ @Override
+ public void onCloseUI() {
+ }
+
+ public void chooseEffortDirectory() {
+ File f = SammoaUtil.chooseDirectory(
+ ui,
+ _("sammoa.title.choose.export.directory"),
+ _("sammoa.action.choose.export.directory"),
+ ui.getModel().getExportDirectory()
+ );
+ ui.getModel().setExportDirectory(f);
+ }
+
+ public void exportEfforts() {
+
+ Action startAction = new AbstractAction(
+ _("sammoa.action.startExport"),
+ SwingUtil.createActionIcon("accept")) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JButton source = (JButton) e.getSource();
+ ExportMapLauncherUI fileChooserUI = SwingUtil.getParentContainer(
+ source, ExportMapLauncherUI.class);
+
+ SammoaUtil.updateBusyState(fileChooserUI, true);
+ try {
+ ExportMapUIModel model = ui.getModel();
+
+ // persist the file name
+ model.setExportEffortsFilename(model.getExportFilename());
+
+ // create export service model
+ ExportMapModel dataModel =
+ model.toModel(model.getExportEffortsFilename());
+
+ // launch export
+ getExportMapService().exportEffortsMap(dataModel);
+
+ } finally {
+
+ SwingUtil.getParentContainer(
+ source, JDialog.class).setVisible(false);
+ }
+ }
+ };
+
+ ExportMapUIModel model = getModel();
+ displayExportLauncher(_("sammoa.title.export.exportEfforts"),
+ model.getExportEffortsFilename(),
+ model,
+ startAction);
+ }
+
+ public void exportObservations() {
+
+ Action startAction = new AbstractAction(
+ _("sammoa.action.startExport"),
+ SwingUtil.createActionIcon("accept")) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ JButton source = (JButton) e.getSource();
+ ExportMapLauncherUI fileChooserUI = SwingUtil.getParentContainer(
+ source, ExportMapLauncherUI.class);
+
+ try {
+ SammoaUtil.updateBusyState(fileChooserUI, true);
+ ExportMapUIModel model = ui.getModel();
+
+ // persist the file name
+ model.setExportObservationsFilename(model.getExportFilename());
+
+ // create export service model
+ ExportMapModel dataModel =
+ model.toModel(model.getExportObservationsFilename());
+
+ // launch export
+ getExportMapService().exportObservationsMap(dataModel);
+
+ } finally {
+
+ SwingUtil.getParentContainer(
+ source, JDialog.class).setVisible(false);
+ }
+ }
+ };
+
+ ExportMapUIModel model = getModel();
+ displayExportLauncher(_("sammoa.title.export.exportObservations"),
+ model.getExportObservationsFilename(),
+ model,
+ startAction);
+ }
+
+ public void exportGeoPoints() {
+
+
+
+ Action startAction = new AbstractAction(
+ _("sammoa.action.startExport"),
+ SwingUtil.createActionIcon("accept")) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ JButton source = (JButton) e.getSource();
+
+ ExportMapLauncherUI fileChooserUI = SwingUtil.getParentContainer(
+ source, ExportMapLauncherUI.class);
+ SammoaUtil.updateBusyState(fileChooserUI, true);
+ try {
+
+ ExportMapUIModel model = getModel();
+
+ // persist the file name
+ model.setExportGeoPointsFilename(model.getExportFilename());
+
+ // create export service model
+ ExportMapModel dataModel =
+ model.toModel(model.getExportGeoPointsFilename());
+
+ // launch export
+ getExportMapService().exportGeoPointsMap(dataModel);
+
+ } finally {
+
+ SwingUtil.getParentContainer(
+ source, JDialog.class).setVisible(false);
+ }
+ }
+ };
+
+ ExportMapUIModel model = getModel();
+ displayExportLauncher(_("sammoa.title.export.exportGeoPoints"),
+ model.getExportGeoPointsFilename(),
+ model,
+ startAction);
+ }
+
+ public ExportMapUIModel getModel() {
+ return ui.getModel();
+ }
+
+ protected void displayExportLauncher(String effortTitle,
+ String defaultFilename,
+ ExportMapUIModel model,
+ Action startAction) {
+
+ model.setExportFilename(defaultFilename);
+ final ExportMapLauncherUI ui = new ExportMapLauncherUI(this);
+
+ JFrame frame = this.ui.getParentContainer(JFrame.class);
+ Action closeAction = new AbstractAction(
+ _("sammoa.action.cancelExport"),
+ SwingUtil.createActionIcon("cancel")) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ ui.getParentContainer(JDialog.class).setVisible(false);
+ }
+ };
+
+ ui.getStart().setAction(startAction);
+ ui.getCancel().setAction(closeAction);
+
+ SammoaUtil.openInDialog(ui,
+ frame,
+ effortTitle,
+ closeAction,
+ new Dimension(550, 150));
+ }
+
+ /**
+ * Remplit le modèle d'une liste graphique avec la liste des entités d'un
+ * type donné sur un service de persistance donné.
+ *
+ * @param list le component graphique à initialiser
+ * @param incomingData les données à mettre dans la liste
+ * @since 0.5
+ */
+ protected <E> void prepareList(BeanListHeader<E> list, List<E> incomingData) {
+
+ Class<E> beanType = list.getBeanType();
+
+ JList jList = list.getList();
+
+ //FIXME-tchemit 2012-08-01 Fix selection model which bugs when deselect
+ OneClicListSelectionModel.installModel(jList);
+
+ // init list
+ Decorator<E> decorator = getDecoratorProvider().getDecoratorByType(beanType);
+ Preconditions.checkNotNull(decorator, "No decorator found for type " + beanType);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Will use decorator " + decorator);
+ }
+
+ list.putClientProperty("decorator", decorator);
+ List<E> data = Lists.newArrayList(incomingData);
+
+ // sort data from first decorator context
+ DecoratorUtil.sort((JXPathDecorator<E>) decorator, data, 0);
+
+ // set datas to list and init renderer
+ list.init((JXPathDecorator<E>) decorator, data);
+
+// // get the renderer initialized
+// ListCellRenderer renderer = list.getList().getCellRenderer();
+//
+// // add the specific renderer
+// list.getList().setCellRenderer(new ReferentielListCellRenderer(renderer));
+
+ list.putClientProperty("data", data);
+ }
+
+
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIModel.java (from rev 413, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,344 @@
+package fr.ulr.sammoa.ui.swing.io.output.map;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ulr.sammoa.application.io.output.map.ExportMapModel;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.Species2;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StringRef;
+import org.jdesktop.beans.AbstractSerializableBean;
+
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Model of export map UI.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class ExportMapUIModel extends AbstractSerializableBean {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CAMPAIGNS = "campaigns";
+
+ public static final String PROPERTY_SELECTED_CAMPAIGN = "selectedCampaign";
+
+ public static final String PROPERTY_BEGIN_DATE = "beginDate";
+
+ public static final String PROPERTY_END_DATE = "endDate";
+
+ public static final String PROPERTY_STRATES = "strates";
+
+ public static final String PROPERTY_SELECTED_STRATES = "selectedStrates";
+
+ public static final String PROPERTY_ROUTE_TYPES = "routeTypes";
+
+ public static final String PROPERTY_SELECTED_ROUTE_TYPES = "selectedRouteTypes";
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_SELECTED_SPECIES = "selectedSpecies";
+
+ public static final String PROPERTY_SPECIES_TYPES = "speciesTypes";
+
+ public static final String PROPERTY_SELECTED_SPECIES_TYPES = "selectedSpeciesTypes";
+
+ public static final String PROPERTY_EXPORT_DIRECTORY = "exportDirectory";
+
+ public static final String PROPERTY_EXPORT_FILENAME = "exportFilename";
+
+ public static final String PROPERTY_EXPORT_EFFORTS_FILENAME = "exportEffortsFilename";
+
+ public static final String PROPERTY_EXPORT_OBSERVATIONS_FILENAME = "exportObservationsFilename";
+
+ public static final String PROPERTY_EXPORT_GEO_POINTS_FILENAME = "exportGeoPointsFilename";
+
+ protected List<Campaign> campaigns;
+
+ protected Campaign selectedCampaign;
+
+ protected Date beginDate;
+
+ protected Date endDate;
+
+ protected List<Strate> strates;
+
+ protected List<Strate> selectedStrates;
+
+ protected List<RouteType> routeTypes;
+
+ protected List<RouteType> selectedRouteTypes;
+
+ protected List<Species> species;
+
+ protected List<Species> selectedSpecies;
+
+ protected List<StringRef> selectedSpeciesTypes;
+
+ protected List<StringRef> speciesTypes;
+
+ protected File exportDirectory;
+
+ protected String exportFilename;
+
+ protected String exportEffortsFilename;
+
+ protected String exportObservationsFilename;
+
+ protected String exportGeoPointsFilename;
+
+ public File getExportDirectory() {
+ return exportDirectory;
+ }
+
+ public void setExportDirectory(File exportDirectory) {
+ File oldValue = this.exportDirectory;
+ this.exportDirectory = exportDirectory;
+ firePropertyChange(PROPERTY_EXPORT_DIRECTORY, oldValue, exportDirectory);
+ }
+
+ public String getExportFilename() {
+ return exportFilename;
+ }
+
+ public void setExportFilename(String exportFilename) {
+ String oldValue = this.exportFilename;
+ this.exportFilename = exportFilename;
+ firePropertyChange(PROPERTY_EXPORT_FILENAME, oldValue, exportFilename);
+ }
+
+ public String getExportEffortsFilename() {
+ return exportEffortsFilename;
+ }
+
+ public void setExportEffortsFilename(String exportEffortsFilename) {
+ String oldValue = this.exportEffortsFilename;
+ this.exportEffortsFilename = exportEffortsFilename;
+ firePropertyChange(PROPERTY_EXPORT_EFFORTS_FILENAME, oldValue, exportEffortsFilename);
+ }
+
+ public String getExportObservationsFilename() {
+ return exportObservationsFilename;
+ }
+
+ public void setExportObservationsFilename(String exportObservationsFilename) {
+ String oldValue = this.exportObservationsFilename;
+ this.exportObservationsFilename = exportObservationsFilename;
+ firePropertyChange(PROPERTY_EXPORT_OBSERVATIONS_FILENAME, oldValue, exportObservationsFilename);
+ }
+
+ public String getExportGeoPointsFilename() {
+ return exportGeoPointsFilename;
+ }
+
+ public void setExportGeoPointsFilename(String exportGeoPointsFilename) {
+ String oldValue = this.exportGeoPointsFilename;
+ this.exportGeoPointsFilename = exportGeoPointsFilename;
+ firePropertyChange(PROPERTY_EXPORT_GEO_POINTS_FILENAME, oldValue, exportGeoPointsFilename);
+ }
+
+ public List<Campaign> getCampaigns() {
+ if (campaigns == null) {
+ campaigns = Lists.newArrayList();
+ }
+ return campaigns;
+ }
+
+ public void setCampaigns(List<Campaign> campaigns) {
+ List<Campaign> oldValue = this.campaigns;
+ this.campaigns = campaigns;
+ firePropertyChange(PROPERTY_CAMPAIGNS, oldValue, campaigns);
+ }
+
+ public Campaign getSelectedCampaign() {
+ return selectedCampaign;
+ }
+
+ public void setSelectedCampaign(Campaign selectedCampaign) {
+ Campaign oldValue = this.selectedCampaign;
+ this.selectedCampaign = selectedCampaign;
+ firePropertyChange(PROPERTY_SELECTED_CAMPAIGN, oldValue, selectedCampaign);
+ }
+
+ public Date getBeginDate() {
+ return beginDate;
+ }
+
+ public void setBeginDate(Date beginDate) {
+ Date oldValue = this.beginDate;
+ this.beginDate = beginDate;
+ firePropertyChange(PROPERTY_BEGIN_DATE, oldValue, beginDate);
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Date endDate) {
+ Date oldValue = this.endDate;
+ this.endDate = endDate;
+ firePropertyChange(PROPERTY_END_DATE, oldValue, endDate);
+ }
+
+ public List<Strate> getStrates() {
+ if (strates == null) {
+ strates = Lists.newArrayList();
+ }
+ return strates;
+ }
+
+ public void setStrates(List<Strate> strates) {
+ List<Strate> oldValue = this.strates;
+ this.strates = strates;
+ firePropertyChange(PROPERTY_STRATES, oldValue, strates);
+ }
+
+ public List<Strate> getSelectedStrates() {
+ if (selectedStrates == null) {
+ selectedStrates = Lists.newArrayList();
+ }
+ return selectedStrates;
+ }
+
+ public void setSelectedStrates(List<Strate> selectedStrates) {
+ List<Strate> oldValue = this.selectedStrates;
+ this.selectedStrates = selectedStrates;
+ firePropertyChange(PROPERTY_SELECTED_STRATES, oldValue, selectedStrates);
+ }
+
+ public List<RouteType> getRouteTypes() {
+ if (routeTypes == null) {
+ routeTypes = Lists.newArrayList();
+ }
+ return routeTypes;
+ }
+
+ public void setRouteTypes(List<RouteType> routeTypes) {
+ List<RouteType> oldValue = this.routeTypes;
+ this.routeTypes = routeTypes;
+ firePropertyChange(PROPERTY_ROUTE_TYPES, oldValue, routeTypes);
+ }
+
+ public List<RouteType> getSelectedRouteTypes() {
+ if (selectedRouteTypes == null) {
+ selectedRouteTypes = Lists.newArrayList();
+ }
+ return selectedRouteTypes;
+ }
+
+ public void setSelectedRouteTypes(List<RouteType> selectedRouteTypes) {
+ List<RouteType> oldValue = this.selectedRouteTypes;
+ this.selectedRouteTypes = selectedRouteTypes;
+ firePropertyChange(PROPERTY_SELECTED_ROUTE_TYPES, oldValue, selectedRouteTypes);
+ }
+
+ public List<Species> getSpecies() {
+ if (species == null) {
+ species = Lists.newArrayList();
+ }
+ return species;
+ }
+
+ public void setSpecies(List<Species> species) {
+ List<Species> oldValue = this.species;
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
+
+ public List<Species> getSelectedSpecies() {
+ if (selectedSpecies == null) {
+ selectedSpecies = Lists.newArrayList();
+ }
+ return selectedSpecies;
+ }
+
+ public void setSelectedSpecies(List<Species> selectedSpecies) {
+ List<Species> oldValue = this.selectedSpecies;
+ this.selectedSpecies = selectedSpecies;
+ firePropertyChange(PROPERTY_SELECTED_SPECIES, oldValue, selectedSpecies);
+ }
+
+ public List<StringRef> getSpeciesTypes() {
+ if (speciesTypes == null) {
+ speciesTypes = Lists.newArrayList();
+ }
+ return speciesTypes;
+ }
+
+ public void setSpeciesTypes(List<StringRef> speciesTypes) {
+ List<StringRef> oldValue = this.speciesTypes;
+ this.speciesTypes = speciesTypes;
+ firePropertyChange(PROPERTY_SPECIES_TYPES, oldValue, speciesTypes);
+ }
+
+ public List<StringRef> getSelectedSpeciesTypes() {
+ if (selectedSpeciesTypes == null) {
+ selectedSpeciesTypes = Lists.newArrayList();
+ }
+ return selectedSpeciesTypes;
+ }
+
+ public void setSelectedSpeciesTypes(List<StringRef> selectedSpeciesTypes) {
+ List<StringRef> oldValue = this.selectedSpeciesTypes;
+ this.selectedSpeciesTypes = selectedSpeciesTypes;
+ firePropertyChange(PROPERTY_SELECTED_SPECIES_TYPES, oldValue, selectedSpeciesTypes);
+ }
+
+ public ExportMapModel toModel(String filename) {
+
+ List<Species> speciesToUse = Species2.getSelectedSpecies(
+ getSpecies(), getSelectedSpecies(), getSelectedSpeciesTypes());
+
+ // Ensure bounds for beginDate and enDate
+ Date beginDate = getBeginDate();
+ Date campaignBeginDate = getSelectedCampaign().getBeginDate();
+ if (beginDate == null || beginDate.before(campaignBeginDate)) {
+ beginDate = campaignBeginDate;
+ }
+ Date endDate = getEndDate();
+ Date campaignEndDate = getSelectedCampaign().getEndDate();
+ if (endDate == null || endDate.after(campaignEndDate)) {
+ endDate = campaignEndDate;
+ }
+
+ ExportMapModel result = ExportMapModel.newModel(
+ getExportDirectory(),
+ filename,
+ getSelectedCampaign(),
+ beginDate,
+ endDate,
+ getSelectedStrates(),
+ getSelectedRouteTypes(),
+ speciesToUse
+ );
+ return result;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/map/ExportMapUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.css (from rev 413, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.css)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.css (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.css 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,91 @@
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+#campaignLabel {
+ text: "sammoa.label.campaign";
+}
+
+#campaignCombobox {
+ renderer: {new DecoratorProviderListCellRenderer(getHandler().getDecoratorProvider())};
+}
+
+#flightLabel {
+ text: "sammoa.label.flight";
+}
+
+#flightCombobox {
+ renderer: {new DecoratorProviderListCellRenderer(getHandler().getDecoratorProvider())};
+}
+
+#quitButton {
+ text:"sammoa.action.quitExportMaps";
+}
+
+#exportButton {
+ text:"sammoa.action.exportApplication";
+}
+
+#exportDirectoryFileChooseAction {
+ actionIcon:"fileChooser";
+}
+
+#exportDirectoryLbl {
+ text:"sammoa.label.exportApplicationDirectory";
+}
+
+#exportDirectory {
+ text:{model.getExportDirectory().getAbsolutePath()};
+}
+
+#exportFilenameLbl {
+ text:"sammoa.label.exportApplicationFilename";
+}
+
+#exportFilename {
+ text:{model.getExportFilename()};
+}
+
+#callbackLbl {
+ text:"sammoa.label.exportApplication.callbacks";
+}
+
+#callbackNothing {
+ text:"sammoa.label.exportApplication.callbackNothing";
+ selected:{ExportApplicationCallbackMode.NOTHING == model.getCallback()};
+ buttonGroup:"callbacks";
+ value:{ExportApplicationCallbackMode.NOTHING};
+}
+
+#callbackRemoveData {
+ text:"sammoa.label.exportApplication.callbackRemoveData";
+ buttonGroup:"callbacks";
+ selected:{ExportApplicationCallbackMode.REMOVE_FLIGHTS == model.getCallback()};
+ value:{ExportApplicationCallbackMode.REMOVE_FLIGHTS};
+}
+
+#callbackRemoveAll {
+ text:"sammoa.label.exportApplication.callbackRemoveAll";
+ buttonGroup:"callbacks";
+ selected:{ExportApplicationCallbackMode.REMOVE_ALL == model.getCallback()};
+ value:{ExportApplicationCallbackMode.REMOVE_ALL};
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.jaxx (from rev 413, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.jaxx)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.jaxx (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.jaxx 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,130 @@
+<!--
+ #%L
+ SAMMOA :: UI Swing
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 UMS 3462, Code Lutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JPanel id='exportApplicationUI' layout='{new BorderLayout()}'
+ implements='fr.ulr.sammoa.ui.swing.SammoaUI<ExportApplicationUIHandler>'>
+
+ <import>
+ fr.ulr.sammoa.persistence.Campaign
+ fr.ulr.sammoa.persistence.Flight
+ fr.ulr.sammoa.ui.swing.SammoaUIContext
+ fr.ulr.sammoa.application.io.output.sammoa.ExportApplicationCallbackMode
+
+ jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer
+
+ java.awt.BorderLayout
+ java.awt.event.ItemEvent
+ java.io.File
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+ public ExportApplicationUI(SammoaUIContext context) {
+ ExportApplicationUIHandler handler =
+ new ExportApplicationUIHandler(context, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+ }
+
+ protected void $afterCompleteSetup() {
+ getHandler().afterInitUI();
+ }
+ ]]></script>
+
+ <ExportApplicationUIModel id='model'
+ initializer='getContextValue(ExportApplicationUIModel.class)'/>
+
+ <ExportApplicationUIHandler id='handler'
+ initializer='getContextValue(ExportApplicationUIHandler.class)'/>
+
+ <Table fill='both' constraints='BorderLayout.CENTER'>
+ <!-- Campaign filter -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='campaignLabel'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0' columns='2'>
+ <JComboBox id='campaignCombobox'
+ onItemStateChanged='if (ItemEvent.SELECTED == event.getStateChange()) { getModel().setSelectedCampaign((Campaign)event.getItem()); } else { getModel().setSelectedCampaign(null); }'/>
+ </cell>
+ </row>
+ <!-- Flight filter -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='flightLabel'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0' columns='2'>
+ <JComboBox id='flightCombobox'
+ onItemStateChanged='if (ItemEvent.SELECTED == event.getStateChange()) { getModel().setSelectedFlight((Flight)event.getItem()); } else { getModel().setSelectedFlight(null); }'/>
+ </cell>
+ </row>
+ <!-- export directory-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='exportDirectoryLbl'/>
+ </cell>
+ <cell weightx='1' fill="horizontal">
+ <JTextField id='exportDirectory'
+ onKeyReleased='getModel().setExportDirectory(new File(((JTextField)event.getSource()).getText()))'/>
+ </cell>
+ <cell anchor="east">
+ <JButton id="exportDirectoryFileChooseAction"
+ onActionPerformed="getHandler().chooseExportDirectory()"/>
+ </cell>
+ </row>
+ <row>
+ <cell anchor='west'>
+ <JLabel id='exportFilenameLbl'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0' columns='2'>
+ <JTextField id='exportFilename'
+ onKeyReleased='model.setExportFilename(((JTextField)event.getSource()).getText())'/>
+ </cell>
+ </row>
+ <!-- callBack -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='callbackLbl'/>
+ </cell>
+ <cell weightx='1' fill="horizontal" columns='2'>
+ <JPanel layout='{new GridLayout(0,1)}'>
+ <JRadioButton id='callbackNothing'/>
+ <JRadioButton id='callbackRemoveData'/>
+ <JRadioButton id='callbackRemoveAll'/>
+ </JPanel>
+ </cell>
+ </row>
+ <!--export actions-->
+ <row>
+ <cell columns='5' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='quitButton' onActionPerformed='getHandler().close()'/>
+ <JButton id='exportButton'
+ onActionPerformed='getHandler().exportApplication()'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</JPanel>
\ No newline at end of file
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIHandler.java (from rev 413, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIHandler.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIHandler.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIHandler.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,270 @@
+package fr.ulr.sammoa.ui.swing.io.output.sammoa;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.application.FlightService;
+import fr.ulr.sammoa.application.ReferentialService;
+import fr.ulr.sammoa.application.io.output.sammoa.ExportApplicationCallbackMode;
+import fr.ulr.sammoa.application.io.output.sammoa.ExportApplicationModel;
+import fr.ulr.sammoa.application.io.output.sammoa.ExportApplicationService;
+import fr.ulr.sammoa.application.io.output.map.ExportMapService;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.ui.swing.SammoaDecoratorProvider;
+import fr.ulr.sammoa.ui.swing.SammoaUIContext;
+import fr.ulr.sammoa.ui.swing.SammoaUIHandler;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import jaxx.runtime.SwingUtil;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.decorator.Decorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Handelr of {@link ExportApplicationUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ExportApplicationUIHandler implements SammoaUIHandler {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ExportApplicationUIHandler.class);
+
+ private final ExportApplicationUI ui;
+
+ protected SammoaUIContext context;
+
+ public ExportApplicationUIHandler(SammoaUIContext context,
+ ExportApplicationUI ui) {
+ this.context = context;
+ this.ui = ui;
+ }
+
+ protected ReferentialService getReferentialService() {
+ return context.getAppContext().getReferentialService();
+ }
+
+ protected FlightService getFlightService() {
+ return context.getAppContext().getFlightService();
+ }
+
+ protected ExportMapService getExportMapService() {
+ return context.getAppContext().getExportMapService();
+ }
+
+ public SammoaDecoratorProvider getDecoratorProvider() {
+ return context.getDecoratorProvider();
+ }
+
+ @Override
+ public void beforeInitUI() {
+
+ //-- create model --//
+
+ ExportApplicationUIModel model = new ExportApplicationUIModel();
+
+ List<Campaign> campaigns = getReferentialService().getCampaigns();
+ //TODO-tchemit-2012-08-03 add an null campaign (for test purpose, should be removed...)
+ campaigns.add(0, null);
+ model.setCampaigns(campaigns);
+
+ String campaignId = context.getCampaignId();
+
+ if (campaignId != null) {
+
+ Campaign campaign = getReferentialService().getCampaign(campaignId);
+
+ // selected cam
+ model.setSelectedCampaign(campaign);
+ }
+
+ String flightId = context.getFlightId();
+
+ if (flightId != null) {
+
+ Flight flight = getFlightService().getFlight(flightId);
+
+ // selected cam
+ model.setSelectedFlight(flight);
+ }
+
+ //-- share model and handler in jaxx context --//
+ ui.setContextValue(this);
+ ui.setContextValue(model);
+
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ if (ExportApplicationUIModel.PROPERTY_SELECTED_CAMPAIGN.equals(evt.getPropertyName())) {
+ Campaign newValue = (Campaign) evt.getNewValue();
+ onSelectedCampaignChanged(newValue);
+ } else if (ExportApplicationUIModel.PROPERTY_FLIGHTS.equals(evt.getPropertyName())) {
+ Collection<Flight> newValue = (Collection<Flight>) evt.getNewValue();
+ onFlightsChanged(newValue);
+ } else if (ExportApplicationUIModel.PROPERTY_SELECTED_FLIGHT.equals(evt.getPropertyName())) {
+ Flight newValue = (Flight) evt.getNewValue();
+ onSelectedFlightChanged(newValue);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void afterInitUI() {
+ ExportApplicationUIModel model = getModel();
+
+ File currentDirectory = FileUtil.getCurrentDirectory();
+ String absolutePath = currentDirectory.getAbsolutePath();
+ if (absolutePath.endsWith(File.separator + ".")) {
+ currentDirectory = new File(absolutePath.substring(0, absolutePath.length() - 2));
+ }
+ if (logger.isInfoEnabled()) {
+ logger.info("Current directory to use: {}", currentDirectory);
+ }
+ model.setExportDirectory(currentDirectory);
+ model.setCallback(ExportApplicationCallbackMode.NOTHING);
+
+ SwingUtil.fillComboBox(ui.getCampaignCombobox(),
+ model.getCampaigns(),
+ model.getSelectedCampaign());
+
+ Flight selectedFlight = model.getSelectedFlight();
+
+ onSelectedCampaignChanged(model.getSelectedCampaign());
+ onSelectedFlightChanged(selectedFlight);
+ }
+
+ public void exportApplication() {
+
+ JFrame frame = ui.getParentContainer(JFrame.class);
+ SammoaUtil.updateBusyState(frame, true);
+
+ try {
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ @Override
+ public void run() {
+ ExportApplicationModel dataModel = getModel().toModel();
+
+ ExportApplicationService service =
+ context.getAppContext().newExportApplicationService();
+ service.exportApplication(dataModel);
+ }
+ }
+ );
+
+ } finally {
+ SammoaUtil.updateBusyState(frame, false);
+ }
+ }
+
+ protected void onSelectedCampaignChanged(Campaign newCampaign) {
+
+ // reset flights,...
+ if (logger.isInfoEnabled()) {
+ Decorator<Campaign> decorator = getDecoratorProvider().getDecoratorByType(Campaign.class);
+ logger.info("New selected campain: {}", decorator.toString(newCampaign));
+ }
+
+ ExportApplicationUIModel model = getModel();
+
+ List<Flight> flights;
+ String filename;
+ if (newCampaign == null) {
+ flights = Collections.emptyList();
+ filename = "";
+ } else {
+ flights = getFlightService().getFlights(newCampaign);
+ filename = String.format("campaign-%s.sammoa", newCampaign.getCode());
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("New flights: {}", flights.size());
+ logger.debug("New filename: {}", filename);
+ }
+ model.setFlights(flights);
+ model.setExportFilename(filename);
+ }
+
+ protected void onFlightsChanged(Collection<Flight> flights) {
+
+ ExportApplicationUIModel model = getModel();
+ Flight selectedFlight = model.getSelectedFlight();
+ if (flights.contains(selectedFlight)) {
+ model.setSelectedFlight(null);
+ }
+
+ SwingUtil.fillComboBox(ui.getFlightCombobox(),
+ flights,
+ selectedFlight);
+ }
+
+ protected void onSelectedFlightChanged(Flight newCampaign) {
+
+ // reset flights,...
+ if (logger.isInfoEnabled()) {
+ Decorator<Flight> decorator = getDecoratorProvider().getDecoratorByType(Flight.class);
+ logger.info("New selected flight: {}", decorator.toString(newCampaign));
+ }
+
+ ExportApplicationUIModel model = getModel();
+ }
+
+ public void close() {
+ context.setHomeScreen();
+ }
+
+ @Override
+ public void onCloseUI() {
+ }
+
+ public void chooseExportDirectory() {
+ File f = SammoaUtil.chooseDirectory(
+ ui,
+ _("sammoa.title.choose.export.directory"),
+ _("sammoa.action.choose.export.directory"),
+ ui.getModel().getExportDirectory()
+ );
+ ui.getModel().setExportDirectory(f);
+ }
+
+
+ public ExportApplicationUIModel getModel() {
+ return ui.getModel();
+ }
+
+
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,161 @@
+package fr.ulr.sammoa.ui.swing.io.output.sammoa;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL: http://svn.forge.codelutin.com/svn/sammoa/trunk/sammoa-ui-swing/src/main/ja… $
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ulr.sammoa.application.io.output.sammoa.ExportApplicationCallbackMode;
+import fr.ulr.sammoa.application.io.output.sammoa.ExportApplicationModel;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Flight;
+import org.jdesktop.beans.AbstractSerializableBean;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Model of export application UI.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ExportApplicationUIModel extends AbstractSerializableBean {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CAMPAIGNS = "campaigns";
+
+ public static final String PROPERTY_SELECTED_CAMPAIGN = "selectedCampaign";
+
+ public static final String PROPERTY_FLIGHTS = "flights";
+
+ public static final String PROPERTY_SELECTED_FLIGHT = "selectedFlight";
+
+ public static final String PROPERTY_EXPORT_DIRECTORY = "exportDirectory";
+
+ public static final String PROPERTY_EXPORT_FILENAME = "exportFilename";
+
+ public static final String PROPERTY_CALLBACK = "callback";
+
+ protected List<Campaign> campaigns;
+
+ protected Campaign selectedCampaign;
+
+ protected List<Flight> flights;
+
+ protected Flight selectedFlight;
+
+ protected File exportDirectory;
+
+ protected String exportFilename;
+
+ protected ExportApplicationCallbackMode callback;
+
+ public File getExportDirectory() {
+ return exportDirectory;
+ }
+
+ public void setExportDirectory(File exportDirectory) {
+ File oldValue = this.exportDirectory;
+ this.exportDirectory = exportDirectory;
+ firePropertyChange(PROPERTY_EXPORT_DIRECTORY, oldValue, exportDirectory);
+ }
+
+ public String getExportFilename() {
+ return exportFilename;
+ }
+
+ public void setExportFilename(String exportFilename) {
+ String oldValue = this.exportFilename;
+ this.exportFilename = exportFilename;
+ firePropertyChange(PROPERTY_EXPORT_FILENAME, oldValue, exportFilename);
+ }
+
+ public List<Campaign> getCampaigns() {
+ if (campaigns == null) {
+ campaigns = Lists.newArrayList();
+ }
+ return campaigns;
+ }
+
+ public void setCampaigns(List<Campaign> campaigns) {
+ List<Campaign> oldValue = this.campaigns;
+ this.campaigns = campaigns;
+ firePropertyChange(PROPERTY_CAMPAIGNS, oldValue, campaigns);
+ }
+
+ public Campaign getSelectedCampaign() {
+ return selectedCampaign;
+ }
+
+ public void setSelectedCampaign(Campaign selectedCampaign) {
+ Campaign oldValue = this.selectedCampaign;
+ this.selectedCampaign = selectedCampaign;
+ firePropertyChange(PROPERTY_SELECTED_CAMPAIGN, oldValue, selectedCampaign);
+ }
+
+ public List<Flight> getFlights() {
+ if (flights == null) {
+ flights = Lists.newArrayList();
+ }
+ return flights;
+ }
+
+ public void setFlights(List<Flight> flights) {
+ List<Flight> oldValue = this.flights;
+ this.flights = flights;
+ firePropertyChange(PROPERTY_FLIGHTS, oldValue, flights);
+ }
+
+ public Flight getSelectedFlight() {
+ return selectedFlight;
+ }
+
+ public void setSelectedFlight(Flight selectedFlight) {
+ Flight oldValue = this.selectedFlight;
+ this.selectedFlight = selectedFlight;
+ firePropertyChange(PROPERTY_SELECTED_FLIGHT, oldValue, selectedFlight);
+ }
+
+ public ExportApplicationCallbackMode getCallback() {
+ return callback;
+ }
+
+ public void setCallback(ExportApplicationCallbackMode callback) {
+ ExportApplicationCallbackMode oldValue = this.callback;
+ this.callback = callback;
+ firePropertyChange(PROPERTY_CALLBACK, oldValue, callback);
+ }
+
+ public ExportApplicationModel toModel() {
+
+ ExportApplicationModel result = ExportApplicationModel.newModel(
+ getExportDirectory(),
+ getExportFilename(),
+ getSelectedCampaign(),
+ getSelectedFlight(),
+ getCallback()
+ );
+ return result;
+ }
+}
\ No newline at end of file
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/sammoa/ExportApplicationUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUIHandler.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUIHandler.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -25,22 +25,23 @@
import fr.ulr.sammoa.application.ReferentialService;
import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.application.io.input.csv.ImportCsvService;
import fr.ulr.sammoa.persistence.Region;
import fr.ulr.sammoa.ui.swing.SammoaDecoratorProvider;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import fr.ulr.sammoa.ui.swing.SammoaUIHandler;
import fr.ulr.sammoa.ui.swing.util.CsvImporter;
-import fr.ulr.sammoa.ui.swing.util.Importer;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import fr.ulr.sammoa.ui.swing.util.UIImporter;
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.swing.*;
+import javax.swing.JFrame;
import java.io.File;
-import java.io.Reader;
+import java.io.IOException;
import static org.nuiton.i18n.I18n._;
@@ -52,22 +53,26 @@
*/
public class RegionUIHandler implements SammoaUIHandler {
- private static final Logger logger = LoggerFactory.getLogger(RegionUIHandler.class);
-
+ private static final Logger logger =
+ LoggerFactory.getLogger(RegionUIHandler.class);
+
protected SammoaUIContext context;
protected RegionUI ui;
-
+
+ protected final UIImporter uiImporter;
+
public RegionUIHandler(SammoaUIContext context,
RegionUI ui) {
this.context = context;
this.ui = ui;
+ this.uiImporter = new UIImporter(ui);
}
public SammoaContext getAppContext() {
return context.getAppContext();
}
-
+
public RegionUIModel getModel() {
return ui.getModel();
}
@@ -98,7 +103,7 @@
public void onCloseUI() {
ui.setVisible(false);
}
-
+
public void openUI() {
if (logger.isInfoEnabled()) {
@@ -113,7 +118,7 @@
}
public void saveRegion() {
-
+
try {
boolean success = true;
@@ -136,7 +141,7 @@
);
}
- success = speciesImporter.readFile(ui, speciesFile);
+ success = uiImporter.importCvs(speciesImporter, speciesFile);
}
SammoaUtil.updateBusyState(ui, false);
@@ -145,17 +150,18 @@
if (success) {
ui.getCloseButton().doClick();
}
-
+
} catch (Exception e) {
ErrorDialogUI.showError(e);
}
}
-
- protected Importer speciesImporter = new CsvImporter() {
+ protected CsvImporter speciesImporter = new CsvImporter() {
+
@Override
- protected String onActionPerformed(Reader reader) {
- int nbImported = getReferentialService().importSpecies(getModel().getId(), reader);
+ public String importCsvFile(File file) throws IOException {
+ ImportCsvService service = new ImportCsvService(getAppContext());
+ int nbImported = service.importSpecies(getModel().getId(), file);
return _("sammoa.messageDialog.species.import.success", nbImported);
}
};
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/transect/TransectUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/transect/TransectUIHandler.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/transect/TransectUIHandler.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -54,7 +54,8 @@
*/
public class TransectUIHandler implements SammoaUIHandler {
- private static final Logger logger = LoggerFactory.getLogger(TransectUIHandler.class);
+ private static final Logger logger =
+ LoggerFactory.getLogger(TransectUIHandler.class);
protected SammoaUIContext context;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/CsvImporter.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/CsvImporter.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/CsvImporter.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -2,8 +2,8 @@
/*
* #%L
* SAMMOA :: UI Swing
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2012 UMS 3462, Code Lutin
* %%
@@ -23,54 +23,16 @@
* #L%
*/
-import org.apache.commons.io.Charsets;
-import org.apache.commons.io.IOUtils;
-
-import javax.swing.JFileChooser;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import java.awt.Component;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
/**
* Created: 17/07/12
*
* @author fdesbois <desbois(a)codelutin.com>
*/
-public abstract class CsvImporter extends Importer {
+public abstract class CsvImporter {
- public void openFileChooser(Component ui) {
+ public abstract String importCsvFile(File file) throws IOException;
- JFileChooser fileChooser = new JFileChooser();
- fileChooser.setFileFilter(new FileNameExtensionFilter("CSV", "csv"));
-
- int response = fileChooser.showOpenDialog(ui);
- if (response == JFileChooser.APPROVE_OPTION) {
-
- File selectedFile = fileChooser.getSelectedFile();
- readFile(ui, selectedFile);
- }
- }
-
- @Override
- protected String onActionPerformed(File file) throws IOException {
-
- String result;
-
- InputStreamReader reader = null;
- try {
- reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
-
- result = onActionPerformed(reader);
-
- } finally {
- IOUtils.closeQuietly(reader);
- }
- return result;
- }
-
- protected abstract String onActionPerformed(Reader reader);
}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/Importer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/Importer.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/Importer.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,79 +0,0 @@
-package fr.ulr.sammoa.ui.swing.util;
-/*
- * #%L
- * SAMMOA :: UI Swing
- * $Id:$
- * $HeadURL:$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import org.nuiton.util.csv.ImportRuntimeException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.swing.*;
-import java.awt.*;
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Created: 17/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public abstract class Importer {
-
- private static final Logger logger = LoggerFactory.getLogger(Importer.class);
-
- public boolean readFile(Component ui, File file) {
-
- boolean result = false;
-
- try {
-
- SammoaUtil.updateBusyState(ui, true);
-
- String successMessage = onActionPerformed(file);
-
- SammoaUtil.updateBusyState(ui, false);
-
- JOptionPane.showMessageDialog(ui, successMessage);
-
- result = true;
-
- } catch (ImportRuntimeException e) {
- showError(ui, file, e);
-
- } catch (IOException e) {
- showError(ui, file, e);
- }
- return result;
- }
-
- protected void showError(Component ui, File file, Exception e) {
-
- if (logger.isInfoEnabled()) {
- logger.info("Import error from file '" + file.getAbsolutePath() + "'", e);
- }
- JOptionPane.showMessageDialog(
- ui, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE, UIManager.getIcon("error"));
- }
-
- protected abstract String onActionPerformed(File file) throws IOException;
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ShpImporter.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ShpImporter.java 2012-08-12 10:34:09 UTC (rev 413)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ShpImporter.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -1,124 +0,0 @@
-package fr.ulr.sammoa.ui.swing.util;
-/*
- * #%L
- * SAMMOA :: UI Swing
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.io.Files;
-import fr.ulr.sammoa.application.map.DbfImport;
-import org.apache.commons.io.FileUtils;
-import org.nuiton.util.csv.ImportModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
-import java.io.IOException;
-
-/**
- * Created: 25/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public abstract class ShpImporter<E> extends Importer {
-
- private static final Logger logger = LoggerFactory.getLogger(Importer.class);
-
- @Override
- protected String onActionPerformed(File file) throws IOException {
-
- File dbfFile;
- String fileName = file.getName();
- File sourceDirectory = file.getParentFile();
-
- String ext = Files.getFileExtension(fileName);
- int extIndex = fileName.lastIndexOf(ext);
- final String fileNameWithoutExt = fileName.substring(0, extIndex);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Source directory '" + sourceDirectory.getAbsolutePath() + "' and fileName '" + fileNameWithoutExt + "'");
- }
-
- if (!ext.equals("dbf")) {
-
- fileName = fileNameWithoutExt + "dbf";
-
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Use dbfFile %s for import", fileName));
- }
-
- dbfFile = new File(sourceDirectory, fileName);
-
- if (!dbfFile.exists()) {
- throw new FileNotFoundException("Can't found dbf file '" + dbfFile.getAbsolutePath() + "' for import");
- }
-
- } else {
- dbfFile = file;
- }
-
- DbfImport<E> importer = new DbfImport<E>(getModel(), dbfFile.toURI().toURL());
-
- String result = onActionPerformed(importer);
-
- String[] files = sourceDirectory.list(new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String fullName) {
- String extension = Files.getFileExtension(fullName);
- int extIndex = fullName.lastIndexOf(extension);
- String name = fullName.substring(0, extIndex);
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Read file : %s [ext = %s] -> check equals for %s",
- fullName,
- extension,
- name)
- );
- }
- return fileNameWithoutExt.equals(name);
- }
- });
-
- for (String name : files) {
- String extension = Files.getFileExtension(name);
- File sourceFile = new File(sourceDirectory, name);
- File targetFile = new File(getCopyDirectory(), getCopyFileName() + "." + extension);
- if (logger.isInfoEnabled()) {
- logger.info(String.format("Copy file '%1$s' to '%2$s'",
- sourceFile.getAbsolutePath(),
- targetFile.getAbsolutePath())
- );
- }
- FileUtils.copyFile(sourceFile, targetFile);
- }
- return result;
- }
-
- protected abstract String onActionPerformed(Iterable<E> elements);
-
- protected abstract ImportModel<E> getModel();
-
- protected abstract String getCopyFileName();
-
- protected abstract File getCopyDirectory();
-}
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java 2012-08-13 22:12:51 UTC (rev 414)
@@ -0,0 +1,91 @@
+package fr.ulr.sammoa.ui.swing.util;
+
+import fr.ulr.sammoa.application.io.CampaignStorage;
+import fr.ulr.sammoa.application.io.input.map.ShpImporter;
+import org.nuiton.util.csv.ImportRuntimeException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import java.awt.Component;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class UIImporter {
+
+ /** Logger. */
+ private static final Logger logger =
+ LoggerFactory.getLogger(UIImporter.class);
+
+ protected final Component ui;
+
+ public UIImporter(Component ui) {
+ this.ui = ui;
+ }
+
+ public boolean importShape(ShpImporter<?> importer, File file, CampaignStorage storage) {
+ boolean result = false;
+
+ try {
+
+ SammoaUtil.updateBusyState(ui, true);
+
+ String successMessage = importer.importShape(file, storage);
+
+ SammoaUtil.updateBusyState(ui, false);
+
+ JOptionPane.showMessageDialog(ui, successMessage);
+
+ result = true;
+
+ } catch (ImportRuntimeException e) {
+ showError(file, e);
+
+ } catch (IOException e) {
+ showError(file, e);
+ }
+ return result;
+ }
+
+ public boolean importCvs(CsvImporter importer, File file) {
+ boolean result = false;
+
+ try {
+
+ SammoaUtil.updateBusyState(ui, true);
+
+ String successMessage = importer.importCsvFile(file);
+
+ SammoaUtil.updateBusyState(ui, false);
+
+ JOptionPane.showMessageDialog(ui, successMessage);
+
+ result = true;
+
+ } catch (ImportRuntimeException e) {
+ showError(file, e);
+
+ } catch (IOException e) {
+ showError(file, e);
+ }
+ return result;
+ }
+
+ protected void showError(File file, Exception e) {
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Import error from file '" + file.getAbsolutePath() + "'", e);
+ }
+ JOptionPane.showMessageDialog(
+ ui, e.getMessage(), "Error",
+ JOptionPane.ERROR_MESSAGE, UIManager.getIcon("error"));
+ }
+
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/UIImporter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
12 Aug '12
Author: tchemit
Date: 2012-08-12 12:34:09 +0200 (Sun, 12 Aug 2012)
New Revision: 413
Url: http://forge.codelutin.com/repositories/revision/sammoa/413
Log:
refs #1201: Export format application (interface graphique done, mise en place du service, reste ?\195?\160 coder le service + les storages)
Added:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationCallbackMode.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationService.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIModel.java
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaScreen.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUIHandler.java
trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java 2012-08-11 09:17:30 UTC (rev 412)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -24,6 +24,7 @@
*/
package fr.ulr.sammoa.application;
+import fr.ulr.sammoa.application.io.exportApplication.ExportApplicationService;
import fr.ulr.sammoa.application.map.ExportMapService;
import fr.ulr.sammoa.persistence.SammoaPersistence;
@@ -87,6 +88,10 @@
return exportMapService;
}
+ public ExportApplicationService newExportApplicationService() {
+ return new ExportApplicationService(this);
+ }
+
public void open() {
persistence.open(
config.getApplicationConfig().getFlatOptions(),
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationCallbackMode.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationCallbackMode.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationCallbackMode.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -0,0 +1,51 @@
+package fr.ulr.sammoa.application.io.exportApplication;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * What to do after a application export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public enum ExportApplicationCallbackMode {
+ /**
+ * Do nothing.
+ * <p/>
+ * Says after this every thing stay in place.
+ */
+ NOTHING,
+ /**
+ * Remove flight data.
+ * <p/>
+ * Says after this referential are still there (Region, Campaign, Strate, Observer, Species).
+ */
+ REMOVE_FLIGHTS,
+ /**
+ * Remove campaign data.
+ * <p/>
+ * Says after this, there is no more stuff in db.
+ */
+ REMOVE_ALL
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationCallbackMode.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationModel.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationModel.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -0,0 +1,85 @@
+package fr.ulr.sammoa.application.io.exportApplication;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Flight;
+
+import java.io.File;
+import java.io.Serializable;
+
+/**
+ * Model of export application.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ExportApplicationModel implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static ExportApplicationModel newModel(File exportDirectory,
+ String exportFilename,
+ Campaign campaign,
+ Flight flight,
+ ExportApplicationCallbackMode callback) {
+ ExportApplicationModel result = new ExportApplicationModel();
+ result.exportDirectory = exportDirectory;
+ result.exportFilename = exportFilename;
+ result.campaign = campaign;
+ result.flight = flight;
+ result.callback = callback;
+ return result;
+ }
+
+ protected Campaign campaign;
+
+ protected Flight flight;
+
+ protected File exportDirectory;
+
+ protected String exportFilename;
+
+ protected ExportApplicationCallbackMode callback;
+
+ public File getExportDirectory() {
+ return exportDirectory;
+ }
+
+ public String getExportFilename() {
+ return exportFilename;
+ }
+
+ public Campaign getCampaign() {
+ return campaign;
+ }
+
+ public Flight getFlight() {
+ return flight;
+ }
+
+ public ExportApplicationCallbackMode getCallback() {
+ return callback;
+ }
+}
\ No newline at end of file
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationService.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationService.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -0,0 +1,111 @@
+package fr.ulr.sammoa.application.io.exportApplication;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.application.SammoaConfig;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.persistence.SammoaPersistence;
+import org.nuiton.util.TimeLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * To export application as a {@code sammoa} file.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ExportApplicationService {
+
+ /** Logger. */
+ private static final Logger logger =
+ LoggerFactory.getLogger(ExportApplicationService.class);
+
+
+ private static final TimeLog timeLog =
+ new TimeLog(ExportApplicationService.class);
+
+ protected final SammoaContext context;
+
+ protected final SammoaConfig config;
+
+ protected final SammoaPersistence persistence;
+
+ public ExportApplicationService(SammoaContext context) {
+ this.context = context;
+ this.persistence = context.getPersistence();
+ this.config = context.getConfig();
+ }
+
+ public void exportApplication(ExportApplicationModel model) {
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Start Application export to {} :: {}",
+ model.getExportDirectory(),
+ model.getExportFilename());
+ }
+
+ long startTime = TimeLog.getTime();
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ //BOUH!
+ }
+
+ //TODO
+
+ startTime = timeLog.log(startTime, "exportApplication",
+ "after Export execution");
+
+ switch (model.getCallback()) {
+
+ case NOTHING:
+ // nothing to do
+ break;
+ case REMOVE_FLIGHTS:
+ removeFlightData(model);
+ break;
+ case REMOVE_ALL:
+ removeAllData();
+ break;
+ }
+
+ timeLog.log(startTime, "exportApplication", "after Callback execution");
+
+ }
+
+ protected void removeFlightData(ExportApplicationModel model) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Will remove flight data for campaign {}",
+ model.getCampaign().getCode());
+ }
+ }
+
+ protected void removeAllData() {
+ if (logger.isInfoEnabled()) {
+ logger.info("Will remove all data from current db (create a new db...)");
+ }
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/exportApplication/ExportApplicationService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java 2012-08-11 09:17:30 UTC (rev 412)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -35,7 +35,7 @@
import java.util.List;
/**
- * Model of export map UI.
+ * Model of export map.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 0.5
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-11 09:17:30 UTC (rev 412)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -35,6 +35,7 @@
import fr.ulr.sammoa.ui.swing.flight.FlightUI;
import fr.ulr.sammoa.ui.swing.flight.FlightUIHandler;
import fr.ulr.sammoa.ui.swing.home.HomeUI;
+import fr.ulr.sammoa.ui.swing.io.exportApplication.ExportApplicationUI;
import fr.ulr.sammoa.ui.swing.io.exportMap.ExportMapUI;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
import jaxx.runtime.SwingUtil;
@@ -165,16 +166,17 @@
campaign.getCode(),
campaign.getRegion().getCode(),
flight.getFlightNumber()));
- ui.getBody().add(currentBody);
+ ui.getBody().add(currentBody, BorderLayout.CENTER);
break;
case CAMPAIGN:
currentBody = new CampaignUI(context);
context.getSwingSession().add(currentBody);
ui.getBody().setTitle(_("sammoa.title.campaign"));
- ui.getBody().add(currentBody);
+ ui.getBody().add(currentBody, BorderLayout.CENTER);
break;
+
case EXPORT_MAP:
currentBody = new ExportMapUI(context);
context.getSwingSession().add(currentBody);
@@ -182,6 +184,12 @@
ui.getBody().add(currentBody);
break;
+ case EXPORT_APPLICATION:
+ currentBody = new ExportApplicationUI(context);
+ context.getSwingSession().add(currentBody);
+ ui.getBody().setTitle(_("sammoa.title.exportApplication"));
+ ui.getBody().add(currentBody);
+ break;
}
ui.setScreen(screen);
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaScreen.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaScreen.java 2012-08-11 09:17:30 UTC (rev 412)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaScreen.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -36,5 +36,7 @@
FLIGHT,
+ EXPORT_APPLICATION,
+
EXPORT_MAP
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java 2012-08-11 09:17:30 UTC (rev 412)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -32,9 +32,7 @@
import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
import org.nuiton.widget.SwingSession;
-/**
- * @author sletellier <letellier(a)codelutin.com>
- */
+/** @author sletellier <letellier(a)codelutin.com> */
public class SammoaUIContext {
private static SammoaUIContext uiContext;
@@ -50,13 +48,11 @@
@Deprecated
protected FlightController flightController;
-
+
protected SwingSession swingSession;
-
+
protected SammoaDecoratorProvider decoratorProvider;
-
-// protected SammoaScreen screen;
-
+
protected String campaignId;
protected String flightId;
@@ -68,15 +64,15 @@
public static SammoaUIContext getUIContext() {
Preconditions.checkNotNull(uiContext,
- "You must create the context with the method " +
- "#newUIContext(SammoaContext) before retrieving it");
+ "You must create the context with the method " +
+ "#newUIContext(SammoaContext) before retrieving it");
return uiContext;
}
protected SammoaUIContext(SammoaContext context) {
this.context = context;
}
-
+
public SammoaContext getAppContext() {
return context;
}
@@ -108,7 +104,7 @@
public void setSwingSession(SwingSession swingSession) {
this.swingSession = swingSession;
}
-
+
public SammoaDecoratorProvider getDecoratorProvider() {
if (decoratorProvider == null) {
decoratorProvider = new SammoaDecoratorProvider();
@@ -132,19 +128,6 @@
return flightId;
}
-// public void setFlightId(String flightId) {
-// this.flightId = flightId;
-// }
-
-// public SammoaScreen getScreen() {
-// return screen;
-// }
-
-// public void setScreen(SammoaScreen screen) {
-// this.screen = screen;
-// mainUIHandler.setScreen(screen);
-// }
-
public void setFlightScreen(String flightId) {
this.flightId = flightId;
mainUIHandler.setScreen(SammoaScreen.FLIGHT);
@@ -164,6 +147,12 @@
mainUIHandler.setScreen(SammoaScreen.EXPORT_MAP);
}
+ public void setExportApplicationScreen(String campaignId, String flightId) {
+ this.campaignId = campaignId;
+ this.flightId = flightId;
+ mainUIHandler.setScreen(SammoaScreen.EXPORT_APPLICATION);
+ }
+
public void setStatusMessage(String message) {
mainUIHandler.getUI().getStatus().setStatus(message);
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.css 2012-08-11 09:17:30 UTC (rev 412)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.css 2012-08-12 10:34:09 UTC (rev 413)
@@ -65,9 +65,8 @@
text: "sammoa.action.exportMap";
}
-#exportButton {
- enabled:false;
- text: "sammoa.action.export";
+#exportApplicationButton {
+ text: "sammoa.action.exportApplication";
}
#onBoardButton {
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.jaxx 2012-08-11 09:17:30 UTC (rev 412)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.jaxx 2012-08-12 10:34:09 UTC (rev 413)
@@ -106,8 +106,8 @@
onActionPerformed='getHandler().showImport()'/>
<JButton id='exportMapButton'
onActionPerformed='getHandler().showExportMap()'/>
- <JButton id='exportButton'
- onActionPerformed='getHandler().showExport()'/>
+ <JButton id='exportApplicationButton'
+ onActionPerformed='getHandler().showExportApplication()'/>
<JButton id='onBoardButton'
onActionPerformed='getHandler().showOnBoard()'/>
<JButton id='validationButton'
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUIHandler.java 2012-08-11 09:17:30 UTC (rev 412)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUIHandler.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -51,7 +51,9 @@
*/
public class HomeUIHandler implements SammoaUIHandler {
- private static final Logger logger = LoggerFactory.getLogger(HomeUIHandler.class);
+ /** Logger. */
+ private static final Logger logger =
+ LoggerFactory.getLogger(HomeUIHandler.class);
// XXX-fdesbois-2012-07-23 : used to avoid set unexpected set null during
// selections, this is a strange behavior of setElements that clear with
@@ -59,7 +61,7 @@
protected boolean comboIsAdjusting;
protected SammoaUIContext context;
-
+
protected HomeUI ui;
public HomeUIHandler(SammoaUIContext context, HomeUI ui) {
@@ -74,7 +76,7 @@
protected FlightService getFlightService() {
return context.getAppContext().getFlightService();
}
-
+
protected ReferentialService getReferentialService() {
return context.getAppContext().getReferentialService();
}
@@ -103,7 +105,7 @@
} else {
Campaign selectedCampaign = null;
-
+
// Get campaign from context, then from config
String campaignId = context.getCampaignId();
if (campaignId == null) {
@@ -138,17 +140,13 @@
Campaign campaign = ui.getCampaignListModel().getSelectedItem();
if (logger.isDebugEnabled()) {
- logger.debug(String.format("Select the campaign %s",
- campaign.getCode())
- );
+ logger.debug("Select the campaign {}", campaign.getCode());
}
getModel().setCampaign(campaign);
if (logger.isDebugEnabled()) {
- logger.debug(String.format("Get flights from campaign %s",
- campaign.getCode())
- );
+ logger.debug("Get flights from campaign {}", campaign.getCode());
}
List<Flight> flights = getFlightService().getFlights(campaign);
@@ -161,26 +159,22 @@
if (logger.isDebugEnabled()) {
- String flightsString = "[" + Joiner.on(";").join(
+ String flightsString = "[" + Joiner.on(";").join(
Iterables.transform(flights, Flights.toFlightNumber())
) + "]";
- logger.debug(String.format("Init flights combobox = %s",
- flightsString)
- );
+ logger.debug("Init flights combobox = {}", flightsString);
}
ui.getFlightListModel().setElements(flights);
if (logger.isDebugEnabled()) {
- String systemsIdString = "[" + Joiner.on(";").join(
+ String systemsIdString = "[" + Joiner.on(";").join(
systemIds
) + "]";
- logger.debug(String.format("Init systemId combobox = %s",
- systemsIdString)
- );
+ logger.debug("Init systemId combobox = {}", systemsIdString);
}
ui.getSystemIdListModel().setElements(systemIds);
@@ -198,19 +192,17 @@
selectSystemId();
}
}
-
+
public void selectSystemId() {
if (!comboIsAdjusting) {
comboIsAdjusting = true;
-
+
String systemId = ui.getSystemIdListModel().getSelectedItem();
if (logger.isDebugEnabled()) {
- logger.debug(String.format("Select the systemId %s",
- systemId)
- );
+ logger.debug("Select the systemId {}", systemId);
}
getModel().setSystemId(systemId);
@@ -222,14 +214,12 @@
if (logger.isDebugEnabled()) {
- String flightString = "[" + Joiner.on(";").join(
+ String flightString = "[" + Joiner.on(";").join(
Iterables.transform(filteredFlights, Flights.toFlightNumber())
) + "]";
- logger.debug(String.format("Init flights combobox filtered by %s = %s",
- systemId,
- flightString)
- );
+ logger.debug("Init flights combobox filtered by {} = {}",
+ systemId, flightString);
}
ui.getFlightListModel().setElements(filteredFlights);
@@ -243,24 +233,24 @@
selectFlight();
}
}
-
+
public void selectFlight() {
if (!comboIsAdjusting) {
-
+
Flight flight = ui.getFlightListModel().getSelectedItem();
if (logger.isDebugEnabled()) {
- logger.debug(String.format("Select the flight %s",
- flight != null ? "" + flight.getFlightNumber() : "null")
+ logger.debug("Select the flight {}",
+ flight != null ? "" + flight.getFlightNumber() : "null"
);
}
getModel().setFlight(flight);
}
}
-
+
public void showSelectedCampaign() {
-
+
Campaign campaign = getModel().getCampaign();
context.setCampaignScreen(campaign.getTopiaId());
@@ -270,29 +260,34 @@
context.setCampaignScreen(null);
}
-
+
public void showImport() {
-
+
}
-
+
public void showExportMap() {
Campaign campaign = getModel().getCampaign();
- String campaignId = campaign==null?null:campaign.getTopiaId();
+ String campaignId = campaign == null ? null : campaign.getTopiaId();
context.setExportMapScreen(campaignId);
}
- public void showExport() {
+ public void showExportApplication() {
+ Campaign campaign = getModel().getCampaign();
+ String campaignId = campaign == null ? null : campaign.getTopiaId();
+ Flight flight = getModel().getFlight();
+ String flightId = flight == null ? null : flight.getTopiaId();
+ context.setExportApplicationScreen(campaignId, flightId);
}
-
+
public void showOnBoard() {
// Save the campaignId in the config for next loading
Campaign campaign = getModel().getCampaign();
getConfig().setCampaignId(campaign.getTopiaId());
getConfig().save();
-
+
Flight flight = getModel().getFlight();
// Create a new Flight for the selected Campaign
@@ -303,11 +298,11 @@
context.setFlightScreen(flight.getTopiaId());
}
-
+
public void showValidation() {
-
+
}
-
+
protected Flight getFirstFlight(List<Flight> flights) {
return flights.size() > 1 ? flights.get(1) : null;
}
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.css (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.css 2012-08-12 10:34:09 UTC (rev 413)
@@ -0,0 +1,91 @@
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+#campaignLabel {
+ text: "sammoa.label.campaign";
+}
+
+#campaignCombobox {
+ renderer: {new DecoratorProviderListCellRenderer(getHandler().getDecoratorProvider())};
+}
+
+#flightLabel {
+ text: "sammoa.label.flight";
+}
+
+#flightCombobox {
+ renderer: {new DecoratorProviderListCellRenderer(getHandler().getDecoratorProvider())};
+}
+
+#quitButton {
+ text:"sammoa.action.quitExportMaps";
+}
+
+#exportButton {
+ text:"sammoa.action.exportApplication";
+}
+
+#exportDirectoryFileChooseAction {
+ actionIcon:"fileChooser";
+}
+
+#exportDirectoryLbl {
+ text:"sammoa.label.exportApplicationDirectory";
+}
+
+#exportDirectory {
+ text:{model.getExportDirectory().getAbsolutePath()};
+}
+
+#exportFilenameLbl {
+ text:"sammoa.label.exportApplicationFilename";
+}
+
+#exportFilename {
+ text:{model.getExportFilename()};
+}
+
+#callbackLbl {
+ text:"sammoa.label.exportApplication.callbacks";
+}
+
+#callbackNothing {
+ text:"sammoa.label.exportApplication.callbackNothing";
+ selected:{ExportApplicationCallbackMode.NOTHING == model.getCallback()};
+ buttonGroup:"callbacks";
+ value:{ExportApplicationCallbackMode.NOTHING};
+}
+
+#callbackRemoveData {
+ text:"sammoa.label.exportApplication.callbackRemoveData";
+ buttonGroup:"callbacks";
+ selected:{ExportApplicationCallbackMode.REMOVE_FLIGHTS == model.getCallback()};
+ value:{ExportApplicationCallbackMode.REMOVE_FLIGHTS};
+}
+
+#callbackRemoveAll {
+ text:"sammoa.label.exportApplication.callbackRemoveAll";
+ buttonGroup:"callbacks";
+ selected:{ExportApplicationCallbackMode.REMOVE_ALL == model.getCallback()};
+ value:{ExportApplicationCallbackMode.REMOVE_ALL};
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.jaxx (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.jaxx 2012-08-12 10:34:09 UTC (rev 413)
@@ -0,0 +1,130 @@
+<!--
+ #%L
+ SAMMOA :: UI Swing
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 UMS 3462, Code Lutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JPanel id='exportApplicationUI' layout='{new BorderLayout()}'
+ implements='fr.ulr.sammoa.ui.swing.SammoaUI<ExportApplicationUIHandler>'>
+
+ <import>
+ fr.ulr.sammoa.persistence.Campaign
+ fr.ulr.sammoa.persistence.Flight
+ fr.ulr.sammoa.ui.swing.SammoaUIContext
+ fr.ulr.sammoa.application.io.exportApplication.ExportApplicationCallbackMode
+
+ jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer
+
+ java.awt.BorderLayout
+ java.awt.event.ItemEvent
+ java.io.File
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+ public ExportApplicationUI(SammoaUIContext context) {
+ ExportApplicationUIHandler handler =
+ new ExportApplicationUIHandler(context, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+ }
+
+ protected void $afterCompleteSetup() {
+ getHandler().afterInitUI();
+ }
+ ]]></script>
+
+ <ExportApplicationUIModel id='model'
+ initializer='getContextValue(ExportApplicationUIModel.class)'/>
+
+ <ExportApplicationUIHandler id='handler'
+ initializer='getContextValue(ExportApplicationUIHandler.class)'/>
+
+ <Table fill='both' constraints='BorderLayout.CENTER'>
+ <!-- Campaign filter -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='campaignLabel'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0' columns='2'>
+ <JComboBox id='campaignCombobox'
+ onItemStateChanged='if (ItemEvent.SELECTED == event.getStateChange()) { getModel().setSelectedCampaign((Campaign)event.getItem()); } else { getModel().setSelectedCampaign(null); }'/>
+ </cell>
+ </row>
+ <!-- Flight filter -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='flightLabel'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0' columns='2'>
+ <JComboBox id='flightCombobox'
+ onItemStateChanged='if (ItemEvent.SELECTED == event.getStateChange()) { getModel().setSelectedFlight((Flight)event.getItem()); } else { getModel().setSelectedFlight(null); }'/>
+ </cell>
+ </row>
+ <!-- export directory-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='exportDirectoryLbl'/>
+ </cell>
+ <cell weightx='1' fill="horizontal">
+ <JTextField id='exportDirectory'
+ onKeyReleased='getModel().setExportDirectory(new File(((JTextField)event.getSource()).getText()))'/>
+ </cell>
+ <cell anchor="east">
+ <JButton id="exportDirectoryFileChooseAction"
+ onActionPerformed="getHandler().chooseExportDirectory()"/>
+ </cell>
+ </row>
+ <row>
+ <cell anchor='west'>
+ <JLabel id='exportFilenameLbl'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0' columns='2'>
+ <JTextField id='exportFilename'
+ onKeyReleased='model.setExportFilename(((JTextField)event.getSource()).getText())'/>
+ </cell>
+ </row>
+ <!-- callBack -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='callbackLbl'/>
+ </cell>
+ <cell weightx='1' fill="horizontal" columns='2'>
+ <JPanel layout='{new GridLayout(0,1)}'>
+ <JRadioButton id='callbackNothing'/>
+ <JRadioButton id='callbackRemoveData'/>
+ <JRadioButton id='callbackRemoveAll'/>
+ </JPanel>
+ </cell>
+ </row>
+ <!--export actions-->
+ <row>
+ <cell columns='5' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='quitButton' onActionPerformed='getHandler().close()'/>
+ <JButton id='exportButton'
+ onActionPerformed='getHandler().exportApplication()'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</JPanel>
\ No newline at end of file
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIHandler.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIHandler.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -0,0 +1,270 @@
+package fr.ulr.sammoa.ui.swing.io.exportApplication;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.application.FlightService;
+import fr.ulr.sammoa.application.ReferentialService;
+import fr.ulr.sammoa.application.io.exportApplication.ExportApplicationCallbackMode;
+import fr.ulr.sammoa.application.io.exportApplication.ExportApplicationModel;
+import fr.ulr.sammoa.application.io.exportApplication.ExportApplicationService;
+import fr.ulr.sammoa.application.map.ExportMapService;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.ui.swing.SammoaDecoratorProvider;
+import fr.ulr.sammoa.ui.swing.SammoaUIContext;
+import fr.ulr.sammoa.ui.swing.SammoaUIHandler;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import jaxx.runtime.SwingUtil;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.decorator.Decorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Handelr of {@link ExportApplicationUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ExportApplicationUIHandler implements SammoaUIHandler {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ExportApplicationUIHandler.class);
+
+ private final ExportApplicationUI ui;
+
+ protected SammoaUIContext context;
+
+ public ExportApplicationUIHandler(SammoaUIContext context,
+ ExportApplicationUI ui) {
+ this.context = context;
+ this.ui = ui;
+ }
+
+ protected ReferentialService getReferentialService() {
+ return context.getAppContext().getReferentialService();
+ }
+
+ protected FlightService getFlightService() {
+ return context.getAppContext().getFlightService();
+ }
+
+ protected ExportMapService getExportMapService() {
+ return context.getAppContext().getExportMapService();
+ }
+
+ public SammoaDecoratorProvider getDecoratorProvider() {
+ return context.getDecoratorProvider();
+ }
+
+ @Override
+ public void beforeInitUI() {
+
+ //-- create model --//
+
+ ExportApplicationUIModel model = new ExportApplicationUIModel();
+
+ List<Campaign> campaigns = getReferentialService().getCampaigns();
+ //TODO-tchemit-2012-08-03 add an null campaign (for test purpose, should be removed...)
+ campaigns.add(0, null);
+ model.setCampaigns(campaigns);
+
+ String campaignId = context.getCampaignId();
+
+ if (campaignId != null) {
+
+ Campaign campaign = getReferentialService().getCampaign(campaignId);
+
+ // selected cam
+ model.setSelectedCampaign(campaign);
+ }
+
+ String flightId = context.getFlightId();
+
+ if (flightId != null) {
+
+ Flight flight = getFlightService().getFlight(flightId);
+
+ // selected cam
+ model.setSelectedFlight(flight);
+ }
+
+ //-- share model and handler in jaxx context --//
+ ui.setContextValue(this);
+ ui.setContextValue(model);
+
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ if (ExportApplicationUIModel.PROPERTY_SELECTED_CAMPAIGN.equals(evt.getPropertyName())) {
+ Campaign newValue = (Campaign) evt.getNewValue();
+ onSelectedCampaignChanged(newValue);
+ } else if (ExportApplicationUIModel.PROPERTY_FLIGHTS.equals(evt.getPropertyName())) {
+ Collection<Flight> newValue = (Collection<Flight>) evt.getNewValue();
+ onFlightsChanged(newValue);
+ } else if (ExportApplicationUIModel.PROPERTY_SELECTED_FLIGHT.equals(evt.getPropertyName())) {
+ Flight newValue = (Flight) evt.getNewValue();
+ onSelectedFlightChanged(newValue);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void afterInitUI() {
+ ExportApplicationUIModel model = getModel();
+
+ File currentDirectory = FileUtil.getCurrentDirectory();
+ String absolutePath = currentDirectory.getAbsolutePath();
+ if (absolutePath.endsWith(File.separator + ".")) {
+ currentDirectory = new File(absolutePath.substring(0, absolutePath.length() - 2));
+ }
+ if (logger.isInfoEnabled()) {
+ logger.info("Current directory to use: {}", currentDirectory);
+ }
+ model.setExportDirectory(currentDirectory);
+ model.setCallback(ExportApplicationCallbackMode.NOTHING);
+
+ SwingUtil.fillComboBox(ui.getCampaignCombobox(),
+ model.getCampaigns(),
+ model.getSelectedCampaign());
+
+ Flight selectedFlight = model.getSelectedFlight();
+
+ onSelectedCampaignChanged(model.getSelectedCampaign());
+ onSelectedFlightChanged(selectedFlight);
+ }
+
+ public void exportApplication() {
+
+ JFrame frame = ui.getParentContainer(JFrame.class);
+ SammoaUtil.updateBusyState(frame, true);
+
+ try {
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ @Override
+ public void run() {
+ ExportApplicationModel dataModel = getModel().toModel();
+
+ ExportApplicationService service =
+ context.getAppContext().newExportApplicationService();
+ service.exportApplication(dataModel);
+ }
+ }
+ );
+
+ } finally {
+ SammoaUtil.updateBusyState(frame, false);
+ }
+ }
+
+ protected void onSelectedCampaignChanged(Campaign newCampaign) {
+
+ // reset flights,...
+ if (logger.isInfoEnabled()) {
+ Decorator<Campaign> decorator = getDecoratorProvider().getDecoratorByType(Campaign.class);
+ logger.info("New selected campain: {}", decorator.toString(newCampaign));
+ }
+
+ ExportApplicationUIModel model = getModel();
+
+ List<Flight> flights;
+ String filename;
+ if (newCampaign == null) {
+ flights = Collections.emptyList();
+ filename = "";
+ } else {
+ flights = getFlightService().getFlights(newCampaign);
+ filename = String.format("campaign-%s.sammoa", newCampaign.getCode());
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("New flights: {}", flights.size());
+ logger.debug("New filename: {}", filename);
+ }
+ model.setFlights(flights);
+ model.setExportFilename(filename);
+ }
+
+ protected void onFlightsChanged(Collection<Flight> flights) {
+
+ ExportApplicationUIModel model = getModel();
+ Flight selectedFlight = model.getSelectedFlight();
+ if (flights.contains(selectedFlight)) {
+ model.setSelectedFlight(null);
+ }
+
+ SwingUtil.fillComboBox(ui.getFlightCombobox(),
+ flights,
+ selectedFlight);
+ }
+
+ protected void onSelectedFlightChanged(Flight newCampaign) {
+
+ // reset flights,...
+ if (logger.isInfoEnabled()) {
+ Decorator<Flight> decorator = getDecoratorProvider().getDecoratorByType(Flight.class);
+ logger.info("New selected flight: {}", decorator.toString(newCampaign));
+ }
+
+ ExportApplicationUIModel model = getModel();
+ }
+
+ public void close() {
+ context.setHomeScreen();
+ }
+
+ @Override
+ public void onCloseUI() {
+ }
+
+ public void chooseExportDirectory() {
+ File f = SammoaUtil.chooseDirectory(
+ ui,
+ _("sammoa.title.choose.export.directory"),
+ _("sammoa.action.choose.export.directory"),
+ ui.getModel().getExportDirectory()
+ );
+ ui.getModel().setExportDirectory(f);
+ }
+
+
+ public ExportApplicationUIModel getModel() {
+ return ui.getModel();
+ }
+
+
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIModel.java 2012-08-12 10:34:09 UTC (rev 413)
@@ -0,0 +1,161 @@
+package fr.ulr.sammoa.ui.swing.io.exportApplication;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ulr.sammoa.application.io.exportApplication.ExportApplicationCallbackMode;
+import fr.ulr.sammoa.application.io.exportApplication.ExportApplicationModel;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Flight;
+import org.jdesktop.beans.AbstractSerializableBean;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Model of export application UI.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.6
+ */
+public class ExportApplicationUIModel extends AbstractSerializableBean {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CAMPAIGNS = "campaigns";
+
+ public static final String PROPERTY_SELECTED_CAMPAIGN = "selectedCampaign";
+
+ public static final String PROPERTY_FLIGHTS = "flights";
+
+ public static final String PROPERTY_SELECTED_FLIGHT = "selectedFlight";
+
+ public static final String PROPERTY_EXPORT_DIRECTORY = "exportDirectory";
+
+ public static final String PROPERTY_EXPORT_FILENAME = "exportFilename";
+
+ public static final String PROPERTY_CALLBACK = "callback";
+
+ protected List<Campaign> campaigns;
+
+ protected Campaign selectedCampaign;
+
+ protected List<Flight> flights;
+
+ protected Flight selectedFlight;
+
+ protected File exportDirectory;
+
+ protected String exportFilename;
+
+ protected ExportApplicationCallbackMode callback;
+
+ public File getExportDirectory() {
+ return exportDirectory;
+ }
+
+ public void setExportDirectory(File exportDirectory) {
+ File oldValue = this.exportDirectory;
+ this.exportDirectory = exportDirectory;
+ firePropertyChange(PROPERTY_EXPORT_DIRECTORY, oldValue, exportDirectory);
+ }
+
+ public String getExportFilename() {
+ return exportFilename;
+ }
+
+ public void setExportFilename(String exportFilename) {
+ String oldValue = this.exportFilename;
+ this.exportFilename = exportFilename;
+ firePropertyChange(PROPERTY_EXPORT_FILENAME, oldValue, exportFilename);
+ }
+
+ public List<Campaign> getCampaigns() {
+ if (campaigns == null) {
+ campaigns = Lists.newArrayList();
+ }
+ return campaigns;
+ }
+
+ public void setCampaigns(List<Campaign> campaigns) {
+ List<Campaign> oldValue = this.campaigns;
+ this.campaigns = campaigns;
+ firePropertyChange(PROPERTY_CAMPAIGNS, oldValue, campaigns);
+ }
+
+ public Campaign getSelectedCampaign() {
+ return selectedCampaign;
+ }
+
+ public void setSelectedCampaign(Campaign selectedCampaign) {
+ Campaign oldValue = this.selectedCampaign;
+ this.selectedCampaign = selectedCampaign;
+ firePropertyChange(PROPERTY_SELECTED_CAMPAIGN, oldValue, selectedCampaign);
+ }
+
+ public List<Flight> getFlights() {
+ if (flights == null) {
+ flights = Lists.newArrayList();
+ }
+ return flights;
+ }
+
+ public void setFlights(List<Flight> flights) {
+ List<Flight> oldValue = this.flights;
+ this.flights = flights;
+ firePropertyChange(PROPERTY_FLIGHTS, oldValue, flights);
+ }
+
+ public Flight getSelectedFlight() {
+ return selectedFlight;
+ }
+
+ public void setSelectedFlight(Flight selectedFlight) {
+ Flight oldValue = this.selectedFlight;
+ this.selectedFlight = selectedFlight;
+ firePropertyChange(PROPERTY_SELECTED_FLIGHT, oldValue, selectedFlight);
+ }
+
+ public ExportApplicationCallbackMode getCallback() {
+ return callback;
+ }
+
+ public void setCallback(ExportApplicationCallbackMode callback) {
+ ExportApplicationCallbackMode oldValue = this.callback;
+ this.callback = callback;
+ firePropertyChange(PROPERTY_CALLBACK, oldValue, callback);
+ }
+
+ public ExportApplicationModel toModel() {
+
+ ExportApplicationModel result = ExportApplicationModel.newModel(
+ getExportDirectory(),
+ getExportFilename(),
+ getSelectedCampaign(),
+ getSelectedFlight(),
+ getCallback()
+ );
+ return result;
+ }
+}
\ No newline at end of file
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/ExportApplicationUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties
===================================================================
--- trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2012-08-11 09:17:30 UTC (rev 412)
+++ trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2012-08-12 10:34:09 UTC (rev 413)
@@ -19,6 +19,7 @@
sammoa.action.edit=Edit
sammoa.action.end.tip=END \: end effort and create a new TRANSIT route
sammoa.action.export=Export
+sammoa.action.exportApplication=Export
sammoa.action.exportEffortsMap=Export Efforts
sammoa.action.exportGeoPointsMap=Export GPS Points
sammoa.action.exportMap=Export Maps
@@ -95,7 +96,12 @@
sammoa.label.campaign.region=Region\:
sammoa.label.campaign.strate=Strates\:
sammoa.label.campaign.transect=Transects\:
-sammoa.label.exportDirectory=Export directory
+sammoa.label.exportApplication.callbackNothing=Do nothing
+sammoa.label.exportApplication.callbackRemoveAll=Remove all data
+sammoa.label.exportApplication.callbackRemoveData=Remove flights data
+sammoa.label.exportApplication.callbacks=Call back after export\:
+sammoa.label.exportApplicationDirectory=Export directory\:
+sammoa.label.exportApplicationFilename=Export filename\:
sammoa.label.exportEffortsFilename=Export filename (Efforts)
sammoa.label.exportGeoPointsFilename=Export filename (GeoPoints)
sammoa.label.exportMapDirectory=Export directory
@@ -218,6 +224,7 @@
sammoa.title.export.exportEfforts=Efforts Export
sammoa.title.export.exportGeoPoints=GPS Points ExportGPS
sammoa.title.export.exportObservations=Observations Export
+sammoa.title.exportApplication=Application Export
sammoa.title.exportshape=Export Maps
sammoa.title.flight=System %1$s - Campaign %2$s - Region %3$s - Flight n°%4$d
sammoa.title.home=Home
1
0
r412 - trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application
by tchemit@users.forge.codelutin.com 11 Aug '12
by tchemit@users.forge.codelutin.com 11 Aug '12
11 Aug '12
Author: tchemit
Date: 2012-08-11 11:17:30 +0200 (Sat, 11 Aug 2012)
New Revision: 412
Url: http://forge.codelutin.com/repositories/revision/sammoa/412
Log:
remove sun class in import
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-08-11 08:56:03 UTC (rev 411)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-08-11 09:17:30 UTC (rev 412)
@@ -62,7 +62,6 @@
import org.nuiton.util.TimeLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import sun.misc.URLClassPath;
import java.util.Collection;
import java.util.Collections;
1
0
r411 - trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap
by tchemit@users.forge.codelutin.com 11 Aug '12
by tchemit@users.forge.codelutin.com 11 Aug '12
11 Aug '12
Author: tchemit
Date: 2012-08-11 10:56:03 +0200 (Sat, 11 Aug 2012)
New Revision: 411
Url: http://forge.codelutin.com/repositories/revision/sammoa/411
Log:
clean code
Modified:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java 2012-08-11 08:54:13 UTC (rev 410)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java 2012-08-11 08:56:03 UTC (rev 411)
@@ -148,7 +148,7 @@
@Override
public void afterInitUI() {
- ExportMapUIModel model = ui.getModel();
+ ExportMapUIModel model = getModel();
model.setExportEffortsFilename("Efforts");
model.setExportObservationsFilename("Observations");
@@ -205,7 +205,7 @@
logger.info("New selected campain: {}", decorator.toString(newCampaign));
}
- ExportMapUIModel model = ui.getModel();
+ ExportMapUIModel model = getModel();
model.setSelectedStrates(Collections.<Strate>emptyList());
model.setSelectedSpecies(Collections.<Species>emptyList());
@@ -257,8 +257,6 @@
public void exportEfforts() {
- ExportMapUIModel model = ui.getModel();
-
Action startAction = new AbstractAction(
_("sammoa.action.startExport"),
SwingUtil.createActionIcon("accept")) {
@@ -293,6 +291,7 @@
}
};
+ ExportMapUIModel model = getModel();
displayExportLauncher(_("sammoa.title.export.exportEfforts"),
model.getExportEffortsFilename(),
model,
@@ -301,8 +300,6 @@
public void exportObservations() {
- ExportMapUIModel model = ui.getModel();
-
Action startAction = new AbstractAction(
_("sammoa.action.startExport"),
SwingUtil.createActionIcon("accept")) {
@@ -337,6 +334,8 @@
}
}
};
+
+ ExportMapUIModel model = getModel();
displayExportLauncher(_("sammoa.title.export.exportObservations"),
model.getExportObservationsFilename(),
model,
@@ -345,8 +344,8 @@
public void exportGeoPoints() {
- ExportMapUIModel model = ui.getModel();
+
Action startAction = new AbstractAction(
_("sammoa.action.startExport"),
SwingUtil.createActionIcon("accept")) {
@@ -363,7 +362,7 @@
SammoaUtil.updateBusyState(fileChooserUI, true);
try {
- ExportMapUIModel model = ui.getModel();
+ ExportMapUIModel model = getModel();
// persist the file name
model.setExportGeoPointsFilename(model.getExportFilename());
@@ -382,6 +381,8 @@
}
}
};
+
+ ExportMapUIModel model = getModel();
displayExportLauncher(_("sammoa.title.export.exportGeoPoints"),
model.getExportGeoPointsFilename(),
model,
1
0
r410 - trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing
by tchemit@users.forge.codelutin.com 11 Aug '12
by tchemit@users.forge.codelutin.com 11 Aug '12
11 Aug '12
Author: tchemit
Date: 2012-08-11 10:54:13 +0200 (Sat, 11 Aug 2012)
New Revision: 410
Url: http://forge.codelutin.com/repositories/revision/sammoa/410
Log:
fixes #1401: Les titres des panneaux ne s'affichent pas
Modified:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.jaxx
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.jaxx 2012-08-11 08:04:54 UTC (rev 409)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.jaxx 2012-08-11 08:54:13 UTC (rev 410)
@@ -79,7 +79,6 @@
</JMenuBar>
<JXTitledPanel id='body'
- layout='{new BorderLayout()}'
constraints='BorderLayout.CENTER'
decorator='boxed'/>
1
0
r409 - in trunk: . sammoa-application sammoa-persistence sammoa-ui-swing
by maven-release@users.forge.codelutin.com 11 Aug '12
by maven-release@users.forge.codelutin.com 11 Aug '12
11 Aug '12
Author: maven-release
Date: 2012-08-11 10:04:54 +0200 (Sat, 11 Aug 2012)
New Revision: 409
Url: http://forge.codelutin.com/repositories/revision/sammoa/409
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
trunk/sammoa-application/pom.xml
trunk/sammoa-persistence/pom.xml
trunk/sammoa-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-08-11 08:04:47 UTC (rev 408)
+++ trunk/pom.xml 2012-08-11 08:04:54 UTC (rev 409)
@@ -15,7 +15,7 @@
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.5</version>
+ <version>0.6-SNAPSHOT</version>
<modules>
<module>sammoa-persistence</module>
@@ -81,12 +81,12 @@
<!-- ************************************************************* -->
<scm>
- <url>http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.5</url>
+ <url>http://svn.forge.codelutin.com/svn/sammoa/trunk</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.5
+ scm:svn:http://svn.forge.codelutin.com/svn/sammoa/trunk
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.5
+ scm:svn:http://svn.forge.codelutin.com/svn/sammoa/trunk
</developerConnection>
</scm>
Modified: trunk/sammoa-application/pom.xml
===================================================================
--- trunk/sammoa-application/pom.xml 2012-08-11 08:04:47 UTC (rev 408)
+++ trunk/sammoa-application/pom.xml 2012-08-11 08:04:54 UTC (rev 409)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.5</version>
+ <version>0.6-SNAPSHOT</version>
</parent>
<artifactId>sammoa-application</artifactId>
Modified: trunk/sammoa-persistence/pom.xml
===================================================================
--- trunk/sammoa-persistence/pom.xml 2012-08-11 08:04:47 UTC (rev 408)
+++ trunk/sammoa-persistence/pom.xml 2012-08-11 08:04:54 UTC (rev 409)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.5</version>
+ <version>0.6-SNAPSHOT</version>
</parent>
<artifactId>sammoa-persistence</artifactId>
Modified: trunk/sammoa-ui-swing/pom.xml
===================================================================
--- trunk/sammoa-ui-swing/pom.xml 2012-08-11 08:04:47 UTC (rev 408)
+++ trunk/sammoa-ui-swing/pom.xml 2012-08-11 08:04:54 UTC (rev 409)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.5</version>
+ <version>0.6-SNAPSHOT</version>
</parent>
<artifactId>sammoa-ui-swing</artifactId>
1
0
Author: maven-release
Date: 2012-08-11 10:04:47 +0200 (Sat, 11 Aug 2012)
New Revision: 408
Url: http://forge.codelutin.com/repositories/revision/sammoa/408
Log:
[maven-release-plugin] copy for tag sammoa-0.5
Added:
tags/sammoa-0.5/
1
0
r407 - in trunk: . sammoa-application sammoa-persistence sammoa-ui-swing
by maven-release@users.forge.codelutin.com 11 Aug '12
by maven-release@users.forge.codelutin.com 11 Aug '12
11 Aug '12
Author: maven-release
Date: 2012-08-11 10:04:38 +0200 (Sat, 11 Aug 2012)
New Revision: 407
Url: http://forge.codelutin.com/repositories/revision/sammoa/407
Log:
[maven-release-plugin] prepare release sammoa-0.5
Modified:
trunk/pom.xml
trunk/sammoa-application/pom.xml
trunk/sammoa-persistence/pom.xml
trunk/sammoa-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-08-10 21:25:07 UTC (rev 406)
+++ trunk/pom.xml 2012-08-11 08:04:38 UTC (rev 407)
@@ -15,7 +15,7 @@
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.5-SNAPSHOT</version>
+ <version>0.5</version>
<modules>
<module>sammoa-persistence</module>
@@ -81,12 +81,12 @@
<!-- ************************************************************* -->
<scm>
- <url>http://svn.forge.codelutin.com/svn/sammoa/trunk</url>
+ <url>http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.5</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/sammoa/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.5
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/sammoa/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.5
</developerConnection>
</scm>
Modified: trunk/sammoa-application/pom.xml
===================================================================
--- trunk/sammoa-application/pom.xml 2012-08-10 21:25:07 UTC (rev 406)
+++ trunk/sammoa-application/pom.xml 2012-08-11 08:04:38 UTC (rev 407)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.5-SNAPSHOT</version>
+ <version>0.5</version>
</parent>
<artifactId>sammoa-application</artifactId>
Modified: trunk/sammoa-persistence/pom.xml
===================================================================
--- trunk/sammoa-persistence/pom.xml 2012-08-10 21:25:07 UTC (rev 406)
+++ trunk/sammoa-persistence/pom.xml 2012-08-11 08:04:38 UTC (rev 407)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.5-SNAPSHOT</version>
+ <version>0.5</version>
</parent>
<artifactId>sammoa-persistence</artifactId>
Modified: trunk/sammoa-ui-swing/pom.xml
===================================================================
--- trunk/sammoa-ui-swing/pom.xml 2012-08-10 21:25:07 UTC (rev 406)
+++ trunk/sammoa-ui-swing/pom.xml 2012-08-11 08:04:38 UTC (rev 407)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.5-SNAPSHOT</version>
+ <version>0.5</version>
</parent>
<artifactId>sammoa-ui-swing</artifactId>
1
0
Author: tchemit
Date: 2012-08-10 23:25:07 +0200 (Fri, 10 Aug 2012)
New Revision: 406
Url: http://forge.codelutin.com/repositories/revision/sammoa/406
Log:
fix doc
Modified:
trunk/src/site/rst/import-export.rst
Modified: trunk/src/site/rst/import-export.rst
===================================================================
--- trunk/src/site/rst/import-export.rst 2012-08-10 16:42:27 UTC (rev 405)
+++ trunk/src/site/rst/import-export.rst 2012-08-10 21:25:07 UTC (rev 406)
@@ -42,7 +42,7 @@
A noter que ce sont des rôles de station de travail, une seule même machine physique peut avoir tous ces différents rôles.
-.. image:: ulr-sammoa-echange-data.png
+.. image:: ulr-sammoa-echange-data.svg
TODO explications supplémentaires sur les étapes
1
0