Class: DataDiagramModel
Defined in: editor/dataDiagramModel.ts:149
Asynchronously fetches and stores the entity diagram content: graph elements and links, as well as element, link and property types; maintains selection and the current language to display the data.
Additionally, the diagram model provides the means to undo/redo commands via history.
Extends
Implements
Properties
Property | Modifier | Type | Description | Overrides | Inherited from |
---|---|---|---|---|---|
| Events for the diagram model. | ‐ | |||
| Provides the mechanism to undo/redo commands on the diagram. | ‐ |
Accessors
dataProvider
Get Signature
get dataProvider():
DataProvider
Defined in: editor/dataDiagramModel.ts:189
Returns the data provider that is associated with the current diagram via creating new or importing an existing layout.
This provider is used to fetch entity graph data on-demand.
By default, it is set to EmptyDataProvider instance without any graph data.
See
Returns
elements
Get Signature
get elements(): readonly
Element
[]
Defined in: diagram/model.ts:208
All elements (nodes) in the graph.
Returns
readonly Element
[]
Implementation of
Inherited from
factory
Get Signature
get factory():
DataFactory
Defined in: diagram/model.ts:204
Provides an RDF term factory to create RDF terms for identifiers and property values.
Returns
Implementation of
Inherited from
language
Get Signature
get language():
string
Defined in: diagram/model.ts:163
Current language for the diagram content.
Language code is specified as lowercase BCP47
string (examples: en
, en-gb
, etc).
Initial language is en
.
Returns
string
Inherited from
links
Get Signature
get links(): readonly
Link
[]
Defined in: diagram/model.ts:212
All links (edges) between elements in the graph.
Returns
readonly Link
[]
Implementation of
Inherited from
locale
Get Signature
get locale():
DataLocaleProvider
Defined in: editor/dataDiagramModel.ts:200
Provides the methods to format the graph data according to the current language.
Returns
operations
Get Signature
get operations(): readonly
FetchOperation
[]
Defined in: editor/dataDiagramModel.ts:207
Returns an immutable snapshot of current fetch operations.
Returns
readonly FetchOperation
[]
selection
Get Signature
Defined in: diagram/model.ts:183
Current diagram selection (elements and/or links).
Returns
Inherited from
Methods
addElement()
addElement(
element
):void
Defined in: diagram/model.ts:343
Adds the element to the diagram.
Throws an error if element with the same Element.id already exists in the graph.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
|
Returns
void
Inherited from
addLink()
addLink(
link
):void
Defined in: editor/dataDiagramModel.ts:597
Adds the link to the diagram.
Throws an error if link with the same Link.id already exists in the graph or any of source or target is not in the graph.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
|
Returns
void
Overrides
bringElements()
bringElements(
targets
,to
):void
Defined in: diagram/model.ts:324
Puts specified elements before or after all other in the display order.
Parameters
Parameter | Type |
---|---|
| readonly |
|
|
Returns
void
Inherited from
createElement()
createElement(
elementIriOrModel
):EntityElement
Defined in: editor/dataDiagramModel.ts:576
Creates or gets an existing entity element on the diagram.
If element is specified as an IRI only, then the placeholder data will be used.
If multiple entity elements with the same IRI is on the diagram, the first one in the order will be returned.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
|
Returns
createElementType()
createElementType(
elementTypeIri
):ElementType
Defined in: editor/dataDiagramModel.ts:721
Creates or gets an existing element type in the graph.
If element type does not exists in the graph yet, it will be created and the data for it will be requested for it from the data provider.
Parameters
Parameter | Type |
---|---|
|
Returns
createLinks()
createLinks(
data
): (RelationLink
|RelationGroup
)[]
Defined in: editor/dataDiagramModel.ts:634
Creates or gets an existing links for the specified link model.
Multiple links may exists for the same link model because in some cases there could be multiple source or target elements with the same IRI.
Each existing link for the same link model will be updated with the specified data,
link state property urn:reactodia:layoutOnly
(TemplateProperties.LayoutOnly)
will be discarded if set.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
|
Returns
(RelationLink
| RelationGroup
)[]
createLinkType()
createLinkType(
linkTypeIri
):LinkType
Defined in: editor/dataDiagramModel.ts:742
Creates or gets an existing link type in the graph.
If link type does not exists in the graph yet, it will be created and the data for it will be requested for it from the data provider.
Parameters
Parameter | Type |
---|---|
|
Returns
createNewDiagram()
createNewDiagram(
params
):Promise
<void
>
Defined in: editor/dataDiagramModel.ts:259
Clears up the diagram and associates a new data provider for it.
This method discards all current diagram state (elements, links and other data) and resets the command history.
Parameters
Parameter | Type | Description |
---|---|---|
| { | ‐ |
| Data provider to associate with the diagram. This provider will be used to fetch entity graph data on-demand for the diagram. | |
| Formatter for the graph data on the diagram. If not specified, the DefaultDataLocaleProvider is used. See | |
|
| Cancellation signal. |
Returns
Promise
<void
>
See
createPropertyType()
createPropertyType(
propertyIri
):PropertyType
Defined in: editor/dataDiagramModel.ts:763
Creates or gets an existing property type in the graph.
If property type does not exists in the graph yet, it will be created and the data for it will be requested for it from the data provider.
Parameters
Parameter | Type |
---|---|
|
Returns
discardLayout()
discardLayout():
void
Defined in: editor/dataDiagramModel.ts:413
Discards all diagram content and resets associated data provider to en empty one.
Returns
void
exportLayout()
exportLayout():
SerializedDiagram
Defined in: editor/dataDiagramModel.ts:442
Exports current diagram state to a serializable object.
The exported state includes element and link geometry, template state, references to described entities and relations (via IRIs). Additionally, link type visibility settings are exported as well.
Returns
See
findLink()
findLink(
linkTypeId
,sourceId
,targetId
):undefined
|Link
Defined in: diagram/model.ts:235
Searches for any link of the specified type between elements with specified IDs in the graph if exists.
If multiple links is found, any of them could be returned.
Parameters
Parameter | Type |
---|---|
| |
|
|
|
|
Returns
undefined
| Link
Implementation of
Inherited from
getElement()
getElement(
elementId
):undefined
|Element
Defined in: diagram/model.ts:223
Gets an element by its Element.id in the graph if exists.
Parameters
Parameter | Type |
---|---|
|
|
Returns
undefined
| Element
Implementation of
Inherited from
getElementLinks()
getElementLinks(
element
): readonlyLink
[]
Defined in: diagram/model.ts:227
Gets all links connected to the specified element in the graph.
If element is not in the graph, no links would be returned.
Parameters
Parameter | Type |
---|---|
|
Returns
readonly Link
[]
Implementation of
DataGraphStructure
.getElementLinks
Inherited from
getElementType()
getElementType(
elementTypeIri
):undefined
|ElementType
Defined in: editor/dataDiagramModel.ts:711
Gets an element type by its ElementType.id in the graph if exists.
Element types are added to the graph as requested by DataDiagramModel.createElementType so the data (e.g. labels) can be fetched from a data provider.
Parameters
Parameter | Type |
---|---|
|
Returns
undefined
| ElementType
See
DataDiagramModel.createElementType
Implementation of
DataGraphStructure
.getElementType
getLink()
getLink(
linkId
):undefined
|Link
Defined in: diagram/model.ts:231
Gets a link by its Link.id in the graph if exists.
Parameters
Parameter | Type |
---|---|
|
|
Returns
undefined
| Link
Implementation of
Inherited from
getLinkType()
getLinkType(
linkTypeIri
):undefined
|LinkType
Defined in: editor/dataDiagramModel.ts:732
Gets an link type by its LinkType.id in the graph if exists.
Link types are added to the graph as requested by DataDiagramModel.createLinkType so the data (e.g. labels) can be fetched from a data provider.
Parameters
Parameter | Type |
---|---|
|
Returns
undefined
| LinkType
See
DataDiagramModel.createLinkType
Implementation of
DataGraphStructure
.getLinkType
getLinkVisibility()
getLinkVisibility(
linkTypeId
):LinkTypeVisibility
Defined in: diagram/model.ts:250
Gets current visibility mode for the specified link type.
Parameters
Parameter | Type |
---|---|
|
Returns
Implementation of
DataGraphStructure
.getLinkVisibility
Inherited from
DiagramModel
.getLinkVisibility
getOperationFailReason()
getOperationFailReason<
T
>(type
,target
):unknown
Defined in: editor/dataDiagramModel.ts:215
Returns a reason (thrown error) why latest fetch operation for specific target
failed, if any; otherwise returns undefined
.
Type Parameters
Type Parameter |
---|
|
Parameters
Parameter | Type |
---|---|
|
|
|
Returns
unknown
getPropertyType()
getPropertyType(
propertyTypeIri
):undefined
|PropertyType
Defined in: editor/dataDiagramModel.ts:753
Gets an property type by its PropertyType.id in the graph if exists.
Property types are added to the graph as requested by DataDiagramModel.createPropertyType so the data (e.g. labels) can be fetched from a data provider.
Parameters
Parameter | Type |
---|---|
|
Returns
undefined
| PropertyType
See
DataDiagramModel.createPropertyType
Implementation of
DataGraphStructure
.getPropertyType
group()
group(
entities
):EntityGroup
Defined in: editor/dataDiagramModel.ts:789
Groups multiple entity elements into an entity group element.
Specified entity elements are removed from the diagram and a single entity group element with these entities is created at the center of the bounding box between them.
Relation links from/to specified elements are re-grouped to form relation group links the same way.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
| readonly |
Returns
See
importLayout()
importLayout(
params
):Promise
<void
>
Defined in: editor/dataDiagramModel.ts:294
Restores diagram content from previously exported state and associates a new data provider for the diagram.
This method discards all current diagram state (elements, links and other data) and resets the command history.
Parameters
Parameter | Type | Description |
---|---|---|
| { | ‐ |
| Data provider to associate with the diagram. This provider will be used to fetch entity graph data on-demand for the diagram. | |
| Diagram state to restore (elements and their positions, links with visibility settings, etc). If specified, current diagram content will be replaced by one from the state, otherwise the diagram will be cleared up only. | |
|
| Whether to fetch known link types on import and automatically hide all unused link types. Default
|
| Formatter for the graph data on the diagram. If not specified, the DefaultDataLocaleProvider is used. See | |
|
| Pre-cached data for the elements which should be used instead of being requested from the data provider on import. |
|
| Cancellation signal. |
|
| Whether links for the between imported elements should be requested from the data provider on import. Default
|
Returns
Promise
<void
>
See
regroupLinks()
regroupLinks(
links
):void
Defined in: editor/dataDiagramModel.ts:955
Re-creates a set of relations or relation groups to automatically group relations with the same link type connected to entity groups.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
| readonly ( |
Returns
void
removeElement()
removeElement(
elementId
):void
Defined in: diagram/model.ts:356
Removes the element with specified ID from the diagram if exists.
When element is removed, all connected links will be removed as well.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
|
|
Returns
void
Inherited from
removeLink()
removeLink(
linkId
):void
Defined in: diagram/model.ts:382
Removes the link with specified ID from the diagram if exists.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
|
|
Returns
void
Inherited from
reorderElements()
reorderElements(
compare
):void
Defined in: diagram/model.ts:316
Changes display order of elements on the diagram.
Parameters
Parameter | Type | Description |
---|---|---|
| ( | Sort comparator to establish a particular ordering |
Returns
void
Inherited from
requestElementData()
requestElementData(
elementIris
):Promise
<void
>
Defined in: editor/dataDiagramModel.ts:531
Requests to fetch the data for the specified elements from a data provider.
Parameters
Parameter | Type |
---|---|
| readonly |
Returns
Promise
<void
>
requestLinks()
requestLinks(
options
):Promise
<void
>
Defined in: editor/dataDiagramModel.ts:538
Requests to fetch links between all elements on the diagram from a data provider.
Parameters
Parameter | Type |
---|---|
|
Returns
Promise
<void
>
requestLinksOfType()
requestLinksOfType(
linkTypeIds?
):Promise
<void
>
Defined in: editor/dataDiagramModel.ts:561
Parameters
Parameter | Type |
---|---|
| readonly |
Returns
Promise
<void
>
Deprecated
Use DataDiagramModel.requestLinks instead.
setLanguage()
setLanguage(
value
):void
Defined in: diagram/model.ts:170
Sets current language for the diagram content.
Language code is specified as lowercase BCP47
string (examples: en
, en-gb
, etc).
Parameters
Parameter | Type |
---|---|
|
|
Returns
void
Inherited from
setLinkVisibility()
setLinkVisibility(
linkTypeId
,value
):void
Defined in: diagram/model.ts:257
Sets current visibility mode for the specified link type.
Parameters
Parameter | Type |
---|---|
| |
|
Returns
void
Inherited from
DiagramModel
.setLinkVisibility
setSelection()
setSelection(
value
):void
Defined in: diagram/model.ts:190
Sets current diagram selection (elements and/or links).
When called, selected cells will be brought to the front before all other diagram cells.
Parameters
Parameter | Type |
---|---|
|
Returns
void
Inherited from
sourceOf()
sourceOf(
link
):undefined
|Element
Defined in: diagram/model.ts:242
Gets a source element for the specified link
in the graph.
If link is not in the graph, undefined
would be returned instead.
Parameters
Parameter | Type |
---|---|
|
Returns
undefined
| Element
Implementation of
Inherited from
targetOf()
targetOf(
link
):undefined
|Element
Defined in: diagram/model.ts:246
Gets a target element for the specified link
in the graph.
If link is not in the graph, undefined
would be returned instead.
Parameters
Parameter | Type |
---|---|
|
Returns
undefined
| Element
Implementation of
Inherited from
ungroupAll()
ungroupAll(
groups
):EntityElement
[]
Defined in: editor/dataDiagramModel.ts:853
Ungroups one or many entity group elements into all contained entity elements.
Specified entity group elements are removed from the diagram and all contained entity elements are created at the same position as the owner group.
Relation links from/to ungrouped entities are re-grouped to form relation group links the same way.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
| readonly |
Returns
See
ungroupSome()
ungroupSome(
group
,entities
):EntityElement
[]
Defined in: editor/dataDiagramModel.ts:902
Ungroups some entities from an entity group element.
Specified entity group is modified to remove target entities and re-create them at the same position as the group. If only one or less entities are left in the group, the group will be completely ungrouped instead.
Relation links from/to ungrouped entities are re-grouped to form relation group links the same way.
The operation puts a command to the command history.
Parameters
Parameter | Type |
---|---|
| |
|
|