Class ModelValidationService

java.lang.Object
io.jmix.dynmodelai.validation.ModelValidationService

@Component("dmagent_ModelValidationService") public class ModelValidationService extends Object
Checks Dynamic Model definitions without modifying them or applying migrations. Provides the same migration, readiness and data-impact checks for typed definitions and YAML. Used before and after agent operations and when reviewing a Draft for publication.

Results describe the state at the time of the check. Run state and authoritative publication checks remain outside this service; a successful result does not guarantee that a later Apply will succeed.

  • Constructor Details

  • Method Details

    • validateDraft

      public DraftApplyValidation validateDraft(String candidateYaml, String baselineContent, @Nullable UUID baselineSettingsId, List<String> entityNames)
      Checks the captured baseline, complete candidate YAML and presence of changes for Review and Apply. A stale baseline stops model validation. Takes snapshot values, not Conversation or Run state.
      Parameters:
      candidateYaml - complete target settings YAML, not the target-only UI preview
      baselineContent - settings YAML captured when work started
      baselineSettingsId - captured revision, or null before the first publication
      entityNames - affected entities, including removals; other entities' readiness findings are excluded
    • validateModel

      public ModelValidationResult validateModel(DynamicModelDefinition target, DynamicModelDefinition baseline, List<String> entityNames)
      Validates migrations for the complete target, then readiness and current-data impact for affected entities. Collects readiness findings even when migration validation fails; advisory findings remain advisory.
      Parameters:
      target - complete target model, not a list of changes
      baseline - published definition before the changes, used for migration diagnostics
      entityNames - affected entities, including ones removed from the target definition
      Returns:
      migration validation and affected-entity readiness; neither input is modified
    • validateYaml

      public ModelValidationResult validateYaml(String targetYaml, DynamicModelDefinition baseline, List<String> entityNames)
      Parses complete Dynamic Model YAML and performs the same checks as validateModel(io.jmix.dynmodel.meta.DynamicModelDefinition, io.jmix.dynmodel.meta.DynamicModelDefinition, java.util.List<java.lang.String>). Malformed YAML produces an invalid-model issue; unexpected service failures are propagated.
      Parameters:
      targetYaml - complete target settings YAML, not the target-only UI preview
      baseline - published definition before the changes, used for migration diagnostics
      entityNames - affected entities, including ones removed from the target definition
      Returns:
      the same validation result as for a typed model, or a parsing issue with no readiness findings
    • validateMigrations

      public MigrationValidationResult validateMigrations(DynamicModelDefinition target, DynamicModelDefinition baseline)
      Checks migration feasibility and collects issues from individual model elements on failure. Keeps the original issues and adds distinct diagnostic findings; no migrations are executed. The platform stops at the first violation, so dependent or model-wide errors may hide further issues.
      Parameters:
      target - complete target model to validate
      baseline - published definition before the Draft changes, used to identify new elements
      Returns:
      migration descriptions on success, or the collected issues on failure
    • validateNewMigrationIssues

      public MigrationValidationResult validateNewMigrationIssues(DynamicModelDefinition target, DynamicModelDefinition start, DynamicModelDefinition baseline)
      Checks the target like validateMigrations(DynamicModelDefinition, DynamicModelDefinition), but reports only issues the starting model did not already have: a problem that was in the editor before the agent's changes does not fail them. The platform stops at the first violation, so an old problem may hide a new one.
      Parameters:
      start - model before the agent's changes, validated only when the target is invalid
    • validateNewBlockingReadiness

      public List<ReadinessFinding> validateNewBlockingReadiness(DynamicModelDefinition target, DynamicModelDefinition start, List<String> entityNames)
      Returns blocking readiness findings of the target that the starting model did not already have. Planning refuses a plan with such a result instead of failing its verification after execution.
      Parameters:
      start - model before the agent's changes, validated only when the target has blocking findings
    • validateReadiness

      public ReadinessValidationResult validateReadiness(DynamicModelDefinition definition, List<String> entityNames)
      Checks configuration completeness and the impact on current data for affected entities. Includes advisory and blocking findings; findings for other entities are excluded.
      Parameters:
      definition - complete target model
      entityNames - affected entities, including ones removed from the target definition
      Returns:
      findings; validation passes when none is blocking, and migration validity is checked separately