Class: MetaChangeApplier

MetaChangeApplier(program)

Applier for inserting substances from metadata into a Program. This class handles the insertion of new substances into a Program based on SubstanceMetadata objects. It ensures applications exist, creates substances with metadata-derived commands, and handles the integration with existing program structure. Name conflicts are ignored for now (Component 6 scope).

Constructor

new MetaChangeApplier(program)

Create a new MetaChangeApplier instance.
Parameters:
Name Type Description
program Program The Program instance to modify in-place
Source:

Methods

upsertMetadata(updateArray) → {Program}

Insert or update substances from metadata update array into the program. This method processes an array of SubstanceMetadataUpdate objects, ensures required applications exist, and either updates existing substances or creates new ones based on the oldName field. If oldName matches an existing substance, it will be updated; otherwise a new substance is created. All metadata is validated before any changes are applied to prevent partial updates.
Parameters:
Name Type Description
updateArray Array.<SubstanceMetadataUpdate> Array of metadata update objects
Source:
Throws:
  • If validation fails for any metadata
    Type
    ValidationError
  • If input is invalid
    Type
    Error
Returns:
The modified program instance (for chaining)
Type
Program