프로젝트

일반

사용자정보

Nerv ICDE 20201104 » nerv_icde_install_20200728.sql

이용우, 2020/08/04 23:46

 
1
-- --------------------------------------------------------
2
-- 호스트:                          127.0.0.1
3
-- 서버 버전:                        5.5.62 - MySQL Community Server (GPL)
4
-- 서버 OS:                        Win64
5
-- HeidiSQL 버전:                  11.0.0.5919
6
-- --------------------------------------------------------
7

    
8
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
9
/*!40101 SET NAMES utf8 */;
10
/*!50503 SET NAMES utf8mb4 */;
11
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
12
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
13

    
14

    
15
-- nerv_icde_xxxx 데이터베이스 구조 내보내기
16
CREATE DATABASE IF NOT EXISTS `nerv_icde_xxxx` /*!40100 DEFAULT CHARACTER SET utf8 */;
17
USE `nerv_icde_xxxx`;
18

    
19
-- 테이블 nerv_icde_xxxx.component 구조 내보내기
20
CREATE TABLE IF NOT EXISTS `component` (
21
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
22
  `systemdomain_id` int(10) unsigned DEFAULT NULL,
23
  `name` varchar(255) DEFAULT NULL,
24
  `seq` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
25
  `description` varchar(255) DEFAULT NULL,
26
  PRIMARY KEY (`id`),
27
  KEY `FK_component_systemdomain_id` (`systemdomain_id`) USING BTREE,
28
  CONSTRAINT `FK_component_1` FOREIGN KEY (`systemdomain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
29
) ENGINE=InnoDB AUTO_INCREMENT=1129 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
30

    
31
-- 테이블 데이터 nerv_icde_xxxx.component:~0 rows (대략적) 내보내기
32
DELETE FROM `component`;
33
/*!40000 ALTER TABLE `component` DISABLE KEYS */;
34
/*!40000 ALTER TABLE `component` ENABLE KEYS */;
35

    
36
-- 테이블 nerv_icde_xxxx.custum_proxy 구조 내보내기
37
CREATE TABLE IF NOT EXISTS `custum_proxy` (
38
  `Id` int(11) NOT NULL AUTO_INCREMENT,
39
  `deploy_id` int(11) unsigned DEFAULT NULL,
40
  `proxy_interface_id` int(10) unsigned NOT NULL,
41
  `object_name` varchar(100) NOT NULL,
42
  `object_id` int(11) unsigned DEFAULT '0',
43
  `stub_object_id` int(11) unsigned DEFAULT NULL,
44
  `stub_ip` varchar(255) DEFAULT '0.0.0.0',
45
  `public` int(11) unsigned NOT NULL DEFAULT '0',
46
  `original_id` int(11) NOT NULL DEFAULT '0',
47
  `original_deployment_id` int(11) NOT NULL DEFAULT '0',
48
  PRIMARY KEY (`Id`),
49
  KEY `FK_custum_proxy_deployments` (`deploy_id`),
50
  KEY `FK_custum_proxy_proxy_interface_object` (`proxy_interface_id`,`object_name`),
51
  CONSTRAINT `FK_custum_proxy_deployments` FOREIGN KEY (`deploy_id`) REFERENCES `deployments` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
52
  CONSTRAINT `FK_custum_proxy_proxy_interface_object` FOREIGN KEY (`proxy_interface_id`, `object_name`) REFERENCES `proxy_interface_object` (`proxy_interface_id`, `object_name`) ON DELETE CASCADE ON UPDATE CASCADE
53
) ENGINE=InnoDB AUTO_INCREMENT=2305 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
54

    
55
-- 테이블 데이터 nerv_icde_xxxx.custum_proxy:~0 rows (대략적) 내보내기
56
DELETE FROM `custum_proxy`;
57
/*!40000 ALTER TABLE `custum_proxy` DISABLE KEYS */;
58
/*!40000 ALTER TABLE `custum_proxy` ENABLE KEYS */;
59

    
60
-- 테이블 nerv_icde_xxxx.custum_stub 구조 내보내기
61
CREATE TABLE IF NOT EXISTS `custum_stub` (
62
  `Id` int(11) NOT NULL AUTO_INCREMENT,
63
  `deploy_id` int(11) unsigned NOT NULL,
64
  `stub_interface_id` int(10) unsigned NOT NULL,
65
  `object_name` varchar(100) NOT NULL,
66
  `object_id` int(11) unsigned DEFAULT '0',
67
  `public` int(11) unsigned NOT NULL DEFAULT '0',
68
  `original_id` int(11) unsigned NOT NULL DEFAULT '0',
69
  `original_deployment_id` int(11) NOT NULL DEFAULT '0',
70
  PRIMARY KEY (`Id`),
71
  KEY `FK_custum_stub_deployments` (`deploy_id`),
72
  KEY `FK_custum_stub_stub_interface_object` (`stub_interface_id`,`object_name`),
73
  CONSTRAINT `FK_custum_stub_deployments` FOREIGN KEY (`deploy_id`) REFERENCES `deployments` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
74
  CONSTRAINT `FK_custum_stub_stub_interface_object` FOREIGN KEY (`stub_interface_id`, `object_name`) REFERENCES `stub_interface_object` (`stub_interface_id`, `object_name`) ON DELETE CASCADE ON UPDATE CASCADE
75
) ENGINE=InnoDB AUTO_INCREMENT=1401 DEFAULT CHARSET=utf8;
76

    
77
-- 테이블 데이터 nerv_icde_xxxx.custum_stub:~0 rows (대략적) 내보내기
78
DELETE FROM `custum_stub`;
79
/*!40000 ALTER TABLE `custum_stub` DISABLE KEYS */;
80
/*!40000 ALTER TABLE `custum_stub` ENABLE KEYS */;
81

    
82
-- 테이블 nerv_icde_xxxx.data 구조 내보내기
83
CREATE TABLE IF NOT EXISTS `data` (
84
  `data_auto_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
85
  `domain_id` int(10) unsigned NOT NULL,
86
  `name` varchar(100) NOT NULL,
87
  `type` enum('struct','alias','enum8_t','enum16_t','enum32_t','char_t','wchar_t','int8_t','int16_t','int32_t','int64_t','u_int8_t','u_int16_t','u_int32_t','u_int64_t','scaled8_t','scaled16_t','scaled32_t','scaled64_t','u_scaled8_t','u_scaled16_t','u_scaled32_t','u_scaled64_t','ieee754_32_t','ieee754_64_t','ieee754_80_t','ip_t','port_t','domain_t','pksize_t','second_t','psecond_t','packed_node_addr_t','packed_client_addr_t','packed_server_addr_t') NOT NULL,
88
  `real_data_auto_id` int(10) unsigned DEFAULT NULL,
89
  `scmin` varchar(100) NOT NULL DEFAULT '',
90
  `scmax` varchar(100) NOT NULL DEFAULT '',
91
  `seq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
92
  `description` mediumtext NOT NULL,
93
  `user_id` varchar(45) NOT NULL,
94
  `depth` int(10) unsigned NOT NULL DEFAULT '0',
95
  PRIMARY KEY (`data_auto_id`),
96
  UNIQUE KEY `domain_id_name` (`domain_id`,`name`),
97
  KEY `FK_data_data` (`real_data_auto_id`),
98
  KEY `type` (`type`),
99
  CONSTRAINT `FK_data_data` FOREIGN KEY (`real_data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE SET NULL ON UPDATE CASCADE,
100
  CONSTRAINT `FK_data_domain_data` FOREIGN KEY (`domain_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
101
) ENGINE=InnoDB AUTO_INCREMENT=528 DEFAULT CHARSET=utf8;
102

    
103
-- 테이블 데이터 nerv_icde_xxxx.data:~0 rows (대략적) 내보내기
104
DELETE FROM `data`;
105
/*!40000 ALTER TABLE `data` DISABLE KEYS */;
106
/*!40000 ALTER TABLE `data` ENABLE KEYS */;
107

    
108
-- 테이블 nerv_icde_xxxx.data_field 구조 내보내기
109
CREATE TABLE IF NOT EXISTS `data_field` (
110
  `data_auto_id` int(10) unsigned NOT NULL DEFAULT '0',
111
  `member_name` varchar(100) NOT NULL,
112
  `type` enum('const','alias','char_t','wchar_t','int8_t','int16_t','int32_t','int64_t','u_int8_t','u_int16_t','u_int32_t','u_int64_t','scaled8_t','scaled16_t','scaled32_t','scaled64_t','u_scaled8_t','u_scaled16_t','u_scaled32_t','u_scaled64_t','ieee754_32_t','ieee754_64_t','ieee754_80_t','ip_t','port_t','domain_t','pksize_t','second_t','psecond_t','packed_node_addr_t','packed_client_addr_t','packed_server_addr_t') DEFAULT NULL,
113
  `real_data_auto_id` int(10) unsigned DEFAULT NULL,
114
  `user_id` varchar(45) NOT NULL,
115
  `bitsize` int(10) unsigned DEFAULT '0',
116
  `scimin` varchar(100) DEFAULT '''''',
117
  `scimax` varchar(100) DEFAULT '''''',
118
  `arraytype` enum('NO','FIX','VARIABLE') NOT NULL DEFAULT 'NO',
119
  `arraysize` int(11) unsigned NOT NULL DEFAULT '0',
120
  `seq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
121
  `description` mediumtext NOT NULL,
122
  PRIMARY KEY (`data_auto_id`,`member_name`),
123
  KEY `FK_data_field_data_2` (`real_data_auto_id`),
124
  KEY `type` (`type`),
125
  CONSTRAINT `FK_data_field_data` FOREIGN KEY (`data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE CASCADE ON UPDATE CASCADE,
126
  CONSTRAINT `FK_data_field_data_2` FOREIGN KEY (`real_data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE SET NULL ON UPDATE CASCADE
127
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
128

    
129
-- 테이블 데이터 nerv_icde_xxxx.data_field:~0 rows (대략적) 내보내기
130
DELETE FROM `data_field`;
131
/*!40000 ALTER TABLE `data_field` DISABLE KEYS */;
132
/*!40000 ALTER TABLE `data_field` ENABLE KEYS */;
133

    
134
-- 테이블 nerv_icde_xxxx.deployments 구조 내보내기
135
CREATE TABLE IF NOT EXISTS `deployments` (
136
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT,
137
  `node_id` int(11) unsigned NOT NULL,
138
  `component_id` int(11) unsigned NOT NULL,
139
  `systemdomain_id` int(11) unsigned NOT NULL DEFAULT '0',
140
  `original_id` int(11) unsigned DEFAULT NULL,
141
  PRIMARY KEY (`Id`),
142
  KEY `FK_deployments_1` (`node_id`),
143
  KEY `FK_deployments_2` (`component_id`),
144
  KEY `deployments_ibfk_1` (`systemdomain_id`),
145
  KEY `Id_node_id` (`Id`,`node_id`),
146
  KEY `FK_deployments_deployments` (`original_id`),
147
  CONSTRAINT `deployments_ibfk_1` FOREIGN KEY (`systemdomain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
148
  CONSTRAINT `deployments_ibfk_2` FOREIGN KEY (`node_id`) REFERENCES `node` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
149
  CONSTRAINT `FK_deployments_1` FOREIGN KEY (`node_id`) REFERENCES `node` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
150
  CONSTRAINT `FK_deployments_2` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
151
  CONSTRAINT `FK_deployments_deployments` FOREIGN KEY (`original_id`) REFERENCES `deployments` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
152
) ENGINE=InnoDB AUTO_INCREMENT=723 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
153

    
154
-- 테이블 데이터 nerv_icde_xxxx.deployments:~0 rows (대략적) 내보내기
155
DELETE FROM `deployments`;
156
/*!40000 ALTER TABLE `deployments` DISABLE KEYS */;
157
/*!40000 ALTER TABLE `deployments` ENABLE KEYS */;
158

    
159
-- 테이블 nerv_icde_xxxx.deployments_bind 구조 내보내기
160
CREATE TABLE IF NOT EXISTS `deployments_bind` (
161
  `deployment_id` int(11) unsigned NOT NULL,
162
  `node_id` int(11) unsigned NOT NULL,
163
  `port` int(11) unsigned NOT NULL,
164
  `ip` varchar(255) NOT NULL DEFAULT '0',
165
  PRIMARY KEY (`deployment_id`,`node_id`,`port`,`ip`),
166
  KEY `FK_deployments_bind_network` (`node_id`,`port`,`ip`),
167
  CONSTRAINT `FK_deployments_bind_deployments` FOREIGN KEY (`deployment_id`, `node_id`) REFERENCES `deployments` (`Id`, `node_id`) ON DELETE CASCADE ON UPDATE CASCADE,
168
  CONSTRAINT `FK_deployments_bind_network` FOREIGN KEY (`node_id`, `port`, `ip`) REFERENCES `network` (`node_id`, `port`, `ip`) ON DELETE CASCADE ON UPDATE CASCADE
169
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
170

    
171
-- 테이블 데이터 nerv_icde_xxxx.deployments_bind:~0 rows (대략적) 내보내기
172
DELETE FROM `deployments_bind`;
173
/*!40000 ALTER TABLE `deployments_bind` DISABLE KEYS */;
174
/*!40000 ALTER TABLE `deployments_bind` ENABLE KEYS */;
175

    
176
-- 테이블 nerv_icde_xxxx.diagrame 구조 내보내기
177
CREATE TABLE IF NOT EXISTS `diagrame` (
178
  `Id` int(11) NOT NULL AUTO_INCREMENT,
179
  `domain_id` int(11) unsigned NOT NULL DEFAULT '0',
180
  `type` int(11) unsigned NOT NULL DEFAULT '0',
181
  `name` varchar(255) NOT NULL DEFAULT '',
182
  `description` mediumtext,
183
  PRIMARY KEY (`Id`),
184
  KEY `diagrame_ibfk_1` (`domain_id`),
185
  CONSTRAINT `diagrame_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
186
  CONSTRAINT `FK_diagrame_domainid` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
187
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
188

    
189
-- 테이블 데이터 nerv_icde_xxxx.diagrame:~0 rows (대략적) 내보내기
190
DELETE FROM `diagrame`;
191
/*!40000 ALTER TABLE `diagrame` DISABLE KEYS */;
192
/*!40000 ALTER TABLE `diagrame` ENABLE KEYS */;
193

    
194
-- 테이블 nerv_icde_xxxx.domain_data 구조 내보내기
195
CREATE TABLE IF NOT EXISTS `domain_data` (
196
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
197
  `uuid` char(36) NOT NULL,
198
  `upper_id` int(10) unsigned DEFAULT '0',
199
  `name` varchar(100) NOT NULL DEFAULT '',
200
  `user_id` varchar(45) NOT NULL,
201
  `public` tinyint(1) unsigned NOT NULL,
202
  `create_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
203
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
204
  `description` mediumtext,
205
  PRIMARY KEY (`id`),
206
  KEY `FK_upper_id` (`upper_id`) USING BTREE,
207
  KEY `FK_user_id` (`user_id`),
208
  CONSTRAINT `FK_domain_data_upper_id` FOREIGN KEY (`upper_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
209
  CONSTRAINT `FK_domain_data_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
210
) ENGINE=InnoDB AUTO_INCREMENT=190 DEFAULT CHARSET=utf8;
211

    
212
-- 테이블 데이터 nerv_icde_xxxx.domain_data:~1 rows (대략적) 내보내기
213
DELETE FROM `domain_data`;
214
/*!40000 ALTER TABLE `domain_data` DISABLE KEYS */;
215
INSERT INTO `domain_data` (`id`, `uuid`, `upper_id`, `name`, `user_id`, `public`, `create_date`, `last_update`, `description`) VALUES
216
	(0, '', 0, '', 'root', 0, '0000-00-00 00:00:00', '2017-11-06 09:46:30', NULL);
217
/*!40000 ALTER TABLE `domain_data` ENABLE KEYS */;
218

    
219
-- 테이블 nerv_icde_xxxx.domain_method 구조 내보내기
220
CREATE TABLE IF NOT EXISTS `domain_method` (
221
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
222
  `uuid` char(36) NOT NULL,
223
  `upper_id` int(10) unsigned DEFAULT '0',
224
  `name` varchar(100) NOT NULL,
225
  `user_id` varchar(45) NOT NULL,
226
  `public` tinyint(1) unsigned NOT NULL,
227
  `standard_port` smallint(5) unsigned NOT NULL,
228
  `description` mediumtext NOT NULL,
229
  `create_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
230
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
231
  PRIMARY KEY (`id`),
232
  KEY `FK_upper_id` (`upper_id`),
233
  KEY `FK_user_id` (`user_id`),
234
  CONSTRAINT `FK_domain_method_upper_id` FOREIGN KEY (`upper_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
235
  CONSTRAINT `FK_domain_method_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
236
) ENGINE=InnoDB AUTO_INCREMENT=224 DEFAULT CHARSET=utf8;
237

    
238
-- 테이블 데이터 nerv_icde_xxxx.domain_method:~1 rows (대략적) 내보내기
239
DELETE FROM `domain_method`;
240
/*!40000 ALTER TABLE `domain_method` DISABLE KEYS */;
241
INSERT INTO `domain_method` (`id`, `uuid`, `upper_id`, `name`, `user_id`, `public`, `standard_port`, `description`, `create_date`, `last_update`) VALUES
242
	(0, '', NULL, '', 'root', 0, 0, '', '0000-00-00 00:00:00', '2017-11-06 09:47:11');
243
/*!40000 ALTER TABLE `domain_method` ENABLE KEYS */;
244

    
245
-- 테이블 nerv_icde_xxxx.domain_system 구조 내보내기
246
CREATE TABLE IF NOT EXISTS `domain_system` (
247
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
248
  `uuid` char(36) NOT NULL DEFAULT '',
249
  `upper_id` int(10) unsigned DEFAULT NULL,
250
  `name` varchar(100) NOT NULL,
251
  `user_id` varchar(45) NOT NULL,
252
  `type` enum('router','switch','computer','sensor','system') NOT NULL,
253
  `public` tinyint(1) unsigned NOT NULL,
254
  `create_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
255
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
256
  `description` mediumtext NOT NULL,
257
  PRIMARY KEY (`id`),
258
  KEY `FK_upper_id` (`upper_id`),
259
  KEY `FK_user_id` (`user_id`),
260
  CONSTRAINT `FK_domain_system_2` FOREIGN KEY (`upper_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
261
  CONSTRAINT `FK_domain_system_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
262
) ENGINE=InnoDB AUTO_INCREMENT=341 DEFAULT CHARSET=utf8;
263

    
264
-- 테이블 데이터 nerv_icde_xxxx.domain_system:~1 rows (대략적) 내보내기
265
DELETE FROM `domain_system`;
266
/*!40000 ALTER TABLE `domain_system` DISABLE KEYS */;
267
INSERT INTO `domain_system` (`id`, `uuid`, `upper_id`, `name`, `user_id`, `type`, `public`, `create_date`, `last_update`, `description`) VALUES
268
	(0, '', NULL, '', 'root', 'router', 0, '0000-00-00 00:00:00', '2017-11-06 09:47:42', '');
269
/*!40000 ALTER TABLE `domain_system` ENABLE KEYS */;
270

    
271
-- 테이블 nerv_icde_xxxx.domain_system_logical_port 구조 내보내기
272
CREATE TABLE IF NOT EXISTS `domain_system_logical_port` (
273
  `domain_system_id` int(11) unsigned NOT NULL DEFAULT '0',
274
  `port_group` int(11) unsigned NOT NULL DEFAULT '0',
275
  PRIMARY KEY (`domain_system_id`,`port_group`) USING BTREE,
276
  CONSTRAINT `domain_system_logical_port_ibfk_1` FOREIGN KEY (`domain_system_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
277
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
278

    
279
-- 테이블 데이터 nerv_icde_xxxx.domain_system_logical_port:~1 rows (대략적) 내보내기
280
DELETE FROM `domain_system_logical_port`;
281
/*!40000 ALTER TABLE `domain_system_logical_port` DISABLE KEYS */;
282
INSERT INTO `domain_system_logical_port` (`domain_system_id`, `port_group`) VALUES
283
	(0, 0);
284
/*!40000 ALTER TABLE `domain_system_logical_port` ENABLE KEYS */;
285

    
286
-- 테이블 nerv_icde_xxxx.domain_system_port 구조 내보내기
287
CREATE TABLE IF NOT EXISTS `domain_system_port` (
288
  `domain_system_id` int(11) unsigned NOT NULL DEFAULT '0',
289
  `port_num` int(11) unsigned NOT NULL DEFAULT '0',
290
  `port_group` int(11) unsigned NOT NULL DEFAULT '0',
291
  `description` text,
292
  PRIMARY KEY (`domain_system_id`,`port_num`,`port_group`) USING BTREE,
293
  KEY `FK_domain_system_port_1` (`domain_system_id`,`port_group`),
294
  CONSTRAINT `FK_domain_system_port_1` FOREIGN KEY (`domain_system_id`, `port_group`) REFERENCES `domain_system_logical_port` (`domain_system_id`, `port_group`) ON DELETE CASCADE ON UPDATE CASCADE
295
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
296

    
297
-- 테이블 데이터 nerv_icde_xxxx.domain_system_port:~0 rows (대략적) 내보내기
298
DELETE FROM `domain_system_port`;
299
/*!40000 ALTER TABLE `domain_system_port` DISABLE KEYS */;
300
/*!40000 ALTER TABLE `domain_system_port` ENABLE KEYS */;
301

    
302
-- 테이블 nerv_icde_xxxx.inheritance_data_data 구조 내보내기
303
CREATE TABLE IF NOT EXISTS `inheritance_data_data` (
304
  `domain_id` int(10) unsigned NOT NULL,
305
  `parent_domain_id` int(10) unsigned NOT NULL,
306
  PRIMARY KEY (`domain_id`,`parent_domain_id`),
307
  KEY `FK_inheritance_data_data_2` (`parent_domain_id`),
308
  CONSTRAINT `FK_inheritance_data_data_1` FOREIGN KEY (`domain_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
309
  CONSTRAINT `FK_inheritance_data_data_2` FOREIGN KEY (`parent_domain_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
310
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
311

    
312
-- 테이블 데이터 nerv_icde_xxxx.inheritance_data_data:~1 rows (대략적) 내보내기
313
DELETE FROM `inheritance_data_data`;
314
/*!40000 ALTER TABLE `inheritance_data_data` DISABLE KEYS */;
315
INSERT INTO `inheritance_data_data` (`domain_id`, `parent_domain_id`) VALUES
316
	(0, 0);
317
/*!40000 ALTER TABLE `inheritance_data_data` ENABLE KEYS */;
318

    
319
-- 테이블 nerv_icde_xxxx.inheritance_method_data 구조 내보내기
320
CREATE TABLE IF NOT EXISTS `inheritance_method_data` (
321
  `domain_id` int(10) unsigned NOT NULL,
322
  `parent_domain_id` int(10) unsigned NOT NULL,
323
  PRIMARY KEY (`domain_id`,`parent_domain_id`),
324
  KEY `FK_inheritance_method_data_parent_domain_in` (`parent_domain_id`),
325
  CONSTRAINT `FK_inheritance_method_data_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
326
  CONSTRAINT `FK_inheritance_method_data_parent_domain_in` FOREIGN KEY (`parent_domain_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
327
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
328

    
329
-- 테이블 데이터 nerv_icde_xxxx.inheritance_method_data:~0 rows (대략적) 내보내기
330
DELETE FROM `inheritance_method_data`;
331
/*!40000 ALTER TABLE `inheritance_method_data` DISABLE KEYS */;
332
/*!40000 ALTER TABLE `inheritance_method_data` ENABLE KEYS */;
333

    
334
-- 테이블 nerv_icde_xxxx.inheritance_method_method 구조 내보내기
335
CREATE TABLE IF NOT EXISTS `inheritance_method_method` (
336
  `domain_id` int(10) unsigned NOT NULL,
337
  `parent_domain_id` int(10) unsigned NOT NULL,
338
  PRIMARY KEY (`domain_id`,`parent_domain_id`),
339
  KEY `FK_inheritance_method_method_parent_domain_id` (`parent_domain_id`),
340
  CONSTRAINT `FK_inheritance_method_method_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
341
  CONSTRAINT `FK_inheritance_method_method_parent_domain_id` FOREIGN KEY (`parent_domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
342
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
343

    
344
-- 테이블 데이터 nerv_icde_xxxx.inheritance_method_method:~0 rows (대략적) 내보내기
345
DELETE FROM `inheritance_method_method`;
346
/*!40000 ALTER TABLE `inheritance_method_method` DISABLE KEYS */;
347
/*!40000 ALTER TABLE `inheritance_method_method` ENABLE KEYS */;
348

    
349
-- 테이블 nerv_icde_xxxx.inheritance_system_method 구조 내보내기
350
CREATE TABLE IF NOT EXISTS `inheritance_system_method` (
351
  `domain_id` int(10) unsigned NOT NULL,
352
  `parent_domain_id` int(10) unsigned NOT NULL,
353
  PRIMARY KEY (`domain_id`,`parent_domain_id`),
354
  KEY `FK_inheritance_system_method_parent_domain_id` (`parent_domain_id`),
355
  CONSTRAINT `FK_inheritance_system_method_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
356
  CONSTRAINT `FK_inheritance_system_method_parent_domain_id` FOREIGN KEY (`parent_domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
357
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
358

    
359
-- 테이블 데이터 nerv_icde_xxxx.inheritance_system_method:~0 rows (대략적) 내보내기
360
DELETE FROM `inheritance_system_method`;
361
/*!40000 ALTER TABLE `inheritance_system_method` DISABLE KEYS */;
362
/*!40000 ALTER TABLE `inheritance_system_method` ENABLE KEYS */;
363

    
364
-- 테이블 nerv_icde_xxxx.interface 구조 내보내기
365
CREATE TABLE IF NOT EXISTS `interface` (
366
  `domain_id` int(10) unsigned NOT NULL DEFAULT '0',
367
  `name` varchar(100) NOT NULL,
368
  `user_id` varchar(45) NOT NULL,
369
  `seq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
370
  `description` mediumtext NOT NULL,
371
  PRIMARY KEY (`domain_id`,`name`),
372
  KEY `FK_user_id` (`user_id`),
373
  CONSTRAINT `FK_interface_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
374
  CONSTRAINT `FK_interface_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
375
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
376

    
377
-- 테이블 데이터 nerv_icde_xxxx.interface:~0 rows (대략적) 내보내기
378
DELETE FROM `interface`;
379
/*!40000 ALTER TABLE `interface` DISABLE KEYS */;
380
/*!40000 ALTER TABLE `interface` ENABLE KEYS */;
381

    
382
-- 테이블 nerv_icde_xxxx.interface_member 구조 내보내기
383
CREATE TABLE IF NOT EXISTS `interface_member` (
384
  `domain_id` int(10) unsigned NOT NULL DEFAULT '0',
385
  `interface` varchar(100) NOT NULL,
386
  `method_domain_id` int(10) unsigned NOT NULL,
387
  `method_name` varchar(45) NOT NULL,
388
  `description` mediumtext NOT NULL,
389
  PRIMARY KEY (`domain_id`,`interface`,`method_domain_id`,`method_name`),
390
  KEY `FK_interface_member_method` (`domain_id`,`method_name`),
391
  KEY `interface_member_ibfk_1` (`method_domain_id`,`method_name`),
392
  CONSTRAINT `FK_interface_member_interface` FOREIGN KEY (`domain_id`, `interface`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE,
393
  CONSTRAINT `interface_member_ibfk_1` FOREIGN KEY (`method_domain_id`, `method_name`) REFERENCES `method` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE
394
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
395

    
396
-- 테이블 데이터 nerv_icde_xxxx.interface_member:~0 rows (대략적) 내보내기
397
DELETE FROM `interface_member`;
398
/*!40000 ALTER TABLE `interface_member` DISABLE KEYS */;
399
/*!40000 ALTER TABLE `interface_member` ENABLE KEYS */;
400

    
401
-- 테이블 nerv_icde_xxxx.interface_parent 구조 내보내기
402
CREATE TABLE IF NOT EXISTS `interface_parent` (
403
  `domain_id` int(10) unsigned NOT NULL,
404
  `interface` varchar(100) NOT NULL,
405
  `parent_domain_id` int(10) unsigned NOT NULL,
406
  `parent_interface` varchar(100) NOT NULL,
407
  PRIMARY KEY (`domain_id`,`interface`,`parent_domain_id`,`parent_interface`),
408
  KEY `FK_interface_parent_parent` (`parent_domain_id`,`parent_interface`),
409
  CONSTRAINT `FK_interface_parent_interface` FOREIGN KEY (`domain_id`, `interface`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE,
410
  CONSTRAINT `FK_interface_parent_parent` FOREIGN KEY (`parent_domain_id`, `parent_interface`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE
411
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
412

    
413
-- 테이블 데이터 nerv_icde_xxxx.interface_parent:~0 rows (대략적) 내보내기
414
DELETE FROM `interface_parent`;
415
/*!40000 ALTER TABLE `interface_parent` DISABLE KEYS */;
416
/*!40000 ALTER TABLE `interface_parent` ENABLE KEYS */;
417

    
418
-- 테이블 nerv_icde_xxxx.members_domain_data 구조 내보내기
419
CREATE TABLE IF NOT EXISTS `members_domain_data` (
420
  `domain_id` int(10) unsigned NOT NULL DEFAULT '0',
421
  `user_id` varchar(45) NOT NULL,
422
  `member_type` enum('manager','member','guest') NOT NULL,
423
  PRIMARY KEY (`domain_id`,`user_id`),
424
  KEY `FK_user_id` (`user_id`),
425
  CONSTRAINT `FK_members_domain_data_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
426
  CONSTRAINT `FK_members_domain_data_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
427
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
428

    
429
-- 테이블 데이터 nerv_icde_xxxx.members_domain_data:~0 rows (대략적) 내보내기
430
DELETE FROM `members_domain_data`;
431
/*!40000 ALTER TABLE `members_domain_data` DISABLE KEYS */;
432
/*!40000 ALTER TABLE `members_domain_data` ENABLE KEYS */;
433

    
434
-- 테이블 nerv_icde_xxxx.members_domain_method 구조 내보내기
435
CREATE TABLE IF NOT EXISTS `members_domain_method` (
436
  `domain_id` int(10) unsigned NOT NULL,
437
  `user_id` varchar(45) NOT NULL,
438
  `member_type` enum('manager','member','guest') NOT NULL,
439
  PRIMARY KEY (`domain_id`,`user_id`),
440
  KEY `FK_user_id` (`user_id`),
441
  CONSTRAINT `FK_members_domain_method_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
442
  CONSTRAINT `FK_members_domain_method_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
443
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
444

    
445
-- 테이블 데이터 nerv_icde_xxxx.members_domain_method:~0 rows (대략적) 내보내기
446
DELETE FROM `members_domain_method`;
447
/*!40000 ALTER TABLE `members_domain_method` DISABLE KEYS */;
448
/*!40000 ALTER TABLE `members_domain_method` ENABLE KEYS */;
449

    
450
-- 테이블 nerv_icde_xxxx.members_domain_system 구조 내보내기
451
CREATE TABLE IF NOT EXISTS `members_domain_system` (
452
  `domain_id` int(10) unsigned NOT NULL,
453
  `user_id` varchar(45) NOT NULL,
454
  `member_type` enum('manager','member','guest') NOT NULL,
455
  PRIMARY KEY (`domain_id`,`user_id`),
456
  KEY `FK_user_id` (`user_id`),
457
  CONSTRAINT `FK_members_domain_system_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
458
  CONSTRAINT `FK_members_domain_system_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
459
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
460

    
461
-- 테이블 데이터 nerv_icde_xxxx.members_domain_system:~0 rows (대략적) 내보내기
462
DELETE FROM `members_domain_system`;
463
/*!40000 ALTER TABLE `members_domain_system` DISABLE KEYS */;
464
/*!40000 ALTER TABLE `members_domain_system` ENABLE KEYS */;
465

    
466
-- 테이블 nerv_icde_xxxx.member_system 구조 내보내기
467
CREATE TABLE IF NOT EXISTS `member_system` (
468
  `domain_id` int(10) unsigned NOT NULL,
469
  `member_domain_id` int(10) unsigned NOT NULL,
470
  PRIMARY KEY (`domain_id`,`member_domain_id`),
471
  KEY `FK_member_system_member` (`member_domain_id`),
472
  CONSTRAINT `FK_member_system_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
473
  CONSTRAINT `FK_member_system_member` FOREIGN KEY (`member_domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
474
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
475

    
476
-- 테이블 데이터 nerv_icde_xxxx.member_system:~0 rows (대략적) 내보내기
477
DELETE FROM `member_system`;
478
/*!40000 ALTER TABLE `member_system` DISABLE KEYS */;
479
/*!40000 ALTER TABLE `member_system` ENABLE KEYS */;
480

    
481
-- 테이블 nerv_icde_xxxx.method 구조 내보내기
482
CREATE TABLE IF NOT EXISTS `method` (
483
  `domain_id` int(10) unsigned NOT NULL DEFAULT '0',
484
  `name` varchar(100) NOT NULL,
485
  `type` enum('CALL','SIGNAL','EVENT','INFORMATION','COMMAND','BROADCAST') NOT NULL DEFAULT 'CALL',
486
  `code` smallint(5) unsigned NOT NULL DEFAULT '0',
487
  `in_data_auto_id` int(10) unsigned DEFAULT NULL,
488
  `out_data_auto_id` int(10) unsigned DEFAULT NULL,
489
  `user_id` varchar(45) NOT NULL,
490
  `description` mediumtext NOT NULL,
491
  PRIMARY KEY (`domain_id`,`name`),
492
  KEY `UQ_method` (`domain_id`,`type`,`code`),
493
  KEY `FK_method_user` (`user_id`),
494
  KEY `FK_method_in_data` (`in_data_auto_id`),
495
  KEY `FK_method_out_data` (`out_data_auto_id`),
496
  CONSTRAINT `FK_method_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
497
  CONSTRAINT `FK_method_in_data` FOREIGN KEY (`in_data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE SET NULL ON UPDATE CASCADE,
498
  CONSTRAINT `FK_method_out_data` FOREIGN KEY (`out_data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE SET NULL ON UPDATE CASCADE,
499
  CONSTRAINT `FK_method_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
500
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
501

    
502
-- 테이블 데이터 nerv_icde_xxxx.method:~0 rows (대략적) 내보내기
503
DELETE FROM `method`;
504
/*!40000 ALTER TABLE `method` DISABLE KEYS */;
505
/*!40000 ALTER TABLE `method` ENABLE KEYS */;
506

    
507
-- 테이블 nerv_icde_xxxx.network 구조 내보내기
508
CREATE TABLE IF NOT EXISTS `network` (
509
  `node_id` int(10) unsigned NOT NULL DEFAULT '0',
510
  `port` int(11) unsigned NOT NULL DEFAULT '0',
511
  `ip` varchar(255) NOT NULL DEFAULT '',
512
  `mask` varchar(255) DEFAULT '',
513
  `net` varchar(50) NOT NULL DEFAULT '',
514
  `gateway` varchar(255) DEFAULT NULL,
515
  `dns` varchar(255) NOT NULL DEFAULT '',
516
  `description` varchar(255) DEFAULT NULL,
517
  `collision` tinyint(3) unsigned NOT NULL DEFAULT '0',
518
  `original_node_id` int(10) unsigned DEFAULT '0',
519
  `original_node_port` int(11) unsigned DEFAULT '0',
520
  `original_node_ip` varchar(255) DEFAULT '',
521
  PRIMARY KEY (`node_id`,`port`,`ip`),
522
  KEY `network_ibfk_3` (`original_node_id`,`original_node_port`,`original_node_ip`),
523
  CONSTRAINT `network_ibfk_1` FOREIGN KEY (`node_id`, `port`) REFERENCES `node_port` (`Id`, `port_group`) ON DELETE CASCADE ON UPDATE CASCADE,
524
  CONSTRAINT `network_ibfk_2` FOREIGN KEY (`node_id`) REFERENCES `node_port` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
525
  CONSTRAINT `network_ibfk_3` FOREIGN KEY (`original_node_id`, `original_node_port`, `original_node_ip`) REFERENCES `network` (`node_id`, `port`, `ip`) ON DELETE CASCADE ON UPDATE CASCADE
526
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
527

    
528
-- 테이블 데이터 nerv_icde_xxxx.network:~0 rows (대략적) 내보내기
529
DELETE FROM `network`;
530
/*!40000 ALTER TABLE `network` DISABLE KEYS */;
531
/*!40000 ALTER TABLE `network` ENABLE KEYS */;
532

    
533
-- 테이블 nerv_icde_xxxx.network_link 구조 내보내기
534
CREATE TABLE IF NOT EXISTS `network_link` (
535
  `s_node_id` int(11) unsigned NOT NULL DEFAULT '0',
536
  `s_sub_system_id` int(11) unsigned NOT NULL DEFAULT '0',
537
  `s_port_id` int(11) unsigned NOT NULL DEFAULT '0',
538
  `d_node_id` int(11) unsigned DEFAULT NULL,
539
  `d_sub_system_id` int(11) unsigned NOT NULL DEFAULT '0',
540
  `d_port_id` int(11) unsigned NOT NULL DEFAULT '0',
541
  PRIMARY KEY (`s_node_id`,`s_sub_system_id`,`s_port_id`),
542
  UNIQUE KEY `d_node_id` (`d_node_id`,`d_sub_system_id`,`d_port_id`),
543
  KEY `s_sub_system_id` (`s_sub_system_id`,`s_port_id`),
544
  KEY `d_sub_system_id` (`d_sub_system_id`,`d_port_id`),
545
  CONSTRAINT `FK_network_link_4` FOREIGN KEY (`d_node_id`) REFERENCES `node` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
546
  CONSTRAINT `network_link_ibfk_1` FOREIGN KEY (`s_sub_system_id`, `s_port_id`) REFERENCES `domain_system_port` (`domain_system_id`, `port_num`) ON DELETE CASCADE ON UPDATE CASCADE,
547
  CONSTRAINT `network_link_ibfk_2` FOREIGN KEY (`d_sub_system_id`, `d_port_id`) REFERENCES `domain_system_port` (`domain_system_id`, `port_num`) ON DELETE CASCADE ON UPDATE CASCADE,
548
  CONSTRAINT `network_link_ibfk_3` FOREIGN KEY (`s_node_id`) REFERENCES `node` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
549
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
550

    
551
-- 테이블 데이터 nerv_icde_xxxx.network_link:~0 rows (대략적) 내보내기
552
DELETE FROM `network_link`;
553
/*!40000 ALTER TABLE `network_link` DISABLE KEYS */;
554
/*!40000 ALTER TABLE `network_link` ENABLE KEYS */;
555

    
556
-- 테이블 nerv_icde_xxxx.network_temp 구조 내보내기
557
CREATE TABLE IF NOT EXISTS `network_temp` (
558
  `node_id` int(10) unsigned NOT NULL DEFAULT '0',
559
  `port` int(11) unsigned NOT NULL DEFAULT '0',
560
  `ip` varchar(255) NOT NULL DEFAULT '',
561
  `mask` varchar(255) DEFAULT '',
562
  `net` varchar(50) NOT NULL DEFAULT '',
563
  `gateway` varchar(255) DEFAULT NULL,
564
  `dns` varchar(255) NOT NULL DEFAULT '',
565
  `description` varchar(255) DEFAULT NULL,
566
  `collision` tinyint(3) unsigned NOT NULL DEFAULT '0',
567
  `original_node_id` int(10) unsigned DEFAULT '0',
568
  `original_node_port` int(11) unsigned DEFAULT '0',
569
  `original_node_ip` varchar(255) DEFAULT ''
570
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
571

    
572
-- 테이블 데이터 nerv_icde_xxxx.network_temp:~0 rows (대략적) 내보내기
573
DELETE FROM `network_temp`;
574
/*!40000 ALTER TABLE `network_temp` DISABLE KEYS */;
575
/*!40000 ALTER TABLE `network_temp` ENABLE KEYS */;
576

    
577
-- 테이블 nerv_icde_xxxx.node 구조 내보내기
578
CREATE TABLE IF NOT EXISTS `node` (
579
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
580
  `systemdomain_id` int(10) unsigned NOT NULL,
581
  `sub_system_domain_id` int(11) unsigned DEFAULT '0',
582
  `name` varchar(255) NOT NULL DEFAULT '',
583
  `type` varchar(45) NOT NULL DEFAULT '',
584
  `description` varchar(255) DEFAULT NULL,
585
  `complete` enum('Y','N') NOT NULL DEFAULT 'N',
586
  PRIMARY KEY (`Id`),
587
  KEY `FK_node_1` (`systemdomain_id`),
588
  KEY `package_domain_id` (`sub_system_domain_id`),
589
  KEY `Id_systemdomain_id` (`Id`,`systemdomain_id`),
590
  CONSTRAINT `node_ibfk_1` FOREIGN KEY (`systemdomain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
591
  CONSTRAINT `node_ibfk_2` FOREIGN KEY (`sub_system_domain_id`) REFERENCES `domain_system` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
592
) ENGINE=InnoDB AUTO_INCREMENT=1199 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
593

    
594
-- 테이블 데이터 nerv_icde_xxxx.node:~1 rows (대략적) 내보내기
595
DELETE FROM `node`;
596
/*!40000 ALTER TABLE `node` DISABLE KEYS */;
597
INSERT INTO `node` (`Id`, `systemdomain_id`, `sub_system_domain_id`, `name`, `type`, `description`, `complete`) VALUES
598
	(0, 0, 0, '', 'sub_system', NULL, 'N');
599
/*!40000 ALTER TABLE `node` ENABLE KEYS */;
600

    
601
-- 테이블 nerv_icde_xxxx.node_port 구조 내보내기
602
CREATE TABLE IF NOT EXISTS `node_port` (
603
  `Id` int(10) unsigned NOT NULL,
604
  `systemdomain_id` int(10) unsigned NOT NULL,
605
  `sub_system_domain_id` int(11) unsigned NOT NULL DEFAULT '0',
606
  `port_group` int(11) unsigned NOT NULL DEFAULT '0',
607
  PRIMARY KEY (`Id`,`systemdomain_id`,`sub_system_domain_id`,`port_group`),
608
  KEY `Id_port_group` (`Id`,`port_group`),
609
  KEY `FK_node_port_domain_system_logical_port` (`sub_system_domain_id`,`port_group`),
610
  CONSTRAINT `FK_node_port_domain_system_logical_port` FOREIGN KEY (`sub_system_domain_id`, `port_group`) REFERENCES `domain_system_logical_port` (`domain_system_id`, `port_group`) ON DELETE CASCADE ON UPDATE CASCADE,
611
  CONSTRAINT `FK_node_port_node` FOREIGN KEY (`Id`, `systemdomain_id`) REFERENCES `node` (`Id`, `systemdomain_id`) ON DELETE CASCADE ON UPDATE CASCADE
612
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
613

    
614
-- 테이블 데이터 nerv_icde_xxxx.node_port:~0 rows (대략적) 내보내기
615
DELETE FROM `node_port`;
616
/*!40000 ALTER TABLE `node_port` DISABLE KEYS */;
617
/*!40000 ALTER TABLE `node_port` ENABLE KEYS */;
618

    
619
-- 테이블 nerv_icde_xxxx.protocol_standard_port 구조 내보내기
620
CREATE TABLE IF NOT EXISTS `protocol_standard_port` (
621
  `Id` int(11) NOT NULL AUTO_INCREMENT,
622
  `title` varchar(255) DEFAULT NULL,
623
  `port` varchar(255) DEFAULT NULL,
624
  `discription` text,
625
  PRIMARY KEY (`Id`)
626
) ENGINE=InnoDB AUTO_INCREMENT=10746 DEFAULT CHARSET=utf8;
627

    
628
-- 테이블 데이터 nerv_icde_xxxx.protocol_standard_port:~0 rows (대략적) 내보내기
629
DELETE FROM `protocol_standard_port`;
630
/*!40000 ALTER TABLE `protocol_standard_port` DISABLE KEYS */;
631
/*!40000 ALTER TABLE `protocol_standard_port` ENABLE KEYS */;
632

    
633
-- 테이블 nerv_icde_xxxx.proxy_interface_object 구조 내보내기
634
CREATE TABLE IF NOT EXISTS `proxy_interface_object` (
635
  `proxy_interface_id` int(10) unsigned NOT NULL,
636
  `object_name` varchar(100) NOT NULL,
637
  `component_id` int(10) unsigned NOT NULL,
638
  PRIMARY KEY (`proxy_interface_id`,`object_name`),
639
  UNIQUE KEY `object_name_component_id` (`object_name`,`component_id`),
640
  KEY `FK_proxy_interface_object_proxy_interface_relation` (`proxy_interface_id`,`component_id`),
641
  CONSTRAINT `FK_proxy_interface_object_proxy_interface_relation` FOREIGN KEY (`proxy_interface_id`, `component_id`) REFERENCES `proxy_interface_relation` (`id`, `component_id`) ON DELETE CASCADE ON UPDATE CASCADE
642
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
643

    
644
-- 테이블 데이터 nerv_icde_xxxx.proxy_interface_object:~0 rows (대략적) 내보내기
645
DELETE FROM `proxy_interface_object`;
646
/*!40000 ALTER TABLE `proxy_interface_object` DISABLE KEYS */;
647
/*!40000 ALTER TABLE `proxy_interface_object` ENABLE KEYS */;
648

    
649
-- 테이블 nerv_icde_xxxx.proxy_interface_relation 구조 내보내기
650
CREATE TABLE IF NOT EXISTS `proxy_interface_relation` (
651
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
652
  `component_id` int(10) unsigned NOT NULL DEFAULT '0',
653
  `method_domain_id` int(10) unsigned NOT NULL DEFAULT '0',
654
  `interface_name` varchar(100) NOT NULL DEFAULT '',
655
  `class_name` varchar(255) DEFAULT '',
656
  PRIMARY KEY (`id`),
657
  UNIQUE KEY `unique_key` (`component_id`,`method_domain_id`,`interface_name`,`class_name`),
658
  KEY `FK_proxy_interface_relation_1` (`component_id`),
659
  KEY `FK_proxy_interface_relation_2` (`method_domain_id`,`interface_name`),
660
  KEY `id_component_id` (`id`,`component_id`),
661
  CONSTRAINT `FK_proxy_interface_relation_1` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
662
  CONSTRAINT `FK_proxy_interface_relation_2` FOREIGN KEY (`method_domain_id`, `interface_name`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE
663
) ENGINE=InnoDB AUTO_INCREMENT=1099 DEFAULT CHARSET=utf8;
664

    
665
-- 테이블 데이터 nerv_icde_xxxx.proxy_interface_relation:~0 rows (대략적) 내보내기
666
DELETE FROM `proxy_interface_relation`;
667
/*!40000 ALTER TABLE `proxy_interface_relation` DISABLE KEYS */;
668
/*!40000 ALTER TABLE `proxy_interface_relation` ENABLE KEYS */;
669

    
670
-- 테이블 nerv_icde_xxxx.server_information 구조 내보내기
671
CREATE TABLE IF NOT EXISTS `server_information` (
672
  `field_name` varchar(100) NOT NULL,
673
  `description` mediumtext NOT NULL,
674
  `seq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
675
  PRIMARY KEY (`field_name`)
676
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
677

    
678
-- 테이블 데이터 nerv_icde_xxxx.server_information:~0 rows (대략적) 내보내기
679
DELETE FROM `server_information`;
680
/*!40000 ALTER TABLE `server_information` DISABLE KEYS */;
681
/*!40000 ALTER TABLE `server_information` ENABLE KEYS */;
682

    
683
-- 테이블 nerv_icde_xxxx.stub_interface_object 구조 내보내기
684
CREATE TABLE IF NOT EXISTS `stub_interface_object` (
685
  `stub_interface_id` int(10) unsigned NOT NULL,
686
  `object_name` varchar(100) NOT NULL,
687
  `component_id` int(10) unsigned NOT NULL,
688
  PRIMARY KEY (`stub_interface_id`,`object_name`),
689
  UNIQUE KEY `object_name_component_id` (`object_name`,`component_id`),
690
  KEY `FK_stub_interface_object_stub_interface_relation` (`stub_interface_id`,`component_id`),
691
  CONSTRAINT `FK_stub_interface_object_stub_interface_relation` FOREIGN KEY (`stub_interface_id`, `component_id`) REFERENCES `stub_interface_relation` (`Id`, `component_id`) ON DELETE CASCADE ON UPDATE CASCADE
692
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
693

    
694
-- 테이블 데이터 nerv_icde_xxxx.stub_interface_object:~0 rows (대략적) 내보내기
695
DELETE FROM `stub_interface_object`;
696
/*!40000 ALTER TABLE `stub_interface_object` DISABLE KEYS */;
697
/*!40000 ALTER TABLE `stub_interface_object` ENABLE KEYS */;
698

    
699
-- 테이블 nerv_icde_xxxx.stub_interface_relation 구조 내보내기
700
CREATE TABLE IF NOT EXISTS `stub_interface_relation` (
701
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
702
  `component_id` int(10) unsigned NOT NULL DEFAULT '0',
703
  `method_domain_id` int(10) unsigned NOT NULL DEFAULT '0',
704
  `interface_name` varchar(100) NOT NULL DEFAULT '',
705
  `class_name` varchar(255) DEFAULT '',
706
  `domain_port` varchar(255) DEFAULT NULL,
707
  `text` text,
708
  PRIMARY KEY (`Id`),
709
  UNIQUE KEY `unique_key` (`component_id`,`method_domain_id`,`interface_name`,`class_name`),
710
  KEY `FK_stub_interface_ralation_1` (`component_id`),
711
  KEY `FK_stub_interface_ralation_2` (`method_domain_id`,`interface_name`),
712
  KEY `Id_component_id` (`Id`,`component_id`),
713
  CONSTRAINT `FK_stub_interface_ralation_1` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
714
  CONSTRAINT `FK_stub_interface_ralation_2` FOREIGN KEY (`method_domain_id`, `interface_name`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE
715
) ENGINE=InnoDB AUTO_INCREMENT=866 DEFAULT CHARSET=utf8;
716

    
717
-- 테이블 데이터 nerv_icde_xxxx.stub_interface_relation:~0 rows (대략적) 내보내기
718
DELETE FROM `stub_interface_relation`;
719
/*!40000 ALTER TABLE `stub_interface_relation` DISABLE KEYS */;
720
/*!40000 ALTER TABLE `stub_interface_relation` ENABLE KEYS */;
721

    
722
-- 테이블 nerv_icde_xxxx.temp_history 구조 내보내기
723
CREATE TABLE IF NOT EXISTS `temp_history` (
724
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
725
  `userid` varchar(45) NOT NULL,
726
  PRIMARY KEY (`timestamp`)
727
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
728

    
729
-- 테이블 데이터 nerv_icde_xxxx.temp_history:~0 rows (대략적) 내보내기
730
DELETE FROM `temp_history`;
731
/*!40000 ALTER TABLE `temp_history` DISABLE KEYS */;
732
/*!40000 ALTER TABLE `temp_history` ENABLE KEYS */;
733

    
734
-- 테이블 nerv_icde_xxxx.umlcomponent 구조 내보내기
735
CREATE TABLE IF NOT EXISTS `umlcomponent` (
736
  `Id` int(11) NOT NULL AUTO_INCREMENT,
737
  `diagrame_id` int(11) NOT NULL DEFAULT '0',
738
  `component_id` int(11) unsigned NOT NULL DEFAULT '0',
739
  `position_x` int(11) unsigned NOT NULL DEFAULT '0',
740
  `position_y` int(11) unsigned NOT NULL DEFAULT '0',
741
  `size` int(11) unsigned NOT NULL DEFAULT '0',
742
  PRIMARY KEY (`Id`),
743
  KEY `FK_umlcomponent_diagrame_id` (`diagrame_id`),
744
  KEY `component_id` (`component_id`),
745
  CONSTRAINT `FK_umlcomponent_component_id` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
746
  CONSTRAINT `FK_umlcomponent_diagrame_id` FOREIGN KEY (`diagrame_id`) REFERENCES `diagrame` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
747
  CONSTRAINT `umlcomponent_ibfk_1` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`)
748
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
749

    
750
-- 테이블 데이터 nerv_icde_xxxx.umlcomponent:~0 rows (대략적) 내보내기
751
DELETE FROM `umlcomponent`;
752
/*!40000 ALTER TABLE `umlcomponent` DISABLE KEYS */;
753
/*!40000 ALTER TABLE `umlcomponent` ENABLE KEYS */;
754

    
755
-- 테이블 nerv_icde_xxxx.users 구조 내보내기
756
CREATE TABLE IF NOT EXISTS `users` (
757
  `user_id` varchar(45) NOT NULL,
758
  `password` varchar(45) NOT NULL,
759
  `description` mediumtext NOT NULL,
760
  `supermanager` tinyint(1) unsigned NOT NULL,
761
  `newacount` tinyint(1) unsigned NOT NULL,
762
  `newdomain` tinyint(1) unsigned NOT NULL,
763
  PRIMARY KEY (`user_id`)
764
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
765

    
766
-- 테이블 데이터 nerv_icde_xxxx.users:~2 rows (대략적) 내보내기
767
DELETE FROM `users`;
768
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
769
INSERT INTO `users` (`user_id`, `password`, `description`, `supermanager`, `newacount`, `newdomain`) VALUES
770
	('anonymous', '', '', 0, 1, 0),
771
	('root', '', '', 1, 1, 1);
772
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
773

    
774
-- 뷰 nerv_icde_xxxx.view_a 구조 내보내기
775
-- VIEW 종속성 오류를 극복하기 위해 임시 테이블을 생성합니다.
776
CREATE TABLE `view_a` (
777
	`s_node_id` INT(11) UNSIGNED NOT NULL,
778
	`s_sub_system_id` INT(11) UNSIGNED NOT NULL,
779
	`s_port_id` INT(11) UNSIGNED NOT NULL,
780
	`d_node_id` INT(11) UNSIGNED NULL,
781
	`d_sub_system_id` INT(11) UNSIGNED NOT NULL,
782
	`d_port_id` INT(11) UNSIGNED NOT NULL
783
) ENGINE=MyISAM;
784

    
785
-- 뷰 nerv_icde_xxxx.view_b 구조 내보내기
786
-- VIEW 종속성 오류를 극복하기 위해 임시 테이블을 생성합니다.
787
CREATE TABLE `view_b` (
788
	`s_node_id` INT(11) UNSIGNED NOT NULL,
789
	`s_sub_system_id` INT(11) UNSIGNED NOT NULL,
790
	`s_port_id` INT(11) UNSIGNED NOT NULL,
791
	`d_node_id` INT(11) UNSIGNED NULL,
792
	`d_sub_system_id` INT(11) UNSIGNED NOT NULL,
793
	`d_port_id` INT(11) UNSIGNED NOT NULL
794
) ENGINE=MyISAM;
795

    
796
-- 프로시저 nerv_icde_xxxx.acountInfoAccessUser 구조 내보내기
797
DELIMITER //
798
CREATE PROCEDURE `acountInfoAccessUser`()
799
BEGIN
800
        declare sm bool;
801
        if loginTest() then
802
                select 1 as test;               
803
                       select user_id,supermanager,newacount,newdomain,description from users where user_id = @nervuser;                              
804
       else
805
                select 0 as test;
806
       end if;
807
END//
808
DELIMITER ;
809

    
810
-- 프로시저 nerv_icde_xxxx.acountlistViewAcountList 구조 내보내기
811
DELIMITER //
812
CREATE PROCEDURE `acountlistViewAcountList`(IN `userkey` varchar(100))
813
BEGIN
814
        declare sm bool;
815
        if loginTest() then
816
                select 1 as test;
817
                if( supermanagerTest(@nervuser) ) then
818
                        select user_id,supermanager,newacount,newdomain,description from users
819
								 where user_id like userkey;
820
                else
821
                        select user_id,supermanager,newacount,newdomain,description from users
822
								 where (user_id = 'anonymous' or user_id=@nervuser) and user_id like userkey;
823
                end if;
824
       else
825
                select 0 as test;
826
       end if;
827
END//
828
DELIMITER ;
829

    
830
-- 프로시저 nerv_icde_xxxx.acountlistViewDeleteAcount 구조 내보내기
831
DELIMITER //
832
CREATE PROCEDURE `acountlistViewDeleteAcount`(IN `acountkey` varchar(100))
833
BEGIN
834
        declare targetsm bool;
835
        if acountkey != 'anonymous' and acountkey != 'root'
836
		  	and acountkey != @nervuser and loginTest() 
837
			  and supermanagerTest(@nervuser) and !supermanagerTest(acountkey) then
838
                select 1 as test;
839
                delete from users where user_id=acountkey;
840
        else
841
                select 0 as test;
842
        end if;
843
END//
844
DELIMITER ;
845

    
846
-- 프로시저 nerv_icde_xxxx.acountlistViewNewAcount 구조 내보내기
847
DELIMITER //
848
CREATE PROCEDURE `acountlistViewNewAcount`(acountidvalue varchar(100),passwordvalue varchar(100) ,descriptionvalue text)
849
BEGIN
850
        declare newacountpriv bool;
851
        declare anonymousnewacount bool;
852
        declare anonymousnewdomain bool;
853
        declare anonymoussupermanager bool;
854

    
855
        if loginTest() then
856
                select newacount into newacountpriv from users where user_id=@nervuser;
857
                if newacountpriv then
858
                        select 1 as test;
859
                        select supermanager into anonymoussupermanager from users where user_id='anonymous';
860
                        select newacount into anonymousnewacount from users where user_id='anonymous';
861
                        select newdomain into anonymousnewdomain from users where user_id='anonymous';
862
                        insert into users(user_id, password,supermanager,newacount,newdomain, description)
863
                                   values(acountidvalue,password(passwordvalue),anonymoussupermanager,anonymousnewacount,anonymousnewdomain,descriptionvalue);
864
                else
865
                        select 0 as test;
866
                end if;
867
        else
868
                select 0 as test;
869
        end if;
870
END//
871
DELIMITER ;
872

    
873
-- 프로시저 nerv_icde_xxxx.acountlistViewToggleNewAcount 구조 내보내기
874
DELIMITER //
875
CREATE PROCEDURE `acountlistViewToggleNewAcount`(acountkey varchar(100))
876
BEGIN
877
        if acountkey != 'root' and loginTest() and supermanagerTest(@nervuser) and !supermanagerTest(acountkey) then
878
                select 1 as test;
879
                update users set newacount = !newacount where user_id=acountkey;
880
        else
881
                select 0 as test;
882
        end if;
883
END//
884
DELIMITER ;
885

    
886
-- 프로시저 nerv_icde_xxxx.acountlistViewToggleNewDomain 구조 내보내기
887
DELIMITER //
888
CREATE PROCEDURE `acountlistViewToggleNewDomain`(acountkey varchar(100))
889
BEGIN
890
        if acountkey != 'root' and loginTest() and supermanagerTest(@nervuser) and !supermanagerTest(acountkey) then
891
                select 1 as test;
892
                update users set newdomain = !newdomain where user_id=acountkey;
893
        else
894
                select 0 as test;
895
        end if;
896
END//
897
DELIMITER ;
898

    
899
-- 프로시저 nerv_icde_xxxx.acountlistViewToggleSupermanager 구조 내보내기
900
DELIMITER //
901
CREATE PROCEDURE `acountlistViewToggleSupermanager`(acountkey varchar(100))
902
BEGIN
903
        if acountkey != 'root' and @nervuser = 'root' and loginTest() then
904
                select 1 as test;
905
                update users set supermanager = !supermanager where user_id=acountkey;
906
        else
907
                select 0 as test;
908
        end if;
909
END//
910
DELIMITER ;
911

    
912
-- 프로시저 nerv_icde_xxxx.acountViewEditAcount 구조 내보내기
913
DELIMITER //
914
CREATE PROCEDURE `acountViewEditAcount`(IN `oldpasswordedit` varchar(100), IN `passwordedit` varchar(100), IN `descriptionedit` text)
915
BEGIN
916
        declare pwd varchar(100);
917
        if @nervuser != 'anonymous' then
918
                if loginTest() then
919
                        select users.password into pwd from users where user_id=@nervuser;
920
                        if pwd = password(oldpasswordedit) then
921
                                select 1 as test;
922
                                update users set password=password(passwordedit), description=descriptionedit
923
										   where user_id=@nervuser;
924
                                set @nervpassword = passwordedit;
925
                        else
926
                                select 0 as test;
927
                        end if;
928
                else
929
                        select 0 as test;
930
                end if;
931
        else
932
                select 0 as test;
933
        end if;
934
END//
935
DELIMITER ;
936

    
937
-- 프로시저 nerv_icde_xxxx.acountViewSecedeAcount 구조 내보내기
938
DELIMITER //
939
CREATE PROCEDURE `acountViewSecedeAcount`()
940
BEGIN
941
        declare pwd varchar(100);
942
        if @nervuser != 'anonymous' then
943
                if loginTest() then
944
                        select 1 as test;
945
                        delete from users where user_id=@nervuser;
946
                else
947
                        select 0 as test;
948
                end if;
949
        else
950
                select 0 as test;
951
        end if;
952
END//
953
DELIMITER ;
954

    
955
-- 프로시저 nerv_icde_xxxx.acountViewUserinfo 구조 내보내기
956
DELIMITER //
957
CREATE PROCEDURE `acountViewUserinfo`()
958
BEGIN
959
       if loginTest() then
960
               select 1 as test;
961
               select user_id,supermanager,newacount,newdomain,description from users where user_id=@nervuser;
962
       else
963
               select 0 as test;
964
       end if;
965
END//
966
DELIMITER ;
967

    
968
-- 프로시저 nerv_icde_xxxx.auto_update_data_field_path 구조 내보내기
969
DELIMITER //
970
CREATE PROCEDURE `auto_update_data_field_path`()
971
BEGIN
972
	declare my_data_id int;
973
	declare my_real_data_auto_id int;		
974
	declare my_domain_id int;
975
	declare my_real_domain_id int;
976
	declare my_real_data_name varchar(50);	
977
	declare my_depth int;	
978
	declare my_real_data_path int;	
979
	declare no_more_rows bool default false;
980
	
981
		DECLARE my_list CURSOR FOR 
982
		select data_field.data_auto_id, data_field.real_data_auto_id  from data_field where data_field.`type`='alias';		
983
		declare continue handler for not found set no_more_rows := TRUE;		
984
		
985
			open my_list;
986
			my_loop : loop		
987
				fetch my_list into my_data_id, my_real_data_auto_id;
988
				if no_more_rows then
989
					close my_list;
990
					leave my_loop;
991
				end if;					
992
				   select  data.domain_id into my_domain_id from data where data.data_auto_id = my_data_id;
993
        			select  data.domain_id into my_real_domain_id from data where data.data_auto_id = my_real_data_auto_id; 
994
        			select  data.name into my_real_data_name from data where data.data_auto_id = my_real_data_auto_id; 
995
        			
996
        			
997
        			
998
        			if my_domain_id=my_real_domain_id then
999
               		select data.depth into my_depth from data where data.data_auto_id=my_data_id;
1000
               		select data.depth into my_real_data_path from data where data.data_auto_id=my_real_data_auto_id;
1001
               		
1002
               		        			
1003
               		        			
1004
               		if my_depth <= my_real_data_path then               		
1005
               			set my_real_data_path = my_real_data_path + 1;
1006
               			               			
1007
               			  update data set data.depth = my_real_data_path where data.data_auto_id = my_data_id;               			
1008
               			  call update_child_depth(my_real_data_auto_id,my_real_domain_id,my_real_data_path);
1009
               		end if;               		
1010
               	end if;               	
1011
   		end loop my_loop;	
1012
END//
1013
DELIMITER ;
1014

    
1015
-- 프로시저 nerv_icde_xxxx.auto_update_data_path 구조 내보내기
1016
DELIMITER //
1017
CREATE PROCEDURE `auto_update_data_path`()
1018
BEGIN
1019

    
1020
	declare my_data_id int;
1021
	declare my_domain_id int;
1022
	declare my_depth int;
1023
	declare my_real_data_auto_id int;	
1024
	declare my_real_data_path int;
1025
	
1026
	declare no_more_rows bool default false;
1027
	
1028
		DECLARE my_list CURSOR FOR 
1029
		select data.data_auto_id, data.domain_id, data.depth, data.real_data_auto_id  from data where data.`type`='alias';
1030
		
1031
		declare continue handler for not found set no_more_rows := TRUE;		
1032
		
1033
			open my_list;
1034
			my_loop : loop		
1035
				fetch my_list into my_data_id, my_domain_id, my_depth, my_real_data_auto_id;
1036
				if no_more_rows then
1037
					close my_list;
1038
					leave my_loop;
1039
				end if;	
1040
        			
1041
               		select data.depth into my_real_data_path from data where data.data_auto_id=my_real_data_auto_id;
1042
               		if my_depth <= my_real_data_path then
1043
								set my_depth = my_real_data_path +1;               		               									
1044

    
1045
               			call update_child_depth(my_data_id,my_domain_id,my_depth);               
1046
								
1047
								 update data set data.depth = my_depth where data.data_auto_id=my_data_id;			
1048
							end if;               	
1049
   		end loop my_loop;	
1050

    
1051
END//
1052
DELIMITER ;
1053

    
1054
-- 프로시저 nerv_icde_xxxx.check_child_depth_limit_loop 구조 내보내기
1055
DELIMITER //
1056
CREATE PROCEDURE `check_child_depth_limit_loop`(
1057
	IN `in_domain_id` INT,
1058
	IN `in_data_name` VARCHAR(100),
1059
	IN `in_real_auto_id` INT
1060
)
1061
BEGIN
1062
	declare no_more_rows bool default false;		
1063
	declare data_type varchar(100);
1064
	declare data_domain_id int;
1065
	declare data_name varchar(100);
1066
	declare child_data_auto_id int;
1067
	declare limit_count int default 0;
1068
	declare check_data_auto_id int;	
1069
	
1070
	DECLARE my_list CURSOR FOR 	
1071
	select data.`type`, data.real_data_auto_id from data where data.data_auto_id = in_real_auto_id and data.domain_id=in_domain_id
1072
 	union 
1073
	select data.`type`, data.real_data_auto_id from data where data.domain_id=in_domain_id and data.data_auto_id in
1074
 		(select data_field.real_data_auto_id from data_field where  data_field.data_auto_id = in_real_auto_id);			
1075
 
1076
	declare continue handler for not found set no_more_rows := TRUE;
1077
	
1078
	set max_sp_recursion_depth = 50;		 
1079
	
1080
	   select data.data_auto_id into check_data_auto_id from data where data.domain_id=in_domain_id and data.name=in_data_name;
1081
   
1082
		open my_list;	
1083
		my_loop : loop
1084
		
1085
			fetch my_list into data_type, child_data_auto_id;
1086
		
1087
			 if no_more_rows then
1088
				 close my_list;
1089
				 leave my_loop;
1090
			 end if;			
1091
			if check_data_auto_id = child_data_auto_id then
1092
				   select 1 into limit_count;	
1093
				   select child_data_auto_id;				
1094
				 close my_list;
1095
				 leave my_loop;
1096
			end if;				
1097
			 if data_type = 'alias' and limit_count = 0 then				 		
1098
			 	   call check_child_depth_limit_loop( in_domain_id, in_data_name, child_data_auto_id);
1099
			 end if;					
1100
		end loop my_loop;					
1101
END//
1102
DELIMITER ;
1103

    
1104
-- 프로시저 nerv_icde_xxxx.check_clone_component 구조 내보내기
1105
DELIMITER //
1106
CREATE PROCEDURE `check_clone_component`(IN `in_system_domain_id` INT, IN `in_component_id` INT)
1107
BEGIN
1108
select b.name, c.name from
1109
(
1110
	select * from deployments where id in
1111
		(select deploy_id from custum_proxy where id != original_id and original_id in
1112
			( select id from custum_proxy where deploy_id in
1113
				 (select id from deployments where component_id=in_component_id and systemdomain_id=in_system_domain_id)
1114
			)
1115
		)
1116
) as a
1117
join
1118
domain_system as b on b.id = a.systemdomain_id
1119
join
1120
node as c on c.Id = a.node_id;
1121
END//
1122
DELIMITER ;
1123

    
1124
-- 프로시저 nerv_icde_xxxx.check_method_code 구조 내보내기
1125
DELIMITER //
1126
CREATE PROCEDURE `check_method_code`(
1127
	IN `in_domain_id` INT,
1128
	IN `in_code` INT,
1129
	IN `in_type` ENUM('CALL','SIGNAL','EVENT','INFORMATION','COMMAND','BROADCAST'),
1130
	IN `in_method_name` VARCHAR(50)
1131

    
1132
)
1133
BEGIN
1134
	if logintest() then
1135
		select 1 as test;
1136
		select method.name from method where method.domain_id=in_domain_id and method.code=in_code and method.`type`= in_type and method.name != in_method_name;
1137
	else
1138
	 	select 0 as test;
1139
	end if;
1140

    
1141
END//
1142
DELIMITER ;
1143

    
1144
-- 프로시저 nerv_icde_xxxx.check_overlap_ip 구조 내보내기
1145
DELIMITER //
1146
CREATE PROCEDURE `check_overlap_ip`(IN `in_system_domain_id` INT, IN `in_node_id` INT, IN `in_port_id` INT)
1147
BEGIN		
1148
	declare logical_port int;
1149
	declare sub_domain_id int;
1150
	declare lock_state int;
1151
	
1152
	delete from network_temp;	
1153
	Select sub_system_domain_id into sub_domain_id from node where id = in_node_id;	
1154
	select port_group into logical_port from domain_system_port as A where A.domain_system_id = sub_domain_id and A.port_num = in_port_id;
1155

    
1156
	call check_overlap_ip_recursion( in_node_id , logical_port , in_node_id , logical_port , 10 );	
1157
	
1158
	update network set collision = 1 where (node_id , ip , port)
1159
	 in ( select node_id , ip , port from network_temp where ip in ( select ip from network_temp as A group by ip having count(*) > 1  ) );	
1160
	update network set collision = 0 where (node_id , ip , port)
1161
	 in ( select node_id , ip , port from network_temp where ip in ( select ip from network_temp as A group by ip having count(*) = 1  ) );
1162

    
1163
	select node.name,  network.port, network.ip, network.mask, network.description from network
1164
	 join node on network.node_id = node.Id where collision = 1 and node.systemdomain_id = in_system_domain_id 
1165
	 and (network.node_id , network.ip) in (select node_id , ip from network_temp);	
1166
END//
1167
DELIMITER ;
1168

    
1169
-- 프로시저 nerv_icde_xxxx.check_overlap_ip_recursion 구조 내보내기
1170
DELIMITER //
1171
CREATE PROCEDURE `check_overlap_ip_recursion`(IN `in_parent_node_id` INT, IN `in_parent_port_group` INT, IN `in_node_id` INT, IN `in_port_group` INT, IN `in_depth` INT)
1172
BEGIN
1173
	declare domain_id int;	
1174
	declare no_more_rows bool default false;		
1175
	declare child_node_id int;
1176
	declare child_port_group int;	
1177
	
1178
	DECLARE my_list CURSOR FOR select K.node_id , domain_system_port.port_group from
1179
		 		(
1180
				 	(
1181
					 	select s_node_id as node_id , s_sub_system_id as sub_system_id , s_port_id as port_id from network_link where
1182
						 							( d_node_id , d_port_id ) in ( select in_node_id, port_num from domain_system_port as A 
1183
													 where A.domain_system_id = domain_id and A.port_group = in_port_group )
1184
					)
1185
						union
1186
				 	(
1187
					 	select d_node_id , d_sub_system_id , d_port_id  from network_link where
1188
						 							( s_node_id , s_port_id ) in ( select in_node_id, port_num from domain_system_port as A
1189
													  where A.domain_system_id = domain_id and A.port_group = in_port_group )
1190
					) 
1191
				) as K
1192
				
1193
			join			
1194
				domain_system_port on K.sub_system_id = domain_system_port.domain_system_id and K.port_id = domain_system_port.port_num					
1195
	where
1196
			not ( K.node_id = in_parent_node_id and domain_system_port.port_group = in_parent_port_group );
1197

    
1198
	declare continue handler for not found set no_more_rows := TRUE;	
1199
	set max_sp_recursion_depth = 50;
1200
	
1201
	insert into network_temp select * from network where node_id = in_node_id and port = in_port_group;
1202
	
1203
	if in_depth > 0 then
1204
		select node.sub_system_domain_id into domain_id from node where node.Id = in_node_id; 	 
1205

    
1206
		open my_list;	
1207
		my_loop : loop		
1208
			fetch my_list into child_node_id , child_port_group;
1209
			if no_more_rows then
1210
				close my_list;
1211
				leave my_loop;
1212
			end if;		
1213
				
1214
			call check_overlap_ip_recursion( in_node_id, in_port_group , child_node_id , child_port_group , in_depth - 1 );
1215
		
1216
		end loop my_loop;		
1217
	end if;	
1218
END//
1219
DELIMITER ;
1220

    
1221
-- 프로시저 nerv_icde_xxxx.check_system_lock_component 구조 내보내기
1222
DELIMITER //
1223
CREATE PROCEDURE `check_system_lock_component`(IN `in_domain_id` INT, IN `in_component_id` INT)
1224
BEGIN
1225

    
1226
	if(check_system_lock_domain(in_domain_id)) then
1227
		if(check_system_lock_component_f(in_component_id)) then
1228
			select 1 as return_value;
1229
		else
1230
			select 0 as return_value;
1231
		end if;
1232
	else
1233
		select 0 as return_value;
1234
	end if;
1235

    
1236
END//
1237
DELIMITER ;
1238

    
1239
-- 프로시저 nerv_icde_xxxx.check_system_lock_domain 구조 내보내기
1240
DELIMITER //
1241
CREATE PROCEDURE `check_system_lock_domain`(IN `in_domain_id` INT)
1242
BEGIN
1243

    
1244
	if(check_system_lock_domain(in_domain_id)) then
1245
		select 1 as return_value;
1246
	else
1247
		select 0 as return_value;
1248
	end if;
1249
END//
1250
DELIMITER ;
1251

    
1252
-- 프로시저 nerv_icde_xxxx.check_system_lock_interface 구조 내보내기
1253
DELIMITER //
1254
CREATE PROCEDURE `check_system_lock_interface`(IN `in_domain_id` INT, IN `in_interface_name` VARCHAR(50))
1255
BEGIN
1256

    
1257
	if(check_system_lock_interface(in_domain_id, in_interface_name)) then
1258
		select 1 as return_value;
1259
	else
1260
		select 0 as return_value;
1261
	end if;
1262
END//
1263
DELIMITER ;
1264

    
1265
-- 프로시저 nerv_icde_xxxx.check_system_lock_networklink 구조 내보내기
1266
DELIMITER //
1267
CREATE PROCEDURE `check_system_lock_networklink`(IN `in_node_id` INT, IN `in_port` INT, IN `in_domain_id` INT)
1268
BEGIN
1269

    
1270
declare sub_domain_id int default 0;
1271

    
1272
select node.sub_system_domain_id into sub_domain_id from node where node.Id=in_node_id;
1273

    
1274
	if(check_system_lock_domain(in_domain_id)) then
1275
		if(check_system_lock_domainport(in_node_id,sub_domain_id,in_port)) then
1276
			select 1 as return_value;
1277
		else
1278
			select 0 as return_value;
1279
		end if;
1280
	else
1281
		select 0 as return_value;
1282
	end if;
1283

    
1284
END//
1285
DELIMITER ;
1286

    
1287
-- 프로시저 nerv_icde_xxxx.check_system_lock_node_port 구조 내보내기
1288
DELIMITER //
1289
CREATE PROCEDURE `check_system_lock_node_port`(IN `in_node_id` INT, IN `in_node_port` INT)
1290
BEGIN
1291

    
1292
	if(check_system_lock_node_port_f(in_node_id, in_node_port)) then
1293
		select 1 as return_value;
1294
	else
1295
		select 0 as return_value;
1296
	end if;
1297
END//
1298
DELIMITER ;
1299

    
1300
-- 프로시저 nerv_icde_xxxx.check_system_lock_objct 구조 내보내기
1301
DELIMITER //
1302
CREATE PROCEDURE `check_system_lock_objct`(IN `in_deploy_id` INT)
1303
BEGIN
1304

    
1305
	declare deploy_system_domain_id int default 0;
1306
	
1307
	select deployments.systemdomain_id into deploy_system_domain_id from deployments where id=in_deploy_id;
1308
	
1309
	if(check_system_lock_domain(deploy_system_domain_id)) then
1310
		select 1 as return_value;
1311
	else
1312
		select 0 as return_value;
1313
	end if;
1314
	
1315
END//
1316
DELIMITER ;
1317

    
1318
-- 프로시저 nerv_icde_xxxx.check_system_lock_proxy_class 구조 내보내기
1319
DELIMITER //
1320
CREATE PROCEDURE `check_system_lock_proxy_class`(IN `in_proxy_id` INT)
1321
BEGIN	
1322
	if(check_system_lock_proxy_class(in_proxy_id)) then	
1323
			select 1 as return_value;	
1324
	else
1325
		select 0 as return_value;
1326
	end if;
1327
END//
1328
DELIMITER ;
1329

    
1330
-- 프로시저 nerv_icde_xxxx.check_system_lock_proxy_object 구조 내보내기
1331
DELIMITER //
1332
CREATE PROCEDURE `check_system_lock_proxy_object`(IN `in_proxy_id` INT, IN `in_proxy_object_name` VARCHAR(50))
1333
BEGIN
1334
	if(check_system_lock_proxy_object_f(in_proxy_id, in_proxy_object_name)) then	
1335
			select 1 as return_value;	
1336
	else
1337
		select 0 as return_value;
1338
	end if;
1339
END//
1340
DELIMITER ;
1341

    
1342
-- 프로시저 nerv_icde_xxxx.check_system_lock_proxy_stub_ip 구조 내보내기
1343
DELIMITER //
1344
CREATE PROCEDURE `check_system_lock_proxy_stub_ip`(IN `in_custum_proxy_id` INT, IN `in_deploy_id` INT)
1345
BEGIN
1346

    
1347
	declare deploy_system_domain_id int default 0;
1348
	
1349
	select deployments.systemdomain_id into deploy_system_domain_id from deployments where id=in_deploy_id;
1350
	
1351
	if(check_system_lock_domain(deploy_system_domain_id)) then
1352
	  if(check_system_lock_proxy_public(in_custum_proxy_id)) then	  
1353
			select 1 as return_value;
1354
		else
1355
		 	select 0 as return_value;
1356
	   end if;
1357
	else
1358
		select 0 as return_value;
1359
	end if;
1360
END//
1361
DELIMITER ;
1362

    
1363
-- 프로시저 nerv_icde_xxxx.check_system_lock_stub_class 구조 내보내기
1364
DELIMITER //
1365
CREATE PROCEDURE `check_system_lock_stub_class`(IN `in_stub_id` INT)
1366
BEGIN
1367

    
1368
	if(check_system_lock_stub_class_f(in_stub_id)) then	
1369
			select 1 as return_value;	
1370
	else
1371
		select 0 as return_value;
1372
	end if;
1373

    
1374
END//
1375
DELIMITER ;
1376

    
1377
-- 프로시저 nerv_icde_xxxx.check_system_lock_stub_object 구조 내보내기
1378
DELIMITER //
1379
CREATE PROCEDURE `check_system_lock_stub_object`(IN `in_stub_id` INT, IN `in_stub_object_name` VARCHAR(50))
1380
BEGIN
1381
	if(check_system_lock_stub_object_f(in_stub_id, in_stub_object_name)) then	
1382
			select 1 as return_value;	
1383
	else
1384
		select 0 as return_value;
1385
	end if;
1386

    
1387
END//
1388
DELIMITER ;
1389

    
1390
-- 프로시저 nerv_icde_xxxx.componentEntityViewcomponentinfoList 구조 내보내기
1391
DELIMITER //
1392
CREATE PROCEDURE `componentEntityViewcomponentinfoList`(in_componentid int)
1393
BEGIN
1394
          
1395
     if loginTest() then
1396
         select 1 as test;
1397
         select id, systemdomain_id, name, seq, description  from component where id = in_componentid;         
1398
         
1399
     else
1400
         select 0 as test;
1401
     end if; 
1402
     
1403
End//
1404
DELIMITER ;
1405

    
1406
-- 프로시저 nerv_icde_xxxx.componentEntityViewNewcomponentEntity 구조 내보내기
1407
DELIMITER //
1408
CREATE PROCEDURE `componentEntityViewNewcomponentEntity`(in_diagrame_id int,
1409
                                                                            in_component_id int,
1410
                                                                            in_position_x   int,
1411
                                                                            in_position_y   int,
1412
                                                                            in_size         int)
1413
BEGIN        
1414
        if loginTest() then
1415
                select 1 as test;
1416
                                
1417
                if componentEntityCheck(in_diagrame_id, in_component_id) then
1418
                  update umlcomponent set position_x=in_position_x,position_y=in_position_y,size=in_size where diagrame_id=in_diagrame_id and component_id=in_component_id;
1419
                else      
1420
                  insert into umlcomponent(diagrame_id, component_id, position_x, position_y, size)
1421
                                  values(in_diagrame_id, in_component_id, in_position_x, in_position_y,in_size);
1422
                end if;
1423
                
1424
                select LAST_INSERT_ID();               
1425
        else
1426
                select 0 as test;
1427
        end if;
1428
END//
1429
DELIMITER ;
1430

    
1431
-- 프로시저 nerv_icde_xxxx.componentsNewcomponent 구조 내보내기
1432
DELIMITER //
1433
CREATE PROCEDURE `componentsNewcomponent`(insystemdomainid int,
1434
                                                             inname varchar(50),
1435
                                                             indescription text)
1436
BEGIN
1437

    
1438

    
1439
     if loginTest() then
1440
         select 1 as test;
1441
         insert into component(systemdomain_id, name, description)
1442
                        values(insystemdomainid, inname, indescription);
1443
         select LAST_INSERT_ID();
1444
         
1445
     else
1446
         select 0 as test;
1447
     end if;
1448
     
1449
     
1450
     
1451
End//
1452
DELIMITER ;
1453

    
1454
-- 프로시저 nerv_icde_xxxx.componentViewDeletecomponent 구조 내보내기
1455
DELIMITER //
1456
CREATE PROCEDURE `componentViewDeletecomponent`(in_component_id int, in_systemdomain_id int)
1457
BEGIN
1458

    
1459
 
1460
        if loginTest() then
1461
                select 1 as test;
1462
                delete from component where
1463
                 id=in_component_id and systemdomain_id = in_systemdomain_id;                       
1464
        else
1465
                select 0 as test;
1466
        end if;
1467
END//
1468
DELIMITER ;
1469

    
1470
-- 프로시저 nerv_icde_xxxx.ComponentViewEditComponent 구조 내보내기
1471
DELIMITER //
1472
CREATE PROCEDURE `ComponentViewEditComponent`(in_component_id int, 
1473
                                                                 in_systemdomain_id int,                
1474
                                                                      in_name varchar(100),
1475
                                                                      in_description  varchar(100))
1476
BEGIN
1477

    
1478
        if loginTest() then
1479
                select 1 as test;
1480
                       update component set name=in_name, description=in_description
1481
                                    where id=in_component_id and systemdomain_id=in_systemdomain_id;
1482
        else
1483
                select 0 as test;
1484
        end if;
1485
END//
1486
DELIMITER ;
1487

    
1488
-- 프로시저 nerv_icde_xxxx.componentViewList 구조 내보내기
1489
DELIMITER //
1490
CREATE PROCEDURE `componentViewList`(indomainid int)
1491
BEGIN
1492

    
1493

    
1494

    
1495
     if loginTest() then
1496
         select 1 as test;
1497
         select Id, systemdomain_id, name, seq, description from component where systemdomain_id = indomainid;         
1498
         
1499
     else
1500
         select 0 as test;
1501
     end if;
1502
     
1503
     
1504
     
1505
End//
1506
DELIMITER ;
1507

    
1508
-- 프로시저 nerv_icde_xxxx.copy_node_port_talble 구조 내보내기
1509
DELIMITER //
1510
CREATE PROCEDURE `copy_node_port_talble`(IN `in_copy_node_id` INT, IN `in_copy_domain_id` INT, IN `in_copy_subsystem_id` INT, IN `in_new_node_id` INT, IN `in_new_domain_id` INT)
1511
BEGIN
1512

    
1513
	if logintest() then
1514
  		select 1 as test;
1515
		insert into node_port (node_port.id, node_port.systemdomain_id, node_port.sub_system_domain_id, node_port.port_group)
1516
   	select in_new_node_id, in_new_domain_id, in_copy_subsystem_id, node_port.port_group from node_port where id=in_copy_node_id and systemdomain_id=in_copy_domain_id; 
1517
  	else 
1518
    	select 0 as test;
1519
   end if;
1520
END//
1521
DELIMITER ;
1522

    
1523
-- 프로시저 nerv_icde_xxxx.coustim_proxyViewlistinfo 구조 내보내기
1524
DELIMITER //
1525
CREATE PROCEDURE `coustim_proxyViewlistinfo`(IN `in_node_id` int, IN `in_component_id` int)
1526
BEGIN
1527
        if loginTest() then
1528
                select 1 as test;
1529
                  select a.id, a.deploy_id, a.proxy_interface_id, b.interface_name, b.class_name,
1530
						       a.object_id, a.stub_object_id, a.stub_ip, c.name, c.id, c.standard_port,
1531
								 a.object_name, a.public, a.original_id from 
1532
                    ((select id, deploy_id, proxy_interface_id, object_id, stub_object_id, stub_ip, object_name, public, original_id
1533
						   FROM custum_proxy where deploy_id in (select Id from deployments where node_id = in_node_id and component_id =in_component_id)) as a
1534
                    join
1535
                    (select id, interface_name, class_name, method_domain_id from proxy_interface_relation) as b on b.id = a.proxy_interface_id)
1536
                    join
1537
                    (select id, name, standard_port from domain_method) as c on c.id = b.method_domain_id;						  
1538
        else
1539
                select 0 as test;
1540
        end if;
1541
END//
1542
DELIMITER ;
1543

    
1544
-- 프로시저 nerv_icde_xxxx.coustim_stubViewlistinfo 구조 내보내기
1545
DELIMITER //
1546
CREATE PROCEDURE `coustim_stubViewlistinfo`(IN `in_node_id` int, IN `in_component_id` int)
1547
BEGIN
1548
        if loginTest() then
1549
                select 1 as test;
1550
                  select a.id, a.deploy_id, a.stub_interface_id, a.object_id, b.interface_name, b.class_name,
1551
						 c.name, c.id, c.standard_port, a.object_name, a.public, a.original_id from 
1552
                    (select id, deploy_id, stub_interface_id, object_id, object_name, public, original_id FROM custum_stub
1553
						   where deploy_id in (select Id from deployments where node_id = in_node_id and component_id =in_component_id)) as a
1554
                    join
1555
                    (select id, interface_name, class_name, method_domain_id from stub_interface_relation) as b on b.id = a.stub_interface_id
1556
                    join
1557
                    (select id, name, standard_port from domain_method) as c on c.id = b.method_domain_id;                 
1558
        else
1559
                select 0 as test;
1560
        end if;
1561
END//
1562
DELIMITER ;
1563

    
1564
-- 프로시저 nerv_icde_xxxx.coustum_proxyViewDeleteInterface 구조 내보내기
1565
DELIMITER //
1566
CREATE PROCEDURE `coustum_proxyViewDeleteInterface`(in_deploy_id int,
1567
                                                              in_interface_id int)
1568
BEGIN
1569
        if loginTest() then
1570
                select 1 as test;
1571
                delete from custum_proxy where deploy_id = in_deploy_id and proxy_interface_id = in_interface_id;
1572
        else
1573
                select 0 as test;
1574
        end if;
1575
END//
1576
DELIMITER ;
1577

    
1578
-- 프로시저 nerv_icde_xxxx.coustum_proxyViewNewobjectid 구조 내보내기
1579
DELIMITER //
1580
CREATE PROCEDURE `coustum_proxyViewNewobjectid`(in_deploy_id int,
1581
                                                                  in_interface_id int,
1582
                                                                  in_object_id int,
1583
                                                                  in_object_name varchar(100))
1584
BEGIN
1585
        if loginTest() then
1586
                select 1 as test;
1587
                insert into custum_proxy (deploy_id, proxy_interface_id, object_id, object_name)
1588
                                values(in_deploy_id, in_interface_id, in_object_id, in_object_name);
1589
        else
1590
                select 0 as test;
1591
        end if;
1592
END//
1593
DELIMITER ;
1594

    
1595
-- 프로시저 nerv_icde_xxxx.coustum_stubViewDeleteInterface 구조 내보내기
1596
DELIMITER //
1597
CREATE PROCEDURE `coustum_stubViewDeleteInterface`(in_deploy_id int,
1598
                                                              in_interface_id int)
1599
BEGIN
1600
        if loginTest() then
1601
                select 1 as test;
1602
                delete from custum_stub where deploy_id = in_deploy_id and proxy_interface_id = in_interface_id;
1603
        else
1604
                select 0 as test;
1605
        end if;
1606
END//
1607
DELIMITER ;
1608

    
1609
-- 프로시저 nerv_icde_xxxx.coustum_stubViewNewobjectid 구조 내보내기
1610
DELIMITER //
1611
CREATE PROCEDURE `coustum_stubViewNewobjectid`(in_deploy_id int,
1612
                                                                  in_interface_id int,
1613
                                                                  in_object_id int,
1614
                                                                  in_object_name varchar(100))
1615
BEGIN
1616
        if loginTest() then
1617
                select 1 as test;
1618
                insert into custum_stub (deploy_id, stub_interface_id, object_id, object_name)
1619
                                values(in_deploy_id, in_interface_id, in_object_id, in_object_name);
1620
        else
1621
                select 0 as test;
1622
        end if;
1623
END//
1624
DELIMITER ;
1625

    
1626
-- 프로시저 nerv_icde_xxxx.coustum_ViewEditobjectid 구조 내보내기
1627
DELIMITER //
1628
CREATE PROCEDURE `coustum_ViewEditobjectid`(IN `in_id` int, IN `in_object_id` int, IN `in_type` int, IN `in_public` int)
1629
BEGIN
1630
        if loginTest() then
1631
                select 1 as test;
1632
               if (in_type = 0) then
1633
                   update custum_proxy set object_id=in_object_id, public=in_public where id = in_id;
1634
               else
1635
                   update custum_stub set object_id=in_object_id, public=in_public where id = in_id;
1636
               end if;                
1637
        else
1638
                select 0 as test;
1639
        end if;
1640
END//
1641
DELIMITER ;
1642

    
1643
-- 프로시저 nerv_icde_xxxx.data_field_auto_seq 구조 내보내기
1644
DELIMITER //
1645
CREATE PROCEDURE `data_field_auto_seq`()
1646
BEGIN
1647

    
1648
	declare no_more_rows bool default false;
1649
	declare find_data_auto_id int;
1650
	declare find_membername varchar(50);
1651
	declare find_seq timestamp;
1652

    
1653
	DECLARE my_list CURSOR FOR 	
1654
	select data_field.data_auto_id, data_field.member_name, data_field.seq from data_field;
1655
 
1656
	declare continue handler for not found set no_more_rows := TRUE;
1657
	
1658
	set max_sp_recursion_depth = 50;		 	
1659
   
1660
		open my_list;	
1661
		my_loop : loop		
1662
			fetch my_list into find_data_auto_id, find_membername, find_seq;
1663
		
1664
			 if no_more_rows then
1665
				 close my_list;
1666
				 leave my_loop;
1667
			 end if;			 		
1668
			 		 
1669
			 	    call data_field_auto_seq_update(find_data_auto_id, find_membername, find_seq);
1670
					
1671
		end loop my_loop;		
1672
END//
1673
DELIMITER ;
1674

    
1675
-- 프로시저 nerv_icde_xxxx.data_field_auto_seq_update 구조 내보내기
1676
DELIMITER //
1677
CREATE PROCEDURE `data_field_auto_seq_update`(IN `in_data_auto_id` INT, IN `in_member_name` VARCHAR(50), IN `in_seq` TIMESTAMP)
1678
BEGIN
1679
	declare seq_count int default 0;	
1680
	
1681
	select count(data_field.seq) into seq_count from data_field
1682
	 where data_field.data_auto_id = in_data_auto_id and data_field.seq = in_seq;
1683
         
1684
   if seq_count > 1 then
1685
      select seq_count;
1686
		 update data_field set data_field.seq = DATE_ADD(in_seq, INTERVAL -seq_count second)
1687
		  where data_field.data_auto_id = in_data_auto_id and data_field.member_name=in_member_name;
1688
	end if;	
1689
END//
1690
DELIMITER ;
1691

    
1692
-- 프로시저 nerv_icde_xxxx.delete_subsystem_object 구조 내보내기
1693
DELIMITER //
1694
CREATE PROCEDURE `delete_subsystem_object`(IN `in_custum_id` INT, IN `in_custum_deploy_id` INT, IN `in_type` INT)
1695
BEGIN
1696
   declare subsystem_deploy_id int;
1697
	declare subsystem_proxy_count int;
1698
	declare subsystem_stub_count int;
1699
	declare subsystem_component_id int;	
1700
	declare no_more_rows bool default false;	
1701
	DECLARE my_list CURSOR FOR 
1702
			select deployments.id from deployments where deployments.node_id in (
1703
			select node.id from node where node.sub_system_domain_id in(
1704
			 select deployments.systemdomain_id from deployments where deployments.Id=in_custum_deploy_id));
1705
	declare continue handler for not found set no_more_rows := TRUE;		
1706

    
1707
	 if in_type = 0 then
1708
  		select 1 as test;	
1709
		 delete from custum_proxy where custum_proxy.original_id=in_custum_id
1710
		  and custum_proxy.original_deployment_id=in_custum_deploy_id
1711
		   and custum_proxy.Id !=in_custum_id and custum_proxy.deploy_id != in_custum_deploy_id;
1712
 else
1713
  	select 1 as test;
1714
 		 delete from custum_stub where custum_stub.original_id=in_custum_id
1715
		   and custum_stub.original_deployment_id=in_custum_deploy_id
1716
			 and custum_stub.Id !=in_custum_id and custum_stub.deploy_id != in_custum_deploy_id;
1717
 end if; 
1718

    
1719
set max_sp_recursion_depth = 50;
1720

    
1721
	open my_list;
1722
			my_loop : loop						
1723
				fetch my_list into subsystem_deploy_id;
1724
				if no_more_rows then				
1725
					close my_list;
1726
					leave my_loop;
1727
				end if;
1728
				
1729
				select count(custum_proxy.deploy_id) into subsystem_proxy_count from custum_proxy
1730
				 where custum_proxy.deploy_id = subsystem_deploy_id;
1731
 				select count(custum_stub.deploy_id) into subsystem_stub_count from custum_stub
1732
				  where custum_stub.deploy_id =subsystem_deploy_id; 				
1733
 				
1734
 				if subsystem_proxy_count = 0 and subsystem_stub_count=0 then 
1735
				 	select deployments.component_id into subsystem_component_id from deployments
1736
					  where deployments.Id = 	subsystem_deploy_id;
1737
 	 				  delete from component where component.id = subsystem_component_id;
1738
 	 			end if;
1739
	end loop my_loop;			
1740
END//
1741
DELIMITER ;
1742

    
1743
-- 프로시저 nerv_icde_xxxx.deployComponentViewInterfaceinfo 구조 내보내기
1744
DELIMITER //
1745
CREATE PROCEDURE `deployComponentViewInterfaceinfo`(IN `in_component_id` INT)
1746
BEGIN
1747

    
1748
 	if logintest() then
1749
 		select 1 as test;
1750
 		
1751
 		select a.id, a.method_domain_id, a.component_id, a.interface_name, b.name, a.class_name from
1752
  		(select stub_interface_relation.Id, stub_interface_relation.method_domain_id, stub_interface_relation.component_id
1753
		  , stub_interface_relation.interface_name, stub_interface_relation.class_name from stub_interface_relation where id in
1754
			(select stub_interface_id from custum_stub where deploy_id in
1755
			 (select id from deployments where component_id = in_component_id))) as a
1756
		join domain_method as b on a.method_domain_id = b.id;
1757
   else
1758
   	select 0 as test;
1759
   end if;
1760
END//
1761
DELIMITER ;
1762

    
1763
-- 프로시저 nerv_icde_xxxx.deploymentsViewDeploymentslist 구조 내보내기
1764
DELIMITER //
1765
CREATE PROCEDURE `deploymentsViewDeploymentslist`(
1766
	IN `in_systemdomainid` int,
1767
	IN `in_componentid` int
1768

    
1769
)
1770
BEGIN
1771
     if loginTest() then
1772
    select 1 as test;
1773
         select Id, node_id, component_id, systemdomain_id from deployments
1774
                     where systemdomain_id = in_systemdomainid and component_id = in_componentid;
1775
         
1776
     else
1777
         select 0 as test;
1778
     end if;       
1779
End//
1780
DELIMITER ;
1781

    
1782
-- 프로시저 nerv_icde_xxxx.deploymentsViewIdInfo 구조 내보내기
1783
DELIMITER //
1784
CREATE PROCEDURE `deploymentsViewIdInfo`(in_nodeid int,
1785
                                                            in_componentid int)
1786
BEGIN
1787

    
1788
     if loginTest() then
1789
    select 1 as test;
1790
         select Id from deployments where node_id = in_nodeid and component_id = in_componentid;
1791
         
1792
     else
1793
         select 0 as test;
1794
     end if;
1795
     
1796
     
1797
     
1798
End//
1799
DELIMITER ;
1800

    
1801
-- 프로시저 nerv_icde_xxxx.deployments_bindTableNewBind 구조 내보내기
1802
DELIMITER //
1803
CREATE PROCEDURE `deployments_bindTableNewBind`(IN `in_deployment_id` INT, IN `in_node_id` INT, IN `in_port` INT, IN `in_ip` VARCHAR(255))
1804
BEGIN
1805

    
1806
declare total_num int;
1807

    
1808
set total_num = 0;
1809

    
1810
	if logintest() then
1811
		select 1 as test;
1812
		select count(*) into total_num from deployments_bind where deployments_bind.deployment_id = in_deployment_id;
1813
		
1814
		if total_num = 0 then
1815
			insert into deployments_bind (deployments_bind.deployment_id, deployments_bind.node_id, deployments_bind.port, deployments_bind.ip)
1816
			       values(in_deployment_id,in_node_id,in_port,in_ip);
1817
		else
1818
			update deployments_bind set deployments_bind.port = in_port, deployments_bind.ip = in_ip
1819
			 where deployments_bind.deployment_id = in_deployment_id;
1820
		end if;
1821
   else
1822
      select 0 as test;
1823
   end if;
1824
END//
1825
DELIMITER ;
1826

    
1827
-- 프로시저 nerv_icde_xxxx.deployments_bind_table_info 구조 내보내기
1828
DELIMITER //
1829
CREATE PROCEDURE `deployments_bind_table_info`(IN `in_deployment_id` INT)
1830
BEGIN
1831
	if logintest() then
1832
		select 1 as test;
1833
		select deployments_bind.node_id, deployments_bind.port, deployments_bind.ip from deployments_bind
1834
		 where deployments_bind.deployment_id = in_deployment_id;
1835
	else 
1836
		select 0 as test;
1837
	end if;
1838
END//
1839
DELIMITER ;
1840

    
1841
-- 프로시저 nerv_icde_xxxx.diagramViewList 구조 내보내기
1842
DELIMITER //
1843
CREATE PROCEDURE `diagramViewList`(IN `indomainid` int)
1844
BEGIN
1845
     if loginTest() then
1846
         select 1 as test;
1847
         select Id, domain_id, type, name, description
1848
          from diagrame where domain_id = indomainid;          
1849
     else
1850
         select 0 as test;
1851
     end if;      
1852
End//
1853
DELIMITER ;
1854

    
1855
-- 프로시저 nerv_icde_xxxx.diagramViewNewDiagram 구조 내보내기
1856
DELIMITER //
1857
CREATE PROCEDURE `diagramViewNewDiagram`(in_domainid int,
1858
                                                            in_type  int,
1859
                                                            in_name  varchar(100),
1860
                                                            in_description  text)
1861
BEGIN        
1862
        if loginTest() then
1863
                select 1 as test;                
1864
                insert into diagrame(domain_id, type, name, description )
1865
                                 values(in_domainid, in_type, in_name, in_description);
1866
                select LAST_INSERT_ID();               
1867
        else
1868
                select 0 as test;
1869
        end if;
1870
END//
1871
DELIMITER ;
1872

    
1873
-- 프로시저 nerv_icde_xxxx.domainAccountViewJoinPrivateDomain 구조 내보내기
1874
DELIMITER //
1875
CREATE PROCEDURE `domainAccountViewJoinPrivateDomain`(IN `in_domainname` varchar(100), IN `in_domainupperid` int, IN `in_domaintype` varchar(100))
1876
BEGIN
1877
     DECLARE domain_id int;
1878
     DECLARE flag tinyint;
1879
     set domain_id = 0;
1880
     set flag =0;
1881
     
1882
        if loginTest() then
1883
           select 1 as test;           
1884
           select exitDomainId(in_domainname, in_domainupperid, in_domaintype) into domain_id;           
1885
           select existMemberDomain(domain_id, @nervuser, in_domaintype) into flag;
1886
           
1887
           if(flag <= 0) then         
1888
                   if(in_domaintype ='data') then
1889
                     insert into members_domain_data(domain_id, user_id, member_type) values(domain_id,@nervuser,'guest');
1890
                   end if;
1891
                   if(in_domaintype ='method') then
1892
                      insert into members_domain_method(domain_id, user_id, member_type) values(domain_id,@nervuser,'guest');              
1893
                   end if;
1894
                   if(in_domaintype ='system') then
1895
                       insert into members_domain_system(domain_id, user_id, member_type) values(domain_id,@nervuser,'guest');
1896
                   end if;                      
1897
           end if;           
1898
           select domain_id as test;
1899
        else
1900
                select 0 as test;
1901
        end if;
1902
END//
1903
DELIMITER ;
1904

    
1905
-- 프로시저 nerv_icde_xxxx.domainDataInfo 구조 내보내기
1906
DELIMITER //
1907
CREATE PROCEDURE `domainDataInfo`(domain_idkey int, domaintype varchar(50))
1908
BEGIN
1909
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
1910
                select 1 as test;
1911
                  select id , upper_id, name , user_id, public, create_date, last_update, description
1912
                    from domain_data where id=domain_idkey;
1913
        else
1914
                select 0 as test;
1915
        end if;
1916
END//
1917
DELIMITER ;
1918

    
1919
-- 프로시저 nerv_icde_xxxx.domainId 구조 내보내기
1920
DELIMITER //
1921
CREATE PROCEDURE `domainId`(domainnamekey varchar(100), domaintype varchar(100))
1922
BEGIN
1923
        
1924
        if loginTest() then
1925
                select 1 as test;
1926

    
1927
                       if(domaintype='data') then
1928
                        select id from domain_data where name = domainnamekey;
1929
                       end if;
1930
                       if(domaintype='method') then
1931
                        select id from domain_method where name = domainnamekey;
1932
                       end if;
1933
                       if(domaintype='system') then
1934
                        select id from domain_system where name = domainnamekey; 
1935
                       end if;
1936

    
1937
       else
1938
               select 0 as test;
1939
       end if;
1940
END//
1941
DELIMITER ;
1942

    
1943
-- 프로시저 nerv_icde_xxxx.domainLogicalPortViewDeletePort 구조 내보내기
1944
DELIMITER //
1945
CREATE PROCEDURE `domainLogicalPortViewDeletePort`(IN `in_system_domain_id` int, IN `in_port_group` int)
1946
BEGIN
1947
     if loginTest() and logical_port_group_count(in_system_domain_id, in_port_group)=0 then
1948
         select 1 as test;
1949
         delete from domain_system_logical_port where domain_system_id = in_system_domain_id and port_group = in_port_group;
1950
     else
1951
         select 2 as test;
1952
     end if;
1953
End//
1954
DELIMITER ;
1955

    
1956
-- 프로시저 nerv_icde_xxxx.domainLogicalPortViewNewPortGroup 구조 내보내기
1957
DELIMITER //
1958
CREATE PROCEDURE `domainLogicalPortViewNewPortGroup`(in_domain_id int, in_group int)
1959
BEGIN
1960
     if loginTest() and logical_port_group_count(in_domain_id, in_group)=0 then
1961
         select 1 as test;
1962
         insert into domain_system_logical_port(domain_system_id, port_group)
1963
                           values(in_domain_id, in_group);
1964
     else
1965
         select 0 as test;
1966
     end if;
1967
End//
1968
DELIMITER ;
1969

    
1970
-- 프로시저 nerv_icde_xxxx.domainLogicalViewlist 구조 내보내기
1971
DELIMITER //
1972
CREATE PROCEDURE `domainLogicalViewlist`(IN `in_domain_id` INT)
1973
BEGIN
1974

    
1975
  if logintest() then
1976
  select 1 as test;
1977
  	select port_group from domain_system_logical_port where domain_system_id = in_domain_id;
1978
  else
1979
    select 0 as test;
1980
  end if;
1981
END//
1982
DELIMITER ;
1983

    
1984
-- 프로시저 nerv_icde_xxxx.domainMethodInfo 구조 내보내기
1985
DELIMITER //
1986
CREATE PROCEDURE `domainMethodInfo`(domain_idkey int, domaintype varchar(50))
1987
BEGIN
1988
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
1989
                select 1 as test;
1990
                  select id , upper_id, name , user_id, public, standard_port, create_date, last_update, description
1991
                    from domain_method where id=domain_idkey;
1992
        else
1993
                select 0 as test;
1994
        end if;
1995
END//
1996
DELIMITER ;
1997

    
1998
-- 프로시저 nerv_icde_xxxx.domainName 구조 내보내기
1999
DELIMITER //
2000
CREATE PROCEDURE `domainName`(idkey varchar(100), domaintype varchar(100))
2001
BEGIN
2002
        
2003
        if loginTest() then
2004
                select 1 as test;
2005
                       if(domaintype='data') then
2006
                        select name from domain_data where id = idkey;
2007
                       end if;
2008
                       if(domaintype='method') then
2009
                        select name from domain_method where id = idkey;
2010
                       end if;
2011
                       if(domaintype='system') then
2012
                        select name from domain_system where id = idkey; 
2013
                       end if;
2014

    
2015
       else
2016
               select 0 as test;
2017
       end if;
2018
END//
2019
DELIMITER ;
2020

    
2021
-- 프로시저 nerv_icde_xxxx.domainnametoid 구조 내보내기
2022
DELIMITER //
2023
CREATE PROCEDURE `domainnametoid`(domain_name varchar(100), domaintype varchar(100))
2024
BEGIN
2025
        
2026
        if loginTest() then
2027
                select 1 as test;
2028
                       if(domaintype='data') then
2029
                        select id from domain_data where name = domain_name;
2030
                       end if;
2031
                       if(domaintype='method') then
2032
                        select id from domain_method where name = domain_name;
2033
                       end if;
2034
                       if(domaintype='system') then
2035
                        select id from domain_system where name = domain_name;
2036
                       end if;
2037

    
2038
       else
2039
               select 0 as test;
2040
       end if;
2041
END//
2042
DELIMITER ;
2043

    
2044
-- 프로시저 nerv_icde_xxxx.domainPortViewDeletePort 구조 내보내기
2045
DELIMITER //
2046
CREATE PROCEDURE `domainPortViewDeletePort`(in_system_domain_id int, in_port_num int)
2047
BEGIN
2048
     if loginTest() then
2049
         select 1 as test;
2050
         delete from domain_system_port where domain_system_id = in_system_domain_id and port_num = in_port_num;
2051
     else
2052
         select 0 as test;
2053
     end if;
2054
End//
2055
DELIMITER ;
2056

    
2057
-- 프로시저 nerv_icde_xxxx.domainPortViewEditPort 구조 내보내기
2058
DELIMITER //
2059
CREATE PROCEDURE `domainPortViewEditPort`(IN `in_system_domain_id` int, IN `in_port_key` int, IN `in_port_edit` int, IN `in_port_group` int, IN `in_description_edit` varchar(100))
2060
BEGIN
2061
     if loginTest() then
2062
         select 1 as test;
2063
         UPDATE domain_system_port set port_num=in_port_edit, port_group=in_port_group, description=in_description_edit
2064
			 where domain_system_id = in_system_domain_id and port_num = in_port_key;
2065
     else
2066
         select 0 as test;
2067
     end if;
2068
End//
2069
DELIMITER ;
2070

    
2071
-- 프로시저 nerv_icde_xxxx.domainPortViewNewPort 구조 내보내기
2072
DELIMITER //
2073
CREATE PROCEDURE `domainPortViewNewPort`(in_domain_id int, in_port int, in_port_group int, in_description varchar(100))
2074
BEGIN
2075
     if loginTest() then
2076
         select 1 as test;
2077
         insert into domain_system_port(domain_system_id, port_num, port_group, description)
2078
                           values(in_domain_id, in_port, in_port_group, in_description);
2079
     else
2080
         select 0 as test;
2081
     end if;
2082
End//
2083
DELIMITER ;
2084

    
2085
-- 프로시저 nerv_icde_xxxx.domainviewCheckOverlapDomainName 구조 내보내기
2086
DELIMITER //
2087
CREATE PROCEDURE `domainviewCheckOverlapDomainName`(IN `in_domain_id` INT, IN `in_upper_id` INT, IN `in_domain_name` VARCHAR(50), IN `in_domain_type` VARCHAR(50))
2088
BEGIN
2089
  if loginTest() then
2090
     select 1 as test;
2091
     if in_domain_type='data' then
2092
     		select * from domain_data where domain_data.upper_id=in_upper_id and domain_data.name=in_domain_name and domain_data.id != in_domain_id;
2093
     end if;
2094
     
2095
     if in_domain_type='method' then
2096
     	   select * from domain_method where domain_method.upper_id=in_upper_id and domain_method.name=in_domain_name and domain_method.id != in_domain_id;
2097
     end if;
2098
     
2099
     if in_domain_type='system' then
2100
         select * from domain_system where domain_system.upper_id=in_upper_id and domain_system.name=in_domain_name and domain_system.id != in_domain_id;
2101
     end if;
2102
  else
2103
  		select 0 as test;
2104
  end if;
2105
END//
2106
DELIMITER ;
2107

    
2108
-- 프로시저 nerv_icde_xxxx.domainViewDeleteDomain 구조 내보내기
2109
DELIMITER //
2110
CREATE PROCEDURE `domainViewDeleteDomain`(domain_id int, domain_type varchar(50) )
2111
BEGIN
2112
        if loginTest() and domainWriteTest(domain_id, domain_type) then
2113
                select 1 as test;
2114
                
2115
                if(domain_type = 'method') then
2116
                        delete from domain_method where id=domain_id;
2117
               end if;
2118

    
2119
                if (domain_type = 'data') then
2120
                        delete from domain_data where id=domain_id;
2121
               end if;
2122

    
2123
                if (domain_type = 'system') then
2124
                        delete from domain_system where id=domain_id;
2125
                end if;  
2126

    
2127
        else
2128
                select 0 as test;
2129
        end if;
2130
END//
2131
DELIMITER ;
2132

    
2133
-- 프로시저 nerv_icde_xxxx.domainViewDeleteParentDomain 구조 내보내기
2134
DELIMITER //
2135
CREATE PROCEDURE `domainViewDeleteParentDomain`(domain_idvalue int, domaintype varchar(100), parentdomain_idvalue int, parentdomain_type int)
2136
BEGIN
2137

    
2138
        if loginTest() and domainWriteTest(domain_idvalue, domaintype) then
2139
                select 1 as test;
2140
                if parentdomain_type = 0 then
2141
                   delete from inheritance_data_data where domain_id = domain_idvalue and parent_domain_id = parentdomain_idvalue;
2142
               end if;
2143
                if parentdomain_type = 1 then
2144
                   delete from inheritance_method_data where domain_id = domain_idvalue and parent_domain_id = parentdomain_idvalue;
2145
               end if;
2146
                if parentdomain_type = 2 then
2147
                   delete from inheritance_method_method where domain_id = domain_idvalue and parent_domain_id = parentdomain_idvalue;
2148
               end if;
2149
                if parentdomain_type = 3 then
2150
                   delete from inheritance_system_method where domain_id = domain_idvalue and parent_domain_id = parentdomain_idvalue;
2151
               end if;
2152
         else
2153
                select 0 as test;
2154
        end if;
2155
END//
2156
DELIMITER ;
2157

    
2158
-- 프로시저 nerv_icde_xxxx.domainViewDomainInfo 구조 내보내기
2159
DELIMITER //
2160
CREATE PROCEDURE `domainViewDomainInfo`(domain_idkey int, domaintype varchar(50))
2161
BEGIN
2162
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
2163
                select 1 as test;
2164
                
2165
                if(domaintype = 'data') then
2166
                   select a.name , u.user_id, u.userdesc , b.* , c.mcnt, d.*, a.public, a.description, a.create_date, a.last_update  from
2167
                                ( select * from domain_data where id=domain_idkey) as a
2168
                   join        ( select user_id,description as userdesc from users ) as u on a.user_id = u.user_id
2169
                   join        ( select count(name) as scnt from data where domain_id=domain_idkey ) as b
2170
                   join        ( select count(domain_id) as mcnt from inheritance_method_data where parent_domain_id=domain_idkey ) as c
2171
                   join        ( select count(name) as icnt from interface where domain_id=domain_idkey ) as d;
2172
                end if;
2173
                if(domaintype = 'method') then
2174
                   select a.name , u.user_id, u.userdesc , a.standard_port,  b.* , c.mcnt,d.*, a.public, a.description, a.create_date, a.last_update from
2175
                                 ( select * from domain_method where id=domain_idkey) as a
2176
                   join        ( select user_id,description as userdesc from users ) as u on a.user_id = u.user_id
2177
                   join        ( select count(domain_id) as scnt from inheritance_method_data where domain_id=domain_idkey ) as b
2178
                   join        ( select count(name) as mcnt from method where domain_id=domain_idkey ) as c
2179
                   join        ( select count(domain_id) as icnt from interface where domain_id=domain_idkey ) as d;
2180
                end if;
2181
                if(domaintype = 'system') then
2182
                   select a.name , u.user_id, u.userdesc , b.* , c.mcnt,d.*, a.public, a.description,a.create_date, a.last_update  from
2183
                                ( select * from domain_system where id=domain_idkey) as a
2184
                   join        ( select user_id,description as userdesc from users ) as u on a.user_id = u.user_id
2185
                   join        ( select count(name) as scnt from data where domain_id=domain_idkey ) as b
2186
                   join        ( select count(name) as mcnt from method where domain_id=domain_idkey ) as c
2187
                   join        ( select count(name) as icnt from interface where domain_id=domain_idkey ) as d;
2188
                end if;
2189

    
2190
        else
2191
                select 0 as test;
2192
        end if;
2193
END//
2194
DELIMITER ;
2195

    
2196
-- 프로시저 nerv_icde_xxxx.domainViewEditDomain 구조 내보내기
2197
DELIMITER //
2198
CREATE PROCEDURE `domainViewEditDomain`(IN `domain_idkey` int, IN `domaintypevalue` varchar(50), IN `edit_domain_name` varchar(100), IN `standardportvalue` smallint(5) unsigned, IN `publicvalue` bool, IN `descriptionvalue` text)
2199
BEGIN
2200
        declare cnt int;
2201
        set cnt = 0;
2202

    
2203
        if loginTest() and domainWriteTest(domain_idkey, domaintypevalue) then
2204
                select 1 as test;
2205
                if (domaintypevalue='data') then
2206
                        update domain_data set name=edit_domain_name, public=publicvalue,description=descriptionvalue where id=domain_idkey;
2207
                end if;
2208
                if (domaintypevalue='method') then
2209
                        update domain_method set  name=edit_domain_name, standard_port=standardportvalue, public=publicvalue,description=descriptionvalue
2210
								 where id=domain_idkey;
2211
                end if;
2212
                if (domaintypevalue='system') then
2213
                        update domain_system set  name=edit_domain_name, public=publicvalue,description=descriptionvalue where id=domain_idkey;
2214
                end if;
2215
                       
2216
        else
2217
                select 0 as test;
2218
        end if;
2219
END//
2220
DELIMITER ;
2221

    
2222
-- 프로시저 nerv_icde_xxxx.domainViewEditDomainName 구조 내보내기
2223
DELIMITER //
2224
CREATE PROCEDURE `domainViewEditDomainName`(domain_idkey int,
2225
                                                               domaintypevalue varchar(50),
2226
                                                               edit_domain_name varchar(100))
2227
BEGIN
2228
        declare cnt int;
2229
        set cnt = 0;
2230

    
2231
        if loginTest() and domainWriteTest(domain_idkey, domaintypevalue) then
2232
                select 1 as test;
2233
                if (domaintypevalue='data') then
2234
                        update domain_data set name=edit_domain_name where id=domain_idkey;
2235
                end if;
2236
                if (domaintypevalue='method') then
2237
                        update domain_method set  name=edit_domain_name where id=domain_idkey;
2238
                end if;
2239
                if (domaintypevalue='system') then
2240
                        update domain_system set  name=edit_domain_name where id=domain_idkey;
2241
                end if;                       
2242
        else
2243
                select 0 as test;
2244
        end if;
2245
END//
2246
DELIMITER ;
2247

    
2248
-- 프로시저 nerv_icde_xxxx.domainViewEditUpperIDDomain 구조 내보내기
2249
DELIMITER //
2250
CREATE PROCEDURE `domainViewEditUpperIDDomain`(in_domain_id_key int, in_edit_upper_id int, in_domain_type varchar(50))
2251
BEGIN
2252
       if loginTest() and domainWriteTest(in_domain_id_key, in_domain_type) then
2253
                select 1 as test;
2254
                if (in_domain_type='data') then
2255
                        update domain_data set upper_id=in_edit_upper_id where id=in_domain_id_key;
2256
                end if;
2257
                if (in_domain_type='method') then
2258
                        update domain_method set  upper_id=in_edit_upper_id where id=in_domain_id_key;
2259
                end if;
2260
                if (in_domain_type='system') then
2261
                        update domain_system set  upper_id=in_edit_upper_id where id=in_domain_id_key;
2262
                end if;
2263
                       
2264
        else
2265
                select 0 as test;
2266
        end if;
2267
END//
2268
DELIMITER ;
2269

    
2270
-- 프로시저 nerv_icde_xxxx.domainViewNewDomain 구조 내보내기
2271
DELIMITER //
2272
CREATE PROCEDURE `domainViewNewDomain`(domaintype varchar(50),
2273
                                                          upper_idvalue  int,
2274
                                                           namevalue varchar(100),
2275
                                                           standardportvalue int,
2276
                                                           publicvalue bool,
2277
                                                           descriptionvalue text)
2278
BEGIN
2279
        declare nd bool;
2280
        declare cnt int default 0;
2281
        
2282
        set nd = false;
2283
        set @logdate = DATE_FORMAT(DATE_ADD(SYSDATE(), INTERVAL 0 DAY), '%Y%m%d%H%i%s');
2284
        
2285
        
2286
        if loginTest() and newDomainTest() then
2287
                select 1 as test;
2288
                if (domaintype='data') then
2289
                insert into domain_data(upper_id, name, user_id, public, create_date, last_update,description )
2290
                                 values(upper_idvalue, namevalue, @nervuser, publicvalue, @logdate, @logdate,descriptionvalue);
2291
                select LAST_INSERT_ID(); 
2292
                end if;
2293
                if (domaintype='method') then
2294
                insert into domain_method(upper_id, name, user_id, public,  standard_port, create_date, last_update,description )
2295
                                 values(upper_idvalue, namevalue, @nervuser, publicvalue, standardportvalue, @logdate, @logdate,descriptionvalue);
2296
                select LAST_INSERT_ID();
2297
                end if;
2298
                if (domaintype='system') then
2299
                 select count(name) into cnt from domain_system where name=namevalue and upper_id = upper_idvalue;
2300
                 if cnt > 0 then
2301
                        select 0 as test;
2302
                else
2303
                       insert into domain_system(upper_id, name, user_id, public, create_date, last_update,description )
2304
                                          values(upper_idvalue, namevalue, @nervuser, publicvalue, @logdate, @logdate,descriptionvalue);
2305
                       select LAST_INSERT_ID();                
2306
                end if;
2307
               end if;
2308
        else
2309
                select 0 as test;
2310
        end if;
2311
END//
2312
DELIMITER ;
2313

    
2314
-- 프로시저 nerv_icde_xxxx.domainViewNewParentCandidateList 구조 내보내기
2315
DELIMITER //
2316
CREATE PROCEDURE `domainViewNewParentCandidateList`(IN `domain_idkey` int, IN `domaintype` varchar(50), IN `parentdomain_type` int)
2317
BEGIN
2318
        if loginTest() and domainWriteTest(domain_idkey, domaintype) then
2319
                select 1 as test;
2320
                if( supermanagerTest(@nervuser) ) then
2321
                       if(parentdomain_type=0) then                                    
2322
                                select * from domain_data where id not in
2323
                                 (select parent_domain_id from inheritance_data_data where domain_id=domain_idkey) order by id desc;
2324
                        end if;
2325
                           if(parentdomain_type=1) then                                    
2326
                                select * from domain_data where id not in
2327
                                 (select parent_domain_id from inheritance_method_data where domain_id=domain_idkey) order by id desc;
2328
                        end if;
2329
                           if(parentdomain_type=2) then                                    
2330
                                select * from domain_method where id not in
2331
                                 (select parent_domain_id from inheritance_method_method where domain_id=domain_idkey) order by id desc;
2332
                        end if;
2333
                           if(parentdomain_type=3) then                                    
2334
                                select * from domain_system where id not in
2335
                                 (select parent_domain_id from inheritance_system_method where domain_id=domain_idkey) order by id desc;
2336
                        end if;
2337
                else
2338
                        if(parentdomain_type=0) then
2339
                         select * from domain_data where (user_id=@nervuser or public =1)
2340
                                                     and (id not in (select parent_domain_id FROM inheritance_data_data where domain_id= domain_idkey))
2341
                                                     and (id != 0);
2342
                        end if;
2343
                        if(parentdomain_type=1) then
2344
                          select * from domain_data where (user_id=@nervuser or public =1)
2345
                                                     and (id not in (select parent_domain_id FROM inheritance_method_data where domain_id= domain_idkey))
2346
                                                     and (id != 0);
2347
                        end if;
2348
                        if(parentdomain_type=2) then
2349
                          select * from domain_method where (user_id=@nervuser or public =1)
2350
                                                     and (id not in (select parent_domain_id FROM inheritance_method_method where domain_id= domain_idkey));                               
2351
                        end if;
2352
                        if(parentdomain_type=3) then
2353
                                select * from
2354
                                (
2355
                                        (
2356
                                          select domain_id from members_domain_system where user_id=@nervuser 
2357
														and (member_type='manager' or member_type='member')
2358
                                        )
2359
                                        union distinct
2360
                                        (
2361
                                                select domain_id from domain_system where (user_id=@nervuser or public=true )
2362
                                        ) order by domain_id desc
2363
                                ) as a
2364
                                where  domain_id not in
2365
                                        (select parent_domain_id from inheritance_system_method where domain_id=domain_idkey);
2366
                        end if;
2367
                end if;
2368
       else
2369
               select 0 as test;
2370
       end if;
2371
END//
2372
DELIMITER ;
2373

    
2374
-- 프로시저 nerv_icde_xxxx.domainViewNewParentDomain 구조 내보내기
2375
DELIMITER //
2376
CREATE PROCEDURE `domainViewNewParentDomain`(IN `domain_idkey` int, IN `domaintype` varchar(50), IN `parent_domain_idkey` int, IN `parentdomaintype` int)
2377
BEGIN
2378
        declare uid varchar(100);
2379

    
2380
        if loginTest() and domainWriteTest(domain_idkey, domaintype)
2381
                       and existDomain(domain_idkey, domaintype) then
2382
            select 1 as test;
2383
                if parentdomaintype=0 then
2384
                   if(domain_idkey != parent_domain_idkey and existDomain(parent_domain_idkey, domaintype)) then
2385
                          insert into inheritance_data_data(domain_id,parent_domain_id) values(domain_idkey,parent_domain_idkey);
2386
                   else
2387
                       select 0;
2388
                   end if;
2389
                end if;
2390
                if parentdomaintype=1 then
2391
                   if(existDomain(parent_domain_idkey, 'data')) then
2392
                          insert into inheritance_method_data(domain_id,parent_domain_id) values(domain_idkey,parent_domain_idkey);
2393
                    else
2394
                       select 0;
2395
                   end if;
2396
                end if;
2397
                if parentdomaintype=2 then
2398
                   if (method_domainCompatibleTest(domain_idkey,parent_domain_idkey, parentdomaintype)
2399
						  and domain_idkey != parent_domain_idkey and existDomain(parent_domain_idkey, domaintype)) then
2400
                      insert into inheritance_method_method(domain_id,parent_domain_id) values(domain_idkey,parent_domain_idkey);
2401
                   else
2402
                        select 2 as test;
2403
                   end if;
2404
                end if;
2405
                if parentdomaintype=3 then
2406
                if(domain_idkey != parent_domain_idkey and existDomain(parent_domain_idkey, domaintype)) then
2407
                   insert into inheritance_system_method(domain_id,parent_domain_id) values(domain_idkey,parent_domain_idkey);
2408
                 else
2409
                       select 0;
2410
                 end if;
2411
                end if;
2412

    
2413
        else
2414
                select 0 as test;
2415
        end if;
2416
END//
2417
DELIMITER ;
2418

    
2419
-- 프로시저 nerv_icde_xxxx.domainViewUpperList 구조 내보내기
2420
DELIMITER //
2421
CREATE PROCEDURE `domainViewUpperList`(in_upper_idkey varchar(100), domaintype varchar(100))
2422
BEGIN
2423
        
2424
        if loginTest() then
2425
                select 1 as test;
2426
                       if(domaintype='data') then
2427
                        select id,name, upper_id, user_id,create_date, last_update, description from domain_data where upper_id = in_upper_idkey;
2428
                       end if;
2429
                       if(domaintype='method') then
2430
                        select id, name, upper_id, user_id, public, create_date, last_update, description from domain_method where upper_id = in_upper_idkey;
2431
                       end if;
2432
                       if(domaintype='system') then
2433
                        select id,name, upper_id, user_id, create_date, last_update, description from domain_system where upper_id = in_upper_idkey;
2434
                       end if;
2435

    
2436
       else
2437
               select 0 as test;
2438
       end if;
2439
END//
2440
DELIMITER ;
2441

    
2442
-- 프로시저 nerv_icde_xxxx.domain_table_Info 구조 내보내기
2443
DELIMITER //
2444
CREATE PROCEDURE `domain_table_Info`(domain_idkey int, domaintype varchar(50))
2445
BEGIN
2446
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
2447
                select 1 as test;
2448
                
2449
                if(domaintype = 'data') then
2450
                   select id , upper_id, name , user_id, public, create_date, last_update, description  from domain_data where id=domain_idkey;
2451
                end if;
2452
                if(domaintype = 'method') then
2453
                 select id , upper_id, name , user_id, public, standard_port, create_date, last_update, description  from domain_method where id=domain_idkey;
2454
                end if;
2455
                if(domaintype = 'system') then
2456
                                 select id , upper_id, name , user_id, public, create_date, last_update, description  from domain_system where id=domain_idkey;
2457
                end if;
2458

    
2459
        else
2460
                select 0 as test;
2461
        end if;
2462
END//
2463
DELIMITER ;
2464

    
2465
-- 프로시저 nerv_icde_xxxx.draw_deployComponentProxyInterfaceList 구조 내보내기
2466
DELIMITER //
2467
CREATE PROCEDURE `draw_deployComponentProxyInterfaceList`(IN `in_systemdomain_id` INT, IN `in_node_id` INT, IN `in_component_id` INT)
2468
BEGIN
2469

    
2470
        if loginTest() then
2471
                select 1 as test;
2472
                 select a.id, a.deploy_id, a.proxy_interface_id, b.interface_name, b.class_name, a.object_id, a.stub_object_id, a.stub_ip,
2473
					   c.name, c.id, c.standard_port, a.object_name, a.public, a.original_id, g.component_id from 
2474
						(
2475
    						((select id, deploy_id, proxy_interface_id, object_id, stub_object_id, stub_ip, object_name, public, original_id FROM custum_proxy
2476
							  where deploy_id in(select Id from deployments where node_id = in_node_id and component_id = in_component_id)) as a
2477
       						join
2478
       					(select id, interface_name, class_name, method_domain_id from proxy_interface_relation) as b on b.id = a.proxy_interface_id)
2479
       						join
2480
       					(select id, name, standard_port from domain_method) as c on c.id = b.method_domain_id                    
2481
       						join		 					
2482
							(select deployments_bind.deployment_id, deployments_bind.ip from deployments_bind) as d on d.ip = a.stub_ip                    
2483
					       	join
2484
					      (select id, node_id, systemdomain_id from deployments) as e on e.id = d.deployment_id and e.systemdomain_id = in_systemdomain_id                    
2485
					       	join
2486
					      (select deploy_id, object_id from custum_stub) as f on f.object_id = a.stub_object_id and f.deploy_id = e.id                    
2487
					       	join
2488
					      (select id, component_id from deployments) as g on g.id = f.deploy_id                   
2489
						) group by g.component_id, a.id,a.deploy_id,a.proxy_interface_id;                
2490
						  
2491
        else
2492
                select 0 as test;
2493
        end if;
2494

    
2495

    
2496

    
2497
END//
2498
DELIMITER ;
2499

    
2500
-- 프로시저 nerv_icde_xxxx.ExposedInterfaceViewInterfaceList 구조 내보내기
2501
DELIMITER //
2502
CREATE PROCEDURE `ExposedInterfaceViewInterfaceList`(in_component_id int)
2503
BEGIN
2504
        if loginTest() then
2505
                select 1 as test;
2506
                select method_domain_id, interface_name from proxy_interface_relation where component_id = in_component_id
2507
                UNION
2508
                SELECT method_domain_id, interface_name from stub_interface_relation where component_id = in_component_id;
2509
        else
2510
                select 0 as test;
2511
        end if;
2512
END//
2513
DELIMITER ;
2514

    
2515
-- 프로시저 nerv_icde_xxxx.get_domain_path 구조 내보내기
2516
DELIMITER //
2517
CREATE PROCEDURE `get_domain_path`(IN `in_domain_id_key` INT, IN `in_domain_type` VARCHAR(50))
2518
BEGIN
2519

    
2520
	if in_domain_type = 'method' then
2521
		select 1 as test;
2522
		select(domainMethodPath(in_domain_id_key,''))  As path;
2523
	end if;
2524
	
2525
	if in_domain_type = 'data' then
2526
		select 1 as test;
2527
		select(domainDataPath(in_domain_id_key,''))  As path;
2528
	end if;
2529
	
2530
		if in_domain_type = 'system' then
2531
   	select 1 as test;
2532
		select(domainSystemPath(in_domain_id_key,''))  As path;
2533
	end if;
2534
END//
2535
DELIMITER ;
2536

    
2537
-- 프로시저 nerv_icde_xxxx.inheritanceSystemMethodViewDeleteparent 구조 내보내기
2538
DELIMITER //
2539
CREATE PROCEDURE `inheritanceSystemMethodViewDeleteparent`(in_domain_id int,
2540
                                                                              in_parent_domain_id int)
2541
BEGIN
2542
        if loginTest() then
2543
                select 1 as test;
2544
                delete from inheritance_system_method where domain_id = in_domain_id and parent_domain_id = in_parent_domain_id;
2545
        else
2546
                select 0 as test;
2547
        end if;
2548
END//
2549
DELIMITER ;
2550

    
2551
-- 프로시저 nerv_icde_xxxx.inheritanceSystemMethodViewNewparent 구조 내보내기
2552
DELIMITER //
2553
CREATE PROCEDURE `inheritanceSystemMethodViewNewparent`(in_domain_id int,
2554
                                                                           in_parent_domain_id int)
2555
BEGIN
2556
        if loginTest() and inheritanceSystemMehtodParentOverlapCheck(in_domain_id, in_parent_domain_id) then
2557
                select 1 as test;
2558
                insert into inheritance_system_method(domain_id, parent_domain_id)
2559
                                      values(in_domain_id, in_parent_domain_id);
2560
        else
2561
                select 0 as test;
2562
        end if;
2563
END//
2564
DELIMITER ;
2565

    
2566
-- 프로시저 nerv_icde_xxxx.inheritance_data_dataViewDomainList 구조 내보내기
2567
DELIMITER //
2568
CREATE PROCEDURE `inheritance_data_dataViewDomainList`(IN `domain_idkey` int)
2569
BEGIN
2570

    
2571
        if loginTest() and domainReadTest(domain_idkey, 'data') then
2572
           select 1 as test;
2573
				
2574
				
2575
				select d.* from 
2576
				(
2577
					select domain_id from data where data.data_auto_id in (select data.real_data_auto_id from data where data.domain_id=domain_idkey and data.`type`='alias')
2578
					union 
2579
					select domain_id from data where data.data_auto_id in(select data_field.real_data_auto_id from data_field
2580
					 where data_field.`type`='alias' and data_field.data_auto_id in
2581
					  (select data.data_auto_id from data where data.domain_id=domain_idkey))
2582
				)as m join domain_data as d on m.domain_id=d.id and d.id != domain_idkey;
2583
			
2584
        else
2585
                select 0 as test;
2586
        end if;
2587
END//
2588
DELIMITER ;
2589

    
2590
-- 프로시저 nerv_icde_xxxx.inheritance_method_dataViewDomainList 구조 내보내기
2591
DELIMITER //
2592
CREATE PROCEDURE `inheritance_method_dataViewDomainList`(IN `domain_idkey` int)
2593
BEGIN
2594

    
2595
        if loginTest() and domainReadTest(domain_idkey, 'method') then
2596
           select 1 as test;
2597
           select d.* from
2598
			  (
2599
					select domain_id from data where data.data_auto_id in (select method.in_data_auto_id from method where method.domain_id=domain_idkey)
2600
					union
2601
					select domain_id from data where data.data_auto_id in	(select method.out_data_auto_id from method where method.domain_id=domain_idkey)
2602
				)as m join domain_data as d on m.domain_id=d.id;
2603

    
2604

    
2605

    
2606
        else
2607
                select 0 as test;
2608
        end if;
2609
END//
2610
DELIMITER ;
2611

    
2612
-- 프로시저 nerv_icde_xxxx.inheritance_method_methodViewDomainList 구조 내보내기
2613
DELIMITER //
2614
CREATE PROCEDURE `inheritance_method_methodViewDomainList`(domain_idkey int)
2615
BEGIN
2616

    
2617
        if loginTest() and domainReadTest(domain_idkey, 'method') then
2618
           select 1 as test;
2619

    
2620
            SELECT b.* from 
2621
            (select * from inheritance_method_method where domain_id=domain_idkey) as a
2622
             join
2623
            (select * from domain_method ) as b on a.parent_domain_id = b.id ;
2624

    
2625
        else
2626
                select 0 as test;
2627
        end if;
2628
END//
2629
DELIMITER ;
2630

    
2631
-- 프로시저 nerv_icde_xxxx.inheritance_system_methodViewDomainList 구조 내보내기
2632
DELIMITER //
2633
CREATE PROCEDURE `inheritance_system_methodViewDomainList`(domain_idkey int)
2634
BEGIN
2635

    
2636
        if loginTest() and domainReadTest(domain_idkey, 'method') then
2637
           select 1 as test;
2638

    
2639
            SELECT b.* from 
2640
            (select * from inheritance_system_method where domain_id=domain_idkey) as a
2641
             join
2642
            (select * from domain_method ) as b on a.parent_domain_id = b.id ;
2643

    
2644
        else
2645
                select 0 as test;
2646
        end if;
2647
END//
2648
DELIMITER ;
2649

    
2650
-- 프로시저 nerv_icde_xxxx.insertProxyInserfaceRelation 구조 내보내기
2651
DELIMITER //
2652
CREATE PROCEDURE `insertProxyInserfaceRelation`(IN `in_system_domain_id` VARCHAR(255), IN `in_component_id` INT, IN `in_method_domain_id` INT, IN `in_interface_name` VARCHAR(255), IN `in_class_name` VARCHAR(255), IN `in_object_name` VARCHAR(255))
2653
BEGIN
2654
 declare select_interface_realation_id_key int;
2655
 declare new_proxy_interface_realation_id int;
2656
 set select_interface_realation_id_key=0;		 
2657
		 
2658
		  select id into select_interface_realation_id_key from proxy_interface_relation
2659
		 		 where  component_id=in_component_id and method_domain_id=in_method_domain_id and interface_name=in_interface_name and class_name=in_class_name;
2660
		 
2661
		  if select_interface_realation_id_key = 0 then
2662
 			select 1 as check_count;
2663
 			insert into proxy_interface_relation (component_id, method_domain_id, interface_name, class_name)
2664
                                values(in_component_id, in_method_domain_id, in_interface_name, in_class_name);
2665
                                
2666
         select last_insert_id() into new_proxy_interface_realation_id;
2667
         
2668
          insert into proxy_interface_object (proxy_interface_id, object_name, component_id)
2669
                                values(new_proxy_interface_realation_id, in_object_name, in_component_id);
2670
          
2671
          insert into custum_proxy (deploy_id, proxy_interface_id, object_name)
2672
                     select id, new_proxy_interface_realation_id, in_object_name from deployments where systemdomain_id = in_system_domain_id and component_id = in_component_id;
2673
 		  else
2674
 		   select 2 as check_count;
2675
 		   insert into proxy_interface_object (proxy_interface_id, object_name, component_id)
2676
                                values( select_interface_realation_id_key, in_object_name, in_component_id);
2677
										   
2678
			insert into custum_proxy (deploy_id, proxy_interface_id, object_name)
2679
                     select id, select_interface_realation_id_key, in_object_name from deployments where systemdomain_id = in_system_domain_id and component_id = in_component_id;
2680
		  end if; 	
2681
END//
2682
DELIMITER ;
2683

    
2684
-- 프로시저 nerv_icde_xxxx.insertStubInserfaceRelation 구조 내보내기
2685
DELIMITER //
2686
CREATE PROCEDURE `insertStubInserfaceRelation`(IN `in_system_domain_id` VARCHAR(255), IN `in_component_id` INT, IN `in_method_domain_id` INT, IN `in_interface_name` VARCHAR(255), IN `in_class_name` VARCHAR(255), IN `in_object_name` VARCHAR(255))
2687
BEGIN
2688
 declare select_interface_realation_id_key int;
2689
 declare new_stub_interface_realation_id int;
2690
 
2691
 set select_interface_realation_id_key=0;
2692
 		 
2693
		  select id into select_interface_realation_id_key from stub_interface_relation
2694
		 		 where  component_id=in_component_id and method_domain_id=in_method_domain_id and interface_name=in_interface_name and class_name=in_class_name;
2695
		 
2696
		  if select_interface_realation_id_key = 0 then
2697
 			select 1 as check_count;
2698
 			insert into stub_interface_relation (component_id, method_domain_id, interface_name, class_name)
2699
                                values(in_component_id, in_method_domain_id, in_interface_name, in_class_name);
2700
                                
2701
         select last_insert_id() into new_stub_interface_realation_id;
2702
         
2703
          insert into stub_interface_object (stub_interface_id, object_name, component_id)
2704
                                values(new_stub_interface_realation_id, in_object_name, in_component_id);
2705
          
2706
          insert into custum_stub (deploy_id, stub_interface_id, object_name)
2707
                     select id, new_stub_interface_realation_id, in_object_name from deployments
2708
							 where systemdomain_id = in_system_domain_id and component_id = in_component_id;
2709
 		  else
2710
 		   select 2 as check_count;
2711
 		   insert into stub_interface_object (stub_interface_id, object_name, component_id)
2712
                                values( select_interface_realation_id_key, in_object_name, in_component_id);
2713
										   
2714
			insert into custum_stub (deploy_id, stub_interface_id, object_name)
2715
                     select id, select_interface_realation_id_key, in_object_name from deployments
2716
							 where systemdomain_id = in_system_domain_id and component_id = in_component_id;
2717
		  end if; 	
2718
END//
2719
DELIMITER ;
2720

    
2721
-- 프로시저 nerv_icde_xxxx.insert_component_deployments_custum 구조 내보내기
2722
DELIMITER //
2723
CREATE PROCEDURE `insert_component_deployments_custum`(IN `in_deployment_id` INT, IN `in_subsystem_domain_id` int, IN `in_node_id` int, IN `in_component_id` int, IN `in_systemdomain_id` int, IN `in_component_name` varchar(100), IN `in_component_description` varchar(100), IN `in_original_node_id` INT)
2724
BEGIN
2725
declare new_component_id int;
2726
declare new_deployment_id int;
2727
declare proxy_object_count int;
2728
declare stub_object_count int;
2729
declare computer_node_id int;
2730

    
2731
select count(id) into proxy_object_count from custum_proxy where custum_proxy.public=1 and custum_proxy.deploy_id = in_deployment_id;
2732
select count(id) into stub_object_count from custum_stub where custum_stub.public=1 and custum_stub.deploy_id = in_deployment_id;
2733

    
2734
if (proxy_object_count !=0 or stub_object_count !=0) then
2735
	insert into component (systemdomain_id, name, description)
2736
	values (in_subsystem_domain_id, in_component_name, in_component_description);
2737
	select Last_INSERT_ID() into new_component_id;
2738
	
2739
	insert into deployments (node_id, component_id, systemdomain_id, original_id)
2740
	values(in_node_id, new_component_id, in_subsystem_domain_id, in_deployment_id);
2741
	select Last_INSERT_ID() into new_deployment_id;
2742

    
2743
	insert into custum_proxy (deploy_id, proxy_interface_id, object_name, object_id, stub_object_id, stub_ip, original_id, original_deployment_id)
2744
 	select new_deployment_id, proxy_interface_id, object_name, object_id, stub_object_id, stub_ip, Id, deploy_id from custum_proxy where custum_proxy.public=1 and deploy_id in
2745
 	(select id from deployments where component_id = in_component_id and systemdomain_id = in_systemdomain_id);
2746
 
2747
 	insert into custum_stub (deploy_id, stub_interface_id, object_name, object_id, original_id, original_deployment_id)
2748
 	select new_deployment_id, stub_interface_id, object_name, object_id, Id, deploy_id from custum_stub where custum_stub.public=1 and deploy_id in
2749
 	(select id from deployments where component_id = in_component_id and systemdomain_id = in_systemdomain_id); 	
2750

    
2751
	 	insert into deployments_bind (deployments_bind.deployment_id, deployments_bind.node_id, deployments_bind.port, deployments_bind.ip)						
2752
			select new_deployment_id, b.node_id, b.port, b.ip from	
2753
			(   		
2754
				(select deployments_bind.node_id, deployments_bind.port, deployments_bind.ip from deployments_bind where node_id =in_original_node_id and deployment_id=in_deployment_id) as a 
2755
				join
2756
				(select network.node_id, network.port, network.ip from network where node_id =in_node_id) as b on b.ip = a.ip 
2757
			) where b.node_id is not NULL;				
2758
	
2759
end if;	
2760
END//
2761
DELIMITER ;
2762

    
2763
-- 프로시저 nerv_icde_xxxx.insert_subsystem_component 구조 내보내기
2764
DELIMITER //
2765
CREATE PROCEDURE `insert_subsystem_component`(IN `in_node_id` int)
2766
BEGIN
2767
	declare domain_id int;
2768
 	declare sub_domain_id int; 	
2769
 	declare depth int;	
2770
	declare no_more_rows bool default false;
2771
	declare deployment_id int;
2772
	declare component_id int;
2773
 	declare component_system_domain_id int;
2774
   declare component_name varchar(100);
2775
   declare component_description varchar(100);	   
2776
	
2777
	DECLARE my_list CURSOR FOR select a.id, c.id, c.systemdomain_id, c.name, c.description from
2778
	
2779
  (select deployments.Id, deployments.component_id from deployments where (node_id,systemdomain_id)
2780
   in (select id,systemdomain_id from node where systemdomain_id=sub_domain_id)) as a
2781
  join  
2782
  (select * from component) as c on c.id = a.component_id group by c.id;
2783

    
2784
	declare continue handler for not found set no_more_rows := TRUE;
2785
	
2786
	set max_sp_recursion_depth = 50;
2787
	set depth=10;
2788
		
2789
	if depth > 0 then
2790
	Select node.systemdomain_id into domain_id from node where node.id = in_node_id;
2791
   Select node.sub_system_domain_id into sub_domain_id from node where node.id = in_node_id;      
2792

    
2793
		open my_list;	
2794
			my_loop : loop		
2795
			fetch my_list into deployment_id, component_id, component_system_domain_id, component_name, component_description;
2796
			if no_more_rows then
2797
				close my_list;
2798
				leave my_loop;
2799
			end if;					
2800
	
2801
	  call insert_component_deployments_custum(deployment_id, domain_id, in_node_id, component_id, component_system_domain_id, component_name, component_description);
2802

    
2803
			set depth = depth -1;
2804
		end loop my_loop;		
2805
	 end if;
2806
END//
2807
DELIMITER ;
2808

    
2809
-- 프로시저 nerv_icde_xxxx.insert_subsystem_custum_interface 구조 내보내기
2810
DELIMITER //
2811
CREATE PROCEDURE `insert_subsystem_custum_interface`(IN `in_subsystem_deployment_id` INT, IN `in_original_custum_id` INT, IN `in_original_custum_deployment_id` INT, IN `in_object_type` INT)
2812
BEGIN
2813
 if(in_object_type = 0) then
2814
	 insert into custum_proxy (custum_proxy.deploy_id, custum_proxy.proxy_interface_id, custum_proxy.object_name,
2815
	 									 custum_proxy.object_id, custum_proxy.stub_object_id, custum_proxy.stub_ip, custum_proxy.public,
2816
										  custum_proxy.original_id, custum_proxy.original_deployment_id)
2817
 	  select in_subsystem_deployment_id, custum_proxy.proxy_interface_id, custum_proxy.object_name, custum_proxy.object_id,
2818
		 custum_proxy.stub_object_id, custum_proxy.stub_ip, 0, in_original_custum_id, in_original_custum_deployment_id
2819
     from custum_proxy where custum_proxy.Id = in_original_custum_id and custum_proxy.deploy_id = in_original_custum_deployment_id;
2820
 else 	
2821
	 insert into custum_stub (custum_stub.deploy_id, custum_stub.stub_interface_id, custum_stub.object_name,
2822
	 									 custum_stub.object_id, custum_stub.public, custum_stub.original_id,
2823
										   custum_stub.original_deployment_id)
2824
 	  select in_subsystem_deployment_id, custum_stub.stub_interface_id, custum_stub.object_name,
2825
		 custum_stub.object_id, 0, in_original_custum_id, in_original_custum_deployment_id
2826
     from custum_stub where custum_stub.Id = in_original_custum_id and custum_stub.deploy_id = in_original_custum_deployment_id; 
2827
 end if;
2828

    
2829
END//
2830
DELIMITER ;
2831

    
2832
-- 프로시저 nerv_icde_xxxx.insert_subsystem_custum_interface_loop 구조 내보내기
2833
DELIMITER //
2834
CREATE PROCEDURE `insert_subsystem_custum_interface_loop`(IN `in_custum_id` INT, IN `in_deployments_id` INT, IN `in_object_type` INT)
2835
BEGIN
2836
	declare sub_system_deploy_id int;
2837
	declare subsystem_node_id int;
2838
	declare no_more_rows bool default false;
2839
	declare deploy_sub_component int default 0;	 	
2840
	declare 	orginal_domain_id int;		
2841
	declare 	orginal_component_id int;
2842
	declare 	orginal_node_id int;
2843
   declare subsystem_domain_id int;
2844
   declare component_id int;
2845
   declare component_system_domain_id int;
2846
   declare component_name varchar(100);
2847
   declare component_description varchar(100);		
2848

    
2849
		DECLARE my_list CURSOR FOR 
2850
			select node.id from node where node.sub_system_domain_id in( select deployments.systemdomain_id from deployments where deployments.Id=in_deployments_id);
2851
		declare continue handler for not found set no_more_rows := TRUE;
2852

    
2853
		set max_sp_recursion_depth = 50;
2854

    
2855
			open my_list;
2856
			my_loop : loop						
2857
				fetch my_list into subsystem_node_id;
2858
				if no_more_rows then				
2859
					close my_list;
2860
					leave my_loop;
2861
				end if;				
2862
				
2863
				select count(deployments.Id) into deploy_sub_component from deployments where deployments.node_id = subsystem_node_id and deployments.original_id = in_deployments_id;
2864
	      	
2865
	      	if deploy_sub_component = 0 then					
2866
					 select deployments.systemdomain_id into orginal_domain_id from deployments where deployments.Id=in_deployments_id;					
2867
					 select deployments.component_id into orginal_component_id from deployments where deployments.Id=in_deployments_id;										
2868
					 select deployments.node_id into orginal_node_id from deployments where deployments.Id=in_deployments_id;	
2869
					 select systemdomain_id into subsystem_domain_id  from node where node.Id = subsystem_node_id;								
2870
			 		 select component.id into component_id from component where id = orginal_component_id;
2871
			 		 select component.systemdomain_id into component_system_domain_id from component where id = orginal_component_id;
2872
			 		 select component.name into component_name from component where id = orginal_component_id;
2873
					 select component.description into component_description from component where id = orginal_component_id;			   				
2874
					 	 				 
2875
 					 call insert_component_deployments_custum(in_deployments_id,  subsystem_domain_id, subsystem_node_id, component_id, component_system_domain_id, component_name, component_description,orginal_node_id);			
2876
 					 
2877
 				else
2878
 				   select deployments.Id into sub_system_deploy_id from deployments where deployments.node_id = subsystem_node_id and deployments.original_id = in_deployments_id;
2879
 				   
2880
					call insert_subsystem_custum_interface( sub_system_deploy_id, in_custum_id, in_deployments_id, in_object_type);		
2881
				end if;		
2882
			
2883
			end loop my_loop;	
2884
END//
2885
DELIMITER ;
2886

    
2887
-- 프로시저 nerv_icde_xxxx.insert_subsystem_custum_interface_loop_new_subsystem 구조 내보내기
2888
DELIMITER //
2889
CREATE PROCEDURE `insert_subsystem_custum_interface_loop_new_subsystem`(IN `in_custum_id` INT, IN `in_deployments_id` INT, IN `in_object_type` INT)
2890
BEGIN
2891
	declare sub_system_deploy_id int;
2892
	declare subsystem_node_id int;
2893
	declare no_more_rows bool default false;
2894
	declare deploy_sub_component int default 0;	 	
2895
	declare 	orginal_domain_id int;		
2896
	declare 	orginal_component_id int;
2897
	declare 	orginal_node_id int;
2898
   declare subsystem_domain_id int;
2899
   declare component_id int;
2900
   declare component_system_domain_id int;
2901
   declare component_name varchar(100);
2902
   declare component_description varchar(100);		
2903

    
2904
		DECLARE my_list CURSOR FOR 
2905
			select node.id from node where node.sub_system_domain_id in
2906
			( select deployments.systemdomain_id from deployments where deployments.Id=in_deployments_id);
2907
		declare continue handler for not found set no_more_rows := TRUE;
2908

    
2909
		set max_sp_recursion_depth = 50;
2910
			open my_list;
2911
			my_loop : loop						
2912
				fetch my_list into subsystem_node_id;
2913
				if no_more_rows then				
2914
					close my_list;
2915
					leave my_loop;
2916
				end if;				
2917
				
2918
				select count(deployments.Id) into deploy_sub_component from deployments where deployments.node_id = subsystem_node_id and deployments.original_id = in_deployments_id;	      	
2919
	      	
2920
	      	if deploy_sub_component = 0 then					
2921
					 select deployments.systemdomain_id into orginal_domain_id from deployments where deployments.Id=in_deployments_id;					
2922
					 select deployments.component_id into orginal_component_id from deployments where deployments.Id=in_deployments_id;										
2923
					 select deployments.node_id into orginal_node_id from deployments where deployments.Id=in_deployments_id;	
2924
					 select systemdomain_id into subsystem_domain_id  from node where node.Id = subsystem_node_id;								
2925
			 		 select component.id into component_id from component where id = orginal_component_id;
2926
			 		 select component.systemdomain_id into component_system_domain_id from component where id = orginal_component_id;
2927
			 		 select component.name into component_name from component where id = orginal_component_id;
2928
					 select component.description into component_description from component where id = orginal_component_id;			   				
2929
	 				 
2930
 					 call insert_component_deployments_custum(in_deployments_id,  subsystem_domain_id, subsystem_node_id, component_id, component_system_domain_id, component_name, component_description,orginal_node_id);			
2931
				end if;
2932
			
2933
			end loop my_loop;	
2934
END//
2935
DELIMITER ;
2936

    
2937
-- 프로시저 nerv_icde_xxxx.insert_subsystem_public_proxy_interface_loop 구조 내보내기
2938
DELIMITER //
2939
CREATE PROCEDURE `insert_subsystem_public_proxy_interface_loop`(IN `in_subsystem_domain_id` INT)
2940
BEGIN
2941

    
2942
	declare in_custum_id int;
2943
	declare in_deploy_id int;
2944
	declare no_more_rows bool default false;	 
2945

    
2946
		DECLARE my_list CURSOR FOR 
2947
		select custum_proxy.Id, custum_proxy.deploy_id from custum_proxy where custum_proxy.public=1 and custum_proxy.deploy_id in (
2948
		select id from deployments where deployments.systemdomain_id=in_subsystem_domain_id);		
2949
		
2950
		declare continue handler for not found set no_more_rows := TRUE;		
2951
		select 1 as test;
2952
			open my_list;
2953
			my_loop : loop		
2954
				fetch my_list into in_custum_id, in_deploy_id;
2955
				if no_more_rows then
2956
					close my_list;
2957
					leave my_loop;
2958
				end if;	 			   
2959
 			
2960
  				call insert_subsystem_custum_interface_loop_new_subsystem(in_custum_id, in_deploy_id, 0);	
2961
			end loop my_loop;		
2962
END//
2963
DELIMITER ;
2964

    
2965
-- 프로시저 nerv_icde_xxxx.insert_subsystem_public_stub_interface_loop 구조 내보내기
2966
DELIMITER //
2967
CREATE PROCEDURE `insert_subsystem_public_stub_interface_loop`(IN `in_subsystem_domain_id` INT)
2968
BEGIN
2969

    
2970
	declare in_custum_id int;
2971
	declare in_deploy_id int;
2972
	declare no_more_rows bool default false;
2973
		
2974
	DECLARE my_list_stub CURSOR FOR 
2975
	select custum_stub.Id, custum_stub.deploy_id from custum_stub where custum_stub.public=1 and custum_stub.deploy_id in (
2976
		select id from deployments where deployments.systemdomain_id=in_subsystem_domain_id);
2977

    
2978
	declare continue handler for not found set no_more_rows := TRUE;
2979
					select 1 as test;
2980
			open my_list_stub;
2981
			my_loop : loop		
2982
				fetch my_list_stub into in_custum_id, in_deploy_id;
2983
				if no_more_rows then
2984
					close my_list_stub;
2985
					leave my_loop;
2986
				end if;	
2987
 		 		
2988
 				call insert_subsystem_custum_interface_loop_new_subsystem(in_custum_id, in_deploy_id, 1);				
2989
			end loop my_loop;	
2990

    
2991
END//
2992
DELIMITER ;
2993

    
2994
-- 프로시저 nerv_icde_xxxx.interfaceViewDeleteInterface 구조 내보내기
2995
DELIMITER //
2996
CREATE PROCEDURE `interfaceViewDeleteInterface`(domain_idkey int,interface_name varchar(100))
2997
BEGIN
2998
        if loginTest() and domainManageTest(domain_idkey) then
2999
                select 1 as test;
3000
                delete from interface where domain_id=domain_idkey and name=interface_name;
3001
                        
3002
        else
3003
                select 0 as test;
3004
        end if;
3005
END//
3006
DELIMITER ;
3007

    
3008
-- 프로시저 nerv_icde_xxxx.interfaceViewDeleteMemberMethod 구조 내보내기
3009
DELIMITER //
3010
CREATE PROCEDURE `interfaceViewDeleteMemberMethod`(IN `domain_idkey` int, IN `interfacename` varchar(100), IN `methoddomain_id` int, IN `methodname` varchar(100))
3011
BEGIN
3012
        if loginTest() and domainManageTest(domain_idkey) then
3013
                select 1 as test;
3014
                delete from interface_member where domain_id=domain_idkey
3015
					  and interface=interfacename and method_domain_id=methoddomain_id and method_name=methodname;
3016
        else
3017
                select 0 as test;
3018
        end if;
3019
END//
3020
DELIMITER ;
3021

    
3022
-- 프로시저 nerv_icde_xxxx.interfaceViewDeleteParentInterface 구조 내보내기
3023
DELIMITER //
3024
CREATE PROCEDURE `interfaceViewDeleteParentInterface`(domain_idkey int,
3025
                                                                        interface_name varchar(100),
3026
                                                                        parentdomain_idkey int,
3027
                                                                        parentinterface_name varchar(100))
3028
BEGIN
3029

    
3030
        if loginTest() and domainManageTest(domain_idkey) then
3031
                select 1 as test;
3032
                delete from interface_parent where domain_id=domain_idkey and interface=interface_name and parent_domain_id=parentdomain_idkey and parent_interface=parentinterface_name;
3033
        else
3034
                select 0 as test;
3035
        end if;
3036
END//
3037
DELIMITER ;
3038

    
3039
-- 프로시저 nerv_icde_xxxx.interfaceViewEditInterface 구조 내보내기
3040
DELIMITER //
3041
CREATE PROCEDURE `interfaceViewEditInterface`(domain_idkey int, interface_name varchar(100),interfacevalue varchar(100),descriptionvalue varchar(100))
3042
BEGIN
3043

    
3044
        if loginTest() and domainManageTest(domain_idkey) then
3045
                select 1 as test;
3046
                       update interface set name=interfacevalue,description=descriptionvalue where domain_id=domain_idkey and name=interface_name;
3047
        else
3048
                select 0 as test;
3049
        end if;
3050
END//
3051
DELIMITER ;
3052

    
3053
-- 프로시저 nerv_icde_xxxx.interfaceViewEditInterfaceSeq 구조 내보내기
3054
DELIMITER //
3055
CREATE PROCEDURE `interfaceViewEditInterfaceSeq`(domain_idkey int, domaintype varchar(50),
3056
                                                                        interfacekey1 varchar(100),
3057
                                                                        interfacekey2 varchar(100))
3058
BEGIN
3059
        declare t1 timestamp;
3060
        declare t2 timestamp;
3061

    
3062
        if loginTest() and domainManageTest(domain_idkey, domaintype) then
3063
                select 1 as test;
3064
                       select seq into t1 from interface where domain_id=domain_idkey and name=interfacekey1;
3065
                       select seq into t2 from interface where domain_id=domain_idkey and name=interfacekey2;
3066
                update interface set seq = t2 where domain_id=domain_idkey and name=interfacekey1;
3067
                update interface set seq = t1 where domain_id=domain_idkey and name=interfacekey2;
3068
        else
3069
                select 0 as test;
3070
        end if;
3071
END//
3072
DELIMITER ;
3073

    
3074
-- 프로시저 nerv_icde_xxxx.interfaceViewEditMemberMethod 구조 내보내기
3075
DELIMITER //
3076
CREATE PROCEDURE `interfaceViewEditMemberMethod`(domain_idkey int,
3077
                                                                     interfacekey varchar(100),
3078
                                                                     method_domain_idkey int,
3079
                                                                     method_namekey varchar(100),
3080
                                                                     method_domain_idvalue int,
3081
                                                                     methodvalue varchar(100),
3082
                                                                     descriptionvalue text)
3083
BEGIN
3084
        if loginTest() and domainManageTest(domain_idkey) and existMethod(method_domain_idvalue,methodvalue) then
3085
                select 1 as test;
3086
                update interface_member set method_domain_id=method_domain_idvalue,
3087
                                            method_name=methodvalue,
3088
                                            description=descriptionvalue
3089
                                        where domain_id=domain_idkey
3090
                                         and  interface=interfacekey
3091
                                         and  method_domain_id=method_domain_idkey
3092
                                         and  method_name=method_namekey;
3093
        else
3094
                select 0 as test;
3095
        end if;
3096
END//
3097
DELIMITER ;
3098

    
3099
-- 프로시저 nerv_icde_xxxx.interfaceViewEditMemberMethodRealdomainList 구조 내보내기
3100
DELIMITER //
3101
CREATE PROCEDURE `interfaceViewEditMemberMethodRealdomainList`(domain_idkey int)
3102
BEGIN
3103
        declare sm bool;
3104
        declare sa varchar(100);
3105
        declare acount varchar(100);
3106
        declare pbc bool;
3107

    
3108
        set sa = '';
3109
        if loginTest() then
3110
                    select supermanager into sm from users where user_id=@nervuser;
3111
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
3112
                    select user_id into acount from domain_method where id=domain_idkey;
3113
                    select public into pbc from domain_method where id=domain_idkey;
3114

    
3115
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3116
                        select 1 as test;
3117
                        (select id, name from domain_method where id in (select parent_domain_id from inheritance_method_method where domain_id=domain_idkey))
3118
                         union
3119
                        (select id, name from domain_method where id=domain_idkey);
3120
                                
3121
                    else
3122
                        select 0 as test;
3123
                     end if;
3124
               else
3125
                 select 0 as test;
3126
        end if;
3127
END//
3128
DELIMITER ;
3129

    
3130
-- 프로시저 nerv_icde_xxxx.interfaceViewEditMemberMethodRealmethodList 구조 내보내기
3131
DELIMITER //
3132
CREATE PROCEDURE `interfaceViewEditMemberMethodRealmethodList`(domain_idkey int, interfacekey varchar(100))
3133
BEGIN
3134
       declare sm bool;
3135
        declare sa varchar(100);
3136
        declare acount varchar(100);
3137
        declare pbc bool;
3138
    
3139
        set sa = '';
3140
        if loginTest() then
3141
                     select supermanager into sm from users where user_id = @nervuser;
3142
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
3143
                     select user_id into acount from domain_method where id = domain_idkey;
3144
                     select public into pbc from domain_method where id = domain_idkey;
3145
                     
3146

    
3147
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3148
                        select 1 as test;
3149
                        select domain_id, name from method where domain_id=domain_idkey and name not in
3150
                                        (select method_name from interface_member where domain_id = domain_idkey and interface=interfacekey);
3151
                     else
3152
                        select 0 as test;
3153
                     end if;               
3154
       else
3155
                select 0 as test;
3156
       end if;
3157

    
3158
END//
3159
DELIMITER ;
3160

    
3161
-- 프로시저 nerv_icde_xxxx.interfaceViewInterfaceList 구조 내보내기
3162
DELIMITER //
3163
CREATE PROCEDURE `interfaceViewInterfaceList`(domain_idkey int, domaintype varchar(100), interface_namekey varchar(100))
3164
BEGIN
3165

    
3166

    
3167
       if loginTest() and domainReadTest(domain_idkey, domaintype) then
3168
               select 1 as test;
3169
               select name,user_id,description, domain_id, seq from interface where domain_id=domain_idkey and name like interface_namekey order by seq asc;
3170
       else
3171
               select 0 as test;
3172
       end if;
3173
END//
3174
DELIMITER ;
3175

    
3176
-- 프로시저 nerv_icde_xxxx.interfaceViewMemberMethodList 구조 내보내기
3177
DELIMITER //
3178
CREATE PROCEDURE `interfaceViewMemberMethodList`(
3179
	IN `domain_idkey` int,
3180
	IN `domaintype` varchar(50),
3181
	IN `interface_namekey` VARCHAR(100) 
3182

    
3183
)
3184
BEGIN
3185

    
3186
       if loginTest() and domainReadTest(domain_idkey, domaintype) then
3187
               select 1 as test;
3188
               select c.name as method_domain, a.name as method_name, type, code, i.domain_id as in_domain_id, d.name as in_domain , i.name as in_data, o.domain_id as out_domain_id, e.name as out_domain, o.name as out_data, user_id, a.description, c.id as method_domain_id from
3189
               (select id, name from domain_method) as c
3190
               	join
3191
               ( select * from method ) as a
3192
                    left outer join
3193
  					(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
3194
     					left outer join
3195
  					(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id
3196
              		left outer join
3197
               (select id, name from domain_data) as d on i.domain_id = d.id
3198
              		left outer join
3199
            	(select id, name from domain_data) as e on o.domain_id = e.id            
3200
             		 join
3201
              ( select method_domain_id, method_name , description from interface_member where domain_id=domain_idkey and interface=interface_namekey) as b
3202
                                                      on a.domain_id=b.method_domain_id and a.name = b.method_name  and a.domain_id = c.id order by type desc;
3203
       else
3204
               select 0 as test;
3205
       end if;
3206
END//
3207
DELIMITER ;
3208

    
3209
-- 프로시저 nerv_icde_xxxx.interfaceViewNewInterface 구조 내보내기
3210
DELIMITER //
3211
CREATE PROCEDURE `interfaceViewNewInterface`(domain_idkey int, domaintype varchar (100),interface_namekey varchar(100),descriptionvalue text)
3212
BEGIN
3213
        if loginTest() and domainManageTest(domain_idkey) and existDomain(domain_idkey, domaintype) then
3214
                select 1 as test;
3215
                insert into interface (domain_id,                name,  user_id, description)
3216
                                values(domain_idkey, interface_namekey, @nervuser, descriptionvalue );
3217
        else
3218
                select 0 as test;
3219
        end if;
3220
END//
3221
DELIMITER ;
3222

    
3223
-- 프로시저 nerv_icde_xxxx.interfaceViewNewMemberMethod 구조 내보내기
3224
DELIMITER //
3225
CREATE PROCEDURE `interfaceViewNewMemberMethod`(domain_idkey int,
3226
                                                                   interface_namekey varchar(100),
3227
                                                                   methoddomain_idvalue int,
3228
                                                                   method_namevalue varchar(100),
3229
                                                                   descriptionvalue text)
3230
BEGIN
3231
        if loginTest() and domainManageTest(domain_idkey) and existMethod(methoddomain_idvalue,method_namevalue) then
3232
                select 1 as test;
3233
                insert into interface_member(domain_id,        interface,     method_domain_id,   method_name, description)
3234
                                    values(domain_idkey,interface_namekey,methoddomain_idvalue,method_namevalue,descriptionvalue);
3235
        else
3236
                select 0 as test;
3237
        end if;
3238
END//
3239
DELIMITER ;
3240

    
3241
-- 프로시저 nerv_icde_xxxx.interfaceViewNewMemberMethodRealdomainList 구조 내보내기
3242
DELIMITER //
3243
CREATE PROCEDURE `interfaceViewNewMemberMethodRealdomainList`(domain_idkey int)
3244
BEGIN
3245
        declare sm bool;
3246
        declare sa varchar(100);
3247
        declare acount varchar(100);
3248
        declare pbc bool;
3249

    
3250
        set sa = '';
3251
        if loginTest() then
3252
                    select supermanager into sm from users where user_id=@nervuser;
3253
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
3254
                    select user_id into acount from domain_method where id=domain_idkey;
3255
                    select public into pbc from domain_method where id=domain_idkey;
3256

    
3257
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3258
                        select 1 as test;
3259
                        (select id, name from domain_method where id in
3260
                                 (select parent_domain_id from inheritance_method_method where domain_id=domain_idkey))
3261
                         union
3262
                        (select id, name from domain_method where id=domain_idkey);
3263
                        
3264
                   else
3265
                        select 0 as test;
3266
                     end if;
3267
               else
3268
                 select 0 as test;
3269
        end if;
3270
End//
3271
DELIMITER ;
3272

    
3273
-- 프로시저 nerv_icde_xxxx.interfaceViewNewMemberMethodRealmethodList 구조 내보내기
3274
DELIMITER //
3275
CREATE PROCEDURE `interfaceViewNewMemberMethodRealmethodList`(in_interface_domain_idkey int, in_method_domain_idkey int,interfacekey varchar(100))
3276
BEGIN
3277
        declare sm bool;
3278
        declare sa varchar(100);
3279
        declare acount varchar(100);
3280
        declare pbc bool;
3281
    
3282
        set sa = '';
3283
        if loginTest() then
3284
                     select supermanager into sm from users where user_id = @nervuser;
3285
                     select member_type into sa from members_domain_method where domain_id=in_method_domain_idkey and user_id=@nervuser;
3286
                     select user_id into acount from domain_method where id = in_method_domain_idkey;
3287
                     select public into pbc from domain_method where id = in_method_domain_idkey;
3288
                     
3289

    
3290
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3291
                        select 1 as test;
3292
                        select domain_id, name,type from method where domain_id=in_method_domain_idkey and name not in
3293
                                        (select method_name from interface_member where domain_id = in_interface_domain_idkey and interface=interfacekey);
3294
                     else
3295
                        select 0 as test;
3296
                     end if;               
3297
       else
3298
                select 0 as test;
3299
       end if;
3300

    
3301
              
3302
END//
3303
DELIMITER ;
3304

    
3305
-- 프로시저 nerv_icde_xxxx.interfaceViewNewParentInterface 구조 내보내기
3306
DELIMITER //
3307
CREATE PROCEDURE `interfaceViewNewParentInterface`(domain_idkey int,
3308
                                                                        interface_namekey varchar(100),
3309
                                                                        parentdomain_id int,
3310
                                                                        parent_namevalue varchar(100))
3311
BEGIN
3312
        if loginTest() and domainManageTest(domain_idkey) and existInterface(parentdomain_id,parent_namevalue) then
3313
                select 1 as test;
3314
                insert into interface_parent(domain_id,          interface,parent_domain_id,parent_interface) 
3315
                                      values(domain_idkey,interface_namekey,parentdomain_id,parent_namevalue);
3316
        else
3317
                select 0 as test;
3318
        end if;
3319
END//
3320
DELIMITER ;
3321

    
3322
-- 프로시저 nerv_icde_xxxx.interfaceViewNewParentInterfaceRealdomainList 구조 내보내기
3323
DELIMITER //
3324
CREATE PROCEDURE `interfaceViewNewParentInterfaceRealdomainList`(domain_idkey int)
3325
BEGIN
3326
         declare sm bool;
3327
        declare sa varchar(100);
3328
        declare acount varchar(100);
3329
        declare pbc bool;
3330
  
3331
        set sa = '';
3332
        if loginTest() then
3333
        
3334
                    select supermanager into sm from users where user_id=@nervuser;
3335
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
3336
                    select user_id into acount from domain_method where id=domain_idkey;
3337
                    select public into pbc from domain_method where id=domain_idkey;
3338

    
3339
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3340
                        select 1 as test;
3341
                        (select id, name from domain_method where id in (select parent_domain_id from inheritance_method_method where domain_id=domain_idkey))
3342
                         union
3343
                        (select id, name from domain_method where id=domain_idkey);
3344
                                
3345
                    else
3346
                        select 0 as test;
3347
                     end if;
3348
               else
3349
                 select 0 as test;
3350
        end if;
3351
End//
3352
DELIMITER ;
3353

    
3354
-- 프로시저 nerv_icde_xxxx.interfaceViewNewParentInterfaceRealinterfaceList 구조 내보내기
3355
DELIMITER //
3356
CREATE PROCEDURE `interfaceViewNewParentInterfaceRealinterfaceList`(domain_idkey int, interfacekey varchar(100))
3357
BEGIN
3358
        declare sm bool;
3359
        declare sa varchar(100);
3360
        declare acount varchar(100);
3361
        declare pbc bool;
3362

    
3363
        set sa = '';
3364
        if loginTest() then       
3365
                     select supermanager into sm from users where user_id=@nervuser;
3366
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
3367
                     select user_id into acount from domain_method where id=domain_idkey;
3368
                     select public into pbc from domain_method where id=domain_idkey;
3369

    
3370
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3371
                        select 1 as test;
3372
                        select domain_id, name, user_id, seq, description from interface where domain_id=domain_idkey and name != interfacekey and name not in
3373
                                        (select parent_interface from interface_parent where parent_domain_id=domain_idkey and interface=interfacekey);
3374
                     else
3375
                        select 0 as test;
3376
                     end if;               
3377

    
3378
        else
3379
                select 0 as test;
3380
        end if;
3381
END//
3382
DELIMITER ;
3383

    
3384
-- 프로시저 nerv_icde_xxxx.interfaceViewParentInterfaceList 구조 내보내기
3385
DELIMITER //
3386
CREATE PROCEDURE `interfaceViewParentInterfaceList`(domain_idkey int, domaintype varchar(100), interface_namekey varchar(100 ) )
3387
BEGIN
3388

    
3389

    
3390
       if loginTest() and domainReadTest(domain_idkey, domaintype) then
3391
               select 1 as test;
3392
               select b.name, a.parent_interface, a.parent_domain_id from
3393
               (select parent_domain_id,parent_interface from interface_parent where domain_id=domain_idkey and interface = interface_namekey) As a
3394
               join
3395
               (select id, name from domain_method) as b on a.parent_domain_id = b.id;
3396
       else
3397
               select 0 as test;
3398
       end if;
3399
END//
3400
DELIMITER ;
3401

    
3402
-- 프로시저 nerv_icde_xxxx.loginResult 구조 내보내기
3403
DELIMITER //
3404
CREATE PROCEDURE `loginResult`()
3405
BEGIN
3406
       select loginTest() as test;
3407
END//
3408
DELIMITER ;
3409

    
3410
-- 프로시저 nerv_icde_xxxx.mainViewDomainAllList 구조 내보내기
3411
DELIMITER //
3412
CREATE PROCEDURE `mainViewDomainAllList`(
3413
	IN `idkey` VARCHAR(50),
3414
	IN `domaintype` VARCHAR(50)
3415
)
3416
BEGIN
3417

    
3418
        declare sm bool;
3419

    
3420

    
3421
        if loginTest() then
3422
                select 1 as test;
3423
                if( supermanagerTest(@nervuser) ) then
3424
                       if(domaintype='data') then
3425
                       	select id, name, upper_id, user_id, public, 0, create_date, last_update, description from domain_data where id like idkey order by id desc;                       
3426
                       end if;
3427
                       
3428
                       if(domaintype='method') then
3429
                        select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description  from domain_method where id like idkey order by id desc;								
3430
                       end if;
3431
                       
3432
                       if(domaintype='system') then
3433
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description from domain_system where id like idkey order by id desc;                        
3434
                       end if;
3435
                else
3436
                      if(domaintype='data') then                       
3437
                         select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_data where id in
3438
                         (select domain_id from members_domain_data where user_id=@nervuser and (member_type='manager' or member_type='member'))
3439
                         union distinct
3440
                         select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_data where (user_id=@nervuser or public = 1);
3441
                      end if;
3442
                                                
3443
                        if(domaintype='method') then
3444
                        select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description  FROM domain_method where id in
3445
                        (select domain_id from members_domain_method where user_id=@nervuser and (member_type='manager' or member_type='member'))
3446
                        union distinct
3447
                        select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description  FROM domain_method where (user_id=@nervuser or public = 1);
3448
                         
3449
                        end if;
3450
                        if(domaintype='system') then
3451
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_system where id in
3452
                        (select domain_id from members_domain_system where user_id=@nervuser and (member_type='manager' or member_type='member'))
3453
                        union distinct
3454
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_system where (user_id=@nervuser or public = 1);
3455
                        end if;
3456
                end if;
3457
       else
3458
               select 0 as test;
3459
       end if;
3460

    
3461
END//
3462
DELIMITER ;
3463

    
3464
-- 프로시저 nerv_icde_xxxx.mainViewDomainList 구조 내보내기
3465
DELIMITER //
3466
CREATE PROCEDURE `mainViewDomainList`(
3467
	IN `idkey` varchar(100),
3468
	IN `domaintype` varchar(100)
3469
)
3470
BEGIN
3471
        declare sm bool;
3472
        if loginTest() then
3473
                select 1 as test;
3474
                if( supermanagerTest(@nervuser) ) then
3475
                       if(domaintype='data') then                        
3476
                        select * from ( select id, name, upper_id, user_id, public, 0, create_date, last_update, description from domain_data where domain_data.upper_id=idkey 
3477
								union
3478
								select id, name, upper_id, user_id, public, 0, create_date, last_update, description from domain_data where domain_data.upper_id in
3479
																(select domain_data.id from domain_data where domain_data.upper_id=idkey)
3480
								) as uuu order by name desc;
3481
                       end if;
3482
                       if(domaintype='method') then                       
3483
                        select * from (select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description from domain_method where domain_method.upper_id=idkey 
3484
								 union
3485
								 select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description from domain_method where domain_method.upper_id in
3486
																(select domain_method.id from domain_method where domain_method.upper_id=idkey)
3487
								) as uuu order by name desc;
3488
                       end if;
3489
                       if(domaintype='system') then
3490
                        select * from ( select id, name, upper_id, user_id, public, 0, create_date, last_update, description from domain_system where domain_system.upper_id=idkey 
3491
								union
3492
								select id, name, upper_id, user_id, public, 0, create_date, last_update, description from domain_system where domain_system.upper_id in
3493
																(select domain_system.id from domain_system where domain_system.upper_id=idkey)
3494
								) as uuu order by name desc;
3495
                       end if;
3496
                else
3497
                      if(domaintype='data') then                       
3498
                        select * from (
3499
						      select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_data where id in
3500
                         (select domain_id from members_domain_data where user_id=@nervuser and (member_type='manager' or member_type='member')) 
3501
                        union distinct
3502
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_data where (user_id=@nervuser or public = 1)
3503
                        ) as uuu order by name desc;
3504
                      end if;
3505
                      if(domaintype='method') then
3506
                        select * from (
3507
                        select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description  FROM domain_method where id in
3508
                        (select domain_id from members_domain_method where user_id=@nervuser and (member_type='manager' or member_type='member'))
3509
                        union distinct
3510
                        select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description  FROM domain_method where (user_id=@nervuser or public = 1)
3511
                        ) as uuu order by name desc;
3512
                      end if;
3513
                      if(domaintype='system') then
3514
                        select * from (
3515
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_system where id in
3516
                        (select domain_id from members_domain_system where user_id=@nervuser and (member_type='manager' or member_type='member'))
3517
                        union distinct
3518
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_system where (user_id=@nervuser or public = 1)
3519
                        ) as uuu order by name desc;
3520
                      end if;
3521
                end if;
3522
       else
3523
               select 0 as test;
3524
       end if;
3525
END//
3526
DELIMITER ;
3527

    
3528
-- 프로시저 nerv_icde_xxxx.metadataViewCopyData 구조 내보내기
3529
DELIMITER //
3530
CREATE PROCEDURE `metadataViewCopyData`(IN `copy_data_auto_id` INT, IN `paste_domain_id` INT)
3531
BEGIN
3532

    
3533
	declare new_data_auto_id int default null;
3534
	
3535
   if loginTest() and newDomainTest() then
3536
      select 1 as test;
3537
      
3538
	   insert into data (data.domain_id, data.name, data.`type`, data.real_data_auto_id, data.scmin, data.scmax, data.seq, data.description, data.user_id)
3539
		select paste_domain_id, data.name, data.`type`, data.real_data_auto_id, data.scmin, data.scmax, data.seq, data.description,@nervuser from data where data_auto_id=copy_data_auto_id;
3540
	
3541
	   select LAST_INSERT_ID() into new_data_auto_id;    
3542
   
3543
		insert into data_field (data_field.data_auto_id, data_field.member_name, data_field.`type`, data_field.real_data_auto_id, data_field.user_id, data_field.bitsize, data_field.scimin, data_field.scimax, data_field.arraytype, data_field.description,data_field.seq )
3544
		select new_data_auto_id, data_field.member_name, data_field.`type`, data_field.real_data_auto_id, @nervuser, data_field.bitsize, data_field.scimin, data_field.scimax, data_field.arraytype, data_field.description, data_field.seq from data_field
3545
				 where data_field.data_auto_id=copy_data_auto_id;
3546
	else
3547
      select 0 as test;
3548
	end if;
3549
END//
3550
DELIMITER ;
3551

    
3552
-- 프로시저 nerv_icde_xxxx.metadataViewDeleteMetadata 구조 내보내기
3553
DELIMITER //
3554
CREATE PROCEDURE `metadataViewDeleteMetadata`(domain_idkey int,metadata_namekey varchar(100))
3555
BEGIN
3556
        if loginTest() and domainManageTest(domain_idkey) then
3557
                select 1 as test;
3558
                delete from data where domain_id=domain_idkey and name=metadata_namekey;
3559
                        
3560
        else
3561
                select 0 as test;
3562
        end if;
3563
END//
3564
DELIMITER ;
3565

    
3566
-- 프로시저 nerv_icde_xxxx.metadataViewDeleteMetafield 구조 내보내기
3567
DELIMITER //
3568
CREATE PROCEDURE `metadataViewDeleteMetafield`(IN `domain_idkey` int, IN `metadata_namekey` varchar(100), IN `member_namekey` varchar(100))
3569
BEGIN
3570

    
3571
	declare datakey_auto_id int default 0;
3572
	
3573
        if loginTest() and domainManageTest(domain_idkey) then
3574
                select 1 as test;
3575
                
3576
                delete from data_field where member_name=member_namekey and data_field.data_auto_id in
3577
					  (select data.data_auto_id from data where data.domain_id=domain_idkey and data.name=metadata_namekey);
3578
        else
3579
                select 0 as test;
3580
        end if;
3581
END//
3582
DELIMITER ;
3583

    
3584
-- 프로시저 nerv_icde_xxxx.metadataViewEditMetadata 구조 내보내기
3585
DELIMITER //
3586
CREATE PROCEDURE `metadataViewEditMetadata`(
3587
	IN `domain_idkey` int,
3588
	IN `metadatakey` varchar(100),
3589
	IN `data_namevalue` varchar(100),
3590
	IN `typevalue` varchar(100),
3591
	IN `in_real_data_auto_id` varchar(100),
3592
	IN `scminvalue` varchar(100),
3593
	IN `scmaxvalue` varchar(100),
3594
	IN `descriptionvalue` TEXT
3595
)
3596
BEGIN
3597
       declare data_depth int default 0;
3598
       declare real_data_domain_id int default 0;
3599
       declare data_id int;
3600
       declare real_data_path int;      
3601
       
3602
        if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(in_real_data_auto_id) )then
3603
                if typevalue='alias' then
3604
					 	select data.domain_id into real_data_domain_id from data where data.data_auto_id=in_real_data_auto_id;                        
3605
					 else
3606
                	set in_real_data_auto_id=null;
3607
                end if;                
3608
                	
3609
               select data.data_auto_id into data_id from data where data.domain_id=domain_idkey and data.name=metadatakey;
3610
               select data.depth into data_depth from data where data.data_auto_id=data_id;
3611
                	
3612
               if domain_idkey=real_data_domain_id then
3613
               	if typevalue ='alias' then               		
3614
               		select data.depth into real_data_path from data where data.data_auto_id=in_real_data_auto_id;
3615
               		if data_depth <= real_data_path then
3616
								set data_depth = real_data_path +1;               		               		
3617
               			call update_child_depth(data_id,domain_idkey,data_depth);
3618
               			
3619
							end if;	      		   	
3620
               	end if;
3621
               end if;   
3622
                
3623
                select 1 as test;
3624
                
3625
                update data set name=data_namevalue,
3626
                                type=typevalue,
3627
                                data.real_data_auto_id=in_real_data_auto_id,
3628
                                scmin=scminvalue,
3629
                                scmax=scmaxvalue,
3630
                                description=descriptionvalue,
3631
                                data.depth = data_depth
3632
                                where data.data_auto_id=data_id;                                
3633
                        
3634
        else
3635
                select 0 as test;
3636
        end if;
3637
END//
3638
DELIMITER ;
3639

    
3640
-- 프로시저 nerv_icde_xxxx.metadataViewEditMetadataRealdomainList 구조 내보내기
3641
DELIMITER //
3642
CREATE PROCEDURE `metadataViewEditMetadataRealdomainList`(domain_idkey int)
3643
BEGIN
3644
        declare sm bool;
3645
        declare sa varchar(100);
3646
        declare acount varchar(100);
3647
        declare pbc bool;
3648

    
3649
        set sa = '';
3650
        if loginTest() then
3651
                    select supermanager into sm from users where user_id=@nervuser;
3652
                    select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
3653
                    select user_id into acount from domain_data where id=domain_idkey;
3654
                    select public into pbc from domain_data where id=domain_idkey;
3655

    
3656
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3657
                        select 1 as test;
3658
                         (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id in (select parent_domain_id from inheritance_data_data where domain_id=domain_idkey))
3659
                           union
3660
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id=domain_idkey);
3661
                                          
3662

    
3663
                     else
3664
                        select 0 as test;
3665
                     end if;
3666
              
3667
        else
3668
                select 0 as test;
3669
        end if;
3670
End//
3671
DELIMITER ;
3672

    
3673
-- 프로시저 nerv_icde_xxxx.metadataViewEditMetadataRealmetadataList 구조 내보내기
3674
DELIMITER //
3675
CREATE PROCEDURE `metadataViewEditMetadataRealmetadataList`(domain_idkey int)
3676
BEGIN
3677
        declare sm bool;
3678
        declare sa varchar(100);
3679
        declare acount varchar(100);
3680
        declare pbc bool;
3681
    
3682
        set sa = '';
3683
        if loginTest() then
3684
                     select supermanager into sm from users where user_id=@nervuser;
3685
                     select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
3686
                     select user_id into acount from domain_data where id=domain_idkey;
3687
                     select public into pbc from domain_data where id=domain_idkey;
3688

    
3689
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3690
                        select 1 as test;
3691
                         select * from data where domain_id=domain_idkey order by seq asc;
3692
                     else
3693
                        select 0 as test;
3694
                     end if;        
3695
        else
3696
                select 0 as test;
3697
        end if;
3698
END//
3699
DELIMITER ;
3700

    
3701
-- 프로시저 nerv_icde_xxxx.metadataViewEditMetadataSeq 구조 내보내기
3702
DELIMITER //
3703
CREATE PROCEDURE `metadataViewEditMetadataSeq`(IN `domain_idkey` int, IN `metadatakey1` varchar(100), IN `metadatakey2` varchar(100))
3704
BEGIN
3705
        declare t1 timestamp;
3706
        declare t2 timestamp;
3707
        
3708

    
3709

    
3710
        if loginTest() and domainManageTest(domain_idkey) then
3711
                select 1 as test;
3712
                       select seq into t1 from data where domain_id=domain_idkey and name=metadatakey1;
3713
                       select seq into t2 from data where domain_id=domain_idkey and name=metadatakey2;
3714
                       update data set seq = t2 where domain_id=domain_idkey and name=metadatakey1;
3715
                       update data set seq = t1 where domain_id=domain_idkey and name=metadatakey2;
3716
        else
3717
                select 0 as test;
3718
        end if;
3719
END//
3720
DELIMITER ;
3721

    
3722
-- 프로시저 nerv_icde_xxxx.metadataViewEditMetafield 구조 내보내기
3723
DELIMITER //
3724
CREATE PROCEDURE `metadataViewEditMetafield`(IN `domain_idkey` int, IN `metadatakey` varchar(100), IN `metafieldkey` varchar(100), IN `metafieldvalue` varchar(100), IN `bitsizevalue` int unsigned, IN `typevalue` varchar(100), IN `realdomainvalue` int, IN `realmetadatavalue` varchar(100), IN `minvalue` varchar(100), IN `in_maxvalue` varchar(100), IN `arraytypevalue` varchar(100), IN `arraysizevalue` int unsigned, IN `descriptionvalue` text)
3725
BEGIN
3726
		 declare data_depth int default 0;
3727
		 declare data_field_depth int default 0;
3728
 		 declare datakey_auto_id int default 0;
3729
 		 declare real_data_auto_id int default 0;
3730
		 
3731
		 if typevalue!='alias' then
3732
       	set real_data_auto_id=null;
3733
       else
3734
       	select data.data_auto_id into real_data_auto_id from data where data.domain_id=realdomainvalue and data.name=realmetadatavalue;
3735
       end if;
3736
		 
3737
       if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(real_data_auto_id) ) then                
3738
                	
3739
           	 select 1 as test;
3740
       			select data.data_auto_id into datakey_auto_id from data where data.domain_id=domain_idkey and data.name=metadatakey; 
3741

    
3742
            	if typevalue ='alias' then            		
3743
  						if domain_idkey=realdomainvalue then
3744
               		select data.depth into data_depth from data where data.data_auto_id=datakey_auto_id;
3745
               		select data.depth into data_field_depth from data where data.data_auto_id=real_data_auto_id;
3746
               		
3747
               		if data_depth <= data_field_depth then               		
3748
               			set data_field_depth = data_field_depth + 1;
3749
               			
3750
               			update data set data.depth = data_field_depth where data.domain_id=domain_idkey and data.name=metadatakey;               			
3751
               			
3752
               			call update_child_depth(real_data_auto_id,realdomainvalue,data_field_depth);
3753
               		end if;               		
3754
               	end if;
3755
               end if;     
3756
                update data_field set member_name=metafieldvalue,
3757
                                      bitsize=bitsizevalue,
3758
                                      type=typevalue,
3759
                                      data_field.real_data_auto_id=real_data_auto_id,
3760
                                      scimin=minvalue,
3761
                                      scimax=in_maxvalue,
3762
                                      arraytype=arraytypevalue,
3763
                                      arraysize=arraysizevalue,
3764
                                      description=descriptionvalue,
3765
                                      seq=seq
3766
                                 where data_field.data_auto_id=datakey_auto_id and data_field.member_name=metafieldkey;
3767
        else
3768
                select 0 as test;
3769
        end if;
3770
END//
3771
DELIMITER ;
3772

    
3773
-- 프로시저 nerv_icde_xxxx.metadataViewEditMetafieldRealdomainList 구조 내보내기
3774
DELIMITER //
3775
CREATE PROCEDURE `metadataViewEditMetafieldRealdomainList`(IN `domain_idkey` int )
3776
BEGIN
3777
        declare sm bool;
3778
        declare sa varchar(100);
3779
        declare acount varchar(100);
3780
        declare pbc bool;
3781

    
3782
        set sa = '';
3783
        if loginTest() then
3784
                    select supermanager into sm from users where user_id=@nervuser;
3785
                    select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
3786
                    select user_id into acount from domain_data where id=domain_idkey;
3787
                    select public into pbc from domain_data where id=domain_idkey;
3788

    
3789
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3790
                        select 1 as test;
3791
                         (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id in
3792
								  (select parent_domain_id from inheritance_data_data where domain_id=domain_idkey))
3793
                           union
3794
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id=domain_idkey);
3795
                                          
3796

    
3797
                     else
3798
                        select 0 as test;
3799
                     end if;
3800
              
3801
        else
3802
                select 0 as test;
3803
        end if;
3804
End//
3805
DELIMITER ;
3806

    
3807
-- 프로시저 nerv_icde_xxxx.metadataViewEditMetafieldRealmetadataList 구조 내보내기
3808
DELIMITER //
3809
CREATE PROCEDURE `metadataViewEditMetafieldRealmetadataList`(domain_idkey int)
3810
BEGIN
3811
        declare sm bool;
3812
        declare sa varchar(100);
3813
        declare acount varchar(100);
3814
        declare pbc bool;
3815
    
3816
        set sa = '';
3817
        if loginTest() then
3818
                     select supermanager into sm from users where user_id=@nervuser;
3819
                     select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
3820
                     select user_id into acount from domain_data where id=domain_idkey;
3821
                     select public into pbc from domain_data where id=domain_idkey;
3822

    
3823
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3824
                        select 1 as test;
3825
                         select * from data where domain_id=domain_idkey order by domain_id asc;
3826
                         
3827
                     else
3828
                        select 0 as test;
3829
                     end if;        
3830
        else
3831
                select 0 as test;
3832
        end if;
3833
END//
3834
DELIMITER ;
3835

    
3836
-- 프로시저 nerv_icde_xxxx.metadataViewEditMetafieldSeq 구조 내보내기
3837
DELIMITER //
3838
CREATE PROCEDURE `metadataViewEditMetafieldSeq`(IN `domain_idkey` int, IN `domaintype` varchar(50), IN `metadatakey` varchar(100), IN `metadatakey1` varchar(100), IN `metadatakey2` varchar(100))
3839
BEGIN
3840
        declare t1 timestamp;
3841
        declare t2 timestamp;
3842

    
3843
        declare data_auto_id_key int default null;
3844
        
3845
        if loginTest() and domainManageTest(domain_idkey) then
3846
                select 1 as test;
3847
                select data.data_auto_id into data_auto_id_key from data where data.domain_id=domain_idkey and data.name=metadatakey;
3848
                
3849
                  select seq into t1 from data_field where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey1;
3850
                  select seq into t2 from data_field where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey2;
3851
                update data_field set seq = t2 where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey1;
3852
                update data_field set seq = t1 where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey2;
3853
        else
3854
                select 0 as test;
3855
        end if;
3856

    
3857
END//
3858
DELIMITER ;
3859

    
3860
-- 프로시저 nerv_icde_xxxx.metadataViewMetadataList 구조 내보내기
3861
DELIMITER //
3862
CREATE PROCEDURE `metadataViewMetadataList`(
3863
	IN `domain_idkey` int,
3864
	IN `metadatakey` varchar(100),
3865
	IN `domain_idtype` varchar(50)
3866

    
3867
)
3868
BEGIN
3869

    
3870
        if loginTest() and domainReadTest(domain_idkey, domain_idtype) then
3871
                select 1 as test;
3872
                
3873
                
3874
                select a.data_auto_id, a.domain_id, a.name, a.user_id, a.type, b.domain_id as real_domain_id, b.name as real_data_name, a.scmin, a.scmax, a.description, c.name as real_domain_name, a.real_data_auto_id from
3875
                
3876
    					(select * from data where domain_id=domain_idkey and name like metadatakey order by depth asc) as a
3877
    						left join
3878
    					(select data.data_auto_id, data.domain_id, data.name from data) as b on a.real_data_auto_id = b.data_auto_id
3879
        					left join
3880
    					(select id, name from domain_data) as c on b.domain_id = c.id;
3881
        else
3882
                select 0 as test;
3883
        end if;
3884
END//
3885
DELIMITER ;
3886

    
3887
-- 프로시저 nerv_icde_xxxx.metadataViewMetadataListByTypeSort 구조 내보내기
3888
DELIMITER //
3889
CREATE PROCEDURE `metadataViewMetadataListByTypeSort`(IN `domain_idkey` int, IN `metadatakey` varchar(100), IN `domain_idtype` varchar(50))
3890
BEGIN
3891

    
3892
        if loginTest() and domainReadTest(domain_idkey, domain_idtype) then
3893
                select 1 as test;
3894
                select a.data_auto_id, a.domain_id, a.name, a.user_id, a.type, b.domain_id, b.name, a.scmin, a.scmax, a.description, c.name, a.real_data_auto_id from                
3895
    					(select * from data where domain_id=domain_idkey and name like metadatakey order by type asc) as a
3896
    						left join
3897
    					(select data.data_auto_id, data.domain_id, data.name from data) as b on a.real_data_auto_id = b.data_auto_id
3898
        					left join
3899
    					(select id, name from domain_data) as c on b.domain_id = c.id;
3900
        else
3901
                select 0 as test;
3902
        end if;
3903
END//
3904
DELIMITER ;
3905

    
3906
-- 프로시저 nerv_icde_xxxx.metadataViewMetafieldList 구조 내보내기
3907
DELIMITER //
3908
CREATE PROCEDURE `metadataViewMetafieldList`(
3909
	IN `domain_idkey` int,
3910
	IN `metadatakey` varchar(100 ),
3911
	IN `domain_idtype` varchar(100) 
3912
)
3913
BEGIN
3914

    
3915
        if loginTest() and domainReadTest(domain_idkey, domain_idtype) then
3916
                select 1 as test;
3917
                
3918
                select o.domain_id, o.name, a.member_name, i.domain_id as real_domain_id,b.name as real_domain_name, i.name as real_data_name, a.user_id , a.type, a.bitsize, a.scimin, a.scimax, a.arraytype, a.arraysize, a.seq, a.description  from
3919
					(select * from data_field where data_field.data_auto_id in (select data_auto_id from data where data.domain_id=domain_idkey and data.name = metadatakey) order by seq asc) as a
3920
						left outer join
3921
					(select data.data_auto_id, data.domain_id, data.name from data) as o on o.data_auto_id=a.data_auto_id    
3922
						left outer join
3923
					(select data.data_auto_id, data.domain_id, data.name from data) as i on a.real_data_auto_id=i.data_auto_id   
3924
					  left outer join
3925
               (select id, name from domain_data) as b on i.domain_id = b.id order by seq asc;
3926
        else
3927
                select 0 as test;
3928
        end if;
3929
END//
3930
DELIMITER ;
3931

    
3932
-- 프로시저 nerv_icde_xxxx.metadataViewNewMetadata 구조 내보내기
3933
DELIMITER //
3934
CREATE PROCEDURE `metadataViewNewMetadata`(
3935
	IN `domain_idkey` int,
3936
	IN `metadatakey` varchar(100),
3937
	IN `typevalue` varchar(100),
3938
	IN `real_data_auto_id` int,
3939
	IN `scminvalue` varchar(100),
3940
	IN `scmaxvalue` varchar(100),
3941
	IN `descriptionvalue` text
3942
)
3943
BEGIN
3944
       declare cnt int default 0;
3945
       declare depth int default 0;       
3946
       declare real_data_domain_id int default null;
3947
       declare real_data_name varchar(100) default null;
3948
       
3949
       if typevalue ='alias' then                     
3950
       	select data.domain_id into real_data_domain_id from data where data.data_auto_id=real_data_auto_id;
3951
       	select data.name into real_data_name from data where data.data_auto_id=real_data_auto_id;
3952
      else
3953
      	set real_data_auto_id = NULL;
3954
       end if;     
3955

    
3956
        if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(real_data_auto_id) )then
3957
 					
3958
					
3959
					
3960
               if domain_idkey=real_data_domain_id then
3961
               	if typevalue ='alias' then
3962
               		select data.depth into depth from data where data.data_auto_id=real_data_auto_id;
3963
               		set depth = depth +1;
3964
               	end if;
3965
               end if;             
3966
              
3967
                select 1 as test;
3968
                insert into data (domain_id   ,name       ,user_id     ,type     , real_data_auto_id     , scmin     ,scmax     ,description, depth)
3969
                              values(domain_idkey,metadatakey,@nervuser,typevalue, real_data_auto_id, scminvalue,scmaxvalue,descriptionvalue, depth);                  
3970
              
3971
        else
3972
                select 0 as test;
3973
        end if;
3974
END//
3975
DELIMITER ;
3976

    
3977
-- 프로시저 nerv_icde_xxxx.metadataViewNewMetadataRealdomainList 구조 내보내기
3978
DELIMITER //
3979
CREATE PROCEDURE `metadataViewNewMetadataRealdomainList`(IN `domain_idkey` int)
3980
BEGIN
3981
        declare sm bool;
3982
        declare sa varchar(100);
3983
        declare acount varchar(100);
3984
        declare pbc bool;
3985
        
3986
        set sa = '';
3987

    
3988
        if loginTest() then
3989
                    select supermanager into sm from users where user_id=@nervuser;
3990
                    select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
3991
                    select user_id into acount from domain_data where id=domain_idkey;
3992
                    select public into pbc from domain_data where id=domain_idkey;
3993

    
3994
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3995
                        select 1 as test;
3996
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data
3997
								 where id in (select parent_domain_id from inheritance_data_data where domain_id=domain_idkey))
3998
                         union
3999
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data
4000
								 where id=domain_idkey);                                
4001
                    else
4002
                        select 0 as test;
4003
                     end if;
4004
               else
4005
                 select 0 as test;
4006
        end if;
4007
End//
4008
DELIMITER ;
4009

    
4010
-- 프로시저 nerv_icde_xxxx.metadataViewNewMetadataRealmetadataList 구조 내보내기
4011
DELIMITER //
4012
CREATE PROCEDURE `metadataViewNewMetadataRealmetadataList`(domain_idkey int)
4013
BEGIN
4014
        declare sm bool;
4015
        declare sa varchar(100);
4016
        declare acount varchar(100);
4017
        declare pbc bool;
4018
    
4019
        set sa = '';
4020
        if loginTest() then
4021
                     select supermanager into sm from users where user_id=@nervuser;
4022
                     select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
4023
                     select user_id into acount from domain_data where id=domain_idkey;
4024
                     select public into pbc from domain_data where id=domain_idkey;
4025

    
4026
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4027
                        select 1 as test;
4028
                         select * from data where domain_id=domain_idkey order by domain_id asc;
4029
                     else
4030
                        select 0 as test;
4031
                     end if;        
4032
        else
4033
                select 0 as test;
4034
        end if;
4035
END//
4036
DELIMITER ;
4037

    
4038
-- 프로시저 nerv_icde_xxxx.metadataViewNewMetafield 구조 내보내기
4039
DELIMITER //
4040
CREATE PROCEDURE `metadataViewNewMetafield`(
4041
	IN `domain_idkey` int,
4042
	IN `metadatakey` varchar(100),
4043
	IN `metafieldkey` varchar(100),
4044
	IN `bitsizevalue` int unsigned,
4045
	IN `typevalue` varchar(100),
4046
	IN `real_domain_id_value` INT,
4047
	IN `real_data_value` VARCHAR(100),
4048
	IN `minvalue` varchar(100),
4049
	IN `in_maxvalue` varchar(100),
4050
	IN `arraytypevalue` varchar(100),
4051
	IN `arraysizevalue` int unsigned,
4052
	IN `descriptionvalue` text
4053

    
4054

    
4055

    
4056

    
4057
)
4058
BEGIN
4059
		 declare datakey_auto_id int default 0;
4060
		 declare real_data_auto_id int default 0;
4061
		 declare data_depth int default 0;
4062
		 declare data_field_depth int default 0;
4063
		 
4064
		 if typevalue!='alias' then
4065
       	set real_data_auto_id=null;
4066
       else
4067
       	select data.data_auto_id into real_data_auto_id from data where data.domain_id=real_domain_id_value and data.name=real_data_value;
4068
       end if;
4069
                        
4070
        if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(real_data_auto_id) ) then
4071

    
4072
        			select data.data_auto_id into datakey_auto_id from data where data.domain_id=domain_idkey and data.name=metadatakey;      				 
4073
					
4074
               if typevalue ='alias' then               	
4075
                  if real_data_auto_id != datakey_auto_id then
4076
							if domain_idkey=real_domain_id_value then
4077
	               		select data.depth into data_depth from data where data.domain_id=domain_idkey and data.name=metadatakey;
4078
	               		select data.depth into data_field_depth from data where data.data_auto_id=real_data_auto_id;               		
4079
	               		
4080
	               		 if data_depth <= data_field_depth then
4081
	               			set data_depth = data_field_depth + 1;
4082
			                             			
4083
									update data set data.depth = data_depth where data.data_auto_id=datakey_auto_id;
4084
									
4085
	               			call update_child_depth(datakey_auto_id, domain_idkey, data_depth);
4086
	               		 end if;               		               	
4087
							end if;
4088
                     select 1 as test;
4089
							insert into data_field( data_auto_id, member_name,       bitsize,      type, real_data_auto_id,   user_id,scimin,  scimax,      arraytype,     arraysize, description)
4090
											values(datakey_auto_id, metafieldkey, bitsizevalue, typevalue, real_data_auto_id, @nervuser,minvalue,in_maxvalue,arraytypevalue,arraysizevalue,descriptionvalue);
4091
							
4092
						else
4093
							select 0 as test;
4094
                  end if;
4095
               else
4096
                 select 1 as test;
4097
                 insert into data_field( data_auto_id, member_name,       bitsize,      type, real_data_auto_id,   user_id,scimin,  scimax,      arraytype,     arraysize, description)
4098
                               values(datakey_auto_id, metafieldkey, bitsizevalue, typevalue, real_data_auto_id, @nervuser,minvalue,in_maxvalue,arraytypevalue,arraysizevalue,descriptionvalue);               
4099
               end if; 
4100

    
4101
        else
4102
                select 0 as test;
4103
        end if;
4104
END//
4105
DELIMITER ;
4106

    
4107
-- 프로시저 nerv_icde_xxxx.metadataViewNewMetafieldRealdomainList 구조 내보내기
4108
DELIMITER //
4109
CREATE PROCEDURE `metadataViewNewMetafieldRealdomainList`(domain_idkey int)
4110
BEGIN
4111
        declare sm bool;
4112
        declare sa varchar(100);
4113
        declare acount varchar(100);
4114
        declare pbc bool;
4115

    
4116
        set sa = '';
4117
        if loginTest() then
4118
                    select supermanager into sm from users where user_id=@nervuser;
4119
                    select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
4120
                    select user_id into acount from domain_data where id=domain_idkey;
4121
                    select public into pbc from domain_data where id=domain_idkey;
4122

    
4123
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4124
                        select 1 as test;
4125
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id
4126
                                in (select parent_domain_id from inheritance_data_data where domain_id=domain_idkey))
4127
                         union
4128
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id=domain_idkey);
4129
                    else
4130
                        select 0 as test;
4131
                     end if;
4132
               else
4133
                 select 0 as test;
4134
        end if;
4135
End//
4136
DELIMITER ;
4137

    
4138
-- 프로시저 nerv_icde_xxxx.metadataViewNewMetafieldRealmetadataList 구조 내보내기
4139
DELIMITER //
4140
CREATE PROCEDURE `metadataViewNewMetafieldRealmetadataList`(IN `domain_idkey` int, IN `domain_name` varchar(100))
4141
BEGIN
4142
        declare sm bool;
4143
        declare sa varchar(100);
4144
        declare acount varchar(100);
4145
        declare pbc bool;
4146
    
4147
        set sa = '';
4148
        if loginTest() then
4149
                     select supermanager into sm from users where user_id=@nervuser;
4150
                     select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
4151
                     select user_id into acount from domain_data where id=domain_idkey;
4152
                     select public into pbc from domain_data where id=domain_idkey;
4153

    
4154
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4155
                        select 1 as test;
4156
                        select data.data_auto_id, data.domain_id, data.name, data.`type`, data.real_data_auto_id, data.scmin, data.scmax, data.seq, data.description, data.user_id from data where domain_id=domain_idkey order by domain_id asc;
4157
                         
4158
                     else
4159
                        select 0 as test;
4160
                     end if;        
4161
        else
4162
                select 0 as test;
4163
        end if;
4164
END//
4165
DELIMITER ;
4166

    
4167
-- 프로시저 nerv_icde_xxxx.methodInfoList 구조 내보내기
4168
DELIMITER //
4169
CREATE PROCEDURE `methodInfoList`(domain_idkey int, methodkey varchar(100))
4170
BEGIN
4171

    
4172
        if loginTest() then
4173
                select 1 as test;
4174
                       select a.type, a.code, a.name,a.in_domain_id, a.in_data, a.out_domain_id, a.out_data, a.user_id, a.description, b.name, c.name from 
4175
                           (select type,code,name,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4176
                              where domain_id=domain_idkey && name=methodkey) as a 
4177
                             left outer join
4178
                              (select id, name from domain_data) as b on a.in_domain_id = b.id
4179
                              left outer join
4180
                              (select id, name from domain_data) as c on a.out_domain_id = c.id;
4181
        else
4182
                select 0 as test;
4183

    
4184
         end if;
4185
          
4186
        
4187
END//
4188
DELIMITER ;
4189

    
4190
-- 프로시저 nerv_icde_xxxx.methodViewDeleteMethod 구조 내보내기
4191
DELIMITER //
4192
CREATE PROCEDURE `methodViewDeleteMethod`(domain_idkey int, methodkey varchar(100))
4193
BEGIN
4194
        if loginTest() and domainManageTest(domain_idkey) then
4195
                select 1 as test;
4196
                delete from method where domain_id=domain_idkey and name=methodkey;
4197
                       
4198
        else
4199
                select 0 as test;
4200
        end if;
4201
END//
4202
DELIMITER ;
4203

    
4204
-- 프로시저 nerv_icde_xxxx.methodViewEditMethod 구조 내보내기
4205
DELIMITER //
4206
CREATE PROCEDURE `methodViewEditMethod`(IN `domain_idkey` int, IN `methodkey` varchar(100), IN `typevalue` varchar(100), IN `codevalue` varchar(100), IN `methodvalue` varchar(100), IN `inputdomainvalue` int(10) unsigned, IN `inputmetadatavalue` varchar(100), IN `outputdomainvalue` int(10) unsigned, IN `outputmetadatavalue` varchar(100), IN `descriptionvalue` text)
4207
BEGIN
4208

    
4209
	declare in_real_data_auto_id int default null;
4210
	declare out_real_data_auto_id int default null;
4211

    
4212
	if inputdomainvalue!=0 then
4213
      select data.data_auto_id into in_real_data_auto_id  from data where data.domain_id=inputdomainvalue and data.name=inputmetadatavalue;
4214
	end if;
4215
	if outputdomainvalue!=0 then
4216
      select data.data_auto_id into out_real_data_auto_id  from data where data.domain_id=outputdomainvalue and data.name=outputmetadatavalue;
4217
	end if;	     
4218

    
4219
     if loginTest() and domainManageTest(domain_idkey) and (in_real_data_auto_id is NULL or existMetadata(in_real_data_auto_id) )
4220
                                                       and (out_real_data_auto_id is NULL or existMetadata(out_real_data_auto_id)) then
4221
                select 1 as test;
4222
                update method set       code=codevalue,
4223
                                        type=typevalue,
4224
                                        name=methodvalue,
4225
                                        method.in_data_auto_id=in_real_data_auto_id,
4226
                                        method.out_data_auto_id=out_real_data_auto_id,
4227
                                        description=descriptionvalue
4228
                              where     domain_id=domain_idkey and name=methodkey;
4229
                              
4230
                                        
4231
                                        
4232
                                        
4233
                                        
4234
                                        
4235
                        
4236
        else
4237
                select 0 as test;
4238
        end if;
4239
END//
4240
DELIMITER ;
4241

    
4242
-- 프로시저 nerv_icde_xxxx.methodViewEditMethodRealdomainList 구조 내보내기
4243
DELIMITER //
4244
CREATE PROCEDURE `methodViewEditMethodRealdomainList`(domain_idkey int)
4245
BEGIN
4246
        declare sm bool;
4247
        declare sa varchar(100);
4248
        declare acount varchar(100);
4249
        declare pbc bool;
4250
        
4251
        set sa = '';
4252
        if loginTest() then
4253
                    select supermanager into sm from users where user_id=@nervuser;
4254
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
4255
                    select user_id into acount from domain_method where id=domain_idkey;
4256
                    select public into pbc from domain_method where id=domain_idkey;
4257

    
4258
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4259
                        select 1 as test;
4260
                        (select name from domain_data where id in (select parent_domain_id from inheritance_method_data where domain_id=domain_idkey))
4261
                         union
4262
                        (select name from domain_method where id=domain_idkey);
4263
                         
4264
                                  
4265
                                
4266
                    else
4267
                        select 0 as test;
4268
                     end if;
4269
               else
4270
                 select 0 as test;
4271
        end if;
4272
End//
4273
DELIMITER ;
4274

    
4275
-- 프로시저 nerv_icde_xxxx.methodViewEditMethodRealmetadataList 구조 내보내기
4276
DELIMITER //
4277
CREATE PROCEDURE `methodViewEditMethodRealmetadataList`(domain_idkey int, domainkey varchar(100))
4278
BEGIN
4279
        declare sm bool;
4280
        declare sa varchar(100);
4281
        declare acount varchar(100);
4282
        declare pbc bool;
4283

    
4284
        set sa = '';
4285
        if loginTest() then
4286

    
4287
                     select supermanager into sm from users where user_id = @nervuser;
4288
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
4289
                     select user_id into acount from domain_method where id = domain_idkey;
4290
                     select public into pbc from domain_method where id = domain_idkey;
4291
                     
4292

    
4293
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4294
                        select 1 as test;
4295
                        
4296
                        select name from data where domain_id in (select id from domain_data where name = domainkey);                                 
4297
                      
4298
                     else
4299
                        select 0 as test;
4300
                     end if;               
4301
       else
4302
                select 0 as test;
4303
       end if;
4304
END//
4305
DELIMITER ;
4306

    
4307
-- 프로시저 nerv_icde_xxxx.methodViewMethodList 구조 내보내기
4308
DELIMITER //
4309
CREATE PROCEDURE `methodViewMethodList`(
4310
	IN `domain_idkey` int,
4311
	IN `in_domaintype` varchar(100),
4312
	IN `typekey` varchar(100),
4313
	IN `codekey` varchar(100),
4314
	IN `methodkey` varchar(100)
4315

    
4316
)
4317
BEGIN
4318
	declare domaintype varchar(20);
4319
	set domaintype = 'method';
4320

    
4321
	if codekey='' then
4322
      set codekey = null;    
4323
	end if;     
4324
         if loginTest() and domainReadTest(domain_idkey, domaintype) then
4325
                select 1 as test;
4326
                if typekey = 'ALL' then
4327
                     if codekey is null then
4328
                     	select a.type, a.code, a.name as method_name, i.domain_id as in_domain_id, i.name as in_data_name, o.domain_id as out_domain_id, o.name as out_data_name, a.user_id, a.description, a.domain_id, b.name as in_domain_name, c.name as out_domain_name from
4329
                      	(select type, code, name, in_data_auto_id, out_data_auto_id, user_id, description, domain_id from method where domain_id=domain_idkey and name like methodkey order by code  asc) as a 
4330
                        	left outer join
4331
                      	(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
4332
                        	left outer join
4333
                       	(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id
4334
									left outer join                            
4335
                        (select id, name from domain_data) as b on i.domain_id = b.id
4336
                           left outer join
4337
                        (select id, name from domain_data) as c on o.domain_id = c.id;                           
4338
                     else
4339
                     	select a.type, a.code, a.name as method_name, i.domain_id as in_domain_id, i.name as in_data_name, o.domain_id as out_domain_id, o.name as out_data_name, a.user_id, a.description, a.domain_id, b.name as in_domain_name, c.name as out_domain_name from
4340
                         (select type, code, name, in_data_auto_id, out_data_auto_id, user_id, description, domain_id from method where domain_id=domain_idkey and code like codekey and name like methodkey order by code  asc) as a    
4341
								   left outer join
4342
                      	(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
4343
                        	left outer join
4344
                       	(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id                       
4345
                           left outer join
4346
                         (select id, name from domain_data) as b on i.domain_id = b.id                           
4347
                           left outer join
4348
                         (select id, name from domain_data) as c on o.domain_id = c.id;
4349
                     end if;
4350
                else
4351
                     if codekey is null then                     
4352
                     	select a.type, a.code, a.name as method_name, i.domain_id as in_domain_id, i.name as in_data_name, o.domain_id as out_domain_id, o.name as out_data_name, a.user_id, a.description, a.domain_id, b.name as in_domain_name, c.name as out_domain_name from
4353
                         (select type, code, name, in_domain_id, in_data, out_domain_id, out_data, user_id, description, domain_id from method where domain_id=domain_idkey and type=typekey and name like methodkey order by code  asc) as a
4354
                         left outer join
4355
                      	(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
4356
                        	left outer join
4357
                       	(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id
4358
                           left outer join
4359
                        (select id, name from domain_data) as b on i.in_domain_id = b.id
4360
                           left outer join
4361
                        (select id, name from domain_data) as c on o.out_domain_id = c.id; 
4362
                     else                     
4363
                     	select a.type, a.code, a.name as method_name, i.domain_id as in_domain_id, i.name as in_data_name, o.domain_id as out_domain_id, o.name as out_data_name, a.user_id, a.description, a.domain_id, b.name as in_domain_name, c.name as out_domain_name from
4364
                         (select type, code, name, in_domain_id, in_data, out_domain_id, out_data, user_id, description, domain_id from method where domain_id=domain_idkey and type=typekey and code like codekey and name like methodkey order by code  asc) as a
4365
                             left outer join
4366
                      	(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
4367
                        	left outer join
4368
                       	(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id
4369
                           left outer join
4370
                        (select id, name from domain_data) as b on i.in_domain_id = b.id
4371
                           left outer join
4372
                        (select id, name from domain_data) as c on o.out_domain_id = c.id; 
4373
                     end if;
4374
                end if;
4375
        else
4376
          select 0 as test;
4377
        end if;
4378
END//
4379
DELIMITER ;
4380

    
4381
-- 프로시저 nerv_icde_xxxx.methodViewNewMethod 구조 내보내기
4382
DELIMITER //
4383
CREATE PROCEDURE `methodViewNewMethod`(IN `domain_idkey` int, IN `typevalue` varchar(100), IN `codekey` varchar(100), IN `methodkey` varchar(100), IN `inputdomainvalue` int(100) unsigned, IN `inputmetadatavalue` varchar(100), IN `outputdomainvalue` int(100) unsigned, IN `outputmetadatavalue` varchar(100), IN `descriptionvalue` text)
4384
BEGIN
4385

    
4386
	declare in_real_data_auto_id int default null;
4387
	declare out_real_data_auto_id int default null;
4388

    
4389
	if inputdomainvalue!=0 then
4390
      select data.data_auto_id into in_real_data_auto_id  from data where data.domain_id=inputdomainvalue and data.name=inputmetadatavalue;
4391
	end if;
4392
	if outputdomainvalue!=0 then
4393
      select data.data_auto_id into out_real_data_auto_id  from data where data.domain_id=outputdomainvalue and data.name=outputmetadatavalue;
4394
	end if;
4395
	
4396
	if  loginTest() and domainManageTest(domain_idkey) and (in_real_data_auto_id is NULL or existMetadata(in_real_data_auto_id) )
4397
		 and (out_real_data_auto_id is NULL or existMetadata(out_real_data_auto_id)) then
4398
                select 1 as test;                
4399
                
4400
                insert into method(    domain_id,    code,      type,      name,     method.in_data_auto_id,     method.out_data_auto_id,   user_id, description)
4401
                            values( domain_idkey, codekey, typevalue, methodkey, in_real_data_auto_id, out_real_data_auto_id, @nervuser, descriptionvalue);
4402
        else
4403
                select 0 as test;
4404
        end if;
4405

    
4406
END//
4407
DELIMITER ;
4408

    
4409
-- 프로시저 nerv_icde_xxxx.methodViewNewMethodRealdomainList 구조 내보내기
4410
DELIMITER //
4411
CREATE PROCEDURE `methodViewNewMethodRealdomainList`(IN `domain_idkey` int)
4412
BEGIN
4413
        declare sm bool;
4414
        declare sa varchar(100);
4415
        declare acount varchar(100);
4416
        declare pbc bool;
4417
        
4418
        
4419
        set sa = '';
4420
        if loginTest() then
4421
        
4422
                    select supermanager into sm from users where user_id=@nervuser;
4423
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
4424
                    select user_id into acount from domain_method where id=domain_idkey;
4425
                    select public into pbc from domain_method where id=domain_idkey;
4426

    
4427
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4428
                        select 1 as test;
4429
                        select d.* from
4430
								(
4431
									select domain_id from data where data.data_auto_id in(select method.in_data_auto_id from method where method.domain_id=domain_idkey)
4432
									union
4433
									select domain_id from data where data.data_auto_id in(select method.out_data_auto_id from method where method.domain_id=domain_idkey)
4434
								)as m join domain_data as d on m.domain_id=d.id;
4435

    
4436
                    else
4437
                        select 0 as test;
4438
                     end if;
4439
               else
4440
                 select 0 as test;
4441
        end if;
4442
End//
4443
DELIMITER ;
4444

    
4445
-- 프로시저 nerv_icde_xxxx.methodViewNewMethodRealmetadataList 구조 내보내기
4446
DELIMITER //
4447
CREATE PROCEDURE `methodViewNewMethodRealmetadataList`(IN `domain_idkey` int)
4448
BEGIN
4449
        declare sm bool;
4450
        declare sa varchar(100);
4451
        declare acount varchar(100);
4452
        declare pbc bool;
4453
        
4454
        
4455
        
4456

    
4457
        set sa = '';
4458
        
4459

    
4460
                     
4461
        if loginTest() then
4462
							
4463
							select supermanager into sm from users where user_id = @nervuser;
4464
       					select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
4465
       					select user_id into acount from domain_data where id = domain_idkey;
4466
       					select public into pbc from domain_data where id = domain_idkey;
4467

    
4468
                       if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4469
                          select 1 as test;
4470
                          select data.data_auto_id, data.domain_id, data.name, data.`type`, data.real_data_auto_id,  data.scmin, data.scmax, data.seq, data.description, data.user_id
4471
                                 from data where domain_id=domain_idkey order by domain_id asc;
4472
								                    
4473
                       else
4474
                          select 0 as test;
4475
                       end if;               
4476
       else
4477
                select 0 as test;
4478
       end if;
4479
END//
4480
DELIMITER ;
4481

    
4482
-- 프로시저 nerv_icde_xxxx.methodViewTreeList 구조 내보내기
4483
DELIMITER //
4484
CREATE PROCEDURE `methodViewTreeList`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `typekey` varchar(100), IN `codekey` varchar(100), IN `methodkey` varchar(100))
4485
BEGIN
4486
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
4487
                select 1 as test;
4488
                if typekey = 'ALL' then
4489
                        if codekey = ' ' then
4490
                                select domain_id, name, type,code,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4491
										   where domain_id=domain_idkey and method like methodkey order by code  asc;
4492
                        else
4493
                                select domain_id, name, type,code,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4494
										   where domain_id=domain_idkey and code like codekey and method like methodkey order by code  asc;
4495
                        end if;
4496
                else
4497
                        if codekey = ' ' then
4498
                                select domain_id, name, type,code,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4499
										   where domain_id=domain_idkey and type=typekey and method like methodkey order by code asc;
4500
                        else
4501
                                select domain_id, name, type,code,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4502
										   where domain_id=domain_idkey and type=typekey and code like codekey and method like methodkey order by code asc;
4503
                        end if;
4504
                end if;
4505
        else
4506
                select 0 as test;
4507
        end if;
4508
END//
4509
DELIMITER ;
4510

    
4511
-- 프로시저 nerv_icde_xxxx.networkLinkViewConnectSwitch 구조 내보내기
4512
DELIMITER //
4513
CREATE PROCEDURE `networkLinkViewConnectSwitch`(in_node_id int)
4514
BEGIN
4515
     if loginTest() then
4516
         select 1 as test;
4517
         select b.node_id, b.ip, b.mask, b.port, b.net from
4518
         (select s_node_id, s_port_id, d_node_id, d_port_id from network_link where s_node_id=in_node_id and d_node_id !=0) as a
4519
         join
4520
         (select node_id, ip, mask, port, net from network) as b on b.node_id = a.d_node_id and b.port=a.d_port_id;
4521
               
4522
               
4523
     else
4524
         select 0 as test;
4525
     end if; 
4526
     
4527
End//
4528
DELIMITER ;
4529

    
4530
-- 프로시저 nerv_icde_xxxx.netWorkLinkViewDeleteNetWorkLink 구조 내보내기
4531
DELIMITER //
4532
CREATE PROCEDURE `netWorkLinkViewDeleteNetWorkLink`(in_s_node_id_key int, in_s_port_id_key int)
4533
BEGIN
4534
     if loginTest() then
4535
         select 1 as test;
4536
         delete from network_link where s_node_id = in_s_node_id_key and s_port_id = in_s_port_id_key;
4537
     else
4538
         select 0 as test;
4539
     end if;
4540
End//
4541
DELIMITER ;
4542

    
4543
-- 프로시저 nerv_icde_xxxx.NetworklinkViewEditNetworkink 구조 내보내기
4544
DELIMITER //
4545
CREATE PROCEDURE `NetworklinkViewEditNetworkink`(in_s_node_id_key int, in_s_node_port_key int,
4546
                                                                    in_s_node_id_edit int, in_s_node_sub_system_domain_id int, in_s_node_port_edit int,
4547
                                                                    in_d_node_id_edit int, in_d_node_sub_system_domain_id int, in_d_node_port_edit int)
4548
BEGIN
4549
     if loginTest() then
4550
         select 1 as test;
4551
         UPDATE network_link set s_node_id=in_s_node_id_edit, s_sub_system_id=in_s_node_sub_system_domain_id, s_port_id=in_s_node_port_edit,
4552
                                 d_node_id=in_d_node_id_edit, d_sub_system_id=in_d_node_sub_system_domain_id, d_port_id=in_d_node_port_edit
4553
                             where s_node_id = in_s_node_id_key and s_port_id=in_s_node_port_key;
4554

    
4555
     else
4556
         select 0 as test;
4557
     end if;
4558
End//
4559
DELIMITER ;
4560

    
4561
-- 프로시저 nerv_icde_xxxx.NetworklinkViewNetworkinkList 구조 내보내기
4562
DELIMITER //
4563
CREATE PROCEDURE `NetworklinkViewNetworkinkList`(
4564
	IN `in_system_domain_id` int
4565
)
4566
BEGIN
4567
     if loginTest() then
4568
         select 1 as test;
4569

    
4570
			select * from          
4571
				(
4572
		         select a.s_node_id, b.name as sname, a.s_port_id as s_port_id, a.d_node_id, c.name as dname, a.d_port_id from
4573
		         ((select s_node_id, s_port_id, d_node_id, d_port_id from network_link where s_node_id in (SELECT id from node where systemdomain_id = in_system_domain_id)) as a
4574
   		      join
4575
      		   (select id, name, node.type  from node) as b on b.id = a.s_node_id
4576
         		join
4577
		         (select id, name from node) as c on c.id = a.d_node_id) order by b.type
4578
	         ) as x order by sname, s_port_id asc;
4579
	         
4580

    
4581
        else
4582
         select 0 as test;
4583
     end if;
4584
End//
4585
DELIMITER ;
4586

    
4587
-- 프로시저 nerv_icde_xxxx.NetworklinkViewNewNetworkink 구조 내보내기
4588
DELIMITER //
4589
CREATE PROCEDURE `NetworklinkViewNewNetworkink`(in_s_node_id int, in_s_sub_system_id int, in_s_port_id int,
4590
                                                                   in_d_node_id int, in_d_sub_system_id int, in_d_port_id int)
4591
BEGIN
4592
     if loginTest() then
4593
         select 1 as test;
4594
         insert into network_link(s_node_id, s_sub_system_id, s_port_id, d_node_id, d_sub_system_id, d_port_id)
4595
                           values(in_s_node_id, in_s_sub_system_id, in_s_port_id, in_d_node_id, in_d_sub_system_id, in_d_port_id);
4596
     else
4597
         select 0 as test;
4598
     end if;
4599
End//
4600
DELIMITER ;
4601

    
4602
-- 프로시저 nerv_icde_xxxx.networkNewip 구조 내보내기
4603
DELIMITER //
4604
CREATE PROCEDURE `networkNewip`(IN `innodeid` int, IN `inip` VARCHAR(255), IN `intmask` VARCHAR(255), IN `innet` varchar(50), IN `intgateway` VARCHAR(255), IN `indns` VARCHAR(255), IN `inport` int, IN `indescription` varchar(255))
4605
BEGIN
4606
     if loginTest() then
4607
     		select 1 as test;
4608
          insert into network (node_id,  ip,   mask,    net,   gateway,    dns,   port,   description, collision, original_node_id, original_node_port, original_node_ip)
4609
                      values(innodeid, inip, intmask, innet, intgateway, indns, inport, indescription, 0, NULL, NULL, NULL);
4610
		    insert into deployments_bind(deployments_bind.deployment_id, deployments_bind.node_id, deployments_bind.port, deployments_bind.ip)
4611
		    select deployments.Id, innodeid, inport, inip from deployments where deployments.node_id = innodeid;
4612
     else
4613
         select 0 as test;
4614
     end if;    
4615
     
4616
End//
4617
DELIMITER ;
4618

    
4619
-- 프로시저 nerv_icde_xxxx.networkViewDeleteip 구조 내보내기
4620
DELIMITER //
4621
CREATE PROCEDURE `networkViewDeleteip`(in_node_id int,
4622
                                                          in_ip varchar(100))
4623
BEGIN
4624
        if loginTest() then
4625
                select 1 as test;
4626
                delete from network where node_id=in_node_id and ip=in_ip;
4627
        else
4628
                select 0 as test;
4629
        end if;
4630
END//
4631
DELIMITER ;
4632

    
4633
-- 프로시저 nerv_icde_xxxx.networkViewEditip 구조 내보내기
4634
DELIMITER //
4635
CREATE PROCEDURE `networkViewEditip`(IN `in_node_idkey` int, IN `in_ipkey` varchar(100), IN `in_edit_ip` varchar(100), IN `in_edit_mask` varchar(100), IN `in_edit_net` varchar(100), IN `in_edit_gateway` varchar(100), IN `in_edit_dns` varchar(100), IN `in_port_key` VARCHAR(100), IN `in_edit_port` varchar(100), IN `in_edit_description` varchar(100))
4636
BEGIN
4637
        if loginTest() then
4638
                select 1 as test;
4639
                       update network set ip=in_edit_ip, mask=in_edit_mask, net=in_edit_net, gateway=in_edit_gateway, dns=in_edit_dns,
4640
                                       port=in_edit_port, description=in_edit_description 
4641
                                    where node_id=in_node_idkey and ip=in_ipkey;
4642
                                    
4643
								if in_ipkey != in_edit_ip then
4644
								  	update network set network.ip = in_edit_ip
4645
							 			where network.original_node_id=in_node_idkey and network.original_node_port=in_edit_port and network.original_node_ip=in_ipkey;
4646
							 			
4647
									update deployments_bind a, (select * from deployments_bind where deployments_bind.deployment_id in
4648
									(select deployments_bind.deployment_id from deployments_bind where deployments_bind.ip = in_ipkey and deployments_bind.node_id in(
4649
																							select node_id from network where network.original_node_id = in_node_idkey and
4650
																							 network.original_node_port=in_port_key and network.original_node_ip=in_ipkey))) b
4651
									 set a.ip=in_edit_ip
4652
									 where a.deployment_id = b.deployment_id;              
4653

    
4654
                     		update network set network.original_node_ip=in_edit_ip
4655
							 			where network.original_node_id=in_node_idkey and network.original_node_port=in_edit_port and network.original_node_ip=in_ipkey;
4656
							 	end if;
4657
                      
4658
        else
4659
                select 0 as test;
4660
        end if;
4661
END//
4662
DELIMITER ;
4663

    
4664
-- 프로시저 nerv_icde_xxxx.networkViewList 구조 내보내기
4665
DELIMITER //
4666
CREATE PROCEDURE `networkViewList`(IN `innode_id` int)
4667
BEGIN
4668
     if loginTest() then
4669
         select 1 as test;
4670
     
4671
     	select a.ip, a.mask, a.gateway, a.dns, a.port, a.description, b.name, c.name, a.original_node_port, a.original_node_ip, a.net from 
4672
     	(select * from network where node_id = innode_id) as a      
4673
      
4674
      join
4675
      (select id, name  from node) as b on b.id = innode_id
4676
		left join
4677
		(select id, name  from node) as c on c.id = a.original_node_id;
4678
     else
4679
         select 0 as test;
4680
     end if;     
4681
End//
4682
DELIMITER ;
4683

    
4684
-- 프로시저 nerv_icde_xxxx.networkViewSubsystemList 구조 내보내기
4685
DELIMITER //
4686
CREATE PROCEDURE `networkViewSubsystemList`(in_sub_system_id int)
4687
BEGIN
4688
     if loginTest() then
4689
         select 1 as test;
4690
         
4691
         SELECT a.d_port_id , b.name, b.type, a.s_port_id, d.ip, d.mask, d.gateway, d.dns, d.description from
4692
         (select s_node_id, s_port_id, d_port_id, d_sub_system_id from network_link where d_sub_system_id = in_sub_system_id) as a
4693
         join
4694
         (select id, name, type from node) as b on b.id = a.s_node_id
4695
         join
4696
         (select id, name from domain_system) as c on c.id = a.d_sub_system_id
4697
         left join
4698
         (select node_id, ip, port, mask, net, gateway, dns, description from network) as d on d.node_id = a.s_node_id and d.port = a.s_port_id;
4699

    
4700
         else
4701
         select 0 as test;
4702
     end if;     
4703
End//
4704
DELIMITER ;
4705

    
4706
-- 프로시저 nerv_icde_xxxx.network_table_node_Ip_ist 구조 내보내기
4707
DELIMITER //
4708
CREATE PROCEDURE `network_table_node_Ip_ist`(IN `in_deploy_id` INT)
4709
BEGIN
4710
     if loginTest() then
4711
         select 1 as test;
4712
			select * from network where network.node_id in(select node_id from deployments where deployments.Id = in_deploy_id);
4713
	  else
4714
	  		select 0 as test;
4715
	  end if;
4716
END//
4717
DELIMITER ;
4718

    
4719
-- 프로시저 nerv_icde_xxxx.nodeComponentViewProxyComponentList 구조 내보내기
4720
DELIMITER //
4721
CREATE PROCEDURE `nodeComponentViewProxyComponentList`(IN `in_node_id` int, IN `in_objectid` int, IN `in_interface_name` varchar(100), IN `in_domain_id` int, IN `in_component_id` INT)
4722
BEGIN 
4723
     if loginTest() then
4724
     select 1 as test;
4725
      
4726
      	select d.*, a.stub_ip, a.stub_object_id, e.name, b.id from
4727
		( 
4728
			select * from custum_proxy where stub_object_id=in_objectid and stub_ip in(
4729
				select ip from deployments_bind where deployments_bind.deployment_id in (select id from deployments where deployments.component_id = in_component_id))
4730
		) as a
4731
		join
4732
		(select * from proxy_interface_relation) as c on c.id = a.proxy_interface_id and c.interface_name=in_interface_name
4733
	   join	 
4734
	  	(select * from deployments) as b on b.id = a.deploy_id and systemdomain_id=in_domain_id	
4735
	  	join
4736
	  	(select * from component) as d on d.id = b.component_id
4737
	  	join
4738
	  	(select * from node) as e on e.id = b.node_id
4739
	  ;
4740
      
4741
     else
4742
         select 0 as test;
4743
     end if; 
4744
 End//
4745
DELIMITER ;
4746

    
4747
-- 프로시저 nerv_icde_xxxx.nodecomponentViewstubcomponentlist 구조 내보내기
4748
DELIMITER //
4749
CREATE PROCEDURE `nodecomponentViewstubcomponentlist`(IN `in_objectid` int, IN `in_networkip` varchar(255), IN `in_domain_id` int)
4750
BEGIN 
4751
     if loginTest() then
4752
     select 1 as test;
4753
      select  a.stub_interface_id, a.object_id, b.component_id , b.interface_name, c.id, c.systemdomain_id, c.name, c.seq, c.description, d.name, a.deploy_id from 
4754
      	(select id, deploy_id, stub_interface_id, object_id FROM custum_stub where object_id = in_objectid and deploy_id in 
4755
         	(select deployments_bind.deployment_id from deployments_bind where deployments_bind.ip=in_networkip and  deployments_bind.deployment_id in
4756
					(select id from deployments where deployments.systemdomain_id=in_domain_id and deployments.node_id in
4757
						(select node_id from network where ip = in_networkip)))) as a
4758
		     join
4759
          (select id, component_id, interface_name, class_name from stub_interface_relation) as b on b.id = a.stub_interface_id
4760
           join
4761
          (select id, systemdomain_id, name, seq, description from component) as c on c.id = b.component_id      
4762
			  join				  
4763
			 (select Id, name from node where node.Id in
4764
				 (select node_id from deployments where deployments.systemdomain_id=in_domain_id and deployments.node_id in
4765
					(select node_id from network where ip = in_networkip)
4766
				 )
4767
			  ) as d ;
4768
     
4769
      else
4770
         select 0 as test;
4771
     end if; 
4772
 End//
4773
DELIMITER ;
4774

    
4775
-- 프로시저 nerv_icde_xxxx.nodeDeleteNodes 구조 내보내기
4776
DELIMITER //
4777
CREATE PROCEDURE `nodeDeleteNodes`(IN `inidkey` int)
4778
BEGIN
4779

    
4780
 declare node_type varchar(100);
4781
 
4782
        if loginTest() and domainManageTest(inidkey) then
4783
                select 1 as test;
4784
                select node.`type` into node_type from node where id=inidkey;
4785
                
4786
                if node_type='sub_system' then
4787
   	             delete from component where component.id in(select deployments.component_id from deployments where deployments.node_id=inidkey);
4788
                end if;
4789
                
4790
                delete from node where id=inidkey;                       
4791
        else
4792
                select 0 as test;
4793
        end if;
4794
END//
4795
DELIMITER ;
4796

    
4797
-- 프로시저 nerv_icde_xxxx.nodeDeploymentViewComponentList 구조 내보내기
4798
DELIMITER //
4799
CREATE PROCEDURE `nodeDeploymentViewComponentList`(IN `in_systemdomain_id` int, IN `in_node_id` int)
4800
BEGIN
4801

    
4802
     if loginTest() then
4803
         select 1 as test;
4804
         
4805
         select Id, systemdomain_id, name, seq, description from component where systemdomain_id = in_systemdomain_id; 
4806
         
4807
     else
4808
         select 0 as test;
4809
     end if;
4810
     
4811
     
4812
     
4813
End//
4814
DELIMITER ;
4815

    
4816
-- 프로시저 nerv_icde_xxxx.nodeDeploymentViewDeleteComponent 구조 내보내기
4817
DELIMITER //
4818
CREATE PROCEDURE `nodeDeploymentViewDeleteComponent`(IN `in_id` int)
4819
BEGIN
4820

    
4821
 
4822
        if loginTest() then
4823
                select 1 as test;
4824
                
4825
                delete from deployments where deployments.Id = in_id;
4826
        else
4827
                select 0 as test;
4828
        end if;
4829
END//
4830
DELIMITER ;
4831

    
4832
-- 프로시저 nerv_icde_xxxx.nodeDeploymentViewInstallList 구조 내보내기
4833
DELIMITER //
4834
CREATE PROCEDURE `nodeDeploymentViewInstallList`(
4835
	IN `in_systemdomain_id` int,
4836
	IN `in_node_id` int
4837
)
4838
BEGIN
4839

    
4840
     if loginTest() then
4841
         select 1 as test;
4842
         
4843
         
4844
         select B.ID as process_id , A.Id as component_id, A.systemdomain_id, A.name, A.seq, A.description from
4845
         
4846
--			( select Id, systemdomain_id, name, seq, description from component  where systemdomain_id = in_systemdomain_id ) as A
4847
			( select Id, systemdomain_id, name, seq, description from component ) as A
4848
         
4849
         join deployments as B
4850
             on A.Id = B.component_id
4851
             where node_id = in_node_id;              
4852
         
4853

    
4854
     else
4855
         select 0 as test;
4856
     end if;
4857
     
4858
     
4859
     
4860
End//
4861
DELIMITER ;
4862

    
4863
-- 프로시저 nerv_icde_xxxx.nodeDeploymentViewNewcomponent 구조 내보내기
4864
DELIMITER //
4865
CREATE PROCEDURE `nodeDeploymentViewNewcomponent`(IN `in_node_id` int, IN `in_component_id` int, IN `in_systemdomain_id` int, IN `in_copy_deploy_id` INT)
4866
BEGIN
4867

    
4868
	  declare new_deployment_id int;  
4869

    
4870
 
4871
     if loginTest() then
4872
     		select 1 as test;
4873
                      
4874
	   	insert into deployments(node_id, component_id, systemdomain_id) values(in_node_id, in_component_id, in_systemdomain_id);
4875
			select Last_INSERT_ID() into new_deployment_id;
4876
 
4877
			insert into custum_proxy (deploy_id, proxy_interface_id, object_name)
4878
			select new_deployment_id, proxy_interface_object.proxy_interface_id, proxy_interface_object.object_name from proxy_interface_object where proxy_interface_id in
4879
			(select id from proxy_interface_relation where component_id = in_component_id);
4880
			
4881
			insert into custum_stub (deploy_id, stub_interface_id, object_name)
4882
			select new_deployment_id, stub_interface_object.stub_interface_id, stub_interface_object.object_name from stub_interface_object where stub_interface_id in
4883
			(select id from stub_interface_relation where component_id = in_component_id);
4884
			
4885
			update custum_proxy set original_id=custum_proxy.Id where custum_proxy.deploy_id = new_deployment_id;
4886
			update custum_stub set original_id=custum_stub.Id where custum_stub.deploy_id = new_deployment_id;
4887
			
4888
			update custum_proxy set original_deployment_id=custum_proxy.deploy_id where custum_proxy.deploy_id = new_deployment_id;
4889
			update custum_stub set original_deployment_id=custum_stub.deploy_id where custum_stub.deploy_id = new_deployment_id;
4890
			
4891
			insert into deployments_bind (deployments_bind.deployment_id, deployments_bind.node_id, deployments_bind.port, deployments_bind.ip)
4892
			select new_deployment_id, network.node_id, network.port, network.ip from network where network.node_id = in_node_id;
4893
			
4894
			
4895
			if in_copy_deploy_id > 0 then
4896
				update custum_proxy as a,
4897
      		(select custum_proxy.object_name, custum_proxy.object_id, custum_proxy.stub_object_id, custum_proxy.stub_ip, custum_proxy.public from custum_proxy
4898
				 where deploy_id = in_copy_deploy_id) as b
4899
      			set a.object_id = b.object_id, a.stub_object_id=b.stub_object_id, a.stub_ip=b.stub_ip, a.public=b.public
4900
      			where a.deploy_id = new_deployment_id and a.object_name=b.object_name;
4901

    
4902
				update custum_stub as a,
4903
      		(select custum_stub.object_name, custum_stub.object_id, custum_stub.public from custum_stub where deploy_id = in_copy_deploy_id) as b
4904
      			set a.object_id = b.object_id, a.public=b.public
4905
      			where a.deploy_id = new_deployment_id and a.object_name=b.object_name;   
4906
      	end if;
4907

    
4908
       else
4909
         select 0 as test;
4910
     end if;     
4911
     
4912
End//
4913
DELIMITER ;
4914

    
4915
-- 프로시저 nerv_icde_xxxx.nodeDeploymentViewUpdateCustumTable 구조 내보내기
4916
DELIMITER //
4917
CREATE PROCEDURE `nodeDeploymentViewUpdateCustumTable`(IN `in_copy_deploy_id` INT, IN `in_new_component_id` INT)
4918
BEGIN
4919

    
4920
	declare in_new_deploy_id int;
4921
   declare new_custum_id int;
4922
  	declare check_public int;
4923
	
4924
	if logintest() then
4925
		select 1 as test;
4926
		select id into in_new_deploy_id from deployments where deployments.component_id = in_new_component_id;		
4927

    
4928
		update custum_proxy as a,
4929
      	(select custum_proxy.object_name, custum_proxy.object_id, custum_proxy.stub_object_id, custum_proxy.stub_ip, custum_proxy.public from custum_proxy where deploy_id = in_copy_deploy_id) as b
4930
      set a.object_id = b.object_id, a.stub_object_id=b.stub_object_id, a.stub_ip=b.stub_ip, a.public=b.public
4931
      where a.deploy_id = in_new_deploy_id and a.object_name=b.object_name;
4932

    
4933

    
4934
		update custum_stub as a,
4935
      	(select custum_stub.object_name, custum_stub.object_id, custum_stub.public from custum_stub where deploy_id = in_copy_deploy_id) as b
4936
      set a.object_id = b.object_id, a.public=b.public
4937
      where a.deploy_id = in_new_deploy_id and a.object_name=b.object_name;     
4938

    
4939
   else
4940
   			select 0 as test;
4941
   end if;
4942
END//
4943
DELIMITER ;
4944

    
4945
-- 프로시저 nerv_icde_xxxx.nodeNewNodes 구조 내보내기
4946
DELIMITER //
4947
CREATE PROCEDURE `nodeNewNodes`(IN `insystemdomainid` int, IN `inname` varchar(50), IN `intype` varchar(50), IN `indescription` text, IN `in_sub_system_domain_id` int)
4948
BEGIN	
4949
	
4950
     if loginTest() then
4951
     		select 1 as test;
4952
    		
4953
			  if intype = 'router' then
4954
     			set intype = 'urouter';
4955
     		end if;
4956
         
4957
			insert into node(systemdomain_id, name, type, description, sub_system_domain_id)
4958
                      values(insystemdomainid, inname, intype, indescription, in_sub_system_domain_id);
4959
         
4960
			select LAST_INSERT_ID();
4961
         
4962
     else
4963
         select 0 as test;
4964
     end if;
4965
     
4966
     
4967
     
4968
End//
4969
DELIMITER ;
4970

    
4971
-- 프로시저 nerv_icde_xxxx.nodeportViewNewNode 구조 내보내기
4972
DELIMITER //
4973
CREATE PROCEDURE `nodeportViewNewNode`(in_node_id int, in_domain_system_id int, in_sub_system_domain_id int)
4974
BEGIN
4975
     if loginTest() then
4976
         select 1 as test;
4977
         insert node_port (id, systemdomain_id, sub_system_domain_id, port_group)
4978
         select in_node_id, in_domain_system_id, domain_system_id, port_group from domain_system_logical_port where domain_system_id = in_sub_system_domain_id;
4979

    
4980
     else
4981
         select 0 as test;
4982
     end if;
4983
End//
4984
DELIMITER ;
4985

    
4986
-- 프로시저 nerv_icde_xxxx.nodeportViewNewPortGroup 구조 내보내기
4987
DELIMITER //
4988
CREATE PROCEDURE `nodeportViewNewPortGroup`(in_sub_system_domain_id int, in_port_group int)
4989
BEGIN
4990
     if loginTest() then
4991
         select 1 as test;
4992
         insert into node_port (id, systemdomain_id, sub_system_domain_id, port_group)
4993
          select id, systemdomain_id, sub_system_domain_id, in_port_group from node where sub_system_domain_id = in_sub_system_domain_id;
4994
  
4995
     else
4996
         select 0 as test;
4997
     end if;
4998
End//
4999
DELIMITER ;
5000

    
5001
-- 프로시저 nerv_icde_xxxx.nodeportViewNodeportInfo 구조 내보내기
5002
DELIMITER //
5003
CREATE PROCEDURE `nodeportViewNodeportInfo`(in_node_id int)
5004
BEGIN
5005
     if loginTest() then
5006
         select 1 as test;
5007
        select  id, systemdomain_id, sub_system_domain_id, port_group from node_port where id =in_node_id;
5008

    
5009
     else
5010
         select 0 as test;
5011
     end if;
5012
End//
5013
DELIMITER ;
5014

    
5015
-- 프로시저 nerv_icde_xxxx.nodeproxyViewNewstubinfo 구조 내보내기
5016
DELIMITER //
5017
CREATE PROCEDURE `nodeproxyViewNewstubinfo`(in_nodeid int,
5018
                                                   in_stub_objectid       varchar(50),
5019
                                                   in_stub_ip     varchar(255))
5020
BEGIN
5021
     if loginTest() then
5022
     select 1 as test;
5023
         update custum_proxy set stub_object_id=in_stub_objectid, stub_ip=in_stub_ip
5024
          where id=in_nodeid;                      
5025
     else
5026
         select 0 as test;
5027
     end if;    
5028
     
5029
End//
5030
DELIMITER ;
5031

    
5032
-- 프로시저 nerv_icde_xxxx.nodesNewSwitch 구조 내보내기
5033
DELIMITER //
5034
CREATE PROCEDURE `nodesNewSwitch`(insystemdomainid int,
5035
                                                     inip varchar(50),
5036
                                                     insubnetmask varchar(50),
5037
                                                     indescription text)
5038
BEGIN
5039
     if loginTest() then
5040
         insert into network(systemdomain_id, ip, subnetmask, description)
5041
                      values(insystemdomainid, inip, insubnetmask, indescription);
5042
         select 1 as test;
5043
     else
5044
         select 0 as test;
5045
     end if;
5046
     
5047
     
5048
     
5049
End//
5050
DELIMITER ;
5051

    
5052
-- 프로시저 nerv_icde_xxxx.nodeViewConnectSwitch 구조 내보내기
5053
DELIMITER //
5054
CREATE PROCEDURE `nodeViewConnectSwitch`(in_node_id int)
5055
BEGIN
5056
     if loginTest() then
5057
         select 1 as test;
5058
                select a.node_id, a.ip, a.mask, a.mac, b. name, a.net from
5059
                (select node_id, ip, mask, port, net from network where connect_node_id = in_node_id) as a
5060
                join
5061
                (select id, name from node )as b on b.id=a.node_id;
5062
     else
5063
         select 0 as test;
5064
     end if; 
5065
     
5066
End//
5067
DELIMITER ;
5068

    
5069
-- 프로시저 nerv_icde_xxxx.NodeViewEditNode 구조 내보내기
5070
DELIMITER //
5071
CREATE PROCEDURE `NodeViewEditNode`(IN `in_node_idkey` int, IN `in_systemdomain_id` int, IN `in_name` varchar(100), IN `in_type` varchar(100), IN `in_description` varchar(100), IN `in_sub_system_domain_id` int, IN `in_lock_state` INT)
5072
BEGIN
5073
declare cnt int;
5074

    
5075
declare enum_lock varchar(10) default 'N';
5076
set cnt=0;
5077
 
5078
        if loginTest() then
5079
          select 1 as test;
5080
          
5081
         if in_type = 'router' then
5082
     			set in_type = 'urouter';
5083
     		end if;     
5084
			  
5085
			if in_lock_state = 1 then
5086
     			set enum_lock = 'Y';
5087
     		end if;   		
5088
                     
5089
			  update node set name=in_name, type=in_type, description=in_description, sub_system_domain_id=in_sub_system_domain_id, complete=enum_lock
5090
                     where id=in_node_idkey and systemdomain_id=in_systemdomain_id;
5091
							
5092
			   select count(*) into cnt from node_port where (id, sub_system_domain_id) in (SELECT  id, sub_system_domain_id  from node where id=241);
5093
                       
5094
           if cnt=0 then
5095
	           delete from node_port where id=in_node_idkey;
5096
              call nodeportViewNewNode(in_node_idkey, in_systemdomain_id, in_sub_system_domain_id);
5097
           end if;       
5098
                          
5099
                     
5100
        else
5101
                select 0 as test;
5102
        end if;
5103
END//
5104
DELIMITER ;
5105

    
5106
-- 프로시저 nerv_icde_xxxx.nodeViewList 구조 내보내기
5107
DELIMITER //
5108
CREATE PROCEDURE `nodeViewList`(
5109
	IN `indomainid` int
5110
)
5111
BEGIN
5112
     if loginTest() then
5113
         select 1 as test;
5114
         
5115
         select * from
5116
				(
5117
		         select a.Id, a.systemdomain_id, a.name as aname, a.type, a.description, a.sub_system_domain_id,  b.name, a.complete from
5118
      		   (select Id, systemdomain_id, name, type, description, sub_system_domain_id, complete from node where systemdomain_id=indomainid) as a 
5119
		         left outer join
5120
		         (select id, name from domain_system ) as b on b.id=a.sub_system_domain_id
5121
		      ) as xxx order by aname asc;
5122
         
5123
     else
5124
         select 0 as test;
5125
     end if; 
5126
     
5127
End//
5128
DELIMITER ;
5129

    
5130
-- 프로시저 nerv_icde_xxxx.nodeViewListnodeKey 구조 내보내기
5131
DELIMITER //
5132
CREATE PROCEDURE `nodeViewListnodeKey`(IN `in_node_id` INT)
5133
BEGIN
5134

    
5135
     if loginTest() then
5136
         select 1 as test;
5137
         select a.Id, a.systemdomain_id, a.name, a.type, a.description, a.sub_system_domain_id,  b.name from
5138
         (select Id, systemdomain_id, name, type, description, sub_system_domain_id from node where node.Id=in_node_id) as a 
5139
         left outer join
5140
         (select id, name from domain_system ) as b on b.id=a.sub_system_domain_id;                
5141
     else
5142
         select 0 as test;
5143
     end if; 
5144

    
5145
END//
5146
DELIMITER ;
5147

    
5148
-- 프로시저 nerv_icde_xxxx.nodeViewNetworkPort 구조 내보내기
5149
DELIMITER //
5150
CREATE PROCEDURE `nodeViewNetworkPort`(in_sub_domain_system_id int, in_node_id int)
5151
BEGIN
5152
        if loginTest() then
5153
           select 1 as test;
5154
                       
5155
             select port_num, description from domain_system_port where domain_system_id=in_sub_domain_system_id and
5156
                  port_num not in (SELECT s_port_id from network_link where s_node_id = in_node_id and s_sub_system_id = in_sub_domain_system_id)
5157
            and   port_num not in (SELECT d_port_id from network_link where d_node_id = in_node_id and d_sub_system_id = in_sub_domain_system_id); 
5158
        else
5159
            select 0 as test;
5160
        end if;
5161
END//
5162
DELIMITER ;
5163

    
5164
-- 프로시저 nerv_icde_xxxx.nodeViewnodeinfo 구조 내보내기
5165
DELIMITER //
5166
CREATE PROCEDURE `nodeViewnodeinfo`(IN `in_deploy_id` int)
5167
BEGIN
5168
     if loginTest() then
5169
         select 1 as test;
5170
         select node.Id, node.systemdomain_id, node.name, node.`type`, node.description from node where node.Id in(select node_id from deployments where id = in_deploy_id);
5171
           
5172
                  
5173
     else
5174
         select 0 as test;
5175
     end if; 
5176
     
5177
End//
5178
DELIMITER ;
5179

    
5180
-- 프로시저 nerv_icde_xxxx.node_table_node_info 구조 내보내기
5181
DELIMITER //
5182
CREATE PROCEDURE `node_table_node_info`(IN `in_deploy_id` INT)
5183
BEGIN
5184

    
5185
	if logintest() then
5186
		select 1 as test;
5187
		select node.Id, node.systemdomain_id, node.name, node.`type`, node.description from node where node.systemdomain_id in(select systemdomain_id from deployments
5188
		 where id = in_deploy_id);
5189
	else
5190
		select 0 as test;
5191
	end if;
5192
	
5193
END//
5194
DELIMITER ;
5195

    
5196
-- 프로시저 nerv_icde_xxxx.proxyComponentViewParentInterfaceRealdomainList 구조 내보내기
5197
DELIMITER //
5198
CREATE PROCEDURE `proxyComponentViewParentInterfaceRealdomainList`(domain_idkey int)
5199
BEGIN
5200
         declare sm bool;
5201
        declare sa varchar(100);
5202
        declare acount varchar(100);
5203
        declare pbc bool;
5204
  
5205
        set sa = '';
5206
        if loginTest() then
5207
        
5208
                    select supermanager into sm from users where user_id=@nervuser;
5209
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
5210
                    select user_id into acount from domain_method where id=domain_idkey;
5211
                    select public into pbc from domain_method where id=domain_idkey;
5212

    
5213
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
5214
                        select 1 as test;
5215
                        (select id, name from domain_method where id in (select parent_domain_id from inheritance_system_method where domain_id=domain_idkey))
5216
                         union
5217
                        (select id, name from domain_method where id=domain_idkey);
5218
                                
5219
                    else
5220
                        select 0 as test;
5221
                     end if;
5222
               else
5223
                 select 0 as test;
5224
        end if;
5225
End//
5226
DELIMITER ;
5227

    
5228
-- 프로시저 nerv_icde_xxxx.proxyComponentViewParentInterfaceRealinterfaceList 구조 내보내기
5229
DELIMITER //
5230
CREATE PROCEDURE `proxyComponentViewParentInterfaceRealinterfaceList`(domain_idkey int,in_component_idkey int)
5231
BEGIN
5232
        declare sm bool;
5233
        declare sa varchar(100);
5234
        declare acount varchar(100);
5235
        declare pbc bool;
5236

    
5237
        set sa = '';
5238
        if loginTest() then       
5239
                     select supermanager into sm from users where user_id=@nervuser;
5240
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
5241
                     select user_id into acount from domain_method where id=domain_idkey;
5242
                     select public into pbc from domain_method where id=domain_idkey;
5243

    
5244
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
5245
                        select 1 as test;
5246
                        select domain_id, name, user_id, seq, description from interface where domain_id=domain_idkey and name not in
5247
                                        (select interface_name from proxy_interface_relation where component_id=in_component_idkey);
5248
                     else
5249
                        select 0 as test;
5250
                     end if;               
5251

    
5252
        else
5253
                select 0 as test;
5254
        end if;
5255
END//
5256
DELIMITER ;
5257

    
5258
-- 프로시저 nerv_icde_xxxx.proxyInterfaceObjectViewDelete 구조 내보내기
5259
DELIMITER //
5260
CREATE PROCEDURE `proxyInterfaceObjectViewDelete`(in_interface_object_id int, in_object_name varchar(100), in_component_id int)
5261
BEGIN 
5262
        if loginTest()then
5263
                select 1 as test;
5264
                delete from proxy_interface_object where proxy_interface_id=in_interface_object_id and object_name=in_object_name and component_id=in_component_id;                       
5265
        else
5266
                select 0 as test;
5267
        end if;
5268
END//
5269
DELIMITER ;
5270

    
5271
-- 프로시저 nerv_icde_xxxx.proxyInterfaceObjectViewEditObjectName 구조 내보내기
5272
DELIMITER //
5273
CREATE PROCEDURE `proxyInterfaceObjectViewEditObjectName`(in_proxy_interface_id int, in_object_name varchar (100), in_component_id int, in_edit_object_name varchar(100))
5274
BEGIN
5275
        if loginTest() then
5276
                select 1 as test;
5277
                UPDATE proxy_interface_object Set object_name=in_edit_object_name
5278
                                where proxy_interface_id=in_proxy_interface_id and component_id=in_component_id and object_name=in_object_name;
5279
        else
5280
                select 0 as test;
5281
        end if;
5282
END//
5283
DELIMITER ;
5284

    
5285
-- 프로시저 nerv_icde_xxxx.proxyInterfaceObjectViewList 구조 내보내기
5286
DELIMITER //
5287
CREATE PROCEDURE `proxyInterfaceObjectViewList`(in_proxy_interface_relation_id int)
5288
BEGIN
5289
     if loginTest() then
5290
         select 1 as test;
5291
         select * from proxy_interface_object where proxy_interface_id=in_proxy_interface_relation_id;
5292
     else
5293
         select 0 as test;
5294
     end if;     
5295
End//
5296
DELIMITER ;
5297

    
5298
-- 프로시저 nerv_icde_xxxx.proxyInterfaceObjectViewNewObjectName 구조 내보내기
5299
DELIMITER //
5300
CREATE PROCEDURE `proxyInterfaceObjectViewNewObjectName`(in_proxy_interface_id int, in_object_name varchar (100), in_component_id int)
5301
BEGIN
5302
        if loginTest() then
5303
                select 1 as test;
5304
                insert into proxy_interface_object (proxy_interface_id, object_name, component_id)
5305
                                values(in_proxy_interface_id, in_object_name, in_component_id);
5306
        else
5307
                select 0 as test;
5308
        end if;
5309
END//
5310
DELIMITER ;
5311

    
5312
-- 프로시저 nerv_icde_xxxx.proxyInterfaceRalationDeleteInterface 구조 내보내기
5313
DELIMITER //
5314
CREATE PROCEDURE `proxyInterfaceRalationDeleteInterface`(inidkey int)
5315
BEGIN 
5316
        if loginTest()then
5317
                select 1 as test;
5318
                delete from proxy_interface_relation where id=inidkey;                       
5319
        else
5320
                select 0 as test;
5321
        end if;
5322
END//
5323
DELIMITER ;
5324

    
5325
-- 프로시저 nerv_icde_xxxx.proxyInterfaceRalationViewEditInterface 구조 내보내기
5326
DELIMITER //
5327
CREATE PROCEDURE `proxyInterfaceRalationViewEditInterface`(in_idkey int,
5328
                                                                              in_method_domain_id int,
5329
                                                                              in_interface_name varchar(100),
5330
                                                                              in_class_name varchar(255))
5331
BEGIN
5332
        if loginTest() then
5333
                select 1 as test;
5334
                update proxy_interface_relation set  method_domain_id = in_method_domain_id,
5335
                                                     interface_name = in_interface_name,
5336
                                                     class_name = in_class_name where id = in_idkey;
5337

    
5338

    
5339
        else
5340
                select 0 as test;
5341
        end if;
5342
END//
5343
DELIMITER ;
5344

    
5345
-- 프로시저 nerv_icde_xxxx.proxyInterfaceRalationViewNewInterface 구조 내보내기
5346
DELIMITER //
5347
CREATE PROCEDURE `proxyInterfaceRalationViewNewInterface`(in_component_id int,
5348
                                                                             in_method_domain_id int,
5349
                                                                             in_interface_name varchar(100),
5350
                                                                             in_class_name varchar(255))
5351
BEGIN
5352
        if loginTest() then
5353
                select 1 as test;
5354
                    insert into proxy_interface_relation (component_id, method_domain_id, interface_name, class_name)
5355
                                values(in_component_id, in_method_domain_id, in_interface_name, in_class_name);
5356
                    select LAST_INSERT_ID();              
5357
        else
5358
                select 0 as test;
5359
                
5360
        end if;
5361
END//
5362
DELIMITER ;
5363

    
5364
-- 프로시저 nerv_icde_xxxx.proxyInterfaceRelationViewClassNameList 구조 내보내기
5365
DELIMITER //
5366
CREATE PROCEDURE `proxyInterfaceRelationViewClassNameList`(in_component_id int, in_method_domain_id int, in_interface_name varchar(100))
5367
BEGIN
5368
     if loginTest() then
5369
         select 1 as test;
5370
         select class_name from proxy_interface_relation where 
5371
                component_id=in_component_id and method_domain_id=in_method_domain_id and interface_name=in_interface_name;
5372
     else
5373
         select 0 as test;
5374
     end if;
5375
End//
5376
DELIMITER ;
5377

    
5378
-- 프로시저 nerv_icde_xxxx.proxyInterfaceRelationViewSearchList 구조 내보내기
5379
DELIMITER //
5380
CREATE PROCEDURE `proxyInterfaceRelationViewSearchList`(in_component_id int, in_method_domain_id int, in_interface_name varchar(100), in_class_name varchar(255))
5381
BEGIN
5382
     if loginTest() then
5383
         select 1 as test;
5384
         select id from proxy_interface_relation where 
5385
                component_id=in_component_id and method_domain_id=in_method_domain_id and interface_name=in_interface_name and class_name=in_class_name;
5386
     else
5387
         select 0 as test;
5388
     end if;
5389
End//
5390
DELIMITER ;
5391

    
5392
-- 프로시저 nerv_icde_xxxx.proxyInterfaceViewList 구조 내보내기
5393
DELIMITER //
5394
CREATE PROCEDURE `proxyInterfaceViewList`(
5395
	IN `incomponent_id` int
5396
)
5397
BEGIN
5398
     if loginTest() then
5399
         select 1 as test;
5400
         
5401
        select a.id,  a.method_domain_id, a.component_id, a.interface_name, b.name as method_domain_name, a.class_name from 
5402
         
5403
         (select id, component_id, method_domain_id, interface_name, class_name from proxy_interface_relation where component_id = incomponent_id) as a
5404
         join
5405
         (select id,name from domain_method) as b on a.method_domain_id = b.id;   
5406
         
5407
     else
5408
         select 0 as test;
5409
     end if;    
5410
     
5411
End//
5412
DELIMITER ;
5413

    
5414
-- 프로시저 nerv_icde_xxxx.SelectinterfaceViewInterfaceList 구조 내보내기
5415
DELIMITER //
5416
CREATE PROCEDURE `SelectinterfaceViewInterfaceList`()
5417
BEGIN
5418
   if loginTest() then
5419
     select 1 as test;
5420
     select b.id, b.name, b.upper_id, a.name, a.user_id, a.seq from
5421
     (select  domain_id, name, user_id, seq, description from interface) As a
5422
     join
5423
     (select id, name, upper_id from domain_method) As b on a.domain_id = b.id;
5424
   else
5425
      select 0 as test;
5426
   end if;
5427
END//
5428
DELIMITER ;
5429

    
5430
-- 프로시저 nerv_icde_xxxx.select_all_deploy_component_only_proxy 구조 내보내기
5431
DELIMITER //
5432
CREATE PROCEDURE `select_all_deploy_component_only_proxy`(IN `in_domain_id` INT)
5433
BEGIN
5434

    
5435
	if logintest() then
5436
		select 1 as test;
5437
select n.id, m.* from
5438
(
5439
select * from component WHERE id in (
5440
SELECT component_id from deployments where systemdomain_id = in_domain_id and component_id not in (
5441
select id from component where id in (
5442
select component_id from deployments where id in (
5443
select k.original_deployment_id from
5444

    
5445
(
5446
   select a_f.original_deployment_id, b_f.interface_name, a_f.object_id, c_f.ip from
5447
          (select * from custum_stub where deploy_id in (select id from deployments where deployments.systemdomain_id=in_domain_id)) as a_f
5448
          join
5449
          (select * from stub_interface_relation) as b_f on b_f.id = a_f.stub_interface_id
5450
          join
5451
          (select * from deployments_bind) as c_f on a_f.deploy_id = c_f.deployment_id
5452
 ) as k
5453
 join
5454

    
5455
(
5456
   select a.original_deployment_id, b.interface_name, a.stub_object_id, a.stub_ip from
5457
   (
5458
	        (select * from custum_proxy where stub_object_id > 0 and public !=1 and deploy_id in (select id from deployments where deployments.systemdomain_id=in_domain_id)) as a
5459
 	        join
5460
	        (select * from proxy_interface_relation) as b on b.id = a.proxy_interface_id
5461
   ) 
5462
) as i
5463
where i.interface_name = k.interface_name and i.stub_object_id=k.object_id and i.stub_ip=k.ip group by k.original_deployment_id
5464
))))) as m
5465
 join deployments as n on n.component_id = m.id;
5466

    
5467
	
5468
		
5469
	else
5470
	   select 0 as test;
5471
	end if;
5472
	
5473
END//
5474
DELIMITER ;
5475

    
5476
-- 프로시저 nerv_icde_xxxx.select_all_deploy_stub_component 구조 내보내기
5477
DELIMITER //
5478
CREATE PROCEDURE `select_all_deploy_stub_component`(IN `in_domain_id` INT, IN `in_component_id` INT)
5479
BEGIN
5480

    
5481
   if logintest() then
5482
      select 1 as test;
5483
      select d.id, c.* from
5484
		(select * from component where component.id != in_component_id and component.id in 
5485
			(select component_id from deployments where deployments.id in 
5486
				(select b.deploy_id from
5487
					(select * from deployments where deployments.systemdomain_id = in_domain_id and id in
5488
						(select deployment_id from deployments_bind where deployments_bind.ip in 
5489
							(select stub_ip from custum_proxy where custum_proxy.stub_object_id !=0 and custum_proxy.deploy_id in
5490
								(select id from deployments where deployments.component_id = in_component_id)))) as a
5491
				join custum_stub as b on b.deploy_id = a.id and b.object_id in
5492
		 			(select stub_object_id from custum_proxy where custum_proxy.stub_object_id !=0 and custum_proxy.deploy_id in
5493
		  				(select id from deployments where deployments.component_id = in_component_id))))) as c		  
5494
		  join deployments as d on d.component_id=c.id;
5495
      
5496
      
5497
      
5498
	else
5499
		select 0 as test;
5500
	end if;
5501

    
5502
END//
5503
DELIMITER ;
5504

    
5505
-- 프로시저 nerv_icde_xxxx.select_deploy_all_components 구조 내보내기
5506
DELIMITER //
5507
CREATE PROCEDURE `select_deploy_all_components`(IN `in_domain_id` INT)
5508
BEGIN
5509

    
5510
   if logintest() then
5511
   	select 1 as test;
5512
   	select a.*, b.node_id from
5513
		(
5514
			(select * from component where id in(select component_id from deployments where deployments.systemdomain_id = in_domain_id)) as a
5515
			join
5516
			(select * from deployments) as b on b.systemdomain_id = in_domain_id
5517
		);
5518
	else
5519
		select 0 as test;
5520
	end if;
5521
END//
5522
DELIMITER ;
5523

    
5524
-- 프로시저 nerv_icde_xxxx.select_group 구조 내보내기
5525
DELIMITER //
5526
CREATE PROCEDURE `select_group`(IN `in_d_subsystem_id` INT, IN `in_d_port_id` INT, IN `in_s_node_id` INT, IN `in_s_node_port` INT)
5527
BEGIN
5528

    
5529

    
5530
	
5531
	declare logical_port int;
5532
	declare sub_domain_id int;
5533

    
5534
	Select sub_system_domain_id into sub_domain_id from node where id = in_s_node_id;
5535
	select port_group into logical_port from domain_system_port as A where A.domain_system_id = sub_domain_id and A.port_num = in_s_node_port;
5536
	
5537
	call select_group_recursion( in_d_subsystem_id , in_d_port_id , 0 , in_d_port_id , in_s_node_id , logical_port , 10 );
5538
	
5539
END//
5540
DELIMITER ;
5541

    
5542
-- 프로시저 nerv_icde_xxxx.select_group_recursion 구조 내보내기
5543
DELIMITER //
5544
CREATE PROCEDURE `select_group_recursion`(IN `in_domain_system_id` INT, IN `in_export_num` INT, IN `in_parent_node_id` INT, IN `in_parent_port_group` INT, IN `in_node_id` INT, IN `in_port_group` INT, IN `in_depth` INT)
5545
BEGIN
5546
	declare domain_id int;	
5547
	declare no_more_rows bool default false;		
5548
	declare child_node_id int;
5549
	declare child_port_group int;
5550
	declare node_port_count int;	
5551
	
5552
	DECLARE my_list CURSOR FOR select K.node_id , domain_system_port.port_group from
5553
		 		(
5554
				 	(
5555
					 	select s_node_id as node_id , s_sub_system_id as sub_system_id , s_port_id as port_id from network_link where
5556
						 							( d_node_id , d_port_id ) in ( select in_node_id, port_num from domain_system_port as A where A.domain_system_id = domain_id and A.port_group = in_port_group )
5557
					)
5558
						union
5559
				 	(
5560
					 	select d_node_id , d_sub_system_id , d_port_id  from network_link where
5561
						 							 ( s_node_id , s_port_id ) in ( select in_node_id, port_num from domain_system_port as A where A.domain_system_id = domain_id and A.port_group = in_port_group )						 							
5562
					) 
5563
				) as K				
5564
			join			
5565
				domain_system_port on K.sub_system_id = domain_system_port.domain_system_id and K.port_id = domain_system_port.port_num					
5566
	where
5567
			not ( K.node_id = in_parent_node_id and domain_system_port.port_group = in_parent_port_group );
5568

    
5569
	declare continue handler for not found set no_more_rows := TRUE;
5570
		set max_sp_recursion_depth = 50;
5571

    
5572
	if in_node_id = 0 then	
5573
		 
5574
		 set node_port_count = 0;
5575
		 select count(*) into node_port_count from node_port where sub_system_domain_id = in_domain_system_id and port_group = in_port_group;
5576
		 
5577
		 if node_port_count = 0 then
5578
		 	 update node_port set port_group = in_port_group where sub_system_domain_id = in_domain_system_id and port_group = in_export_num;			 	
5579
		 end if;		 
5580
	end if;
5581

    
5582
	if in_depth > 0 then		
5583
		select node.sub_system_domain_id into domain_id from node where node.Id = in_node_id; 
5584
		open my_list;	
5585
		my_loop : loop
5586
		
5587
			fetch my_list into child_node_id , child_port_group;
5588
			if no_more_rows then
5589
				close my_list;
5590
				leave my_loop;
5591
			end if;				
5592
			call select_group_recursion( in_domain_system_id, in_export_num , in_node_id, in_port_group , child_node_id , child_port_group , in_depth - 1 );		
5593
		end loop my_loop;		
5594
	end if;	
5595
END//
5596
DELIMITER ;
5597

    
5598
-- 프로시저 nerv_icde_xxxx.select_network 구조 내보내기
5599
DELIMITER //
5600
CREATE PROCEDURE `select_network`(IN `in_node_id` INT)
5601
BEGIN
5602
	declare sub_domain_id int;
5603
	declare export_group int;
5604
	declare inner_node_id int;
5605
	declare  inner_port_group int;
5606
	declare no_more_rows bool default false;
5607

    
5608
	DECLARE my_list CURSOR FOR select D.port_group as export_group , s_node_id as inner_node_id , E.port_group as inner_port_group from 
5609
		(
5610
			select s_node_id , sub_system_domain_id, type, s_port_id , port_group  from  
5611
				(
5612
					 select s_node_id , s_port_id , port_group from
5613
					 	(
5614
						 	select * from network_link where d_node_id = 0 and d_sub_system_id = sub_domain_id
5615
						) as A
5616
							join			
5617
						(
5618
							select * from domain_system_port where domain_system_id = sub_domain_id
5619
						) as B
5620
							on  A.d_port_id = B.port_num group by port_group
5621
				) as C
5622
					join node on C.s_node_id = node.id
5623
		) as D
5624
			join domain_system_port as E on D.sub_system_domain_id = E.domain_system_id and D.s_port_id = E.port_num;
5625
			
5626
	declare continue handler for not found set no_more_rows := TRUE;
5627
	
5628
	set max_sp_recursion_depth = 50;			
5629
	select sub_system_domain_id into sub_domain_id from node where id = in_node_id;
5630
	
5631
	open my_list;	
5632
	my_loop : loop	
5633
		fetch my_list into export_group , inner_node_id , inner_port_group;
5634
		if no_more_rows then
5635
			close my_list;
5636
			leave my_loop;
5637
		end if;		
5638
		 call select_network_recursion( in_node_id, export_group, 0 , export_group , inner_node_id , inner_port_group , 10 );		
5639
	end loop my_loop;	
5640
END//
5641
DELIMITER ;
5642

    
5643
-- 프로시저 nerv_icde_xxxx.select_network_recursion 구조 내보내기
5644
DELIMITER //
5645
CREATE PROCEDURE `select_network_recursion`(IN `in_insert_node` INT, IN `in_insert_port_group` INT, IN `in_parent_node_id` INT, IN `in_parent_port_group` INT, IN `in_node_id` INT, IN `in_port_group` INT, IN `in_depth` INT)
5646
BEGIN
5647
	declare domain_id int;	
5648
	declare no_more_rows bool default false;		
5649
	declare child_node_id int;
5650
	declare child_port_group int;
5651
	declare network_count int;	
5652
	
5653
	DECLARE my_list CURSOR FOR select K.node_id , domain_system_port.port_group from
5654
		 		(
5655
				 	(
5656
					 	select s_node_id as node_id , s_sub_system_id as sub_system_id , s_port_id as port_id from network_link where ( d_node_id , d_port_id ) in
5657
						  ( select in_node_id, port_num from domain_system_port as A where A.domain_system_id = domain_id and A.port_group = in_port_group )
5658
					)
5659
						union
5660
				 	(
5661
					 	select d_node_id , d_sub_system_id , d_port_id  from network_link where	( s_node_id , s_port_id ) in
5662
						  ( select in_node_id, port_num from domain_system_port as A where A.domain_system_id = domain_id and A.port_group = in_port_group )
5663
					) 
5664
				) as K
5665
				
5666
			join domain_system_port	on K.sub_system_id = domain_system_port.domain_system_id and K.port_id = domain_system_port.port_num					
5667
	where	not ( K.node_id = in_parent_node_id and domain_system_port.port_group = in_parent_port_group );
5668

    
5669
	declare continue handler for not found set no_more_rows := TRUE;
5670
	
5671
	select count(*) into network_count from network where node_id = in_insert_node and
5672
	 (original_node_id, original_node_port, original_node_ip) in
5673
	  (select node_id, port, ip from network where node_id = in_node_id and port = in_port_group); 	 
5674
	
5675
	  if network_count=0  then 
5676
	       insert into network ( node_id, port , ip, mask , net , gateway , dns, description, original_node_id, original_node_port, original_node_ip )
5677
	            select in_insert_node , in_insert_port_group , ip, mask , net , gateway , dns, description, node_id, port, ip from network
5678
					 where node_id = in_node_id and port = in_port_group;
5679
	  end if;
5680

    
5681
	if in_depth > 0 then
5682
		select node.sub_system_domain_id into domain_id from node where node.Id = in_node_id; 		
5683
		open my_list;	
5684
		my_loop : loop		
5685
			fetch my_list into child_node_id , child_port_group;
5686

    
5687
			if no_more_rows then
5688
				close my_list;
5689
				leave my_loop;
5690
			end if;				
5691
			call select_network_recursion( in_insert_node, in_insert_port_group, in_node_id, in_port_group , child_node_id , child_port_group , in_depth - 1 );		
5692
		end loop my_loop;		
5693
	end if;	
5694
END//
5695
DELIMITER ;
5696

    
5697
-- 프로시저 nerv_icde_xxxx.select_search_data_name 구조 내보내기
5698
DELIMITER //
5699
CREATE PROCEDURE `select_search_data_name`(IN `in_search_name` VARCHAR(50))
5700
BEGIN
5701
	if loginTest() then	
5702
			select 1 as test;				
5703
		  select id,('domain') as type, name, (select `domainDataPath`(domain_data.id, ''))as path from domain_data where name like in_search_name
5704
				union all		
5705
			select domain_id,('data') as type, name, (select `domainDataPath`(data.domain_id, ''))as path from data where data.name like in_search_name 
5706
				union all
5707
			select b.domain_id,('data_field') as type, a.member_name as name, concat((select `domainDataPath`(b.domain_id, '')),b.name) as path from
5708
	 		(select data_field.data_auto_id, data_field.member_name from data_field where member_name like in_search_name) as a
5709
	 		   join
5710
	 		(select data.data_auto_id, data.domain_id,  concat(data.name,'\\')as name from data) as b on a.data_auto_id=b.data_auto_id;		 		
5711
	else	
5712
		select 0 as test;		
5713
	end if;
5714
END//
5715
DELIMITER ;
5716

    
5717
-- 프로시저 nerv_icde_xxxx.select_search_method_name 구조 내보내기
5718
DELIMITER //
5719
CREATE PROCEDURE `select_search_method_name`(IN `in_search_name` VARCHAR(50))
5720
BEGIN
5721

    
5722
	if loginTest() then	
5723
		select 1 as test;
5724
		
5725
		select id,('domain') as type, name, (select `domainMethodPath`(domain_method.id, ''))as path from domain_method where name like in_search_name
5726
			  union all		
5727
		select domain_id,('method') as type, name, (select `domainMethodPath`(method.domain_id, ''))as path from method where method.name like in_search_name 
5728
			 union all
5729
		select domain_id,('interface') as type, name, (select `domainMethodPath`(interface.domain_id, ''))as path from interface where interface.name like in_search_name;	 		
5730
	else	
5731
		select 0 as test;		
5732
	end if;
5733

    
5734
END//
5735
DELIMITER ;
5736

    
5737
-- 프로시저 nerv_icde_xxxx.select_search_system_name 구조 내보내기
5738
DELIMITER //
5739
CREATE PROCEDURE `select_search_system_name`(IN `in_search_name` VARCHAR(50))
5740
BEGIN
5741

    
5742
	if loginTest() then	
5743
		select 1 as test;
5744
		
5745
		 select id,('domain') as type, name, (select `domainSystemPath`(domain_system.id, ''))as path from domain_system where name like in_search_name
5746
  			union all
5747
		 select systemdomain_id,('node') as type, name, concat((select `domainSystemPath`(node.systemdomain_id, '')),'Nodes\\')as path from node where node.name like in_search_name		 		
5748
  			union all
5749
		 select systemdomain_id,('component') as type, name, concat((select `domainSystemPath`(component.systemdomain_id, '')),'Components\\')as path from component where component.name like in_search_name
5750
 		 	union all
5751
 		 	
5752
 		 select b.systemdomain_id, ('proxy_class') as type, a.class_name as name, concat((select `domainSystemPath`(b.systemdomain_id, '')),b.name,'\\proxy\\')as path from
5753
			(select * from proxy_interface_relation where proxy_interface_relation.class_name like in_search_name) as a
5754
				join
5755
			(select component.id, component.systemdomain_id, concat('Components\\',component.name)as name from component)as b on a.component_id=b.id
5756
 		 
5757
			union all
5758
			
5759
	   select b.systemdomain_id, ('stub_class') as type, a.class_name as name, concat((select `domainSystemPath`(b.systemdomain_id, '')),b.name,'\\stub\\')as path from
5760
				(select * from stub_interface_relation where stub_interface_relation.class_name like in_search_name) as a
5761
					join
5762
				(select component.id, component.systemdomain_id, concat('Components\\',component.name)as name from component)as b on a.component_id=b.id
5763
			union all	
5764
			
5765
		select b.systemdomain_id, ('proxy_object') as type, (a.object_name)as name, concat((select `domainSystemPath`(b.systemdomain_id, '')),b.name,'\\proxy\\',c.class_name,'\\')as path from
5766
				(select * from proxy_interface_object where proxy_interface_object.object_name like in_search_name) as a
5767
					join
5768
				(select component.id, component.systemdomain_id, concat('Components\\',component.name)as name from component)as b on a.component_id=b.id
5769
					join
5770
				(select proxy_interface_relation.id, proxy_interface_relation.interface_name, proxy_interface_relation.class_name from  proxy_interface_relation)as c on a.proxy_interface_id=c.id
5771
		  union all
5772
		  
5773
	  select b.systemdomain_id, ('stub_object') as type, (a.object_name)as name, concat((select `domainSystemPath`(b.systemdomain_id, '')),b.name,'\\stub\\',c.class_name,'\\')as path from
5774
			(select * from stub_interface_object where stub_interface_object.object_name like in_search_name) as a
5775
				join
5776
			(select component.id, component.systemdomain_id, concat('Components\\',component.name)as name from component)as b on a.component_id=b.id
5777
				join
5778
			(select stub_interface_relation.id, stub_interface_relation.interface_name, stub_interface_relation.class_name from  stub_interface_relation)as c on a.stub_interface_id=c.id;
5779

    
5780
	else	
5781
		select 0 as test;		
5782
	end if;
5783

    
5784

    
5785
END//
5786
DELIMITER ;
5787

    
5788
-- 프로시저 nerv_icde_xxxx.serverViewDeleteField 구조 내보내기
5789
DELIMITER //
5790
CREATE PROCEDURE `serverViewDeleteField`(fieldvalue varchar(100))
5791
BEGIN
5792
        if loginTest() and supermanagerTest(@nervuser) then
5793
                select 1 as test;
5794
                delete from server_information where field_name=fieldvalue;
5795
        else
5796
                select 0 as test;
5797
        end if;
5798
END//
5799
DELIMITER ;
5800

    
5801
-- 프로시저 nerv_icde_xxxx.serverViewEditField 구조 내보내기
5802
DELIMITER //
5803
CREATE PROCEDURE `serverViewEditField`(fieldvalue varchar(100), fieldedit varchar(100), descriptionedit text)
5804
BEGIN
5805

    
5806
END//
5807
DELIMITER ;
5808

    
5809
-- 프로시저 nerv_icde_xxxx.serverViewEditFieldSeq 구조 내보내기
5810
DELIMITER //
5811
CREATE PROCEDURE `serverViewEditFieldSeq`(fieldkey1 varchar(100), fieldkey2 varchar(100))
5812
BEGIN
5813
        declare t1 timestamp;
5814
        declare t2 timestamp;
5815
        if loginTest() and supermanagerTest(@nervuser) then
5816
                select 1 as test;
5817
                select seq into t1 from server_information where field_name=fieldkey1;
5818
                select seq into t2 from server_information where field_name=fieldkey2;
5819
                update server_information set seq = t2 where field_name=fieldkey1;
5820
                update server_information set seq = t1 where field_name=fieldkey2;
5821
        else
5822
                select 0 as test;
5823
        end if;
5824
END//
5825
DELIMITER ;
5826

    
5827
-- 프로시저 nerv_icde_xxxx.serverViewNewField 구조 내보내기
5828
DELIMITER //
5829
CREATE PROCEDURE `serverViewNewField`(fieldvalue varchar(100), seqvalue int, descriptionvalue text)
5830
BEGIN
5831
        if loginTest() and supermanagerTest(@nervuser) then
5832
                select 1 as test;
5833
                insert into server_information(field_name,seq, description) values(fieldvalue,seqvalue, descriptionvalue);
5834
        else
5835
                select 0 as test;
5836
        end if;
5837

    
5838

    
5839
END//
5840
DELIMITER ;
5841

    
5842
-- 프로시저 nerv_icde_xxxx.serverViewServerInfo 구조 내보내기
5843
DELIMITER //
5844
CREATE PROCEDURE `serverViewServerInfo`()
5845
BEGIN
5846
       if loginTest() then
5847
               select 1 as test;
5848
               select * from server_information order by seq asc;
5849
       else
5850
               select 0 as test;
5851
       end if;
5852
END//
5853
DELIMITER ;
5854

    
5855
-- 프로시저 nerv_icde_xxxx.setup_public_interface_to_subsystem 구조 내보내기
5856
DELIMITER //
5857
CREATE PROCEDURE `setup_public_interface_to_subsystem`(IN `in_node_id` INT, IN `in_type` INT)
5858
BEGIN
5859
	 if loginTest() then
5860
          select 1 as test;
5861
          
5862
          if in_type = 0 then
5863
          		select custum_proxy.Id, custum_proxy.deploy_id,custum_proxy.public from custum_proxy where public=1 and deploy_id in
5864
					(select id from deployments where node_id=in_node_id);
5865
			else
5866
			 		select custum_stub.Id, custum_stub.deploy_id,custum_stub.public from custum_stub where public=1 and deploy_id in
5867
					(select id from deployments where node_id=in_node_id);
5868
			end if;
5869

    
5870
	 else	
5871
			 select 0 as test;
5872
	 end if;
5873

    
5874
END//
5875
DELIMITER ;
5876

    
5877
-- 프로시저 nerv_icde_xxxx.standard_port 구조 내보내기
5878
DELIMITER //
5879
CREATE PROCEDURE `standard_port`(in_port varchar(100), in_idkey int)
5880
BEGIN
5881
        if loginTest() then
5882
              select 1 as test;
5883
               update protocol_standard_port set discription=in_port where id=in_idkey;
5884
         else
5885
                         select 0 as test;
5886
         end if;
5887
END//
5888
DELIMITER ;
5889

    
5890
-- 프로시저 nerv_icde_xxxx.standard_portViewCheckPort 구조 내보내기
5891
DELIMITER //
5892
CREATE PROCEDURE `standard_portViewCheckPort`(in_port varchar(100))
5893
BEGIN
5894
        if loginTest() then
5895
           select 1 as test;
5896
           select * from protocol_standard_port where port like in_port;        
5897
         else
5898
           select 0 as test;
5899
         end if;
5900
END//
5901
DELIMITER ;
5902

    
5903
-- 프로시저 nerv_icde_xxxx.stubComponentViewParentInterfaceRealdomainList 구조 내보내기
5904
DELIMITER //
5905
CREATE PROCEDURE `stubComponentViewParentInterfaceRealdomainList`(domain_idkey int)
5906
BEGIN
5907
         declare sm bool;
5908
        declare sa varchar(100);
5909
        declare acount varchar(100);
5910
        declare pbc bool;
5911
  
5912
        set sa = '';
5913
        if loginTest() then
5914
        
5915
                    select supermanager into sm from users where user_id=@nervuser;
5916
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
5917
                    select user_id into acount from domain_method where id=domain_idkey;
5918
                    select public into pbc from domain_method where id=domain_idkey;
5919

    
5920
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
5921
                        select 1 as test;
5922
                        (select id, name from domain_method where id in (select parent_domain_id from inheritance_system_method where domain_id=domain_idkey))
5923
                         union
5924
                        (select id, name from domain_method where id=domain_idkey);
5925
                                
5926
                    else
5927
                        select 0 as test;
5928
                     end if;
5929
               else
5930
                 select 0 as test;
5931
        end if;
5932
End//
5933
DELIMITER ;
5934

    
5935
-- 프로시저 nerv_icde_xxxx.stubComponentViewParentInterfaceRealinterfaceList 구조 내보내기
5936
DELIMITER //
5937
CREATE PROCEDURE `stubComponentViewParentInterfaceRealinterfaceList`(domain_idkey int,in_component_idkey int)
5938
BEGIN
5939
        declare sm bool;
5940
        declare sa varchar(100);
5941
        declare acount varchar(100);
5942
        declare pbc bool;
5943

    
5944
        set sa = '';
5945
        if loginTest() then       
5946
                     select supermanager into sm from users where user_id=@nervuser;
5947
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
5948
                     select user_id into acount from domain_method where id=domain_idkey;
5949
                     select public into pbc from domain_method where id=domain_idkey;
5950

    
5951
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
5952
                        select 1 as test;
5953
                        select domain_id, name, user_id, seq, description from interface where domain_id=domain_idkey and name not in
5954
                                        (select interface_name from stub_interface_relation where component_id=in_component_idkey);
5955
                     else
5956
                        select 0 as test;
5957
                     end if;               
5958

    
5959
        else
5960
                select 0 as test;
5961
        end if;
5962
END//
5963
DELIMITER ;
5964

    
5965
-- 프로시저 nerv_icde_xxxx.stubInterfaceObjectViewDelete 구조 내보내기
5966
DELIMITER //
5967
CREATE PROCEDURE `stubInterfaceObjectViewDelete`(in_interface_object_id int, in_object_name varchar(100), in_component_id int)
5968
BEGIN 
5969
        if loginTest()then
5970
                select 1 as test;
5971
                delete from stub_interface_object where stub_interface_id=in_interface_object_id and object_name=in_object_name and component_id=in_component_id;                       
5972
        else
5973
                select 0 as test;
5974
        end if;
5975
END//
5976
DELIMITER ;
5977

    
5978
-- 프로시저 nerv_icde_xxxx.stubInterfaceObjectViewEditObjectName 구조 내보내기
5979
DELIMITER //
5980
CREATE PROCEDURE `stubInterfaceObjectViewEditObjectName`(in_stub_interface_id int, in_object_name varchar (100), in_component_id int, in_edit_object_name varchar(100))
5981
BEGIN
5982
        if loginTest() then
5983
                select 1 as test;
5984
                UPDATE stub_interface_object Set object_name=in_edit_object_name
5985
                                where stub_interface_id=in_stub_interface_id and component_id=in_component_id and object_name=in_object_name;
5986
        else
5987
                select 0 as test;
5988
        end if;
5989
END//
5990
DELIMITER ;
5991

    
5992
-- 프로시저 nerv_icde_xxxx.stubInterfaceObjectViewList 구조 내보내기
5993
DELIMITER //
5994
CREATE PROCEDURE `stubInterfaceObjectViewList`(in_stub_interface_relation_id int)
5995
BEGIN
5996
     if loginTest() then
5997
         select 1 as test;
5998
         select * from stub_interface_object where stub_interface_id=in_stub_interface_relation_id;
5999
     else
6000
         select 0 as test;
6001
     end if;     
6002
End//
6003
DELIMITER ;
6004

    
6005
-- 프로시저 nerv_icde_xxxx.stubInterfaceObjectViewNewObjectName 구조 내보내기
6006
DELIMITER //
6007
CREATE PROCEDURE `stubInterfaceObjectViewNewObjectName`(in_stub_interface_id int, in_object_name varchar (100), in_component_id int)
6008
BEGIN
6009
        if loginTest() then
6010
                select 1 as test;
6011
                insert into stub_interface_object (stub_interface_id, object_name, component_id)
6012
                                values(in_stub_interface_id, in_object_name, in_component_id);
6013
        else
6014
                select 0 as test;
6015
        end if;
6016
END//
6017
DELIMITER ;
6018

    
6019
-- 프로시저 nerv_icde_xxxx.stubInterfaceRalationDeleteInterface 구조 내보내기
6020
DELIMITER //
6021
CREATE PROCEDURE `stubInterfaceRalationDeleteInterface`(inidkey int)
6022
BEGIN
6023

    
6024
 
6025
        if loginTest()then
6026
                select 1 as test;
6027
                delete from stub_interface_relation where id=inidkey;                       
6028
        else
6029
                select 0 as test;
6030
        end if;
6031
END//
6032
DELIMITER ;
6033

    
6034
-- 프로시저 nerv_icde_xxxx.stubInterfaceRalationViewEditInterface 구조 내보내기
6035
DELIMITER //
6036
CREATE PROCEDURE `stubInterfaceRalationViewEditInterface`(in_idkey int,
6037
                                                                              in_method_domain_id int,
6038
                                                                              in_interface_name varchar(100),
6039
                                                                              in_class_name varchar(255))
6040
BEGIN
6041
        if loginTest() then
6042
                select 1 as test;
6043
                update stub_interface_relation set  method_domain_id = in_method_domain_id,
6044
                                                     interface_name = in_interface_name,
6045
                                                     class_name = in_class_name
6046
                                               where id = in_idkey;
6047

    
6048

    
6049
        else
6050
                select 0 as test;
6051
        end if;
6052
END//
6053
DELIMITER ;
6054

    
6055
-- 프로시저 nerv_icde_xxxx.stubInterfaceRalationViewNewInterface 구조 내보내기
6056
DELIMITER //
6057
CREATE PROCEDURE `stubInterfaceRalationViewNewInterface`(in_component_id int,
6058
                                                                             in_method_domain_id int,
6059
                                                                             in_interface_name varchar(100),
6060
                                                                             in_class_name varchar(255))
6061
BEGIN
6062
        if loginTest() then
6063
                select 1 as test;
6064
                insert into stub_interface_relation (component_id, method_domain_id, interface_name, class_name)
6065
                                values(in_component_id, in_method_domain_id, in_interface_name, in_class_name);                                 
6066
                                
6067
                select LAST_INSERT_ID();
6068
        else
6069
                select 0 as test;
6070
        end if;
6071
END//
6072
DELIMITER ;
6073

    
6074
-- 프로시저 nerv_icde_xxxx.stubInterfaceRelationViewClassNameList 구조 내보내기
6075
DELIMITER //
6076
CREATE PROCEDURE `stubInterfaceRelationViewClassNameList`(in_component_id int, in_method_domain_id int, in_interface_name varchar(100))
6077
BEGIN
6078
     if loginTest() then
6079
         select 1 as test;
6080
         select class_name from stub_interface_relation where 
6081
                component_id=in_component_id and method_domain_id=in_method_domain_id and interface_name=in_interface_name;
6082
     else
6083
         select 0 as test;
6084
     end if;
6085
End//
6086
DELIMITER ;
6087

    
6088
-- 프로시저 nerv_icde_xxxx.stubInterfaceRelationViewSearchList 구조 내보내기
6089
DELIMITER //
6090
CREATE PROCEDURE `stubInterfaceRelationViewSearchList`(in_component_id int, in_method_domain_id int, in_interface_name varchar(100), in_class_name varchar(255))
6091
BEGIN
6092
     if loginTest() then
6093
         select 1 as test;
6094
         select id from stub_interface_relation where 
6095
                component_id=in_component_id and method_domain_id=in_method_domain_id and interface_name=in_interface_name and class_name=in_class_name;
6096
     else
6097
         select 0 as test;
6098
     end if;
6099
End//
6100
DELIMITER ;
6101

    
6102
-- 프로시저 nerv_icde_xxxx.stubInterfaceViewList 구조 내보내기
6103
DELIMITER //
6104
CREATE PROCEDURE `stubInterfaceViewList`(
6105
	IN `incomponent_id` int
6106
)
6107
BEGIN
6108
     if loginTest() then
6109
         select 1 as test;
6110
         
6111
         select a.id,  a.method_domain_id, a.component_id, a.interface_name, b.name as method_domain_name , a.class_name from
6112
         
6113
         (select id, component_id, method_domain_id, interface_name, class_name from stub_interface_relation where component_id = incomponent_id) as a
6114
         join
6115
         (select id,name from domain_method) as b on a.method_domain_id = b.id ;
6116
         
6117
         
6118
     else
6119
         select 0 as test;
6120
     end if;
6121
     
6122
     
6123
     
6124
End//
6125
DELIMITER ;
6126

    
6127
-- 프로시저 nerv_icde_xxxx.switchSubComponentInfo 구조 내보내기
6128
DELIMITER //
6129
CREATE PROCEDURE `switchSubComponentInfo`(in_node_id int)
6130
BEGIN
6131

    
6132
     if loginTest() then
6133
     select 1 as test;
6134
        select component_id from stub_interface_relation where component_id in (select component_id from deployments where node_id=in_node_id);
6135
     else
6136
         select 0 as test;
6137
     end if;     
6138
End//
6139
DELIMITER ;
6140

    
6141
-- 프로시저 nerv_icde_xxxx.systemDomainPortViewList 구조 내보내기
6142
DELIMITER //
6143
CREATE PROCEDURE `systemDomainPortViewList`(in_system_domain_id int)
6144
BEGIN
6145
     if loginTest() then
6146
         select 1 as test;
6147
         select domain_system_id, port_num, port_group, description from domain_system_port where domain_system_id=in_system_domain_id;
6148
     else
6149
         select 0 as test;
6150
     end if;
6151
End//
6152
DELIMITER ;
6153

    
6154
-- 프로시저 nerv_icde_xxxx.ten_pro 구조 내보내기
6155
DELIMITER //
6156
CREATE PROCEDURE `ten_pro`()
6157
BEGIN
6158
	select s_node_id , s_port_id , port_group from ( select * from network_link where d_node_id = 0 and d_sub_system_id in
6159
	 (select sub_system_domain_id from node where id = 165) ) as A join domain_system_port as B on A.d_sub_system_id = B.domain_system_id  and A.d_port_id = B.port_num group by port_group;
6160
END//
6161
DELIMITER ;
6162

    
6163
-- 프로시저 nerv_icde_xxxx.testpro 구조 내보내기
6164
DELIMITER //
6165
CREATE PROCEDURE `testpro`(IN `idkey` int , IN `domaintype` varchar(100))
6166
BEGIN
6167
     if( idkey != 0 ) then
6168
         select id, upper_id, name from domain_method  where id = idkey;
6169
   
6170
               
6171
         call testpro(upper_id, 'method');
6172
     else
6173
     
6174
         select 0 as test;
6175
     end if;
6176
END//
6177
DELIMITER ;
6178

    
6179
-- 프로시저 nerv_icde_xxxx.TreeDomainChildViewList 구조 내보내기
6180
DELIMITER //
6181
CREATE PROCEDURE `TreeDomainChildViewList`(
6182
	IN `idkey` int,
6183
	IN `domaintype` varchar(100)
6184

    
6185
)
6186
BEGIN
6187
        declare sm bool;
6188
        if loginTest() then
6189
                select 1 as test;
6190
                if( supermanagerTest(@nervuser) ) then
6191
                       if(domaintype='data') then
6192
                        select id, name , upper_id from domain_data where upper_id = idkey order by name desc;
6193
                       end if;
6194
                       if(domaintype='method') then
6195
                        select id, name, upper_id from domain_method where upper_id = idkey order by name desc;
6196
                       end if;
6197
                       if(domaintype='system') then
6198
                        select id, name, upper_id from domain_system where upper_id = idkey order by name desc;
6199
                       end if;
6200
                 end if;
6201
       else
6202
               select 0 as test;
6203
       end if;
6204
END//
6205
DELIMITER ;
6206

    
6207
-- 프로시저 nerv_icde_xxxx.treeViewEditItemName 구조 내보내기
6208
DELIMITER //
6209
CREATE PROCEDURE `treeViewEditItemName`(in_idkey int,
6210
                                                            in_typevalue int,
6211
                                                            in_orignalnamekey varchar(100),
6212
                                                            in_editname varchar(100))
6213
BEGIN    
6214

    
6215
        if loginTest() then 
6216
               
6217
                
6218
                if (in_typevalue=0) then
6219
                        update domain_system set  name=in_editname where id=in_idkey;
6220
                        select 1 as test;
6221
                end if;                       
6222
                
6223
                if (in_typevalue=1) then
6224
                        update domain_method set  name=in_editname where id=in_idkey;
6225
                        select 1 as test;
6226
                end if;
6227
                
6228
                if (in_typevalue=2) then
6229
                        update domain_data set name=in_editname where id=in_idkey;
6230
                        select 1 as test;
6231
                end if;
6232
                
6233
                if (in_typevalue=3) then
6234
                        update data set  name=in_editname where domain_id=in_idkey and name = in_orignalnamekey;
6235
                        select 1 as test;
6236
                end if;                       
6237
                
6238
                if (in_typevalue=4) then
6239
                        update method set  name=in_editname where domain_id=in_idkey and name = in_orignalnamekey;
6240
                        select 1 as test;
6241
                end if;
6242
                
6243
                if (in_typevalue=6) then
6244
                        update interface set name=in_editname where domain_id=in_idkey and name = in_orignalnamekey;
6245
                        select 1 as test;
6246
                end if;
6247
                
6248
                if (in_typevalue=7) then
6249
                        update node set name=in_editname where id=in_idkey and name = in_orignalnamekey;
6250
                        select 1 as test;
6251
                end if;
6252
                if (in_typevalue=8) then
6253
                        update component set name=in_editname where id=in_idkey and name = in_orignalnamekey;
6254
                        select 1 as test;
6255
                end if;
6256
                
6257
                
6258
        else
6259
                select 0 as test;
6260
        end if;
6261
END//
6262
DELIMITER ;
6263

    
6264
-- 프로시저 nerv_icde_xxxx.umlcomponententityViewList 구조 내보내기
6265
DELIMITER //
6266
CREATE PROCEDURE `umlcomponententityViewList`(in_diagramid int)
6267
BEGIN
6268
     if loginTest() then
6269
         select 1 as test;
6270
         select id, diagrame_id, component_id, position_x, position_y, size from umlcomponent where diagrame_id = in_diagramid;        
6271
         
6272
     else
6273
         select 0 as test;
6274
     end if;
6275
     
6276
     
6277
     
6278
End//
6279
DELIMITER ;
6280

    
6281
-- 프로시저 nerv_icde_xxxx.update_child_depth 구조 내보내기
6282
DELIMITER //
6283
CREATE PROCEDURE `update_child_depth`(IN `in_data_auto_id` INT, IN `in_data_domain_id` INT, IN `in_data_depth` INT)
6284
BEGIN	
6285
	
6286

    
6287
	declare no_more_rows bool default false;
6288

    
6289
	declare child_data_auto_id int;		
6290
	declare child_domain_id int;
6291
	declare child_depth int;
6292
	
6293
	DECLARE my_list CURSOR FOR 
6294

    
6295
		select data.data_auto_id, data.domain_id, data.depth from data where data.real_data_auto_id=in_data_auto_id and data.domain_id=in_data_domain_id and data.`type`='alias'
6296
		union
6297
		select data.data_auto_id, data.domain_id, data.depth from data where data.domain_id=in_data_domain_id and data.data_auto_id in
6298
		(select data_field.data_auto_id from data_field where data_field.`type`='alias' and data_field.real_data_auto_id = in_data_auto_id);	
6299

    
6300
	declare continue handler for not found set no_more_rows := TRUE;
6301
	
6302
	set max_sp_recursion_depth = 50;		 
6303

    
6304
		open my_list;	
6305
		my_loop : loop
6306
		
6307
			fetch my_list into child_data_auto_id, child_domain_id, child_depth;
6308
			if no_more_rows then
6309
				close my_list;
6310
				leave my_loop;
6311
			end if;					
6312

    
6313
			if child_depth <= in_data_depth then
6314
			 	update data set data.depth=(in_data_depth+1) where data.data_auto_id=child_data_auto_id;
6315
			 	call update_child_depth( child_data_auto_id, child_domain_id , in_data_depth+1);
6316
			end if;
6317
		
6318
		end loop my_loop;
6319
		
6320

    
6321

    
6322
END//
6323
DELIMITER ;
6324

    
6325
-- 프로시저 nerv_icde_xxxx.userViewEditDomainUserGuest 구조 내보내기
6326
DELIMITER //
6327
CREATE PROCEDURE `userViewEditDomainUserGuest`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `acountkey` varchar(100))
6328
BEGIN
6329
        declare domaincreator varchar(100);
6330
        declare mb varchar(100);
6331
        declare targetmb varchar(100); 
6332
        
6333
        if(domaintype='data') then
6334
              select user_id into domaincreator from domain_data where id=domain_idkey;
6335
              if acountkey != domaincreator then
6336
                  select member_type into mb from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
6337
                  select member_type into targetmb from members_domain_data where domain_id=domain_idkey and user_id=acountkey;
6338
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6339
                        if loginTest() then
6340
                                select 1 as test;
6341
                                update members_domain_data set member_type = 'guest' where domain_id=domain_idkey and user_id=acountkey;
6342
                        else
6343
                                select 0 as test;
6344
                        end if;
6345
                  else
6346
                        select 0 as test;
6347
                  end if;
6348
              else
6349
                select 0 as test;
6350
              end if;
6351
        end if;
6352
        
6353
        if(domaintype='method') then
6354
              select user_id into domaincreator from domain_method where id=domain_idkey;
6355
              if acountkey != domaincreator then
6356
                  select member_type into mb from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6357
                  select member_type into targetmb from members_domain_method where domain_id=domain_idkey and user_id=acountkey;
6358
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6359
                        if loginTest() then
6360
                                select 1 as test;
6361
                                update members_domain_method set member_type = 'guest' where domain_id=domain_idkey and user_id=acountkey;
6362
                        else
6363
                                select 0 as test;
6364
                        end if;
6365
                  else
6366
                        select 0 as test;
6367
                  end if;
6368
              else
6369
                select 2 as test;
6370
              end if;
6371
        end if;
6372
        
6373
        if(domaintype='system') then
6374
              select user_id into domaincreator from domain_system where id=domain_idkey;
6375
              if acountkey != domaincreator then
6376
                  select member_type into mb from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
6377
                  select member_type into targetmb from members_domain_system where domain_id=domain_idkey and user_id=acountkey;
6378
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6379
                        if loginTest() then
6380
                                select 1 as test;
6381
                                update members_domain_system set member_type = 'guest' where domain_id=domain_idkey and user_id=acountkey;
6382
                        else
6383
                                select 0 as test;
6384
                        end if;
6385
                  else
6386
                        select 0 as test;
6387
                  end if;
6388
              else
6389
                select 0 as test;
6390
              end if;
6391
        end if;
6392
END//
6393
DELIMITER ;
6394

    
6395
-- 프로시저 nerv_icde_xxxx.userViewEditDomainUserManager 구조 내보내기
6396
DELIMITER //
6397
CREATE PROCEDURE `userViewEditDomainUserManager`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `acountkey` varchar(100))
6398
BEGIN
6399
        declare domaincreator varchar(100);
6400
        
6401
        if(domaintype='data') then
6402
                    select user_id into domaincreator from domain_data where id=domain_idkey;
6403

    
6404
                    if acountkey != domaincreator and @nervuser = domaincreator or supermanagerTest(@nervuser) then
6405
                       if loginTest() then
6406
                           select 1 as test;
6407
                           update members_domain_data set member_type = 'manager' where domain_id=domain_idkey and user_id=acountkey;
6408
                       else
6409
                           select 0 as test;
6410
                       end if;
6411
                    else
6412
                       select 0 as test;
6413
                    end if;
6414
         end if;
6415
         
6416
         if(domaintype='method') then
6417
                    select user_id into domaincreator from domain_method where id=domain_idkey;
6418

    
6419
                    if acountkey != domaincreator and @nervuser = domaincreator or supermanagerTest(@nervuser) then
6420
                       if loginTest() then
6421
                           select 1 as test;
6422
                           update members_domain_method set member_type = 'manager' where domain_id=domain_idkey and user_id=acountkey;
6423
                       else
6424
                           select 0 as test;
6425
                       end if;
6426
                    else
6427
                       select 0 as test;
6428
                    end if;
6429
         end if;
6430
         
6431
         if(domaintype='system') then
6432
                    select user_id into domaincreator from domain_system where id=domain_idkey;
6433

    
6434
                    if acountkey != domaincreator and @nervuser = domaincreator or supermanagerTest(@nervuser) then
6435
                       if loginTest() then
6436
                           select 1 as test;
6437
                           update members_domain_system set member_type = 'manager' where domain_id=domain_idkey and user_id=acountkey;
6438
                       else
6439
                           select 0 as test;
6440
                       end if;
6441
                    else
6442
                       select 0 as test;
6443
                    end if;
6444
         end if;
6445
END//
6446
DELIMITER ;
6447

    
6448
-- 프로시저 nerv_icde_xxxx.userViewEditDomainUserMember 구조 내보내기
6449
DELIMITER //
6450
CREATE PROCEDURE `userViewEditDomainUserMember`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `acountkey` varchar(100))
6451
BEGIN
6452
        declare domaincreator varchar(100);
6453
        declare mb varchar(100);
6454
        declare targetmb varchar(100);        
6455

    
6456
        if(domaintype='data') then
6457
                     select user_id into domaincreator from domain_data where id=domain_idkey;
6458
                     if acountkey != domaincreator then
6459
                        select member_type into mb from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
6460
                        select member_type into targetmb from members_domain_data where domain_id=domain_idkey and user_id=acountkey;
6461
                        if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6462
                           if loginTest() then
6463
                                select 1 as test;
6464
                                update members_domain_data set member_type = 'member' where  domain_id=domain_idkey and user_id=acountkey;
6465
                           else
6466
                                select 0 as test;
6467
                           end if;
6468
                        else
6469
                           select 0 as test;
6470
                        end if;
6471
                      else
6472
                         select 0 as test;
6473
                      end if;
6474
          end if;
6475
          
6476
          if(domaintype='method') then
6477
                     select user_id into domaincreator from domain_method where id=domain_idkey;
6478
                     if acountkey != domaincreator then
6479
                        select member_type into mb from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6480
                        select member_type into targetmb from members_domain_method where domain_id=domain_idkey and user_id=acountkey;
6481
                        if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6482
                           if loginTest() then
6483
                                select 1 as test;
6484
                                update members_domain_method set member_type = 'member' where  domain_id=domain_idkey and user_id=acountkey;
6485
                           else
6486
                                select 0 as test;
6487
                           end if;
6488
                        else
6489
                           select 2 as test;
6490
                        end if;
6491
                      else
6492
                         select -1 as test;
6493
                      end if;                      
6494
          end if;          
6495
          if(domaintype='system') then
6496
                     select user_id into domaincreator from domain_system where id=domain_idkey;
6497

    
6498
                     if acountkey != domaincreator then
6499
                        select member_type into mb from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
6500
                        select member_type into targetmb from members_domain_system where domain_id=domain_idkey and user_id=acountkey;
6501
                        if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6502
                           if loginTest() then
6503
                                select 1 as test;
6504
                                update members_domain_system set member_type = 'member' where  domain_id=domain_idkey and user_id=acountkey;
6505
                           else
6506
                                select 0 as test;
6507
                           end if;
6508
                        else
6509
                           select 0 as test;
6510
                        end if;
6511
                      else
6512
                         select 0 as test;
6513
                      end if;
6514
          end if;
6515

    
6516
END//
6517
DELIMITER ;
6518

    
6519
-- 프로시저 nerv_icde_xxxx.userViewEditDomainUserPurge 구조 내보내기
6520
DELIMITER //
6521
CREATE PROCEDURE `userViewEditDomainUserPurge`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `acountkey` varchar(100))
6522
BEGIN
6523
        declare domaincreator varchar(100);
6524
        declare mb varchar(100);
6525
        declare targetmb varchar(100);
6526
        
6527
        if(domaintype='data') then
6528
              select user_id into domaincreator from domain_data where id=domain_idkey;
6529
              if acountkey != domaincreator then
6530
                  select member_type into mb from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
6531
                  select member_type into targetmb from members_domain_data where domain_id=domain_idkey and user_id=acountkey;
6532
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6533
                        if loginTest() then
6534
                                select 1 as test;
6535
                                 delete from members_domain_data where domain_id=domain_idkey and user_id=acountkey;
6536
                                
6537
                        else
6538
                                select 0 as test;
6539
                        end if;
6540
                  else
6541
                        select 0 as test;
6542
                  end if;
6543
              else
6544
                select 0 as test;
6545
              end if;
6546
        end if;
6547
        
6548
        if(domaintype='method') then
6549
              select user_id into domaincreator from domain_method where id=domain_idkey;
6550
              if acountkey != domaincreator then
6551
                  select member_type into mb from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6552
                  select member_type into targetmb from members_domain_method where domain_id=domain_idkey and user_id=acountkey;
6553
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6554
                        if loginTest() then
6555
                                select 1 as test;
6556
                                 delete from members_domain_method where domain_id=domain_idkey and user_id=acountkey;
6557
                        else
6558
                                select 0 as test;
6559
                        end if;
6560
                  else
6561
                        select 0 as test;
6562
                  end if;
6563
              else
6564
                select 0 as test;
6565
              end if;
6566
        end if;
6567
        
6568
        if(domaintype='system') then
6569
              select user_id into domaincreator from domain_system where id=domain_idkey;
6570
              if acountkey != domaincreator then
6571
                  select member_type into mb from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
6572
                  select member_type into targetmb from members_domain_system where domain_id=domain_idkey and user_id=acountkey;
6573
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6574
                        if loginTest() then
6575
                                select 1 as test;
6576
                                 delete from members_domain_system where domain_id=domain_idkey and user_id=acountkey;
6577
                        else
6578
                                select 0 as test;
6579
                        end if;
6580
                  else
6581
                        select 0 as test;
6582
                  end if;
6583
              else
6584
                select 0 as test;
6585
              end if;
6586
        end if;
6587
END//
6588
DELIMITER ;
6589

    
6590
-- 프로시저 nerv_icde_xxxx.userViewJoinDomain 구조 내보내기
6591
DELIMITER //
6592
CREATE PROCEDURE `userViewJoinDomain`(domain_idkey int, domaintype varchar(100))
6593
BEGIN
6594
        if loginTest() then
6595
                if (domaintype ='data') then
6596
                   select 1 as test;
6597
                   insert into members_domain_data(domain_id,user_id,member_type) values(domain_idkey,@nervuser,'guest');
6598
                end if;
6599
                if (domaintype ='method') then
6600
                   select 1 as test;
6601
                   insert into members_domain_method(domain_id,user_id,member_type) values(domain_idkey,@nervuser,'guest');
6602
                end if;
6603
                if (domaintype ='system') then
6604
                   select 1 as test;
6605
                   insert into members_domain_system(domain_id,user_id,member_type) values(domain_idkey,@nervuser,'guest');
6606
                end if;
6607
        else
6608
                select 0 as test;
6609
        end if;
6610
END//
6611
DELIMITER ;
6612

    
6613
-- 프로시저 nerv_icde_xxxx.userViewSecessionDomain 구조 내보내기
6614
DELIMITER //
6615
CREATE PROCEDURE `userViewSecessionDomain`(domain_idkey int, domaintype varchar(100))
6616
BEGIN
6617
        if loginTest() then
6618
                if (domaintype ='data') then
6619
                   select 1 as test;
6620
                   delete from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
6621
                end if;
6622
                if (domaintype ='method') then
6623
                   select 1 as test;
6624
                   delete from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6625
                end if;
6626
                if (domaintype ='system') then
6627
                   select 1 as test;
6628
                   delete from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
6629
                end if;       
6630
        
6631
               
6632
        else
6633
                select 0 as test;
6634
        end if;
6635
END//
6636
DELIMITER ;
6637

    
6638
-- 프로시저 nerv_icde_xxxx.userViewUserList 구조 내보내기
6639
DELIMITER //
6640
CREATE PROCEDURE `userViewUserList`(domain_idkey int, domaintype varchar(100), userkey varchar(100),memberkey varchar(100))
6641
BEGIN
6642
        if loginTest() then
6643
                select 1 as test;
6644
                if domainReadTest(domain_idkey, domaintype) then                
6645
                   if (domaintype ='data') then
6646
                        if memberkey='all' then
6647
                                select a.user_id,member_type, description from
6648
                                        (select * from members_domain_data where domain_id=domain_idkey and user_id like userkey) as a
6649
                                                join
6650
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6651
                        else
6652
                                select a.user_id,member_type, description from
6653
                                        (select * from members_domain_data where domain_id=domain_idkey and user_id like userkey and member_type=memberkey) as a
6654
                                                join
6655
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6656
                        end if;
6657
                   end if;
6658
                   
6659
                   if (domaintype ='method') then
6660
                        if memberkey='all' then
6661
                                select a.user_id,member_type, description from
6662
                                        (select * from members_domain_method where domain_id=domain_idkey and user_id like userkey) as a
6663
                                                join
6664
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6665
                        else
6666
                                select a.user_id,member_type, description from
6667
                                        (select * from members_domain_method where domain_id=domain_idkey and user_id like userkey and member_type=memberkey) as a
6668
                                                join
6669
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6670
                        end if;
6671
                   end if;
6672
                   
6673
                   if (domaintype ='system') then
6674
                        if memberkey='all' then
6675
                                select a.user_id,member_type, description from
6676
                                        (select * from members_domain_system where domain_id=domain_idkey and user_id like userkey) as a
6677
                                                join
6678
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6679
                        else
6680
                                select a.user_id,member_type, description from
6681
                                        (select * from members_domain_system where domain_id=domain_idkey and user_id like userkey and member_type=memberkey) as a
6682
                                                join
6683
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6684
                        end if;
6685
                   end if;
6686
                   
6687
                else
6688
                     if (domaintype ='data') then
6689
                        if memberkey='all' then
6690
                                select a.user_id,member_type, description from
6691
                                        (select * from members_domain_data where domain_id=domain_idkey and (user_id='anonymous' or user_id=@nervuser) and user_id like userkey) as a
6692
                                                join
6693
                                        (select user_id,description from users where userid like userkey ) as b on a.user_id=b.user_id;
6694
                        else
6695
                                select a.user_id,member_type, description from
6696
                                        (select * from members_domain_data where domain_id=domain_idkey and (user_id='anonymous' or user_id=@nervuser) and user_id like userkey and member_type=memberkey) as a
6697
                                                join
6698
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6699
                        end if;
6700
                     end if;
6701
                     
6702
                     if (domaintype ='method') then
6703
                        if memberkey='all' then
6704
                                select a.user_id,member_type, description from
6705
                                        (select * from members_domain_method where domain_id=domain_idkey and (user_id='anonymous' or user_id=@nervuser) and user_id like userkey) as a
6706
                                                join
6707
                                        (select user_id,description from users where userid like userkey ) as b on a.user_id=b.user_id;
6708
                        else
6709
                                select a.user_id,member_type, description from
6710
                                        (select * from members_domain_method where domain_id=domain_idkey and (user_id='anonymous' or user_id=@nervuser) and user_id like userkey and member_type=memberkey) as a
6711
                                                join
6712
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6713
                        end if;
6714
                     end if;
6715
                     
6716
                     if (domaintype ='system') then
6717
                        if memberkey='all' then
6718
                                select a.user_id,member_type, description from
6719
                                        (select * from members_domain_system where domain_id=domain_idkey and (user_id='anonymous' or user_id=@nervuser) and user_id like userkey) as a
6720
                                                join
6721
                                        (select user_id,description from users where userid like userkey ) as b on a.user_id=b.user_id;
6722
                        else
6723
                                select a.user_id,member_type, description from
6724
                                        (select * from members_domain_system where domain_id=domain_idkey and (user_id='anonymous' or user_id=@nervuser) and user_id like userkey and member_type=memberkey) as a
6725
                                                join
6726
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6727
                        end if;
6728
                     end if;
6729
                end if;
6730
       else
6731
               select 0 as test;
6732
       end if;
6733
END//
6734
DELIMITER ;
6735

    
6736
-- 프로시저 nerv_icde_xxxx.xmldocumentViewimportData 구조 내보내기
6737
DELIMITER //
6738
CREATE PROCEDURE `xmldocumentViewimportData`(IN `domain_idkey` int, IN `data_namevalue` varchar(100), IN `typevalue` varchar(100), IN `physicalvalue` varchar(100), IN `realdomain_idvalue` int, IN `realmetadatavalue` varchar(100), IN `scminvalue` varchar(100), IN `scmaxvalue` varchar(100), IN `descriptionvalue` varchar(100))
6739
BEGIN
6740

    
6741
	declare in_data_auto_id int default null;
6742
	declare in_real_data_auto_id int default null;
6743

    
6744
        if typevalue ='alias' and realdomain_idvalue != 0 then
6745
               select data.data_auto_id into in_real_data_auto_id from data where data.domain_id=realdomain_idvalue and data.name=realmetadatavalue;
6746
         end if;
6747
                
6748
        if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(in_real_data_auto_id) )then
6749
        
6750
        			select data.data_auto_id into in_data_auto_id from data where data.domain_id=domain_idkey and data.name=data_namevalue;
6751
        
6752
                
6753
                select 1 as test;
6754
                if existMetadata(in_data_auto_id) then
6755
                
6756
                update data set name=data_namevalue,
6757
                                type=typevalue,
6758
                                real_data_auto_id=in_real_data_auto_id,                                
6759
                                scmin=scminvalue,
6760
                                scmax=scmaxvalue,
6761
                                description=descriptionvalue
6762
                                where data.data_auto_id=in_data_auto_id;
6763
                else
6764
                   insert into data (domain_id   ,name       ,type     , real_data_auto_id,       scmin     ,scmax     , description, user_id)
6765
                              values(domain_idkey,data_namevalue, typevalue, in_real_data_auto_id,scminvalue,scmaxvalue,descriptionvalue, @nervuser );
6766
                end if;
6767
                        
6768
        else
6769
                select 0 as test;
6770
        end if;
6771
END//
6772
DELIMITER ;
6773

    
6774
-- 프로시저 nerv_icde_xxxx.xmldocumentViewimportDatafield 구조 내보내기
6775
DELIMITER //
6776
CREATE PROCEDURE `xmldocumentViewimportDatafield`(IN `domain_idkey` int, IN `metadatakey` varchar(100), IN `metafieldvalue` varchar(100), IN `bitsizevalue` int unsigned, IN `typevalue` varchar(100), IN `physicalvalue` varchar(100), IN `realdomainvalue` int, IN `realmetadatavalue` varchar(100), IN `minvalue` varchar(100), IN `in_maxvalue` varchar(100), IN `arraytypevalue` varchar(100), IN `arraysizevalue` int unsigned, IN `descriptionvalue` text)
6777
BEGIN
6778

    
6779
	declare data_auto_id_key int default null;
6780
	declare in_real_data_auto_id int default null;
6781
	
6782
	select data.data_auto_id into data_auto_id_key from data where data.domain_id=domain_idkey and data.name=metadatakey;  	   	
6783
	
6784
      if typevalue ='alias' and realdomainvalue !=0 then
6785
	      select data.data_auto_id into in_real_data_auto_id from data where data.domain_id=realdomainvalue and data.name=realmetadatavalue;  	   	
6786
      end if;
6787
      
6788
      if loginTest() and domainManageTest(domain_idkey) and (typevalue!='alias' or existMetadata(in_real_data_auto_id)) then                
6789
                select 1 as test;
6790
                if existMetadatafield(domain_idkey, metadatakey, metafieldvalue) then
6791
                
6792
                update data_field set member_name=metafieldvalue,
6793
                                      type=typevalue,
6794
                                      real_data_auto_id=in_real_data_auto_id,
6795
                                      bitsize=bitsizevalue,
6796
                                      scimin=minvalue,
6797
                                      scimax=in_maxvalue,
6798
                                      arraytype=arraytypevalue,
6799
                                      arraysize=arraysizevalue,
6800
                                      description=descriptionvalue                                      
6801
                                 where data_field.data_auto_id=data_auto_id_key and member_name=metafieldvalue;
6802
                else
6803
                     insert into data_field( data_auto_id, member_name, type, real_data_auto_id, bitsize, user_id, scimin, scimax, arraytype, arraysize, description)
6804
          values(data_auto_id_key, metafieldvalue, typevalue, in_real_data_auto_id, bitsizevalue, @nervuser, minvalue, in_maxvalue, arraytypevalue, arraysizevalue, descriptionvalue);
6805
                end if;
6806
                        
6807
        else
6808
                select 0 as test;
6809
        end if;
6810
END//
6811
DELIMITER ;
6812

    
6813
-- 프로시저 nerv_icde_xxxx.xmldocumentViewimportDomain 구조 내보내기
6814
DELIMITER //
6815
CREATE PROCEDURE `xmldocumentViewimportDomain`(IN `in_id` INT, IN `upper_idvalue` INT, IN `domaintype` VARCHAR(50), IN `namevalue` VARCHAR(100), IN `standardportvalue` SMALLINT, IN `publicvalue` TINYINT, IN `descriptionvalue` TEXT)
6816
BEGIN
6817

    
6818
	 
6819
        if loginTest() and newDomainTest() then
6820
                select 1 as test;
6821
                
6822
					 if (domaintype='data') then
6823
					 	if existDomain(in_id,domaintype) then
6824
                		update domain_data set upper_id=upper_idvalue, name=namevalue,  public=publicvalue  where domain_data.id=in_id;
6825
                	else
6826
                		insert into domain_data(id, upper_id, name, user_id, public, create_date, last_update,description )
6827
                                 values(in_id, upper_idvalue, namevalue, @nervuser, publicvalue, @logdate, @logdate,descriptionvalue);
6828
               	end if;
6829
                end if;
6830
                
6831
					 if (domaintype='method') then
6832
                	if existDomain(in_id,domaintype) then
6833
                		update domain_method set upper_id=upper_idvalue, name=namevalue,  public=publicvalue,  standard_port=standardportvalue where domain_method.id=in_id;
6834
                	else
6835
		                insert into domain_method(id, upper_id, name, user_id, public,  standard_port, create_date, last_update,description )
6836
                                 values(in_id, upper_idvalue, namevalue, @nervuser, publicvalue, standardportvalue, @logdate, @logdate,descriptionvalue);
6837
                  end if;
6838
                end if;
6839
                
6840
			else
6841
                select 0 as test;
6842
        end if;
6843

    
6844
END//
6845
DELIMITER ;
6846

    
6847
-- 프로시저 nerv_icde_xxxx.xmldocumentViewimportInterface 구조 내보내기
6848
DELIMITER //
6849
CREATE PROCEDURE `xmldocumentViewimportInterface`(domain_idkey int,
6850
                                                                     interfacevalue varchar(100),
6851
                                                                     descriptionvalue varchar(100))
6852
BEGIN
6853

    
6854
        if loginTest() and domainManageTest(domain_idkey) then
6855
                select 1 as test;
6856
                if existInterface(domain_idkey,interfacevalue) then
6857
                       update interface set name=interfacevalue,description=descriptionvalue where domain_id=domain_idkey and name=interfacevalue;
6858
                else
6859
                insert into interface (domain_id,                name,  user_id, description)
6860
                                values(domain_idkey, interfacevalue, @nervuser, descriptionvalue );
6861
                end if;
6862
        else
6863
                select 0 as test;
6864
        end if;
6865
END//
6866
DELIMITER ;
6867

    
6868
-- 프로시저 nerv_icde_xxxx.xmldocumentViewimportInterfacemembermethod 구조 내보내기
6869
DELIMITER //
6870
CREATE PROCEDURE `xmldocumentViewimportInterfacemembermethod`(domain_idkey int,
6871
                                                                                interfacekey varchar(100),
6872
                                                                                methodvalue varchar(100),
6873
                                                                                descriptionvalue varchar(100))
6874
BEGIN
6875
        if loginTest() and domainManageTest(domain_idkey) and existMethod(domain_idkey, methodvalue) and !existInterfaceMemberMethod(domain_idkey,interfacekey,methodvalue)then
6876
                select 1 as test;
6877
                insert into interface_member(domain_id,        interface,     method_domain_id,   method_name, description)
6878
                                    values(domain_idkey, interfacekey, domain_idkey, methodvalue, descriptionvalue);
6879
        else
6880
                select 0 as test;
6881
        end if;
6882
END//
6883
DELIMITER ;
6884

    
6885
-- 프로시저 nerv_icde_xxxx.xmldocumentViewimportMethod 구조 내보내기
6886
DELIMITER //
6887
CREATE PROCEDURE `xmldocumentViewimportMethod`(IN `in_domain_id` int, IN `in_methodvalue` varchar(100), IN `in_typevalue` varchar(100), IN `in_codevalue` varchar(100), IN `inputdomainvalue` int(10) unsigned, IN `inputmetadatavalue` varchar(100), IN `outputdomainvalue` int(10) unsigned, IN `outputmetadatavalue` varchar(100), IN `descriptionvalue` text)
6888
BEGIN
6889

    
6890
	declare in_real_data_auto_id int default null;
6891
	declare out_real_data_auto_id int default null;
6892

    
6893
	
6894
     if inputdomainvalue!=0 then
6895
     		select data.data_auto_id into in_real_data_auto_id from data where data.domain_id=inputdomainvalue and data.name=inputmetadatavalue;
6896
     end if;
6897
     
6898
     if outputdomainvalue!=0 then
6899
	     select data.data_auto_id into out_real_data_auto_id from data where data.domain_id=outputdomainvalue and data.name=outputmetadatavalue;
6900
     end if;
6901

    
6902
     if loginTest() and domainManageTest(in_domain_id) and (in_real_data_auto_id is NULL or existMetadata(in_real_data_auto_id) )
6903
                                                       and (out_real_data_auto_id is NULL or existMetadata(out_real_data_auto_id)) then
6904
                select 1 as test;
6905
                if existMethod(in_domain_id, in_methodvalue) then
6906
                
6907
                update method set       code=in_codevalue,
6908
                                        type=in_typevalue,
6909
                                        name=in_methodvalue,
6910
                                        in_data_auto_id=in_real_data_auto_id,
6911
													 out_data_auto_id=out_real_data_auto_id,
6912
                                        description=descriptionvalue
6913
                              where     domain_id=in_domain_id and name=in_methodvalue;
6914
                else
6915
                insert into method(    domain_id,           name,         type,         code,      in_data_auto_id,  out_data_auto_id,  user_id, description)
6916
                            values( in_domain_id, in_methodvalue, in_typevalue, in_codevalue, in_real_data_auto_id, out_data_auto_id, @nervuser, descriptionvalue);
6917
                end if;
6918
                        
6919
        else
6920
                select 0 as test;
6921
        end if;
6922
END//
6923
DELIMITER ;
6924

    
6925
-- 함수 nerv_icde_xxxx.check_system_lock_component_f 구조 내보내기
6926
DELIMITER //
6927
CREATE FUNCTION `check_system_lock_component_f`(
6928
	`in_component_id` INT
6929
) RETURNS tinyint(1)
6930
BEGIN
6931

    
6932
	declare deploy_id int default 0;
6933
	declare proxy_cnt int default 0;
6934
	declare stub_cnt int default 0;
6935

    
6936
	
6937
	select deployments.Id into deploy_id from deployments where component_id=in_component_id;	
6938
	select count(*) into proxy_cnt from custum_proxy where custum_proxy.deploy_id=deploy_id and public=1;
6939
	select count(*) into stub_cnt  from custum_stub where custum_stub.deploy_id=deploy_id and public=1;
6940

    
6941

    
6942
	if proxy_cnt > 0  or stub_cnt > 0 then
6943
		return 0;
6944
	else
6945
		return 0;
6946
	end if;
6947
END//
6948
DELIMITER ;
6949

    
6950
-- 함수 nerv_icde_xxxx.check_system_lock_domain 구조 내보내기
6951
DELIMITER //
6952
CREATE FUNCTION `check_system_lock_domain`(
6953
	`in_domain_id` INT
6954
) RETURNS tinyint(1)
6955
BEGIN
6956
	declare cnt int default 0;
6957

    
6958
	select count(node.Id) into cnt from node where node.sub_system_domain_id=in_domain_id and node.complete='Y';
6959

    
6960
	if cnt > 0 then
6961
		return 0;
6962
	else
6963
		return 0;
6964
	end if;
6965
END//
6966
DELIMITER ;
6967

    
6968
-- 함수 nerv_icde_xxxx.check_system_lock_domainport 구조 내보내기
6969
DELIMITER //
6970
CREATE FUNCTION `check_system_lock_domainport`(
6971
	`in_node_id` INT,
6972
	`in_domain_id` INT,
6973
	`in_port_num` INT
6974
) RETURNS tinyint(1)
6975
BEGIN
6976

    
6977
	declare cnt int default 0;
6978

    
6979
	select count(b.d_node_id) into cnt from
6980
	(select * from domain_system_port where domain_system_port.domain_system_id=in_domain_id and domain_system_port.port_group in
6981
		(select port_group from domain_system_port where domain_system_port.domain_system_id=in_domain_id and domain_system_port.port_num=in_port_num))as a
6982
	join
6983
	(select * from network_link) as b on b.s_port_id = a.port_num and b.s_node_id = in_node_id and b.d_node_id = 0;
6984

    
6985
	if cnt > 0 then
6986
		return 0;
6987
	else
6988
		return 0;
6989
	end if; 
6990

    
6991
END//
6992
DELIMITER ;
6993

    
6994
-- 함수 nerv_icde_xxxx.check_system_lock_interface 구조 내보내기
6995
DELIMITER //
6996
CREATE FUNCTION `check_system_lock_interface`(
6997
	`in_domain_id` INT,
6998
	`in_interface_name` VARCHAR(50)
6999

    
7000
) RETURNS tinyint(1)
7001
BEGIN
7002

    
7003
		declare proxy_cnt int default 0;
7004
		declare stub_cnt int default 0;		
7005
		
7006
		select count(id) into proxy_cnt from custum_proxy where custum_proxy.public=1 and custum_proxy.proxy_interface_id in (
7007
			select id from proxy_interface_relation where proxy_interface_relation.method_domain_id=in_domain_id
7008
																 and proxy_interface_relation.interface_name =in_interface_name);
7009
																 
7010
	  select count(id) into stub_cnt from custum_stub where custum_stub.public=1 and custum_stub.stub_interface_id in (
7011
			select id from stub_interface_relation where stub_interface_relation.method_domain_id=in_domain_id
7012
																 and stub_interface_relation.interface_name =in_interface_name);
7013
		
7014
		
7015
	if proxy_cnt > 0 or stub_cnt > 0 then
7016
		return 0;
7017
	else
7018
		return 0;
7019
	end if; 
7020

    
7021
END//
7022
DELIMITER ;
7023

    
7024
-- 함수 nerv_icde_xxxx.check_system_lock_node_port_f 구조 내보내기
7025
DELIMITER //
7026
CREATE FUNCTION `check_system_lock_node_port_f`(
7027
	`in_node_id` INT,
7028
	`in_node_port` INT
7029
) RETURNS tinyint(1)
7030
BEGIN
7031

    
7032
	declare cnt int default 0;
7033
	select count(*) into cnt from node where node.complete='Y' and node.id in (
7034
		select node_id from network where network.original_node_id=in_node_id and network.original_node_port=in_node_port);
7035

    
7036
	if cnt > 0 then
7037
		return 0;
7038
	else
7039
		return 0;
7040
	end if; 
7041

    
7042
END//
7043
DELIMITER ;
7044

    
7045
-- 함수 nerv_icde_xxxx.check_system_lock_proxy_class 구조 내보내기
7046
DELIMITER //
7047
CREATE FUNCTION `check_system_lock_proxy_class`(
7048
	`in_proxy_id` INT
7049
) RETURNS tinyint(1)
7050
BEGIN
7051

    
7052
	declare cnt int default 0;
7053

    
7054
	
7055
	select count(*) into cnt from node where node.complete='y' and node.sub_system_domain_id in 
7056
		(select systemdomain_id from deployments where deployments.id in
7057
			(select deploy_id from custum_proxy where custum_proxy.proxy_interface_id = in_proxy_id and custum_proxy.public=1));
7058
	
7059
	
7060
		if cnt > 0 then
7061
		return 0;
7062
	else
7063
		return 0;
7064
	end if;
7065
END//
7066
DELIMITER ;
7067

    
7068
-- 함수 nerv_icde_xxxx.check_system_lock_proxy_object_f 구조 내보내기
7069
DELIMITER //
7070
CREATE FUNCTION `check_system_lock_proxy_object_f`(
7071
	`in_proxy_id` INT,
7072
	`in_proxy_object_name` VARCHAR(50)
7073
) RETURNS tinyint(1)
7074
BEGIN
7075

    
7076
declare cnt int default 0;
7077

    
7078
select count(*) into cnt from custum_proxy where proxy_interface_id=in_proxy_id and object_name=in_proxy_object_name and public=1;
7079

    
7080
if cnt > 0 then
7081
		return 0;
7082
	else
7083
		return 0;
7084
	end if;
7085
END//
7086
DELIMITER ;
7087

    
7088
-- 함수 nerv_icde_xxxx.check_system_lock_proxy_public 구조 내보내기
7089
DELIMITER //
7090
CREATE FUNCTION `check_system_lock_proxy_public`(
7091
	`in_custum_id` INT
7092
) RETURNS tinyint(1)
7093
BEGIN
7094
		declare cnt int default 0;
7095
		select count(id) into cnt from custum_proxy where custum_proxy.Id = in_custum_id and custum_proxy.public=1;
7096
		
7097
	if cnt > 0 then
7098
		return 0;
7099
	else
7100
		return 0;
7101
	end if; 
7102
END//
7103
DELIMITER ;
7104

    
7105
-- 함수 nerv_icde_xxxx.check_system_lock_stub_class_f 구조 내보내기
7106
DELIMITER //
7107
CREATE FUNCTION `check_system_lock_stub_class_f`(
7108
	`in_stub_id` INT
7109
) RETURNS tinyint(1)
7110
BEGIN
7111
	declare cnt int default 0;
7112

    
7113
	
7114
	select count(*) into cnt from node where node.complete='y' and node.sub_system_domain_id in 
7115
		(select systemdomain_id from deployments where deployments.id in
7116
			(select deploy_id from custum_stub where custum_stub.stub_interface_id = in_stub_id and custum_stub.public=1));
7117
	
7118
	
7119
		if cnt > 0 then
7120
		return 0;
7121
	else
7122
		return 0;
7123
	end if;
7124
END//
7125
DELIMITER ;
7126

    
7127
-- 함수 nerv_icde_xxxx.check_system_lock_stub_object_f 구조 내보내기
7128
DELIMITER //
7129
CREATE FUNCTION `check_system_lock_stub_object_f`(
7130
	`in_stub_id` INT,
7131
	`in_stub_object_name` VARCHAR(50)
7132
) RETURNS tinyint(1)
7133
BEGIN
7134

    
7135
declare cnt int default 0;
7136

    
7137
select count(*) into cnt from custum_stub where stub_interface_id=in_stub_id and object_name=in_stub_object_name and public=1;
7138

    
7139
if cnt > 0 then
7140
		return 0;
7141
	else
7142
		return 0;
7143
	end if;
7144
	
7145
END//
7146
DELIMITER ;
7147

    
7148
-- 함수 nerv_icde_xxxx.componentEntityCheck 구조 내보내기
7149
DELIMITER //
7150
CREATE FUNCTION `componentEntityCheck`(in_diagrameid int, in_component_id int) RETURNS tinyint(1)
7151
BEGIN
7152
        declare cnt int default 0;
7153
        select count(id) into cnt from umlcomponent where diagrame_id=in_diagrameid and component_id=in_component_id;
7154
        if cnt > 0 then
7155
                return 1;
7156
        else
7157
                return 0;
7158
        end if;
7159
END//
7160
DELIMITER ;
7161

    
7162
-- 함수 nerv_icde_xxxx.domainDataPath 구조 내보내기
7163
DELIMITER //
7164
CREATE FUNCTION `domainDataPath`(`in_domain_idkey` INT, `in_path` TEXT) RETURNS text CHARSET utf8
7165
BEGIN
7166

    
7167
	declare path varchar(50);
7168
	declare in_upper_id int default null;
7169
	declare in_name varchar(50) default null;
7170
	
7171
	 loop
7172
		select domain_data.upper_id into in_upper_id from domain_data where domain_data.id=in_domain_idkey;
7173
		select name into path from domain_data where id=in_domain_idkey;
7174
		
7175
		
7176
		 select (concat_WS('\\',path,in_path)) into in_path;
7177
		
7178
		 if in_upper_id=0 then
7179
		 	return in_path;
7180
		 end if;
7181
		
7182
		set in_domain_idkey=in_upper_id;
7183
	 end loop;
7184
		
7185
	
7186

    
7187
END//
7188
DELIMITER ;
7189

    
7190
-- 함수 nerv_icde_xxxx.domainManageTest 구조 내보내기
7191
DELIMITER //
7192
CREATE FUNCTION `domainManageTest`(domain_idkey int) RETURNS tinyint(1)
7193
BEGIN
7194
        declare sa varchar(100);
7195
        declare acount varchar(100);
7196
        declare pbc bool;
7197

    
7198
        set sa = '';
7199

    
7200
        if( supermanagerTest(@nervuser) ) then
7201
            return 1;
7202
        end if;
7203

    
7204
              select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
7205
               if( sa='manager' ) then
7206
                   return 1;
7207
               end if;
7208
               
7209
               select user_id into acount from domain_data where id=domain_idkey;
7210
               if(acount = @nervuser) then
7211
                    return 1;
7212
               end if;
7213
    
7214
               select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
7215
               if( sa='manager' ) then
7216
                   return 1;
7217
               end if;
7218
               select user_id into acount from domain_method where id=domain_idkey;
7219
               if(acount = @nervuser) then
7220
                    return 1;
7221
               end if;
7222
    
7223
               select member_type into sa from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
7224
               if( sa='manager' ) then
7225
                   return 1;
7226
               end if;
7227
               select user_id into acount from domain_system where id=domain_idkey;
7228
               if(acount = @nervuser) then
7229
                    return 1;
7230
               end if;
7231

    
7232

    
7233
        return 0;
7234
END//
7235
DELIMITER ;
7236

    
7237
-- 함수 nerv_icde_xxxx.domainMethodPath 구조 내보내기
7238
DELIMITER //
7239
CREATE FUNCTION `domainMethodPath`(`in_domain_idkey` INT, `in_path` TEXT) RETURNS text CHARSET utf8
7240
BEGIN
7241
	declare path varchar(50);
7242
	declare in_upper_id int default null;
7243
	declare in_name varchar(50) default null;
7244
	
7245
	 loop
7246
		select domain_method.upper_id into in_upper_id from domain_method where domain_method.id=in_domain_idkey;
7247
		select name into path from domain_method where id=in_domain_idkey;
7248
		
7249
		
7250
		 select (concat_WS('\\',path,in_path)) into in_path;
7251
		
7252
		 if in_upper_id=0 then
7253
		 	return in_path;
7254
		 end if;
7255
		
7256
		set in_domain_idkey=in_upper_id;
7257
	 end loop;
7258

    
7259
END//
7260
DELIMITER ;
7261

    
7262
-- 함수 nerv_icde_xxxx.domainReadTest 구조 내보내기
7263
DELIMITER //
7264
CREATE FUNCTION `domainReadTest`(domain_idkey int, domaintype varchar(50)) RETURNS tinyint(1)
7265
BEGIN
7266
        declare sa varchar(100);
7267
        declare acount varchar(100);
7268
        declare pbc bool;
7269
        set sa = '';
7270

    
7271

    
7272

    
7273
        if( supermanagerTest(@nervuser) ) then
7274
             return 1;
7275
        end if;
7276
        
7277
        if (domaintype = 'system') then
7278
           select member_type into sa from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
7279
        end if;
7280
        if (domaintype = 'method') then
7281
           select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
7282
        end if;
7283
        if (domaintype = 'data') then
7284
           select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
7285
        end if;
7286

    
7287
        if( sa='member' or sa='manager' ) then
7288
           return 1;
7289
        end if;
7290
        
7291
        
7292

    
7293
        if (domaintype = 'system') then
7294
           select user_id into acount from domain_system where id=domain_idkey;   
7295
        end if;
7296
        if (domaintype = 'method') then
7297
           select user_id into acount from domain_method where id=domain_idkey;   
7298
        end if;
7299
        if (domaintype = 'data') then
7300
           select user_id into acount from domain_data where id=domain_idkey;   
7301
        end if;
7302
        
7303
        if(acount = @nervuser) then
7304
           return 1;
7305
        end if;
7306
        
7307
        
7308

    
7309
        if (domaintype = 'system') then
7310
           select public into pbc from domain_system where id=domain_idkey;   
7311
        end if;
7312
        if (domaintype = 'method') then
7313
           select public into pbc from domain_method where id=domain_idkey;   
7314
        end if;
7315
        if (domaintype = 'data') then
7316
           select public into pbc from domain_data where id=domain_idkey;   
7317
        end if;
7318
        
7319
        if(pbc) then
7320
         return 1;
7321
        end if;
7322
        return 0;
7323
END//
7324
DELIMITER ;
7325

    
7326
-- 함수 nerv_icde_xxxx.domainSystemPath 구조 내보내기
7327
DELIMITER //
7328
CREATE FUNCTION `domainSystemPath`(`in_domain_idkey` INT, `in_path` TEXT) RETURNS text CHARSET utf8
7329
BEGIN
7330
	declare path varchar(50);
7331
	declare in_upper_id int default null;
7332
	declare in_name varchar(50) default null;
7333
	
7334
	 loop
7335
		select domain_system.upper_id into in_upper_id from domain_system where domain_system.id=in_domain_idkey;
7336
		select name into path from domain_system where id=in_domain_idkey;
7337
		
7338
		select (concat_WS('\\',path,in_path)) into in_path;
7339
		
7340
		 if in_upper_id=0 then
7341
		 	return in_path;
7342
		 end if;
7343
		
7344
		set in_domain_idkey=in_upper_id;
7345
	 end loop;
7346

    
7347
END//
7348
DELIMITER ;
7349

    
7350
-- 함수 nerv_icde_xxxx.domainWriteTest 구조 내보내기
7351
DELIMITER //
7352
CREATE FUNCTION `domainWriteTest`(domain_idkey int, domaintypevalue varchar(100)) RETURNS tinyint(1)
7353
BEGIN
7354
        declare sa varchar(100);
7355
        declare acount varchar(100);
7356
        
7357
           if( supermanagerTest(@nervuser) ) then
7358
             return 1;
7359
        end if;
7360
        
7361
        if domaintypevalue = 'data' then
7362
          select user_id into acount from members_domain_data where domain_id=domain_idkey;
7363
          if(acount = @nervuser) then
7364
              return 1;
7365
          end if;
7366
            select user_id into acount from domain_data where id = domain_idkey;
7367
            
7368
          
7369
        end if;
7370

    
7371
        if domaintypevalue = 'method' then
7372
          select user_id into acount from members_domain_method where domain_id=domain_idkey;
7373
          if(acount = @nervuser) then
7374
              return 1;
7375
          end if;
7376
          select user_id into acount from domain_method where id = domain_idkey;
7377
        end if;
7378
        
7379
        if domaintypevalue = 'system' then
7380
          select user_id into acount from members_domain_system where domain_id=domain_idkey;
7381
          if(acount = @nervuser) then
7382
              return 1;
7383
          end if;
7384
          select user_id into acount from domain_system where id = domain_idkey;
7385
        end if;
7386
                
7387
        if(acount = @nervuser) then
7388
              return 1;
7389
        end if;      
7390
        return 0;
7391
END//
7392
DELIMITER ;
7393

    
7394
-- 함수 nerv_icde_xxxx.existDomain 구조 내보내기
7395
DELIMITER //
7396
CREATE FUNCTION `existDomain`(`domainkey` int, `domaintypevalue` varchar(100)) RETURNS tinyint(1)
7397
BEGIN
7398
        declare cnt tinyint(1);
7399
        declare cnt_2 tinyint(1);
7400
        set cnt = 0;
7401
        
7402
        if(domaintypevalue = 'data') then
7403
             select count(*) into cnt from domain_data where id=domainkey;
7404
             return cnt;
7405
        end if;
7406
        if(domaintypevalue = 'method') then
7407
             select count(*) into cnt from domain_method where id=domainkey;
7408
             return cnt;
7409
             
7410
             
7411
        end if;
7412
        if(domaintypevalue = 'system') then
7413
             select count(*) into cnt from domain_system where id=domainkey;
7414
             return cnt;
7415
        end if;
7416
END//
7417
DELIMITER ;
7418

    
7419
-- 함수 nerv_icde_xxxx.existInterface 구조 내보내기
7420
DELIMITER //
7421
CREATE FUNCTION `existInterface`(domain_idkey int, interface_name varchar(100)) RETURNS tinyint(1)
7422
BEGIN
7423
        declare cnt tinyint(1);
7424
        set cnt = 0;
7425

    
7426
        select count(*) into cnt from interface where domain_id=domain_idkey and name=interface_name;
7427

    
7428
        return cnt;
7429
END//
7430
DELIMITER ;
7431

    
7432
-- 함수 nerv_icde_xxxx.existInterfaceMemberMethod 구조 내보내기
7433
DELIMITER //
7434
CREATE FUNCTION `existInterfaceMemberMethod`(domain_idkey int ,
7435
                                                                interfacekey varchar(100),
7436
                                                                methodnamekey varchar(100) ) RETURNS tinyint(1)
7437
BEGIN
7438
        declare cnt tinyint(1);
7439
        set cnt = 0;
7440

    
7441
        select count(*) into cnt from interface_member where domain_id=domain_idkey and interface=interfacekey and method_name=methodnamekey;
7442

    
7443
        return cnt;
7444
END//
7445
DELIMITER ;
7446

    
7447
-- 함수 nerv_icde_xxxx.existMemberDomain 구조 내보내기
7448
DELIMITER //
7449
CREATE FUNCTION `existMemberDomain`(in_domainid int, in_userid varchar(100), in_domaintype varchar(100) ) RETURNS tinyint(1)
7450
BEGIN
7451
        declare cnt tinyint(1);
7452
        set cnt = 0;
7453
        if(in_domaintype='data')then
7454
            select count(*) into cnt from members_domain_data where domain_id=in_domainid and user_id=in_userid;
7455
        end if;
7456
        if(in_domaintype='method')then
7457
            select count(*) into cnt from members_domain_method where domain_id=in_domainid and user_id=in_userid;
7458
        end if;
7459
        if(in_domaintype='system')then
7460
            select count(*) into cnt from members_domain_system where domain_id=in_domainid and user_id=in_userid;
7461
        end if;
7462

    
7463
        return cnt;
7464
END//
7465
DELIMITER ;
7466

    
7467
-- 함수 nerv_icde_xxxx.existMetadata 구조 내보내기
7468
DELIMITER //
7469
CREATE FUNCTION `existMetadata`(`in_data_auto_id_key` int) RETURNS tinyint(1)
7470
BEGIN
7471
        declare cnt tinyint(1);
7472
        set cnt = 0;
7473
        select count(*) into cnt from data where data.data_auto_id=in_data_auto_id_key;
7474

    
7475
        return cnt;
7476
END//
7477
DELIMITER ;
7478

    
7479
-- 함수 nerv_icde_xxxx.existMetadatafield 구조 내보내기
7480
DELIMITER //
7481
CREATE FUNCTION `existMetadatafield`(`domain_idkey` int, `metadata_name` varchar(100), `metadatafield_name` varchar(100) ) RETURNS tinyint(1)
7482
BEGIN
7483
        declare cnt tinyint(1);
7484
        declare data_auto_id_key int default null;
7485
        
7486
		  select data.data_auto_id into data_auto_id_key from data where data.domain_id=domain_idkey and data.name=metadata_name;
7487
		  
7488
        set cnt = 0;
7489
        select count(*) into cnt from data_field where data_field.data_auto_id=data_auto_id_key and member_name=metadatafield_name;
7490

    
7491
        return cnt;
7492
END//
7493
DELIMITER ;
7494

    
7495
-- 함수 nerv_icde_xxxx.existMethod 구조 내보내기
7496
DELIMITER //
7497
CREATE FUNCTION `existMethod`(domain_idkey int , method_name varchar(100) ) RETURNS tinyint(1)
7498
BEGIN
7499
        declare cnt tinyint(1);
7500
        set cnt = 0;
7501

    
7502
        select count(*) into cnt from method where domain_id=domain_idkey and name=method_name;
7503

    
7504
        return cnt;
7505
END//
7506
DELIMITER ;
7507

    
7508
-- 함수 nerv_icde_xxxx.exitDomainId 구조 내보내기
7509
DELIMITER //
7510
CREATE FUNCTION `exitDomainId`(in_domainname varchar(100), in_upperid varchar(100), in_domaintype varchar(100) ) RETURNS int(10) unsigned
7511
BEGIN
7512
        declare domain_id int unsigned;
7513
        set domain_id = 0;
7514
        
7515
        if(in_domaintype='data')then
7516
            select id into domain_id from domain_data where name=in_domainname and upper_id=in_upperid;            
7517
        end if;
7518
        if(in_domaintype='method')then
7519
            select id into domain_id from domain_method where name=in_domainname and upper_id=in_upperid;
7520
        end if;
7521
        if(in_domaintype='system')then
7522
            select id into domain_id from domain_system where name=in_domainname and upper_id=in_upperid;
7523
        end if;
7524

    
7525
        return domain_id;
7526
END//
7527
DELIMITER ;
7528

    
7529
-- 함수 nerv_icde_xxxx.inheritanceSystemMehtodParentOverlapCheck 구조 내보내기
7530
DELIMITER //
7531
CREATE FUNCTION `inheritanceSystemMehtodParentOverlapCheck`(domainkey int, parentdomainidkey int) RETURNS tinyint(1)
7532
BEGIN
7533
        declare cnt tinyint(1);
7534
        
7535
        set cnt = 0;
7536
              
7537
        select count(*) into cnt from inheritance_system_method where domain_id=domainkey and parent_domain_id=parentdomainidkey;
7538
        
7539
        if(cnt = 0) then
7540
            return 1;
7541
        end if;
7542
                
7543
         return 0;
7544
        
7545
END//
7546
DELIMITER ;
7547

    
7548
-- 함수 nerv_icde_xxxx.logical_port_group_count 구조 내보내기
7549
DELIMITER //
7550
CREATE FUNCTION `logical_port_group_count`(in_system_domain_id int, in_port_group int) RETURNS tinyint(1)
7551
BEGIN
7552
        declare cnt tinyint(1);
7553
        set cnt=0;
7554
        
7555
        select count(*) into cnt from domain_system_port where domain_system_id=in_system_domain_id and port_group=in_port_group;
7556
        return cnt;
7557
END//
7558
DELIMITER ;
7559

    
7560
-- 함수 nerv_icde_xxxx.loginTest 구조 내보내기
7561
DELIMITER //
7562
CREATE FUNCTION `loginTest`() RETURNS tinyint(1)
7563
BEGIN
7564
        declare cnt int default 0;
7565
        select count(user_id) into cnt from users where user_id=@nervuser and password = password(@nervpassword);
7566
        if cnt > 0 then
7567
                return 1;
7568
        else
7569
                return 0;
7570
        end if;
7571
END//
7572
DELIMITER ;
7573

    
7574
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest 구조 내보내기
7575
DELIMITER //
7576
CREATE FUNCTION `method_domainCompatibleTest`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7577
BEGIN
7578
        declare cnt int;
7579
        declare itor int default 0;
7580
        declare pdomain int;
7581
        
7582
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7583
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7584

    
7585
        
7586
        if( domain_idkey = parent_domain_idkey) then
7587
            return 1;
7588
        end if;
7589
        
7590
        open cur1;
7591
        set itor = 0;
7592
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7593
        while itor < cnt do
7594
            fetch cur1 into pdomain;
7595
            if( !method_domainCompatibleTest_depth_0( parent_domain_idkey , pdomain,depth+1) ) then
7596
                 close cur1;
7597
                 return 0;
7598
            end if;
7599
            set itor = itor + 1;
7600
        end while;
7601
        close cur1;
7602

    
7603
        open cur2;
7604
        set itor = 0;
7605
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7606
        while itor < cnt do
7607
            fetch cur2 into pdomain;
7608
            if( !method_domainCompatibleTest_depth_0( domain_idkey , pdomain,depth+1) ) then
7609
                    close cur2;
7610
                    return 0;
7611
            end if;
7612
            set itor = itor + 1;
7613
        end while;
7614
        close cur2;
7615

    
7616
        select count(*) into cnt from
7617
            (select type,code from method where domain_id=domain_idkey) as a
7618
            join
7619
            (select type,code from method where domain_id=parent_domain_idkey) as b
7620
            on a.type=b.type and a.code = b.code;
7621

    
7622
         if( cnt > 0) then
7623
            return 0;
7624
         end if;
7625
         
7626
         return 1;
7627
END//
7628
DELIMITER ;
7629

    
7630
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_0 구조 내보내기
7631
DELIMITER //
7632
CREATE FUNCTION `method_domainCompatibleTest_depth_0`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7633
BEGIN
7634
        declare cnt int;
7635
        declare itor int default 0;
7636
        declare pdomain int;
7637
        
7638
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7639
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7640

    
7641
        
7642
        if( domain_idkey = parent_domain_idkey) then
7643
            return 1;
7644
        end if;
7645
        
7646
        open cur1;
7647
        set itor = 0;
7648
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7649
        while itor < cnt do
7650
            fetch cur1 into pdomain;
7651
            if( !method_domainCompatibleTest_depth_1( parent_domain_idkey , pdomain,depth+1) ) then
7652
                 close cur1;
7653
                 return 0;
7654
            end if;
7655
            set itor = itor + 1;
7656
        end while;
7657
        close cur1;
7658

    
7659
        open cur2;
7660
        set itor = 0;
7661
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7662
        while itor < cnt do
7663
            fetch cur2 into pdomain;
7664
            if( !method_domainCompatibleTest_depth_1( domain_idkey , pdomain,depth+1) ) then
7665
                    close cur2;
7666
                    return 0;
7667
            end if;
7668
            set itor = itor + 1;
7669
        end while;
7670
        close cur2;
7671

    
7672
        select count(*) into cnt from
7673
            (select type,code from method where domain_id=domain_idkey) as a
7674
            join
7675
            (select type,code from method where domain_id=parent_domain_idkey) as b
7676
            on a.type=b.type and a.code = b.code;
7677

    
7678
         if( cnt > 0) then
7679
            return 0;
7680
         end if;
7681
         
7682
         return 1;
7683
END//
7684
DELIMITER ;
7685

    
7686
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_1 구조 내보내기
7687
DELIMITER //
7688
CREATE FUNCTION `method_domainCompatibleTest_depth_1`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7689
BEGIN
7690
        declare cnt int;
7691
        declare itor int default 0;
7692
        declare pdomain int;
7693
        
7694
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7695
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7696

    
7697
        
7698
        if( domain_idkey = parent_domain_idkey) then
7699
            return 1;
7700
        end if;
7701
        
7702
        open cur1;
7703
        set itor = 0;
7704
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7705
        while itor < cnt do
7706
            fetch cur1 into pdomain;
7707
            if( !method_domainCompatibleTest_depth_2( parent_domain_idkey , pdomain,depth+1) ) then
7708
                 close cur1;
7709
                 return 0;
7710
            end if;
7711
            set itor = itor + 1;
7712
        end while;
7713
        close cur1;
7714

    
7715
        open cur2;
7716
        set itor = 0;
7717
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7718
        while itor < cnt do
7719
            fetch cur2 into pdomain;
7720
            if( !method_domainCompatibleTest_depth_2( domain_idkey , pdomain,depth+1) ) then
7721
                    close cur2;
7722
                    return 0;
7723
            end if;
7724
            set itor = itor + 1;
7725
        end while;
7726
        close cur2;
7727

    
7728
        select count(*) into cnt from
7729
            (select type,code from method where domain_id=domain_idkey) as a
7730
            join
7731
            (select type,code from method where domain_id=parent_domain_idkey) as b
7732
            on a.type=b.type and a.code = b.code;
7733

    
7734
         if( cnt > 0) then
7735
            return 0;
7736
         end if;
7737
         
7738
         return 1;
7739
END//
7740
DELIMITER ;
7741

    
7742
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_10 구조 내보내기
7743
DELIMITER //
7744
CREATE FUNCTION `method_domainCompatibleTest_depth_10`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7745
BEGIN
7746
        declare cnt int;
7747
        declare itor int default 0;
7748
        declare pdomain int;
7749
        
7750
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7751
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7752

    
7753
        
7754
        if( domain_idkey = parent_domain_idkey) then
7755
            return 1;
7756
        end if;
7757
        
7758
        open cur1;
7759
        set itor = 0;
7760
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7761
        while itor < cnt do
7762
            fetch cur1 into pdomain;
7763
            if( !method_domainCompatibleTest_depth_1( parent_domain_idkey , pdomain,depth+1) ) then
7764
                 close cur1;
7765
                 return 0;
7766
            end if;
7767
            set itor = itor + 1;
7768
        end while;
7769
        close cur1;
7770

    
7771
        open cur2;
7772
        set itor = 0;
7773
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7774
        while itor < cnt do
7775
            fetch cur2 into pdomain;
7776
            if( !method_domainCompatibleTest_depth_1( domain_idkey , pdomain,depth+1) ) then
7777
                    close cur2;
7778
                    return 0;
7779
            end if;
7780
            set itor = itor + 1;
7781
        end while;
7782
        close cur2;
7783

    
7784
        select count(*) into cnt from
7785
            (select type,code from method where domain_id=domain_idkey) as a
7786
            join
7787
            (select type,code from method where domain_id=parent_domain_idkey) as b
7788
            on a.type=b.type and a.code = b.code;
7789

    
7790
         if( cnt > 0) then
7791
            return 0;
7792
         end if;
7793
         
7794
         return 1;
7795
END//
7796
DELIMITER ;
7797

    
7798
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_2 구조 내보내기
7799
DELIMITER //
7800
CREATE FUNCTION `method_domainCompatibleTest_depth_2`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7801
BEGIN
7802
        declare cnt int;
7803
        declare itor int default 0;
7804
        declare pdomain int;
7805
        
7806
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7807
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7808

    
7809
        
7810
        if( domain_idkey = parent_domain_idkey) then
7811
            return 1;
7812
        end if;
7813
        
7814
        open cur1;
7815
        set itor = 0;
7816
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7817
        while itor < cnt do
7818
            fetch cur1 into pdomain;
7819
            if( !method_domainCompatibleTest_depth_3( parent_domain_idkey , pdomain,depth+1) ) then
7820
                 close cur1;
7821
                 return 0;
7822
            end if;
7823
            set itor = itor + 1;
7824
        end while;
7825
        close cur1;
7826

    
7827
        open cur2;
7828
        set itor = 0;
7829
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7830
        while itor < cnt do
7831
            fetch cur2 into pdomain;
7832
            if( !method_domainCompatibleTest_depth_3( domain_idkey , pdomain,depth+1) ) then
7833
                    close cur2;
7834
                    return 0;
7835
            end if;
7836
            set itor = itor + 1;
7837
        end while;
7838
        close cur2;
7839

    
7840
        select count(*) into cnt from
7841
            (select type,code from method where domain_id=domain_idkey) as a
7842
            join
7843
            (select type,code from method where domain_id=parent_domain_idkey) as b
7844
            on a.type=b.type and a.code = b.code;
7845

    
7846
         if( cnt > 0) then
7847
            return 0;
7848
         end if;
7849
         
7850
         return 1;
7851
END//
7852
DELIMITER ;
7853

    
7854
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_3 구조 내보내기
7855
DELIMITER //
7856
CREATE FUNCTION `method_domainCompatibleTest_depth_3`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7857
BEGIN
7858
        declare cnt int;
7859
        declare itor int default 0;
7860
        declare pdomain int;
7861
        
7862
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7863
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7864

    
7865
        
7866
        if( domain_idkey = parent_domain_idkey) then
7867
            return 1;
7868
        end if;
7869
        
7870
        open cur1;
7871
        set itor = 0;
7872
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7873
        while itor < cnt do
7874
            fetch cur1 into pdomain;
7875
            if( !method_domainCompatibleTest_depth_4( parent_domain_idkey , pdomain,depth+1) ) then
7876
                 close cur1;
7877
                 return 0;
7878
            end if;
7879
            set itor = itor + 1;
7880
        end while;
7881
        close cur1;
7882

    
7883
        open cur2;
7884
        set itor = 0;
7885
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7886
        while itor < cnt do
7887
            fetch cur2 into pdomain;
7888
            if( !method_domainCompatibleTest_depth_4( domain_idkey , pdomain,depth+1) ) then
7889
                    close cur2;
7890
                    return 0;
7891
            end if;
7892
            set itor = itor + 1;
7893
        end while;
7894
        close cur2;
7895

    
7896
        select count(*) into cnt from
7897
            (select type,code from method where domain_id=domain_idkey) as a
7898
            join
7899
            (select type,code from method where domain_id=parent_domain_idkey) as b
7900
            on a.type=b.type and a.code = b.code;
7901

    
7902
         if( cnt > 0) then
7903
            return 0;
7904
         end if;
7905
         
7906
         return 1;
7907
END//
7908
DELIMITER ;
7909

    
7910
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_4 구조 내보내기
7911
DELIMITER //
7912
CREATE FUNCTION `method_domainCompatibleTest_depth_4`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7913
BEGIN
7914
        declare cnt int;
7915
        declare itor int default 0;
7916
        declare pdomain int;
7917
        
7918
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7919
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7920

    
7921
        
7922
        if( domain_idkey = parent_domain_idkey) then
7923
            return 1;
7924
        end if;
7925
        
7926
        open cur1;
7927
        set itor = 0;
7928
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7929
        while itor < cnt do
7930
            fetch cur1 into pdomain;
7931
            if( !method_domainCompatibleTest_depth_5( parent_domain_idkey , pdomain,depth+1) ) then
7932
                 close cur1;
7933
                 return 0;
7934
            end if;
7935
            set itor = itor + 1;
7936
        end while;
7937
        close cur1;
7938

    
7939
        open cur2;
7940
        set itor = 0;
7941
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7942
        while itor < cnt do
7943
            fetch cur2 into pdomain;
7944
            if( !method_domainCompatibleTest_depth_5( domain_idkey , pdomain,depth+1) ) then
7945
                    close cur2;
7946
                    return 0;
7947
            end if;
7948
            set itor = itor + 1;
7949
        end while;
7950
        close cur2;
7951

    
7952
        select count(*) into cnt from
7953
            (select type,code from method where domain_id=domain_idkey) as a
7954
            join
7955
            (select type,code from method where domain_id=parent_domain_idkey) as b
7956
            on a.type=b.type and a.code = b.code;
7957

    
7958
         if( cnt > 0) then
7959
            return 0;
7960
         end if;
7961
         
7962
         return 1;
7963
END//
7964
DELIMITER ;
7965

    
7966
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_5 구조 내보내기
7967
DELIMITER //
7968
CREATE FUNCTION `method_domainCompatibleTest_depth_5`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7969
BEGIN
7970
        declare cnt int;
7971
        declare itor int default 0;
7972
        declare pdomain int;
7973
        
7974
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7975
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7976

    
7977
        
7978
        if( domain_idkey = parent_domain_idkey) then
7979
            return 1;
7980
        end if;
7981
        
7982
        open cur1;
7983
        set itor = 0;
7984
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7985
        while itor < cnt do
7986
            fetch cur1 into pdomain;                   
7987
            if( !method_domainCompatibleTest_depth_6( parent_domain_idkey , pdomain,depth+1) ) then
7988
                 close cur1;
7989
                 return 0;
7990
            end if;
7991
            set itor = itor + 1;
7992
        end while;
7993
        close cur1;
7994

    
7995
        open cur2;
7996
        set itor = 0;
7997
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7998
        while itor < cnt do
7999
            fetch cur2 into pdomain;
8000
            if( !method_domainCompatibleTest_depth_6( domain_idkey , pdomain,depth+1) ) then
8001
                    close cur2;
8002
                    return 0;
8003
            end if;
8004
            set itor = itor + 1;
8005
        end while;
8006
        close cur2;
8007

    
8008
        select count(*) into cnt from
8009
            (select type,code from method where domain_id=domain_idkey) as a
8010
            join
8011
            (select type,code from method where domain_id=parent_domain_idkey) as b
8012
            on a.type=b.type and a.code = b.code;
8013

    
8014
         if( cnt > 0) then
8015
            return 0;
8016
         end if;
8017
         
8018
         return 1;
8019
END//
8020
DELIMITER ;
8021

    
8022
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_6 구조 내보내기
8023
DELIMITER //
8024
CREATE FUNCTION `method_domainCompatibleTest_depth_6`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8025
BEGIN
8026
        declare cnt int;
8027
        declare itor int default 0;
8028
        declare pdomain int;
8029
        
8030
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8031
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8032

    
8033
        
8034
        if( domain_idkey = parent_domain_idkey) then
8035
            return 1;
8036
        end if;
8037
        
8038
        open cur1;
8039
        set itor = 0;
8040
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8041
        while itor < cnt do
8042
            fetch cur1 into pdomain;                   
8043
            if( !method_domainCompatibleTest_depth_7( parent_domain_idkey , pdomain,depth+1) ) then
8044
                 close cur1;
8045
                 return 0;
8046
            end if;
8047
            set itor = itor + 1;
8048
        end while;
8049
        close cur1;
8050

    
8051
        open cur2;
8052
        set itor = 0;
8053
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8054
        while itor < cnt do
8055
            fetch cur2 into pdomain;
8056
            if( !method_domainCompatibleTest_depth_7( domain_idkey , pdomain,depth+1) ) then
8057
                    close cur2;
8058
                    return 0;
8059
            end if;
8060
            set itor = itor + 1;
8061
        end while;
8062
        close cur2;
8063

    
8064
        select count(*) into cnt from
8065
            (select type,code from method where domain_id=domain_idkey) as a
8066
            join
8067
            (select type,code from method where domain_id=parent_domain_idkey) as b
8068
            on a.type=b.type and a.code = b.code;
8069

    
8070
         if( cnt > 0) then
8071
            return 0;
8072
         end if;
8073
         
8074
         return 1;
8075
END//
8076
DELIMITER ;
8077

    
8078
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_7 구조 내보내기
8079
DELIMITER //
8080
CREATE FUNCTION `method_domainCompatibleTest_depth_7`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8081
BEGIN
8082
        declare cnt int;
8083
        declare itor int default 0;
8084
        declare pdomain int;
8085
        
8086
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8087
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8088

    
8089
        
8090
        if( domain_idkey = parent_domain_idkey) then
8091
            return 1;
8092
        end if;
8093
        
8094
        open cur1;
8095
        set itor = 0;
8096
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8097
        while itor < cnt do
8098
            fetch cur1 into pdomain;
8099
            if( !method_domainCompatibleTest_depth_8( parent_domain_idkey , pdomain,depth+1) ) then
8100
                 close cur1;
8101
                 return 0;
8102
            end if;
8103
            set itor = itor + 1;
8104
        end while;
8105
        close cur1;
8106

    
8107
        open cur2;
8108
        set itor = 0;
8109
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8110
        while itor < cnt do
8111
            fetch cur2 into pdomain;
8112
            if( !method_domainCompatibleTest_depth_8( domain_idkey , pdomain,depth+1) ) then
8113
                    close cur2;
8114
                    return 0;
8115
            end if;
8116
            set itor = itor + 1;
8117
        end while;
8118
        close cur2;
8119

    
8120
        select count(*) into cnt from
8121
            (select type,code from method where domain_id=domain_idkey) as a
8122
            join
8123
            (select type,code from method where domain_id=parent_domain_idkey) as b
8124
            on a.type=b.type and a.code = b.code;
8125

    
8126
         if( cnt > 0) then
8127
            return 0;
8128
         end if;
8129
         
8130
         return 1;
8131
END//
8132
DELIMITER ;
8133

    
8134
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_8 구조 내보내기
8135
DELIMITER //
8136
CREATE FUNCTION `method_domainCompatibleTest_depth_8`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8137
BEGIN
8138
        declare cnt int;
8139
        declare itor int default 0;
8140
        declare pdomain int;
8141
        
8142
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8143
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8144

    
8145
        
8146
        if( domain_idkey = parent_domain_idkey) then
8147
            return 1;
8148
        end if;
8149
        
8150
        open cur1;
8151
        set itor = 0;
8152
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8153
        while itor < cnt do
8154
            fetch cur1 into pdomain;                   
8155
            if( !method_domainCompatibleTest_depth_9( parent_domain_idkey , pdomain,depth+1) ) then
8156
                 close cur1;
8157
                 return 0;
8158
            end if;
8159
            set itor = itor + 1;
8160
        end while;
8161
        close cur1;
8162

    
8163
        open cur2;
8164
        set itor = 0;
8165
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8166
        while itor < cnt do
8167
            fetch cur2 into pdomain;
8168
            if( !method_domainCompatibleTest_depth_9( domain_idkey , pdomain,depth+1) ) then
8169
                    close cur2;
8170
                    return 0;
8171
            end if;
8172
            set itor = itor + 1;
8173
        end while;
8174
        close cur2;
8175

    
8176
        select count(*) into cnt from
8177
            (select type,code from method where domain_id=domain_idkey) as a
8178
            join
8179
            (select type,code from method where domain_id=parent_domain_idkey) as b
8180
            on a.type=b.type and a.code = b.code;
8181

    
8182
         if( cnt > 0) then
8183
            return 0;
8184
         end if;
8185
         
8186
         return 1;
8187
END//
8188
DELIMITER ;
8189

    
8190
-- 함수 nerv_icde_xxxx.method_domainCompatibleTest_depth_9 구조 내보내기
8191
DELIMITER //
8192
CREATE FUNCTION `method_domainCompatibleTest_depth_9`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8193
BEGIN
8194
        declare cnt int;
8195
        declare itor int default 0;
8196
        declare pdomain int;
8197
        
8198
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8199
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8200

    
8201
        
8202
        if( domain_idkey = parent_domain_idkey) then
8203
            return 1;
8204
        end if;
8205
        
8206
        open cur1;
8207
        set itor = 0;
8208
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8209
        while itor < cnt do
8210
            fetch cur1 into pdomain;                   
8211
            if( !method_domainCompatibleTest_depth_10( parent_domain_idkey , pdomain,depth+1) ) then
8212
                 close cur1;
8213
                 return 0;
8214
            end if;
8215
            set itor = itor + 1;
8216
        end while;
8217
        close cur1;
8218

    
8219
        open cur2;
8220
        set itor = 0;
8221
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8222
        while itor < cnt do
8223
            fetch cur2 into pdomain;
8224
            if( !method_domainCompatibleTest_depth_10( domain_idkey , pdomain,depth+1) ) then
8225
                    close cur2;
8226
                    return 0;
8227
            end if;
8228
            set itor = itor + 1;
8229
        end while;
8230
        close cur2;
8231

    
8232
        select count(*) into cnt from
8233
            (select type,code from method where domain_id=domain_idkey) as a
8234
            join
8235
            (select type,code from method where domain_id=parent_domain_idkey) as b
8236
            on a.type=b.type and a.code = b.code;
8237

    
8238
         if( cnt > 0) then
8239
            return 0;
8240
         end if;
8241
         
8242
         return 1;
8243
END//
8244
DELIMITER ;
8245

    
8246
-- 함수 nerv_icde_xxxx.newDomainTest 구조 내보내기
8247
DELIMITER //
8248
CREATE FUNCTION `newDomainTest`() RETURNS tinyint(1)
8249
BEGIN
8250
        declare nd bool;
8251
        set nd = false;
8252
        select newdomain into nd from users where user_id=@nervuser;
8253
        return nd;
8254
END//
8255
DELIMITER ;
8256

    
8257
-- 함수 nerv_icde_xxxx.return_domainid 구조 내보내기
8258
DELIMITER //
8259
CREATE FUNCTION `return_domainid`(in_domainname int, in_upperid int, in_domaintype varchar(100)) RETURNS int(1)
8260
BEGIN
8261
        declare cnt int(1);
8262
        set cnt = 0;
8263
        
8264
        if(in_domaintype ='data') then
8265
                         select id into cnt from domain_data where name=in_domainname and upper_id=in_upperid;
8266
        end if;
8267
        if(in_domaintype ='method') then
8268
                         select id into cnt from domain_method where name=in_domainname and upper_id=in_upperid;
8269
        end if;
8270
                if(in_domaintype ='system') then
8271
                         select id into cnt from domain_system where name=in_domainname and upper_id=in_upperid;
8272
        end if;
8273
        
8274
        return cnt;
8275
END//
8276
DELIMITER ;
8277

    
8278
-- 함수 nerv_icde_xxxx.return_proxy_interface id 구조 내보내기
8279
DELIMITER //
8280
CREATE FUNCTION `return_proxy_interface id`(in_component_id int unsigned, in_method_domain_id int unsigned, in_interface_name varchar(100), in_class_name varchar(255)) RETURNS int(10) unsigned
8281
BEGIN
8282
        declare interface_key_id int unsigned;
8283
        set interface_key_id=0;
8284
      
8285
        select count(*) into interface_key_id from proxy_interface_relation
8286
         where component_id=in_component_id and method_domain_id=in_method_domain_id and interface_name=in_interface_name and class_name=in_class_name;
8287
      
8288
      if interface_key_id>0 then     
8289
        return 1;
8290
      else
8291
          return 0;
8292
      end if;
8293
END//
8294
DELIMITER ;
8295

    
8296
-- 함수 nerv_icde_xxxx.supermanagerTest 구조 내보내기
8297
DELIMITER //
8298
CREATE FUNCTION `supermanagerTest`(useridkey varchar(100)) RETURNS tinyint(1)
8299
BEGIN
8300
        declare sm bool;
8301
        select supermanager into sm from users where user_id=useridkey;
8302
        return sm;
8303
END//
8304
DELIMITER ;
8305

    
8306
-- 함수 nerv_icde_xxxx.updata_data_real_data_auto_id 구조 내보내기
8307
DELIMITER //
8308
CREATE FUNCTION `updata_data_real_data_auto_id`() RETURNS int(11)
8309
BEGIN
8310

    
8311
update data d,
8312
(select a.data_auto_id as auto_id, b.data_auto_id from
8313
	(select data_auto_id, domain_id, name,real_data_auto_id, real_domain_id, real_data from data where data.real_domain_id != 0) as a
8314
	join 
8315
	(select data_auto_id, domain_id, name from data) as b on a.real_domain_id=b.domain_id and a.real_data=b.name
8316
)as f
8317
set d.real_data_auto_id = f.data_auto_id
8318
where d.data_auto_id = f.auto_id;
8319

    
8320
return 0;
8321
END//
8322
DELIMITER ;
8323

    
8324
-- 함수 nerv_icde_xxxx.update_data_field_table_data_auto_id 구조 내보내기
8325
DELIMITER //
8326
CREATE FUNCTION `update_data_field_table_data_auto_id`() RETURNS int(11)
8327
BEGIN
8328
update data_field d,
8329
(select a.domain_id, a.data_name as name, b.data_auto_id as data_id from
8330
	(select * from data_field) as a
8331
	join
8332
	(select data.data_auto_id,data.domain_id,data.name from data) as b on a.domain_id=b.domain_id and a.data_name=b.name
8333
)as f
8334
set d.data_auto_id=f.data_id
8335
where d.domain_id=f.domain_id and d.data_name=f.name;
8336

    
8337
return 0;
8338
END//
8339
DELIMITER ;
8340

    
8341
-- 함수 nerv_icde_xxxx.update_data_field_table_real_data_id 구조 내보내기
8342
DELIMITER //
8343
CREATE FUNCTION `update_data_field_table_real_data_id`() RETURNS int(11)
8344
BEGIN
8345

    
8346
 update data_field d,
8347
 (
8348
	select a.data_auto_id, a.member_name,b.data_auto_id as data_id from
8349
	(select * from data_field) as a
8350
	join
8351
	(select data.data_auto_id,data.domain_id,data.name from data) as b on a.real_domain=b.domain_id and a.real_data=b.name
8352
 )as f
8353
 	set d.real_data_auto_id=f.data_id
8354
 	where d.data_auto_id=f.data_auto_id and d.member_name=f.member_name;
8355
 	
8356
 	return 0;
8357
END//
8358
DELIMITER ;
8359

    
8360
-- 함수 nerv_icde_xxxx.update_method_table_data_auto_id 구조 내보내기
8361
DELIMITER //
8362
CREATE FUNCTION `update_method_table_data_auto_id`() RETURNS int(11)
8363
BEGIN
8364

    
8365
update method c,
8366
 (
8367
	select a.domain_id as method_domain_id,a.name as method_name, a.in_domain_id, a.in_data, b.* from
8368
	(select * from method) as a
8369
	join
8370
	(select data.data_auto_id, data.domain_id, data.name from data) as b on a.in_domain_id=b.domain_id and a.in_data=b.name
8371
 )as f
8372
 set c.in_data_auto_id=f.data_auto_id
8373
 where c.domain_id=f.method_domain_id and c.name=f.method_name ;
8374

    
8375

    
8376
 update method c,
8377
 (
8378
	select a.domain_id as method_domain_id,a.name as method_name, a.out_domain_id, a.out_data, b.* from
8379
	(select * from method) as a
8380
	join
8381
	(select data.data_auto_id, data.domain_id, data.name from data) as b on a.out_domain_id=b.domain_id and a.out_data=b.name
8382
 )as f
8383
 set c.out_data_auto_id=f.data_auto_id
8384
 where c.domain_id=f.method_domain_id and c.name=f.method_name ;
8385
 
8386
 return 0;
8387
 
8388
END//
8389
DELIMITER ;
8390

    
8391
-- 뷰 nerv_icde_xxxx.view_a 구조 내보내기
8392
-- 임시 테이블을 제거하고 최종 VIEW 구조를 생성
8393
DROP TABLE IF EXISTS `view_a`;
8394
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `view_a` AS select `network_link`.`s_node_id` AS `s_node_id`,`network_link`.`s_sub_system_id` AS `s_sub_system_id`,`network_link`.`s_port_id` AS `s_port_id`,`network_link`.`d_node_id` AS `d_node_id`,`network_link`.`d_sub_system_id` AS `d_sub_system_id`,`network_link`.`d_port_id` AS `d_port_id` from `network_link` where `network_link`.`d_sub_system_id` in (select `node`.`sub_system_domain_id` from `node` where (`node`.`Id` = 165));
8395

    
8396
-- 뷰 nerv_icde_xxxx.view_b 구조 내보내기
8397
-- 임시 테이블을 제거하고 최종 VIEW 구조를 생성
8398
DROP TABLE IF EXISTS `view_b`;
8399
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `view_b` AS select `network_link`.`s_node_id` AS `s_node_id`,`network_link`.`s_sub_system_id` AS `s_sub_system_id`,`network_link`.`s_port_id` AS `s_port_id`,`network_link`.`d_node_id` AS `d_node_id`,`network_link`.`d_sub_system_id` AS `d_sub_system_id`,`network_link`.`d_port_id` AS `d_port_id` from `network_link` where `network_link`.`d_sub_system_id` in (select `node`.`sub_system_domain_id` from `node` where (`node`.`Id` = 165));
8400

    
8401
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
8402
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
8403
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
(1-1/3)