Class ProcessModelState

java.lang.Object
neqsim.process.processmodel.lifecycle.ProcessModelState
All Implemented Interfaces:
Serializable

public class ProcessModelState extends Object implements Serializable
Represents a serializable state snapshot of a ProcessModel containing multiple ProcessSystems.

This class enables:

  • Multi-Process Checkpointing: Save and restore complete multi-system models
  • Cross-Process Connections: Track streams shared between ProcessSystems
  • Version Control: Export models to JSON for Git-based versioning
  • Digital Twin Lifecycle: Track model evolution through concept → design → operation

Usage Example:

ProcessModel model = new ProcessModel();
model.add("upstream", upstreamProcess);
model.add("downstream", downstreamProcess);
model.run();

// Export state
ProcessModelState state = ProcessModelState.fromProcessModel(model);
state.setVersion("1.0.0");
state.setDescription("Full field development model");
state.saveToFile("field_model_v1.json");

// Later: restore
ProcessModelState loaded = ProcessModelState.loadFromFile("field_model_v1.json");
ProcessModel restored = loaded.toProcessModel();
Version:
1.0
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • CURRENT_SCHEMA_VERSION

      private static final String CURRENT_SCHEMA_VERSION
      Current schema version for JSON format compatibility.
      See Also:
    • logger

      private static final org.apache.logging.log4j.Logger logger
      Logger for this class.
    • schemaVersion

      private String schemaVersion
      Schema version of this state (for migration support).
    • name

      private String name
    • version

      private String version
    • description

      private String description
    • createdAt

      private Instant createdAt
    • lastModifiedAt

      private Instant lastModifiedAt
    • createdBy

      private String createdBy
    • processStates

      private Map<String, ProcessSystemState> processStates
      Map of process name to its state.
    • interProcessConnections

      private List<ProcessModelState.InterProcessConnection> interProcessConnections
      Connections between different ProcessSystems.
    • customProperties

      private Map<String,Object> customProperties
      Custom properties for extensibility.
    • executionConfig

      private ProcessModelState.ExecutionConfig executionConfig
      Execution configuration.
  • Constructor Details

    • ProcessModelState

      public ProcessModelState()
      Default constructor.
  • Method Details

    • fromProcessModel

      public static ProcessModelState fromProcessModel(ProcessModel model)
      Creates a state snapshot from a ProcessModel.
      Parameters:
      model - the process model to capture
      Returns:
      a new ProcessModelState representing the current state
    • captureInterProcessConnections

      private void captureInterProcessConnections(ProcessModel model)
      Captures connections between different ProcessSystems in the model.

      This detects when streams from one ProcessSystem are referenced by another, enabling proper reconstruction of complex multi-process models.

      Parameters:
      model - the process model to analyze
    • checkAndAddInterProcessConnection

      private void checkAndAddInterProcessConnection(StreamInterface stream, String currentProcess, Map<String,String> streamToProcess)
      Checks if a stream comes from a different process and adds an inter-process connection.
    • toProcessModel

      public ProcessModel toProcessModel()
      Reconstructs a ProcessModel from this state.

      This creates ProcessSystems for each captured state. Full equipment reconstruction requires the original equipment classes to be available.

      Returns:
      a new ProcessModel initialized with the captured state
    • saveToFile

      public void saveToFile(String filename)
      Saves this state to a file (JSON or compressed JSON based on extension).
      Parameters:
      filename - the file path (use .json for plain JSON, .json.gz for compressed)
    • loadFromFile

      public static ProcessModelState loadFromFile(String filename)
      Loads a ProcessModelState from a file.
      Parameters:
      filename - the file path to load from
      Returns:
      the loaded ProcessModelState
    • migrateIfNeeded

      private void migrateIfNeeded()
      Migrates state from older schema versions if needed.
    • createGson

      private static com.google.gson.Gson createGson()
      Creates a Gson instance with custom type adapters.
    • validate

      Validates the state for completeness and consistency.
      Returns:
      a ValidationResult with any issues found
    • getSchemaVersion

      public String getSchemaVersion()
      Gets the schema version.
      Returns:
      the schema version
    • getName

      public String getName()
      Gets the name.
      Returns:
      the name
    • setName

      public void setName(String name)
      Sets the name.
      Parameters:
      name - the name
    • getVersion

      public String getVersion()
      Gets the version.
      Returns:
      the version
    • setVersion

      public void setVersion(String version)
      Sets the version.
      Parameters:
      version - the version
    • getDescription

      public String getDescription()
      Gets the description.
      Returns:
      the description
    • setDescription

      public void setDescription(String description)
      Sets the description.
      Parameters:
      description - the description
    • getCreatedAt

      public Instant getCreatedAt()
      Gets when this state was created.
      Returns:
      creation timestamp
    • getLastModifiedAt

      public Instant getLastModifiedAt()
      Gets when this state was last modified.
      Returns:
      last modification timestamp
    • getCreatedBy

      public String getCreatedBy()
      Gets who created this state.
      Returns:
      creator identifier
    • setCreatedBy

      public void setCreatedBy(String createdBy)
      Sets who created this state.
      Parameters:
      createdBy - creator identifier
    • getProcessStates

      public Map<String, ProcessSystemState> getProcessStates()
      Gets the process states map.
      Returns:
      map of process name to ProcessSystemState
    • getInterProcessConnections

      public List<ProcessModelState.InterProcessConnection> getInterProcessConnections()
      Gets inter-process connections.
      Returns:
      list of inter-process connections
    • getCustomProperties

      public Map<String,Object> getCustomProperties()
      Gets custom properties.
      Returns:
      custom properties map
    • setCustomProperty

      public void setCustomProperty(String key, Object value)
      Sets a custom property.
      Parameters:
      key - property key
      value - property value
    • getExecutionConfig

      public ProcessModelState.ExecutionConfig getExecutionConfig()
      Gets the execution configuration.
      Returns:
      execution configuration
    • getProcessCount

      public int getProcessCount()
      Gets the number of ProcessSystems in this state.
      Returns:
      number of process systems