r234 - in trunk: tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service tutti-persistence-adagio/src/main/resources tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service tutti-persistence-adagio/src/test/resources tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise tutti-ui-swing/src/main/java/fr/i
Author: tchemit Date: 2013-01-19 12:46:29 +0100 (Sat, 19 Jan 2013) New Revision: 234 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/234 Log: - improve spring usage (use only one service locator instance + clean xml configuration) - improve TuttiEnumerationFile (everything is checked by it self, no more need to add a test for each field) - add missing header + svn properties Added: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml trunk/tutti-persistence-adagio/src/test/resources/beanRefFactoryWitNoDb.xml Removed: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java trunk/tutti-persistence-adagio/src/main/resources/applicationContext-service-tutti.xml trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/CancelEditProgramAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/CancelEditProtocolAction.java Deleted: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java 2013-01-19 11:46:29 UTC (rev 234) @@ -1,202 +0,0 @@ -package fr.ifremer.tutti.persistence; - -/* - * #%L - * Tutti :: Persistence Adagio (impl) - * $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 org.springframework.beans.factory.annotation.Value; - -/** - * Contains all constants usable via the enumeration file. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public class TuttiEnumerationFile { - - @Value("${GearClassificationId.SCIENTIFIC_CRUISE}") - public final Integer GEAR_CLASSIFICIATION_ID_SCIENTIFIC = null; - - @Value("${GearClassificationId.FAO}") - public final Integer GEAR_CLASSIFICIATION_ID_FISHING = null; - - @Value("${LocationLevelId.PAYS_ISO3}") - public final Integer LOCATION_LEVEL_ID_COUNTRY = null; - - @Value("${LocationLevelId.LOCALITE}") - public final Integer LOCATION_LEVEL_ID_LOCALITE = null; - - @Value("${LocationLevelId.PROGRAM}") - public final Integer LOCATION_LEVEL_ID_PROGRAMM = null; - - @Value("${LocationLevelId.STRATA}") - public final Integer LOCATION_LEVEL_ID_STRATA = null; - - @Value("${LocationLevelId.SUBSTRATA}") - public final Integer LOCATION_LEVEL_ID_SUB_STRATA = null; - - @Value("${MatrixId.GEAR}") - public final Integer MATRIX_ID_GEAR = null; - - @Value("${MatrixId.INDIVIDUAL}") - public final Integer MATRIX_ID_INDIVIDUAL = null; - - @Value("${MethodId.DECLARATION}") - public final Integer METHOD_ID_DECLARATION = null; - - @Value("${ParameterCode.AGE}") - public final String PARAMETER_CODE_AGE = null; - - @Value("${ParameterCode.WEIGHT}") - public final String PARAMETER_CODE_WEIGHT = null; - - @Value("${ParameterGroupId.ENVIRONEMENT_MEASUREMENT}") - public final Integer PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT = null; - - @Value("${ParameterGroupId.HYDROLOGIC_MEASUREMENT}") - public final Integer PARAMETER_GROUP_HYDROLOGIC = null; - - @Value("${PmfmId.SIZE_CATEGORY}") - public final Integer PMFM_ID_SIZE_CATEGORY = null; - - @Value("${PmfmId.SEX}") - public final Integer PMFM_ID_SEX = null; - - @Value("${PmfmId.SORTED_UNSORTED}") - public final Integer PMFM_ID_SORTED_UNSORTED = null; - - @Value("${PmfmId.MATURITY}") - public final Integer PMFM_ID_MATURITY = null; - - @Value("${PmfmId.MACRO_WASTE_CATEGORY}") - public final Integer PMFM_ID_MACRO_WASTE_CATEGORY = null; - - @Value("${PmfmId.MACRO_WASTE_SIZE_CATEGORY}") - public final Integer PMFM_ID_MACRO_WASTE_SIZE_CATEGORY = null; - - @Value("${UnitId.NONE}") - public final Integer UNIT_ID_NONE = null; - - @Value("${UserProfilId.OBSERVER}") - public final Integer USER_PROFIL_ID_OBSERVER = null; - - @Value("${UserProfilId.PROJECT_MEMBER}") - public final Integer USER_PROFIL_ID_PROJECT_MEMBER = null; - - @Value("${UserProfilId.USER}") - public final Integer USER_PROFIL_ID_USER = null; - - @Value("${VesselTypeId.SCIENTIFIC_RESEARCH_VESSEL}") - public final Integer VESSEL_TYPE_ID_SCIENTIFIC = null; - - @Value("${VesselTypeId.FISHING_VESSEL}") - public final Integer VESSEL_TYPE_ID_FISHING = null; - - @Value("${LocationLevelId.RECTANGLE_STATISTIQUE_MED}") - public final Integer RECTANGLE_STATISTIQUE_MED = null; - - @Value("${QualitativeValueId.VRAC}") - public final Integer QUALITATIVE_VRAC_ID = null; - - @Value("${StatusCode.ENABLE}") - public final String STATUS_VALID_CODE = null; - - @Value("${StatusCode.TEMPORARY}") - public final String STATUS_TEMPORARY_CODE = null; - - @Value("${PersonId.UNKNOWN_RECORDER_PERSON}") - public final Integer PERSON_ID_UNKNOWN_RECORDER_PERSON = null; - - @Value("${QualityFlagCode.NOTQUALIFIED}") - public final String QUALITY_FLAG_CODE_NOT_QUALIFIED = null; - - @Value("${PmfmId.STATION_NUMBER}") - public final Integer PMFM_ID_STATION_NUMBER = null; - - @Value("${PmfmId.TRAWL_DISTANCE}") - public final Integer PMFM_ID_TRAWL_DISTANCE = null; - - @Value("${PmfmId.RECTILINEAR_OPERATION}") - public final Integer PMFM_ID_RECTILINEAR_OPERATION = null; - - @Value("${QualitativeValueId.RECTILINEAR_OPERATION_YES}") - public final Integer QUALITATIVE_RECTILINEAR_OPERATION_YES = null; - - @Value("${QualitativeValueId.RECTILINEAR_OPERATION_NO}") - public final Integer QUALITATIVE_RECTILINEAR_OPERATION_NO = null; - - @Value("${PmfmId.HAUL_VALID}") - public final Integer PMFM_ID_HAUL_VALID = null; - - @Value("${QualitativeValueId.HAUL_VALID_YES}") - public final Integer QUALITATIVE_HAUL_VALID_YES = null; - - @Value("${QualitativeValueId.HAUL_VALID_NO}") - public final Integer QUALITATIVE_HAUL_VALID_NO = null; - - - public void init() { - Preconditions.checkNotNull(GEAR_CLASSIFICIATION_ID_SCIENTIFIC, "GEAR_CLASSIFICIATION_ID_SCIENTIFIC constant not found"); - Preconditions.checkNotNull(GEAR_CLASSIFICIATION_ID_FISHING, "GEAR_CLASSIFICIATION_ID_FISHING constant not found"); - Preconditions.checkNotNull(LOCATION_LEVEL_ID_COUNTRY, "LOCATION_LEVEL_ID_COUNTRY constant not found"); - Preconditions.checkNotNull(LOCATION_LEVEL_ID_LOCALITE, "LOCATION_LEVEL_ID_LOCALITE constant not found"); - Preconditions.checkNotNull(LOCATION_LEVEL_ID_PROGRAMM, "LOCATION_LEVEL_ID_PROGRAMM constant not found"); - Preconditions.checkNotNull(LOCATION_LEVEL_ID_STRATA, "LOCATION_LEVEL_ID_STRATA constant not found"); - Preconditions.checkNotNull(LOCATION_LEVEL_ID_SUB_STRATA, "LOCATION_LEVEL_ID_SUB_STRATA constant not found"); - Preconditions.checkNotNull(MATRIX_ID_GEAR, "MATRIX_ID_GEAR constant not found"); - Preconditions.checkNotNull(MATRIX_ID_INDIVIDUAL, "MATRIX_ID_INDIVIDUAL constant not found"); - Preconditions.checkNotNull(METHOD_ID_DECLARATION, "METHOD_ID_DECLARATION constant not found"); - Preconditions.checkNotNull(PARAMETER_CODE_AGE, "PARAMETER_CODE_AGE constant not found"); - Preconditions.checkNotNull(PARAMETER_CODE_WEIGHT, "PARAMETER_CODE_WEIGHT constant not found"); - Preconditions.checkNotNull(PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT, "PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT constant not found"); - Preconditions.checkNotNull(PARAMETER_GROUP_HYDROLOGIC, "PARAMETER_GROUP_HYDROLOGIC constant not found"); - Preconditions.checkNotNull(PERSON_ID_UNKNOWN_RECORDER_PERSON, "PERSON_ID_UNKNOWN_RECORDER_PERSON constant not found"); - Preconditions.checkNotNull(PMFM_ID_SIZE_CATEGORY, "PMFM_ID_SIZE_CATEGORY constant not found"); - Preconditions.checkNotNull(PMFM_ID_SEX, "PMFM_ID_SEX constant not found"); - Preconditions.checkNotNull(PMFM_ID_SORTED_UNSORTED, "PMFM_ID_SORTED_UNSORTED constant not found"); - Preconditions.checkNotNull(PMFM_ID_MATURITY, "PMFM_ID_MATURITY constant not found"); - Preconditions.checkNotNull(PMFM_ID_MACRO_WASTE_CATEGORY, "PMFM_ID_MACRO_WASTE_CATEGORY constant not found"); - Preconditions.checkNotNull(PMFM_ID_MACRO_WASTE_SIZE_CATEGORY, "PMFM_ID_MACRO_WASTE_SIZE_CATEGORY constant not found"); - Preconditions.checkNotNull(PMFM_ID_STATION_NUMBER, "PMFM_ID_STATION_NUMBER constant not found"); - Preconditions.checkNotNull(PMFM_ID_TRAWL_DISTANCE, "PMFM_ID_TRAWL_DISTANCE constant not found"); - Preconditions.checkNotNull(PMFM_ID_RECTILINEAR_OPERATION, "PMFM_ID_RECTILINEAR_OPERATION constant not found"); - Preconditions.checkNotNull(PMFM_ID_HAUL_VALID, "PMFM_ID_HAUL_VALID constant not found"); - Preconditions.checkNotNull(QUALITY_FLAG_CODE_NOT_QUALIFIED, "QUALITY_FLAG_CODE_NOT_QUALIFIED constant not found"); - Preconditions.checkNotNull(UNIT_ID_NONE, "UNIT_ID_NONE constant not found"); - Preconditions.checkNotNull(USER_PROFIL_ID_OBSERVER, "USER_PROFIL_ID_OBSERVER constant not found"); - Preconditions.checkNotNull(USER_PROFIL_ID_PROJECT_MEMBER, "USER_PROFIL_ID_PROJECT_MEMBER constant not found"); - Preconditions.checkNotNull(USER_PROFIL_ID_USER, "USER_PROFIL_ID_USER constant not found"); - Preconditions.checkNotNull(VESSEL_TYPE_ID_SCIENTIFIC, "VESSEL_TYPE_ID_SCIENTIFIC constant not found"); - Preconditions.checkNotNull(VESSEL_TYPE_ID_FISHING, "VESSEL_TYPE_ID_FISHING constant not found"); - Preconditions.checkNotNull(RECTANGLE_STATISTIQUE_MED, "LocationLevelId.RECTANGLE_STATISTIQUE_MED constant not found"); - Preconditions.checkNotNull(STATUS_VALID_CODE, "StatusCode.ENABLE constant not found"); - Preconditions.checkNotNull(STATUS_TEMPORARY_CODE, "StatusCode.TEMPORARY constant not found"); - Preconditions.checkNotNull(QUALITATIVE_VRAC_ID, "QualitativeValueId.VRAC constant not found"); - Preconditions.checkNotNull(QUALITATIVE_RECTILINEAR_OPERATION_YES, "QualitativeValueId.RECTILINEAR_OPERATION_YES constant not found"); - Preconditions.checkNotNull(QUALITATIVE_RECTILINEAR_OPERATION_NO, "QualitativeValueId.RECTILINEAR_OPERATION_NO constant not found"); - Preconditions.checkNotNull(QUALITATIVE_HAUL_VALID_YES, "QualitativeValueId.HAUL_VALID_YES constant not found"); - Preconditions.checkNotNull(QUALITATIVE_HAUL_VALID_NO, "QualitativeValueId.HAUL_VALID_NO constant not found"); - - } -} Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-01-19 11:46:29 UTC (rev 234) @@ -26,7 +26,6 @@ import com.google.common.base.Preconditions; import fr.ifremer.adagio.core.dao.administration.programStrategy.ProgramDao; -import fr.ifremer.tutti.persistence.TuttiEnumerationFile; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Query; Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-19 11:46:29 UTC (rev 234) @@ -33,7 +33,6 @@ import fr.ifremer.adagio.core.dao.referential.QualityFlagDao; import fr.ifremer.adagio.core.dao.referential.location.Location; import fr.ifremer.adagio.core.dao.referential.location.LocationDao; -import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmDao; import fr.ifremer.adagio.core.dao.referential.vessel.VesselDao; import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus; import fr.ifremer.tutti.persistence.entities.data.Cruise; Copied: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java (from rev 231, trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java) =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java (rev 0) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-01-19 11:46:29 UTC (rev 234) @@ -0,0 +1,177 @@ +package fr.ifremer.tutti.persistence.service; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $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 org.springframework.beans.factory.annotation.Value; +import org.springframework.util.ReflectionUtils; + +import java.lang.reflect.Field; + +/** + * Contains all constants usable via the enumeration file. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class TuttiEnumerationFile { + + @Value("${GearClassificationId.SCIENTIFIC_CRUISE}") + public final Integer GEAR_CLASSIFICIATION_ID_SCIENTIFIC = null; + + @Value("${GearClassificationId.FAO}") + public final Integer GEAR_CLASSIFICIATION_ID_FISHING = null; + + @Value("${LocationLevelId.PAYS_ISO3}") + public final Integer LOCATION_LEVEL_ID_COUNTRY = null; + + @Value("${LocationLevelId.LOCALITE}") + public final Integer LOCATION_LEVEL_ID_LOCALITE = null; + + @Value("${LocationLevelId.PROGRAM}") + public final Integer LOCATION_LEVEL_ID_PROGRAMM = null; + + @Value("${LocationLevelId.STRATA}") + public final Integer LOCATION_LEVEL_ID_STRATA = null; + + @Value("${LocationLevelId.SUBSTRATA}") + public final Integer LOCATION_LEVEL_ID_SUB_STRATA = null; + + @Value("${MatrixId.GEAR}") + public final Integer MATRIX_ID_GEAR = null; + + @Value("${MatrixId.INDIVIDUAL}") + public final Integer MATRIX_ID_INDIVIDUAL = null; + + @Value("${MethodId.DECLARATION}") + public final Integer METHOD_ID_DECLARATION = null; + + @Value("${ParameterCode.AGE}") + public final String PARAMETER_CODE_AGE = null; + + @Value("${ParameterCode.WEIGHT}") + public final String PARAMETER_CODE_WEIGHT = null; + + @Value("${ParameterGroupId.ENVIRONEMENT_MEASUREMENT}") + public final Integer PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT = null; + + @Value("${ParameterGroupId.HYDROLOGIC_MEASUREMENT}") + public final Integer PARAMETER_GROUP_HYDROLOGIC = null; + + @Value("${PmfmId.SIZE_CATEGORY}") + public final Integer PMFM_ID_SIZE_CATEGORY = null; + + @Value("${PmfmId.SEX}") + public final Integer PMFM_ID_SEX = null; + + @Value("${PmfmId.SORTED_UNSORTED}") + public final Integer PMFM_ID_SORTED_UNSORTED = null; + + @Value("${PmfmId.MATURITY}") + public final Integer PMFM_ID_MATURITY = null; + + @Value("${PmfmId.MACRO_WASTE_CATEGORY}") + public final Integer PMFM_ID_MACRO_WASTE_CATEGORY = null; + + @Value("${PmfmId.MACRO_WASTE_SIZE_CATEGORY}") + public final Integer PMFM_ID_MACRO_WASTE_SIZE_CATEGORY = null; + + @Value("${UnitId.NONE}") + public final Integer UNIT_ID_NONE = null; + + @Value("${UserProfilId.OBSERVER}") + public final Integer USER_PROFIL_ID_OBSERVER = null; + + @Value("${UserProfilId.PROJECT_MEMBER}") + public final Integer USER_PROFIL_ID_PROJECT_MEMBER = null; + + @Value("${UserProfilId.USER}") + public final Integer USER_PROFIL_ID_USER = null; + + @Value("${VesselTypeId.SCIENTIFIC_RESEARCH_VESSEL}") + public final Integer VESSEL_TYPE_ID_SCIENTIFIC = null; + + @Value("${VesselTypeId.FISHING_VESSEL}") + public final Integer VESSEL_TYPE_ID_FISHING = null; + + @Value("${LocationLevelId.RECTANGLE_STATISTIQUE_MED}") + public final Integer RECTANGLE_STATISTIQUE_MED = null; + + @Value("${QualitativeValueId.VRAC}") + public final Integer QUALITATIVE_VRAC_ID = null; + + @Value("${StatusCode.ENABLE}") + public final String STATUS_VALID_CODE = null; + + @Value("${StatusCode.TEMPORARY}") + public final String STATUS_TEMPORARY_CODE = null; + + @Value("${PersonId.UNKNOWN_RECORDER_PERSON}") + public final Integer PERSON_ID_UNKNOWN_RECORDER_PERSON = null; + + @Value("${QualityFlagCode.NOTQUALIFIED}") + public final String QUALITY_FLAG_CODE_NOT_QUALIFIED = null; + + @Value("${PmfmId.STATION_NUMBER}") + public final Integer PMFM_ID_STATION_NUMBER = null; + + @Value("${PmfmId.TRAWL_DISTANCE}") + public final Integer PMFM_ID_TRAWL_DISTANCE = null; + + @Value("${PmfmId.RECTILINEAR_OPERATION}") + public final Integer PMFM_ID_RECTILINEAR_OPERATION = null; + + @Value("${QualitativeValueId.RECTILINEAR_OPERATION_YES}") + public final Integer QUALITATIVE_RECTILINEAR_OPERATION_YES = null; + + @Value("${QualitativeValueId.RECTILINEAR_OPERATION_NO}") + public final Integer QUALITATIVE_RECTILINEAR_OPERATION_NO = null; + + @Value("${PmfmId.HAUL_VALID}") + public final Integer PMFM_ID_HAUL_VALID = null; + + @Value("${QualitativeValueId.HAUL_VALID_YES}") + public final Integer QUALITATIVE_HAUL_VALID_YES = null; + + @Value("${QualitativeValueId.HAUL_VALID_NO}") + public final Integer QUALITATIVE_HAUL_VALID_NO = null; + + public void init() { + + Field[] declaredFields = getClass().getDeclaredFields(); + for (Field declaredField : declaredFields) { + Value annotation = declaredField.getAnnotation(Value.class); + if (annotation != null) { + + // check on that field that his value is here + Object fieldValue = ReflectionUtils.getField(declaredField, this); + Preconditions.checkNotNull( + fieldValue, + annotation.value() + " constant not found (field " + + declaredField.getName() + ")"); + } + } + } +} Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-01-19 11:46:29 UTC (rev 234) @@ -35,69 +35,80 @@ */ public class TuttiPersistenceServiceLocator extends ServiceLocator { - protected static final TuttiPersistenceServiceLocator INSTANCE = - new TuttiPersistenceServiceLocator(); + static { + initTuttiDefault(); + } - protected TuttiPersistenceServiceLocator() { - super("beanRefFactory.xml", "TuttiBeanRefFactory"); + public static void initTuttiDefault() { + instance().init("beanRefFactory.xml", "TuttiBeanRefFactory"); } + public static void initTutti(String beanFactoryReferenceLocation, + String beanRefFactoryReferenceId) { + instance().init(beanFactoryReferenceLocation, beanRefFactoryReferenceId); + } + + public static TuttiEnumerationFile getTuttiEnumerationFile() { + return instance().getService("tuttiEnumerationFile", + TuttiEnumerationFile.class); + } + public static TuttiPersistence getPersistenceService() { - return INSTANCE.getService("tuttiPersistence", - TuttiPersistence.class); + return instance().getService("tuttiPersistence", + TuttiPersistence.class); } public static ReferentialPersistenceService getReferentialPersistenceService() { - return INSTANCE.getService("referentialPersistenceService", - ReferentialPersistenceService.class); + return instance().getService("referentialPersistenceService", + ReferentialPersistenceService.class); } public static ProgramPersistenceService getProgramPersistenceService() { - return INSTANCE.getService("programPersistenceService", - ProgramPersistenceService.class); + return instance().getService("programPersistenceService", + ProgramPersistenceService.class); } public static CruisePersistenceService getCruisePersistenceService() { - return INSTANCE.getService("cruisePersistenceService", - CruisePersistenceService.class); + return instance().getService("cruisePersistenceService", + CruisePersistenceService.class); } public static FishingOperationPersistenceService getFishingOperationPersistenceService() { - return INSTANCE.getService("fishingOperationPersistenceService", - FishingOperationPersistenceService.class); + return instance().getService("fishingOperationPersistenceService", + FishingOperationPersistenceService.class); } public static SpeciesBatchPersistenceService getSpeciesBatchPersistenceService() { - return INSTANCE.getService("speciesBatchPersistenceService", - SpeciesBatchPersistenceService.class); + return instance().getService("speciesBatchPersistenceService", + SpeciesBatchPersistenceService.class); } public static BenthosBatchPersistenceService getBenthosBatchPersistenceService() { - return INSTANCE.getService("benthosBatchPersistenceService", - BenthosBatchPersistenceService.class); + return instance().getService("benthosBatchPersistenceService", + BenthosBatchPersistenceService.class); } public static PlanktonBatchPersistenceService getPlanktonBatchPersistenceService() { - return INSTANCE.getService("planktonBatchPersistenceService", - PlanktonBatchPersistenceService.class); + return instance().getService("planktonBatchPersistenceService", + PlanktonBatchPersistenceService.class); } public static MacroWasteBatchPersistenceService getMacroWasteBatchPersistenceService() { - return INSTANCE.getService("macroWasteBatchPersistenceService", - MacroWasteBatchPersistenceService.class); + return instance().getService("macroWasteBatchPersistenceService", + MacroWasteBatchPersistenceService.class); } public static AccidentalBatchPersistenceService getAccidentalBatchPersistenceService() { - return INSTANCE.getService("accidentalBatchPersistenceService", - AccidentalBatchPersistenceService.class); + return instance().getService("accidentalBatchPersistenceService", + AccidentalBatchPersistenceService.class); } public static ProtocolPersistenceService getProtocolPersistenceService() { - return INSTANCE.getService("protocolPersistenceService", - ProtocolPersistenceService.class); + return instance().getService("protocolPersistenceService", + ProtocolPersistenceService.class); } public static void close() { - INSTANCE.shutdown(); + instance().shutdown(); } } Modified: trunk/tutti-persistence-adagio/src/main/resources/applicationContext-service-tutti.xml =================================================================== --- trunk/tutti-persistence-adagio/src/main/resources/applicationContext-service-tutti.xml 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-persistence-adagio/src/main/resources/applicationContext-service-tutti.xml 2013-01-19 11:46:29 UTC (rev 234) @@ -34,7 +34,7 @@ <bean id="tuttiPersistence" init-method="open" destroy-method="close" class="fr.ifremer.tutti.persistence.TuttiPersistenceAdagioImpl"/> - <bean init-method="init" - class="fr.ifremer.tutti.persistence.TuttiEnumerationFile"/> + <bean id="tuttiEnumerationFile" init-method="init" + class="fr.ifremer.tutti.persistence.service.TuttiEnumerationFile"/> </beans> \ No newline at end of file Modified: trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml =================================================================== --- trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml 2013-01-19 11:46:29 UTC (rev 234) @@ -29,8 +29,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - <import resource="classpath:applicationContext-conf.xml"/> - <bean id="TuttiBeanRefFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext"> <constructor-arg> Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java 2013-01-19 11:46:29 UTC (rev 234) @@ -58,11 +58,24 @@ protected DatabaseFixtures fixtures; + private final String beanFactoryReferenceLocation; + + private final String beanRefFactoryReferenceId; + + public DatabaseResource() { + this(null, null); + } + + public DatabaseResource(String beanFactoryReferenceLocation, + String beanRefFactoryReferenceId) { + this.beanFactoryReferenceLocation = beanFactoryReferenceLocation; + this.beanRefFactoryReferenceId = beanRefFactoryReferenceId; + } + public TuttiPersistenceAdagioConfig getConfig() { return config; } - public DatabaseFixtures getFixtures() { return fixtures; } @@ -125,6 +138,12 @@ if (log.isDebugEnabled()) { log.debug("Use conf.properties at " + config.getDbConfigurationPath()); } + + if (beanFactoryReferenceLocation != null) { + TuttiPersistenceServiceLocator.initTutti( + beanFactoryReferenceLocation, + beanRefFactoryReferenceId); + } } protected void after(Description description) throws IOException { @@ -138,6 +157,12 @@ } TuttiPersistenceServiceLocator.close(); + + if (beanFactoryReferenceLocation != null) { + + // push back default tutti configuration + TuttiPersistenceServiceLocator.initTuttiDefault(); + } } public static File getTestSpecificDirectory(Class<?> testClass, Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java 2013-01-19 11:46:29 UTC (rev 234) @@ -0,0 +1,54 @@ +package fr.ifremer.tutti.persistence.service; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $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.DatabaseResource; +import org.junit.Assert; +import org.junit.ClassRule; +import org.junit.Test; + +/** + * This test load the {@link TuttiEnumerationFile} via Spring and then + * validates that we miss not constant. + * + * @author tchemit <chemit@codelutin.com> + * @see TuttiEnumerationFile#init() + * @since 1.0 + */ +public class TuttiEnumerationFileTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource( + "beanRefFactoryWitNoDb.xml", "TuttiBeanRefFactoryWithNoDb"); + + @Test + public void init() { + + TuttiEnumerationFile file = + TuttiPersistenceServiceLocator.getTuttiEnumerationFile(); + Assert.assertNotNull(file); + } + +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml =================================================================== --- trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml (rev 0) +++ trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml 2013-01-19 11:46:29 UTC (rev 234) @@ -0,0 +1,37 @@ +<!-- + #%L + Tutti :: Persistence Adagio (impl) + $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% + --> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + + <!-- needed to load @Value on tuttiEnumerationFile --> + <context:annotation-config/> + + <bean id="tuttiEnumerationFile" init-method="init" lazy-init="true" + class="fr.ifremer.tutti.persistence.service.TuttiEnumerationFile"/> + +</beans> \ No newline at end of file Property changes on: trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-persistence-adagio/src/test/resources/beanRefFactoryWitNoDb.xml (from rev 231, trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml) =================================================================== --- trunk/tutti-persistence-adagio/src/test/resources/beanRefFactoryWitNoDb.xml (rev 0) +++ trunk/tutti-persistence-adagio/src/test/resources/beanRefFactoryWitNoDb.xml 2013-01-19 11:46:29 UTC (rev 234) @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Tutti :: Persistence Adagio (impl) + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 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% + --> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> + + <bean id="TuttiBeanRefFactoryWithNoDb" + class="org.springframework.context.support.ClassPathXmlApplicationContext"> + <constructor-arg> + <list> + <value>applicationContext-conf.xml</value> + <value>applicationContext-service-resources.xml</value> + </list> + </constructor-arg> + </bean> + +</beans> \ No newline at end of file Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.java 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.java 2013-01-19 11:46:29 UTC (rev 234) @@ -1,5 +1,29 @@ package fr.ifremer.tutti.ui.swing.content.cruise; +/* + * #%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.AbstractTuttiAction; import fr.ifremer.tutti.ui.swing.TuttiScreen; Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.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/program/CancelEditProgramAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/CancelEditProgramAction.java 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/CancelEditProgramAction.java 2013-01-19 11:46:29 UTC (rev 234) @@ -1,5 +1,29 @@ package fr.ifremer.tutti.ui.swing.content.program; +/* + * #%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.AbstractTuttiAction; import fr.ifremer.tutti.ui.swing.TuttiScreen; Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/CancelEditProgramAction.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/CancelEditProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/CancelEditProtocolAction.java 2013-01-19 07:26:53 UTC (rev 233) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/CancelEditProtocolAction.java 2013-01-19 11:46:29 UTC (rev 234) @@ -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.AbstractTuttiAction; import fr.ifremer.tutti.ui.swing.TuttiScreen; Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/CancelEditProtocolAction.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL
participants (1)
-
tchemit@users.forge.codelutin.com