Class: DataDiagramModel
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. | ‐ | ||
|
| Provides the methods to format the content according to the current language. Deprecated Use useTranslation hook instead. | ‐ |
Accessors
dataProvider
get
dataProvider():DataProvider
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
Defined in
editor/dataDiagramModel.ts:186
elements
get
elements(): readonlyElement
[]
All elements (nodes) in the graph.
Returns
readonly Element
[]
Implementation of
Inherited from
Defined in
factory
get
factory():DataFactory
Provides an RDF term factory to create RDF terms for identifiers and property values.
Returns
Implementation of
Inherited from
Defined in
language
get
language():string
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
Defined in
links
get
links(): readonlyLink
[]
All links (edges) between elements in the graph.
Returns
readonly Link
[]
Implementation of
Inherited from
Defined in
operations
get
operations(): readonlyFetchOperation
[]
Returns an immutable snapshot of current fetch operations.
Returns
readonly FetchOperation
[]
Defined in
editor/dataDiagramModel.ts:197
selection
Current diagram selection (elements and/or links).
Returns
Inherited from
Defined in
Methods
addElement()
addElement(
element
):void
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
Defined in
addLink()
addLink(
link
):void
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
Defined in
editor/dataDiagramModel.ts:553
bringElements()
bringElements(
targets
,to
):void
Puts specified elements before or after all other in the display order.
Parameters
Parameter | Type |
---|---|
| readonly |
|
|
Returns
void
Inherited from
Defined in
createElement()
createElement(
elementIriOrModel
):EntityElement
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
Defined in
editor/dataDiagramModel.ts:532
createElementType()
createElementType(
elementTypeIri
):ElementType
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
Defined in
editor/dataDiagramModel.ts:677
createLinkType()
createLinkType(
linkTypeIri
):LinkType
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
Defined in
editor/dataDiagramModel.ts:698
createLinks()
createLinks(
data
): (RelationLink
|RelationGroup
)[]
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
)[]
Defined in
editor/dataDiagramModel.ts:590
createNewDiagram()
createNewDiagram(
params
):Promise
<void
>
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. | |
|
| Cancellation signal. |
Returns
Promise
<void
>
See
Defined in
editor/dataDiagramModel.ts:249
createPropertyType()
createPropertyType(
propertyIri
):PropertyType
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
Defined in
editor/dataDiagramModel.ts:719
discardLayout()
discardLayout():
void
Discards all diagram content and resets associated data provider to en empty one.
Returns
void
Defined in
editor/dataDiagramModel.ts:380
exportLayout()
exportLayout():
SerializedDiagram
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
Defined in
editor/dataDiagramModel.ts:398
findLink()
findLink(
linkTypeId
,sourceId
,targetId
):undefined
|Link
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
Defined in
getElement()
getElement(
elementId
):undefined
|Element
Gets an element by its Element.id in the graph if exists.
Parameters
Parameter | Type |
---|---|
|
|
Returns
undefined
| Element
Implementation of
Inherited from
Defined in
getElementLinks()
getElementLinks(
element
): readonlyLink
[]
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
Defined in
getElementType()
getElementType(
elementTypeIri
):undefined
|ElementType
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
Defined in
editor/dataDiagramModel.ts:667
getLink()
getLink(
linkId
):undefined
|Link
Gets a link by its Link.id in the graph if exists.
Parameters
Parameter | Type |
---|---|
|
|
Returns
undefined
| Link
Implementation of
Inherited from
Defined in
getLinkType()
getLinkType(
linkTypeIri
):undefined
|LinkType
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
Defined in
editor/dataDiagramModel.ts:688
getLinkVisibility()
getLinkVisibility(
linkTypeId
):LinkTypeVisibility
Gets current visibility mode for the specified link type.
Parameters
Parameter | Type |
---|---|
|
Returns
Implementation of
DataGraphStructure
.getLinkVisibility
Inherited from
DiagramModel
.getLinkVisibility
Defined in
getOperationFailReason()
getOperationFailReason<
T
>(type
,target
):unknown
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
Defined in
editor/dataDiagramModel.ts:205
getPropertyType()
getPropertyType(
propertyTypeIri
):undefined
|PropertyType
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
Defined in
editor/dataDiagramModel.ts:709
group()
group(
entities
):EntityGroup
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
Defined in
editor/dataDiagramModel.ts:745
importLayout()
importLayout(
params
):Promise
<void
>
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
|
|
| 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
Defined in
editor/dataDiagramModel.ts:276
regroupLinks()
regroupLinks(
links
):void
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
Defined in
editor/dataDiagramModel.ts:911
removeElement()
removeElement(
elementId
):void
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
Defined in
removeLink()
removeLink(
linkId
):void
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
Defined in
reorderElements()
reorderElements(
compare
):void
Changes display order of elements on the diagram.
Parameters
Parameter | Type | Description |
---|---|---|
| ( | Sort comparator to establish a particular ordering |
Returns
void
Inherited from
Defined in
requestElementData()
requestElementData(
elementIris
):Promise
<void
>
Requests to fetch the data for the specified elements from a data provider.
Parameters
Parameter | Type |
---|---|
| readonly |
Returns
Promise
<void
>
Defined in
editor/dataDiagramModel.ts:487
requestLinks()
requestLinks(
options
):Promise
<void
>
Requests to fetch links between all elements on the diagram from a data provider.
Parameters
Parameter | Type |
---|---|
|
Returns
Promise
<void
>
Defined in
editor/dataDiagramModel.ts:494
requestLinksOfType()
requestLinksOfType(
linkTypeIds
?):Promise
<void
>
Parameters
Parameter | Type |
---|---|
| readonly |
Returns
Promise
<void
>
Deprecated
Use DataDiagramModel.requestLinks instead.
Defined in
editor/dataDiagramModel.ts:517
setLanguage()
setLanguage(
value
):void
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
Defined in
setLinkVisibility()
setLinkVisibility(
linkTypeId
,value
):void
Sets current visibility mode for the specified link type.
Parameters
Parameter | Type |
---|---|
| |
|
Returns
void
Inherited from
DiagramModel
.setLinkVisibility
Defined in
setSelection()
setSelection(
value
):void
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
Defined in
sourceOf()
sourceOf(
link
):undefined
|Element
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
Defined in
targetOf()
targetOf(
link
):undefined
|Element
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
Defined in
ungroupAll()
ungroupAll(
groups
):EntityElement
[]
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
Defined in
editor/dataDiagramModel.ts:809
ungroupSome()
ungroupSome(
group
,entities
):EntityElement
[]
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 |
---|---|
| |
|
|
Returns
See
- group
- ungroupAll