Notes & anchors
Not everything worth recording is part of the ontology itself. A note is a free-text annotation — a modeling decision, a caveat, a "revisit this" — and an anchor is the link that attaches a note to the element it comments on. Together they are OntoUML's equivalent of a UML comment and its connector.
Notes and anchors carry no ontological meaning: they don't constrain instances and they're ignored by semantic analyses. They exist for the humans reading the model. A note can float on its own, or be anchored to one or several elements when the same remark applies to more than one.
Writing a note
Build a note from its container package with noteBuilder() and give it text.
The text is multilingual, just like element names, so a language tag is
accepted as an optional second argument.
import { class ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project } from 'ontouml-js';
const const project: Projectproject = new new Project(): ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilderCreates a builder for a new
Package
in this project.packageBuilder().PackageBuilder.root(): PackageBuilderSets the package as the root package of its project, i.e., the package
that contains the entire model.root().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilderAdds a name to the element in the given language.name('Library').PackageBuilder.build(): PackageBuilds an instance of
Package
with the parameters passed to the
builder. When no methods are evoked, the created package has the
following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `contents: []`build();
const const note: Notenote = const model: Packagemodel
.Package.noteBuilder(): NoteBuilderCreates a builder for a
Note
contained in this package.noteBuilder()
.NoteBuilder.text(value: string, language?: string): NoteBuilderAdds the text of the note in the given language.text('Loan periods differ by member type — confirm with the library.')
.NoteBuilder.build(): NoteBuilds an instance of
Note
with the parameters passed to the
builder. When no methods are evoked, the created note has the following
defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `text: empty`build();
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const project: Projectproject.Project.notes: Note[]The notes contained in this project.notes.Array<Note>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.length); // 1
Anchoring it to an element
An unattached note is valid but rootless. To point it at something, build an
anchor that connects the note to the element it annotates. The most
direct route is note.anchorBuilder(), which pre-fills the note for you:
import { class ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project } from 'ontouml-js';
const const project: Projectproject = new new Project(): ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilderCreates a builder for a new
Package
in this project.packageBuilder().PackageBuilder.root(): PackageBuilderSets the package as the root package of its project, i.e., the package
that contains the entire model.root().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilderAdds a name to the element in the given language.name('Library').PackageBuilder.build(): PackageBuilds an instance of
Package
with the parameters passed to the
builder. When no methods are evoked, the created package has the
following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `contents: []`build();
const const loan: Classloan = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.relator(): ClassBuilderSets the stereotype of the class to «relator», which decorates rigid
classes whose instances are relators, i.e., entities that mediate other
entities and are the truthmakers of material relations (e.g.,
`Marriage`, `Enrollment`). Also applies the following defaults:
- `restrictedTo = [ "relator" ]`
- `order = 1`relator().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Loan').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const const note: Notenote = const model: Packagemodel
.Package.noteBuilder(): NoteBuilderCreates a builder for a
Note
contained in this package.noteBuilder()
.NoteBuilder.text(value: string, language?: string): NoteBuilderAdds the text of the note in the given language.text('Loan periods differ by member type.')
.NoteBuilder.build(): NoteBuilds an instance of
Note
with the parameters passed to the
builder. When no methods are evoked, the created note has the following
defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `text: empty`build();
const const anchor: Anchoranchor = const note: Notenote.Note.anchorBuilder(): AnchorBuilderCreates a builder for an
Anchor
that attaches this note to a
model element.anchorBuilder().AnchorBuilder.annotates(element: ModelElement): AnchorBuilderSets the
ModelElement
annotated by the note connected by the
anchor.annotates(const loan: Classloan).AnchorBuilder.build(): AnchorBuilds an instance of
Anchor
with the parameters passed to the
builder. Both the note and the annotated element are required before
`build()` is evoked. When no other methods are evoked, the created anchor
has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date()`build();
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const anchor: Anchoranchor.Anchor.note: NoteThe note attached by this anchor.note === const note: Notenote); // true
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const anchor: Anchoranchor.Anchor.element: ModelElementThe model element annotated by
note
.element === const loan: Classloan); // true
Equivalently, build the anchor from a package and set both ends explicitly — useful when you want the anchor to live in a particular package:
import { class ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project } from 'ontouml-js';
const const project: Projectproject = new new Project(): ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilderCreates a builder for a new
Package
in this project.packageBuilder().PackageBuilder.root(): PackageBuilderSets the package as the root package of its project, i.e., the package
that contains the entire model.root().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilderAdds a name to the element in the given language.name('Library').PackageBuilder.build(): PackageBuilds an instance of
Package
with the parameters passed to the
builder. When no methods are evoked, the created package has the
following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `contents: []`build();
const const person: Classperson = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.kind(): ClassBuilderSets the stereotype of the class to «kind», which decorates rigid
classes that provide an identity principle to their instances, which are
functional complexes (e.g., `Person`, `Car`). Also applies the following
defaults:
- `restrictedTo = [ "functional-complex" ]`
- `order = 1`kind().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Person').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const const note: Notenote = const model: Packagemodel.Package.noteBuilder(): NoteBuilderCreates a builder for a
Note
contained in this package.noteBuilder().NoteBuilder.text(value: string, language?: string): NoteBuilderAdds the text of the note in the given language.text('Members are always persons.').NoteBuilder.build(): NoteBuilds an instance of
Note
with the parameters passed to the
builder. When no methods are evoked, the created note has the following
defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `text: empty`build();
const model: Packagemodel.Package.anchorBuilder(): AnchorBuilderCreates a builder for an
Anchor
contained in this package.anchorBuilder().AnchorBuilder.note(note: Note): AnchorBuilderSets the
Note
connected by the anchor.note(const note: Notenote).AnchorBuilder.annotates(element: ModelElement): AnchorBuilderSets the
ModelElement
annotated by the note connected by the
anchor.annotates(const person: Classperson).AnchorBuilder.build(): AnchorBuilds an instance of
Anchor
with the parameters passed to the
builder. Both the note and the annotated element are required before
`build()` is evoked. When no other methods are evoked, the created anchor
has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date()`build();
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const project: Projectproject.Project.anchors: Anchor[]The anchors contained in this project, i.e., the links between notes
and the elements they annotate.anchors.Array<Anchor>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.length); // 1
A note can annotate several elements at once: build multiple anchors from the
same note, each with a different annotates(...) target. Each anchor is an
independent link.
Key takeaways
- A note is free multilingual text; build it with
noteBuilder().text(...). - An anchor attaches a note to an element —
note.anchorBuilder()is the shorthand;package.anchorBuilder().note(...).annotates(...)gives container control. - Notes and anchors are annotations: no ontological force, purely for readers.
- Read them back through
project.notesandproject.anchors; an anchor exposesnoteandelement.
Next: project metadata →, to make your model citable and FAIR.