migrate

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package migrate writes a SysML v1 model, read from XMI, as SysML v2 textual notation, and reports what each v1 element became.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// ID is the element's xmi:id, the handle a v1 tool addresses it by.
	ID string `json:"id"`
	// Kind is the v1 element as modeled: its stereotype when one classifies it
	// («Block», «Requirement»), else its UML metaclass.
	Kind string `json:"kind"`
	// Name is the element's qualified name in the v1 model.
	Name string `json:"name"`
	// Target is the v2 declaration written for it (a qualified name with its
	// keyword), or "" when nothing was.
	Target  string  `json:"target,omitempty"`
	Verdict Verdict `json:"verdict"`
	// Note explains an approximation or an omission.
	Note string `json:"note,omitempty"`
}

Entry records the verdict on one v1 element.

type LayoutSummary

type LayoutSummary struct {
	Source       string `json:"source"`
	MTIPVersion  string `json:"mtipVersion,omitempty"`
	CameoVersion string `json:"cameoVersion,omitempty"`
	ExportTime   string `json:"exportTime,omitempty"`
	// Diagrams counts the export's diagram records; DiagramsJoined those whose
	// diagram's view was written and laid out, DiagramsUnmatched those whose
	// diagram is not written as a view or matches none — joined + unmatched
	// always equals Diagrams.
	Diagrams          int `json:"diagrams"`
	DiagramsJoined    int `json:"diagramsJoined"`
	DiagramsUnmatched int `json:"diagramsUnmatched"`
	// ViewsWithoutLayout counts the written views the export does not cover.
	ViewsWithoutLayout int `json:"viewsWithoutLayout"`
	// Placements counts the shown elements the export positions;
	// PlacementsWritten those positioned into a view, PlacementsUnexposed
	// those the view neither exposes nor draws, PlacementsDangling those
	// resolving to no element. Routes likewise per connector, RoutesUnexposed
	// counting every route pinned to no member, for the reasons RoutesByKind itemizes.
	Placements          int `json:"placements"`
	PlacementsWritten   int `json:"placementsWritten"`
	PlacementsUnexposed int `json:"placementsUnexposed"`
	PlacementsDangling  int `json:"placementsDangling"`
	Routes              int `json:"routes"`
	RoutesWritten       int `json:"routesWritten"`
	RoutesUnexposed     int `json:"routesUnexposed"`
	RoutesDangling      int `json:"routesDangling"`
	// RoutesByKind itemizes the routes by the connector's v1 kind and why each
	// is or is not pinned to a member of the view.
	RoutesByKind []RouteKind `json:"routesByKind,omitempty"`
	// Malformed counts the export's malformed records; Unsupported the
	// presentation properties DiagramLayout carries no attribute for, by tag.
	Malformed   int            `json:"malformed"`
	Unsupported map[string]int `json:"unsupported,omitempty"`
}

LayoutSummary accounts for what an MTIP export contributed to a migration: how many of its diagram records joined, and how much of their geometry was written into the views.

type Options

type Options struct {
	// Layout is the parsed MTIP export; nil migrates without layout.
	Layout *mtip.Export
	// LayoutSource names the file Layout was read from, for the report and
	// diagnostics.
	LayoutSource string
}

Options carries the optional inputs of a migration: an MTIP export whose diagram records lay out the views the migration writes.

type Report

type Report struct {
	// Source names the v1 document migrated.
	Source string `json:"source"`
	// Exporter is the tool the document says wrote it, when it says.
	Exporter string  `json:"exporter,omitempty"`
	Entries  []Entry `json:"entries"`
	// Layout accounts for the MTIP export the migration was augmented with;
	// nil when none was.
	Layout *LayoutSummary `json:"layout,omitempty"`
}

Report is the per-element account of a migration.

func (*Report) Count

func (r *Report) Count() map[Verdict]int

Count returns how many entries carry each verdict.

func (*Report) Summary

func (r *Report) Summary() string

Summary is the one-line account a command prints after migrating.

func (*Report) Unreferenced

func (r *Report) Unreferenced() int

Unreferenced returns how many skipped entries are the user's own elements that nothing refers to, as opposed to profile, library or notation content.

func (*Report) WriteJSON

func (r *Report) WriteJSON(w io.Writer) error

WriteJSON writes the report as one JSON document.

func (*Report) WriteText

func (r *Report) WriteText(w io.Writer) error

WriteText writes the report as a table, one element per line, grouped by verdict with the elements that need attention first.

type Result

type Result struct {
	Notation []byte
	Report   *Report
	Results  *simresults.Results
}

Result is a migration's output: the v2 notation, the report over it, and the result snapshots of its run configurations.

func FromModel

func FromModel(name string, model *sysmlv1.Model) *Result

FromModel migrates an already-read XMI model.

func FromModelOptions

func FromModelOptions(name string, model *sysmlv1.Model, opts Options) *Result

FromModelOptions is FromModel with the augments opts carries. Unlike MigrateOptions it cannot fail, so a layout export joins whatever of the model it can and reports the rest.

func Migrate

func Migrate(name string, data []byte) (*Result, error)

Migrate reads a SysML v1 model as UML XMI, or a zip archive (such as a .mdzip) holding it, and writes it as SysML v2 notation. name labels the source in the report.

func MigrateOptions

func MigrateOptions(name string, data []byte, opts Options) (*Result, error)

MigrateOptions is Migrate with the augments opts carries. A layout export whose diagram records match no diagram of the model is an error: the file was exported from a different project.

type RouteKind

type RouteKind struct {
	Kind   string `json:"kind"`
	Reason string `json:"reason"`
	Count  int    `json:"count"`
}

RouteKind counts the routes of one v1 connector kind that share a reason: written, not drawn, not exposed, unnamed, not written, no v2 member, duplicate or dangling.

type Verdict

type Verdict int

Verdict is what the migration did with one SysML v1 element.

const (
	// Mapped: the element has a SysML v2 counterpart that states the same thing.
	Mapped Verdict = iota
	// Approximated: the element was written, but the v2 form loses or
	// restates part of what v1 said; the note says what.
	Approximated
	// Unmapped: the element has no v2 counterpart in this migration and is
	// recorded as a comment where it stood.
	Unmapped
	// Skipped: the element is not the user's model — a profile, a library the
	// tool bundled, a diagram — or nothing in the model refers to it, so no v2
	// form would say anything; it is left out without a comment.
	Skipped
)

func (Verdict) MarshalText

func (v Verdict) MarshalText() ([]byte, error)

MarshalText writes the verdict by name, so the JSON report reads as the text one.

func (Verdict) String

func (v Verdict) String() string

func (*Verdict) UnmarshalText

func (v *Verdict) UnmarshalText(text []byte) error

UnmarshalText reads a verdict written by MarshalText.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL