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 2011
- 2 participants
- 86 discussions
r208 - in trunk/echobase-ui/src/main/env: dev/resources prod/resources
by tchemit@users.forge.codelutin.com 20 Dec '11
by tchemit@users.forge.codelutin.com 20 Dec '11
20 Dec '11
Author: tchemit
Date: 2011-12-20 10:21:01 +0100 (Tue, 20 Dec 2011)
New Revision: 208
Url: http://forge.codelutin.com/repositories/revision/echobase/208
Log:
increase topia log levels
Modified:
trunk/echobase-ui/src/main/env/dev/resources/log4j.properties
trunk/echobase-ui/src/main/env/prod/resources/log4j.properties
Modified: trunk/echobase-ui/src/main/env/dev/resources/log4j.properties
===================================================================
--- trunk/echobase-ui/src/main/env/dev/resources/log4j.properties 2011-12-19 23:15:41 UTC (rev 207)
+++ trunk/echobase-ui/src/main/env/dev/resources/log4j.properties 2011-12-20 09:21:01 UTC (rev 208)
@@ -33,5 +33,6 @@
log4j.logger.fr.ifremer.echobase=INFO
log4j.logger.org.nuiton=WARN
log4j.logger.org.nuiton.topia.migration=INFO
+log4j.logger.org.nuiton.topia.replication=INFO
log4j.logger.com.opensymphony.xwork2.util.logging.commons.CommonsLogger=ERROR
log4j.logger.org.apache.struts2.util.TokenHelper=ERROR
Modified: trunk/echobase-ui/src/main/env/prod/resources/log4j.properties
===================================================================
--- trunk/echobase-ui/src/main/env/prod/resources/log4j.properties 2011-12-19 23:15:41 UTC (rev 207)
+++ trunk/echobase-ui/src/main/env/prod/resources/log4j.properties 2011-12-20 09:21:01 UTC (rev 208)
@@ -31,5 +31,6 @@
log4j.logger.fr.ifremer.echobase=INFO
log4j.logger.org.nuiton.topia.migration=INFO
+log4j.logger.org.nuiton.topia.replication=INFO
log4j.logger.com.opensymphony.xwork2.util.logging.commons.CommonsLogger=ERROR
log4j.logger.org.apache.struts2.util.TokenHelper=ERROR
1
0
r207 - trunk/echobase-services/src/main/java/fr/ifremer/echobase/services
by tchemit@users.forge.codelutin.com 19 Dec '11
by tchemit@users.forge.codelutin.com 19 Dec '11
19 Dec '11
Author: tchemit
Date: 2011-12-20 00:15:41 +0100 (Tue, 20 Dec 2011)
New Revision: 207
Url: http://forge.codelutin.com/repositories/revision/echobase/207
Log:
fix association loading
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java 2011-12-19 21:56:39 UTC (rev 206)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java 2011-12-19 23:15:41 UTC (rev 207)
@@ -271,8 +271,22 @@
ImportToMap importer = MyImportToMap.newImport(model, reader);
StringBuilder builder = new StringBuilder();
+
try {
- String updateString = "UPDATE " + target.getContract().getSimpleName() + " SET " + source.getContract().getSimpleName() + " = '%s' WHERE topiaId ='%s';";
+ String updateString;
+ String targetTableName = target.getContract().getSimpleName();
+ String sourceTableName = source.getContract().getSimpleName();
+ String table = targetTableName;
+ if (source == EchoBaseEntityEnum.Voyage && target == EchoBaseEntityEnum.Echotype) {
+ table = targetTableName + "_" + sourceTableName;
+ updateString = "UPDATE " + table + " SET " + sourceTableName + " = '%s' WHERE " + meta.getName() + " ='%s';";
+ } else if (source == EchoBaseEntityEnum.Voyage && target == EchoBaseEntityEnum.Strata) {
+ table = targetTableName + "_" + source.getContract().getSimpleName();
+ updateString = "UPDATE " + table + " SET " + sourceTableName + " = '%s' WHERE " + meta.getName() + " ='%s';";
+ } else {
+ updateString = "UPDATE " + table + " SET " + sourceTableName + " = '%s' WHERE topiaId ='%s';";
+ }
+
if (log.isDebugEnabled()) {
log.debug("Will apply " + updateString);
}
@@ -283,7 +297,7 @@
for (String association : associations) {
builder.append(String.format(updateString, topiaId, association)).append('\n');
compt++;
- if (compt == 10000) {
+ if (compt % 10000 == 0) {
// flush it
getTransaction().executeSQL(builder.toString());
builder = new StringBuilder();
@@ -291,6 +305,9 @@
}
csvResult.incrementsNumberUpdated();
}
+ if (builder.length() > 0) {
+ getTransaction().executeSQL(builder.toString());
+ }
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(
"Could not execute sql script", eee);
1
0
Author: tchemit
Date: 2011-12-19 22:56:39 +0100 (Mon, 19 Dec 2011)
New Revision: 206
Url: http://forge.codelutin.com/repositories/revision/echobase/206
Log:
optimize dependencies
Modified:
trunk/echobase-services/pom.xml
Modified: trunk/echobase-services/pom.xml
===================================================================
--- trunk/echobase-services/pom.xml 2011-12-19 21:45:05 UTC (rev 205)
+++ trunk/echobase-services/pom.xml 2011-12-19 21:56:39 UTC (rev 206)
@@ -102,6 +102,11 @@
<artifactId>topia-service-replication</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
1
0
r205 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase/entities echobase-services/src/main/java/fr/ifremer/echobase/services echobase-ui/src/main/env/dev/resources echobase-ui/src/main/env/prod/resources
by tchemit@users.forge.codelutin.com 19 Dec '11
by tchemit@users.forge.codelutin.com 19 Dec '11
19 Dec '11
Author: tchemit
Date: 2011-12-19 22:45:05 +0100 (Mon, 19 Dec 2011)
New Revision: 205
Url: http://forge.codelutin.com/repositories/revision/echobase/205
Log:
improve DbImportService
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java
trunk/echobase-ui/src/main/env/dev/resources/log4j.properties
trunk/echobase-ui/src/main/env/prod/resources/log4j.properties
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-19 19:18:47 UTC (rev 204)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-19 21:45:05 UTC (rev 205)
@@ -175,6 +175,8 @@
result.add(EchoBaseEntityEnum.OperationMetadata);
result.add(EchoBaseEntityEnum.GearMetadata);
result.add(EchoBaseEntityEnum.Gear);
+ result.add(EchoBaseEntityEnum.LengthAgeKey);
+ result.add(EchoBaseEntityEnum.LengthWeightKey);
return result.toArray(new EchoBaseEntityEnum[result.size()]);
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java 2011-12-19 19:18:47 UTC (rev 204)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java 2011-12-19 21:45:05 UTC (rev 205)
@@ -38,6 +38,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.StringUtil;
@@ -99,10 +100,6 @@
log.warn("There is " + missingEntries.size() + "missing mandatory files " +
" in import " + file + "\n" + StringUtil.join(missingEntries, "\n", false));
}
-
-// throw new EchoBaseTechnicalException(
-// "There is some missing mandatory files " +
-// missingEntries + " in import " + file);
}
return result;
@@ -187,125 +184,120 @@
}
- public <E extends TopiaEntity> void importFile(MetaFilenameAware entry,
- Reader reader,
- CsvImportResult csvResult) throws IOException {
+ public void importFile(MetaFilenameAware entry,
+ Reader reader,
+ CsvImportResult csvResult) throws IOException, TopiaException {
- DbEditorService service = getDbEditorService();
- long s0;
+ long s0 = TimeLog.getTime();
- s0 = TimeLog.getTime();
+ if (log.isInfoEnabled()) {
+ log.info("Will import " + entry);
+ }
if (entry instanceof AssociationMeta) {
// load a association input
+ importAssociationfile((AssociationMeta) entry, reader, csvResult);
- AssociationMeta meta = (AssociationMeta) entry;
+ } else {
- if (log.isInfoEnabled()) {
- log.info("Will import " + meta);
- }
+ // normal entity table import
+ importEntityFile((TableMeta) entry, reader, csvResult);
+ }
- EchoBaseEntityEnum source = meta.getSource();
- EchoBaseEntityEnum target = meta.getTarget();
- timeLog.log(s0, "importFile::getTargetEntities");
-// List<TopiaEntity> targetEntities = getEntities(target);
-// Map<String, TopiaEntity> targetsById =
-// Maps.uniqueIndex(targetEntities, EchoBaseFunctions.TO_TOPIAID);
+ timeLog.log(s0, "importFile::done");
- ImportModel<Map<String, Object>> model =
- EntityAssociationImportModel.newImportModel(
- getConfiguration().getCsvSeparator(),
- meta
- );
+ s0 = TimeLog.getTime();
-// EchoBaseEntityEnum sourceType = meta.getSource();
+ flushTransaction();
- ImportToMap importer = MyImportToMap.newImport(model, reader);
+ timeLog.log(s0, "importFile::flushTransaction");
+ }
- s0 = TimeLog.getTime();
-// List<E> sourceEntities = getEntities(sourceType);
- timeLog.log(s0, "importFile::getSourceEntities");
-// Map<String, E> sourcesById =
-// Maps.uniqueIndex(sourceEntities, EchoBaseFunctions.TO_TOPIAID);
- StringBuilder builder = new StringBuilder();
- try {
- s0 = TimeLog.getTime();
- String updateString = "UPDATE " + target.getContract().getSimpleName() + " SET " + source.getContract().getSimpleName() + " = '%s' WHERE topiaId ='%s';";
- if (log.isInfoEnabled()) {
- log.info("Will apply " + updateString);
- }
- int compt = 0;
- for (Map<String, Object> row : importer) {
- String topiaId = (String) row.get(TopiaEntity.TOPIA_ID);
- String[] associations = (String[]) row.get("target");
- for (String association : associations) {
- builder.append(String.format(updateString, topiaId, association)).append('\n');
- compt++;
- if (compt == 10000) {
- // flush it
- getTransaction().executeSQL(builder.toString());
- builder = new StringBuilder();
- }
- }
- csvResult.incrementsNumberUpdated();
- }
- timeLog.log(s0, "importFile::import");
- } catch (TopiaException eee) {
- throw new EchoBaseTechnicalException(
- "Could not execute sql script", eee);
- } finally {
+ public MetaFilenameAware[] getEntries() {
- importer.close();
- }
+ List<MetaFilenameAware> entities = Lists.newArrayList();
+ List<MetaFilenameAware> associations = Lists.newArrayList();
- } else {
+ addEntries(entities, associations, EntitiesUtil.getReferenceTypesForCopy());
+ addEntries(entities, associations, EntitiesUtil.getDataTypesforCopy());
+ entities.addAll(associations);
+ return entities.toArray(new MetaFilenameAware[entities.size()]);
+ }
- // normal entity table import
+ protected void importEntityFile(TableMeta meta, Reader reader, CsvImportResult csvResult) {
- TableMeta meta = (TableMeta) entry;
+ ImportModel<TopiaEntity> model = getDbEditorService().buildForImport(meta);
- if (log.isInfoEnabled()) {
- log.info("Will import " + meta);
- }
+ Import<TopiaEntity> importer = Import.newImport(model, reader);
- ImportModel<TopiaEntity> model = service.buildForImport(meta);
+ try {
+ TopiaDAO<TopiaEntity> dao = getDAO(meta.getSource());
+ for (TopiaEntity entity : importer) {
- Import<TopiaEntity> importer = Import.newImport(model, reader);
+ TopiaEntity entityToSave = dao.create(TopiaEntity.TOPIA_ID,
+ entity.getTopiaId());
- try {
- TopiaDAO<TopiaEntity> dao = getDAO(meta.getSource());
- s0 = TimeLog.getTime();
- for (TopiaEntity entity : importer) {
+ meta.copy(entity, entityToSave);
- TopiaEntity entityToSave = dao.create(TopiaEntity.TOPIA_ID,
- entity.getTopiaId());
+ csvResult.incrementsNumberUpdated();
+ }
- meta.copy(entity, entityToSave);
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException("Could not import entities of type " + meta.getSource(), eee);
+ } finally {
- csvResult.incrementsNumberUpdated();
- }
- timeLog.log(s0, "importFile::import");
- } catch (Exception eee) {
- throw new EchoBaseTechnicalException("Could not import entities of type " + meta.getSource(), eee);
- } finally {
-
- importer.close();
- }
+ importer.close();
}
}
- public MetaFilenameAware[] getEntries() {
+ protected void flushTransaction() throws TopiaException {
+ TopiaContextImplementor tx = (TopiaContextImplementor) getTransaction();
+ tx.getHibernate().flush();
+ }
- List<MetaFilenameAware> entities = Lists.newArrayList();
- List<MetaFilenameAware> associations = Lists.newArrayList();
+ protected void importAssociationfile(AssociationMeta meta, Reader reader, CsvImportResult csvResult) {
+ EchoBaseEntityEnum source = meta.getSource();
+ EchoBaseEntityEnum target = meta.getTarget();
- addEntries(entities, associations, EntitiesUtil.getReferenceTypesForCopy());
- addEntries(entities, associations, EntitiesUtil.getDataTypesforCopy());
- entities.addAll(associations);
- return entities.toArray(new MetaFilenameAware[entities.size()]);
+ ImportModel<Map<String, Object>> model =
+ EntityAssociationImportModel.newImportModel(
+ getConfiguration().getCsvSeparator(),
+ meta
+ );
+
+ ImportToMap importer = MyImportToMap.newImport(model, reader);
+
+ StringBuilder builder = new StringBuilder();
+ try {
+ String updateString = "UPDATE " + target.getContract().getSimpleName() + " SET " + source.getContract().getSimpleName() + " = '%s' WHERE topiaId ='%s';";
+ if (log.isDebugEnabled()) {
+ log.debug("Will apply " + updateString);
+ }
+ int compt = 0;
+ for (Map<String, Object> row : importer) {
+ String topiaId = (String) row.get(TopiaEntity.TOPIA_ID);
+ String[] associations = (String[]) row.get("target");
+ for (String association : associations) {
+ builder.append(String.format(updateString, topiaId, association)).append('\n');
+ compt++;
+ if (compt == 10000) {
+ // flush it
+ getTransaction().executeSQL(builder.toString());
+ builder = new StringBuilder();
+ }
+ }
+ csvResult.incrementsNumberUpdated();
+ }
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(
+ "Could not execute sql script", eee);
+ } finally {
+
+ importer.close();
+ }
}
protected TableMeta getTableMeta(EchoBaseEntityEnum tableName) {
Modified: trunk/echobase-ui/src/main/env/dev/resources/log4j.properties
===================================================================
--- trunk/echobase-ui/src/main/env/dev/resources/log4j.properties 2011-12-19 19:18:47 UTC (rev 204)
+++ trunk/echobase-ui/src/main/env/dev/resources/log4j.properties 2011-12-19 21:45:05 UTC (rev 205)
@@ -34,3 +34,4 @@
log4j.logger.org.nuiton=WARN
log4j.logger.org.nuiton.topia.migration=INFO
log4j.logger.com.opensymphony.xwork2.util.logging.commons.CommonsLogger=ERROR
+log4j.logger.org.apache.struts2.util.TokenHelper=ERROR
Modified: trunk/echobase-ui/src/main/env/prod/resources/log4j.properties
===================================================================
--- trunk/echobase-ui/src/main/env/prod/resources/log4j.properties 2011-12-19 19:18:47 UTC (rev 204)
+++ trunk/echobase-ui/src/main/env/prod/resources/log4j.properties 2011-12-19 21:45:05 UTC (rev 205)
@@ -32,3 +32,4 @@
log4j.logger.fr.ifremer.echobase=INFO
log4j.logger.org.nuiton.topia.migration=INFO
log4j.logger.com.opensymphony.xwork2.util.logging.commons.CommonsLogger=ERROR
+log4j.logger.org.apache.struts2.util.TokenHelper=ERROR
1
0
Author: tchemit
Date: 2011-12-19 20:18:47 +0100 (Mon, 19 Dec 2011)
New Revision: 204
Url: http://forge.codelutin.com/repositories/revision/echobase/204
Log:
update reunion CR
Modified:
trunk/src/doc/reunions/reunion-2011-12-19.txt
Modified: trunk/src/doc/reunions/reunion-2011-12-19.txt
===================================================================
--- trunk/src/doc/reunions/reunion-2011-12-19.txt 2011-12-19 19:16:34 UTC (rev 203)
+++ trunk/src/doc/reunions/reunion-2011-12-19.txt 2011-12-19 19:18:47 UTC (rev 204)
@@ -9,39 +9,55 @@
--------
- Revoir quelques points sur le modèle
+- Discuter de l'import des nouvelles campagnes
Modèle pêche
------------
-- SpeciesCategory ?
-- Sample est lié à SpeciesCategory et Species ?
-- LengthAgeKey ?
-- WeightLengthKey ?
-- BiometryScale ?
+SizeCategory et SexCategory sont inversés.
-Import nouvelles données
-------------------------
+- SpeciesCategory On remplit la table lors de l'insertion des Samples
-- Planning ?
+ - pour Unsorted : on utilise le code 0 de la taille (SizeCategory)?
+ - pour le Total et Subsample : le code taille (SizeCategory) = CATEG
+ - pour individual : juste Species renseignés dans SpeciesCategory.
-Réalisation modèle pêche
+- Sample est lié à SpeciesCategory et Species ? Non on supprime le lien vers Species.
+
+- LengthAgeKey ? Remplir à partir de CLE_TAILLE_AGE
+
+- LengthWeightKey ? et pas WeightLengthKey... A remplir depuis TAILLE_POIDS
+
+ quand categorie = NA ou H alors utiliser 0
+
+ Enregistrer à nulle le numberSampled si pas de données (pas de 0)
+
+Supprimer entité BiometryScale
+
+Trouver comment mettre sur une même ligne toutes les SampleData d'un même Sample.
+
+TODO Voir comment corriger les problèmes d'encoding dans Libre-Office.
+
+- Faire un export globale de la base sur le même format que l'import de la base complête
+- Lors d'un ré-import, ne pas écraser le référentiel
+- Proposer à l'utilisateur le mode d'import : écraser ou pas les données.
+
+- Modifier Se connecter à la base : sur demo l'url est jdbc:postgresql://localhost/echobase localhost
+
+autoriser cette ip 134.246.53.25 sur le pg de demo
+
+- Ajouter une utiliser lecture seule sur la base.
+
+Réflechir sur comment effecuter les nouveaux import.
+
+Import nouvelles données
------------------------
-- Report des modifications du modèle
-- Remplissage du référentiel OperationEvent
-- Remplissage du référentiel SampleDataType
-- Remplissage du référentiel SampleType
-- Création entité BiometryScale
-- Remplissage du référentiel BiometryScale
-- Remplissage du référentiel SexCategory
-- Remplissage du référentiel SizeCategory
-- Remplissage du référentiel OperationMetadata
-- Remplissage du référentiel GearMetadata
-- Remplissage du référentiel Gear
+- On commnce ça début janvier
+- On se base sur le système déjà existant utilisé pour l'import d'une
+ base complête, sauf pour les clef étrangère et les associations où on utilise
+ non plus les identifiants techniques (topiaId) mais des clefs métiers.
-- Import des opérations (depuis table STATIONS)
-- Import des samples (depuis table CAPTURES/MENSURATIONS/BIOMETRIE_VALEURS)
-
Action
------
@@ -55,4 +71,4 @@
Prochaine réunion :
- - Lundi 19 à 10h00 à l'Ifremer avec Mathieu
\ No newline at end of file
+ - Mercredi 4 janvier 10h00 à l'Ifremer avec Mathieu
\ No newline at end of file
1
0
r203 - in trunk/echobase-tools: . src/main/java/fr/ifremer/echobase/tools/loaders src/test/java/fr/ifremer/echobase/tools/loaders src/test/resources/csv/new
by tchemit@users.forge.codelutin.com 19 Dec '11
by tchemit@users.forge.codelutin.com 19 Dec '11
19 Dec '11
Author: tchemit
Date: 2011-12-19 20:16:34 +0100 (Mon, 19 Dec 2011)
New Revision: 203
Url: http://forge.codelutin.com/repositories/revision/echobase/203
Log:
continue catches import
Added:
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoader.java
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoader.java
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoaderIT.java
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoaderIT.java
Removed:
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoader.java
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoaderIT.java
trunk/echobase-tools/src/test/resources/csv/new/input-BiometryScale.csv
Modified:
trunk/echobase-tools/pom.xml
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/OperationLoader.java
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SampleLoader.java
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SpeciesCategoryLoader.java
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/AbstractLoaderIT.java
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/OperationLoaderIT.java
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SampleLoaderIT.java
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SpeciesCategoryLoaderIT.java
trunk/echobase-tools/src/test/resources/csv/new/input-SexCategory.csv
trunk/echobase-tools/src/test/resources/csv/new/input-SizeCategory.csv
Modified: trunk/echobase-tools/pom.xml
===================================================================
--- trunk/echobase-tools/pom.xml 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/pom.xml 2011-12-19 19:16:34 UTC (rev 203)
@@ -65,7 +65,7 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
-
+
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
@@ -213,7 +213,7 @@
<testResource>
<directory>src/test/resources</directory>
<includes>
- <include>**/*.properties</include>
+ <include>**/*.*</include>
</includes>
</testResource>
</testResources>
Deleted: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoader.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoader.java 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoader.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -1,67 +0,0 @@
-/*
- * #%L
- * EchoBase :: Tools
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 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%
- */
-package fr.ifremer.echobase.tools.loaders;
-
-import fr.ifremer.echobase.EchoBaseFunctions;
-import fr.ifremer.echobase.entities.meta.TableMeta;
-import fr.ifremer.echobase.entities.references.BiometryScale;
-import fr.ifremer.echobase.entities.references.SampleDataType;
-import fr.ifremer.echobase.services.models.EntityCsvModel;
-import fr.ifremer.echobase.tools.FileType;
-
-import java.util.List;
-
-/**
- * {@link BiometryScale} loader.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class BiometryScaleLoader extends EntityLoader<BiometryScale> {
-
- public BiometryScaleLoader() {
- super(BiometryScale.class, FileType.NEW);
- }
-
- @Override
- protected EntityCsvModel<BiometryScale> createCsvImportModel(TableMeta meta) {
-
- List<SampleDataType> sampleDataTypes =
- getEntities(SampleDataType.class);
-
- EntityCsvModel<BiometryScale> model = EntityCsvModel.newModel(
- getCsvSeparator(),
- meta
- );
-
- /*
- raptriBiometryDataType;ScaleCode;ScaleMeaningEng;ScaleMeaningFr
- */
- model.addForeignKeyForImport("raptriBiometryDataType", BiometryScale.PROPERTY_SAMPLE_DATA_TYPE, SampleDataType.class, sampleDataTypes, EchoBaseFunctions.SAMPLE_DATA_TYPE_RAPTRI_CODE);
- model.addDefaultColumn("ScaleCode",BiometryScale.PROPERTY_CODE, int.class);
- model.newMandatoryColumn("ScaleMeaningEng",BiometryScale.PROPERTY_MEANING_EN);
- model.newMandatoryColumn("ScaleMeaningFr",BiometryScale.PROPERTY_MEANING_FR);
- return model;
- }
-}
\ No newline at end of file
Added: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoader.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoader.java (rev 0)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoader.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -0,0 +1,102 @@
+/*
+ * #%L
+ * EchoBase :: Tools
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 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%
+ */
+package fr.ifremer.echobase.tools.loaders;
+
+import com.google.common.collect.Lists;
+import com.healthmarketscience.jackcess.Database;
+import fr.ifremer.echobase.EchoBaseFunctions;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.references.LengthAgeKey;
+import fr.ifremer.echobase.entities.references.Species;
+import fr.ifremer.echobase.tools.FileType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * {@link LengthAgeKey} loader.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class LengthAgeKeyLoader extends EntityLoader<LengthAgeKey> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(LengthAgeKeyLoader.class);
+
+ public LengthAgeKeyLoader() {
+ super(LengthAgeKey.class, EchoBaseEntityEnum.Voyage,
+ Voyage.PROPERTY_LENGTH_AGE_KEY,
+ FileType.BARACOUDA);
+ }
+
+ @Override
+ protected void importBaracoudaEntities(Database db) throws IOException, TopiaException {
+
+ Map<String, Voyage> voyagesByName = getUniverse(
+ Voyage.class, EchoBaseFunctions.VOYAGE_NAME);
+
+ Map<String, Species> speciesByName = getUniverse(
+ Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE);
+
+ TopiaDAO<LengthAgeKey> dao = getDAO();
+
+ List<LengthAgeKey> lengthAgeKeys = Lists.newArrayList();
+
+ for (Map<String, Object> row : db.getTable("CLE_TAILLE_AGE")) {
+
+ String voyageName = (String) row.get("CAMPAGNE");
+ Voyage voyage = getFK(voyagesByName, voyageName);
+
+ String speciesCode = (String) row.get("GENRE_ESP");
+ Species species = getFK(speciesByName, speciesCode);
+
+ Integer age = Integer.valueOf(row.get("AGE").toString());
+ Float length = (Float) row.get("TAILLE");
+ Float percentAtAge = (Float) row.get("POURCENTAGE");
+ String metadata = (String) row.get("Origine_Data");
+
+ LengthAgeKey lengthAgeKey = dao.create(
+ LengthAgeKey.PROPERTY_SPECIES, species,
+ LengthAgeKey.PROPERTY_LENGTH, length,
+ LengthAgeKey.PROPERTY_AGE, age,
+ LengthAgeKey.PROPERTY_PERCENT_AT_AGE, percentAtAge,
+ LengthAgeKey.PROPERTY_METADATA, metadata
+ );
+ lengthAgeKeys.add(lengthAgeKey);
+ voyage.addLengthAgeKey(lengthAgeKey);
+ }
+ if (log.isInfoEnabled()) {
+ log.info("Found " + lengthAgeKeys.size() + " lengthAgeKey(s).");
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoader.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoader.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoader.java (rev 0)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoader.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -0,0 +1,130 @@
+/*
+ * #%L
+ * EchoBase :: Tools
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 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%
+ */
+package fr.ifremer.echobase.tools.loaders;
+
+import com.google.common.collect.Lists;
+import com.healthmarketscience.jackcess.Database;
+import fr.ifremer.echobase.EchoBaseFunctions;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.references.LengthWeightKey;
+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.tools.FileType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * {@link LengthWeightKey} loader.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class LengthWeightKeyLoader extends EntityLoader<LengthWeightKey> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(LengthWeightKeyLoader.class);
+
+ public LengthWeightKeyLoader() {
+ super(LengthWeightKey.class, EchoBaseEntityEnum.Voyage,
+ Voyage.PROPERTY_LENGTH_WEIGHT_KEY,
+ FileType.BARACOUDA);
+ }
+
+ @Override
+ protected void importBaracoudaEntities(Database db) throws IOException, TopiaException {
+
+ Map<String, Voyage> voyagesByName = getUniverse(
+ Voyage.class, EchoBaseFunctions.VOYAGE_NAME);
+
+ Map<String, Species> speciesByName = getUniverse(
+ Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE);
+
+ Map<String, SizeCategory> sizeCategoryByName = getUniverse(
+ SizeCategory.class, EchoBaseFunctions.SIZE_CATEGORY_NAME);
+
+ Map<String, SpeciesCategory> speciesCategoryBySizeAndName = getUniverse(
+ SpeciesCategory.class, EchoBaseFunctions.SPECIES_CATEGORY_SPIECIES);
+
+ TopiaDAO<LengthWeightKey> dao = getDAO();
+
+ List<LengthWeightKey> lengthWeightKeys = Lists.newArrayList();
+
+ for (Map<String, Object> row : db.getTable("TAILLE_POIDS")) {
+
+ String voyageName = (String) row.get("Campagne");
+ Voyage voyage = getFK(voyagesByName, voyageName);
+
+ String speciesCode = (String) row.get("Genre_esp");
+ Species species = getFK(speciesByName, speciesCode);
+
+ String sizeCode = (String) row.get("Categorie");
+ if ("NA".equals(sizeCode) || "H".equals(sizeCode)) {
+ sizeCode = "0";
+ }
+
+ SizeCategory sizeCategory = getFK(sizeCategoryByName, sizeCode);
+ SpeciesCategory speciesCategory = getSpeciesCategory(
+ species,
+ sizeCategory,
+ speciesCategoryBySizeAndName);
+
+ Float aParameter = (Float) row.get("Coeff_A_RTP");
+ Float bParameter = (Float) row.get("Exposant_N_RTP");
+ String metadata = (String) row.get("Origine_DATA");
+
+ LengthWeightKey lengthWeightKey = dao.create(
+ LengthWeightKey.PROPERTY_SPECIES_CATEGORY, speciesCategory,
+ LengthWeightKey.PROPERTY_APARAMETER, aParameter,
+ LengthWeightKey.PROPERTY_BPARAMETER, bParameter,
+ LengthWeightKey.PROPERTY_METADATA, metadata
+ );
+ voyage.addLengthWeightKey(lengthWeightKey);
+ lengthWeightKeys.add(lengthWeightKey);
+ }
+ if (log.isInfoEnabled()) {
+ log.info("Found " + lengthWeightKeys.size() + " lengthWeightKey(s).");
+ }
+ }
+
+ protected SpeciesCategory getSpeciesCategory(Species species,
+ SizeCategory sizeCategory,
+ Map<String, SpeciesCategory> speciesCategoryByName) throws TopiaException {
+
+ String speciesCategoryKey = EchoBaseFunctions.getSpeciesCategoryKey(species, sizeCategory, null);
+
+ // get species category to use
+ SpeciesCategory speciesCategory = getFK(speciesCategoryByName, speciesCategoryKey);
+ return speciesCategory;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoader.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/OperationLoader.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/OperationLoader.java 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/OperationLoader.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -299,17 +299,9 @@
Float midHauleLatitude = (Float) row.get("LATDD");
Preconditions.checkNotNull(midHauleLatitude);
-// if (midHauleLatitude == null) {
-// messages.add("No midHauleLatitude");
-// midHauleLatitude = 0f;
-// }
Float midHauleLongitude = (Float) row.get("LGDD");
Preconditions.checkNotNull(midHauleLongitude);
-// if (midHauleLongitude== null) {
-// messages.add("No midHauleLongitude");
-// midHauleLongitude = 0f;
-// }
Date shootingStartTime = (Date) row.get("DHTUDEB");
Date shootingEndTime = (Date) row.get("DHTUFIN");
Modified: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SampleLoader.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SampleLoader.java 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SampleLoader.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -24,6 +24,7 @@
package fr.ifremer.echobase.tools.loaders;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.Sets;
@@ -38,16 +39,22 @@
import fr.ifremer.echobase.entities.references.SampleDataType;
import fr.ifremer.echobase.entities.references.SampleType;
import fr.ifremer.echobase.entities.references.SampleTypeDAO;
+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.tools.FileType;
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.util.StringUtil;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -103,7 +110,15 @@
copyAndLoadEntities(outputDir, meta.getAssociations(Sample.PROPERTY_SAMPLE_DATA), false, FileType.ASSOCIATION);
}
+ protected SampleDataDAO sampleDataDAO;
+ protected SpeciesCategoryDAO speciesCategoryDAO;
+ protected TopiaDAO<Sample> dao;
+
+ protected Map<String, SizeCategory> sizeCategoryByName;
+ protected Map<String, SexCategory> sexCategoryByName;
+ protected Map<String, SpeciesCategory> speciesCategoryByName;
+
@Override
protected void importBaracoudaEntities(Database db) throws IOException, TopiaException {
@@ -116,6 +131,15 @@
Map<String, SampleDataType> sampleDataTypeByRaptriCode = getUniverse(
SampleDataType.class, EchoBaseFunctions.SAMPLE_DATA_TYPE_RAPTRI_CODE);
+ sizeCategoryByName = getUniverse(
+ SizeCategory.class, EchoBaseFunctions.SIZE_CATEGORY_NAME);
+
+ sexCategoryByName = getUniverse(
+ SexCategory.class, EchoBaseFunctions.SEX_CATEGORY_NAME);
+
+ speciesCategoryByName = getUniverse(
+ SpeciesCategory.class, EchoBaseFunctions.SPECIES_CATEGORY_SPIECIES);
+
Multimap<String, Map<String, Object>> mensurationByNosta = Multimaps.index(
db.getTable("MENSURATIONS", true),
EchoBaseFunctions.newRowFunction("NOSTA")
@@ -147,37 +171,36 @@
SampleType sampleTypeIndividual = sampleTypeDAO.findByName("Individual");
Preconditions.checkNotNull(sampleTypeIndividual);
-// SampleDataTypeDAO sampleDataTypeDAO =
-// (SampleDataTypeDAO) getDAO(SampleDataType.class);
+ sampleDataDAO = (SampleDataDAO) getDAO(SampleData.class);
- SampleDataDAO sampleDataDAO = (SampleDataDAO) getDAO(SampleData.class);
-
-// SampleDataType sampleDataTypeMeanLength = sampleDataTypeDAO.findByName("MeanLengthcm");
+ //MeanLengthcm
SampleDataType sampleDataTypeMeanLength = getFK(sampleDataTypeByRaptriCode, "114");
-// SampleDataType sampleDataTypeMeanWeight = sampleDataTypeDAO.findByName("MeanWeightg");
+ //MeanWeightg
SampleDataType sampleDataTypeMeanWeight = getFK(sampleDataTypeByRaptriCode, "115");
-
-// SampleDataType sampleDataTypeNoPerKg = sampleDataTypeDAO.findByName("NoPerKg");
+ //NoPerKg
SampleDataType sampleDataTypeNoPerKg = getFK(sampleDataTypeByRaptriCode, "116");
-// SampleDataType sampleDataTypeNumberAtLength = sampleDataTypeDAO.findByName("NumberAtLength");
+ //NumberAtLength
SampleDataType sampleDataTypeNumberAtLength = getFK(sampleDataTypeByRaptriCode, "112");
-// SampleDataType sampleDataTypeWeightAtLength = sampleDataTypeDAO.findByName("WeightAtLengthkg");
+ //WeightAtLengthkg
SampleDataType sampleDataTypeWeightAtLength = getFK(sampleDataTypeByRaptriCode, "113");
- TopiaDAO<Sample> dao = getDAO();
-
+ dao = getDAO();
+ speciesCategoryDAO = (SpeciesCategoryDAO) getDAO(SpeciesCategory.class);
int nbSampleUnsorted = 0;
int nbSampleTotal = 0;
int nbSubSample = 0;
int nbIndividualSample = 0;
+ List<String> operationNotFound = Lists.newArrayList();
+ List<String> ntotNull = Lists.newArrayList();
+ List<String> pmensNull = Lists.newArrayList();
+ List<String> valeurBiometryNull = Lists.newArrayList();
+
for (String operationId : capturesByNosta.keySet()) {
Preconditions.checkNotNull(operationId);
Operation operation = operationById.get(operationId);
if (operation == null) {
- if (log.isWarnEnabled()) {
- log.warn("Operation " + operationId + " not found...");
- }
+ operationNotFound.add(operationId);
continue;
}
Collection<Map<String, Object>> biometryValues =
@@ -187,33 +210,53 @@
biometryValues,
EchoBaseFunctions.newRowFunction("GENRE_ESP_VALEUR_BIOMETRIE")
);
+
+ SpeciesCategory speciesCategory;
+ SpeciesCategory speciesCategoryForSpecies;
+
for (Map<String, Object> row : capturesByNosta.get(operationId)) {
String type = (String) row.get("CATEG");
SampleType sampleType;
+ String speciesId = (String) row.get("GENRE_ESP");
+ Species species = getFK(speciesByName, speciesId);
+
if ("H".equals(type)) {
+
+ speciesCategory = getSpeciesCategory(species, "0", null);
+ speciesCategoryForSpecies = getSpeciesCategory(species, null, null);
sampleType = sampleTypeUnsorted;
nbSampleUnsorted++;
} else {
sampleType = sampleTypeTotal;
+
+ if ("F".equals(type) || "M".equals(type)) {
+
+ speciesCategory = getSpeciesCategory(
+ species,
+ null,
+ type);
+ } else {
+
+ speciesCategory = getSpeciesCategory(
+ species,
+ type,
+ null);
+ }
+
+ speciesCategoryForSpecies = getSpeciesCategory(species, null, null);
nbSampleTotal++;
}
- String speciesId = (String) row.get("GENRE_ESP");
- Species species = getFK(speciesByName, speciesId);
-
Integer number = (Integer) row.get("NTOT");
if (number == null) {
- if (log.isWarnEnabled()) {
- log.warn("NTOT is null for operation " + operationId + "/" + speciesId);
- }
- number = 0;
+ ntotNull.add(operationId + "/" + speciesId);
}
Float weight = (Float) row.get("PT_ESP");
Sample sample = dao.create(
- Sample.PROPERTY_SPECIES, species,
+ Sample.PROPERTY_SPECIES_CATEGORY, speciesCategory,
Sample.PROPERTY_SAMPLE_TYPE, sampleType,
Sample.PROPERTY_NUMBER_SAMPLED, number,
Sample.PROPERTY_SAMPLE_WEIGHT, weight
@@ -221,20 +264,17 @@
operation.addSample(sample);
- addSampleData(sampleDataDAO,
- sample,
+ addSampleData(sample,
sampleDataTypeMeanWeight,
"NA",
row.get("PMOY"));
- addSampleData(sampleDataDAO,
- sample,
+ addSampleData(sample,
sampleDataTypeMeanLength,
"NA",
row.get("LMOY"));
- addSampleData(sampleDataDAO,
- sample,
+ addSampleData(sample,
sampleDataTypeNoPerKg,
"NA",
row.get("MOULE_MENS"));
@@ -244,20 +284,15 @@
Float sampleWeight = (Float) row.get("PESP_MENS");
if (sampleWeight == null) {
- if (log.isWarnEnabled()) {
- log.warn("PESP_MENS is null for operation " + operationId + "/" + speciesId);
- }
- sampleWeight = 0f;
+ pmensNull.add(operationId + "/" + speciesId);
}
- addSubSamples(dao,
- sampleDataDAO,
+ addSubSamples(speciesCategory,
sampleTypeSubsample,
sampleDataTypeNumberAtLength,
sampleDataTypeWeightAtLength,
operation,
type,
- species,
sampleWeight,
mensurationRows);
@@ -267,19 +302,39 @@
Collection<Map<String, Object>> biometryValuesRows =
biometryValuesBySpecies.get(speciesId);
- int nbSampleIndiv = addSampleIndividuals(dao,
- sampleDataDAO,
- operation,
- species,
+ int nbSampleIndiv = addSampleIndividuals(operation,
+ speciesCategoryForSpecies,
sampleTypeIndividual,
sampleDataTypeByRaptriCode,
biometryScalesByRaptri,
- biometryValuesRows);
+ biometryValuesRows,
+ valeurBiometryNull);
nbIndividualSample += nbSampleIndiv;
}
}
+ if (!operationNotFound.isEmpty()) {
+ if (log.isWarnEnabled()) {
+ log.warn("operation not found : \n" + StringUtil.join(operationNotFound, "\n", false));
+ }
+ }
+
+ if (!ntotNull.isEmpty()) {
+ if (log.isWarnEnabled()) {
+ log.warn("NTOT is null for operation :\n" + StringUtil.join(ntotNull, "\n", false));
+ }
+ }
+ if (!pmensNull.isEmpty()) {
+ if (log.isWarnEnabled()) {
+ log.warn("PESP_MENS is null for operation\n" + StringUtil.join(pmensNull, "\n", false));
+ }
+ }
+ if (!valeurBiometryNull.isEmpty()) {
+ if (log.isWarnEnabled()) {
+ log.warn("Null value of VALEUR_BIOMETRIE for operationId/Species/Individu/Code param\n" + StringUtil.join(valeurBiometryNull, "\n", false));
+ }
+ }
if (log.isInfoEnabled()) {
log.info("Found " + nbSampleTotal + " 'total' sample(s).");
log.info("Found " + nbSampleUnsorted + " 'unsorted' sample(s).");
@@ -289,29 +344,78 @@
}
}
- private int addSampleIndividuals(TopiaDAO<Sample> dao,
- SampleDataDAO sampleDataDAO,
- Operation operation,
- Species species,
+ private void addSubSamples(SpeciesCategory speciesCategory,
+ SampleType sampleTypeSubsample,
+ SampleDataType sampleDataTypeNumberAtLength,
+ SampleDataType sampleDataTypeWeightAtLength,
+ Operation operation,
+ String type,
+ Float sampleWeight,
+ Collection<Map<String, Object>> mesnurationRows) throws TopiaException {
+
+ String speciesId = speciesCategory.getSpecies().getBaracoudaCode();
+
+ for (Map<String, Object> row : mesnurationRows) {
+ String categ = (String) row.get("CATEG");
+ if (!type.equals(categ)) {
+
+ // not good category
+ continue;
+ }
+ String rowSpeciesId = (String) row.get("GENRE_ESP");
+ if (!speciesId.equals(rowSpeciesId)) {
+
+ // not good species
+ continue;
+ }
+
+ // ok found a good row
+ Sample subsample = dao.create(
+ Sample.PROPERTY_SPECIES_CATEGORY, speciesCategory,
+ Sample.PROPERTY_SAMPLE_TYPE, sampleTypeSubsample,
+ Sample.PROPERTY_SAMPLE_WEIGHT, sampleWeight
+ );
+
+ Object lengthClass = row.get("TAILLE");
+
+ addSampleData(subsample,
+ sampleDataTypeNumberAtLength,
+ lengthClass,
+ row.get("NBIND")
+ );
+
+ addSampleData(subsample,
+ sampleDataTypeWeightAtLength,
+ lengthClass,
+ row.get("POIDSTAILLE")
+ );
+
+ operation.addSample(subsample);
+
+ }
+ }
+
+ private int addSampleIndividuals(Operation operation,
+ SpeciesCategory speciesCategory,
SampleType sampleTypeIndividual,
Map<String, SampleDataType> sampleDataTypeByRaptriCode,
Multimap<Integer, Map<String, Object>> biometryScalesByRaptri,
- Collection<Map<String, Object>> biometryValuesRows) throws TopiaException {
+ Collection<Map<String, Object>> biometryValuesRows,
+ List<String> valeurBiometryNull) throws TopiaException {
int result = 0;
Sample sample = null;
Set<Integer> individus = Sets.newHashSet();
+ String speciesId = speciesCategory.getSpecies().getBaracoudaCode();
for (Map<String, Object> biometryValuesRow : biometryValuesRows) {
Integer ind = Integer.valueOf(biometryValuesRow.get("NUMIND_VALEUR_BIOMETRIE").toString());
Integer codeParameter = (Integer) biometryValuesRow.get("CODE_PARAM_VALEUR_BIOMETRIE");
String label = null;
Float value = (Float) biometryValuesRow.get("VALEUR_BIOMETRIE");
- if (value==null) {
- if (log.isWarnEnabled()) {
- log.warn("Null value of VALEUR_BIOMETRIE for operationId/Species/Individu/Code param " + operation.getId() + "/" + species.getBaracoudaCode() + "/" + ind+"/"+codeParameter);
- }
+ if (value == null) {
+ valeurBiometryNull.add(operation.getId() + "/" + speciesId + "/" + ind + "/" + codeParameter);
continue;
}
- Preconditions.checkNotNull(value, "Null value of VALEUR_BIOMETRIE for operationId/Species/Individu/Code param " + operation.getId() + "/" + species.getBaracoudaCode() + "/" + ind+"/"+codeParameter);
+ Preconditions.checkNotNull(value, "Null value of VALEUR_BIOMETRIE for operationId/Species/Individu/Code param " + operation.getId() + "/" + speciesId + "/" + ind + "/" + codeParameter);
SampleDataType sampleDataType = getFK(sampleDataTypeByRaptriCode, String.valueOf(codeParameter));
boolean add = individus.add(ind);
@@ -319,7 +423,7 @@
// new sample
sample = dao.create(
- Sample.PROPERTY_SPECIES, species,
+ Sample.PROPERTY_SPECIES_CATEGORY, speciesCategory,
Sample.PROPERTY_SAMPLE_TYPE, sampleTypeIndividual
);
@@ -348,8 +452,7 @@
}
}
}
- addSampleData(sampleDataDAO,
- sample,
+ addSampleData(sample,
sampleDataType,
label,
value
@@ -358,65 +461,7 @@
return result;
}
- private void addSubSamples(TopiaDAO<Sample> dao,
- SampleDataDAO sampleDataDAO,
- SampleType sampleTypeSubsample,
- SampleDataType sampleDataTypeNumberAtLength,
- SampleDataType sampleDataTypeWeightAtLength,
- Operation operation,
- String type,
- Species species,
- Float sampleWeight,
- Collection<Map<String, Object>> mesnurationRows) throws TopiaException {
-
- String speciesId = species.getBaracoudaCode();
-
- for (Map<String, Object> row : mesnurationRows) {
- String categ = (String) row.get("CATEG");
- if (!type.equals(categ)) {
-
- // not good category
- continue;
- }
- String rowSpeciesId = (String) row.get("GENRE_ESP");
- if (!speciesId.equals(rowSpeciesId)) {
-
- // not good species
- continue;
- }
-
- // ok found a good row
- Sample subsample = dao.create(
- Sample.PROPERTY_SPECIES, species,
- Sample.PROPERTY_SAMPLE_TYPE, sampleTypeSubsample,
- Sample.PROPERTY_SAMPLE_WEIGHT, sampleWeight
- );
-
- Object lengthClass = row.get("TAILLE");
-
- addSampleData(sampleDataDAO,
- subsample,
- sampleDataTypeNumberAtLength,
- lengthClass,
- row.get("NBIND")
- );
-
- addSampleData(sampleDataDAO,
- subsample,
- sampleDataTypeWeightAtLength,
- lengthClass,
- row.get("POIDSTAILLE")
- );
-
-
- operation.addSample(subsample);
-
- }
- }
-
-
- protected void addSampleData(TopiaDAO<SampleData> dao,
- Sample operation,
+ protected void addSampleData(Sample operation,
SampleDataType sampleDataType,
Object label,
Object value
@@ -426,7 +471,7 @@
return;
}
- SampleData sampleData = dao.create(
+ SampleData sampleData = sampleDataDAO.create(
SampleData.PROPERTY_SAMPLE_DATA_TYPE, sampleDataType,
SampleData.PROPERTY_DATA_LABEL, label.toString(),
SampleData.PROPERTY_DATA_VALUE, Float.valueOf(value.toString())
@@ -434,5 +479,23 @@
operation.addSampleData(sampleData);
}
+ protected SpeciesCategory getSpeciesCategory(Species species,
+ String sizeName,
+ String sexName) throws TopiaException {
+ SexCategory sexCategory = null;
+ if (sexName != null) {
+ sexCategory = getFK(sexCategoryByName, sexName);
+ }
+
+ SizeCategory sizeCategory = null;
+ if (sizeName != null) {
+ sizeCategory = getFK(sizeCategoryByName, sizeName);
+ }
+ String speciesCategoryKey = EchoBaseFunctions.getSpeciesCategoryKey(species, sizeCategory, sexCategory);
+
+ // get species category to use
+ SpeciesCategory speciesCategory = getFK(speciesCategoryByName, speciesCategoryKey);
+ return speciesCategory;
+ }
}
\ No newline at end of file
Modified: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SpeciesCategoryLoader.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SpeciesCategoryLoader.java 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SpeciesCategoryLoader.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -23,11 +23,24 @@
*/
package fr.ifremer.echobase.tools.loaders;
-import fr.ifremer.echobase.entities.meta.TableMeta;
+import com.google.common.collect.Lists;
+import com.healthmarketscience.jackcess.Database;
+import fr.ifremer.echobase.EchoBaseFunctions;
+import fr.ifremer.echobase.entities.references.LengthWeightKey;
+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.services.models.EntityCsvModel;
+import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
import fr.ifremer.echobase.tools.FileType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
/**
* To load {@link SpeciesCategory} entities.
*
@@ -36,23 +49,148 @@
*/
public class SpeciesCategoryLoader extends EntityLoader<SpeciesCategory> {
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SpeciesCategoryLoader.class);
+
public SpeciesCategoryLoader() {
- super(SpeciesCategory.class, FileType.NEW);
+ super(SpeciesCategory.class, FileType.BARACOUDA);
}
-
@Override
- protected EntityCsvModel<SpeciesCategory> createCsvImportModel(TableMeta meta) {
+ protected void importBaracoudaEntities(Database db) throws IOException, TopiaException {
- EntityCsvModel<SpeciesCategory> model = EntityCsvModel.newModel(
- getCsvSeparator(),
- meta
+ Map<String, Species> speciesByName = getUniverse(
+ Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE);
+
+ Map<String, SizeCategory> sizeCategoryByName = getUniverse(
+ SizeCategory.class, EchoBaseFunctions.SIZE_CATEGORY_NAME);
+
+ Map<String, SexCategory> sexCategoryByName = getUniverse(
+ SexCategory.class, EchoBaseFunctions.SEX_CATEGORY_NAME);
+
+ SpeciesCategoryDAO speciesCategoryDAO =
+ (SpeciesCategoryDAO) getDAO(SpeciesCategory.class);
+
+ List<LengthWeightKey> lengthWeightKeys = Lists.newArrayList();
+
+ for (Map<String, Object> row : db.getTable("TAILLE_POIDS")) {
+
+ String speciesCode = (String) row.get("Genre_esp");
+ Species species = getFK(speciesByName, speciesCode);
+
+ String sizeCode = (String) row.get("Categorie");
+ if ("NA".equals(sizeCode) || "H".equals(sizeCode)) {
+ sizeCode = "0";
+ }
+
+ SizeCategory sizeCategory = getFK(sizeCategoryByName, sizeCode);
+ getSpeciesCategory(speciesCategoryDAO, species, sizeCategory);
+ }
+
+ for (Map<String, Object> row : db.getTable("CAPTURES")) {
+
+ String speciesCode = (String) row.get("GENRE_ESP");
+ Species species = getFK(speciesByName, speciesCode);
+
+ String sizeCode = (String) row.get("CATEG");
+ if ("H".equals(sizeCode)) {
+ sizeCode = "0";
+ }
+
+ if ("F".equals(sizeCode) || "M".equals(sizeCode)) {
+
+ SexCategory sexCategory = getFK(sexCategoryByName, sizeCode);
+ getSpeciesCategory(speciesCategoryDAO, species, sexCategory);
+
+ } else {
+
+ SizeCategory sizeCategory = getFK(sizeCategoryByName, sizeCode);
+ getSpeciesCategory(speciesCategoryDAO, species, sizeCategory);
+ }
+
+ getSpeciesCategory(speciesCategoryDAO, species);
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Found " + lengthWeightKeys.size() + " speciesCategories.");
+ }
+ }
+
+ protected SpeciesCategory getSpeciesCategory(SpeciesCategoryDAO speciesCategoryDAO,
+ Species species,
+ SizeCategory sizeCategory) throws TopiaException {
+
+ // get species category to use
+ SpeciesCategory speciesCategory = speciesCategoryDAO.findByProperties(
+ SpeciesCategory.PROPERTY_SPECIES, species,
+ SpeciesCategory.PROPERTY_SIZE_CATEGORY, sizeCategory
);
- model.newMandatoryColumn(SpeciesCategory.PROPERTY_SPECIES);
- model.newMandatoryColumn(SpeciesCategory.PROPERTY_SIZE_CATEGORY);
- model.newMandatoryColumn(SpeciesCategory.PROPERTY_AGE_CATEGORY);
- model.newMandatoryColumn(SpeciesCategory.PROPERTY_SEX_CATEGORY);
- return model;
+ if (speciesCategory == null) {
+
+ // create it in db
+ speciesCategory = speciesCategoryDAO.create(
+ SpeciesCategory.PROPERTY_SPECIES, species,
+ SpeciesCategory.PROPERTY_SIZE_CATEGORY, sizeCategory
+ );
+
+ if (log.isInfoEnabled()) {
+ log.info("Create speciesCategory speciesBaracoudaCode/size : " +
+ species.getBaracoudaCode() + "/" +
+ (sizeCategory == null ? null : sizeCategory.getName()));
+ }
+ }
+ return speciesCategory;
}
+ protected SpeciesCategory getSpeciesCategory(SpeciesCategoryDAO speciesCategoryDAO,
+ Species species,
+ SexCategory sexCategory) throws TopiaException {
+
+ // get species category to use
+ SpeciesCategory speciesCategory = speciesCategoryDAO.findByProperties(
+ SpeciesCategory.PROPERTY_SPECIES, species,
+ SpeciesCategory.PROPERTY_SEX_CATEGORY, sexCategory
+ );
+ if (speciesCategory == null) {
+
+ // create it in db
+ speciesCategory = speciesCategoryDAO.create(
+ SpeciesCategory.PROPERTY_SPECIES, species,
+ SpeciesCategory.PROPERTY_SEX_CATEGORY, sexCategory
+ );
+
+ if (log.isInfoEnabled()) {
+ log.info("Create speciesCategory speciesBaracoudaCode/sex : " +
+ species.getBaracoudaCode() + "/" +
+ (sexCategory == null ? null : sexCategory.getName()));
+ }
+ }
+ return speciesCategory;
+ }
+
+ protected SpeciesCategory getSpeciesCategory(SpeciesCategoryDAO speciesCategoryDAO,
+ Species species) throws TopiaException {
+
+ // get species category to use
+ SpeciesCategory speciesCategory = speciesCategoryDAO.findByProperties(
+ SpeciesCategory.PROPERTY_SPECIES, species,
+ SpeciesCategory.PROPERTY_SEX_CATEGORY, null,
+ SpeciesCategory.PROPERTY_SIZE_CATEGORY, null
+ );
+
+ if (speciesCategory == null) {
+
+ // create it in db
+ speciesCategory = speciesCategoryDAO.create(
+ SpeciesCategory.PROPERTY_SPECIES, species
+ );
+
+ if (log.isInfoEnabled()) {
+ log.info("Create speciesCategory speciesBaracoudaCode : " +
+ species.getBaracoudaCode());
+ }
+ }
+ return speciesCategory;
+ }
}
\ No newline at end of file
Modified: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/AbstractLoaderIT.java
===================================================================
--- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/AbstractLoaderIT.java 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/AbstractLoaderIT.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -357,7 +357,8 @@
entityLoaders.add(newService(OperationEventLoader.class));
entityLoaders.add(newService(SampleDataTypeLoader.class));
entityLoaders.add(newService(SampleTypeLoader.class));
- entityLoaders.add(newService(BiometryScaleLoader.class));
+ entityLoaders.add(newService(LengthAgeKeyLoader.class));
+ entityLoaders.add(newService(LengthWeightKeyLoader.class));
entityLoaders.add(newService(SexCategoryLoader.class));
entityLoaders.add(newService(SizeCategoryLoader.class));
entityLoaders.add(newService(OperationMetadataLoader.class));
Deleted: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoaderIT.java
===================================================================
--- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoaderIT.java 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoaderIT.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -1,45 +0,0 @@
-/*
- * #%L
- * EchoBase :: Tools
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 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%
- */
-package fr.ifremer.echobase.tools.loaders;
-
-import fr.ifremer.echobase.entities.references.BiometryScale;
-import org.junit.Test;
-
-/**
- * To test the {@link BiometryScaleLoader}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class BiometryScaleLoaderIT extends AbstractLoaderIT<BiometryScale, BiometryScaleLoader> {
-
- public BiometryScaleLoaderIT() {
- super(BiometryScaleLoader.class, 44, 0);
- }
-
- @Test
- public void testGenerateNewEntities() throws Exception {
- generateNewEntities();
- }
-}
Added: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoaderIT.java
===================================================================
--- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoaderIT.java (rev 0)
+++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoaderIT.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * EchoBase :: Tools
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 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%
+ */
+package fr.ifremer.echobase.tools.loaders;
+
+import fr.ifremer.echobase.entities.references.LengthAgeKey;
+import org.junit.Test;
+
+/**
+ * To test the {@link LengthAgeKeyLoader}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class LengthAgeKeyLoaderIT extends AbstractLoaderIT<LengthAgeKey, LengthAgeKeyLoader> {
+
+ public LengthAgeKeyLoaderIT() {
+ super(LengthAgeKeyLoader.class, 0, 1637);
+ }
+
+ @Test
+ public void testGenerateEntitiesFromBaracouda() throws Exception {
+ generateBaracoudaEntities();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthAgeKeyLoaderIT.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoaderIT.java
===================================================================
--- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoaderIT.java (rev 0)
+++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoaderIT.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * EchoBase :: Tools
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 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%
+ */
+package fr.ifremer.echobase.tools.loaders;
+
+import fr.ifremer.echobase.entities.references.LengthWeightKey;
+import org.junit.Test;
+
+/**
+ * To test the {@link LengthWeightKeyLoader}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class LengthWeightKeyLoaderIT extends AbstractLoaderIT<LengthWeightKey, LengthWeightKeyLoader> {
+
+ public LengthWeightKeyLoaderIT() {
+ super(LengthWeightKeyLoader.class, 0, 218);
+ }
+
+ @Test
+ public void testGenerateEntitiesFromBaracouda() throws Exception {
+ generateBaracoudaEntities();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/LengthWeightKeyLoaderIT.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/OperationLoaderIT.java
===================================================================
--- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/OperationLoaderIT.java 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/OperationLoaderIT.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -35,7 +35,7 @@
public class OperationLoaderIT extends AbstractLoaderIT<Operation, OperationLoader> {
public OperationLoaderIT() {
- super(OperationLoader.class, 0, 1374);
+ super(OperationLoader.class, 0, 1489);
}
@Test
Modified: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SampleLoaderIT.java
===================================================================
--- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SampleLoaderIT.java 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SampleLoaderIT.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -35,7 +35,7 @@
public class SampleLoaderIT extends AbstractLoaderIT<Sample, SampleLoader> {
public SampleLoaderIT() {
- super(SampleLoader.class, 0, 324809);
+ super(SampleLoader.class, 0, 333783);
}
@Test
Modified: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SpeciesCategoryLoaderIT.java
===================================================================
--- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SpeciesCategoryLoaderIT.java 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SpeciesCategoryLoaderIT.java 2011-12-19 19:16:34 UTC (rev 203)
@@ -35,12 +35,12 @@
public class SpeciesCategoryLoaderIT extends AbstractLoaderIT<SpeciesCategory, SpeciesCategoryLoader> {
public SpeciesCategoryLoaderIT() {
- super(SpeciesCategoryLoader.class, 0, 0);
+ super(SpeciesCategoryLoader.class, 0, 443);
}
@Test
- public void testGenerateNewEntities() throws Exception {
- generateNewEntities();
+ public void testGenerateEntitiesFromBaracouda() throws Exception {
+ generateBaracoudaEntities();
}
}
\ No newline at end of file
Deleted: trunk/echobase-tools/src/test/resources/csv/new/input-BiometryScale.csv
===================================================================
--- trunk/echobase-tools/src/test/resources/csv/new/input-BiometryScale.csv 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/test/resources/csv/new/input-BiometryScale.csv 2011-12-19 19:16:34 UTC (rev 203)
@@ -1,45 +0,0 @@
-raptriBiometryDataType;ScaleCode;ScaleMeaningEng;ScaleMeaningFr
-3;0;Undetermined;indeterminé
-3;1;Male;male
-3;2;Female;femelle
-3;3;NA (IEO- Pelacus1007);Non renseigné (IEO- Pelacus1007)
-4;1;Immature/virgin;Immature/virgin
-4;2;Developing;Developing
-4;3;Prespawning;Prespawning
-4;4;Spawning;Spawning
-4;5;Spent;Spent
-4;6;Resting;Resting
-7;0;Easily readable;facile à lire
-7;1;Hardly readable;difficile à lire
-7;2;Unreadable;illisible
-7;3;Estimated (ex. juvenile otoliths);Estimée (ex. Otolimetrie juvenile)
-8;-1;To be checked by PG;à faire préciser par PG
-8;1;"opaque (""H"")";"opaque (""H"")"
-8;2;"hyalin (""O"")";"hyalin (""O"")"
-8;3;opaque/hyalin;opaque/hyalin
-23;1;No fat;No fat
-23;2;Low fat;Low fat
-23;3;Fat;Fat
-23;4;High fat;High fat
-24;0;no anisakis;zéro anisakis
-24;1;1-10 anisakis;1 à 10 anisakis
-24;2;10-20 anisakis;10 à 20 anisakis
-24;3;>20 anisakis;> 20 anisakis
-25;0;;
-25;1;IFREMER - NANTES (PG);IFREMER - NANTES (PG)
-25;2;IFREMER - LORIENT (ED);IFREMER - LORIENT (ED)
-25;3;AZTI + (PP);AZTI + (PP)
-25;4;AZTI (lecture AGE) + IFREMER Nantes (PG) (mesure rayon);AZTI (lecture AGE) + IFREMER Nantes (PG) (mesure rayon)
-25;5;EPHE - PERPIGNAN (PL);EPHE - PERPIGNAN (PL)
-25;6;IFREMER - IEO (double lecture à bord : Patrick-Carla);IFREMER - IEO (double lecture à bord : Patrick-Carla)
-25;7;biometrie et otolithe IFREMER-NANTES (PG) - génétique : EPHE;biometrie et otolithe IFREMER-NANTES (PG) - génétique : EPHE
-26;0;clé Taille/Age : NON Valide;clé Taille/Age : NON Valide
-26;1;clé Taille/Age : VALIDE;clé Taille/Age : VALIDE
-45;0;NA;NA
-45;1;Blanc ?;Blanc ?
-45;2;?;?
-45;3;Complète;Complète
-45;4;partielle;partielle
-49;0;NA;NA
-49;1;DROIT;DROIT
-49;2;GAUCHE;GAUCHE
\ No newline at end of file
Modified: trunk/echobase-tools/src/test/resources/csv/new/input-SexCategory.csv
===================================================================
--- trunk/echobase-tools/src/test/resources/csv/new/input-SexCategory.csv 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/test/resources/csv/new/input-SexCategory.csv 2011-12-19 19:16:34 UTC (rev 203)
@@ -1,5 +1,5 @@
CategoryID;CategoryName
-0;All
-G;Large
-P;Small
-TP;Very small
+N;Not determined
+F;Female
+M;Male
+I;Immature
\ No newline at end of file
Modified: trunk/echobase-tools/src/test/resources/csv/new/input-SizeCategory.csv
===================================================================
--- trunk/echobase-tools/src/test/resources/csv/new/input-SizeCategory.csv 2011-12-19 19:16:01 UTC (rev 202)
+++ trunk/echobase-tools/src/test/resources/csv/new/input-SizeCategory.csv 2011-12-19 19:16:34 UTC (rev 203)
@@ -1,5 +1,5 @@
CategoryID;CategoryName
-N;Not determined
-F;Female
+0;All
G;Large
-I;Immature
\ No newline at end of file
+P;Small
+TP;Very small
\ No newline at end of file
1
0
r202 - in trunk/echobase-entities/src/main: java/fr/ifremer/echobase java/fr/ifremer/echobase/entities resources/i18n xmi
by tchemit@users.forge.codelutin.com 19 Dec '11
by tchemit@users.forge.codelutin.com 19 Dec '11
19 Dec '11
Author: tchemit
Date: 2011-12-19 20:16:01 +0100 (Mon, 19 Dec 2011)
New Revision: 202
Url: http://forge.codelutin.com/repositories/revision/echobase/202
Log:
fix entity name + properties
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDecoratorProvider.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDecoratorProvider.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDecoratorProvider.java 2011-12-19 08:20:03 UTC (rev 201)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDecoratorProvider.java 2011-12-19 19:16:01 UTC (rev 202)
@@ -61,6 +61,7 @@
import fr.ifremer.echobase.entities.references.GearMetadata;
import fr.ifremer.echobase.entities.references.Impacte;
import fr.ifremer.echobase.entities.references.LengthAgeKey;
+import fr.ifremer.echobase.entities.references.LengthWeightKey;
import fr.ifremer.echobase.entities.references.MeasureType;
import fr.ifremer.echobase.entities.references.MeasurementMetadata;
import fr.ifremer.echobase.entities.references.Mission;
@@ -80,7 +81,6 @@
import fr.ifremer.echobase.entities.references.TSParameters;
import fr.ifremer.echobase.entities.references.Vessel;
import fr.ifremer.echobase.entities.references.VesselType;
-import fr.ifremer.echobase.entities.references.WeightLengthKey;
import org.nuiton.util.decorator.DecoratorMulti18nProvider;
import java.util.Locale;
@@ -233,8 +233,8 @@
// VesselType decorator
registerJXPathDecorator(locale, VesselType.class, "${name}$s");
- // WeightLengthKey decorator
- registerJXPathDecorator(locale, WeightLengthKey.class, "Species ${species.genusSpecies}$s - a=${aParameter}$s, b=${bParameter}$s");
+ // LengthWeightKey decorator
+ registerJXPathDecorator(locale, LengthWeightKey.class, "Species ${species.genusSpecies}$s - a=${aParameter}$s, b=${bParameter}$s");
// Cell decorator
registerJXPathDecorator(locale, Cell.class, "${name}$s");
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2011-12-19 08:20:03 UTC (rev 201)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2011-12-19 19:16:01 UTC (rev 202)
@@ -40,7 +40,10 @@
import fr.ifremer.echobase.entities.references.ReferenceDatum;
import fr.ifremer.echobase.entities.references.ReferenceDatumType;
import fr.ifremer.echobase.entities.references.SampleDataType;
+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 org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.persistence.TopiaEntity;
@@ -192,7 +195,38 @@
return input.getId();
}
};
+ public static final Function<SizeCategory, String> SIZE_CATEGORY_NAME = new Function<SizeCategory, String>() {
+ @Override
+ public String apply(SizeCategory input) {
+ return input.getName();
+ }
+ };
+ public static final Function<SpeciesCategory, String> SPECIES_CATEGORY_SPIECIES = new Function<SpeciesCategory, String>() {
+ @Override
+ public String apply(SpeciesCategory input) {
+ return getSpeciesCategoryKey(input.getSpecies(), input.getSizeCategory(), input.getSexCategory());
+ }
+ };
+
+ public static final Function<SexCategory, String> SEX_CATEGORY_NAME = new Function<SexCategory, String>() {
+ @Override
+ public String apply(SexCategory input) {
+ return input.getName();
+ }
+ };
+
+ public static String getSpeciesCategoryKey(Species species, SizeCategory sizeCategory,SexCategory sexCategory) {
+ String key = species.getBaracoudaCode();
+ if (sizeCategory != null) {
+ key += "_" + sizeCategory.getName();
+ }
+ if (sexCategory != null) {
+ key += "_" + sexCategory.getName();
+ }
+ return key;
+ }
+
public static Function<Map<String, Object>, String> newRowFunction(final String key) {
return new Function<Map<String, Object>, String>() {
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-19 08:20:03 UTC (rev 201)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-19 19:16:01 UTC (rev 202)
@@ -118,13 +118,12 @@
result.add(EchoBaseEntityEnum.OperationType);
result.add(EchoBaseEntityEnum.MeasurementMetadata);
result.add(EchoBaseEntityEnum.SampleDataType);
- result.add(EchoBaseEntityEnum.BiometryScale);
result.add(EchoBaseEntityEnum.SampleType);
result.add(EchoBaseEntityEnum.Vessel);
result.add(EchoBaseEntityEnum.Echotype);
result.add(EchoBaseEntityEnum.DataMetadata);
result.add(EchoBaseEntityEnum.LengthAgeKey);
- result.add(EchoBaseEntityEnum.WeightLengthKey);
+ result.add(EchoBaseEntityEnum.LengthWeightKey);
result.add(EchoBaseEntityEnum.CellType);
result.add(EchoBaseEntityEnum.Impacte);
result.add(EchoBaseEntityEnum.Mission);
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-12-19 08:20:03 UTC (rev 201)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-12-19 19:16:01 UTC (rev 202)
@@ -1,5 +1,6 @@
+echobase.common.AParameter=
+echobase.common.BParameter=
echobase.common.TSParameters=
-echobase.common.aParameter=
echobase.common.accuracyEstimate=
echobase.common.acknowledgement=
echobase.common.acousticDensityUnit=
@@ -18,12 +19,10 @@
echobase.common.authorReference=
echobase.common.axis=
echobase.common.b=
-echobase.common.bParameter=
echobase.common.baracoudaCode=
echobase.common.binSizePingAxis=
echobase.common.binSizeRangeAxis=
echobase.common.binUnitsPingAxis=
-echobase.common.biometryScale=
echobase.common.calendar=
echobase.common.calibration=calibration
echobase.common.callsign=
@@ -95,7 +94,6 @@
echobase.common.gearShootingStartLatitude=
echobase.common.gearShootingStartLongitude=
echobase.common.gearShootingStartTime=
-echobase.common.gearType=
echobase.common.genusSpecies=
echobase.common.geospatialLatMax=
echobase.common.geospatialLatMin=
@@ -104,7 +102,6 @@
echobase.common.geospatialVerticalMax=
echobase.common.geospatialVerticalMin=
echobase.common.geospatialVerticalPositive=
-echobase.common.group=
echobase.common.history=
echobase.common.id=Identifiant
echobase.common.imo=
@@ -117,6 +114,7 @@
echobase.common.lastModifiedUser=Utilisateur de dernière modification
echobase.common.length=
echobase.common.lengthAgeKey=
+echobase.common.lengthWeightKey=
echobase.common.level=
echobase.common.licence=
echobase.common.linestring=
@@ -137,7 +135,6 @@
echobase.common.measurementUnit=
echobase.common.metadata=metadata
echobase.common.metadataGroup=
-echobase.common.metadataType=
echobase.common.midHauleLatitude=
echobase.common.midHauleLongitude=
echobase.common.minLatitude=
@@ -188,7 +185,6 @@
echobase.common.sampleDataType=
echobase.common.sampleType=
echobase.common.sampleWeight=
-echobase.common.sampling=
echobase.common.scaleFactor=
echobase.common.seafloorSubstrate=
echobase.common.sexCategory=
@@ -257,5 +253,4 @@
echobase.common.vessel=Navire
echobase.common.vesselType=
echobase.common.voyage=Campagne
-echobase.common.weightLengthKey=
echobase.config.data.directory.description=Chemin de l'application
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
1
0
19 Dec '11
Author: tchemit
Date: 2011-12-19 09:20:03 +0100 (Mon, 19 Dec 2011)
New Revision: 201
Url: http://forge.codelutin.com/repositories/revision/echobase/201
Log:
optimize dependencies
Modified:
trunk/echobase-services/pom.xml
trunk/echobase-tools/pom.xml
trunk/pom.xml
Modified: trunk/echobase-services/pom.xml
===================================================================
--- trunk/echobase-services/pom.xml 2011-12-19 08:10:42 UTC (rev 200)
+++ trunk/echobase-services/pom.xml 2011-12-19 08:20:03 UTC (rev 201)
@@ -55,10 +55,10 @@
<artifactId>commons-lang3</artifactId>
</dependency>
- <!--dependency>
- <groupId>org.apache.struts.xwork</groupId>
- <artifactId>xwork-core</artifactId>
- </dependency-->
+ <dependency>
+ <groupId>net.sourceforge.javacsv</groupId>
+ <artifactId>javacsv</artifactId>
+ </dependency>
<dependency>
<groupId>commons-beanutils</groupId>
Modified: trunk/echobase-tools/pom.xml
===================================================================
--- trunk/echobase-tools/pom.xml 2011-12-19 08:10:42 UTC (rev 200)
+++ trunk/echobase-tools/pom.xml 2011-12-19 08:20:03 UTC (rev 201)
@@ -62,6 +62,11 @@
<!-- commons dependencies -->
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-12-19 08:10:42 UTC (rev 200)
+++ trunk/pom.xml 2011-12-19 08:20:03 UTC (rev 201)
@@ -309,6 +309,12 @@
<version>10.0.1</version>
</dependency>
+ <dependency>
+ <groupId>net.sourceforge.javacsv</groupId>
+ <artifactId>javacsv</artifactId>
+ <version>2.0</version>
+ </dependency>
+
<!-- librairies web -->
<dependency>
1
0
r200 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase/entities echobase-entities/src/main/xmi echobase-services/src/main/java/fr/ifremer/echobase/services src/doc/reunions
by tchemit@users.forge.codelutin.com 19 Dec '11
by tchemit@users.forge.codelutin.com 19 Dec '11
19 Dec '11
Author: tchemit
Date: 2011-12-19 09:10:42 +0100 (Mon, 19 Dec 2011)
New Revision: 200
Url: http://forge.codelutin.com/repositories/revision/echobase/200
Log:
little stuff before small release
Added:
trunk/src/doc/reunions/reunion-2011-12-19.txt
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
trunk/echobase-entities/src/main/xmi/echobase.zargo
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-16 17:54:16 UTC (rev 199)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-12-19 08:10:42 UTC (rev 200)
@@ -169,6 +169,9 @@
result.add(EchoBaseEntityEnum.DataQuality);
result.add(EchoBaseEntityEnum.CellMethod);
result.add(EchoBaseEntityEnum.CellType);
+ result.add(EchoBaseEntityEnum.OperationEvent);
+ result.add(EchoBaseEntityEnum.SampleDataType);
+ result.add(EchoBaseEntityEnum.SampleType);
result.add(EchoBaseEntityEnum.DataMetadata);
result.add(EchoBaseEntityEnum.OperationMetadata);
result.add(EchoBaseEntityEnum.GearMetadata);
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java 2011-12-16 17:54:16 UTC (rev 199)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportService.java 2011-12-19 08:10:42 UTC (rev 200)
@@ -294,7 +294,6 @@
importer.close();
}
-
}
}
@@ -320,10 +319,6 @@
TableMeta tableMeta = getTableMeta(type);
entities.add(tableMeta);
-
-// for (AssociationMeta associationMeta : tableMeta.getAssociations()) {
-// associations.add(associationMeta);
-// }
associations.addAll(tableMeta.getAssociations());
}
}
Added: trunk/src/doc/reunions/reunion-2011-12-19.txt
===================================================================
--- trunk/src/doc/reunions/reunion-2011-12-19.txt (rev 0)
+++ trunk/src/doc/reunions/reunion-2011-12-19.txt 2011-12-19 08:10:42 UTC (rev 200)
@@ -0,0 +1,58 @@
+projet echobase
+---------------
+
+Lundi 19-12-2011 (Ifremer)
+
+Présents : Mathieu et Tony
+
+Planning
+--------
+
+- Revoir quelques points sur le modèle
+
+Modèle pêche
+------------
+
+- SpeciesCategory ?
+- Sample est lié à SpeciesCategory et Species ?
+- LengthAgeKey ?
+- WeightLengthKey ?
+- BiometryScale ?
+
+Import nouvelles données
+------------------------
+
+- Planning ?
+
+Réalisation modèle pêche
+------------------------
+
+- Report des modifications du modèle
+- Remplissage du référentiel OperationEvent
+- Remplissage du référentiel SampleDataType
+- Remplissage du référentiel SampleType
+- Création entité BiometryScale
+- Remplissage du référentiel BiometryScale
+- Remplissage du référentiel SexCategory
+- Remplissage du référentiel SizeCategory
+- Remplissage du référentiel OperationMetadata
+- Remplissage du référentiel GearMetadata
+- Remplissage du référentiel Gear
+
+- Import des opérations (depuis table STATIONS)
+- Import des samples (depuis table CAPTURES/MENSURATIONS/BIOMETRIE_VALEURS)
+
+Action
+------
+
+- Code
+
+ - livraison 0.2 avec toutes les données anciennes
+
+- Ifremer
+
+ - fournir les référentiels manquants
+
+Prochaine réunion :
+
+ - Lundi 19 à 10h00 à l'Ifremer avec Mathieu
\ No newline at end of file
Property changes on: trunk/src/doc/reunions/reunion-2011-12-19.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r199 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase echobase-entities/src/main/resources/i18n echobase-entities/src/main/xmi echobase-tools echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders src/doc/reunions
by tchemit@users.forge.codelutin.com 16 Dec '11
by tchemit@users.forge.codelutin.com 16 Dec '11
16 Dec '11
Author: tchemit
Date: 2011-12-16 18:54:16 +0100 (Fri, 16 Dec 2011)
New Revision: 199
Url: http://forge.codelutin.com/repositories/revision/echobase/199
Log:
- fix test resources
- continue Catches legacy datas import
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
trunk/echobase-tools/pom.xml
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoader.java
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/OperationLoader.java
trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SampleLoader.java
trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SampleLoaderIT.java
trunk/src/doc/reunions/reunion-2011-12-14.txt
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2011-12-16 01:46:20 UTC (rev 198)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2011-12-16 17:54:16 UTC (rev 199)
@@ -45,7 +45,6 @@
import org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.persistence.TopiaEntity;
-import javax.annotation.Nullable;
import java.io.File;
import java.util.Map;
@@ -165,7 +164,7 @@
return input.getName();
}
};
- public static final Function<SampleDataType, String> SAMPLE_DATA_TYPE_RAPRI_CODE = new Function<SampleDataType, String>() {
+ public static final Function<SampleDataType, String> SAMPLE_DATA_TYPE_RAPTRI_CODE = new Function<SampleDataType, String>() {
@Override
public String apply(SampleDataType input) {
return String.valueOf(input.getRaptriBiometryDataType());
@@ -186,6 +185,7 @@
return StringUtils.isEmpty(casinoGearName) ? input.getName() : casinoGearName;
}
};
+
public static final Function<Operation, String> OPERATION_ID = new Function<Operation, String>() {
@Override
public String apply(Operation input) {
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-12-16 01:46:20 UTC (rev 198)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-12-16 17:54:16 UTC (rev 199)
@@ -138,6 +138,8 @@
echobase.common.metadata=metadata
echobase.common.metadataGroup=
echobase.common.metadataType=
+echobase.common.midHauleLatitude=
+echobase.common.midHauleLongitude=
echobase.common.minLatitude=
echobase.common.minLongitude=
echobase.common.mission=mission
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
Modified: trunk/echobase-tools/pom.xml
===================================================================
--- trunk/echobase-tools/pom.xml 2011-12-16 01:46:20 UTC (rev 198)
+++ trunk/echobase-tools/pom.xml 2011-12-16 17:54:16 UTC (rev 199)
@@ -205,6 +205,12 @@
<include>**/*.csv</include>
</includes>
</testResource>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
</testResources>
</build>
</profile>
Modified: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoader.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoader.java 2011-12-16 01:46:20 UTC (rev 198)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/BiometryScaleLoader.java 2011-12-16 17:54:16 UTC (rev 199)
@@ -58,7 +58,7 @@
/*
raptriBiometryDataType;ScaleCode;ScaleMeaningEng;ScaleMeaningFr
*/
- model.addForeignKeyForImport("raptriBiometryDataType", BiometryScale.PROPERTY_SAMPLE_DATA_TYPE, SampleDataType.class, sampleDataTypes, EchoBaseFunctions.SAMPLE_DATA_TYPE_RAPRI_CODE);
+ model.addForeignKeyForImport("raptriBiometryDataType", BiometryScale.PROPERTY_SAMPLE_DATA_TYPE, SampleDataType.class, sampleDataTypes, EchoBaseFunctions.SAMPLE_DATA_TYPE_RAPTRI_CODE);
model.addDefaultColumn("ScaleCode",BiometryScale.PROPERTY_CODE, int.class);
model.newMandatoryColumn("ScaleMeaningEng",BiometryScale.PROPERTY_MEANING_EN);
model.newMandatoryColumn("ScaleMeaningFr",BiometryScale.PROPERTY_MEANING_FR);
Modified: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/OperationLoader.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/OperationLoader.java 2011-12-16 01:46:20 UTC (rev 198)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/OperationLoader.java 2011-12-16 17:54:16 UTC (rev 199)
@@ -119,40 +119,63 @@
copyAndLoadEntities(outputDir, meta.getAssociations(Operation.PROPERTY_OPERATION_METADATA_VALUE), false, FileType.ASSOCIATION);
copyAndLoadEntities(outputDir, meta.getAssociations(Operation.PROPERTY_GEAR_METADATA_VALUE), false, FileType.ASSOCIATION);
-
}
+ //SONDE
+ OperationMetadata MeanWaterDepthOperationMeta;
+ //JOUR_NUIT
+ OperationMetadata DielPeriodOperationMeta;
+ //SONDEDEB
+ OperationMetadata StartWaterDepthOperationMeta;
+ //SONDEFIN
+ OperationMetadata EndWaterDepthOperationMeta;
+
+ //LFUNES
+ GearMetadata CableLengthGearMeta;
+ //VMIN
+ GearMetadata MinSpeedGearMeta;
+ //VMAX
+ GearMetadata MaxSpeedGearMeta;
+
+ TopiaDAO<Operation> dao;
+ TopiaDAO<OperationMetadataValue> operationMetadataValueDAO;
+ TopiaDAO<GearMetadataValue> gearMetadataValueDAO;
+
+ Map<String, DepthStratum> depthStratumByName;
+ Map<String, Gear> gearByCasinoGearName;
+
@Override
- protected void importBaracoudaEntities(Database db) throws IOException, TopiaException {
+ protected void importBaracoudaEntities(Database db) throws
+ IOException, TopiaException {
Map<String, Voyage> voyagesByName = getUniverse(
Voyage.class, EchoBaseFunctions.VOYAGE_NAME);
- Map<String, DepthStratum> depthStratumByName = getUniverse(
+ depthStratumByName = getUniverse(
DepthStratum.class, EchoBaseFunctions.DEPTH_STRATUM_ID);
- Map<String, Gear> gearByCasinoGearName = getUniverse(
+ gearByCasinoGearName = getUniverse(
Gear.class, EchoBaseFunctions.GEAR_CASINO_GEAR_NAME);
OperationMetadataDAO operationMetadataDAO =
(OperationMetadataDAO) getDAO(OperationMetadata.class);
//SONDE
- OperationMetadata MeanWaterDepthOperationMeta =
+ MeanWaterDepthOperationMeta =
operationMetadataDAO.findByName("MeanWaterDepth");
Preconditions.checkNotNull(MeanWaterDepthOperationMeta);
//JOUR_NUIT
- OperationMetadata DielPeriodOperationMeta =
+ DielPeriodOperationMeta =
operationMetadataDAO.findByName("DielPeriod");
Preconditions.checkNotNull(DielPeriodOperationMeta);
//SONDEDEB
- OperationMetadata StartWaterDepthOperationMeta = operationMetadataDAO.findByProperties(
+ StartWaterDepthOperationMeta = operationMetadataDAO.findByProperties(
OperationMetadata.PROPERTY_NAME, "WaterDepth",
OperationMetadata.PROPERTY_OPERATION_EVENT + "." + OperationEvent.PROPERTY_NAME, "ShootingStart"
);
Preconditions.checkNotNull(StartWaterDepthOperationMeta);
//SONDEFIN
- OperationMetadata EndWaterDepthOperationMeta = operationMetadataDAO.findByProperties(
+ EndWaterDepthOperationMeta = operationMetadataDAO.findByProperties(
OperationMetadata.PROPERTY_NAME, "WaterDepth",
OperationMetadata.PROPERTY_OPERATION_EVENT + "." + OperationEvent.PROPERTY_NAME, "HaulingEnd"
);
@@ -162,24 +185,19 @@
(GearMetadataDAO) getDAO(GearMetadata.class);
//LFUNES
- GearMetadata CableLengthGearMeta = gearMetadataDAO.findByType("CableLength");
+ CableLengthGearMeta = gearMetadataDAO.findByType("CableLength");
Preconditions.checkNotNull(CableLengthGearMeta);
-
//VMIN
- GearMetadata MinSpeedGearMeta = gearMetadataDAO.findByType("MinSpeed");
+ MinSpeedGearMeta = gearMetadataDAO.findByType("MinSpeed");
Preconditions.checkNotNull(MinSpeedGearMeta);
-
//VMAX
- GearMetadata MaxSpeedGearMeta = gearMetadataDAO.findByType("MaxSpeed");
+ MaxSpeedGearMeta = gearMetadataDAO.findByType("MaxSpeed");
Preconditions.checkNotNull(MaxSpeedGearMeta);
- TopiaDAO<Operation> dao = getDAO();
- TopiaDAO<OperationMetadataValue> operationMetadataValueDAO =
- getDAO(OperationMetadataValue.class);
+ dao = getDAO();
+ operationMetadataValueDAO = getDAO(OperationMetadataValue.class);
+ gearMetadataValueDAO = getDAO(GearMetadataValue.class);
- TopiaDAO<GearMetadataValue> gearMetadataValueDAO =
- getDAO(GearMetadataValue.class);
-
Multimap<String, Map<String, Object>> stationByCampagneName = Multimaps.index(
db.getTable("STATIONS"), EchoBaseFunctions.newRowFunction("CAMPAGNE"));
@@ -196,142 +214,169 @@
Preconditions.checkNotNull(transect);
Collection<Map<String, Object>> rows =
stationByCampagneName.get(voyageName);
+
for (Map<String, Object> row : rows) {
- String status = (String) row.get("ETAT");
- if ("FICTIF".equalsIgnoreCase(status)) {
+ Operation operation = addOperation(row, messages);
+ if (operation != null) {
+ operations.add(operation);
+ transect.addOperation(operation);
- // skip fictif operation
- continue;
- }
- String operationId = (String) row.get("NOSTA");
+ if (!messages.isEmpty()) {
- DepthStratum depthStratum = null;
- String depthStratumId = (String) row.get("STA_IMAGES");
- if (StringUtils.isBlank(depthStratumId) ||
- "nul".equals(depthStratumId)) {
- messages.add("No depthStraum defined");
- } else {
- depthStratum = getFK(depthStratumByName, depthStratumId.trim());
+ if (log.isWarnEnabled()) {
+ log.warn("For operation " + operation.getId() + " : " + messages);
+ }
+ messages.clear();
+ }
}
+ }
+ }
- String gearId = (String) row.get("ENGIN");
- if (gearId == null) {
- messages.add("No gear id");
- } else {
- Gear gear = getFK(gearByCasinoGearName, gearId);
+ if (log.isInfoEnabled()) {
+ log.info("Found " + operations.size() + " operation(s).");
+ }
+ }
- Float shootingStartLatitude = (Float) row.get("LATDEB");
- if (shootingStartLatitude == null) {
- messages.add("No shootingStartLatitude");
- shootingStartLatitude = 0f;
- }
- Float shootingEndLatitude = (Float) row.get("LATDD");
- if (shootingEndLatitude == null) {
- messages.add("No shootingEndLatitude");
- shootingEndLatitude = 0f;
- }
- Float shootingStartLongitude = (Float) row.get("LGDEB");
- if (shootingStartLongitude == null) {
- messages.add("No shootingStartLongitude");
- shootingStartLongitude = 0f;
- }
- Float shootingEndLongitude = (Float) row.get("LGDD");
- if (shootingEndLongitude == null) {
- messages.add("No shootingEndLongitude");
- shootingEndLongitude = 0f;
- }
+ protected Operation addOperation(Map<String, Object> row,
+ List<String> messages) throws TopiaException {
+ String status = (String) row.get("ETAT");
- Date shootingStartTime = (Date) row.get("DHTUDEB");
- Date shootingEndTime = (Date) row.get("DHTUFIN");
+ if ("FICTIF".equalsIgnoreCase(status)) {
- String comment = (String) row.get("COMMENTAIRE");
+ // skip fictif operation
+ return null;
+ }
- // create a operation
- Operation operation = dao.create(
- Operation.PROPERTY_ID, operationId,
- Operation.PROPERTY_DEPTH_STRATUM, depthStratum,
- Operation.PROPERTY_GEAR, gear,
- Operation.PROPERTY_GEAR_SHOOTING_START_LATITUDE, shootingStartLatitude,
- Operation.PROPERTY_GEAR_SHOOTING_END_LATITUDE, shootingEndLatitude,
- Operation.PROPERTY_GEAR_SHOOTING_START_LONGITUDE, shootingStartLongitude,
- Operation.PROPERTY_GEAR_SHOOTING_END_LONGITUDE, shootingEndLongitude,
- Operation.PROPERTY_GEAR_SHOOTING_START_TIME, shootingStartTime,
- Operation.PROPERTY_GEAR_SHOOTING_END_TIME, shootingEndTime,
- Operation.PROPERTY_COMMENT, comment
- );
+ String operationId = (String) row.get("NOSTA");
- addOperationMetadataValue(operationMetadataValueDAO,
- operation,
- MeanWaterDepthOperationMeta,
- row.get("SONDE"));
+ String gearId = (String) row.get("ENGIN");
+ if (gearId == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("No gear id for Operation " + operationId);
+ }
+ return null;
+ }
- addOperationMetadataValue(operationMetadataValueDAO,
- operation,
- DielPeriodOperationMeta,
- row.get("JOUR_NUIT"));
+ DepthStratum depthStratum = null;
+ String depthStratumId = (String) row.get("STA_IMAGES");
+ if (StringUtils.isBlank(depthStratumId) ||
+ "nul".equals(depthStratumId)) {
+ messages.add("No depthStraum defined");
+ } else {
+ depthStratum = getFK(depthStratumByName, depthStratumId.trim());
+ }
- addOperationMetadataValue(operationMetadataValueDAO,
- operation,
- StartWaterDepthOperationMeta,
- row.get("SONDEDEB"));
+ Gear gear = getFK(gearByCasinoGearName, gearId);
- addOperationMetadataValue(operationMetadataValueDAO,
- operation,
- EndWaterDepthOperationMeta,
- row.get("SONDEFIN"));
+ Float shootingStartLatitude = (Float) row.get("LATDEB");
+ if (shootingStartLatitude == null) {
+ messages.add("No shootingStartLatitude");
+ }
- addGearMetadataValue(gearMetadataValueDAO,
- operation,
- CableLengthGearMeta,
- row.get("LFUNES"));
+ Double doubleValue = (Double) row.get("LATFIN");
+ Float shootingEndLatitude;
+ if (doubleValue == null) {
+ messages.add("No shootingEndLatitude");
+ shootingEndLatitude = null;
+ } else {
+ shootingEndLatitude = doubleValue.floatValue();
+ }
- addGearMetadataValue(gearMetadataValueDAO,
- operation,
- MinSpeedGearMeta,
- row.get("VMIN"));
+ Float shootingStartLongitude = (Float) row.get("LGDEB");
+ if (shootingStartLongitude == null) {
+ messages.add("No shootingStartLongitude");
+ }
- addGearMetadataValue(gearMetadataValueDAO,
- operation,
- MaxSpeedGearMeta,
- row.get("VMAX"));
+ doubleValue = (Double) row.get("LGFIN");
+ Float shootingEndLongitude;
+ if (doubleValue == null) {
+ messages.add("No shootingEndLongitude");
+ shootingEndLongitude = null;
+ } else {
+ shootingEndLongitude = doubleValue.floatValue();
+ }
- operations.add(operation);
- transect.addOperation(operation);
+ Float midHauleLatitude = (Float) row.get("LATDD");
+ Preconditions.checkNotNull(midHauleLatitude);
+// if (midHauleLatitude == null) {
+// messages.add("No midHauleLatitude");
+// midHauleLatitude = 0f;
+// }
- }
- if (!messages.isEmpty()) {
+ Float midHauleLongitude = (Float) row.get("LGDD");
+ Preconditions.checkNotNull(midHauleLongitude);
+// if (midHauleLongitude== null) {
+// messages.add("No midHauleLongitude");
+// midHauleLongitude = 0f;
+// }
- if (log.isWarnEnabled()) {
- log.warn("For operation " + operationId + ", status " + status + " : " + messages);
- }
- messages.clear();
- }
- }
- }
+ Date shootingStartTime = (Date) row.get("DHTUDEB");
+ Date shootingEndTime = (Date) row.get("DHTUFIN");
+ String comment = (String) row.get("COMMENTAIRE");
- if (log.isInfoEnabled()) {
- log.info("Found " + operations.size() + " operation(s).");
- }
+ // create a operation
+ Operation operation = dao.create(
+ Operation.PROPERTY_ID, operationId,
+ Operation.PROPERTY_DEPTH_STRATUM, depthStratum,
+ Operation.PROPERTY_GEAR, gear,
+ Operation.PROPERTY_GEAR_SHOOTING_START_LATITUDE, shootingStartLatitude,
+ Operation.PROPERTY_GEAR_SHOOTING_END_LATITUDE, shootingEndLatitude,
+ Operation.PROPERTY_GEAR_SHOOTING_START_LONGITUDE, shootingStartLongitude,
+ Operation.PROPERTY_GEAR_SHOOTING_END_LONGITUDE, shootingEndLongitude,
+ Operation.PROPERTY_GEAR_SHOOTING_START_TIME, shootingStartTime,
+ Operation.PROPERTY_GEAR_SHOOTING_END_TIME, shootingEndTime,
+ Operation.PROPERTY_MID_HAULE_LATITUDE, midHauleLatitude,
+ Operation.PROPERTY_MID_HAULE_LONGITUDE, midHauleLongitude,
+ Operation.PROPERTY_COMMENT, comment
+ );
+
+ addOperationMetadataValue(operation,
+ MeanWaterDepthOperationMeta,
+ row.get("SONDE"));
+
+ addOperationMetadataValue(operation,
+ DielPeriodOperationMeta,
+ row.get("JOUR_NUIT"));
+
+ addOperationMetadataValue(operation,
+ StartWaterDepthOperationMeta,
+ row.get("SONDEDEB"));
+
+ addOperationMetadataValue(operation,
+ EndWaterDepthOperationMeta,
+ row.get("SONDEFIN"));
+
+ addGearMetadataValue(operation,
+ CableLengthGearMeta,
+ row.get("LFUNES"));
+
+ addGearMetadataValue(operation,
+ MinSpeedGearMeta,
+ row.get("VMIN"));
+
+ addGearMetadataValue(operation,
+ MaxSpeedGearMeta,
+ row.get("VMAX"));
+
+ return operation;
}
- protected void addOperationMetadataValue(TopiaDAO<OperationMetadataValue> dao,
- Operation operation,
+ protected void addOperationMetadataValue(Operation operation,
OperationMetadata meta,
Object value
) throws TopiaException {
if (value == null) {
return;
}
- OperationMetadataValue operationMetadataValue = dao.create(
+ OperationMetadataValue operationMetadataValue = operationMetadataValueDAO.create(
OperationMetadataValue.PROPERTY_OPERATION_METADATA, meta,
OperationMetadataValue.PROPERTY_DATA_VALUE, value.toString()
);
operation.addOperationMetadataValue(operationMetadataValue);
}
- protected void addGearMetadataValue(TopiaDAO<GearMetadataValue> dao,
- Operation operation,
+ protected void addGearMetadataValue(Operation operation,
GearMetadata meta,
Object value
) throws TopiaException {
@@ -339,7 +384,7 @@
if (value == null) {
return;
}
- GearMetadataValue gearMetadataValue = dao.create(
+ GearMetadataValue gearMetadataValue = gearMetadataValueDAO.create(
GearMetadataValue.PROPERTY_GEAR_METADATA, meta,
GearMetadataValue.PROPERTY_DATA_VALUE, value.toString(),
GearMetadataValue.PROPERTY_GEAR, operation.getGear()
Modified: trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SampleLoader.java
===================================================================
--- trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SampleLoader.java 2011-12-16 01:46:20 UTC (rev 198)
+++ trunk/echobase-tools/src/main/java/fr/ifremer/echobase/tools/loaders/SampleLoader.java 2011-12-16 17:54:16 UTC (rev 199)
@@ -26,6 +26,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
+import com.google.common.collect.Sets;
import com.healthmarketscience.jackcess.Database;
import fr.ifremer.echobase.EchoBaseFunctions;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
@@ -35,7 +36,6 @@
import fr.ifremer.echobase.entities.data.SampleDataDAO;
import fr.ifremer.echobase.entities.meta.TableMeta;
import fr.ifremer.echobase.entities.references.SampleDataType;
-import fr.ifremer.echobase.entities.references.SampleDataTypeDAO;
import fr.ifremer.echobase.entities.references.SampleType;
import fr.ifremer.echobase.entities.references.SampleTypeDAO;
import fr.ifremer.echobase.entities.references.Species;
@@ -49,6 +49,7 @@
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
+import java.util.Set;
/**
* To load {@link Sample} entities.
@@ -100,9 +101,9 @@
TableMeta meta = getMeta();
copyAndLoadEntities(outputDir, meta.getAssociations(Sample.PROPERTY_SAMPLE_DATA), false, FileType.ASSOCIATION);
-
}
+
@Override
protected void importBaracoudaEntities(Database db) throws IOException, TopiaException {
@@ -112,6 +113,9 @@
Map<String, Species> speciesByName = getUniverse(
Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE);
+ Map<String, SampleDataType> sampleDataTypeByRaptriCode = getUniverse(
+ SampleDataType.class, EchoBaseFunctions.SAMPLE_DATA_TYPE_RAPTRI_CODE);
+
Multimap<String, Map<String, Object>> mensurationByNosta = Multimaps.index(
db.getTable("MENSURATIONS", true),
EchoBaseFunctions.newRowFunction("NOSTA")
@@ -121,6 +125,16 @@
db.getTable("CAPTURES", true),
EchoBaseFunctions.newRowFunction("NOSTA")
);
+
+ Multimap<Integer, Map<String, Object>> biometryScalesByRaptri = Multimaps.index(
+ db.getTable("BIOMETRIE_ECHELLE", true),
+ EchoBaseFunctions.newRowIntegerFunction("Code_Param_Biometrie_Echelle")
+ );
+
+ Multimap<String, Map<String, Object>> biometryValuesByNosta = Multimaps.index(
+ db.getTable("BIOMETRIE_VALEUR", true),
+ EchoBaseFunctions.newRowFunction("NOSTA_VALEUR_BIOMETRIE")
+ );
SampleTypeDAO sampleTypeDAO =
(SampleTypeDAO) getDAO(SampleType.class);
@@ -130,28 +144,32 @@
Preconditions.checkNotNull(sampleTypeUnsorted);
SampleType sampleTypeSubsample = sampleTypeDAO.findByName("Subsample");
Preconditions.checkNotNull(sampleTypeSubsample);
+ SampleType sampleTypeIndividual = sampleTypeDAO.findByName("Individual");
+ Preconditions.checkNotNull(sampleTypeIndividual);
- SampleDataTypeDAO sampleDataTypeDAO =
- (SampleDataTypeDAO) getDAO(SampleDataType.class);
+// SampleDataTypeDAO sampleDataTypeDAO =
+// (SampleDataTypeDAO) getDAO(SampleDataType.class);
SampleDataDAO sampleDataDAO = (SampleDataDAO) getDAO(SampleData.class);
- SampleDataType sampleDataTypeMeanLength = sampleDataTypeDAO.findByName("MeanLengthcm");
- Preconditions.checkNotNull(sampleDataTypeMeanLength);
- SampleDataType sampleDataTypeMeanWeight = sampleDataTypeDAO.findByName("MeanWeightg");
- Preconditions.checkNotNull(sampleDataTypeMeanWeight);
- SampleDataType sampleDataTypeNoPerKg = sampleDataTypeDAO.findByName("NoPerKg");
- Preconditions.checkNotNull(sampleDataTypeNoPerKg);
- SampleDataType sampleDataTypeNumberAtLength = sampleDataTypeDAO.findByName("NumberAtLength");
- Preconditions.checkNotNull(sampleDataTypeNumberAtLength);
- SampleDataType sampleDataTypeWeightAtLength = sampleDataTypeDAO.findByName("WeightAtLengthkg");
- Preconditions.checkNotNull(sampleDataTypeWeightAtLength);
+// SampleDataType sampleDataTypeMeanLength = sampleDataTypeDAO.findByName("MeanLengthcm");
+ SampleDataType sampleDataTypeMeanLength = getFK(sampleDataTypeByRaptriCode, "114");
+// SampleDataType sampleDataTypeMeanWeight = sampleDataTypeDAO.findByName("MeanWeightg");
+ SampleDataType sampleDataTypeMeanWeight = getFK(sampleDataTypeByRaptriCode, "115");
+// SampleDataType sampleDataTypeNoPerKg = sampleDataTypeDAO.findByName("NoPerKg");
+ SampleDataType sampleDataTypeNoPerKg = getFK(sampleDataTypeByRaptriCode, "116");
+// SampleDataType sampleDataTypeNumberAtLength = sampleDataTypeDAO.findByName("NumberAtLength");
+ SampleDataType sampleDataTypeNumberAtLength = getFK(sampleDataTypeByRaptriCode, "112");
+// SampleDataType sampleDataTypeWeightAtLength = sampleDataTypeDAO.findByName("WeightAtLengthkg");
+ SampleDataType sampleDataTypeWeightAtLength = getFK(sampleDataTypeByRaptriCode, "113");
+
TopiaDAO<Sample> dao = getDAO();
int nbSampleUnsorted = 0;
int nbSampleTotal = 0;
int nbSubSample = 0;
+ int nbIndividualSample = 0;
for (String operationId : capturesByNosta.keySet()) {
Preconditions.checkNotNull(operationId);
@@ -162,6 +180,13 @@
}
continue;
}
+ Collection<Map<String, Object>> biometryValues =
+ biometryValuesByNosta.get(operationId);
+
+ Multimap<String, Map<String, Object>> biometryValuesBySpecies = Multimaps.index(
+ biometryValues,
+ EchoBaseFunctions.newRowFunction("GENRE_ESP_VALEUR_BIOMETRIE")
+ );
for (Map<String, Object> row : capturesByNosta.get(operationId)) {
String type = (String) row.get("CATEG");
@@ -214,7 +239,7 @@
"NA",
row.get("MOULE_MENS"));
- Collection<Map<String, Object>> mesnurationRows =
+ Collection<Map<String, Object>> mensurationRows =
mensurationByNosta.get(operationId);
Float sampleWeight = (Float) row.get("PESP_MENS");
@@ -224,6 +249,7 @@
}
sampleWeight = 0f;
}
+
addSubSamples(dao,
sampleDataDAO,
sampleTypeSubsample,
@@ -233,22 +259,105 @@
type,
species,
sampleWeight,
- mesnurationRows);
+ mensurationRows);
int nbSamples = operation.sizeSample();
nbSubSample += nbSamples - 1;
+
+ Collection<Map<String, Object>> biometryValuesRows =
+ biometryValuesBySpecies.get(speciesId);
+
+ int nbSampleIndiv = addSampleIndividuals(dao,
+ sampleDataDAO,
+ operation,
+ species,
+ sampleTypeIndividual,
+ sampleDataTypeByRaptriCode,
+ biometryScalesByRaptri,
+ biometryValuesRows);
+ nbIndividualSample += nbSampleIndiv;
+
}
}
-
if (log.isInfoEnabled()) {
log.info("Found " + nbSampleTotal + " 'total' sample(s).");
log.info("Found " + nbSampleUnsorted + " 'unsorted' sample(s).");
log.info("Found " + nbSubSample + " 'sub' sample(s).");
- log.info("Total " + (nbSampleTotal + nbSampleUnsorted + nbSubSample) + " sample(s).");
+ log.info("Found " + nbIndividualSample + " 'Individual' sample(s).");
+ log.info("Total " + (nbSampleTotal + nbSampleUnsorted + nbIndividualSample + nbSubSample) + " sample(s).");
}
}
+ private int addSampleIndividuals(TopiaDAO<Sample> dao,
+ SampleDataDAO sampleDataDAO,
+ Operation operation,
+ Species species,
+ SampleType sampleTypeIndividual,
+ Map<String, SampleDataType> sampleDataTypeByRaptriCode,
+ Multimap<Integer, Map<String, Object>> biometryScalesByRaptri,
+ Collection<Map<String, Object>> biometryValuesRows) throws TopiaException {
+ int result = 0;
+ Sample sample = null;
+ Set<Integer> individus = Sets.newHashSet();
+ for (Map<String, Object> biometryValuesRow : biometryValuesRows) {
+ Integer ind = Integer.valueOf(biometryValuesRow.get("NUMIND_VALEUR_BIOMETRIE").toString());
+ Integer codeParameter = (Integer) biometryValuesRow.get("CODE_PARAM_VALEUR_BIOMETRIE");
+ String label = null;
+ Float value = (Float) biometryValuesRow.get("VALEUR_BIOMETRIE");
+ if (value==null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Null value of VALEUR_BIOMETRIE for operationId/Species/Individu/Code param " + operation.getId() + "/" + species.getBaracoudaCode() + "/" + ind+"/"+codeParameter);
+ }
+ continue;
+ }
+ Preconditions.checkNotNull(value, "Null value of VALEUR_BIOMETRIE for operationId/Species/Individu/Code param " + operation.getId() + "/" + species.getBaracoudaCode() + "/" + ind+"/"+codeParameter);
+ SampleDataType sampleDataType = getFK(sampleDataTypeByRaptriCode, String.valueOf(codeParameter));
+
+ boolean add = individus.add(ind);
+ if (add) {
+
+ // new sample
+ sample = dao.create(
+ Sample.PROPERTY_SPECIES, species,
+ Sample.PROPERTY_SAMPLE_TYPE, sampleTypeIndividual
+ );
+
+ operation.addSample(sample);
+ result++;
+ }
+
+ Collection<Map<String, Object>> scalesRows =
+ biometryScalesByRaptri.get(codeParameter);
+
+ if (scalesRows == null) {
+
+ label = "NA";
+ } else {
+
+ // find the correct line
+ int valueAsInteger = value.intValue();
+
+ for (Map<String, Object> scalesRow : scalesRows) {
+ Float scaleCode = (Float) scalesRow.get("Code_echelle");
+ if (valueAsInteger == scaleCode.intValue()) {
+
+ // ok find the correct scale
+ label = (String) scalesRow.get("Descriptif");
+ break;
+ }
+ }
+ }
+ addSampleData(sampleDataDAO,
+ sample,
+ sampleDataType,
+ label,
+ value
+ );
+ }
+ return result;
+ }
+
private void addSubSamples(TopiaDAO<Sample> dao,
SampleDataDAO sampleDataDAO,
SampleType sampleTypeSubsample,
Modified: trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SampleLoaderIT.java
===================================================================
--- trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SampleLoaderIT.java 2011-12-16 01:46:20 UTC (rev 198)
+++ trunk/echobase-tools/src/test/java/fr/ifremer/echobase/tools/loaders/SampleLoaderIT.java 2011-12-16 17:54:16 UTC (rev 199)
@@ -35,7 +35,7 @@
public class SampleLoaderIT extends AbstractLoaderIT<Sample, SampleLoader> {
public SampleLoaderIT() {
- super(SampleLoader.class, 0, 208199);
+ super(SampleLoader.class, 0, 324809);
}
@Test
Modified: trunk/src/doc/reunions/reunion-2011-12-14.txt
===================================================================
--- trunk/src/doc/reunions/reunion-2011-12-14.txt 2011-12-16 01:46:20 UTC (rev 198)
+++ trunk/src/doc/reunions/reunion-2011-12-14.txt 2011-12-16 17:54:16 UTC (rev 199)
@@ -50,6 +50,7 @@
- Remplissage du référentiel Gear
- Import des opérations (depuis table STATIONS)
+- Import des samples (depuis table CAPTURES/MENSURATIONS/BIOMETRIE_VALEURS)
Action
------
1
0