Interface MTDataProvider
public interface MTDataProvider
Register an implementation of this interface to add plugin data
to models, symbols or documents.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
copyModelData
(MTCompleteModel source, MTCompleteModel target) Optionally copies data when a copy of a model is made.default void
copySymbolData
(MTCompleteSymbol source, MTCompleteSymbol target) Optionally copies data when a copy of a symbol is made.createOrLoadData
(MTStore store, MTCompleteModel model, Collection<MTPluginData> existing) Create or load data for a model.createOrLoadData
(MTStore store, MTCompleteSymbol symbol, Collection<MTPluginData> existing) Create or load data for a symbol.createOrLoadData
(MTStore store, MTDocument document, Collection<MTPluginData> existing) Create or load data for a document.void
edgeAdded
(MTCompleteEdge edge) This is called when a edge is added to a model but before the edge is saved to storage.void
edgeRemoved
(MTCompleteEdge edge) This is called when an edge is removed from a model but before the edge is removed from storage.default Optional<MTDataPresenter>
Returns an optional presenter than can be used to list and present data of a given type in the user interface.Returns the UUID of the provider.boolean
hasData
(MTCompleteModel model) Should returntrue
if the provider wish to provide data for this model.boolean
hasData
(MTCompleteSymbol symbol) Should returntrue
if the provider wish to provide data for this symbol.boolean
hasData
(MTDocument document) Should returntrue
if the provider wish to provide data for this document.void
imported()
Called after an import or other similar batch change of data where all the data belonging to this provider may have changed.byte[]
replaceBinaryData
(MTPluginDataOperations.Data data, String fromLangUUID, String toLangUUID) Replaces the byte data.replaceTextData
(MTPluginDataOperations.Data data, String fromLangUUID, String toLangUUID) Replaces the text data.void
vertexAdded
(MTCompleteVertex vertex) This is called when a vertex is added to a model but before the vertex is saved to storage.void
vertexRemoved
(MTCompleteVertex vertex) This is called when a vertex is removed from a model but before the vertex is removed from storage.
-
Method Details
-
getProviderUUID
UUID getProviderUUID()Returns the UUID of the provider.- Returns:
- The unique UUID of the provider.
- Since:
- 3.3
-
imported
void imported()Called after an import or other similar batch change of data where all the data belonging to this provider may have changed. -
replaceBinaryData
Replaces the byte data. Called if the fromLang is removed and replaced with toLang (such as on some imports) or if toLang is added. In the former case, fromLang may no longer be available in the store. In the latter case, fromLang will be the default language (and available in the store).- Parameters:
data
- a plugin data that may not be persisted. This must not be altered by the call. Will always have a provider uuid equal to this MTDataProvider's getProviderUUID().
NOTE: If this MTDataProvider has no concept of language, it should return a copy of the byte array in the data parameter.fromLangUUID
- The language that should be available in the data and hence to translate from. The language having this uuid may no longer be available (has been removed and replaced with toLang) in the store.toLangUUID
- The language to "translate" to.- Returns:
- A byte array that has updated any references to fromLang to that of toLang, and any data associated with fromLang possibly translated (if possible). The returned byte array must not be the same as the byte array returned by data.getBinaryContent().
-
replaceTextData
Replaces the text data. Called if the fromLang is removed and replaced with toLang (such as on some imports) or if toLang is added. In the former case, fromLang may no longer be available in the store. In the latter case, fromLang will be the language to copy data from (and available in the store).- Parameters:
data
- a plugin data that may not be persisted. This must not be altered by the call. Will always have a provider uuid equal to this MTDataProvider's getProviderUUID().
NOTE: If this MTDataProvider has no concept of language, it should return the string returned by data.getTextContent(). The difference between this method and replaceBinaryData is that strings are immutable so there is no need to return a copy.fromLangUUID
- The language that should be available in the data and hence to translate from. The language having this uuid may no longer be available (has been removed and replaced with toLang) in the store.toLangUUID
- The language to "translate" to.- Returns:
- A string that has updated any references to fromLang to that of toLang, and any data associated with fromLang possibly translated (if possible).
-
hasData
Should returntrue
if the provider wish to provide data for this model.- Returns:
true
if the provider wish to provide data for this model.
-
createOrLoadData
Create or load data for a model.- Parameters:
model
- The model.- Returns:
- A plugin-specific object created from plugin data. This object can later be retrieved by calling getPluginData() on the model.
- Since:
- 3.3
-
hasData
Should returntrue
if the provider wish to provide data for this symbol.- Returns:
true
if the provider wish to provide data for this symbol.
-
createOrLoadData
Create or load data for a symbol.- Parameters:
symbol
- The symbol.- Returns:
- A plugin-specific object created from plugin data. This object can later be retrieved by calling getPluginData() on the symbol.
- Since:
- 3.3
-
hasData
Should returntrue
if the provider wish to provide data for this document.- Returns:
true
if the provider wish to provide data for this document.
-
createOrLoadData
Create or load data for a document.- Parameters:
document
- The document.- Returns:
- A plugin-specific object created from plugin data. This object can later be retrieved by calling getPluginData() on the document.
- Since:
- 3.3
-
vertexAdded
This is called when a vertex is added to a model but before the vertex is saved to storage. The symbol is guaranteed to already exist in storage.- Parameters:
vertex
- The vertex that was added to the model.
-
vertexRemoved
This is called when a vertex is removed from a model but before the vertex is removed from storage. It cannot be assumed that the vertex has been saved to storage when this method is called.- Parameters:
vertex
- The vertex that was removed from the model.
-
edgeAdded
This is called when a edge is added to a model but before the edge is saved to storage. It cannot be assumed that the connected vertices have been saved yet.- Parameters:
edge
- The edge that was added to the model.
-
edgeRemoved
This is called when an edge is removed from a model but before the edge is removed from storage. It cannot be assumed that the edge has been saved to storage when this method is called.- Parameters:
edge
- The edge that was removed from the model.
-
getPresenter
Returns an optional presenter than can be used to list and present data of a given type in the user interface. -
copyModelData
default void copyModelData(MTCompleteModel source, MTCompleteModel target) throws MTRemoteChangeException Optionally copies data when a copy of a model is made. Changes should be persisted to storage when the call returns.- Throws:
MTRemoteChangeException
-
copySymbolData
default void copySymbolData(MTCompleteSymbol source, MTCompleteSymbol target) throws MTRemoteChangeException Optionally copies data when a copy of a symbol is made. Changes should be persisted to storage when the call returns.- Throws:
MTRemoteChangeException
-