webgme-engine
Version:
WebGME server and Client API without a GUI
3,558 lines (1,048 loc) • 414 kB
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Client</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Client</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>Client<span class="signature">(gmeConfig)</span><span class="type-signature"></span></h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Client"><span class="type-signature"></span>new Client<span class="signature">(gmeConfig)</span><span class="type-signature"></span></h4>
<div class="description">
<p>The Client class represents the Client API which is the way to communicate
with your project from your user-defined UI pieces. It allows project selection, project tracking,
model interpretation and model manipulation.</p>
<p>!! Documentation of the class is incomplete !!</p>
<p>What is mainly missing are the node setters. Until added here use the <a href="Core.html">Core documentation</a>
and simply replace any Core nodes in the arguments with the id/path of the nodes instead.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>gmeConfig</code></td>
<td class="type">
<span class="param-type"><a href="global.html#GmeConfig">GmeConfig</a></span>
</td>
<td class="description last"><p>the main configuration of the WebGME that holds information
about the server and other options.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="docs_client.doc.js.html">docs/client.doc.js</a>, <a href="docs_client.doc.js.html#line6">line 6</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="abortPlugin"><span class="type-signature"></span>abortPlugin<span class="signature">(executionId)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Initiates the abort of the given plugin execution.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>executionId</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="description last"><p>unique identifier that identifies the plugin execution</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="docs_client.doc.js.html">docs/client.doc.js</a>, <a href="docs_client.doc.js.html#line664">line 664</a>
</li></ul></dd>
</dl>
<h4 class="name" id="addLibrary"><span class="type-signature"></span>addLibrary<span class="signature">(name, blobHashLibraryInfoOrSeedName, callback)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Sends a server request to add specified library to the current project and branch.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="description last"><p>Name of new library (cannot contain dots or exist already)</p></td>
</tr>
<tr>
<td class="name"><code>blobHashLibraryInfoOrSeedName</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
|
<span class="param-type"><a href="global.html#object">object</a></span>
</td>
<td class="description last"><p>If blobHash string given will import library from blob,
if string will import from seed, otherwise project at info (will also be added to info at library).</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>projectId</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The projectId of your library.</p></td>
</tr>
<tr>
<td class="name"><code>branchName</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>The branch that your library follows in the
origin project.</p></td>
</tr>
<tr>
<td class="name"><code>commitHash</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>The commit-hash of your library.</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="description last"><p>Invoked when request completed.</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>err</code></td>
<td class="type">
<span class="param-type"><a href="global.html#null">null</a></span>
|
<span class="param-type"><a href="global.html#Error">Error</a></span>
</td>
<td class="description last"><p>If request failed.</p></td>
</tr>
<tr>
<td class="name"><code>result</code></td>
<td class="type">
<span class="param-type"><a href="module-Storage.html#~CommitResult">module:Storage~CommitResult</a></span>
</td>
<td class="description last"><p>Result from the commit made.</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="docs_client.doc.js.html">docs/client.doc.js</a>, <a href="docs_client.doc.js.html#line292">line 292</a>
</li></ul></dd>
</dl>
<h4 class="name" id="addMember"><span class="type-signature"></span>addMember<span class="signature">(path, memberPath, setId, msg<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Add a new member node to the given set of the
specified node.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>path</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the path/id of the node that will be modified.</p></td>
</tr>
<tr>
<td class="name"><code>memberPath</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the path/id of the member node.</p></td>
</tr>
<tr>
<td class="name"><code>setId</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the name of the set to expand.</p></td>
</tr>
<tr>
<td class="name"><code>msg</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>optional commit message, if not supplied a default one with the
function name and input parameters will be used</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="client_gmeNodeSetter.js.html">client/gmeNodeSetter.js</a>, <a href="client_gmeNodeSetter.js.html#line617">line 617</a>
</li></ul></dd>
</dl>
<h4 class="name" id="addMixin"><span class="type-signature"></span>addMixin<span class="signature">(path, addMixin, msg<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Creates a mixin connection to the node.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>path</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the path/id of the node that will be modified.</p></td>
</tr>
<tr>
<td class="name"><code>addMixin</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the path/id of the mixin node.</p></td>
</tr>
<tr>
<td class="name"><code>msg</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>optional commit message, if not supplied a default one with the
function name and input parameters will be used</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="client_gmeNodeSetter.js.html">client/gmeNodeSetter.js</a>, <a href="client_gmeNodeSetter.js.html#line1133">line 1133</a>
</li></ul></dd>
</dl>
<h4 class="name" id="addUI"><span class="type-signature"></span>addUI<span class="signature">(ui<span class="signature-attributes">opt</span>, eventHandler, guid<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="global.html#string">string</a>}</span></h4>
<div class="description">
<p>Adds a "user" for receiving events regarding nodes in a specified territory.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>ui</code></td>
<td class="type">
<span class="param-type"><a href="global.html#object">object</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>Object with additional methods to be invoked.</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>reLaunch</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>Triggered when active project/branch is switched.</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>eventHandler</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Function invoked at changes for, or initial loading of, nodes within the
"user's" territory.</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>events</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Array">Array</a>.<<a href="global.html#object">object</a>></span>
</td>
<td class="description last"><p>Array of event data for affected nodes within the territory.</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>guid</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>Unique id of user (if not provided one will be generated).</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="docs_client.doc.js.html">docs/client.doc.js</a>, <a href="docs_client.doc.js.html#line46">line 46</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>The id (guid) of the newly added "user".</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#string">string</a></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>// The eventHandler is invoked whenever there are changes to the nodes
// matching any of the patterns.
// There are three cases when it is triggered:
// 1) updateTerritory was invoked by us.
// 2) Another client made changes to nodes within the territory.
// 3) We made changes to any of the nodes (via the setters).
function eventHandler(events) {
var i,
nodeObj;
for (i = 0; i < events.length; i += 1) {
if (events[i].etype === 'load') {
// The node is loaded and we have access to it.
// It was either just created or this is the initial
// updateTerritory we invoked.
nodeObj = client.getNode(events[i].eid);
} else if (events[i].etype === 'update') {
// There were changes made to the node (or any of its bases, meta-types and/or reverse relationships).
// The node is still loaded and we have access to it.
nodeObj = client.getNode(events[i].eid);
} else if (events[i].etype === 'unload') {
// The node was removed from the model (we can no longer access it).
// We still get the path/id via events[i].eid
} else {
// "Technical events" not used.
}
}
}
var userId = client.addUI(null, eventHandler);</code></pre>
<h4 class="name" id="canRedo"><span class="type-signature"></span>canRedo<span class="signature">(branchName)</span><span class="type-signature"> → {<a href="global.html#boolean">boolean</a>}</span></h4>
<div class="description">
<p>Returns true if the provided branchName matches the selected and if there were no commits after the
previous undo.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>branchName</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="description last"><p>Must match the active branch.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="docs_client.doc.js.html">docs/client.doc.js</a>, <a href="docs_client.doc.js.html#line654">line 654</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>True if it's fine to call client.redo()</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#boolean">boolean</a></span>
</dd>
</dl>
<h4 class="name" id="canUndo"><span class="type-signature"></span>canUndo<span class="signature">(branchName)</span><span class="type-signature"> → {<a href="global.html#boolean">boolean</a>}</span></h4>
<div class="description">
<p>Returns true if the provided branchName matches the selected and if the current user did made the latest
change.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>branchName</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="description last"><p>Must match the active branch.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="docs_client.doc.js.html">docs/client.doc.js</a>, <a href="docs_client.doc.js.html#line644">line 644</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>True if it's fine to call client.undo()</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#boolean">boolean</a></span>
</dd>
</dl>
<h4 class="name" id="clearMetaRules"><span class="type-signature"></span>clearMetaRules<span class="signature">(path, msg<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Removes all Meta rules from the node (does not have effect on the inherited rules).</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>path</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the path/id of the node that will be modified.</p></td>
</tr>
<tr>
<td class="name"><code>msg</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>optional commit message, if not supplied a default one with the
function name and input parameters will be used</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="client_gmeNodeSetter.js.html">client/gmeNodeSetter.js</a>, <a href="client_gmeNodeSetter.js.html#line1114">line 1114</a>
</li></ul></dd>
</dl>
<h4 class="name" id="closeProject"><span class="type-signature"></span>closeProject<span class="signature">(callback)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Closes the currently selected project. If a branch is opened it will be closed as well.
Will resolve with error if no project is opened.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="description last"><p>Invoked when request completed.</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>err</code></td>
<td class="type">
<span class="param-type"><a href="global.html#null">null</a></span>
|
<span class="param-type"><a href="global.html#Error">Error</a></span>
</td>
<td class="description last"><p>If the request failed.</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="docs_client.doc.js.html">docs/client.doc.js</a>, <a href="docs_client.doc.js.html#line413">line 413</a>
</li></ul></dd>
</dl>
<h5>Fires:</h5>
<ul>
<li><a href="Client.html#event:PROJECT_CLOSED">Client#event:PROJECT_CLOSED</a></li>
<li><a href="Client.html#event:BRANCH_CLOSED">Client#event:BRANCH_CLOSED</a></li>
<li><a href="Client.html#event:BRANCH_CHANGED">Client#event:BRANCH_CHANGED</a></li>
</ul>
<h4 class="name" id="completeTransaction"><span class="type-signature"></span>completeTransaction<span class="signature">(msg<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Completes any open transaction and persists the changes to server.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>msg</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
']'
</td>
<td class="description last"><p>End of commit-message.</p></td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>Optional callback that's invoked when the commit has reached the server.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="docs_client.doc.js.html">docs/client.doc.js</a>, <a href="docs_client.doc.js.html#line232">line 232</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>var nodeId = 'someIdToANodeThatIsLoaded';
client.startTransaction('start of commitMessage');
// While transaction is open nothing will be committed to the server.
client.setAttributes(nodeId, 'name', 'newName', 'changes within the transaction');
client.setRegistry(nodeId, 'position', {x: 100, y:200}, 'some more changes');
// When we have made all of our changes we make a single commit.
client.completeTransaction('end of commitMessage', function (err, result) {
// Here we have the option to get notified when the commit has reached the server
// and been persisted in the database.
// The commit hash of the new state of our model.
console.log(result.hash);
// If we are working in a branch - this is the status of our commit.
// 'SYNCED', 'FORKED'.
console.log(result.status);
});</code></pre>
<h4 class="name" id="connectToDatabase"><span class="type-signature"></span>connectToDatabase<span class="signature">(callback)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Establishes a websocket-connection to the storage/database on the server. If already connected - it will
resolve immediately. Note that the client itself attempts to reconnect on unintended disconnections. To monitor the
status register for the client.CONSTANTS.NETWORK_STATUS_CHANGED event.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type"><a href="global.html#function">function</a></span>
</td>
<td class="description last"><p>Invoked when request completed.</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>err</code></td>
<td class="type">
<span class="param-type"><a href="global.html#null">null</a></span>
|
<span class="param-type"><a href="global.html#Error">Error</a></span>
</td>
<td class="description last"><p>If the request failed.</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="docs_client.doc.js.html">docs/client.doc.js</a>, <a href="docs_client.doc.js.html#line364">line 364</a>
</li></ul></dd>
</dl>
<h5>Fires:</h5>
<ul>
<li><a href="Client.html#event:NETWORK_STATUS_CHANGED">Client#event:NETWORK_STATUS_CHANGED</a></li>
</ul>
<h4 class="name" id="copyMoreNodes"><span class="type-signature"></span>copyMoreNodes<span class="signature">(parameters, msg<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Copies the given nodes into the parent (does not enforce meta-rules
and requires all participating nodes to be loaded in the client)</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>parameters</code></td>
<td class="type">
<span class="param-type"><a href="global.html#object">object</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the parameters holding parentId and nodes to be copied
indexed by their ids/paths (see example)</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>parentId</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="description last"><p>the id/path of the parent where the new copies should be created</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>msg</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>optional commit message, if not supplied a default one with the
function name and input parameters will be used</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="client_gmeNodeSetter.js.html">client/gmeNodeSetter.js</a>, <a href="client_gmeNodeSetter.js.html#line230">line 230</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>client.copyMoreNodes({
parentId: '',
'/4': {},
'/5': {
attributes: {
name: 'MyNamedCopy'
},
registry: {
position: {x: 100, y:100}
}
}
}, 'Copied two nodes with some additional init data.');</code></pre>
<h4 class="name" id="copyNode"><span class="type-signature"></span>copyNode<span class="signature">(path, parentId, desc<span class="signature-attributes">opt</span>, msg<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="GMENode.html">GMENode</a>|<a href="global.html#undefined">undefined</a>}</span></h4>
<div class="description">
<p>Copies the given node into parent
(does not enforce meta-rules and requires all participating nodes to be loaded in the client)</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>path</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the id/path of the node to copy</p></td>
</tr>
<tr>
<td class="name"><code>parentId</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the id/path of the parent where the new copy should be created</p></td>
</tr>
<tr>
<td class="name"><code>desc</code></td>
<td class="type">
<span class="param-type"><a href="global.html#object">object</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
{}
</td>
<td class="description last"><p>named attributes and/or registries to set for the new node (see example)</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>attributes</code></td>
<td class="type">
<span class="param-type"><a href="global.html#object">object</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
{}
</td>
<td class="description last"><p>named attributes to set for the new node</p></td>
</tr>
<tr>
<td class="name"><code>registry</code></td>
<td class="type">
<span class="param-type"><a href="global.html#object">object</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
{}
</td>
<td class="description last"><p>named registries to set for the new node</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>msg</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>optional commit message, if not supplied a default one
with the function name and input parameters will be used</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="client_gmeNodeSetter.js.html">client/gmeNodeSetter.js</a>, <a href="client_gmeNodeSetter.js.html#line181">line 181</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>the newly created node if it could be copied</li>
</ul>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="GMENode.html">GMENode</a></span>
|
<span class="param-type"><a href="global.html#undefined">undefined</a></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>var nodeCopy1 = client.copyNode('/4', '');
var nodeCopy2 = client.copyNode('/4', '', {
attributes: {
name: 'CopiedNode'
},
registry: {
position: {x: 100, y: 100}
}
}, 'Created node with specific name and position.');</code></pre>
<h4 class="name" id="copyNodes"><span class="type-signature"></span>copyNodes<span class="signature">(paths, parentId, msg<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="global.html#Array">Array</a>.<<a href="GMENode.html">GMENode</a>>|<a href="global.html#undefined">undefined</a>}</span></h4>
<div class="description">
<p>Copies the given nodes into the parent
(does not enforce meta-rules and requires all participating nodes
to be loaded in the client)</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>paths</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Array">Array</a>.<<a href="global.html#string">string</a>></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>array of the ids/paths of the nodes to copy</p></td>
</tr>
<tr>
<td class="name"><code>parentId</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the id/path of the parent where the new copies should be created</p></td>
</tr>
<tr>
<td class="name"><code>msg</code></td>
<td class="type">
<span class="param-type"><a href="global.html#string">string</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>optional commit message, if not supplied a default one with
the function name and input
parameters will be used</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="client_gmeNodeSetter.js.html">client/gmeNodeSetter.js</a>, <a href="client_gmeNodeSetter.js.html#line2272">line 2272</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><p>For reference check the correspondent
Core function <a href="Core.html#copyNodes">copyNodes</a></p></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="para