Echobase-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
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
December 2013
- 2 participants
- 34 discussions
16 Dec '13
Author: tchemit
Date: 2013-12-16 23:34:04 +0100 (Mon, 16 Dec 2013)
New Revision: 917
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/917
Log:
fix on sql migration
Modified:
trunk/echobase-services/src/main/resources/postgis-structure.sql
Modified: trunk/echobase-services/src/main/resources/postgis-structure.sql
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 22:25:41 UTC (rev 916)
+++ trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 22:34:04 UTC (rev 917)
@@ -1216,5 +1216,6 @@
-- Compute all data
SELECT echobase_compute_all_cell_spatial_data();
SELECT echobase_compute_all_operation_spatial_data();
-SELECT count(*) from echobase_cell_spatial;
-SELECT count(*) from echobase_operation_spatial;
+
+-- Add an update query as the migration service will execute this script and can't finish with a query instruction (see PreparedStatement#executeUpdate)
+UPDATE echobase_operation_spatial SET lastUpdateDate = now() WHERE operationid IS NULL;
\ No newline at end of file
1
0
16 Dec '13
Author: tchemit
Date: 2013-12-16 23:25:41 +0100 (Mon, 16 Dec 2013)
New Revision: 916
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/916
Log:
remove migration 2.5 + try some fix on sql migration
Modified:
trunk/echobase-services/src/main/resources/postgis-structure.sql
Modified: trunk/echobase-services/src/main/resources/postgis-structure.sql
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 22:20:26 UTC (rev 915)
+++ trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 22:25:41 UTC (rev 916)
@@ -1206,14 +1206,15 @@
RETURNS VOID AS $$
DECLARE cell_id VARCHAR;
BEGIN
+ EXECUTE echobase_compute_all_cell_spatial_data();
EXECUTE echobase_compute_all_operation_spatial_data();
- EXECUTE echobase_compute_all_cell_spatial_data();
END
$$
LANGUAGE plpgsql;
-- Compute all data
--- SELECT echobase_compute_all_cell_spatial_data();
--- SELECT echobase_compute_all_operation_spatial_data();
-SELECT echobase_compute_all_spatial_data();
+SELECT echobase_compute_all_cell_spatial_data();
+SELECT echobase_compute_all_operation_spatial_data();
+SELECT count(*) from echobase_cell_spatial;
+SELECT count(*) from echobase_operation_spatial;
1
0
r915 - in trunk/echobase-domain/src/main: java/fr/ifremer/echobase/persistence/migration/workingDb resources/META-INF/services
by tchemit@users.forge.codelutin.com 16 Dec '13
by tchemit@users.forge.codelutin.com 16 Dec '13
16 Dec '13
Author: tchemit
Date: 2013-12-16 23:20:26 +0100 (Mon, 16 Dec 2013)
New Revision: 915
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/915
Log:
remove migration 2.5 + try some fix on sql migration
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java
trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java 2013-12-16 22:12:34 UTC (rev 914)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java 2013-12-16 22:20:26 UTC (rev 915)
@@ -64,7 +64,7 @@
if (spatialAware) {
- // repass postgis scripts (http://forge.codelutin.com/issues/3672)
+ // repass postgis scripts (http://forge.codelutin.com/issues/4018)
updatePostgis(queries);
}
}
@@ -72,9 +72,5 @@
protected void updatePostgis(List<String> queries) {
queries.add(EchoBaseIOUtil.loadScript(EchoBasePersistenceContext.POSTGIS_STRUCTURE_SQL));
queries.add(EchoBaseIOUtil.loadScript(EchoBasePersistenceContext.POSTGIS_VIEW_SQL));
-
- // fix http://forge.codelutin.com/issues/3973
- queries.add("update echobase_operation_spatial set operationname = (select op.id from operation op where op.topiaid = operationid);");
-
}
}
Modified: trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion
===================================================================
--- trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2013-12-16 22:12:34 UTC (rev 914)
+++ trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2013-12-16 22:20:26 UTC (rev 915)
@@ -1,3 +1,2 @@
fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_2
-fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_5
fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_5_1
\ No newline at end of file
1
0
r914 - in trunk: echobase-domain/src/main/java/fr/ifremer/echobase/entities/data echobase-domain/src/main/java/fr/ifremer/echobase/entities/references echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb echobase-services/src/main/resources echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery echobase-ui/src/main/webapp/images
by tchemit@users.forge.codelutin.com 16 Dec '13
by tchemit@users.forge.codelutin.com 16 Dec '13
16 Dec '13
Author: tchemit
Date: 2013-12-16 23:12:34 +0100 (Mon, 16 Dec 2013)
New Revision: 914
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/914
Log:
prepare release + try some fix on sql migration
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CategoryDAOImpl.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellTypeImpl.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataMetadataImpl.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypeImpl.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java
trunk/echobase-services/src/main/resources/postgis-structure.sql
trunk/echobase-services/src/main/resources/postgis-view.sql
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/AbstractEditExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/CloneExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ConfirmDeleteExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DeleteExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/SaveExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ShowExportQuery.java
trunk/echobase-ui/src/main/webapp/images/menu3.jpg
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CategoryDAOImpl.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CategoryDAOImpl.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CategoryDAOImpl.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: Domain
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CategoryDAOImpl.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.entities.data;
+/*
+ * #%L
+ * EchoBase :: Domain
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2013 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import fr.ifremer.echobase.entities.references.DataMetadata;
import java.util.List;
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellTypeImpl.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellTypeImpl.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellTypeImpl.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: Domain
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellTypeImpl.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataMetadataImpl.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataMetadataImpl.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataMetadataImpl.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: Domain
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataMetadataImpl.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypeImpl.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypeImpl.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypeImpl.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: Domain
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypeImpl.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: Domain
* $Id$
- * $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-domain/src/main/… $
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
@@ -132,7 +132,7 @@
private void addPostgisView(List<String> queries) {
// add cell data view
- queries.add("DROP VIEW IF EXISTS echobase_cell_spatial_data;");
+ queries.add("DROP VIEW IF EXISTS echobase_cell_spatial_data CASCADE;");
queries.add("CREATE OR REPLACE VIEW echobase_cell_spatial_data AS\n" +
"SELECT\n" +
" s.*,\n" +
@@ -149,7 +149,7 @@
" d.datametadata = m.topiaid;");
// add cell result view
- queries.add("DROP VIEW IF EXISTS echobase_cell_spatial_result;");
+ queries.add("DROP VIEW IF EXISTS echobase_cell_spatial_result CASCADE;");
queries.add("CREATE OR REPLACE VIEW echobase_cell_spatial_result AS\n" +
"SELECT\n" +
" s.*,\n" +
@@ -166,7 +166,7 @@
" r.datametadata = m.topiaid;");
// add operation data view
- queries.add("DROP VIEW IF EXISTS TotalSampleEngrEnc;");
+ queries.add("DROP VIEW IF EXISTS TotalSampleEngrEnc CASCADE;");
queries.add("CREATE OR REPLACE VIEW TotalSampleEngrEnc AS\n" +
"\n" +
"SELECT \n" +
@@ -196,7 +196,7 @@
" sampletype.name = 'Total' AND\n" +
" species.baracoudacode='ENGR-ENC';\n");
- queries.add("DROP VIEW IF EXISTS TotalSampleSardPil;");
+ queries.add("DROP VIEW IF EXISTS TotalSampleSardPil CASCADE;");
queries.add("CREATE OR REPLACE VIEW TotalSampleSardPil AS\n" +
"\n" +
"SELECT \n" +
@@ -226,7 +226,7 @@
" sampletype.name = 'Total' AND\n" +
" species.baracoudacode='SARD-PIL';");
- queries.add("DROP VIEW IF EXISTS TotalSampleTracTru;");
+ queries.add("DROP VIEW IF EXISTS TotalSampleTracTru CASCADE;");
queries.add("CREATE OR REPLACE VIEW TotalSampleTracTru AS\n" +
"\n" +
"SELECT \n" +
@@ -256,7 +256,7 @@
" sampletype.name = 'Total' AND\n" +
" species.baracoudacode='TRAC-TRU';");
- queries.add("DROP VIEW IF EXISTS TotalSampleSpraSpr;");
+ queries.add("DROP VIEW IF EXISTS TotalSampleSpraSpr CASCADE;");
queries.add("CREATE OR REPLACE VIEW TotalSampleSpraSpr AS\n" +
"\n" +
"SELECT \n" +
@@ -286,7 +286,7 @@
" sampletype.name = 'Total' AND\n" +
" species.baracoudacode='SPRA-SPR';");
- queries.add("DROP VIEW IF EXISTS TotalSampleScomSco;");
+ queries.add("DROP VIEW IF EXISTS TotalSampleScomSco CASCADE;");
queries.add("CREATE OR REPLACE VIEW TotalSampleScomSco AS\n" +
"\n" +
"SELECT \n" +
@@ -316,7 +316,7 @@
" sampletype.name = 'Total' AND\n" +
" species.baracoudacode='SCOM-SCO';");
- queries.add("DROP VIEW IF EXISTS TotalSampleMicrPou;");
+ queries.add("DROP VIEW IF EXISTS TotalSampleMicrPou CASCADE;");
queries.add("CREATE OR REPLACE VIEW TotalSampleMicrPou AS\n" +
"\n" +
"SELECT \n" +
@@ -346,7 +346,7 @@
" sampletype.name = 'Total' AND\n" +
" species.baracoudacode='MICR-POU';");
- queries.add("DROP VIEW IF EXISTS TotalCatchSpOpWide;");
+ queries.add("DROP VIEW IF EXISTS TotalCatchSpOpWide CASCADE;");
queries.add("CREATE OR REPLACE VIEW TotalCatchSpOpWide AS\n" +
"\n" +
"SELECT\n" +
@@ -362,7 +362,7 @@
" echobase_operation_spatial.operationid\n" +
"From echobase_operation_spatial;");
- queries.add("DROP VIEW IF EXISTS cellmapview;");
+ queries.add("DROP VIEW IF EXISTS cellmapview CASCADE;");
queries.add("CREATE OR REPLACE VIEW cellmapview AS \n" +
" SELECT echobase_cell_spatial.voyagename, echobase_cell_spatial.coordinate, echobase_cell_spatial.shape, datametadata.name, result.resultvalue, species.baracoudacode, echobase_cell_spatial.cellname, result.topiaid AS resultid\n" +
" FROM echobase_cell_spatial, result, datametadata, category, speciescategory, species\n" +
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.persistence.migration.workingDb;
+/*
+ * #%L
+ * EchoBase :: Domain
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2013 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import fr.ifremer.echobase.entities.EchoBasePersistenceContext;
import fr.ifremer.echobase.entities.TopiaEchoBasePersistenceContext;
import fr.ifremer.echobase.io.EchoBaseIOUtil;
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-services/src/main/resources/postgis-structure.sql
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 22:12:34 UTC (rev 914)
@@ -1214,5 +1214,6 @@
-- Compute all data
-SELECT echobase_compute_all_cell_spatial_data();
-SELECT echobase_compute_all_operation_spatial_data();
\ No newline at end of file
+-- SELECT echobase_compute_all_cell_spatial_data();
+-- SELECT echobase_compute_all_operation_spatial_data();
+SELECT echobase_compute_all_spatial_data();
Modified: trunk/echobase-services/src/main/resources/postgis-view.sql
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-view.sql 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-services/src/main/resources/postgis-view.sql 2013-12-16 22:12:34 UTC (rev 914)
@@ -1,3 +1,25 @@
+---
+-- #%L
+-- EchoBase :: Services
+-- $Id$
+-- $HeadURL$
+-- %%
+-- Copyright (C) 2011 - 2013 Ifremer, Codelutin
+-- %%
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU Affero 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 Affero General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+-- #L%
+---
-- ajout de vues liés aux tables spatiales
DROP VIEW IF EXISTS echobase_cell_spatial_result;
Property changes on: trunk/echobase-services/src/main/resources/postgis-view.sql
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/AbstractEditExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/AbstractEditExportQuery.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/AbstractEditExportQuery.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: UI
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/AbstractEditExportQuery.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/CloneExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/CloneExportQuery.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/CloneExportQuery.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: UI
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/CloneExportQuery.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ConfirmDeleteExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ConfirmDeleteExportQuery.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ConfirmDeleteExportQuery.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: UI
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ConfirmDeleteExportQuery.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DeleteExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DeleteExportQuery.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DeleteExportQuery.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: UI
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DeleteExportQuery.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/SaveExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/SaveExportQuery.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/SaveExportQuery.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -4,7 +4,7 @@
* #%L
* EchoBase :: UI
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2013 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/SaveExportQuery.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ShowExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ShowExportQuery.java 2013-12-16 21:43:46 UTC (rev 913)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ShowExportQuery.java 2013-12-16 22:12:34 UTC (rev 914)
@@ -3,7 +3,7 @@
* EchoBase :: UI
*
* $Id$
- * $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-ui/src/main/java… $
+ * $HeadURL$
* %%
* Copyright (C) 2011 Ifremer, Codelutin
* %%
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ShowExportQuery.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/echobase-ui/src/main/webapp/images/menu3.jpg
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
16 Dec '13
Author: tchemit
Date: 2013-12-16 22:43:46 +0100 (Mon, 16 Dec 2013)
New Revision: 913
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/913
Log:
refs #4018: Migration de base en erreur (add cascade on each drop command to avoid migration failures
Modified:
trunk/echobase-services/src/main/resources/postgis-structure.sql
trunk/echobase-services/src/main/resources/postgis-view.sql
Modified: trunk/echobase-services/src/main/resources/postgis-structure.sql
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 21:21:32 UTC (rev 912)
+++ trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 21:43:46 UTC (rev 913)
@@ -22,69 +22,63 @@
---
CREATE EXTENSION IF NOT EXISTS postgis;
-DROP VIEW IF EXISTS TotalCatchSpOpWide;
-DROP VIEW IF EXISTS echobase_spatial_cell_result;
-DROP VIEW IF EXISTS echobase_spatial_cell_data;
-DROP VIEW IF EXISTS TotalSampleEngrEnc;
-DROP VIEW IF EXISTS TotalSampleSardPil;
-DROP VIEW IF EXISTS TotalSampleTracTru;
-DROP VIEW IF EXISTS TotalSampleSpraSpr;
-DROP VIEW IF EXISTS TotalSampleScomSco;
-DROP VIEW IF EXISTS TotalSampleMicrPou;
-DROP VIEW IF EXISTS cellmapview;
+DROP VIEW IF EXISTS TotalCatchSpOpWide CASCADE;
+DROP VIEW IF EXISTS echobase_cell_spatial_data CASCADE;
+DROP VIEW IF EXISTS echobase_cell_spatial_result CASCADE;
+DROP VIEW IF EXISTS TotalSampleEngrEnc CASCADE;
+DROP VIEW IF EXISTS TotalSampleSardPil CASCADE;
+DROP VIEW IF EXISTS TotalSampleTracTru CASCADE;
+DROP VIEW IF EXISTS TotalSampleSpraSpr CASCADE;
+DROP VIEW IF EXISTS TotalSampleScomSco CASCADE;
+DROP VIEW IF EXISTS TotalSampleMicrPou CASCADE;
+DROP VIEW IF EXISTS cellmapview CASCADE;
-DROP TABLE IF EXISTS echobase_cell_spatial;
-DROP INDEX IF EXISTS echobase_cell_spatial_coordinate_gix;
-DROP INDEX IF EXISTS echobase_cell_spatial_coordinate3D_gix;
-DROP INDEX IF EXISTS echobase_cell_spatial_shape_gix;
-DROP INDEX IF EXISTS echobase_cell_spatial_voyageid_idx;
-DROP TABLE IF EXISTS echobase_cell_spatial_temp;
+DROP INDEX IF EXISTS echobase_cell_spatial_coordinate_gix CASCADE;
+DROP INDEX IF EXISTS echobase_cell_spatial_coordinate3D_gix CASCADE;
+DROP INDEX IF EXISTS echobase_cell_spatial_shape_gix CASCADE;
+DROP INDEX IF EXISTS echobase_cell_spatial_voyageid_idx CASCADE;
+DROP TABLE IF EXISTS echobase_cell_spatial CASCADE;
+DROP TABLE IF EXISTS echobase_cell_spatial_temp CASCADE;
-DROP TRIGGER IF EXISTS echobase_fill_cell_spatial_work_table_trigger ON data;
-DROP FUNCTION IF EXISTS echobase_fill_spatial_temp_table();
-DROP FUNCTION IF EXISTS echobase_fill_cell_spatial_temp_table();
-
-DROP TRIGGER IF EXISTS echobase_delete_cell ON cell;
-DROP FUNCTION IF EXISTS echobase_delete_cell();
-DROP FUNCTION IF EXISTS echobase_compute_all_cell_spatial_data();
-DROP FUNCTION IF EXISTS echobase_fill_cell_spatial_table();
-DROP FUNCTION IF EXISTS echobase_fill_cell_spatial_row(cell_id VARCHAR);
-DROP FUNCTION IF EXISTS echobase_fill_esdu_cell_spatial_table(cell_id VARCHAR);
-DROP FUNCTION IF EXISTS echobase_fill_elementary_cell_spatial_table(cell_id VARCHAR);
-DROP FUNCTION IF EXISTS echobase_fill_region_cell_spatial_table(cell_id VARCHAR);
-DROP FUNCTION IF EXISTS echobase_fill_map_cell_spatial_table(cell_id VARCHAR);
+DROP TRIGGER IF EXISTS echobase_fill_cell_spatial_work_table_trigger ON data CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_spatial_temp_table() CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_cell_spatial_temp_table() CASCADE;
+DROP TRIGGER IF EXISTS echobase_delete_cell ON cell CASCADE;
+DROP FUNCTION IF EXISTS echobase_delete_cell() CASCADE;
+DROP FUNCTION IF EXISTS echobase_compute_all_cell_spatial_data() CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_cell_spatial_table() CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_cell_spatial_row(cell_id VARCHAR) CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_esdu_cell_spatial_table(cell_id VARCHAR) CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_elementary_cell_spatial_table(cell_id VARCHAR) CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_region_cell_spatial_table(cell_id VARCHAR) CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_map_cell_spatial_table(cell_id VARCHAR) CASCADE;
DROP FUNCTION IF EXISTS echobase_create_echobase_cell_spatial_row(
cell_id VARCHAR,
coordinateText VARCHAR,
coordinate3dText VARCHAR,
-shapeText VARCHAR);
+shapeText VARCHAR) CASCADE;
+DROP FUNCTION IF EXISTS echobase_get_cell_type(cell_id VARCHAR) CASCADE;
-DROP FUNCTION IF EXISTS echobase_get_cell_type(cell_id VARCHAR);
-
-
-DROP TABLE IF EXISTS echobase_operation_spatial;
DROP INDEX IF EXISTS echobase_operation_spatial_coordinate_gix;
DROP INDEX IF EXISTS echobase_operation_spatial_voyageid_idx;
-DROP TABLE IF EXISTS echobase_operation_spatial_temp;
-DROP TRIGGER IF EXISTS echobase_fill_operation_spatial_work_table_trigger ON operation;
-DROP FUNCTION IF EXISTS echobase_fill_operation_spatial_temp_table();
-DROP TRIGGER IF EXISTS echobase_delete_operation ON operation;
-DROP FUNCTION IF EXISTS echobase_delete_operation();
-
-DROP FUNCTION IF EXISTS echobase_compute_all_operation_spatial_data();
-DROP FUNCTION IF EXISTS echobase_fill_operation_spatial_table();
-DROP FUNCTION IF EXISTS echobase_fill_operation_spatial_row(operation_id VARCHAR);
-
+DROP TABLE IF EXISTS echobase_operation_spatial CASCADE ;
+DROP TABLE IF EXISTS echobase_operation_spatial_temp CASCADE;
+DROP TRIGGER IF EXISTS echobase_fill_operation_spatial_work_table_trigger ON operation CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_operation_spatial_temp_table() CASCADE;
+DROP TRIGGER IF EXISTS echobase_delete_operation ON operation CASCADE;
+DROP FUNCTION IF EXISTS echobase_delete_operation() CASCADE;
+DROP FUNCTION IF EXISTS echobase_compute_all_operation_spatial_data() CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_operation_spatial_table() CASCADE;
+DROP FUNCTION IF EXISTS echobase_fill_operation_spatial_row(operation_id VARCHAR) CASCADE;
DROP FUNCTION IF EXISTS echobase_create_echobase_operation_spatial_row(
operation_id VARCHAR,
-coordinateText VARCHAR);
+coordinateText VARCHAR) CASCADE;
+DROP FUNCTION IF EXISTS echobase_latitudetext_to_dd(latitude VARCHAR) CASCADE;
+DROP FUNCTION IF EXISTS echobase_longitudetext_to_dd(longitude VARCHAR) CASCADE;
+DROP FUNCTION IF EXISTS echobase_dms2dd(D INTEGER, M INTEGER, S INTEGER, HEMI CHARACTER VARYING(1)) CASCADE;
+DROP FUNCTION IF EXISTS echobase_compute_all_spatial_data() CASCADE;
-DROP FUNCTION IF EXISTS echobase_latitudetext_to_dd(latitude VARCHAR);
-DROP FUNCTION IF EXISTS echobase_longitudetext_to_dd(longitude VARCHAR);
-DROP FUNCTION IF EXISTS echobase_dms2dd(D INTEGER, M INTEGER, S INTEGER, HEMI CHARACTER VARYING(1));
-DROP FUNCTION IF EXISTS echobase_compute_all_spatial_data();
-
--------------------------------------------------------------------------------
-- Table spatial pour les cellules ---------------------------------------------
--------------------------------------------------------------------------------
Modified: trunk/echobase-services/src/main/resources/postgis-view.sql
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-view.sql 2013-12-16 21:21:32 UTC (rev 912)
+++ trunk/echobase-services/src/main/resources/postgis-view.sql 2013-12-16 21:43:46 UTC (rev 913)
@@ -1,7 +1,7 @@
-- ajout de vues liés aux tables spatiales
-DROP VIEW IF EXISTS echobase_spatial_cell_result;
-CREATE OR REPLACE VIEW echobase_spatial_cell_result AS
+DROP VIEW IF EXISTS echobase_cell_spatial_result;
+CREATE OR REPLACE VIEW echobase_cell_spatial_result AS
SELECT
s.*,
m.topiaId AS metaDataId,
@@ -16,8 +16,8 @@
s.cellid = r.cell AND
r.datametadata = m.topiaid;
-DROP VIEW IF EXISTS echobase_spatial_cell_data;
-CREATE OR REPLACE VIEW echobase_spatial_cell_data AS
+DROP VIEW IF EXISTS echobase_cell_spatial_data;
+CREATE OR REPLACE VIEW echobase_cell_spatial_data AS
SELECT
s.*,
m.topiaId AS metaDataId,
1
0
r912 - trunk/echobase-domain/src/main/resources/META-INF/services
by tchemit@users.forge.codelutin.com 16 Dec '13
by tchemit@users.forge.codelutin.com 16 Dec '13
16 Dec '13
Author: tchemit
Date: 2013-12-16 22:21:32 +0100 (Mon, 16 Dec 2013)
New Revision: 912
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/912
Log:
register migration
Modified:
trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion
Modified: trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion
===================================================================
--- trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2013-12-16 18:37:32 UTC (rev 911)
+++ trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2013-12-16 21:21:32 UTC (rev 912)
@@ -1,2 +1,3 @@
fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_2
-fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_5
\ No newline at end of file
+fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_5
+fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_5_1
\ No newline at end of file
1
0
Author: tchemit
Date: 2013-12-16 19:37:32 +0100 (Mon, 16 Dec 2013)
New Revision: 911
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/911
Log:
fix site
Modified:
trunk/src/site/site_en.xml
trunk/src/site/site_fr.xml
Modified: trunk/src/site/site_en.xml
===================================================================
--- trunk/src/site/site_en.xml 2013-12-16 18:22:36 UTC (rev 910)
+++ trunk/src/site/site_en.xml 2013-12-16 18:37:32 UTC (rev 911)
@@ -54,34 +54,34 @@
<poweredBy>
<logo href="http://maven.apache.org" name="Maven"
- img="http://maven-site.chorem.org/public/images/logos/maven-feather.png"/>
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/maven-feather…"/>
<logo href="http://struts.apache.org/" name="Struts 2"
- img="http://maven-site.chorem.org/public/images/logos/struts2-logo.png"/>
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/struts2-logo.…"/>
<logo href="http://docutils.sourceforge.net/rst.html"
name="ReStructuredText"
- img="http://maven-site.chorem.org/public/images/logos/restructuredtext-logo.png"/>
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/restructuredt…"/>
- <logo href="http://maven-site.nuiton.org/jrst" name="JRst"
- img="http://maven-site.chorem.org/public/images/logos/jrst-logo.png"/>
+ <logo href="http://maven-site.forge.codelutin.com/jrst" name="JRst"
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/jrst-logo.png"/>
- <logo href="http://maven-site.nuiton.org/topia" name="ToPIA"
- img="http://maven-site.chorem.org/public/images/logos/topia-logo.png"/>
+ <logo href="http://maven-site.forge.codelutin.com/topia" name="ToPIA"
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/topia-logo.png"/>
<logo href="http://argouml.tigris.org/" name="ArgoUML"
- img="http://maven-site.chorem.org/public/images/logos/argouml-logo.png"/>
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/argouml-logo.…"/>
</poweredBy>
<body>
<head>
<script type="text/javascript"
- src="http://maven-site.chorem.org/public/js/mavenpom-site.js">
+ src="http://maven-site.forge.codelutin.com/common/0.2/js/mavenpom-site.js">
</script>
<link rel="stylesheet" type="text/css"
- href="http://maven-site.chorem.org/public/css/mavenpom-site.css"/>
+ href="http://maven-site.forge.codelutin.com/common/0.2/css/mavenpom-site.css"/>
</head>
<links>
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2013-12-16 18:22:36 UTC (rev 910)
+++ trunk/src/site/site_fr.xml 2013-12-16 18:37:32 UTC (rev 911)
@@ -54,23 +54,23 @@
<poweredBy>
<logo href="http://maven.apache.org" name="Maven"
- img="http://maven-site.chorem.org/common/dev/images/logos/maven-feather.png"/>
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/maven-feather…"/>
<logo href="http://struts.apache.org/" name="Struts 2"
- img="http://maven-site.chorem.org/common/dev/images/logos/struts2-logo.png"/>
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/struts2-logo.…"/>
<logo href="http://docutils.sourceforge.net/rst.html"
name="ReStructuredText"
- img="http://maven-site.chorem.org/common/dev/images/logos/restructuredtext-logo.…"/>
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/restructuredt…"/>
- <logo href="http://maven-site.nuiton.org/jrst" name="JRst"
- img="http://maven-site.chorem.org/common/dev/images/logos/jrst-logo.png"/>
+ <logo href="http://maven-site.forge.codelutin.com/jrst" name="JRst"
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/jrst-logo.png"/>
- <logo href="http://maven-site.nuiton.org/topia" name="ToPIA"
- img="http://maven-site.chorem.org/common/dev/images/logos/topia-logo.png"/>
+ <logo href="http://maven-site.forge.codelutin.com/topia" name="ToPIA"
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/topia-logo.png"/>
<logo href="http://argouml.tigris.org/" name="ArgoUML"
- img="http://maven-site.chorem.org/common/dev/images/logos/argouml-logo.png"/>
+ img="http://maven-site.forge.codelutin.com/common/0.2/images/logos/argouml-logo.…"/>
</poweredBy>
@@ -78,11 +78,11 @@
<head>
<script type="text/javascript"
- src="http://maven-site.chorem.org/common/dev/js/mavenpom-site.js">
+ src="http://maven-site.forge.codelutin.com/common/0.2/js/mavenpom-site.js">
</script>
<link rel="stylesheet" type="text/css"
- href="http://maven-site.chorem.org/common/dev/css/mavenpom-site.css"/>
+ href="http://maven-site.forge.codelutin.com/common/0.2/css/mavenpom-site.css"/>
</head>
<links>
@@ -149,8 +149,7 @@
piwikId='${project.piwikId}'
locale='fr'
scmwebeditor_vmFiles=",install.html,usage.html,"
- scmwebeditor_skipDefaultFiles="true"
- scmwebeditor_skipFiles=",model.html,">
+ scmwebeditor_skipDefaultFiles="true">
</div>
</footer>
</body>
1
0
16 Dec '13
Author: tchemit
Date: 2013-12-16 19:22:36 +0100 (Mon, 16 Dec 2013)
New Revision: 910
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/910
Log:
prepare release 2.5.1 + prepare topia 3.0 migration
Added:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java
Removed:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/
Modified:
trunk/echobase-domain/pom.xml
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/csv/CellValueParser.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/csv/EchoBaseCsvUtil.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBasePersistenceContext.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/TopiaEchoBasePersistenceContext.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CellDAOImpl.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/io/EchoBaseIOUtil.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallBackForVersion.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java
trunk/echobase-domain/src/main/xmi/echobase.properties
trunk/echobase-services/pom.xml
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/DbEditorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/DecoratorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/WorkingDbPersistenceService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportdb/ExportDbService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportdb/ExportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportquery/ExportQueryService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CatchesImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonAllImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonVoyageImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/OperationImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsEsduCellImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsMapFishCellImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsMapOtherCellImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsRegionCellImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsVoyageImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportModel.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/ImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/AbstractImportDbStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/FreeImportDbStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/ReferentialImportDbStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/RemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/AbstractRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/AcousticRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CatchesRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonAllRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonTransectRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonTransitRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonVoyageRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/LegacyVoyageRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/OperationRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultEsduRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultMapFishRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultMapOtherRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultRegionRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultVoyageRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/workingDb/WorkingDbConfigurationService.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FixCellsIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/exportdb/ExportDbServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java
trunk/echobase-ui/pom.xml
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/AbstractEditExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/CloneExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ConfirmDeleteExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DeleteExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/SaveExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetDataProcessingsForVoyage.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetVesselsForVoyage.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/AbstractGetVoyage.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/AddSpatial.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/GetImportLogDetail.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/GetVoyage.java
trunk/pom.xml
trunk/src/site/site_en.xml
trunk/src/site/site_fr.xml
Modified: trunk/echobase-domain/pom.xml
===================================================================
--- trunk/echobase-domain/pom.xml 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/pom.xml 2013-12-16 18:22:36 UTC (rev 910)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>echobase</artifactId>
- <version>2.6-SNAPSHOT</version>
+ <version>2.5.1-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.echobase</groupId>
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/csv/CellValueParser.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/csv/CellValueParser.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/csv/CellValueParser.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -27,9 +27,9 @@
import fr.ifremer.echobase.entities.data.CellDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import org.apache.commons.collections.CollectionUtils;
-import org.nuiton.topia.TopiaException;
import org.nuiton.csv.ImportRuntimeException;
import org.nuiton.csv.ValueParser;
+import org.nuiton.topia.TopiaException;
import java.text.ParseException;
import java.util.List;
@@ -43,7 +43,7 @@
private CellDAO cellDAO;
- protected CellValueParser(Voyage voyage, CellDAO cellDAO) {
+ public CellValueParser(Voyage voyage, CellDAO cellDAO) {
this.voyage = voyage;
this.esduCellMap = Maps.newTreeMap();
this.cellDAO = cellDAO;
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/csv/EchoBaseCsvUtil.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/csv/EchoBaseCsvUtil.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/csv/EchoBaseCsvUtil.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -119,10 +119,6 @@
// avoid instanciation on helper class
}
- public static ValueParser<Cell> newCellValueParser(Voyage voyage, CellDAO cellDAO) {
- return new CellValueParser(voyage, cellDAO);
- }
-
public static ValueParser<Cell> newCellValueParser(Voyage voyage,
Map<String, Cell> esduCellMap) {
return new CellValueParser(voyage, esduCellMap);
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBasePersistenceContext.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBasePersistenceContext.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBasePersistenceContext.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -36,5 +36,9 @@
*/
public interface EchoBasePersistenceContext extends TopiaTransaction, TopiaPersistenceContext, TopiaSqlSupport {
+ String POSTGIS_STRUCTURE_SQL = "/postgis-structure.sql";
+
+ String POSTGIS_VIEW_SQL = "/postgis-view.sql";
+
TopiaContext getContext();
}
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/TopiaEchoBasePersistenceContext.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/TopiaEchoBasePersistenceContext.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/TopiaEchoBasePersistenceContext.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -23,9 +23,13 @@
* #L%
*/
+import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import fr.ifremer.echobase.EchoBaseTechnicalException;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -37,11 +41,17 @@
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaIdFactory;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.List;
import java.util.Properties;
public class TopiaEchoBasePersistenceContext extends AbstractTopiaEchoBasePersistenceContext {
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(TopiaEchoBasePersistenceContext.class);
+
public TopiaEchoBasePersistenceContext(TopiaContext context) {
super(context);
}
@@ -146,6 +156,35 @@
getTopiaSqlSupport().executeSQL(sqlScript);
}
+ protected void executeInClassPathSQL(String scriptPath) {
+
+ // get sql file
+ InputStream inputStream = getClass().getResourceAsStream(scriptPath);
+
+ Preconditions.checkNotNull(
+ inputStream,
+ "Could not find resource in classpath " + scriptPath);
+
+ String sql;
+ try {
+ sql = IOUtils.toString(inputStream, Charsets.UTF_8);
+ } catch (IOException e) {
+ throw new EchoBaseTechnicalException(
+ "Could not load sql file " + scriptPath, e);
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Will execute sql file " + scriptPath);
+ }
+
+ try {
+ executeSQL(sql);
+ } catch (Exception e) {
+ throw new EchoBaseTechnicalException(
+ "Could not execute sql file " + scriptPath, e);
+ }
+ }
+
public final <E extends TopiaEntity> E getEntityById(Class<E> entityType, String id) {
Preconditions.checkNotNull(entityType);
Preconditions.checkArgument(StringUtils.isNotEmpty(id));
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CellDAOImpl.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CellDAOImpl.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CellDAOImpl.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -24,8 +24,10 @@
*/
import com.google.common.collect.Lists;
+import fr.ifremer.echobase.csv.CellValueParser;
import fr.ifremer.echobase.entities.references.CellType;
import fr.ifremer.echobase.entities.spatial.CellPoint;
+import org.nuiton.csv.ValueParser;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaSQLQuery;
@@ -77,6 +79,10 @@
return cellIds;
}
+ public ValueParser<Cell> newCellValueParser(Voyage voyage) {
+ return new CellValueParser(voyage, (CellDAO)this);
+ }
+
protected TopiaSQLQuery<CellPoint> newLatLongSqlQuery(final String voyageId, final String cellTypeId) {
return new TopiaSQLQuery<CellPoint>() {
@Override
Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java (rev 0)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -0,0 +1,32 @@
+package fr.ifremer.echobase.entities.data;
+
+import fr.ifremer.echobase.entities.references.DataMetadata;
+
+import java.util.List;
+import java.util.Set;
+
+public class ResultDAOImpl<E extends Result> extends ResultDAOAbstract<E> {
+
+ public List<E> findAllWithCategoryCellAndDataMetadata(Set<String> cellIds,
+ DataMetadata requiredDataMetadata,
+ List<String> categoryIds) {
+
+ String query = createSimpleQuery(null) + " WHERE cell.id IN :cell AND dataMetadata = :dataMetadata";
+ return findAllByQuery(
+ query + " AND category.id IN :category",
+ Result.PROPERTY_CELL, cellIds,
+ Result.PROPERTY_DATA_METADATA, requiredDataMetadata,
+ Result.PROPERTY_CATEGORY, categoryIds);
+ }
+
+ public List<E> findAllWithNoCategoryCellAndDataMetadata(Set<String> cellIds,
+ DataMetadata requiredDataMetadata) {
+
+ String query = createSimpleQuery(null) + " WHERE cell.id IN :cell AND dataMetadata = :dataMetadata";
+ return findAllByQuery(
+ query + " AND category IS NULL",
+ Result.PROPERTY_CELL, cellIds,
+ Result.PROPERTY_DATA_METADATA, requiredDataMetadata);
+ }
+
+} //ResultDAOImpl<E extends Result>
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/ResultDAOImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/io/EchoBaseIOUtil.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/io/EchoBaseIOUtil.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/io/EchoBaseIOUtil.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -221,6 +221,26 @@
inputFile.setFile(target);
}
+ public static String loadScript(String scriptPath) {
+
+ // get file
+ InputStream inputStream =
+ EchoBaseIOUtil.class.getResourceAsStream(scriptPath);
+
+ Preconditions.checkNotNull(
+ inputStream,
+ "Could not find resource in classpath " + scriptPath);
+
+ String sql;
+ try {
+ sql = IOUtils.toString(inputStream, Charsets.UTF_8);
+ } catch (IOException e) {
+ throw new EchoBaseTechnicalException(
+ "Could not load file " + scriptPath, e);
+ }
+ return sql;
+ }
+
protected EchoBaseIOUtil() {
// no instance of helper class
}
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallBackForVersion.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallBackForVersion.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/internalDb/MigrationCallBackForVersion.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -23,9 +23,6 @@
* #L%
*/
-import org.hibernate.dialect.Dialect;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
/**
@@ -36,9 +33,9 @@
*/
public abstract class MigrationCallBackForVersion extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
- protected Dialect getDialect(TopiaContext tx) throws TopiaNotFoundException {
- Dialect dialect =
- Dialect.getDialect(tx.getHibernateConfiguration().getProperties());
- return dialect;
- }
+// protected Dialect getDialect(TopiaContext tx) throws TopiaNotFoundException {
+// Dialect dialect =
+// Dialect.getDialect(tx.getHibernateConfiguration().getProperties());
+// return dialect;
+// }
}
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -23,9 +23,6 @@
* #L%
*/
-import org.hibernate.dialect.Dialect;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG;
/**
@@ -36,9 +33,9 @@
*/
public abstract class MigrationCallBackForVersion extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
- protected Dialect getDialect(TopiaContext tx) throws TopiaNotFoundException {
- Dialect dialect =
- Dialect.getDialect(tx.getHibernateConfiguration().getProperties());
- return dialect;
- }
+// protected Dialect getDialect(TopiaContext tx) throws TopiaNotFoundException {
+// Dialect dialect =
+// Dialect.getDialect(tx.getHibernateConfiguration().getProperties());
+// return dialect;
+// }
}
Modified: trunk/echobase-domain/src/main/xmi/echobase.properties
===================================================================
--- trunk/echobase-domain/src/main/xmi/echobase.properties 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-domain/src/main/xmi/echobase.properties 2013-12-16 18:22:36 UTC (rev 910)
@@ -25,7 +25,7 @@
model.tagValue.generateOperatorForDAOHelper=true
model.tagValue.generateStandaloneEnumForDAOHelper=true
model.tagValue.constantPrefix=PROPERTY_
-model.tagValue.version=2.5
+model.tagValue.version=2.5.1
model.tagValue.noPCS=true
model.tagValue.doNotGenerateBooleanGetMethods=true
model.tagValue.indexForeignKeys=true
Modified: trunk/echobase-services/pom.xml
===================================================================
--- trunk/echobase-services/pom.xml 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/pom.xml 2013-12-16 18:22:36 UTC (rev 910)
@@ -6,7 +6,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>echobase</artifactId>
- <version>2.6-SNAPSHOT</version>
+ <version>2.5.1-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.echobase</groupId>
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -24,13 +24,11 @@
import fr.ifremer.echobase.config.EchoBaseConfiguration;
import fr.ifremer.echobase.entities.TopiaEchoBaseInternalPersistenceContext;
-import fr.ifremer.echobase.entities.TopiaEchoBasePersistenceContext;
import fr.ifremer.echobase.persistence.EchoBaseDbMeta;
import fr.ifremer.echobase.services.service.DbEditorService;
import fr.ifremer.echobase.services.service.DecoratorService;
import fr.ifremer.echobase.services.service.InternalDbPersistenceService;
import fr.ifremer.echobase.services.service.UserService;
-import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import fr.ifremer.echobase.services.service.exportdb.ExportDbService;
import fr.ifremer.echobase.services.service.exportdb.ExportService;
import fr.ifremer.echobase.services.service.exportquery.ExportQueryService;
@@ -58,9 +56,9 @@
return serviceContext.newService(serviceClass);
}
- public TopiaEchoBasePersistenceContext getEchoBasePersistenceContext() {
- return serviceContext.getEchoBasePersistenceContext();
- }
+// public TopiaEchoBasePersistenceContext getEchoBasePersistenceContext() {
+// return serviceContext.getEchoBasePersistenceContext();
+// }
public TopiaEchoBaseInternalPersistenceContext getEchoBaseInternalPersistenceContext() {
return serviceContext.getEchoBaseInternalPersistenceContext();
@@ -102,9 +100,9 @@
return newService(InternalDbPersistenceService.class);
}
- public WorkingDbPersistenceService getWorkingDbPersistenceService() {
- return newService(WorkingDbPersistenceService.class);
- }
+// public WorkingDbPersistenceService getWorkingDbPersistenceService() {
+// return newService(WorkingDbPersistenceService.class);
+// }
public UserService getUserService() {
return newService(UserService.class);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/DbEditorService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/DbEditorService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -31,7 +31,8 @@
import fr.ifremer.echobase.csv.EchoBaseCsvUtil;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EntityModificationLog;
+import fr.ifremer.echobase.entities.TopiaEchoBasePersistenceContext;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -77,10 +78,21 @@
/** Logger. */
private static final Log log = LogFactory.getLog(DbEditorService.class);
+ private WorkingDbPersistenceService persistenceService;
+
+ private TopiaEchoBasePersistenceContext persistenceContext;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+ persistenceContext = serviceContext.getEchoBasePersistenceContext();
+ }
+
public <E extends TopiaEntity> List<E> getForeignData(Class<E> entityType) {
Preconditions.checkNotNull(entityType);
try {
- TopiaDAO<E> dao = getEchoBasePersistenceContext().getDAO(entityType);
+ TopiaDAO<E> dao = persistenceContext.getDAO(entityType);
List<E> result = dao.findAll();
return result;
@@ -119,7 +131,7 @@
EchoBaseEntityEnum entityEnum = tableMeta.getSource();
try {
- TopiaDAO<E> dao = (TopiaDAO<E>) getEchoBasePersistenceContext().getDAO(entityEnum.getContract());
+ TopiaDAO<E> dao = (TopiaDAO<E>) persistenceContext.getDAO(entityEnum.getContract());
List<Object> paramsList = Lists.newArrayList();
@@ -156,7 +168,7 @@
String extraWhereQuery) {
try {
- TopiaDAO<E> dao = (TopiaDAO<E>) getEchoBasePersistenceContext().getDAO(tableMeta.getSource().getContract());
+ TopiaDAO<E> dao = (TopiaDAO<E>) persistenceContext.getDAO(tableMeta.getSource().getContract());
String hql = "FROM " +
dao.getTopiaEntityEnum().getImplementationFQN() + " e";
@@ -175,7 +187,7 @@
EchoBaseEntityEnum entityEnum = tableMeta.getSource();
try {
- TopiaDAO<?> dao = getEchoBasePersistenceContext().getDAO(entityEnum.getContract());
+ TopiaDAO<?> dao = persistenceContext.getDAO(entityEnum.getContract());
TopiaEntity entity = dao.findByTopiaId(topiaId);
ExportModel<TopiaEntity> model = buildForLoad(tableMeta, TopiaEntity.PROPERTY_TOPIA_ID, true);
return loadRow(entity, model);
@@ -184,20 +196,6 @@
}
}
- public <E extends TopiaEntity> void decorateForeignKey(
- Map data,
- Class<E> propertyType,
- String property,
- String decoratorContext) {
-
- DecoratorService decoratorService =
- serviceContext.newService(DecoratorService.class);
-
- E mission = getEchoBasePersistenceContext().getEntityById(propertyType, (String) data.get(property));
- String voyageToString = decoratorService.decorate(getLocale(), mission, decoratorContext);
- data.put(property + "_lbl", voyageToString);
- }
-
public void saveEntity(TableMeta<EchoBaseEntityEnum> meta,
Map<String, String> properties,
EchoBaseUser user) {
@@ -230,7 +228,7 @@
user,
false
);
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.commit();
}
public boolean saveEntity(TableMeta<EchoBaseEntityEnum> tableMeta,
@@ -244,7 +242,7 @@
String id = entity.getTopiaId();
try {
- TopiaDAO<?> dao = getEchoBasePersistenceContext().getDAO(tableMeta.getSource().getContract());
+ TopiaDAO<?> dao = persistenceContext.getDAO(tableMeta.getSource().getContract());
TopiaEntity entityToSave;
@@ -489,12 +487,12 @@
}
}
- getEchoBasePersistenceContext().getEntityModificationLogDAO().create(
- EntityModificationLog.PROPERTY_ENTITY_TYPE, tableMeta.getSource().name(),
- EntityModificationLog.PROPERTY_ENTITY_ID, topiaId,
- EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
- EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
- EntityModificationLog.PROPERTY_MODIFICATION_TEXT, buffer.toString()
+ persistenceService.createEntityModificationLog(
+ tableMeta.getSource().name(),
+ topiaId,
+ user.getEmail(),
+ newDate(),
+ buffer.toString()
);
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/DecoratorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/DecoratorService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/DecoratorService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -165,6 +165,17 @@
return result;
}
+ public <E extends TopiaEntity> void decorateForeignKey(
+ Map data,
+ String property,
+ E entity,
+ String decoratorContext) {
+
+ String voyageToString = decorate(getLocale(), entity, decoratorContext);
+ data.put(property + "_lbl", voyageToString);
+ }
+
+
protected <O> Decorator<O> getDecoratorAndSort(Locale locale,
String context,
List<O> list) {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/WorkingDbPersistenceService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/WorkingDbPersistenceService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/WorkingDbPersistenceService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -23,69 +23,64 @@
* #L%
*/
-import fr.ifremer.echobase.entities.EntityModificationLogDAO;
-import fr.ifremer.echobase.entities.ImportLogDAO;
-import fr.ifremer.echobase.entities.data.CategoryDAO;
-import fr.ifremer.echobase.entities.data.CellDAO;
-import fr.ifremer.echobase.entities.data.DataAcquisitionDAO;
-import fr.ifremer.echobase.entities.data.DataDAO;
-import fr.ifremer.echobase.entities.data.DataProcessingDAO;
-import fr.ifremer.echobase.entities.data.EchotypeDAO;
-import fr.ifremer.echobase.entities.data.GearMetadataValueDAO;
-import fr.ifremer.echobase.entities.data.LengthAgeKeyDAO;
-import fr.ifremer.echobase.entities.data.LengthWeightKeyDAO;
-import fr.ifremer.echobase.entities.data.OperationDAO;
-import fr.ifremer.echobase.entities.data.OperationMetadataValueDAO;
-import fr.ifremer.echobase.entities.data.ResultDAO;
-import fr.ifremer.echobase.entities.data.SampleDAO;
-import fr.ifremer.echobase.entities.data.SampleDataDAO;
-import fr.ifremer.echobase.entities.data.TransectDAO;
-import fr.ifremer.echobase.entities.data.TransitDAO;
-import fr.ifremer.echobase.entities.data.VoyageDAO;
-import fr.ifremer.echobase.entities.references.AcousticInstrumentDAO;
-import fr.ifremer.echobase.entities.references.AgeCategoryDAO;
-import fr.ifremer.echobase.entities.references.AreaOfOperationDAO;
-import fr.ifremer.echobase.entities.references.CalibrationDAO;
-import fr.ifremer.echobase.entities.references.CategoryMeaningDAO;
-import fr.ifremer.echobase.entities.references.CategoryRefDAO;
-import fr.ifremer.echobase.entities.references.CategoryTypeDAO;
-import fr.ifremer.echobase.entities.references.CellMethodDAO;
-import fr.ifremer.echobase.entities.references.CellTypeDAO;
-import fr.ifremer.echobase.entities.references.DataMetadataDAO;
-import fr.ifremer.echobase.entities.references.DataProtocolDAO;
-import fr.ifremer.echobase.entities.references.DataQualityDAO;
-import fr.ifremer.echobase.entities.references.DataTypeDAO;
-import fr.ifremer.echobase.entities.references.DepthStratumDAO;
-import fr.ifremer.echobase.entities.references.EchotypeCategoryDAO;
-import fr.ifremer.echobase.entities.references.GearCharacteristicDAO;
-import fr.ifremer.echobase.entities.references.GearCharacteristicValueDAO;
-import fr.ifremer.echobase.entities.references.GearDAO;
-import fr.ifremer.echobase.entities.references.GearMetadataDAO;
-import fr.ifremer.echobase.entities.references.ImpacteDAO;
-import fr.ifremer.echobase.entities.references.MeasureTypeDAO;
-import fr.ifremer.echobase.entities.references.MeasurementMetadataDAO;
-import fr.ifremer.echobase.entities.references.MissionDAO;
-import fr.ifremer.echobase.entities.references.OperationEventDAO;
-import fr.ifremer.echobase.entities.references.OperationMetadataDAO;
-import fr.ifremer.echobase.entities.references.ReferenceDatumDAO;
-import fr.ifremer.echobase.entities.references.ReferenceDatumTypeDAO;
-import fr.ifremer.echobase.entities.references.ReferencingMethodDAO;
-import fr.ifremer.echobase.entities.references.SampleDataTypeDAO;
-import fr.ifremer.echobase.entities.references.SampleTypeDAO;
-import fr.ifremer.echobase.entities.references.SexCategoryDAO;
-import fr.ifremer.echobase.entities.references.SizeCategoryDAO;
-import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
-import fr.ifremer.echobase.entities.references.SpeciesDAO;
-import fr.ifremer.echobase.entities.references.StrataDAO;
-import fr.ifremer.echobase.entities.references.TSParametersDAO;
-import fr.ifremer.echobase.entities.references.VesselDAO;
-import fr.ifremer.echobase.entities.references.VesselTypeDAO;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.DriverType;
+import fr.ifremer.echobase.entities.EntityModificationLog;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.TopiaEchoBasePersistenceContext;
+import fr.ifremer.echobase.entities.data.Category;
+import fr.ifremer.echobase.entities.data.Cell;
+import fr.ifremer.echobase.entities.data.Data;
+import fr.ifremer.echobase.entities.data.DataAcquisition;
+import fr.ifremer.echobase.entities.data.DataProcessing;
+import fr.ifremer.echobase.entities.data.Echotype;
+import fr.ifremer.echobase.entities.data.GearMetadataValue;
+import fr.ifremer.echobase.entities.data.LengthAgeKey;
+import fr.ifremer.echobase.entities.data.LengthWeightKey;
+import fr.ifremer.echobase.entities.data.Operation;
+import fr.ifremer.echobase.entities.data.OperationMetadataValue;
+import fr.ifremer.echobase.entities.data.Result;
+import fr.ifremer.echobase.entities.data.Sample;
+import fr.ifremer.echobase.entities.data.SampleData;
+import fr.ifremer.echobase.entities.data.Transect;
+import fr.ifremer.echobase.entities.data.Transit;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.references.AcousticInstrument;
+import fr.ifremer.echobase.entities.references.AgeCategory;
+import fr.ifremer.echobase.entities.references.AreaOfOperation;
+import fr.ifremer.echobase.entities.references.CellType;
+import fr.ifremer.echobase.entities.references.DataMetadata;
+import fr.ifremer.echobase.entities.references.Mission;
+import fr.ifremer.echobase.entities.references.SampleDataType;
+import fr.ifremer.echobase.entities.references.SampleType;
+import fr.ifremer.echobase.entities.references.SexCategory;
+import fr.ifremer.echobase.entities.references.SizeCategory;
+import fr.ifremer.echobase.entities.references.Species;
+import fr.ifremer.echobase.entities.references.SpeciesCategory;
+import fr.ifremer.echobase.entities.references.Vessel;
+import fr.ifremer.echobase.entities.spatial.CellPoint;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import org.nuiton.csv.ValueParser;
+import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.framework.TopiaSQLQuery;
+import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaIdFactory;
+import java.util.Collection;
+import java.util.Date;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* TODO
@@ -95,239 +90,693 @@
*/
public class WorkingDbPersistenceService extends EchoBaseServiceSupport {
- public EntityModificationLogDAO getEntityModificationLogDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getEntityModificationLogDAO();
+ private TopiaEchoBasePersistenceContext persistenceContext;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+ persistenceContext = serviceContext.getEchoBasePersistenceContext();
}
- public ImportLogDAO getImportLogDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getImportLogDAO();
+ //------------------------------------------------------------------------//
+ //--- AgeCategory --------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public AgeCategory createAgeCategory(String ageCategoryName,
+ String ageCategoryMeaning) {
+
+ AgeCategory ageCategory = persistenceContext.getAgeCategoryDAO().create(
+ AgeCategory.PROPERTY_NAME, ageCategoryName,
+ AgeCategory.PROPERTY_MEANING, ageCategoryMeaning
+ );
+ return ageCategory;
}
- public CategoryDAO getCategoryDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getCategoryDAO();
+ //------------------------------------------------------------------------//
+ //--- AreaOfOperation ----------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public AreaOfOperation getAreaOfOperation(String id) {
+ AreaOfOperation areaOfOperation = persistenceContext.getAreaOfOperationDAO().
+ findByTopiaId(id);
+ return areaOfOperation;
}
- public CellDAO getCellDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getCellDAO();
+ //------------------------------------------------------------------------//
+ //--- Category -----------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Category getCategoryByEchotypeAndSpeciesCategory(Echotype echotype,
+ SpeciesCategory speciesCategory) {
+ Category category = persistenceContext.getCategoryDAO().findByProperties(
+ Category.PROPERTY_ECHOTYPE, echotype,
+ Category.PROPERTY_SPECIES_CATEGORY, speciesCategory
+ );
+ return category;
}
- public DataDAO getDataDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getDataDAO();
+ public List<Category> getCategoryUsingEchotype(Voyage voyage) throws TopiaException {
+
+ List<Category> result = persistenceContext.getCategoryDAO().
+ getCategoryUsingEchotype(voyage);
+ return result;
}
- public DataAcquisitionDAO getDataAcquisitionDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getDataAcquisitionDAO();
+ public List<Category> getCategorysByEchotype(Echotype echotype) {
+ List<Category> result = persistenceContext.getCategoryDAO().
+ findAllByEchotype(echotype);
+ return result;
}
- public DataProcessingDAO getDataProcessingDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getDataProcessingDAO();
+ public Iterable<Category> getCategories(Predicate<Category> acceptPredicate) {
+ Iterable<Category> result = Iterables.filter(
+ persistenceContext.getCategoryDAO(),
+ acceptPredicate);
+ return result;
}
- public EchotypeDAO getEchotypeDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getEchotypeDAO();
+ public long countCategoryUsingEchotype(Voyage voyage) throws TopiaException {
+
+ long result = persistenceContext.getCategoryDAO().
+ countCategoryUsingEchotype(voyage);
+ return result;
}
- public GearMetadataValueDAO getGearMetadataValueDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getGearMetadataValueDAO();
+ public Category createCategory(Echotype echotype,
+ SpeciesCategory speciesCategory) {
+ Category category = persistenceContext.getCategoryDAO().create(
+ Category.PROPERTY_ECHOTYPE, echotype,
+ Category.PROPERTY_SPECIES_CATEGORY, speciesCategory
+ );
+ return category;
}
- public LengthAgeKeyDAO getLengthAgeKeyDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getLengthAgeKeyDAO();
+ public void deleteCategory(Category category) {
+ persistenceContext.getCategoryDAO().delete(category);
}
- public LengthWeightKeyDAO getLengthWeightKeyDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getLengthWeightKeyDAO();
+ public void deleteCategories(Collection<Category> categories) {
+ persistenceContext.getCategoryDAO().deleteAll(categories);
}
- public OperationDAO getOperationDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getOperationDAO();
+ //------------------------------------------------------------------------//
+ //--- Cell ---------------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Cell getCell(String id) {
+ return persistenceContext.getCellDAO().findByTopiaId(id);
}
- public OperationMetadataValueDAO getOperationMetadataValueDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getOperationMetadataValueDAO();
+ public Cell getCellContainsResult(Result result) {
+ return persistenceContext.getCellDAO().findContainsResult(result);
}
- public ResultDAO getResultDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getResultDAO();
+ public long countVoyageOrphanCells(final Voyage voyage) {
+ return persistenceContext.getCellDAO().countVoyageOrphanCells(voyage);
}
- public SampleDAO getSampleDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getSampleDAO();
+ public long countVoyageCellResults(final Voyage voyage) {
+ return persistenceContext.getCellDAO().countVoyageCellResults(voyage);
}
- public SampleDataDAO getSampleDataDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getSampleDataDAO();
+ public List<String> getVoyageCellIds() throws TopiaException {
+ return persistenceContext.getCellDAO().getVoyageCellIds();
}
- public TransectDAO getTransectDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getTransectDAO();
+ public List<String> getVoyageCellIds(Voyage voyage) throws TopiaException {
+ return persistenceContext.getCellDAO().getVoyageCellIds(voyage);
}
- public TransitDAO getTransitDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getTransitDAO();
+ public List<CellPoint> getVoyageCellPoints(Voyage voyage, CellType cellType) {
+ return persistenceContext.getCellDAO().getVoyageCellPoints(voyage, cellType);
}
- public VoyageDAO getVoyageDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getVoyageDAO();
+ public ValueParser<Cell> newCellValueParser(Voyage voyage) {
+ return persistenceContext.getCellDAO().newCellValueParser(voyage);
}
- public AcousticInstrumentDAO getAcousticInstrumentDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getAcousticInstrumentDAO();
+ public Cell createCell(CellType cellType,
+ String cellName) {
+ Cell cell = persistenceContext.getCellDAO().create(
+ Cell.PROPERTY_CELL_TYPE, cellType,
+ Cell.PROPERTY_NAME, cellName);
+ return cell;
}
- public AgeCategoryDAO getAgeCategoryDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getAgeCategoryDAO();
+ public Cell createCell(Cell cell) {
+ Cell cellCreated = persistenceContext.getCellDAO().create(cell);
+ return cellCreated;
}
- public AreaOfOperationDAO getAreaOfOperationDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getAreaOfOperationDAO();
+ public void deleteCell(Cell cell) {
+ persistenceContext.getCellDAO().delete(cell);
}
- public CalibrationDAO getCalibrationDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getCalibrationDAO();
+ //------------------------------------------------------------------------//
+ //--- CellType -----------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public CellType getCellType(String id) {
+ CellType cellType = persistenceContext.getCellTypeDAO().findByTopiaId(id);
+ return cellType;
}
- public CategoryMeaningDAO getCategoryMeaningDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getCategoryMeaningDAO();
+ public CellType getCellTypeById(String id) {
+ CellType cellType = persistenceContext.getCellTypeDAO().findById(id);
+ return cellType;
}
- public CategoryRefDAO getCategoryRefDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getCategoryRefDAO();
+ //------------------------------------------------------------------------//
+ //--- Data ---------------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Data createData(DataMetadata dataMetaData, String dataValue) {
+ Data data = persistenceContext.getDataDAO().create(
+ Data.PROPERTY_DATA_METADATA, dataMetaData,
+ Data.PROPERTY_DATA_VALUE, dataValue
+ );
+ return data;
}
- public CategoryTypeDAO getCategoryTypeDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getCategoryTypeDAO();
+ //------------------------------------------------------------------------//
+ //--- DataAcquisition ----------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public DataAcquisition getDataAcquisition(String id) {
+ return persistenceContext.getDataAcquisitionDAO().findByTopiaId(id);
}
- public CellMethodDAO getCellMethodDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getCellMethodDAO();
+ public DataAcquisition createDataAcquisition(AcousticInstrument instrument) {
+ DataAcquisition dataAcquisition =
+ persistenceContext.getDataAcquisitionDAO().create(
+ DataAcquisition.PROPERTY_ACOUSTIC_INSTRUMENT, instrument
+ );
+ return dataAcquisition;
}
- public CellTypeDAO getCellTypeDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getCellTypeDAO();
+ public void deleteDataAcquisition(DataAcquisition dataAcquisition) {
+ persistenceContext.getDataAcquisitionDAO().delete(dataAcquisition);
}
- public DataMetadataDAO getDataMetadataDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getDataMetadataDAO();
+ //------------------------------------------------------------------------//
+ //--- DataMetadata -------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public DataMetadata getDataMetadata(String id) {
+ DataMetadata dataMetadata = persistenceContext.getDataMetadataDAO().
+ findByTopiaId(id);
+ return dataMetadata;
}
- public DataProtocolDAO getDataProtocolDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getDataProtocolDAO();
+ public DataMetadata getDataMetadataByName(String name) {
+ DataMetadata dataMetadata = persistenceContext.getDataMetadataDAO().
+ findByName(name);
+ return dataMetadata;
}
- public DataQualityDAO getDataQualityDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getDataQualityDAO();
+ //------------------------------------------------------------------------//
+ //--- DataProcessing -----------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public DataProcessing createDataProcessing(String id,
+ String processingTemplate) {
+ DataProcessing dataAcquisition = persistenceContext.getDataProcessingDAO().create(
+ DataProcessing.PROPERTY_ID, id,
+ DataProcessing.PROPERTY_PROCESSING_TEMPLATE, processingTemplate
+ );
+ return dataAcquisition;
}
- public DataTypeDAO getDataTypeDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getDataTypeDAO();
+ public DataProcessing getDataProcessing(String id) {
+ DataProcessing dataAcquisition = persistenceContext.getDataProcessingDAO().findByTopiaId(id);
+ return dataAcquisition;
}
- public DepthStratumDAO getDepthStratumDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getDepthStratumDAO();
+ public DataProcessing getDataProcessingContainsCell(Cell cell) {
+ DataProcessing dataAcquisition = persistenceContext.getDataProcessingDAO().findContainsCell(cell);
+ return dataAcquisition;
}
- public EchotypeCategoryDAO getEchotypeCategoryDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getEchotypeCategoryDAO();
+ //------------------------------------------------------------------------//
+ //--- Echotype -----------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Optional<Echotype> getOptionalEchotype(String id) {
+ return Optional.fromNullable(persistenceContext.getEchotypeDAO().findByTopiaId(id));
}
- public GearDAO getGearDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getGearDAO();
+ public Echotype getEchotype(String id) {
+ return persistenceContext.getEchotypeDAO().findByTopiaId(id);
}
- public GearCharacteristicDAO getGearCharacteristicDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getGearCharacteristicDAO();
+ public Echotype createEchotype(Echotype echotype) {
+ Echotype echotypeCreated = persistenceContext.getEchotypeDAO().create(echotype);
+ return echotypeCreated;
}
- public GearCharacteristicValueDAO getGearCharacteristicValueDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getGearCharacteristicValueDAO();
+ public void deleteEchotype(Echotype echotype) {
+ persistenceContext.getEchotypeDAO().delete(echotype);
}
- public GearMetadataDAO getGearMetadataDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getGearMetadataDAO();
+ //------------------------------------------------------------------------//
+ //--- EntityModificationLog ----------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public EntityModificationLog createEntityModificationLog(String entityType,
+ String entityId,
+ String userEmail,
+ Date date,
+ String comment) {
+ EntityModificationLog result = persistenceContext.getEntityModificationLogDAO().create(
+ EntityModificationLog.PROPERTY_ENTITY_TYPE, entityType,
+ EntityModificationLog.PROPERTY_ENTITY_ID, entityId,
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, userEmail,
+ EntityModificationLog.PROPERTY_MODIFICATION_DATE, date,
+ EntityModificationLog.PROPERTY_MODIFICATION_TEXT, comment
+ );
+ return result;
}
- public ImpacteDAO getImpacteDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getImpacteDAO();
+ //------------------------------------------------------------------------//
+ //--- GearMetadataValue --------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public GearMetadataValue createGearMetadataValue(GearMetadataValue gearMetadataValue) {
+ GearMetadataValue gearMetadataValueCreated = persistenceContext.getGearMetadataValueDAO().create(gearMetadataValue);
+ return gearMetadataValueCreated;
}
- public MeasureTypeDAO getMeasureTypeDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getMeasureTypeDAO();
+ //------------------------------------------------------------------------//
+ //--- ImportLog ----------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public List<ImportLog> getImportLogs() {
+ return persistenceContext.getImportLogDAO().findAll();
}
- public MeasurementMetadataDAO getMeasurementMetadataDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getMeasurementMetadataDAO();
+ public ImportLog getImportLog(String id) {
+ return persistenceContext.getImportLogDAO().findByTopiaId(id);
}
- public MissionDAO getMissionDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getMissionDAO();
+ public ImportLog createImportLog(String voyageId,
+ ImportType importType,
+ String userEMail,
+ Date date,
+ String comment,
+ List<String> importIds) {
+ ImportLog importLog = persistenceContext.getImportLogDAO().create(
+ ImportLog.PROPERTY_VOYAGE_ID, voyageId,
+ ImportLog.PROPERTY_IMPORT_TYPE, importType,
+ ImportLog.PROPERTY_IMPORT_USER, userEMail,
+ ImportLog.PROPERTY_IMPORT_DATE, date,
+ ImportLog.PROPERTY_IMPORT_TEXT, comment,
+ ImportLog.PROPERTY_IMPORT_ID, importIds
+ );
+ return importLog;
}
- public OperationEventDAO getOperationEventDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getOperationEventDAO();
+ public void deleteImportLog(ImportLog importLog) {
+ persistenceContext.getImportLogDAO().delete(importLog);
}
- public OperationMetadataDAO getOperationMetadataDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getOperationMetadataDAO();
+ //------------------------------------------------------------------------//
+ //--- LengthAgeKey -------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public LengthAgeKey getLengthAgeKey(String id) {
+ return persistenceContext.getLengthAgeKeyDAO().findByTopiaId(id);
}
- public ReferenceDatumDAO getReferenceDatumDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getReferenceDatumDAO();
+ public LengthAgeKey createLengthAgeKey(LengthAgeKey lengthAgeKey) {
+ LengthAgeKey lengthAgeKeyCreated = persistenceContext.getLengthAgeKeyDAO().create(lengthAgeKey);
+ return lengthAgeKeyCreated;
}
- public ReferenceDatumTypeDAO getReferenceDatumTypeDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getReferenceDatumTypeDAO();
+ public void deleteLengthAgeKey(LengthAgeKey lengthAgeKey) {
+ persistenceContext.getLengthAgeKeyDAO().delete(lengthAgeKey);
}
- public ReferencingMethodDAO getReferencingMethodDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getReferencingMethodDAO();
+ //------------------------------------------------------------------------//
+ //--- LengthWeightKey ----------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public LengthWeightKey getLengthWeightKey(String id) {
+ return persistenceContext.getLengthWeightKeyDAO().findByTopiaId(id);
}
- public SampleDataTypeDAO getSampleDataTypeDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getSampleDataTypeDAO();
+ public LengthWeightKey createLengthWeightKey(LengthWeightKey lengthWeightKey) {
+ LengthWeightKey lengthWeightKeyCreated = persistenceContext.getLengthWeightKeyDAO().create(lengthWeightKey);
+ return lengthWeightKeyCreated;
}
- public SampleTypeDAO getSampleTypeDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getSampleTypeDAO();
+ public void deleteLengthWeightKey(LengthWeightKey lengthAgeKey) {
+ persistenceContext.getLengthWeightKeyDAO().delete(lengthAgeKey);
}
- public SexCategoryDAO getSexCategoryDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getSexCategoryDAO();
+ //------------------------------------------------------------------------//
+ //--- Mission ------------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Mission getMission(String id) {
+ Mission mission = persistenceContext.getMissionDAO().findByTopiaId(id);
+ return mission;
}
- public SizeCategoryDAO getSizeCategoryDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getSizeCategoryDAO();
+ public boolean isMissionExistByName(String missionname) {
+ boolean result = persistenceContext.getMissionDAO().existByProperties(Mission.PROPERTY_NAME, missionname);
+ return result;
}
- public SpeciesDAO getSpeciesDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getSpeciesDAO();
+ public Mission createMission(Mission mission) {
+ Mission missionCreated = persistenceContext.getMissionDAO().create(mission);
+ return missionCreated;
}
- public SpeciesCategoryDAO getSpeciesCategoryDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getSpeciesCategoryDAO();
+ //------------------------------------------------------------------------//
+ //--- Operation ----------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Operation getOperation(String id) {
+ return persistenceContext.getOperationDAO().findByTopiaId(id);
}
- public StrataDAO getStrataDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getStrataDAO();
+ public Operation getOperationContainsSample(Sample sample) {
+ Operation dataAcquisition = persistenceContext.getOperationDAO().findContainsSample(sample);
+ return dataAcquisition;
}
- public TSParametersDAO getTSParametersDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getTSParametersDAO();
+ public Operation createOperation(Operation operation) {
+ Operation operationCreated = persistenceContext.getOperationDAO().create(operation);
+ return operationCreated;
}
- public VesselDAO getVesselDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getVesselDAO();
+ public void deleteOperation(Operation operation) {
+ persistenceContext.getOperationDAO().delete(operation);
}
- public VesselTypeDAO getVesselTypeDAO() throws TopiaException {
- return getEchoBasePersistenceContext().getVesselTypeDAO();
+ //------------------------------------------------------------------------//
+ //--- OperationMetadataValue ---------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public OperationMetadataValue createOperationMetadataValue(OperationMetadataValue operationMetadataValue) {
+ OperationMetadataValue operationMetadataValueCreated = persistenceContext.getOperationMetadataValueDAO().create(operationMetadataValue);
+ return operationMetadataValueCreated;
}
+ //------------------------------------------------------------------------//
+ //--- Result -------------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public List<Result> getAllWithCategoryCellAndDataMetadata(Set<String> cellIds,
+ DataMetadata requiredDataMetadata,
+ List<String> categoryIds) {
+ return persistenceContext.getResultDAO().findAllWithCategoryCellAndDataMetadata(cellIds, requiredDataMetadata, categoryIds);
+ }
+
+ public List<Result> getAllWithNoCategoryCellAndDataMetadata(Set<String> cellIds,
+ DataMetadata requiredDataMetadata) {
+ return persistenceContext.getResultDAO().findAllWithNoCategoryCellAndDataMetadata(cellIds, requiredDataMetadata);
+ }
+
+ public Result getResult(String id) {
+ return persistenceContext.getResultDAO().findByTopiaId(id);
+ }
+
+ public Result createResult(Result result) {
+ Result resultCreated = persistenceContext.getResultDAO().create(result);
+ return resultCreated;
+ }
+
+ public void deleteResult(Result result) {
+ persistenceContext.getResultDAO().delete(result);
+ }
+
+ public void deleteResults(Collection<Result> results) {
+ persistenceContext.getResultDAO().deleteAll(results);
+ }
+
+ //------------------------------------------------------------------------//
+ //--- Sample -------------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Sample getSample(String id) {
+ Sample sample = persistenceContext.getSampleDAO().findByTopiaId(id);
+ return sample;
+ }
+
+ public Sample newSample() {
+ Sample sample = persistenceContext.getSampleDAO().newInstance();
+ return sample;
+ }
+
+ public Sample createSample(Sample sample) {
+ Sample sampleCreated = persistenceContext.getSampleDAO().create(sample);
+ return sampleCreated;
+ }
+
+ public void deleteSample(Sample sample) {
+ persistenceContext.getSampleDAO().delete(sample);
+ }
+
+ //------------------------------------------------------------------------//
+ //--- SampleType ---------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public SampleType getSampleTypeByName(String name) {
+ SampleType sampleDataType = persistenceContext.getSampleTypeDAO().findByName(name);
+ return sampleDataType;
+ }
+
+ //------------------------------------------------------------------------//
+ //--- SampleData ---------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public SampleData createSampleData(SampleDataType sampleDataType,
+ String label,
+ float value) {
+ SampleData sampleCreated = persistenceContext.getSampleDataDAO().create(
+ SampleData.PROPERTY_SAMPLE_DATA_TYPE, sampleDataType,
+ SampleData.PROPERTY_DATA_LABEL, label,
+ SampleData.PROPERTY_DATA_VALUE, value
+ );
+ return sampleCreated;
+ }
+
+ public SampleData createSampleData(SampleData sample) {
+ SampleData sampleCreated = persistenceContext.getSampleDataDAO().create(
+ sample);
+ return sampleCreated;
+ }
+
+ //------------------------------------------------------------------------//
+ //--- SampleDataType -----------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public SampleDataType getSampleDataTypeByName(String name) {
+ SampleDataType sampleDataType = persistenceContext.getSampleDataTypeDAO().findByName(name);
+ return sampleDataType;
+ }
+
+ //------------------------------------------------------------------------//
+ //--- SizeCategory -------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public SizeCategory createSizeCategory(String sizeCategoryName,
+ String sizeCategoryMeaning) {
+
+ SizeCategory sizeCategory = persistenceContext.getSizeCategoryDAO().create(
+ SizeCategory.PROPERTY_NAME, sizeCategoryName,
+ SizeCategory.PROPERTY_MEANING, sizeCategoryMeaning
+ );
+ return sizeCategory;
+ }
+
+ //------------------------------------------------------------------------//
+ //--- SpeciesCategory ----------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Optional<Species> getOptionalSpecies(String id) {
+ Species species = persistenceContext.getSpeciesDAO().findByTopiaId(
+ id);
+ return Optional.fromNullable(species);
+ }
+
+ //------------------------------------------------------------------------//
+ //--- SpeciesCategory ----------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public SpeciesCategory getSpeciesCategory(Species species,
+ SizeCategory sizeCategory,
+ AgeCategory ageCategory,
+ SexCategory sexCategory) {
+ SpeciesCategory category = persistenceContext.getSpeciesCategoryDAO().findByProperties(
+ SpeciesCategory.PROPERTY_SPECIES, species,
+ SpeciesCategory.PROPERTY_SIZE_CATEGORY, sizeCategory,
+ SpeciesCategory.PROPERTY_AGE_CATEGORY, ageCategory,
+ SpeciesCategory.PROPERTY_SEX_CATEGORY, sexCategory
+ );
+ return category;
+ }
+
+ public SpeciesCategory createSpeciesCategory(Species species,
+ SizeCategory sizeCategory,
+ AgeCategory ageCategory,
+ SexCategory sexCategory) {
+ SpeciesCategory category = persistenceContext.getSpeciesCategoryDAO().create(
+ SpeciesCategory.PROPERTY_SPECIES, species,
+ SpeciesCategory.PROPERTY_SIZE_CATEGORY, sizeCategory,
+ SpeciesCategory.PROPERTY_AGE_CATEGORY, ageCategory,
+ SpeciesCategory.PROPERTY_SEX_CATEGORY, sexCategory
+ );
+ return category;
+ }
+
+ //------------------------------------------------------------------------//
+ //--- Transect -----------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Transect getTransect(String id) {
+ return persistenceContext.getTransectDAO().findByTopiaId(id);
+ }
+
+ public Transect getTransectContainsOperation(Operation operation) {
+ return persistenceContext.getTransectDAO().findContainsOperation(operation);
+ }
+
+ public Transect getTransectContainsDataAcquisition(DataAcquisition dataAcquisition) {
+ return persistenceContext.getTransectDAO().findContainsDataAcquisition(dataAcquisition);
+ }
+
+ public Transect createTransect(Transect transect) {
+ Transect transectCreated = persistenceContext.getTransectDAO().create(transect);
+ return transectCreated;
+ }
+
+ public void deleteTransect(Transect transect) {
+ persistenceContext.getTransectDAO().delete(transect);
+ }
+
+ //------------------------------------------------------------------------//
+ //--- Transit ------------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Transit getTransit(String id) {
+ return persistenceContext.getTransitDAO().findByTopiaId(id);
+ }
+
+ public Transit getTransitContainsTransect(Transect transect) {
+ return persistenceContext.getTransitDAO().findContainsTransect(transect);
+ }
+
+ public Transit createTransit(Transit transit) {
+ Transit transitCreated = persistenceContext.getTransitDAO().create(transit);
+ return transitCreated;
+ }
+
+ public void deleteTransit(Transit transit) {
+ persistenceContext.getTransitDAO().delete(transit);
+ }
+
+ //------------------------------------------------------------------------//
+ //--- Vessel -------------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Vessel getVessel(String id) {
+ Vessel mission = persistenceContext.getVesselDAO().findByTopiaId(id);
+ return mission;
+ }
+
+ //------------------------------------------------------------------------//
+ //--- Voyage -------------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
+ public Voyage getVoyage(String id) {
+ return persistenceContext.getVoyageDAO().findByTopiaId(id);
+ }
+
+ public long countVoyage() {
+ return persistenceContext.getVoyageDAO().count();
+ }
+
+ public Voyage createVoyage(Voyage voyage) {
+ Voyage voyageCreated = persistenceContext.getVoyageDAO().create(voyage);
+ return voyageCreated;
+ }
+
+ public void deleteVoyage(Voyage voyage) {
+ persistenceContext.getVoyageDAO().delete(voyage);
+ }
+
+ //------------------------------------------------------------------------//
+ //--- Transversal --------------------------------------------------------//
+ //------------------------------------------------------------------------//
+
public <E extends TopiaEntity> Map<String, String> loadSortAndDecorate(Class<E> beanType) {
- List<E> beans = getEchoBasePersistenceContext().getDAO(beanType).findAll();
-
+ List<E> beans = persistenceContext.getDAO(beanType).findAll();
return getDecoratorService().sortAndDecorate(getLocale(), beans, null);
}
+ public <E extends TopiaEntity, K> Map<K, E> getEntitiesMap(
+ Class<E> entityType,
+ Function<E, K> function) {
+ List<E> allVoyages = persistenceContext.getDAO(entityType).findAll();
+ Map<K, E> voyageMap = Maps.uniqueIndex(
+ allVoyages, function);
+ return voyageMap;
+ }
+
+ public void executeSQL(String sqlScript) {
+ persistenceContext.executeSQL(sqlScript);
+ }
+
+ public void clear() {
+ persistenceContext.clear();
+ }
+
+ public void flush() {
+ persistenceContext.flush();
+ }
+
+ public void commit() {
+ persistenceContext.commitTransaction();
+ }
+
+ public <R> R findSingleResult(TopiaSQLQuery<R> sqlQuery) {
+ return sqlQuery.findSingleResult(persistenceContext.getContext());
+ }
+
+ public <R> List<R> findMultipleResult(TopiaSQLQuery<R> sqlQuery) {
+ return sqlQuery.findMultipleResult(persistenceContext.getContext());
+ }
+
+ public boolean isPostgresql() {
+ return persistenceContext.isPostgresql();
+ }
+
+ public boolean isSpatialAware() {
+ return persistenceContext.isSpatialAware();
+ }
+
+ public boolean isIdExists(String id) {
+ try {
+ boolean result = getDAOFromId(id).existByTopiaId(id);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException(
+ "Could not find out if id " + id + " exists.", e);
+ }
+ }
+
+ protected <E extends TopiaEntity> TopiaDAO<E> getDAOFromId(String id) {
+ try {
+ TopiaIdFactory topiaIdFactory = persistenceContext.getTopiaIdFactory();
+ Class<E> className = topiaIdFactory.getClassName(id);
+ return persistenceContext.getDAO(className);
+ } catch (TopiaNotFoundException e) {
+
+ throw new EchoBaseTechnicalException(
+ "Could not find class from id: " + id, e);
+ }
+ }
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportdb/ExportDbService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportdb/ExportDbService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportdb/ExportDbService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -31,7 +31,9 @@
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.io.EchoBaseIOUtil;
import fr.ifremer.echobase.persistence.EchoBaseDbMeta;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
@@ -64,6 +66,14 @@
public static final TimeLog timeLog = new TimeLog(ExportDbService.class);
+ private WorkingDbPersistenceService persistenceService;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+ }
+
public void doExport(ExportDbConfiguration model) throws IOException {
String fileName = model.getFileName();
@@ -89,7 +99,7 @@
if (exportVoyagesByVisitor) {
- long nbVoyages = getEchoBasePersistenceContext().getVoyageDAO().count();
+ long nbVoyages = persistenceService.countVoyage();
if (exportDbMode == ExportDbMode.ALL ||
model.getVoyageIds().length == nbVoyages) {
@@ -191,7 +201,7 @@
model.incrementsProgress();
- Voyage voyage = getEchoBasePersistenceContext().getVoyageDAO().findByTopiaId(voyageId);
+ Voyage voyage = persistenceService.getVoyage(voyageId);
visitor.export(voyage);
}
} finally {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportdb/ExportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportdb/ExportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportdb/ExportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -24,9 +24,11 @@
package fr.ifremer.echobase.services.service.exportdb;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import fr.ifremer.echobase.services.service.DbEditorService;
import fr.ifremer.echobase.services.service.DecoratorService;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.csv.ExportModel;
@@ -54,6 +56,15 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ExportService.class);
+ private WorkingDbPersistenceService persistenceService;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+
+ }
+
public String exportData(TableMeta<EchoBaseEntityEnum> meta, boolean asSeen) {
if (log.isInfoEnabled()) {
@@ -76,7 +87,7 @@
defaultPrepareDataForExport,
file);
- getEchoBasePersistenceContext().clear();
+ persistenceService.clear();
}
@@ -90,7 +101,7 @@
defaultPrepareDataForExport,
file);
- getEchoBasePersistenceContext().clear();
+ persistenceService.clear();
}
public ExportModelFactory<EchoBaseEntityEnum> getModelFactory(boolean asSeen) {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportquery/ExportQueryService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportquery/ExportQueryService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/exportquery/ExportQueryService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -29,7 +29,9 @@
import fr.ifremer.echobase.entities.ExportQueries;
import fr.ifremer.echobase.entities.ExportQuery;
import fr.ifremer.echobase.entities.ExportQueryDAO;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import org.apache.commons.lang3.StringUtils;
import org.nuiton.csv.Export;
import org.nuiton.topia.TopiaException;
@@ -47,6 +49,14 @@
*/
public class ExportQueryService extends EchoBaseServiceSupport {
+ private WorkingDbPersistenceService persistenceService;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+ }
+
public ExportQuery getExportQuery(String topiaId) throws ExportQueryNotFoundException {
ExportQuery exportQuery = getDAO().findByTopiaId(topiaId);
@@ -174,7 +184,7 @@
String safeSql = getSafeSql(sql);
GenericSQLQuery sqlQuery = new GenericSQLQuery(safeSql, null);
- getEchoBasePersistenceContext().findSingleResult(sqlQuery);
+ persistenceService.findSingleResult(sqlQuery);
sqlQuery.getColumnNames();
}
@@ -187,7 +197,7 @@
GenericSQLQuery sqlQuery = new GenericSQLQuery(sql, pager);
try {
List<Map<String, Object>> result =
- getEchoBasePersistenceContext().findMultipleResult(sqlQuery);
+ persistenceService.findMultipleResult(sqlQuery);
return result.toArray(new Map[result.size()]);
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(
@@ -206,7 +216,7 @@
// do a limit query to one result and obtain the column names
// from the meta data of the result set
GenericSQLQuery sqlQuery = new GenericSQLQuery(limitSql, null);
- getEchoBasePersistenceContext().findSingleResult(sqlQuery);
+ persistenceService.findSingleResult(sqlQuery);
String[] result = sqlQuery.getColumnNames();
return result;
} catch (TopiaException eee) {
@@ -225,7 +235,7 @@
GenericSQLQuery sqlQuery = new GenericSQLQuery(sql, null);
List<Map<String, Object>> rows;
try {
- rows = getEchoBasePersistenceContext().findMultipleResult(sqlQuery);
+ rows = persistenceService.findMultipleResult(sqlQuery);
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(
"Could not execute sql query", eee);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -24,23 +24,18 @@
package fr.ifremer.echobase.services.service.importdata;
import com.google.common.base.Charsets;
-import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.csv.EchoBaseCsvUtil;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EntityModificationLog;
import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.data.Category;
-import fr.ifremer.echobase.entities.data.CategoryDAO;
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.Data;
-import fr.ifremer.echobase.entities.data.DataDAO;
import fr.ifremer.echobase.entities.data.Echotype;
import fr.ifremer.echobase.entities.data.Result;
-import fr.ifremer.echobase.entities.data.ResultDAO;
import fr.ifremer.echobase.entities.references.AgeCategory;
import fr.ifremer.echobase.entities.references.DataMetadata;
import fr.ifremer.echobase.entities.references.DataQuality;
@@ -48,16 +43,14 @@
import fr.ifremer.echobase.entities.references.SizeCategory;
import fr.ifremer.echobase.entities.references.Species;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
-import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
import fr.ifremer.echobase.io.InputFile;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.csv.ImportRuntimeException;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.TopiaDAO;
-import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.TimeLog;
import java.io.BufferedReader;
@@ -93,6 +86,14 @@
public static final TimeLog TIME_LOG =
new TimeLog(AbstractImportDataService.class);
+ protected WorkingDbPersistenceService persistenceService;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+ }
+
public final String doImport(M configuration,
EchoBaseUser user) throws ImportException {
@@ -115,7 +116,7 @@
String result = computeResultAndLogBookEntry(configuration, user);
// do commit
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.commit();
// update sql spatial data
getSpatialService().updatePostgisTable();
@@ -173,13 +174,13 @@
}
String importText = buffer.toString().trim();
- ImportLog importLog = getEchoBasePersistenceContext().getImportLogDAO().create(
- ImportLog.PROPERTY_VOYAGE_ID, configuration.getVoyageId(),
- ImportLog.PROPERTY_IMPORT_TYPE, configuration.getImportType(),
- ImportLog.PROPERTY_IMPORT_USER, importUser,
- ImportLog.PROPERTY_IMPORT_DATE, importDate,
- ImportLog.PROPERTY_IMPORT_TEXT, importText,
- ImportLog.PROPERTY_IMPORT_ID, importIds
+ ImportLog importLog = persistenceService.createImportLog(
+ configuration.getVoyageId(),
+ configuration.getImportType(),
+ importUser,
+ importDate,
+ importText,
+ importIds
);
return importLog;
}
@@ -196,12 +197,12 @@
String result = importLog.getImportText();
- getEchoBasePersistenceContext().getEntityModificationLogDAO().create(
- EntityModificationLog.PROPERTY_ENTITY_TYPE, "Import",
- EntityModificationLog.PROPERTY_ENTITY_ID, importType,
- EntityModificationLog.PROPERTY_MODIFICATION_USER, importUser,
- EntityModificationLog.PROPERTY_MODIFICATION_DATE, importDate,
- EntityModificationLog.PROPERTY_MODIFICATION_TEXT, result
+ persistenceService.createEntityModificationLog(
+ "Import",
+ importType,
+ importUser,
+ importDate,
+ result
);
return result;
}
@@ -236,25 +237,6 @@
}
}
- protected <E extends TopiaEntity, K> Map<K, E> getEntitiesMap(
- Class<E> entityType,
- Function<E, K> function) {
- List<E> allVoyages = getEchoBasePersistenceContext().getDAO(entityType).findAll();
- Map<K, E> voyageMap = Maps.uniqueIndex(
- allVoyages, function);
- return voyageMap;
- }
-
- protected <E extends TopiaEntity> E newInstance(TopiaDAO<E> dao) {
- try {
- E result = dao.newInstance();
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException(
- "Could not create new instance of entity", e);
- }
- }
-
protected String getImportMessage(M configuration, InputFile inputFile) {
String message = l_(getLocale(), "echobase.importLabel.withFile",
getImportLabel(configuration), inputFile.getFileName());
@@ -268,14 +250,13 @@
if (rowNumber % 1000 == 0) {
// flush each 1000 imported rows
String message = getImportMessage(configuration, inputFile);
- getEchoBasePersistenceContext().flush();
+ persistenceService.flush();
}
}
protected Map<String, SpeciesCategory> speciesCategories = Maps.newTreeMap();
protected SpeciesCategory getSpeciesCategory(
- SpeciesCategoryDAO speciesCategoryDAO,
Species species,
SizeCategory sizeCategory,
AgeCategory ageCategory,
@@ -293,22 +274,22 @@
// try to find it in db
- category = speciesCategoryDAO.findByProperties(
- SpeciesCategory.PROPERTY_SPECIES, species,
- SpeciesCategory.PROPERTY_AGE_CATEGORY, ageCategory,
- SpeciesCategory.PROPERTY_SIZE_CATEGORY, sizeCategory,
- SpeciesCategory.PROPERTY_SEX_CATEGORY, sexCategory
+ category = persistenceService.getSpeciesCategory(
+ species,
+ sizeCategory,
+ ageCategory,
+ sexCategory
);
if (category == null) {
// not found in db, create it
- category = speciesCategoryDAO.create(
- SpeciesCategory.PROPERTY_SPECIES, species,
- SpeciesCategory.PROPERTY_SIZE_CATEGORY, sizeCategory,
- SpeciesCategory.PROPERTY_AGE_CATEGORY, ageCategory,
- SpeciesCategory.PROPERTY_SEX_CATEGORY, sexCategory
+ category = persistenceService.createSpeciesCategory(
+ species,
+ sizeCategory,
+ ageCategory,
+ sexCategory
);
importResult.incrementsNumberCreated(EchoBaseEntityEnum.SpeciesCategory);
}
@@ -321,8 +302,6 @@
protected Map<String, Category> categories = Maps.newTreeMap();
protected Category getResultCategory(
- CategoryDAO categoryDAO,
- SpeciesCategoryDAO speciesCategoryDAO,
Echotype echotype,
Species species,
SizeCategory sizeCategory,
@@ -332,22 +311,19 @@
// get species categorie first
SpeciesCategory speciesCategory = getSpeciesCategory(
- speciesCategoryDAO,
species,
sizeCategory,
ageCategory,
null,
importResult);
- Category category = getResultCategory(categoryDAO,
- echotype,
+ Category category = getResultCategory(echotype,
speciesCategory,
importResult);
return category;
}
protected Category getResultCategory(
- CategoryDAO categoryDAO,
Echotype echotype,
SpeciesCategory speciesCategory,
EchoBaseCsvFileImportResult importResult) {
@@ -361,17 +337,17 @@
// try to find it in db
- category = categoryDAO.findByProperties(
- Category.PROPERTY_ECHOTYPE, echotype,
- Category.PROPERTY_SPECIES_CATEGORY, speciesCategory
+ category = persistenceService.getCategoryByEchotypeAndSpeciesCategory(
+ echotype,
+ speciesCategory
);
if (category == null) {
// not found in db, create it
- category = categoryDAO.create(
- Category.PROPERTY_ECHOTYPE, echotype,
- Category.PROPERTY_SPECIES_CATEGORY, speciesCategory
+ category = persistenceService.createCategory(
+ echotype,
+ speciesCategory
);
importResult.incrementsNumberCreated(EchoBaseEntityEnum.Category);
}
@@ -415,15 +391,13 @@
return result;
}
- protected void createCellData(DataDAO dao,
- Cell cell,
+ protected void createCellData(Cell cell,
DataMetadata dataMetaData,
String dataValue,
DataQuality dataQuality,
EchoBaseCsvFileImportResult importResult) {
- Data data = dao.create(Data.PROPERTY_DATA_METADATA, dataMetaData,
- Data.PROPERTY_DATA_VALUE, dataValue);
+ Data data = persistenceService.createData(dataMetaData, dataValue);
cell.addData(data);
cell.setDataQuality(dataQuality);
@@ -434,7 +408,6 @@
Cell cell,
Category category,
String resultLabel,
- ResultDAO dao,
EchoBaseCsvFileImportResult importResult,
boolean collecIds) {
List<Result> results = row.getResult();
@@ -445,7 +418,7 @@
result.setCategory(category);
result.setResultLabel(resultLabel);
- Result resultCreated = dao.create(result);
+ Result resultCreated = persistenceService.createResult(result);
cell.addResult(resultCreated);
if (collecIds) {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -32,17 +32,14 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Cell;
-import fr.ifremer.echobase.entities.data.CellDAO;
import fr.ifremer.echobase.entities.data.DataAcquisition;
-import fr.ifremer.echobase.entities.data.DataAcquisitionDAO;
-import fr.ifremer.echobase.entities.data.DataDAO;
import fr.ifremer.echobase.entities.data.DataProcessing;
-import fr.ifremer.echobase.entities.data.DataProcessingDAO;
import fr.ifremer.echobase.entities.data.Transect;
import fr.ifremer.echobase.entities.data.Transit;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.references.AcousticInstrument;
import fr.ifremer.echobase.entities.references.CellType;
+import fr.ifremer.echobase.entities.references.CellTypeImpl;
import fr.ifremer.echobase.entities.references.DataMetadata;
import fr.ifremer.echobase.entities.references.DataQuality;
import fr.ifremer.echobase.entities.references.Vessel;
@@ -84,19 +81,19 @@
EchoBaseUser user) throws ImportException {
// get selected voyage
- Voyage voyage = getEchoBasePersistenceContext().getVoyageDAO().findByTopiaId(
+ Voyage voyage = persistenceService.getVoyage(
configuration.getVoyageId());
// get selected vessel
- Vessel vessel = getEchoBasePersistenceContext().getVesselDAO().findByTopiaId(
+ Vessel vessel = persistenceService.getVessel(
configuration.getVesselId());
- CellType esduCellType = getEchoBasePersistenceContext().getCellTypeDAO().findByProperty(
- CellType.PROPERTY_ID, "Esdu");
+ CellType esduCellType = persistenceService.getCellTypeById(
+ CellTypeImpl.ESDU);
Preconditions.checkNotNull(esduCellType);
- CellType elementaryCellType = getEchoBasePersistenceContext().getCellTypeDAO().findByProperty(
- CellType.PROPERTY_ID, "Elementary");
+ CellType elementaryCellType = persistenceService.getCellTypeById(
+ CellTypeImpl.ELEMENTARY);
Preconditions.checkNotNull(elementaryCellType);
EchoBaseCsvFileImportResult importResult =
@@ -149,25 +146,18 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Map<String, AcousticInstrument> instrumentsById =
- getEntitiesMap(AcousticInstrument.class,
- EchoBaseFunctions.ACOUSTIC_INSTRUMENT_ID);
+ persistenceService.getEntitiesMap(AcousticInstrument.class,
+ EchoBaseFunctions.ACOUSTIC_INSTRUMENT_ID);
- Map<String, DataMetadata> dataMetadatasByName = getEntitiesMap(
+ Map<String, DataMetadata> dataMetadatasByName = persistenceService.getEntitiesMap(
DataMetadata.class, EchoBaseFunctions.DATA_METADATA_NAME);
- Map<String, DataQuality> dataQualityMap = getEntitiesMap(
+ Map<String, DataQuality> dataQualityMap = persistenceService.getEntitiesMap(
DataQuality.class, EchoBaseFunctions.DATA_QUALITY_NAME);
AcousticImportModel csvModel = new AcousticImportModel(
getCsvSeparator(), instrumentsById, dataQualityMap);
- DataAcquisitionDAO dataAcquisitionDAO =
- getEchoBasePersistenceContext().getDataAcquisitionDAO();
- DataProcessingDAO dataProcessingDAO =
- getEchoBasePersistenceContext().getDataProcessingDAO();
- CellDAO cellDAO = getEchoBasePersistenceContext().getCellDAO();
- DataDAO dataDAO = getEchoBasePersistenceContext().getDataDAO();
-
boolean addDataAcquisition = configuration.isAddDataAcquisition();
String suffix =
@@ -279,9 +269,7 @@
instrument,
softwareVersion,
soundSpeedCalculations,
- row,
- dataAcquisitionDAO
- );
+ row);
// collect id of the import
importResult.addId(EchoBaseEntityEnum.DataAcquisition,
@@ -305,9 +293,7 @@
dataProcessingId,
softwareVersion,
soundSpeedCalculations,
- row,
- dataProcessingDAO
- );
+ row);
if (log.isDebugEnabled()) {
log.debug("[row " + rowNumber +
@@ -353,10 +339,8 @@
// this is a esdu cell row
// create esdu cell
- Cell esduCell = cellDAO.create(
- Cell.PROPERTY_CELL_TYPE, esduCellType,
- Cell.PROPERTY_NAME, esduCellId
- );
+ Cell esduCell = persistenceService.createCell(
+ esduCellType, esduCellId);
esduCell.setDataQuality(dataQuality);
@@ -384,7 +368,6 @@
dataMetadatasByName,
row,
dataQuality,
- dataDAO,
importResult);
} else {
@@ -402,10 +385,8 @@
}
// create the elementary cell
- elementaryCell = cellDAO.create(
- Cell.PROPERTY_CELL_TYPE, elementaryCellType,
- Cell.PROPERTY_NAME, elementaryCellId
- );
+ elementaryCell = persistenceService.createCell(
+ elementaryCellType, elementaryCellId);
elementaryCell.setDataQuality(dataQuality);
// keep (to attach them to esdu cell)
@@ -420,7 +401,6 @@
surface,
row,
dataQuality,
- dataDAO,
importResult);
}
}
@@ -438,65 +418,64 @@
Map<String, DataMetadata> dataMetadatas,
AcousticImportRow row,
DataQuality dataQuality,
- DataDAO dao,
EchoBaseCsvFileImportResult importResult) {
String dataValue;
// create Latitude data
dataValue = String.valueOf(row.getCellLatitude());
- createCellData(dao, cell, dataMetadatas, "Latitude" + suffix,
+ createCellData(cell, dataMetadatas, "Latitude" + suffix,
dataValue, dataQuality, importResult);
// create Longitude data
dataValue = String.valueOf(row.getCellLongitude());
- createCellData(dao, cell, dataMetadatas, "Longitude" + suffix,
+ createCellData(cell, dataMetadatas, "Longitude" + suffix,
dataValue, dataQuality, importResult);
// create Depth data
dataValue = row.getEsduCellDataDepth();
- createCellData(dao, cell, dataMetadatas, "DepthRefSurface" + suffix,
+ createCellData(cell, dataMetadatas, "DepthRefSurface" + suffix,
dataValue, dataQuality, importResult);
// create Time Start data
dataValue = cellDateFormat.format(row.getCellDateStart());
- createCellData(dao, cell, dataMetadatas, "TimeStart",
+ createCellData(cell, dataMetadatas, "TimeStart",
dataValue, dataQuality, importResult);
// create Time end data
dataValue = cellDateFormat.format(row.getCellDateEnd());
- createCellData(dao, cell, dataMetadatas, "TimeEnd",
+ createCellData(cell, dataMetadatas, "TimeEnd",
dataValue, dataQuality, importResult);
// create NASC data
if (row.getCellNasc() != null) {
dataValue = String.valueOf(row.getCellNasc());
- createCellData(dao, cell, dataMetadatas, "NASC",
+ createCellData(cell, dataMetadatas, "NASC",
dataValue, dataQuality, importResult);
}
// create Volume data
if (row.getCellVolume() != null) {
dataValue = String.valueOf(row.getCellVolume());
- createCellData(dao, cell, dataMetadatas, "Volume ",
+ createCellData(cell, dataMetadatas, "Volume",
dataValue, dataQuality, importResult);
}
// create Surface data
dataValue = String.valueOf(row.getCellSurface());
- createCellData(dao, cell, dataMetadatas, "Surface",
+ createCellData(cell, dataMetadatas, "Surface",
dataValue, dataQuality, importResult);
// create NumberOfSamplesRecorded data
if (row.getCellNumberOfSamplesRecorded() != null) {
dataValue = String.valueOf(row.getCellNumberOfSamplesRecorded());
- createCellData(dao, cell, dataMetadatas, "NumberOfSamplesRecorded",
+ createCellData(cell, dataMetadatas, "NumberOfSamplesRecorded",
dataValue, dataQuality, importResult);
}
// create NumberOfSamplesEchoIntegrated data
if (row.getCellNumberOfSamplesEchoIntegrated() != null) {
dataValue = String.valueOf(row.getCellNumberOfSamplesEchoIntegrated());
- createCellData(dao, cell, dataMetadatas, "NumberOfSamplesEchoIntegrated",
+ createCellData(cell, dataMetadatas, "NumberOfSamplesEchoIntegrated",
dataValue, dataQuality, importResult);
}
}
@@ -507,7 +486,6 @@
boolean surface,
AcousticImportRow row,
DataQuality dataQuality,
- DataDAO dao,
EchoBaseCsvFileImportResult importResult) {
String dataValue;
@@ -531,62 +509,62 @@
// create Latitude data
dataValue = String.valueOf(row.getCellLatitude());
- createCellData(dao, cell, dataMetadatas, "Latitude" + suffix,
+ createCellData(cell, dataMetadatas, "Latitude" + suffix,
dataValue, dataQuality, importResult);
// create Longitude data
dataValue = String.valueOf(row.getCellLongitude());
- createCellData(dao, cell, dataMetadatas, "Longitude" + suffix,
+ createCellData(cell, dataMetadatas, "Longitude" + suffix,
dataValue, dataQuality, importResult);
// create depth start data
dataValue = String.valueOf(row.getCellDepthStart());
- createCellData(dao, cell, dataMetadatas, startMeta, dataValue,
+ createCellData(cell, dataMetadatas, startMeta, dataValue,
dataQuality, importResult);
// create depth end data
dataValue = String.valueOf(row.getCellDepthEnd());
- createCellData(dao, cell, dataMetadatas, endMeta, dataValue,
+ createCellData(cell, dataMetadatas, endMeta, dataValue,
dataQuality, importResult);
// create Time Start data
dataValue = cellDateFormat.format(row.getCellDateStart());
- createCellData(dao, cell, dataMetadatas, "TimeStart",
+ createCellData(cell, dataMetadatas, "TimeStart",
dataValue, dataQuality, importResult);
// create Time end data
dataValue = cellDateFormat.format(row.getCellDateEnd());
- createCellData(dao, cell, dataMetadatas, "TimeEnd",
+ createCellData(cell, dataMetadatas, "TimeEnd",
dataValue, dataQuality, importResult);
// create acoustic density data
if (row.getCellNasc() != null) {
dataValue = String.valueOf(row.getCellNasc());
- createCellData(dao, cell, dataMetadatas, "NASC", dataValue,
+ createCellData(cell, dataMetadatas, "NASC", dataValue,
dataQuality, importResult);
}
// create Volume data
if (row.getCellVolume() != null) {
dataValue = String.valueOf(row.getCellVolume());
- createCellData(dao, cell, dataMetadatas, "Volume ",
+ createCellData(cell, dataMetadatas, "Volume",
dataValue, dataQuality, importResult);
}
// create Surface data
dataValue = String.valueOf(row.getCellSurface());
- createCellData(dao, cell, dataMetadatas, "Surface",
+ createCellData(cell, dataMetadatas, "Surface",
dataValue, dataQuality, importResult);
// create NumberOfSamplesRecorded data
if (row.getCellNumberOfSamplesRecorded() != null) {
dataValue = String.valueOf(row.getCellNumberOfSamplesRecorded());
- createCellData(dao, cell, dataMetadatas, "NumberOfSamplesRecorded",
+ createCellData(cell, dataMetadatas, "NumberOfSamplesRecorded",
dataValue, dataQuality, importResult);
}
// create NumberOfSamplesEchoIntegrated data
if (row.getCellNumberOfSamplesEchoIntegrated() != null) {
dataValue = String.valueOf(row.getCellNumberOfSamplesEchoIntegrated());
- createCellData(dao, cell, dataMetadatas, "NumberOfSamplesEchoIntegrated",
+ createCellData(cell, dataMetadatas, "NumberOfSamplesEchoIntegrated",
dataValue, dataQuality, importResult);
}
}
@@ -595,8 +573,7 @@
AcousticInstrument instrument,
String softwareVersion,
String soundSpeedCalculations,
- AcousticImportRow row,
- DataAcquisitionDAO dataAcquisitionDAO) {
+ AcousticImportRow row) {
String transceiverAcquisitionAbsorptionDescription =
configuration.getTransceiverAcquisitionAbsorptionDescription();
@@ -604,12 +581,10 @@
String loggedDataDatatype = configuration.getLoggedDataDatatype();
String pingDutyCycle = configuration.getPingDutyCycle();
- DataAcquisition dataAcquisition = dataAcquisitionDAO.create(
- DataAcquisition.PROPERTY_ACOUSTIC_INSTRUMENT, instrument
- );
+ DataAcquisition dataAcquisition = persistenceService.createDataAcquisition(
+ instrument);
// fill from manual configuration
-// dataAcquisition.setAcousticInstrument(instrument);
dataAcquisition.setTransceiverAcquisitionAbsorptionDescription(transceiverAcquisitionAbsorptionDescription);
dataAcquisition.setAcquisitionSoftwareVersion(softwareVersion);
dataAcquisition.setLoggedDataFormat(loggedDataFormat);
@@ -652,8 +627,7 @@
String id,
String softwareVersion,
String soundSpeedCalculations,
- AcousticImportRow row,
- DataProcessingDAO dataProcessingDAO) {
+ AcousticImportRow row) {
String transceiverAcquisitionAbsorptionDescription =
configuration.getTransceiverAcquisitionAbsorptionDescription();
@@ -664,14 +638,10 @@
String acousticDensityUnit = configuration.getAcousticDensityUnit();
String notes = configuration.getNotes();
- DataProcessing dataProcessing = dataProcessingDAO.create(
- DataProcessing.PROPERTY_ID, id,
- DataProcessing.PROPERTY_PROCESSING_TEMPLATE, processingTemplate
- );
+ DataProcessing dataProcessing = persistenceService.createDataProcessing(
+ id, processingTemplate);
// fill from manual configuration
-// dataProcessing.setId(id);
-// dataProcessing.setProcessingTemplate(processingTemplate);
dataProcessing.setProcessingDescription(processingDescription);
dataProcessing.setSounderConstant(sounderConstant);
dataProcessing.setDigitThreshold(digitThreshold);
@@ -711,32 +681,18 @@
return dataProcessing;
}
- private void createCellData(DataDAO dao,
- Cell cell,
+ private void createCellData(Cell cell,
Map<String, DataMetadata> dataMetadatasByName,
String metadataName,
String dataValue,
DataQuality dataQuality,
EchoBaseCsvFileImportResult importResult) {
createCellData(
- dao,
cell,
dataMetadatasByName.get(metadataName),
dataValue,
dataQuality,
- importResult
- );
-
-// DataMetadata dataMetaData = dataMetadatasByName.get(metadataName);
-// Data data = create(dao,
-// Data.PROPERTY_DATA_METADATA, dataMetaData,
-// Data.PROPERTY_DATA_VALUE, dataValue
-// );
-// data.setDataMetadata(dataMetaData);
-// data.setDataValue(dataValue);
-// cell.addData(data);
-
-// importResult.incrementsNumberCreated(EchoBaseEntityEnum.Data);
+ importResult);
}
private String getSoftwareVersion(AcousticImportConfiguration configuration,
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CatchesImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CatchesImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CatchesImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -32,20 +32,16 @@
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Operation;
import fr.ifremer.echobase.entities.data.Sample;
-import fr.ifremer.echobase.entities.data.SampleDAO;
import fr.ifremer.echobase.entities.data.SampleData;
-import fr.ifremer.echobase.entities.data.SampleDataDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.references.SampleDataType;
-import fr.ifremer.echobase.entities.references.SampleDataTypeDAO;
+import fr.ifremer.echobase.entities.references.SampleDataTypeImpl;
import fr.ifremer.echobase.entities.references.SampleType;
-import fr.ifremer.echobase.entities.references.SampleTypeDAO;
import fr.ifremer.echobase.entities.references.SampleTypeImpl;
import fr.ifremer.echobase.entities.references.SexCategory;
import fr.ifremer.echobase.entities.references.SizeCategory;
import fr.ifremer.echobase.entities.references.Species;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
-import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.service.importdata.csv.BiometrySampleImportModel;
import fr.ifremer.echobase.services.service.importdata.csv.BiometrySampleImportRow;
@@ -81,8 +77,8 @@
protected void startImport(CatchesImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class,
- configuration.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(
+ configuration.getVoyageId());
// get all operation for this voyage and this vessel
Collection<Operation> operations = voyage.getAllOperations();
@@ -91,11 +87,11 @@
Map<String, Operation> operationMap = Maps.uniqueIndex(
operations, EchoBaseFunctions.OPERATION_ID);
- Map<String, Species> speciesMap = getEntitiesMap(
+ Map<String, Species> speciesMap = persistenceService.getEntitiesMap(
Species.class,
EchoBaseFunctions.SPECIES_BARACOUDA_CODE);
- Map<String, SizeCategory> sizeCategoryMap = getEntitiesMap(
+ Map<String, SizeCategory> sizeCategoryMap = persistenceService.getEntitiesMap(
SizeCategory.class,
EchoBaseFunctions.SIZE_CATEGORY_NAME);
@@ -132,8 +128,7 @@
operationMap,
operationWithTotalOrUnsortedSample,
speciesMap,
- sizeCategoryMap
- );
+ sizeCategoryMap);
configuration.addResult(importResult);
}
@@ -171,24 +166,18 @@
sizeCategoryMap
);
- SampleDAO sampleDAO = getEchoBasePersistenceContext().getSampleDAO();
- SampleDataDAO sampleDataDAO = getEchoBasePersistenceContext().getSampleDataDAO();
- SampleTypeDAO sampleTypeDAO = getEchoBasePersistenceContext().getSampleTypeDAO();
- SampleDataTypeDAO sampleDataTypeDAO = getEchoBasePersistenceContext().getSampleDataTypeDAO();
- SpeciesCategoryDAO speciesCategoryDAO = getEchoBasePersistenceContext().getSpeciesCategoryDAO();
-
- SampleType sampleTypeTotal = sampleTypeDAO.findByProperties(SampleType.PROPERTY_NAME, SampleTypeImpl.TOTAL_SAMPLE_TYPE);
+ SampleType sampleTypeTotal = persistenceService.getSampleTypeByName(SampleTypeImpl.TOTAL_SAMPLE_TYPE);
Preconditions.checkNotNull(sampleTypeTotal);
- SampleType sampleTypeUnsorted = sampleTypeDAO.findByProperties(SampleType.PROPERTY_NAME, SampleTypeImpl.UNSORTED_SAMPLE_TYPE);
+ SampleType sampleTypeUnsorted = persistenceService.getSampleTypeByName(SampleTypeImpl.UNSORTED_SAMPLE_TYPE);
Preconditions.checkNotNull(sampleTypeUnsorted);
- SampleType sampleTypeSorted = sampleTypeDAO.findByProperties(SampleType.PROPERTY_NAME, SampleTypeImpl.SORTED_SAMPLE_TYPE);
+ SampleType sampleTypeSorted = persistenceService.getSampleTypeByName(SampleTypeImpl.SORTED_SAMPLE_TYPE);
Preconditions.checkNotNull(sampleTypeSorted);
- SampleDataType sampleDataTypeMeanLength = sampleDataTypeDAO.findByProperties(SampleDataType.PROPERTY_NAME, "MeanLengthcm");
+ SampleDataType sampleDataTypeMeanLength = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.MEAN_LENGTHCM);
Preconditions.checkNotNull(sampleDataTypeMeanLength);
- SampleDataType sampleDataTypeMeanWeight = sampleDataTypeDAO.findByProperties(SampleDataType.PROPERTY_NAME, "MeanWeightg");
+ SampleDataType sampleDataTypeMeanWeight = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.MEAN_WEIGHTG);
Preconditions.checkNotNull(sampleDataTypeMeanWeight);
- SampleDataType sampleDataTypeNoPerKg = sampleDataTypeDAO.findByProperties(SampleDataType.PROPERTY_NAME, "NoPerKg");
+ SampleDataType sampleDataTypeNoPerKg = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.NO_PER_KG);
Preconditions.checkNotNull(sampleDataTypeNoPerKg);
Reader reader = getInputFileReader(inputFile);
@@ -208,13 +197,11 @@
SizeCategory sizeCategory = row.getSizeCategory();
SpeciesCategory category = getSpeciesCategory(
- speciesCategoryDAO,
species,
sizeCategory,
null,
null,
- importResult
- );
+ importResult);
SampleType sampleType;
@@ -247,15 +234,14 @@
sample = row.getSample();
sample.setSpeciesCategory(category);
sample.setSampleType(sampleType);
- sample = addSample(sampleDAO, operation, sample, importResult);
+ sample = addSample(operation, sample, importResult);
// create datas
if (row.getMeanLength() != null) {
//create meanLength data
- addSampleData(sampleDataDAO,
- sampleDataTypeMeanLength,
+ addSampleData(sampleDataTypeMeanLength,
null,
row.getMeanLength(),
sample,
@@ -265,8 +251,7 @@
if (row.getMeanWeight() != null) {
//create meanWeight data
- addSampleData(sampleDataDAO,
- sampleDataTypeMeanWeight,
+ addSampleData(sampleDataTypeMeanWeight,
null,
row.getMeanWeight(),
sample,
@@ -276,24 +261,22 @@
if (row.getNoPerKg() != null) {
//create noPerKg data
- addSampleData(sampleDataDAO,
- sampleDataTypeNoPerKg,
+ addSampleData(sampleDataTypeNoPerKg,
null,
row.getNoPerKg(),
sample,
importResult);
}
- Sample createdSortedSample = newInstance(sampleDAO);
+ Sample createdSortedSample = persistenceService.newSample();
createdSortedSample.setSampleType(sampleTypeSorted);
createdSortedSample.setSampleWeight(row.getSortedWeight());
// create sorted sample
- createdSortedSample = addSample(sampleDAO,
- operation,
- createdSortedSample,
- importResult);
-
+ createdSortedSample = addSample(
+ operation,
+ createdSortedSample,
+ importResult);
}
return importResult;
@@ -318,7 +301,7 @@
inputFile.getFileName());
}
- Map<String, SexCategory> sexCategoryMap = getEntitiesMap(
+ Map<String, SexCategory> sexCategoryMap = persistenceService.getEntitiesMap(
SexCategory.class,
EchoBaseFunctions.SEX_CATEGORY_NAME);
@@ -332,22 +315,16 @@
sizeCategoryMap,
sexCategoryMap);
- SampleDAO sampleDAO = getEchoBasePersistenceContext().getSampleDAO();
- SampleDataDAO sampleDataDAO = getEchoBasePersistenceContext().getSampleDataDAO();
- SampleTypeDAO sampleTypeDAO = getEchoBasePersistenceContext().getSampleTypeDAO();
- SampleDataTypeDAO sampleDataTypeDAO = getEchoBasePersistenceContext().getSampleDataTypeDAO();
- SpeciesCategoryDAO speciesCategoryDAO = getEchoBasePersistenceContext().getSpeciesCategoryDAO();
-
- SampleType sampleTypeSubsample = sampleTypeDAO.findByProperties(SampleType.PROPERTY_NAME, SampleTypeImpl.SUB_SAMPLE_TYPE);
+ SampleType sampleTypeSubsample = persistenceService.getSampleTypeByName(SampleTypeImpl.SUB_SAMPLE_TYPE);
Preconditions.checkNotNull(sampleTypeSubsample);
- SampleDataType sampleDataTypeNumberAtLength = sampleDataTypeDAO.findByProperties(SampleDataType.PROPERTY_NAME, "NumberAtLength");
+ SampleDataType sampleDataTypeNumberAtLength = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.NUMBER_AT_LENGTH);
Preconditions.checkNotNull(sampleDataTypeNumberAtLength);
- SampleDataType sampleDataTypeNumberAtLength05cm = sampleDataTypeDAO.findByProperties(SampleDataType.PROPERTY_NAME, "LTcm0.5");
+ SampleDataType sampleDataTypeNumberAtLength05cm = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.LTCM0_5);
Preconditions.checkNotNull(sampleDataTypeNumberAtLength05cm);
- SampleDataType sampleDataTypeNumberAtLength1cm = sampleDataTypeDAO.findByProperties(SampleDataType.PROPERTY_NAME, "LTcm1");
+ SampleDataType sampleDataTypeNumberAtLength1cm = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.L_TCM_1);
Preconditions.checkNotNull(sampleDataTypeNumberAtLength1cm);
- SampleDataType sampleDataTypeWeightAtLength = sampleDataTypeDAO.findByProperties(SampleDataType.PROPERTY_NAME, "WeightAtLengthkg");
+ SampleDataType sampleDataTypeWeightAtLength = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.WEIGHT_AT_LENGTHKG);
Preconditions.checkNotNull(sampleDataTypeWeightAtLength);
Reader reader = getInputFileReader(inputFile);
@@ -371,14 +348,11 @@
SizeCategory sizeCategory = row.getSizeCategory();
SexCategory sexCategory = row.getSexCategory();
- SpeciesCategory category = getSpeciesCategory(
- speciesCategoryDAO,
- species,
- sizeCategory,
- null,
- sexCategory,
- importResult
- );
+ SpeciesCategory category = getSpeciesCategory(species,
+ sizeCategory,
+ null,
+ sexCategory,
+ importResult);
// find the sample with this category
Sample sample = operation.getSample(category,
@@ -392,8 +366,7 @@
sample.setSpeciesCategory(category);
sample.setSampleType(sampleTypeSubsample);
- sample = addSample(sampleDAO,
- operation,
+ sample = addSample(operation,
sample,
importResult);
}
@@ -410,8 +383,7 @@
}
//create numberAtLength data
- addSampleData(sampleDataDAO,
- dataType,
+ addSampleData(dataType,
"" + row.getLengthClass(),
row.getNumberAtLength(),
sample,
@@ -420,8 +392,7 @@
if (row.getWeightAtLength() != null) {
//create weightAtLength data
- addSampleData(sampleDataDAO,
- sampleDataTypeWeightAtLength,
+ addSampleData(sampleDataTypeWeightAtLength,
"" + row.getLengthClass(),
row.getWeightAtLength(),
sample,
@@ -461,7 +432,7 @@
inputFile.getFileName());
}
- Map<String, SampleDataType> sampleDataTypeMap = getEntitiesMap(
+ Map<String, SampleDataType> sampleDataTypeMap = persistenceService.getEntitiesMap(
SampleDataType.class,
EchoBaseFunctions.SAMPLE_DATA_TYPE_NAME);
@@ -473,12 +444,8 @@
speciesMap,
sampleDataTypeMap);
- SampleDAO sampleDAO = getEchoBasePersistenceContext().getSampleDAO();
- SampleDataDAO sampleDataDAO = getEchoBasePersistenceContext().getSampleDataDAO();
- SampleTypeDAO sampleTypeDAO = getEchoBasePersistenceContext().getSampleTypeDAO();
- SpeciesCategoryDAO speciesCategoryDAO = getEchoBasePersistenceContext().getSpeciesCategoryDAO();
- SampleType sampleTypeIndividual = sampleTypeDAO.findByProperties(SampleType.PROPERTY_NAME, SampleTypeImpl.INDIVIDUAL_SAMPLE_TYPE);
+ SampleType sampleTypeIndividual = persistenceService.getSampleTypeByName(SampleTypeImpl.INDIVIDUAL_SAMPLE_TYPE);
Preconditions.checkNotNull(sampleTypeIndividual);
Map<String, Sample> samples = Maps.newTreeMap();
@@ -513,32 +480,30 @@
if (sample == null) {
// create a new sample
- sample = newInstance(sampleDAO);
+ sample = persistenceService.newSample();
sample.setSampleType(sampleTypeIndividual);
SpeciesCategory category = getSpeciesCategory(
- speciesCategoryDAO,
species,
null,
null,
null,
- importResult
- );
+ importResult);
sample.setSpeciesCategory(category);
- sample = addSample(sampleDAO,
- operation,
- sample,
- importResult);
+ sample = addSample(
+ operation,
+ sample,
+ importResult);
samples.put(sampleKey, sample);
}
SampleData sampleData = row.getSampleData();
- SampleData sampleDataCreated = sampleDataDAO.create(sampleData);
+ SampleData sampleDataCreated = persistenceService.createSampleData(sampleData);
sample.addSampleData(sampleDataCreated);
importResult.incrementsNumberCreated(EchoBaseEntityEnum.SampleData);
}
@@ -551,13 +516,12 @@
}
}
- private Sample addSample(SampleDAO dao,
- Operation operation,
+ private Sample addSample(Operation operation,
Sample sample,
EchoBaseCsvFileImportResult importResult) {
Preconditions.checkNotNull(operation);
Preconditions.checkNotNull(sample);
- Sample result = dao.create(sample);
+ Sample result = persistenceService.createSample(sample);
operation.addSample(result);
// collect ids
@@ -565,18 +529,15 @@
return result;
}
- private SampleData addSampleData(SampleDataDAO dao,
- SampleDataType sampleDataType,
+ private SampleData addSampleData(SampleDataType sampleDataType,
String label,
float value,
Sample sample,
EchoBaseCsvFileImportResult importResult) {
- SampleData sampleData = dao.create(
- SampleData.PROPERTY_SAMPLE_DATA_TYPE, sampleDataType,
- SampleData.PROPERTY_DATA_VALUE, value,
- SampleData.PROPERTY_DATA_LABEL, label
-
- );
+ SampleData sampleData = persistenceService.createSampleData(
+ sampleDataType,
+ label,
+ value);
sample.addSampleData(sampleData);
importResult.incrementsNumberCreated(EchoBaseEntityEnum.SampleData);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonAllImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonAllImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonAllImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -42,7 +42,7 @@
EchoBaseUser user) throws ImportException {
// get usable vessels
- Map<String, Vessel> vesselMap = getEntitiesMap(
+ Map<String, Vessel> vesselMap = persistenceService.getEntitiesMap(
Vessel.class, EchoBaseFunctions.VESSEL_NAME);
EchoBaseCsvFileImportResult importResult;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,7 +28,6 @@
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.references.Mission;
-import fr.ifremer.echobase.entities.references.MissionDAO;
import org.nuiton.topia.TopiaException;
/**
@@ -77,17 +76,15 @@
Preconditions.checkNotNull(mission);
try {
- MissionDAO dao = getEchoBasePersistenceContext().getMissionDAO();
-
// check mission name is unique
- boolean exists = dao.existByProperties(Mission.PROPERTY_NAME,
- mission.getName());
+ boolean exists = persistenceService.isMissionExistByName(
+ mission.getName());
if (exists) {
throw new MissionNameAlreadyExistException();
}
- Mission result = getEchoBasePersistenceContext().getMissionDAO().create(mission);
- getEchoBasePersistenceContext().commitTransaction();
+ Mission result = persistenceService.createMission(mission);
+ persistenceService.commit();
return result;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,7 +28,6 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Transect;
-import fr.ifremer.echobase.entities.data.TransectDAO;
import fr.ifremer.echobase.entities.data.Transit;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.references.Vessel;
@@ -65,7 +64,7 @@
EchoBaseUser user) throws ImportException {
// get usable vessels
- Map<String, Vessel> vesselMap = getEntitiesMap(
+ Map<String, Vessel> vesselMap = persistenceService.getEntitiesMap(
Vessel.class, EchoBaseFunctions.VESSEL_NAME);
EchoBaseCsvFileImportResult importResult;
@@ -89,8 +88,8 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
// get voyage
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class,
- configuration.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(
+ configuration.getVoyageId());
// restrict voyage to use to this voyage
Map<String, Voyage> voyageMap = Maps.uniqueIndex(
@@ -107,8 +106,6 @@
voyageMap,
vesselMap);
- TransectDAO dao = getEchoBasePersistenceContext().getTransectDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<TransectImportRow> importer =
@@ -137,7 +134,7 @@
geospatialVerticalPositive);
transect.setBinUnitsPingAxis(binUnitsPingAxis);
- Transect createdTransect = dao.create(transect);
+ Transect createdTransect = persistenceService.createTransect(transect);
transit.addTransect(createdTransect);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,7 +28,6 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Transit;
-import fr.ifremer.echobase.entities.data.TransitDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.service.importdata.csv.TransitImportModel;
@@ -77,8 +76,8 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
// get voyage
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class,
- configuration.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(
+ configuration.getVoyageId());
// restrict voyage to use to this voyage
Map<String, Voyage> voyageMap = Maps.uniqueIndex(
@@ -89,8 +88,6 @@
TransitImportModel csvModel =
new TransitImportModel(getCsvSeparator(), voyageMap);
- TransitDAO dao = getEchoBasePersistenceContext().getTransitDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<TransitImportRow> importer =
@@ -104,7 +101,7 @@
transit.setRelatedActivity(relatedActivity);
- Transit createdTransit = dao.create(transit);
+ Transit createdTransit = persistenceService.createTransit(transit);
voyage.addTransit(createdTransit);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonVoyageImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonVoyageImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/CommonVoyageImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -26,7 +26,6 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.entities.data.VoyageDAO;
import fr.ifremer.echobase.entities.references.AreaOfOperation;
import fr.ifremer.echobase.entities.references.Mission;
import fr.ifremer.echobase.io.InputFile;
@@ -75,19 +74,17 @@
inputFile.getFileName());
}
- Mission mission = getEchoBasePersistenceContext().getEntityById(Mission.class,
- configuration.getMissionId());
+ Mission mission = persistenceService.getMission(
+ configuration.getMissionId());
AreaOfOperation areaOfOperation =
- getEchoBasePersistenceContext().getEntityById(AreaOfOperation.class,
- configuration.getAreaOfOperationId());
+ persistenceService.getAreaOfOperation(
+ configuration.getAreaOfOperationId());
EchoBaseCsvFileImportResult result = newImportResult(inputFile);
String voyageDescription = configuration.getVoyageDescription();
String datum = configuration.getDatum();
- VoyageDAO dao = getEchoBasePersistenceContext().getVoyageDAO();
-
ImportModel<Voyage> csvModel = new VoyageImportModel(getCsvSeparator());
Voyage newVoyage = null;
@@ -106,7 +103,7 @@
voyage.setDescription(voyageDescription);
voyage.setDatum(datum);
- Voyage createdVoyage = dao.create(voyage);
+ Voyage createdVoyage = persistenceService.createVoyage(voyage);
if (newVoyage == null) {
newVoyage = createdVoyage;
} else {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/OperationImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/OperationImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/OperationImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,11 +28,8 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.GearMetadataValue;
-import fr.ifremer.echobase.entities.data.GearMetadataValueDAO;
import fr.ifremer.echobase.entities.data.Operation;
-import fr.ifremer.echobase.entities.data.OperationDAO;
import fr.ifremer.echobase.entities.data.OperationMetadataValue;
-import fr.ifremer.echobase.entities.data.OperationMetadataValueDAO;
import fr.ifremer.echobase.entities.data.Transect;
import fr.ifremer.echobase.entities.data.Transit;
import fr.ifremer.echobase.entities.data.Voyage;
@@ -76,15 +73,15 @@
EchoBaseUser user) throws ImportException {
// get selected voyage
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class,
- configuration.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(
+ configuration.getVoyageId());
// get usable vessels from the voyage by their name
Map<String, Vessel> vesselMap = Maps.uniqueIndex(
voyage.getAllVessels(), EchoBaseFunctions.VESSEL_NAME);
// get usable gears by their casino gear name
- Map<String, Gear> gearMap = getEntitiesMap(
+ Map<String, Gear> gearMap = persistenceService.getEntitiesMap(
Gear.class, EchoBaseFunctions.GEAR_CASINO_GEAR_NAME);
EchoBaseCsvFileImportResult importResult;
@@ -130,7 +127,7 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
- Map<String, DepthStratum> depthStratumMap = getEntitiesMap(
+ Map<String, DepthStratum> depthStratumMap = persistenceService.getEntitiesMap(
DepthStratum.class, EchoBaseFunctions.DEPTH_STRATUM_ID);
OperationImportModel csvModel =
@@ -139,8 +136,6 @@
gearMap,
depthStratumMap);
- OperationDAO dao = getEchoBasePersistenceContext().getOperationDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<OperationImportRow> importer =
@@ -162,7 +157,7 @@
Transect transect = transit.getTransect(vessel);
- Operation createdOperation = dao.create(operation);
+ Operation createdOperation = persistenceService.createOperation(operation);
// collect ids
importResult.addId(EchoBaseEntityEnum.Operation,
@@ -194,8 +189,8 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Map<String, OperationMetadata> operationMetadatasByName =
- getEntitiesMap(OperationMetadata.class,
- EchoBaseFunctions.OPERATION_METADATA_NAME);
+ persistenceService.getEntitiesMap(OperationMetadata.class,
+ EchoBaseFunctions.OPERATION_METADATA_NAME);
OperationMetadataValueImportModel csvModel =
new OperationMetadataValueImportModel(getCsvSeparator(),
@@ -203,9 +198,6 @@
operationMetadatasByName,
operationMap);
- OperationMetadataValueDAO dao =
- getEchoBasePersistenceContext().getOperationMetadataValueDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<OperationMetadataValueImportRow> importer =
@@ -220,7 +212,7 @@
OperationMetadataValue operationMetadataValueToCreate =
row.getOperationMetadataValue();
- OperationMetadataValue operationMetadataValue = dao.create(
+ OperationMetadataValue operationMetadataValue = persistenceService.createOperationMetadataValue(
operationMetadataValueToCreate);
operation.addOperationMetadataValue(operationMetadataValue);
@@ -250,8 +242,8 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Map<String, GearMetadata> gearMetadatasByType =
- getEntitiesMap(GearMetadata.class,
- EchoBaseFunctions.GEAR_METADATA_NAME);
+ persistenceService.getEntitiesMap(GearMetadata.class,
+ EchoBaseFunctions.GEAR_METADATA_NAME);
GearMetadataValueImportModel csvModel =
new GearMetadataValueImportModel(getCsvSeparator(),
@@ -260,9 +252,6 @@
gearMap,
operationMap);
- GearMetadataValueDAO dao =
- getEchoBasePersistenceContext().getGearMetadataValueDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<GearMetadataValueImportRow> importer =
@@ -277,7 +266,7 @@
GearMetadataValue gearMetadataValuetoCreate =
row.getGearMetadataValue();
- GearMetadataValue gearMetadataValue = dao.create(
+ GearMetadataValue gearMetadataValue = persistenceService.createGearMetadataValue(
gearMetadataValuetoCreate);
operation.addGearMetadataValue(gearMetadataValue);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsEsduCellImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsEsduCellImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsEsduCellImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,20 +28,15 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Category;
-import fr.ifremer.echobase.entities.data.CategoryDAO;
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.DataProcessing;
import fr.ifremer.echobase.entities.data.Echotype;
-import fr.ifremer.echobase.entities.data.ResultDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.references.AgeCategory;
-import fr.ifremer.echobase.entities.references.AgeCategoryDAO;
import fr.ifremer.echobase.entities.references.DataMetadata;
import fr.ifremer.echobase.entities.references.DataQuality;
import fr.ifremer.echobase.entities.references.SizeCategory;
-import fr.ifremer.echobase.entities.references.SizeCategoryDAO;
import fr.ifremer.echobase.entities.references.Species;
-import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.service.importdata.csv.EsduResultByEchotypeAndSpeciesCategoryImportModel;
import fr.ifremer.echobase.services.service.importdata.csv.EsduResultByEchotypeAndSpeciesCategoryImportRow;
@@ -79,31 +74,29 @@
ResultsImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
- Map<String, Species> speciesMap = getEntitiesMap(
+ Map<String, Species> speciesMap = persistenceService.getEntitiesMap(
Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE);
Map<String, SizeCategory> sizeCategoryMap = Maps.newTreeMap();
- sizeCategoryMap.putAll(getEntitiesMap(
+ sizeCategoryMap.putAll(persistenceService.getEntitiesMap(
SizeCategory.class, EchoBaseFunctions.SIZE_CATEGORY_NAME));
Map<String, AgeCategory> ageCategoryMap = Maps.newTreeMap();
- ageCategoryMap.putAll(getEntitiesMap(
+ ageCategoryMap.putAll(persistenceService.getEntitiesMap(
AgeCategory.class, EchoBaseFunctions.AGE_CATEGORY_NAME));
- Map<String, DataMetadata> dataMetadataMap = getEntitiesMap(
+ Map<String, DataMetadata> dataMetadataMap = persistenceService.getEntitiesMap(
DataMetadata.class, EchoBaseFunctions.DATA_METADATA_NAME);
- Map<String, DataQuality> dataQualityMap = getEntitiesMap(
+ Map<String, DataQuality> dataQualityMap = persistenceService.getEntitiesMap(
DataQuality.class, EchoBaseFunctions.DATA_QUALITY_NAME);
-
// get selected voyage
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class,
- configuration.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(
+ configuration.getVoyageId());
// get selected dataProcessing
- DataProcessing dataProcessing = getEchoBasePersistenceContext().getEntityById(
- DataProcessing.class,
+ DataProcessing dataProcessing = persistenceService.getDataProcessing(
configuration.getDataProcessingId());
// authorize only the selected voyage to be imported
@@ -218,9 +211,6 @@
metas,
dataQualityMap);
- CategoryDAO categoryDAO = getEchoBasePersistenceContext().getCategoryDAO();
- ResultDAO dao = getEchoBasePersistenceContext().getResultDAO();
-
String resultLabel = configuration.getResultLabel();
Reader reader = getInputFileReader(inputFile);
@@ -237,12 +227,11 @@
Cell cell = row.getCell();
- Category category = getResultCategory(categoryDAO,
- row.getEchotype(),
+ Category category = getResultCategory(row.getEchotype(),
null,
importResult);
- addResults(row, cell, category, resultLabel, dao, importResult, true);
+ addResults(row, cell, category, resultLabel, importResult, true);
}
return importResult;
} catch (ImportRuntimeException e) {
@@ -282,14 +271,6 @@
dataMetadataMap,
header);
- SpeciesCategoryDAO speciesCategoryDAO =
- getEchoBasePersistenceContext().getSpeciesCategoryDAO();
-
- CategoryDAO categoryDAO =
- getEchoBasePersistenceContext().getCategoryDAO();
-
- ResultDAO dao = getEchoBasePersistenceContext().getResultDAO();
-
EsduResultByEchotypeAndSpeciesCategoryImportModel csvModel = new EsduResultByEchotypeAndSpeciesCategoryImportModel(
getCsvSeparator(),
voyageMap,
@@ -316,15 +297,13 @@
Cell cell = row.getCell();
- Category category = getResultCategory(categoryDAO,
- speciesCategoryDAO,
- row.getEchotype(),
+ Category category = getResultCategory(row.getEchotype(),
row.getSpecies(),
row.getSizeCategory(),
null,
importResult);
- addResults(row, cell, category, resultLabel, dao, importResult, true);
+ addResults(row, cell, category, resultLabel, importResult, true);
}
return importResult;
@@ -363,13 +342,6 @@
dataMetadataMap,
header);
- SpeciesCategoryDAO speciesCategoryDAO =
- getEchoBasePersistenceContext().getSpeciesCategoryDAO();
-
- SizeCategoryDAO sizeCategoryDAO =
- getEchoBasePersistenceContext().getSizeCategoryDAO();
-
-
EsduResultBySpeciesAndSizeCategoryImportModel csvModel = new EsduResultBySpeciesAndSizeCategoryImportModel(
getCsvSeparator(),
voyageMap,
@@ -379,9 +351,6 @@
metas,
dataQualityMap);
- CategoryDAO categoryDAO = getEchoBasePersistenceContext().getCategoryDAO();
- ResultDAO dao = getEchoBasePersistenceContext().getResultDAO();
-
String resultLabel = configuration.getResultLabel();
Reader reader = getInputFileReader(inputFile);
@@ -405,9 +374,9 @@
if (sizeCategory == null) {
// create a new sizeCategory
- sizeCategory = sizeCategoryDAO.create(
- SizeCategory.PROPERTY_NAME, sizeCategoryName,
- SizeCategory.PROPERTY_MEANING, row.getSizeCategoryMeaning()
+ sizeCategory = persistenceService.createSizeCategory(
+ sizeCategoryName,
+ row.getSizeCategoryMeaning()
);
importResult.incrementsNumberCreated(
EchoBaseEntityEnum.SizeCategory);
@@ -417,15 +386,13 @@
sizeCategoryMap.put(sizeCategoryName, sizeCategory);
}
- Category category = getResultCategory(categoryDAO,
- speciesCategoryDAO,
- null,
+ Category category = getResultCategory(null,
row.getSpecies(),
sizeCategory,
null,
importResult);
- addResults(row, cell, category, resultLabel, dao, importResult, true);
+ addResults(row, cell, category, resultLabel, importResult, true);
}
return importResult;
@@ -465,13 +432,6 @@
dataMetadataMap,
header);
- SpeciesCategoryDAO speciesCategoryDAO =
- getEchoBasePersistenceContext().getSpeciesCategoryDAO();
- AgeCategoryDAO ageCategoryDAO =
- getEchoBasePersistenceContext().getAgeCategoryDAO();
- CategoryDAO categoryDAO = getEchoBasePersistenceContext().getCategoryDAO();
- ResultDAO dao = getEchoBasePersistenceContext().getResultDAO();
-
EsduResultBySpeciesAndAgeCategoryImportModel csvModel = new EsduResultBySpeciesAndAgeCategoryImportModel(
getCsvSeparator(),
voyageMap,
@@ -504,9 +464,9 @@
if (ageCategory == null) {
// create a new sizeCategory
- ageCategory = ageCategoryDAO.create(
- AgeCategory.PROPERTY_NAME, ageCategoryName,
- AgeCategory.PROPERTY_MEANING, row.getAgeCategoryMeaning()
+ ageCategory = persistenceService.createAgeCategory(
+ ageCategoryName,
+ row.getAgeCategoryMeaning()
);
importResult.incrementsNumberCreated(
EchoBaseEntityEnum.AgeCategory);
@@ -516,15 +476,14 @@
ageCategoryMap.put(ageCategoryName, ageCategory);
}
- Category category = getResultCategory(categoryDAO,
- speciesCategoryDAO,
- null,
- row.getSpecies(),
- null,
- ageCategory,
- importResult);
+ Category category = getResultCategory(
+ null,
+ row.getSpecies(),
+ null,
+ ageCategory,
+ importResult);
- addResults(row, cell, category, resultLabel, dao, importResult, true);
+ addResults(row, cell, category, resultLabel, importResult, true);
}
return importResult;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsMapFishCellImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsMapFishCellImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsMapFishCellImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -29,21 +29,16 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Category;
-import fr.ifremer.echobase.entities.data.CategoryDAO;
import fr.ifremer.echobase.entities.data.Cell;
-import fr.ifremer.echobase.entities.data.CellDAO;
-import fr.ifremer.echobase.entities.data.DataDAO;
-import fr.ifremer.echobase.entities.data.ResultDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.references.AgeCategory;
import fr.ifremer.echobase.entities.references.CellType;
-import fr.ifremer.echobase.entities.references.CellTypeDAO;
+import fr.ifremer.echobase.entities.references.CellTypeImpl;
import fr.ifremer.echobase.entities.references.DataMetadata;
-import fr.ifremer.echobase.entities.references.DataMetadataDAO;
+import fr.ifremer.echobase.entities.references.DataMetadataImpl;
import fr.ifremer.echobase.entities.references.DataQuality;
import fr.ifremer.echobase.entities.references.SizeCategory;
import fr.ifremer.echobase.entities.references.Species;
-import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.service.importdata.csv.MapCellImportModel;
import fr.ifremer.echobase.services.service.importdata.csv.MapCellImportRow;
@@ -76,8 +71,8 @@
EchoBaseUser user) throws ImportException {
// get selected voyage
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class,
- configuration.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(
+ configuration.getVoyageId());
EchoBaseCsvFileImportResult importResult;
importResult = importMapFile(configuration, voyage);
@@ -97,49 +92,46 @@
String resultLabel = configuration.getResultLabel();
- CellTypeDAO cellTypeDAO = getEchoBasePersistenceContext().getCellTypeDAO();
- CellType cellType = cellTypeDAO.findById("Map");
+ CellType cellType = persistenceService.getCellTypeById(CellTypeImpl.MAP);
Preconditions.checkNotNull(cellType);
- DataMetadataDAO dataMetadataDAO =
- getEchoBasePersistenceContext().getDataMetadataDAO();
- DataMetadata dataLongitudeMeta = dataMetadataDAO.findByName("GridCellLongitude");
+ DataMetadata dataLongitudeMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_CELL_LONGITUDE);
Preconditions.checkNotNull(dataLongitudeMeta);
- DataMetadata dataLatitudeMeta = dataMetadataDAO.findByName("GridCellLatitude");
+ DataMetadata dataLatitudeMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_CELL_LATITUDE);
Preconditions.checkNotNull(dataLatitudeMeta);
- DataMetadata dataDepthMeta = dataMetadataDAO.findByName("GridCellDepth");
+ DataMetadata dataDepthMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_CELL_DEPTH);
Preconditions.checkNotNull(dataDepthMeta);
- DataMetadata dataLongitudeLagMeta = dataMetadataDAO.findByName("GridLongitudeLag");
+ DataMetadata dataLongitudeLagMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_LONGITUDE_LAG);
Preconditions.checkNotNull(dataLongitudeLagMeta);
- DataMetadata dataLatitudeLagMeta = dataMetadataDAO.findByName("GridLatitudeLag");
+ DataMetadata dataLatitudeLagMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_LATITUDE_LAG);
Preconditions.checkNotNull(dataLatitudeLagMeta);
- DataMetadata dataDepthLagMeta = dataMetadataDAO.findByName("GridDepthLag");
+ DataMetadata dataDepthLagMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_DEPTH_LAG);
Preconditions.checkNotNull(dataDepthLagMeta);
// authorize only the selected voyage to be imported
Map<String, Voyage> voyageMap = Maps.uniqueIndex(Arrays.asList(
voyage), EchoBaseFunctions.VOYAGE_NAME);
- Map<String, Species> speciesMap = getEntitiesMap(
+ Map<String, Species> speciesMap = persistenceService.getEntitiesMap(
Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE);
Map<String, SizeCategory> sizeCategoryMap = Maps.newTreeMap();
- sizeCategoryMap.putAll(getEntitiesMap(
+ sizeCategoryMap.putAll(persistenceService.getEntitiesMap(
SizeCategory.class, EchoBaseFunctions.SIZE_CATEGORY_NAME));
Map<String, AgeCategory> ageCategoryMap = Maps.newTreeMap();
- ageCategoryMap.putAll(getEntitiesMap(
+ ageCategoryMap.putAll(persistenceService.getEntitiesMap(
AgeCategory.class, EchoBaseFunctions.AGE_CATEGORY_NAME));
- Map<String, DataMetadata> dataMetadataMap = getEntitiesMap(
+ Map<String, DataMetadata> dataMetadataMap = persistenceService.getEntitiesMap(
DataMetadata.class, EchoBaseFunctions.DATA_METADATA_NAME);
- Map<String, DataQuality> dataQualityMap = getEntitiesMap(
+ Map<String, DataQuality> dataQualityMap = persistenceService.getEntitiesMap(
DataQuality.class, EchoBaseFunctions.DATA_QUALITY_NAME);
// first get header of file to detect which results to import
@@ -163,17 +155,6 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
- CellDAO dao = getEchoBasePersistenceContext().getCellDAO();
- SpeciesCategoryDAO speciesCategoryDAO =
- getEchoBasePersistenceContext().getSpeciesCategoryDAO();
-
- CategoryDAO categoryDAO =
- getEchoBasePersistenceContext().getCategoryDAO();
-
-
- DataDAO dataDao = getEchoBasePersistenceContext().getDataDAO();
- ResultDAO resultDao = getEchoBasePersistenceContext().getResultDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<MapCellImportRow> importer =
@@ -186,7 +167,7 @@
doFlushTransaction(++rowNumber, inputFile, configuration);
- Cell cell = dao.create(row.getCell());
+ Cell cell = persistenceService.createCell(row.getCell());
voyage.addPostCell(cell);
// collect ids
@@ -195,68 +176,59 @@
DataQuality dataQuality = row.getDataQuality();
// add gridCellLongitude data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataLongitudeMeta,
String.valueOf(row.getGridCellLongitude()),
dataQuality,
- importResult
- );
+ importResult);
// add gridCellLatitude data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataLatitudeMeta,
String.valueOf(row.getGridCellLatitude()),
dataQuality,
- importResult
- );
+ importResult);
// add gridCellDepth data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataDepthMeta,
String.valueOf(row.getGridCellDepth()),
dataQuality,
- importResult
- );
+ importResult);
// add gridLongitudeLag data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataLongitudeLagMeta,
String.valueOf(row.getGridLongitudeLag()),
dataQuality,
- importResult
- );
+ importResult);
// add gridLatitudeLag data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataLatitudeLagMeta,
String.valueOf(row.getGridLatitudeLag()),
dataQuality,
- importResult
- );
+ importResult);
// add gridDepthLag data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataDepthLagMeta,
String.valueOf(row.getGridDepthLag()),
dataQuality,
- importResult
- );
+ importResult);
- Category category = getResultCategory(categoryDAO,
- speciesCategoryDAO,
- null,
+ Category category = getResultCategory(null,
row.getSpecies(),
row.getSizeCategory(),
row.getAgeCategory(),
importResult);
- addResults(row, cell, category, resultLabel, resultDao, importResult, false);
+ addResults(row,
+ cell,
+ category,
+ resultLabel,
+ importResult,
+ false);
}
return importResult;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsMapOtherCellImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsMapOtherCellImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsMapOtherCellImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -29,14 +29,11 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Cell;
-import fr.ifremer.echobase.entities.data.CellDAO;
-import fr.ifremer.echobase.entities.data.DataDAO;
-import fr.ifremer.echobase.entities.data.ResultDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.references.CellType;
-import fr.ifremer.echobase.entities.references.CellTypeDAO;
+import fr.ifremer.echobase.entities.references.CellTypeImpl;
import fr.ifremer.echobase.entities.references.DataMetadata;
-import fr.ifremer.echobase.entities.references.DataMetadataDAO;
+import fr.ifremer.echobase.entities.references.DataMetadataImpl;
import fr.ifremer.echobase.entities.references.DataQuality;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.service.importdata.csv.MapCellImportModel;
@@ -70,8 +67,7 @@
EchoBaseUser user) throws ImportException {
// get selected voyage
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class,
- configuration.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(configuration.getVoyageId());
EchoBaseCsvFileImportResult importResult;
importResult = importMapFile(configuration, voyage);
@@ -91,39 +87,35 @@
String resultLabel = configuration.getResultLabel();
- CellTypeDAO cellTypeDAO = getEchoBasePersistenceContext().getCellTypeDAO();
- CellType cellType = cellTypeDAO.findById("Map");
+ CellType cellType = persistenceService.getCellTypeById(CellTypeImpl.MAP);
Preconditions.checkNotNull(cellType);
- DataMetadataDAO dataMetadataDAO =
- getEchoBasePersistenceContext().getDataMetadataDAO();
-
- DataMetadata dataLongitudeMeta = dataMetadataDAO.findByName("GridCellLongitude");
+ DataMetadata dataLongitudeMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_CELL_LONGITUDE);
Preconditions.checkNotNull(dataLongitudeMeta);
- DataMetadata dataLatitudeMeta = dataMetadataDAO.findByName("GridCellLatitude");
+ DataMetadata dataLatitudeMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_CELL_LATITUDE);
Preconditions.checkNotNull(dataLatitudeMeta);
- DataMetadata dataDepthMeta = dataMetadataDAO.findByName("GridCellDepth");
+ DataMetadata dataDepthMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_CELL_DEPTH);
Preconditions.checkNotNull(dataDepthMeta);
- DataMetadata dataLongitudeLagMeta = dataMetadataDAO.findByName("GridLongitudeLag");
+ DataMetadata dataLongitudeLagMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_LONGITUDE_LAG);
Preconditions.checkNotNull(dataLongitudeLagMeta);
- DataMetadata dataLatitudeLagMeta = dataMetadataDAO.findByName("GridLatitudeLag");
+ DataMetadata dataLatitudeLagMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_LATITUDE_LAG);
Preconditions.checkNotNull(dataLatitudeLagMeta);
- DataMetadata dataDepthLagMeta = dataMetadataDAO.findByName("GridDepthLag");
+ DataMetadata dataDepthLagMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.GRID_DEPTH_LAG);
Preconditions.checkNotNull(dataDepthLagMeta);
// authorize only the selected voyage to be imported
Map<String, Voyage> voyageMap = Maps.uniqueIndex(Arrays.asList(
voyage), EchoBaseFunctions.VOYAGE_NAME);
- Map<String, DataMetadata> dataMetadataMap = getEntitiesMap(
+ Map<String, DataMetadata> dataMetadataMap = persistenceService.getEntitiesMap(
DataMetadata.class, EchoBaseFunctions.DATA_METADATA_NAME);
- Map<String, DataQuality> dataQualityMap = getEntitiesMap(
+ Map<String, DataQuality> dataQualityMap = persistenceService.getEntitiesMap(
DataQuality.class, EchoBaseFunctions.DATA_QUALITY_NAME);
// first get header of file to detect which results to import
@@ -144,10 +136,6 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
- CellDAO dao = getEchoBasePersistenceContext().getCellDAO();
- DataDAO dataDao = getEchoBasePersistenceContext().getDataDAO();
- ResultDAO resultDao = getEchoBasePersistenceContext().getResultDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<MapCellImportRow> importer =
@@ -160,7 +148,7 @@
doFlushTransaction(++rowNumber, inputFile, configuration);
- Cell cell = dao.create(row.getCell());
+ Cell cell = persistenceService.createCell(row.getCell());
voyage.addPostCell(cell);
// collect ids
@@ -169,60 +157,48 @@
DataQuality dataQuality = row.getDataQuality();
// add gridCellLongitude data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataLongitudeMeta,
String.valueOf(row.getGridCellLongitude()),
dataQuality,
- importResult
- );
+ importResult);
// add gridCellLatitude data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataLatitudeMeta,
String.valueOf(row.getGridCellLatitude()),
dataQuality,
- importResult
- );
+ importResult);
// add gridCellDepth data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataDepthMeta,
String.valueOf(row.getGridCellDepth()),
dataQuality,
- importResult
- );
+ importResult);
// add gridLongitudeLag data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataLongitudeLagMeta,
String.valueOf(row.getGridLongitudeLag()),
dataQuality,
- importResult
- );
+ importResult);
// add gridLatitudeLag data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataLatitudeLagMeta,
String.valueOf(row.getGridLatitudeLag()),
dataQuality,
- importResult
- );
+ importResult);
// add gridDepthLag data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataDepthLagMeta,
String.valueOf(row.getGridDepthLag()),
dataQuality,
- importResult
- );
+ importResult);
- addResults(row, cell, null, resultLabel, resultDao, importResult, false);
+ addResults(row, cell, null, resultLabel, importResult, false);
}
return importResult;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsRegionCellImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsRegionCellImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsRegionCellImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -29,21 +29,16 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Category;
-import fr.ifremer.echobase.entities.data.CategoryDAO;
import fr.ifremer.echobase.entities.data.Cell;
-import fr.ifremer.echobase.entities.data.CellDAO;
-import fr.ifremer.echobase.entities.data.DataDAO;
import fr.ifremer.echobase.entities.data.Echotype;
-import fr.ifremer.echobase.entities.data.ResultDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.references.CellType;
-import fr.ifremer.echobase.entities.references.CellTypeDAO;
+import fr.ifremer.echobase.entities.references.CellTypeImpl;
import fr.ifremer.echobase.entities.references.DataMetadata;
-import fr.ifremer.echobase.entities.references.DataMetadataDAO;
+import fr.ifremer.echobase.entities.references.DataMetadataImpl;
import fr.ifremer.echobase.entities.references.DataQuality;
import fr.ifremer.echobase.entities.references.SizeCategory;
import fr.ifremer.echobase.entities.references.Species;
-import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.service.importdata.csv.RegionCellAssociationImportModel;
import fr.ifremer.echobase.services.service.importdata.csv.RegionCellAssociationImportRow;
@@ -75,15 +70,14 @@
LogFactory.getLog(ResultsRegionCellImportService.class);
@Override
- public void startImport(
- ResultsImportConfiguration configuration,
- EchoBaseUser user) throws ImportException {
+ public void startImport(ResultsImportConfiguration configuration,
+ EchoBaseUser user) throws ImportException {
// get selected voyage
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class,
- configuration.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(
+ configuration.getVoyageId());
- Map<String, DataQuality> dataQualityMap = getEntitiesMap(
+ Map<String, DataQuality> dataQualityMap = persistenceService.getEntitiesMap(
DataQuality.class, EchoBaseFunctions.DATA_QUALITY_NAME);
EchoBaseCsvFileImportResult importResult;
@@ -105,21 +99,16 @@
InputFile inputFile = configuration.getRegionsFile();
- CellTypeDAO cellTypeDAO = getEchoBasePersistenceContext().getCellTypeDAO();
-
- CellType cellSurfaceType = cellTypeDAO.findById("RegionSURF");
+ CellType cellSurfaceType = persistenceService.getCellTypeById(CellTypeImpl.REGION_SURF);
Preconditions.checkNotNull(cellSurfaceType);
- CellType cellBottomType = cellTypeDAO.findById("RegionCLAS");
+ CellType cellBottomType = persistenceService.getCellTypeById(CellTypeImpl.REGION_CLAS);
Preconditions.checkNotNull(cellBottomType);
- DataMetadataDAO dataMetadataDAO =
- getEchoBasePersistenceContext().getDataMetadataDAO();
-
- DataMetadata dataCoordinateMeta = dataMetadataDAO.findByName("RegionEnvCoordinates");
+ DataMetadata dataCoordinateMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.REGION_ENV_COORDINATES);
Preconditions.checkNotNull(dataCoordinateMeta);
- DataMetadata dataSurfaceMeta = dataMetadataDAO.findByName("Surface");
+ DataMetadata dataSurfaceMeta = persistenceService.getDataMetadataByName(DataMetadataImpl.SURFACE);
Preconditions.checkNotNull(dataSurfaceMeta);
// authorize only the selected voyage to be imported
@@ -135,8 +124,7 @@
getCsvSeparator(),
voyageMap,
cellTypeMap,
- dataQualityMap
- );
+ dataQualityMap);
if (log.isInfoEnabled()) {
log.info("Starts import of Region cells from file " +
@@ -145,9 +133,6 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
- CellDAO dao = getEchoBasePersistenceContext().getCellDAO();
- DataDAO dataDao = getEchoBasePersistenceContext().getDataDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<RegionCellImportRow> importer =
@@ -162,33 +147,27 @@
doFlushTransaction(++rowNumber, inputFile, configuration);
if (cell == null || !row.getName().equals(cell.getName())) {
- cell = dao.create(
- Cell.PROPERTY_CELL_TYPE, row.getCellType(),
- Cell.PROPERTY_NAME, row.getName()
- );
+ cell = persistenceService.createCell(
+ row.getCellType(), row.getName());
voyage.addPostCell(cell);
// collect ids
importResult.addId(EchoBaseEntityEnum.Cell, cell);
// add surface data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataSurfaceMeta,
String.valueOf(row.getDataSurface()),
row.getDataQuality(),
- importResult
- );
+ importResult);
}
// add coordinate data
- createCellData(dataDao,
- cell,
+ createCellData(cell,
dataCoordinateMeta,
row.getDataCoordinate(),
row.getDataQuality(),
- importResult
- );
+ importResult);
}
return importResult;
@@ -217,14 +196,11 @@
Map<String, Cell> regionsMap = Maps.uniqueIndex(
voyage.getRegionCells(), EchoBaseFunctions.CELL_BY_NAME);
- CellDAO dao = getEchoBasePersistenceContext().getCellDAO();
-
RegionCellAssociationImportModel csvModel = new RegionCellAssociationImportModel(
getCsvSeparator(),
- voyage,
voyageMap,
regionsMap,
- dao);
+ persistenceService.newCellValueParser(voyage));
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
@@ -277,14 +253,14 @@
Map<String, Echotype> echotypeMap = Maps.uniqueIndex(
voyage.getEchotype(), EchoBaseFunctions.ECHOTYPE_NAME);
- Map<String, Species> speciesMap = getEntitiesMap(
+ Map<String, Species> speciesMap = persistenceService.getEntitiesMap(
Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE);
Map<String, SizeCategory> sizeCategoryMap = Maps.newTreeMap();
- sizeCategoryMap.putAll(getEntitiesMap(
+ sizeCategoryMap.putAll(persistenceService.getEntitiesMap(
SizeCategory.class, EchoBaseFunctions.SIZE_CATEGORY_NAME));
- Map<String, DataMetadata> dataMetadataMap = getEntitiesMap(
+ Map<String, DataMetadata> dataMetadataMap = persistenceService.getEntitiesMap(
DataMetadata.class, EchoBaseFunctions.DATA_METADATA_NAME);
// first get header of file to detect which results to import
@@ -310,11 +286,6 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
- SpeciesCategoryDAO speciesCategoryDAO =
- getEchoBasePersistenceContext().getSpeciesCategoryDAO();
- CategoryDAO categoryDAO = getEchoBasePersistenceContext().getCategoryDAO();
- ResultDAO dao = getEchoBasePersistenceContext().getResultDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<RegionCellResultImportRow> importer =
@@ -328,15 +299,13 @@
Cell cell = row.getCell();
- Category category = getResultCategory(categoryDAO,
- speciesCategoryDAO,
- row.getEchotype(),
+ Category category = getResultCategory(row.getEchotype(),
row.getSpecies(),
row.getSizeCategory(),
null,
importResult);
- addResults(row, cell, category, resultLabel, dao, importResult, false);
+ addResults(row, cell, category, resultLabel, importResult, false);
}
return importResult;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsVoyageImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsVoyageImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/ResultsVoyageImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -33,13 +33,11 @@
import fr.ifremer.echobase.entities.data.Echotype;
import fr.ifremer.echobase.entities.data.LengthAgeKey;
import fr.ifremer.echobase.entities.data.LengthWeightKey;
-import fr.ifremer.echobase.entities.data.LengthWeightKeyDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.references.DepthStratum;
import fr.ifremer.echobase.entities.references.SizeCategory;
import fr.ifremer.echobase.entities.references.Species;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
-import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
import fr.ifremer.echobase.entities.references.Strata;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.service.importdata.csv.EchotypeImportModel;
@@ -52,7 +50,6 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.csv.Import;
import org.nuiton.csv.ImportRuntimeException;
-import org.nuiton.topia.persistence.TopiaDAO;
import java.io.Reader;
import java.util.Arrays;
@@ -75,16 +72,16 @@
public void startImport(ResultsImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
- Map<String, Species> speciesMap = getEntitiesMap(
+ Map<String, Species> speciesMap = persistenceService.getEntitiesMap(
Species.class,
EchoBaseFunctions.SPECIES_BARACOUDA_CODE);
- Map<String, Strata> strataMap = getEntitiesMap(
+ Map<String, Strata> strataMap = persistenceService.getEntitiesMap(
Strata.class, EchoBaseFunctions.STRATA_BY_NAME);
// get selected voyage
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class,
- configuration.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(
+ configuration.getVoyageId());
// authorize only the selected voyage to be imported
Map<String, Voyage> voyageMap = Maps.uniqueIndex(Arrays.asList(
@@ -148,7 +145,7 @@
EchoBaseCsvFileImportResult importResult = new EchoBaseCsvFileImportResult(
inputFile.getFileName());
- Map<String, SizeCategory> sizeCategoryMap = getEntitiesMap(
+ Map<String, SizeCategory> sizeCategoryMap = persistenceService.getEntitiesMap(
SizeCategory.class,
EchoBaseFunctions.SIZE_CATEGORY_NAME);
@@ -159,11 +156,6 @@
sizeCategoryMap,
speciesMap);
- LengthWeightKeyDAO dao = getEchoBasePersistenceContext().getLengthWeightKeyDAO();
-
- SpeciesCategoryDAO speciesCategoryDAO =
- getEchoBasePersistenceContext().getSpeciesCategoryDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
@@ -179,7 +171,6 @@
// find speciesCategory
SpeciesCategory speciesCategory = getSpeciesCategory(
- speciesCategoryDAO,
row.getSpecies(),
row.getSizeCategory(),
null,
@@ -190,7 +181,7 @@
LengthWeightKey toCreate = row.getLengthWeightKey();
toCreate.setSpeciesCategory(speciesCategory);
- LengthWeightKey lengthWeightKey = dao.create(toCreate);
+ LengthWeightKey lengthWeightKey = persistenceService.createLengthWeightKey(toCreate);
//TODO should we import it ?
//lengthWeightKey.setMetadata(row.getMetadata());
@@ -231,8 +222,6 @@
strataMap,
speciesMap);
- TopiaDAO<LengthAgeKey> dao = getEchoBasePersistenceContext().getLengthAgeKeyDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<LengthAgeKeyImportRow> importer =
@@ -248,7 +237,7 @@
Voyage voyage = row.getVoyage();
LengthAgeKey lengthAgeKeyToCreate = row.getLengthAgeKey();
- LengthAgeKey lengthAgeKey = dao.create(lengthAgeKeyToCreate);
+ LengthAgeKey lengthAgeKey = persistenceService.createLengthAgeKey(lengthAgeKeyToCreate);
// attach it to voyage
voyage.addLengthAgeKey(lengthAgeKey);
@@ -278,7 +267,7 @@
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
- Map<String, DepthStratum> depthStratumMap = getEntitiesMap(
+ Map<String, DepthStratum> depthStratumMap = persistenceService.getEntitiesMap(
DepthStratum.class,
EchoBaseFunctions.DEPTH_STRATUM_ID);
@@ -288,8 +277,6 @@
depthStratumMap,
speciesMap);
- TopiaDAO<Echotype> dao = getEchoBasePersistenceContext().getEchotypeDAO();
-
Reader reader = getInputFileReader(inputFile);
try {
Import<EchotypeImportRow> importer =
@@ -324,7 +311,7 @@
if (echotype == null) {
// creates it
- echotype = dao.create(rowEchotype);
+ echotype = persistenceService.createEchotype(rowEchotype);
// attach it to voyage
voyage.addEchotype(echotype);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportModel.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportModel.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -23,10 +23,9 @@
*/
package fr.ifremer.echobase.services.service.importdata.csv;
-import fr.ifremer.echobase.csv.EchoBaseCsvUtil;
import fr.ifremer.echobase.entities.data.Cell;
-import fr.ifremer.echobase.entities.data.CellDAO;
import fr.ifremer.echobase.entities.data.Voyage;
+import org.nuiton.csv.ValueParser;
import org.nuiton.topia.persistence.csv.in.AbstractImportModel;
import java.util.Map;
@@ -40,14 +39,13 @@
public class RegionCellAssociationImportModel extends AbstractImportModel<RegionCellAssociationImportRow> {
public RegionCellAssociationImportModel(char separator,
- Voyage voyage,
Map<String, Voyage> voyageMap,
Map<String, Cell> regionCellMap,
- CellDAO cellDAO) {
+ ValueParser<Cell> cellParser) {
super(separator);
newForeignKeyColumn(RegionCellAssociationImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, voyageMap);
newForeignKeyColumn("regionName", RegionCellAssociationImportRow.PROPERTY_REGION_CELL, Cell.class, Cell.PROPERTY_NAME, regionCellMap);
- newMandatoryColumn("esduName", RegionCellAssociationImportRow.PROPERTY_ESDU_CELL, EchoBaseCsvUtil.newCellValueParser(voyage, cellDAO));
+ newMandatoryColumn("esduName", RegionCellAssociationImportRow.PROPERTY_ESDU_CELL, cellParser);
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/ImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/ImportService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/ImportService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,8 +28,10 @@
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.service.DbEditorService;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -55,6 +57,14 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ImportService.class);
+ private WorkingDbPersistenceService persistenceService;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+ }
+
public CsvImportResult<EchoBaseEntityEnum> importDatas(EchoBaseEntityEnum entityType,
String importFileName,
File importFile,
@@ -104,7 +114,7 @@
bf.close();
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.commit();
} catch (EchoBaseTechnicalException eee) {
throw eee;
} catch (Exception eee) {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/AbstractImportDbStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/AbstractImportDbStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/AbstractImportDbStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -27,12 +27,13 @@
import com.google.common.collect.Lists;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EntityModificationLog;
-import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.TopiaEchoBasePersistenceContext;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.io.EchoBaseIOUtil;
import fr.ifremer.echobase.persistence.EchoBaseDbMeta;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import fr.ifremer.echobase.services.service.importdata.ImportException;
import fr.ifremer.echobase.services.service.importdb.EchoBaseImportModelFactory;
import fr.ifremer.echobase.services.service.importdb.ImportDbConfiguration;
@@ -40,7 +41,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.csv.in.CsvImportResult;
import org.nuiton.topia.persistence.csv.in.ImportStrategy;
import org.nuiton.topia.persistence.csv.in.TopiaCsvImports;
@@ -72,6 +72,17 @@
public static final TimeLog TIME_LOG =
new TimeLog(AbstractImportDbStrategy.class);
+ protected WorkingDbPersistenceService persistenceService;
+
+ private TopiaEchoBasePersistenceContext persistenceContext;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+ persistenceContext = serviceContext.getEchoBasePersistenceContext();
+ }
+
public final void doImport(ImportDbConfiguration model,
EchoBaseUser user) throws IOException, ImportException, TopiaException {
File file = model.getInput().getFile();
@@ -118,7 +129,7 @@
ImportStrategy<EchoBaseEntityEnum> strategy = new EchoBaseImportStrategy(
EchoBaseImportModelFactory.newFactory(this),
- getEchoBasePersistenceContext(),
+ persistenceContext,
1000
);
@@ -138,19 +149,14 @@
if (importedVoyages != null &&
!Iterables.isEmpty(importedVoyages)) {
- createImportLogEntry(getEchoBasePersistenceContext().getImportLogDAO(),
- user,
- file,
- importedVoyages);
+ createImportLogEntry(user, file, importedVoyages);
}
- createLogBookEntry(getEchoBasePersistenceContext().getEntityModificationLogDAO(),
- user,
- file);
+ createLogBookEntry(user, file);
zipFile.close();
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.commit();
} finally {
@@ -165,13 +171,11 @@
protected abstract void validateAssociationEntries(EchoBaseDbMeta dbMeta,
Map<AssociationMeta<EchoBaseEntityEnum>, ZipEntry> associations) throws ImportException;
- protected abstract void createImportLogEntry(TopiaDAO<ImportLog> dao,
- EchoBaseUser user,
+ protected abstract void createImportLogEntry(EchoBaseUser user,
File file,
Iterable<Voyage> importedVoyages) throws TopiaException;
- protected abstract void createLogBookEntry(TopiaDAO<EntityModificationLog> dao,
- EchoBaseUser user,
+ protected abstract void createLogBookEntry(EchoBaseUser user,
File file) throws TopiaException;
protected Iterable<Voyage> importTables(ImportStrategy<EchoBaseEntityEnum> strategy,
@@ -222,17 +226,17 @@
s0 = TIME_LOG.log(s0, "importFile::done");
- getEchoBasePersistenceContext().flush();
+ persistenceService.flush();
TIME_LOG.log(s0, "importFile::flushTransaction");
reader.close();
} finally {
IOUtils.closeQuietly(reader);
if (commitAfterEachFile) {
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.commit();
}
- getEchoBasePersistenceContext().clear();
+ persistenceService.clear();
}
}
@@ -274,7 +278,7 @@
s0 = TIME_LOG.log(s0, "importFile::done");
- getEchoBasePersistenceContext().flush();
+ persistenceService.flush();
TIME_LOG.log(s0, "importFile::flushTransaction");
} finally {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/FreeImportDbStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/FreeImportDbStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/FreeImportDbStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -23,17 +23,15 @@
* #L%
*/
+import com.google.common.collect.Lists;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EntityModificationLog;
-import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.persistence.EchoBaseDbMeta;
import fr.ifremer.echobase.services.service.importdata.ImportException;
import org.nuiton.decorator.Decorator;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.metadata.AssociationMeta;
import org.nuiton.topia.persistence.metadata.TableMeta;
@@ -63,8 +61,7 @@
}
@Override
- protected void createImportLogEntry(TopiaDAO<ImportLog> dao,
- EchoBaseUser user,
+ protected void createImportLogEntry(EchoBaseUser user,
File file,
Iterable<Voyage> importedVoyages) throws TopiaException {
Date date = newDate();
@@ -73,29 +70,29 @@
getLocale(), Voyage.class, null);
for (Voyage importedVoyage : importedVoyages) {
+
// create a importLog entry
- ImportLog importLog = dao.create(
- ImportLog.PROPERTY_VOYAGE_ID, importedVoyage.getTopiaId(),
- ImportLog.PROPERTY_IMPORT_TYPE, ImportType.VOYAGE,
- ImportLog.PROPERTY_IMPORT_USER, user.getEmail(),
- ImportLog.PROPERTY_IMPORT_DATE, date,
- ImportLog.PROPERTY_IMPORT_TEXT, "Import voyage " + decorator.toString(importedVoyage) + " from file " + file.getName()
+ persistenceService.createImportLog(
+ importedVoyage.getTopiaId(),
+ ImportType.VOYAGE,
+ user.getEmail(),
+ date,
+ "Import voyage " + decorator.toString(importedVoyage) + " from file " + file.getName(),
+ Lists.newArrayList(importedVoyage.getTopiaId())
);
- importLog.addImportId(importedVoyage.getTopiaId());
}
}
@Override
- protected void createLogBookEntry(TopiaDAO<EntityModificationLog> dao,
- EchoBaseUser user,
+ protected void createLogBookEntry(EchoBaseUser user,
File file) throws TopiaException {
- dao.create(
- EntityModificationLog.PROPERTY_ENTITY_TYPE, "Import db",
- EntityModificationLog.PROPERTY_ENTITY_ID, "EchoBase (referential + data) db",
- EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
- EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
- EntityModificationLog.PROPERTY_MODIFICATION_TEXT, "import db from file " + file.getName()
+ persistenceService.createEntityModificationLog(
+ "Import db",
+ "EchoBase (referential + data) db",
+ user.getEmail(),
+ newDate(),
+ "import db from file " + file.getName()
);
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/ReferentialImportDbStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/ReferentialImportDbStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/strategy/ReferentialImportDbStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -26,13 +26,10 @@
import com.google.common.collect.Lists;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EntityModificationLog;
-import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.persistence.EchoBaseDbMeta;
import fr.ifremer.echobase.services.service.importdata.ImportException;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.metadata.AssociationMeta;
import org.nuiton.topia.persistence.metadata.TableMeta;
@@ -89,26 +86,23 @@
}
@Override
- protected void createImportLogEntry(TopiaDAO<ImportLog> dao,
- EchoBaseUser user,
+ protected void createImportLogEntry(EchoBaseUser user,
File file,
Iterable<Voyage> importedVoyages) {
// no importLog entry to add
}
@Override
- protected void createLogBookEntry(TopiaDAO<EntityModificationLog> dao,
- EchoBaseUser user,
+ protected void createLogBookEntry(EchoBaseUser user,
File file) throws TopiaException {
- dao.create(
- EntityModificationLog.PROPERTY_ENTITY_TYPE, "Import referential only db",
- EntityModificationLog.PROPERTY_ENTITY_ID, "Referential EchoBase db",
- EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
- EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
- EntityModificationLog.PROPERTY_MODIFICATION_TEXT, "import db from file " + file.getName()
+ persistenceService.createEntityModificationLog(
+ "Import referential only db",
+ "Referential EchoBase db",
+ user.getEmail(),
+ newDate(),
+ "import db from file " + file.getName()
);
-
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/RemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/RemoveDataService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/RemoveDataService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,11 +28,12 @@
import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EntityModificationLog;
import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import fr.ifremer.echobase.services.service.removedata.strategy.AbstractRemoveDataStrategy;
import fr.ifremer.echobase.services.service.removedata.strategy.AcousticRemoveDataStrategy;
import fr.ifremer.echobase.services.service.removedata.strategy.CatchesRemoveDataStrategy;
@@ -51,10 +52,6 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.decorator.Decorator;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.persistence.TopiaDAO;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.persistence.TopiaIdFactory;
import org.nuiton.util.TimeLog;
import java.util.Comparator;
@@ -110,6 +107,15 @@
}
}
+ private WorkingDbPersistenceService persistenceService;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+ }
+
public String removeImport(RemoveDataConfiguration model, EchoBaseUser user) {
// build map of strategy to apply
@@ -120,13 +126,13 @@
Maps.newTreeMap(IMPORT_LOG_COMPARATOR);
for (String id : model.getImportLogIds()) {
- ImportLog importLog = getEchoBasePersistenceContext().getEntityById(ImportLog.class, id);
+ ImportLog importLog = persistenceService.getImportLog(id);
Class<? extends AbstractRemoveDataStrategy> strategyType =
getStrategy(importLog);
AbstractRemoveDataStrategy strategy = newService(strategyType);
strategy.setProgressModel(model);
- Voyage voyage = getWorkingDbPersistenceService().getVoyageDAO().findByTopiaId(importLog.getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(importLog.getVoyageId());
long l = strategy.computeNbSteps(voyage, importLog);
ImportContext importContext = new ImportContext(id, l + 3, strategy, voyage);
toTreat.put(importLog, importContext);
@@ -150,7 +156,7 @@
EchoBaseUser user) {
// check that importLog still exists
- ImportLog importLog = getWorkingDbPersistenceService().getImportLogDAO().findByTopiaId(importContext.importLogId);
+ ImportLog importLog = persistenceService.getImportLog(importContext.importLogId);
AbstractRemoveDataStrategy strategy = importContext.strategy;
@@ -183,7 +189,7 @@
strategy.incrementOp("Log book entry for " + importLog.getTopiaId());
// do commit
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.commit();
strategy.incrementOp("Commit importLog " + importLog.getTopiaId());
TIME_LOG.log(s0, "Commit importLog " + importLog.getTopiaId());
return result;
@@ -197,15 +203,13 @@
Set<ImportType> possibleSubImportType =
strategy.getPossibleSubImportType();
- TopiaDAO<ImportLog> dao = getEchoBasePersistenceContext().getImportLogDAO();
+ for (ImportLog logEntry : persistenceService.getImportLogs()) {
- for (ImportLog logEntry : dao) {
-
if (importLog.equals(logEntry)) {
// for sure remove me
// but do not add to result
- dao.delete(logEntry);
+ persistenceService.deleteImportLog(logEntry);
continue;
}
@@ -221,7 +225,7 @@
// try to find out if first id is still exists
String firstId = logEntry.getImportId().iterator().next();
- if (!isIdExists(firstId)) {
+ if (!persistenceService.isIdExists(firstId)) {
// one of id does not exist, can safely remove importLog
@@ -230,7 +234,7 @@
logEntry.getImportType() + ": " + logEntry.getTopiaId());
}
- dao.delete(logEntry);
+ persistenceService.deleteImportLog(logEntry);
// add it in result
result.add(logEntry);
@@ -285,35 +289,13 @@
if (log.isDebugEnabled()) {
log.debug("Log text: " + result);
}
- getEchoBasePersistenceContext().getEntityModificationLogDAO().create(
- EntityModificationLog.PROPERTY_ENTITY_TYPE, "Removed Import",
- EntityModificationLog.PROPERTY_ENTITY_ID, importLog.getTopiaId(),
- EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
- EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
- EntityModificationLog.PROPERTY_MODIFICATION_TEXT, result
+ persistenceService.createEntityModificationLog(
+ "Removed Import",
+ importLog.getTopiaId(),
+ user.getEmail(),
+ newDate(),
+ result
);
return result;
}
-
- protected boolean isIdExists(String id) {
- try {
- boolean result = getDAOFromId(id).existByTopiaId(id);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException(
- "Could not find out if id " + id + " exists.", e);
- }
- }
-
- protected <E extends TopiaEntity> TopiaDAO<E> getDAOFromId(String id) {
- try {
- TopiaIdFactory topiaIdFactory = getEchoBasePersistenceContext().getTopiaIdFactory();
- Class<E> className = topiaIdFactory.getClassName(id);
- return getEchoBasePersistenceContext().getDAO(className);
- } catch (TopiaNotFoundException e) {
-
- throw new EchoBaseTechnicalException(
- "Could not find class from id: " + id, e);
- }
- }
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/AbstractRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/AbstractRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/AbstractRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,29 +28,17 @@
import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Category;
-import fr.ifremer.echobase.entities.data.CategoryDAO;
import fr.ifremer.echobase.entities.data.Cell;
-import fr.ifremer.echobase.entities.data.CellDAO;
-import fr.ifremer.echobase.entities.data.DataProcessingDAO;
-import fr.ifremer.echobase.entities.data.EchotypeDAO;
-import fr.ifremer.echobase.entities.data.LengthAgeKeyDAO;
-import fr.ifremer.echobase.entities.data.LengthWeightKeyDAO;
import fr.ifremer.echobase.entities.data.Result;
-import fr.ifremer.echobase.entities.data.ResultDAO;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.entities.data.VoyageDAO;
import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import fr.ifremer.echobase.services.ProgressModel;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaSQLQuery;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -71,37 +59,17 @@
protected ProgressModel progressModel;
+ protected WorkingDbPersistenceService persistenceService;
+
public String getImportLabel() {
return importLabel;
}
- protected VoyageDAO voyageDao;
-
- protected DataProcessingDAO dataProcessingDAO;
-
- protected CellDAO cellDAO;
-
- protected CategoryDAO categoryDAO;
-
- protected EchotypeDAO echotypeDAO;
-
- protected LengthAgeKeyDAO lengthAgeKeyDAO;
-
- protected LengthWeightKeyDAO lengthWeightKeyDAO;
-
- protected ResultDAO resultDAO;
-
@Override
public void setServiceContext(EchoBaseServiceContext serviceContext) {
super.setServiceContext(serviceContext);
- dataProcessingDAO = getEchoBasePersistenceContext().getDataProcessingDAO();
- cellDAO = getEchoBasePersistenceContext().getCellDAO();
- echotypeDAO = getEchoBasePersistenceContext().getEchotypeDAO();
- voyageDao = getEchoBasePersistenceContext().getVoyageDAO();
- lengthAgeKeyDAO = getEchoBasePersistenceContext().getLengthAgeKeyDAO();
- lengthWeightKeyDAO = getEchoBasePersistenceContext().getLengthWeightKeyDAO();
- categoryDAO = getEchoBasePersistenceContext().getCategoryDAO();
- resultDAO = getEchoBasePersistenceContext().getResultDAO();
+
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
}
public void setProgressModel(ProgressModel progressModel) {
@@ -119,7 +87,7 @@
removePreDataInVoyage(voyage);
- getEchoBasePersistenceContext().flush();
+ persistenceService.flush();
for (String importId : importLog.getImportId()) {
@@ -132,11 +100,11 @@
incrementOp("ImportLog " + importId + "Removed");
}
- getEchoBasePersistenceContext().flush();
+ persistenceService.flush();
removePostDataInVoyage(voyage);
- getEchoBasePersistenceContext().flush();
+ persistenceService.flush();
}
long opIndex;
@@ -158,34 +126,38 @@
protected void removeVoyage(Voyage entity) throws TopiaException {
// get categories to remove after
- List<Category> categories = getCategoryUsingEchotype(entity);
+ List<Category> categories =
+ persistenceService.getCategoryUsingEchotype(entity);
// dettach obsolete categories from their echotypes
+ // FIXME This with topia 3.0 ?
for (Category category : categories) {
category.setEchotype(null);
}
// delete it
- voyageDao.delete(entity);
+ persistenceService.deleteVoyage(entity);
// remove obsolete categories
for (Category category : categories) {
- categoryDAO.delete(category);
+ persistenceService.deleteCategory(category);
incrementOp("Remove orphan category " + category.getTopiaId());
}
}
protected void removeVoyagePostCell(Voyage entity) throws TopiaException {
+
if (!entity.isPostCellEmpty()) {
+
for (Cell cell : Sets.newHashSet(entity.getPostCell())) {
// remove it from the voyage
entity.removePostCell(cell);
// delete postcell
- cellDAO.delete(cell);
+ persistenceService.deleteCell(cell);
// increments operation
incrementOp("Remove postCell " + cell.getTopiaId());
@@ -196,166 +168,98 @@
}
}
- protected void removeVoyageCellResults(final Voyage voyage) throws TopiaException {
+ protected void removeVoyageCellResults(Voyage voyage) throws TopiaException {
// Get all cells of the voyage
- TopiaSQLQuery<String> query = new TopiaSQLQuery<String>() {
- @Override
- protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
- String hql = "SELECT c.topiaid FROM Transit ta, " +
- " Transect te, " +
- " DataAcquisition da, " +
- " DataProcessing dp, " +
- " Cell c " +
- "WHERE ta.voyage = ? " +
- "AND ta.topiaId = te.transit " +
- "AND te.topiaId = da.transect " +
- "AND da.topiaId = dp.dataacquisition " +
- "AND dp.topiaId = c.dataprocessing";
- PreparedStatement result = connection.prepareStatement(hql);
- result.setString(1, voyage.getTopiaId());
- return result;
- }
+// TopiaSQLQuery<String> query = new TopiaSQLQuery<String>() {
+// @Override
+// protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
+// String hql = "SELECT c.topiaid FROM Transit ta, " +
+// " Transect te, " +
+// " DataAcquisition da, " +
+// " DataProcessing dp, " +
+// " Cell c " +
+// "WHERE ta.voyage = ? " +
+// "AND ta.topiaId = te.transit " +
+// "AND te.topiaId = da.transect " +
+// "AND da.topiaId = dp.dataacquisition " +
+// "AND dp.topiaId = c.dataprocessing";
+// PreparedStatement result = connection.prepareStatement(hql);
+// result.setString(1, voyage.getTopiaId());
+// return result;
+// }
+//
+// @Override
+// protected String prepareResult(ResultSet set) throws SQLException {
+// return set.getString(1);
+// }
+// };
- @Override
- protected String prepareResult(ResultSet set) throws SQLException {
- return set.getString(1);
- }
- };
+ List<String> cellIds = persistenceService.getVoyageCellIds(voyage);
- List<String> cellIds = getEchoBasePersistenceContext().findMultipleResult(query);
// remove all result of cells
-
for (String cellId : cellIds) {
- Cell cell = cellDAO.findByTopiaId(cellId);
+ Cell cell = persistenceService.getCell(cellId);
if (cell != null && !cell.isResultEmpty()) {
Collection<Result> cellResult = cell.getResult();
// for (Result result : cellResult) {
// cell.removeResult(result);
// }
- resultDAO.deleteAll(cellResult);
+ persistenceService.deleteResults(cellResult);
cell.clearResult();
}
incrementOp("Remove cell " + cellId + " results");
}
}
- protected long countVoyageCellResults(final Voyage voyage) {
- TopiaSQLQuery<Long> query = new TopiaSQLQuery<Long>() {
- @Override
- protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
- String hql = "SELECT count(c.topiaid) FROM Transit ta, " +
- " Transect te, " +
- " DataAcquisition da, " +
- " DataProcessing dp, " +
- " Cell c " +
- "WHERE ta.voyage = ? " +
- "AND ta.topiaId = te.transit " +
- "AND te.topiaId = da.transect " +
- "AND da.topiaId = dp.dataacquisition " +
- "AND dp.topiaId = c.dataprocessing";
- PreparedStatement result = connection.prepareStatement(hql);
- result.setString(1, voyage.getTopiaId());
- return result;
- }
+// protected long countVoyageCellResults(final Voyage voyage) {
+// TopiaSQLQuery<Long> query = new TopiaSQLQuery<Long>() {
+// @Override
+// protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
+// String hql = "SELECT count(c.topiaid) FROM Transit ta, " +
+// " Transect te, " +
+// " DataAcquisition da, " +
+// " DataProcessing dp, " +
+// " Cell c " +
+// "WHERE ta.voyage = ? " +
+// "AND ta.topiaId = te.transit " +
+// "AND te.topiaId = da.transect " +
+// "AND da.topiaId = dp.dataacquisition " +
+// "AND dp.topiaId = c.dataprocessing";
+// PreparedStatement result = connection.prepareStatement(hql);
+// result.setString(1, voyage.getTopiaId());
+// return result;
+// }
+//
+// @Override
+// protected Long prepareResult(ResultSet set) throws SQLException {
+// return set.getLong(1);
+// }
+// };
+// try {
+// Long result = getEchoBasePersistenceContext().findSingleResult(query);
+// return result;
+// } catch (TopiaException e) {
+// throw new EchoBaseTechnicalException(e);
+// }
+// }
- @Override
- protected Long prepareResult(ResultSet set) throws SQLException {
- return set.getLong(1);
- }
- };
- try {
- Long result = getEchoBasePersistenceContext().findSingleResult(query);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException(e);
- }
- }
-
protected void removeVoyageOrphanCells() throws TopiaException {
- // Get all cells of the voyage
- TopiaSQLQuery<String> query = new TopiaSQLQuery<String>() {
- @Override
- protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
- String hql = "SELECT c.topiaid FROM Cell c " +
- "WHERE c.cell IS NULL AND c.dataprocessing IS NULL AND c.voyage IS NULL";
- PreparedStatement result = connection.prepareStatement(hql);
- return result;
- }
- @Override
- protected String prepareResult(ResultSet set) throws SQLException {
- return set.getString(1);
- }
- };
-
- List<String> cellIds = getEchoBasePersistenceContext().findMultipleResult(query);
+ List<String> cellIds = persistenceService.getVoyageCellIds();
for (String cellId : cellIds) {
-
- Cell cell = cellDAO.findByTopiaId(cellId);
- cellDAO.delete(cell);
+ Cell cell = persistenceService.getCell(cellId);
+ persistenceService.deleteCell(cell);
incrementOp("Remove orphan cell " + cellId);
}
}
- protected long countVoyageOrphanCells(final Voyage voyage) {
- TopiaSQLQuery<Long> query = new TopiaSQLQuery<Long>() {
- @Override
- protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
- String hql = "SELECT count(c2.topiaid) FROM Transit ta, " +
- " Transect te, " +
- " DataAcquisition da, " +
- " DataProcessing dp, " +
- " Cell c, Cell c2 " +
- "WHERE ta.voyage = ? " +
- "AND ta.topiaId = te.transit " +
- "AND te.topiaId = da.transect " +
- "AND da.topiaId = dp.dataacquisition " +
- "AND dp.topiaId = c.dataprocessing " +
- "AND c.topiaId = c2.cell";
- PreparedStatement result = connection.prepareStatement(hql);
- result.setString(1, voyage.getTopiaId());
- return result;
- }
-
- @Override
- protected Long prepareResult(ResultSet set) throws SQLException {
- return set.getLong(1);
- }
- };
- try {
- Long result = getEchoBasePersistenceContext().findSingleResult(query);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException(e);
- }
- }
-
- private List<Category> getCategoryUsingEchotype(final Voyage voyage) throws TopiaException {
- String hql = "SELECT DISTINCT c FROM VoyageImpl v, CategoryImpl c WHERE " +
- "v = :voyage AND c.echotype in elements(v.echotype)";
- List<Category> result = categoryDAO.findAllByQuery(hql, "voyage", voyage);
- return result;
- }
-
-
- protected long countCategoryUsingEchotype(final Voyage voyage) {
- String hql = "SELECT COUNT(DISTINCT c) FROM VoyageImpl v, CategoryImpl c WHERE " +
- "v = :voyage AND c.echotype in elements(v.echotype)";
- try {
- long result = categoryDAO.countByQuery(hql, "voyage", voyage);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException(e);
- }
- }
-
public void incrementOp(String message) {
opIndex++;
if (opIndex % 1000 == 0) {
- getEchoBasePersistenceContext().flush();
+ persistenceService.flush();
}
progressModel.incrementsProgress();
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/AcousticRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/AcousticRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/AcousticRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,12 +28,9 @@
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.DataAcquisition;
-import fr.ifremer.echobase.entities.data.DataAcquisitionDAO;
import fr.ifremer.echobase.entities.data.DataProcessing;
import fr.ifremer.echobase.entities.data.Transect;
-import fr.ifremer.echobase.entities.data.TransectDAO;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
@@ -54,31 +51,19 @@
private static final Log log =
LogFactory.getLog(AcousticRemoveDataStrategy.class);
- protected DataAcquisitionDAO dataAcquisitionDAO;
-
- protected TransectDAO transectDAO;
-
@Override
- public void setServiceContext(EchoBaseServiceContext serviceContext) {
- super.setServiceContext(serviceContext);
-
- dataAcquisitionDAO = getEchoBasePersistenceContext().getDataAcquisitionDAO();
- transectDAO = getEchoBasePersistenceContext().getTransectDAO();
- }
-
- @Override
public long computeNbSteps(Voyage voyage, ImportLog importLog) {
long result = importLog.sizeImportId();
// add all cell results
- result += countVoyageCellResults(voyage);
+ result += persistenceService.countVoyageCellResults(voyage);
// add all postCell
result += voyage.sizePostCell();
// add all orphan cells
- result += countVoyageOrphanCells(voyage);
+ result += persistenceService.countVoyageOrphanCells(voyage);
return result;
}
@@ -105,31 +90,31 @@
if (id.startsWith(DataAcquisition.class.getName())) {
// get dataAcquisition
- DataAcquisition dataAcquisition = dataAcquisitionDAO.findByTopiaId(id);
+ DataAcquisition dataAcquisition = persistenceService.getDataAcquisition(id);
// remove it from cell
- Transect transect = transectDAO.findContainsDataAcquisition(dataAcquisition);
+ Transect transect = persistenceService.getTransectContainsDataAcquisition(dataAcquisition);
transect.removeDataAcquisition(dataAcquisition);
// remove dataAcquisition
- dataAcquisitionDAO.delete(dataAcquisition);
+ persistenceService.deleteDataAcquisition(dataAcquisition);
if (log.isDebugEnabled()) {
log.debug(dataAcquisition.getTopiaId() + " was removed");
}
} else if (id.startsWith(Cell.class.getName())) {
// get cell
- Cell cell = cellDAO.findByTopiaId(id);
+ Cell cell = persistenceService.getCell(id);
if (cell == null) {
throw new IllegalStateException("Could not find cell " + id);
}
// remove it from the dataAcquisition
- DataProcessing dataProcessing = dataProcessingDAO.findContainsCell(cell);
+ DataProcessing dataProcessing = persistenceService.getDataProcessingContainsCell(cell);
dataProcessing.removeCell(cell);
// remove cell
- cellDAO.delete(cell);
+ persistenceService.deleteCell(cell);
if (log.isDebugEnabled()) {
log.debug(cell.getTopiaId() + " was removed");
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CatchesRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CatchesRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CatchesRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -26,11 +26,8 @@
import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Operation;
-import fr.ifremer.echobase.entities.data.OperationDAO;
import fr.ifremer.echobase.entities.data.Sample;
-import fr.ifremer.echobase.entities.data.SampleDAO;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
@@ -52,18 +49,7 @@
private static final Log log =
LogFactory.getLog(CatchesRemoveDataStrategy.class);
- protected SampleDAO sampleDAO;
-
- protected OperationDAO operationDAO;
-
@Override
- public void setServiceContext(EchoBaseServiceContext serviceContext) {
- super.setServiceContext(serviceContext);
- sampleDAO = getEchoBasePersistenceContext().getSampleDAO();
- operationDAO = getEchoBasePersistenceContext().getOperationDAO();
- }
-
- @Override
public long computeNbSteps(Voyage voyage, ImportLog importLog) {
long result = importLog.sizeImportId();
return result;
@@ -75,14 +61,14 @@
if (id.startsWith(Sample.class.getName())) {
// get sample
- Sample sample = sampleDAO.findByTopiaId(id);
+ Sample sample = persistenceService.getSample(id);
// remove it from operation
- Operation operation = operationDAO.findContainsSample(sample);
+ Operation operation = persistenceService.getOperationContainsSample(sample);
operation.removeSample(sample);
// remove sample
- sampleDAO.delete( sample);
+ persistenceService.deleteSample(sample);
if (log.isDebugEnabled()) {
log.debug(sample.getTopiaId() + " was removed");
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonAllRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonAllRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonAllRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -60,10 +60,10 @@
long result = importLog.sizeImportId();
// add all categories to be removed after
- result += countCategoryUsingEchotype(voyage);
+ result += persistenceService.countCategoryUsingEchotype(voyage);
// add all orphan cells
- result += countVoyageOrphanCells(voyage);
+ result += persistenceService.countVoyageOrphanCells(voyage);
return result;
}
@@ -73,7 +73,7 @@
if (id.startsWith(Voyage.class.getName())) {
// get entity to delete
- Voyage entity = voyageDao.findByTopiaId(id);
+ Voyage entity = persistenceService.getVoyage(id);
// delete it
removeVoyage(entity);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonTransectRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonTransectRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonTransectRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -27,11 +27,8 @@
import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Transect;
-import fr.ifremer.echobase.entities.data.TransectDAO;
import fr.ifremer.echobase.entities.data.Transit;
-import fr.ifremer.echobase.entities.data.TransitDAO;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
@@ -52,31 +49,19 @@
private static final Log log =
LogFactory.getLog(CommonTransectRemoveDataStrategy.class);
- protected TransectDAO transectDAO;
-
- protected TransitDAO transitDAO;
-
@Override
- public void setServiceContext(EchoBaseServiceContext serviceContext) {
- super.setServiceContext(serviceContext);
-
- transectDAO = getEchoBasePersistenceContext().getTransectDAO();
- transitDAO = getEchoBasePersistenceContext().getTransitDAO();
- }
-
- @Override
public long computeNbSteps(Voyage voyage, ImportLog importLog) {
long result = importLog.sizeImportId();
// add all cell results
- result += countVoyageCellResults(voyage);
+ result += persistenceService.countVoyageCellResults(voyage);
// add all postCell
result += voyage.sizePostCell();
// add all orphan cells
- result += countVoyageOrphanCells(voyage);
+ result += persistenceService.countVoyageOrphanCells(voyage);
return result;
}
@@ -103,14 +88,14 @@
if (id.startsWith(Transect.class.getName())) {
// remove transect
- Transect transect = transectDAO.findByTopiaId(id);
+ Transect transect = persistenceService.getTransect(id);
// remove it from transit
- Transit transit = transitDAO.findContainsTransect(transect);
+ Transit transit = persistenceService.getTransitContainsTransect(transect);
transit.removeTransect(transect);
// delete it
- transectDAO.delete( transect);
+ persistenceService.deleteTransect(transect);
if (log.isDebugEnabled()) {
log.debug(transect.getTopiaId() + " was removed");
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonTransitRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonTransitRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonTransitRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -26,9 +26,7 @@
import com.google.common.collect.Sets;
import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.TransectDAO;
import fr.ifremer.echobase.entities.data.Transit;
-import fr.ifremer.echobase.entities.data.TransitDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
@@ -51,31 +49,19 @@
private static final Log log =
LogFactory.getLog(CommonTransectRemoveDataStrategy.class);
- protected TransectDAO transectDAO;
-
- protected TransitDAO transitDAO;
-
@Override
- public void setServiceContext(EchoBaseServiceContext serviceContext) {
- super.setServiceContext(serviceContext);
-
- transectDAO = getEchoBasePersistenceContext().getTransectDAO();
- transitDAO = getEchoBasePersistenceContext().getTransitDAO();
- }
-
- @Override
public long computeNbSteps(Voyage voyage, ImportLog importLog) {
long result = importLog.sizeImportId();
// add all cell results
- result += countVoyageCellResults(voyage);
+ result += persistenceService.countVoyageCellResults(voyage);
// add all postCell
result += voyage.sizePostCell();
// add all orphan cells
- result += countVoyageOrphanCells(voyage);
+ result += persistenceService.countVoyageOrphanCells(voyage);
return result;
}
@@ -102,15 +88,15 @@
if (id.startsWith(Transit.class.getName())) {
// remove transit
- Transit transit = transitDAO.findByTopiaId(id);
+ Transit transit = persistenceService.getTransit(id);
// remove it from voyage
- Voyage entity = voyageDao.findByTopiaId(voyage.getTopiaId());
+ Voyage entity = persistenceService.getVoyage(voyage.getTopiaId());
entity.removeTransit(transit);
// delete it
- transitDAO.delete( transit);
+ persistenceService.deleteTransit(transit);
if (log.isDebugEnabled()) {
log.debug(transit.getTopiaId() + " was removed");
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonVoyageRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonVoyageRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/CommonVoyageRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -61,10 +61,10 @@
long result = importLog.sizeImportId();
// add all categories to be removed after
- result += countCategoryUsingEchotype(voyage);
+ result += persistenceService.countCategoryUsingEchotype(voyage);
// add all orphan cells
- result += countVoyageOrphanCells(voyage);
+ result += persistenceService.countVoyageOrphanCells(voyage);
return result;
}
@@ -74,7 +74,7 @@
if (id.startsWith(Voyage.class.getName())) {
// get entity to delete
- Voyage entity = voyageDao.findByTopiaId(id);
+ Voyage entity = persistenceService.getVoyage(id);
// delete it
removeVoyage(entity);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/LegacyVoyageRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/LegacyVoyageRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/LegacyVoyageRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -60,10 +60,10 @@
long result = importLog.sizeImportId();
// add all categories to be removed after
- result += countCategoryUsingEchotype(voyage);
+ result += persistenceService.countCategoryUsingEchotype(voyage);
// add all orphan cells
- result += countVoyageOrphanCells(voyage);
+ result += persistenceService.countVoyageOrphanCells(voyage);
return result;
}
@@ -73,7 +73,7 @@
if (id.startsWith(Voyage.class.getName())) {
// get entity to delete
- Voyage entity = voyageDao.findByTopiaId(id);
+ Voyage entity = persistenceService.getVoyage(id);
// delete it
removeVoyage(entity);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/OperationRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/OperationRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/OperationRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -27,11 +27,8 @@
import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Operation;
-import fr.ifremer.echobase.entities.data.OperationDAO;
import fr.ifremer.echobase.entities.data.Transect;
-import fr.ifremer.echobase.entities.data.TransectDAO;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
@@ -52,19 +49,7 @@
private static final Log log =
LogFactory.getLog(OperationRemoveDataStrategy.class);
- protected OperationDAO operationDAO;
-
- protected TransectDAO transectDAO;
-
@Override
- public void setServiceContext(EchoBaseServiceContext serviceContext) {
- super.setServiceContext(serviceContext);
-
- operationDAO = getEchoBasePersistenceContext().getOperationDAO();
- transectDAO = getEchoBasePersistenceContext().getTransectDAO();
- }
-
- @Override
public long computeNbSteps(Voyage voyage, ImportLog importLog) {
long result = importLog.sizeImportId();
@@ -77,14 +62,14 @@
if (id.startsWith(Operation.class.getName())) {
// get operation
- Operation operation = operationDAO.findByTopiaId(id);
+ Operation operation = persistenceService.getOperation(id);
// remove it from transect
- Transect transect = transectDAO.findContainsOperation(operation);
+ Transect transect = persistenceService.getTransectContainsOperation(operation);
transect.removeOperation(operation);
// remove it
- operationDAO.delete( operation);
+ persistenceService.deleteOperation(operation);
if (log.isDebugEnabled()) {
log.debug(operation.getTopiaId() + " was removed");
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultEsduRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultEsduRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultEsduRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -62,14 +62,14 @@
if (id.startsWith(Result.class.getName())) {
// get result
- Result result = resultDAO.findByTopiaId(id);
+ Result result = persistenceService.getResult(id);
// remove it from cell
- Cell cell = cellDAO.findContainsResult(result);
+ Cell cell = persistenceService.getCellContainsResult(result);
cell.removeResult(result);
// remove result
- resultDAO.delete( result);
+ persistenceService.deleteResult(result);
if (log.isDebugEnabled()) {
log.debug(result.getTopiaId() + " was removed");
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultMapFishRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultMapFishRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultMapFishRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -61,7 +61,7 @@
if (id.startsWith(Cell.class.getName())) {
// get cell
- Cell cell = cellDAO.findByTopiaId(id);
+ Cell cell = persistenceService.getCell(id);
// dettach cell childs, we do not want to delete them from here ?
cell.clearChilds();
@@ -70,7 +70,7 @@
voyage.removePostCell(cell);
// remove cell
- cellDAO.delete( cell);
+ persistenceService.deleteCell(cell);
if (log.isDebugEnabled()) {
log.debug(cell.getTopiaId() + " was removed");
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultMapOtherRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultMapOtherRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultMapOtherRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -61,7 +61,7 @@
if (id.startsWith(Cell.class.getName())) {
// get cell
- Cell cell = cellDAO.findByTopiaId(id);
+ Cell cell = persistenceService.getCell(id);
// dettach cell childs, we do not want to delete them from here ?
cell.clearChilds();
@@ -70,7 +70,7 @@
voyage.removePostCell(cell);
// remove cell
- cellDAO.delete(cell);
+ persistenceService.deleteCell(cell);
if (log.isDebugEnabled()) {
log.debug(cell.getTopiaId() + " was removed");
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultRegionRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultRegionRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultRegionRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -61,7 +61,7 @@
if (id.startsWith(Cell.class.getName())) {
// get cell
- Cell cell = cellDAO.findByTopiaId(id);
+ Cell cell = persistenceService.getCell(id);
// dettach cell childs, we do not want to delete them from here ?
cell.clearChilds();
@@ -70,7 +70,7 @@
voyage.removePostCell(cell);
// remove cell
- cellDAO.delete(cell);
+ persistenceService.deleteCell(cell);
if (log.isDebugEnabled()) {
log.debug(cell.getTopiaId() + " was removed");
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultVoyageRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultVoyageRemoveDataStrategy.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/removedata/strategy/ResultVoyageRemoveDataStrategy.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -59,7 +59,7 @@
long result = importLog.sizeImportId();
// add all cell results
- result += countVoyageCellResults(voyage);
+ result += persistenceService.countVoyageCellResults(voyage);
// add all postCell
result += voyage.sizePostCell();
@@ -80,11 +80,11 @@
if (id.startsWith(Echotype.class.getName())) {
// remove echotype
- Echotype echotype = echotypeDAO.findByTopiaId(id);
+ Echotype echotype = persistenceService.getEchotype(id);
// delete all categories using this echotype
- List<Category> allByEchotype = categoryDAO.findAllByEchotype(echotype);
- categoryDAO.deleteAll(allByEchotype);
+ List<Category> allByEchotype = persistenceService.getCategorysByEchotype(echotype);
+ persistenceService.deleteCategories(allByEchotype);
if (voyage != null) {
@@ -93,7 +93,7 @@
}
// delete echotype
- echotypeDAO.delete(echotype);
+ persistenceService.deleteEchotype(echotype);
incrementOp("Remove echotype " + echotype.getTopiaId());
@@ -103,9 +103,9 @@
} else if (id.startsWith(LengthAgeKey.class.getName())) {
// remove lengthAgeKey
- LengthAgeKey lengthAgeKey = lengthAgeKeyDAO.findByTopiaId(id);
+ LengthAgeKey lengthAgeKey = persistenceService.getLengthAgeKey(id);
- lengthAgeKeyDAO.delete(lengthAgeKey);
+ persistenceService.deleteLengthAgeKey(lengthAgeKey);
if (voyage != null) {
@@ -120,9 +120,9 @@
} else if (id.startsWith(LengthWeightKey.class.getName())) {
// remove lengthWeightKey
- LengthWeightKey lengthWeightKey = lengthWeightKeyDAO.findByTopiaId(id);
+ LengthWeightKey lengthWeightKey = persistenceService.getLengthWeightKey(id);
- lengthWeightKeyDAO.delete(lengthWeightKey);
+ persistenceService.deleteLengthWeightKey(lengthWeightKey);
if (voyage != null) {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -23,8 +23,8 @@
* #L%
*/
-import com.google.common.base.Charsets;
import com.google.common.base.Function;
+import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
@@ -34,12 +34,10 @@
import com.google.common.collect.Sets;
import fr.ifremer.echobase.EchoBaseFunctions;
import fr.ifremer.echobase.EchoBaseTechnicalException;
-import fr.ifremer.echobase.entities.TopiaEchoBasePersistenceContext;
+import fr.ifremer.echobase.entities.EchoBasePersistenceContext;
import fr.ifremer.echobase.entities.data.Category;
-import fr.ifremer.echobase.entities.data.CellDAO;
import fr.ifremer.echobase.entities.data.Echotype;
import fr.ifremer.echobase.entities.data.Result;
-import fr.ifremer.echobase.entities.data.ResultDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.references.CellType;
import fr.ifremer.echobase.entities.references.DataMetadata;
@@ -47,22 +45,22 @@
import fr.ifremer.echobase.entities.spatial.CellPoint;
import fr.ifremer.echobase.entities.spatial.SpatialConfiguration;
import fr.ifremer.echobase.entities.spatial.SpatialData;
+import fr.ifremer.echobase.io.EchoBaseIOUtil;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.persistence.TopiaEntities;
import org.nuiton.util.TimeLog;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
- * TODO
+ * Spatial service.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.2
@@ -74,42 +72,29 @@
public static final TimeLog TILE_LOG = new TimeLog(SpatialService.class);
- public static final String POSTGIS_STRUCTURE_SQL = "postgis-structure.sql";
+ private WorkingDbPersistenceService persistenceService;
- public void addSpatialStructure() {
- // get sql file
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ super.setServiceContext(serviceContext);
+ persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+ }
- InputStream inputStream =
- getClass().getResourceAsStream("/" + POSTGIS_STRUCTURE_SQL);
+ public void addSpatialSupport() {
- Preconditions.checkNotNull(
- inputStream,
- "Could not find resource in classpath " + POSTGIS_STRUCTURE_SQL);
+ // add spatial structure
+ executeSqlScript(EchoBasePersistenceContext.POSTGIS_STRUCTURE_SQL);
- String sql;
- try {
- sql = IOUtils.toString(inputStream, Charsets.UTF_8);
- } catch (IOException e) {
- throw new EchoBaseTechnicalException(
- "Could not load sql file " + POSTGIS_STRUCTURE_SQL, e);
- }
+ // add spatial views
+ executeSqlScript(EchoBasePersistenceContext.POSTGIS_VIEW_SQL);
- if (log.isInfoEnabled()) {
- log.info("Will execute sql file " + POSTGIS_STRUCTURE_SQL);
- }
-
- try {
- getEchoBasePersistenceContext().executeSQL(sql);
- getEchoBasePersistenceContext().commitTransaction();
- } catch (Exception e) {
- throw new EchoBaseTechnicalException(
- "Could not execute sql file " + POSTGIS_STRUCTURE_SQL, e);
- }
+ // do commit
+ persistenceService.commit();
}
public Set<SpatialData> getSpatialData(SpatialConfiguration model) {
- Set<SpatialData> result = null;
+ Set<SpatialData> result;
String voyageId = model.getVoyageId();
@@ -119,40 +104,38 @@
String speciesId = model.getSpeciesId();
String echotypeId = model.getEchotypeId();
- TopiaEchoBasePersistenceContext persistenceContext = getEchoBasePersistenceContext();
+ Voyage voyage = persistenceService.getVoyage(voyageId);
- Voyage voyage = persistenceContext.getEntityById(Voyage.class, voyageId);
-
Preconditions.checkNotNull(
voyage,
"Could not find voyage with id " + voyageId);
DataMetadata dataMetadata =
- persistenceContext.getEntityById(DataMetadata.class, dataMetadataId);
+ persistenceService.getDataMetadata(dataMetadataId);
Preconditions.checkNotNull(
dataMetadata,
"Could not find dataMetadata with id " + dataMetadataId);
CellType cellType =
- persistenceContext.getEntityById(CellType.class, cellTypeId);
+ persistenceService.getCellType(cellTypeId);
Preconditions.checkNotNull(
cellType,
"Could not find cellType with id " + cellTypeId);
- Species species =
- persistenceContext.getEntityOrNullById(Species.class, speciesId);
+ Optional<Species> species =
+ persistenceService.getOptionalSpecies(speciesId);
- Echotype echotype =
- persistenceContext.getEntityOrNullById(Echotype.class, echotypeId);
+ Optional<Echotype> echotype =
+ persistenceService.getOptionalEchotype(echotypeId);
List<Predicate<Category>> predicates = Lists.newArrayList();
- if (species != null) {
- predicates.add(newSpeciesCategoryPredicate(species));
+ if (species.isPresent()) {
+ predicates.add(newSpeciesCategoryPredicate(species.get()));
}
- if (echotype != null) {
- predicates.add(newEchotypeCategoryPredicate(echotype));
+ if (echotype.isPresent()) {
+ predicates.add(newEchotypeCategoryPredicate(echotype.get()));
}
Predicate<Category> acceptPredicate = Predicates.or(predicates);
@@ -162,6 +145,23 @@
return result;
}
+ protected void executeSqlScript(String scriptPath) {
+
+ // get sql script
+ String sql = EchoBaseIOUtil.loadScript(scriptPath);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will execute sql file " + scriptPath);
+ }
+
+ try {
+ persistenceService.executeSQL(sql);
+ } catch (Exception e) {
+ throw new EchoBaseTechnicalException(
+ "Could not execute sql file " + scriptPath, e);
+ }
+ }
+
protected Set<SpatialData> getSpatialData(Voyage voyage,
DataMetadata requiredDataMetadata,
CellType cellType,
@@ -171,19 +171,14 @@
// get possible category
List<String> categoryIds = Lists.newArrayList(
- Iterables.transform(
- Iterables.filter(
- getEchoBasePersistenceContext().getCategoryDAO(),
- acceptPredicate),
- TopiaEntities.GET_TOPIA_ID));
+ Iterables.transform(persistenceService.getCategories(acceptPredicate),
+ TopiaEntities.GET_TOPIA_ID));
- CellDAO dao = getEchoBasePersistenceContext().getCellDAO();
- ResultDAO resultDao = getEchoBasePersistenceContext().getResultDAO();
boolean filterByCategory = CollectionUtils.isNotEmpty(categoryIds);
// get all cell with spatial points
- List<CellPoint> voyageCellPoints = dao.getVoyageCellPoints(voyage, cellType);
+ List<CellPoint> voyageCellPoints = persistenceService.getVoyageCellPoints(voyage, cellType);
int nbCells = voyageCellPoints.size();
s0 = TILE_LOG.log(s0, String.format("Get cell points (%s)", nbCells));
@@ -194,21 +189,17 @@
s0 = TILE_LOG.log(s0, String.format("Get cell points list and map (%s)", nbCells));
- String query = resultDao.createSimpleQuery(null) + " WHERE cell.id IN :cell AND dataMetadata = :dataMetadata";
-
List<Result> results;
if (filterByCategory) {
- results = resultDao.findAllByQuery(
- query + " AND category.id IN :category",
- Result.PROPERTY_CELL, cellIds,
- Result.PROPERTY_DATA_METADATA, requiredDataMetadata,
- Result.PROPERTY_CATEGORY, categoryIds);
+ results = persistenceService.getAllWithCategoryCellAndDataMetadata(
+ cellIds,
+ requiredDataMetadata,
+ categoryIds);
} else {
- results = resultDao.findAllByQuery(
- query + " AND category IS NULL",
- Result.PROPERTY_CELL, cellIds,
- Result.PROPERTY_DATA_METADATA, requiredDataMetadata);
+ results = persistenceService.getAllWithNoCategoryCellAndDataMetadata(
+ cellIds,
+ requiredDataMetadata);
}
@@ -254,12 +245,12 @@
}
public boolean isSpatialAware() {
- boolean result = getEchoBasePersistenceContext().isSpatialAware();
+ boolean result = persistenceService.isSpatialAware();
return result;
}
public boolean isPostgresql() {
- boolean result = getEchoBasePersistenceContext().isPostgresql();
+ boolean result = persistenceService.isPostgresql();
return result;
}
@@ -278,12 +269,12 @@
if (log.isInfoEnabled()) {
log.info("Will try to compute operation spatial data from temp table...");
}
- getEchoBasePersistenceContext().executeSQL("SELECT echobase_fill_operation_spatial_table();");
+ persistenceService.executeSQL("SELECT echobase_fill_operation_spatial_table();");
if (log.isInfoEnabled()) {
log.info("Will try to compute cell spatial data from temp table...");
}
- getEchoBasePersistenceContext().executeSQL("SELECT echobase_fill_cell_spatial_table();");
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.executeSQL("SELECT echobase_fill_cell_spatial_table();");
+ persistenceService.commit();
} catch (Exception e) {
if (log.isErrorEnabled()) {
log.error("Could not compute spatial data", e);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/workingDb/WorkingDbConfigurationService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/workingDb/WorkingDbConfigurationService.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/workingDb/WorkingDbConfigurationService.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -162,7 +162,7 @@
log.info("Create new postgres database: " + dbName +
" with sql statement: " + sql);
}
- getEchoBasePersistenceContext().getContext().getHibernateSession().doWork(
+ serviceContext.getEchoBasePersistenceContext().getContext().getHibernateSession().doWork(
new AbstractTopiaContext.SQLWork(sql) {
@Override
public void execute(Connection connection) throws SQLException {
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -213,7 +213,7 @@
protected <E extends TopiaEntity> void assertNbEntities(Class<E> entityType,
int expectedNumber) throws TopiaException {
- long count = getEchoBasePersistenceContext().getDAO(entityType).count();
+ long count = serviceContext.getEchoBasePersistenceContext().getDAO(entityType).count();
Assert.assertEquals(count, expectedNumber);
}
@@ -224,14 +224,14 @@
}
protected String getVoyageId() {
- Voyage voyage = getEchoBasePersistenceContext().getVoyageDAO().findAll().get(0);
+ Voyage voyage = serviceContext.getEchoBasePersistenceContext().getVoyageDAO().findAll().get(0);
Preconditions.checkNotNull(voyage);
return voyage.getTopiaId();
}
protected String getTransitId(String voyageId) {
Preconditions.checkNotNull(voyageId);
- Voyage voyage = getEchoBasePersistenceContext().getVoyageDAO().findByTopiaId(voyageId);
+ Voyage voyage = serviceContext.getEchoBasePersistenceContext().getVoyageDAO().findByTopiaId(voyageId);
Preconditions.checkArgument(!voyage.isTransitEmpty());
List<Transit> transits = voyage.getTransit();
Transit transit = transits.get(0);
@@ -239,7 +239,7 @@
}
protected String getDataProcessingId() {
- DataProcessing dataProcessing = getEchoBasePersistenceContext().getDataProcessingDAO().findAll().get(0);
+ DataProcessing dataProcessing = serviceContext.getEchoBasePersistenceContext().getDataProcessingDAO().findAll().get(0);
Preconditions.checkNotNull(dataProcessing);
return dataProcessing.getTopiaId();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FixCellsIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FixCellsIT.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FixCellsIT.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -28,6 +28,7 @@
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.Data;
import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import fr.ifremer.echobase.services.service.importdata.AcousticImportConfiguration;
import fr.ifremer.echobase.services.service.importdata.AcousticImportService;
import fr.ifremer.echobase.services.service.importdata.CellPositionReference;
@@ -180,8 +181,10 @@
protected void fixCellDatas() throws TopiaException, ParseException {
int nb = 0;
- TopiaDAO<Cell> cellDAO = getEchoBasePersistenceContext().getCellDAO();
+ TopiaDAO<Cell> cellDAO = serviceContext.getEchoBasePersistenceContext().getCellDAO();
+ WorkingDbPersistenceService persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+
long nbCells = cellDAO.count();
for (Cell cell : cellDAO) {
@@ -205,24 +208,27 @@
if (log.isInfoEnabled()) {
log.info("Flush at " + nb + "/" + nbCells);
}
- getEchoBasePersistenceContext().flush();
+ persistenceService.flush();
}
}
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.commit();
}
private void exportDatabase() throws TopiaException, IOException {
- TopiaDAO<Voyage> voyageDAO = getEchoBasePersistenceContext().getVoyageDAO();
+ TopiaDAO<Voyage> voyageDAO = serviceContext.getEchoBasePersistenceContext().getVoyageDAO();
+ WorkingDbPersistenceService persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+ long nbVoyages = persistenceService.countVoyage();
+
Voyage voyage;
- if (voyageDAO.count() == 0) {
+ if (nbVoyages == 0) {
// crate voyage
- voyage = voyageDAO.create(Voyage.PROPERTY_MISSION, getEchoBasePersistenceContext().getMissionDAO().findAll().get(0),
+ voyage = voyageDAO.create(Voyage.PROPERTY_MISSION, serviceContext.getEchoBasePersistenceContext().getMissionDAO().findAll().get(0),
Voyage.PROPERTY_NAME, "name",
Voyage.PROPERTY_START_DATE, newDate(),
Voyage.PROPERTY_END_DATE, newDate(),
@@ -232,12 +238,12 @@
Voyage.PROPERTY_DATUM, "datum"
);
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.commit();
} else {
voyage = voyageDAO.findAll().get(0);
}
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceService.commit();
exportDb(voyage, "fixCells");
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/exportdb/ExportDbServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/exportdb/ExportDbServiceTest.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/exportdb/ExportDbServiceTest.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -42,6 +42,7 @@
import fr.ifremer.echobase.io.EchoBaseIOUtil;
import fr.ifremer.echobase.services.EchoBaseTestServiceSupport;
import fr.ifremer.echobase.services.FakeEchoBaseServiceContext;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -79,22 +80,23 @@
public void setUp() throws Exception {
super.setUp();
- TopiaDAO<DataProcessing> dataProcessingDAO = getEchoBasePersistenceContext().getDataProcessingDAO();
- TopiaDAO<DataAcquisition> dataAcquisitionDAO = getEchoBasePersistenceContext().getDataAcquisitionDAO();
- TopiaDAO<Cell> cellDAO = getEchoBasePersistenceContext().getCellDAO();
- TopiaDAO<Category> categoryDAO = getEchoBasePersistenceContext().getCategoryDAO();
- TopiaDAO<Result> resultDAO = getEchoBasePersistenceContext().getResultDAO();
- TopiaDAO<SpeciesCategory> speciesCategoryDAO = getEchoBasePersistenceContext().getSpeciesCategoryDAO();
- TopiaDAO<Data> dataDAO = getEchoBasePersistenceContext().getDataDAO();
+ TopiaDAO<DataProcessing> dataProcessingDAO = serviceContext.getEchoBasePersistenceContext().getDataProcessingDAO();
+ TopiaDAO<DataAcquisition> dataAcquisitionDAO = serviceContext.getEchoBasePersistenceContext().getDataAcquisitionDAO();
+ TopiaDAO<Cell> cellDAO = serviceContext.getEchoBasePersistenceContext().getCellDAO();
+ TopiaDAO<Category> categoryDAO = serviceContext.getEchoBasePersistenceContext().getCategoryDAO();
+ TopiaDAO<Result> resultDAO = serviceContext.getEchoBasePersistenceContext().getResultDAO();
+ TopiaDAO<SpeciesCategory> speciesCategoryDAO = serviceContext.getEchoBasePersistenceContext().getSpeciesCategoryDAO();
+ TopiaDAO<Data> dataDAO = serviceContext.getEchoBasePersistenceContext().getDataDAO();
+ WorkingDbPersistenceService persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
- Voyage voyage = getEchoBasePersistenceContext().getEntityById(Voyage.class, getVoyageId());
+ Voyage voyage = persistenceService.getVoyage(getVoyageId());
Assert.assertNotNull(voyage);
Transect transect = voyage.getTransit().get(0).getTransect().get(0);
Assert.assertNotNull(transect);
- List<AcousticInstrument> acousticInstruments = getEchoBasePersistenceContext().getAcousticInstrumentDAO().findAll();
+ List<AcousticInstrument> acousticInstruments = serviceContext.getEchoBasePersistenceContext().getAcousticInstrumentDAO().findAll();
Assert.assertTrue(CollectionUtils.isNotEmpty(acousticInstruments));
AcousticInstrument acousticInstrument = acousticInstruments.get(0);
DataAcquisition dataAcquisition = dataAcquisitionDAO.create(
@@ -107,11 +109,11 @@
);
dataAcquisition.addDataProcessing(dataProcessing);
- List<Species> speciesList = getEchoBasePersistenceContext().getSpeciesDAO().findAll();
+ List<Species> speciesList = serviceContext.getEchoBasePersistenceContext().getSpeciesDAO().findAll();
Assert.assertTrue(CollectionUtils.isNotEmpty(speciesList));
Species species = speciesList.get(0);
- List<DataMetadata> dataMetadatas = getEchoBasePersistenceContext().getDataMetadataDAO().findAll();
+ List<DataMetadata> dataMetadatas = serviceContext.getEchoBasePersistenceContext().getDataMetadataDAO().findAll();
Assert.assertTrue(CollectionUtils.isNotEmpty(dataMetadatas));
DataMetadata dataMetadata = dataMetadatas.get(0);
@@ -123,7 +125,7 @@
Category.PROPERTY_SPECIES_CATEGORY, speciesCategory
);
- List<CellType> cellTypes = getEchoBasePersistenceContext().getCellTypeDAO().findAll();
+ List<CellType> cellTypes = serviceContext.getEchoBasePersistenceContext().getCellTypeDAO().findAll();
Assert.assertTrue(CollectionUtils.isNotEmpty(cellTypes));
CellType cellType = cellTypes.get(0);
@@ -192,7 +194,7 @@
);
postCell.addResult(postCellResult);
- getEchoBasePersistenceContext().commitTransaction();
+ serviceContext.getEchoBasePersistenceContext().commitTransaction();
}
@Test
@@ -297,7 +299,7 @@
}
ZipEntry zipEntry = entry.getValue();
long nbCells = EchoBaseIOUtil.countLines(zipFile, Sets.newHashSet(zipEntry));
- Assert.assertEquals(1 + getEchoBasePersistenceContext().getDAO(type.getEntityType()).count(), nbCells);
+ Assert.assertEquals(1 + serviceContext.getEchoBasePersistenceContext().getDAO(type.getEntityType()).count(), nbCells);
}
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataServiceIT.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataServiceIT.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -49,6 +49,7 @@
import fr.ifremer.echobase.entities.references.CellTypeDAO;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.EchoBaseTestServiceSupport;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
@@ -152,8 +153,11 @@
String voyageId,
InputFile inputFile) throws TopiaException {
+
+ WorkingDbPersistenceService persistenceService = serviceContext.newService(WorkingDbPersistenceService.class);
+
ResultsImportService service = newService(ResultsImportService.class);
- Voyage voyage = getWorkingDbPersistenceService().getVoyageDAO().findByTopiaId(voyageId);
+ Voyage voyage = persistenceService.getVoyage(voyageId);
Transit transit;
Transect transect;
DataAcquisition dataAcquisition;
@@ -162,7 +166,7 @@
if (voyage.isTransitEmpty()) {
// create a fake transit
- transit = getEchoBasePersistenceContext().getTransitDAO().create();
+ transit = serviceContext.getEchoBasePersistenceContext().getTransitDAO().create();
voyage.addTransit(transit);
} else {
transit = voyage.getTransit().get(0);
@@ -171,7 +175,7 @@
if (transit.isTransectEmpty()) {
// create a fake transect
- transect = getEchoBasePersistenceContext().getTransectDAO().create();
+ transect = serviceContext.getEchoBasePersistenceContext().getTransectDAO().create();
transit.addTransect(transect);
} else {
transect = transit.getTransect().get(0);
@@ -180,9 +184,9 @@
if (transect.isDataAcquisitionEmpty()) {
// create a fake dataAcquisition
- dataAcquisition = getEchoBasePersistenceContext().getDataAcquisitionDAO().create(
+ dataAcquisition = serviceContext.getEchoBasePersistenceContext().getDataAcquisitionDAO().create(
DataAcquisition.PROPERTY_ACOUSTIC_INSTRUMENT,
- getEchoBasePersistenceContext().getAcousticInstrumentDAO().findAll().get(0));
+ serviceContext.getEchoBasePersistenceContext().getAcousticInstrumentDAO().findAll().get(0));
transect.addDataAcquisition(dataAcquisition);
} else {
dataAcquisition = transect.getDataAcquisition().iterator().next();
@@ -191,7 +195,7 @@
if (dataAcquisition.isDataProcessingEmpty()) {
// creates a fake dataProcessing
- dataProcessing = getEchoBasePersistenceContext().getDataProcessingDAO().create(
+ dataProcessing = serviceContext.getEchoBasePersistenceContext().getDataProcessingDAO().create(
DataProcessing.PROPERTY_ID, "id",
DataProcessing.PROPERTY_PROCESSING_TEMPLATE, "pt"
);
@@ -200,7 +204,7 @@
dataProcessing = dataAcquisition.getDataProcessing().iterator().next();
}
- CellDAO dao = getEchoBasePersistenceContext().getCellDAO();
+ CellDAO dao = serviceContext.getEchoBasePersistenceContext().getCellDAO();
Set<String> cellsNames;
@@ -216,7 +220,7 @@
esduColumnName,
inputFile.getFile());
- CellTypeDAO cellTypeDAO = getEchoBasePersistenceContext().getCellTypeDAO();
+ CellTypeDAO cellTypeDAO = serviceContext.getEchoBasePersistenceContext().getCellTypeDAO();
CellType esduCellType = cellTypeDAO.findById("Esdu");
Preconditions.checkNotNull(esduCellType);
@@ -244,7 +248,7 @@
}
}
- getEchoBasePersistenceContext().flush();
+ persistenceService.flush();
} finally {
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportServiceIT.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportServiceIT.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -69,7 +69,7 @@
conf.setImportType(ImportType.COMMON_TRANSECT);
// let's delete every transects
- for (Transit transit : getEchoBasePersistenceContext().getTransitDAO()) {
+ for (Transit transit : serviceContext.getEchoBasePersistenceContext().getTransitDAO()) {
transit.clearTransect();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportServiceIT.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportServiceIT.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -58,7 +58,7 @@
assertImportCommonData();
// let's delete every transits
- for (Voyage voyage : getEchoBasePersistenceContext().getVoyageDAO()) {
+ for (Voyage voyage : serviceContext.getEchoBasePersistenceContext().getVoyageDAO()) {
voyage.clearTransit();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -27,6 +27,7 @@
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.TopiaEchoBasePersistenceContext;
import fr.ifremer.echobase.entities.data.Category;
import fr.ifremer.echobase.entities.data.CategoryDAO;
import fr.ifremer.echobase.entities.data.Cell;
@@ -241,31 +242,36 @@
return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_NO_DATA());
}
+
+ TopiaEchoBasePersistenceContext persistenceContext;
+
@Override
@Before
public void setUp() throws Exception {
super.setUp();
- voyageDao = getEchoBasePersistenceContext().getVoyageDAO();
- transectDAO = getEchoBasePersistenceContext().getTransectDAO();
- transitDAO = getEchoBasePersistenceContext().getTransitDAO();
- dataAcquisitionDAO = getEchoBasePersistenceContext().getDataAcquisitionDAO();
- dataProcessingDAO = getEchoBasePersistenceContext().getDataProcessingDAO();
+ persistenceContext = serviceContext.getEchoBasePersistenceContext();
- cellDAO = getEchoBasePersistenceContext().getCellDAO();
- dataDAO = getEchoBasePersistenceContext().getDataDAO();
- operationDAO = getEchoBasePersistenceContext().getOperationDAO();
- operationMetadataValueDAO = getEchoBasePersistenceContext().getOperationMetadataValueDAO();
- gearMetadataValueDAO = getEchoBasePersistenceContext().getGearMetadataValueDAO();
- sampleDAO = getEchoBasePersistenceContext().getSampleDAO();
- sampleDataDAO = getEchoBasePersistenceContext().getSampleDataDAO();
+ voyageDao = persistenceContext.getVoyageDAO();
+ transectDAO = persistenceContext.getTransectDAO();
+ transitDAO = persistenceContext.getTransitDAO();
+ dataAcquisitionDAO = persistenceContext.getDataAcquisitionDAO();
+ dataProcessingDAO = persistenceContext.getDataProcessingDAO();
- echotypeDAO = getEchoBasePersistenceContext().getEchotypeDAO();
- lengthAgeKeyDAO = getEchoBasePersistenceContext().getLengthAgeKeyDAO();
- lengthWeightKeyDAO = getEchoBasePersistenceContext().getLengthWeightKeyDAO();
- categoryDAO = getEchoBasePersistenceContext().getCategoryDAO();
- resultDAO = getEchoBasePersistenceContext().getResultDAO();
+ cellDAO = persistenceContext.getCellDAO();
+ dataDAO = persistenceContext.getDataDAO();
+ operationDAO = persistenceContext.getOperationDAO();
+ operationMetadataValueDAO = persistenceContext.getOperationMetadataValueDAO();
+ gearMetadataValueDAO = persistenceContext.getGearMetadataValueDAO();
+ sampleDAO = persistenceContext.getSampleDAO();
+ sampleDataDAO = persistenceContext.getSampleDataDAO();
+ echotypeDAO = persistenceContext.getEchotypeDAO();
+ lengthAgeKeyDAO = persistenceContext.getLengthAgeKeyDAO();
+ lengthWeightKeyDAO = persistenceContext.getLengthWeightKeyDAO();
+ categoryDAO = persistenceContext.getCategoryDAO();
+ resultDAO = persistenceContext.getResultDAO();
+
//create imports for voyage 1
createCommonVoyageImportV1();
createCommonTransitImportV1();
@@ -355,16 +361,16 @@
}
private <E extends TopiaEntity> E getFirstEntity(Class<E> entityType) {
- List<E> entities = getEchoBasePersistenceContext().getDAO(entityType).findAll();
+ List<E> entities = persistenceContext.getDAO(entityType).findAll();
Assert.assertTrue(CollectionUtils.isNotEmpty(entities));
return entities.get(0);
}
private <E extends TopiaEntity> E getEntity(String id) throws TopiaException {
- TopiaIdFactory topiaIdFactory = getEchoBasePersistenceContext().getTopiaIdFactory();
+ TopiaIdFactory topiaIdFactory = persistenceContext.getTopiaIdFactory();
Class entityType = topiaIdFactory.getClassName(id);
- TopiaDAO<E> dao = getEchoBasePersistenceContext().getDAO(entityType);
+ TopiaDAO<E> dao = persistenceContext.getDAO(entityType);
E entity = dao.findByTopiaId(id);
return entity;
}
@@ -384,7 +390,7 @@
Voyage.PROPERTY_DATUM, "voyage1Datum"
);
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceContext.commitTransaction();
importCommonVoyage1Id = createImport(
CommonAllImportService.class,
@@ -410,7 +416,7 @@
Voyage.PROPERTY_DATUM, "voyage2Datum"
);
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceContext.commitTransaction();
importCommonVoyage2Id = createImport(
CommonAllImportService.class,
@@ -438,7 +444,7 @@
);
voyage.addTransit(transit);
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceContext.commitTransaction();
importCommonTransit1Id = createImport(
CommonAllImportService.class,
@@ -466,7 +472,7 @@
);
voyage.addTransit(transit);
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceContext.commitTransaction();
importCommonTransit2Id = createImport(
CommonAllImportService.class,
@@ -502,7 +508,7 @@
);
transit.addTransect(transect2);
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceContext.commitTransaction();
importCommonTransect1Id = createImport(
CommonAllImportService.class,
@@ -537,7 +543,7 @@
);
transit.addTransect(transect2);
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceContext.commitTransaction();
importCommonTransect2Id = createImport(
CommonAllImportService.class,
@@ -867,7 +873,7 @@
importLog.addImportId(importId.getTopiaId());
}
- getEchoBasePersistenceContext().commitTransaction();
+ persistenceContext.commitTransaction();
String importId = importLog.getTopiaId();
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/pom.xml 2013-12-16 18:22:36 UTC (rev 910)
@@ -7,7 +7,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>echobase</artifactId>
- <version>2.6-SNAPSHOT</version>
+ <version>2.5.1-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.echobase</groupId>
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -132,7 +132,8 @@
String importTypeToString = importTypes.get(importType);
row.put(ImportLog.PROPERTY_IMPORT_TYPE, importTypeToString);
- dbEditorService.decorateForeignKey(row, Voyage.class, ImportLog.PROPERTY_VOYAGE_ID, null);
+ Voyage voyage = workingDbPersistenceService.getVoyage((String) row.get(ImportLog.PROPERTY_VOYAGE_ID));
+ decoratorService.decorateForeignKey(row, ImportLog.PROPERTY_VOYAGE_ID, voyage, null);
}
return SUCCESS;
}
@@ -146,7 +147,7 @@
getLocale(), ImportLog.class, DecoratorService.DATE_ONLY);
Multimap<String, ImportLog> importLogsByVoyage = Multimaps.index(
- workingDbPersistenceService.getImportLogDAO().findAll(),
+ workingDbPersistenceService.getImportLogs(),
EchoBaseFunctions.IMPORT_LOG_VOYAGE_ID);
for (Map row : datas) {
@@ -155,8 +156,10 @@
Collection<ImportLog> importLogs = importLogsByVoyage.get(id);
- dbEditorService.decorateForeignKey(row, Voyage.class, "id", null);
+ Voyage voyage = workingDbPersistenceService.getVoyage(id);
+ decoratorService.decorateForeignKey(row, "id", voyage, null);
+
// to keep importLogs decorated, indexed by their topiaId
Map<String, String> imports = Maps.newHashMap();
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/AbstractEditExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/AbstractEditExportQuery.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/AbstractEditExportQuery.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.ui.actions.exportQuery;
+/*
+ * #%L
+ * EchoBase :: UI
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2011 - 2013 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ExportQuery;
import fr.ifremer.echobase.services.service.InternalDbPersistenceService;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/CloneExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/CloneExportQuery.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/CloneExportQuery.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.ui.actions.exportQuery;
+/*
+ * #%L
+ * EchoBase :: UI
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2011 - 2013 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ConfirmDeleteExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ConfirmDeleteExportQuery.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/ConfirmDeleteExportQuery.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.ui.actions.exportQuery;
+/*
+ * #%L
+ * EchoBase :: UI
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2011 - 2013 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import fr.ifremer.echobase.entities.ExportQuery;
import fr.ifremer.echobase.services.service.exportquery.ExportQueryService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DeleteExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DeleteExportQuery.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/DeleteExportQuery.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.ui.actions.exportQuery;
+/*
+ * #%L
+ * EchoBase :: UI
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2011 - 2013 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import fr.ifremer.echobase.entities.ExportQuery;
import fr.ifremer.echobase.services.service.exportquery.ExportQueryService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/SaveExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/SaveExportQuery.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/exportQuery/SaveExportQuery.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.ui.actions.exportQuery;
+/*
+ * #%L
+ * EchoBase :: UI
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2011 - 2013 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetDataProcessingsForVoyage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetDataProcessingsForVoyage.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetDataProcessingsForVoyage.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -64,7 +64,7 @@
} else {
- Voyage voyage = workingDbPersistenceService.getVoyageDAO().findByTopiaId(voyageId);
+ Voyage voyage = workingDbPersistenceService.getVoyage(voyageId);
Preconditions.checkNotNull(
voyage,
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetVesselsForVoyage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetVesselsForVoyage.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetVesselsForVoyage.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -66,7 +66,7 @@
if (StringUtils.isNotEmpty(voyageId)) {
- Voyage voyage = workingDbPersistenceService.getVoyageDAO().findByTopiaId(voyageId);
+ Voyage voyage = workingDbPersistenceService.getVoyage(voyageId);
Preconditions.checkNotNull(voyage,
"Could not find voyage with id " + voyageId);
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -86,9 +86,9 @@
if (log.isInfoEnabled()) {
log.info("Load import log " + id);
}
- ImportLog importLog = workingDbPersistenceService.getImportLogDAO().findByTopiaId(id);
+ ImportLog importLog = workingDbPersistenceService.getImportLog(id);
- Voyage voyageEntity = workingDbPersistenceService.getVoyageDAO().findByTopiaId(importLog.getVoyageId());
+ Voyage voyageEntity = workingDbPersistenceService.getVoyage(importLog.getVoyageId());
String voyage = decorator.toString(voyageEntity);
String importType = importTypes.get(importLog.getImportType().name());
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/AbstractGetVoyage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/AbstractGetVoyage.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/AbstractGetVoyage.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -66,7 +66,7 @@
} else {
- Voyage voyage = workingDbPersistenceService.getVoyageDAO().findByTopiaId(voyageId);
+ Voyage voyage = workingDbPersistenceService.getVoyage(voyageId);
Preconditions.checkNotNull(
voyage,
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/AddSpatial.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/AddSpatial.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/AddSpatial.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -40,7 +40,7 @@
@Override
public String execute() throws Exception {
- spatialService.addSpatialStructure();
+ spatialService.addSpatialSupport();
addFlashMessage(_("echobase.info.workingDbconfiguration.spatialStructureAdded"));
return SUCCESS;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/GetImportLogDetail.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/GetImportLogDetail.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/GetImportLogDetail.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -29,6 +29,7 @@
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.service.DbEditorService;
import fr.ifremer.echobase.services.service.DecoratorService;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import org.nuiton.topia.persistence.metadata.TableMeta;
@@ -69,7 +70,8 @@
data.put(ImportLog.PROPERTY_IMPORT_TYPE, importTypes.get(importType));
// decorate foreign keys
- dbEditorService.decorateForeignKey(data, Voyage.class, ImportLog.PROPERTY_VOYAGE_ID, null);
+ Voyage voyage = workingDbPersistenceService.getVoyage((String) data.get(ImportLog.PROPERTY_VOYAGE_ID));
+ decoratorService.decorateForeignKey(data, ImportLog.PROPERTY_VOYAGE_ID, voyage, null);
return SUCCESS;
}
@@ -78,6 +80,12 @@
//-- Injected objects //
//------------------------------------------------------------------------//
+ protected transient WorkingDbPersistenceService workingDbPersistenceService;
+
+ public void setWorkingDbPersistenceService(WorkingDbPersistenceService workingDbPersistenceService) {
+ this.workingDbPersistenceService = workingDbPersistenceService;
+ }
+
protected transient DbEditorService dbEditorService;
public void setDbEditorService(DbEditorService dbEditorService) {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/GetVoyage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/GetVoyage.java 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/GetVoyage.java 2013-12-16 18:22:36 UTC (rev 910)
@@ -29,6 +29,8 @@
import fr.ifremer.echobase.entities.references.AreaOfOperation;
import fr.ifremer.echobase.entities.references.Mission;
import fr.ifremer.echobase.services.service.DbEditorService;
+import fr.ifremer.echobase.services.service.DecoratorService;
+import fr.ifremer.echobase.services.service.WorkingDbPersistenceService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import org.nuiton.topia.persistence.metadata.TableMeta;
@@ -64,9 +66,12 @@
data = dbEditorService.getData(tableMeta, voyageId);
// decorate foreign keys
- dbEditorService.decorateForeignKey(data, Mission.class, Voyage.PROPERTY_MISSION, null);
- dbEditorService.decorateForeignKey(data, AreaOfOperation.class, Voyage.PROPERTY_AREA_OF_OPERATION, null);
+ Mission mission = workingDbPersistenceService.getMission((String) data.get(Voyage.PROPERTY_MISSION));
+ decoratorService.decorateForeignKey(data, Voyage.PROPERTY_MISSION, mission, null);
+ AreaOfOperation areaOfOperation = workingDbPersistenceService.getAreaOfOperation((String) data.get(Voyage.PROPERTY_AREA_OF_OPERATION));
+ decoratorService.decorateForeignKey(data, Voyage.PROPERTY_AREA_OF_OPERATION, areaOfOperation, null);
+
return SUCCESS;
}
@@ -74,6 +79,18 @@
//-- Injected objects //
//------------------------------------------------------------------------//
+ protected transient WorkingDbPersistenceService workingDbPersistenceService;
+
+ public void setWorkingDbPersistenceService(WorkingDbPersistenceService workingDbPersistenceService) {
+ this.workingDbPersistenceService = workingDbPersistenceService;
+ }
+
+ protected transient DecoratorService decoratorService;
+
+ public void setDecoratorService(DecoratorService decoratorService) {
+ this.decoratorService = decoratorService;
+ }
+
protected transient DbEditorService dbEditorService;
public void setDbEditorService(DbEditorService dbEditorService) {
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/pom.xml 2013-12-16 18:22:36 UTC (rev 910)
@@ -11,7 +11,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>echobase</artifactId>
- <version>2.6-SNAPSHOT</version>
+ <version>2.5.1-SNAPSHOT</version>
<modules>
<module>echobase-domain</module>
Modified: trunk/src/site/site_en.xml
===================================================================
--- trunk/src/site/site_en.xml 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/src/site/site_en.xml 2013-12-16 18:22:36 UTC (rev 910)
@@ -145,7 +145,9 @@
scmwebeditorurl='${project.scmwebeditorUrl}'
siteSourcesType='${project.siteSourcesType}'
piwikEnabled='${project.piwikEnabled}'
- piwikId='${project.piwikId}' locale='en'>
+ piwikId='${project.piwikId}' locale='en'
+ scmwebeditor_vmFiles=",install.html,usage.html,"
+ scmwebeditor_skipDefaultFiles="true">
</div>
</footer>
</body>
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2013-12-16 15:32:13 UTC (rev 909)
+++ trunk/src/site/site_fr.xml 2013-12-16 18:22:36 UTC (rev 910)
@@ -54,23 +54,23 @@
<poweredBy>
<logo href="http://maven.apache.org" name="Maven"
- img="http://maven-site.chorem.org/public/images/logos/maven-feather.png"/>
+ img="http://maven-site.chorem.org/common/dev/images/logos/maven-feather.png"/>
<logo href="http://struts.apache.org/" name="Struts 2"
- img="http://maven-site.chorem.org/public/images/logos/struts2-logo.png"/>
+ img="http://maven-site.chorem.org/common/dev/images/logos/struts2-logo.png"/>
<logo href="http://docutils.sourceforge.net/rst.html"
name="ReStructuredText"
- img="http://maven-site.chorem.org/public/images/logos/restructuredtext-logo.png"/>
+ img="http://maven-site.chorem.org/common/dev/images/logos/restructuredtext-logo.…"/>
<logo href="http://maven-site.nuiton.org/jrst" name="JRst"
- img="http://maven-site.chorem.org/public/images/logos/jrst-logo.png"/>
+ img="http://maven-site.chorem.org/common/dev/images/logos/jrst-logo.png"/>
<logo href="http://maven-site.nuiton.org/topia" name="ToPIA"
- img="http://maven-site.chorem.org/public/images/logos/topia-logo.png"/>
+ img="http://maven-site.chorem.org/common/dev/images/logos/topia-logo.png"/>
<logo href="http://argouml.tigris.org/" name="ArgoUML"
- img="http://maven-site.chorem.org/public/images/logos/argouml-logo.png"/>
+ img="http://maven-site.chorem.org/common/dev/images/logos/argouml-logo.png"/>
</poweredBy>
@@ -78,15 +78,15 @@
<head>
<script type="text/javascript"
- src="http://maven-site.chorem.org/public/js/mavenpom-site.js">
+ src="http://maven-site.chorem.org/common/dev/js/mavenpom-site.js">
</script>
<link rel="stylesheet" type="text/css"
- href="http://maven-site.chorem.org/public/css/mavenpom-site.css"/>
+ href="http://maven-site.chorem.org/common/dev/css/mavenpom-site.css"/>
</head>
<links>
- <item name="Forge" href="http://www.forge.codelutin.com"/>
+ <item name="Forge" href="http://forge.codelutin.com"/>
<item name="CodeLutin" href="http://codelutin.com"/>
<item name="Libre-Entreprise" href="http://www.libre-entreprise.org/"/>
</links>
@@ -146,7 +146,11 @@
scmwebeditorurl='${project.scmwebeditorUrl}'
siteSourcesType='${project.siteSourcesType}'
piwikEnabled='${project.piwikEnabled}'
- piwikId='${project.piwikId}' locale='fr'>
+ piwikId='${project.piwikId}'
+ locale='fr'
+ scmwebeditor_vmFiles=",install.html,usage.html,"
+ scmwebeditor_skipDefaultFiles="true"
+ scmwebeditor_skipFiles=",model.html,">
</div>
</footer>
</body>
1
0
16 Dec '13
Author: tchemit
Date: 2013-12-16 16:32:13 +0100 (Mon, 16 Dec 2013)
New Revision: 909
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/909
Log:
fixes #4019: Probl?\195?\168me de mise ?\195?\160 jour des donn?\195?\169es spatiales d'op?\195?\169ration
Modified:
trunk/echobase-services/src/main/resources/postgis-structure.sql
Modified: trunk/echobase-services/src/main/resources/postgis-structure.sql
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 15:16:01 UTC (rev 908)
+++ trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 15:32:13 UTC (rev 909)
@@ -1084,8 +1084,8 @@
-- create row
RAISE DEBUG 'Will create spatial operation %', operation_id;
-- get operation infos
- SELECT op.id
- INTO operationName
+ SELECT op.id, op.topiaid
+ INTO operationName, operationId
FROM operation op
WHERE op.topiaid = operation_id;
-- get transect infos
@@ -1111,13 +1111,13 @@
WHERE t.topiaid = transitId AND v.topiaid = t.voyage;
INSERT INTO echobase_operation_spatial (lastUpdateDate, voyageid, voyagename, transitid, transitname, transectid, transectname, operationid, operationname, coordinate)
- VALUES (now(), voyageId, voyageName, transitId, transitName, transectId, transectName, operation_id, operationName, coordinateData);
+ VALUES (now(), voyageId, voyageName, transitId, transitName, transectId, transectName, operationId, operationName, coordinateData);
ELSE
-- update row
RAISE DEBUG 'Will update spatial operation % ', operation_id;
- UPDATE echobase_operation_spatial
- SET coordinate = coordinateData
- WHERE operationid = operation_id;
+ UPDATE echobase_operation_spatial eos
+ SET eos.coordinate = coordinateData
+ WHERE eos.operationid = operation_id;
END IF;
END
$$ LANGUAGE plpgsql;
1
0
r908 - in trunk: echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb echobase-services/src/main/resources
by tchemit@users.forge.codelutin.com 16 Dec '13
by tchemit@users.forge.codelutin.com 16 Dec '13
16 Dec '13
Author: tchemit
Date: 2013-12-16 16:16:01 +0100 (Mon, 16 Dec 2013)
New Revision: 908
Url: http://forge.codelutin.com/projects/echobase/repository/revisions/908
Log:
fixes #4018: Migration de base en erreur
Added:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java
trunk/echobase-services/src/main/resources/postgis-structure.sql
trunk/echobase-services/src/main/resources/postgis-view.sql
Removed:
trunk/echobase-services/src/main/resources/postgis-structure.sql
Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java (rev 0)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java 2013-12-16 15:16:01 UTC (rev 908)
@@ -0,0 +1,57 @@
+package fr.ifremer.echobase.persistence.migration.workingDb;
+
+import fr.ifremer.echobase.entities.EchoBasePersistenceContext;
+import fr.ifremer.echobase.entities.TopiaEchoBasePersistenceContext;
+import fr.ifremer.echobase.io.EchoBaseIOUtil;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.util.Version;
+
+import java.util.List;
+
+/**
+ * Created on 12/16/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.5.1
+ */
+public class MigrationCallBackForVersion2_5_1 extends MigrationCallBackForVersion {
+
+ @Override
+ public Version getVersion() {
+ return new Version("2.5.1");
+ }
+
+ @Override
+ protected void prepareMigrationScript(TopiaContext tx,
+ List<String> queries,
+ boolean showSql,
+ boolean showProgression) throws TopiaException {
+
+ boolean spatialAware;
+
+ TopiaEchoBasePersistenceContext persistenceContext =
+ new TopiaEchoBasePersistenceContext(tx);
+ try {
+
+ spatialAware = persistenceContext.isSpatialAware();
+ } finally {
+ persistenceContext.rollbackTransaction();
+ }
+
+ if (spatialAware) {
+
+ // repass postgis scripts (http://forge.codelutin.com/issues/3672)
+ updatePostgis(queries);
+ }
+ }
+
+ protected void updatePostgis(List<String> queries) {
+ queries.add(EchoBaseIOUtil.loadScript(EchoBasePersistenceContext.POSTGIS_STRUCTURE_SQL));
+ queries.add(EchoBaseIOUtil.loadScript(EchoBasePersistenceContext.POSTGIS_VIEW_SQL));
+
+ // fix http://forge.codelutin.com/issues/3973
+ queries.add("update echobase_operation_spatial set operationname = (select op.id from operation op where op.topiaid = operationid);");
+
+ }
+}
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/echobase-services/src/main/resources/postgis-structure.sql
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 10:40:24 UTC (rev 907)
+++ trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 15:16:01 UTC (rev 908)
@@ -1,1219 +0,0 @@
----
--- #%L
--- EchoBase :: UI
--- $Id$
--- $HeadURL$
--- %%
--- Copyright (C) 2011 - 2013 Ifremer, Codelutin
--- %%
--- This program is free software: you can redistribute it and/or modify
--- it under the terms of the GNU Affero 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 Affero General Public License
--- along with this program. If not, see <http://www.gnu.org/licenses/>.
--- #L%
----
-CREATE EXTENSION IF NOT EXISTS postgis;
-
---------------------------------------------------------------------------------
--- Table spatial pour les cellules ---------------------------------------------
---------------------------------------------------------------------------------
-
-DROP TABLE IF EXISTS echobase_cell_spatial;
-CREATE TABLE echobase_cell_spatial (
- voyageid VARCHAR(256) NOT NULL,
- voyagename VARCHAR(256),
- transitid VARCHAR(256),
- transitname VARCHAR(256),
- transectid VARCHAR(256),
- transectname VARCHAR(256),
- dataAcquisitionid VARCHAR(256),
- dataAcquisitionname VARCHAR(256),
- dataProcessingid VARCHAR(256),
- dataProcessingname VARCHAR(256),
- celltypeid VARCHAR(256) NOT NULL,
- celltypename VARCHAR(256) NOT NULL,
- cellid VARCHAR(256) PRIMARY KEY,
- cellname VARCHAR(256) NOT NULL,
- lastUpdateDate TIMESTAMP NOT NULL,
- FOREIGN KEY (cellid) REFERENCES cell (topiaid),
- FOREIGN KEY (celltypeid) REFERENCES celltype (topiaid),
- FOREIGN KEY (dataacquisitionid) REFERENCES dataacquisition (topiaid),
- FOREIGN KEY (dataprocessingid) REFERENCES dataprocessing (topiaid),
- FOREIGN KEY (transectid) REFERENCES transect (topiaid),
- FOREIGN KEY (transitid) REFERENCES transit (topiaid),
- FOREIGN KEY (voyageid) REFERENCES voyage (topiaid)
-);
-
-SELECT AddGeometryColumn('echobase_cell_spatial', 'coordinate', 4326, 'POINT',2 );
-SELECT AddGeometryColumn('echobase_cell_spatial', 'coordinate3d', 4326, 'POINT',3);
-SELECT AddGeometryColumn('echobase_cell_spatial', 'shape', 4326, 'POLYGON',2 );
-
-CREATE INDEX echobase_cell_spatial_coordinate_gix ON echobase_cell_spatial USING GIST (coordinate);
-CREATE INDEX echobase_cell_spatial_coordinate3D_gix ON echobase_cell_spatial USING GIST (coordinate3d);
-CREATE INDEX echobase_cell_spatial_shape_gix ON echobase_cell_spatial USING GIST (shape);
-
--- ajout de vues
-
-DROP VIEW IF EXISTS echobase_spatial_cell_result;
-CREATE OR REPLACE VIEW echobase_spatial_cell_result AS
-SELECT
- s.*,
- m.topiaId as metaDataId,
- m.name as metaDataName,
- r.resultvalue as resultValue,
- r.topiaid as resultId
-FROM
- echobase_cell_spatial s,
- result r,
- datametadata m
-WHERE
- s.cellid = r.cell AND
- r.datametadata = m.topiaid;
-
-DROP VIEW IF EXISTS echobase_spatial_cell_data;
-CREATE OR REPLACE VIEW echobase_spatial_cell_data AS
-SELECT
- s.*,
- m.topiaId as metaDataId,
- m.name as metaDataName,
- d.datavalue as dataValue,
- d.topiaid as dataId
-FROM
- echobase_cell_spatial s,
- data d,
- datametadata m
-WHERE
- s.cellid = d.cell AND
- d.datametadata = m.topiaid;
-
--- pour stoquer les traitements spatiaux a effectuer
-DROP TABLE IF EXISTS echobase_cell_spatial_temp;
-CREATE TABLE echobase_cell_spatial_temp (
- cellid VARCHAR(256) PRIMARY KEY,
- celltype VARCHAR(256) NOT NULL,
- FOREIGN KEY (cellid) REFERENCES cell (topiaid)
-);
-
---
--- Trigger qui met à jour la table des traitements spatiaux à faire
---
-
-DROP FUNCTION IF EXISTS echobase_fill_spatial_temp_table();
-DROP TRIGGER IF EXISTS echobase_fill_spatial_work_table_trigger ON data;
-
-CREATE OR REPLACE FUNCTION echobase_fill_cell_spatial_temp_table()
- RETURNS TRIGGER AS $$
-DECLARE
- cell_id VARCHAR;
- data_type_id VARCHAR;
- cellType VARCHAR;
- dataType VARCHAR;
- doInsert BOOLEAN;
- result RECORD;
-BEGIN
-
- IF (TG_OP = 'DELETE')
- THEN
- result = OLD;
- ELSE
- result = NEW;
- END IF;
-
- cell_id = result.cell;
- data_type_id = result.datametadata;
- doInsert = FALSE;
--- recuperation du type de la cellule
- cellType = echobase_get_cell_type(cell_id);
-
- IF (SELECT
- count(*)
- FROM echobase_cell_spatial_temp c
- WHERE c.cellid = cell_id) > 0
- THEN
--- la cellule est deja a traitee
- RETURN result;
- END IF;
--- recuperation du type de la la data
- SELECT
- dt.name
- INTO dataType
- FROM datametadata dt
- WHERE dt.topiaId = data_type_id;
-
- CASE cellType
- WHEN 'ESDU'
- THEN
--- Cell of type Esdu
- CASE dataType
- WHEN 'LatitudeStart', 'LatitudeBary', 'LatitudeEnd', 'LongitudeStart', 'LongitudeBary', 'LongitudeEnd'
- THEN
- doInsert = TRUE;
- ELSE
- doInsert = FALSE;
- END CASE;
- WHEN 'ELEMENTARY'
- THEN
--- Cell of type Elementary
- CASE dataType
- WHEN 'LatitudeStart', 'LatitudeBary', 'LatitudeEnd', 'LongitudeStart', 'LongitudeBary', 'LongitudeEnd', 'DepthRefSurfaceStart', 'DepthRefSurfaceEnd', 'DepthRefBottomStart', 'DepthRefBottomEnd'
- THEN
- doInsert = TRUE;
- ELSE
- doInsert = FALSE;
- END CASE;
- WHEN 'REGION', 'REGIONSURF', 'REGIONCLAS'
- THEN
--- Cell of type Region
- CASE dataType
- WHEN 'RegionEnvCoordinates'
- THEN
- doInsert = TRUE;
- cellType = 'REGION';
- ELSE
- doInsert = FALSE;
- END CASE;
- WHEN 'MAP'
- THEN
--- Cell of type Map
- CASE dataType
- WHEN 'GridCellLatitude', 'GridCellLongitude', 'GridLatitudeLag', 'GridLongitudeLag'
- THEN
- doInsert = TRUE;
- ELSE
- doInsert = FALSE;
- END CASE;
- END CASE;
-
- IF doInsert = TRUE
- THEN
---- Ajout de la cellule dans la table des traitements à effectuer
- RAISE DEBUG 'Add cell % [type %] to echobase_cell_spatial_temp', cell_id, cellType;
- INSERT INTO echobase_cell_spatial_temp (cellid, celltype) VALUES (cell_id, cellType);
- END IF;
-
- RETURN result;
-END
-$$
-LANGUAGE 'plpgsql';
-
-DROP TRIGGER IF EXISTS echobase_fill_cell_spatial_work_table_trigger ON data;
-CREATE TRIGGER echobase_fill_cell_spatial_work_table_trigger
-AFTER INSERT OR UPDATE ON data
-FOR EACH ROW WHEN (NEW.cell IS NOT
- NULL) EXECUTE PROCEDURE echobase_fill_cell_spatial_temp_table();
-
---
--- Trigger qui met à jour la table des traitements spatiaux à faire lors d
--- 'une suppression de cellule
---
-
-CREATE OR REPLACE FUNCTION echobase_delete_cell()
- RETURNS TRIGGER AS $$
-BEGIN
-
- RAISE DEBUG 'Delete cell % , delete cascade in echobase_cell_spatial_table', OLD.topiaid;
-
- DELETE FROM echobase_cell_spatial WHERE cellid = OLD.topiaid;
-
- RETURN OLD;
-END
-$$
-LANGUAGE 'plpgsql';
-
-DROP TRIGGER IF EXISTS echobase_delete_cell ON cell;
-
-CREATE TRIGGER echobase_delete_cell
-BEFORE DELETE ON cell
-FOR EACH ROW EXECUTE PROCEDURE echobase_delete_cell();
-
---
--- Mettre a jour toutes les données spatiales de cellule
---
-
-CREATE OR REPLACE FUNCTION echobase_compute_all_cell_spatial_data()
- RETURNS VOID AS $$
-DECLARE cell_id VARCHAR;
-BEGIN
- DELETE FROM echobase_cell_spatial;
-
- FOR cell_id IN SELECT topiaid FROM cell LOOP
- PERFORM echobase_fill_cell_spatial_row(cell_id);
- END LOOP;
-END
-$$
-LANGUAGE plpgsql;
-
---
--- Mettre a jour la table echobase_cell_spatial depuis echobase_cell_spatial_temp
---
-
-CREATE OR REPLACE FUNCTION echobase_fill_cell_spatial_table()
- RETURNS VOID AS $$
-DECLARE
- cellRow RECORD;
-BEGIN
- FOR cellRow IN SELECT
- *
- FROM echobase_cell_spatial_temp LOOP
-
- PERFORM echobase_fill_cell_spatial_row(cellRow.cellid);
-
- END LOOP;
-
- DELETE FROM echobase_cell_spatial_temp;
-
-END
-$$
-LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION echobase_fill_cell_spatial_row(cell_id VARCHAR)
- RETURNS VOID AS $$
- DECLARE cell_type VARCHAR;
-BEGIN
-
- cell_type = echobase_get_cell_type(cell_id);
-
- RAISE DEBUG 'Treat spatial cell % [type %] ...', cell_id, cell_type;
- CASE cell_type
- WHEN 'ESDU'
- THEN
- EXECUTE echobase_fill_esdu_cell_spatial_table(cell_id);
- WHEN 'ELEMENTARY'
- THEN
- EXECUTE echobase_fill_elementary_cell_spatial_table(cell_id);
- WHEN 'REGION'
- THEN
- EXECUTE echobase_fill_region_cell_spatial_table(cell_id);
- WHEN 'MAP'
- THEN
- EXECUTE echobase_fill_map_cell_spatial_table(cell_id);
- ELSE
- RAISE LOG 'Can not deal with celltype % (cell %)', cell_type, cell_id;
- END CASE;
-END
-$$
-LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION echobase_fill_esdu_cell_spatial_table(
- cell_id VARCHAR)
- RETURNS VOID AS $$
-DECLARE
- latitude VARCHAR;
- longitude VARCHAR;
- depth RECORD;
- spatialText VARCHAR;
- latitudeNumber REAL;
- longitudeNumber REAL;
-BEGIN
- RAISE DEBUG 'Treat esdu cell % ', cell_id;
--- test if start / bary / end event
- SELECT
- d.datavalue
- INTO latitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LatitudeStart';
- IF FOUND
- THEN
--- start data
- RAISE DEBUG 'Treat esdu Start cell % ', cell_id;
- SELECT
- d.datavalue
- INTO longitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LongitudeStart';
- ELSE
- SELECT
- d.datavalue
- INTO latitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LatitudeBary';
- IF FOUND
- THEN
--- bary data
- RAISE DEBUG 'Treat esdu Bary cell %', cell_id;
- SELECT
- d.datavalue
- INTO longitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LongitudeBary';
- ELSE
- SELECT
- d.datavalue
- INTO latitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LatitudeEnd';
- IF FOUND
- THEN
--- end data
- RAISE DEBUG 'Treat End cell %', cell_id;
- SELECT
- d.datavalue
- INTO longitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LongitudeEnd';
- ELSE
--- no spatial data
- RAISE LOG 'Could not find spatial data for cell %', cell_id;
- RETURN;
- END IF;
- END IF;
- END IF;
-
--- convert dms latitude to dd latitude
- SELECT
- echobase_latitudetext_to_dd(latitude)
- INTO latitudeNumber;
-
- IF latitude IS NOT NULL AND latitudeNumber IS NULL
- THEN
- latitudeNumber := latitude :: REAL;
- END IF;
-
--- convert dms longitude to dd longitude
- SELECT
- echobase_longitudetext_to_dd(longitude)
- INTO longitudeNumber;
-
- IF longitude IS NOT NULL AND longitudeNumber IS NULL
- THEN
- longitudeNumber := longitude :: REAL;
- END IF;
-
- SELECT
- 'SRID=4326;POINT(' || longitudeNumber || ' ' || latitudeNumber || ')'
- INTO spatialText;
- RAISE DEBUG 'spatial data % for cell %', spatialText, cell_id;
-
- PERFORM echobase_create_echobase_cell_spatial_row(cell_id,
- spatialText,
- NULL,
- NULL);
-END
-$$ LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION echobase_fill_elementary_cell_spatial_table(
- cell_id VARCHAR)
- RETURNS VOID AS $$
-DECLARE
- latitude VARCHAR;
- longitude VARCHAR;
- depth VARCHAR;
- spatialText VARCHAR;
- latitudeNumber REAL;
- longitudeNumber REAL;
-BEGIN
- RAISE DEBUG 'Treat elementary cell % ', cell_id;
--- try start elementary
- SELECT
- d.datavalue
- INTO latitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LatitudeStart';
- IF FOUND
- THEN
--- this is a start elementary
- RAISE DEBUG 'Treat elementary Start cell % ', cell_id;
--- get longitude
- SELECT
- d.datavalue
- INTO longitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LongitudeStart';
--- get depth (try first surface one)
- SELECT
- d.datavalue
- INTO depth
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'DepthRefSurfaceStart';
- IF NOT FOUND
- THEN
--- try then bottom
- SELECT
- d.datavalue
- INTO depth
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'DepthRefBottomStart';
- END IF;
- ELSE
--- try bary elementary
- SELECT
- d.datavalue
- INTO latitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LatitudeBary';
- IF FOUND
- THEN
--- this is a bary elementary
- RAISE DEBUG 'Treat elementary Bary cell %', cell_id;
- SELECT
- d.datavalue
- INTO longitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LongitudeBary';
- SELECT
- d.datavalue
- INTO depth
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'DepthRefSurfaceBary';
- IF NOT FOUND
- THEN
--- use depth bottom
- SELECT
- d.datavalue
- INTO depth
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'DepthRefBottomBary';
- END IF;
- ELSE
--- try end elementary
- SELECT
- d.datavalue
- INTO latitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LatitudeEnd';
- IF FOUND
- THEN
--- this is a end elementary
- RAISE DEBUG 'Treat elementary End cell %', cell_id;
- SELECT
- d.datavalue
- INTO longitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'LongitudeEnd';
- SELECT
- d.datavalue
- INTO depth
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'DepthRefSurfaceEnd';
- IF NOT FOUND
- THEN
--- use depth bottom
- SELECT
- d.datavalue
- INTO depth
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'DepthRefBottomEnd';
- END IF;
- ELSE
--- no spatial data
- RAISE DEBUG 'Could not find spatial data for cell %', cell_id;
- RETURN;
- END IF;
- END IF;
- END IF;
-
--- convert dms latitude to dd latitude
- SELECT
- echobase_latitudetext_to_dd(latitude)
- INTO latitudeNumber;
-
- IF latitude IS NOT NULL AND latitudeNumber IS NULL
- THEN
- latitudeNumber := latitude :: REAL;
- END IF;
-
--- convert dms longitude to dd longitude
- SELECT
- echobase_longitudetext_to_dd(longitude)
- INTO longitudeNumber;
-
- IF longitude IS NOT NULL AND longitudeNumber IS NULL
- THEN
- longitudeNumber := longitude :: REAL;
- END IF;
-
- SELECT
- 'SRID=4326;POINT(' || longitudeNumber || ' ' || latitudeNumber || ' ' ||
- depth || ')'
- INTO spatialText;
- RAISE DEBUG 'spatial data % for cell %', spatialText, cell_id;
-
- PERFORM echobase_create_echobase_cell_spatial_row(cell_id,
- NULL,
- spatialText,
- NULL);
-END
-$$ LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION echobase_fill_region_cell_spatial_table(
- cell_id VARCHAR)
- RETURNS VOID AS $$
-DECLARE
- latitude REAL;
- longitude REAL;
- depth REAL;
- dataMetadataId VARCHAR;
- dataValue VARCHAR;
- spatialText VARCHAR := 'POLYGON((';
-BEGIN
- RAISE DEBUG 'Treat region cell %', cell_id;
- SELECT
- topiaid
- INTO dataMetadataId
- FROM datametadata
- WHERE name = 'RegionEnvCoordinates';
- FOR dataValue IN SELECT
- d.datavalue
- FROM data d
- WHERE d.cell = cell_id AND d.datametadata = dataMetadataId
- ORDER BY d.topiacreatedate LOOP
--- split dataValue in lat - long - depth
- SELECT
- split_part(dataValue, ' ', 1) :: REAL
- INTO latitude;
- SELECT
- split_part(dataValue, ' ', 2) :: REAL
- INTO longitude;
- SELECT
- split_part(dataValue, ' ', 3) :: REAL
- INTO depth;
- SELECT
- spatialText || longitude || ' ' || latitude || ','
- INTO spatialText;
- END LOOP;
- SELECT
- left(spatialText, -1) || '))'
- INTO spatialText;
-
- SELECT 'SRID=4326;' || spatialText INTO spatialText;
-
- RAISE DEBUG 'spatial data % for cell %', spatialText, cell_id;
-
- PERFORM echobase_create_echobase_cell_spatial_row(cell_id,
- NULL,
- NULL,
- spatialText);
-END
-$$ LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION echobase_fill_map_cell_spatial_table(
- cell_id VARCHAR)
- RETURNS VOID AS $$
-DECLARE
- latitude REAL;
- longitude REAL;
- deltaLatitude REAL;
- deltaLongitude REAL;
- P0 VARCHAR;
- P1 VARCHAR;
- P2 VARCHAR;
- P3 VARCHAR;
- spatialText VARCHAR;
-BEGIN
- RAISE DEBUG 'Treat map cell % ', cell_id;
--- get GridCellLatitude
- SELECT
- d.datavalue :: REAL
- INTO latitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'GridCellLatitude';
--- get GridCellLatitude
- SELECT
- d.datavalue :: REAL
- INTO longitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'GridCellLongitude';
--- get GridCellLatitude
- SELECT
- d.datavalue :: REAL
- INTO deltaLatitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'GridLatitudeLag';
--- get GridCellLatitude
- SELECT
- d.datavalue :: REAL
- INTO deltaLongitude
- FROM data d LEFT OUTER JOIN datametadata AS dm
- ON d.datametadata = dm.topiaid
- WHERE d.cell = cell_id AND dm.name = 'GridLongitudeLag';
-
- IF
- latitude IS NOT NULL AND longitude IS NOT NULL AND deltaLatitude IS NOT NULL
- AND deltaLongitude IS NOT NULL
- THEN
- SELECT
- longitude || ' ' || latitude
- INTO P0;
- SELECT
- longitude || ' ' || latitude + deltaLatitude
- INTO P1;
- SELECT
- longitude + deltaLongitude || ' ' || latitude + deltaLatitude
- INTO P2;
- SELECT
- longitude + deltaLongitude || ' ' || latitude
- INTO P3;
-
- SELECT
- 'SRID=4326;POLYGON((' || p0 || ',' || P1 || ',' || P2 || ',' || P3 || ',' || P0 ||
- '))'
- INTO spatialText;
- RAISE DEBUG 'spatial data % for cell %', spatialText, cell_id;
-
- PERFORM echobase_create_echobase_cell_spatial_row(cell_id,
- NULL,
- NULL,
- spatialText);
- END IF;
-END
-$$ LANGUAGE plpgsql;
-
--- procedure pour creer (ou mettre à jour) une ligne dans echobase_cell_spatial
-
-CREATE OR REPLACE FUNCTION echobase_create_echobase_cell_spatial_row(
- cell_id VARCHAR,
- coordinateText VARCHAR,
- coordinate3dText VARCHAR,
- shapeText VARCHAR)
- RETURNS VOID AS $$
-DECLARE
- cellSpatialRow RECORD;
- voyageId VARCHAR;
- voyageName VARCHAR;
- transitId VARCHAR;
- transitName VARCHAR;
- transectId VARCHAR;
- transectName VARCHAR;
- dataAcquisitionId VARCHAR;
- dataAcquisitionName VARCHAR;
- dataProcessingId VARCHAR;
- dataProcessingName VARCHAR;
- cellName VARCHAR;
- cellTypeId VARCHAR;
- cellTypeName VARCHAR;
- cellParentId VARCHAR;
- cellRow RECORD;
- coordinateData GEOMETRY;
- coordinate3dData GEOMETRY;
- shapeData GEOMETRY;
-BEGIN
- IF coordinateText IS NULL AND coordinate3dText IS NULL AND
- shapeText IS NULL
- THEN
- RAISE DEBUG 'Could not find spatial data for cell %', cell_id;
- RETURN;
- END IF;
- IF coordinateText IS NOT NULL
- THEN
- BEGIN
- coordinateData = ST_GeomFromEWKT(coordinateText);
- EXCEPTION WHEN internal_error
- THEN
-
- RAISE LOG 'Could not create coordinate spatial data %', coordinateText;
- RETURN;
- END;
- ELSEIF coordinate3dText IS NOT NULL
- THEN
- BEGIN
- coordinate3dData = ST_GeomFromEWKT(coordinate3dText);
- EXCEPTION WHEN internal_error
- THEN
-
- RAISE LOG 'Could not create coordinate3D spatial data %', coordinate3dText;
- RETURN;
- END;
- ELSEIF shapeText IS NOT NULL
- THEN
- BEGIN
- shapeData = ST_GeomFromEWKT(shapeText);
- EXCEPTION WHEN internal_error
- THEN
-
- RAISE LOG 'Could not create shape spatial data %', shapeText;
- RETURN;
- END;
- END IF;
-
- SELECT
- *
- INTO cellSpatialRow
- FROM echobase_cell_spatial cs
- WHERE cs.cellid = cell_id;
- IF NOT FOUND
- THEN
--- create row
- RAISE DEBUG 'Will create spatial cell %', cell_id;
- SELECT
- cell_id
- INTO cellParentId;
- LOOP
- IF dataProcessingId IS NULL
- THEN
--- try to get dataprocessingId from this cell
- SELECT
- dp.topiaid,
- dp.processingdescription
- INTO dataProcessingId
- FROM dataprocessing dp, cell c
- WHERE c.topiaid = cellParentId AND dp.topiaid = c.dataprocessing;
- END IF;
- SELECT
- topiaid,
- cell
- INTO cellRow
- FROM cell
- WHERE topiaid = cellParentId;
- EXIT WHEN cellRow.cell IS NULL;
- SELECT
- cellRow.cell
- INTO cellParentId;
- END LOOP;
- RAISE DEBUG 'use cell parentId %', cellParentId;
--- get cell infos
- SELECT
- c.name,
- ct.name,
- ct.topiaid
- INTO cellName, cellTypeName, cellTypeId
- FROM cell c, celltype ct
- WHERE c.topiaid = cell_id AND c.celltype = ct.topiaid;
-
- IF dataProcessingId IS NULL
- THEN
--- get voyage infos
- SELECT
- v.topiaid,
- v.name
- INTO voyageId, voyageName
- FROM voyage v, cell c
- WHERE c.topiaid = cellParentId AND v.topiaid = c.voyage;
- ELSE
-
--- get dataAcquisition infos
- SELECT
- da.topiaid,
- da.acousticinstrument
- INTO dataAcquisitionId, dataAcquisitionName
- FROM dataacquisition da, dataprocessing dp
- WHERE dp.topiaId = dataProcessingId AND da.topiaid = dp.dataacquisition;
--- get transect infos
- SELECT
- t.topiaid,
- t.vessel
- INTO transectId, transitName
- FROM transect t, dataacquisition da
- WHERE da.topiaid = dataAcquisitionId AND t.topiaid = da.transect;
--- get transit infos
- SELECT
- t.topiaid,
- (t.starttime || ' - ' || t.endtime)
- INTO transitId, transitName
- FROM transit t, transect tt
- WHERE tt.topiaid = transectId AND t.topiaid = tt.transit;
--- get voyage infos
- SELECT
- v.topiaid,
- v.name
- INTO voyageId, voyageName
- FROM voyage v, transit t
- WHERE t.topiaid = transitId AND v.topiaid = t.voyage;
- END IF;
- INSERT INTO echobase_cell_spatial (lastUpdateDate, voyageid, voyagename, transitid, transitname, transectid, transectname, dataacquisitionid, dataacquisitionname, dataprocessingid, dataprocessingname, celltypeid, celltypename, cellid, cellname, coordinate, coordinate3d, shape)
- VALUES (now(), voyageId, voyageName, transitId, transitName, transectId, transectName, dataAcquisitionId, dataAcquisitionName, dataProcessingId, dataProcessingName, cellTypeId, cellTypeName, cell_id, cellName, coordinateData, coordinate3dData, shapeData);
- ELSE
--- update row
- RAISE DEBUG 'Will update spatial cell % ', cell_id;
- UPDATE echobase_cell_spatial
- SET coordinate = coordinateData,
- coordinate3d = coordinate3dData,
- shape = shapeData
- WHERE cellid = cell_id;
- END IF;
-END
-$$ LANGUAGE plpgsql;
-
--- pour obtenir le type d'une cellule sous forme ESDU - ELEMENTARY - REGION ou MAP
-CREATE OR REPLACE FUNCTION echobase_get_cell_type(cell_id VARCHAR)
- RETURNS VARCHAR AS $$
-DECLARE result VARCHAR;
-BEGIN
- SELECT
- UPPER(ct.id)
- INTO result
- FROM celltype ct, cell ce
- WHERE ce.topiaid = cell_id AND ct.topiaId = ce.celltype;
- IF 'REGIONCLAS' = result OR 'REGIONSURF' = result
- THEN
- result = 'REGION';
- END IF;
- RETURN result;
-END
-$$
-LANGUAGE plpgsql;
-
---------------------------------------------------------------------------------
--- Table spatial pour les operations -------------------------------------------
---------------------------------------------------------------------------------
-
-DROP TABLE IF EXISTS echobase_operation_spatial;
-CREATE TABLE echobase_operation_spatial (
- voyageid VARCHAR(256) NOT NULL,
- voyagename VARCHAR(256),
- transitid VARCHAR(256),
- transitname VARCHAR(256),
- transectid VARCHAR(256),
- transectname VARCHAR(256),
- operationid VARCHAR(256),
- operationname VARCHAR(256),
- lastUpdateDate TIMESTAMP NOT NULL,
- FOREIGN KEY (operationid) REFERENCES operation (topiaid),
- FOREIGN KEY (transectid) REFERENCES transect (topiaid),
- FOREIGN KEY (transitid) REFERENCES transit (topiaid),
- FOREIGN KEY (voyageid) REFERENCES voyage (topiaid)
-);
-
-SELECT AddGeometryColumn('echobase_operation_spatial', 'coordinate', 4326, 'POINT',2 );
-
-CREATE INDEX echobase_operation_spatial_coordinate_gix ON echobase_operation_spatial USING GIST (coordinate);
-
--- ajout de vues
-
-DROP VIEW IF EXISTS echobase_spatial_operation_data;
-
---CREATE OR REPLACE VIEW echobase_spatial_operation_data AS
---SELECT
--- echobase_cell_spatial.*,
--- datametadata.name,
--- data.dataValue
--- data.topiaid as dataId
---FROM
--- echobase_cell_spatial,
--- data,
--- datametadata
---WHERE
--- echobase_cell_spatial.cellid = data.cell AND
--- data.datametadata = datametadata.topiaid;
-
--- pour stoquer les traitements spatiaux a effectuer
-DROP TABLE IF EXISTS echobase_operation_spatial_temp;
-CREATE TABLE echobase_operation_spatial_temp (
- operationid VARCHAR(256) PRIMARY KEY,
- FOREIGN KEY (operationid) REFERENCES operation (topiaid)
-);
-
---
--- Trigger qui met à jour la table des traitements spatiaux à faire
---
-
-CREATE OR REPLACE FUNCTION echobase_fill_operation_spatial_temp_table()
- RETURNS TRIGGER AS $$
-DECLARE
- operation_id VARCHAR;
- result RECORD;
-BEGIN
-
- IF (TG_OP = 'DELETE')
- THEN
- result = OLD;
- ELSE
- result = NEW;
- END IF;
-
- operation_id = result.topiaid;
-
- IF (SELECT count(*) FROM echobase_operation_spatial_temp c
- WHERE c.operationid = operation_id) > 0
- THEN
--- operation est deja a traitee
- RETURN result;
- END IF;
---- Ajout de l'operation dans la table des traitements à effectuer
- RAISE DEBUG 'Add operation % to echobase_operation_spatial_temp', operation_id;
- INSERT INTO echobase_operation_spatial_temp (operationid) VALUES (operation_id);
- RETURN result;
-END
-$$
-LANGUAGE 'plpgsql';
-
-DROP TRIGGER IF EXISTS echobase_fill_operation_spatial_work_table_trigger ON operation;
-CREATE TRIGGER echobase_fill_operation_spatial_work_table_trigger
-AFTER INSERT OR UPDATE ON operation
-FOR EACH ROW WHEN (NEW.topiaid IS NOT
- NULL) EXECUTE PROCEDURE echobase_fill_operation_spatial_temp_table();
-
---
--- Trigger qui met à jour la table des traitements spatiaux à faire lors de la
--- suppression d'une operation
---
-
-CREATE OR REPLACE FUNCTION echobase_delete_operation()
- RETURNS TRIGGER AS $$
-BEGIN
-
- RAISE DEBUG 'Delete operation % , delete cascade in echobase_operation_spatial_table', OLD.topiaid;
-
- DELETE FROM echobase_operation_spatial WHERE operationid = OLD.topiaid;
-
- RETURN OLD;
-END
-$$
-LANGUAGE 'plpgsql';
-
-DROP TRIGGER IF EXISTS echobase_delete_operation ON operation;
-
-CREATE TRIGGER echobase_delete_operation
-BEFORE DELETE ON operation
-FOR EACH ROW EXECUTE PROCEDURE echobase_delete_operation();
-
---
--- Mettre a jour toutes les données spatiales d'operation
---
-
-CREATE OR REPLACE FUNCTION echobase_compute_all_operation_spatial_data()
- RETURNS VOID AS $$
-DECLARE operation_id VARCHAR;
-BEGIN
- DELETE FROM echobase_operation_spatial;
-
- FOR operation_id IN SELECT topiaid FROM operation LOOP
- PERFORM echobase_fill_operation_spatial_row(operation_id);
- END LOOP;
-END
-$$
-LANGUAGE plpgsql;
-
---
--- Mettre a jour la table echobase_cell_spatial depuis echobase_operation_spatial_temp
---
-
-CREATE OR REPLACE FUNCTION echobase_fill_operation_spatial_table()
- RETURNS VOID AS $$
-DECLARE
- operationRow RECORD;
-BEGIN
- FOR operationRow IN SELECT * FROM echobase_operation_spatial_temp LOOP
-
- PERFORM echobase_fill_operation_spatial_row(operationRow.operationid);
- END LOOP;
-
- DELETE FROM echobase_operation_spatial_temp;
-
-END
-$$
-LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION echobase_fill_operation_spatial_row(operation_id VARCHAR)
- RETURNS VOID AS $$
- DECLARE
- spatialText VARCHAR;
- latitudeNumber REAL;
- longitudeNumber REAL;
-BEGIN
- RAISE NOTICE 'Treat spatial operation % ...', operation_id;
- SELECT o.midHaulLatitude, o.midHaulLongitude
- INTO latitudeNumber, longitudeNumber FROM operation o
- WHERE o.topiaid = operation_id;
-
- SELECT
- 'SRID=4326;POINT(' || longitudeNumber || ' ' || latitudeNumber || ')'
- INTO spatialText;
- RAISE DEBUG 'spatial data % for operation %', spatialText, operation_id;
-
- PERFORM echobase_create_echobase_operation_spatial_row(operation_id,
- spatialText);
-END
-$$
-LANGUAGE plpgsql;
-
--- procedure pour creer (ou mettre à jour) une ligne dans echobase_cell_spatial
-
-CREATE OR REPLACE FUNCTION echobase_create_echobase_operation_spatial_row(
- operation_id VARCHAR,
- coordinateText VARCHAR)
- RETURNS VOID AS $$
-DECLARE
- operationSpatialRow RECORD;
- voyageId VARCHAR;
- voyageName VARCHAR;
- transitId VARCHAR;
- transitName VARCHAR;
- transectId VARCHAR;
- transectName VARCHAR;
- operationId VARCHAR;
- operationName VARCHAR;
- operationRow RECORD;
- coordinateData GEOMETRY;
-BEGIN
- IF coordinateText IS NULL
- THEN
- RAISE DEBUG 'Could not find spatial data for operation %', operation_id;
- RETURN;
- END IF;
- BEGIN
- coordinateData = ST_GeomFromEWKT(coordinateText);
- EXCEPTION WHEN internal_error
- THEN
- RAISE LOG 'Could not create coordinate operation spatial data %', coordinateText;
- RETURN;
- END;
-
- SELECT * INTO operationSpatialRow FROM echobase_operation_spatial os
- WHERE os.operationid = operation_id;
- IF NOT FOUND
- THEN
--- create row
- RAISE DEBUG 'Will create spatial operation %', operation_id;
--- get transect infos
- SELECT
- t.topiaid,
- t.vessel
- INTO transectId, transitName
- FROM transect t, operation op
- WHERE op.topiaid = operation_id AND t.topiaid = op.transect;
--- get transit infos
- SELECT
- t.topiaid,
- (t.starttime || ' - ' || t.endtime)
- INTO transitId, transitName
- FROM transit t, transect tt
- WHERE tt.topiaid = transectId AND t.topiaid = tt.transit;
--- get voyage infos
- SELECT
- v.topiaid,
- v.name
- INTO voyageId, voyageName
- FROM voyage v, transit t
- WHERE t.topiaid = transitId AND v.topiaid = t.voyage;
-
- INSERT INTO echobase_operation_spatial (lastUpdateDate, voyageid, voyagename, transitid, transitname, transectid, transectname, operationid, operationname, coordinate)
- VALUES (now(), voyageId, voyageName, transitId, transitName, transectId, transectName, operation_id, operationName, coordinateData);
- ELSE
--- update row
- RAISE DEBUG 'Will update spatial operation % ', operation_id;
- UPDATE echobase_operation_spatial
- SET coordinate = coordinateData
- WHERE operationid = operation_id;
- END IF;
-END
-$$ LANGUAGE plpgsql;
-
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
-
--- pour convertir des latitudes en dms (+ hemi) en dd
-CREATE OR REPLACE FUNCTION echobase_latitudetext_to_dd(latitude VARCHAR)
- RETURNS REAL AS $$
-DECLARE
- degre_ INTEGER;
- minute_ INTEGER;
- second_ INTEGER;
- hemi_ VARCHAR(1);
-BEGIN
- SELECT
- right(latitude, 1),
- left(latitude, 2) :: INTEGER,
- substring(latitude FROM 3 FOR 2) :: INTEGER,
- substring(latitude FROM 6 FOR 3) :: INTEGER
- INTO hemi_, degre_, minute_, second_;
-
- RETURN echobase_dms2dd(degre_, minute_, second_, hemi_);
- EXCEPTION WHEN invalid_text_representation
- THEN
- RETURN NULL;
-END
-$$ LANGUAGE plpgsql;
-
--- pour convertir des longitudes en dms (+ hemi) en dd
-CREATE OR REPLACE FUNCTION echobase_longitudetext_to_dd(longitude VARCHAR)
- RETURNS REAL AS $$
-DECLARE
- degre_ INTEGER;
- minute_ INTEGER;
- second_ INTEGER;
- hemi_ VARCHAR(1);
-BEGIN
- SELECT
- right(longitude, 1),
- left(longitude, 3) :: INTEGER,
- substring(longitude FROM 4 FOR 2) :: INTEGER,
- substring(longitude FROM 7 FOR 3) :: INTEGER
- INTO hemi_, degre_, minute_, second_;
-
- RETURN echobase_dms2dd(degre_, minute_, second_, hemi_);
- EXCEPTION WHEN invalid_text_representation
- THEN
- RETURN NULL;
-END
-$$ LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION echobase_dms2dd(
- D INTEGER, M INTEGER, S INTEGER, HEMI CHARACTER VARYING(1)
-)
- RETURNS DOUBLE PRECISION AS $$
-DECLARE
- ret DOUBLE PRECISION;
- dir INTEGER;
-BEGIN
- dir := 1;
---init to 1 for default positive return
- ret := 0;
---init to zero.
- --ONLY S or W will trip this. Any other letter or NULL will result in positive return value
- IF UPPER(HEMI) = 'S' OR UPPER(HEMI) = 'W'
- THEN
- dir := -1; --then southern or western hemisphere
- END IF;
---SOME data has negative values in minutes and seconds as well as degrees. Use ABS to standardize all three.
- ret := (ABS(CAST(D AS DOUBLE PRECISION)) + (ABS((CAST(M AS DOUBLE PRECISION) +
- (ABS((CAST(S AS
- DOUBLE PRECISION))
- / 60))) / 60)));
- ret := ret * dir;
- RETURN ret;
-
-END;
-$$ LANGUAGE plpgsql;
-
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
-
---
--- Mettre a jour toutes les données spatiales
---
-
-CREATE OR REPLACE FUNCTION echobase_compute_all_spatial_data()
- RETURNS VOID AS $$
-DECLARE cell_id VARCHAR;
-BEGIN
- EXECUTE echobase_compute_all_operation_spatial_data();
- EXECUTE echobase_compute_all_cell_spatial_data();
-END
-$$
-LANGUAGE plpgsql;
-
-
--- Compute all data
-SELECT echobase_compute_all_cell_spatial_data();
-SELECT echobase_compute_all_operation_spatial_data();
\ No newline at end of file
Copied: trunk/echobase-services/src/main/resources/postgis-structure.sql (from rev 906, trunk/echobase-services/src/main/resources/postgis-structure.sql)
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-structure.sql (rev 0)
+++ trunk/echobase-services/src/main/resources/postgis-structure.sql 2013-12-16 15:16:01 UTC (rev 908)
@@ -0,0 +1,1224 @@
+---
+-- #%L
+-- EchoBase :: UI
+-- $Id$
+-- $HeadURL$
+-- %%
+-- Copyright (C) 2011 - 2013 Ifremer, Codelutin
+-- %%
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU Affero 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 Affero General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+-- #L%
+---
+CREATE EXTENSION IF NOT EXISTS postgis;
+
+DROP VIEW IF EXISTS TotalCatchSpOpWide;
+DROP VIEW IF EXISTS echobase_spatial_cell_result;
+DROP VIEW IF EXISTS echobase_spatial_cell_data;
+DROP VIEW IF EXISTS TotalSampleEngrEnc;
+DROP VIEW IF EXISTS TotalSampleSardPil;
+DROP VIEW IF EXISTS TotalSampleTracTru;
+DROP VIEW IF EXISTS TotalSampleSpraSpr;
+DROP VIEW IF EXISTS TotalSampleScomSco;
+DROP VIEW IF EXISTS TotalSampleMicrPou;
+DROP VIEW IF EXISTS cellmapview;
+
+DROP TABLE IF EXISTS echobase_cell_spatial;
+DROP INDEX IF EXISTS echobase_cell_spatial_coordinate_gix;
+DROP INDEX IF EXISTS echobase_cell_spatial_coordinate3D_gix;
+DROP INDEX IF EXISTS echobase_cell_spatial_shape_gix;
+DROP INDEX IF EXISTS echobase_cell_spatial_voyageid_idx;
+DROP TABLE IF EXISTS echobase_cell_spatial_temp;
+
+DROP TRIGGER IF EXISTS echobase_fill_cell_spatial_work_table_trigger ON data;
+DROP FUNCTION IF EXISTS echobase_fill_spatial_temp_table();
+DROP FUNCTION IF EXISTS echobase_fill_cell_spatial_temp_table();
+
+DROP TRIGGER IF EXISTS echobase_delete_cell ON cell;
+DROP FUNCTION IF EXISTS echobase_delete_cell();
+DROP FUNCTION IF EXISTS echobase_compute_all_cell_spatial_data();
+DROP FUNCTION IF EXISTS echobase_fill_cell_spatial_table();
+DROP FUNCTION IF EXISTS echobase_fill_cell_spatial_row(cell_id VARCHAR);
+DROP FUNCTION IF EXISTS echobase_fill_esdu_cell_spatial_table(cell_id VARCHAR);
+DROP FUNCTION IF EXISTS echobase_fill_elementary_cell_spatial_table(cell_id VARCHAR);
+DROP FUNCTION IF EXISTS echobase_fill_region_cell_spatial_table(cell_id VARCHAR);
+DROP FUNCTION IF EXISTS echobase_fill_map_cell_spatial_table(cell_id VARCHAR);
+DROP FUNCTION IF EXISTS echobase_create_echobase_cell_spatial_row(
+cell_id VARCHAR,
+coordinateText VARCHAR,
+coordinate3dText VARCHAR,
+shapeText VARCHAR);
+
+DROP FUNCTION IF EXISTS echobase_get_cell_type(cell_id VARCHAR);
+
+
+
+DROP TABLE IF EXISTS echobase_operation_spatial;
+DROP INDEX IF EXISTS echobase_operation_spatial_coordinate_gix;
+DROP INDEX IF EXISTS echobase_operation_spatial_voyageid_idx;
+DROP TABLE IF EXISTS echobase_operation_spatial_temp;
+DROP TRIGGER IF EXISTS echobase_fill_operation_spatial_work_table_trigger ON operation;
+DROP FUNCTION IF EXISTS echobase_fill_operation_spatial_temp_table();
+DROP TRIGGER IF EXISTS echobase_delete_operation ON operation;
+DROP FUNCTION IF EXISTS echobase_delete_operation();
+
+DROP FUNCTION IF EXISTS echobase_compute_all_operation_spatial_data();
+DROP FUNCTION IF EXISTS echobase_fill_operation_spatial_table();
+DROP FUNCTION IF EXISTS echobase_fill_operation_spatial_row(operation_id VARCHAR);
+
+DROP FUNCTION IF EXISTS echobase_create_echobase_operation_spatial_row(
+operation_id VARCHAR,
+coordinateText VARCHAR);
+
+DROP FUNCTION IF EXISTS echobase_latitudetext_to_dd(latitude VARCHAR);
+DROP FUNCTION IF EXISTS echobase_longitudetext_to_dd(longitude VARCHAR);
+DROP FUNCTION IF EXISTS echobase_dms2dd(D INTEGER, M INTEGER, S INTEGER, HEMI CHARACTER VARYING(1));
+DROP FUNCTION IF EXISTS echobase_compute_all_spatial_data();
+
+--------------------------------------------------------------------------------
+-- Table spatial pour les cellules ---------------------------------------------
+--------------------------------------------------------------------------------
+
+CREATE TABLE echobase_cell_spatial (
+ voyageid VARCHAR(256) NOT NULL,
+ voyagename VARCHAR(256),
+ transitid VARCHAR(256),
+ transitname VARCHAR(256),
+ transectid VARCHAR(256),
+ transectname VARCHAR(256),
+ dataAcquisitionid VARCHAR(256),
+ dataAcquisitionname VARCHAR(256),
+ dataProcessingid VARCHAR(256),
+ dataProcessingname VARCHAR(256),
+ celltypeid VARCHAR(256) NOT NULL,
+ celltypename VARCHAR(256) NOT NULL,
+ cellid VARCHAR(256) PRIMARY KEY,
+ cellname VARCHAR(256) NOT NULL,
+ lastUpdateDate TIMESTAMP NOT NULL,
+ FOREIGN KEY (cellid) REFERENCES cell (topiaid),
+ FOREIGN KEY (celltypeid) REFERENCES celltype (topiaid),
+ FOREIGN KEY (dataacquisitionid) REFERENCES dataacquisition (topiaid),
+ FOREIGN KEY (dataprocessingid) REFERENCES dataprocessing (topiaid),
+ FOREIGN KEY (transectid) REFERENCES transect (topiaid),
+ FOREIGN KEY (transitid) REFERENCES transit (topiaid),
+ FOREIGN KEY (voyageid) REFERENCES voyage (topiaid)
+);
+
+SELECT AddGeometryColumn('echobase_cell_spatial', 'coordinate', 4326, 'POINT',2 );
+SELECT AddGeometryColumn('echobase_cell_spatial', 'coordinate3d', 4326, 'POINT',3);
+SELECT AddGeometryColumn('echobase_cell_spatial', 'shape', 4326, 'POLYGON',2 );
+
+CREATE INDEX echobase_cell_spatial_coordinate_gix ON echobase_cell_spatial USING GIST (coordinate);
+CREATE INDEX echobase_cell_spatial_coordinate3D_gix ON echobase_cell_spatial USING GIST (coordinate3d);
+CREATE INDEX echobase_cell_spatial_shape_gix ON echobase_cell_spatial USING GIST (shape);
+CREATE INDEX echobase_cell_spatial_voyageid_idx ON echobase_cell_spatial USING BTREE(voyageid);
+
+-- pour stoquer les traitements spatiaux a effectuer
+
+CREATE TABLE echobase_cell_spatial_temp (
+ cellid VARCHAR(256) PRIMARY KEY,
+ celltype VARCHAR(256) NOT NULL,
+ FOREIGN KEY (cellid) REFERENCES cell (topiaid)
+);
+
+--
+-- Trigger qui met à jour la table des traitements spatiaux à faire
+--
+
+CREATE OR REPLACE FUNCTION echobase_fill_cell_spatial_temp_table()
+ RETURNS TRIGGER AS $$
+DECLARE
+ cell_id VARCHAR;
+ data_type_id VARCHAR;
+ cellType VARCHAR;
+ dataType VARCHAR;
+ doInsert BOOLEAN;
+ result RECORD;
+BEGIN
+
+ IF (TG_OP = 'DELETE')
+ THEN
+ result = OLD;
+ ELSE
+ result = NEW;
+ END IF;
+
+ cell_id = result.cell;
+ data_type_id = result.datametadata;
+ doInsert = FALSE;
+-- recuperation du type de la cellule
+ cellType = echobase_get_cell_type(cell_id);
+
+ IF (SELECT
+ count(*)
+ FROM echobase_cell_spatial_temp c
+ WHERE c.cellid = cell_id) > 0
+ THEN
+-- la cellule est deja a traitee
+ RETURN result;
+ END IF;
+-- recuperation du type de la la data
+ SELECT
+ dt.name
+ INTO dataType
+ FROM datametadata dt
+ WHERE dt.topiaId = data_type_id;
+
+ CASE cellType
+ WHEN 'ESDU'
+ THEN
+-- Cell of type Esdu
+ CASE dataType
+ WHEN 'LatitudeStart', 'LatitudeBary', 'LatitudeEnd', 'LongitudeStart', 'LongitudeBary', 'LongitudeEnd'
+ THEN
+ doInsert = TRUE;
+ ELSE
+ doInsert = FALSE;
+ END CASE;
+ WHEN 'ELEMENTARY'
+ THEN
+-- Cell of type Elementary
+ CASE dataType
+ WHEN 'LatitudeStart', 'LatitudeBary', 'LatitudeEnd', 'LongitudeStart', 'LongitudeBary', 'LongitudeEnd', 'DepthRefSurfaceStart', 'DepthRefSurfaceEnd', 'DepthRefBottomStart', 'DepthRefBottomEnd'
+ THEN
+ doInsert = TRUE;
+ ELSE
+ doInsert = FALSE;
+ END CASE;
+ WHEN 'REGION', 'REGIONSURF', 'REGIONCLAS'
+ THEN
+-- Cell of type Region
+ CASE dataType
+ WHEN 'RegionEnvCoordinates'
+ THEN
+ doInsert = TRUE;
+ cellType = 'REGION';
+ ELSE
+ doInsert = FALSE;
+ END CASE;
+ WHEN 'MAP'
+ THEN
+-- Cell of type Map
+ CASE dataType
+ WHEN 'GridCellLatitude', 'GridCellLongitude', 'GridLatitudeLag', 'GridLongitudeLag'
+ THEN
+ doInsert = TRUE;
+ ELSE
+ doInsert = FALSE;
+ END CASE;
+ END CASE;
+
+ IF doInsert = TRUE
+ THEN
+--- Ajout de la cellule dans la table des traitements à effectuer
+ RAISE DEBUG 'Add cell % [type %] to echobase_cell_spatial_temp', cell_id, cellType;
+ INSERT INTO echobase_cell_spatial_temp (cellid, celltype) VALUES (cell_id, cellType);
+ END IF;
+
+ RETURN result;
+END
+$$
+LANGUAGE 'plpgsql';
+
+CREATE TRIGGER echobase_fill_cell_spatial_work_table_trigger
+AFTER INSERT OR UPDATE ON data
+FOR EACH ROW WHEN (NEW.cell IS NOT
+ NULL) EXECUTE PROCEDURE echobase_fill_cell_spatial_temp_table();
+
+--
+-- Trigger qui met à jour la table des traitements spatiaux à faire lors d
+-- 'une suppression de cellule
+--
+
+CREATE OR REPLACE FUNCTION echobase_delete_cell()
+ RETURNS TRIGGER AS $$
+BEGIN
+
+ RAISE DEBUG 'Delete cell % , delete cascade in echobase_cell_spatial_table', OLD.topiaid;
+
+ DELETE FROM echobase_cell_spatial WHERE cellid = OLD.topiaid;
+
+ RETURN OLD;
+END
+$$
+LANGUAGE 'plpgsql';
+
+CREATE TRIGGER echobase_delete_cell
+BEFORE DELETE ON cell
+FOR EACH ROW EXECUTE PROCEDURE echobase_delete_cell();
+
+--
+-- Mettre a jour toutes les données spatiales de cellule
+--
+
+CREATE OR REPLACE FUNCTION echobase_compute_all_cell_spatial_data()
+ RETURNS VOID AS $$
+DECLARE cell_id VARCHAR;
+BEGIN
+ DELETE FROM echobase_cell_spatial;
+
+ FOR cell_id IN SELECT topiaid FROM cell LOOP
+ PERFORM echobase_fill_cell_spatial_row(cell_id);
+ END LOOP;
+END
+$$
+LANGUAGE plpgsql;
+
+--
+-- Mettre a jour la table echobase_cell_spatial depuis echobase_cell_spatial_temp
+--
+
+CREATE OR REPLACE FUNCTION echobase_fill_cell_spatial_table()
+ RETURNS VOID AS $$
+DECLARE
+ cellRow RECORD;
+BEGIN
+ FOR cellRow IN SELECT
+ *
+ FROM echobase_cell_spatial_temp LOOP
+
+ PERFORM echobase_fill_cell_spatial_row(cellRow.cellid);
+
+ END LOOP;
+
+ DELETE FROM echobase_cell_spatial_temp;
+
+END
+$$
+LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION echobase_fill_cell_spatial_row(cell_id VARCHAR)
+ RETURNS VOID AS $$
+ DECLARE cell_type VARCHAR;
+BEGIN
+
+ cell_type = echobase_get_cell_type(cell_id);
+
+ RAISE DEBUG 'Treat spatial cell % [type %] ...', cell_id, cell_type;
+ CASE cell_type
+ WHEN 'ESDU'
+ THEN
+ EXECUTE echobase_fill_esdu_cell_spatial_table(cell_id);
+ WHEN 'ELEMENTARY'
+ THEN
+ EXECUTE echobase_fill_elementary_cell_spatial_table(cell_id);
+ WHEN 'REGION'
+ THEN
+ EXECUTE echobase_fill_region_cell_spatial_table(cell_id);
+ WHEN 'MAP'
+ THEN
+ EXECUTE echobase_fill_map_cell_spatial_table(cell_id);
+ ELSE
+ RAISE LOG 'Can not deal with celltype % (cell %)', cell_type, cell_id;
+ END CASE;
+END
+$$
+LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION echobase_fill_esdu_cell_spatial_table(
+ cell_id VARCHAR)
+ RETURNS VOID AS $$
+DECLARE
+ latitude VARCHAR;
+ longitude VARCHAR;
+ depth RECORD;
+ spatialText VARCHAR;
+ latitudeNumber REAL;
+ longitudeNumber REAL;
+BEGIN
+ RAISE DEBUG 'Treat esdu cell % ', cell_id;
+-- test if start / bary / end event
+ SELECT
+ d.datavalue
+ INTO latitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LatitudeStart';
+ IF FOUND
+ THEN
+-- start data
+ RAISE DEBUG 'Treat esdu Start cell % ', cell_id;
+ SELECT
+ d.datavalue
+ INTO longitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LongitudeStart';
+ ELSE
+ SELECT
+ d.datavalue
+ INTO latitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LatitudeBary';
+ IF FOUND
+ THEN
+-- bary data
+ RAISE DEBUG 'Treat esdu Bary cell %', cell_id;
+ SELECT
+ d.datavalue
+ INTO longitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LongitudeBary';
+ ELSE
+ SELECT
+ d.datavalue
+ INTO latitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LatitudeEnd';
+ IF FOUND
+ THEN
+-- end data
+ RAISE DEBUG 'Treat End cell %', cell_id;
+ SELECT
+ d.datavalue
+ INTO longitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LongitudeEnd';
+ ELSE
+-- no spatial data
+ RAISE LOG 'Could not find spatial data for cell %', cell_id;
+ RETURN;
+ END IF;
+ END IF;
+ END IF;
+
+-- convert dms latitude to dd latitude
+ SELECT
+ echobase_latitudetext_to_dd(latitude)
+ INTO latitudeNumber;
+
+ IF latitude IS NOT NULL AND latitudeNumber IS NULL
+ THEN
+ latitudeNumber := latitude :: REAL;
+ END IF;
+
+-- convert dms longitude to dd longitude
+ SELECT
+ echobase_longitudetext_to_dd(longitude)
+ INTO longitudeNumber;
+
+ IF longitude IS NOT NULL AND longitudeNumber IS NULL
+ THEN
+ longitudeNumber := longitude :: REAL;
+ END IF;
+
+ SELECT
+ 'SRID=4326;POINT(' || longitudeNumber || ' ' || latitudeNumber || ')'
+ INTO spatialText;
+ RAISE DEBUG 'spatial data % for cell %', spatialText, cell_id;
+
+ PERFORM echobase_create_echobase_cell_spatial_row(cell_id,
+ spatialText,
+ NULL,
+ NULL);
+END
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION echobase_fill_elementary_cell_spatial_table(
+ cell_id VARCHAR)
+ RETURNS VOID AS $$
+DECLARE
+ latitude VARCHAR;
+ longitude VARCHAR;
+ depth VARCHAR;
+ spatialText VARCHAR;
+ latitudeNumber REAL;
+ longitudeNumber REAL;
+BEGIN
+ RAISE DEBUG 'Treat elementary cell % ', cell_id;
+-- try start elementary
+ SELECT
+ d.datavalue
+ INTO latitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LatitudeStart';
+ IF FOUND
+ THEN
+-- this is a start elementary
+ RAISE DEBUG 'Treat elementary Start cell % ', cell_id;
+-- get longitude
+ SELECT
+ d.datavalue
+ INTO longitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LongitudeStart';
+-- get depth (try first surface one)
+ SELECT
+ d.datavalue
+ INTO depth
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'DepthRefSurfaceStart';
+ IF NOT FOUND
+ THEN
+-- try then bottom
+ SELECT
+ d.datavalue
+ INTO depth
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'DepthRefBottomStart';
+ END IF;
+ ELSE
+-- try bary elementary
+ SELECT
+ d.datavalue
+ INTO latitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LatitudeBary';
+ IF FOUND
+ THEN
+-- this is a bary elementary
+ RAISE DEBUG 'Treat elementary Bary cell %', cell_id;
+ SELECT
+ d.datavalue
+ INTO longitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LongitudeBary';
+ SELECT
+ d.datavalue
+ INTO depth
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'DepthRefSurfaceBary';
+ IF NOT FOUND
+ THEN
+-- use depth bottom
+ SELECT
+ d.datavalue
+ INTO depth
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'DepthRefBottomBary';
+ END IF;
+ ELSE
+-- try end elementary
+ SELECT
+ d.datavalue
+ INTO latitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LatitudeEnd';
+ IF FOUND
+ THEN
+-- this is a end elementary
+ RAISE DEBUG 'Treat elementary End cell %', cell_id;
+ SELECT
+ d.datavalue
+ INTO longitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'LongitudeEnd';
+ SELECT
+ d.datavalue
+ INTO depth
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'DepthRefSurfaceEnd';
+ IF NOT FOUND
+ THEN
+-- use depth bottom
+ SELECT
+ d.datavalue
+ INTO depth
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'DepthRefBottomEnd';
+ END IF;
+ ELSE
+-- no spatial data
+ RAISE DEBUG 'Could not find spatial data for cell %', cell_id;
+ RETURN;
+ END IF;
+ END IF;
+ END IF;
+
+-- convert dms latitude to dd latitude
+ SELECT
+ echobase_latitudetext_to_dd(latitude)
+ INTO latitudeNumber;
+
+ IF latitude IS NOT NULL AND latitudeNumber IS NULL
+ THEN
+ latitudeNumber := latitude :: REAL;
+ END IF;
+
+-- convert dms longitude to dd longitude
+ SELECT
+ echobase_longitudetext_to_dd(longitude)
+ INTO longitudeNumber;
+
+ IF longitude IS NOT NULL AND longitudeNumber IS NULL
+ THEN
+ longitudeNumber := longitude :: REAL;
+ END IF;
+
+ SELECT
+ 'SRID=4326;POINT(' || longitudeNumber || ' ' || latitudeNumber || ' ' ||
+ depth || ')'
+ INTO spatialText;
+ RAISE DEBUG 'spatial data % for cell %', spatialText, cell_id;
+
+ PERFORM echobase_create_echobase_cell_spatial_row(cell_id,
+ NULL,
+ spatialText,
+ NULL);
+END
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION echobase_fill_region_cell_spatial_table(cell_id VARCHAR)
+ RETURNS VOID AS $$
+DECLARE
+ latitude REAL;
+ longitude REAL;
+ depth REAL;
+ dataMetadataId VARCHAR;
+ dataValue VARCHAR;
+ spatialText VARCHAR := 'POLYGON((';
+BEGIN
+ RAISE DEBUG 'Treat region cell %', cell_id;
+ SELECT
+ topiaid
+ INTO dataMetadataId
+ FROM datametadata
+ WHERE name = 'RegionEnvCoordinates';
+ FOR dataValue IN SELECT
+ d.datavalue
+ FROM data d
+ WHERE d.cell = cell_id AND d.datametadata = dataMetadataId
+ ORDER BY d.topiacreatedate LOOP
+-- split dataValue in lat - long - depth
+ SELECT
+ split_part(dataValue, ' ', 1) :: REAL
+ INTO latitude;
+ SELECT
+ split_part(dataValue, ' ', 2) :: REAL
+ INTO longitude;
+ SELECT
+ split_part(dataValue, ' ', 3) :: REAL
+ INTO depth;
+ SELECT
+ spatialText || longitude || ' ' || latitude || ','
+ INTO spatialText;
+ END LOOP;
+ SELECT
+ left(spatialText, -1) || '))'
+ INTO spatialText;
+
+ SELECT 'SRID=4326;' || spatialText INTO spatialText;
+
+ RAISE DEBUG 'spatial data % for cell %', spatialText, cell_id;
+
+ PERFORM echobase_create_echobase_cell_spatial_row(cell_id,
+ NULL,
+ NULL,
+ spatialText);
+END
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION echobase_fill_map_cell_spatial_table(cell_id VARCHAR)
+ RETURNS VOID AS $$
+DECLARE
+ latitude REAL;
+ longitude REAL;
+ deltaLatitude REAL;
+ deltaLongitude REAL;
+ P0 VARCHAR;
+ P1 VARCHAR;
+ P2 VARCHAR;
+ P3 VARCHAR;
+ spatialText VARCHAR;
+BEGIN
+ RAISE DEBUG 'Treat map cell % ', cell_id;
+-- get GridCellLatitude
+ SELECT
+ d.datavalue :: REAL
+ INTO latitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'GridCellLatitude';
+-- get GridCellLatitude
+ SELECT
+ d.datavalue :: REAL
+ INTO longitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'GridCellLongitude';
+-- get GridCellLatitude
+ SELECT
+ d.datavalue :: REAL
+ INTO deltaLatitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'GridLatitudeLag';
+-- get GridCellLatitude
+ SELECT
+ d.datavalue :: REAL
+ INTO deltaLongitude
+ FROM data d LEFT OUTER JOIN datametadata AS dm
+ ON d.datametadata = dm.topiaid
+ WHERE d.cell = cell_id AND dm.name = 'GridLongitudeLag';
+
+ IF
+ latitude IS NOT NULL AND longitude IS NOT NULL AND deltaLatitude IS NOT NULL
+ AND deltaLongitude IS NOT NULL
+ THEN
+ SELECT
+ longitude || ' ' || latitude
+ INTO P0;
+ SELECT
+ longitude || ' ' || latitude + deltaLatitude
+ INTO P1;
+ SELECT
+ longitude + deltaLongitude || ' ' || latitude + deltaLatitude
+ INTO P2;
+ SELECT
+ longitude + deltaLongitude || ' ' || latitude
+ INTO P3;
+
+ SELECT
+ 'SRID=4326;POLYGON((' || p0 || ',' || P1 || ',' || P2 || ',' || P3 || ',' || P0 ||
+ '))'
+ INTO spatialText;
+ RAISE DEBUG 'spatial data % for cell %', spatialText, cell_id;
+
+ PERFORM echobase_create_echobase_cell_spatial_row(cell_id,
+ NULL,
+ NULL,
+ spatialText);
+ END IF;
+END
+$$ LANGUAGE plpgsql;
+
+-- procedure pour creer (ou mettre à jour) une ligne dans echobase_cell_spatial
+
+CREATE OR REPLACE FUNCTION echobase_create_echobase_cell_spatial_row(
+ cell_id VARCHAR,
+ coordinateText VARCHAR,
+ coordinate3dText VARCHAR,
+ shapeText VARCHAR)
+ RETURNS VOID AS $$
+DECLARE
+ cellSpatialRow RECORD;
+ voyageId VARCHAR;
+ voyageName VARCHAR;
+ transitId VARCHAR;
+ transitName VARCHAR;
+ transectId VARCHAR;
+ transectName VARCHAR;
+ dataAcquisitionId VARCHAR;
+ dataAcquisitionName VARCHAR;
+ dataProcessingId VARCHAR;
+ dataProcessingName VARCHAR;
+ cellName VARCHAR;
+ cellTypeId VARCHAR;
+ cellTypeName VARCHAR;
+ cellParentId VARCHAR;
+ cellRow RECORD;
+ coordinateData GEOMETRY;
+ coordinate3dData GEOMETRY;
+ shapeData GEOMETRY;
+BEGIN
+ IF coordinateText IS NULL AND coordinate3dText IS NULL AND
+ shapeText IS NULL
+ THEN
+ RAISE DEBUG 'Could not find spatial data for cell %', cell_id;
+ RETURN;
+ END IF;
+ IF coordinateText IS NOT NULL
+ THEN
+ BEGIN
+ coordinateData = ST_GeomFromEWKT(coordinateText);
+ EXCEPTION WHEN internal_error
+ THEN
+
+ RAISE LOG 'Could not create coordinate spatial data %', coordinateText;
+ RETURN;
+ END;
+ ELSEIF coordinate3dText IS NOT NULL
+ THEN
+ BEGIN
+ coordinate3dData = ST_GeomFromEWKT(coordinate3dText);
+ EXCEPTION WHEN internal_error
+ THEN
+
+ RAISE LOG 'Could not create coordinate3D spatial data %', coordinate3dText;
+ RETURN;
+ END;
+ ELSEIF shapeText IS NOT NULL
+ THEN
+ BEGIN
+ shapeData = ST_GeomFromEWKT(shapeText);
+ EXCEPTION WHEN internal_error
+ THEN
+
+ RAISE LOG 'Could not create shape spatial data %', shapeText;
+ RETURN;
+ END;
+ END IF;
+
+ SELECT
+ *
+ INTO cellSpatialRow
+ FROM echobase_cell_spatial cs
+ WHERE cs.cellid = cell_id;
+ IF NOT FOUND
+ THEN
+-- create row
+ RAISE DEBUG 'Will create spatial cell %', cell_id;
+ SELECT
+ cell_id
+ INTO cellParentId;
+ LOOP
+ IF dataProcessingId IS NULL
+ THEN
+-- try to get dataprocessingId from this cell
+ SELECT
+ dp.topiaid,
+ dp.processingdescription
+ INTO dataProcessingId
+ FROM dataprocessing dp, cell c
+ WHERE c.topiaid = cellParentId AND dp.topiaid = c.dataprocessing;
+ END IF;
+ SELECT
+ topiaid,
+ cell
+ INTO cellRow
+ FROM cell
+ WHERE topiaid = cellParentId;
+ EXIT WHEN cellRow.cell IS NULL;
+ SELECT
+ cellRow.cell
+ INTO cellParentId;
+ END LOOP;
+ RAISE DEBUG 'use cell parentId %', cellParentId;
+-- get cell infos
+ SELECT
+ c.name,
+ ct.name,
+ ct.topiaid
+ INTO cellName, cellTypeName, cellTypeId
+ FROM cell c, celltype ct
+ WHERE c.topiaid = cell_id AND c.celltype = ct.topiaid;
+
+ IF dataProcessingId IS NULL
+ THEN
+-- get voyage infos
+ SELECT
+ v.topiaid,
+ v.name
+ INTO voyageId, voyageName
+ FROM voyage v, cell c
+ WHERE c.topiaid = cellParentId AND v.topiaid = c.voyage;
+ ELSE
+
+-- get dataAcquisition infos
+ SELECT
+ da.topiaid,
+ da.acousticinstrument
+ INTO dataAcquisitionId, dataAcquisitionName
+ FROM dataacquisition da, dataprocessing dp
+ WHERE dp.topiaId = dataProcessingId AND da.topiaid = dp.dataacquisition;
+-- get transect infos
+ SELECT
+ t.topiaid,
+ t.vessel
+ INTO transectId, transitName
+ FROM transect t, dataacquisition da
+ WHERE da.topiaid = dataAcquisitionId AND t.topiaid = da.transect;
+-- get transit infos
+ SELECT
+ t.topiaid,
+ (t.starttime || ' - ' || t.endtime)
+ INTO transitId, transitName
+ FROM transit t, transect tt
+ WHERE tt.topiaid = transectId AND t.topiaid = tt.transit;
+-- get voyage infos
+ SELECT
+ v.topiaid,
+ v.name
+ INTO voyageId, voyageName
+ FROM voyage v, transit t
+ WHERE t.topiaid = transitId AND v.topiaid = t.voyage;
+ END IF;
+ INSERT INTO echobase_cell_spatial (lastUpdateDate, voyageid, voyagename, transitid, transitname, transectid, transectname, dataacquisitionid, dataacquisitionname, dataprocessingid, dataprocessingname, celltypeid, celltypename, cellid, cellname, coordinate, coordinate3d, shape)
+ VALUES (now(), voyageId, voyageName, transitId, transitName, transectId, transectName, dataAcquisitionId, dataAcquisitionName, dataProcessingId, dataProcessingName, cellTypeId, cellTypeName, cell_id, cellName, coordinateData, coordinate3dData, shapeData);
+ ELSE
+-- update row
+ RAISE DEBUG 'Will update spatial cell % ', cell_id;
+ UPDATE echobase_cell_spatial
+ SET coordinate = coordinateData,
+ coordinate3d = coordinate3dData,
+ shape = shapeData
+ WHERE cellid = cell_id;
+ END IF;
+END
+$$ LANGUAGE plpgsql;
+
+-- pour obtenir le type d'une cellule sous forme ESDU - ELEMENTARY - REGION ou MAP
+CREATE OR REPLACE FUNCTION echobase_get_cell_type(cell_id VARCHAR)
+ RETURNS VARCHAR AS $$
+DECLARE result VARCHAR;
+BEGIN
+ SELECT
+ UPPER(ct.id)
+ INTO result
+ FROM celltype ct, cell ce
+ WHERE ce.topiaid = cell_id AND ct.topiaId = ce.celltype;
+ IF 'REGIONCLAS' = result OR 'REGIONSURF' = result
+ THEN
+ result = 'REGION';
+ END IF;
+ RETURN result;
+END
+$$
+LANGUAGE plpgsql;
+
+--------------------------------------------------------------------------------
+-- Table spatial pour les operations -------------------------------------------
+--------------------------------------------------------------------------------
+
+CREATE TABLE echobase_operation_spatial (
+ voyageid VARCHAR(256) NOT NULL,
+ voyagename VARCHAR(256),
+ transitid VARCHAR(256),
+ transitname VARCHAR(256),
+ transectid VARCHAR(256),
+ transectname VARCHAR(256),
+ operationid VARCHAR(256) PRIMARY KEY,
+ operationname VARCHAR(256) NOT NULL,
+ lastUpdateDate TIMESTAMP NOT NULL,
+ FOREIGN KEY (operationid) REFERENCES operation (topiaid),
+ FOREIGN KEY (transectid) REFERENCES transect (topiaid),
+ FOREIGN KEY (transitid) REFERENCES transit (topiaid),
+ FOREIGN KEY (voyageid) REFERENCES voyage (topiaid)
+);
+
+SELECT AddGeometryColumn('echobase_operation_spatial', 'coordinate', 4326, 'POINT',2 );
+
+CREATE INDEX echobase_operation_spatial_coordinate_gix ON echobase_operation_spatial USING GIST (coordinate);
+CREATE INDEX echobase_operation_spatial_voyageid_idx ON echobase_operation_spatial USING BTREE(voyageid);
+
+-- pour stoquer les traitements spatiaux a effectuer
+
+CREATE TABLE echobase_operation_spatial_temp (
+ operationid VARCHAR(256) PRIMARY KEY,
+ FOREIGN KEY (operationid) REFERENCES operation (topiaid)
+);
+
+--
+-- Trigger qui met à jour la table des traitements spatiaux à faire
+--
+
+CREATE OR REPLACE FUNCTION echobase_fill_operation_spatial_temp_table()
+ RETURNS TRIGGER AS $$
+DECLARE
+ operation_id VARCHAR;
+ result RECORD;
+BEGIN
+
+ IF (TG_OP = 'DELETE')
+ THEN
+ result = OLD;
+ ELSE
+ result = NEW;
+ END IF;
+
+ operation_id = result.topiaid;
+
+ IF (SELECT count(*) FROM echobase_operation_spatial_temp c
+ WHERE c.operationid = operation_id) > 0
+ THEN
+-- operation est deja a traitee
+ RETURN result;
+ END IF;
+--- Ajout de l'operation dans la table des traitements à effectuer
+ RAISE DEBUG 'Add operation % to echobase_operation_spatial_temp', operation_id;
+ INSERT INTO echobase_operation_spatial_temp (operationid) VALUES (operation_id);
+ RETURN result;
+END
+$$
+LANGUAGE 'plpgsql';
+
+CREATE TRIGGER echobase_fill_operation_spatial_work_table_trigger
+AFTER INSERT OR UPDATE ON operation
+FOR EACH ROW WHEN (NEW.topiaid IS NOT
+ NULL) EXECUTE PROCEDURE echobase_fill_operation_spatial_temp_table();
+
+--
+-- Trigger qui met à jour la table des traitements spatiaux à faire lors de la
+-- suppression d'une operation
+--
+
+CREATE OR REPLACE FUNCTION echobase_delete_operation()
+ RETURNS TRIGGER AS $$
+BEGIN
+
+ RAISE DEBUG 'Delete operation % , delete cascade in echobase_operation_spatial_table', OLD.topiaid;
+
+ DELETE FROM echobase_operation_spatial WHERE operationid = OLD.topiaid;
+
+ RETURN OLD;
+END
+$$
+LANGUAGE 'plpgsql';
+
+CREATE TRIGGER echobase_delete_operation
+BEFORE DELETE ON operation
+FOR EACH ROW EXECUTE PROCEDURE echobase_delete_operation();
+
+--
+-- Mettre a jour toutes les données spatiales d'operation
+--
+
+CREATE OR REPLACE FUNCTION echobase_compute_all_operation_spatial_data()
+ RETURNS VOID AS $$
+DECLARE operation_id VARCHAR;
+BEGIN
+ DELETE FROM echobase_operation_spatial;
+
+ FOR operation_id IN SELECT topiaid FROM operation LOOP
+ PERFORM echobase_fill_operation_spatial_row(operation_id);
+ END LOOP;
+END
+$$
+LANGUAGE plpgsql;
+
+--
+-- Mettre a jour la table echobase_cell_spatial depuis echobase_operation_spatial_temp
+--
+
+CREATE OR REPLACE FUNCTION echobase_fill_operation_spatial_table()
+ RETURNS VOID AS $$
+DECLARE
+ operationRow RECORD;
+BEGIN
+ FOR operationRow IN SELECT * FROM echobase_operation_spatial_temp LOOP
+
+ PERFORM echobase_fill_operation_spatial_row(operationRow.operationid);
+ END LOOP;
+
+ DELETE FROM echobase_operation_spatial_temp;
+
+END
+$$
+LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION echobase_fill_operation_spatial_row(operation_id VARCHAR)
+ RETURNS VOID AS $$
+ DECLARE
+ spatialText VARCHAR;
+ latitudeNumber REAL;
+ longitudeNumber REAL;
+BEGIN
+ RAISE NOTICE 'Treat spatial operation % ...', operation_id;
+ SELECT o.midHaulLatitude, o.midHaulLongitude
+ INTO latitudeNumber, longitudeNumber FROM operation o
+ WHERE o.topiaid = operation_id;
+
+ SELECT
+ 'SRID=4326;POINT(' || longitudeNumber || ' ' || latitudeNumber || ')'
+ INTO spatialText;
+ RAISE DEBUG 'spatial data % for operation %', spatialText, operation_id;
+
+ PERFORM echobase_create_echobase_operation_spatial_row(operation_id,
+ spatialText);
+END
+$$
+LANGUAGE plpgsql;
+
+-- procedure pour creer (ou mettre à jour) une ligne dans echobase_cell_spatial
+
+CREATE OR REPLACE FUNCTION echobase_create_echobase_operation_spatial_row(
+ operation_id VARCHAR,
+ coordinateText VARCHAR)
+ RETURNS VOID AS $$
+DECLARE
+ operationSpatialRow RECORD;
+ voyageId VARCHAR;
+ voyageName VARCHAR;
+ transitId VARCHAR;
+ transitName VARCHAR;
+ transectId VARCHAR;
+ transectName VARCHAR;
+ operationId VARCHAR;
+ operationName VARCHAR;
+ operationRow RECORD;
+ coordinateData GEOMETRY;
+BEGIN
+ IF coordinateText IS NULL
+ THEN
+ RAISE DEBUG 'Could not find spatial data for operation %', operation_id;
+ RETURN;
+ END IF;
+ BEGIN
+ coordinateData = ST_GeomFromEWKT(coordinateText);
+ EXCEPTION WHEN internal_error
+ THEN
+ RAISE LOG 'Could not create coordinate operation spatial data %', coordinateText;
+ RETURN;
+ END;
+
+ SELECT * INTO operationSpatialRow FROM echobase_operation_spatial os
+ WHERE os.operationid = operation_id;
+ IF NOT FOUND
+ THEN
+-- create row
+ RAISE DEBUG 'Will create spatial operation %', operation_id;
+-- get operation infos
+ SELECT op.id
+ INTO operationName
+ FROM operation op
+ WHERE op.topiaid = operation_id;
+-- get transect infos
+ SELECT
+ t.topiaid,
+ t.vessel
+ INTO transectId, transitName
+ FROM transect t, operation op
+ WHERE op.topiaid = operation_id AND t.topiaid = op.transect;
+-- get transit infos
+ SELECT
+ t.topiaid,
+ (t.starttime || ' - ' || t.endtime)
+ INTO transitId, transitName
+ FROM transit t, transect tt
+ WHERE tt.topiaid = transectId AND t.topiaid = tt.transit;
+-- get voyage infos
+ SELECT
+ v.topiaid,
+ v.name
+ INTO voyageId, voyageName
+ FROM voyage v, transit t
+ WHERE t.topiaid = transitId AND v.topiaid = t.voyage;
+
+ INSERT INTO echobase_operation_spatial (lastUpdateDate, voyageid, voyagename, transitid, transitname, transectid, transectname, operationid, operationname, coordinate)
+ VALUES (now(), voyageId, voyageName, transitId, transitName, transectId, transectName, operation_id, operationName, coordinateData);
+ ELSE
+-- update row
+ RAISE DEBUG 'Will update spatial operation % ', operation_id;
+ UPDATE echobase_operation_spatial
+ SET coordinate = coordinateData
+ WHERE operationid = operation_id;
+ END IF;
+END
+$$ LANGUAGE plpgsql;
+
+--------------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+-- pour convertir des latitudes en dms (+ hemi) en dd
+CREATE OR REPLACE FUNCTION echobase_latitudetext_to_dd(latitude VARCHAR)
+ RETURNS REAL AS $$
+DECLARE
+ degre_ INTEGER;
+ minute_ INTEGER;
+ second_ INTEGER;
+ hemi_ VARCHAR(1);
+BEGIN
+ SELECT
+ right(latitude, 1),
+ left(latitude, 2) :: INTEGER,
+ substring(latitude FROM 3 FOR 2) :: INTEGER,
+ substring(latitude FROM 6 FOR 3) :: INTEGER
+ INTO hemi_, degre_, minute_, second_;
+
+ RETURN echobase_dms2dd(degre_, minute_, second_, hemi_);
+ EXCEPTION WHEN invalid_text_representation
+ THEN
+ RETURN NULL;
+END
+$$ LANGUAGE plpgsql;
+
+-- pour convertir des longitudes en dms (+ hemi) en dd
+CREATE OR REPLACE FUNCTION echobase_longitudetext_to_dd(longitude VARCHAR)
+ RETURNS REAL AS $$
+DECLARE
+ degre_ INTEGER;
+ minute_ INTEGER;
+ second_ INTEGER;
+ hemi_ VARCHAR(1);
+BEGIN
+ SELECT
+ right(longitude, 1),
+ left(longitude, 3) :: INTEGER,
+ substring(longitude FROM 4 FOR 2) :: INTEGER,
+ substring(longitude FROM 7 FOR 3) :: INTEGER
+ INTO hemi_, degre_, minute_, second_;
+
+ RETURN echobase_dms2dd(degre_, minute_, second_, hemi_);
+ EXCEPTION WHEN invalid_text_representation
+ THEN
+ RETURN NULL;
+END
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION echobase_dms2dd(
+ D INTEGER, M INTEGER, S INTEGER, HEMI CHARACTER VARYING(1)
+)
+ RETURNS DOUBLE PRECISION AS $$
+DECLARE
+ ret DOUBLE PRECISION;
+ dir INTEGER;
+BEGIN
+ dir := 1;
+--init to 1 for default positive return
+ ret := 0;
+--init to zero.
+ --ONLY S or W will trip this. Any other letter or NULL will result in positive return value
+ IF UPPER(HEMI) = 'S' OR UPPER(HEMI) = 'W'
+ THEN
+ dir := -1; --then southern or western hemisphere
+ END IF;
+--SOME data has negative values in minutes and seconds as well as degrees. Use ABS to standardize all three.
+ ret := (ABS(CAST(D AS DOUBLE PRECISION)) + (ABS((CAST(M AS DOUBLE PRECISION) +
+ (ABS((CAST(S AS
+ DOUBLE PRECISION))
+ / 60))) / 60)));
+ ret := ret * dir;
+ RETURN ret;
+
+END;
+$$ LANGUAGE plpgsql;
+
+--------------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--
+-- Mettre a jour toutes les données spatiales
+--
+
+CREATE OR REPLACE FUNCTION echobase_compute_all_spatial_data()
+ RETURNS VOID AS $$
+DECLARE cell_id VARCHAR;
+BEGIN
+ EXECUTE echobase_compute_all_operation_spatial_data();
+ EXECUTE echobase_compute_all_cell_spatial_data();
+END
+$$
+LANGUAGE plpgsql;
+
+
+-- Compute all data
+SELECT echobase_compute_all_cell_spatial_data();
+SELECT echobase_compute_all_operation_spatial_data();
\ No newline at end of file
Added: trunk/echobase-services/src/main/resources/postgis-view.sql
===================================================================
--- trunk/echobase-services/src/main/resources/postgis-view.sql (rev 0)
+++ trunk/echobase-services/src/main/resources/postgis-view.sql 2013-12-16 15:16:01 UTC (rev 908)
@@ -0,0 +1,269 @@
+-- ajout de vues liés aux tables spatiales
+
+DROP VIEW IF EXISTS echobase_spatial_cell_result;
+CREATE OR REPLACE VIEW echobase_spatial_cell_result AS
+ SELECT
+ s.*,
+ m.topiaId AS metaDataId,
+ m.name AS metaDataName,
+ r.resultvalue AS resultValue,
+ r.topiaid AS resultId
+ FROM
+ echobase_cell_spatial s,
+ result r,
+ datametadata m
+ WHERE
+ s.cellid = r.cell AND
+ r.datametadata = m.topiaid;
+
+DROP VIEW IF EXISTS echobase_spatial_cell_data;
+CREATE OR REPLACE VIEW echobase_spatial_cell_data AS
+ SELECT
+ s.*,
+ m.topiaId AS metaDataId,
+ m.name AS metaDataName,
+ d.datavalue AS dataValue,
+ d.topiaid AS dataId
+ FROM
+ echobase_cell_spatial s,
+ data d,
+ datametadata m
+ WHERE
+ s.cellid = d.cell AND
+ d.datametadata = m.topiaid;
+
+DROP VIEW IF EXISTS TotalSampleEngrEnc;
+CREATE OR REPLACE VIEW TotalSampleEngrEnc AS
+
+ SELECT
+ echobase_operation_spatial.voyageid,
+ operation.id AS operation_id,
+ echobase_operation_spatial.coordinate,
+ sampletype.name AS sampletype_name,
+ sample.sampleweight,
+ sizecategory.name AS sizecategory_name,
+ species.baracoudacode,
+ sample.topiaid
+ FROM
+ echobase_operation_spatial,
+ operation,
+ sample,
+ speciescategory,
+ sizecategory,
+ species,
+ sampletype
+ WHERE
+ echobase_operation_spatial.operationid = operation.topiaid AND
+ operation.topiaid = sample.operation AND
+ sample.speciescategory = speciescategory.topiaid AND
+ sample.sampletype = sampletype.topiaid AND
+ speciescategory.sizecategory = sizecategory.topiaid AND
+ speciescategory.species = species.topiaid AND
+ sampletype.name = 'Total' AND
+ species.baracoudacode = 'ENGR-ENC';
+
+DROP VIEW IF EXISTS TotalSampleSardPil;
+CREATE OR REPLACE VIEW TotalSampleSardPil AS
+ SELECT
+ echobase_operation_spatial.voyageid,
+ operation.id AS operation_id,
+ echobase_operation_spatial.coordinate,
+ sampletype.name AS sampletype_name,
+ sample.sampleweight,
+ sizecategory.name AS sizecategory_name,
+ species.baracoudacode,
+ sample.topiaid
+ FROM
+ echobase_operation_spatial,
+ operation,
+ sample,
+ speciescategory,
+ sizecategory,
+ species,
+ sampletype
+ WHERE
+ echobase_operation_spatial.operationid = operation.topiaid AND
+ operation.topiaid = sample.operation AND
+ sample.speciescategory = speciescategory.topiaid AND
+ sample.sampletype = sampletype.topiaid AND
+ speciescategory.sizecategory = sizecategory.topiaid AND
+ speciescategory.species = species.topiaid AND
+ sampletype.name = 'Total' AND
+ species.baracoudacode = 'SARD-PIL';
+
+DROP VIEW IF EXISTS TotalSampleTracTru;
+CREATE OR REPLACE VIEW TotalSampleTracTru AS
+ SELECT
+ echobase_operation_spatial.voyageid,
+ operation.id AS operation_id,
+ echobase_operation_spatial.coordinate,
+ sampletype.name AS sampletype_name,
+ sample.sampleweight,
+ sizecategory.name AS sizecategory_name,
+ species.baracoudacode,
+ sample.topiaid
+ FROM
+ echobase_operation_spatial,
+ operation,
+ sample,
+ speciescategory,
+ sizecategory,
+ species,
+ sampletype
+ WHERE
+ echobase_operation_spatial.operationid = operation.topiaid AND
+ operation.topiaid = sample.operation AND
+ sample.speciescategory = speciescategory.topiaid AND
+ sample.sampletype = sampletype.topiaid AND
+ speciescategory.sizecategory = sizecategory.topiaid AND
+ speciescategory.species = species.topiaid AND
+ sampletype.name = 'Total' AND
+ species.baracoudacode = 'TRAC-TRU';
+
+DROP VIEW IF EXISTS TotalSampleSpraSpr;
+CREATE OR REPLACE VIEW TotalSampleSpraSpr AS
+ SELECT
+ echobase_operation_spatial.voyageid,
+ operation.id AS operation_id,
+ echobase_operation_spatial.coordinate,
+ sampletype.name AS sampletype_name,
+ sample.sampleweight,
+ sizecategory.name AS sizecategory_name,
+ species.baracoudacode,
+ sample.topiaid
+ FROM
+ echobase_operation_spatial,
+ operation,
+ sample,
+ speciescategory,
+ sizecategory,
+ species,
+ sampletype
+ WHERE
+ echobase_operation_spatial.operationid = operation.topiaid AND
+ operation.topiaid = sample.operation AND
+ sample.speciescategory = speciescategory.topiaid AND
+ sample.sampletype = sampletype.topiaid AND
+ speciescategory.sizecategory = sizecategory.topiaid AND
+ speciescategory.species = species.topiaid AND
+ sampletype.name = 'Total' AND
+ species.baracoudacode = 'SPRA-SPR';
+
+DROP VIEW IF EXISTS TotalSampleScomSco;
+CREATE OR REPLACE VIEW TotalSampleScomSco AS
+ SELECT
+ echobase_operation_spatial.voyageid,
+ operation.id AS operation_id,
+ echobase_operation_spatial.coordinate,
+ sampletype.name AS sampletype_name,
+ sample.sampleweight,
+ sizecategory.name AS sizecategory_name,
+ species.baracoudacode,
+ sample.topiaid
+ FROM
+ echobase_operation_spatial,
+ operation,
+ sample,
+ speciescategory,
+ sizecategory,
+ species,
+ sampletype
+ WHERE
+ echobase_operation_spatial.operationid = operation.topiaid AND
+ operation.topiaid = sample.operation AND
+ sample.speciescategory = speciescategory.topiaid AND
+ sample.sampletype = sampletype.topiaid AND
+ speciescategory.sizecategory = sizecategory.topiaid AND
+ speciescategory.species = species.topiaid AND
+ sampletype.name = 'Total' AND
+ species.baracoudacode = 'SCOM-SCO';
+
+DROP VIEW IF EXISTS TotalSampleMicrPou;
+CREATE OR REPLACE VIEW TotalSampleMicrPou AS
+ SELECT
+ echobase_operation_spatial.voyageid,
+ operation.id AS operation_id,
+ echobase_operation_spatial.coordinate,
+ sampletype.name AS sampletype_name,
+ sample.sampleweight,
+ sizecategory.name AS sizecategory_name,
+ species.baracoudacode,
+ sample.topiaid
+ FROM
+ echobase_operation_spatial,
+ operation,
+ sample,
+ speciescategory,
+ sizecategory,
+ species,
+ sampletype
+ WHERE
+ echobase_operation_spatial.operationid = operation.topiaid AND
+ operation.topiaid = sample.operation AND
+ sample.speciescategory = speciescategory.topiaid AND
+ sample.sampletype = sampletype.topiaid AND
+ speciescategory.sizecategory = sizecategory.topiaid AND
+ speciescategory.species = species.topiaid AND
+ sampletype.name = 'Total' AND
+ species.baracoudacode = 'MICR-POU';
+
+-- Create a view with species catches as columns
+
+DROP VIEW IF EXISTS TotalCatchSpOpWide;
+CREATE OR REPLACE VIEW TotalCatchSpOpWide AS
+ SELECT
+ echobase_operation_spatial.voyagename,
+ echobase_operation_spatial.operationname,
+ echobase_operation_spatial.coordinate,
+ (SELECT
+ SUM(totalsampleengrenc.sampleweight)
+ FROM totalsampleengrenc
+ WHERE totalsampleengrenc.operation_id =
+ echobase_operation_spatial.operationname) AS TotalCatchENGRENC,
+ (SELECT
+ SUM(totalsamplesardpil.sampleweight)
+ FROM totalsamplesardpil
+ WHERE totalsamplesardpil.operation_id =
+ echobase_operation_spatial.operationname) AS TotalCatchSARDPIL,
+ (SELECT
+ SUM(totalsamplespraspr.sampleweight)
+ FROM totalsamplespraspr
+ WHERE totalsamplespraspr.operation_id =
+ echobase_operation_spatial.operationname) AS TotalCatchSPRASPR,
+ (SELECT
+ SUM(totalsamplemicrpou.sampleweight)
+ FROM totalsamplemicrpou
+ WHERE totalsamplemicrpou.operation_id =
+ echobase_operation_spatial.operationname) AS TotalCatchMICRPOU,
+ (SELECT
+ SUM(totalsamplescomsco.sampleweight)
+ FROM totalsamplescomsco
+ WHERE totalsamplescomsco.operation_id =
+ echobase_operation_spatial.operationname) AS TotalCatchSCOMSCO,
+ (SELECT
+ SUM(totalsampletractru.sampleweight)
+ FROM totalsampletractru
+ WHERE totalsampletractru.operation_id =
+ echobase_operation_spatial.operationname) AS TotalCatchTRACTRU,
+ echobase_operation_spatial.operationid
+ FROM echobase_operation_spatial;
+
+DROP VIEW IF EXISTS cellmapview;
+CREATE OR REPLACE VIEW cellmapview AS
+ SELECT
+ echobase_cell_spatial.voyagename,
+ echobase_cell_spatial.coordinate,
+ echobase_cell_spatial.shape,
+ datametadata.name,
+ result.resultvalue,
+ species.baracoudacode,
+ echobase_cell_spatial.cellname,
+ result.topiaid AS resultid
+ FROM echobase_cell_spatial, result, datametadata, category, speciescategory,
+ species
+ WHERE echobase_cell_spatial.cellid = result.cell
+ AND result.datametadata = datametadata.topiaid
+ AND result.category = category.topiaid
+ AND category.speciescategory = speciescategory.topiaid
+ AND speciescategory.species = species.topiaid
+ AND echobase_cell_spatial.celltypename = 'Map cell';
\ No newline at end of file
1
0