Skip to content

GME Libraries

Patrik Meijer edited this page Sep 21, 2016 · 12 revisions

Intro

Libraries provide a way for reusing models (including Meta models) between different projects. Any project can be used as a library within another project. When a library is imported into a project, the (chosen) name of the library root becomes the library's namespace identifier. All nodes within the imported library will be stored under the given namespace. Nodes within a library cannot be modified, however they may still be referred and instantiated (the read-only property is not carried over to the instances).

Properties of a library

  • A library is always read-only.
  • The root of the library cannot be moved, copied or instantiated.
  • Meta elements of the library are part of the owning project's Meta.
  • Elements of the library can be instantiated or copied but not moved or modified in any way.
  • The libraries are stored as direct children of the project's ROOT.
  • The FCO of the library will be a descendant of the FCO of the container project.
  • A library source may be used multiple times under different namespaces, however within the project there will be no association between them (more than the source info stored within the library roots).

Namespaces and Fully Qualified Name

With the introduction of libraries, the core now implements the concept of fully qualified name (FQN).

/**
 * Returns the fully qualified name of the node, which is the list of 
 * its namespaces separated by dot and followed by the name of the node.
 *
 * @param {module:Core~Node} node - the node in question.
 *
 * @return {string} - Returns the fully qualified name of the node,
 * i.e. its namespaces and name join together by dots.
 *
 * @example NS1.NS2.name
 */
 core.getFullyQualifiedName(node);

The FQN will be computed based on the namespaces of the containing libraries. For example if your project uses a library under the namespace 'LibraryA' and that library contains another library under the namespace 'InnerLibrary', then the FQN of the 'Item' node of the embedded library will be LibraryA.InnerLibrary.Item.

The FQN and the namespaces are used throughout the UI making the identification of nodes easy.

Using libraries from the GUI

Adding a library to your project

You can add a library to your project with the following steps:

  • Bring up the context-menu of the ROOT of your project in the ObjectBrowser panel, by right-clicking on the ROOT item.
  • Choose the 'Add Library ...' option, that will bring up a dialog box.
  • In the dialog give a unique name to your library and set its source with one of the following options:
  • Use an earlier exported project package (.webgmex).
  • Use the URL of your library project (only URL pointing to the same WebGME server are allowed).
  • Press the 'Add' button.

After this, the library became and integral part of your project and you can use its contents.

Updating a library

You can update any library in your project using the next procedure:

  • Bring up the context-menu of the root of the library in the ObjectBrowser panel.
  • Choose the 'Update Library ...' option that will bring up a dialog.
  • Give the source of the new version of your library:
  • by using a project package (.webgmex)
  • or by giving the URL of the library project
  • Press the 'Update' and your library will be refreshed.

N.B if a node was removed in the originating project, then all instances of that node will be removed in the project after updating the library.

Refresh a library

If your library follows a branch of a project, you are able to refresh it without giving any additional source of the new version. If in the update library dialog the Refresh button is active, then it means you are able to refresh your library. The library will then be identical with the latest version of the branch of the given project. Other than that, it is the same update procedure, so lookout for automatic element removal!

Checking the information of a library

If you forget the origin of your library and the 'refresh' option is not available you can get information about the project of the library by hovering over the root of the library in the ObjectBrowser. The tooltip will contain all accessible information about your library. Here is an example of how the information could look like:
origin: demo+FiniteStateMachine : master@#808e3ca0070629ff4f6cc96be3605bbaade96cc9 (it contains the projectId of the library, the branch it follows, and the commit hash to show the 'version').

Clone this wiki locally