Author: echatellier Date: 2014-07-24 14:41:06 +0200 (Thu, 24 Jul 2014) New Revision: 4063 Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4063 Log: Add necessary stuff on SimulationContext to delete to TopiaContext and remove use of TopiaContext in user scripts Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java 2014-07-24 09:26:29 UTC (rev 4062) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java 2014-07-24 12:41:06 UTC (rev 4063) @@ -26,6 +26,8 @@ package fr.ifremer.isisfish.simulator; import fr.ifremer.isisfish.IsisFish; +import fr.ifremer.isisfish.IsisFishDAOHelper; + import java.io.File; import java.util.HashMap; import java.util.LinkedHashSet; @@ -39,11 +41,14 @@ import org.nuiton.topia.persistence.TopiaEntity; import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.*; import fr.ifremer.isisfish.simulator.sensitivity.SensitivityUtils; import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.util.IsisCache; + import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; + import org.nuiton.config.ApplicationConfig; import org.nuiton.config.OverwriteApplicationConfig; import org.nuiton.math.matrix.MatrixFactory; @@ -540,4 +545,301 @@ } return v; } + + /** + * Rollback region database transaction. + * + * @throws TopiaException + * @since 4.3.1.0 + */ + public void rollbackRuleChanges() throws TopiaException { + TopiaContext tx = getDB(); + tx.rollbackTransaction(); + } + + /** + * Commit result storage transaction. + * + * @throws TopiaException + * @since 4.3.1.0 + */ + public void commitResults() throws TopiaException { + TopiaContext tx = getDbResult(); + tx.commitTransaction(); + } + + /** + * Get {@link ActiveRuleDAO} on region database. + * + * @return ActiveRuleDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public ActiveRuleDAO getActiveRuleDAO() throws TopiaException { + return IsisFishDAOHelper.getActiveRuleDAO(getDB()); + } + + /** + * Get {@link CellDAO} on region database. + * + * @return CellDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public CellDAO getCellDAO() throws TopiaException { + return IsisFishDAOHelper.getCellDAO(getDB()); + } + + /** + * Get {@link EffortDescriptionDAO} on region database. + * + * @return EffortDescriptionDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public EffortDescriptionDAO getEffortDescriptionDAO() throws TopiaException { + return IsisFishDAOHelper.getEffortDescriptionDAO(getDB()); + } + + /** + * Get {@link EquationDAO} on region database. + * + * @return EquationDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public EquationDAO getEquationDAO() throws TopiaException { + return IsisFishDAOHelper.getEquationDAO(getDB()); + } + + /** + * Get {@link FisheryRegionDAO} on region database. + * + * @return FisheryRegionDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public FisheryRegionDAO getFisheryRegionDAO() throws TopiaException { + return IsisFishDAOHelper.getFisheryRegionDAO(getDB()); + } + + /** + * Get {@link GearDAO} on region database. + * + * @return GearDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public GearDAO getGearDAO() throws TopiaException { + return IsisFishDAOHelper.getGearDAO(getDB()); + } + + /** + * Get {@link MetierDAO} on region database. + * + * @return MetierDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public MetierDAO getMetierDAO() throws TopiaException { + return IsisFishDAOHelper.getMetierDAO(getDB()); + } + + /** + * Get {@link MetierSeasonInfoDAO} on region database. + * + * @return MetierSeasonInfoDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public MetierSeasonInfoDAO getMetierSeasonInfoDAO() throws TopiaException { + return IsisFishDAOHelper.getMetierSeasonInfoDAO(getDB()); + } + + /** + * Get {@link ObservationDAO} on region database. + * + * @return ObservationDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public ObservationDAO getObservationDAO() throws TopiaException { + return IsisFishDAOHelper.getObservationDAO(getDB()); + } + + /** + * Get {@link PopulationDAO} on region database. + * + * @return PopulationDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public PopulationDAO getPopulationDAO() throws TopiaException { + return IsisFishDAOHelper.getPopulationDAO(getDB()); + } + + /** + * Get {@link PopulationGroupDAO} on region database. + * + * @return PopulationGroupDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public PopulationGroupDAO getPopulationGroupDAO() throws TopiaException { + return IsisFishDAOHelper.getPopulationGroupDAO(getDB()); + } + + /** + * Get {@link PopulationSeasonInfoDAO} on region database. + * + * @return PopulationSeasonInfoDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public PopulationSeasonInfoDAO getPopulationSeasonInfoDAO() throws TopiaException { + return IsisFishDAOHelper.getPopulationSeasonInfoDAO(getDB()); + } + + /** + * Get {@link PortDAO} on region database. + * + * @return PortDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public PortDAO getPortDAO() throws TopiaException { + return IsisFishDAOHelper.getPortDAO(getDB()); + } + + /** + * Get {@link ResultDAO} on region database. + * + * @return ResultDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public ResultDAO getResultDAO() throws TopiaException { + return IsisFishDAOHelper.getResultDAO(getDB()); + } + + /** + * Get {@link SeasonDAO} on region database. + * + * @return SeasonDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public SeasonDAO getSeasonDAO() throws TopiaException { + return IsisFishDAOHelper.getSeasonDAO(getDB()); + } + + /** + * Get {@link SelectivityDAO} on region database. + * + * @return SelectivityDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public SelectivityDAO getSelectivityDAO() throws TopiaException { + return IsisFishDAOHelper.getSelectivityDAO(getDB()); + } + + /** + * Get {@link SetOfVesselsDAO} on region database. + * + * @return SetOfVesselsDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public SetOfVesselsDAO getSetOfVesselsDAO() throws TopiaException { + return IsisFishDAOHelper.getSetOfVesselsDAO(getDB()); + } + + /** + * Get {@link SpeciesDAO} on region database. + * + * @return SpeciesDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public SpeciesDAO getSpeciesDAO() throws TopiaException { + return IsisFishDAOHelper.getSpeciesDAO(getDB()); + } + + /** + * Get {@link StrategyDAO} on region database. + * + * @return StrategyDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public StrategyDAO getStrategyDAO() throws TopiaException { + return IsisFishDAOHelper.getStrategyDAO(getDB()); + } + + /** + * Get {@link StrategyMonthInfoDAO} on region database. + * + * @return StrategyMonthInfoDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public StrategyMonthInfoDAO getStrategyMonthInfoDAO() throws TopiaException { + return IsisFishDAOHelper.getStrategyMonthInfoDAO(getDB()); + } + + /** + * Get {@link TargetSpeciesDAO} on region database. + * + * @return TargetSpeciesDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public TargetSpeciesDAO getTargetSpeciesDAO() throws TopiaException { + return IsisFishDAOHelper.getTargetSpeciesDAO(getDB()); + } + + /** + * Get {@link TripTypeDAO} on region database. + * + * @return TripTypeDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public TripTypeDAO getTripTypeDAO() throws TopiaException { + return IsisFishDAOHelper.getTripTypeDAO(getDB()); + } + + /** + * Get {@link VariableDAO} on region database. + * + * @return VariableDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public VariableDAO getVariableDAO() throws TopiaException { + return IsisFishDAOHelper.getVariableDAO(getDB()); + } + + /** + * Get {@link VesselTypeDAO} on region database. + * + * @return VesselTypeDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public VesselTypeDAO getVesselTypeDAO() throws TopiaException { + return IsisFishDAOHelper.getVesselTypeDAO(getDB()); + } + + /** + * Get {@link ZoneDAO} on region database. + * + * @return ZoneDAO + * @throws TopiaException + * @since 4.3.1.0 + */ + public ZoneDAO getZoneDAO() throws TopiaException { + return IsisFishDAOHelper.getZoneDAO(getDB()); + } }