Tutti-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
July 2013
- 4 participants
- 57 discussions
24 Jul '13
Author: tchemit
Date: 2013-07-24 19:37:47 +0200 (Wed, 24 Jul 2013)
New Revision: 1154
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1154
Log:
add missing license header + svn properties
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java
trunk/tutti-persistence/src/main/resources/META-INF/services/org.apache.commons.beanutils.Converter
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/MandatorySampleCategoryColumnIdentifier.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.config;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.entities;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.TuttiPersistence;
/**
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.entities.data;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.entities.data;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import fr.ifremer.tutti.persistence.TuttiPersistence;
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.entities.protocol.v1;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.entities.TuttiEntity;
import javax.annotation.Generated;
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.entities.protocol.v1;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.entities.TuttiEntityBean;
import javax.annotation.Generated;
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.entities.protocol.v1;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.entities.CommentAware;
import fr.ifremer.tutti.persistence.entities.TuttiEntity;
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.entities.protocol.v1;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.entities.TuttiEntityBean;
import javax.annotation.Generated;
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/tutti-persistence/src/main/resources/META-INF/services/org.apache.commons.beanutils.Converter
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.config;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
Property changes on: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.operation.catches;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
/**
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/MandatorySampleCategoryColumnIdentifier.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/MandatorySampleCategoryColumnIdentifier.java 2013-07-24 17:35:44 UTC (rev 1153)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/MandatorySampleCategoryColumnIdentifier.java 2013-07-24 17:37:47 UTC (rev 1154)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.protocol;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
/**
1
0
24 Jul '13
Author: tchemit
Date: 2013-07-24 19:35:44 +0200 (Wed, 24 Jul 2013)
New Revision: 1153
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1153
Log:
- mise ?\195?\160 jour des librairies
- refs #2889: [TECH] - Prise en compte de nouvelles cat?\195?\169gories dans l'applicatif
Added:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java
trunk/tutti-persistence/src/main/resources/META-INF/services/org.apache.commons.beanutils.Converter
trunk/tutti-persistence/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java
trunk/tutti-service/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/MandatorySampleCategoryColumnIdentifier.java
trunk/tutti-ui-swing/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider
Removed:
trunk/changelog.txt
trunk/tutti-persistence/changelog.txt
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryEnum.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SexEnum.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SizeEnum.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/
trunk/tutti-persistence/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceWriteTest.java
trunk/tutti-service/changelog.txt
trunk/tutti-service/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider
trunk/tutti-ui-swing/changelog.txt
trunk/tutti-ui-swing/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider
Modified:
trunk/pom.xml
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/ProgressionModel.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfig.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigOption.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigProvider.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/AttachementObjectTypeEnum.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/test/DatabaseResource.java
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceWriteTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
trunk/tutti-service/pom.xml
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDecorator.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/AccidentalCatchRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/AttachmentRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CaracteristicRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchFrequencyRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/IndividualObservationRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MarineLitterRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfig.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigOption.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigProvider.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportSampleCategory.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/CaracteristicRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/SpeciesRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/SpeciesRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/GearModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/TuttiReferentialImportExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/VesselModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/AbstractServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/DecoratorServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigOption.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigProvider.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderIdsTableCell.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiBeanMonitor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiLocationTableCell.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/VesselTableCell.java
trunk/tutti-ui-swing/src/main/resources/META-INF/aop.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Deleted: trunk/changelog.txt
===================================================================
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/pom.xml 2013-07-24 17:35:44 UTC (rev 1153)
@@ -120,15 +120,15 @@
<!-- libraries version -->
- <nuitonUtilsVersion>2.6.12</nuitonUtilsVersion>
<nuitonI18nVersion>2.5.2</nuitonI18nVersion>
+ <nuitonValidatorVersion>3.0-alpha-1</nuitonValidatorVersion>
- <eugenePluginVersion>2.6.3</eugenePluginVersion>
+ <eugenePluginVersion>2.7</eugenePluginVersion>
<hibernateVersion>3.6.10.Final</hibernateVersion>
- <jaxxVersion>2.5.24</jaxxVersion>
+ <jaxxVersion>2.6-SNAPSHOT</jaxxVersion>
<swingXVersion>1.6.4</swingXVersion>
- <xworkVersion>2.3.15</xworkVersion>
+ <xworkVersion>2.3.15.1</xworkVersion>
<slf4jVersion>1.7.5</slf4jVersion>
@@ -200,25 +200,31 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
- <version>${nuitonUtilsVersion}</version>
+ <version>3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.nuiton</groupId>
+ <artifactId>nuiton-decorator</artifactId>
+ <version>3.0-alpha-1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
<artifactId>nuiton-config</artifactId>
- <version>${nuitonUtilsVersion}</version>
+ <version>3.0-alpha-1</version>
</dependency>
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-updater</artifactId>
- <version>${nuitonUtilsVersion}</version>
+ <version>3.0-alpha-1</version>
</dependency>
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-csv</artifactId>
- <version>${nuitonUtilsVersion}</version>
+ <version>3.0-alpha-1</version>
</dependency>
<dependency>
@@ -236,13 +242,14 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-validator</artifactId>
- <version>${nuitonUtilsVersion}</version>
+ <version>${nuitonValidatorVersion}</version>
</dependency>
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-validator</artifactId>
- <version>${nuitonUtilsVersion}</version>
+ <version>${nuitonValidatorVersion}</version>
+ <scope>test</scope>
<classifier>tests</classifier>
</dependency>
@@ -697,8 +704,8 @@
<plugin>
<groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils-maven-report-plugin</artifactId>
- <version>${nuitonUtilsVersion}</version>
+ <artifactId>nuiton-maven-report-plugin</artifactId>
+ <version>3.0-alpha-1</version>
<inherited>false</inherited>
<reportSets>
<reportSet>
Deleted: trunk/tutti-persistence/changelog.txt
===================================================================
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/ProgressionModel.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/ProgressionModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/ProgressionModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,7 +25,7 @@
*/
import org.jdesktop.beans.AbstractSerializableBean;
-import org.nuiton.util.updater.DownloadMonitor;
+import org.nuiton.updater.DownloadMonitor;
/**
* Simple model for a progression long task.
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -35,7 +35,6 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
@@ -48,6 +47,7 @@
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.persistence.entities.referential.TuttiReferentialEntity;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
@@ -75,6 +75,8 @@
*/
void clearAllCaches();
+ TuttiEnumerationFile getEnumerationFile();
+
//------------------------------------------------------------------------//
//-- Referential methods --//
//------------------------------------------------------------------------//
@@ -253,6 +255,12 @@
Caracteristic getWeightMeasuredCaracteristic();
+ Caracteristic getCaracteristic(Integer pmfmId);
+
+ boolean isVracSpeciesBatch(SpeciesBatch speciesBatch);
+
+ boolean isVracBenthosBatch(BenthosBatch benthosBatch);
+
boolean isTemporary(TuttiReferentialEntity entity);
List<Gear> getAllScientificGear();
@@ -595,21 +603,6 @@
List<BenthosBatchFrequency> frequencies);
//------------------------------------------------------------------------//
- //-- Plancton Batch methods --//
- //------------------------------------------------------------------------//
-
- List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId);
-
- @Transactional(readOnly = false)
- PlanktonBatch createPlanktonBatch(PlanktonBatch bean);
-
- @Transactional(readOnly = false)
- PlanktonBatch savePlanktonBatch(PlanktonBatch bean);
-
- @Transactional(readOnly = false)
- void deletePlanktonBatch(String id);
-
- //------------------------------------------------------------------------//
//-- MarineLitter Batch methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,8 +24,10 @@
* #L%
*/
+import com.google.common.base.Predicate;
import com.google.common.collect.Maps;
import fr.ifremer.adagio.core.service.technical.CacheService;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
@@ -37,7 +39,6 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
@@ -59,11 +60,11 @@
import fr.ifremer.tutti.persistence.service.FishingOperationPersistenceService;
import fr.ifremer.tutti.persistence.service.IndividualObservationBatchPersistenceService;
import fr.ifremer.tutti.persistence.service.MarineLitterBatchPersistenceService;
-import fr.ifremer.tutti.persistence.service.PlanktonBatchPersistenceService;
import fr.ifremer.tutti.persistence.service.ProgramPersistenceService;
import fr.ifremer.tutti.persistence.service.ProtocolPersistenceService;
import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService;
import fr.ifremer.tutti.persistence.service.SpeciesBatchPersistenceService;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -107,9 +108,6 @@
protected BenthosBatchPersistenceService benthosBatchService;
@Autowired
- protected PlanktonBatchPersistenceService planktonBatchService;
-
- @Autowired
protected MarineLitterBatchPersistenceService marineLitterBatchService;
@Autowired
@@ -127,6 +125,10 @@
@Autowired
protected CacheService cacheService;
+ protected Predicate<SpeciesBatch> speciesBatchVracPredicate;
+
+ protected Predicate<BenthosBatch> benthosBatchVracPredicate;
+
@Override
public String getImplementationName() {
return "Persistence Adagio implementation";
@@ -138,6 +140,11 @@
}
@Override
+ public TuttiEnumerationFile getEnumerationFile() {
+ return referentialService.getEnumerationFile();
+ }
+
+ @Override
public void init() {
if (log.isInfoEnabled()) {
log.info("Open persistence driver " + getImplementationName());
@@ -149,12 +156,16 @@
catchBatchService.init();
speciesBatchService.init();
benthosBatchService.init();
- planktonBatchService.init();
marineLitterBatchService.init();
accidentalBatchService.init();
individualObservationBatchService.init();
protocolService.init();
attachmentService.init();
+
+ TuttiEnumerationFile enumerationFile = getEnumerationFile();
+
+ speciesBatchVracPredicate = TuttiEntities.newSpeciesBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
+ benthosBatchVracPredicate = TuttiEntities.newBenthosBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
}
@Override
@@ -170,7 +181,6 @@
catchBatchService.close();
speciesBatchService.close();
benthosBatchService.close();
- planktonBatchService.close();
marineLitterBatchService.close();
accidentalBatchService.close();
individualObservationBatchService.close();
@@ -375,6 +385,21 @@
}
@Override
+ public Caracteristic getCaracteristic(Integer pmfmId) {
+ return referentialService.getCaracteristic(pmfmId);
+ }
+
+ @Override
+ public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
+ return speciesBatchVracPredicate.apply(speciesBatch);
+ }
+
+ @Override
+ public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
+ return benthosBatchVracPredicate.apply(benthosBatch);
+ }
+
+ @Override
public boolean isTemporary(TuttiReferentialEntity entity) {
return referentialService.isTemporary(entity);
}
@@ -711,30 +736,6 @@
}
//------------------------------------------------------------------------//
- //-- Plancton Batch methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
- return planktonBatchService.getAllPlanktonBatch(fishingOperationId);
- }
-
- @Override
- public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) {
- return planktonBatchService.createPlanktonBatch(bean);
- }
-
- @Override
- public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) {
- return planktonBatchService.savePlanktonBatch(bean);
- }
-
- @Override
- public void deletePlanktonBatch(String id) {
- planktonBatchService.deletePlanktonBatch(id);
- }
-
- //------------------------------------------------------------------------//
//-- MarineLitter Batch methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -35,7 +35,6 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
@@ -48,6 +47,7 @@
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.persistence.entities.referential.TuttiReferentialEntity;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import java.io.File;
import java.io.IOException;
@@ -67,6 +67,21 @@
}
@Override
+ public TuttiEnumerationFile getEnumerationFile() {
+ throw notImplemented();
+ }
+
+ @Override
+ public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
+ throw notImplemented();
+ }
+
+ @Override
+ public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
+ throw notImplemented();
+ }
+
+ @Override
public void clearAllCaches() {
throw notImplemented();
}
@@ -227,6 +242,11 @@
}
@Override
+ public Caracteristic getCaracteristic(Integer pmfmId) {
+ throw notImplemented();
+ }
+
+ @Override
public boolean isTemporary(TuttiReferentialEntity entity) {
throw notImplemented();
}
@@ -507,26 +527,6 @@
}
@Override
- public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
- throw notImplemented();
- }
-
- @Override
- public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) {
- throw notImplemented();
- }
-
- @Override
- public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) {
- throw notImplemented();
- }
-
- @Override
- public void deletePlanktonBatch(String id) {
- throw notImplemented();
- }
-
- @Override
public BatchContainer<MarineLitterBatch> getRootMarineLitterBatch(String fishingOperationId) {
throw notImplemented();
}
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,70 @@
+package fr.ifremer.tutti.persistence.config;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import org.apache.commons.beanutils.ConversionException;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To convert to a {@link SampleCategoryModel} from a string representation.
+ * <p/>
+ * Each entry is a couple (categoryId,label).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class SampleCategoryModelConverter implements Converter {
+
+ @Override
+ public Object convert(Class aClass, Object value) {
+ Preconditions.checkNotNull(
+ value, "Can not convert a null SampleCategoryModel");
+ if (isEnabled(aClass)) {
+ Object result;
+ if (isEnabled(value.getClass())) {
+ result = value;
+ return result;
+ }
+ if (value instanceof String) {
+
+ List<SampleCategoryModelEntry> entries = Lists.newArrayList();
+
+ String strValue = (String) value;
+
+ if (StringUtils.isNotEmpty(strValue)) {
+ String[] entryStrs = strValue.split("\\s*\\|\\s*");
+
+ for (String entryStr : entryStrs) {
+ String[] entryParts = entryStr.split("\\s*\\,\\s*");
+ SampleCategoryModelEntry entry = new SampleCategoryModelEntry();
+ entry.setCategoryId(Integer.valueOf(entryParts[0]));
+ if (entryParts.length > 1) {
+ entry.setLabel(entryParts[1]);
+ }
+ entry.setOrder(entries.size());
+ entries.add(entry);
+ }
+ }
+ result = new SampleCategoryModel(entries);
+ return result;
+ }
+ }
+ throw new ConversionException(
+ _("nuitonutil.error.no.convertor", aClass.getName(), value));
+ }
+
+ protected boolean isEnabled(Class<?> aClass) {
+ return SampleCategoryModel.class.equals(aClass);
+ }
+
+ public Class<?> getType() {
+ return SampleCategoryModel.class;
+ }
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/SampleCategoryModelConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfig.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfig.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfig.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -31,10 +31,11 @@
import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.RessourceClassLoader;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.config.ApplicationConfig;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -137,6 +138,15 @@
return config.getOption(TuttiPersistenceConfigOption.DB_NAME.getKey());
}
+ public SampleCategoryModel getSampleCategoryModel() {
+ SampleCategoryModel result = config.getOption(SampleCategoryModel.class, TuttiPersistenceConfigOption.SAMPLE_CATEGORY_MODEL.getKey());
+ return result;
+ }
+
+ public void setSampleCategoryModel(SampleCategoryModel model) {
+ config.setOption(TuttiPersistenceConfigOption.SAMPLE_CATEGORY_MODEL.getKey(), String.valueOf(model));
+ }
+
public boolean isDbExists() {
File f = new File(getDbDirectory(), getDbName() + ".data");
return f.exists();
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigOption.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigOption.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigOption.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,9 +24,10 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import org.hibernate.dialect.HSQLDialect;
import org.hsqldb.jdbcDriver;
-import org.nuiton.util.config.ConfigOptionDef;
+import org.nuiton.config.ConfigOptionDef;
import java.io.File;
@@ -44,92 +45,68 @@
"tutti.persistence.db.directory",
n_("tutti.config.option.persistence.db.directory.description"),
"${tutti.data.directory}/db",
- File.class,
- true,
- true),
+ File.class),
DB_ATTACHMENT_DIRECTORY(
"tutti.persistence.db.attachment.directory",
n_("tutti.config.option.persistence.db.attachment.directory.description"),
"${tutti.data.directory}/meas_files",
- File.class,
- true,
- true),
+ File.class),
DB_CACHE_DIRECTORY(
"tutti.persistence.db.cache.directory",
n_("tutti.config.option.persistence.db.cache.directory.description"),
"${tutti.data.directory}/dbcache",
- File.class,
- true,
- true),
+ File.class),
DB_PROTOCOL_DIRECTORY(
"tutti.persistence.db.protocol.directory",
n_("tutti.config.option.persistence.db.protocol.directory.description"),
"${tutti.data.directory}/protocol",
- File.class,
- true,
- true),
+ File.class),
DB_CONFIGURATION_PATH(
"tutti.persistence.db.configurationPath",
n_("tutti.config.option.persistence.db.configurationPath.description"),
"${tutti.data.directory}/dbconf/conf.properties",
- File.class,
- true,
- true),
+ File.class),
DB_ENUMERATION_PATH(
"tutti.persistence.db.enumerationPath",
n_("tutti.config.option.persistence.db.enumerationPath.description"),
"${tutti.data.directory}/dbconf/enumerations-v3.properties",
- File.class,
- true,
- true),
+ File.class),
DB_NAME(
"tutti.persistence.db.name",
n_("tutti.config.option.persistence.db.name.description"),
"allegro",
- String.class,
- true,
- true),
+ String.class),
JDBC_USERNAME(
"tutti.persistence.jdbc.username",
n_("tutti.config.option.persistence.jdbc.username.description"),
"sa",
- String.class,
- true,
- true),
+ String.class),
JDBC_PASSWORD(
"tutti.persistence.jdbc.password",
n_("tutti.config.option.persistence.jdbc.password.description"),
"",
- String.class,
- true,
- true),
+ String.class),
JDBC_URL(
"tutti.persistence.jdbc.url",
n_("tutti.config.option.persistence.jdbc.url.description"),
"jdbc:hsqldb:file:${tutti.persistence.db.directory}/${tutti.persistence.db.name}",
- String.class,
- true,
- true),
+ String.class),
JDBC_DRIVER(
"tutti.persistence.jdbc.driver",
n_("tutti.config.option.persistence.jdbc.driver.description"),
jdbcDriver.class.getName(),
- Class.class,
- true,
- true),
+ Class.class),
HIBERNATE_DIALECT(
"tutti.persistence.hibernate.dialect",
n_("tutti.config.option.persistence.hibernate.dialect.description"),
HSQLDialect.class.getName(),
- Class.class,
- true,
- true),
+ Class.class),
HIBERNATE_SHOW_SQL(
"tutti.persistence.hibernate.showSql",
n_("tutti.config.option.persistence.hibernate.showSql.description"),
@@ -150,8 +127,17 @@
Boolean.FALSE.toString(),
boolean.class,
false,
- false);
+ false),
+ SAMPLE_CATEGORY_MODEL(
+ "tutti.persistence.SampleCategoryModel",
+ n_("tutti.config.option.persistence.SampleCategoryModel.description"),
+ "1428,Vrac/Hors Vrac|198,Classe de Tri|196,Sexe|174,Maturité|1430,Age",
+ SampleCategoryModel.class,
+ false,
+ false
+ );
+
/** Configuration key. */
private final String key;
@@ -173,6 +159,18 @@
TuttiPersistenceConfigOption(String key,
String description,
String defaultValue,
+ Class<?> type) {
+ this.key = key;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.type = type;
+ this.isTransient = true;
+ this.isFinal = true;
+ }
+
+ TuttiPersistenceConfigOption(String key,
+ String description,
+ String defaultValue,
Class<?> type,
boolean isTransient,
boolean isFinal) {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigProvider.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigProvider.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigProvider.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,9 +24,9 @@
* #L%
*/
-import org.nuiton.util.config.ApplicationConfigProvider;
-import org.nuiton.util.config.ConfigActionDef;
-import org.nuiton.util.config.ConfigOptionDef;
+import org.nuiton.config.ApplicationConfigProvider;
+import org.nuiton.config.ConfigActionDef;
+import org.nuiton.config.ConfigOptionDef;
import java.util.Locale;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -33,8 +33,6 @@
import com.google.common.collect.Multimaps;
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
@@ -98,30 +96,6 @@
}
};
- public static final Predicate<SpeciesBatch> IS_VRAC_SPECIES_BATCH = new Predicate<SpeciesBatch>() {
-
- public boolean apply(SpeciesBatch input) {
- return SampleCategoryEnum.sortedUnsorted == input.getSampleCategoryType() &&
- SortedUnsortedEnum.SORTED.getFieldValue().equals(((CaracteristicQualitativeValue)input.getSampleCategoryValue()).getIdAsInt());
- }
- };
-
- public static final Predicate<BenthosBatch> IS_VRAC_BENTHOS = new Predicate<BenthosBatch>() {
-
- public boolean apply(BenthosBatch input) {
- return SampleCategoryEnum.sortedUnsorted == input.getSampleCategoryType() &&
- SortedUnsortedEnum.SORTED.getFieldValue().equals(((CaracteristicQualitativeValue)input.getSampleCategoryValue()).getIdAsInt());
- }
- };
-
- public static boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
- return IS_VRAC_SPECIES_BATCH.apply(speciesBatch);
- }
-
- public static boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
- return IS_VRAC_BENTHOS.apply(benthosBatch);
- }
-
/** Logger. */
private static final Log log = LogFactory.getLog(TuttiEntities.class);
@@ -199,10 +173,14 @@
return new IdPredicate<B>(id);
}
- public static Predicate<Caracteristic> newCaracteristicCategoryPredicate(String cateogryId) {
- return new CaracteristicCategoryPredicate(cateogryId);
+ public static Predicate<SpeciesBatch> newSpeciesBatchCategoryPredicate(Integer cateogryId, Integer value) {
+ return new SpeciesBatchCategoryPredicate(cateogryId, value);
}
+ public static Predicate<BenthosBatch> newBenthosBatchCategoryPredicate(Integer cateogryId, Integer value) {
+ return new BenthosBatchCategoryPredicate(cateogryId, value);
+ }
+
public static <B extends TuttiEntity> B findById(Iterable<B> beans,
String id) {
B result = Iterables.tryFind(beans, newIdPredicate(id)).orNull();
@@ -316,6 +294,21 @@
return value;
}
+ public static Float getValueOrComputedValue(Float value, Float computedValue) {
+ return value == null ? computedValue : value;
+ }
+
+ public static Boolean getValueOrComputedValueComputed(Float value, Float computedValue) {
+ Boolean result;
+ if (value == null) {
+
+ result = computedValue == null ? null : true;
+ } else {
+ result = false;
+ }
+ return result;
+ }
+
protected static class IdPredicate<B extends TuttiEntity> implements Predicate<B> {
private final String id;
@@ -344,6 +337,58 @@
}
}
+ protected static class CaracteristicQualitativeValuePredicate implements Predicate<CaracteristicQualitativeValue> {
+
+ private final Integer id;
+
+ public CaracteristicQualitativeValuePredicate(Integer id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean apply(CaracteristicQualitativeValue input) {
+ return id.equals(input.getIdAsInt());
+ }
+ }
+
+ protected static class SpeciesBatchCategoryPredicate implements Predicate<SpeciesBatch> {
+
+ private final Integer id;
+
+ private final Integer qualitativeValue;
+
+ public SpeciesBatchCategoryPredicate(Integer id, Integer qualitativeValue) {
+ this.id = id;
+ this.qualitativeValue = qualitativeValue;
+ }
+
+ @Override
+ public boolean apply(SpeciesBatch input) {
+ return id.equals(input.getSampleCategoryId()) &&
+ input.getSampleCategoryValue() instanceof CaracteristicQualitativeValue &&
+ qualitativeValue.equals(((CaracteristicQualitativeValue)input.getSampleCategoryValue()).getIdAsInt());
+ }
+ }
+
+ protected static class BenthosBatchCategoryPredicate implements Predicate<BenthosBatch> {
+
+ private final Integer id;
+
+ private final Integer qualitativeValue;
+
+ public BenthosBatchCategoryPredicate(Integer id, Integer qualitativeValue) {
+ this.id = id;
+ this.qualitativeValue = qualitativeValue;
+ }
+
+ @Override
+ public boolean apply(BenthosBatch input) {
+ return id.equals(input.getSampleCategoryId()) &&
+ input.getSampleCategoryValue() instanceof CaracteristicQualitativeValue &&
+ qualitativeValue.equals(((CaracteristicQualitativeValue)input.getSampleCategoryValue()).getIdAsInt());
+ }
+ }
+
public static <K, V> void fillEntries(Map<K, V> map,
Collection<K> keys,
Function<K, V> function) {
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,25 @@
+package fr.ifremer.tutti.persistence.entities;
+
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+
+/**
+ * Contract to place on enumeration that must be synched to field inside this class.
+ * <p/>
+ * {@link #getFieldValue()} will be filled when {@link TuttiPersistence#init()} method is
+ * invoked and then the {@link #isInit()} will return true.
+ *
+ * @param <O> type of fieldValue
+ * @since 1.0.2
+ */
+public interface TuttiEnumerable<O> {
+
+ String getFieldName();
+
+ O getFieldValue();
+
+ void setFieldValue(O fieldValue);
+
+ boolean isInit();
+
+ void setInit(boolean init);
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEnumerable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/AttachementObjectTypeEnum.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/AttachementObjectTypeEnum.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/AttachementObjectTypeEnum.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,12 +26,13 @@
import com.google.common.base.Preconditions;
import fr.ifremer.adagio.core.dao.referential.ObjectType;
+import fr.ifremer.tutti.persistence.entities.TuttiEnumerable;
import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
/**
* Define all usable {@link ObjectType} in {@link Attachment}.
* <p/>
- * <strong>Note: </strong>This enumeration implements {@link TuttiEnumerationFile.TuttiEnumerable},
+ * <strong>Note: </strong>This enumeration implements {@link TuttiEnumerable},
* so all values must be synched to the enumeration file and before usage we
* must be invoke the {@link TuttiEnumerationFile#init()} method.
*
@@ -39,7 +40,7 @@
* @see Attachment#getObjectType()
* @since 1.0.2
*/
-public enum AttachementObjectTypeEnum implements TuttiEnumerationFile.TuttiEnumerable<String> {
+public enum AttachementObjectTypeEnum implements TuttiEnumerable<String> {
/** For cruise only. */
SCIENTIFIC_CRUISE("OBJECT_TYPE_SCIENTIFIC_CRUISE"),
@@ -80,8 +81,8 @@
}
@Override
- public void setFieldValue(Object fieldValue) {
- this.fieldValue = String.valueOf(fieldValue);
+ public void setFieldValue(String fieldValue) {
+ this.fieldValue = fieldValue;
}
@Override
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -38,12 +38,14 @@
private static final long serialVersionUID = 1L;
+ public static final String PROPERTY_CATEGORY_WEIGHT = "categoryWeight";
+
/**
- * Sample category type.
+ * Sample category definition.
*
- * @since 0.3
+ * @since 2.5
*/
- protected SampleCategoryEnum categoryType;
+ protected SampleCategoryModelEntry categoryDef;
/**
* Sample category value.
@@ -82,23 +84,27 @@
*/
protected boolean onlyOneFrequency;
- public static <C extends Serializable> SampleCategory<C> newSample(SampleCategoryEnum categoryType) {
+ public static <C extends Serializable> SampleCategory<C> newSample(SampleCategoryModelEntry categoryDef) {
SampleCategory<C> result = new SampleCategory<C>();
- result.setCategoryType(categoryType);
+ result.setCategoryDef(categoryDef);
return result;
}
protected SampleCategory() {
}
- public SampleCategoryEnum getCategoryType() {
- return categoryType;
+ public SampleCategoryModelEntry getCategoryDef() {
+ return categoryDef;
}
- public void setCategoryType(SampleCategoryEnum categoryType) {
- this.categoryType = categoryType;
+ public void setCategoryDef(SampleCategoryModelEntry categoryDef) {
+ this.categoryDef = categoryDef;
}
+ public Integer getCategoryId() {
+ return categoryDef.getCategoryId();
+ }
+
public C getCategoryValue() {
return categoryValue;
}
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryEnum.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryEnum.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryEnum.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,98 +0,0 @@
-package fr.ifremer.tutti.persistence.entities.data;
-
-/*
- * #%L
- * Tutti :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
-import fr.ifremer.tutti.LabelAware;
-import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
-
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
-
-public enum SampleCategoryEnum implements TuttiEnumerationFile.TuttiEnumerable<Integer>, LabelAware {
-
- sortedUnsorted("PMFM_ID_SORTED_UNSORTED",
- n_("tutti.sampleCategoryType.sortedUnsorted")),
- size("PMFM_ID_SIZE_CATEGORY", n_("tutti.sampleCategoryType.size")),
- sex("PMFM_ID_SEX", n_("tutti.sampleCategoryType.sex")),
- maturity("PMFM_ID_MATURITY", n_("tutti.sampleCategoryType.maturity")),
- age("PMFM_ID_AGE", n_("tutti.sampleCategoryType.age"));
-
- private final String fieldName;
-
- private final String i18nKey;
-
- private Integer fieldValue;
-
- private boolean init;
-
- SampleCategoryEnum(String fieldName, String i18nKey) {
- this.fieldName = fieldName;
- this.i18nKey = i18nKey;
- }
-
- @Override
- public String getLabel() {
- return _(i18nKey);
- }
-
- @Override
- public String getFieldName() {
- return fieldName;
- }
-
- @Override
- public Integer getFieldValue() {
- Preconditions.checkState(isInit(), "Enumeration " + getClass() + " was not init!");
- return fieldValue;
- }
-
- @Override
- public void setFieldValue(Object fieldValue) {
- this.fieldValue = (Integer) fieldValue;
- }
-
- @Override
- public boolean isInit() {
- return init;
- }
-
- @Override
- public void setInit(boolean init) {
- this.init = init;
- }
-
- public static Map<Integer, SampleCategoryEnum> toIdMapping() {
- Map<Integer, SampleCategoryEnum> result = Maps.newTreeMap();
- for (SampleCategoryEnum anEnum : values()) {
- result.put(anEnum.getFieldValue(), anEnum);
- }
- return result;
- }
-} //SampleCategoryEnum
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,103 @@
+package fr.ifremer.tutti.persistence.entities.data;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Define the complete sample category model.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class SampleCategoryModel implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final List<SampleCategoryModelEntry> category;
+
+ protected final List<Integer> samplingOrder;
+
+ protected final List<SampleCategoryModelEntry> reverseCategory;
+
+ protected final Map<Integer, SampleCategoryModelEntry> categoryMap;
+
+ public SampleCategoryModel(List<SampleCategoryModelEntry> category) {
+ List<Integer> samplingOrder = Lists.newArrayList();
+ this.category = Lists.newArrayList(category);
+ this.categoryMap = Maps.newLinkedHashMap();
+ for (SampleCategoryModelEntry def : category) {
+ categoryMap.put(def.getCategoryId(), def);
+ samplingOrder.add(def.getCategoryId());
+ }
+
+ this.samplingOrder = Collections.unmodifiableList(samplingOrder);
+
+ List<SampleCategoryModelEntry> reverseCategory = Lists.newArrayList(category);
+ Collections.reverse(reverseCategory);
+ this.reverseCategory = Collections.unmodifiableList(reverseCategory);
+ }
+
+ public void load(TuttiPersistence service) {
+
+ for (SampleCategoryModelEntry def : category) {
+ def.load(service);
+ }
+ }
+
+ public List<Integer> getSamplingOrder() {
+ return samplingOrder;
+ }
+
+ public List<SampleCategoryModelEntry> getCategory() {
+ return category;
+ }
+
+ public List<SampleCategoryModelEntry> getReverseCategory() {
+ return reverseCategory;
+ }
+
+ public Map<Integer, SampleCategoryModelEntry> getCategoryMap() {
+ return categoryMap;
+ }
+
+ public SampleCategoryModelEntry getCategoryById(Integer categoryId) {
+ return categoryMap.get(categoryId);
+ }
+
+ public SampleCategoryModelEntry getCategoryByIndex(int index) {
+ return category.get(index);
+ }
+
+ @Override
+ public String toString() {
+ List<String> entries = Lists.newArrayList();
+ for (SampleCategoryModelEntry entry : category) {
+ entries.add(entry.toString());
+ }
+ String result = Joiner.on('|').join(entries);
+ return result;
+ }
+
+ public Integer getLastCategoryId() {
+ return samplingOrder.isEmpty() ? null : samplingOrder.get(samplingOrder.size() - 1);
+ }
+
+ public int getNbSampling() {
+ return samplingOrder.size();
+ }
+
+ public Integer getFirstCategoryId() {
+ return samplingOrder.isEmpty() ? null : samplingOrder.get(0);
+ }
+
+ public boolean containsCategoryId(Integer id) {
+ return samplingOrder.contains(id);
+ }
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,78 @@
+package fr.ifremer.tutti.persistence.entities.data;
+
+import com.google.common.base.Preconditions;
+import com.google.common.primitives.Ints;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Serializable;
+
+/**
+ * To define a sample category in application.
+ * <p/>
+ * It just wrap the underligned category, his order and his label.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class SampleCategoryModelEntry implements Comparable<SampleCategoryModelEntry>, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String label;
+
+ protected Integer categoryId;
+
+ protected int order;
+
+ protected transient Caracteristic caracteristic;
+
+ public void load(TuttiPersistence service) {
+ Preconditions.checkNotNull(categoryId, "Can't have a null category id");
+ caracteristic = service.getCaracteristic(categoryId);
+ Preconditions.checkNotNull(caracteristic, "Could not find category if id: " + categoryId);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public Caracteristic getCaracteristic() {
+ return caracteristic;
+ }
+
+ public void setCaracteristic(Caracteristic caracteristic) {
+ this.caracteristic = caracteristic;
+ }
+
+ public Integer getCategoryId() {
+ return categoryId;
+ }
+
+ public void setCategoryId(Integer categoryId) {
+ this.categoryId = categoryId;
+ }
+
+ public int getOrder() {
+ return order;
+ }
+
+ public void setOrder(int order) {
+ this.order = order;
+ }
+
+ @Override
+ public int compareTo(SampleCategoryModelEntry o) {
+ return Ints.compare(order, o.getOrder());
+ }
+
+ @Override
+ public String toString() {
+ return categoryId + "," + (StringUtils.isBlank(label) ? "" : label);
+ }
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryModelEntry.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SexEnum.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SexEnum.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SexEnum.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,95 +0,0 @@
-package fr.ifremer.tutti.persistence.entities.data;
-
-/*
- * #%L
- * Tutti :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
-
-/**
- * Represents the sorted - unsorted pmfm.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public enum SexEnum implements TuttiEnumerationFile.TuttiEnumerable<Integer> {
-
- MALE("QUALITATIVE_SEX_MALE_ID"),
- FEMALE("QUALITATIVE_SEX_FEMALE_ID");
-
- private final String fieldName;
-
- private Integer fieldValue;
-
- private boolean init;
-
- SexEnum(String fieldName) {
- this.fieldName = fieldName;
- }
-
- @Override
- public String getFieldName() {
- return fieldName;
- }
-
- @Override
- public Integer getFieldValue() {
- Preconditions.checkState(isInit(), "Enumeration " + getClass() + " was not init!");
- return fieldValue;
- }
-
- @Override
- public void setFieldValue(Object fieldValue) {
- this.fieldValue = (Integer) fieldValue;
- }
-
- @Override
- public boolean isInit() {
- return init;
- }
-
- @Override
- public void setInit(boolean init) {
- this.init = init;
- }
-
- public boolean matchValue(CaracteristicQualitativeValue value) {
- return fieldValue.equals(Integer.valueOf(value.getId()));
- }
-
- public CaracteristicQualitativeValue getValue(Caracteristic c) {
- Preconditions.checkNotNull(c);
- Preconditions.checkState(!c.isQualitativeValueEmpty());
- CaracteristicQualitativeValue result = null;
- for (CaracteristicQualitativeValue value : c.getQualitativeValue()) {
- if (matchValue(value)) {
- result = value;
- break;
- }
- }
- return result;
- }
-}
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SizeEnum.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SizeEnum.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SizeEnum.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,96 +0,0 @@
-package fr.ifremer.tutti.persistence.entities.data;
-
-/*
- * #%L
- * Tutti :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
-
-/**
- * Represents the sorted - unsorted pmfm.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public enum SizeEnum implements TuttiEnumerationFile.TuttiEnumerable<Integer> {
-
- SMALL("QUALITATIVE_SIZE_SMALL_ID"),
- MEDIUM("QUALITATIVE_SIZE_MEDIUM_ID"),
- BIG("QUALITATIVE_SIZE_BIG_ID");
-
- private final String fieldName;
-
- private Integer fieldValue;
-
- private boolean init;
-
- SizeEnum(String fieldName) {
- this.fieldName = fieldName;
- }
-
- @Override
- public String getFieldName() {
- return fieldName;
- }
-
- @Override
- public Integer getFieldValue() {
- Preconditions.checkState(isInit(), "Enumeration " + getClass() + " was not init!");
- return fieldValue;
- }
-
- @Override
- public void setFieldValue(Object fieldValue) {
- this.fieldValue = (Integer) fieldValue;
- }
-
- @Override
- public boolean isInit() {
- return init;
- }
-
- @Override
- public void setInit(boolean init) {
- this.init = init;
- }
-
- public boolean matchValue(CaracteristicQualitativeValue value) {
- return fieldValue.equals(Integer.valueOf(value.getId()));
- }
-
- public CaracteristicQualitativeValue getValue(Caracteristic c) {
- Preconditions.checkNotNull(c);
- Preconditions.checkState(!c.isQualitativeValueEmpty());
- CaracteristicQualitativeValue result = null;
- for (CaracteristicQualitativeValue value : c.getQualitativeValue()) {
- if (matchValue(value)) {
- result = value;
- break;
- }
- }
- return result;
- }
-}
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,95 +0,0 @@
-package fr.ifremer.tutti.persistence.entities.data;
-
-/*
- * #%L
- * Tutti :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
-
-/**
- * Represents the sorted - unsorted pmfm.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public enum SortedUnsortedEnum implements TuttiEnumerationFile.TuttiEnumerable<Integer> {
-
- SORTED("QUALITATIVE_VRAC_ID"),
- UNSORTED("QUALITATIVE_HORS_VRAC_ID");
-
- private final String fieldName;
-
- private Integer fieldValue;
-
- private boolean init;
-
- SortedUnsortedEnum(String fieldName) {
- this.fieldName = fieldName;
- }
-
- @Override
- public String getFieldName() {
- return fieldName;
- }
-
- @Override
- public Integer getFieldValue() {
- Preconditions.checkState(isInit(), "Enumeration " + getClass() + " was not init!");
- return fieldValue;
- }
-
- @Override
- public void setFieldValue(Object fieldValue) {
- this.fieldValue = (Integer) fieldValue;
- }
-
- @Override
- public boolean isInit() {
- return init;
- }
-
- @Override
- public void setInit(boolean init) {
- this.init = init;
- }
-
- public boolean matchValue(CaracteristicQualitativeValue value) {
- return fieldValue.equals(Integer.valueOf(value.getId()));
- }
-
- public CaracteristicQualitativeValue getValue(Caracteristic c) {
- Preconditions.checkNotNull(c);
- Preconditions.checkState(!c.isQualitativeValueEmpty());
- CaracteristicQualitativeValue result = null;
- for (CaracteristicQualitativeValue value : c.getQualitativeValue()) {
- if (matchValue(value)) {
- result = value;
- break;
- }
- }
- return result;
- }
-}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -34,12 +34,18 @@
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.protocol.v1.SpeciesProtocol1;
+import fr.ifremer.tutti.persistence.entities.protocol.v1.SpeciesProtocolBean1;
+import fr.ifremer.tutti.persistence.entities.protocol.v1.TuttiProtocol1;
+import fr.ifremer.tutti.persistence.entities.protocol.v1.TuttiProtocolBean1;
import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
import java.io.BufferedWriter;
import java.io.File;
@@ -74,23 +80,119 @@
}
}
- public static TuttiProtocol fromFile(File file) {
+ public static TuttiProtocol fromFile(TuttiEnumerationFile enumeration, File file) {
-
Reader fileReader = null;
try {
fileReader = Files.newReader(file, Charsets.UTF_8);
YamlReader reader = new YamlReader(fileReader, createConfig());
TuttiProtocol result = reader.read(TuttiBeanFactory.typeOfTuttiProtocol());
fileReader.close();
+
+ // transform String to Integer...
+
+ if (!result.isBenthosEmpty()) {
+ for (SpeciesProtocol speciesProtocol : result.getBenthos()) {
+ List mandatorySampleCategoryId = speciesProtocol.getMandatorySampleCategoryId();
+ List<Integer> mandatorySampleCategoryIdInteger = Lists.newArrayList();
+ for (Object o : mandatorySampleCategoryId) {
+ mandatorySampleCategoryIdInteger.add(Integer.valueOf(o.toString()));
+ }
+ speciesProtocol.setMandatorySampleCategoryId(mandatorySampleCategoryIdInteger);
+
+ }
+ }
+ if (!result.isSpeciesEmpty()) {
+ for (SpeciesProtocol speciesProtocol : result.getSpecies()) {
+ List mandatorySampleCategoryId = speciesProtocol.getMandatorySampleCategoryId();
+ List<Integer> mandatorySampleCategoryIdInteger = Lists.newArrayList();
+ for (Object o : mandatorySampleCategoryId) {
+ mandatorySampleCategoryIdInteger.add(Integer.valueOf(o.toString()));
+ }
+ speciesProtocol.setMandatorySampleCategoryId(mandatorySampleCategoryIdInteger);
+
+ }
+ }
return result;
} catch (Exception e) {
+ // try to load a v1
+ TuttiProtocol1 tuttiProtocol1 = fromFileV1(file);
+
+ TuttiProtocol result = fromTuttiProtocol1(enumeration, tuttiProtocol1);
+ return result;
+
+ } finally {
+ IOUtils.closeQuietly(fileReader);
+ }
+ }
+
+ public static TuttiProtocol1 fromFileV1(File file) {
+
+ Reader fileReader = null;
+ try {
+ fileReader = Files.newReader(file, Charsets.UTF_8);
+ YamlReader reader = new YamlReader(fileReader, createConfigV1());
+ TuttiProtocol1 result = reader.read(TuttiProtocolBean1.class);
+ fileReader.close();
+ return result;
+ } catch (Exception e) {
throw new TuttiTechnicalException(_("tutti.persistence.protocol.fromFile.error", file), e);
} finally {
IOUtils.closeQuietly(fileReader);
}
}
+ protected static TuttiProtocol fromTuttiProtocol1(TuttiEnumerationFile enumeration, TuttiProtocol1 tuttiProtocol1) {
+ TuttiProtocol result = TuttiBeanFactory.newTuttiProtocol();
+ Binder<TuttiProtocol1, TuttiProtocol> binder = BinderFactory.newBinder(TuttiProtocol1.class, TuttiProtocol.class);
+ binder.copy(tuttiProtocol1, result);
+ if (!tuttiProtocol1.isSpeciesEmpty()) {
+ result.setSpecies(Lists.<SpeciesProtocol>newArrayList());
+ Binder<SpeciesProtocol1, SpeciesProtocol> binderSpecies = BinderFactory.newBinder(SpeciesProtocol1.class, SpeciesProtocol.class);
+ for (SpeciesProtocol1 speciesProtocol1 : tuttiProtocol1.getSpecies()) {
+ SpeciesProtocol row = TuttiBeanFactory.newSpeciesProtocol();
+ row.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
+ binderSpecies.copy(speciesProtocol1, row);
+ if (speciesProtocol1.isAgeEnabled()) {
+ row.addMandatorySampleCategoryId(enumeration.PMFM_ID_AGE);
+ }
+ if (speciesProtocol1.isSizeEnabled()) {
+ row.addMandatorySampleCategoryId(enumeration.PMFM_ID_SIZE_CATEGORY);
+ }
+ if (speciesProtocol1.isMaturityEnabled()) {
+ row.addMandatorySampleCategoryId(enumeration.PMFM_ID_MATURITY);
+ }
+ if (speciesProtocol1.isSexEnabled()) {
+ row.addMandatorySampleCategoryId(enumeration.PMFM_ID_SEX);
+ }
+ result.addSpecies(row);
+ }
+ }
+ if (!tuttiProtocol1.isBenthosEmpty()) {
+ result.setBenthos(Lists.<SpeciesProtocol>newArrayList());
+ Binder<SpeciesProtocol1, SpeciesProtocol> binderSpecies = BinderFactory.newBinder(SpeciesProtocol1.class, SpeciesProtocol.class);
+ for (SpeciesProtocol1 speciesProtocol1 : tuttiProtocol1.getBenthos()) {
+ SpeciesProtocol row = TuttiBeanFactory.newSpeciesProtocol();
+ row.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
+ binderSpecies.copy(speciesProtocol1, row);
+ if (speciesProtocol1.isAgeEnabled()) {
+ row.addMandatorySampleCategoryId(enumeration.PMFM_ID_AGE);
+ }
+ if (speciesProtocol1.isSizeEnabled()) {
+ row.addMandatorySampleCategoryId(enumeration.PMFM_ID_SIZE_CATEGORY);
+ }
+ if (speciesProtocol1.isMaturityEnabled()) {
+ row.addMandatorySampleCategoryId(enumeration.PMFM_ID_MATURITY);
+ }
+ if (speciesProtocol1.isSexEnabled()) {
+ row.addMandatorySampleCategoryId(enumeration.PMFM_ID_SEX);
+ }
+ result.addBenthos(row);
+ }
+ }
+ return result;
+ }
+
protected static YamlConfig createConfig() {
YamlConfig result = new YamlConfig();
result.setClassTag(SpeciesProtocol.class.getSimpleName(),
@@ -100,6 +202,15 @@
return result;
}
+ protected static YamlConfig createConfigV1() {
+ YamlConfig result = new YamlConfig();
+ result.setClassTag(SpeciesProtocol.class.getSimpleName(),
+ SpeciesProtocolBean1.class);
+ result.writeConfig.setAlwaysWriteClassname(false);
+ result.writeConfig.setWriteRootTags(false);
+ return result;
+ }
+
/**
* Is the species batch respecting the protocol recommendations?
*
@@ -119,11 +230,11 @@
SpeciesProtocol speciesProtocol = getSpeciesProtocol(species, speciesProtocols);
if (speciesProtocol != null) {
- List<SampleCategoryEnum> mandatoryCategories = getMandatoryCategories(speciesProtocol);
+ List<Integer> mandatoryCategories = speciesProtocol.getMandatorySampleCategoryId();
SpeciesBatch browsingBatch = batch;
while (browsingBatch.getParentBatch() != null) {
- mandatoryCategories.remove(browsingBatch.getSampleCategoryType());
+ mandatoryCategories.remove(browsingBatch.getSampleCategoryId());
browsingBatch = browsingBatch.getParentBatch();
}
result = mandatoryCategories.isEmpty() &&
@@ -155,11 +266,12 @@
if (speciesProtocol != null) {
// get the categories which should be set
- List<SampleCategoryEnum> mandatoryCategories = getMandatoryCategories(speciesProtocol);
+ List<Integer> mandatoryCategories =
+ speciesProtocol.getMandatorySampleCategoryId();
BenthosBatch browsingBatch = batch;
while (browsingBatch.getParentBatch() != null) {
- mandatoryCategories.remove(browsingBatch.getSampleCategoryType());
+ mandatoryCategories.remove(browsingBatch.getSampleCategoryId());
browsingBatch = browsingBatch.getParentBatch();
}
result = mandatoryCategories.isEmpty() &&
@@ -178,7 +290,8 @@
* @param speciesProtocols
* @return
*/
- protected static SpeciesProtocol getSpeciesProtocol(Species species, List<SpeciesProtocol> speciesProtocols) {
+ protected static SpeciesProtocol getSpeciesProtocol(Species species,
+ List<SpeciesProtocol> speciesProtocols) {
for (SpeciesProtocol speciesProtocol : speciesProtocols) {
if (species.getReferenceTaxonId().equals(
speciesProtocol.getSpeciesReferenceTaxonId())) {
@@ -187,27 +300,4 @@
}
return null;
}
-
- /**
- * Gets the mandatory categories accroding to the protocol
- *
- * @param speciesProtocol
- * @return
- */
- protected static List<SampleCategoryEnum> getMandatoryCategories(SpeciesProtocol speciesProtocol) {
- List<SampleCategoryEnum> mandatoryCategories = Lists.newArrayList();
- if (speciesProtocol.isSizeEnabled()) {
- mandatoryCategories.add(SampleCategoryEnum.size);
- }
- if (speciesProtocol.isSexEnabled()) {
- mandatoryCategories.add(SampleCategoryEnum.sex);
- }
- if (speciesProtocol.isMaturityEnabled()) {
- mandatoryCategories.add(SampleCategoryEnum.maturity);
- }
- if (speciesProtocol.isAgeEnabled()) {
- mandatoryCategories.add(SampleCategoryEnum.age);
- }
- return mandatoryCategories;
- }
}
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,90 @@
+package fr.ifremer.tutti.persistence.entities.protocol.v1;
+
+import fr.ifremer.tutti.persistence.entities.TuttiEntity;
+
+import javax.annotation.Generated;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * To migrate old species protocol to last version.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+@Generated(value = "org.nuiton.eugene.java.SimpleJavaBeanTransformer", date = "Wed Jul 24 16:30:03 CEST 2013")
+public interface SpeciesProtocol1 extends TuttiEntity {
+
+ String PROPERTY_SPECIES_REFERENCE_TAXON_ID = "speciesReferenceTaxonId";
+
+ String PROPERTY_SPECIES_SURVEY_CODE = "speciesSurveyCode";
+
+ String PROPERTY_SIZE_ENABLED = "sizeEnabled";
+
+ String PROPERTY_SEX_ENABLED = "sexEnabled";
+
+ String PROPERTY_MATURITY_ENABLED = "maturityEnabled";
+
+ String PROPERTY_AGE_ENABLED = "ageEnabled";
+
+ String PROPERTY_LENGTH_STEP_PMFM_ID = "lengthStepPmfmId";
+
+ String PROPERTY_WEIGHT_ENABLED = "weightEnabled";
+
+ String PROPERTY_COUNT_IF_NO_FREQUENCY_ENABLED = "countIfNoFrequencyEnabled";
+
+ String PROPERTY_CALCIFY_SAMPLE_ENABLED = "calcifySampleEnabled";
+
+ String PROPERTY_LENGTH_STEP = "lengthStep";
+
+ String PROPERTY_MADE_FROM_AREFERENT_TAXON = "madeFromAReferentTaxon";
+
+ Integer getSpeciesReferenceTaxonId();
+
+ void setSpeciesReferenceTaxonId(Integer speciesReferenceTaxonId);
+
+ String getSpeciesSurveyCode();
+
+ void setSpeciesSurveyCode(String speciesSurveyCode);
+
+ boolean isSizeEnabled();
+
+ void setSizeEnabled(boolean sizeEnabled);
+
+ boolean isSexEnabled();
+
+ void setSexEnabled(boolean sexEnabled);
+
+ boolean isMaturityEnabled();
+
+ void setMaturityEnabled(boolean maturityEnabled);
+
+ boolean isAgeEnabled();
+
+ void setAgeEnabled(boolean ageEnabled);
+
+ String getLengthStepPmfmId();
+
+ void setLengthStepPmfmId(String lengthStepPmfmId);
+
+ boolean isWeightEnabled();
+
+ void setWeightEnabled(boolean weightEnabled);
+
+ boolean isCountIfNoFrequencyEnabled();
+
+ void setCountIfNoFrequencyEnabled(boolean countIfNoFrequencyEnabled);
+
+ boolean isCalcifySampleEnabled();
+
+ void setCalcifySampleEnabled(boolean calcifySampleEnabled);
+
+ Float getLengthStep();
+
+ void setLengthStep(Float lengthStep);
+
+ boolean isMadeFromAReferentTaxon();
+
+ void setMadeFromAReferentTaxon(boolean madeFromAReferentTaxon);
+
+} //SpeciesProtocol
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocol1.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,162 @@
+package fr.ifremer.tutti.persistence.entities.protocol.v1;
+
+import fr.ifremer.tutti.persistence.entities.TuttiEntityBean;
+
+import javax.annotation.Generated;
+
+/**
+ * To migrate old species protocol to last version.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+@Generated(value = "org.nuiton.eugene.java.SimpleJavaBeanTransformer", date = "Wed Jul 24 16:08:49 CEST 2013")
+public class SpeciesProtocolBean1 extends TuttiEntityBean implements SpeciesProtocol1 {
+
+ private static final long serialVersionUID = 3486411950096802662L;
+
+ protected Integer speciesReferenceTaxonId;
+
+ protected String speciesSurveyCode;
+
+ protected boolean sizeEnabled;
+
+ protected boolean sexEnabled;
+
+ protected boolean maturityEnabled;
+
+ protected boolean ageEnabled;
+
+ protected String lengthStepPmfmId;
+
+ protected boolean weightEnabled;
+
+ protected boolean countIfNoFrequencyEnabled;
+
+ protected boolean calcifySampleEnabled;
+
+ protected Float lengthStep;
+
+ protected boolean madeFromAReferentTaxon;
+
+ @Override
+ public Integer getSpeciesReferenceTaxonId() {
+ return speciesReferenceTaxonId;
+ }
+
+ @Override
+ public void setSpeciesReferenceTaxonId(Integer speciesReferenceTaxonId) {
+ this.speciesReferenceTaxonId = speciesReferenceTaxonId;
+ }
+
+ @Override
+ public String getSpeciesSurveyCode() {
+ return speciesSurveyCode;
+ }
+
+ @Override
+ public void setSpeciesSurveyCode(String speciesSurveyCode) {
+ this.speciesSurveyCode = speciesSurveyCode;
+ }
+
+ @Override
+ public boolean isSizeEnabled() {
+ return sizeEnabled;
+ }
+
+ @Override
+ public void setSizeEnabled(boolean sizeEnabled) {
+ this.sizeEnabled = sizeEnabled;
+ }
+
+ @Override
+ public boolean isSexEnabled() {
+ return sexEnabled;
+ }
+
+ @Override
+ public void setSexEnabled(boolean sexEnabled) {
+ this.sexEnabled = sexEnabled;
+ }
+
+ @Override
+ public boolean isMaturityEnabled() {
+ return maturityEnabled;
+ }
+
+ @Override
+ public void setMaturityEnabled(boolean maturityEnabled) {
+ this.maturityEnabled = maturityEnabled;
+ }
+
+ @Override
+ public boolean isAgeEnabled() {
+ return ageEnabled;
+ }
+
+ @Override
+ public void setAgeEnabled(boolean ageEnabled) {
+ this.ageEnabled = ageEnabled;
+ }
+
+ @Override
+ public String getLengthStepPmfmId() {
+ return lengthStepPmfmId;
+ }
+
+ @Override
+ public void setLengthStepPmfmId(String lengthStepPmfmId) {
+ this.lengthStepPmfmId = lengthStepPmfmId;
+ }
+
+ @Override
+ public boolean isWeightEnabled() {
+ return weightEnabled;
+ }
+
+ @Override
+ public void setWeightEnabled(boolean weightEnabled) {
+ this.weightEnabled = weightEnabled;
+ }
+
+ @Override
+ public boolean isCountIfNoFrequencyEnabled() {
+ return countIfNoFrequencyEnabled;
+ }
+
+ @Override
+ public void setCountIfNoFrequencyEnabled(boolean countIfNoFrequencyEnabled) {
+ this.countIfNoFrequencyEnabled = countIfNoFrequencyEnabled;
+ }
+
+ @Override
+ public boolean isCalcifySampleEnabled() {
+ return calcifySampleEnabled;
+ }
+
+ @Override
+ public void setCalcifySampleEnabled(boolean calcifySampleEnabled) {
+ this.calcifySampleEnabled = calcifySampleEnabled;
+ }
+
+ @Override
+ public Float getLengthStep() {
+ return lengthStep;
+ }
+
+ @Override
+ public void setLengthStep(Float lengthStep) {
+ this.lengthStep = lengthStep;
+ }
+
+ @Override
+ public boolean isMadeFromAReferentTaxon() {
+ return madeFromAReferentTaxon;
+ }
+
+ @Override
+ public void setMadeFromAReferentTaxon(boolean madeFromAReferentTaxon) {
+ this.madeFromAReferentTaxon = madeFromAReferentTaxon;
+ }
+
+} //SpeciesProtocolBean
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/SpeciesProtocolBean1.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,151 @@
+package fr.ifremer.tutti.persistence.entities.protocol.v1;
+
+import fr.ifremer.tutti.persistence.entities.CommentAware;
+import fr.ifremer.tutti.persistence.entities.TuttiEntity;
+
+import javax.annotation.Generated;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * To migrate old protocol to last version.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+@Generated(value = "org.nuiton.eugene.java.SimpleJavaBeanTransformer", date = "Wed Jul 24 16:08:49 CEST 2013")
+public interface TuttiProtocol1 extends CommentAware, TuttiEntity {
+
+ String PROPERTY_NAME = "name";
+
+ String PROPERTY_COMMENT = "comment";
+
+ String PROPERTY_GEAR_USE_FEATURE_PMFM_ID = "gearUseFeaturePmfmId";
+
+ String PROPERTY_VESSEL_USE_FEATURE_PMFM_ID = "vesselUseFeaturePmfmId";
+
+ String PROPERTY_LENGTH_CLASSES_PMFM_ID = "lengthClassesPmfmId";
+
+ String PROPERTY_SPECIES = "species";
+
+ String PROPERTY_BENTHOS = "benthos";
+
+ String getName();
+
+ void setName(String name);
+
+ String getComment();
+
+ void setComment(String comment);
+
+ String getGearUseFeaturePmfmId(int index);
+
+ boolean isGearUseFeaturePmfmIdEmpty();
+
+ int sizeGearUseFeaturePmfmId();
+
+ void addGearUseFeaturePmfmId(String gearUseFeaturePmfmId);
+
+ void addAllGearUseFeaturePmfmId(Collection<String> gearUseFeaturePmfmId);
+
+ boolean removeGearUseFeaturePmfmId(String gearUseFeaturePmfmId);
+
+ boolean removeAllGearUseFeaturePmfmId(Collection<String> gearUseFeaturePmfmId);
+
+ boolean containsGearUseFeaturePmfmId(String gearUseFeaturePmfmId);
+
+ boolean containsAllGearUseFeaturePmfmId(Collection<String> gearUseFeaturePmfmId);
+
+ List<String> getGearUseFeaturePmfmId();
+
+ void setGearUseFeaturePmfmId(List<String> gearUseFeaturePmfmId);
+
+ String getVesselUseFeaturePmfmId(int index);
+
+ boolean isVesselUseFeaturePmfmIdEmpty();
+
+ int sizeVesselUseFeaturePmfmId();
+
+ void addVesselUseFeaturePmfmId(String vesselUseFeaturePmfmId);
+
+ void addAllVesselUseFeaturePmfmId(Collection<String> vesselUseFeaturePmfmId);
+
+ boolean removeVesselUseFeaturePmfmId(String vesselUseFeaturePmfmId);
+
+ boolean removeAllVesselUseFeaturePmfmId(Collection<String> vesselUseFeaturePmfmId);
+
+ boolean containsVesselUseFeaturePmfmId(String vesselUseFeaturePmfmId);
+
+ boolean containsAllVesselUseFeaturePmfmId(Collection<String> vesselUseFeaturePmfmId);
+
+ List<String> getVesselUseFeaturePmfmId();
+
+ void setVesselUseFeaturePmfmId(List<String> vesselUseFeaturePmfmId);
+
+ String getLengthClassesPmfmId(int index);
+
+ boolean isLengthClassesPmfmIdEmpty();
+
+ int sizeLengthClassesPmfmId();
+
+ void addLengthClassesPmfmId(String lengthClassesPmfmId);
+
+ void addAllLengthClassesPmfmId(Collection<String> lengthClassesPmfmId);
+
+ boolean removeLengthClassesPmfmId(String lengthClassesPmfmId);
+
+ boolean removeAllLengthClassesPmfmId(Collection<String> lengthClassesPmfmId);
+
+ boolean containsLengthClassesPmfmId(String lengthClassesPmfmId);
+
+ boolean containsAllLengthClassesPmfmId(Collection<String> lengthClassesPmfmId);
+
+ List<String> getLengthClassesPmfmId();
+
+ void setLengthClassesPmfmId(List<String> lengthClassesPmfmId);
+
+ SpeciesProtocol1 getSpecies(int index);
+
+ boolean isSpeciesEmpty();
+
+ int sizeSpecies();
+
+ void addSpecies(SpeciesProtocol1 species);
+
+ void addAllSpecies(Collection<SpeciesProtocol1> species);
+
+ boolean removeSpecies(SpeciesProtocol1 species);
+
+ boolean removeAllSpecies(Collection<SpeciesProtocol1> species);
+
+ boolean containsSpecies(SpeciesProtocol1 species);
+
+ boolean containsAllSpecies(Collection<SpeciesProtocol1> species);
+
+ List<SpeciesProtocol1> getSpecies();
+
+ void setSpecies(List<SpeciesProtocol1> species);
+
+ SpeciesProtocol1 getBenthos(int index);
+
+ boolean isBenthosEmpty();
+
+ int sizeBenthos();
+
+ void addBenthos(SpeciesProtocol1 benthos);
+
+ void addAllBenthos(Collection<SpeciesProtocol1> benthos);
+
+ boolean removeBenthos(SpeciesProtocol1 benthos);
+
+ boolean removeAllBenthos(Collection<SpeciesProtocol1> benthos);
+
+ boolean containsBenthos(SpeciesProtocol1 benthos);
+
+ boolean containsAllBenthos(Collection<SpeciesProtocol1> benthos);
+
+ List<SpeciesProtocol1> getBenthos();
+
+ void setBenthos(List<SpeciesProtocol1> benthos);
+
+} //TuttiProtocol
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocol1.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,354 @@
+package fr.ifremer.tutti.persistence.entities.protocol.v1;
+
+import fr.ifremer.tutti.persistence.entities.TuttiEntityBean;
+
+import javax.annotation.Generated;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * To migrate old protocol to last version.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+@Generated(value = "org.nuiton.eugene.java.SimpleJavaBeanTransformer", date = "Wed Jul 24 16:08:49 CEST 2013")
+public class TuttiProtocolBean1 extends TuttiEntityBean implements TuttiProtocol1 {
+
+ private static final long serialVersionUID = 3847260679792845110L;
+
+ protected String name;
+
+ protected String comment;
+
+ protected List<String> gearUseFeaturePmfmId;
+
+ protected List<String> vesselUseFeaturePmfmId;
+
+ protected List<String> lengthClassesPmfmId;
+
+ protected List<SpeciesProtocol1> species;
+
+ protected List<SpeciesProtocol1> benthos;
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getComment() {
+ return comment;
+ }
+
+ @Override
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ @Override
+ public String getGearUseFeaturePmfmId(int index) {
+ String o = getChild(gearUseFeaturePmfmId, index);
+ return o;
+ }
+
+ @Override
+ public boolean isGearUseFeaturePmfmIdEmpty() {
+ return gearUseFeaturePmfmId == null || gearUseFeaturePmfmId.isEmpty();
+ }
+
+ @Override
+ public int sizeGearUseFeaturePmfmId() {
+ return gearUseFeaturePmfmId == null ? 0 : gearUseFeaturePmfmId.size();
+ }
+
+ @Override
+ public void addGearUseFeaturePmfmId(String gearUseFeaturePmfmId) {
+ getGearUseFeaturePmfmId().add(gearUseFeaturePmfmId);
+ }
+
+ @Override
+ public void addAllGearUseFeaturePmfmId(Collection<String> gearUseFeaturePmfmId) {
+ getGearUseFeaturePmfmId().addAll(gearUseFeaturePmfmId);
+ }
+
+ @Override
+ public boolean removeGearUseFeaturePmfmId(String gearUseFeaturePmfmId) {
+ boolean removed = getGearUseFeaturePmfmId().remove(gearUseFeaturePmfmId);
+ return removed;
+ }
+
+ @Override
+ public boolean removeAllGearUseFeaturePmfmId(Collection<String> gearUseFeaturePmfmId) {
+ boolean removed = getGearUseFeaturePmfmId().removeAll(gearUseFeaturePmfmId);
+ return removed;
+ }
+
+ @Override
+ public boolean containsGearUseFeaturePmfmId(String gearUseFeaturePmfmId) {
+ boolean contains = getGearUseFeaturePmfmId().contains(gearUseFeaturePmfmId);
+ return contains;
+ }
+
+ @Override
+ public boolean containsAllGearUseFeaturePmfmId(Collection<String> gearUseFeaturePmfmId) {
+ boolean contains = getGearUseFeaturePmfmId().containsAll(gearUseFeaturePmfmId);
+ return contains;
+ }
+
+ @Override
+ public List<String> getGearUseFeaturePmfmId() {
+ return gearUseFeaturePmfmId;
+ }
+
+ @Override
+ public void setGearUseFeaturePmfmId(List<String> gearUseFeaturePmfmId) {
+ this.gearUseFeaturePmfmId = gearUseFeaturePmfmId;
+ }
+
+ @Override
+ public String getVesselUseFeaturePmfmId(int index) {
+ String o = getChild(vesselUseFeaturePmfmId, index);
+ return o;
+ }
+
+ @Override
+ public boolean isVesselUseFeaturePmfmIdEmpty() {
+ return vesselUseFeaturePmfmId == null || vesselUseFeaturePmfmId.isEmpty();
+ }
+
+ @Override
+ public int sizeVesselUseFeaturePmfmId() {
+ return vesselUseFeaturePmfmId == null ? 0 : vesselUseFeaturePmfmId.size();
+ }
+
+ @Override
+ public void addVesselUseFeaturePmfmId(String vesselUseFeaturePmfmId) {
+ getVesselUseFeaturePmfmId().add(vesselUseFeaturePmfmId);
+ }
+
+ @Override
+ public void addAllVesselUseFeaturePmfmId(Collection<String> vesselUseFeaturePmfmId) {
+ getVesselUseFeaturePmfmId().addAll(vesselUseFeaturePmfmId);
+ }
+
+ @Override
+ public boolean removeVesselUseFeaturePmfmId(String vesselUseFeaturePmfmId) {
+ boolean removed = getVesselUseFeaturePmfmId().remove(vesselUseFeaturePmfmId);
+ return removed;
+ }
+
+ @Override
+ public boolean removeAllVesselUseFeaturePmfmId(Collection<String> vesselUseFeaturePmfmId) {
+ boolean removed = getVesselUseFeaturePmfmId().removeAll(vesselUseFeaturePmfmId);
+ return removed;
+ }
+
+ @Override
+ public boolean containsVesselUseFeaturePmfmId(String vesselUseFeaturePmfmId) {
+ boolean contains = getVesselUseFeaturePmfmId().contains(vesselUseFeaturePmfmId);
+ return contains;
+ }
+
+ @Override
+ public boolean containsAllVesselUseFeaturePmfmId(Collection<String> vesselUseFeaturePmfmId) {
+ boolean contains = getVesselUseFeaturePmfmId().containsAll(vesselUseFeaturePmfmId);
+ return contains;
+ }
+
+ @Override
+ public List<String> getVesselUseFeaturePmfmId() {
+ return vesselUseFeaturePmfmId;
+ }
+
+ @Override
+ public void setVesselUseFeaturePmfmId(List<String> vesselUseFeaturePmfmId) {
+ this.vesselUseFeaturePmfmId = vesselUseFeaturePmfmId;
+ }
+
+ @Override
+ public String getLengthClassesPmfmId(int index) {
+ String o = getChild(lengthClassesPmfmId, index);
+ return o;
+ }
+
+ @Override
+ public boolean isLengthClassesPmfmIdEmpty() {
+ return lengthClassesPmfmId == null || lengthClassesPmfmId.isEmpty();
+ }
+
+ @Override
+ public int sizeLengthClassesPmfmId() {
+ return lengthClassesPmfmId == null ? 0 : lengthClassesPmfmId.size();
+ }
+
+ @Override
+ public void addLengthClassesPmfmId(String lengthClassesPmfmId) {
+ getLengthClassesPmfmId().add(lengthClassesPmfmId);
+ }
+
+ @Override
+ public void addAllLengthClassesPmfmId(Collection<String> lengthClassesPmfmId) {
+ getLengthClassesPmfmId().addAll(lengthClassesPmfmId);
+ }
+
+ @Override
+ public boolean removeLengthClassesPmfmId(String lengthClassesPmfmId) {
+ boolean removed = getLengthClassesPmfmId().remove(lengthClassesPmfmId);
+ return removed;
+ }
+
+ @Override
+ public boolean removeAllLengthClassesPmfmId(Collection<String> lengthClassesPmfmId) {
+ boolean removed = getLengthClassesPmfmId().removeAll(lengthClassesPmfmId);
+ return removed;
+ }
+
+ @Override
+ public boolean containsLengthClassesPmfmId(String lengthClassesPmfmId) {
+ boolean contains = getLengthClassesPmfmId().contains(lengthClassesPmfmId);
+ return contains;
+ }
+
+ @Override
+ public boolean containsAllLengthClassesPmfmId(Collection<String> lengthClassesPmfmId) {
+ boolean contains = getLengthClassesPmfmId().containsAll(lengthClassesPmfmId);
+ return contains;
+ }
+
+ @Override
+ public List<String> getLengthClassesPmfmId() {
+ return lengthClassesPmfmId;
+ }
+
+ @Override
+ public void setLengthClassesPmfmId(List<String> lengthClassesPmfmId) {
+ this.lengthClassesPmfmId = lengthClassesPmfmId;
+ }
+
+ @Override
+ public SpeciesProtocol1 getSpecies(int index) {
+ SpeciesProtocol1 o = getChild(species, index);
+ return o;
+ }
+
+ @Override
+ public boolean isSpeciesEmpty() {
+ return species == null || species.isEmpty();
+ }
+
+ @Override
+ public int sizeSpecies() {
+ return species == null ? 0 : species.size();
+ }
+
+ @Override
+ public void addSpecies(SpeciesProtocol1 species) {
+ getSpecies().add(species);
+ }
+
+ @Override
+ public void addAllSpecies(Collection<SpeciesProtocol1> species) {
+ getSpecies().addAll(species);
+ }
+
+ @Override
+ public boolean removeSpecies(SpeciesProtocol1 species) {
+ boolean removed = getSpecies().remove(species);
+ return removed;
+ }
+
+ @Override
+ public boolean removeAllSpecies(Collection<SpeciesProtocol1> species) {
+ boolean removed = getSpecies().removeAll(species);
+ return removed;
+ }
+
+ @Override
+ public boolean containsSpecies(SpeciesProtocol1 species) {
+ boolean contains = getSpecies().contains(species);
+ return contains;
+ }
+
+ @Override
+ public boolean containsAllSpecies(Collection<SpeciesProtocol1> species) {
+ boolean contains = getSpecies().containsAll(species);
+ return contains;
+ }
+
+ @Override
+ public List<SpeciesProtocol1> getSpecies() {
+ return species;
+ }
+
+ @Override
+ public void setSpecies(List<SpeciesProtocol1> species) {
+ this.species = species;
+ }
+
+ @Override
+ public SpeciesProtocol1 getBenthos(int index) {
+ SpeciesProtocol1 o = getChild(benthos, index);
+ return o;
+ }
+
+ @Override
+ public boolean isBenthosEmpty() {
+ return benthos == null || benthos.isEmpty();
+ }
+
+ @Override
+ public int sizeBenthos() {
+ return benthos == null ? 0 : benthos.size();
+ }
+
+ @Override
+ public void addBenthos(SpeciesProtocol1 benthos) {
+ getBenthos().add(benthos);
+ }
+
+ @Override
+ public void addAllBenthos(Collection<SpeciesProtocol1> benthos) {
+ getBenthos().addAll(benthos);
+ }
+
+ @Override
+ public boolean removeBenthos(SpeciesProtocol1 benthos) {
+ boolean removed = getBenthos().remove(benthos);
+ return removed;
+ }
+
+ @Override
+ public boolean removeAllBenthos(Collection<SpeciesProtocol1> benthos) {
+ boolean removed = getBenthos().removeAll(benthos);
+ return removed;
+ }
+
+ @Override
+ public boolean containsBenthos(SpeciesProtocol1 benthos) {
+ boolean contains = getBenthos().contains(benthos);
+ return contains;
+ }
+
+ @Override
+ public boolean containsAllBenthos(Collection<SpeciesProtocol1> benthos) {
+ boolean contains = getBenthos().containsAll(benthos);
+ return contains;
+ }
+
+ @Override
+ public List<SpeciesProtocol1> getBenthos() {
+ return benthos;
+ }
+
+ @Override
+ public void setBenthos(List<SpeciesProtocol1> benthos) {
+ this.benthos = benthos;
+ }
+
+} //TuttiProtocolBean
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/v1/TuttiProtocolBean1.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -41,7 +41,7 @@
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper;
@@ -81,11 +81,20 @@
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
+ protected SampleCategoryModel sampleCategoryModel;
+
//------------------------------------------------------------------------//
//-- Benthos Batch methods --//
//------------------------------------------------------------------------//
@Override
+ public void init() {
+ super.init();
+
+ sampleCategoryModel = config.getSampleCategoryModel();
+ }
+
+ @Override
public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
Preconditions.checkNotNull(fishingOperationId);
@@ -240,7 +249,8 @@
public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) {
Preconditions.checkNotNull(benthosBatchId);
- List<SortingBatch> frequencyChilds = batchHelper.getFrequencies(benthosBatchId);
+ List<SortingBatch> frequencyChilds = batchHelper.getFrequencies(
+ sampleCategoryModel, benthosBatchId);
List<BenthosBatchFrequency> results = Lists.newArrayList();
for (SortingBatch child : frequencyChilds) {
BenthosBatchFrequency target = TuttiBeanFactory.newBenthosBatchFrequency();
@@ -280,7 +290,8 @@
// Remember child ids, to remove unchanged item (see at bottom in this method)
List<Integer> notUpdatedChildIds = Lists.newArrayList();
- List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(parentBatch);
+ List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(
+ sampleCategoryModel, parentBatch);
for (SortingBatch child : frequencyChilds) {
notUpdatedChildIds.add(child.getId());
}
@@ -366,8 +377,9 @@
sm = batchHelper.getInheritedSortingMeasurement(source);
}
if (sm != null) {
- SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(sm.getPmfm().getId());
- if (sampleCategory != null) {
+ boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(
+ sm.getPmfm().getId());
+ if (isSamplingCategory) {
Integer qualitativeId = null;
if (sm.getQualitativeValue() != null) {
qualitativeId = sm.getQualitativeValue().getId();
@@ -381,7 +393,7 @@
}
}
- if (target.getSampleCategoryType() != null) {
+ if (target.getSampleCategoryId() != null) {
List<BenthosBatch> targetChilds = Lists.newArrayList();
for (Batch batch : source.getChildBatchs()) {
SortingBatch sourceChild = (SortingBatch) batch;
@@ -458,7 +470,7 @@
|| target.getRootBatch() == null
|| (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) {
batchHelper.setBenthosBatchParents(
- source.getSampleCategoryType(),
+ source.getSampleCategoryId(),
source.getSampleCategoryValue(),
target,
parentBatchId,
@@ -496,9 +508,7 @@
target.setSubgroupCount(1f);
// Weight or SampleCategoryWeight
- if (source.getWeight() == null && source.getSampleCategoryWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
+ if (source.getWeight() == null && source.getSampleCategoryWeight() != null) {
QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
target,
source.getSampleCategoryWeight());
@@ -526,13 +536,13 @@
}
// Sorting measurement
- if (source.getSampleCategoryType() != null && source.getSampleCategoryValue() != null) {
- Integer pmfmId = source.getSampleCategoryType().getFieldValue();
+ if (source.getSampleCategoryId() != null && source.getSampleCategoryValue() != null) {
+ Integer pmfmId = source.getSampleCategoryId();
// Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(
target,
- source.getSampleCategoryType(),
+ pmfmId,
source.getSampleCategoryValue());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
@@ -653,10 +663,10 @@
return;
}
- SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(pmfmId);
- Preconditions.checkNotNull(sampleCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId);
+ boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(pmfmId);
+ Preconditions.checkNotNull(isSamplingCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId);
- target.setSampleCategoryType(sampleCategory);
+ target.setSampleCategoryId(pmfmId);
Serializable categoryValue = batchHelper.getSampleCategoryQualitative(
pmfmId,
numericalvalue,
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,52 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
-import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-
-/**
- * CRUD of {@link PlanktonBatch} entity.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-@Transactional(readOnly = true)
-public interface PlanktonBatchPersistenceService extends TuttiPersistenceServiceImplementor {
-
- List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId);
-
- @Transactional(readOnly = false)
- PlanktonBatch createPlanktonBatch(PlanktonBatch bean);
-
- @Transactional(readOnly = false)
- PlanktonBatch savePlanktonBatch(PlanktonBatch bean);
-
- @Transactional(readOnly = false)
- void deletePlanktonBatch(String id);
-}
Deleted: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,70 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-@Service("planktonBatchPersistenceService")
-public class PlanktonBatchPersistenceServiceImpl extends AbstractPersistenceService implements PlanktonBatchPersistenceService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(PlanktonBatchPersistenceServiceImpl.class);
-
- @Override
- public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
- List<PlanktonBatch> result = Lists.newArrayList();
-
- // TODO BL
-
- return result;
- }
-
- @Override
- public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) {
- return null;
- }
-
- @Override
- public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) {
- return null;
- }
-
- @Override
- public void deletePlanktonBatch(String id) {
- Preconditions.checkNotNull(id);
- }
-}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -107,7 +107,7 @@
@Override
public TuttiProtocol getProtocol(String id) {
File file = getProtocolFile(id);
- TuttiProtocol result = TuttiProtocols.fromFile(file);
+ TuttiProtocol result = TuttiProtocols.fromFile(enumeration, file);
return result;
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -305,4 +305,6 @@
@Transactional(readOnly = false)
@CacheEvict(value = "gears", allEntries = true)
List<Gear> importTemporaryGear(List<Gear> gears);
+
+ TuttiEnumerationFile getEnumerationFile();
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -719,6 +719,11 @@
return Collections.unmodifiableList(result);
}
+ @Override
+ public TuttiEnumerationFile getEnumerationFile() {
+ return enumeration;
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -39,7 +39,7 @@
import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -81,6 +81,15 @@
@Resource(name = "batchPersistenceHelper")
protected BatchPersistenceHelper batchHelper;
+ protected SampleCategoryModel sampleCategoryModel;
+
+ @Override
+ public void init() {
+ super.init();
+
+ sampleCategoryModel = config.getSampleCategoryModel();
+ }
+
//------------------------------------------------------------------------//
//-- SpeciesBatch methods --//
//------------------------------------------------------------------------//
@@ -254,7 +263,7 @@
Preconditions.checkNotNull(speciesBatchId);
List<SortingBatch> frequencyChilds =
- batchHelper.getFrequencies(speciesBatchId);
+ batchHelper.getFrequencies(sampleCategoryModel, speciesBatchId);
List<SpeciesBatchFrequency> results = Lists.newArrayList();
for (SortingBatch child : frequencyChilds) {
SpeciesBatchFrequency target =
@@ -302,7 +311,7 @@
// Remember child ids, to remove unchanged item (see at bottom in this method)
List<Integer> notUpdatedChildIds = Lists.newArrayList();
- List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(parentBatch);
+ List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(sampleCategoryModel, parentBatch);
for (SortingBatch child : frequencyChilds) {
notUpdatedChildIds.add(child.getId());
}
@@ -407,8 +416,9 @@
sm = batchHelper.getInheritedSortingMeasurement(source);
}
if (sm != null) {
- SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(sm.getPmfm().getId());
- if (sampleCategory != null) {
+
+ boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(sm.getPmfm().getId());
+ if (isSamplingCategory) {
Integer qualitativeId = null;
if (sm.getQualitativeValue() != null) {
qualitativeId = sm.getQualitativeValue().getId();
@@ -422,7 +432,7 @@
}
}
- if (target.getSampleCategoryType() != null) {
+ if (target.getSampleCategoryId() != null) {
List<SpeciesBatch> targetChilds = Lists.newArrayList();
for (Batch batch : source.getChildBatchs()) {
SortingBatch sourceChild = (SortingBatch) batch;
@@ -499,7 +509,7 @@
|| (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) {
batchHelper.setSpeciesBatchParents(
- source.getSampleCategoryType(),
+ source.getSampleCategoryId(),
source.getSampleCategoryValue(),
target,
parentBatchId,
@@ -539,9 +549,7 @@
target.setSubgroupCount(1f);
// Weight or SampleCategoryWeight
- if (source.getWeight() == null && source.getSampleCategoryWeight() == null) {
- // Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
+ if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement(
target,
source.getSampleCategoryWeight());
@@ -569,13 +577,13 @@
}
// Sorting measurement
- if (source.getSampleCategoryType() != null && source.getSampleCategoryValue() != null) {
- Integer pmfmId = source.getSampleCategoryType().getFieldValue();
+ if (source.getSampleCategoryId() != null && source.getSampleCategoryValue() != null) {
+ Integer pmfmId = source.getSampleCategoryId();
// Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(
target,
- source.getSampleCategoryType(),
+ pmfmId,
source.getSampleCategoryValue());
notChangedSortingMeasurements.remove(sortingMeasurement);
}
@@ -696,37 +704,16 @@
return;
}
- SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(pmfmId);
- Preconditions.checkNotNull(sampleCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId);
+ boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(pmfmId);
+ Preconditions.checkNotNull(isSamplingCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId);
- target.setSampleCategoryType(sampleCategory);
+ target.setSampleCategoryId(pmfmId);
Serializable categoryValue = batchHelper.getSampleCategoryQualitative(
pmfmId,
numericalvalue,
alphanumericalValue,
qualitativeValueId);
target.setSampleCategoryValue(categoryValue);
-// if (numericalvalue != null) {
-// target.setSampleCategoryValue(numericalvalue);
-// return;
-// }
-// if (alphanumericalValue != null) {
-// target.setSampleCategoryValue(alphanumericalValue);
-// return;
-// }
-//
-// Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
-// if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
-// return;
-// }
-// CaracteristicQualitativeValue value = null;
-// for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
-// if (qualitativeValueId.equals(qv.getIdAsInt())) {
-// value = qv;
-// break;
-// }
-// }
-// target.setSampleCategoryValue(value);
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,11 +27,8 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.TuttiEnumerable;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.data.SexEnum;
-import fr.ifremer.tutti.persistence.entities.data.SizeEnum;
-import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ReflectionUtils;
@@ -293,32 +290,8 @@
@Value("${PmfmId.OTOLITHE_ID}")
public final Integer PMFM_ID_OTOLITHE_ID = null;
- /**
- * Contract to place on enumeration that must be synched to field inside this class.
- * <p/>
- * {@link #getFieldValue()} will be filled when {@link #init()} method is
- * invoked and then the {@link #isInit()} will return true.
- *
- * @param <O> type of fieldValue
- * @since 1.0.2
- */
- public interface TuttiEnumerable<O> {
-
- String getFieldName();
-
- O getFieldValue();
-
- void setFieldValue(Object fieldValue);
-
- boolean isInit();
-
- void setInit(boolean init);
- }
-
protected Set<Integer> propertedPmfmIds;
- protected Map<Integer, SampleCategoryEnum> pmfmIdToSampleCategory;
-
public void init() {
Map<String, Object> annotatedFieldValues = Maps.newTreeMap();
@@ -340,12 +313,9 @@
}
// init enums
- initEnum(SortedUnsortedEnum.class, annotatedFieldValues);
- initEnum(SexEnum.class, annotatedFieldValues);
- initEnum(SizeEnum.class, annotatedFieldValues);
initEnum(AttachementObjectTypeEnum.class, annotatedFieldValues);
- initEnum(SampleCategoryEnum.class, annotatedFieldValues);
+ //FIXME Should also add the one from sample category model ?
// init protected pmfm ids
propertedPmfmIds = Sets.newHashSet(
PMFM_ID_MULTIRIG_AGGREGATION,
@@ -362,11 +332,6 @@
PMFM_ID_AGE,
PMFM_ID_ID_PSFM
);
-
- pmfmIdToSampleCategory = Maps.newTreeMap();
- for (SampleCategoryEnum type : SampleCategoryEnum.values()) {
- pmfmIdToSampleCategory.put(type.getFieldValue(), type);
- }
}
/**
@@ -378,19 +343,6 @@
return propertedPmfmIds.contains(pmfmId);
}
-
- /**
- * Convert a PMFM ID into a SampleCategoryEnum.<br/>
- * This method will typically use enumeration values, to compare with the given pmfmId.
- *
- * @param pmfmId a Id of a PMFM
- * @return a SampleCategoryEnum, or null if the PMFM is not mapped
- */
- public SampleCategoryEnum getSampleCategoryByPmfmId(Integer pmfmId) {
- SampleCategoryEnum result = pmfmIdToSampleCategory.get(pmfmId);
- return result;
- }
-
protected <O, E extends Enum<E> & TuttiEnumerable<O>> void initEnum(
Class<E> enumType,
Map<String, Object> annotatedFieldValues) {
@@ -401,7 +353,7 @@
Preconditions.checkNotNull(
field,
"Could not find field " + fieldName + ")");
- e.setFieldValue(field);
+ e.setFieldValue((O) field);
e.setInit(true);
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -95,11 +95,6 @@
BenthosBatchPersistenceService.class);
}
- public static PlanktonBatchPersistenceService getPlanktonBatchPersistenceService() {
- return getPersistenceService("planktonBatchPersistenceService",
- PlanktonBatchPersistenceService.class);
- }
-
public static MarineLitterBatchPersistenceService getMarineLitterBatchPersistenceService() {
return getPersistenceService("marineLitterBatchPersistenceService",
MarineLitterBatchPersistenceService.class);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -41,7 +41,7 @@
import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.entities.TuttiEntity;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
@@ -193,26 +193,29 @@
return catchBatchDao.setQuantificationMeasurement(batch, enumeration.PMFM_ID_WEIGHT_MEASURED, getRecorderDepartmentId(), weightValue, true);
}
- public List<SortingBatch> getFrequencyChilds(SortingBatch sortingBatch) {
+ public List<SortingBatch> getFrequencyChilds(SampleCategoryModel sampleCategoryModel,
+ SortingBatch sortingBatch) {
List<SortingBatch> result = Lists.newArrayList();
for (Batch batch : sortingBatch.getChildBatchs()) {
SortingBatch child = (SortingBatch) batch;
- if (isFrequencyBatch(child)) {
+ if (isFrequencyBatch(sampleCategoryModel, child)) {
result.add(child);
}
}
return result;
}
- public List<SortingBatch> getFrequencies(String batchId) {
+ public List<SortingBatch> getFrequencies(SampleCategoryModel sampleCategoryModel,
+ String batchId) {
Preconditions.checkNotNull(batchId);
Integer sortingBatchId = Integer.valueOf(batchId);
CatchBatch catchBatch = getRootCatchBatchByBatchId(sortingBatchId);
SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
catchBatch, sortingBatchId);
- List<SortingBatch> frequencyChilds = getFrequencyChilds(sortingBatch);
+ List<SortingBatch> frequencyChilds = getFrequencyChilds(sampleCategoryModel,
+ sortingBatch);
return frequencyChilds;
}
@@ -263,7 +266,7 @@
return result;
}
- public void setSpeciesBatchParents(SampleCategoryEnum sampleCategoryType,
+ public void setSpeciesBatchParents(Integer sampleCategoryId,
Serializable sampleCategoryValue,
SortingBatch target,
String parentBatchIdStr,
@@ -283,10 +286,10 @@
// Or retrieve parent batch, from pmfm id
// Retrieve category type
- if (!sampleCategoryType.equals(SampleCategoryEnum.sortedUnsorted)) {
+ if (!sampleCategoryId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
throw new DataIntegrityViolationException(MessageFormat.format(
"A species or benthos batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
- SampleCategoryEnum.sortedUnsorted.name(),
+ sampleCategoryId,
enumeration.PMFM_ID_SORTED_UNSORTED));
}
@@ -366,7 +369,7 @@
target.setParentBatch(parentBatch);
}
- public void setBenthosBatchParents(SampleCategoryEnum sampleCategoryType,
+ public void setBenthosBatchParents(Integer sampleCategoryType,
Serializable sampleCategoryValue,
SortingBatch target,
String parentBatchIdStr,
@@ -386,10 +389,10 @@
// Or retrieve parent batch, from pmfm id
// Retrieve category type
- if (!sampleCategoryType.equals(SampleCategoryEnum.sortedUnsorted)) {
+ if (!sampleCategoryType.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
throw new DataIntegrityViolationException(MessageFormat.format(
"A species or benthos batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
- SampleCategoryEnum.sortedUnsorted.name(),
+ sampleCategoryType,
enumeration.PMFM_ID_SORTED_UNSORTED));
}
@@ -804,22 +807,22 @@
);
}
- public SortingMeasurement setSortingMeasurement(
- SortingBatch sortingBatch,
- SampleCategoryEnum sampleCategory,
- Serializable value) {
- Preconditions.checkNotNull(sampleCategory);
- Preconditions.checkNotNull(value);
+// public SortingMeasurement setSortingMeasurement(
+// SortingBatch sortingBatch,
+// SampleCategoryEnum sampleCategory,
+// Serializable value) {
+// Preconditions.checkNotNull(sampleCategory);
+// Preconditions.checkNotNull(value);
+//
+// Integer pmfmId = sampleCategory.getFieldValue();
+//
+// Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
+// SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement(
+// sortingBatch, pmfmId, getRecorderDepartmentId(), true);
+// measurementPersistenceHelper.setMeasurement(sortingMeasurement, caracteristic, value);
+// return sortingMeasurement;
+// }
- Integer pmfmId = sampleCategory.getFieldValue();
-
- Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
- SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement(
- sortingBatch, pmfmId, getRecorderDepartmentId(), true);
- measurementPersistenceHelper.setMeasurement(sortingMeasurement, caracteristic, value);
- return sortingMeasurement;
- }
-
public SortingMeasurement setSortingMeasurement(
SortingBatch sortingBatch,
Integer pmfmId,
@@ -881,19 +884,21 @@
* <li>the measurement pmfm is not a sample category</li>
* </ul>
*
- * @param sortingBatch batch to check
+ * @param sampleCategoryModel model of authorized sample categories
+ * @param sortingBatch batch to check
* @return {@code true} if given batch is a frequency batch,
* {@code false} otherwise.
*/
- protected boolean isFrequencyBatch(SortingBatch sortingBatch) {
+ protected boolean isFrequencyBatch(SampleCategoryModel sampleCategoryModel,
+ SortingBatch sortingBatch) {
boolean result = false;
if (sortingBatch.getSortingMeasurements().size() == 1) {
SortingMeasurement sm
= sortingBatch.getSortingMeasurements().iterator().next();
Pmfm pmfm = sm.getPmfm();
- SampleCategoryEnum sampleCategoryByPmfmId =
- enumeration.getSampleCategoryByPmfmId(pmfm.getId());
- result = sampleCategoryByPmfmId == null;
+// SampleCategoryEnum sampleCategoryByPmfmId =
+// enumeration.getSampleCategoryByPmfmId(pmfm.getId());
+ result = !sampleCategoryModel.containsCategoryId(pmfm.getId());
}
return result;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/test/DatabaseResource.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/test/DatabaseResource.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/test/DatabaseResource.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -45,7 +45,8 @@
import org.junit.runner.notification.Failure;
import org.junit.runners.model.Statement;
import org.nuiton.util.FileUtil;
-import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.config.ApplicationConfig;
+import org.nuiton.util.converter.ConverterUtil;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -167,7 +168,7 @@
Class<?> testClass;
- protected void prepareConfig(ApplicationConfig applicationConfig,
+ public void prepareConfig(ApplicationConfig applicationConfig,
File resourceDirectory) {
applicationConfig.loadDefaultOptions(
@@ -202,6 +203,9 @@
oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(loader);
+ ConverterUtil.deregister();
+ ConverterUtil.initConverters();
+
// check that config file is in classpath (avoid to find out why it does not works...)
String configFilename = writeDb ?
"tutti-test-write" :
Added: trunk/tutti-persistence/src/main/resources/META-INF/services/org.apache.commons.beanutils.Converter
===================================================================
--- trunk/tutti-persistence/src/main/resources/META-INF/services/org.apache.commons.beanutils.Converter (rev 0)
+++ trunk/tutti-persistence/src/main/resources/META-INF/services/org.apache.commons.beanutils.Converter 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1 @@
+fr.ifremer.tutti.persistence.config.SampleCategoryModelConverter
\ No newline at end of file
Copied: trunk/tutti-persistence/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider (from rev 1152, trunk/tutti-persistence/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider)
===================================================================
--- trunk/tutti-persistence/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider (rev 0)
+++ trunk/tutti-persistence/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1 @@
+fr.ifremer.tutti.persistence.config.TuttiPersistenceConfigProvider
\ No newline at end of file
Deleted: trunk/tutti-persistence/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider
===================================================================
--- trunk/tutti-persistence/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1 +0,0 @@
-fr.ifremer.tutti.persistence.config.TuttiPersistenceConfigProvider
\ No newline at end of file
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,3 +1,5 @@
+nuitonutil.error.no.convertor=
+tutti.config.option.persistence.SampleCategoryModel.description=
tutti.config.option.persistence.db.attachment.directory.description=
tutti.config.option.persistence.db.cache.directory.description=
tutti.config.option.persistence.db.configurationPath.description=
@@ -13,6 +15,7 @@
tutti.config.option.persistence.jdbc.password.description=
tutti.config.option.persistence.jdbc.url.description=
tutti.config.option.persistence.jdbc.username.description=
+tutti.config.option.persistence.samplingCategories.description=
tutti.config.persistence=
tutti.persistence.attachment.copyFile.error=
tutti.persistence.attachment.deleteFile.error=
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,3 +1,5 @@
+nuitonutil.error.no.convertor=
+tutti.config.option.persistence.SampleCategoryModel.description=
tutti.config.option.persistence.db.attachment.directory.description=Répertoire où sont stockées les pièces-jointes
tutti.config.option.persistence.db.cache.directory.description=Répertoire où sont stockées les caches de persistance
tutti.config.option.persistence.db.configurationPath.description=Chemin du fichier de configuration d'Adagio
@@ -13,6 +15,7 @@
tutti.config.option.persistence.jdbc.password.description=Mot de passe de l'utilisateur pour se connecter à la base de données
tutti.config.option.persistence.jdbc.url.description=URL de connexion à la base de données
tutti.config.option.persistence.jdbc.username.description=Login de l'utilisateur pour se connecter à la base de données
+tutti.config.option.persistence.samplingCategories.description=
tutti.config.persistence=Configuration de la persistance de l'application
tutti.persistence.attachment.copyFile.error=Erreur lors de la copie de la pièce jointe %1s dans le fichier %2s
tutti.persistence.attachment.deleteFile.error=Erreur lors de la suppression de la pièce jointe %s
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties
===================================================================
--- trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties 2013-07-24 17:35:44 UTC (rev 1153)
@@ -31,8 +31,10 @@
model.tagvalue.simpleBeanGenerateInterface=true
model.tagvalue.simpleBeanGenerateFactory=true
model.tagvalue.simpleBeanClassNameSuffix=Bean
-model.tagvalue.simpleBeanExtractPojoInterface=true
+model.tagvalue.simpleBeanExtractInterface=true
+fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol.attribute.mandatorySampleCategoryId.stereotype=indexed
+
fr.ifremer.tutti.persistence.entities.data.Cruise.attribute.gear.stereotype=ordered
fr.ifremer.tutti.persistence.entities.data.Cruise.attribute.headOfMission.stereotype=ordered
fr.ifremer.tutti.persistence.entities.data.Cruise.attribute.headOfSortRoom.stereotype=ordered
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
Added: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java (rev 0)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,165 @@
+package fr.ifremer.tutti.persistence.config;
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.persistence.test.DatabaseResource;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.nuiton.config.ApplicationConfig;
+import org.nuiton.config.ArgumentsParserException;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.converter.ConverterUtil;
+
+import java.io.File;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class TuttiPersistenceConfigTest {
+
+ public static final long TIMESTAMP = System.nanoTime();
+
+ @Rule
+ public final TestName name = new TestName();
+
+ protected File datadirectory;
+
+ @Before
+ public void setUp() throws Exception {
+
+ ConverterUtil.deregister();
+ ConverterUtil.initConverters();
+
+ datadirectory = FileUtil.getTestSpecificDirectory(getClass(),
+ name.getMethodName(),
+ null,
+ TIMESTAMP);
+ }
+
+ @Test
+ public void getDefaultSampleCategoryModel() throws Exception {
+
+ File configFile = new File(datadirectory, "empty.properties");
+
+ Assert.assertFalse(configFile.exists());
+
+ TuttiPersistenceConfig config = getConfig(configFile);
+
+ SampleCategoryModelEntry vracHVrac = new SampleCategoryModelEntry();
+ vracHVrac.setCategoryId(1428);
+ vracHVrac.setLabel("Vrac/Hors Vrac");
+ vracHVrac.setOrder(0);
+
+ SampleCategoryModelEntry classDeTri = new SampleCategoryModelEntry();
+ classDeTri.setCategoryId(198);
+ classDeTri.setLabel("Classe de Tri");
+ classDeTri.setOrder(1);
+
+ SampleCategoryModelEntry sex = new SampleCategoryModelEntry();
+ sex.setCategoryId(196);
+ sex.setLabel("Sexe");
+ sex.setOrder(2);
+
+ SampleCategoryModelEntry maturity = new SampleCategoryModelEntry();
+ maturity.setCategoryId(174);
+ maturity.setLabel("Maturité");
+ maturity.setOrder(3);
+
+ SampleCategoryModelEntry age = new SampleCategoryModelEntry();
+ age.setCategoryId(1430);
+ age.setLabel("Age");
+ age.setOrder(4);
+
+ SampleCategoryModel model = config.getSampleCategoryModel();
+ Assert.assertNotNull(model);
+ Assert.assertNotNull(model.getCategory());
+ Assert.assertEquals(5, model.getCategory().size());
+
+ assertModelEntry(vracHVrac, model.getCategoryByIndex(0));
+ assertModelEntry(classDeTri, model.getCategoryByIndex(1));
+ assertModelEntry(sex, model.getCategoryByIndex(2));
+ assertModelEntry(maturity, model.getCategoryByIndex(3));
+ assertModelEntry(age, model.getCategoryByIndex(4));
+ }
+
+
+ @Test
+ public void getSampleCategoryModel() throws Exception {
+
+ File configFile = new File(datadirectory, "empty.properties");
+
+ Assert.assertFalse(configFile.exists());
+
+ TuttiPersistenceConfig config = getConfig(configFile);
+
+
+ SampleCategoryModelEntry e = new SampleCategoryModelEntry();
+ e.setCategoryId(1);
+ e.setLabel("Label1");
+ e.setOrder(0);
+
+ SampleCategoryModelEntry e2 = new SampleCategoryModelEntry();
+ e2.setCategoryId(2);
+ e2.setLabel("Label2");
+ e2.setOrder(1);
+
+ SampleCategoryModel model = new SampleCategoryModel(Lists.newArrayList(e, e2));
+ config.setSampleCategoryModel(model);
+
+ SampleCategoryModel model2 = config.getSampleCategoryModel();
+ Assert.assertNotNull(model2);
+ Assert.assertNotNull(model2.getCategory());
+ Assert.assertEquals(2, model2.getCategory().size());
+
+ assertModelEntry(e, model2.getCategoryByIndex(0));
+ assertModelEntry(e2, model2.getCategoryByIndex(1));
+
+ config.getConfig().save(configFile, false);
+
+ Assert.assertTrue(configFile.exists());
+
+ TuttiPersistenceConfig config2 = getConfig(configFile);
+ model2 = config2.getSampleCategoryModel();
+ Assert.assertNotNull(model2);
+ Assert.assertNotNull(model2.getCategory());
+ Assert.assertEquals(2, model2.getCategory().size());
+
+ assertModelEntry(e, model2.getCategoryByIndex(0));
+ assertModelEntry(e2, model2.getCategoryByIndex(1));
+
+ model2.getCategory().remove(1);
+
+ config.setSampleCategoryModel(model2);
+
+ model2 = config2.getSampleCategoryModel();
+ Assert.assertNotNull(model2);
+ Assert.assertNotNull(model2.getCategory());
+ Assert.assertEquals(1, model2.getCategory().size());
+
+ assertModelEntry(e, model2.getCategoryByIndex(0));
+ }
+
+ protected void assertModelEntry(SampleCategoryModelEntry expected, SampleCategoryModelEntry actual) {
+ Assert.assertEquals(expected.getCategoryId(), actual.getCategoryId());
+ Assert.assertEquals(expected.getLabel(), actual.getLabel());
+ Assert.assertEquals(expected.getOrder(), actual.getOrder());
+
+ }
+
+ protected TuttiPersistenceConfig getConfig(File configFile) throws ArgumentsParserException {
+ ApplicationConfig applicationConfig = new ApplicationConfig(configFile.getAbsolutePath());
+
+ DatabaseResource databaseResource = DatabaseResource.noDb();
+ databaseResource.prepareConfig(applicationConfig, datadirectory);
+
+ applicationConfig.parse();
+
+ TuttiPersistenceConfig config = new TuttiPersistenceConfig(applicationConfig);
+ return config;
+ }
+}
Property changes on: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -28,6 +28,8 @@
import com.google.common.collect.Lists;
import com.google.common.io.Files;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
+import org.apache.commons.lang3.reflect.FieldUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
@@ -37,6 +39,7 @@
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Field;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -52,20 +55,22 @@
" id: 1\n" +
" calcifySampleEnabled: true\n" +
" lengthStepPmfmId: 1394\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 174\n" +
+ " - 196\n" +
" speciesReferenceTaxonId: 11242\n" +
" speciesSurveyCode: BAR\n" +
" weightEnabled: true\n" +
"- !SpeciesProtocol\n" +
" id: 2\n" +
- " ageEnabled: true\n" +
" calcifySampleEnabled: true\n" +
" countIfNoFrequencyEnabled: true\n" +
" lengthStepPmfmId: 323\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
- " sizeEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 1430\n" +
+ " - 174\n" +
+ " - 196\n" +
+ " - 198\n" +
" speciesReferenceTaxonId: 3835\n" +
" speciesSurveyCode: CHIN\n" +
" weightEnabled: true\n" +
@@ -81,29 +86,41 @@
" id: 1\n" +
" calcifySampleEnabled: true\n" +
" lengthStepPmfmId: 1394\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 174\n" +
+ " - 196\n" +
" speciesReferenceTaxonId: 11242\n" +
" speciesSurveyCode: BAR\n" +
" weightEnabled: true\n" +
"- !SpeciesProtocol\n" +
" id: 2\n" +
- " ageEnabled: true\n" +
" calcifySampleEnabled: true\n" +
" countIfNoFrequencyEnabled: true\n" +
" lengthStepPmfmId: 323\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
- " sizeEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 1430\n" +
+ " - 174\n" +
+ " - 196\n" +
+ " - 198\n" +
" speciesReferenceTaxonId: 3835\n" +
" speciesSurveyCode: CHIN\n" +
" weightEnabled: true\n" +
+ "version: 2\n" +
"vesselUseFeaturePmfmId: \n" +
"- 114\n" +
"- 228\n" +
"- 821";
+ public static final int VRAC_HORS_VRAC = 1428;
+ public static final int SIZE = 198;
+
+ public static final int SEX = 196;
+
+ public static final int MATURITY = 174;
+
+ public static final int AGE = 1430;
+
public static final long TIMESTAMP = System.nanoTime();
@Rule
@@ -137,8 +154,14 @@
Assert.assertEquals(PROTOCOL_FILE_CONTENT, exportFileToString);
}
+ protected void setField(Object o, String fieldName, Object value) throws IllegalAccessException {
+ Field field = FieldUtils.getField(o.getClass(), fieldName);
+// field.setAccessible(true);
+ FieldUtils.writeField(field, o, value, true);
+ }
+
@Test
- public void fromFile() throws IOException {
+ public void fromFile() throws Exception {
File file = new File(datadirectory, "importProtocol.yaml");
@@ -146,8 +169,16 @@
Files.write(PROTOCOL_FILE_CONTENT, file, Charsets.UTF_8);
- TuttiProtocol protocol = TuttiProtocols.fromFile(file);
+ TuttiEnumerationFile enumeration = new TuttiEnumerationFile();
+ setField(enumeration, "PMFM_ID_SORTED_UNSORTED", VRAC_HORS_VRAC);
+ setField(enumeration, "PMFM_ID_SIZE_CATEGORY", SIZE);
+ setField(enumeration, "PMFM_ID_SEX", SEX);
+ setField(enumeration, "PMFM_ID_MATURITY", MATURITY);
+ setField(enumeration, "PMFM_ID_AGE", AGE);
+
+ TuttiProtocol protocol = TuttiProtocols.fromFile(enumeration, file);
+
Assert.assertNotNull(protocol);
Assert.assertEquals("1", protocol.getId());
Assert.assertEquals("protocolName", protocol.getName());
@@ -164,12 +195,12 @@
Assert.assertEquals(11242, sp1.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("BAR", sp1.getSpeciesSurveyCode());
Assert.assertEquals("1394", sp1.getLengthStepPmfmId());
- Assert.assertFalse(sp1.isAgeEnabled());
+ Assert.assertFalse(sp1.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(sp1.isCalcifySampleEnabled());
Assert.assertFalse(sp1.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(sp1.isMaturityEnabled());
- Assert.assertTrue(sp1.isSexEnabled());
- Assert.assertFalse(sp1.isSizeEnabled());
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(SEX));
+ Assert.assertFalse(sp1.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(sp1.isWeightEnabled());
SpeciesProtocol sp2 = protocol.getSpecies().get(1);
@@ -178,12 +209,12 @@
Assert.assertEquals(3835, sp2.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("CHIN", sp2.getSpeciesSurveyCode());
Assert.assertEquals("323", sp2.getLengthStepPmfmId());
- Assert.assertTrue(sp2.isAgeEnabled());
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(sp2.isCalcifySampleEnabled());
Assert.assertTrue(sp2.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(sp2.isMaturityEnabled());
- Assert.assertTrue(sp2.isSexEnabled());
- Assert.assertTrue(sp2.isSizeEnabled());
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(SEX));
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(sp2.isWeightEnabled());
Assert.assertNotNull(protocol.getBenthos());
@@ -194,12 +225,12 @@
Assert.assertEquals(11242, b1.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("BAR", b1.getSpeciesSurveyCode());
Assert.assertEquals("1394", b1.getLengthStepPmfmId());
- Assert.assertFalse(b1.isAgeEnabled());
+ Assert.assertFalse(b1.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(b1.isCalcifySampleEnabled());
Assert.assertFalse(b1.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(b1.isMaturityEnabled());
- Assert.assertTrue(b1.isSexEnabled());
- Assert.assertFalse(b1.isSizeEnabled());
+ Assert.assertTrue(b1.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(b1.containsMandatorySampleCategoryId(SEX));
+ Assert.assertFalse(b1.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(b1.isWeightEnabled());
SpeciesProtocol b2 = protocol.getBenthos().get(1);
@@ -208,17 +239,18 @@
Assert.assertEquals(3835, b2.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("CHIN", b2.getSpeciesSurveyCode());
Assert.assertEquals("323", b2.getLengthStepPmfmId());
- Assert.assertTrue(b2.isAgeEnabled());
+ Assert.assertTrue(b2.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(b2.isCalcifySampleEnabled());
Assert.assertTrue(b2.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(b2.isMaturityEnabled());
- Assert.assertTrue(b2.isSexEnabled());
- Assert.assertTrue(b2.isSizeEnabled());
+ Assert.assertTrue(b2.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(b2.containsMandatorySampleCategoryId(SEX));
+ Assert.assertTrue(b2.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(b2.isWeightEnabled());
}
private TuttiProtocol createProtocolFixture() {
TuttiProtocol protocol = TuttiBeanFactory.newTuttiProtocol();
+ protocol.setVersion(2);
protocol.setId("1");
protocol.setName("protocolName");
protocol.setComment("Commentaire");
@@ -228,53 +260,57 @@
protocol.setSpecies(Lists.<SpeciesProtocol>newArrayList());
SpeciesProtocol sp1 = TuttiBeanFactory.newSpeciesProtocol();
+ sp1.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp1.setId("1");
sp1.setSpeciesReferenceTaxonId(11242);
sp1.setSpeciesSurveyCode("BAR");
sp1.setLengthStepPmfmId("1394");
sp1.setCalcifySampleEnabled(true);
- sp1.setMaturityEnabled(true);
- sp1.setSexEnabled(true);
+ sp1.addMandatorySampleCategoryId(MATURITY);
+ sp1.addMandatorySampleCategoryId(SEX);
sp1.setWeightEnabled(true);
protocol.addSpecies(sp1);
SpeciesProtocol sp2 = TuttiBeanFactory.newSpeciesProtocol();
+ sp2.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp2.setId("2");
sp2.setSpeciesReferenceTaxonId(3835);
sp2.setSpeciesSurveyCode("CHIN");
sp2.setLengthStepPmfmId("323");
- sp2.setAgeEnabled(true);
+ sp2.addMandatorySampleCategoryId(AGE);
sp2.setCalcifySampleEnabled(true);
sp2.setCountIfNoFrequencyEnabled(true);
- sp2.setMaturityEnabled(true);
- sp2.setSexEnabled(true);
- sp2.setSizeEnabled(true);
+ sp2.addMandatorySampleCategoryId(MATURITY);
+ sp2.addMandatorySampleCategoryId(SEX);
+ sp2.addMandatorySampleCategoryId(SIZE);
sp2.setWeightEnabled(true);
protocol.addSpecies(sp2);
protocol.setBenthos(Lists.<SpeciesProtocol>newArrayList());
SpeciesProtocol b1 = TuttiBeanFactory.newSpeciesProtocol();
+ b1.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
b1.setId("1");
b1.setSpeciesReferenceTaxonId(11242);
b1.setSpeciesSurveyCode("BAR");
b1.setLengthStepPmfmId("1394");
b1.setCalcifySampleEnabled(true);
- b1.setMaturityEnabled(true);
- b1.setSexEnabled(true);
+ b1.addMandatorySampleCategoryId(MATURITY);
+ b1.addMandatorySampleCategoryId(SEX);
b1.setWeightEnabled(true);
protocol.addBenthos(b1);
SpeciesProtocol b2 = TuttiBeanFactory.newSpeciesProtocol();
+ b2.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
b2.setId("2");
b2.setSpeciesReferenceTaxonId(3835);
b2.setSpeciesSurveyCode("CHIN");
b2.setLengthStepPmfmId("323");
- b2.setAgeEnabled(true);
+ b2.addMandatorySampleCategoryId(AGE);
b2.setCalcifySampleEnabled(true);
b2.setCountIfNoFrequencyEnabled(true);
- b2.setMaturityEnabled(true);
- b2.setSexEnabled(true);
- b2.setSizeEnabled(true);
+ b2.addMandatorySampleCategoryId(MATURITY);
+ b2.addMandatorySampleCategoryId(SEX);
+ b2.addMandatorySampleCategoryId(SIZE);
b2.setWeightEnabled(true);
protocol.addBenthos(b2);
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,14 +25,13 @@
*/
import com.google.common.collect.Maps;
-import fr.ifremer.tutti.persistence.test.DatabaseResource;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.test.DatabaseResource;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Ignore;
@@ -64,8 +63,11 @@
protected FishingOperation fishingOperation;
+ protected TuttiEnumerationFile enumerationFile;
+
@Before
public void setUp() throws Exception {
+ enumerationFile = TuttiPersistenceServiceLocator.getReferentialPersistenceService().getEnumerationFile();
service = TuttiPersistenceServiceLocator.getBenthosBatchPersistenceService();
fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
@@ -92,16 +94,16 @@
}
- public static void assertSpeciesBatch(SpeciesBatch expectedBatch,
- SpeciesBatch actualBatch,
- boolean assertIdEquals) {
+ public void assertSpeciesBatch(SpeciesBatch expectedBatch,
+ SpeciesBatch actualBatch,
+ boolean assertIdEquals) {
assertNotNull(actualBatch);
assertNotNull(actualBatch.getId());
if (assertIdEquals && expectedBatch.getId() != null) {
assertEquals(expectedBatch.getId(), actualBatch.getId());
}
assertEquals(expectedBatch.getWeight(), actualBatch.getWeight());
- assertEquals(expectedBatch.getSampleCategoryType(), actualBatch.getSampleCategoryType());
+ assertEquals(expectedBatch.getSampleCategoryId(), actualBatch.getSampleCategoryId());
if (expectedBatch.getSampleCategoryValue() != null && expectedBatch.getSampleCategoryValue() instanceof CaracteristicQualitativeValue) {
assertNotNull("Bad sampleCategoryValue : expected <" + ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId() + "> but was <null>",
actualBatch.getSampleCategoryValue());
@@ -118,7 +120,7 @@
// Check species only if Vrac/HorsVrac or if batch has been load throw getAllxxx method
// (Because getBenthosBatch(id) could not always retrieve the species)
if (expectedBatch.getSpecies() != null && (
- expectedBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted
+ enumerationFile.PMFM_ID_SORTED_UNSORTED.equals(expectedBatch.getSampleCategoryId())
|| actualBatch.getSpecies() != null)) {
assertNotNull(actualBatch.getSpecies());
assertEquals(expectedBatch.getSpecies().getId(), actualBatch.getSpecies().getId());
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,19 +26,18 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import fr.ifremer.tutti.persistence.test.DatabaseResource;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.test.DatabaseResource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
@@ -113,6 +112,8 @@
protected Caracteristic frequencyPMFM;
+ protected TuttiEnumerationFile enumerationFile;
+
@Before
public void setUp() throws Exception {
@@ -121,6 +122,7 @@
catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
+ enumerationFile = referentialService.getEnumerationFile();
species = referentialService.getAllSpecies();
assertNotNull(species);
@@ -217,7 +219,7 @@
batch.setParentBatch(null);
batch.setFishingOperation(fishingOperationNoCatchBatch);
batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SORTED_UNSORTED);
batch.setSampleCategoryValue(vracQualitativeValue);
batch.setSampleCategoryWeight(5f);
@@ -235,7 +237,7 @@
batch.setParentBatch(esp1Batch);
batch.setSpecies(taxon1);
batch.setComment("ESP1 - Vrac/5 Male/2 ss-ech/1 Nombre/7");
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SEX);
batch.setSampleCategoryValue(maleQualitativeValue);
batch.setSampleCategoryWeight(2f);
batch.setWeight(1f);
@@ -252,7 +254,7 @@
batch.setParentBatch(esp1Batch);
batch.setSpecies(taxon1);
batch.setComment("ESP1 - Vrac/5 Female/3 Nombre/14");
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SEX);
batch.setSampleCategoryValue(femaleQualitativeValue);
batch.setSampleCategoryWeight(3f);
batch.setWeight(null);
@@ -268,7 +270,7 @@
batch = TuttiBeanFactory.newBenthosBatch();
batch.setParentBatch(null);
batch.setSpecies(taxon2);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SORTED_UNSORTED);
batch.setSampleCategoryValue(vracQualitativeValue);
batch.setSampleCategoryWeight(7f);
@@ -281,7 +283,7 @@
batch.setParentBatch(esp2Batch);
batch.setSpecies(taxon2);
batch.setComment("ESP2 - Vrac/7 UNK/2 ss-ech/1 Nombre/11");
- batch.setSampleCategoryType(SampleCategoryEnum.maturity);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_MATURITY);
batch.setSampleCategoryValue(firstMaturityQualitativeValue);
batch.setSampleCategoryWeight(2f);
batch.setWeight(1f);
@@ -294,7 +296,7 @@
// -----------------------------------------------------------------------------
// Batch : ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99
batch.setComment("ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99");
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SEX);
batch.setSampleCategoryValue(unkQualitativeValue);
batch.setSampleCategoryWeight(1.75f);
batch.setWeight(1.11f);
@@ -380,7 +382,7 @@
batch.setParentBatch(null);
batch.setFishingOperation(fishingOperationWithEmptyBatch);
batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SORTED_UNSORTED);
batch.setSampleCategoryValue(vracQualitativeValue);
batch.setSampleCategoryWeight(5f);
assertCreateAndReloadBenthosBatch(batch, null);
@@ -391,7 +393,7 @@
batch.setParentBatch(esp1Batch);
batch.setFishingOperation(fishingOperationWithEmptyBatch);
batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SEX);
batch.setSampleCategoryValue(maleQualitativeValue);
batch.setSampleCategoryWeight(2f);
assertCreateAndReloadBenthosBatch(batch, esp1Batch.getId());
@@ -435,7 +437,7 @@
assertEquals(expectedBatch.getId(), actualBatch.getId());
}
assertEquals(expectedBatch.getWeight(), actualBatch.getWeight());
- assertEquals(expectedBatch.getSampleCategoryType(), actualBatch.getSampleCategoryType());
+ assertEquals(expectedBatch.getSampleCategoryId(), actualBatch.getSampleCategoryId());
if (expectedBatch.getSampleCategoryValue() != null && expectedBatch.getSampleCategoryValue() instanceof CaracteristicQualitativeValue) {
assertNotNull("Bad sampleCategoryValue : expected <" + ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId()
+ "> but was <null>",
@@ -453,7 +455,7 @@
// Check species only if Vrac/HorsVrac or if batch has been load throw getAllxxx method
// (Because getBenthosBatch(id) could not always retrieve the species)
if (expectedBatch.getSpecies() != null && (
- expectedBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted
+ enumerationFile.PMFM_ID_SORTED_UNSORTED.equals(expectedBatch.getSampleCategoryId())
|| actualBatch.getSpecies() != null)) {
assertNotNull(actualBatch.getSpecies());
assertEquals(expectedBatch.getSpecies().getId(), actualBatch.getSpecies().getId());
Deleted: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceReadTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceReadTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,61 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.test.DatabaseResource;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * To test {@link PlanktonBatchPersistenceService} for read operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-@Ignore
-public class PlanktonBatchPersistenceServiceReadTest {
-
- @ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.readDb();
-
- protected PlanktonBatchPersistenceService service;
-
- @Before
- public void setUp() throws Exception {
- service = TuttiPersistenceServiceLocator.getPlanktonBatchPersistenceService();
- }
-
- @Test
- public void getAllPlanktonBatch(/*String fishingOperationId*/) {
-
- }
-
- @Test
- public void getPlanktonBatch(/*String id*/) {
-
- }
-}
Deleted: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceWriteTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceWriteTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,65 +0,0 @@
-package fr.ifremer.tutti.persistence.service;
-
-/*
- * #%L
- * Tutti :: Persistence API
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.test.DatabaseResource;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * To test {@link PlanktonBatchPersistenceService} for write operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-@Ignore
-public class PlanktonBatchPersistenceServiceWriteTest {
-
- @ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.writeDb();
-
- protected PlanktonBatchPersistenceService service;
-
- @Before
- public void setUp() throws Exception {
- service = TuttiPersistenceServiceLocator.getPlanktonBatchPersistenceService();
- }
-
- @Test
- public void createPlanktonBatch(/*PlanktonBatch bean*/) {
-
- }
-
- @Test
- public void savePlanktonBatch(/*PlanktonBatch bean*/) {
-
- }
-
- @Test
- public void deletePlanktonBatch(/*String id*/) {
- }
-}
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceReadTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceReadTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,10 +25,10 @@
*/
import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.test.DatabaseResource;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.test.DatabaseResource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
@@ -49,6 +49,16 @@
protected ProtocolPersistenceService service;
+ public static final int VRAC_HORS_VRAC = 1428;
+
+ public static final int SIZE = 198;
+
+ public static final int SEX = 196;
+
+ public static final int MATURITY = 174;
+
+ public static final int AGE = 1430;
+
@Before
public void setUp() throws Exception {
service = TuttiPersistenceServiceLocator.getProtocolPersistenceService();
@@ -77,8 +87,9 @@
Assert.assertNotNull(loadedProtocol);
}
- protected TuttiProtocol createProtocolFixture() {
+ protected static TuttiProtocol createProtocolFixture() {
TuttiProtocol protocol = TuttiBeanFactory.newTuttiProtocol();
+ protocol.setVersion(2);
protocol.setId("1");
protocol.setName("protocolName");
protocol.setComment("Commentaire");
@@ -88,51 +99,60 @@
protocol.setSpecies(Lists.<SpeciesProtocol>newArrayList());
SpeciesProtocol sp1 = TuttiBeanFactory.newSpeciesProtocol();
+ sp1.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp1.setId("1");
sp1.setSpeciesReferenceTaxonId(11242);
+ sp1.setSpeciesSurveyCode("BAR");
sp1.setLengthStepPmfmId("1394");
sp1.setCalcifySampleEnabled(true);
- sp1.setMaturityEnabled(true);
- sp1.setSexEnabled(true);
+ sp1.addMandatorySampleCategoryId(MATURITY);
+ sp1.addMandatorySampleCategoryId(SEX);
sp1.setWeightEnabled(true);
protocol.addSpecies(sp1);
SpeciesProtocol sp2 = TuttiBeanFactory.newSpeciesProtocol();
+ sp2.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp2.setId("2");
sp2.setSpeciesReferenceTaxonId(3835);
+ sp2.setSpeciesSurveyCode("CHIN");
sp2.setLengthStepPmfmId("323");
- sp2.setAgeEnabled(true);
+ sp2.addMandatorySampleCategoryId(AGE);
sp2.setCalcifySampleEnabled(true);
sp2.setCountIfNoFrequencyEnabled(true);
- sp2.setMaturityEnabled(true);
- sp2.setSexEnabled(true);
- sp2.setSizeEnabled(true);
+ sp2.addMandatorySampleCategoryId(MATURITY);
+ sp2.addMandatorySampleCategoryId(SEX);
+ sp2.addMandatorySampleCategoryId(SIZE);
sp2.setWeightEnabled(true);
protocol.addSpecies(sp2);
protocol.setBenthos(Lists.<SpeciesProtocol>newArrayList());
- SpeciesProtocol bp1 = TuttiBeanFactory.newSpeciesProtocol();
- bp1.setId("21");
- bp1.setSpeciesReferenceTaxonId(11242);
- bp1.setLengthStepPmfmId("1394");
- bp1.setCalcifySampleEnabled(true);
- bp1.setMaturityEnabled(true);
- bp1.setSexEnabled(true);
- bp1.setWeightEnabled(true);
- protocol.addBenthos(bp1);
+ SpeciesProtocol b1 = TuttiBeanFactory.newSpeciesProtocol();
+ b1.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
+ b1.setId("1");
+ b1.setSpeciesReferenceTaxonId(11242);
+ b1.setSpeciesSurveyCode("BAR");
+ b1.setLengthStepPmfmId("1394");
+ b1.setCalcifySampleEnabled(true);
+ b1.addMandatorySampleCategoryId(MATURITY);
+ b1.addMandatorySampleCategoryId(SEX);
+ b1.setWeightEnabled(true);
+ protocol.addBenthos(b1);
- SpeciesProtocol bp2 = TuttiBeanFactory.newSpeciesProtocol();
- bp2.setId("22");
- bp2.setSpeciesReferenceTaxonId(3835);
- bp2.setLengthStepPmfmId("323");
- bp2.setAgeEnabled(true);
- bp2.setCalcifySampleEnabled(true);
- bp2.setCountIfNoFrequencyEnabled(true);
- bp2.setMaturityEnabled(true);
- bp2.setSexEnabled(true);
- bp2.setSizeEnabled(true);
- bp2.setWeightEnabled(true);
- protocol.addBenthos(bp2);
+ SpeciesProtocol b2 = TuttiBeanFactory.newSpeciesProtocol();
+ b2.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
+ b2.setId("2");
+ b2.setSpeciesReferenceTaxonId(3835);
+ b2.setSpeciesSurveyCode("CHIN");
+ b2.setLengthStepPmfmId("323");
+ b2.addMandatorySampleCategoryId(AGE);
+ b2.setCalcifySampleEnabled(true);
+ b2.setCountIfNoFrequencyEnabled(true);
+ b2.addMandatorySampleCategoryId(MATURITY);
+ b2.addMandatorySampleCategoryId(SEX);
+ b2.addMandatorySampleCategoryId(SIZE);
+ b2.setWeightEnabled(true);
+ protocol.addBenthos(b2);
+
return protocol;
}
}
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceWriteTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceWriteTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,11 +24,8 @@
* #L%
*/
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.test.DatabaseResource;
-import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.test.DatabaseResource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
@@ -48,28 +45,32 @@
protected ProtocolPersistenceService service;
public static final String PROTOCOL_FILE_CONTENT =
+ "id: 1\n" +
+ "name: protocolName\n" +
"benthos: \n" +
"- !SpeciesProtocol\n" +
- " id: 21\n" +
+ " id: 1\n" +
" calcifySampleEnabled: true\n" +
" lengthStepPmfmId: 1394\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 174\n" +
+ " - 196\n" +
" speciesReferenceTaxonId: 11242\n" +
+ " speciesSurveyCode: BAR\n" +
" weightEnabled: true\n" +
"- !SpeciesProtocol\n" +
- " id: 22\n" +
- " ageEnabled: true\n" +
+ " id: 2\n" +
" calcifySampleEnabled: true\n" +
" countIfNoFrequencyEnabled: true\n" +
" lengthStepPmfmId: 323\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
- " sizeEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 1430\n" +
+ " - 174\n" +
+ " - 196\n" +
+ " - 198\n" +
" speciesReferenceTaxonId: 3835\n" +
+ " speciesSurveyCode: CHIN\n" +
" weightEnabled: true\n" +
- "id: 1\n" +
- "name: protocolName\n" +
"comment: Commentaire\n" +
"gearUseFeaturePmfmId: \n" +
"- 21\n" +
@@ -82,21 +83,26 @@
" id: 1\n" +
" calcifySampleEnabled: true\n" +
" lengthStepPmfmId: 1394\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 174\n" +
+ " - 196\n" +
" speciesReferenceTaxonId: 11242\n" +
+ " speciesSurveyCode: BAR\n" +
" weightEnabled: true\n" +
"- !SpeciesProtocol\n" +
" id: 2\n" +
- " ageEnabled: true\n" +
" calcifySampleEnabled: true\n" +
" countIfNoFrequencyEnabled: true\n" +
" lengthStepPmfmId: 323\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
- " sizeEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 1430\n" +
+ " - 174\n" +
+ " - 196\n" +
+ " - 198\n" +
" speciesReferenceTaxonId: 3835\n" +
+ " speciesSurveyCode: CHIN\n" +
" weightEnabled: true\n" +
+ "version: 2\n" +
"vesselUseFeaturePmfmId: \n" +
"- 114\n" +
"- 228\n" +
@@ -110,7 +116,7 @@
@Test
public void createProtocol(/*TuttiProtocol bean*/) {
- TuttiProtocol protocol = createProtocolFixture();
+ TuttiProtocol protocol = ProtocolPersistenceServiceReadTest.createProtocolFixture();
TuttiProtocol createdProtocol = service.createProtocol(protocol);
Assert.assertNotNull(createdProtocol);
String id = createdProtocol.getId();
@@ -121,7 +127,7 @@
@Test
public void saveProtocol(/*TuttiProtocol bean*/) {
- TuttiProtocol protocol = createProtocolFixture();
+ TuttiProtocol protocol = ProtocolPersistenceServiceReadTest.createProtocolFixture();
TuttiProtocol createdProtocol = service.createProtocol(protocol);
Assert.assertNotNull(createdProtocol);
@@ -135,7 +141,7 @@
@Test
public void deleteProtocol() {
- TuttiProtocol protocol = createProtocolFixture();
+ TuttiProtocol protocol = ProtocolPersistenceServiceReadTest.createProtocolFixture();
TuttiProtocol createdProtocol = service.createProtocol(protocol);
Assert.assertNotNull(createdProtocol);
@@ -145,64 +151,4 @@
service.deleteProtocol(id);
Assert.assertFalse(service.getAllProtocolId().contains(id));
}
-
- protected TuttiProtocol createProtocolFixture() {
- TuttiProtocol protocol = TuttiBeanFactory.newTuttiProtocol();
- protocol.setId("1");
- protocol.setName("protocolName");
- protocol.setComment("Commentaire");
- protocol.setLengthClassesPmfmId(Lists.newArrayList("14", "18"));
- protocol.setVesselUseFeaturePmfmId(Lists.newArrayList("114", "228", "821"));
- protocol.setGearUseFeaturePmfmId(Lists.newArrayList("21", "22"));
-
- protocol.setSpecies(Lists.<SpeciesProtocol>newArrayList());
- SpeciesProtocol sp1 = TuttiBeanFactory.newSpeciesProtocol();
- sp1.setId("1");
- sp1.setSpeciesReferenceTaxonId(11242);
- sp1.setLengthStepPmfmId("1394");
- sp1.setCalcifySampleEnabled(true);
- sp1.setMaturityEnabled(true);
- sp1.setSexEnabled(true);
- sp1.setWeightEnabled(true);
- protocol.addSpecies(sp1);
-
- SpeciesProtocol sp2 = TuttiBeanFactory.newSpeciesProtocol();
- sp2.setId("2");
- sp2.setSpeciesReferenceTaxonId(3835);
- sp2.setLengthStepPmfmId("323");
- sp2.setAgeEnabled(true);
- sp2.setCalcifySampleEnabled(true);
- sp2.setCountIfNoFrequencyEnabled(true);
- sp2.setMaturityEnabled(true);
- sp2.setSexEnabled(true);
- sp2.setSizeEnabled(true);
- sp2.setWeightEnabled(true);
- protocol.addSpecies(sp2);
-
- protocol.setBenthos(Lists.<SpeciesProtocol>newArrayList());
- SpeciesProtocol bp1 = TuttiBeanFactory.newSpeciesProtocol();
- bp1.setId("21");
- bp1.setSpeciesReferenceTaxonId(11242);
- bp1.setLengthStepPmfmId("1394");
- bp1.setCalcifySampleEnabled(true);
- bp1.setMaturityEnabled(true);
- bp1.setSexEnabled(true);
- bp1.setWeightEnabled(true);
- protocol.addBenthos(bp1);
-
- SpeciesProtocol bp2 = TuttiBeanFactory.newSpeciesProtocol();
- bp2.setId("22");
- bp2.setSpeciesReferenceTaxonId(3835);
- bp2.setLengthStepPmfmId("323");
- bp2.setAgeEnabled(true);
- bp2.setCalcifySampleEnabled(true);
- bp2.setCountIfNoFrequencyEnabled(true);
- bp2.setMaturityEnabled(true);
- bp2.setSexEnabled(true);
- bp2.setSizeEnabled(true);
- bp2.setWeightEnabled(true);
- protocol.addBenthos(bp2);
-
- return protocol;
- }
}
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,13 +25,12 @@
*/
import com.google.common.collect.Maps;
-import fr.ifremer.tutti.persistence.test.DatabaseResource;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.test.DatabaseResource;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Ignore;
@@ -63,8 +62,11 @@
protected FishingOperation fishingOperation;
+ protected TuttiEnumerationFile enumerationFile;
+
@Before
public void setUp() throws Exception {
+ enumerationFile = TuttiPersistenceServiceLocator.getReferentialPersistenceService().getEnumerationFile();
service = TuttiPersistenceServiceLocator.getSpeciesBatchPersistenceService();
fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
@@ -96,16 +98,16 @@
}
- public static void assertSpeciesBatch(SpeciesBatch expectedBatch,
- SpeciesBatch actualBatch,
- boolean assertIdEquals) {
+ public void assertSpeciesBatch(SpeciesBatch expectedBatch,
+ SpeciesBatch actualBatch,
+ boolean assertIdEquals) {
assertNotNull(actualBatch);
assertNotNull(actualBatch.getId());
if (assertIdEquals && expectedBatch.getId() != null) {
assertEquals(expectedBatch.getId(), actualBatch.getId());
}
assertEquals(expectedBatch.getWeight(), actualBatch.getWeight());
- assertEquals(expectedBatch.getSampleCategoryType(), actualBatch.getSampleCategoryType());
+ assertEquals(expectedBatch.getSampleCategoryId(), actualBatch.getSampleCategoryId());
if (expectedBatch.getSampleCategoryValue() != null && expectedBatch.getSampleCategoryValue() instanceof CaracteristicQualitativeValue) {
assertNotNull("Bad sampleCategoryValue : expected <" + ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId() + "> but was <null>",
actualBatch.getSampleCategoryValue());
@@ -122,7 +124,7 @@
// Check species only if Vrac/HorsVrac or if batch has been load throw getAllxxx method
// (Because getSpeciesBatch(id) could not always retrieve the species)
if (expectedBatch.getSpecies() != null && (
- expectedBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted
+ enumerationFile.PMFM_ID_SORTED_UNSORTED.equals(expectedBatch.getSampleCategoryId())
|| actualBatch.getSpecies() != null)) {
assertNotNull(actualBatch.getSpecies());
assertEquals(expectedBatch.getSpecies().getId(), actualBatch.getSpecies().getId());
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,13 +26,11 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import fr.ifremer.tutti.persistence.test.DatabaseResource;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -40,6 +38,7 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.test.DatabaseResource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
@@ -104,6 +103,8 @@
protected Caracteristic frequencyPMFM;
+ protected TuttiEnumerationFile enumerationFile;
+
@Before
public void setUp() throws Exception {
@@ -113,6 +114,7 @@
CatchBatchPersistenceService catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService();
FishingOperationPersistenceService fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService();
ReferentialPersistenceService referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService();
+ enumerationFile = referentialService.getEnumerationFile();
species = referentialService.getAllSpecies();
assertNotNull(species);
@@ -209,7 +211,7 @@
batch.setParentBatch(null);
batch.setFishingOperation(fishingOperationNoCatchBatch);
batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SORTED_UNSORTED);
batch.setSampleCategoryValue(vracQualitativeValue);
batch.setSampleCategoryWeight(5f);
@@ -227,7 +229,7 @@
batch.setParentBatch(esp1Batch);
batch.setSpecies(taxon1);
batch.setComment("ESP1 - Vrac/5 Male/2 ss-ech/1 Nombre/7");
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SEX);
batch.setSampleCategoryValue(maleQualitativeValue);
batch.setSampleCategoryWeight(2f);
batch.setWeight(1f);
@@ -244,7 +246,7 @@
batch.setParentBatch(esp1Batch);
batch.setSpecies(taxon1);
batch.setComment("ESP1 - Vrac/5 Female/3 Nombre/14");
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SEX);
batch.setSampleCategoryValue(femaleQualitativeValue);
batch.setSampleCategoryWeight(3f);
batch.setWeight(null);
@@ -260,7 +262,7 @@
batch = TuttiBeanFactory.newSpeciesBatch();
batch.setParentBatch(null);
batch.setSpecies(taxon2);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SORTED_UNSORTED);
batch.setSampleCategoryValue(vracQualitativeValue);
batch.setSampleCategoryWeight(7f);
@@ -273,7 +275,7 @@
batch.setParentBatch(esp2Batch);
batch.setSpecies(taxon2);
batch.setComment("ESP2 - Vrac/7 UNK/2 ss-ech/1 Nombre/11");
- batch.setSampleCategoryType(SampleCategoryEnum.maturity);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_MATURITY);
batch.setSampleCategoryValue(firstMaturityQualitativeValue);
batch.setSampleCategoryWeight(2f);
batch.setWeight(1f);
@@ -286,7 +288,7 @@
// -----------------------------------------------------------------------------
// Batch : ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99
batch.setComment("ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99");
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SEX);
batch.setSampleCategoryValue(unkQualitativeValue);
batch.setSampleCategoryWeight(1.75f);
batch.setWeight(1.11f);
@@ -373,7 +375,7 @@
batch.setParentBatch(null);
batch.setFishingOperation(fishingOperationWithEmptyBatch);
batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SORTED_UNSORTED);
batch.setSampleCategoryValue(vracQualitativeValue);
batch.setSampleCategoryWeight(5f);
assertCreateAndReloadSpeciesBatch(batch, null);
@@ -384,7 +386,7 @@
batch.setParentBatch(esp1Batch);
batch.setFishingOperation(fishingOperationWithEmptyBatch);
batch.setSpecies(taxon1);
- batch.setSampleCategoryType(SampleCategoryEnum.sex);
+ batch.setSampleCategoryId(enumerationFile.PMFM_ID_SEX);
batch.setSampleCategoryValue(maleQualitativeValue);
batch.setSampleCategoryWeight(2f);
assertCreateAndReloadSpeciesBatch(batch, esp1Batch.getId());
@@ -428,7 +430,7 @@
assertEquals(expectedBatch.getId(), actualBatch.getId());
}
assertEquals(expectedBatch.getWeight(), actualBatch.getWeight());
- assertEquals(expectedBatch.getSampleCategoryType(), actualBatch.getSampleCategoryType());
+ assertEquals(expectedBatch.getSampleCategoryId(), actualBatch.getSampleCategoryId());
if (expectedBatch.getSampleCategoryValue() != null && expectedBatch.getSampleCategoryValue() instanceof CaracteristicQualitativeValue) {
assertNotNull("Bad sampleCategoryValue : expected <" + ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId()
+ "> but was <null>",
@@ -446,7 +448,7 @@
// Check species only if Vrac/HorsVrac or if batch has been load throw getAllxxx method
// (Because getSpeciesBatch(id) could not always retrieve the species)
if (expectedBatch.getSpecies() != null && (
- expectedBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted
+ enumerationFile.PMFM_ID_SORTED_UNSORTED.equals(expectedBatch.getSampleCategoryId())
|| actualBatch.getSpecies() != null)) {
assertNotNull(actualBatch.getSpecies());
assertEquals(expectedBatch.getSpecies().getId(), actualBatch.getSpecies().getId());
Deleted: trunk/tutti-service/changelog.txt
===================================================================
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/pom.xml 2013-07-24 17:35:44 UTC (rev 1153)
@@ -54,6 +54,11 @@
<dependency>
<groupId>org.nuiton</groupId>
+ <artifactId>nuiton-decorator</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
<artifactId>nuiton-config</artifactId>
</dependency>
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -29,6 +29,7 @@
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -39,8 +40,8 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import org.nuiton.util.decorator.Decorator;
-import org.nuiton.util.decorator.DecoratorProvider;
+import org.nuiton.decorator.Decorator;
+import org.nuiton.decorator.DecoratorProvider;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
@@ -94,6 +95,7 @@
@Override
protected void loadDecorators() {
+ registerTuttiDecorator(SampleCategoryModelEntry.class, "${label}$s", SEPARATOR, " - ");
registerTuttiDecorator(TuttiLocation.class, "${label}$s#${name}$s", SEPARATOR, " - ");
registerTuttiDecorator(Cruise.class, "${name}$s", SEPARATOR, " - ");
registerTuttiDecorator(TuttiProtocol.class, "${name}$s", SEPARATOR, " - ");
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -42,7 +42,6 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
@@ -55,6 +54,7 @@
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.persistence.entities.referential.TuttiReferentialEntity;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator;
import fr.ifremer.tutti.service.config.TuttiServiceConfig;
import org.apache.commons.io.IOUtils;
@@ -106,6 +106,11 @@
driver.clearAllCaches();
}
+ @Override
+ public TuttiEnumerationFile getEnumerationFile() {
+ return driver.getEnumerationFile();
+ }
+
public static final DateFormat EXPORT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
public static final String EXPORT_DIRECTORY_FORMAT = "tutti-%s-%s";
@@ -473,6 +478,21 @@
}
@Override
+ public Caracteristic getCaracteristic(Integer pmfmId) {
+ return driver.getCaracteristic(pmfmId);
+ }
+
+ @Override
+ public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
+ return driver.isVracSpeciesBatch(speciesBatch);
+ }
+
+ @Override
+ public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
+ return driver.isVracBenthosBatch(benthosBatch);
+ }
+
+ @Override
public boolean isTemporary(TuttiReferentialEntity entity) {
return driver.isTemporary(entity);
}
@@ -812,30 +832,6 @@
}
//------------------------------------------------------------------------//
- //-- Plankton Batch methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
- return driver.getAllPlanktonBatch(fishingOperationId);
- }
-
- @Override
- public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) {
- return driver.createPlanktonBatch(bean);
- }
-
- @Override
- public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) {
- return driver.savePlanktonBatch(bean);
- }
-
- @Override
- public void deletePlanktonBatch(String id) {
- driver.deletePlanktonBatch(id);
- }
-
- //------------------------------------------------------------------------//
//-- Macrodechet Batch methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -37,21 +37,22 @@
import org.apache.commons.beanutils.NestedNullException;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
-import org.nuiton.util.csv.Common;
-import org.nuiton.util.csv.ExportModel;
-import org.nuiton.util.csv.ExportableColumn;
-import org.nuiton.util.csv.ValueFormatter;
-import org.nuiton.util.csv.ValueGetter;
-import org.nuiton.util.csv.ValueParserFormatter;
-import org.nuiton.util.csv.ext.AbstractExportModel;
-import org.nuiton.util.csv.ext.AbstractImportExportModel;
-import org.nuiton.util.csv.ext.RepeatableExport;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.csv.Common;
+import org.nuiton.csv.ExportModel;
+import org.nuiton.csv.ExportableColumn;
+import org.nuiton.csv.ValueFormatter;
+import org.nuiton.csv.ValueGetter;
+import org.nuiton.csv.ValueParserFormatter;
+import org.nuiton.csv.ext.AbstractExportModel;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+import org.nuiton.csv.ext.RepeatableExport;
+import org.nuiton.decorator.Decorator;
import java.io.Serializable;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -162,6 +163,14 @@
return newNullableColumnForExport(headerName, propertyName, TuttiCsvUtil.STRING);
}
+ public <T> ExportableColumn<M, T> newIndexNullableColumnForExport(String headerName, String collectionName, int order, String propertyName, ValueFormatter<T> valueFormatter) {
+ return modelBuilder.newColumnForExport(headerName, new BeanIndexNullableGetter<M, T>(collectionName, order, propertyName), valueFormatter);
+ }
+
+ public ExportableColumn<M, String> newIndexNullableColumnForExport(String headerName, String collectionName, int order, String propertyName) {
+ return newIndexNullableColumnForExport(headerName, collectionName, order, propertyName, TuttiCsvUtil.STRING);
+ }
+
}
public static class StringParserFormatter extends Common.NullableParserFormatter<String> {
@@ -275,6 +284,42 @@
}
}
+ public static class BeanIndexNullableGetter<E, T> implements ValueGetter<E, T> {
+
+ protected String collectionName;
+
+ protected int order;
+
+ protected String propertyName;
+
+ BeanIndexNullableGetter(String collectionName, int order, String suffix) {
+ this.collectionName = collectionName;
+ this.order = order;
+ this.propertyName = collectionName + "[" + order + "]." + suffix;
+
+ }
+
+ @Override
+ public T get(E object) throws Exception {
+ T value = null;
+ try {
+ Collection c = (Collection) PropertyUtils.getProperty(object, collectionName);
+ if (c != null && order < c.size()) {
+ value = (T) PropertyUtils.getProperty(object, propertyName);
+ }
+ } catch (NestedNullException e) {
+ value = null;
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof NullPointerException) {
+ value = null;
+ } else {
+ throw e;
+ }
+ }
+ return value;
+ }
+ }
+
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0
@@ -333,6 +378,9 @@
public static final ValueFormatter<List<Person>> LIST_PERSON_FORMATTER =
new ListPersonValueFormatter();
+ public static final ValueParserFormatter<List<Integer>> LIST_INTEGER_PARSER_FORMATTER =
+ new ListIntegerValueFormatter();
+
public static final ValueFormatter<List<Gear>> LIST_GEAR_FORMATTER =
new ListGearValueFormatter();
@@ -438,6 +486,31 @@
}
}
+ protected static class ListIntegerValueFormatter implements ValueParserFormatter<List<Integer>> {
+
+ @Override
+ public String format(List<Integer> value) {
+ List<String> decoratedValues =
+ Lists.transform(value, new Function<Integer, String>() {
+ @Override
+ public String apply(Integer input) {
+ return input.toString();
+ }
+ });
+ return Joiner.on('|').join(decoratedValues);
+ }
+
+ @Override
+ public List<Integer> parse(String value) throws ParseException {
+ String[] split = value.split("\\s*\\|\\s*");
+ List<Integer> result = Lists.newArrayList();
+ for (String string : split) {
+ result.add(Integer.valueOf(string));
+ }
+ return result;
+ }
+ }
+
protected static class ListPersonValueFormatter implements ValueFormatter<List<Person>> {
@Override
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -30,6 +30,7 @@
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -38,6 +39,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import fr.ifremer.tutti.service.config.TuttiServiceConfig;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -109,6 +111,12 @@
*/
protected String fishingOperationId;
+ /**
+ * Model of sampling as defined in configuration.
+ *
+ * @since 2.5
+ */
+ protected SampleCategoryModel sampleCategoryModel;
protected Program program;
@@ -177,9 +185,11 @@
});
}
- public void open(PersistenceService persistenceService) {
+ public void open(TuttiServiceConfig config, PersistenceService persistenceService) {
close();
this.service = persistenceService;
+ sampleCategoryModel = config.getPersistenceConfig().getSampleCategoryModel();
+ sampleCategoryModel.load(persistenceService);
}
@Override
@@ -192,6 +202,7 @@
program = null;
cruise = null;
fishingOperation = null;
+ sampleCategoryModel = null;
resetProtocol();
resetVessels();
resetGears();
@@ -314,6 +325,10 @@
firePropertyChange(PROPERTY_CRUISE_ID, oldCruiseId, saneCruiseId);
}
+ public SampleCategoryModel getSampleCategoryModel() {
+ return sampleCategoryModel;
+ }
+
public String getProgramId() {
return programId;
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDecorator.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDecorator.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDecorator.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -32,8 +32,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.beans.BeanUtil;
-import org.nuiton.util.decorator.JXPathDecorator;
-import org.nuiton.util.decorator.MultiJXPathDecorator;
+import org.nuiton.decorator.JXPathDecorator;
+import org.nuiton.decorator.MultiJXPathDecorator;
import java.beans.PropertyDescriptor;
import java.io.Serializable;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -31,6 +31,7 @@
import com.opensymphony.xwork2.util.ValueStack;
import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.RessourceClassLoader;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.service.config.TuttiServiceConfig;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
@@ -149,4 +150,10 @@
}
services.invalidateAll();
}
+
+ public SampleCategoryModel getSampleCategoryModel() {
+ SampleCategoryModel result = getDataContext().getSampleCategoryModel();
+ Preconditions.checkNotNull(result, "Need a not null sample category model");
+ return result;
+ }
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -28,7 +28,6 @@
import com.google.common.collect.Maps;
import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.TuttiTechnicalException;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
@@ -270,7 +269,7 @@
ktch.put("commonName", speciesWithVerncularCode.getVernacularCode());
existingSortedWeight = 0f;
- existingTotalWeight= 0f;
+ existingTotalWeight = 0f;
} else {
existingSortedWeight = (Float) ktch.get("sortedWeight");
@@ -283,7 +282,7 @@
}
ktch.put("sortedWeight", weight + existingSortedWeight);
- if (TuttiEntities.isVracSpeciesBatch(batch)) {
+ if (persistenceService.isVracSpeciesBatch(batch)) {
weight *= ratio;
}
weight += existingTotalWeight;
@@ -310,7 +309,7 @@
batchWeight = batch.getSampleCategoryComputedWeight();
}
sortedWeight += batchWeight;
- if (TuttiEntities.isVracBenthosBatch(batch)) {
+ if (persistenceService.isVracBenthosBatch(batch)) {
batchWeight *= ratio;
}
benthosTotalWeight += batchWeight;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,18 +26,23 @@
import com.google.common.collect.Maps;
import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.*;
+import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.ValidationService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -63,12 +68,15 @@
protected DecoratorService decoratorService;
+ protected SampleCategoryModel sampleCategoryModel;
+
@Override
public void setServiceContext(TuttiServiceContext context) {
super.setServiceContext(context);
persistenceService = getService(PersistenceService.class);
validationService = getService(ValidationService.class);
decoratorService = getService(DecoratorService.class);
+ sampleCategoryModel = context.getSampleCategoryModel();
}
/**
@@ -157,9 +165,9 @@
/**
* Compute the weights of the catch batch (not the ones of the species, benthos nor marine litter batches)
*
- * @param catchBatch the catch batch with the weights to compute
- * @param rootSpeciesBatch the species batches with already computed weights
- * @param rootBenthosBatch the benthos batches with already computed weights
+ * @param catchBatch the catch batch with the weights to compute
+ * @param rootSpeciesBatch the species batches with already computed weights
+ * @param rootBenthosBatch the benthos batches with already computed weights
* @param rootMarineLitterBatch the marine litter batches with already computed weights
*/
public void computeCatchBatchWeights(CatchBatch catchBatch,
@@ -174,16 +182,18 @@
if (rootSpeciesBatch != null) {
for (int i = 0; i < rootSpeciesBatch.getChildren().size(); i++) {
SpeciesBatch row = rootSpeciesBatch.getChildren().get(i);
- Float weight = row.getSampleCategoryWeight();
+// Float weight = row.getSampleCategoryWeight();
+// if (weight == null) {
+// weight = row.getSampleCategoryComputedWeight();
+// }
+ Float weight = TuttiEntities.getValueOrComputedValue(
+ row.getSampleCategoryWeight(),
+ row.getSampleCategoryComputedWeight());
if (weight == null) {
- weight = row.getSampleCategoryComputedWeight();
- }
- if (weight == null) {
break;
}
- CaracteristicQualitativeValue value = (CaracteristicQualitativeValue) row.getSampleCategoryValue();
- if (SortedUnsortedEnum.SORTED.matchValue(value)) {
+ if (persistenceService.isVracSpeciesBatch(row)) {
speciesTotalComputedSortedWeight += weight;
} else {
speciesTotalComputedUnsortedWeight += weight;
@@ -230,16 +240,18 @@
if (rootBenthosBatch != null) {
for (int i = 0; i < rootBenthosBatch.getChildren().size(); i++) {
BenthosBatch row = rootBenthosBatch.getChildren().get(i);
- Float weight = row.getSampleCategoryWeight();
+ Float weight = TuttiEntities.getValueOrComputedValue(
+ row.getSampleCategoryWeight(),
+ row.getSampleCategoryComputedWeight());
+// Float weight = row.getSampleCategoryWeight();
+// if (weight == null) {
+// weight = row.getSampleCategoryComputedWeight();
+// }
if (weight == null) {
- weight = row.getSampleCategoryComputedWeight();
- }
- if (weight == null) {
break;
}
- CaracteristicQualitativeValue value = (CaracteristicQualitativeValue) row.getSampleCategoryValue();
- if (SortedUnsortedEnum.SORTED.matchValue(value)) {
+ if (persistenceService.isVracBenthosBatch(row)) {
benthosTotalComputedSortedWeight += weight;
} else {
benthosTotalComputedUnsortedWeight += weight;
@@ -363,6 +375,13 @@
return rootSpeciesBatch;
}
+ protected String getCategoryLabel(Integer sampleCategoryId) {
+ SampleCategoryModelEntry category =
+ sampleCategoryModel.getCategoryById(sampleCategoryId);
+ String result = category.getLabel();
+ return result;
+ }
+
public Float computeSpeciesBatch(SpeciesBatch batch) {
Float result = null;
int thisIndex = currentSpeciesRowIndex++;
@@ -375,11 +394,15 @@
NuitonValidatorResult validation = validationService.validateSpeciesBatch(batch);
if (!validation.isValid()) {
List<String> messages = validation.getErrorMessages(SpeciesBatch.PROPERTY_WEIGHT);
+ String categoryLabel = getCategoryLabel(batch.getSampleCategoryId());
throw new TuttiWeightComputingException(_(messages.get(0),
- species, batch.getSampleCategoryType().getLabel(), categoryValue,
- batch.getWeight(), batch.getSampleCategoryWeight()),
- SpeciesBatch.PROPERTY_WEIGHT,
- thisIndex);
+ species,
+ categoryLabel,
+ categoryValue,
+ batch.getWeight(),
+ batch.getSampleCategoryWeight()),
+ SpeciesBatch.PROPERTY_WEIGHT,
+ thisIndex);
}
List<SpeciesBatch> children = batch.getChildBatchs();
@@ -401,10 +424,14 @@
batch.setSampleCategoryComputedWeight(sum);
} else if (categoryWeight < sum) {
+ String categoryLabel = getCategoryLabel(batch.getSampleCategoryId());
throw new TuttiWeightComputingException(
_("tutti.service.operations.computeWeights.error.species.incoherentParentCategoryWeight",
- species, batch.getSampleCategoryType().getLabel(), categoryValue,
- categoryWeight, sum),
+ species,
+ categoryLabel,
+ categoryValue,
+ categoryWeight,
+ sum),
SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT,
thisIndex);
@@ -442,12 +469,17 @@
// throw new TuttiBusinessException(_("tutti.service.operations.computeWeights.error.incoherentRowWeightCategory"));
} else if (rowWeight != null && frequencyWeight != null
- && !rowWeight.equals(frequencyWeight)) {
+ && !rowWeight.equals(frequencyWeight)) {
+ String categoryLabel = getCategoryLabel(batch.getSampleCategoryId());
+
throw new TuttiWeightComputingException(
_("tutti.service.operations.computeWeights.error.species.incoherentRowWeightFrequency",
- species, batch.getSampleCategoryType().getLabel(), categoryValue,
- frequencyWeight, rowWeight),
+ species,
+ categoryLabel,
+ categoryValue,
+ frequencyWeight,
+ rowWeight),
SpeciesBatch.PROPERTY_WEIGHT,
thisIndex);
@@ -463,10 +495,16 @@
// if the weight of the frequencies is different from the category
// weight, then set the weight of the sample
if (frequencyWeight > categoryWeight) {
+
+ String categoryLabel = getCategoryLabel(batch.getSampleCategoryId());
+
throw new TuttiWeightComputingException(
_("tutti.service.operations.computeWeights.error.species.incoherentCategoryWeight",
- species, batch.getSampleCategoryType().getLabel(), categoryValue,
- frequencyWeight, categoryWeight),
+ species,
+ categoryLabel,
+ categoryValue,
+ frequencyWeight,
+ categoryWeight),
SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT,
thisIndex);
@@ -485,9 +523,14 @@
}
}
if (result == null) {
+
+ String categoryLabel = getCategoryLabel(batch.getSampleCategoryId());
+
throw new TuttiWeightComputingException(
_("tutti.service.operations.computeWeights.error.species.noWeight",
- species, batch.getSampleCategoryType().getLabel(), categoryValue),
+ species,
+ categoryLabel,
+ categoryValue),
SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT,
thisIndex);
}
@@ -529,16 +572,21 @@
NuitonValidatorResult validation = validationService.validateBenthosBatch(batch);
if (!validation.isValid()) {
List<String> messages = validation.getErrorMessages(BenthosBatch.PROPERTY_WEIGHT);
+
+ String categoryLabel = getCategoryLabel(batch.getSampleCategoryId());
throw new TuttiWeightComputingException(_(messages.get(0),
- species, batch.getSampleCategoryType().getLabel(), categoryValue,
- batch.getWeight(), batch.getSampleCategoryWeight()),
+ species,
+ categoryLabel,
+ categoryValue,
+ batch.getWeight(),
+ batch.getSampleCategoryWeight()),
BenthosBatch.PROPERTY_WEIGHT,
thisIndex);
}
List<BenthosBatch> children = batch.getChildBatchs();
// if the row is not a leaf
- if (batch.sizeChildBatchs() > 0) {
+ if (!batch.isChildBatchsEmpty()) {
Float sum = 0f;
// make the sum of the children weights
for (BenthosBatch child : children) {
@@ -555,10 +603,16 @@
batch.setSampleCategoryComputedWeight(sum);
} else if (categoryWeight < sum) {
+ String categoryLabel =
+ getCategoryLabel(batch.getSampleCategoryId());
+
throw new TuttiWeightComputingException(
_("tutti.service.operations.computeWeights.error.benthos.incoherentParentCategoryWeight",
- species, batch.getSampleCategoryType().getLabel(), categoryValue,
- categoryWeight, sum),
+ species,
+ categoryLabel,
+ categoryValue,
+ categoryWeight,
+ sum),
BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT,
thisIndex);
@@ -597,12 +651,18 @@
// throw new TuttiBusinessException(_("tutti.service.operations.computeWeights.error.incoherentRowWeightCategory"));
} else if (rowWeight != null && frequencyWeight != null
- && !rowWeight.equals(frequencyWeight)) {
+ && !rowWeight.equals(frequencyWeight)) {
+ String categoryLabel =
+ getCategoryLabel(batch.getSampleCategoryId());
+
throw new TuttiWeightComputingException(
_("tutti.service.operations.computeWeights.error.benthos.incoherentRowWeightFrequency",
- species, batch.getSampleCategoryType().getLabel(), categoryValue,
- rowWeight, categoryWeight),
+ species,
+ categoryLabel,
+ categoryValue,
+ rowWeight,
+ categoryWeight),
BenthosBatch.PROPERTY_WEIGHT,
thisIndex);
@@ -618,10 +678,17 @@
// if the weight of the frequencies is different from the category
// weight, then set the weight of the sample
if (frequencyWeight > categoryWeight) {
+
+ String categoryLabel =
+ getCategoryLabel(batch.getSampleCategoryId());
+
throw new TuttiWeightComputingException(
_("tutti.service.operations.computeWeights.error.benthos.incoherentCategoryWeight",
- species, batch.getSampleCategoryType().getLabel(), categoryValue,
- frequencyWeight, categoryWeight),
+ species,
+ categoryLabel,
+ categoryValue,
+ frequencyWeight,
+ categoryWeight),
BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT,
thisIndex);
@@ -640,9 +707,15 @@
}
}
if (result == null) {
+
+ String categoryLabel =
+ getCategoryLabel(batch.getSampleCategoryId());
+
throw new TuttiWeightComputingException(
_("tutti.service.operations.computeWeights.error.benthos.noWeight",
- species, batch.getSampleCategoryType().getLabel(), categoryValue),
+ species,
+ categoryLabel,
+ categoryValue),
BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT,
thisIndex);
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -36,6 +36,7 @@
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
@@ -50,7 +51,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import org.nuiton.validator.NuitonValidatorResult;
import org.nuiton.validator.NuitonValidatorScope;
@@ -79,6 +80,8 @@
protected DecoratorService decoratorService;
+ protected SampleCategoryModel sampleCategoryModel;
+
@Override
public void setServiceContext(TuttiServiceContext context) {
super.setServiceContext(context);
@@ -86,6 +89,7 @@
validationService = getService(ValidationService.class);
tuttiWeightComputingService = getService(TuttiWeightComputingService.class);
decoratorService = getService(DecoratorService.class);
+ sampleCategoryModel = context.getSampleCategoryModel();
}
/**
@@ -380,7 +384,10 @@
if (batch.isChildBatchsEmpty()) {
List<BenthosBatchFrequency> frequencies =
persistenceService.getAllBenthosBatchFrequency(batch.getId());
- return !TuttiProtocols.isBenthosBatchValid(protocol, batch, frequencies);
+ return !TuttiProtocols.isBenthosBatchValid(
+ protocol,
+ batch,
+ frequencies);
}
for (BenthosBatch child : batch.getChildBatchs()) {
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/AccidentalCatchRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/AccidentalCatchRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/AccidentalCatchRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -31,7 +31,7 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.csv.ValueFormatter;
import java.util.List;
import java.util.Map;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/AttachmentRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/AttachmentRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/AttachmentRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,8 +25,8 @@
*/
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.ValueFormatter;
-import org.nuiton.util.csv.ValueParser;
+import org.nuiton.csv.ValueFormatter;
+import org.nuiton.csv.ValueParser;
import java.io.File;
import java.text.ParseException;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CaracteristicRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CaracteristicRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CaracteristicRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -30,7 +30,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.csv.ValueFormatter;
import java.io.Serializable;
import java.util.List;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchFrequencyRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchFrequencyRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchFrequencyRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -29,7 +29,7 @@
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.csv.ValueFormatter;
import java.util.List;
import java.util.Map;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRow.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRow.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -44,16 +44,20 @@
public static final String SPECIES = "species";
- public static final String SORTED_UNSORTED_SAMPLE_CATEGORY = "sortedUnsortedSampleCategory";
+// public static final String SORTED_UNSORTED_SAMPLE_CATEGORY = "sortedUnsortedSampleCategory";
+//
+// public static final String SIZE_SAMPLE_CATEGORY = "sizeSampleCategory";
+//
+// public static final String SEX_SAMPLE_CATEGORY = "sexSampleCategory";
+//
+// public static final String MATURITY_SAMPLE_CATEGORY = "maturitySampleCategory";
+//
+// public static final String AGE_SAMPLE_CATEGORY = "ageSampleCategory";
- public static final String SIZE_SAMPLE_CATEGORY = "sizeSampleCategory";
+ public static final String CATEGORY_ID = "categoryId";
- public static final String SEX_SAMPLE_CATEGORY = "sexSampleCategory";
+ public static final String CATEGORY_VALUE = "categoryValue";
- public static final String MATURITY_SAMPLE_CATEGORY = "maturitySampleCategory";
-
- public static final String AGE_SAMPLE_CATEGORY = "ageSampleCategory";
-
public static final String CATEGORY_WEIGHT = "categoryWeight";
public static final String WEIGHT = "weight";
@@ -70,16 +74,20 @@
protected Species species;
- protected Serializable sortedUnsortedSampleCategory;
+ protected Integer categoryId;
- protected Serializable sizeSampleCategory;
+ protected Serializable categoryValue;
- protected Serializable sexSampleCategory;
+// protected Serializable sortedUnsortedSampleCategory;
+//
+// protected Serializable sizeSampleCategory;
+//
+// protected Serializable sexSampleCategory;
+//
+// protected Serializable maturitySampleCategory;
+//
+// protected Serializable ageSampleCategory;
- protected Serializable maturitySampleCategory;
-
- protected Serializable ageSampleCategory;
-
protected Float categoryWeight;
protected Float weight;
@@ -114,46 +122,62 @@
this.species = species;
}
- public Serializable getSortedUnsortedSampleCategory() {
- return sortedUnsortedSampleCategory;
+ public Integer getCategoryId() {
+ return categoryId;
}
- public void setSortedUnsortedSampleCategory(Serializable sortedUnsortedSampleCategory) {
- this.sortedUnsortedSampleCategory = sortedUnsortedSampleCategory;
+ public void setCategoryId(Integer categoryId) {
+ this.categoryId = categoryId;
}
- public Serializable getSizeSampleCategory() {
- return sizeSampleCategory;
+ public Serializable getCategoryValue() {
+ return categoryValue;
}
- public void setSizeSampleCategory(Serializable sizeSampleCategory) {
- this.sizeSampleCategory = sizeSampleCategory;
+ public void setCategoryValue(Serializable categoryValue) {
+ this.categoryValue = categoryValue;
}
- public Serializable getSexSampleCategory() {
- return sexSampleCategory;
- }
+// public Serializable getSortedUnsortedSampleCategory() {
+// return sortedUnsortedSampleCategory;
+// }
+//
+// public void setSortedUnsortedSampleCategory(Serializable sortedUnsortedSampleCategory) {
+// this.sortedUnsortedSampleCategory = sortedUnsortedSampleCategory;
+// }
+//
+// public Serializable getSizeSampleCategory() {
+// return sizeSampleCategory;
+// }
+//
+// public void setSizeSampleCategory(Serializable sizeSampleCategory) {
+// this.sizeSampleCategory = sizeSampleCategory;
+// }
+//
+// public Serializable getSexSampleCategory() {
+// return sexSampleCategory;
+// }
+//
+// public void setSexSampleCategory(Serializable sexSampleCategory) {
+// this.sexSampleCategory = sexSampleCategory;
+// }
+//
+// public Serializable getMaturitySampleCategory() {
+// return maturitySampleCategory;
+// }
+//
+// public void setMaturitySampleCategory(Serializable maturitySampleCategory) {
+// this.maturitySampleCategory = maturitySampleCategory;
+// }
+//
+// public Serializable getAgeSampleCategory() {
+// return ageSampleCategory;
+// }
+//
+// public void setAgeSampleCategory(Serializable ageSampleCategory) {
+// this.ageSampleCategory = ageSampleCategory;
+// }
- public void setSexSampleCategory(Serializable sexSampleCategory) {
- this.sexSampleCategory = sexSampleCategory;
- }
-
- public Serializable getMaturitySampleCategory() {
- return maturitySampleCategory;
- }
-
- public void setMaturitySampleCategory(Serializable maturitySampleCategory) {
- this.maturitySampleCategory = maturitySampleCategory;
- }
-
- public Serializable getAgeSampleCategory() {
- return ageSampleCategory;
- }
-
- public void setAgeSampleCategory(Serializable ageSampleCategory) {
- this.ageSampleCategory = ageSampleCategory;
- }
-
public Float getCategoryWeight() {
return categoryWeight;
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -29,7 +29,7 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.csv.ValueFormatter;
import java.io.Serializable;
import java.util.List;
@@ -89,36 +89,37 @@
Species.PROPERTY_REFERENCE_TAXON_ID,
speciesMap);
- newColumnForExport(CatchRow.SORTED_UNSORTED_SAMPLE_CATEGORY,
- caracteristicValueFormatter);
+ //FIXME: deal with it!
+// newColumnForExport(CatchRow.SORTED_UNSORTED_SAMPLE_CATEGORY,
+// caracteristicValueFormatter);
+//
+// newMandatoryColumn(CatchRow.SORTED_UNSORTED_SAMPLE_CATEGORY,
+// TuttiCsvUtil.STRING);
+//
+// newColumnForExport(CatchRow.SIZE_SAMPLE_CATEGORY,
+// caracteristicValueFormatter);
+//
+// newMandatoryColumn(CatchRow.SIZE_SAMPLE_CATEGORY,
+// TuttiCsvUtil.STRING);
+//
+// newColumnForExport(CatchRow.SEX_SAMPLE_CATEGORY,
+// caracteristicValueFormatter);
+//
+// newMandatoryColumn(CatchRow.SEX_SAMPLE_CATEGORY,
+// TuttiCsvUtil.STRING);
+//
+// newColumnForExport(CatchRow.MATURITY_SAMPLE_CATEGORY,
+// caracteristicValueFormatter);
+//
+// newMandatoryColumn(CatchRow.MATURITY_SAMPLE_CATEGORY,
+// TuttiCsvUtil.STRING);
+//
+// newColumnForExport(CatchRow.AGE_SAMPLE_CATEGORY,
+// caracteristicValueFormatter);
+//
+// newMandatoryColumn(CatchRow.AGE_SAMPLE_CATEGORY,
+// TuttiCsvUtil.STRING);
- newMandatoryColumn(CatchRow.SORTED_UNSORTED_SAMPLE_CATEGORY,
- TuttiCsvUtil.STRING);
-
- newColumnForExport(CatchRow.SIZE_SAMPLE_CATEGORY,
- caracteristicValueFormatter);
-
- newMandatoryColumn(CatchRow.SIZE_SAMPLE_CATEGORY,
- TuttiCsvUtil.STRING);
-
- newColumnForExport(CatchRow.SEX_SAMPLE_CATEGORY,
- caracteristicValueFormatter);
-
- newMandatoryColumn(CatchRow.SEX_SAMPLE_CATEGORY,
- TuttiCsvUtil.STRING);
-
- newColumnForExport(CatchRow.MATURITY_SAMPLE_CATEGORY,
- caracteristicValueFormatter);
-
- newMandatoryColumn(CatchRow.MATURITY_SAMPLE_CATEGORY,
- TuttiCsvUtil.STRING);
-
- newColumnForExport(CatchRow.AGE_SAMPLE_CATEGORY,
- caracteristicValueFormatter);
-
- newMandatoryColumn(CatchRow.AGE_SAMPLE_CATEGORY,
- TuttiCsvUtil.STRING);
-
newColumnForImportExport(CatchRow.CATEGORY_WEIGHT,
TuttiCsvUtil.FLOAT);
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/IndividualObservationRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/IndividualObservationRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/IndividualObservationRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -30,7 +30,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.csv.ValueFormatter;
import java.util.List;
import java.util.Map;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MarineLitterRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MarineLitterRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MarineLitterRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -29,7 +29,7 @@
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.csv.ValueFormatter;
import java.util.List;
import java.util.Map;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -37,7 +37,18 @@
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.*;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
@@ -49,13 +60,10 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.vfs2.AllFileSelector;
-import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.lang3.tuple.Pair;
+import org.nuiton.csv.Export;
+import org.nuiton.csv.Import;
import org.nuiton.util.ZipUtil;
-import org.nuiton.util.csv.Export;
-import org.nuiton.util.csv.Import;
import java.io.BufferedWriter;
import java.io.File;
@@ -64,7 +72,10 @@
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
-import java.util.*;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
import static org.nuiton.i18n.I18n._;
@@ -76,8 +87,8 @@
*/
public class TuttiMultiPostImportExportService extends AbstractTuttiService {
- private static final Log log =
- LogFactory.getLog(TuttiMultiPostImportExportService.class);
+// private static final Log log =
+// LogFactory.getLog(TuttiMultiPostImportExportService.class);
public static final String BATCHES_KEY = "batchesKey";
@@ -107,7 +118,7 @@
protected char csvSeparator;
- protected List<SampleCategoryEnum> samplingOrder;
+// protected List<SampleCategoryEnum> samplingOrder;
@Override
public void setServiceContext(TuttiServiceContext context) {
@@ -117,19 +128,19 @@
csvSeparator = context.getConfig().getCsvSeparator();
- Map<Integer, SampleCategoryEnum> idMapping = SampleCategoryEnum.toIdMapping();
-
- samplingOrder = Lists.newArrayList();
-
- // always first sampling category
- samplingOrder.add(SampleCategoryEnum.sortedUnsorted);
-
- for (Integer categoryId : context.getConfig().getSamplingOrderIds()) {
- SampleCategoryEnum categoryEnum = idMapping.get(categoryId);
- if (SampleCategoryEnum.sortedUnsorted != categoryEnum) {
- samplingOrder.add(categoryEnum);
- }
- }
+// Map<Integer, SampleCategoryEnum> idMapping = SampleCategoryEnum.toIdMapping();
+//
+// samplingOrder = Lists.newArrayList();
+//
+// // always first sampling category
+// samplingOrder.add(SampleCategoryEnum.sortedUnsorted);
+//
+// for (Integer categoryId : context.getConfig().getSamplingOrderIds()) {
+// SampleCategoryEnum categoryEnum = idMapping.get(categoryId);
+// if (SampleCategoryEnum.sortedUnsorted != categoryEnum) {
+// samplingOrder.add(categoryEnum);
+// }
+// }
}
/**
@@ -565,11 +576,11 @@
batch.setComment(row.getComment());
batch.setSpeciesToConfirm(row.isToConfirm());
- Object[] valueAndCategoryType = getValueAndCategoryType(row);
- SampleCategoryEnum categoryType = (SampleCategoryEnum) valueAndCategoryType[0];
- Serializable value = (Serializable) valueAndCategoryType[1];
+ Pair<Integer, Serializable> valueAndCategoryType = getValueAndCategoryType(row);
+ Integer categoryId = valueAndCategoryType.getKey();
+ Serializable value = valueAndCategoryType.getValue();
- batch.setSampleCategoryType(categoryType);
+ batch.setSampleCategoryId(categoryId);
batch.setSampleCategoryValue(value);
batch.setSampleCategoryWeight(row.getCategoryWeight());
@@ -595,7 +606,7 @@
if (batchesToBrowse != null) {
for (SpeciesBatch sb : batchesToBrowse) {
if (sb.getSpecies().equals(species)
- && (!sb.getSampleCategoryType().equals(batch.getSampleCategoryType())
+ && (!sb.getSampleCategoryId().equals(batch.getSampleCategoryId())
|| sb.getSampleCategoryValue().equals(value))) {
existingBatch = sb;
@@ -771,11 +782,12 @@
batch.setComment(row.getComment());
batch.setSpeciesToConfirm(row.isToConfirm());
- Object[] valueAndCategoryType = getValueAndCategoryType(row);
- SampleCategoryEnum categoryType = (SampleCategoryEnum) valueAndCategoryType[0];
- Serializable value = (Serializable) valueAndCategoryType[1];
+ Pair<Integer, Serializable> valueAndCategoryType = getValueAndCategoryType(row);
+ Integer categoryId = valueAndCategoryType.getKey();
+ Serializable value = valueAndCategoryType.getValue();
- batch.setSampleCategoryType(categoryType);
+ batch.setSampleCategoryId(categoryId);
+// batch.setSampleCategoryType(categoryType);
batch.setSampleCategoryValue(value);
batch.setSampleCategoryWeight(row.getCategoryWeight());
@@ -801,7 +813,7 @@
if (batchesToBrowse != null) {
for (BenthosBatch bb : batchesToBrowse) {
if (bb.getSpecies().equals(species)
- && (!bb.getSampleCategoryType().equals(batch.getSampleCategoryType())
+ && (!bb.getSampleCategoryId().equals(batch.getSampleCategoryId())
|| bb.getSampleCategoryValue().equals(value))) {
existingBatch = bb;
@@ -1368,23 +1380,26 @@
row.setParentId(parentId);
row.setSpecies(batch.getSpecies());
- switch (batch.getSampleCategoryType()) {
- case sortedUnsorted:
- row.setSortedUnsortedSampleCategory(batch.getSampleCategoryValue());
- break;
- case sex:
- row.setSexSampleCategory(batch.getSampleCategoryValue());
- break;
- case size:
- row.setSizeSampleCategory(batch.getSampleCategoryValue());
- break;
- case maturity:
- row.setMaturitySampleCategory(batch.getSampleCategoryValue());
- break;
- case age:
- row.setAgeSampleCategory(batch.getSampleCategoryValue());
- break;
- }
+ row.setCategoryId(batch.getSampleCategoryId());
+ row.setCategoryValue(batch.getSampleCategoryValue());
+
+// switch (batch.getSampleCategoryType()) {
+// case sortedUnsorted:
+// row.setSortedUnsortedSampleCategory(batch.getSampleCategoryValue());
+// break;
+// case sex:
+// row.setSexSampleCategory(batch.getSampleCategoryValue());
+// break;
+// case size:
+// row.setSizeSampleCategory(batch.getSampleCategoryValue());
+// break;
+// case maturity:
+// row.setMaturitySampleCategory(batch.getSampleCategoryValue());
+// break;
+// case age:
+// row.setAgeSampleCategory(batch.getSampleCategoryValue());
+// break;
+// }
row.setCategoryWeight(batch.getSampleCategoryWeight());
row.setWeight(batch.getWeight());
row.setNumber(batch.getNumber());
@@ -1413,23 +1428,26 @@
row.setParentId(parentId);
row.setSpecies(batch.getSpecies());
- switch (batch.getSampleCategoryType()) {
- case sortedUnsorted:
- row.setSortedUnsortedSampleCategory(batch.getSampleCategoryValue());
- break;
- case sex:
- row.setSexSampleCategory(batch.getSampleCategoryValue());
- break;
- case size:
- row.setSizeSampleCategory(batch.getSampleCategoryValue());
- break;
- case maturity:
- row.setMaturitySampleCategory(batch.getSampleCategoryValue());
- break;
- case age:
- row.setAgeSampleCategory(batch.getSampleCategoryValue());
- break;
- }
+ row.setCategoryId(batch.getSampleCategoryId());
+ row.setCategoryValue(batch.getSampleCategoryValue());
+
+// switch (batch.getSampleCategoryType()) {
+// case sortedUnsorted:
+// row.setSortedUnsortedSampleCategory(batch.getSampleCategoryValue());
+// break;
+// case sex:
+// row.setSexSampleCategory(batch.getSampleCategoryValue());
+// break;
+// case size:
+// row.setSizeSampleCategory(batch.getSampleCategoryValue());
+// break;
+// case maturity:
+// row.setMaturitySampleCategory(batch.getSampleCategoryValue());
+// break;
+// case age:
+// row.setAgeSampleCategory(batch.getSampleCategoryValue());
+// break;
+// }
row.setCategoryWeight(batch.getSampleCategoryWeight());
row.setWeight(batch.getWeight());
row.setNumber(batch.getNumber());
@@ -1517,47 +1535,49 @@
}
}
- protected Object[] getValueAndCategoryType(CatchRow row) {
+ protected Pair<Integer, Serializable> getValueAndCategoryType(CatchRow row) {
- String sortedUnsortedValue = (String) row.getSortedUnsortedSampleCategory();
- String sizeValue = (String) row.getSizeSampleCategory();
- String sexValue = (String) row.getSexSampleCategory();
- String maturityValue = (String) row.getMaturitySampleCategory();
- String ageValue = (String) row.getAgeSampleCategory();
+// String sortedUnsortedValue = (String) row.getSortedUnsortedSampleCategory();
+// String sizeValue = (String) row.getSizeSampleCategory();
+// String sexValue = (String) row.getSexSampleCategory();
+// String maturityValue = (String) row.getMaturitySampleCategory();
+// String ageValue = (String) row.getAgeSampleCategory();
- Serializable value = null;
- SampleCategoryEnum categoryType = null;
+ Serializable value = row.getCategoryValue();
+ Integer categoryId = row.getCategoryId();
+// SampleCategoryEnum categoryType = null;
+//
+// if (StringUtils.isNotEmpty(sortedUnsortedValue)) {
+// Integer id = Integer.parseInt(sortedUnsortedValue);
+// Caracteristic caracteristic = persistenceService.getSortedUnsortedCaracteristic();
+// value = TuttiEntities.getQualitativeValue(caracteristic, id);
+// categoryType = SampleCategoryEnum.sortedUnsorted;
+//
+// } else if (StringUtils.isNotEmpty(sizeValue)) {
+// Integer id = Integer.parseInt(sizeValue);
+// Caracteristic caracteristic = persistenceService.getSizeCategoryCaracteristic();
+// value = TuttiEntities.getQualitativeValue(caracteristic, id);
+// categoryType = SampleCategoryEnum.size;
+//
+// } else if (StringUtils.isNotEmpty(sexValue)) {
+// Integer id = Integer.parseInt(sexValue);
+// Caracteristic caracteristic = persistenceService.getSexCaracteristic();
+// value = TuttiEntities.getQualitativeValue(caracteristic, id);
+// categoryType = SampleCategoryEnum.sex;
+//
+// } else if (StringUtils.isNotEmpty(maturityValue)) {
+// Integer id = Integer.parseInt(maturityValue);
+// Caracteristic caracteristic = persistenceService.getMaturityCaracteristic();
+// value = TuttiEntities.getQualitativeValue(caracteristic, id);
+// categoryType = SampleCategoryEnum.maturity;
+//
+// } else if (StringUtils.isNotEmpty(ageValue)) {
+// categoryType = SampleCategoryEnum.age;
+// value = Float.parseFloat(ageValue);
+// }
- if (StringUtils.isNotEmpty(sortedUnsortedValue)) {
- Integer id = Integer.parseInt(sortedUnsortedValue);
- Caracteristic caracteristic = persistenceService.getSortedUnsortedCaracteristic();
- value = TuttiEntities.getQualitativeValue(caracteristic, id);
- categoryType = SampleCategoryEnum.sortedUnsorted;
-
- } else if (StringUtils.isNotEmpty(sizeValue)) {
- Integer id = Integer.parseInt(sizeValue);
- Caracteristic caracteristic = persistenceService.getSizeCategoryCaracteristic();
- value = TuttiEntities.getQualitativeValue(caracteristic, id);
- categoryType = SampleCategoryEnum.size;
-
- } else if (StringUtils.isNotEmpty(sexValue)) {
- Integer id = Integer.parseInt(sexValue);
- Caracteristic caracteristic = persistenceService.getSexCaracteristic();
- value = TuttiEntities.getQualitativeValue(caracteristic, id);
- categoryType = SampleCategoryEnum.sex;
-
- } else if (StringUtils.isNotEmpty(maturityValue)) {
- Integer id = Integer.parseInt(maturityValue);
- Caracteristic caracteristic = persistenceService.getMaturityCaracteristic();
- value = TuttiEntities.getQualitativeValue(caracteristic, id);
- categoryType = SampleCategoryEnum.maturity;
-
- } else if (StringUtils.isNotEmpty(ageValue)) {
- categoryType = SampleCategoryEnum.age;
- value = Float.parseFloat(ageValue);
- }
-
- return new Object[]{categoryType, value};
+// return new Object[]{categoryType, value};
+ return Pair.of(categoryId, value);
}
protected void importAttachments(File directory,
@@ -1612,9 +1632,9 @@
if (iterator.hasNext()) {
AbstractFishingOperationRow row = iterator.next();
if (ObjectUtils.notEqual(row.getStationNumber(), operation.getStationNumber())
- || ObjectUtils.notEqual(row.getOperationNumber(), operation.getFishingOperationNumber())
- || ObjectUtils.notEqual(row.getMultirigAggregation(), operation.getMultirigAggregation())
- || ObjectUtils.notEqual(row.getDate(), operation.getGearShootingStartDate())) {
+ || ObjectUtils.notEqual(row.getOperationNumber(), operation.getFishingOperationNumber())
+ || ObjectUtils.notEqual(row.getMultirigAggregation(), operation.getMultirigAggregation())
+ || ObjectUtils.notEqual(row.getDate(), operation.getGearShootingStartDate())) {
throw new TuttiBusinessException(_("tutti.service.multipost.import.wrongOperation.error",
decoratorService.getDecoratorByType(FishingOperation.class)
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfig.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfig.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfig.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,7 +27,7 @@
import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
import org.nuiton.util.Version;
-import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.config.ApplicationConfig;
import java.io.File;
import java.net.URL;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigOption.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigOption.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigOption.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,7 +25,7 @@
*/
import org.nuiton.util.Version;
-import org.nuiton.util.config.ConfigOptionDef;
+import org.nuiton.config.ConfigOptionDef;
import java.io.File;
import java.net.URL;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigProvider.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigProvider.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigProvider.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,9 +24,9 @@
* #L%
*/
-import org.nuiton.util.config.ApplicationConfigProvider;
-import org.nuiton.util.config.ConfigActionDef;
-import org.nuiton.util.config.ConfigOptionDef;
+import org.nuiton.config.ApplicationConfigProvider;
+import org.nuiton.config.ConfigActionDef;
+import org.nuiton.config.ConfigOptionDef;
import java.util.Locale;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -31,7 +31,8 @@
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -44,7 +45,6 @@
import java.io.Serializable;
import java.util.List;
-import java.util.Map;
/**
* Model of a catch export.
@@ -56,14 +56,13 @@
public static final String WEIGHT_OR_VOL_TYPE = "Poids";
- Map<SampleCategoryEnum, Caracteristic> sampleCategoryToCaracteristics;
+ protected SampleCategoryModel sampleCategoryModel;
public CatchExportModel(char separator,
- List<SampleCategoryEnum> samplingOrder,
- Map<SampleCategoryEnum, Caracteristic> sampleCategoryToCaracteristics,
+ SampleCategoryModel sampleCategoryModel,
DecoratorService decoratorService) {
super(separator);
- this.sampleCategoryToCaracteristics = sampleCategoryToCaracteristics;
+ this.sampleCategoryModel = sampleCategoryModel;
newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
@@ -77,27 +76,31 @@
newColumnForExport("Nom_scientifique", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
newColumnForExport("Commentaire", SpeciesBatch.PROPERTY_COMMENT);
- for (SampleCategoryEnum sampleCategoryEnum : samplingOrder) {
- switch (sampleCategoryEnum) {
-
- case sortedUnsorted:
- addSampleCategory("VracHorsVrac", CatchExportRow.SORTED_UNSORTED_SAMPLE_CATEGORY);
- break;
- case size:
- addSampleCategory("Cat_Tri", CatchExportRow.SIZE_SAMPLE_CATEGORY);
- break;
- case sex:
- addSampleCategory("Sexe", CatchExportRow.SEX_SAMPLE_CATEGORY);
- break;
- case maturity:
- addSampleCategory("Maturite", CatchExportRow.MATURITY_SAMPLE_CATEGORY);
- break;
- case age:
- addSampleCategory("Age", CatchExportRow.AGE_SAMPLE_CATEGORY);
- break;
- }
+ for (SampleCategoryModelEntry entry : sampleCategoryModel.getCategory()) {
+ addSampleCategory(entry.getLabel(), entry.getOrder());
}
+// for (SampleCategoryEnum sampleCategoryEnum : samplingOrder) {
+// switch (sampleCategoryEnum) {
+//
+// case sortedUnsorted:
+// addSampleCategory("VracHorsVrac", CatchExportRow.SORTED_UNSORTED_SAMPLE_CATEGORY);
+// break;
+// case size:
+// addSampleCategory("Cat_Tri", CatchExportRow.SIZE_SAMPLE_CATEGORY);
+// break;
+// case sex:
+// addSampleCategory("Sexe", CatchExportRow.SEX_SAMPLE_CATEGORY);
+// break;
+// case maturity:
+// addSampleCategory("Maturite", CatchExportRow.MATURITY_SAMPLE_CATEGORY);
+// break;
+// case age:
+// addSampleCategory("Age", CatchExportRow.AGE_SAMPLE_CATEGORY);
+// break;
+// }
+// }
+
// mensuration
newNullableColumnForExport("Code_Longueur", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_ID);
@@ -132,11 +135,11 @@
row.setSpecies(speciesBatch.getSpecies());
row.setBatchWeightUnit(batchWeightUnit);
- if (TuttiEntities.isVracSpeciesBatch(speciesBatch)) {
+ if (persistenceService.isVracSpeciesBatch(speciesBatch)) {
// compute species total weight in catch
- float sortedBatchWeight = TuttiExportService.getValueOrComputedValue(
+ float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
speciesBatch.getSampleCategoryWeight(),
speciesBatch.getSampleCategoryComputedWeight());
@@ -160,11 +163,11 @@
row.setSpecies(benthosBatch.getSpecies());
row.setBatchWeightUnit(batchWeightUnit);
- if (TuttiEntities.isVracBenthosBatch(benthosBatch)) {
+ if (persistenceService.isVracBenthosBatch(benthosBatch)) {
// compute species total weight in catch
- float sortedBatchWeight = TuttiExportService.getValueOrComputedValue(
+ float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
benthosBatch.getSampleCategoryWeight(),
benthosBatch.getSampleCategoryComputedWeight());
@@ -191,7 +194,7 @@
currentRow.addComment(speciesBatch.getComment());
prepareBatch(currentRow,
- speciesBatch.getSampleCategoryType(),
+ speciesBatch.getSampleCategoryId(),
speciesBatch.getSampleCategoryValue(),
speciesBatch.getSampleCategoryWeight(),
speciesBatch.getSampleCategoryComputedWeight(),
@@ -214,13 +217,13 @@
// Get reference weight
- Float referenceWeight = TuttiExportService.getValueOrComputedValue(
+ Float referenceWeight = TuttiEntities.getValueOrComputedValue(
speciesBatch.getWeight(),
speciesBatch.getComputedWeight());
if (referenceWeight == null) {
- referenceWeight = TuttiExportService.getValueOrComputedValue(
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
speciesBatch.getSampleCategoryWeight(),
speciesBatch.getSampleCategoryComputedWeight());
}
@@ -239,12 +242,12 @@
// no weight on frequencies use upper reference weight
- referenceWeight = TuttiExportService.getValueOrComputedValue(
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
speciesBatch.getWeight(),
speciesBatch.getComputedWeight());
if (referenceWeight == null) {
- referenceWeight = TuttiExportService.getValueOrComputedValue(
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
speciesBatch.getSampleCategoryWeight(),
speciesBatch.getSampleCategoryComputedWeight());
}
@@ -286,9 +289,8 @@
SpeciesBatch speciesBatch) {
-
prepareBatch(currentRow,
- speciesBatch.getSampleCategoryType(),
+ speciesBatch.getSampleCategoryId(),
speciesBatch.getSampleCategoryValue(),
speciesBatch.getSampleCategoryWeight(),
speciesBatch.getSampleCategoryComputedWeight(),
@@ -298,7 +300,7 @@
CatchExportRow row = currentRow.copy();
row.addComment(speciesBatch.getComment());
- float referenceWeight = TuttiExportService.getValueOrComputedValue(
+ float referenceWeight = TuttiEntities.getValueOrComputedValue(
speciesBatch.getSampleCategoryWeight(),
speciesBatch.getSampleCategoryComputedWeight());
@@ -315,7 +317,7 @@
currentRow.addComment(benthosBatch.getComment());
prepareBatch(currentRow,
- benthosBatch.getSampleCategoryType(),
+ benthosBatch.getSampleCategoryId(),
benthosBatch.getSampleCategoryValue(),
benthosBatch.getSampleCategoryWeight(),
benthosBatch.getSampleCategoryComputedWeight(),
@@ -338,12 +340,12 @@
// Get reference weight
- Float referenceWeight = TuttiExportService.getValueOrComputedValue(
+ Float referenceWeight = TuttiEntities.getValueOrComputedValue(
benthosBatch.getWeight(),
benthosBatch.getComputedWeight());
if (referenceWeight == null) {
- referenceWeight = TuttiExportService.getValueOrComputedValue(
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
benthosBatch.getSampleCategoryWeight(),
benthosBatch.getSampleCategoryComputedWeight());
}
@@ -363,12 +365,12 @@
// no weight on frequencies use upper reference weight
- referenceWeight = TuttiExportService.getValueOrComputedValue(
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
benthosBatch.getWeight(),
benthosBatch.getComputedWeight());
if (referenceWeight == null) {
- referenceWeight = TuttiExportService.getValueOrComputedValue(
+ referenceWeight = TuttiEntities.getValueOrComputedValue(
benthosBatch.getSampleCategoryWeight(),
benthosBatch.getSampleCategoryComputedWeight());
}
@@ -409,7 +411,7 @@
BenthosBatch benthosBatch) {
prepareBatch(currentRow,
- benthosBatch.getSampleCategoryType(),
+ benthosBatch.getSampleCategoryId(),
benthosBatch.getSampleCategoryValue(),
benthosBatch.getSampleCategoryWeight(),
benthosBatch.getSampleCategoryComputedWeight(),
@@ -420,7 +422,7 @@
CatchExportRow row = currentRow.copy();
row.addComment(benthosBatch.getComment());
- float referenceWeight = TuttiExportService.getValueOrComputedValue(
+ float referenceWeight = TuttiEntities.getValueOrComputedValue(
benthosBatch.getSampleCategoryWeight(),
benthosBatch.getSampleCategoryComputedWeight());
@@ -437,7 +439,7 @@
}
protected void prepareBatch(CatchExportRow currentRow,
- SampleCategoryEnum sampleCategoryType,
+ Integer sampleCategoryId,
Serializable sampleCategoryValue,
Float sampleCategoryWeight,
Float sampleCategoryComputedWeight,
@@ -448,9 +450,9 @@
ExportSampleCategory<Serializable> sampleCategory =
new ExportSampleCategory<Serializable>();
- Caracteristic caracteristic = sampleCategoryToCaracteristics.get(sampleCategoryType);
- sampleCategory.setCategoryCaracteristic(caracteristic);
- sampleCategory.setCategoryType(sampleCategoryType);
+ SampleCategoryModelEntry categoryById =
+ sampleCategoryModel.getCategoryById(sampleCategoryId);
+ sampleCategory.setCategoryDef(categoryById);
sampleCategory.setCategoryValue(sampleCategoryValue);
sampleCategory.setCategoryWeight(sampleCategoryWeight);
sampleCategory.setSampleWeight(batchWeight);
@@ -459,15 +461,25 @@
sampleCategory.setWeightOrVolType(WEIGHT_OR_VOL_TYPE);
sampleCategory.setRankOrder(batchRankOrder);
- currentRow.addCategory(sampleCategory);
+ currentRow.addSampleCategory(sampleCategory);
}
- protected void addSampleCategory(String headerPrefix, String categoryName) {
- newNullableColumnForExport(headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- newNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName + "." + ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
- newNullableColumnForExport("Tot_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Ech_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE);
+ protected void addSampleCategory(String headerPrefix, int categoryOrder) {
+// String categoryName = CatchExportRow.SAMPLE_CATEGORY + "[" + categoryOrder + "]";
+// newNullableColumnForExport(headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+// newNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName + "." + ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
+// newNullableColumnForExport("Tot_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT);
+// newNullableColumnForExport("Ech_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT);
+// newNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE);
+// newNullableColumnForExport("Unite_Volume_Poids_" + headerPrefix, CatchExportRow.BATCH_WEIGHT_UNIT);
+
+
+ String categoryName = CatchExportRow.SAMPLE_CATEGORY;
+ newIndexNullableColumnForExport(headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
+ newIndexNullableColumnForExport("Tot_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT);
+ newIndexNullableColumnForExport("Ech_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT);
+ newIndexNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE);
newNullableColumnForExport("Unite_Volume_Poids_" + headerPrefix, CatchExportRow.BATCH_WEIGHT_UNIT);
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,12 +27,10 @@
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.persistence.entities.referential.Species;
@@ -44,7 +42,6 @@
import java.io.Serializable;
import java.util.Date;
import java.util.List;
-import java.util.Map;
/**
* A row in a catch export.
@@ -69,16 +66,8 @@
public static final String FREQUENCY_RANK_ORDER = "frequency.rankOrder";
- public static final String SORTED_UNSORTED_SAMPLE_CATEGORY = "sortedUnsortedSampleCategory";
+ public static final String SAMPLE_CATEGORY = "sampleCategory";
- public static final String SIZE_SAMPLE_CATEGORY = "sizeSampleCategory";
-
- public static final String SEX_SAMPLE_CATEGORY = "sexSampleCategory";
-
- public static final String MATURITY_SAMPLE_CATEGORY = "maturitySampleCategory";
-
- public static final String AGE_SAMPLE_CATEGORY = "ageSampleCategory";
-
public static final String REFERENCE_WEIGHT = "referenceWeight";
public static final String RAISING_FACTOR = "raisingFactor";
@@ -91,10 +80,8 @@
protected FishingOperation fishingOperation;
- protected ExportSampleCategory speciesCategory;
+ protected final List<ExportSampleCategory> sampleCategory = Lists.newLinkedList();
- protected final Map<SampleCategoryEnum, ExportSampleCategory> categories = Maps.newEnumMap(SampleCategoryEnum.class);
-
protected SpeciesBatchFrequency speciesFrequency;
protected BenthosBatchFrequency benthosFrequency;
@@ -119,10 +106,6 @@
this.fishingOperation = fishingOperation;
}
- public void setSpeciesCategory(ExportSampleCategory sampleCategory) {
- this.speciesCategory = sampleCategory;
- }
-
public void setReferenceWeight(float referenceWeight) {
this.referenceWeight = referenceWeight;
}
@@ -135,8 +118,12 @@
this.batchNumber = batchNumber;
}
- public void addCategory(ExportSampleCategory sampleCategory) {
- categories.put(sampleCategory.getCategoryType(), sampleCategory);
+ public void addSampleCategory(ExportSampleCategory sampleCategory) {
+ int order = sampleCategory.getCategoryDef().getOrder();
+ while (this.sampleCategory.size() <= order) {
+ this.sampleCategory.add(null);
+ }
+ this.sampleCategory.set(order, sampleCategory);
}
public void setSpeciesFrequency(SpeciesBatchFrequency speciesFrequency) {
@@ -187,30 +174,10 @@
return speciesFrequency == null ? benthosFrequency : speciesFrequency;
}
- public ExportSampleCategory getSpeciesSampleCategory() {
- return speciesCategory;
+ public List<ExportSampleCategory> getSampleCategory() {
+ return sampleCategory;
}
- public ExportSampleCategory getSortedUnsortedSampleCategory() {
- return categories.get(SampleCategoryEnum.sortedUnsorted);
- }
-
- public ExportSampleCategory getSizeSampleCategory() {
- return categories.get(SampleCategoryEnum.size);
- }
-
- public ExportSampleCategory getSexSampleCategory() {
- return categories.get(SampleCategoryEnum.sex);
- }
-
- public ExportSampleCategory getMaturitySampleCategory() {
- return categories.get(SampleCategoryEnum.maturity);
- }
-
- public ExportSampleCategory getAgeSampleCategory() {
- return categories.get(SampleCategoryEnum.age);
- }
-
public Species getSpecies() {
return species;
}
@@ -243,8 +210,8 @@
CatchExportRow result = new CatchExportRow();
result.setCruise(cruise);
result.setFishingOperation(fishingOperation);
- result.setSpeciesCategory(speciesCategory);
- result.categories.putAll(categories);
+// result.setSpeciesCategory(speciesCategory);
+ result.sampleCategory.addAll(sampleCategory);
if (benthosFrequency != null) {
result.setBenthosFrequency(benthosFrequency);
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportSampleCategory.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportSampleCategory.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportSampleCategory.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -58,34 +58,12 @@
public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
-// private Integer number;
-//
-// private Integer computedNumber;
-
private Integer rankOrder;
private String weightOrVolType;
private Float sampleWeight;
- private Caracteristic categoryCaracteristic;
-
-// public Integer getNumber() {
-// return number;
-// }
-//
-// public void setNumber(Integer number) {
-// this.number = number;
-// }
-//
-// public Integer getComputedNumber() {
-// return computedNumber;
-// }
-//
-// public void setComputedNumber(Integer computedNumber) {
-// this.computedNumber = computedNumber;
-// }
-
public String getWeightOrVolType() {
return weightOrVolType;
}
@@ -110,11 +88,8 @@
this.sampleWeight = sampleWeight;
}
- public void setCategoryCaracteristic(Caracteristic categoryCaracteristic) {
- this.categoryCaracteristic = categoryCaracteristic;
- }
-
public Caracteristic getCategoryCaracteristic() {
- return categoryCaracteristic;
+ return categoryDef.getCaracteristic();
}
+
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -279,210 +279,210 @@
}
public Float getCatchTotalWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getCatchTotalWeight(),
catchBatch.getCatchTotalComputedWeight());
}
public Boolean getCatchTotalWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getCatchTotalWeight(),
catchBatch.getCatchTotalComputedWeight());
}
public Float getCatchTotalSortedTremisWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getCatchTotalSortedTremisWeight(), null);
}
public Boolean getCatchTotalSortedTremisWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getCatchTotalSortedTremisWeight(), null);
}
public Float getCatchTotalSortedCarousselWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getCatchTotalSortedCarousselWeight(), null);
}
public Boolean getCatchTotalSortedCarousselWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getCatchTotalSortedCarousselWeight(), null);
}
public Float getCatchTotalSortedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
null, catchBatch.getCatchTotalSortedComputedWeight());
}
public Boolean getCatchTotalSortedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
null, catchBatch.getCatchTotalSortedComputedWeight());
}
public Float getCatchTotalUnsortedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
null, catchBatch.getCatchTotalUnsortedComputedWeight());
}
public Boolean getCatchTotalUnsortedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
null, catchBatch.getCatchTotalUnsortedComputedWeight());
}
public Float getCatchTotalRejectedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getCatchTotalRejectedWeight(),
catchBatch.getCatchTotalRejectedComputedWeight());
}
public Boolean getCatchTotalRejectedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getCatchTotalRejectedWeight(),
catchBatch.getCatchTotalRejectedComputedWeight());
}
public Float getSpeciesTotalWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
null, catchBatch.getSpeciesTotalComputedWeight());
}
public Boolean getSpeciesTotalWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
null, catchBatch.getSpeciesTotalComputedWeight());
}
public Float getSpeciesTotalSortedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getSpeciesTotalSortedWeight(),
catchBatch.getSpeciesTotalSortedComputedWeight());
}
public Boolean getSpeciesTotalSortedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getSpeciesTotalSortedWeight(),
catchBatch.getSpeciesTotalSortedComputedWeight());
}
public Float getSpeciesTotalUnsortedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
null, catchBatch.getSpeciesTotalUnsortedComputedWeight());
}
public Boolean getSpeciesTotalUnsortedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
null, catchBatch.getSpeciesTotalUnsortedComputedWeight());
}
public Float getSpeciesTotalSampleSortedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getSpeciesTotalSampleSortedComputedWeight(),
catchBatch.getSpeciesTotalSampleSortedComputedWeight());
}
public Boolean getSpeciesTotalSampleSortedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
null, catchBatch.getSpeciesTotalSampleSortedComputedWeight());
}
public Float getSpeciesTotalInertWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getSpeciesTotalInertWeight(),
catchBatch.getSpeciesTotalInertComputedWeight());
}
public Boolean getSpeciesTotalInertWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getSpeciesTotalInertWeight(),
catchBatch.getSpeciesTotalInertComputedWeight());
}
public Float getSpeciesTotalLivingNotItemizedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
}
public Boolean getSpeciesTotalLivingNotItemizedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
}
public Float getBenthosTotalWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
null, catchBatch.getBenthosTotalComputedWeight());
}
public Boolean getBenthosTotalWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
null, catchBatch.getBenthosTotalComputedWeight());
}
public Float getBenthosTotalSortedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getBenthosTotalSortedWeight(),
catchBatch.getBenthosTotalSortedComputedWeight());
}
public Boolean getBenthosTotalSortedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getBenthosTotalSortedWeight(),
catchBatch.getBenthosTotalSortedComputedWeight());
}
public Float getBenthosTotalUnsortedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
null, catchBatch.getBenthosTotalUnsortedComputedWeight());
}
public Boolean getBenthosTotalUnsortedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
null, catchBatch.getBenthosTotalUnsortedComputedWeight());
}
public Float getBenthosTotalSampleSortedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
null, catchBatch.getBenthosTotalSampleSortedComputedWeight());
}
public Boolean getBenthosTotalSampleSortedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
null, catchBatch.getBenthosTotalSampleSortedComputedWeight());
}
public Float getBenthosTotalInertWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getBenthosTotalInertWeight(),
catchBatch.getBenthosTotalInertComputedWeight());
}
public Boolean getBenthosTotalInertWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getBenthosTotalInertWeight(),
catchBatch.getBenthosTotalInertComputedWeight());
}
public Float getBenthosTotalLivingNotItemizedWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getBenthosTotalLivingNotItemizedWeight(),
catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
}
public Boolean getBenthosTotalLivingNotItemizedWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getBenthosTotalLivingNotItemizedWeight(),
catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
}
public Float getMarineLitterTotalWeight() {
- return TuttiExportService.getValueOrComputedValue(
+ return TuttiEntities.getValueOrComputedValue(
catchBatch.getMarineLitterTotalWeight(),
catchBatch.getMarineLitterTotalComputedWeight());
}
public Boolean getMarineLitterTotalWeightComputed() {
- return TuttiExportService.getValueOrComputedValueComputed(
+ return TuttiEntities.getValueOrComputedValueComputed(
catchBatch.getMarineLitterTotalWeight(),
catchBatch.getMarineLitterTotalComputedWeight());
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -41,7 +41,7 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -58,7 +58,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import java.io.BufferedWriter;
import java.io.Closeable;
@@ -101,10 +101,8 @@
protected TuttiLocation country;
- protected List<SampleCategoryEnum> samplingOrder;
+ protected SampleCategoryModel sampleCategoryModel;
- protected Map<SampleCategoryEnum, Caracteristic> samplingToCaracteristic;
-
protected Caracteristic sampleIdCaracteristic;
protected Caracteristic otolitheIdCaracteristic;
@@ -117,21 +115,6 @@
protected Caracteristic pmfmIdCaracteristic;
- public static Float getValueOrComputedValue(Float value, Float computedValue) {
- return value == null ? computedValue : value;
- }
-
- public static Boolean getValueOrComputedValueComputed(Float value, Float computedValue) {
- Boolean result;
- if (value == null) {
-
- result = computedValue == null ? null : true;
- } else {
- result = false;
- }
- return result;
- }
-
@Override
public void setServiceContext(TuttiServiceContext context) {
super.setServiceContext(context);
@@ -139,6 +122,8 @@
decoratorService = getService(DecoratorService.class);
tuttiWeightComputingService = getService(TuttiWeightComputingService.class);
+ sampleCategoryModel = context.getSampleCategoryModel();
+
csvSeparator = context.getConfig().getCsvSeparator();
verticalOpeningCaracteristic = persistenceService.getVerticalOpeningCaracteristic();
horizontalOpeningWingCaracteristic = persistenceService.getHorizontalOpeningWingCaracteristic();
@@ -153,32 +138,6 @@
List<TuttiLocation> allCountry = persistenceService.getAllCountry();
String countryId = context.getConfig().getExportCountryId();
country = TuttiEntities.splitById(allCountry).get(countryId);
-
- List<Caracteristic> allCaracteristic = persistenceService.getAllCaracteristicWithProtected();
- Map<String, Caracteristic> allCaracteristicById = TuttiEntities.splitById(allCaracteristic);
-
- samplingToCaracteristic = Maps.newEnumMap(SampleCategoryEnum.class);
-
- Map<Integer, SampleCategoryEnum> idMapping = SampleCategoryEnum.toIdMapping();
-
- samplingOrder = Lists.newArrayList();
-
- // always first sampling category
- samplingOrder.add(SampleCategoryEnum.sortedUnsorted);
-
- samplingToCaracteristic.put(
- SampleCategoryEnum.sortedUnsorted,
- allCaracteristicById.get(SampleCategoryEnum.sortedUnsorted.getFieldValue().toString()));
-
- for (Integer categoryId : context.getConfig().getSamplingOrderIds()) {
- SampleCategoryEnum categoryEnum = idMapping.get(categoryId);
- if (SampleCategoryEnum.sortedUnsorted != categoryEnum) {
- samplingOrder.add(categoryEnum);
- }
- samplingToCaracteristic.put(
- categoryEnum,
- allCaracteristicById.get(categoryId.toString()));
- }
}
public void exportProgram(String programId,
@@ -280,8 +239,9 @@
deadOrAliveCaracteristic,
genderCaracteristic,
pmfmIdCaracteristic,
- samplingOrder,
- samplingToCaracteristic,
+ sampleCategoryModel,
+// samplingOrder,
+// samplingToCaracteristic,
speciesById);
}
@@ -550,7 +510,7 @@
rootSpeciesBatch,
rootBenthosBatch);
- Float totalWeight = getValueOrComputedValue(
+ Float totalWeight = TuttiEntities.getValueOrComputedValue(
catchBatch.getCatchTotalWeight(),
catchBatch.getCatchTotalComputedWeight());
@@ -558,14 +518,14 @@
catchBatch.getCatchTotalUnsortedComputedWeight();
- Float totalSortedSpeciesWeight = getValueOrComputedValue(
+ Float totalSortedSpeciesWeight = TuttiEntities.getValueOrComputedValue(
catchBatch.getSpeciesTotalSortedWeight(),
catchBatch.getSpeciesTotalSortedComputedWeight());
Float totalSampleSortedSpeciesWeight =
catchBatch.getSpeciesTotalSampleSortedComputedWeight();
- Float totalSortedBenthosWeight = getValueOrComputedValue(
+ Float totalSortedBenthosWeight = TuttiEntities.getValueOrComputedValue(
catchBatch.getBenthosTotalSortedWeight(),
catchBatch.getBenthosTotalSortedComputedWeight());
@@ -717,8 +677,7 @@
Caracteristic deadOrAliveCaracteristic,
Caracteristic genderCaracteristic,
Caracteristic pmfmIdCaracteristic,
- List<SampleCategoryEnum> samplingOrder,
- Map<SampleCategoryEnum, Caracteristic> samplingToCaracteristic,
+ SampleCategoryModel sampleCategoryModel,
Map<String, Species> speciesById) {
this.speciesById = speciesById;
@@ -774,8 +733,7 @@
marineLitterModel = new MarineLitterExportModel(csvSeparator);
catchModel = new CatchExportModel(csvSeparator,
- samplingOrder,
- samplingToCaracteristic,
+ sampleCategoryModel,
decoratorService);
accidentalCatchModel = new AccidentalCatchExportModel(
csvSeparator,
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/CaracteristicRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/CaracteristicRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/CaracteristicRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,7 +27,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.Common;
+import org.nuiton.csv.Common;
import java.util.Map;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/SpeciesRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/SpeciesRow.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/SpeciesRow.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -31,6 +31,7 @@
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
+import java.util.List;
/**
* Row of a {@link SpeciesProtocol} to import or export.
@@ -52,14 +53,6 @@
public static final String PROPERTY_SPECIES_SURVEY_CODE = "speciesSurveyCode";
- public static final String PROPERTY_SIZE_ENABLED = "sizeEnabled";
-
- public static final String PROPERTY_SEX_ENABLED = "sexEnabled";
-
- public static final String PROPERTY_MATURITY_ENABLED = "maturityEnabled";
-
- public static final String PROPERTY_AGE_ENABLED = "ageEnabled";
-
public static final String PROPERTY_LENGTH_STEP_PMFM = "lengthStepPmfm";
public static final String PROPERTY_LENGTH_STEP_PMFM_PARAMETER_NAME = "lengthStepPmfmParameterName";
@@ -78,6 +71,8 @@
public static final String PROPERTY_CALCIFY_SAMPLE_ENABLED = "calcifySampleEnabled";
+ public static final String PROPERTY_MANDATORY_SAMPLE_CATEGORY_ID = "mandatorySampleCategoryId";
+
protected final SpeciesProtocol delegate;
protected Species species;
@@ -163,38 +158,6 @@
return lengthStepPmfm == null ? null : lengthStepPmfm.getFractionName();
}
- public boolean isSizeEnabled() {
- return delegate.isSizeEnabled();
- }
-
- public void setSizeEnabled(boolean sizeEnabled) {
- delegate.setSizeEnabled(sizeEnabled);
- }
-
- public boolean isSexEnabled() {
- return delegate.isSexEnabled();
- }
-
- public void setSexEnabled(boolean sexEnabled) {
- delegate.setSexEnabled(sexEnabled);
- }
-
- public boolean isMaturityEnabled() {
- return delegate.isMaturityEnabled();
- }
-
- public void setMaturityEnabled(boolean maturityEnabled) {
- delegate.setMaturityEnabled(maturityEnabled);
- }
-
- public boolean isAgeEnabled() {
- return delegate.isAgeEnabled();
- }
-
- public void setAgeEnabled(boolean ageEnabled) {
- delegate.setAgeEnabled(ageEnabled);
- }
-
public boolean isWeightEnabled() {
return delegate.isWeightEnabled();
}
@@ -234,4 +197,12 @@
public String getId() {
return delegate.getId();
}
+
+ public void setMandatorySampleCategoryId(List<Integer> mandatorySampleCategoryId) {
+ delegate.setMandatorySampleCategoryId(mandatorySampleCategoryId);
+ }
+
+ public List<Integer> getMandatorySampleCategoryId() {
+ return delegate.getMandatorySampleCategoryId();
+ }
}
\ No newline at end of file
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/SpeciesRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/SpeciesRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/SpeciesRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -29,7 +29,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.Common;
+import org.nuiton.csv.Common;
import java.text.ParseException;
import java.util.Map;
@@ -88,10 +88,7 @@
newIgnoredColumn(SpeciesRow.PROPERTY_LENGTH_STEP_PMFM_METHOD_NAME);
newMandatoryColumn(SpeciesRow.PROPERTY_SPECIES_SURVEY_CODE, new TuttiCsvUtil.StringParserFormatter(null, true));
- newMandatoryColumn(SpeciesRow.PROPERTY_SIZE_ENABLED, Common.PRIMITIVE_BOOLEAN);
- newMandatoryColumn(SpeciesRow.PROPERTY_SEX_ENABLED, Common.PRIMITIVE_BOOLEAN);
- newMandatoryColumn(SpeciesRow.PROPERTY_MATURITY_ENABLED, Common.PRIMITIVE_BOOLEAN);
- newMandatoryColumn(SpeciesRow.PROPERTY_AGE_ENABLED, Common.PRIMITIVE_BOOLEAN);
+ newMandatoryColumn(SpeciesRow.PROPERTY_MANDATORY_SAMPLE_CATEGORY_ID, TuttiCsvUtil.LIST_INTEGER_PARSER_FORMATTER);
newMandatoryColumn(SpeciesRow.PROPERTY_WEIGHT_ENABLED, Common.PRIMITIVE_BOOLEAN);
newMandatoryColumn(SpeciesRow.PROPERTY_COUNT_IF_NO_FREQUENCY_ENABLED, Common.PRIMITIVE_BOOLEAN);
newMandatoryColumn(SpeciesRow.PROPERTY_CALCIFY_SAMPLE_ENABLED, Common.PRIMITIVE_BOOLEAN);
@@ -107,11 +104,7 @@
newColumnForExport(SpeciesRow.PROPERTY_LENGTH_STEP_PMFM_MATRIX_NAME);
newColumnForExport(SpeciesRow.PROPERTY_LENGTH_STEP_PMFM_FRACTION_NAME);
newColumnForExport(SpeciesRow.PROPERTY_LENGTH_STEP_PMFM_METHOD_NAME);
-
- newColumnForExport(SpeciesRow.PROPERTY_SIZE_ENABLED, Common.PRIMITIVE_BOOLEAN);
- newColumnForExport(SpeciesRow.PROPERTY_SEX_ENABLED, Common.PRIMITIVE_BOOLEAN);
- newColumnForExport(SpeciesRow.PROPERTY_MATURITY_ENABLED, Common.PRIMITIVE_BOOLEAN);
- newColumnForExport(SpeciesRow.PROPERTY_AGE_ENABLED, Common.PRIMITIVE_BOOLEAN);
+ newColumnForExport(SpeciesRow.PROPERTY_MANDATORY_SAMPLE_CATEGORY_ID, TuttiCsvUtil.LIST_INTEGER_PARSER_FORMATTER);
newColumnForExport(SpeciesRow.PROPERTY_WEIGHT_ENABLED, Common.PRIMITIVE_BOOLEAN);
newColumnForExport(SpeciesRow.PROPERTY_COUNT_IF_NO_FREQUENCY_ENABLED, Common.PRIMITIVE_BOOLEAN);
newColumnForExport(SpeciesRow.PROPERTY_CALCIFY_SAMPLE_ENABLED, Common.PRIMITIVE_BOOLEAN);
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -34,21 +34,25 @@
import com.google.common.io.Files;
import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiServiceContext;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.csv.Export;
+import org.nuiton.csv.Import;
+import org.nuiton.csv.ImportRuntimeException;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
-import org.nuiton.util.csv.Export;
-import org.nuiton.util.csv.Import;
-import org.nuiton.util.csv.ImportRuntimeException;
import java.io.BufferedWriter;
import java.io.File;
@@ -72,12 +76,24 @@
private static final Log log =
LogFactory.getLog(TuttiProtocolImportExportService.class);
+ protected SampleCategoryModel sampleCategoryModel;
+
+ protected TuttiEnumerationFile enumerationFile;
+
+ @Override
+ public void setServiceContext(TuttiServiceContext context) {
+ super.setServiceContext(context);
+ PersistenceService service = getService(PersistenceService.class);
+ sampleCategoryModel = context.getDataContext().getSampleCategoryModel();
+ enumerationFile = service.getEnumerationFile();
+ }
+
public void exportProtocol(TuttiProtocol protocol, File file) {
TuttiProtocols.toFile(protocol, file);
}
public TuttiProtocol importProtocol(File file) {
- TuttiProtocol result = TuttiProtocols.fromFile(file);
+ TuttiProtocol result = TuttiProtocols.fromFile(enumerationFile, file);
return result;
}
@@ -258,6 +274,8 @@
sp = TuttiBeanFactory.newSpeciesProtocol();
}
binder.copy(bean, sp);
+ sp.setMandatorySampleCategoryId(Lists.newArrayList(
+ bean.getMandatorySampleCategoryId()));
ids.put(id, sp);
}
@@ -499,6 +517,8 @@
result.setLengthStepPmfm(caracteristic);
}
result.setSpecies(species);
+ // always use a copy of list
+ result.setMandatorySampleCategoryId(Lists.newArrayList(input.getMandatorySampleCategoryId()));
return result;
}
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,7 +26,7 @@
import fr.ifremer.tutti.service.TuttiCsvUtil;
import org.apache.commons.lang3.StringUtils;
-import org.nuiton.util.csv.ValueParser;
+import org.nuiton.csv.ValueParser;
import java.text.ParseException;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,7 +25,7 @@
*/
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.ValueParser;
+import org.nuiton.csv.ValueParser;
import java.text.ParseException;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -41,14 +41,11 @@
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.data.SexEnum;
-import fr.ifremer.tutti.persistence.entities.data.SizeEnum;
-import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import fr.ifremer.tutti.service.AbstractTuttiService;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiDataContext;
@@ -59,14 +56,14 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.csv.Export;
-import org.nuiton.util.csv.Import;
+import org.nuiton.csv.Export;
+import org.nuiton.csv.Import;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
+import java.io.Serializable;
import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -107,27 +104,36 @@
persistenceService = getService(PersistenceService.class);
dataContext = context.getDataContext();
- // get the sorted/unsorted caracteristics
- Caracteristic sortedUnsortedcaracteristic =
- persistenceService.getSortedUnsortedCaracteristic();
- sortedCaracteristic = SortedUnsortedEnum.SORTED.getValue(sortedUnsortedcaracteristic);
- unsortedCaracteristic = SortedUnsortedEnum.UNSORTED.getValue(sortedUnsortedcaracteristic);
+ TuttiEnumerationFile enumerationFile =
+ persistenceService.getEnumerationFile();
- Caracteristic sexCaracteristic = persistenceService.getSexCaracteristic();
- maleCaracteristic = SexEnum.MALE.getValue(sexCaracteristic);
- femaleCaracteristic = SexEnum.FEMALE.getValue(sexCaracteristic);
+ { // sorted/unsorted caracteristic
+ Caracteristic caracteristic =
+ persistenceService.getSortedUnsortedCaracteristic();
- Caracteristic sizeCaracteristic = persistenceService.getSizeCategoryCaracteristic();
- smallCaracteristic = SizeEnum.SMALL.getValue(sizeCaracteristic);
- mediumCaracteristic = SizeEnum.MEDIUM.getValue(sizeCaracteristic);
- bigCaracteristic = SizeEnum.BIG.getValue(sizeCaracteristic);
+ sortedCaracteristic = TuttiEntities.getQualitativeValue(caracteristic, enumerationFile.QUALITATIVE_VRAC_ID);
+ unsortedCaracteristic = TuttiEntities.getQualitativeValue(caracteristic, enumerationFile.QUALITATIVE_HORS_VRAC_ID);
+ }
+
+ { // sex category
+ Caracteristic caracteristic = persistenceService.getSexCaracteristic();
+
+ maleCaracteristic = TuttiEntities.getQualitativeValue(caracteristic, enumerationFile.QUALITATIVE_SEX_MALE_ID);
+ femaleCaracteristic = TuttiEntities.getQualitativeValue(caracteristic, enumerationFile.QUALITATIVE_SEX_FEMALE_ID);
+ }
+ { // size category
+ Caracteristic caracteristic = persistenceService.getSizeCategoryCaracteristic();
+ smallCaracteristic = TuttiEntities.getQualitativeValue(caracteristic, enumerationFile.QUALITATIVE_SIZE_SMALL_ID);
+ mediumCaracteristic = TuttiEntities.getQualitativeValue(caracteristic, enumerationFile.QUALITATIVE_SIZE_MEDIUM_ID);
+ bigCaracteristic = TuttiEntities.getQualitativeValue(caracteristic, enumerationFile.QUALITATIVE_SIZE_BIG_ID);
+ }
}
/**
- * @param trunkFile
- * @param carrouselFile
- * @param operation
- * @param catchBatch
+ * @param trunkFile incoming trunk file
+ * @param carrouselFile incoming carroussle file
+ * @param operation target operation
+ * @param catchBatch target catch batch
* @return the number of rows of the .car file which have not been imported
*/
public int importPupitri(File trunkFile,
@@ -339,59 +345,63 @@
persistenceService.deleteSpeciesBatch(batch.getId());
}
+ TuttiEnumerationFile enumerationFile = persistenceService.getEnumerationFile();
+
for (PupitriCatch pupitriCatch : catches) {
Float catchWeight = pupitriCatch.getWeightBySign().get(PupitriCatch.Signs.DEFAULT);
CaracteristicQualitativeValue cqv = pupitriCatch.isSorted() ?
sortedCaracteristic : unsortedCaracteristic;
- SpeciesBatch batch = TuttiBeanFactory.newSpeciesBatch();
- batch.setFishingOperation(operation);
- batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
- batch.setSampleCategoryValue(cqv);
- batch.setSpecies(pupitriCatch.getSpecies());
- batch.setSampleCategoryWeight(catchWeight);
+ Species species = pupitriCatch.getSpecies();
+ SpeciesBatch batch = createSpeciesBatch(operation,
+ species,
+ catchWeight,
+ enumerationFile.PMFM_ID_SORTED_UNSORTED,
+ cqv);
+
batch = persistenceService.createSpeciesBatch(batch, null);
// if the batch is splitted
if (catchWeight == null) {
- SampleCategoryEnum category = null;
+ Integer categoryId = null;
for (PupitriCatch.Signs s : pupitriCatch.getWeightBySign().keySet()) {
CaracteristicQualitativeValue splitCqv = null;
switch (s) {
case MALE:
+ categoryId = enumerationFile.PMFM_ID_SEX;
splitCqv = maleCaracteristic;
- category = SampleCategoryEnum.sex;
break;
case FEMALE:
+ categoryId = enumerationFile.PMFM_ID_SEX;
splitCqv = femaleCaracteristic;
- category = SampleCategoryEnum.sex;
break;
case SMALL:
+ categoryId = enumerationFile.PMFM_ID_SIZE_CATEGORY;
splitCqv = smallCaracteristic;
- category = SampleCategoryEnum.size;
break;
case MEDIUM:
+ categoryId = enumerationFile.PMFM_ID_SIZE_CATEGORY;
splitCqv = mediumCaracteristic;
- category = SampleCategoryEnum.size;
break;
case BIG:
+ categoryId = enumerationFile.PMFM_ID_SIZE_CATEGORY;
splitCqv = bigCaracteristic;
- category = SampleCategoryEnum.size;
break;
}
- SpeciesBatch childBatch = TuttiBeanFactory.newSpeciesBatch();
- childBatch.setFishingOperation(operation);
- childBatch.setSampleCategoryType(category);
- childBatch.setSampleCategoryValue(splitCqv);
- childBatch.setSpecies(pupitriCatch.getSpecies());
- childBatch.setSampleCategoryWeight(pupitriCatch.getWeightBySign().get(s));
+ SpeciesBatch childBatch = createSpeciesBatch(
+ operation,
+ species,
+ pupitriCatch.getWeightBySign().get(s),
+ categoryId,
+ splitCqv
+ );
persistenceService.createSpeciesBatch(childBatch, batch.getId());
}
@@ -413,6 +423,7 @@
return result;
}
+
public void exportSpecies(List<Species> species, File target) {
SpeciesRowModel speciesCsvModel = new SpeciesRowModel(';');
@@ -443,6 +454,20 @@
}
}
+ protected SpeciesBatch createSpeciesBatch(FishingOperation operation,
+ Species species,
+ Float catchWeight,
+ Integer categoryId,
+ Serializable cqv) {
+ SpeciesBatch batch = TuttiBeanFactory.newSpeciesBatch();
+ batch.setFishingOperation(operation);
+ batch.setSampleCategoryId(categoryId);
+ batch.setSampleCategoryValue(cqv);
+ batch.setSpecies(species);
+ batch.setSampleCategoryWeight(catchWeight);
+ return batch;
+ }
+
protected File createFileWithHeaders(File file, String[] header, char separator) throws IOException {
File fileWithHeaders = new File(FileUtils.getTempDirectory(), file.getName());
String headers = StringUtils.join(header, separator);
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/GearModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/GearModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/GearModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,7 +27,7 @@
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.Common;
+import org.nuiton.csv.Common;
import java.util.Set;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/TuttiReferentialImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/TuttiReferentialImportExportService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/TuttiReferentialImportExportService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -45,9 +45,9 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.csv.Export;
-import org.nuiton.util.csv.Import;
-import org.nuiton.util.csv.ImportRuntimeException;
+import org.nuiton.csv.Export;
+import org.nuiton.csv.Import;
+import org.nuiton.csv.ImportRuntimeException;
import java.io.BufferedWriter;
import java.io.File;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/VesselModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/VesselModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/VesselModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,7 +27,7 @@
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.Common;
+import org.nuiton.csv.Common;
/**
* Model to import / export {@link Vessel} in csv format.
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/CatchRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -28,8 +28,8 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.util.csv.Common;
-import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.csv.Common;
+import org.nuiton.csv.ValueFormatter;
import static org.nuiton.i18n.I18n._;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -43,7 +43,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.csv.Export;
+import org.nuiton.csv.Export;
import java.io.BufferedWriter;
import java.io.File;
Copied: trunk/tutti-service/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider (from rev 1152, trunk/tutti-service/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider)
===================================================================
--- trunk/tutti-service/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider (rev 0)
+++ trunk/tutti-service/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1 @@
+fr.ifremer.tutti.service.config.TuttiServiceConfigProvider
\ No newline at end of file
Deleted: trunk/tutti-service/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider
===================================================================
--- trunk/tutti-service/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1 +0,0 @@
-fr.ifremer.tutti.service.config.TuttiServiceConfigProvider
\ No newline at end of file
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/AbstractServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/AbstractServiceTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/AbstractServiceTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -33,8 +33,9 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
+import org.nuiton.config.ApplicationConfig;
import org.nuiton.util.FileUtil;
-import org.nuiton.util.config.ApplicationConfig;
+import org.nuiton.util.converter.ConverterUtil;
import java.io.File;
@@ -59,7 +60,6 @@
@Before
public void setUp() throws Exception {
-
datadirectory = FileUtil.getTestSpecificDirectory(getClass(),
name.getMethodName(),
null,
@@ -86,6 +86,9 @@
new TuttiServiceConfig(applicationConfig);
serviceContext = createServiceContext(loader, config);
+
+ ConverterUtil.deregister();
+ ConverterUtil.initConverters();
}
@After
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/DecoratorServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/DecoratorServiceTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/DecoratorServiceTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -45,7 +45,7 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import static org.nuiton.i18n.I18n._;
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -34,8 +34,8 @@
import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.junit.runner.Description;
+import org.nuiton.config.ApplicationConfig;
import org.nuiton.i18n.I18n;
-import org.nuiton.util.config.ApplicationConfig;
import java.io.File;
import java.io.IOException;
@@ -55,8 +55,8 @@
}
@Override
- protected void prepareConfig(ApplicationConfig applicationConfig,
- File resourceDirectory) {
+ public void prepareConfig(ApplicationConfig applicationConfig,
+ File resourceDirectory) {
applicationConfig.loadDefaultOptions(
TuttiPersistenceConfigOption.values());
applicationConfig.loadDefaultOptions(
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingServiceTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingServiceTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -85,8 +85,10 @@
public void setUp() throws Exception {
TuttiServiceContext serviceContext = dbResource.getServiceContext();
+ persistenceService = serviceContext.getService(PersistenceService.class);
+
+ serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
tuttiWeightComputingService = serviceContext.getService(TuttiWeightComputingService.class);
- persistenceService = serviceContext.getService(PersistenceService.class);
}
@Test
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -74,7 +74,7 @@
public static final String OPERATION_2_ID = "100113";
public static final String CATCH_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;VracHorsVrac;Num_Ordre_VracHorsVrac_H2;Tot_VracHorsVrac;Ech_VracHorsVrac;Type_Volume_Poids_VracHorsVrac;Unite_Volume_Poids_VracHorsVrac;Cat_Tri;Num_Ordre_Cat_Tri_H2;Tot_Cat_Tri;Ech_Cat_Tri;Type_Volume_Poids_Cat_Tri;Unite_Volume_Poids_Cat_Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturite;Num_Ordre_Maturite_H2;Tot_Maturite;Ech_Maturite;Type_Volume_Poids_Maturite;Unite_Volume_Poids_Maturite;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Final_Elevation\n" +
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;Vrac/Hors Vrac;Num_Ordre_Vrac/Hors Vrac_H2;Tot_Vrac/Hors Vrac;Ech_Vrac/Hors Vrac;Type_Volume_Poids_Vrac/Hors Vrac;Unite_Volume_Poids_Vrac/Hors Vrac;Classe de Tri;Num_Ordre_Classe de Tri_H2;Tot_Classe de Tri;Ech_Classe de Tri;Type_Volume_Poids_Classe de Tri;Unite_Volume_Poids_Classe de Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
"2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;\n" +
"2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;9.074075;\n" +
"2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;5.0;1;0.6;cm;1.0;4;0.6;907.4074;\n" +
@@ -133,6 +133,8 @@
Assert.assertNotNull(franceCountry);
dbResource.getServiceConfig().setExportCountry(franceCountry.getId());
+ serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
+
service = serviceContext.getService(TuttiExportService.class);
loadData(PROGRAM_ID, CRUISE_ID);
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -108,7 +108,7 @@
"2013;Campagne CGFS;;A;2;1;308;Nombre d'engin - engin - totale - Déclaration d'un professionnel;2.0;";
public static final String CATCH_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;VracHorsVrac;Num_Ordre_VracHorsVrac_H2;Tot_VracHorsVrac;Ech_VracHorsVrac;Type_Volume_Poids_VracHorsVrac;Unite_Volume_Poids_VracHorsVrac;Cat_Tri;Num_Ordre_Cat_Tri_H2;Tot_Cat_Tri;Ech_Cat_Tri;Type_Volume_Poids_Cat_Tri;Unite_Volume_Poids_Cat_Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturite;Num_Ordre_Maturite_H2;Tot_Maturite;Ech_Maturite;Type_Volume_Poids_Maturite;Unite_Volume_Poids_Maturite;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Final_Elevation\n" +
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;Vrac/Hors Vrac;Num_Ordre_Vrac/Hors Vrac_H2;Tot_Vrac/Hors Vrac;Ech_Vrac/Hors Vrac;Type_Volume_Poids_Vrac/Hors Vrac;Unite_Volume_Poids_Vrac/Hors Vrac;Classe de Tri;Num_Ordre_Classe de Tri_H2;Tot_Classe de Tri;Ech_Classe de Tri;Type_Volume_Poids_Classe de Tri;Unite_Volume_Poids_Classe de Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
"2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.0;1;;cm;0.5;5;5.0;20.0;\n" +
"2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;2;;cm;0.5;2;5.0;20.0;\n" +
"2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;11.0;3;;cm;0.5;1;5.0;20.0;\n" +
@@ -120,7 +120,7 @@
"2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;2;20.0;1.0;";
public static final String CATCH_CONTENT_2 =
- "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;VracHorsVrac;Num_Ordre_VracHorsVrac_H2;Tot_VracHorsVrac;Ech_VracHorsVrac;Type_Volume_Poids_VracHorsVrac;Unite_Volume_Poids_VracHorsVrac;Cat_Tri;Num_Ordre_Cat_Tri_H2;Tot_Cat_Tri;Ech_Cat_Tri;Type_Volume_Poids_Cat_Tri;Unite_Volume_Poids_Cat_Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturite;Num_Ordre_Maturite_H2;Tot_Maturite;Ech_Maturite;Type_Volume_Poids_Maturite;Unite_Volume_Poids_Maturite;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Final_Elevation\n" +
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;Vrac/Hors Vrac;Num_Ordre_Vrac/Hors Vrac_H2;Tot_Vrac/Hors Vrac;Ech_Vrac/Hors Vrac;Type_Volume_Poids_Vrac/Hors Vrac;Unite_Volume_Poids_Vrac/Hors Vrac;Classe de Tri;Num_Ordre_Classe de Tri_H2;Tot_Classe de Tri;Ech_Classe de Tri;Type_Volume_Poids_Classe de Tri;Unite_Volume_Poids_Classe de Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
"2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;365;Aequipecten opercularis;taxon;Vrac;1;0.005;0.005;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.005;1.0;\n" +
"2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;491;Alloteuthis;taxon;Vrac;2;0.004;0.004;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.004;1.0;\n" +
"2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;300;Buccinum undatum;taxon;Vrac;3;0.015;0.015;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.015;1.0;\n" +
@@ -236,6 +236,8 @@
Assert.assertNotNull(franceCountry);
dbResource.getServiceConfig().setExportCountry(franceCountry.getId());
+ serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
+
service = serviceContext.getService(TuttiExportService.class);
loadData(PROGRAM_ID, CRUISE_ID);
@@ -305,6 +307,7 @@
exportContext.gearCaracteristicsFile,
GEAR_CARACTERISTICS_CONTENT);
}
+
@Test
public void exportOperations() throws Exception {
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -28,17 +28,15 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
-import fr.ifremer.tutti.persistence.RessourceClassLoader;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.AbstractServiceTest;
-import fr.ifremer.tutti.service.TuttiServiceContext;
-import fr.ifremer.tutti.service.config.TuttiServiceConfig;
+import fr.ifremer.tutti.service.ServiceDbResource;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.ClassRule;
import org.junit.Test;
import java.io.File;
@@ -48,10 +46,24 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0
*/
-public class TuttiProtocolImportExportServiceTest extends AbstractServiceTest {
+public class TuttiProtocolImportExportServiceTest {
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.writeDb("dbCGFS");
+
protected TuttiProtocolImportExportService service;
+ public static final int VRAC_HORS_VRAC = 1428;
+
+ public static final int SIZE = 198;
+
+ public static final int SEX = 196;
+
+ public static final int MATURITY = 174;
+
+ public static final int AGE = 1430;
+
public static final String PROTOCOL_FILE_CONTENT =
"id: 1\n" +
"name: protocolName\n" +
@@ -60,20 +72,22 @@
" id: 21\n" +
" calcifySampleEnabled: true\n" +
" lengthStepPmfmId: 1394\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 174\n" +
+ " - 196\n" +
" speciesReferenceTaxonId: 11242\n" +
" speciesSurveyCode: cruiseCode1\n" +
" weightEnabled: true\n" +
"- !SpeciesProtocol\n" +
" id: 22\n" +
- " ageEnabled: true\n" +
" calcifySampleEnabled: true\n" +
" countIfNoFrequencyEnabled: true\n" +
" lengthStepPmfmId: 323\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
- " sizeEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 1430\n" +
+ " - 174\n" +
+ " - 196\n" +
+ " - 198\n" +
" speciesReferenceTaxonId: 3835\n" +
" weightEnabled: true\n" +
"comment: Commentaire\n" +
@@ -88,22 +102,25 @@
" id: 1\n" +
" calcifySampleEnabled: true\n" +
" lengthStepPmfmId: 1394\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 174\n" +
+ " - 196\n" +
" speciesReferenceTaxonId: 11242\n" +
" speciesSurveyCode: cruiseCode1\n" +
" weightEnabled: true\n" +
"- !SpeciesProtocol\n" +
" id: 2\n" +
- " ageEnabled: true\n" +
" calcifySampleEnabled: true\n" +
" countIfNoFrequencyEnabled: true\n" +
" lengthStepPmfmId: 323\n" +
- " maturityEnabled: true\n" +
- " sexEnabled: true\n" +
- " sizeEnabled: true\n" +
+ " mandatorySampleCategoryId: \n" +
+ " - 1430\n" +
+ " - 174\n" +
+ " - 196\n" +
+ " - 198\n" +
" speciesReferenceTaxonId: 3835\n" +
" weightEnabled: true\n" +
+ "version: 2\n" +
"vesselUseFeaturePmfmId: \n" +
"- 114\n" +
"- 228\n" +
@@ -124,29 +141,26 @@
"5;;parameterName5;matrixName5;fractionName5;methodName5;";
public static final String PROTOCOL_SPECIES_FILE_CONTENT =
- "speciesReferenceTaxonId;speciesRefTaxCode;speciesName;speciesSurveyCode;lengthStepPmfmId;lengthStepPmfmParameterName;lengthStepPmfmMatrixName;lengthStepPmfmFractionName;lengthStepPmfmMethodName;sizeEnabled;sexEnabled;maturityEnabled;ageEnabled;weightEnabled;countIfNoFrequencyEnabled;calcifySampleEnabled\n" +
- "1;speciesRefTaxCode1;speciesName1;cruiseCode1;2;parameterName2;matrixName2;fractionName2;methodName2;Y;Y;Y;Y;Y;Y;Y;\n" +
- "2;speciesRefTaxCode2;speciesName2;;;;;;;N;Y;N;Y;Y;Y;Y;";
+ "speciesReferenceTaxonId;speciesRefTaxCode;speciesName;speciesSurveyCode;lengthStepPmfmId;lengthStepPmfmParameterName;lengthStepPmfmMatrixName;lengthStepPmfmFractionName;lengthStepPmfmMethodName;mandatorySampleCategoryId;weightEnabled;countIfNoFrequencyEnabled;calcifySampleEnabled\n" +
+ "1;speciesRefTaxCode1;speciesName1;cruiseCode1;2;parameterName2;matrixName2;fractionName2;methodName2;1430|198|174|196;Y;Y;Y;\n" +
+ "2;speciesRefTaxCode2;speciesName2;;;;;;;1430|196;Y;Y;Y;";
public static final String PROTOCOL_BENTHOS_FILE_CONTENT =
- "speciesReferenceTaxonId;speciesRefTaxCode;speciesName;speciesSurveyCode;lengthStepPmfmId;lengthStepPmfmParameterName;lengthStepPmfmMatrixName;lengthStepPmfmFractionName;lengthStepPmfmMethodName;sizeEnabled;sexEnabled;maturityEnabled;ageEnabled;weightEnabled;countIfNoFrequencyEnabled;calcifySampleEnabled\n" +
- "1;speciesRefTaxCode1;speciesName1;cruiseCode1;2;parameterName2;matrixName2;fractionName2;methodName2;Y;Y;Y;Y;Y;Y;Y;\n" +
- "2;speciesRefTaxCode2;speciesName2;;;;;;;N;Y;N;Y;Y;Y;Y;";
+ "speciesReferenceTaxonId;speciesRefTaxCode;speciesName;speciesSurveyCode;lengthStepPmfmId;lengthStepPmfmParameterName;lengthStepPmfmMatrixName;lengthStepPmfmFractionName;lengthStepPmfmMethodName;mandatorySampleCategoryId;weightEnabled;countIfNoFrequencyEnabled;calcifySampleEnabled\n" +
+ "1;speciesRefTaxCode1;speciesName1;cruiseCode1;2;parameterName2;matrixName2;fractionName2;methodName2;1430|198|174|196;Y;Y;Y;\n" +
+ "2;speciesRefTaxCode2;speciesName2;;;;;;;1430|196;Y;Y;Y;";
+ File datadirectory;
- @Override
- protected TuttiServiceContext createServiceContext(RessourceClassLoader loader, TuttiServiceConfig config) {
- return new TuttiServiceContext(loader, config);
- }
-
@Before
public void setUp() throws Exception {
- super.setUp();
- serviceContext.getConfig().setCsvSeparator(';');
+ dbResource.getServiceConfig().setCsvSeparator(';');
- service = serviceContext.getService(
+ service = dbResource.getServiceContext().getService(
TuttiProtocolImportExportService.class);
+
+ datadirectory = dbResource.getServiceConfig().getDataDirectory();
}
@Test
@@ -158,6 +172,7 @@
Assert.assertFalse(exportFile.exists());
TuttiProtocol protocol = TuttiBeanFactory.newTuttiProtocol();
+ protocol.setVersion(2);
protocol.setId("1");
protocol.setName("protocolName");
protocol.setComment("Commentaire");
@@ -167,51 +182,55 @@
protocol.setSpecies(Lists.<SpeciesProtocol>newArrayList());
SpeciesProtocol sp1 = TuttiBeanFactory.newSpeciesProtocol();
+ sp1.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp1.setId(1);
sp1.setSpeciesReferenceTaxonId(11242);
sp1.setSpeciesSurveyCode("cruiseCode1");
sp1.setLengthStepPmfmId("1394");
sp1.setCalcifySampleEnabled(true);
- sp1.setMaturityEnabled(true);
- sp1.setSexEnabled(true);
+ sp1.addMandatorySampleCategoryId(MATURITY);
+ sp1.addMandatorySampleCategoryId(SEX);
sp1.setWeightEnabled(true);
protocol.addSpecies(sp1);
SpeciesProtocol sp2 = TuttiBeanFactory.newSpeciesProtocol();
+ sp2.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp2.setId(2);
sp2.setSpeciesReferenceTaxonId(3835);
sp2.setLengthStepPmfmId("323");
- sp2.setAgeEnabled(true);
+ sp2.addMandatorySampleCategoryId(AGE);
sp2.setCalcifySampleEnabled(true);
sp2.setCountIfNoFrequencyEnabled(true);
- sp2.setMaturityEnabled(true);
- sp2.setSexEnabled(true);
- sp2.setSizeEnabled(true);
+ sp2.addMandatorySampleCategoryId(MATURITY);
+ sp2.addMandatorySampleCategoryId(SEX);
+ sp2.addMandatorySampleCategoryId(SIZE);
sp2.setWeightEnabled(true);
protocol.addSpecies(sp2);
protocol.setBenthos(Lists.<SpeciesProtocol>newArrayList());
SpeciesProtocol bp1 = TuttiBeanFactory.newSpeciesProtocol();
+ bp1.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
bp1.setId(21);
bp1.setSpeciesSurveyCode("cruiseCode1");
bp1.setSpeciesReferenceTaxonId(11242);
bp1.setLengthStepPmfmId("1394");
bp1.setCalcifySampleEnabled(true);
- bp1.setMaturityEnabled(true);
- bp1.setSexEnabled(true);
+ bp1.addMandatorySampleCategoryId(MATURITY);
+ bp1.addMandatorySampleCategoryId(SEX);
bp1.setWeightEnabled(true);
protocol.addBenthos(bp1);
SpeciesProtocol bp2 = TuttiBeanFactory.newSpeciesProtocol();
+ bp2.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
bp2.setId(22);
bp2.setSpeciesReferenceTaxonId(3835);
bp2.setLengthStepPmfmId("323");
- bp2.setAgeEnabled(true);
+ bp2.addMandatorySampleCategoryId(AGE);
bp2.setCalcifySampleEnabled(true);
bp2.setCountIfNoFrequencyEnabled(true);
- bp2.setMaturityEnabled(true);
- bp2.setSexEnabled(true);
- bp2.setSizeEnabled(true);
+ bp2.addMandatorySampleCategoryId(MATURITY);
+ bp2.addMandatorySampleCategoryId(SEX);
+ bp2.addMandatorySampleCategoryId(SIZE);
bp2.setWeightEnabled(true);
protocol.addBenthos(bp2);
@@ -235,6 +254,7 @@
Assert.assertNotNull(protocol);
Assert.assertEquals("1", protocol.getId());
+ Assert.assertEquals(2, protocol.getVersion(),0);
Assert.assertEquals("protocolName", protocol.getName());
Assert.assertEquals("Commentaire", protocol.getComment());
Assert.assertEquals(Lists.newArrayList("14", "18"), protocol.getLengthClassesPmfmId());
@@ -249,12 +269,12 @@
Assert.assertEquals(11242, sp1.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("cruiseCode1", sp1.getSpeciesSurveyCode());
Assert.assertEquals("1394", sp1.getLengthStepPmfmId());
- Assert.assertFalse(sp1.isAgeEnabled());
+ Assert.assertFalse(sp1.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(sp1.isCalcifySampleEnabled());
Assert.assertFalse(sp1.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(sp1.isMaturityEnabled());
- Assert.assertTrue(sp1.isSexEnabled());
- Assert.assertFalse(sp1.isSizeEnabled());
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(SEX));
+ Assert.assertFalse(sp1.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(sp1.isWeightEnabled());
SpeciesProtocol sp2 = protocol.getSpecies(1);
@@ -262,12 +282,12 @@
Assert.assertEquals(2, sp2.getIdAsInt(), 0);
Assert.assertEquals(3835, sp2.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("323", sp2.getLengthStepPmfmId());
- Assert.assertTrue(sp2.isAgeEnabled());
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(sp2.isCalcifySampleEnabled());
Assert.assertTrue(sp2.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(sp2.isMaturityEnabled());
- Assert.assertTrue(sp2.isSexEnabled());
- Assert.assertTrue(sp2.isSizeEnabled());
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(SEX));
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(sp2.isWeightEnabled());
Assert.assertNotNull(protocol.getBenthos());
@@ -278,12 +298,12 @@
Assert.assertEquals(11242, b1.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("cruiseCode1", b1.getSpeciesSurveyCode());
Assert.assertEquals("1394", b1.getLengthStepPmfmId());
- Assert.assertFalse(b1.isAgeEnabled());
+ Assert.assertFalse(b1.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(b1.isCalcifySampleEnabled());
Assert.assertFalse(b1.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(b1.isMaturityEnabled());
- Assert.assertTrue(b1.isSexEnabled());
- Assert.assertFalse(b1.isSizeEnabled());
+ Assert.assertTrue(b1.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(b1.containsMandatorySampleCategoryId(SEX));
+ Assert.assertFalse(b1.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(b1.isWeightEnabled());
SpeciesProtocol b2 = protocol.getBenthos(1);
@@ -291,12 +311,12 @@
Assert.assertEquals(22, b2.getIdAsInt(), 0);
Assert.assertEquals(3835, b2.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("323", b2.getLengthStepPmfmId());
- Assert.assertTrue(b2.isAgeEnabled());
+ Assert.assertTrue(b2.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(b2.isCalcifySampleEnabled());
Assert.assertTrue(b2.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(b2.isMaturityEnabled());
- Assert.assertTrue(b2.isSexEnabled());
- Assert.assertTrue(b2.isSizeEnabled());
+ Assert.assertTrue(b2.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(b2.containsMandatorySampleCategoryId(SEX));
+ Assert.assertTrue(b2.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(b2.isWeightEnabled());
}
@@ -392,12 +412,12 @@
Assert.assertEquals(1, sp1.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("cruiseCode1", sp1.getSpeciesSurveyCode());
Assert.assertEquals("2", sp1.getLengthStepPmfmId());
- Assert.assertTrue(sp1.isAgeEnabled());
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(sp1.isCalcifySampleEnabled());
Assert.assertTrue(sp1.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(sp1.isMaturityEnabled());
- Assert.assertTrue(sp1.isSexEnabled());
- Assert.assertTrue(sp1.isSizeEnabled());
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(SEX));
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(sp1.isWeightEnabled());
SpeciesProtocol sp2 = protocol.getSpecies().get(1);
@@ -405,12 +425,12 @@
Assert.assertEquals(2, sp2.getSpeciesReferenceTaxonId(), 0);
Assert.assertNull(sp2.getSpeciesSurveyCode());
Assert.assertNull(sp2.getLengthStepPmfmId());
- Assert.assertTrue(sp2.isAgeEnabled());
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(sp2.isCalcifySampleEnabled());
Assert.assertTrue(sp2.isCountIfNoFrequencyEnabled());
- Assert.assertFalse(sp2.isMaturityEnabled());
- Assert.assertTrue(sp2.isSexEnabled());
- Assert.assertFalse(sp2.isSizeEnabled());
+ Assert.assertFalse(sp2.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(SEX));
+ Assert.assertFalse(sp2.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(sp2.isWeightEnabled());
}
@@ -427,12 +447,13 @@
protocol.setSpecies(Lists.<SpeciesProtocol>newArrayList());
SpeciesProtocol sp1 = TuttiBeanFactory.newSpeciesProtocol();
+ sp1.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp1.setSpeciesReferenceTaxonId(1);
sp1.setSpeciesSurveyCode("cruiseCode1");
- sp1.setAgeEnabled(true);
- sp1.setSizeEnabled(true);
- sp1.setMaturityEnabled(true);
- sp1.setSexEnabled(true);
+ sp1.addMandatorySampleCategoryId(AGE);
+ sp1.addMandatorySampleCategoryId(SIZE);
+ sp1.addMandatorySampleCategoryId(MATURITY);
+ sp1.addMandatorySampleCategoryId(SEX);
sp1.setWeightEnabled(true);
sp1.setCountIfNoFrequencyEnabled(true);
sp1.setCalcifySampleEnabled(true);
@@ -441,11 +462,12 @@
protocol.addSpecies(sp1);
SpeciesProtocol sp2 = TuttiBeanFactory.newSpeciesProtocol();
+ sp2.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp2.setSpeciesReferenceTaxonId(2);
- sp2.setAgeEnabled(true);
- sp1.setSizeEnabled(true);
- sp1.setMaturityEnabled(true);
- sp2.setSexEnabled(true);
+ sp2.addMandatorySampleCategoryId(AGE);
+ sp2.removeMandatorySampleCategoryId(SIZE);
+ sp2.removeMandatorySampleCategoryId(MATURITY);
+ sp2.addMandatorySampleCategoryId(SEX);
sp2.setWeightEnabled(true);
sp2.setCalcifySampleEnabled(true);
sp2.setCountIfNoFrequencyEnabled(true);
@@ -490,12 +512,12 @@
Assert.assertEquals(1, sp1.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("cruiseCode1", sp1.getSpeciesSurveyCode());
Assert.assertEquals("2", sp1.getLengthStepPmfmId());
- Assert.assertTrue(sp1.isAgeEnabled());
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(sp1.isCalcifySampleEnabled());
Assert.assertTrue(sp1.isCountIfNoFrequencyEnabled());
- Assert.assertTrue(sp1.isMaturityEnabled());
- Assert.assertTrue(sp1.isSexEnabled());
- Assert.assertTrue(sp1.isSizeEnabled());
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(SEX));
+ Assert.assertTrue(sp1.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(sp1.isWeightEnabled());
SpeciesProtocol sp2 = protocol.getBenthos(1);
@@ -503,12 +525,12 @@
Assert.assertEquals(2, sp2.getSpeciesReferenceTaxonId(), 0);
Assert.assertNull(sp2.getSpeciesSurveyCode());
Assert.assertNull(sp2.getLengthStepPmfmId());
- Assert.assertTrue(sp2.isAgeEnabled());
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(AGE));
Assert.assertTrue(sp2.isCalcifySampleEnabled());
Assert.assertTrue(sp2.isCountIfNoFrequencyEnabled());
- Assert.assertFalse(sp2.isMaturityEnabled());
- Assert.assertTrue(sp2.isSexEnabled());
- Assert.assertFalse(sp2.isSizeEnabled());
+ Assert.assertFalse(sp2.containsMandatorySampleCategoryId(MATURITY));
+ Assert.assertTrue(sp2.containsMandatorySampleCategoryId(SEX));
+ Assert.assertFalse(sp2.containsMandatorySampleCategoryId(SIZE));
Assert.assertTrue(sp2.isWeightEnabled());
}
@@ -525,13 +547,14 @@
protocol.setBenthos(Lists.<SpeciesProtocol>newArrayList());
SpeciesProtocol sp1 = TuttiBeanFactory.newSpeciesProtocol();
+ sp1.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp1.setId(21);
sp1.setSpeciesReferenceTaxonId(1);
sp1.setSpeciesSurveyCode("cruiseCode1");
- sp1.setAgeEnabled(true);
- sp1.setSizeEnabled(true);
- sp1.setMaturityEnabled(true);
- sp1.setSexEnabled(true);
+ sp1.addMandatorySampleCategoryId(AGE);
+ sp1.addMandatorySampleCategoryId(SIZE);
+ sp1.addMandatorySampleCategoryId(MATURITY);
+ sp1.addMandatorySampleCategoryId(SEX);
sp1.setWeightEnabled(true);
sp1.setCountIfNoFrequencyEnabled(true);
sp1.setCalcifySampleEnabled(true);
@@ -540,12 +563,13 @@
protocol.addBenthos(sp1);
SpeciesProtocol sp2 = TuttiBeanFactory.newSpeciesProtocol();
+ sp2.setMandatorySampleCategoryId(Lists.<Integer>newArrayList());
sp2.setId(22);
sp2.setSpeciesReferenceTaxonId(2);
- sp2.setAgeEnabled(true);
- sp2.setSizeEnabled(false);
- sp2.setMaturityEnabled(false);
- sp2.setSexEnabled(true);
+ sp2.addMandatorySampleCategoryId(AGE);
+ sp2.removeMandatorySampleCategoryId(SIZE);
+ sp2.removeMandatorySampleCategoryId(MATURITY);
+ sp2.addMandatorySampleCategoryId(SEX);
sp2.setWeightEnabled(true);
sp2.setCalcifySampleEnabled(true);
sp2.setCountIfNoFrequencyEnabled(true);
Deleted: trunk/tutti-ui-swing/changelog.txt
===================================================================
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,28 +1,5 @@
-###
-# #%L
-# Tutti :: UI
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2012 - 2013 Ifremer
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Fri May 24 09:39:08 CEST 2013
+#Tue Jul 23 13:28:56 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.save.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -37,6 +14,7 @@
tutti.createBenthosBatch.action.cancel.help=editFishingOperation.html\#captureBenthosActions
tutti.createBenthosBatch.action.save.help=editFishingOperation.html\#captureBenthosActions
tutti.createBenthosBatch.field.batchWeight.help=editFishingOperation.html\#captureBenthosFields
+tutti.createBenthosBatch.field.sampleCategory.help=
tutti.createBenthosBatch.field.sortedUnsortedCategory.help=editFishingOperation.html\#captureBenthosFields
tutti.createBenthosBatch.field.species.help=editFishingOperation.html\#captureBenthosFields
tutti.createBenthosBatch.help=editFishingOperation.html\#captureBenthos
@@ -58,6 +36,7 @@
tutti.createSpeciesBatch.action.cancel.help=editFishingOperation.html\#captureEspecesCreeLotActions
tutti.createSpeciesBatch.action.save.help=editFishingOperation.html\#captureEspecesCreeLotActions
tutti.createSpeciesBatch.field.batchWeight.help=editFishingOperation.html\#captureEspecesCreeLotFields
+tutti.createSpeciesBatch.field.sampleCategory.help=
tutti.createSpeciesBatch.field.sortedUnsortedCategory.help=editFishingOperation.html\#captureEspecesCreeLotFields
tutti.createSpeciesBatch.field.species.help=editFishingOperation.html\#captureEspecesCreeLotFields
tutti.createSpeciesBatch.help=editFishingOperation.html\#captureEspecesCreeLot
@@ -266,16 +245,16 @@
tutti.fishingOperations.field.fishingOperation.help=editFishingOperation.html\#fields
tutti.fishingOperations.help=editFishingOperation.html
tutti.index.help=index.html
-tutti.main.action.changeLocale.help=menu.html#menu_aide
-tutti.main.action.changeLocaleFR.help=menu.html#menu_aide
-tutti.main.action.changeLocaleUK.help=menu.html#menu_aide
-tutti.main.action.showHelp.help=menu.html#menu_aide
-tutti.main.help=menu.html#menu_aide
-tutti.main.menu.action.about.help=menu.html#menu_aide
-tutti.main.menu.action.changeLocale.help=menu.html#menu_aide
-tutti.main.menu.action.changeLocaleFR.help=menu.html#menu_aide
-tutti.main.menu.action.changeLocaleUK.help=menu.html#menu_aide
-tutti.main.menu.action.configuration.help=menu.html#menu_fichier_configuration
+tutti.main.action.changeLocale.help=menu.html\#menu_aide
+tutti.main.action.changeLocaleFR.help=menu.html\#menu_aide
+tutti.main.action.changeLocaleUK.help=menu.html\#menu_aide
+tutti.main.action.showHelp.help=menu.html\#menu_aide
+tutti.main.help=menu.html\#menu_aide
+tutti.main.menu.action.about.help=menu.html\#menu_aide
+tutti.main.menu.action.changeLocale.help=menu.html\#menu_aide
+tutti.main.menu.action.changeLocaleFR.help=menu.html\#menu_aide
+tutti.main.menu.action.changeLocaleUK.help=menu.html\#menu_aide
+tutti.main.menu.action.configuration.help=menu.html\#menu_fichier_configuration
tutti.main.menu.action.editCatches.help=menu.html\#menu_action
tutti.main.menu.action.editCruise.help=menu.html\#menu_action
tutti.main.menu.action.editProgram.help=menu.html\#menu_action
@@ -318,20 +297,20 @@
tutti.selectCruise.field.program.help=selectCruise.html\#fields
tutti.selectCruise.field.protocol.help=selectCruise.html\#fields
tutti.selectCruise.help=selectCruise.html
-tutti.splitBenthosBatch.action.cancel.help=editFishingOperation.html#captureBenthosActions
-tutti.splitBenthosBatch.action.save.help=editFishingOperation.html#captureBenthosActions
-tutti.splitBenthosBatch.field.batchWeightField.help=editFishingOperation.html#captureBenthosFields
-tutti.splitBenthosBatch.field.categoryField.help=editFishingOperation.html#captureBenthosFields
-tutti.splitBenthosBatch.field.sampleWeightField.help=editFishingOperation.html#captureBenthosFields
-tutti.splitBenthosBatch.field.speciesField.help=editFishingOperation.html#captureBenthosFields
-tutti.splitBenthosBatch.help=editFishingOperation.html#captureBenthos
-tutti.splitSpeciesBatch.action.cancel.help=editFishingOperation.html#captureEspcesActions
-tutti.splitSpeciesBatch.action.save.help=editFishingOperation.html#captureEspcesActions
-tutti.splitSpeciesBatch.field.batchWeightField.help=editFishingOperation.html#captureEspcesFields
-tutti.splitSpeciesBatch.field.categoryField.help=editFishingOperation.html#captureEspcesFields
-tutti.splitSpeciesBatch.field.sampleWeightField.help=editFishingOperation.html#captureEspcesFields
-tutti.splitSpeciesBatch.field.speciesField.help=editFishingOperation.html#captureEspcesFields
-tutti.splitSpeciesBatch.help=editFishingOperation.html#captureEspces
+tutti.splitBenthosBatch.action.cancel.help=editFishingOperation.html\#captureBenthosActions
+tutti.splitBenthosBatch.action.save.help=editFishingOperation.html\#captureBenthosActions
+tutti.splitBenthosBatch.field.batchWeightField.help=editFishingOperation.html\#captureBenthosFields
+tutti.splitBenthosBatch.field.categoryField.help=editFishingOperation.html\#captureBenthosFields
+tutti.splitBenthosBatch.field.sampleWeightField.help=editFishingOperation.html\#captureBenthosFields
+tutti.splitBenthosBatch.field.speciesField.help=editFishingOperation.html\#captureBenthosFields
+tutti.splitBenthosBatch.help=editFishingOperation.html\#captureBenthos
+tutti.splitSpeciesBatch.action.cancel.help=editFishingOperation.html\#captureEspcesActions
+tutti.splitSpeciesBatch.action.save.help=editFishingOperation.html\#captureEspcesActions
+tutti.splitSpeciesBatch.field.batchWeightField.help=editFishingOperation.html\#captureEspcesFields
+tutti.splitSpeciesBatch.field.categoryField.help=editFishingOperation.html\#captureEspcesFields
+tutti.splitSpeciesBatch.field.sampleWeightField.help=editFishingOperation.html\#captureEspcesFields
+tutti.splitSpeciesBatch.field.speciesField.help=editFishingOperation.html\#captureEspcesFields
+tutti.splitSpeciesBatch.help=editFishingOperation.html\#captureEspces
tutti.validateCruise.navigation.action.export.all.help=validateCruise.html\#actions
tutti.validateCruise.navigation.action.export.help=validateCruise.html\#actions
tutti.validateCruise.navigation.action.export.operation.help=validateCruise.html\#actions
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1,28 +1,5 @@
-###
-# #%L
-# Tutti :: UI
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2012 - 2013 Ifremer
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/gpl-3.0.html>.
-# #L%
-###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Fri May 24 09:39:08 CEST 2013
+#Tue Jul 23 13:28:56 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.save.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -37,6 +14,7 @@
tutti.createBenthosBatch.action.cancel.help=editFishingOperation.html\#captureBenthosActions
tutti.createBenthosBatch.action.save.help=editFishingOperation.html\#captureBenthosActions
tutti.createBenthosBatch.field.batchWeight.help=editFishingOperation.html\#captureBenthosFields
+tutti.createBenthosBatch.field.sampleCategory.help=
tutti.createBenthosBatch.field.sortedUnsortedCategory.help=editFishingOperation.html\#captureBenthosFields
tutti.createBenthosBatch.field.species.help=editFishingOperation.html\#captureBenthosFields
tutti.createBenthosBatch.help=editFishingOperation.html\#captureBenthos
@@ -58,6 +36,7 @@
tutti.createSpeciesBatch.action.cancel.help=editFishingOperation.html\#captureEspecesCreeLotActions
tutti.createSpeciesBatch.action.save.help=editFishingOperation.html\#captureEspecesCreeLotActions
tutti.createSpeciesBatch.field.batchWeight.help=editFishingOperation.html\#captureEspecesCreeLotFields
+tutti.createSpeciesBatch.field.sampleCategory.help=
tutti.createSpeciesBatch.field.sortedUnsortedCategory.help=editFishingOperation.html\#captureEspecesCreeLotFields
tutti.createSpeciesBatch.field.species.help=editFishingOperation.html\#captureEspecesCreeLotFields
tutti.createSpeciesBatch.help=editFishingOperation.html\#captureEspecesCreeLot
@@ -266,16 +245,16 @@
tutti.fishingOperations.field.fishingOperation.help=editFishingOperation.html\#fields
tutti.fishingOperations.help=editFishingOperation.html
tutti.index.help=index.html
-tutti.main.action.changeLocale.help=menu.html#menu_aide
-tutti.main.action.changeLocaleFR.help=menu.html#menu_aide
-tutti.main.action.changeLocaleUK.help=menu.html#menu_aide
-tutti.main.action.showHelp.help=menu.html#menu_aide
+tutti.main.action.changeLocale.help=menu.html\#menu_aide
+tutti.main.action.changeLocaleFR.help=menu.html\#menu_aide
+tutti.main.action.changeLocaleUK.help=menu.html\#menu_aide
+tutti.main.action.showHelp.help=menu.html\#menu_aide
tutti.main.help=index.html
-tutti.main.menu.action.about.help=menu.html#menu_aide
-tutti.main.menu.action.changeLocale.help=menu.html#menu_aide
-tutti.main.menu.action.changeLocaleFR.help=menu.html#menu_aide
-tutti.main.menu.action.changeLocaleUK.help=menu.html#menu_aide
-tutti.main.menu.action.configuration.help=menu.html#menu_fichier_configuration
+tutti.main.menu.action.about.help=menu.html\#menu_aide
+tutti.main.menu.action.changeLocale.help=menu.html\#menu_aide
+tutti.main.menu.action.changeLocaleFR.help=menu.html\#menu_aide
+tutti.main.menu.action.changeLocaleUK.help=menu.html\#menu_aide
+tutti.main.menu.action.configuration.help=menu.html\#menu_fichier_configuration
tutti.main.menu.action.editCatches.help=menu.html\#menu_action
tutti.main.menu.action.editCruise.help=menu.html\#menu_action
tutti.main.menu.action.editProgram.help=menu.html\#menu_action
@@ -318,20 +297,20 @@
tutti.selectCruise.field.program.help=selectCruise.html\#fields
tutti.selectCruise.field.protocol.help=selectCruise.html\#fields
tutti.selectCruise.help=selectCruise.html
-tutti.splitBenthosBatch.action.cancel.help=editFishingOperation.html#captureBenthosActions
-tutti.splitBenthosBatch.action.save.help=editFishingOperation.html#captureBenthosActions
-tutti.splitBenthosBatch.field.batchWeightField.help=editFishingOperation.html#captureBenthosFields
-tutti.splitBenthosBatch.field.categoryField.help=editFishingOperation.html#captureBenthosFields
-tutti.splitBenthosBatch.field.sampleWeightField.help=editFishingOperation.html#captureBenthosFields
-tutti.splitBenthosBatch.field.speciesField.help=editFishingOperation.html#captureBenthosFields
-tutti.splitBenthosBatch.help=editFishingOperation.html#captureBenthos
-tutti.splitSpeciesBatch.action.cancel.help=editFishingOperation.html#captureEspcesActions
-tutti.splitSpeciesBatch.action.save.help=editFishingOperation.html#captureEspcesActions
-tutti.splitSpeciesBatch.field.batchWeightField.help=editFishingOperation.html#captureEspcesFields
-tutti.splitSpeciesBatch.field.categoryField.help=editFishingOperation.html#captureEspcesFields
-tutti.splitSpeciesBatch.field.sampleWeightField.help=editFishingOperation.html#captureEspcesFields
-tutti.splitSpeciesBatch.field.speciesField.help=editFishingOperation.html#captureEspcesFields
-tutti.splitSpeciesBatch.help=editFishingOperation.html#captureEspces
+tutti.splitBenthosBatch.action.cancel.help=editFishingOperation.html\#captureBenthosActions
+tutti.splitBenthosBatch.action.save.help=editFishingOperation.html\#captureBenthosActions
+tutti.splitBenthosBatch.field.batchWeightField.help=editFishingOperation.html\#captureBenthosFields
+tutti.splitBenthosBatch.field.categoryField.help=editFishingOperation.html\#captureBenthosFields
+tutti.splitBenthosBatch.field.sampleWeightField.help=editFishingOperation.html\#captureBenthosFields
+tutti.splitBenthosBatch.field.speciesField.help=editFishingOperation.html\#captureBenthosFields
+tutti.splitBenthosBatch.help=editFishingOperation.html\#captureBenthos
+tutti.splitSpeciesBatch.action.cancel.help=editFishingOperation.html\#captureEspcesActions
+tutti.splitSpeciesBatch.action.save.help=editFishingOperation.html\#captureEspcesActions
+tutti.splitSpeciesBatch.field.batchWeightField.help=editFishingOperation.html\#captureEspcesFields
+tutti.splitSpeciesBatch.field.categoryField.help=editFishingOperation.html\#captureEspcesFields
+tutti.splitSpeciesBatch.field.sampleWeightField.help=editFishingOperation.html\#captureEspcesFields
+tutti.splitSpeciesBatch.field.speciesField.help=editFishingOperation.html\#captureEspcesFields
+tutti.splitSpeciesBatch.help=editFishingOperation.html\#captureEspces
tutti.validateCruise.navigation.action.export.all.help=validateCruise.html\#actions
tutti.validateCruise.navigation.action.export.help=validateCruise.html\#actions
tutti.validateCruise.navigation.action.export.operation.help=validateCruise.html\#actions
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -41,9 +41,9 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.updater.ApplicationInfo;
-import org.nuiton.util.updater.ApplicationUpdater;
-import org.nuiton.util.updater.ApplicationUpdaterCallback;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
+import org.nuiton.updater.ApplicationUpdaterCallback;
import java.io.File;
import java.io.IOException;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -70,6 +70,7 @@
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.i18n.init.UserI18nInitializer;
+import org.nuiton.util.converter.ConverterUtil;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -321,6 +322,11 @@
// use our special classLoader (which will read some files from resources from a configuration directory)
Thread.currentThread().setContextClassLoader(getResourceLoader());
+ // converters are stored in current classloader, we need then to rescan them
+ // each time we change current classloader
+ ConverterUtil.deregister();
+ ConverterUtil.initConverters();
+
// Use shutdownHook to close context on System.exit
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@@ -508,7 +514,7 @@
// use real service
service = serviceContext.getService(PersistenceService.class);
- dataContext.open(service);
+ dataContext.open(config.getServiceConfig(), service);
}
} else {
service = serviceContext.getService(ClosedPersistenceService.class);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -34,10 +34,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.Version;
-import org.nuiton.util.config.ApplicationConfig;
-import org.nuiton.util.config.ApplicationConfigHelper;
-import org.nuiton.util.config.ApplicationConfigProvider;
-import org.nuiton.util.config.ArgumentsParserException;
+import org.nuiton.config.ApplicationConfig;
+import org.nuiton.config.ApplicationConfigHelper;
+import org.nuiton.config.ApplicationConfigProvider;
+import org.nuiton.config.ArgumentsParserException;
import javax.swing.KeyStroke;
import java.awt.Color;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigOption.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigOption.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigOption.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,7 +25,7 @@
*/
import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType;
-import org.nuiton.util.config.ConfigOptionDef;
+import org.nuiton.config.ConfigOptionDef;
import javax.swing.KeyStroke;
import java.awt.Color;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigProvider.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigProvider.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigProvider.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,9 +24,9 @@
* #L%
*/
-import org.nuiton.util.config.ApplicationConfigProvider;
-import org.nuiton.util.config.ConfigActionDef;
-import org.nuiton.util.config.ConfigOptionDef;
+import org.nuiton.config.ApplicationConfigProvider;
+import org.nuiton.config.ConfigActionDef;
+import org.nuiton.config.ConfigOptionDef;
import java.util.Locale;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -37,8 +37,8 @@
import jaxx.runtime.swing.AboutPanel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.updater.ApplicationInfo;
-import org.nuiton.util.updater.ApplicationUpdater;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -35,7 +35,7 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.updater.ApplicationUpdater;
+import org.nuiton.updater.ApplicationUpdater;
import java.io.File;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -34,7 +34,7 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.updater.ApplicationUpdater;
+import org.nuiton.updater.ApplicationUpdater;
import java.io.File;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -33,7 +33,7 @@
import jaxx.runtime.swing.ComponentResizer;
import jaxx.runtime.swing.model.JaxxDefaultListModel;
import jaxx.runtime.swing.renderer.MultiDecoratorListCellRenderer;
-import org.nuiton.util.decorator.JXPathDecorator;
+import org.nuiton.decorator.JXPathDecorator;
import javax.swing.AbstractAction;
import javax.swing.Action;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderIdsTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderIdsTableCell.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderIdsTableCell.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -28,13 +28,12 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fr.ifremer.tutti.TuttiTechnicalException;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicBean;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
@@ -61,7 +60,7 @@
protected final Decorator<CaracteristicBean> decorator;
- protected final Map<Integer, SampleCategoryEnum> mapping;
+ protected final Map<Integer, Object> mapping;
protected final Map<Integer, Caracteristic> caracteristicMap;
@@ -70,14 +69,14 @@
public SampleOrderIdsTableCell(TuttiUIContext context) {
this.context = context;
- this.mapping = SampleCategoryEnum.toIdMapping();
+ this.mapping = null;
this.caracteristicMap = Maps.newTreeMap();
PersistenceService persistenceService = context.getPersistenceService();
- this.caracteristicMap.put(SampleCategoryEnum.size.getFieldValue(), persistenceService.getSizeCategoryCaracteristic());
- this.caracteristicMap.put(SampleCategoryEnum.sex.getFieldValue(), persistenceService.getSexCaracteristic());
- this.caracteristicMap.put(SampleCategoryEnum.maturity.getFieldValue(), persistenceService.getMaturityCaracteristic());
- this.caracteristicMap.put(SampleCategoryEnum.age.getFieldValue(), persistenceService.getAgeCaracteristic());
+// this.caracteristicMap.put(SampleCategoryEnum.size.getFieldValue(), persistenceService.getSizeCategoryCaracteristic());
+// this.caracteristicMap.put(SampleCategoryEnum.sex.getFieldValue(), persistenceService.getSexCaracteristic());
+// this.caracteristicMap.put(SampleCategoryEnum.maturity.getFieldValue(), persistenceService.getMaturityCaracteristic());
+// this.caracteristicMap.put(SampleCategoryEnum.age.getFieldValue(), persistenceService.getAgeCaracteristic());
this.decorator = context.getDecoratorService().getDecoratorByType(
CaracteristicBean.class,
@@ -158,7 +157,7 @@
List<Caracteristic> result = Lists.newArrayList();
for (Integer id : ids) {
- SampleCategoryEnum sampleCategoryEnum = mapping.get(id);
+ Object sampleCategoryEnum = mapping.get(id);
if (sampleCategoryEnum == null) {
throw new TuttiTechnicalException(_("tutti.sampleOrder.caracteristicNotFound", id));
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -62,6 +62,9 @@
getHandler().reloadPersistenceService();
} catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not open db",e);
+ }
// no more db
getContext().setDbLoaded(false);
getHandler().reloadPersistenceService();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -47,7 +47,7 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,7 +26,14 @@
*/
import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.*;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.catches.TuttiWeightComputingException;
import fr.ifremer.tutti.service.catches.TuttiWeightComputingService;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
@@ -34,11 +41,9 @@
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
-import org.jdesktop.swingx.JXTable;
import javax.swing.JOptionPane;
import java.util.List;
-import java.util.Map;
import static org.nuiton.i18n.I18n._;
@@ -54,6 +59,8 @@
@Override
protected void doAction() throws Exception {
+ PersistenceService persistenceService = getContext().getPersistenceService();
+
TuttiWeightComputingService tuttiWeightComputingService = getContext().getTuttiWeightComputingService();
EditCatchesUIModel model = getModel();
@@ -64,7 +71,7 @@
try {
computedSpeciesBatches =
tuttiWeightComputingService.getComputedSpeciesBatches(model.getFishingOperation());
- totalSpeciesSortedWeight = computeSpeciesBatches(computedSpeciesBatches);
+ totalSpeciesSortedWeight = computeSpeciesBatches(persistenceService, computedSpeciesBatches);
} catch (TuttiWeightComputingException e) {
getUI().getTabPane().setSelectedIndex(1);
@@ -73,7 +80,7 @@
SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getModel().getRows().get(index);
int column;
if (SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) {
- column = getFinestCategoryColumn(row.getFinestCategory().getCategoryType());
+ column = getFinestCategoryColumn(row.getFinestCategory().getCategoryId());
} else {
column = 6;
}
@@ -87,7 +94,7 @@
try {
computedBenthosBatches =
tuttiWeightComputingService.getComputedBenthosBatches(model.getFishingOperation());
- totalBenthosSortedWeight = computeBenthosBatches(computedBenthosBatches);
+ totalBenthosSortedWeight = computeBenthosBatches(persistenceService, computedBenthosBatches);
} catch (TuttiWeightComputingException e) {
getUI().getTabPane().setSelectedIndex(2);
@@ -96,7 +103,7 @@
BenthosBatchRowModel row = getUI().getBenthosTabContent().getModel().getRows().get(index);
int column;
if (BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) {
- column = getFinestCategoryColumn(row.getFinestCategory().getCategoryType());
+ column = getFinestCategoryColumn(row.getFinestCategory().getCategoryId());
} else {
column = 6;
}
@@ -199,7 +206,7 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
- protected Float computeSpeciesBatches(BatchContainer<SpeciesBatch> computedSpeciesBatches) {
+ protected Float computeSpeciesBatches(PersistenceService persistenceService, BatchContainer<SpeciesBatch> computedSpeciesBatches) {
Float totalSortedWeight = 0f;
if (computedSpeciesBatches != null) {
@@ -207,14 +214,21 @@
List<SpeciesBatch> children = computedSpeciesBatches.getChildren();
for (SpeciesBatch batch : children) {
SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getHandler().loadBatch(batch, null, rows);
- Float weight = row.getSortedUnsortedCategoryWeight();
- if (weight == null) {
- weight = row.getSortedUnsortedCategoryComputedWeight();
- }
- if (SortedUnsortedEnum.SORTED.matchValue(
- row.getSortedUnsortedCategoryValue())) {
+// Float weight = row.getSortedUnsortedCategoryWeight();
+// if (weight == null) {
+// weight = row.getSortedUnsortedCategoryComputedWeight();
+// }
+ if (persistenceService.isVracSpeciesBatch(row)) {
+ SampleCategory<?> sampleCategory = row.getFirstSampleCategory();
+ Float weight = TuttiEntities.getValueOrComputedValue(
+ sampleCategory.getCategoryWeight(),
+ sampleCategory.getComputedWeight());
totalSortedWeight += weight;
}
+// if (SortedUnsortedEnum.SORTED.matchValue(
+// row.getSortedUnsortedCategoryValue())) {
+// totalSortedWeight += weight;
+// }
}
getUI().getSpeciesTabContent().getModel().setRows(rows);
}
@@ -222,7 +236,7 @@
return totalSortedWeight;
}
- protected Float computeBenthosBatches(BatchContainer<BenthosBatch> computedBenthosBatches) {
+ protected Float computeBenthosBatches(PersistenceService persistenceService, BatchContainer<BenthosBatch> computedBenthosBatches) {
Float totalSortedWeight = 0f;
if (computedBenthosBatches != null) {
@@ -230,15 +244,22 @@
List<BenthosBatch> children = computedBenthosBatches.getChildren();
for (BenthosBatch batch : children) {
BenthosBatchRowModel row = getUI().getBenthosTabContent().getHandler().loadBatch(batch, null, rows);
- Float weight = row.getSortedUnsortedCategoryWeight();
- if (weight == null) {
- weight = row.getSortedUnsortedCategoryComputedWeight();
+// Float weight = row.getSortedUnsortedCategoryWeight();
+// if (weight == null) {
+// weight = row.getSortedUnsortedCategoryComputedWeight();
+//
+// }
- }
- if (SortedUnsortedEnum.SORTED.matchValue(
- row.getSortedUnsortedCategoryValue())) {
+ if (persistenceService.isVracBenthosBatch(row)) {
+ SampleCategory<?> sampleCategory = row.getFirstSampleCategory();
+ Float weight = TuttiEntities.getValueOrComputedValue(
+ sampleCategory.getCategoryWeight(),
+ sampleCategory.getComputedWeight());
totalSortedWeight += weight;
}
+// if (SortedUnsortedEnum.SORTED.matchValue(row.getSortedUnsortedCategoryValue())) {
+// totalSortedWeight += weight;
+// }
}
getUI().getBenthosTabContent().getModel().setRows(rows);
@@ -246,11 +267,10 @@
return totalSortedWeight;
}
- protected int getFinestCategoryColumn(SampleCategoryEnum categoryType) {
+ protected int getFinestCategoryColumn(Integer categoryId) {
int column = 1;
List<Integer> samplingOrderIds = getConfig().getServiceConfig().getSamplingOrderIds();
- Integer categoryId = categoryType.getFieldValue();
int index = samplingOrderIds.indexOf(categoryId);
if (index > -1) {
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,26 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches;
+
+import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public interface SampleCategoryAble<E extends SampleCategoryAble> {
+
+ Integer getCategoryIndex(Integer id);
+
+ void setSampleCategory(SampleCategory sampleCategory);
+
+ SampleCategory<?> getFirstSampleCategory();
+
+ SampleCategory getFinestCategory();
+
+ SampleCategory getSampleCategoryById(Integer sampleCategoryId);
+
+ void setSampleCategoryWeight(Integer sampleCategoryId, Object value);
+
+ E getFirstAncestor(SampleCategory<?> entrySampleCategory);
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,53 +24,50 @@
* #L%
*/
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 1.2
*/
-public class SampleCategoryColumnIdentifier<R> extends ColumnIdentifier<R> {
+public class SampleCategoryColumnIdentifier<R extends SampleCategoryAble> extends ColumnIdentifier<R> {
private static final long serialVersionUID = 1L;
- public static <R> SampleCategoryColumnIdentifier<R> newId(String propertyName,
- String weightPropertyName,
- SampleCategoryEnum sampleCategoryType,
- String headerI18nKey,
- String headerTipI18nKey) {
+ public static <R extends SampleCategoryAble> SampleCategoryColumnIdentifier<R> newId(String propertyName,
+ Integer sampleCategoryId,
+ String headerI18nKey,
+ String headerTipI18nKey) {
return new SampleCategoryColumnIdentifier<R>(propertyName,
- weightPropertyName,
- sampleCategoryType,
+ sampleCategoryId,
headerI18nKey,
headerTipI18nKey);
}
- private final SampleCategoryEnum sampleCategoryType;
+ private final Integer sampleCategoryId;
- private final String weightPropertyName;
-
SampleCategoryColumnIdentifier(String propertyName,
- String weightPropertyName,
- SampleCategoryEnum sampleCategoryType,
+ Integer sampleCategoryId,
String headerI18nKey,
String headerTipI18nKey) {
super(propertyName, headerI18nKey, headerTipI18nKey);
- this.weightPropertyName = weightPropertyName;
- this.sampleCategoryType = sampleCategoryType;
+ this.sampleCategoryId = sampleCategoryId;
}
- public void setWeightValue(R entry, Object value) {
- TuttiUIUtil.setProperty(entry, weightPropertyName, value);
+ @Override
+ public Object getValue(R entry) {
+ SampleCategory sampleCategory = entry.getSampleCategoryById(getSampleCategoryId());
+ return sampleCategory;
}
- public SampleCategoryEnum getSampleCategoryType() {
- return sampleCategoryType;
+ public void setWeightValue(R entry, Object value) {
+
+ entry.setSampleCategoryWeight(getSampleCategoryId(), value);
}
- public String getWeightPropertyName() {
- return weightPropertyName;
+ public Integer getSampleCategoryId() {
+ return sampleCategoryId;
}
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -28,7 +28,7 @@
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.swing.editor.NumberEditor;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import javax.swing.AbstractCellEditor;
import javax.swing.JComponent;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -63,7 +63,7 @@
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import org.nuiton.validator.NuitonValidatorResult;
import javax.swing.JComponent;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -32,12 +32,14 @@
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryAble;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -56,7 +58,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, BenthosBatchRowModel> implements BenthosBatch, AttachmentModelAware {
+public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, BenthosBatchRowModel> implements BenthosBatch, AttachmentModelAware, SampleCategoryAble<BenthosBatchRowModel> {
private static final long serialVersionUID = 1L;
@@ -64,46 +66,14 @@
public static final String PROPERTY_SPECIES = "species";
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory";
+ public static final String PROPERTY_SAMPLE_CATEGORY = "sampleCategory";
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE = "sortedUnsortedCategoryValue";
+ public static final String PROPERTY_SAMPLE_CATEGORY_VALUE = "sampleCategoryValue";
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT = "sortedUnsortedCategoryWeight";
+ public static final String PROPERTY_SAMPLE_CATEGORY_WEIGHT = "sampleCategoryWeight";
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_COMPUTED_WEIGHT = "sortedUnsortedComputedWeight";
+ public static final String PROPERTY_SAMPLE_CATEGORY_COMPUTED_WEIGHT = "sampleCategoryComputedWeight";
- public static final String PROPERTY_SIZE_CATEGORY = "sizeCategory";
-
- public static final String PROPERTY_SIZE_CATEGORY_VALUE = "sizeCategoryValue";
-
- public static final String PROPERTY_SIZE_CATEGORY_WEIGHT = "sizeCategoryWeight";
-
- public static final String PROPERTY_SIZE_CATEGORY_COMPUTED_WEIGHT = "sexCategoryComputedWeight";
-
- public static final String PROPERTY_SEX_CATEGORY = "sexCategory";
-
- public static final String PROPERTY_SEX_CATEGORY_VALUE = "sexCategoryValue";
-
- public static final String PROPERTY_SEX_CATEGORY_WEIGHT = "sexCategoryWeight";
-
- public static final String PROPERTY_SEX_CATEGORY_COMPUTED_WEIGHT = "sexCategoryComputedWeight";
-
- public static final String PROPERTY_MATURITY_CATEGORY = "maturityCategory";
-
- public static final String PROPERTY_MATURITY_CATEGORY_VALUE = "maturityCategoryValue";
-
- public static final String PROPERTY_MATURITY_CATEGORY_COMPUTED_WEIGHT = "maturityCategoryComputedWeight";
-
- public static final String PROPERTY_MATURITY_CATEGORY_WEIGHT = "maturityCategoryWeight";
-
- public static final String PROPERTY_AGE_CATEGORY = "ageCategory";
-
- public static final String PROPERTY_AGE_CATEGORY_VALUE = "ageCategoryValue";
-
- public static final String PROPERTY_AGE_CATEGORY_COMPUTED_WEIGHT = "ageCategoryComputedWeight";
-
- public static final String PROPERTY_AGE_CATEGORY_WEIGHT = "ageCategoryWeight";
-
public static final String PROPERTY_WEIGHT = "weight";
public static final String PROPERTY_NUMBER = "number";
@@ -130,41 +100,13 @@
protected Species species;
/**
- * Is catch is vrac or horsVrac?.
+ * All categories(can not be null).
*
- * @since 0.2
+ * @since 2.5
*/
- protected SampleCategory<CaracteristicQualitativeValue> sortedUnsortedCategory;
+ protected final SampleCategory<?>[] categories;
/**
- * Weight category (can be null).
- *
- * @since 0.2
- */
- protected SampleCategory<CaracteristicQualitativeValue> sizeCategory;
-
- /**
- * Sex (can be null).
- *
- * @since 0.2
- */
- protected SampleCategory<CaracteristicQualitativeValue> sexCategory;
-
- /**
- * Maturity (can be null).
- *
- * @since 0.2
- */
- protected SampleCategory<CaracteristicQualitativeValue> maturityCategory;
-
- /**
- * Age (can be null).
- *
- * @since 0.2
- */
- protected SampleCategory<Float> ageCategory;
-
- /**
* Is the species need to be confirmed?.
*
* @since 0.2
@@ -224,6 +166,8 @@
*/
protected List<BenthosBatchRowModel> childBatch;
+ protected final SampleCategoryModel sampleCategoryModel;
+
protected static final Binder<BenthosBatch, BenthosBatchRowModel> fromBeanBinder =
BinderFactory.newBinder(BenthosBatch.class,
BenthosBatchRowModel.class);
@@ -232,23 +176,28 @@
BinderFactory.newBinder(BenthosBatchRowModel.class,
BenthosBatch.class);
- public BenthosBatchRowModel() {
+ public BenthosBatchRowModel(SampleCategoryModel sampleCategoryModel) {
super(BenthosBatch.class, fromBeanBinder, toBeanBinder);
- sortedUnsortedCategory = SampleCategory.newSample(SampleCategoryEnum.sortedUnsorted);
- sizeCategory = SampleCategory.newSample(SampleCategoryEnum.size);
- sexCategory = SampleCategory.newSample(SampleCategoryEnum.sex);
- maturityCategory = SampleCategory.newSample(SampleCategoryEnum.maturity);
- ageCategory = SampleCategory.newSample(SampleCategoryEnum.age);
+ this.sampleCategoryModel = sampleCategoryModel;
+ categories = new SampleCategory[sampleCategoryModel.getNbSampling()];
+
+ for (int i = 0; i < categories.length; i++) {
+ SampleCategoryModelEntry entry = sampleCategoryModel.getCategoryByIndex(i);
+ SampleCategory<?> category = SampleCategory.newSample(entry);
+ categories[i] = category;
+ }
+
computedOrNotWeight.addPropagateListener(PROPERTY_WEIGHT, this);
computedOrNotWeight.addPropagateListener(PROPERTY_COMPUTED_WEIGHT, this);
computedOrNotNumber.addPropagateListener(PROPERTY_NUMBER, this);
computedOrNotNumber.addPropagateListener(PROPERTY_COMPUTED_NUMBER, this);
}
- public BenthosBatchRowModel(BenthosBatch aBatch,
+ public BenthosBatchRowModel(SampleCategoryModel sampleCategoryModel,
+ BenthosBatch aBatch,
List<BenthosBatchFrequency> frequencies) {
- this();
+ this(sampleCategoryModel);
fromBean(aBatch);
List<BenthosFrequencyRowModel> frequencyRows =
BenthosFrequencyRowModel.fromBeans(frequencies);
@@ -262,69 +211,82 @@
}
//------------------------------------------------------------------------//
- //-- Sample category --//
+ //-- SampleCategoryAble --//
//------------------------------------------------------------------------//
- public void setSampleCategory(SampleCategory sampleCategory) {
- switch (sampleCategory.getCategoryType()) {
- case sortedUnsorted:
- setSortedUnsortedCategory(sampleCategory);
+ @Override
+ public Integer getCategoryIndex(Integer id) {
+ Integer result = null;
+ for (SampleCategory<?> category : categories) {
+ if (category != null && id.equals(category.getCategoryId())) {
+ result = category.getCategoryDef().getOrder();
break;
- case size:
- setSizeCategory(sampleCategory);
- break;
- case sex:
- setSexCategory(sampleCategory);
- break;
- case maturity:
- setMaturityCategory(sampleCategory);
- break;
- case age:
- setAgeCategory(sampleCategory);
+ }
}
+ return result;
}
- public SampleCategory<?> getSampleCategory(SampleCategoryEnum sampleCategoryEnum) {
- SampleCategory sampleCategory = null;
- switch (sampleCategoryEnum) {
- case sortedUnsorted:
- sampleCategory = getSortedUnsortedCategory();
+ @Override
+ public void setSampleCategory(SampleCategory sampleCategory) {
+ int index = sampleCategory.getCategoryDef().getOrder();
+ SampleCategory<?> oldCategory = categories[index];
+ Object oldValue = oldCategory.getCategoryValue();
+ Object oldWeight = oldCategory.getCategoryWeight();
+ Object oldComputedWeight = oldCategory.getComputedWeight();
+ categories[index] = sampleCategory;
+ //FIXME (indexed)
+ fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY, index, oldCategory, sampleCategory);
+ fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, index, oldValue, sampleCategory.getCategoryValue());
+ fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_WEIGHT, index, oldWeight, sampleCategory.getCategoryWeight());
+ fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_COMPUTED_WEIGHT, index, oldComputedWeight, sampleCategory.getComputedWeight());
+ }
+
+ @Override
+ public SampleCategory<?> getFirstSampleCategory() {
+ return categories[0];
+ }
+
+ @Override
+ public SampleCategory getFinestCategory() {
+ SampleCategory result = null;
+ for (int i = categories.length - 1; i > -1; i--) {
+ SampleCategory<?> category = categories[i];
+ if (category != null && category.isValid()) {
+ result = category;
break;
- case size:
- sampleCategory = getSizeCategory();
- break;
- case sex:
- sampleCategory = getSexCategory();
- break;
- case maturity:
- sampleCategory = getMaturityCategory();
- break;
- case age:
- sampleCategory = getAgeCategory();
- break;
- default:
+ }
}
- return sampleCategory;
+ return result;
}
- public SampleCategory getFinestCategory() {
- SampleCategory finestCategory;
- if (ageCategory.isValid()) {
- finestCategory = ageCategory;
+ @Override
+ public SampleCategory<?> getSampleCategoryById(Integer sampleCategoryId) {
+ Integer index = getCategoryIndex(sampleCategoryId);
+ SampleCategory<?> result = index == null ? null : categories[index];
+ return result;
+ }
- } else if (maturityCategory.isValid()) {
- finestCategory = maturityCategory;
+ @Override
+ public void setSampleCategoryWeight(Integer sampleCategoryId, Object value) {
+ SampleCategory<?> sampleCategory =
+ getSampleCategoryById(sampleCategoryId);
+ TuttiUIUtil.setProperty(sampleCategory,
+ SampleCategory.PROPERTY_CATEGORY_WEIGHT, value);
+ firePropertyChange(PROPERTY_SAMPLE_CATEGORY_WEIGHT, null, sampleCategory);
+ }
- } else if (sexCategory.isValid()) {
- finestCategory = sexCategory;
+ @Override
+ public BenthosBatchRowModel getFirstAncestor(SampleCategory<?> entrySampleCategory) {
+ BenthosBatchRowModel result = this;
+ if (getParentBatch() != null) {
+ BenthosBatchRowModel parentBatch = getParentBatch();
+ SampleCategory<?> parentSampleCategory = parentBatch.getSampleCategoryById(entrySampleCategory.getCategoryId());
+ if (ObjectUtils.equals(entrySampleCategory, parentSampleCategory)) {
- } else if (sizeCategory.isValid()) {
- finestCategory = sizeCategory;
-
- } else {
- finestCategory = sortedUnsortedCategory;
+ result = parentBatch.getFirstAncestor(entrySampleCategory);
+ }
}
- return finestCategory;
+ return result;
}
//------------------------------------------------------------------------//
@@ -344,226 +306,6 @@
}
//------------------------------------------------------------------------//
- //-- SortedUnsorted category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<CaracteristicQualitativeValue> getSortedUnsortedCategory() {
- return sortedUnsortedCategory;
- }
-
- public void setSortedUnsortedCategory(SampleCategory<CaracteristicQualitativeValue> sortedUnsortedCategory) {
- Object oldCategory = getSortedUnsortedCategory();
- Object oldValue = getSortedUnsortedCategoryValue();
- Object oldWeight = getSortedUnsortedCategoryWeight();
- Object oldComputedWeight = getSortedUnsortedCategoryComputedWeight();
- this.sortedUnsortedCategory = sortedUnsortedCategory;
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldCategory, sortedUnsortedCategory);
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE, oldValue, getSortedUnsortedCategoryValue());
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldWeight, getSortedUnsortedCategoryWeight());
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getSortedUnsortedCategoryComputedWeight());
- }
-
- public CaracteristicQualitativeValue getSortedUnsortedCategoryValue() {
- return sortedUnsortedCategory.getCategoryValue();
- }
-
- public Float getSortedUnsortedCategoryWeight() {
- return sortedUnsortedCategory.getCategoryWeight();
- }
-
- public void setSortedUnsortedCategoryWeight(Float sortedUnsortedCategoryWeight) {
- Object oldValue = getSortedUnsortedCategoryWeight();
- sortedUnsortedCategory.setCategoryWeight(sortedUnsortedCategoryWeight);
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldValue, sortedUnsortedCategoryWeight);
- }
-
- public Float getSortedUnsortedCategoryComputedWeight() {
- return sortedUnsortedCategory.getComputedWeight();
- }
-
- public void setSortedUnsortedCategoryComputedWeight(Float sortedUnsortedCategoryComputedWeight) {
- Object oldValue = getSortedUnsortedCategoryComputedWeight();
- sortedUnsortedCategory.setComputedWeight(sortedUnsortedCategoryComputedWeight);
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_COMPUTED_WEIGHT, oldValue, sortedUnsortedCategoryComputedWeight);
- }
-
- //------------------------------------------------------------------------//
- //-- Size category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<CaracteristicQualitativeValue> getSizeCategory() {
- return sizeCategory;
- }
-
- public void setSizeCategory(SampleCategory<CaracteristicQualitativeValue> sizeCategory) {
- Object oldCategory = getSizeCategory();
- Object oldValue = getSizeCategoryValue();
- Object oldWeight = getSizeCategoryWeight();
- Object oldComputedWeight = getSizeCategoryComputedWeight();
- this.sizeCategory = sizeCategory;
- firePropertyChange(PROPERTY_SIZE_CATEGORY, oldCategory, sizeCategory);
- firePropertyChange(PROPERTY_SIZE_CATEGORY_VALUE, oldValue, getSizeCategoryValue());
- firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldWeight, getSizeCategoryWeight());
- firePropertyChange(PROPERTY_SIZE_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getSizeCategoryComputedWeight());
- }
-
- public CaracteristicQualitativeValue getSizeCategoryValue() {
- return sizeCategory.getCategoryValue();
- }
-
- public Float getSizeCategoryWeight() {
- return sizeCategory.getCategoryWeight();
- }
-
- public void setSizeCategoryWeight(Float sizeCategoryWeight) {
- Object oldValue = getSizeCategoryWeight();
- this.sizeCategory.setCategoryWeight(sizeCategoryWeight);
- firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldValue, sizeCategoryWeight);
- }
-
- public Float getSizeCategoryComputedWeight() {
- return sizeCategory.getComputedWeight();
- }
-
- public void setSizeCategoryComputedWeight(Float sizeCategoryComputedWeight) {
- Object oldValue = getSizeCategoryComputedWeight();
- this.sizeCategory.setComputedWeight(sizeCategoryComputedWeight);
- firePropertyChange(PROPERTY_SIZE_CATEGORY_COMPUTED_WEIGHT, oldValue, sizeCategoryComputedWeight);
- }
-
- //------------------------------------------------------------------------//
- //-- Sex category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<CaracteristicQualitativeValue> getSexCategory() {
- return sexCategory;
- }
-
- public void setSexCategory(SampleCategory<CaracteristicQualitativeValue> sexCategory) {
- Object oldCategory = getSexCategory();
- Object oldValue = getSexCategoryValue();
- Object oldWeight = getSexCategoryWeight();
- Object oldComputedWeight = getSexCategoryComputedWeight();
- this.sexCategory = sexCategory;
- firePropertyChange(PROPERTY_SEX_CATEGORY, oldCategory, sexCategory);
- firePropertyChange(PROPERTY_SEX_CATEGORY_VALUE, oldValue, getSexCategoryValue());
- firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldWeight, getSexCategoryWeight());
- firePropertyChange(PROPERTY_SEX_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getSexCategoryComputedWeight());
- }
-
- public CaracteristicQualitativeValue getSexCategoryValue() {
- return sexCategory.getCategoryValue();
- }
-
- public Float getSexCategoryWeight() {
- return sexCategory.getCategoryWeight();
- }
-
- public void setSexCategoryWeight(Float sexCategoryWeight) {
- Object oldValue = getSexCategoryWeight();
- this.sexCategory.setCategoryWeight(sexCategoryWeight);
- firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldValue, sexCategoryWeight);
- }
-
- public Float getSexCategoryComputedWeight() {
- return sexCategory.getComputedWeight();
- }
-
- public void setSexCategoryComputedWeight(Float sexCategoryComputedWeight) {
- Object oldValue = getSexCategoryComputedWeight();
- this.sexCategory.setComputedWeight(sexCategoryComputedWeight);
- firePropertyChange(PROPERTY_SEX_CATEGORY_COMPUTED_WEIGHT, oldValue, sexCategoryComputedWeight);
- }
-
- //------------------------------------------------------------------------//
- //-- Maturity category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<CaracteristicQualitativeValue> getMaturityCategory() {
- return maturityCategory;
- }
-
- public void setMaturityCategory(SampleCategory<CaracteristicQualitativeValue> maturityCategory) {
- Object oldCategory = getMaturityCategory();
- Object oldValue = getMaturityCategoryValue();
- Object oldWeight = getMaturityCategoryWeight();
- Object oldComputedWeight = getMaturityCategoryComputedWeight();
- this.maturityCategory = maturityCategory;
- firePropertyChange(PROPERTY_MATURITY_CATEGORY, oldCategory, maturityCategory);
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_VALUE, oldValue, getMaturityCategoryValue());
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldWeight, getMaturityCategoryWeight());
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getMaturityCategoryComputedWeight());
- }
-
- public CaracteristicQualitativeValue getMaturityCategoryValue() {
- return maturityCategory.getCategoryValue();
- }
-
- public Float getMaturityCategoryWeight() {
- return maturityCategory.getCategoryWeight();
- }
-
- public void setMaturityCategoryWeight(Float maturityCategoryWeight) {
- Object oldValue = getMaturityCategoryWeight();
- this.maturityCategory.setCategoryWeight(maturityCategoryWeight);
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldValue, maturityCategoryWeight);
- }
-
- public Float getMaturityCategoryComputedWeight() {
- return maturityCategory.getComputedWeight();
- }
-
- public void setMaturityCategoryComputedWeight(Float maturityCategoryComputedWeight) {
- Object oldValue = getMaturityCategoryComputedWeight();
- this.maturityCategory.setComputedWeight(maturityCategoryComputedWeight);
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_COMPUTED_WEIGHT, oldValue, maturityCategoryComputedWeight);
- }
-
- //------------------------------------------------------------------------//
- //-- Age category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<Float> getAgeCategory() {
- return ageCategory;
- }
-
- public void setAgeCategory(SampleCategory<Float> ageCategory) {
- Object oldCategory = getAgeCategory();
- Object oldValue = getAgeCategoryValue();
- Object oldWeight = getAgeCategoryWeight();
- Object oldComputedWeight = getAgeCategoryComputedWeight();
- this.ageCategory = ageCategory;
- firePropertyChange(PROPERTY_AGE_CATEGORY, oldCategory, ageCategory);
- firePropertyChange(PROPERTY_AGE_CATEGORY_VALUE, oldValue, getAgeCategoryValue());
- firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldWeight, getAgeCategoryWeight());
- firePropertyChange(PROPERTY_AGE_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getAgeCategoryComputedWeight());
- }
-
- public Float getAgeCategoryValue() {
- return ageCategory.getCategoryValue();
- }
-
- public Float getAgeCategoryWeight() {
- return ageCategory.getCategoryWeight();
- }
-
- public void setAgeCategoryWeight(Float ageCategoryWeight) {
- Object oldValue = getAgeCategoryWeight();
- ageCategory.setCategoryWeight(ageCategoryWeight);
- firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldValue, ageCategoryWeight);
- }
-
- public Float getAgeCategoryComputedWeight() {
- return ageCategory.getComputedWeight();
- }
-
- public void setAgeCategoryComputedWeight(Float ageCategoryComputedWeight) {
- Object oldValue = getAgeCategoryComputedWeight();
- ageCategory.setComputedWeight(ageCategoryComputedWeight);
- firePropertyChange(PROPERTY_AGE_CATEGORY_COMPUTED_WEIGHT, oldValue, ageCategoryComputedWeight);
- }
-
- //------------------------------------------------------------------------//
//-- Navigation properties --//
//------------------------------------------------------------------------//
@@ -740,12 +482,12 @@
}
@Override
- public SampleCategoryEnum getSampleCategoryType() {
+ public Integer getSampleCategoryId() {
return null;
}
@Override
- public void setSampleCategoryType(SampleCategoryEnum sampleCategoryType) {
+ public void setSampleCategoryId(Integer sampleCategoryId) {
}
@Override
@@ -851,19 +593,6 @@
}
}
- public BenthosBatchRowModel getFirstAncestor(SampleCategory<?> entrySampleCategory) {
- BenthosBatchRowModel result = this;
- if (getParentBatch() != null) {
- BenthosBatchRowModel parentBatch = getParentBatch();
- SampleCategory<?> parentSampleCategory = parentBatch.getSampleCategory(entrySampleCategory.getCategoryType());
- if (ObjectUtils.equals(entrySampleCategory, parentSampleCategory)) {
-
- result = parentBatch.getFirstAncestor(entrySampleCategory);
- }
- }
- return result;
- }
-
@Override
public Integer getRankOrder() {
return null;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,7 +26,7 @@
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryColumnIdentifier;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
@@ -35,6 +35,8 @@
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.table.TableColumnModelExt;
+import javax.swing.table.TableColumn;
+import java.util.Enumeration;
import java.util.Set;
import static org.nuiton.i18n.I18n.n_;
@@ -56,41 +58,6 @@
n_("tutti.editBenthosBatch.table.header.species"),
n_("tutti.editBenthosBatch.table.header.species.tip"));
- public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId(
- BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
- BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
- SampleCategoryEnum.sortedUnsorted,
- n_("tutti.editBenthosBatch.table.header.sortedUnsortedCategory"),
- n_("tutti.editBenthosBatch.table.header.sortedUnsortedCategory.tip"));
-
- public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId(
- BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY,
- BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
- SampleCategoryEnum.size,
- n_("tutti.editBenthosBatch.table.header.sizeCategory"),
- n_("tutti.editBenthosBatch.table.header.sizeCategory.tip"));
-
- public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId(
- BenthosBatchRowModel.PROPERTY_SEX_CATEGORY,
- BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
- SampleCategoryEnum.sex,
- n_("tutti.editBenthosBatch.table.header.sexCategory"),
- n_("tutti.editBenthosBatch.table.header.sexCategory.tip"));
-
- public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId(
- BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
- SampleCategoryEnum.maturity,
- n_("tutti.editBenthosBatch.table.header.maturityCategory"),
- n_("tutti.editBenthosBatch.table.header.maturityCategory.tip"));
-
- public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId(
- BenthosBatchRowModel.PROPERTY_AGE_CATEGORY,
- BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
- SampleCategoryEnum.age,
- n_("tutti.editBenthosBatch.table.header.ageCategory"),
- n_("tutti.editBenthosBatch.table.header.ageCategory.tip"));
-
public static final ColumnIdentifier<BenthosBatchRowModel> WEIGHT = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_COMPUTED_WEIGHT,
n_("tutti.editBenthosBatch.table.header.weight"),
@@ -130,8 +97,12 @@
*/
protected final Set<SampleCategoryColumnIdentifier<BenthosBatchRowModel>> sampleCols;
- public BenthosBatchTableModel(TableColumnModelExt columnModel) {
+ protected final SampleCategoryModel sampleCategoryModel;
+
+ public BenthosBatchTableModel(SampleCategoryModel sampleCategoryModel,
+ TableColumnModelExt columnModel) {
super(columnModel, false, false);
+ this.sampleCategoryModel = sampleCategoryModel;
setNoneEditableCols(SPECIES);
frequencyCols = Sets.newHashSet();
@@ -139,27 +110,21 @@
frequencyCols.add(WEIGHT);
sampleCols = Sets.newHashSet();
- sampleCols.add(SORTED_UNSORTED_CATEGORY);
- sampleCols.add(SIZE_CATEGORY);
- sampleCols.add(SEX_CATEGORY);
- sampleCols.add(MATURITY_CATEGORY);
- sampleCols.add(AGE_CATEGORY);
- }
-
- public SampleCategoryColumnIdentifier<BenthosBatchRowModel> getCategoryIdentifierForWeightProperty(String weightPropertyName) {
- SampleCategoryColumnIdentifier<BenthosBatchRowModel> result = null;
- for (SampleCategoryColumnIdentifier<BenthosBatchRowModel> sampleCol : sampleCols) {
- if (weightPropertyName.equals(sampleCol.getWeightPropertyName())) {
- result = sampleCol;
- break;
+ Enumeration<TableColumn> columns = columnModel.getColumns();
+ while (columns.hasMoreElements()) {
+ TableColumn tableColumn = columns.nextElement();
+ Object identifier = tableColumn.getIdentifier();
+ if (identifier instanceof SampleCategoryColumnIdentifier<?>) {
+ SampleCategoryColumnIdentifier<BenthosBatchRowModel> categoryColumnIdentifier =
+ (SampleCategoryColumnIdentifier<BenthosBatchRowModel>) identifier;
+ sampleCols.add(categoryColumnIdentifier);
}
}
- return result;
}
@Override
public BenthosBatchRowModel createNewRow() {
- BenthosBatchRowModel result = new BenthosBatchRowModel();
+ BenthosBatchRowModel result = new BenthosBatchRowModel(sampleCategoryModel);
// by default empty row is not valid
result.setValid(false);
@@ -172,25 +137,17 @@
int columnIndex,
ColumnIdentifier<BenthosBatchRowModel> propertyName,
BenthosBatchRowModel entry) {
- /*
if (sampleCols.contains(propertyName)) {
- ((SampleCategoryColumnIdentifier<BenthosBatchRowModel>) propertyName).setWeightValue(entry, aValue);
- } else {
- super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
- }
- */
- if (sampleCols.contains(propertyName)) {
-
SampleCategoryColumnIdentifier<BenthosBatchRowModel> sampleCategoryColumnIdentifier = (SampleCategoryColumnIdentifier<BenthosBatchRowModel>) propertyName;
sampleCategoryColumnIdentifier.setWeightValue(entry, aValue);
// must find out first ancestor with this category
- SampleCategoryEnum sampleCategoryType = sampleCategoryColumnIdentifier.getSampleCategoryType();
+ Integer sampleCategoryId = sampleCategoryColumnIdentifier.getSampleCategoryId();
if (log.isDebugEnabled()) {
- log.debug("Sample category: " + sampleCategoryType + " modified at row: " + rowIndex);
+ log.debug("Sample category: " + sampleCategoryId + " modified at row: " + rowIndex);
}
- SampleCategory<?> sampleCategory = entry.getSampleCategory(sampleCategoryType);
+ SampleCategory<?> sampleCategory = entry.getSampleCategoryById(sampleCategoryId);
BenthosBatchRowModel firstAncestor = entry.getFirstAncestor(sampleCategory);
int firstRowIndex = getRowIndex(firstAncestor);
@@ -234,8 +191,6 @@
} else if (sampleCols.contains(propertyName)) {
- SampleCategoryColumnIdentifier<BenthosBatchRowModel> samplePropertyName = (SampleCategoryColumnIdentifier<BenthosBatchRowModel>) propertyName;
-
// can only edit if a category value is setted
BenthosBatchRowModel entry = getEntry(rowIndex);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
@@ -34,7 +33,8 @@
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
@@ -54,6 +54,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
@@ -69,6 +70,7 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -78,7 +80,7 @@
import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.jdesktop.swingx.table.TableColumnModelExt;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import org.nuiton.validator.NuitonValidatorResult;
import javax.swing.JComponent;
@@ -96,10 +98,10 @@
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -111,50 +113,26 @@
private static final Log log =
LogFactory.getLog(BenthosBatchUIHandler.class);
- public static final Set<String> SAMPLING_PROPERTIES = Sets.newHashSet(
- BenthosBatchRowModel.PROPERTY_SPECIES,
- BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
- BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY,
- BenthosBatchRowModel.PROPERTY_SEX_CATEGORY,
- BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- BenthosBatchRowModel.PROPERTY_AGE_CATEGORY,
- BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT);
-
- public static final Set<String> SAMPLING_WEIGHT_PROPERTIES = Sets.newHashSet(
- BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT);
-
private final EnumMap<TableViewMode, RowFilter<BenthosBatchTableModel, Integer>> tableFilters;
protected ValidationService validationService = getContext().getValidationService();
+ protected final SampleCategoryModel sampleCategoryModel;
+
public BenthosBatchUIHandler(TuttiUI<?, ?> parentUi,
BenthosBatchUI ui) {
super(parentUi, ui,
- BenthosBatchRowModel.PROPERTY_SPECIES,
- BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
- BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY,
- BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_SEX_CATEGORY,
- BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_AGE_CATEGORY,
- BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_WEIGHT,
- BenthosBatchRowModel.PROPERTY_NUMBER,
- BenthosBatchRowModel.PROPERTY_COMMENT,
- BenthosBatchRowModel.PROPERTY_ATTACHMENT,
- BenthosBatchRowModel.PROPERTY_FREQUENCY,
- BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM);
+ SpeciesBatchRowModel.PROPERTY_SPECIES,
+ SpeciesBatchRowModel.PROPERTY_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_NUMBER,
+ SpeciesBatchRowModel.PROPERTY_SAMPLE_CATEGORY_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_COMMENT,
+ SpeciesBatchRowModel.PROPERTY_ATTACHMENT,
+ SpeciesBatchRowModel.PROPERTY_FREQUENCY,
+ SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM);
+
+ sampleCategoryModel = getDataContext().getSampleCategoryModel();
+
tableFilters = new EnumMap<TableViewMode, RowFilter<BenthosBatchTableModel, Integer>>(TableViewMode.class);
tableFilters.put(TableViewMode.ALL, new RowFilter<BenthosBatchTableModel, Integer>() {
@@ -224,13 +202,16 @@
List<BenthosBatch> catches = rootBenthosBatch.getChildren();
+ // use first category from configuration
+ Integer firstCategoryId = sampleCategoryModel.getFirstCategoryId();
+
for (BenthosBatch aBatch : catches) {
// root batch sample categroy is species
Preconditions.checkState(
- aBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted,
+ firstCategoryId.equals(aBatch.getSampleCategoryId()),
"Root species batch must be a sortedUnsorted sample " +
- "category but was:" + aBatch.getSampleCategoryType());
+ "category but was:" + aBatch.getSampleCategoryId());
BenthosBatchRowModel rootRow =
loadBatch(aBatch, null, rows);
@@ -238,7 +219,7 @@
if (log.isDebugEnabled()) {
log.debug("Loaded root batch " +
decorate(rootRow.getSpecies(), DecoratorService.FROM_PROTOCOL) + " - " +
- decorate(rootRow.getSortedUnsortedCategoryValue()));
+ decorate(rootRow.getSampleCategoryById(firstCategoryId)));
}
}
}
@@ -274,9 +255,10 @@
&& row.isBatchLeaf()) {
List<BenthosBatchFrequency> frequencies =
BenthosFrequencyRowModel.toBeans(row.getFrequency(), batch);
- result = TuttiProtocols.isBenthosBatchValid(getDataContext().getProtocol(),
- batch,
- frequencies);
+ result = TuttiProtocols.isBenthosBatchValid(
+ getDataContext().getProtocol(),
+ batch,
+ frequencies);
}
return result;
@@ -291,16 +273,22 @@
recomputeRowValidState(row);
- if (SAMPLING_WEIGHT_PROPERTIES.contains(propertyName)) {
+ if (log.isInfoEnabled()) {
+ log.info("Property modified [" + propertyName + "] <" +
+ oldValue + ":" + newValue + ">");
+ }
+ if (SpeciesBatchRowModel.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(propertyName)) {
+
// sampling category weight has changed, must then save the top
// ancestor row
+ // new value is the sample category
+ SampleCategory<?> sampleCategory = (SampleCategory<?>) newValue;
+ Integer sampleCategoryId = sampleCategory.getCategoryId();
+
BenthosBatchTableModel tableModel = getTableModel();
- SampleCategoryColumnIdentifier<BenthosBatchRowModel> sampleCategoryColumnIdentifier = tableModel.getCategoryIdentifierForWeightProperty(propertyName);
- SampleCategoryEnum sampleCategoryType = sampleCategoryColumnIdentifier.getSampleCategoryType();
- SampleCategory<?> sampleCategory = row.getSampleCategory(sampleCategoryType);
BenthosBatchRowModel firstAncestorRow = row.getFirstAncestor(sampleCategory);
int firstAncestorIndex = tableModel.getRowIndex(firstAncestorRow);
if (rowIndex != firstAncestorIndex) {
@@ -309,7 +297,7 @@
// then only save ancestor
if (log.isInfoEnabled()) {
- log.info("Sample category " + sampleCategoryType +
+ log.info("Sample category " + sampleCategoryId +
" weight was modified, First ancestor row: " +
firstAncestorIndex + " will save it");
}
@@ -502,15 +490,8 @@
initUI(ui);
- Map<Integer, SampleCategoryEnum> categoryEnumMap =
- SampleCategoryEnum.toIdMapping();
+ List<Integer> samplingOrder = sampleCategoryModel.getSamplingOrder();
- List<SampleCategoryEnum> samplingOrder = Lists.newArrayList();
-
- List<Integer> samplingOrderIds = getConfig().getServiceConfig().getSamplingOrderIds();
- for (Integer id : samplingOrderIds) {
- samplingOrder.add(categoryEnumMap.get(id));
- }
if (log.isInfoEnabled()) {
log.info("Will use sampling order: " + samplingOrder);
}
@@ -540,64 +521,22 @@
BenthosBatchTableModel.SPECIES);
}
- { // SortedUnsortedCategory column
+ // Sample category columns
+ for (SampleCategoryModelEntry sampleCategoryDef : sampleCategoryModel.getCategory()) {
+
+ SampleCategoryColumnIdentifier<BenthosBatchRowModel> columnIdentifier = SampleCategoryColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_SAMPLE_CATEGORY + "[" + sampleCategoryDef.getOrder() + "]",
+ sampleCategoryDef.getCategoryId(),
+ n_(sampleCategoryDef.getLabel()),
+ n_(sampleCategoryDef.getLabel()));
+
addSampleCategoryColumnToModel(columnModel,
- BenthosBatchTableModel.SORTED_UNSORTED_CATEGORY,
+ columnIdentifier,
caracteristicDecorator,
defaultRenderer);
}
- for (SampleCategoryEnum sampleCategoryType : samplingOrder) {
- switch (sampleCategoryType) {
-
- case size:
-
- { // SizeCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- BenthosBatchTableModel.SIZE_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
- break;
- case sex:
-
- { // SexCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- BenthosBatchTableModel.SEX_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
- break;
- case maturity:
-
- { // MaturityCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- BenthosBatchTableModel.MATURITY_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
-
- break;
- case age:
-
-
- { // AgeCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- BenthosBatchTableModel.AGE_CATEGORY,
- getDecorator(Float.class, null),
- defaultRenderer);
- }
-
- break;
- }
- }
-
-
{ // Weight column
addColumnToModel(columnModel,
@@ -641,7 +580,7 @@
// create table model
BenthosBatchTableModel tableModel =
- new BenthosBatchTableModel(columnModel);
+ new BenthosBatchTableModel(sampleCategoryModel, columnModel);
table.setModel(tableModel);
table.setColumnModel(columnModel);
@@ -700,9 +639,9 @@
Species species = bethosBatchRootRowModel.getSpecies();
newRow.setSpecies(species);
- CaracteristicQualitativeValue sortedUnsortedCategory = bethosBatchRootRowModel.getSortedUnsortedCategory();
- SampleCategory<CaracteristicQualitativeValue> category = newRow.getSortedUnsortedCategory();
- category.setCategoryValue(sortedUnsortedCategory);
+ CaracteristicQualitativeValue sampleCategory = bethosBatchRootRowModel.getSampleCategory();
+ SampleCategory category = newRow.getFirstSampleCategory();
+ category.setCategoryValue(sampleCategory);
category.setCategoryWeight(bethosBatchRootRowModel.getBatchWeight());
newRow.setSampleCategory(category);
@@ -798,7 +737,7 @@
// create batch rows
- SampleCategoryEnum sampleCategoryEnum = splitModel.getSelectedCategory();
+ SampleCategoryModelEntry sampleCategoryDef = splitModel.getSelectedCategory();
// Create rows in batch table model
@@ -811,7 +750,7 @@
loadBatchRow(parentBatch,
newBatch,
- sampleCategoryEnum,
+ sampleCategoryDef.getCategoryId(),
row.getCategoryValue(),
row.getWeight(),
null);
@@ -837,10 +776,6 @@
}
recomputeBatchActionEnable();
-
-// // reselect this cell
-// AbstractSelectTableAction.doSelectCell(table, rowIndex, 0);
-// table.requestFocus();
}
public void updateTotalFromFrequencies(BenthosBatchRowModel row) {
@@ -877,7 +812,7 @@
Preconditions.checkNotNull(row.getSpecies());
SampleCategory<?> sampleCategory = row.getFinestCategory();
Preconditions.checkNotNull(sampleCategory);
- Preconditions.checkNotNull(sampleCategory.getCategoryType());
+ Preconditions.checkNotNull(sampleCategory.getCategoryId());
Preconditions.checkNotNull(sampleCategory.getCategoryValue());
BenthosBatch catchBean = row.toBean();
@@ -889,7 +824,7 @@
}
// apply sample category
- catchBean.setSampleCategoryType(sampleCategory.getCategoryType());
+ catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
catchBean.setSampleCategoryWeight(sampleCategory.getCategoryWeight());
@@ -944,7 +879,6 @@
//TODO Improve this test
boolean enableAdd = true;
-// CollectionUtils.isNotEmpty(getModel().getAvailableSpecies());
boolean enableRename = false;
boolean enableSplit = false;
@@ -980,16 +914,12 @@
if (enableSplit) {
// can split if selected batch is a leaf
- Map<Integer, SampleCategoryEnum> categoryEnumMap =
- SampleCategoryEnum.toIdMapping();
- List<Integer> samplingOrderIds = getConfig().getServiceConfig().getSamplingOrderIds();
- int lastSamplingId = samplingOrderIds.get(samplingOrderIds.size() - 1);
- SampleCategoryEnum lastCategory = categoryEnumMap.get(lastSamplingId);
+ Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
enableSplit = row.isBatchLeaf()
&& selectedRowCount == 1
- && !lastCategory.equals(row.getFinestCategory().getCategoryType())
+ && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
&& row.getNumber() == null
&& (row.getComputedNumber() == null
|| row.getComputedNumber() == 0);
@@ -1069,7 +999,9 @@
persistenceService.getAllBenthosBatchFrequency(id);
BenthosBatchRowModel newRow =
- new BenthosBatchRowModel(aBatch, frequencies);
+ new BenthosBatchRowModel(sampleCategoryModel,
+ aBatch,
+ frequencies);
List<Attachment> attachments =
persistenceService.getAllAttachments(newRow.getObjectType(),
@@ -1088,15 +1020,15 @@
}
}
- SampleCategoryEnum sampleCategoryEnum = aBatch.getSampleCategoryType();
+ Integer sampleCategoryId = aBatch.getSampleCategoryId();
Preconditions.checkNotNull(
- sampleCategoryEnum,
+ sampleCategoryId,
"Can't have a batch with no sample category, but was: " + aBatch);
loadBatchRow(parentRow,
newRow,
- sampleCategoryEnum,
+ sampleCategoryId,
aBatch.getSampleCategoryValue(),
aBatch.getSampleCategoryWeight(),
aBatch.getSampleCategoryComputedWeight());
@@ -1139,14 +1071,14 @@
protected void loadBatchRow(BenthosBatchRowModel parentRow,
BenthosBatchRowModel newRow,
- SampleCategoryEnum sampleCategoryEnum,
+ Integer sampleCategoryId,
Serializable categoryValue,
Float categoryWeight,
Float categoryComputedWeight) {
// get sample category from his type
SampleCategory sampleCategory =
- newRow.getSampleCategory(sampleCategoryEnum);
+ newRow.getSampleCategoryById(sampleCategoryId);
// fill it
sampleCategory.setCategoryValue(categoryValue);
@@ -1165,21 +1097,12 @@
newRow.setParentBatch(parentRow);
newRow.setSpecies(parentRow.getSpecies());
- if (sampleCategoryEnum != SampleCategoryEnum.sortedUnsorted) {
- newRow.setSortedUnsortedCategory(parentRow.getSortedUnsortedCategory());
+
+ for (Integer id : sampleCategoryModel.getSamplingOrder()) {
+ if (!id.equals(sampleCategoryId)) {
+ newRow.setSampleCategory(parentRow.getSampleCategoryById(id));
+ }
}
- if (sampleCategoryEnum != SampleCategoryEnum.size) {
- newRow.setSizeCategory(parentRow.getSizeCategory());
- }
- if (sampleCategoryEnum != SampleCategoryEnum.sex) {
- newRow.setSexCategory(parentRow.getSexCategory());
- }
- if (sampleCategoryEnum != SampleCategoryEnum.maturity) {
- newRow.setMaturityCategory(parentRow.getMaturityCategory());
- }
- if (sampleCategoryEnum != SampleCategoryEnum.age) {
- newRow.setAgeCategory(parentRow.getAgeCategory());
- }
}
}
@@ -1199,13 +1122,14 @@
public void removeFromSpeciesUsed(BenthosBatchRowModel row) {
Preconditions.checkNotNull(row);
Preconditions.checkNotNull(row.getSpecies());
- Preconditions.checkNotNull(row.getSortedUnsortedCategoryValue());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
+ Preconditions.checkNotNull(firstSampleCategory);
if (log.isInfoEnabled()) {
- log.info("Remove from speciesUsed: " + decorate(row.getSortedUnsortedCategoryValue()) + " - " + decorate(row.getSpecies()));
+ log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
}
BenthosBatchUIModel model = getModel();
- model.getSpeciesUsed().remove(row.getSortedUnsortedCategoryValue(),
- row.getSpecies());
+ model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
if (row.isBatchRoot()) {
model.setRootNumber(model.getRootNumber() - 1);
@@ -1215,15 +1139,16 @@
protected void addToSpeciesUsed(BenthosBatchRowModel row) {
Preconditions.checkNotNull(row);
Preconditions.checkNotNull(row.getSpecies());
- Preconditions.checkNotNull(row.getSortedUnsortedCategoryValue());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
+ Preconditions.checkNotNull(firstSampleCategory);
if (log.isDebugEnabled()) {
log.debug("Add to speciesUsed: " +
- decorate(row.getSortedUnsortedCategoryValue()) +
+ decorate(categoryValue) +
" - " + decorate(row.getSpecies()));
}
BenthosBatchUIModel model = getModel();
- model.getSpeciesUsed().put(row.getSortedUnsortedCategoryValue(),
- row.getSpecies());
+ model.getSpeciesUsed().put(categoryValue, row.getSpecies());
model.setRootNumber(model.getRootNumber() + 1);
}
@@ -1242,13 +1167,13 @@
protected BenthosBatch convertRowToBean(BenthosBatchRowModel row, boolean convertParent) {
SampleCategory<?> sampleCategory = row.getFinestCategory();
Preconditions.checkNotNull(sampleCategory);
- Preconditions.checkNotNull(sampleCategory.getCategoryType());
+ Preconditions.checkNotNull(sampleCategory.getCategoryId());
Preconditions.checkNotNull(sampleCategory.getCategoryValue());
BenthosBatch catchBean = row.toBean();
// apply sample category
- catchBean.setSampleCategoryType(sampleCategory.getCategoryType());
+ catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
catchBean.setSampleCategoryWeight(sampleCategory.getCategoryWeight());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,11 +25,14 @@
*/
import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.jdesktop.swingx.JXTable;
+import java.io.Serializable;
import java.util.Collection;
import java.util.List;
@@ -61,9 +64,11 @@
BenthosBatchUIModel model = handler.getModel();
List<Species> speciesList = Lists.newArrayList(
getDataContext().getReferentBenthosWithSurveyCode());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ Serializable categoryValue = firstSampleCategory.getCategoryValue();
speciesList.removeAll(
model.getSpeciesUsed().get(
- row.getSortedUnsortedCategoryValue()));
+ (CaracteristicQualitativeValue) categoryValue));
selectedSpecies = getHandler().openAddSpeciesDialog(
_("tutti.selectSpecies.title"),
@@ -90,8 +95,10 @@
PersistenceService persistenceService = getContext().getPersistenceService();
persistenceService.changeBenthosBatchSpecies(row.getId(), selectedSpecies);
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ Serializable categoryValue = firstSampleCategory.getCategoryValue();
Collection<Species> speciesUsed = getModel().getSpeciesUsed()
- .get(row.getSortedUnsortedCategoryValue());
+ .get((CaracteristicQualitativeValue) categoryValue);
speciesUsed.remove(row.getSpecies());
changeChildrenSpecies(row, selectedSpecies);
speciesUsed.add(selectedSpecies);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css 2013-07-24 17:35:44 UTC (rev 1153)
@@ -51,16 +51,16 @@
data: {model.getAvailableSpecies()};
}
-#sortedUnsortedCategoryLabel {
- text: "tutti.createBenthosBatch.field.sortedUnsortedCategory";
- toolTipText: "tutti.createBenthosBatch.field.sortedUnsortedCategory.tip";
- labelFor: {sortedUnsortedCategoryComboBox};
- _help: {"tutti.createBenthosBatch.field.sortedUnsortedCategory.help"};
+#sampleCategoryLabel {
+ text: "tutti.createBenthosBatch.field.sampleCategory";
+ toolTipText: "tutti.createBenthosBatch.field.sampleCategory.tip";
+ labelFor: {sampleCategoryComboBox};
+ _help: {"tutti.createBenthosBatch.field.sampleCategory.help"};
}
-#sortedUnsortedCategoryComboBox {
- property: sortedUnsortedCategory;
- selectedItem: {model.getSortedUnsortedCategory()};
+#sampleCategoryComboBox {
+ property: sampleCategory;
+ selectedItem: {model.getSampleCategory()};
}
#batchWeightLabel {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx 2013-07-24 17:35:44 UTC (rev 1153)
@@ -65,8 +65,8 @@
<BeanValidator id='validator' bean='model'
uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
<field name='species' component='speciesComboBox'/>
- <field name='sortedUnsortedCategory'
- component='sortedUnsortedCategoryComboBox'/>
+ <field name='sampleCategory'
+ component='sampleCategoryComboBox'/>
<field name='batchWeight' component='batchWeightField'/>
</BeanValidator>
@@ -102,10 +102,10 @@
<!-- Sorted / Unsorted Category -->
<row>
<cell anchor='west'>
- <JLabel id='sortedUnsortedCategoryLabel'/>
+ <JLabel id='sampleCategoryLabel'/>
</cell>
<cell weightx='1.0' columns='2'>
- <BeanFilterableComboBox id='sortedUnsortedCategoryComboBox'
+ <BeanFilterableComboBox id='sampleCategoryComboBox'
constructorParams='this'
genericType='CaracteristicQualitativeValue'/>
</cell>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,7 +27,9 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
@@ -72,9 +74,12 @@
super(parentUi.getHandler().getContext(), ui);
this.persistenceService = context.getPersistenceService();
- Caracteristic caracteristic =
- persistenceService.getSortedUnsortedCaracteristic();
- sortedValue = SortedUnsortedEnum.SORTED.getValue(caracteristic);
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ SampleCategoryModelEntry caracteristic = sampleCategoryModel.getCategoryById(sampleCategoryModel.getFirstCategoryId());
+
+ sortedValue = caracteristic.getCaracteristic().getQualitativeValue(0);
}
//------------------------------------------------------------------------//
@@ -101,7 +106,7 @@
Caracteristic caracteristic =
persistenceService.getSortedUnsortedCaracteristic();
- initBeanFilterableComboBox(ui.getSortedUnsortedCategoryComboBox(),
+ initBeanFilterableComboBox(ui.getSampleCategoryComboBox(),
Lists.newArrayList(caracteristic.getQualitativeValue()),
null);
@@ -119,14 +124,14 @@
if (newValue == null || source.getSpeciesUsed() == null) {
- source.setSortedUnsortedCategory(null);
+ source.setSampleCategory(null);
} else {
// look for best value : if sorted is available then use it
List<CaracteristicQualitativeValue> qualitativeValues =
- ui.getSortedUnsortedCategoryComboBox().getData();
+ ui.getSampleCategoryComboBox().getData();
CaracteristicQualitativeValue newCategory = null;
@@ -139,7 +144,7 @@
}
}
}
- source.setSortedUnsortedCategory(newCategory);
+ source.setSampleCategory(newCategory);
}
}
});
@@ -199,7 +204,7 @@
ui.getValidator().setBean(model);
model.setSpecies(null);
- model.setSortedUnsortedCategory(null);
+ model.setSampleCategory(null);
model.setBatchWeight(null);
List<Species> speciesToUse = Lists.newArrayList();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -51,7 +51,7 @@
public static final String PROPERTY_SPECIES = "species";
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory";
+ public static final String PROPERTY_SAMPLE_CATEGORY = "sampleCategory";
public static final String PROPERTY_BATCH_WEIGHT = "batchWeight";
@@ -70,11 +70,11 @@
protected Species species;
/**
- * Sorted Unsorted category.
+ * First sample category.
*
- * @since 0.3
+ * @since 2.5
*/
- protected CaracteristicQualitativeValue sortedUnsortedCategory;
+ protected CaracteristicQualitativeValue sampleCategory;
/**
* Incoming batch weight to split.
@@ -84,7 +84,7 @@
protected Float batchWeight;
/**
- * Already used species by sortedUnsorted category.
+ * Already used species by sample category.
*
* @since 0.3
*/
@@ -121,14 +121,14 @@
firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
}
- public CaracteristicQualitativeValue getSortedUnsortedCategory() {
- return sortedUnsortedCategory;
+ public CaracteristicQualitativeValue getSampleCategory() {
+ return sampleCategory;
}
- public void setSortedUnsortedCategory(CaracteristicQualitativeValue sortedUnsortedCategory) {
- Object oldSpecies = getSortedUnsortedCategory();
- this.sortedUnsortedCategory = sortedUnsortedCategory;
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldSpecies, sortedUnsortedCategory);
+ public void setSampleCategory(CaracteristicQualitativeValue sampleCategory) {
+ Object oldValue = getSampleCategory();
+ this.sampleCategory = sampleCategory;
+ firePropertyChange(PROPERTY_SAMPLE_CATEGORY, oldValue, sampleCategory);
}
public Float getBatchWeight() {
@@ -146,14 +146,14 @@
}
public boolean isSpeciesAndCategoryAvailable() {
- boolean result = species != null && sortedUnsortedCategory != null &&
- isSpeciesAndCategoryAvailable(species, sortedUnsortedCategory);
+ boolean result = species != null && sampleCategory != null &&
+ isSpeciesAndCategoryAvailable(species, sampleCategory);
return result;
}
public boolean isSpeciesAndCategoryAvailable(Species species,
- CaracteristicQualitativeValue sortedUnsortedCategory) {
- boolean result = !speciesUsed.containsEntry(sortedUnsortedCategory, species);
+ CaracteristicQualitativeValue value) {
+ boolean result = !speciesUsed.containsEntry(value, species);
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -29,6 +29,7 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -199,8 +200,12 @@
@Override
public void beforeInitUI() {
- BenthosFrequencyUIModel model = new BenthosFrequencyUIModel();
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+ BenthosFrequencyUIModel model =
+ new BenthosFrequencyUIModel(sampleCategoryModel);
+
ui.setContextValue(model);
}
@@ -640,7 +645,7 @@
public String decorateCategory(BenthosBatchRowModel object) {
return object == null ? "" :
- decorate(object.getFinestCategory().getCategoryType()) + " / " + decorate(object.getFinestCategory().getCategoryValue());
+ decorate(object.getFinestCategory().getCategoryDef()) + " / " + decorate(object.getFinestCategory().getCategoryValue());
}
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,9 +25,9 @@
*/
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
import java.util.List;
@@ -37,7 +37,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class BenthosFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, BenthosFrequencyRowModel, BenthosFrequencyUIModel> {
+public class BenthosFrequencyUIModel extends AbstractTuttiTableUIModel<BenthosBatchRowModel, BenthosFrequencyRowModel, BenthosFrequencyUIModel> {
private static final long serialVersionUID = 1L;
@@ -143,8 +143,11 @@
protected Set<BenthosFrequencyRowModel> emptyRows;
- public BenthosFrequencyUIModel() {
- super(SpeciesBatchRowModel.class, null, null);
+ protected SampleCategoryModel sampleCategoryModel;
+
+ public BenthosFrequencyUIModel(SampleCategoryModel sampleCategoryModel) {
+ super(BenthosBatchRowModel.class, null, null);
+ this.sampleCategoryModel = sampleCategoryModel;
setEmptyRows(Sets.<BenthosFrequencyRowModel>newHashSet());
}
@@ -297,7 +300,7 @@
}
@Override
- protected SpeciesBatchRowModel newEntity() {
- return new SpeciesBatchRowModel();
+ protected BenthosBatchRowModel newEntity() {
+ return new BenthosBatchRowModel(sampleCategoryModel);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,7 +25,7 @@
*/
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
@@ -68,12 +68,12 @@
super(SplitBenthosBatchRowModel.class, fromBeanBinder, toBeanBinder);
}
- public SampleCategoryEnum getCategoryType() {
- return category.getCategoryType();
+ public SampleCategoryModelEntry getCategorytype() {
+ return category.getCategoryDef();
}
- public void setCategoryType(SampleCategoryEnum categoryType) {
- category.setCategoryType(categoryType);
+ public void setCategoryType(SampleCategoryModelEntry categoryType) {
+ category.setCategoryDef(categoryType);
}
public Serializable getCategoryValue() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.jaxx 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.jaxx 2013-07-24 17:35:44 UTC (rev 1153)
@@ -33,7 +33,6 @@
org.jdesktop.swingx.JXTable
jaxx.runtime.validator.swing.SwingValidatorUtil
- jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
javax.swing.ListSelectionModel
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,14 +27,15 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchTableModel;
import fr.ifremer.tutti.ui.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
@@ -69,19 +70,11 @@
private static final Log log =
LogFactory.getLog(SplitBenthosBatchUIHandler.class);
- /**
- * Parent UI.
- *
- * @since 0.3
- */
- private final BenthosBatchUI parentUi;
-
public SplitBenthosBatchUIHandler(EditCatchesUI parentUi,
SplitBenthosBatchUI ui) {
super(parentUi.getHandler().getContext(), ui,
SplitBenthosBatchRowModel.PROPERTY_CATEGORY_VALUE,
SplitBenthosBatchRowModel.PROPERTY_WEIGHT);
- this.parentUi = parentUi.getBenthosTabContent();
}
//------------------------------------------------------------------------//
@@ -146,8 +139,11 @@
@Override
public void beforeInitUI() {
- SplitBenthosBatchUIModel model = new SplitBenthosBatchUIModel();
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+ SplitBenthosBatchUIModel model = new SplitBenthosBatchUIModel(sampleCategoryModel);
+
ui.setContextValue(model);
}
@@ -170,7 +166,7 @@
source.setSelectedCategory(null);
// fill comboBox with new list
- List<SampleCategoryEnum> data = (List<SampleCategoryEnum>) evt.getNewValue();
+ List<SampleCategoryModelEntry> data = (List<SampleCategoryModelEntry>) evt.getNewValue();
ui.getCategoryComboBox().setModel(new DefaultComboBoxModel(data.toArray()));
}
});
@@ -186,20 +182,20 @@
// when selected category change, sample total weight is reset
source.setSampleWeight(null);
- SampleCategoryEnum newValue =
- (SampleCategoryEnum) evt.getNewValue();
+ SampleCategoryModelEntry newValue =
+ (SampleCategoryModelEntry) evt.getNewValue();
generateTableModel(newValue);
}
});
- ui.getCategoryComboBox().setRenderer(newListCellRender(SampleCategoryEnum.class));
+ ui.getCategoryComboBox().setRenderer(newListCellRender(SampleCategoryModelEntry.class));
ui.getCategoryComboBox().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox comboBox = (JComboBox) e.getSource();
- getModel().setSelectedCategory((SampleCategoryEnum) comboBox.getSelectedItem());
+ getModel().setSelectedCategory((SampleCategoryModelEntry) comboBox.getSelectedItem());
}
});
@@ -257,47 +253,35 @@
public void editBatch(BenthosBatchRowModel batch) {
// get possible the last used
- List<SampleCategoryEnum> categories =
- Lists.newArrayList(SampleCategoryEnum.values());
+ List<SampleCategoryModelEntry> categories = Lists.newArrayList();
if (batch != null) {
- //TODO Use the samplingOrder (+ the one from the table model)
+ // get sample category model
+ SampleCategoryModel sampleCategoryModel =
+ getModel().getSampleCategoryModel();
+
+ // set all categories (the no more available will be removed later)
+ categories.addAll(sampleCategoryModel.getCategory());
+
SampleCategory<?> lastCategory = batch.getFinestCategory();
Preconditions.checkNotNull(
lastCategory,
- "Can't split a species batch with no sample category.");
+ "Can't split a benthos batch with no sample category.");
- if (batch.getSortedUnsortedCategory().isValid()) {
- categories.remove(SampleCategoryEnum.sortedUnsorted);
- }
+ int firstOrder = lastCategory.getCategoryDef().getOrder();
- if (batch.getSizeCategory().isValid()) {
- categories.remove(SampleCategoryEnum.size);
- categories.remove(SampleCategoryEnum.sortedUnsorted);
- }
+ for (Integer sampleCategoryId : sampleCategoryModel.getSamplingOrder()) {
+ SampleCategory<?> sampleCategory = batch.getSampleCategoryById(sampleCategoryId);
+ int order = sampleCategory.getCategoryDef().getOrder();
+ if (order < firstOrder || sampleCategory.isValid()) {
- if (batch.getSexCategory().isValid()) {
- categories.remove(SampleCategoryEnum.sex);
- categories.remove(SampleCategoryEnum.size);
- categories.remove(SampleCategoryEnum.sortedUnsorted);
+ // remove category if before the finest one
+ // remove category if not filled
+ categories.remove(sampleCategory.getCategoryDef());
+ }
}
-
- if (batch.getMaturityCategory().isValid()) {
- categories.remove(SampleCategoryEnum.maturity);
- categories.remove(SampleCategoryEnum.sex);
- categories.remove(SampleCategoryEnum.size);
- categories.remove(SampleCategoryEnum.sortedUnsorted);
- }
-
- if (batch.getAgeCategory().isValid()) {
- categories.remove(SampleCategoryEnum.age);
- categories.remove(SampleCategoryEnum.maturity);
- categories.remove(SampleCategoryEnum.sex);
- categories.remove(SampleCategoryEnum.size);
- categories.remove(SampleCategoryEnum.sortedUnsorted);
- }
}
SplitBenthosBatchUIModel model = getModel();
@@ -352,7 +336,7 @@
getModel().setSampleWeight(result);
}
- protected void generateTableModel(SampleCategoryEnum category) {
+ protected void generateTableModel(SampleCategoryModelEntry category) {
// when generate a new table model, then reset previous rows from model
getModel().setRows(null);
@@ -370,26 +354,15 @@
boolean editableCategoryValue = false;
if (category != null) {
- switch (category) {
+ if (!category.getCaracteristic().isQualitativeValueEmpty()) {
- case sortedUnsorted:
- data = persistenceService.getSortedUnsortedCaracteristic();
- break;
- case size:
- data = persistenceService.getSizeCategoryCaracteristic();
- break;
- case sex:
- data = persistenceService.getSexCaracteristic();
- break;
- case maturity:
- data = persistenceService.getMaturityCaracteristic();
- break;
- case age:
- editableCategoryValue = true;
- addFloatColumnToModel(columnModel,
- SplitBenthosBatchTableModel.EDITABLE_CATEGORY_VALUE,
- TuttiUI.DECIMAL1_PATTERN);
- break;
+ // qualitative category
+ data = category.getCaracteristic();
+ } else {
+ editableCategoryValue = true;
+ addFloatColumnToModel(columnModel,
+ SplitSpeciesBatchTableModel.EDITABLE_CATEGORY_VALUE,
+ TuttiUI.DECIMAL1_PATTERN);
}
if (data != null) {
@@ -400,12 +373,12 @@
addColumnToModel(columnModel,
null,
newTableCellRender(CaracteristicQualitativeValue.class),
- SplitBenthosBatchTableModel.READ_ONLY_CATEGORY_VALUE);
+ SplitSpeciesBatchTableModel.READ_ONLY_CATEGORY_VALUE);
}
{ // Weight
addFloatColumnToModel(columnModel,
- SplitBenthosBatchTableModel.WEIGHT,
+ SplitSpeciesBatchTableModel.WEIGHT,
TuttiUI.DECIMAL3_PATTERN);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,7 +24,8 @@
* #L%
*/
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
@@ -64,14 +65,14 @@
*
* @since 0.3
*/
- protected List<SampleCategoryEnum> category;
+ protected List<SampleCategoryModelEntry> category;
/**
* Selected Sample category.
*
* @since 0.3
*/
- protected SampleCategoryEnum selectedCategory;
+ protected SampleCategoryModelEntry selectedCategory;
/**
* Sample weight of split batches.
@@ -80,8 +81,11 @@
*/
protected Float sampleWeight;
- public SplitBenthosBatchUIModel() {
+ protected SampleCategoryModel sampleCategoryModel;
+
+ public SplitBenthosBatchUIModel(SampleCategoryModel sampleCategoryModel) {
super(BenthosBatchRowModel.class, null, null);
+ this.sampleCategoryModel = sampleCategoryModel;
}
public BenthosBatchRowModel getBatch() {
@@ -90,32 +94,31 @@
public void setBatch(BenthosBatchRowModel batch) {
Object oldSpecies = getSpecies();
- Object oldWeight = getBatchWeight();
this.batch = batch;
firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
- firePropertyChange(PROPERTY_BATCH_WEIGHT, oldWeight, getBatchWeight());
+ firePropertyChange(PROPERTY_BATCH_WEIGHT, null, getBatchWeight());
}
public Species getSpecies() {
return batch == null ? null : batch.getSpecies();
}
- public List<SampleCategoryEnum> getCategory() {
+ public List<SampleCategoryModelEntry> getCategory() {
return category;
}
- public void setCategory(List<SampleCategoryEnum> category) {
+ public void setCategory(List<SampleCategoryModelEntry> category) {
Object oldValue = getCategory();
this.category = category;
firePropertyChange(PROPERTY_CATEGORY, oldValue, category);
}
- public SampleCategoryEnum getSelectedCategory() {
+ public SampleCategoryModelEntry getSelectedCategory() {
return selectedCategory;
}
- public void setSelectedCategory(SampleCategoryEnum selectedCategory) {
+ public void setSelectedCategory(SampleCategoryModelEntry selectedCategory) {
Object oldValue = getSelectedCategory();
this.selectedCategory = selectedCategory;
firePropertyChange(PROPERTY_SELECTED_CATEGORY, oldValue, selectedCategory);
@@ -137,6 +140,10 @@
@Override
protected BenthosBatchRowModel newEntity() {
- return new BenthosBatchRowModel();
+ return new BenthosBatchRowModel(sampleCategoryModel);
}
+
+ public SampleCategoryModel getSampleCategoryModel() {
+ return sampleCategoryModel;
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -60,7 +60,7 @@
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import org.nuiton.validator.NuitonValidatorResult;
import javax.swing.JComponent;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,11 +25,14 @@
*/
import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.jdesktop.swingx.JXTable;
+import java.io.Serializable;
import java.util.Collection;
import java.util.List;
@@ -61,9 +64,10 @@
SpeciesBatchUIModel model = handler.getModel();
List<Species> speciesList = Lists.newArrayList(
getDataContext().getReferentSpeciesWithSurveyCode());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ Serializable categoryValue = firstSampleCategory.getCategoryValue();
speciesList.removeAll(
- model.getSpeciesUsed().get(
- row.getSortedUnsortedCategoryValue()));
+ model.getSpeciesUsed().get((CaracteristicQualitativeValue) categoryValue));
selectedSpecies = getHandler().openAddSpeciesDialog(
_("tutti.selectSpecies.title"),
@@ -90,8 +94,11 @@
PersistenceService persistenceService = getContext().getPersistenceService();
persistenceService.changeSpeciesBatchSpecies(row.getId(), selectedSpecies);
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ Serializable categoryValue = firstSampleCategory.getCategoryValue();
+
Collection<Species> speciesUsed = getModel().getSpeciesUsed()
- .get(row.getSortedUnsortedCategoryValue());
+ .get((CaracteristicQualitativeValue) categoryValue);
speciesUsed.remove(row.getSpecies());
changeChildrenSpecies(row, selectedSpecies);
speciesUsed.add(selectedSpecies);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -30,14 +30,16 @@
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryAble;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -56,50 +58,18 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class SpeciesBatchRowModel extends AbstractTuttiBeanUIModel<SpeciesBatch, SpeciesBatchRowModel> implements SpeciesBatch, AttachmentModelAware {
+public class SpeciesBatchRowModel extends AbstractTuttiBeanUIModel<SpeciesBatch, SpeciesBatchRowModel> implements SpeciesBatch, AttachmentModelAware, SampleCategoryAble<SpeciesBatchRowModel> {
private static final long serialVersionUID = 1L;
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory";
+ public static final String PROPERTY_SAMPLE_CATEGORY = "sampleCategory";
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE = "sortedUnsortedCategoryValue";
+ public static final String PROPERTY_SAMPLE_CATEGORY_VALUE = "sampleCategoryValue";
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT = "sortedUnsortedCategoryWeight";
+ public static final String PROPERTY_SAMPLE_CATEGORY_WEIGHT = "sampleCategoryWeight";
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_COMPUTED_WEIGHT = "sortedUnsortedCategoryComputedWeight";
+ public static final String PROPERTY_SAMPLE_CATEGORY_COMPUTED_WEIGHT = "sampleCategoryComputedWeight";
- public static final String PROPERTY_SIZE_CATEGORY = "sizeCategory";
-
- public static final String PROPERTY_SIZE_CATEGORY_VALUE = "sizeCategoryValue";
-
- public static final String PROPERTY_SIZE_CATEGORY_WEIGHT = "sizeCategoryWeight";
-
- public static final String PROPERTY_SIZE_CATEGORY_COMPUTED_WEIGHT = "sexCategoryComputedWeight";
-
- public static final String PROPERTY_SEX_CATEGORY = "sexCategory";
-
- public static final String PROPERTY_SEX_CATEGORY_VALUE = "sexCategoryValue";
-
- public static final String PROPERTY_SEX_CATEGORY_WEIGHT = "sexCategoryWeight";
-
- public static final String PROPERTY_SEX_CATEGORY_COMPUTED_WEIGHT = "sexCategoryComputedWeight";
-
- public static final String PROPERTY_MATURITY_CATEGORY = "maturityCategory";
-
- public static final String PROPERTY_MATURITY_CATEGORY_VALUE = "maturityCategoryValue";
-
- public static final String PROPERTY_MATURITY_CATEGORY_COMPUTED_WEIGHT = "maturityCategoryComputedWeight";
-
- public static final String PROPERTY_MATURITY_CATEGORY_WEIGHT = "maturityCategoryWeight";
-
- public static final String PROPERTY_AGE_CATEGORY = "ageCategory";
-
- public static final String PROPERTY_AGE_CATEGORY_VALUE = "ageCategoryValue";
-
- public static final String PROPERTY_AGE_CATEGORY_COMPUTED_WEIGHT = "ageCategoryComputedWeight";
-
- public static final String PROPERTY_AGE_CATEGORY_WEIGHT = "ageCategoryWeight";
-
public static final String PROPERTY_FREQUENCY = "frequency";
public static final String PROPERTY_COMPUTED_NUMBER = "computedOrNotNumber";
@@ -120,41 +90,13 @@
protected final SpeciesBatch editObject = TuttiBeanFactory.newSpeciesBatch();
/**
- * Sorted - Unsorted category (can not be null).
+ * All categories(can not be null).
*
- * @since 0.2
+ * @since 2.5
*/
- protected SampleCategory<CaracteristicQualitativeValue> sortedUnsortedCategory;
+ protected final SampleCategory<?>[] categories;
/**
- * Weight category (can be null).
- *
- * @since 0.2
- */
- protected SampleCategory<CaracteristicQualitativeValue> sizeCategory;
-
- /**
- * Sex category (can be null).
- *
- * @since 0.2
- */
- protected SampleCategory<CaracteristicQualitativeValue> sexCategory;
-
- /**
- * Maturity category (can be null).
- *
- * @since 0.2
- */
- protected SampleCategory<CaracteristicQualitativeValue> maturityCategory;
-
- /**
- * Age category (can be null).
- *
- * @since 0.2
- */
- protected SampleCategory<Float> ageCategory;
-
- /**
* Observed weight.
*
* @since 0.2
@@ -192,6 +134,8 @@
*/
protected List<SpeciesBatchRowModel> childBatch;
+ protected final SampleCategoryModel sampleCategoryModel;
+
protected static final Binder<SpeciesBatch, SpeciesBatchRowModel> fromBeanBinder =
BinderFactory.newBinder(SpeciesBatch.class,
SpeciesBatchRowModel.class);
@@ -200,23 +144,27 @@
BinderFactory.newBinder(SpeciesBatchRowModel.class,
SpeciesBatch.class);
- public SpeciesBatchRowModel() {
+ public SpeciesBatchRowModel(SampleCategoryModel sampleCategoryModel) {
super(SpeciesBatch.class, fromBeanBinder, toBeanBinder);
- sortedUnsortedCategory = SampleCategory.newSample(SampleCategoryEnum.sortedUnsorted);
- sizeCategory = SampleCategory.newSample(SampleCategoryEnum.size);
- sexCategory = SampleCategory.newSample(SampleCategoryEnum.sex);
- maturityCategory = SampleCategory.newSample(SampleCategoryEnum.maturity);
- ageCategory = SampleCategory.newSample(SampleCategoryEnum.age);
+ this.sampleCategoryModel = sampleCategoryModel;
+ categories = new SampleCategory[sampleCategoryModel.getNbSampling()];
+ for (int i = 0; i < categories.length; i++) {
+ SampleCategoryModelEntry entry = sampleCategoryModel.getCategoryByIndex(i);
+ SampleCategory<?> category = SampleCategory.newSample(entry);
+ categories[i] = category;
+ }
+
computedOrNotWeight.addPropagateListener(PROPERTY_WEIGHT, this);
computedOrNotWeight.addPropagateListener(PROPERTY_COMPUTED_WEIGHT, this);
computedOrNotNumber.addPropagateListener(PROPERTY_NUMBER, this);
computedOrNotNumber.addPropagateListener(PROPERTY_COMPUTED_NUMBER, this);
}
- public SpeciesBatchRowModel(SpeciesBatch aBatch,
+ public SpeciesBatchRowModel(SampleCategoryModel sampleCategoryModel,
+ SpeciesBatch aBatch,
List<SpeciesBatchFrequency> frequencies) {
- this();
+ this(sampleCategoryModel);
fromBean(aBatch);
List<SpeciesFrequencyRowModel> frequencyRows =
SpeciesFrequencyRowModel.fromBeans(frequencies);
@@ -323,12 +271,12 @@
}
@Override
- public SampleCategoryEnum getSampleCategoryType() {
+ public Integer getSampleCategoryId() {
return null;
}
@Override
- public void setSampleCategoryType(SampleCategoryEnum sampleCategoryType) {
+ public void setSampleCategoryId(Integer sampleCategoryId) {
}
@Override
@@ -431,292 +379,87 @@
}
//------------------------------------------------------------------------//
- //-- Sample category --//
+ //-- SampleCategoryAble --//
//------------------------------------------------------------------------//
- public void setSampleCategory(SampleCategory sampleCategory) {
- switch (sampleCategory.getCategoryType()) {
- case sortedUnsorted:
- setSortedUnsortedCategory(sampleCategory);
+ @Override
+ public Integer getCategoryIndex(Integer id) {
+ int result = 0;
+ for (SampleCategory<?> category : categories) {
+ if (category != null && id.equals(category.getCategoryId())) {
break;
- case size:
- setSizeCategory(sampleCategory);
- break;
- case sex:
- setSexCategory(sampleCategory);
- break;
- case maturity:
- setMaturityCategory(sampleCategory);
- break;
- case age:
- setAgeCategory(sampleCategory);
+ } else {
+ result++;
+ }
}
+ return result;
}
- public SampleCategory<?> getSampleCategory(SampleCategoryEnum sampleCategoryEnum) {
- SampleCategory<?> sampleCategory = null;
- switch (sampleCategoryEnum) {
- case sortedUnsorted:
- sampleCategory = getSortedUnsortedCategory();
- break;
- case size:
- sampleCategory = getSizeCategory();
- break;
- case sex:
- sampleCategory = getSexCategory();
- break;
- case maturity:
- sampleCategory = getMaturityCategory();
- break;
- case age:
- sampleCategory = getAgeCategory();
- break;
- default:
- }
- return sampleCategory;
- }
+ @Override
+ public void setSampleCategory(SampleCategory sampleCategory) {
+ int index = getCategoryIndex(sampleCategory.getCategoryId());
+ SampleCategory<?> oldCategory = categories[index];
+ Object oldValue = oldCategory.getCategoryValue();
+ Object oldWeight = oldCategory.getCategoryWeight();
+ Object oldComputedWeight = oldCategory.getComputedWeight();
+ categories[index] = sampleCategory;
- public SampleCategory getFinestCategory() {
- SampleCategory finestCategory;
- if (ageCategory.isValid()) {
- finestCategory = ageCategory;
-
- } else if (maturityCategory.isValid()) {
- finestCategory = maturityCategory;
-
- } else if (sexCategory.isValid()) {
- finestCategory = sexCategory;
-
- } else if (sizeCategory.isValid()) {
- finestCategory = sizeCategory;
-
- } else {
- finestCategory = sortedUnsortedCategory;
- }
- return finestCategory;
+ //FIXME (indexed)
+ fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY, index, oldCategory, sampleCategory);
+ fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, index, oldValue, sampleCategory.getCategoryValue());
+ fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_WEIGHT, index, oldWeight, sampleCategory.getCategoryWeight());
+ fireIndexedPropertyChange(PROPERTY_SAMPLE_CATEGORY_COMPUTED_WEIGHT, index, oldComputedWeight, sampleCategory.getComputedWeight());
}
- //------------------------------------------------------------------------//
- //-- SortedUnsorted category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<CaracteristicQualitativeValue> getSortedUnsortedCategory() {
- return sortedUnsortedCategory;
+ @Override
+ public SampleCategory<?> getSampleCategoryById(Integer sampleCategoryId) {
+ Integer index = getCategoryIndex(sampleCategoryId);
+ SampleCategory<?> result = index == null ? null : categories[index];
+ return result;
}
- public void setSortedUnsortedCategory(SampleCategory<CaracteristicQualitativeValue> sortedUnsortedCategory) {
- Object oldCategory = getSortedUnsortedCategory();
- Object oldValue = getSortedUnsortedCategoryValue();
- Object oldWeight = getSortedUnsortedCategoryWeight();
- Object oldComputedWeight = getSortedUnsortedCategoryComputedWeight();
- this.sortedUnsortedCategory = sortedUnsortedCategory;
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldCategory, sortedUnsortedCategory);
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE, oldValue, getSortedUnsortedCategoryValue());
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldWeight, getSortedUnsortedCategoryWeight());
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getSortedUnsortedCategoryComputedWeight());
+ @Override
+ public void setSampleCategoryWeight(Integer sampleCategoryId, Object value) {
+ SampleCategory<?> sampleCategory =
+ getSampleCategoryById(sampleCategoryId);
+ TuttiUIUtil.setProperty(sampleCategory,
+ SampleCategory.PROPERTY_CATEGORY_WEIGHT, value);
+ firePropertyChange(PROPERTY_SAMPLE_CATEGORY_WEIGHT, null, sampleCategory);
}
- public CaracteristicQualitativeValue getSortedUnsortedCategoryValue() {
- return sortedUnsortedCategory.getCategoryValue();
+ @Override
+ public SampleCategory getFinestCategory() {
+ SampleCategory result = null;
+ for (int i = categories.length - 1; i > -1; i--) {
+ SampleCategory<?> category = categories[i];
+ if (category != null && category.isValid()) {
+ result = category;
+ break;
+ }
+ }
+ return result;
}
- public Float getSortedUnsortedCategoryWeight() {
- return sortedUnsortedCategory.getCategoryWeight();
+ @Override
+ public SampleCategory<?> getFirstSampleCategory() {
+ return categories[0];
}
- public void setSortedUnsortedCategoryWeight(Float sortedUnsortedCategoryWeight) {
- Object oldValue = getSortedUnsortedCategoryWeight();
- sortedUnsortedCategory.setCategoryWeight(sortedUnsortedCategoryWeight);
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldValue, sortedUnsortedCategoryWeight);
- }
+ @Override
+ public SpeciesBatchRowModel getFirstAncestor(SampleCategory<?> entrySampleCategory) {
+ SpeciesBatchRowModel result = this;
+ if (getParentBatch() != null) {
+ SpeciesBatchRowModel parentBatch = getParentBatch();
+ SampleCategory<?> parentSampleCategory = parentBatch.getSampleCategoryById(entrySampleCategory.getCategoryId());
+ if (ObjectUtils.equals(entrySampleCategory, parentSampleCategory)) {
- public Float getSortedUnsortedCategoryComputedWeight() {
- return sortedUnsortedCategory.getComputedWeight();
+ result = parentBatch.getFirstAncestor(entrySampleCategory);
+ }
+ }
+ return result;
}
- public void setSortedUnsortedCategoryComputedWeight(Float sortedUnsortedCategoryComputedWeight) {
- Object oldValue = getSortedUnsortedCategoryComputedWeight();
- sortedUnsortedCategory.setComputedWeight(sortedUnsortedCategoryComputedWeight);
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_COMPUTED_WEIGHT, oldValue, sortedUnsortedCategoryComputedWeight);
- }
-
//------------------------------------------------------------------------//
- //-- Size category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<CaracteristicQualitativeValue> getSizeCategory() {
- return sizeCategory;
- }
-
- public void setSizeCategory(SampleCategory<CaracteristicQualitativeValue> sizeCategory) {
- Object oldCategory = getSizeCategory();
- Object oldValue = getSizeCategoryValue();
- Object oldWeight = getSizeCategoryWeight();
- Object oldComputedWeight = getSizeCategoryComputedWeight();
- this.sizeCategory = sizeCategory;
- firePropertyChange(PROPERTY_SIZE_CATEGORY, oldCategory, sizeCategory);
- firePropertyChange(PROPERTY_SIZE_CATEGORY_VALUE, oldValue, getSizeCategoryValue());
- firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldWeight, getSizeCategoryWeight());
- firePropertyChange(PROPERTY_SIZE_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getSizeCategoryComputedWeight());
- }
-
- public CaracteristicQualitativeValue getSizeCategoryValue() {
- return sizeCategory.getCategoryValue();
- }
-
- public Float getSizeCategoryWeight() {
- return sizeCategory.getCategoryWeight();
- }
-
- public void setSizeCategoryWeight(Float sizeCategoryWeight) {
- Object oldValue = getSizeCategoryWeight();
- this.sizeCategory.setCategoryWeight(sizeCategoryWeight);
- firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldValue, sizeCategoryWeight);
- }
-
- public Float getSizeCategoryComputedWeight() {
- return sizeCategory.getComputedWeight();
- }
-
- public void setSizeCategoryComputedWeight(Float sizeCategoryComputedWeight) {
- Object oldValue = getSizeCategoryComputedWeight();
- this.sizeCategory.setComputedWeight(sizeCategoryComputedWeight);
- firePropertyChange(PROPERTY_SIZE_CATEGORY_COMPUTED_WEIGHT, oldValue, sizeCategoryComputedWeight);
- }
-
- //------------------------------------------------------------------------//
- //-- Sex category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<CaracteristicQualitativeValue> getSexCategory() {
- return sexCategory;
- }
-
- public void setSexCategory(SampleCategory<CaracteristicQualitativeValue> sexCategory) {
- Object oldCategory = getSexCategory();
- Object oldValue = getSexCategoryValue();
- Object oldWeight = getSexCategoryWeight();
- Object oldComputedWeight = getSexCategoryComputedWeight();
- this.sexCategory = sexCategory;
- firePropertyChange(PROPERTY_SEX_CATEGORY, oldCategory, sexCategory);
- firePropertyChange(PROPERTY_SEX_CATEGORY_VALUE, oldValue, getSexCategoryValue());
- firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldWeight, getSexCategoryWeight());
- firePropertyChange(PROPERTY_SEX_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getSexCategoryComputedWeight());
- }
-
- public CaracteristicQualitativeValue getSexCategoryValue() {
- return sexCategory.getCategoryValue();
- }
-
- public Float getSexCategoryWeight() {
- return sexCategory.getCategoryWeight();
- }
-
- public void setSexCategoryWeight(Float sexCategoryWeight) {
- Object oldValue = getSexCategoryWeight();
- this.sexCategory.setCategoryWeight(sexCategoryWeight);
- firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldValue, sexCategoryWeight);
- }
-
- public Float getSexCategoryComputedWeight() {
- return sexCategory.getComputedWeight();
- }
-
- public void setSexCategoryComputedWeight(Float sexCategoryComputedWeight) {
- Object oldValue = getSexCategoryComputedWeight();
- this.sexCategory.setComputedWeight(sexCategoryComputedWeight);
- firePropertyChange(PROPERTY_SEX_CATEGORY_COMPUTED_WEIGHT, oldValue, sexCategoryComputedWeight);
- }
-
- //------------------------------------------------------------------------//
- //-- Maturity category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<CaracteristicQualitativeValue> getMaturityCategory() {
- return maturityCategory;
- }
-
- public void setMaturityCategory(SampleCategory<CaracteristicQualitativeValue> maturityCategory) {
- Object oldCategory = getMaturityCategory();
- Object oldValue = getMaturityCategoryValue();
- Object oldWeight = getMaturityCategoryWeight();
- Object oldComputedWeight = getMaturityCategoryComputedWeight();
- this.maturityCategory = maturityCategory;
- firePropertyChange(PROPERTY_MATURITY_CATEGORY, oldCategory, maturityCategory);
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_VALUE, oldValue, getMaturityCategoryValue());
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldWeight, getMaturityCategoryWeight());
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getMaturityCategoryComputedWeight());
- }
-
- public CaracteristicQualitativeValue getMaturityCategoryValue() {
- return maturityCategory.getCategoryValue();
- }
-
- public Float getMaturityCategoryWeight() {
- return maturityCategory.getCategoryWeight();
- }
-
- public void setMaturityCategoryWeight(Float maturityCategoryWeight) {
- Object oldValue = getMaturityCategoryWeight();
- this.maturityCategory.setCategoryWeight(maturityCategoryWeight);
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldValue, maturityCategoryWeight);
- }
-
- public Float getMaturityCategoryComputedWeight() {
- return maturityCategory.getComputedWeight();
- }
-
- public void setMaturityCategoryComputedWeight(Float maturityCategoryComputedWeight) {
- Object oldValue = getMaturityCategoryComputedWeight();
- this.maturityCategory.setComputedWeight(maturityCategoryComputedWeight);
- firePropertyChange(PROPERTY_MATURITY_CATEGORY_COMPUTED_WEIGHT, oldValue, maturityCategoryComputedWeight);
- }
-
- //------------------------------------------------------------------------//
- //-- Age category --//
- //------------------------------------------------------------------------//
-
- public SampleCategory<Float> getAgeCategory() {
- return ageCategory;
- }
-
- public void setAgeCategory(SampleCategory<Float> ageCategory) {
- Object oldCategory = getAgeCategory();
- Object oldValue = getAgeCategoryValue();
- Object oldWeight = getAgeCategoryWeight();
- Object oldComputedWeight = getAgeCategoryComputedWeight();
- this.ageCategory = ageCategory;
- firePropertyChange(PROPERTY_AGE_CATEGORY, oldCategory, ageCategory);
- firePropertyChange(PROPERTY_AGE_CATEGORY_VALUE, oldValue, getAgeCategoryValue());
- firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldWeight, getAgeCategoryWeight());
- firePropertyChange(PROPERTY_AGE_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getAgeCategoryComputedWeight());
- }
-
- public Float getAgeCategoryValue() {
- return ageCategory.getCategoryValue();
- }
-
- public Float getAgeCategoryWeight() {
- return ageCategory.getCategoryWeight();
- }
-
- public void setAgeCategoryWeight(Float ageCategoryWeight) {
- Object oldValue = getAgeCategoryWeight();
- ageCategory.setCategoryWeight(ageCategoryWeight);
- firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldValue, ageCategoryWeight);
- }
-
- public Float getAgeCategoryComputedWeight() {
- return ageCategory.getComputedWeight();
- }
-
- public void setAgeCategoryComputedWeight(Float ageCategoryComputedWeight) {
- Object oldValue = getAgeCategoryComputedWeight();
- ageCategory.setComputedWeight(ageCategoryComputedWeight);
- firePropertyChange(PROPERTY_AGE_CATEGORY_COMPUTED_WEIGHT, oldValue, ageCategoryComputedWeight);
- }
-
- //------------------------------------------------------------------------//
//-- AttachmentModelAware --//
//------------------------------------------------------------------------//
@@ -820,16 +563,4 @@
}
}
- public SpeciesBatchRowModel getFirstAncestor(SampleCategory<?> entrySampleCategory) {
- SpeciesBatchRowModel result = this;
- if (getParentBatch() != null) {
- SpeciesBatchRowModel parentBatch = getParentBatch();
- SampleCategory<?> parentSampleCategory = parentBatch.getSampleCategory(entrySampleCategory.getCategoryType());
- if (ObjectUtils.equals(entrySampleCategory, parentSampleCategory)) {
-
- result = parentBatch.getFirstAncestor(entrySampleCategory);
- }
- }
- return result;
- }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,7 +26,7 @@
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryColumnIdentifier;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
@@ -35,6 +35,8 @@
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.table.TableColumnModelExt;
+import javax.swing.table.TableColumn;
+import java.util.Enumeration;
import java.util.Set;
import static org.nuiton.i18n.I18n.n_;
@@ -56,41 +58,6 @@
n_("tutti.editSpeciesBatch.table.header.species"),
n_("tutti.editSpeciesBatch.table.header.species"));
- public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
- SampleCategoryEnum.sortedUnsorted,
- n_("tutti.editSpeciesBatch.table.header.sortedUnsortedCategory"),
- n_("tutti.editSpeciesBatch.table.header.sortedUnsortedCategory"));
-
- public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
- SampleCategoryEnum.size,
- n_("tutti.editSpeciesBatch.table.header.sizeCategory"),
- n_("tutti.editSpeciesBatch.table.header.sizeCategory"));
-
- public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
- SampleCategoryEnum.sex,
- n_("tutti.editSpeciesBatch.table.header.sexCategory"),
- n_("tutti.editSpeciesBatch.table.header.sexCategory"));
-
- public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
- SampleCategoryEnum.maturity,
- n_("tutti.editSpeciesBatch.table.header.maturityCategory"),
- n_("tutti.editSpeciesBatch.table.header.maturityCategory"));
-
- public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
- SampleCategoryEnum.age,
- n_("tutti.editSpeciesBatch.table.header.ageCategory"),
- n_("tutti.editSpeciesBatch.table.header.ageCategory"));
-
public static final ColumnIdentifier<SpeciesBatchRowModel> WEIGHT = ColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_COMPUTED_WEIGHT,
n_("tutti.editSpeciesBatch.table.header.weight"),
@@ -130,8 +97,12 @@
*/
protected final Set<SampleCategoryColumnIdentifier<SpeciesBatchRowModel>> sampleCols;
- public SpeciesBatchTableModel(TableColumnModelExt columnModel) {
+ protected final SampleCategoryModel sampleCategoryModel;
+
+ public SpeciesBatchTableModel(SampleCategoryModel sampleCategoryModel,
+ TableColumnModelExt columnModel) {
super(columnModel, false, false);
+ this.sampleCategoryModel = sampleCategoryModel;
setNoneEditableCols(SPECIES);
frequencyCols = Sets.newHashSet();
@@ -139,27 +110,20 @@
frequencyCols.add(WEIGHT);
sampleCols = Sets.newHashSet();
- sampleCols.add(SORTED_UNSORTED_CATEGORY);
- sampleCols.add(SIZE_CATEGORY);
- sampleCols.add(SEX_CATEGORY);
- sampleCols.add(MATURITY_CATEGORY);
- sampleCols.add(AGE_CATEGORY);
- }
- public SampleCategoryColumnIdentifier<SpeciesBatchRowModel> getCategoryIdentifierForWeightProperty(String weightPropertyName) {
- SampleCategoryColumnIdentifier<SpeciesBatchRowModel> result = null;
- for (SampleCategoryColumnIdentifier<SpeciesBatchRowModel> sampleCol : sampleCols) {
- if (weightPropertyName.equals(sampleCol.getWeightPropertyName())) {
- result = sampleCol;
- break;
+ Enumeration<TableColumn> columns = columnModel.getColumns();
+ while (columns.hasMoreElements()) {
+ TableColumn tableColumn = columns.nextElement();
+ Object identifier = tableColumn.getIdentifier();
+ if (identifier instanceof SampleCategoryColumnIdentifier) {
+ sampleCols.add((SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) identifier);
}
}
- return result;
}
@Override
public SpeciesBatchRowModel createNewRow() {
- SpeciesBatchRowModel result = new SpeciesBatchRowModel();
+ SpeciesBatchRowModel result = new SpeciesBatchRowModel(sampleCategoryModel);
// by default empty row is not valid
result.setValid(false);
@@ -178,11 +142,11 @@
sampleCategoryColumnIdentifier.setWeightValue(entry, aValue);
// must find out first ancestor with this category
- SampleCategoryEnum sampleCategoryType = sampleCategoryColumnIdentifier.getSampleCategoryType();
+ Integer sampleCategoryId = sampleCategoryColumnIdentifier.getSampleCategoryId();
if (log.isDebugEnabled()) {
- log.debug("Sample category: " + sampleCategoryType + " modified at row: " + rowIndex);
+ log.debug("Sample category: " + sampleCategoryId + " modified at row: " + rowIndex);
}
- SampleCategory<?> sampleCategory = entry.getSampleCategory(sampleCategoryType);
+ SampleCategory<?> sampleCategory = entry.getSampleCategoryById(sampleCategoryId);
SpeciesBatchRowModel firstAncestor = entry.getFirstAncestor(sampleCategory);
int firstRowIndex = getRowIndex(firstAncestor);
@@ -208,20 +172,6 @@
}
}
-// @Override
-// public void setValueAt(Object aValue,
-// int rowIndex,
-// int columnIndex,
-// ColumnIdentifier<SpeciesBatchRowModel> propertyName,
-// SpeciesBatchRowModel entry) {
-// if (sampleCols.contains(propertyName)) {
-//
-// ((SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) propertyName).setWeightValue(entry, aValue);
-// } else {
-// super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
-// }
-// }
-
@Override
protected boolean isCellEditable(int rowIndex,
int columnIndex,
@@ -240,8 +190,6 @@
} else if (sampleCols.contains(propertyName)) {
- SampleCategoryColumnIdentifier<SpeciesBatchRowModel> samplePropertyName = (SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) propertyName;
-
// can only edit if a category value is setted
SpeciesBatchRowModel entry = getEntry(rowIndex);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -26,13 +26,13 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
@@ -67,6 +67,7 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -76,7 +77,7 @@
import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.jdesktop.swingx.table.TableColumnModelExt;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import org.nuiton.validator.NuitonValidatorResult;
import javax.swing.JComponent;
@@ -94,10 +95,10 @@
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -109,52 +110,28 @@
private static final Log log =
LogFactory.getLog(SpeciesBatchUIHandler.class);
- public static final Set<String> SAMPLING_PROPERTIES = Sets.newHashSet(
- SpeciesBatchRowModel.PROPERTY_SPECIES,
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT);
-
- public static final Set<String> SAMPLING_WEIGHT_PROPERTIES = Sets.newHashSet(
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT);
-
private final EnumMap<TableViewMode, RowFilter<SpeciesBatchTableModel, Integer>> tableFilters;
protected ValidationService validationService = getContext().getValidationService();
protected final EditCatchesUI parentUi;
+ protected final SampleCategoryModel sampleCategoryModel;
+
public SpeciesBatchUIHandler(EditCatchesUI parentUi,
SpeciesBatchUI ui) {
super(parentUi, ui,
SpeciesBatchRowModel.PROPERTY_SPECIES,
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_NUMBER,
SpeciesBatchRowModel.PROPERTY_COMMENT,
SpeciesBatchRowModel.PROPERTY_ATTACHMENT,
+ SpeciesBatchRowModel.PROPERTY_SAMPLE_CATEGORY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_FREQUENCY,
SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM);
+
+ sampleCategoryModel = getDataContext().getSampleCategoryModel();
+
this.parentUi = parentUi;
tableFilters = new EnumMap<TableViewMode, RowFilter<SpeciesBatchTableModel, Integer>>(TableViewMode.class);
@@ -229,13 +206,17 @@
List<SpeciesBatch> catches = rootSpeciesBatch.getChildren();
+ // use first category from configuration
+ Integer firstCategoryId = sampleCategoryModel.getFirstCategoryId();
+
for (SpeciesBatch aBatch : catches) {
- // root batch sample categroy is species
+ // root batch sample category is species
+
Preconditions.checkState(
- aBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted,
+ firstCategoryId.equals(aBatch.getSampleCategoryId()),
"Root species batch must be a sortedUnsorted sample " +
- "category but was:" + aBatch.getSampleCategoryType());
+ "category but was:" + aBatch.getSampleCategoryId());
SpeciesBatchRowModel rootRow =
loadBatch(aBatch, null, rows);
@@ -243,7 +224,7 @@
if (log.isDebugEnabled()) {
log.debug("Loaded root batch " +
decorate(rootRow.getSpecies(), DecoratorService.FROM_PROTOCOL) + " - " +
- decorate(rootRow.getSortedUnsortedCategoryValue()));
+ decorate(rootRow.getSampleCategoryById(firstCategoryId)));
}
}
}
@@ -297,16 +278,17 @@
recomputeRowValidState(row);
- if (SAMPLING_WEIGHT_PROPERTIES.contains(propertyName)) {
+ if (SpeciesBatchRowModel.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(propertyName)) {
// sampling category weight has changed, must then save the top
// ancestor row
+ // new value is the sample category
+ SampleCategory<?> sampleCategory = (SampleCategory<?>) newValue;
+ Integer sampleCategoryId = sampleCategory.getCategoryId();
+
SpeciesBatchTableModel tableModel = getTableModel();
- SampleCategoryColumnIdentifier<SpeciesBatchRowModel> sampleCategoryColumnIdentifier = tableModel.getCategoryIdentifierForWeightProperty(propertyName);
- SampleCategoryEnum sampleCategoryType = sampleCategoryColumnIdentifier.getSampleCategoryType();
- SampleCategory<?> sampleCategory = row.getSampleCategory(sampleCategoryType);
SpeciesBatchRowModel firstAncestorRow = row.getFirstAncestor(sampleCategory);
int firstAncestorIndex = tableModel.getRowIndex(firstAncestorRow);
if (rowIndex != firstAncestorIndex) {
@@ -315,7 +297,7 @@
// then only save ancestor
if (log.isInfoEnabled()) {
- log.info("Sample category " + sampleCategoryType +
+ log.info("Sample category " + sampleCategoryId +
" weight was modified, First ancestor row: " +
firstAncestorIndex + " will save it");
}
@@ -508,15 +490,8 @@
initUI(ui);
- Map<Integer, SampleCategoryEnum> categoryEnumMap =
- SampleCategoryEnum.toIdMapping();
+ List<Integer> samplingOrder = sampleCategoryModel.getSamplingOrder();
- List<SampleCategoryEnum> samplingOrder = Lists.newArrayList();
-
- List<Integer> samplingOrderIds = getConfig().getServiceConfig().getSamplingOrderIds();
- for (Integer id : samplingOrderIds) {
- samplingOrder.add(categoryEnumMap.get(id));
- }
if (log.isInfoEnabled()) {
log.info("Will use sampling order: " + samplingOrder);
}
@@ -546,64 +521,22 @@
SpeciesBatchTableModel.SPECIES);
}
- { // SortedUnsortedCategory column
+ // Sample category columns
+ for (SampleCategoryModelEntry sampleCategoryDef : sampleCategoryModel.getCategory()) {
+
+ SampleCategoryColumnIdentifier<SpeciesBatchRowModel> columnIdentifier = SampleCategoryColumnIdentifier.newId(
+ sampleCategoryDef.getLabel(),
+ sampleCategoryDef.getCategoryId(),
+ n_(sampleCategoryDef.getLabel()),
+ n_(sampleCategoryDef.getLabel()));
+
addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY,
+ columnIdentifier,
caracteristicDecorator,
defaultRenderer);
}
- for (SampleCategoryEnum sampleCategoryType : samplingOrder) {
- switch (sampleCategoryType) {
-
- case size:
-
- { // SizeCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.SIZE_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
- break;
- case sex:
-
- { // SexCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.SEX_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
- break;
- case maturity:
-
- { // MaturityCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.MATURITY_CATEGORY,
- caracteristicDecorator,
- defaultRenderer);
- }
-
- break;
- case age:
-
-
- { // AgeCategory column
-
- addSampleCategoryColumnToModel(columnModel,
- SpeciesBatchTableModel.AGE_CATEGORY,
- getDecorator(Float.class, null),
- defaultRenderer);
- }
-
- break;
- }
- }
-
-
{ // Weight column
addColumnToModel(columnModel,
@@ -647,7 +580,7 @@
// create table model
SpeciesBatchTableModel tableModel =
- new SpeciesBatchTableModel(columnModel);
+ new SpeciesBatchTableModel(sampleCategoryModel, columnModel);
table.setModel(tableModel);
table.setColumnModel(columnModel);
@@ -708,9 +641,9 @@
Species species = speciesBatchRootRowModel.getSpecies();
newRow.setSpecies(species);
- CaracteristicQualitativeValue sortedUnsortedCategory = speciesBatchRootRowModel.getSortedUnsortedCategory();
- SampleCategory<CaracteristicQualitativeValue> category = newRow.getSortedUnsortedCategory();
- category.setCategoryValue(sortedUnsortedCategory);
+ CaracteristicQualitativeValue sampleCategory = speciesBatchRootRowModel.getSampleCategory();
+ SampleCategory category = newRow.getFirstSampleCategory();
+ category.setCategoryValue(sampleCategory);
category.setCategoryWeight(speciesBatchRootRowModel.getBatchWeight());
newRow.setSampleCategory(category);
@@ -793,7 +726,7 @@
}
}
- public void splitBatch(SampleCategoryEnum sampleCategoryEnum,
+ public void splitBatch(SampleCategoryModelEntry sampleCategoryDef,
List<SplitSpeciesBatchRowModel> rows,
Float totalRowWeight) {
JXTable table = getTable();
@@ -818,7 +751,7 @@
loadBatchRow(parentBatch,
newBatch,
- sampleCategoryEnum,
+ sampleCategoryDef.getCategoryId(),
row.getCategoryValue(),
row.getWeight(),
null);
@@ -883,7 +816,7 @@
Preconditions.checkNotNull(row.getSpecies());
SampleCategory<?> sampleCategory = row.getFinestCategory();
Preconditions.checkNotNull(sampleCategory);
- Preconditions.checkNotNull(sampleCategory.getCategoryType());
+ Preconditions.checkNotNull(sampleCategory.getCategoryId());
Preconditions.checkNotNull(sampleCategory.getCategoryValue());
SpeciesBatch catchBean = row.toBean();
@@ -895,7 +828,7 @@
}
// apply sample category
- catchBean.setSampleCategoryType(sampleCategory.getCategoryType());
+ catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
catchBean.setSampleCategoryWeight(sampleCategory.getCategoryWeight());
@@ -948,7 +881,6 @@
//TODO Improve this test
boolean enableAdd = true;
-// CollectionUtils.isNotEmpty(getModel().getAvailableSpecies());
boolean enableRename = false;
boolean enableSplit = false;
@@ -984,16 +916,11 @@
if (enableSplit) {
// can split if selected batch is a leaf
- Map<Integer, SampleCategoryEnum> categoryEnumMap =
- SampleCategoryEnum.toIdMapping();
+ Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
- List<Integer> samplingOrderIds = getConfig().getServiceConfig().getSamplingOrderIds();
- int lastSamplingId = samplingOrderIds.get(samplingOrderIds.size() - 1);
- SampleCategoryEnum lastCategory = categoryEnumMap.get(lastSamplingId);
-
enableSplit = row.isBatchLeaf()
&& selectedRowCount == 1
- && !lastCategory.equals(row.getFinestCategory().getCategoryType())
+ && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
&& row.getNumber() == null
&& (row.getComputedNumber() == null
|| row.getComputedNumber() == 0);
@@ -1073,7 +1000,9 @@
persistenceService.getAllSpeciesBatchFrequency(id);
SpeciesBatchRowModel newRow =
- new SpeciesBatchRowModel(aBatch, frequencies);
+ new SpeciesBatchRowModel(sampleCategoryModel,
+ aBatch,
+ frequencies);
List<Attachment> attachments =
persistenceService.getAllAttachments(newRow.getObjectType(),
@@ -1092,15 +1021,15 @@
}
}
- SampleCategoryEnum sampleCategoryEnum = aBatch.getSampleCategoryType();
+ Integer sampleCategoryId = aBatch.getSampleCategoryId();
Preconditions.checkNotNull(
- sampleCategoryEnum,
+ sampleCategoryId,
"Can't have a batch with no sample category, but was: " + aBatch);
loadBatchRow(parentRow,
newRow,
- sampleCategoryEnum,
+ sampleCategoryId,
aBatch.getSampleCategoryValue(),
aBatch.getSampleCategoryWeight(),
aBatch.getSampleCategoryComputedWeight());
@@ -1144,14 +1073,14 @@
protected void loadBatchRow(SpeciesBatchRowModel parentRow,
SpeciesBatchRowModel newRow,
- SampleCategoryEnum sampleCategoryEnum,
+ Integer sampleCategoryId,
Serializable categoryValue,
Float categoryWeight,
Float categoryComputedWeight) {
// get sample category from his type
SampleCategory sampleCategory =
- newRow.getSampleCategory(sampleCategoryEnum);
+ newRow.getSampleCategoryById(sampleCategoryId);
// fill it
sampleCategory.setCategoryValue(categoryValue);
@@ -1170,21 +1099,12 @@
newRow.setParentBatch(parentRow);
newRow.setSpecies(parentRow.getSpecies());
- if (sampleCategoryEnum != SampleCategoryEnum.sortedUnsorted) {
- newRow.setSortedUnsortedCategory(parentRow.getSortedUnsortedCategory());
+
+ for (Integer id : sampleCategoryModel.getSamplingOrder()) {
+ if (!id.equals(sampleCategoryId)) {
+ newRow.setSampleCategory(parentRow.getSampleCategoryById(id));
+ }
}
- if (sampleCategoryEnum != SampleCategoryEnum.size) {
- newRow.setSizeCategory(parentRow.getSizeCategory());
- }
- if (sampleCategoryEnum != SampleCategoryEnum.sex) {
- newRow.setSexCategory(parentRow.getSexCategory());
- }
- if (sampleCategoryEnum != SampleCategoryEnum.maturity) {
- newRow.setMaturityCategory(parentRow.getMaturityCategory());
- }
- if (sampleCategoryEnum != SampleCategoryEnum.age) {
- newRow.setAgeCategory(parentRow.getAgeCategory());
- }
}
}
@@ -1204,13 +1124,14 @@
public void removeFromSpeciesUsed(SpeciesBatchRowModel row) {
Preconditions.checkNotNull(row);
Preconditions.checkNotNull(row.getSpecies());
- Preconditions.checkNotNull(row.getSortedUnsortedCategoryValue());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
+ Preconditions.checkNotNull(firstSampleCategory);
if (log.isInfoEnabled()) {
- log.info("Remove from speciesUsed: " + decorate(row.getSortedUnsortedCategoryValue()) + " - " + decorate(row.getSpecies()));
+ log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
}
SpeciesBatchUIModel model = getModel();
- model.getSpeciesUsed().remove(row.getSortedUnsortedCategoryValue(),
- row.getSpecies());
+ model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
if (row.isBatchRoot()) {
model.setRootNumber(model.getRootNumber() - 1);
@@ -1220,15 +1141,16 @@
protected void addToSpeciesUsed(SpeciesBatchRowModel row) {
Preconditions.checkNotNull(row);
Preconditions.checkNotNull(row.getSpecies());
- Preconditions.checkNotNull(row.getSortedUnsortedCategoryValue());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ Preconditions.checkNotNull(firstSampleCategory);
+ CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
if (log.isDebugEnabled()) {
log.debug("Add to speciesUsed: " +
- decorate(row.getSortedUnsortedCategoryValue()) +
+ decorate(categoryValue) +
" - " + decorate(row.getSpecies()));
}
SpeciesBatchUIModel model = getModel();
- model.getSpeciesUsed().put(row.getSortedUnsortedCategoryValue(),
- row.getSpecies());
+ model.getSpeciesUsed().put(categoryValue, row.getSpecies());
model.setRootNumber(model.getRootNumber() + 1);
}
@@ -1247,13 +1169,13 @@
protected SpeciesBatch convertRowToBean(SpeciesBatchRowModel row, boolean convertParent) {
SampleCategory<?> sampleCategory = row.getFinestCategory();
Preconditions.checkNotNull(sampleCategory);
- Preconditions.checkNotNull(sampleCategory.getCategoryType());
+ Preconditions.checkNotNull(sampleCategory.getCategoryId());
Preconditions.checkNotNull(sampleCategory.getCategoryValue());
SpeciesBatch catchBean = row.toBean();
// apply sample category
- catchBean.setSampleCategoryType(sampleCategory.getCategoryType());
+ catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
catchBean.setSampleCategoryWeight(sampleCategory.getCategoryWeight());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css 2013-07-24 17:35:44 UTC (rev 1153)
@@ -51,16 +51,16 @@
data: {model.getAvailableSpecies()};
}
-#sortedUnsortedCategoryLabel {
- text: "tutti.createSpeciesBatch.field.sortedUnsortedCategory";
- toolTipText: "tutti.createSpeciesBatch.field.sortedUnsortedCategory.tip";
- labelFor: {sortedUnsortedCategoryComboBox};
- _help: {"tutti.createSpeciesBatch.field.sortedUnsortedCategory.help"};
+#sampleCategoryLabel {
+ text: "tutti.createSpeciesBatch.field.sampleCategory";
+ toolTipText: "tutti.createSpeciesBatch.field.sampleCategory.tip";
+ labelFor: {sampleCategoryComboBox};
+ _help: {"tutti.createSpeciesBatch.field.sampleCategory.help"};
}
-#sortedUnsortedCategoryComboBox {
- property: sortedUnsortedCategory;
- selectedItem: {model.getSortedUnsortedCategory()};
+#sampleCategoryComboBox {
+ property: sampleCategory;
+ selectedItem: {model.getSampleCategory()};
}
#batchWeightLabel {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx 2013-07-24 17:35:44 UTC (rev 1153)
@@ -65,8 +65,8 @@
<BeanValidator id='validator' bean='model'
uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
<field name='species' component='speciesComboBox'/>
- <field name='sortedUnsortedCategory'
- component='sortedUnsortedCategoryComboBox'/>
+ <field name='sampleCategory'
+ component='sampleCategoryComboBox'/>
<field name='batchWeight' component='batchWeightField'/>
</BeanValidator>
@@ -99,13 +99,13 @@
</cell>
</row>
- <!-- Sorted / Unsorted Category -->
+ <!-- Sample Category -->
<row>
<cell anchor='west'>
- <JLabel id='sortedUnsortedCategoryLabel'/>
+ <JLabel id='sampleCategoryLabel'/>
</cell>
<cell weightx='1.0' columns='2'>
- <BeanFilterableComboBox id='sortedUnsortedCategoryComboBox'
+ <BeanFilterableComboBox id='sampleCategoryComboBox'
constructorParams='this'
genericType='CaracteristicQualitativeValue'/>
</cell>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,7 +27,8 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
@@ -72,9 +73,12 @@
super(parentUi.getHandler().getContext(), ui);
this.persistenceService = context.getPersistenceService();
- Caracteristic caracteristic =
- persistenceService.getSortedUnsortedCaracteristic();
- sortedValue = SortedUnsortedEnum.SORTED.getValue(caracteristic);
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ SampleCategoryModelEntry caracteristic = sampleCategoryModel.getCategoryById(sampleCategoryModel.getFirstCategoryId());
+
+ sortedValue = caracteristic.getCaracteristic().getQualitativeValue(0);
}
//------------------------------------------------------------------------//
@@ -101,7 +105,7 @@
Caracteristic caracteristic =
persistenceService.getSortedUnsortedCaracteristic();
- initBeanFilterableComboBox(ui.getSortedUnsortedCategoryComboBox(),
+ initBeanFilterableComboBox(ui.getSampleCategoryComboBox(),
caracteristic.getQualitativeValue(),
null);
@@ -119,14 +123,14 @@
if (newValue == null || source.getSpeciesUsed() == null) {
- source.setSortedUnsortedCategory(null);
+ source.setSampleCategory(null);
} else {
// look for best value : if sorted is available then use it
List<CaracteristicQualitativeValue> qualitativeValues =
- ui.getSortedUnsortedCategoryComboBox().getData();
+ ui.getSampleCategoryComboBox().getData();
CaracteristicQualitativeValue newCategory = null;
@@ -139,7 +143,7 @@
}
}
}
- source.setSortedUnsortedCategory(newCategory);
+ source.setSampleCategory(newCategory);
}
}
});
@@ -199,7 +203,7 @@
ui.getValidator().setBean(model);
model.setSpecies(null);
- model.setSortedUnsortedCategory(null);
+ model.setSampleCategory(null);
model.setBatchWeight(null);
List<Species> speciesToUse = Lists.newArrayList();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -50,7 +50,7 @@
public static final String PROPERTY_SPECIES = "species";
- public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory";
+ public static final String PROPERTY_SAMPLE_CATEGORY = "sampleCategory";
public static final String PROPERTY_BATCH_WEIGHT = "batchWeight";
@@ -69,11 +69,11 @@
protected Species species;
/**
- * Sorted Unsorted category.
+ * First sample category.
*
- * @since 0.3
+ * @since 2.5
*/
- protected CaracteristicQualitativeValue sortedUnsortedCategory;
+ protected CaracteristicQualitativeValue sampleCategory;
/**
* Incoming batch weight to split.
@@ -83,7 +83,7 @@
protected Float batchWeight;
/**
- * Already used species by sortedUnsorted category.
+ * Already used species by sample category.
*
* @since 0.3
*/
@@ -120,14 +120,14 @@
firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
}
- public CaracteristicQualitativeValue getSortedUnsortedCategory() {
- return sortedUnsortedCategory;
+ public CaracteristicQualitativeValue getSampleCategory() {
+ return sampleCategory;
}
- public void setSortedUnsortedCategory(CaracteristicQualitativeValue sortedUnsortedCategory) {
- Object oldSpecies = getSortedUnsortedCategory();
- this.sortedUnsortedCategory = sortedUnsortedCategory;
- firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldSpecies, sortedUnsortedCategory);
+ public void setSampleCategory(CaracteristicQualitativeValue sampleCategory) {
+ Object oldValue = getSampleCategory();
+ this.sampleCategory = sampleCategory;
+ firePropertyChange(PROPERTY_SAMPLE_CATEGORY, oldValue, sampleCategory);
}
public Float getBatchWeight() {
@@ -145,14 +145,14 @@
}
public boolean isSpeciesAndCategoryAvailable() {
- boolean result = species != null && sortedUnsortedCategory != null &&
- isSpeciesAndCategoryAvailable(species, sortedUnsortedCategory);
+ boolean result = species != null && sampleCategory != null &&
+ isSpeciesAndCategoryAvailable(species, sampleCategory);
return result;
}
public boolean isSpeciesAndCategoryAvailable(Species species,
- CaracteristicQualitativeValue sortedUnsortedCategory) {
- boolean result = !speciesUsed.containsEntry(sortedUnsortedCategory, species);
+ CaracteristicQualitativeValue sampleCategory) {
+ boolean result = !speciesUsed.containsEntry(sampleCategory, species);
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -29,6 +29,7 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -199,7 +200,9 @@
@Override
public void beforeInitUI() {
- SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel();
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+ SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel(sampleCategoryModel);
ui.setContextValue(model);
}
@@ -481,7 +484,7 @@
frequencyEditor = editor;
Caracteristic lengthStepCaracteristic = null;
- Float lengthStep = 1f;
+ Float lengthStep;
List<SpeciesFrequencyRowModel> editFrequency = Lists.newArrayList();
@@ -641,7 +644,7 @@
public String decorateCategory(SpeciesBatchRowModel object) {
return object == null ? "" :
- decorate(object.getFinestCategory().getCategoryType()) + " / " + decorate(object.getFinestCategory().getCategoryValue());
+ decorate(object.getFinestCategory().getCategoryDef()) + " / " + decorate(object.getFinestCategory().getCategoryValue());
}
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,6 +25,7 @@
*/
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
@@ -142,8 +143,11 @@
protected Set<SpeciesFrequencyRowModel> emptyRows;
- public SpeciesFrequencyUIModel() {
+ protected SampleCategoryModel sampleCategoryModel;
+
+ public SpeciesFrequencyUIModel(SampleCategoryModel sampleCategoryModel) {
super(SpeciesBatchRowModel.class, null, null);
+ this.sampleCategoryModel = sampleCategoryModel;
setEmptyRows(Sets.<SpeciesFrequencyRowModel>newHashSet());
}
@@ -297,6 +301,6 @@
@Override
protected SpeciesBatchRowModel newEntity() {
- return new SpeciesBatchRowModel();
+ return new SpeciesBatchRowModel(sampleCategoryModel);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -25,7 +25,7 @@
*/
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
@@ -57,12 +57,12 @@
super(SplitSpeciesBatchRowModel.class, null, null);
}
- public SampleCategoryEnum getCategoryType() {
- return category.getCategoryType();
+ public SampleCategoryModelEntry getCategorytype() {
+ return category.getCategoryDef();
}
- public void setCategoryType(SampleCategoryEnum categoryType) {
- category.setCategoryType(categoryType);
+ public void setCategoryType(SampleCategoryModelEntry categoryType) {
+ category.setCategoryDef(categoryType);
}
public Serializable getCategoryValue() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx 2013-07-24 17:35:44 UTC (rev 1153)
@@ -33,7 +33,6 @@
org.jdesktop.swingx.JXTable
jaxx.runtime.validator.swing.SwingValidatorUtil
- jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
javax.swing.ListSelectionModel
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,14 +27,14 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
@@ -69,19 +69,19 @@
private static final Log log =
LogFactory.getLog(SplitSpeciesBatchUIHandler.class);
- /**
- * Parent UI.
- *
- * @since 0.3
- */
- private final SpeciesBatchUI parentUi;
+// /**
+// * Parent UI.
+// *
+// * @since 0.3
+// */
+// private final SpeciesBatchUI parentUi;
public SplitSpeciesBatchUIHandler(EditCatchesUI parentUi,
SplitSpeciesBatchUI ui) {
super(parentUi.getHandler().getContext(), ui,
SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
SplitSpeciesBatchRowModel.PROPERTY_WEIGHT);
- this.parentUi = parentUi.getSpeciesTabContent();
+// this.parentUi = parentUi.getSpeciesTabContent();
}
//------------------------------------------------------------------------//
@@ -146,8 +146,11 @@
@Override
public void beforeInitUI() {
- SplitSpeciesBatchUIModel model = new SplitSpeciesBatchUIModel();
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+ SplitSpeciesBatchUIModel model = new SplitSpeciesBatchUIModel(sampleCategoryModel);
+
ui.setContextValue(model);
}
@@ -170,7 +173,7 @@
source.setSelectedCategory(null);
// fill comboBox with new list
- List<SampleCategoryEnum> data = (List<SampleCategoryEnum>) evt.getNewValue();
+ List<SampleCategoryModelEntry> data = (List<SampleCategoryModelEntry>) evt.getNewValue();
ui.getCategoryComboBox().setModel(new DefaultComboBoxModel(data.toArray()));
}
});
@@ -186,19 +189,19 @@
// when selected category change, sample total weight is reset
source.setSampleWeight(null);
- SampleCategoryEnum newValue =
- (SampleCategoryEnum) evt.getNewValue();
+ SampleCategoryModelEntry newValue =
+ (SampleCategoryModelEntry) evt.getNewValue();
generateTableModel(newValue);
}
});
- ui.getCategoryComboBox().setRenderer(newListCellRender(SampleCategoryEnum.class));
+ ui.getCategoryComboBox().setRenderer(newListCellRender(SampleCategoryModelEntry.class));
ui.getCategoryComboBox().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox comboBox = (JComboBox) e.getSource();
- getModel().setSelectedCategory((SampleCategoryEnum) comboBox.getSelectedItem());
+ getModel().setSelectedCategory((SampleCategoryModelEntry) comboBox.getSelectedItem());
}
});
@@ -256,47 +259,35 @@
public void editBatch(SpeciesBatchRowModel batch) {
// get possible the last used
- List<SampleCategoryEnum> categories =
- Lists.newArrayList(SampleCategoryEnum.values());
+ List<SampleCategoryModelEntry> categories = Lists.newArrayList();
if (batch != null) {
- //TODO Use the samplingOrder (+ the one from the table model)
+ // get sample category model
+ SampleCategoryModel sampleCategoryModel =
+ getModel().getSampleCategoryModel();
+
+ // set all categories (the no more available will be removed later)
+ categories.addAll(sampleCategoryModel.getCategory());
+
SampleCategory<?> lastCategory = batch.getFinestCategory();
Preconditions.checkNotNull(
lastCategory,
"Can't split a species batch with no sample category.");
- if (batch.getSortedUnsortedCategory().isValid()) {
- categories.remove(SampleCategoryEnum.sortedUnsorted);
- }
+ int firstOrder = lastCategory.getCategoryDef().getOrder();
- if (batch.getSizeCategory().isValid()) {
- categories.remove(SampleCategoryEnum.size);
- categories.remove(SampleCategoryEnum.sortedUnsorted);
- }
+ for (Integer sampleCategoryId : sampleCategoryModel.getSamplingOrder()) {
+ SampleCategory<?> sampleCategory = batch.getSampleCategoryById(sampleCategoryId);
+ int order = sampleCategory.getCategoryDef().getOrder();
+ if (order < firstOrder || sampleCategory.isValid()) {
- if (batch.getSexCategory().isValid()) {
- categories.remove(SampleCategoryEnum.sex);
- categories.remove(SampleCategoryEnum.size);
- categories.remove(SampleCategoryEnum.sortedUnsorted);
+ // remove category if before the finest one
+ // remove category if not filled
+ categories.remove(sampleCategory.getCategoryDef());
+ }
}
-
- if (batch.getMaturityCategory().isValid()) {
- categories.remove(SampleCategoryEnum.maturity);
- categories.remove(SampleCategoryEnum.sex);
- categories.remove(SampleCategoryEnum.size);
- categories.remove(SampleCategoryEnum.sortedUnsorted);
- }
-
- if (batch.getAgeCategory().isValid()) {
- categories.remove(SampleCategoryEnum.age);
- categories.remove(SampleCategoryEnum.maturity);
- categories.remove(SampleCategoryEnum.sex);
- categories.remove(SampleCategoryEnum.size);
- categories.remove(SampleCategoryEnum.sortedUnsorted);
- }
}
SplitSpeciesBatchUIModel model = getModel();
@@ -357,7 +348,7 @@
getModel().setSampleWeight(result);
}
- protected void generateTableModel(SampleCategoryEnum category) {
+ protected void generateTableModel(SampleCategoryModelEntry category) {
// when generate a new table model, then reset previous rows from model
getModel().setRows(null);
@@ -369,32 +360,23 @@
{ // Selection
- addBooleanColumnToModel(columnModel, SplitSpeciesBatchTableModel.SELECTED, getTable());
+ addBooleanColumnToModel(columnModel,
+ SplitSpeciesBatchTableModel.SELECTED,
+ getTable());
}
boolean editableCategoryValue = false;
if (category != null) {
- switch (category) {
+ if (!category.getCaracteristic().isQualitativeValueEmpty()) {
- case sortedUnsorted:
- data = persistenceService.getSortedUnsortedCaracteristic();
- break;
- case size:
- data = persistenceService.getSizeCategoryCaracteristic();
- break;
- case sex:
- data = persistenceService.getSexCaracteristic();
- break;
- case maturity:
- data = persistenceService.getMaturityCaracteristic();
- break;
- case age:
- editableCategoryValue = true;
- addFloatColumnToModel(columnModel,
- SplitSpeciesBatchTableModel.EDITABLE_CATEGORY_VALUE,
- TuttiUI.DECIMAL1_PATTERN);
- break;
+ // qualitative category
+ data = category.getCaracteristic();
+ } else {
+ editableCategoryValue = true;
+ addFloatColumnToModel(columnModel,
+ SplitSpeciesBatchTableModel.EDITABLE_CATEGORY_VALUE,
+ TuttiUI.DECIMAL1_PATTERN);
}
if (data != null) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,7 +24,8 @@
* #L%
*/
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
@@ -64,14 +65,14 @@
*
* @since 0.3
*/
- protected List<SampleCategoryEnum> category;
+ protected List<SampleCategoryModelEntry> category;
/**
* Selected Sample category.
*
* @since 0.3
*/
- protected SampleCategoryEnum selectedCategory;
+ protected SampleCategoryModelEntry selectedCategory;
/**
* Sample weight of split batches.
@@ -80,8 +81,11 @@
*/
protected Float sampleWeight;
- public SplitSpeciesBatchUIModel() {
+ protected SampleCategoryModel sampleCategoryModel;
+
+ public SplitSpeciesBatchUIModel(SampleCategoryModel sampleCategoryModel) {
super(SpeciesBatchRowModel.class, null, null);
+ this.sampleCategoryModel = sampleCategoryModel;
}
public SpeciesBatchRowModel getBatch() {
@@ -101,21 +105,21 @@
return batch == null ? null : batch.getSpecies();
}
- public List<SampleCategoryEnum> getCategory() {
+ public List<SampleCategoryModelEntry> getCategory() {
return category;
}
- public void setCategory(List<SampleCategoryEnum> category) {
+ public void setCategory(List<SampleCategoryModelEntry> category) {
Object oldValue = getCategory();
this.category = category;
firePropertyChange(PROPERTY_CATEGORY, oldValue, category);
}
- public SampleCategoryEnum getSelectedCategory() {
+ public SampleCategoryModelEntry getSelectedCategory() {
return selectedCategory;
}
- public void setSelectedCategory(SampleCategoryEnum selectedCategory) {
+ public void setSelectedCategory(SampleCategoryModelEntry selectedCategory) {
Object oldValue = getSelectedCategory();
this.selectedCategory = selectedCategory;
firePropertyChange(PROPERTY_SELECTED_CATEGORY, oldValue, selectedCategory);
@@ -137,6 +141,10 @@
@Override
protected SpeciesBatchRowModel newEntity() {
- return new SpeciesBatchRowModel();
+ return new SpeciesBatchRowModel(sampleCategoryModel);
}
+
+ public SampleCategoryModel getSampleCategoryModel() {
+ return sampleCategoryModel;
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -32,6 +32,9 @@
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.util.Collection;
+import java.util.List;
+
/**
* @author kmorin
* @since 0.3
@@ -44,14 +47,6 @@
public static final String PROPERTY_SPECIES = "species";
- public static final String PROPERTY_SIZE_ENABLED = "sizeEnabled";
-
- public static final String PROPERTY_SEX_ENABLED = "sexEnabled";
-
- public static final String PROPERTY_MATURITY_ENABLED = "maturityEnabled";
-
- public static final String PROPERTY_AGE_ENABLED = "ageEnabled";
-
public static final String PROPERTY_LENGTH_STEP_PMFM = "lengthStepPmfm";
public static final String PROPERTY_WEIGHT_ENABLED = "weightEnabled";
@@ -64,14 +59,6 @@
protected String speciesSurveyCode;
- protected boolean sizeEnabled;
-
- protected boolean sexEnabled;
-
- protected boolean maturityEnabled;
-
- protected boolean ageEnabled;
-
protected Caracteristic lengthStepPmfm;
protected boolean weightEnabled;
@@ -80,6 +67,8 @@
protected boolean calcifySampleEnabled;
+ protected List<Integer> mandatorySampleCategoryId;
+
protected static final Binder<SpeciesProtocol, EditProtocolSpeciesRowModel> fromBeanBinder =
BinderFactory.newBinder(SpeciesProtocol.class,
EditProtocolSpeciesRowModel.class);
@@ -124,54 +113,6 @@
}
@Override
- public boolean isSizeEnabled() {
- return sizeEnabled;
- }
-
- @Override
- public void setSizeEnabled(boolean sizeEnabled) {
- Object oldValue = isSizeEnabled();
- this.sizeEnabled = sizeEnabled;
- firePropertyChange(PROPERTY_SIZE_ENABLED, oldValue, sizeEnabled);
- }
-
- @Override
- public boolean isSexEnabled() {
- return sexEnabled;
- }
-
- @Override
- public void setSexEnabled(boolean sexEnabled) {
- Object oldValue = isSexEnabled();
- this.sexEnabled = sexEnabled;
- firePropertyChange(PROPERTY_SEX_ENABLED, oldValue, sexEnabled);
- }
-
- @Override
- public boolean isMaturityEnabled() {
- return maturityEnabled;
- }
-
- @Override
- public void setMaturityEnabled(boolean maturityEnabled) {
- Object oldValue = isMaturityEnabled();
- this.maturityEnabled = maturityEnabled;
- firePropertyChange(PROPERTY_MATURITY_ENABLED, oldValue, maturityEnabled);
- }
-
- @Override
- public boolean isAgeEnabled() {
- return ageEnabled;
- }
-
- @Override
- public void setAgeEnabled(boolean ageEnabled) {
- Object oldValue = isAgeEnabled();
- this.ageEnabled = ageEnabled;
- firePropertyChange(PROPERTY_AGE_ENABLED, oldValue, ageEnabled);
- }
-
- @Override
public String getLengthStepPmfmId() {
return lengthStepPmfm != null ? lengthStepPmfm.getId() : null;
}
@@ -248,4 +189,65 @@
protected SpeciesProtocol newEntity() {
return TuttiBeanFactory.newSpeciesProtocol();
}
+
+ @Override
+ public Integer getMandatorySampleCategoryId(int index) {
+ Integer o = getChild(mandatorySampleCategoryId, index);
+ return o;
+ }
+
+ @Override
+ public boolean isMandatorySampleCategoryIdEmpty() {
+ return mandatorySampleCategoryId == null || mandatorySampleCategoryId.isEmpty();
+ }
+
+ @Override
+ public int sizeMandatorySampleCategoryId() {
+ return mandatorySampleCategoryId == null ? 0 : mandatorySampleCategoryId.size();
+ }
+
+ @Override
+ public void addMandatorySampleCategoryId(Integer mandatorySampleCategoryId) {
+ getMandatorySampleCategoryId().add(mandatorySampleCategoryId);
+ }
+
+ @Override
+ public void addAllMandatorySampleCategoryId(Collection<Integer> mandatorySampleCategoryId) {
+ getMandatorySampleCategoryId().addAll(mandatorySampleCategoryId);
+ }
+
+ @Override
+ public boolean removeMandatorySampleCategoryId(Integer mandatorySampleCategoryId) {
+ boolean removed = getMandatorySampleCategoryId().remove(mandatorySampleCategoryId);
+ return removed;
+ }
+
+ @Override
+ public boolean removeAllMandatorySampleCategoryId(Collection<Integer> mandatorySampleCategoryId) {
+ boolean removed = getMandatorySampleCategoryId().removeAll(mandatorySampleCategoryId);
+ return removed;
+ }
+
+ @Override
+ public boolean containsMandatorySampleCategoryId(Integer mandatorySampleCategoryId) {
+ boolean contains = getMandatorySampleCategoryId().contains(mandatorySampleCategoryId);
+ return contains;
+ }
+
+ @Override
+ public boolean containsAllMandatorySampleCategoryId(Collection<Integer> mandatorySampleCategoryId) {
+ boolean contains = getMandatorySampleCategoryId().containsAll(mandatorySampleCategoryId);
+ return contains;
+ }
+
+ @Override
+ public List<Integer> getMandatorySampleCategoryId() {
+ return mandatorySampleCategoryId;
+ }
+
+ @Override
+ public void setMandatorySampleCategoryId(List<Integer> mandatorySampleCategoryId) {
+ this.mandatorySampleCategoryId = mandatorySampleCategoryId;
+ firePropertyChange(PROPERTY_MANDATORY_SAMPLE_CATEGORY_ID, null, mandatorySampleCategoryId);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -24,10 +24,14 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import org.jdesktop.swingx.table.TableColumnModelExt;
+import java.util.List;
+
import static org.nuiton.i18n.I18n.n_;
/**
@@ -46,26 +50,6 @@
n_("tutti.editProtocol.table.header.speciesSurveyCode"),
n_("tutti.editProtocol.table.header.speciesSurveyCode.tip"));
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_ENABLED = ColumnIdentifier.newId(
- EditProtocolSpeciesRowModel.PROPERTY_SIZE_ENABLED,
- n_("tutti.editProtocol.table.header.size"),
- n_("tutti.editProtocol.table.header.size.tip"));
-
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SEX_ENABLED = ColumnIdentifier.newId(
- EditProtocolSpeciesRowModel.PROPERTY_SEX_ENABLED,
- n_("tutti.editProtocol.table.header.sex"),
- n_("tutti.editProtocol.table.header.sex.tip"));
-
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> MATURITY_ENABLED = ColumnIdentifier.newId(
- EditProtocolSpeciesRowModel.PROPERTY_MATURITY_ENABLED,
- n_("tutti.editProtocol.table.header.maturity"),
- n_("tutti.editProtocol.table.header.maturity.tip"));
-
- public static final ColumnIdentifier<EditProtocolSpeciesRowModel> AGE_ENABLED = ColumnIdentifier.newId(
- EditProtocolSpeciesRowModel.PROPERTY_AGE_ENABLED,
- n_("tutti.editProtocol.table.header.age"),
- n_("tutti.editProtocol.table.header.age.tip"));
-
public static final ColumnIdentifier<EditProtocolSpeciesRowModel> LENGTH_STEP_PMFM_ID = ColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_LENGTH_STEP_PMFM,
n_("tutti.editProtocol.table.header.lengthStep"),
@@ -86,20 +70,24 @@
n_("tutti.editProtocol.table.header.calcifySample"),
n_("tutti.editProtocol.table.header.calcifySample.tip"));
+ protected final SampleCategoryModel sampleCategoryModel;
+
private static final long serialVersionUID = 1L;
- public EditProtocolSpeciesTableModel(TableColumnModelExt columnModel) {
+ public EditProtocolSpeciesTableModel(SampleCategoryModel sampleCategoryModel, TableColumnModelExt columnModel) {
super(columnModel, false, false);
-
+ this.sampleCategoryModel = sampleCategoryModel;
setNoneEditableCols(SPECIES_ID);
}
- public static EditProtocolSpeciesRowModel newRow() {
+ public static EditProtocolSpeciesRowModel newRow(SampleCategoryModel sampleCategoryModel) {
EditProtocolSpeciesRowModel result = new EditProtocolSpeciesRowModel();
- result.setMaturityEnabled(true);
- result.setSizeEnabled(true);
- result.setSexEnabled(true);
- result.setAgeEnabled(true);
+
+ List<Integer> mandatoryIds =
+ Lists.newArrayList(sampleCategoryModel.getSamplingOrder());
+
+ result.setMandatorySampleCategoryId(mandatoryIds);
+
result.setWeightEnabled(true);
result.setCountIfNoFrequencyEnabled(true);
result.setCalcifySampleEnabled(true);
@@ -109,7 +97,7 @@
@Override
public EditProtocolSpeciesRowModel createNewRow() {
- EditProtocolSpeciesRowModel result = newRow();
+ EditProtocolSpeciesRowModel result = newRow(sampleCategoryModel);
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -29,6 +29,8 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
@@ -58,7 +60,7 @@
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import javax.swing.JComboBox;
import javax.swing.JComponent;
@@ -112,9 +114,12 @@
*/
protected final PersistenceService persistenceService;
+ protected final SampleCategoryModel sampleCategoryModel;
+
public EditProtocolUIHandler(TuttiUI parentUi, EditProtocolUI ui) {
super(parentUi.getHandler().getContext(), ui);
this.persistenceService = context.getPersistenceService();
+ this.sampleCategoryModel = context.getDataContext().getSampleCategoryModel();
}
public JXTable getSpeciesTable() {
@@ -284,15 +289,27 @@
addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.WEIGHT_ENABLED, table);
addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.COUNT_IF_NO_FREQUENCY_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SIZE_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SEX_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.MATURITY_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.AGE_ENABLED, table);
+ for (SampleCategoryModelEntry sampleCategoryModelEntry : sampleCategoryModel.getCategory()) {
+ MandatorySampleCategoryColumnIdentifier identifier = MandatorySampleCategoryColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_MANDATORY_SAMPLE_CATEGORY_ID,
+ sampleCategoryModelEntry.getCategoryId(),
+ sampleCategoryModelEntry.getLabel(),
+ sampleCategoryModelEntry.getLabel()
+ );
+
+ addBooleanColumnToModel(columnModel, identifier, table);
+ }
+
+// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SIZE_ENABLED, table);
+// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SEX_ENABLED, table);
+// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.MATURITY_ENABLED, table);
+// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.AGE_ENABLED, table);
+
addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.CALCIFY_SAMPLE_ENABLED, table);
EditProtocolSpeciesTableModel tableModel =
- new EditProtocolSpeciesTableModel(columnModel);
+ new EditProtocolSpeciesTableModel(sampleCategoryModel, columnModel);
table.setModel(tableModel);
table.setColumnModel(columnModel);
@@ -332,15 +349,28 @@
addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.WEIGHT_ENABLED, table);
addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.COUNT_IF_NO_FREQUENCY_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SIZE_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SEX_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.MATURITY_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.AGE_ENABLED, table);
+ for (SampleCategoryModelEntry sampleCategoryModelEntry : sampleCategoryModel.getCategory()) {
+ MandatorySampleCategoryColumnIdentifier identifier = MandatorySampleCategoryColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_MANDATORY_SAMPLE_CATEGORY_ID,
+ sampleCategoryModelEntry.getCategoryId(),
+ sampleCategoryModelEntry.getLabel(),
+ sampleCategoryModelEntry.getLabel()
+ );
+
+ addBooleanColumnToModel(columnModel, identifier, table);
+ }
+
+// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SIZE_ENABLED, table);
+// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SEX_ENABLED, table);
+// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.MATURITY_ENABLED, table);
+// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.AGE_ENABLED, table);
+
addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.CALCIFY_SAMPLE_ENABLED, table);
EditProtocolSpeciesTableModel tableModel =
- new EditProtocolSpeciesTableModel(columnModel);
+ new EditProtocolSpeciesTableModel(sampleCategoryModel,
+ columnModel);
table.setModel(tableModel);
table.setColumnModel(columnModel);
@@ -465,10 +495,13 @@
speciesComboBox.removeItem(species);
benthosComboBox.removeItem(species);
- EditProtocolSpeciesRowModel row = EditProtocolSpeciesTableModel.newRow();
+ EditProtocolSpeciesRowModel row = EditProtocolSpeciesTableModel.newRow(sampleCategoryModel);
row.setSpecies(species);
row.setLengthStepPmfm(allCaracteristic.get(speciesProtocol.getLengthStepPmfmId()));
row.fromBean(speciesProtocol);
+
+ // make sure to get a clean copy of the list
+ row.setMandatorySampleCategoryId(Lists.newArrayList(speciesProtocol.getMandatorySampleCategoryId()));
result.add(row);
}
}
@@ -699,7 +732,7 @@
if (CollectionUtils.isNotEmpty(selectedIds)) {
for (String selectedId : selectedIds) {
Caracteristic e = caracteristicMap.get(selectedId);
- Preconditions.checkNotNull(e,"Could not find caracteristic with id: "+selectedId);
+ Preconditions.checkNotNull(e, "Could not find caracteristic with id: " + selectedId);
selection.add(e);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -554,4 +554,14 @@
@Override
public void setBenthos(List<SpeciesProtocol> benthos) {
}
+
+ @Override
+ public Integer getVersion() {
+ return editObject.getVersion();
+ }
+
+ @Override
+ public void setVersion(Integer version) {
+ editObject.setVersion(version);
+ }
}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/MandatorySampleCategoryColumnIdentifier.java (from rev 1152, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/MandatorySampleCategoryColumnIdentifier.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/MandatorySampleCategoryColumnIdentifier.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1,55 @@
+package fr.ifremer.tutti.ui.swing.content.protocol;
+
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class MandatorySampleCategoryColumnIdentifier extends ColumnIdentifier<EditProtocolSpeciesRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static MandatorySampleCategoryColumnIdentifier newId(String propertyName,
+ Integer sampleCategoryId,
+ String headerI18nKey,
+ String headerTipI18nKey) {
+ return new MandatorySampleCategoryColumnIdentifier(propertyName,
+ sampleCategoryId,
+ headerI18nKey,
+ headerTipI18nKey);
+ }
+
+ private final Integer sampleCategoryId;
+
+ MandatorySampleCategoryColumnIdentifier(String propertyName,
+ Integer sampleCategoryId,
+ String headerI18nKey,
+ String headerTipI18nKey) {
+ super(propertyName, headerI18nKey, headerTipI18nKey);
+ this.sampleCategoryId = sampleCategoryId;
+ }
+
+ @Override
+ public Object getValue(EditProtocolSpeciesRowModel entry) {
+ boolean result = entry.containsMandatorySampleCategoryId(sampleCategoryId);
+ return result;
+ }
+
+ @Override
+ public void setValue(EditProtocolSpeciesRowModel entry, Object value) {
+ Boolean toAdd = value == null ? false : Boolean.valueOf(value.toString());
+ if (toAdd) {
+ if (!entry.containsMandatorySampleCategoryId(sampleCategoryId)) {
+ entry.addMandatorySampleCategoryId(sampleCategoryId);
+ }
+ } else {
+ entry.removeMandatorySampleCategoryId(sampleCategoryId);
+ }
+ }
+
+ public Integer getSampleCategoryId() {
+ return sampleCategoryId;
+ }
+
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,8 +27,12 @@
import fr.ifremer.tutti.PropagatePropertyChangeListener;
import fr.ifremer.tutti.persistence.entities.TuttiEntity;
import org.jdesktop.beans.AbstractSerializableBean;
+import org.nuiton.util.CollectionUtil;
import org.nuiton.util.beans.Binder;
+import java.util.Collection;
+import java.util.List;
+
/**
* Abstract UI model to edit a bean.
*
@@ -142,5 +146,12 @@
firePropertyChange(propertyName, oldValue, newValue);
}
+ protected <B> B getChild(Collection<B> child, int index) {
+ return CollectionUtil.getOrNull(child, index);
+ }
+ protected <B> B getChild(List<B> child, int index) {
+ return CollectionUtil.getOrNull(child, index);
+ }
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -59,8 +59,8 @@
import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
import org.jdesktop.swingx.table.TableColumnExt;
-import org.nuiton.util.decorator.Decorator;
-import org.nuiton.util.decorator.JXPathDecorator;
+import org.nuiton.decorator.Decorator;
+import org.nuiton.decorator.JXPathDecorator;
import org.nuiton.validator.bean.simple.SimpleBeanValidator;
import javax.swing.AbstractAction;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiBeanMonitor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiBeanMonitor.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiBeanMonitor.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -46,6 +46,10 @@
this.monitor = new BeanMonitor(properties);
}
+ public void setProperties(String... properties) {
+ monitor.setProperties(properties);
+ }
+
public B getBean() {
return (B) monitor.getBean();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -32,7 +32,7 @@
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import org.jdesktop.beans.AbstractBean;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
/**
* Tutti base action.
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -27,7 +27,7 @@
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import jaxx.runtime.SwingUtil;
import org.apache.commons.collections.CollectionUtils;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import javax.swing.JComponent;
import javax.swing.JTable;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapCellComponent.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapCellComponent.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -34,7 +34,7 @@
import org.apache.commons.collections.MapUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -37,7 +37,7 @@
import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import javax.swing.AbstractCellEditor;
import javax.swing.JComboBox;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -30,7 +30,7 @@
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
-import org.nuiton.util.decorator.Decorator;
+import org.nuiton.decorator.Decorator;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiLocationTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiLocationTableCell.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiLocationTableCell.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -30,8 +30,8 @@
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
-import org.nuiton.util.decorator.Decorator;
-import org.nuiton.util.decorator.JXPathDecorator;
+import org.nuiton.decorator.Decorator;
+import org.nuiton.decorator.JXPathDecorator;
import javax.swing.DefaultCellEditor;
import javax.swing.DefaultListCellRenderer;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/VesselTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/VesselTableCell.java 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/VesselTableCell.java 2013-07-24 17:35:44 UTC (rev 1153)
@@ -30,8 +30,8 @@
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
-import org.nuiton.util.decorator.Decorator;
-import org.nuiton.util.decorator.JXPathDecorator;
+import org.nuiton.decorator.Decorator;
+import org.nuiton.decorator.JXPathDecorator;
import javax.swing.DefaultCellEditor;
import javax.swing.DefaultListCellRenderer;
Modified: trunk/tutti-ui-swing/src/main/resources/META-INF/aop.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/META-INF/aop.xml 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/resources/META-INF/aop.xml 2013-07-24 17:35:44 UTC (rev 1153)
@@ -33,7 +33,7 @@
expression="
execution(* fr.ifremer.tutti.ui.swing.util..*(..))
||execution(* fr.ifremer.tutti.ui.swing.content..*(..))
- ||execution(* org.nuiton.util.decorator..*(..))
+ ||execution(* org.nuiton.decorator..*(..))
||execution(* jaxx.runtime.swing.editor.bean.BeanComboBox.*(..))
"/>
</concrete-aspect>
Copied: trunk/tutti-ui-swing/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider (from rev 1152, trunk/tutti-ui-swing/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider)
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/META-INF/services/org.nuiton.config.ApplicationConfigProvider 2013-07-24 17:35:44 UTC (rev 1153)
@@ -0,0 +1 @@
+fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfigProvider
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/resources/META-INF/services/org.nuiton.util.config.ApplicationConfigProvider 2013-07-24 17:35:44 UTC (rev 1153)
@@ -1 +0,0 @@
-fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfigProvider
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml 2013-07-24 17:35:44 UTC (rev 1153)
@@ -42,7 +42,7 @@
</field-validator>
</field>
- <field name="sortedUnsortedCategory">
+ <field name="sampleCategory">
<field-validator type="required" short-circuit="true">
<message>
tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml 2013-07-24 17:35:44 UTC (rev 1153)
@@ -42,7 +42,7 @@
</field-validator>
</field>
- <field name="sortedUnsortedCategory">
+ <field name="sampleCategory">
<field-validator type="required" short-circuit="true">
<message>
tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-24 17:35:44 UTC (rev 1153)
@@ -163,6 +163,8 @@
tutti.createBenthosBatch.action.save.tip=
tutti.createBenthosBatch.field.batchWeight=
tutti.createBenthosBatch.field.batchWeight.tip=
+tutti.createBenthosBatch.field.sampleCategory=
+tutti.createBenthosBatch.field.sampleCategory.tip=
tutti.createBenthosBatch.field.sortedUnsortedCategory=
tutti.createBenthosBatch.field.sortedUnsortedCategory.tip=
tutti.createBenthosBatch.field.species=
@@ -215,6 +217,8 @@
tutti.createSpeciesBatch.action.save.tip=
tutti.createSpeciesBatch.field.batchWeight=
tutti.createSpeciesBatch.field.batchWeight.tip=
+tutti.createSpeciesBatch.field.sampleCategory=
+tutti.createSpeciesBatch.field.sampleCategory.tip=
tutti.createSpeciesBatch.field.sortedUnsortedCategory=
tutti.createSpeciesBatch.field.sortedUnsortedCategory.tip=
tutti.createSpeciesBatch.field.species=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-18 15:54:10 UTC (rev 1152)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-24 17:35:44 UTC (rev 1153)
@@ -157,6 +157,8 @@
tutti.createBenthosBatch.action.save.tip=Enregistrer la création du lot espèce
tutti.createBenthosBatch.field.batchWeight=Poids du lot (kg)
tutti.createBenthosBatch.field.batchWeight.tip=Poids du lot (kg)
+tutti.createBenthosBatch.field.sampleCategory=
+tutti.createBenthosBatch.field.sampleCategory.tip=
tutti.createBenthosBatch.field.sortedUnsortedCategory=V / HV
tutti.createBenthosBatch.field.sortedUnsortedCategory.tip=Catégorie Vrac / Hors Vrac
tutti.createBenthosBatch.field.species=Espèce du lot
@@ -209,6 +211,8 @@
tutti.createSpeciesBatch.action.save.tip=Enregistrer la création du lot espèce
tutti.createSpeciesBatch.field.batchWeight=Poids du lot (kg)
tutti.createSpeciesBatch.field.batchWeight.tip=Poids du lot (non obligatoire à ce stade)
+tutti.createSpeciesBatch.field.sampleCategory=
+tutti.createSpeciesBatch.field.sampleCategory.tip=
tutti.createSpeciesBatch.field.sortedUnsortedCategory=V / HV
tutti.createSpeciesBatch.field.sortedUnsortedCategory.tip=Vrac ou Hors Vrac
tutti.createSpeciesBatch.field.species=Espèce du lot
1
0
r1152 - trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export
by tchemit@users.forge.codelutin.com 18 Jul '13
by tchemit@users.forge.codelutin.com 18 Jul '13
18 Jul '13
Author: tchemit
Date: 2013-07-18 17:54:10 +0200 (Thu, 18 Jul 2013)
New Revision: 1152
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1152
Log:
fixes #2905: [EXPORT GENERIQUE] changer nom d'un champ et ?\195?\169criture Male
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-07-18 15:52:08 UTC (rev 1151)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-07-18 15:54:10 UTC (rev 1152)
@@ -110,7 +110,7 @@
newNullableColumnForExport("Nbr", CatchExportRow.BATCH_NUMBER, TuttiCsvUtil.INTEGER);
newColumnForExport("Poids_Reference", CatchExportRow.REFERENCE_WEIGHT, TuttiCsvUtil.PRIMITIVE_FLOAT);
- newColumnForExport("Coef_Final_Elevation", CatchExportRow.RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
+ newColumnForExport("Coef_Elev_Espece_Capture", CatchExportRow.RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
}
public void prepareRows(PersistenceService persistenceService,
1
0
r1151 - trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches
by tchemit@users.forge.codelutin.com 18 Jul '13
by tchemit@users.forge.codelutin.com 18 Jul '13
18 Jul '13
Author: tchemit
Date: 2013-07-18 17:52:08 +0200 (Thu, 18 Jul 2013)
New Revision: 1151
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1151
Log:
fixes #2901: [RAPPORT] erreur poids total tri?\195?\169
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-07-18 13:34:21 UTC (rev 1150)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-07-18 15:52:08 UTC (rev 1151)
@@ -154,7 +154,7 @@
}
op.put("totalWeight", totalWeight);
- op.put("totalSortedWeight", catchBatch.getCatchTotalSortedComputedWeight() + catchBatch.getCatchTotalUnsortedComputedWeight());
+ op.put("totalSortedWeight", catchBatch.getSpeciesTotalSampleSortedComputedWeight() + catchBatch.getBenthosTotalSampleSortedComputedWeight());
// create catches data model
1
0
Author: tchemit
Date: 2013-07-18 15:34:21 +0200 (Thu, 18 Jul 2013)
New Revision: 1150
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1150
Log:
updates i18n to 2.5.2
Modified:
trunk/pom.xml
trunk/tutti-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-07-18 13:20:51 UTC (rev 1149)
+++ trunk/pom.xml 2013-07-18 13:34:21 UTC (rev 1150)
@@ -121,7 +121,7 @@
<!-- libraries version -->
<nuitonUtilsVersion>2.6.12</nuitonUtilsVersion>
- <nuitonI18nVersion>2.5.1</nuitonI18nVersion>
+ <nuitonI18nVersion>2.5.2</nuitonI18nVersion>
<eugenePluginVersion>2.6.3</eugenePluginVersion>
<hibernateVersion>3.6.10.Final</hibernateVersion>
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-07-18 13:20:51 UTC (rev 1149)
+++ trunk/tutti-ui-swing/pom.xml 2013-07-18 13:34:21 UTC (rev 1150)
@@ -246,14 +246,6 @@
<include>**/*</include>
</includes>
</resource>
- <!-- FIXME-TC Remove this when i18n will do it for use-->
- <resource>
- <directory>${maven.gen.dir}/resources</directory>
- <filtering>false</filtering>
- <includes>
- <include>**/*.csv</include>
- </includes>
- </resource>
</resources>
<plugins>
1
0
Author: tchemit
Date: 2013-07-18 15:20:51 +0200 (Thu, 18 Jul 2013)
New Revision: 1149
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1149
Log:
updates mavenpom to 2.3.13
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-07-18 09:15:15 UTC (rev 1148)
+++ trunk/pom.xml 2013-07-18 13:20:51 UTC (rev 1149)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.4.12</version>
+ <version>3.4.13</version>
</parent>
<groupId>fr.ifremer</groupId>
1
0
r1148 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation/catches/benthos/frequency content/operation/catches/species/frequency util
by tchemit@users.forge.codelutin.com 18 Jul '13
by tchemit@users.forge.codelutin.com 18 Jul '13
18 Jul '13
Author: tchemit
Date: 2013-07-18 11:15:15 +0200 (Thu, 18 Jul 2013)
New Revision: 1148
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1148
Log:
fixes #2895: [MENSURATION] probl?\195?\168mes en mode g?\195?\169n?\195?\169ration de classe
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-07-16 17:52:28 UTC (rev 1147)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-07-18 09:15:15 UTC (rev 1148)
@@ -113,9 +113,9 @@
protected boolean isRowValid(BenthosFrequencyRowModel row) {
return row.getLengthStepCaracteristic() != null &&
row.getLengthStep() != null &&
- ((row.getNumber() == null && row.getWeight() == null) ||
- (row.getNumber() != null && row.getNumber() > 0 &&
- (withWeightRows.isEmpty() || row.getWeight() != null && row.getWeight() > 0)));
+ ((row.getNumber() == null && row.getWeight() == null) ||
+ (row.getNumber() != null && row.getNumber() > 0 &&
+ (withWeightRows.isEmpty() || row.getWeight() != null && row.getWeight() > 0)));
}
@Override
@@ -399,8 +399,8 @@
Caracteristic lengthStepCaracteristic = model.getLengthStepCaracteristic();
for (float i = minStep, step = model.getStep(); i <= maxStep;
- i = model.getLengthStep(i+step)) {
-
+ i = TuttiUIUtil.getRoundedLengthStep(i + step, true)) {
+
if (!rowsByStep.containsKey(i)) {
// add it
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-07-16 17:52:28 UTC (rev 1147)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-07-18 09:15:15 UTC (rev 1148)
@@ -61,9 +61,6 @@
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.math.BigDecimal;
-import java.math.MathContext;
-import java.math.RoundingMode;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -402,7 +399,7 @@
Caracteristic lengthStepCaracteristic = model.getLengthStepCaracteristic();
for (float i = minStep, step = model.getStep(); i <= maxStep;
- i = model.getLengthStep(i+step)) {
+ i = TuttiUIUtil.getRoundedLengthStep(i + step, true)) {
if (!rowsByStep.containsKey(i)) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-07-16 17:52:28 UTC (rev 1147)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-07-18 09:15:15 UTC (rev 1148)
@@ -366,4 +366,10 @@
throw new TuttiBusinessException(_(i18nKey, url));
}
}
+
+ public static float getRoundedLengthStep(float lengthStep, boolean aroundUp) {
+ int intValue = (int) ((lengthStep + (aroundUp ? 0.001f : 0f)) * 10);
+ float result = intValue / 10f;
+ return result;
+ }
}
1
0
r1147 - in trunk: . tutti-persistence tutti-service tutti-ui-swing
by maven-release@users.forge.codelutin.com 16 Jul '13
by maven-release@users.forge.codelutin.com 16 Jul '13
16 Jul '13
Author: maven-release
Date: 2013-07-16 19:52:28 +0200 (Tue, 16 Jul 2013)
New Revision: 1147
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1147
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
trunk/tutti-service/pom.xml
trunk/tutti-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-07-16 17:52:20 UTC (rev 1146)
+++ trunk/pom.xml 2013-07-16 17:52:28 UTC (rev 1147)
@@ -32,7 +32,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.3.3</version>
+ <version>2.4-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Tutti</name>
@@ -86,12 +86,12 @@
</modules>
<scm>
- <url>http://svn.forge.codelutin.com/svn/tutti/tags/tutti-2.3.3</url>
+ <url>http://svn.forge.codelutin.com/svn/tutti/trunk</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-2.3.3
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-2.3.3
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
</developerConnection>
</scm>
<distributionManagement>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-07-16 17:52:20 UTC (rev 1146)
+++ trunk/tutti-persistence/pom.xml 2013-07-16 17:52:28 UTC (rev 1147)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.3.3</version>
+ <version>2.4-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-07-16 17:52:20 UTC (rev 1146)
+++ trunk/tutti-service/pom.xml 2013-07-16 17:52:28 UTC (rev 1147)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.3.3</version>
+ <version>2.4-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-07-16 17:52:20 UTC (rev 1146)
+++ trunk/tutti-ui-swing/pom.xml 2013-07-16 17:52:28 UTC (rev 1147)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.3.3</version>
+ <version>2.4-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
1
0
Author: maven-release
Date: 2013-07-16 19:52:20 +0200 (Tue, 16 Jul 2013)
New Revision: 1146
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1146
Log:
[maven-release-plugin] copy for tag tutti-2.3.3
Added:
tags/tutti-2.3.3/
1
0
r1145 - in trunk: . tutti-persistence tutti-service tutti-ui-swing
by maven-release@users.forge.codelutin.com 16 Jul '13
by maven-release@users.forge.codelutin.com 16 Jul '13
16 Jul '13
Author: maven-release
Date: 2013-07-16 19:52:11 +0200 (Tue, 16 Jul 2013)
New Revision: 1145
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1145
Log:
[maven-release-plugin] prepare release tutti-2.3.3
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
trunk/tutti-service/pom.xml
trunk/tutti-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-07-16 17:50:28 UTC (rev 1144)
+++ trunk/pom.xml 2013-07-16 17:52:11 UTC (rev 1145)
@@ -32,7 +32,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.4-SNAPSHOT</version>
+ <version>2.3.3</version>
<packaging>pom</packaging>
<name>Tutti</name>
@@ -86,12 +86,12 @@
</modules>
<scm>
- <url>http://svn.forge.codelutin.com/svn/tutti/trunk</url>
+ <url>http://svn.forge.codelutin.com/svn/tutti/tags/tutti-2.3.3</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-2.3.3
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-2.3.3
</developerConnection>
</scm>
<distributionManagement>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-07-16 17:50:28 UTC (rev 1144)
+++ trunk/tutti-persistence/pom.xml 2013-07-16 17:52:11 UTC (rev 1145)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.4-SNAPSHOT</version>
+ <version>2.3.3</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-07-16 17:50:28 UTC (rev 1144)
+++ trunk/tutti-service/pom.xml 2013-07-16 17:52:11 UTC (rev 1145)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.4-SNAPSHOT</version>
+ <version>2.3.3</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-07-16 17:50:28 UTC (rev 1144)
+++ trunk/tutti-ui-swing/pom.xml 2013-07-16 17:52:11 UTC (rev 1145)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.4-SNAPSHOT</version>
+ <version>2.3.3</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
1
0