Skip to main content
Version: 1.0.0

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.

Theory: annotations are not model elements you reason over

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 Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
} from 'ontouml-js';
const const project: Projectproject = new new Project(): Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilder
Creates a builder for a new Package in this project.
packageBuilder
().PackageBuilder.root(): PackageBuilder
Sets the package as the root package of its project, i.e., the package that contains the entire model.
@returnsthis builder, for method chaining.
root
().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Library').PackageBuilder.build(): Package
Builds 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: []`
@throwsan error if the builder has already been used.
build
();
const const note: Notenote = const model: Packagemodel .Package.noteBuilder(): NoteBuilder
Creates a builder for a Note contained in this package.
noteBuilder
()
.NoteBuilder.text(value: string, language?: string): NoteBuilder
Adds the text of the note in the given language.
@paramvalue - the note text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
text
('Loan periods differ by member type — confirm with the library.')
.NoteBuilder.build(): Note
Builds 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`
@throwsan error if the builder has already been used.
build
();
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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: number
Gets 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 Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
} from 'ontouml-js';
const const project: Projectproject = new new Project(): Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilder
Creates a builder for a new Package in this project.
packageBuilder
().PackageBuilder.root(): PackageBuilder
Sets the package as the root package of its project, i.e., the package that contains the entire model.
@returnsthis builder, for method chaining.
root
().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Library').PackageBuilder.build(): Package
Builds 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: []`
@throwsan error if the builder has already been used.
build
();
const const loan: Classloan = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.relator(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
relator
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Loan').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const const note: Notenote = const model: Packagemodel .Package.noteBuilder(): NoteBuilder
Creates a builder for a Note contained in this package.
noteBuilder
()
.NoteBuilder.text(value: string, language?: string): NoteBuilder
Adds the text of the note in the given language.
@paramvalue - the note text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
text
('Loan periods differ by member type.')
.NoteBuilder.build(): Note
Builds 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`
@throwsan error if the builder has already been used.
build
();
const const anchor: Anchoranchor = const note: Notenote.Note.anchorBuilder(): AnchorBuilder
Creates a builder for an Anchor that attaches this note to a model element.
anchorBuilder
().AnchorBuilder.annotates(element: ModelElement): AnchorBuilder
Sets the ModelElement annotated by the note connected by the anchor.
@returnsthis builder, for method chaining.
annotates
(const loan: Classloan).AnchorBuilder.build(): Anchor
Builds 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()`
@throwsan error if the builder has already been used.
build
();
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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: Note
The note attached by this anchor.
note
=== const note: Notenote); // true
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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: ModelElement
The 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 Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
} from 'ontouml-js';
const const project: Projectproject = new new Project(): Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilder
Creates a builder for a new Package in this project.
packageBuilder
().PackageBuilder.root(): PackageBuilder
Sets the package as the root package of its project, i.e., the package that contains the entire model.
@returnsthis builder, for method chaining.
root
().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Library').PackageBuilder.build(): Package
Builds 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: []`
@throwsan error if the builder has already been used.
build
();
const const person: Classperson = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.kind(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
kind
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Person').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const const note: Notenote = const model: Packagemodel.Package.noteBuilder(): NoteBuilder
Creates a builder for a Note contained in this package.
noteBuilder
().NoteBuilder.text(value: string, language?: string): NoteBuilder
Adds the text of the note in the given language.
@paramvalue - the note text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
text
('Members are always persons.').NoteBuilder.build(): Note
Builds 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`
@throwsan error if the builder has already been used.
build
();
const model: Packagemodel.Package.anchorBuilder(): AnchorBuilder
Creates a builder for an Anchor contained in this package.
anchorBuilder
().AnchorBuilder.note(note: Note): AnchorBuilder
Sets the Note connected by the anchor.
@returnsthis builder, for method chaining.
note
(const note: Notenote).AnchorBuilder.annotates(element: ModelElement): AnchorBuilder
Sets the ModelElement annotated by the note connected by the anchor.
@returnsthis builder, for method chaining.
annotates
(const person: Classperson).AnchorBuilder.build(): Anchor
Builds 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()`
@throwsan error if the builder has already been used.
build
();
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
length
); // 1
One note, many anchors

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.notes and project.anchors; an anchor exposes note and element.

Next: project metadata →, to make your model citable and FAIR.