Class ProcessRunner
Accepts a JSON process definition, optionally pre-validates it using Validator, then
builds and runs the process using ProcessSystem.fromJsonAndRun(String). Returns the
simulation result as a JSON string in the standard envelope format.
Input JSON Format:
{ "fluid": { "model": "SRK", "temperature": 298.15, "pressure": 50.0, "mixingRule":
"classic", "components": {"methane": 0.85, "ethane": 0.10, "propane": 0.05} }, "process": [
{"type": "Stream", "name": "feed", "properties": {"flowRate": [50000.0, "kg/hr"]}}, {"type":
"Separator", "name": "HP Sep", "inlet": "feed"}, {"type": "Compressor", "name": "Comp", "inlet":
"HP Sep.gasOut", "properties": {"outletPressure": [80.0, "bara"]}} ] } - Author:
- Even Solbraa @version 1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor — all methods are static. -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringCreates a standard error JSON response.private static intextractEquipmentCount(String json) Counts the number of equipment entries in the process definition.private static StringextractMixingRule(String json) Extracts the mixing rule from the input JSON.private static StringextractModel(String json) Extracts the EOS model name from the input JSON.private static voidnormalizeLegacyPropertyObjects(com.google.gson.JsonObject properties) Converts legacy {value, unit} property objects to [value, unit] arrays expected by the JsonProcessBuilder reflection setter logic.private static StringnormalizeProcessJson(String json) Normalizes accepted process JSON variants to the canonical schema.static StringRuns a process simulation from a JSON definition string.static ApiEnvelope<ProcessResult> Runs a process simulation and returns a typed result.static StringvalidateAndRun(String json) Validates and then runs a process simulation.
-
Field Details
-
GSON
private static final com.google.gson.Gson GSON
-
-
Constructor Details
-
ProcessRunner
private ProcessRunner()Private constructor — all methods are static.
-
-
Method Details
-
run
Runs a process simulation from a JSON definition string.Delegates to
ProcessSystem.fromJsonAndRun(String)and returns the result in the standard JSON envelope format with status, report, and any warnings or errors.- Parameters:
json- the JSON process definition- Returns:
- a JSON string with the simulation result
-
validateAndRun
Validates and then runs a process simulation.First performs pre-flight validation using
Validator. If validation finds errors, returns them without running the simulation. If only warnings are found, proceeds with the simulation and includes the validation warnings in the response.- Parameters:
json- the JSON process definition- Returns:
- a JSON string with validation issues and/or simulation results
-
runTyped
Runs a process simulation and returns a typed result.This is the typed counterpart to
run(String). It accepts a JSON string (same format) but returns a typedApiEnvelopewith aProcessResultpayload for direct Java consumers.- Parameters:
json- the JSON process definition- Returns:
- an ApiEnvelope containing the ProcessResult on success, or errors on failure
-
extractModel
-
extractMixingRule
-
extractEquipmentCount
Counts the number of equipment entries in the process definition.- Parameters:
json- the input JSON string- Returns:
- the equipment count, or 0 if not parseable
-
normalizeProcessJson
Normalizes accepted process JSON variants to the canonical schema.Canonical schema expects
processto be an array. Some legacy clients send{"process": {"equipment": [...]}}. This method converts the legacy shape to the canonical one while preserving all other fields.- Parameters:
json- raw process JSON- Returns:
- canonical JSON string (or original input if not parseable)
-
normalizeLegacyPropertyObjects
private static void normalizeLegacyPropertyObjects(com.google.gson.JsonObject properties) Converts legacy {value, unit} property objects to [value, unit] arrays expected by the JsonProcessBuilder reflection setter logic.- Parameters:
properties- mutable properties object
-
errorJson
-