new Element(graph, objAttrs, isProcess) → {object}
Properties:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
graph |
object | Contains the main Graph instance to be used for the operation on the Element. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
id |
string | Contains the id of the Element. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
nLevel |
number | Contains the nesting level of the Element. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
runtimes |
object | Contains the run times information of the Element. Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
scope |
enum | Contains scope of the Element, default is "private". Element can also be set a "shared", this is used in creating the connections from with in process to outer scope. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
sharedId |
string | if an Element is shared then its id is stored here to be used in generating the XML. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
type |
enum | Stores the type of Element, i-e "event" or "process" . |
|||||||||||||||||||||||||||||||||||||||||||||||||||
custom |
object | Stores all the custom properties of the Elements stored in the custom section of the standard DCR XML structure. Properties
|
Main Element Class, it will be used to create Events or Processes
Parameters:
Name | Type | Description |
---|---|---|
graph |
object | A graph object of the current application is passed so it can be used to update the garph easily. |
objAttrs |
object | These are the main object attributes provided by user they can be custom but XML writing for custum attributes is not supported by CORE library yet. |
isProcess |
boolean | This is used to create either an event or a processes possible values can be true, false. |
Returns:
Returns Element Object.
- Type
- object
Methods
(static) addHighlight() → {Highlight}
Add Highlight to an Element of graph, e-g: activity, process, form.
Returns:
- An object of
Highlight
class.
- Type
- Highlight
(static) connectFrom(from, type, guard, level, desc) → {object}
Function to create a connection from one object to another object, similar to connectTo but this is inverse of it as this selects the calling object as target and the object passed as source.
Example
var myApp = new DCR();
myApp.createEvent({'id':'Exit'}).connectFrom(myApp.createEvent({'id':'Enter'}), 'condition');
//this will create an Event Element Enter and Exit, then we can use the function to create a condition connection between two.
Parameters:
Name | Type | Description |
---|---|---|
from |
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) connectTo(to, type, guard, level, desc) → {object}
Function to create a connection from one object to another object
Example
var myApp = new DCR();
myApp.createEvent({'id':'Enter'}).connectTo(myApp.createEvent({'id':'Exit'}), 'response');
//this will create an Event Element Enter and Exit, then we can use the function to create a response connection between two.
Parameters:
Name | Type | Description |
---|---|---|
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) createConnection(secObj, type, isFrom, guard, level, desc) → {object}
Function to create a connection from one object to another object or vice versa
Example
var myApp = new DCR();
myApp.createEvent({'id':'Enter'});
myApp.createEvent({'id':'Enter'}).createConnection(myApp.createEvent({'id':'Exit'}), 'response', true);
//this will create an Event Element Enter and Exit, then we can use the function to create a response connection between two setting source as Exit and target as Enter.
Parameters:
Name | Type | Description |
---|---|---|
secObj |
object | An Element object is passed as source/target element. |
type |
string | Connection type is passed as string so a connection can be identified, possible values are 'condition', 'response', 'include', 'exclude', 'milestone', 'spawn', 'update'. |
isFrom |
boolean | This value determines either to create connectoin to second object passed or from it, default connection will be to the second object. |
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) currentLevel() → {integer}
Function to get current Nested level of current Element.
Returns:
Returns the nesting level of current level.
- Type
- integer
(static) getBBox() → {object}
Function to get the bounding box of current Element.
Returns:
Returns an object containing x, y cordinates of current element along with height and width of it.
- Type
- object
(static) getChilds(skipProChilds) → {array}
Recursive Function to get all childs of current element.
Parameters:
Name | Type | Description |
---|---|---|
skipProChilds |
boolean | If this value is passed true then all the events with in the processes will be skipped and only those processes will be considered childs including their sibling events. |
Returns:
Returns an array of Element objects.
- Type
- array
(static) getConnections(fromOrTo, type) → {array}
Function to get all to/from Connections of an Element object.
Examples
var myApp = new DCR();
myApp.createEvent({'id':'Exit'}).connectFrom(myApp.createEvent({'id':'Enter'}), 'condition');
myApp.getById('Exit').getConnections();
//this will get all the connections to/from the Exit Element
var myApp = new DCR();
myApp.createEvent({'id':'Exit'}).connectFrom(myApp.createEvent({'id':'Enter'}), 'condition');
myApp.getById('Exit').getConnections(true);
//this will get all the connections to the Exit Element
var myApp = new DCR();
myApp.createEvent({'id':'Exit'}).connectTo(myApp.createEvent({'id':'Enter'}), 'condition');
myApp.getById('Exit').getConnections(false);
//this will get all the connections from the Exit Element
var myApp = new DCR();
myApp.createEvent({'id':'Exit'}).connectTo(myApp.createEvent({'id':'Enter'}), 'condition');
myApp.getById('Exit').connectTo(myApp.createEvent({'id':'New'}), 'response');
myApp.getById('Exit').getConnections(false);
//this will get all the connections from the Exit Element
Parameters:
Name | Type | Description |
---|---|---|
fromOrTo |
boolean | Getting to or from connections according to type provided, if passed true from connections will be returned, if false is passed then to will be returned if nothing is passed then all will be returned. |
type |
string | Connection type is passed as string so a connection can be identified, possible values are 'condition', 'response', 'include', 'exclude', 'milestone', 'spawn'. |
Returns:
Returns an array of Element object to/from which connections are associated
- Type
- array
(static) getDirectChilds() → {array}
Function to get only direct child of current element.
Returns:
Returns an array of Element objects.
- Type
- array
(static) getHighlights() → {array}
Get Highlights related to a Element of graph, e-g: activity, process, form.
Returns:
- An array of graph Highlights.
- Type
- array
(static) getParent() → {object|null}
Function to return the direct parent of a child Element
Returns:
Returns an Element object.
- Type
- object | null
(static) getParentForm() → {object|null}
Function to get the parent form of current Element.
Returns:
Returns an object of Element objects or null.
- Type
- object | null
(static) getParentProcess() → {object|null}
Function to get the parent process of current Element.
Returns:
Returns an object of Element objects or null.
- Type
- object | null
(static) getParents() → {array}
Function to get all parents of current element.
Returns:
Returns an array of Element objects.
- Type
- array
(static) getRuntime(eRuntime) → {boolean|null}
Function to get the the default runtimes of current Element.
Parameters:
Name | Type | Description |
---|---|---|
eRuntime |
string | The runtime for which the value to get against of current element. possible values are: 'included', 'pending', 'executed'. |
Returns:
Returns a value of requested property or null.
- Type
- boolean | null