2015-10-26 08:03:30 +01:00
|
|
|
|
2017-09-10 19:41:34 +08:00
|
|
|
import { logger } from '../../logger'
|
|
|
|
|
2017-04-11 22:14:25 +08:00
|
|
|
var relations = []
|
2015-10-26 08:03:30 +01:00
|
|
|
|
2017-04-11 22:14:25 +08:00
|
|
|
var classes
|
2015-11-15 15:06:24 +01:00
|
|
|
classes = {
|
2017-04-11 22:14:25 +08:00
|
|
|
}
|
2015-11-15 15:06:24 +01:00
|
|
|
|
2015-10-26 08:03:30 +01:00
|
|
|
/**
|
2015-12-27 14:18:21 +01:00
|
|
|
* Function called by parser when a node definition has been found.
|
2015-10-26 08:03:30 +01:00
|
|
|
* @param id
|
|
|
|
* @param text
|
|
|
|
* @param type
|
|
|
|
* @param style
|
|
|
|
*/
|
2017-09-10 21:23:04 +08:00
|
|
|
export const addClass = function (id) {
|
2017-04-11 22:14:25 +08:00
|
|
|
if (typeof classes[id] === 'undefined') {
|
|
|
|
classes[id] = {
|
|
|
|
id: id,
|
|
|
|
methods: [],
|
|
|
|
members: []
|
2015-10-26 08:03:30 +01:00
|
|
|
}
|
2017-04-11 22:14:25 +08:00
|
|
|
}
|
|
|
|
}
|
2015-10-26 08:03:30 +01:00
|
|
|
|
2017-09-10 21:23:04 +08:00
|
|
|
export const clear = function () {
|
2017-04-11 22:14:25 +08:00
|
|
|
relations = []
|
|
|
|
classes = {}
|
|
|
|
}
|
2015-10-26 08:03:30 +01:00
|
|
|
|
2017-09-10 21:23:04 +08:00
|
|
|
export const getClass = function (id) {
|
2017-04-11 22:14:25 +08:00
|
|
|
return classes[id]
|
|
|
|
}
|
2017-09-10 21:23:04 +08:00
|
|
|
export const getClasses = function () {
|
2017-04-11 22:14:25 +08:00
|
|
|
return classes
|
|
|
|
}
|
2015-10-29 07:49:08 +01:00
|
|
|
|
2017-09-10 21:23:04 +08:00
|
|
|
export const getRelations = function () {
|
2017-04-11 22:14:25 +08:00
|
|
|
return relations
|
|
|
|
}
|
2015-10-26 08:03:30 +01:00
|
|
|
|
2017-09-10 21:23:04 +08:00
|
|
|
export const addRelation = function (relation) {
|
2017-09-10 19:41:34 +08:00
|
|
|
logger.warn('Adding relation: ' + JSON.stringify(relation))
|
2017-09-10 21:23:04 +08:00
|
|
|
addClass(relation.id1)
|
|
|
|
addClass(relation.id2)
|
2017-04-11 22:14:25 +08:00
|
|
|
relations.push(relation)
|
|
|
|
}
|
2015-10-28 08:12:47 +01:00
|
|
|
|
2017-09-10 21:23:04 +08:00
|
|
|
export const addMembers = function (className, MembersArr) {
|
2017-04-11 22:14:25 +08:00
|
|
|
var theClass = classes[className]
|
|
|
|
if (typeof MembersArr === 'string') {
|
|
|
|
if (MembersArr.substr(-1) === ')') {
|
|
|
|
theClass.methods.push(MembersArr)
|
|
|
|
} else {
|
|
|
|
theClass.members.push(MembersArr)
|
2015-11-01 19:00:14 +01:00
|
|
|
}
|
2017-04-11 22:14:25 +08:00
|
|
|
}
|
|
|
|
}
|
2015-10-28 08:12:47 +01:00
|
|
|
|
2017-09-10 21:23:04 +08:00
|
|
|
export const cleanupLabel = function (label) {
|
2017-04-11 22:14:25 +08:00
|
|
|
if (label.substring(0, 1) === ':') {
|
|
|
|
return label.substr(2).trim()
|
|
|
|
} else {
|
|
|
|
return label.trim()
|
|
|
|
}
|
|
|
|
}
|
2015-11-11 13:16:38 +01:00
|
|
|
|
2017-09-10 21:23:04 +08:00
|
|
|
export const lineType = {
|
2017-04-11 22:14:25 +08:00
|
|
|
LINE: 0,
|
|
|
|
DOTTED_LINE: 1
|
|
|
|
}
|
2015-10-26 08:03:30 +01:00
|
|
|
|
2017-09-10 21:23:04 +08:00
|
|
|
export const relationType = {
|
2017-04-11 22:14:25 +08:00
|
|
|
AGGREGATION: 0,
|
|
|
|
EXTENSION: 1,
|
|
|
|
COMPOSITION: 2,
|
|
|
|
DEPENDENCY: 3
|
|
|
|
}
|