Skip to content

Trails #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f10e971
First commit for the new Trails implementation
Aug 12, 2021
b01ee37
Avoid exposing List class from Trail module
Aug 12, 2021
bb80264
only exporting trail in trail.js
raphael-melo Aug 18, 2021
f6df1d8
Removing List from require
Aug 18, 2021
c717128
Adding in-memory functions
Aug 24, 2021
906b5ad
Adding fetch trail to hkdatasource
Aug 25, 2021
89dbdeb
Merge branch 'trails' of https://github.com/ibm-hyperknowledge/hklib …
Aug 25, 2021
6f1709c
Sorting actions based on timestamps
Sep 1, 2021
748073c
Trail Internals now appear on the Inspector
GabrielaPC Sep 8, 2021
1e62956
Improving use of linked-list lib for in-memory operations
Sep 21, 2021
97b10dd
Improving Action load with linked list
Sep 22, 2021
8bf4efa
Improving action class and its loading and sorting
Sep 24, 2021
07c724c
Removing unused require
Sep 25, 2021
8892edf
Added actions to hkgraph
GabrielaPC Nov 24, 2021
e47309f
Merge pull request #39 from ibm-hyperknowledge/actions
rbrandao Nov 24, 2021
f1af0da
this.actions.toArray is not a function bugfix
GabrielaPC Dec 13, 2021
ba8161d
Bugfix Trail.out not working with only one action
GabrielaPC Jan 19, 2022
dbb4b26
Merge remote-tracking branch 'origin/dev' into trails
Jun 15, 2022
43823a4
Merge bugfix
Jun 28, 2022
32c8870
Identation fix
eltonfss Jun 29, 2022
66c0f80
Added linked-list to HKLib
Jun 30, 2022
4cd8929
Merge branch 'trails-merge' of https://github.com/ibm-hyperknowledge/…
Jun 30, 2022
9e6f618
Trail build bugfix
Jun 30, 2022
7d229eb
fixed indentation
Jul 1, 2022
f0ab249
mend
Jul 1, 2022
adf93a0
undo mend
Jul 1, 2022
b3d170b
Merge branch 'trails-merge' of https://github.com/ibm-hyperknowledge/…
Jul 6, 2022
a43ca6d
Updated trail from function to class
Jul 11, 2022
c8e1c1f
edited linked-list import
Jul 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"ninja-util": "^1.3.1",
"request": "^2.88.0",
"request-promise-native": "^1.0.8",
"shortid": "^2.2.14"
"shortid": "^2.2.14",
"linked-list": "file:src/linked-list"
},
"license": "MIT",
"repository": {
Expand Down
49 changes: 48 additions & 1 deletion src/datasource/hkdatasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ class HKDatasource
}
});
}

/**
* Get entities from a context
*
Expand Down Expand Up @@ -584,6 +584,53 @@ class HKDatasource
});
}

/**
* @callback GetTrailCallback
* @param {string} err An error object that indicate if the operation was succesful or not
* @param {object} trail
*/
/**
* Fetch trail
*
* @param {string} trailId The trail id to retrieve their nested entities.
* @param {GetTrailCallback} callback Callback with the entities
*/

fetchTrail(trailId, callback = () => {})
{
let url = this.url + "repository/" + this.graphName + "/trail/" + encodeURIComponent(trailId);

request.get(url, this.options, (err, res) =>
{
// console.log(res.body);
if (!err)
{
if (requestCompletedWithSuccess(res.statusCode))
{
try
{
let entities = convertEntities(res.body);
callback(null, entities[trailId]);
}
catch (exp)
{
callback(exp);
}
}

else
{
callback(`Server responded with ${res.statusCode}. ${res.body}`);
}
}

else
{
callback(err);
}
});
}

/**
* Filter entities using CSS pattern `(TODO: document it better)`
*
Expand Down
31 changes: 28 additions & 3 deletions src/hkgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Reference = require("./reference");
const Trail = require("./trail");
const HKTypes = require("./types");
const shortId = require('shortid');
const { Action } = require("./trail");
const VirtualContext = require("./virtualcontext");
const HKEntity = require("./hkentity");
const VirtualNode = require("./virtualnode");
Expand All @@ -32,6 +33,8 @@ class HKGraph
this.connectors = {};
this.refs = {};
this.trails = {};
this.actions = {};

// Auxiliar maps
this.bindsMap = {};
this.linkMap = {};
Expand All @@ -55,7 +58,8 @@ class HKGraph
this.links.hasOwnProperty(id) ||
this.connectors.hasOwnProperty(id) ||
this.refs.hasOwnProperty(id) ||
this.trails.hasOwnProperty(id);
this.trails.hasOwnProperty(id) ||
this.actions.hasOwnProperty(id);
}

/**
Expand All @@ -82,7 +86,7 @@ class HKGraph
oldEntity.className = entity.className;
}

if (entity.type === HKTypes.NODE || entity.type === HKTypes.REFERENCE || entity.type === HKTypes.CONTEXT || entity.type === HKTypes.VIRTUAL_NODE || entity.type === HKTypes.VIRTUAL_CONTEXT)
if (entity.type === HKTypes.NODE || entity.type === HKTypes.TRAIL || entity.type === HKTypes.REFERENCE || entity.type === HKTypes.CONTEXT || entity.type === HKTypes.VIRTUAL_NODE || entity.type === HKTypes.VIRTUAL_CONTEXT || entity.type === HKTypes.ACTION)
{
oldEntity.interfaces = entity.interfaces;
}
Expand Down Expand Up @@ -218,9 +222,25 @@ class HKGraph
{
newEntity = new Trail(entity);
this.trails[entity.id] = newEntity;
this.contextMap[entity.id] = {};

if(this.orphans.hasOwnProperty(entity.id))
{
this.contextMap[entity.id] = this.orphans[entity.id];
delete this.orphans[entity.id];
}
}
break;
}
case HKTypes.ACTION:
{
if(entity instanceof Trail.Action)
{
newEntity = entity;
this.actions[entity.id] = newEntity;
}
break;
}
case HKTypes.LINK:
{
if (Link.isValid(entity))
Expand Down Expand Up @@ -439,8 +459,13 @@ class HKGraph
{
/* delete children trails? */
delete this.trails[id];
delete this.contextMap[entity.id];
break;
}
case Action.type:
{
delete this.actions[id];
}
}

if (this.orphans.hasOwnProperty(entity.parent))
Expand Down Expand Up @@ -612,7 +637,7 @@ class HKGraph
c.id = null;
return c;
}
return this.nodes[id] || this.virtualNodes[id] || this.contexts[id] || this.virtualContexts[id] || this.virtualLinks[id] || this.links[id] || this.connectors[id] || this.refs[id] || this.trails[id] || null;
return this.nodes[id] || this.virtualNodes[id] || this.contexts[id] || this.virtualContexts[id] || this.virtualLinks[id] || this.links[id] || this.connectors[id] || this.refs[id] || this.trails[id] || this.actions[id] || null;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ exports.CONNECTOR_TYPE = require("./types").CONNECTOR;
exports.BIND_TYPE = require("./types").BIND;
exports.INTERFACE = require("./types").INTERFACE;
exports.TRAIL_TYPE = require("./types").TRAIL;
exports.ACTION_TYPE = require("./types").ACTION;
exports.VIRTUAL_NODE_TYPE = require("./types").VIRTUAL_NODE;
exports.VIRTUAL_CONTEXT_TYPE = require("./types").VIRTUAL_CONTEXT;
exports.VIRTUAL_LINK_TYPE = require("./types").VIRTUAL_LINK;
Expand Down
Loading