-
Notifications
You must be signed in to change notification settings - Fork 0
/
asset.js
156 lines (118 loc) · 4.89 KB
/
asset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
var assetLinks = function(user) {
return {
title: 'Chevron'
};
};
asset.manager = function(ctx) {
return {
create: function(options) {
log.info("Entered");
var ref = require('utils').time;
var GovernanceConstants = Packages.org.wso2.carbon.governance.api.util;
//Check if the options object has a createdtime attribute and populate it
if ((options.attributes) && (options.attributes.hasOwnProperty('overview_createdtime'))) {
options.attributes.overview_createdtime = ref.getCurrentTime();
}
this._super.create.call(this, options);
// log.info(options);
var asset = this.get(options.id);
log.info(asset);
for (var key in this.registry) {
log.info('key: ' + key);
}
//TODO
/* var user = require('store').user;
var reg = user.userRegistry(session);
reg.put(<PATH>,<CONTENT>); */
if (asset.attributes.properties_Associated_process_models != null) {
var tempArray1 = asset.attributes.properties_Associated_process_models.split("\,");
for (var i = 0; i < tempArray1.length; i++) {
var modelAsset = this.get(tempArray1[i]);
this.registry.associate(asset.path, modelAsset.path, "Associated process models");
log.info("associations process models");
}
}
if (asset.attributes.properties_owner != null) {
var tempArray1 = asset.attributes.properties_owner.split("\,");
for (var i = 0; i < tempArray1.length; i++) {
var ownerAsset = this.get(tempArray1[i]);
this.registry.associate(asset.path, ownerAsset.path, "Owner");
log.info("associations Owners");
}
}
//Adding Associatin for Process Name
if (asset.attributes.properties_name != null) {
var tempArray1 = asset.attributes.properties_name.split("\,");
for (var i = 0; i < tempArray1.length; i++) {
var nameAsset = this.get(tempArray1[i]);
this.registry.associate(asset.path, nameAsset.path, "Name");
log.info("associations Names");
}
}
//Adding Associatin for Predecessors
if (asset.attributes.properties_predecessors != null) {
var tempArray1 = asset.attributes.properties_predecessors.split("\,");
for (var i = 0; i < tempArray1.length; i++) {
var preAsset = this.get(tempArray1[i]);
this.registry.associate(asset.path, preAsset.path, "Predecessors");
log.info("associations Predecessors");
}
}
//Adding Associatin for properties_successor
if (asset.attributes.properties_successors != null) {
var tempArray4 = asset.attributes.properties_successors.split("\,");
for (var i = 0; i < tempArray4.length; i++) {
var sucAsset = this.get(tempArray4[i]);
this.registry.associate(asset.path, sucAsset.path, "Successors");
log.info("associations Successors");
}
}
/*Get info from the four fields and string split and add associations with special names*/
// this.registry.addAssociation(asset.path, path, GovernanceConstants.USED_BY);;
}
};
};
asset.server = function(ctx) {
var type = ctx.type;
return {
onUserLoggedIn: function() {},
endpoints: {
apis: [{
url: 'assets',
path: 'assets.jag'
}, {
url: 'processes',
path: 'processes.jag'
}],
pages: [{
title: 'Asset: ' + type,
url: 'asset',
path: 'asset.jag'
}, {}, {
title: 'Create ' + type,
url: 'create',
path: 'create.jag'
}, {
title: 'Update ' + type,
url: 'update',
path: 'update.jag'
}, {
title: 'Details ' + type,
url: 'details',
path: 'details.jag'
}, {
title: 'List ' + type,
url: 'list',
path: 'list.jag'
}, {
title: 'Lifecycle',
url: 'lifecycle',
path: 'lifecycle.jag'
}, {
title: 'Variant' + type,
url: 'variant',
path: 'variant.jag'
}]
}
};
};