new Graph() → {object}
Properties:
Name | Type | Description |
---|---|---|
XML |
string | Stores the XML of the graph. |
Events |
array | Stores all the events of graph as objects of Element Class. |
ExternalEvents |
array | Stores all external events of graph while loading the XML of the graph, its items are in XML format. |
Processes |
array | Stores all the Processes of graph as objects of Element Class. |
Parents |
array | Stores Parent elements of graph as objects of Element Class. |
Childs |
array | Stores all Child elements of graph as an array which has child object (instance of Element Class) on 0 index and a string id of its parent object on index 1. |
Connections |
array | Array to store All Connections of graph as objects of Connection Class. |
AllConnections |
array | This array is used as temporary container to store all the connections from XML on loading for supporting Nesting levels. |
Roles |
array | Array to store All Roles of graph in string format. |
Groups |
array | Array to store All Groups of graph in string format. |
AllParameters |
array | This array is used for temporary purposes on loading the graph XML to store all the parameters of the graph supporting Nesting levels. |
Parameters |
array | Array to store All the Unique Parameters of graph as an object {id: "a", type: "variable", value: "10"}. |
AllParametersSim |
array | This array is used for temporary purposes on loading the graph XML to storing all the parameters of simulation in the graph supporting Nesting levels. |
ParametersSim |
array | Array to store All the Unique Parameters for simulation of graph as an object {id: "a", type: "variable", value: "10"}. |
EventTypes |
array | Stores Event Types of graph as strings. |
Title |
string | Contains the Title of Graph. |
Description |
string | Contains Description for the Graph. |
Documentation |
string | Contains Documentation for the Graph. |
ZoomLevel |
number | An integer of values -9 to 9 ranging (10% to 190%). |
FilterLevel |
number | Array to store All Connections of graph. |
FilterRoles |
array | Array to store All Roles in string format for filteration of graph. |
FilterGroups |
array | Array to store All Groups in string format for filteration of graph. |
eCount |
number | Contains Events count. |
pCount |
number | Contains Processes count. |
ProcessedPs |
array | Temporary container used in loading of graph XML so once traversed processes are not traversed again. |
ProcessedProcesses |
array | Temporary container used in writing of graph XML so once XML of processes is writter they are not used again as recursive functions are used for supporting N level of nesting. |
ProcessedEvents |
array | Temporary container used in writing of graph XML so once XML of Events is written they are not used again as recursive functions are used for supporting N level of nesting. |
AllSharedEvents |
array | While witing XML shared events are stored in this array to be used later. |
Core Class to handle the Graph Operations.
This will be returned by the main DCR function to be utilized by the users or apps.
Graph Prototype will have the most common graph related functions, such as load/write XML
users can extend this class prototype in plugins.
Returns:
Returns Graph Object.
- Type
- object
Methods
(static) addHighlight() → {Highlight}
Add Highlight to graph.
Returns:
- An object of
Highlight
class.
- Type
- Highlight
(static) addHighlightLayer() → {HighlightLayer}
Add Highlight layer to graph.
Returns:
- An object of
HighlightLayer
class.
- Type
- HighlightLayer
(static) createConnection(from, to, type, guard, level, desc) → {object}
Function to to create a Connection in graph, if connection is strong condition, create a condition and a milestone with link
Example
var myApp = new DCR();
myApp.createEvent({'id':'Enter'});
myApp.createEvent({'id':'Exit'});
myApp.createConnection(myApp.getById('Enter'), myApp.getById('Exit'), 'response');
//this will create an Event Element Enter and Exit, then we can use the app to create a response connection between two by finding them by their Ids.
Parameters:
Name | Type | Description |
---|---|---|
from |
object | An element object is passed as source element from where connection will originate. |
to |
object | An element object is passed as target element to where connection will end up. |
type |
string | Connection type is passed as string so a connection can be identified, possible values are 'condition', 'response', 'include', 'exclude', 'milestone', 'spawn', 'update'. |
guard |
string | Guard for the connection as string. |
level |
number | filter level of the connection greater than or equal to Zero. |
desc |
string | Description of the connection as string. |
Returns:
Returns an object of Connection Class.
- Type
- object
(static) createEvent(el) → {object}
Function to to create an Events in graph
Example
var myApp = new DCR();
myApp.createEvent(); //this will create a simple event
myApp.createEvent({'custom' : {'label':'An Event', 'eventDescription':'This is a test Event'}});
//we can also provide attributes for the event object like above
Parameters:
Name | Type | Description |
---|---|---|
el |
object | An object can be passed with properties assign to it, see example |
Returns:
Returns an object of Element Class.
- Type
- object
(static) createForm(el) → {object}
Function to to create Form in graph
Example
var myApp = new DCR();
myApp.createForm(); //this will create a simple process
myApp.createForm({'custom' : {'label':'A Form', 'eventDescription':'This is a test Form'}});
//we can also provide attributes for the process object like above, most of the properties of events and processes are same so we can use the same properties here
Parameters:
Name | Type | Description |
---|---|---|
el |
object | An object can be passed with properties assign to it, see example |
Returns:
Returns an object of Element Class.
- Type
- object
(static) createFragment(el) → {object}
Function to to create Fragment in graph
Example
var myApp = new DCR();
myApp.createFragment(); //this will create a simple process
myApp.createFragment({'custom' : {'label':'A Form', 'eventDescription':'This is a test Form'}});
//we can also provide attributes for the process object like above, most of the properties of events and processes are same so we can use the same properties here
Parameters:
Name | Type | Description |
---|---|---|
el |
object | An object can be passed with properties assign to it, see example |
Returns:
Returns an object of Element Class.
- Type
- object
(static) createProcess(el) → {object}
Function to to create Process in graph
Example
var myApp = new DCR();
myApp.createProcess(); //this will create a simple process
myApp.createProcess({'custom' : {'label':'A Process', 'eventDescription':'This is a test Process'}});
//we can also provide attributes for the process object like above, most of the properties of events and processes are same so we can use the same properties here
Parameters:
Name | Type | Description |
---|---|---|
el |
object | An object can be passed with properties assign to it, see example |
Returns:
Returns an object of Element Class.
- Type
- object
(static) export() → {object}
Main funtion to export DCR XML.
Returns:
Returns XML as string of Graph.
- Type
- object
(static) findActivity(id) → {object}
Function to search events in a graph
Example
var myApp = new DCR();
myApp.createEvent({'id':'An Event', 'custom' : {'label': 'test item'}});
myApp.findActivity('An Event');
//returns Element
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Id of the object to be found, value is case sensitive. |
Returns:
Returns the first item found as an object of Element class or returns null.
- Type
- object
(static) generateHighlightXML() → {string}
Generates Highlights XML markup for highlights
Example
<highlighterMarkup>
<highlightLayers>
<highlightLayer default="true" name="description">... highlight text here ...</highlightLayer>
</highlightLayers>
<highlights>
... highlight xml here ...
</highlights>
</highlighterMarkup>
Returns:
- Highlight markup for DCR containing layers and highlights within it.
- Type
- string
(static) getAllLevels() → {array}
Function to get all the Filter levels currently available.
Example
var myApp = new DCR();
myApp.createEvent({'custom' : {'label':'An Event', 'level':2}});
myApp.createEvent({'custom' : {'label':'Another Event', 'level':5}});
myApp.getAllLevels();
//returns [2, 5]
Returns:
Returns an array of numbers containing the filter levels available in graph.
- Type
- array
(static) getById(id) → {object}
Function to search events/processes in a graph
Example
var myApp = new DCR();
myApp.createEvent({'id':'An Event', 'custom' : {'label': 'test item'}});
myApp.getById('An Event');
//returns Element
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Id of the object to be found, value is case sensitive. |
Returns:
Returns the first item found as an object of Element class.
- Type
- object
(static) getDefaultHighlightLayer() → {HighlightLayer}
Get default Highlight layer of graph, it will add a new layer if graph doesn't have any layer.
Returns:
- An object of
HighlightLayer
class or return undefined.
- Type
- HighlightLayer
(static) getEscapedHighlighterText() → {string}
Get escaped text of Highlight layer to be used as base text to be embeded in DOM
Returns:
- Returns text of default HighlightLayer or Graph Description
- Type
- string
(static) getEventsByLevel(sLevel, proToo) → {array}
Function to get all the events by a specific level
Example
var myApp = new DCR();
myApp.createEvent({'custom' : {'label':'An Event', 'level':2}});
myApp.createEvent({'custom' : {'label':'Another Event','level':5}});
myApp.getEventsByLevel(5);
//returns [Element]
Parameters:
Name | Type | Description |
---|---|---|
sLevel |
number | Value of the level of which events are to be find. |
proToo |
boolean | Requires True to find Processes too. |
Returns:
Returns an array of Element Class object which have the specified level assigned to them in graph.
- Type
- array
(static) getEventsByRole(sRole) → {array}
Function to get all the events by a specific role.
Example
var myApp = new DCR();
myApp.createEvent({'custom' : {'label':'An Event', 'roles':['test']}});
myApp.createEvent({'custom' : {'label':'Another Event','roles':['test']}});
myApp.getEventsByRole('test');
//returns [Element, Element]
Parameters:
Name | Type | Description |
---|---|---|
sRole |
string | Name of the role for which to search Events against. |
Returns:
Returns an array of Element Class object which have the specified role assigned to them in graph.
- Type
- array
(static) getHighlightByGUID(id) → {object}
Get a Highlight in graph by using its GUID.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | GUID of the highlight to get. |
Returns:
- Returns Highlight Object, or undefined if no item found.
- Type
- object
(static) getHighlighterText(layer) → {string}
Get text of Highlight layer, for now it will return the text of ist default layer found, or graph description if none found.
Parameters:
Name | Type | Description |
---|---|---|
layer |
object | HighlightLayer object to get text of, //optional for now as it is to be implemented later with layer full support |
Returns:
- Returns text of default HighlightLayer or Graph Description
- Type
- string
(static) getInterfaceEvents() → {array}
Function to get all interface Events
Example
var myApp = new DCR();
myApp.getInterfaceEvents({'interfaceEvent': true, 'custom' : {'label':'An Event', 'level':2}});
myApp.createEvent({'custom' : {'label':'Another Event','level':5}});
myApp.getInterfaceEvents();
//returns [Element]
Returns:
Returns an array of Element Class object which are interface Events in graph.
- Type
- array
(static) getMaxNLevel() → {Number}
Function to get the number of Nesting levels currently available, this number is generated on the basis of nesting in the graph to find out to which extant nesting is occuring. Base starts from 0 to N level of nesting
Returns:
Returns the maximum number of the nesting level.
- Type
- Number
(static) getMaxSequence() → {Number}
Function to get the number of Sequence number currently available. Base starts from 0
Returns:
Returns the maximum number of the sequence number.
- Type
- Number
(static) import(graphXML, graphID, configs, options, callback) → {object}
Main function to import DCR XML and populate the graph with XML data.
Parameters:
Name | Type | Description |
---|---|---|
graphXML |
string | XML of graph to be imported |
graphID |
number | Used for creating forms/processes |
configs |
object | Main configs |
options |
object | Import options |
callback |
function | Function to be called after import is done |
Returns:
Returns an object of Graph Class.
- Type
- object
(static) intializeGraphXml(graphXml, callback) → {object}
The function will make an ajax request to dcrgraphs.net api to initialize the graph and if successful it will callback the function provided
Example
var myApp = new DCR();
myApp.intializeGraphXml(xml);
//if the request is made successful then this will load the graph ready to be used
Parameters:
Name | Type | Description |
---|---|---|
graphXml |
string | Requires DCR Graph id from dcrgraphs.net to load the graph XML |
callback |
function | This function will be executed when the Graph will be successfully loaded after ajax request |
Returns:
Returns an object of Graph Class.
- Type
- object
(static) loadGraph(graphId, callback) → {object}
Main funtion to get a DCR graph based on the id of the graph. The function will make an ajax request to dcrgraphs.net api to get the graph details and if successful it will load the xml of graph
Example
var myApp = new DCR();
myApp.loadGraph(2275);
//if the request is made successful then this will load the graph ready to be used
Parameters:
Name | Type | Description |
---|---|---|
graphId |
number | Requires DCR Graph id from dcrgraphs.net to load the graph XML |
callback |
function | This function will be executed when the Graph will be successfully loaded after ajax request |
Returns:
Returns an object of Graph Class.
- Type
- object
(static) loadXML(graphXML) → {object}
Main funtion to load the DCR XML and populate the graph with XML data. The standard DCR Graph XML structure will be needed to properly load the Graph
Parameters:
Name | Type | Description |
---|---|---|
graphXML |
string | Requires DCR Graph XML in XML format to load the graph |
Returns:
Returns an object of Graph Class.
- Type
- object
(static) loadXMLString(graphXML) → {object}
Main funtion to load the DCR XML and populate the graph with XML data. The standard DCR Graph XML structure will be needed to properly load the Graph
Example
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Demo App</title>
</head>
<body>
<script src="jquery.js"></script>
<script src="xml2json.js"></script>
<script src="DCR.js"></script>
<script>
$(document).ready(function () {
var myApp = new DCR();
$('#loadGraph').on('click', function () {
var fileXML = $('#xmlInput').val();
if(fileXML==" " || fileXML == ""){
alert('Invalid Input');
return;
}
myApp.loadXMLString(fileXML);
//graph will reset first by default by this function just in case user clicks several time
//so each time new graph is to be laoded properly
});
})
</script>
<textarea id="xmlInput"></textarea>
<input type="submit" id="loadGraph" value="Load DCR Graph" />
</body>
</html>
Parameters:
Name | Type | Description |
---|---|---|
graphXML |
string | Requires DCR Graph XML in string format to load the graph |
Returns:
Returns an object of Graph Class.
- Type
- object
(static) printXML() → {object}
Fucntion to print current XML of graph on the console
Example
var myApp = new DCR();
myApp.loadGraph(2275);
myApp.printXML();
//we can get the latest XML of the graph through the above command
Returns:
Returns an object of Graph Class.
- Type
- object
(static) removeHighlightsOf(item)
Removes the item from Highlights, if there are no more Items in Highlight then Highlight will also be removed
Parameters:
Name | Type | Description |
---|---|---|
item |
object | An object either of Class |
(static) reset() → {object}
Function to reset the graph and its properties
Example
var myApp = new DCR();
myApp.createEvent(); //An Event will be added to the graph.
myApp.reset(); // will reset the graph.
Returns:
Returns an object of Graph Class.
- Type
- object
(static) setupHighlighterMarkup(textContainerId)
Creates the markup required for current app to work with in HTML format, so that app still works as it is
Parameters:
Name | Type | Description |
---|---|---|
textContainerId |
string | Id of the element in which HTML markup is to be generated. |
(static) updateMarkup(textContainerId)
Updates the range postions if the HTML is edited in Highlighter app.
Parameters:
Name | Type | Description |
---|---|---|
textContainerId |
string | Id of the element in which HTML markup is to be generated. |
(static) writeXML() → {object}
Main function to generate the graph XML based on the data in the graph properties, as this function is called the XML of graph is also updated to latest changes in the graph data
Example
var myApp = new DCR();
myApp.loadGraph(2275);
myApp.createEvent({'custom' : {'label':'An Event'}});
myApp.writeXML();
//we can get the latest XML of the graph through the above command
Returns:
Returns an object of Graph Class.
- Type
- object