Class SimulationContext

java.lang.Object
fr.ifremer.isisfish.simulator.SimulationContext

public class SimulationContext extends Object
Keep all information on one simulation.
  • Launch parameter
  • Database (TopiaContext)
  • SimulationControl
  • Effective by pop (N)
  • Result
Created: 3 juil. 2006 17:05:27
Version:
$Revision$ Last update: $Date$ by : $Author$
Author:
poussin
  • Field Details

    • config

      protected org.nuiton.config.ApplicationConfig config
      configuration for current simulation (some value of config is overwrited for simulation)
    • values

      protected Map<String,Object> values
    • simulation

      protected SimulationStorage simulation
    • simulationControl

      protected SimulationControl simulationControl
    • populationMonitor

      protected PopulationMonitor populationMonitor
    • metierMonitor

      protected MetierMonitor metierMonitor
    • ruleMonitor

      protected RuleMonitor ruleMonitor
    • resultManager

      protected ResultManager resultManager
    • simulationListeners

      protected Set<SimulationListener> simulationListeners
    • stepListener

      protected PropertyChangeListener stepListener
    • timeStepStat

      protected org.nuiton.profiling.Statistic timeStepStat
    • classLoader

      protected ClassLoader classLoader
    • equationClassLoaders

      protected Map<String,ClassLoader> equationClassLoaders
    • scriptDirectory

      protected File scriptDirectory
    • trace

      protected org.nuiton.profiling.Trace trace
      l'objet trace qui conserve les donnees statistiques des appels de methodes
    • computeResultTrace

      protected ComputeResultTrace computeResultTrace
      l'objet trace qui conserve les donnees statistiques des appels de methodes
    • cache

      protected IsisCache cache
      cache used by aspect for this simulation
    • db

      protected org.nuiton.topia.TopiaContext db
      TopiaContext must be used by rule action to modify data
    • dbResult

      protected org.nuiton.topia.TopiaContext dbResult
      TopiaContext must be used to save result
    • variablesCache

      protected Map<org.nuiton.topia.persistence.TopiaEntity,SimulationVariable> variablesCache
      CacheAspect des variables d'entités. Topia id > map of attributes.
    • contextEquationValue

      protected Map<String,Double> contextEquationValue
      Context value used in equation.
  • Constructor Details

    • SimulationContext

      protected SimulationContext()
  • Method Details

    • initForSimulation

      public void initForSimulation()
      init SimulationContext for simulation.
    • get

      public static SimulationContext get()
      Return SimulationContext if not created, create new context without initialisation needed for simulation
      Returns:
      simulation context for the current simulation (current thread)
    • remove

      public static void remove()
      remove simulation associate with current thread
    • getConfig

      public org.nuiton.config.ApplicationConfig getConfig()
      Get specifique ApplicationConfig for current thread.simulation. Needed for simulation some configurations values are overwrited by simulation parameter tag/value
      Returns:
    • addSimulationListener

      public void addSimulationListener(SimulationListener l)
      Add simulation listener, if listener is SimulationResultListener, it's automatically added as listener on ResultManager
      Parameters:
      l -
    • closeDB

      public void closeDB()
    • closeDBResult

      @Deprecated public void closeDBResult()
      Deprecated.
      a supprimer lorsqu'on aura supprimer ResultDatabaseStorage
    • removeSimulationListener

      public void removeSimulationListener(SimulationListener l)
      Remove simulation listener, if listener is SimulationResultListener, it's Automatically removed as listener on ResultManager
      Parameters:
      l -
    • fireBeforeSimulation

      public void fireBeforeSimulation()
    • fireStepChange

      public void fireStepChange(TimeStep step)
    • fireAfterSimulation

      public void fireAfterSimulation()
    • getClassLoader

      public ClassLoader getClassLoader()
      Returns:
      Returns the classLoader.
    • getEquationClassLoaders

      public Map<String,ClassLoader> getEquationClassLoaders()
    • setClassLoader

      public void setClassLoader(ClassLoader classLoader)
      Parameters:
      classLoader - The classLoader to set.
    • getTrace

      public org.nuiton.profiling.Trace getTrace()
    • getComputeResultTrace

      public ComputeResultTrace getComputeResultTrace()
    • getCache

      public IsisCache getCache()
    • getValue

      public Object getValue(String name)
      Permet de recuperer une valeur prealablement stocker avec un setValue
      Parameters:
      name - le nom de la valeur souhaitée
      Returns:
      la valeur ou null si aucune valeur ne porte se nom
    • setValue

      public void setValue(String name, Object value)
      Permet de stocker une valeur en fonction d'une cle, cela peut-etre util pour partager des informations entre Rule ou d'autre objet.
      Parameters:
      name - le nom de la valeur
      value - la valeur
    • getSimulationStorage

      public SimulationStorage getSimulationStorage()
      Returns:
      Returns the topiaContext.
    • setSimulationStorage

      public void setSimulationStorage(SimulationStorage simulation)
      Parameters:
      simulation - The simulation storage to set.
    • getTimeStepStat

      public org.nuiton.profiling.Statistic getTimeStepStat()
    • getSimulationControl

      public SimulationControl getSimulationControl()
      Returns:
      Returns the simulationControl.
    • setSimulationControl

      public void setSimulationControl(SimulationControl simulationControl)
      Parameters:
      simulationControl - The simulationControl to set.
    • getPopulationMonitor

      public PopulationMonitor getPopulationMonitor()
      Returns:
      Returns the populationMonitor.
    • getMetierMonitor

      public MetierMonitor getMetierMonitor()
      Returns:
      Returns the metierMonitor.
    • getRuleMonitor

      public RuleMonitor getRuleMonitor()
      Returns:
      Returns the ruleMonitor.
    • getResultManager

      public ResultManager getResultManager()
      Returns:
      Returns the resultManager.
    • getDB

      public org.nuiton.topia.TopiaContext getDB() throws org.nuiton.topia.TopiaException
      This method return TopiaContext that Rule action must used to modify data. This TopiaContext is rollbacked after each step.
      Returns:
      TopiaContext that Rule action must used
      Throws:
      org.nuiton.topia.TopiaException
    • getDbResult

      @Deprecated public org.nuiton.topia.TopiaContext getDbResult() throws org.nuiton.topia.TopiaException
      Deprecated.
      ne sert plus a rien lorsque ResultDatabaseStorage sera supprime
      this method return TopiaContext that must be used to save result
      Returns:
      Returns the dbResult.
      Throws:
      org.nuiton.topia.TopiaException
    • clearCache

      @Deprecated public void clearCache(TimeStep step) throws org.nuiton.topia.TopiaException
      Deprecated.
      ne sert plus a rien, le cache est directement listener de la simulation
      Clear isis fish cache for specified time step.
      Parameters:
      step - time step to remove data
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.1.1.0
    • getScriptDirectory

      public File getScriptDirectory()
      Returns:
      Returns the scriptDirectory.
    • setScriptDirectory

      public void setScriptDirectory(File scriptDirectory)
      Script directory to use. Used to change isis-database-3 directory in running simulation context.
      Parameters:
      scriptDirectory -
    • message

      public void message(String message)
      Parameters:
      message - message
    • setComputeValue

      public void setComputeValue(String key, Double value)
      Add value/key pair into context (computed value).
      Parameters:
      key - key
      value - value
    • getValueAndCompute

      public double getValueAndCompute(String key, double defaultValue)
      Return value from context.
      Parameters:
      key - key
      defaultValue - default value or value to compute
      Returns:
      computed value or defaultValue if not found
    • get

      public SimulationVariable get(org.nuiton.topia.persistence.TopiaEntity entity)
      Get object containing variable for given entity.
      Parameters:
      entity - entity
      Returns:
      map object for this class
      Since:
      4.1.0.0
    • rollbackRuleChanges

      public void rollbackRuleChanges() throws org.nuiton.topia.TopiaException
      Rollback region database transaction.
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • validateDBChanges

      public void validateDBChanges() throws org.nuiton.topia.TopiaException
      Valide (commit) database modification
      Throws:
      org.nuiton.topia.TopiaException
    • commitResults

      @Deprecated public void commitResults() throws org.nuiton.topia.TopiaException
      Deprecated.
      ne sert plus a rien lorsque ResultDatabaseStorage sera supprime
      Commit result storage transaction.
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getActiveRuleDAO

      public ActiveRuleDAO getActiveRuleDAO() throws org.nuiton.topia.TopiaException
      Get ActiveRuleDAO on region database.
      Returns:
      ActiveRuleDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getCellDAO

      public CellDAO getCellDAO() throws org.nuiton.topia.TopiaException
      Get CellDAO on region database.
      Returns:
      CellDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getEffortDescriptionDAO

      public EffortDescriptionDAO getEffortDescriptionDAO() throws org.nuiton.topia.TopiaException
      Get EffortDescriptionDAO on region database.
      Returns:
      EffortDescriptionDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getEquationDAO

      public EquationDAO getEquationDAO() throws org.nuiton.topia.TopiaException
      Get EquationDAO on region database.
      Returns:
      EquationDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getFisheryRegionDAO

      public FisheryRegionDAO getFisheryRegionDAO() throws org.nuiton.topia.TopiaException
      Get FisheryRegionDAO on region database.
      Returns:
      FisheryRegionDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getGearDAO

      public GearDAO getGearDAO() throws org.nuiton.topia.TopiaException
      Get GearDAO on region database.
      Returns:
      GearDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getMetierDAO

      public MetierDAO getMetierDAO() throws org.nuiton.topia.TopiaException
      Get MetierDAO on region database.
      Returns:
      MetierDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getMetierSeasonInfoDAO

      public MetierSeasonInfoDAO getMetierSeasonInfoDAO() throws org.nuiton.topia.TopiaException
      Get MetierSeasonInfoDAO on region database.
      Returns:
      MetierSeasonInfoDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getObservationDAO

      public ObservationDAO getObservationDAO() throws org.nuiton.topia.TopiaException
      Get ObservationDAO on region database.
      Returns:
      ObservationDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getPopulationDAO

      public PopulationDAO getPopulationDAO() throws org.nuiton.topia.TopiaException
      Get PopulationDAO on region database.
      Returns:
      PopulationDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getPopulationGroupDAO

      public PopulationGroupDAO getPopulationGroupDAO() throws org.nuiton.topia.TopiaException
      Get PopulationGroupDAO on region database.
      Returns:
      PopulationGroupDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getPopulationSeasonInfoDAO

      public PopulationSeasonInfoDAO getPopulationSeasonInfoDAO() throws org.nuiton.topia.TopiaException
      Get PopulationSeasonInfoDAO on region database.
      Returns:
      PopulationSeasonInfoDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getPortDAO

      public PortDAO getPortDAO() throws org.nuiton.topia.TopiaException
      Get PortDAO on region database.
      Returns:
      PortDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getResultDAO

      public ResultDAO getResultDAO() throws org.nuiton.topia.TopiaException
      Get ResultDAO on region database.
      Returns:
      ResultDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getSeasonDAO

      public SeasonDAO getSeasonDAO() throws org.nuiton.topia.TopiaException
      Get SeasonDAO on region database.
      Returns:
      SeasonDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getSelectivityDAO

      public SelectivityDAO getSelectivityDAO() throws org.nuiton.topia.TopiaException
      Get SelectivityDAO on region database.
      Returns:
      SelectivityDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getSetOfVesselsDAO

      public SetOfVesselsDAO getSetOfVesselsDAO() throws org.nuiton.topia.TopiaException
      Get SetOfVesselsDAO on region database.
      Returns:
      SetOfVesselsDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getSpeciesDAO

      public SpeciesDAO getSpeciesDAO() throws org.nuiton.topia.TopiaException
      Get SpeciesDAO on region database.
      Returns:
      SpeciesDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getStrategyDAO

      public StrategyDAO getStrategyDAO() throws org.nuiton.topia.TopiaException
      Get StrategyDAO on region database.
      Returns:
      StrategyDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getStrategyMonthInfoDAO

      public StrategyMonthInfoDAO getStrategyMonthInfoDAO() throws org.nuiton.topia.TopiaException
      Get StrategyMonthInfoDAO on region database.
      Returns:
      StrategyMonthInfoDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getTargetSpeciesDAO

      public TargetSpeciesDAO getTargetSpeciesDAO() throws org.nuiton.topia.TopiaException
      Get TargetSpeciesDAO on region database.
      Returns:
      TargetSpeciesDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getTripTypeDAO

      public TripTypeDAO getTripTypeDAO() throws org.nuiton.topia.TopiaException
      Get TripTypeDAO on region database.
      Returns:
      TripTypeDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getVariableDAO

      public VariableDAO getVariableDAO() throws org.nuiton.topia.TopiaException
      Get VariableDAO on region database.
      Returns:
      VariableDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getVesselTypeDAO

      public VesselTypeDAO getVesselTypeDAO() throws org.nuiton.topia.TopiaException
      Get VesselTypeDAO on region database.
      Returns:
      VesselTypeDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0
    • getZoneDAO

      public ZoneDAO getZoneDAO() throws org.nuiton.topia.TopiaException
      Get ZoneDAO on region database.
      Returns:
      ZoneDAO
      Throws:
      org.nuiton.topia.TopiaException
      Since:
      4.3.1.0