프로젝트

일반

사용자정보

Nerv ICDE » nerv_icde_install_20210107.sql

이용우, 2021/01/06 22:28

 
1
-- --------------------------------------------------------
2
-- 호스트:                          127.0.0.1
3
-- 서버 버전:                        5.5.62 - MySQL Community Server (GPL)
4
-- 서버 OS:                        Win64
5
-- HeidiSQL 버전:                  11.1.0.6116
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
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
14

    
15

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

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

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

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

    
59
-- 테이블 데이터 nerv_icde_test.custum_proxy:~0 rows (대략적) 내보내기
60
DELETE FROM `custum_proxy`;
61
/*!40000 ALTER TABLE `custum_proxy` DISABLE KEYS */;
62
/*!40000 ALTER TABLE `custum_proxy` ENABLE KEYS */;
63

    
64
-- 테이블 nerv_icde_test.custum_stub 구조 내보내기
65
DROP TABLE IF EXISTS `custum_stub`;
66
CREATE TABLE IF NOT EXISTS `custum_stub` (
67
  `Id` int(11) NOT NULL AUTO_INCREMENT,
68
  `deploy_id` int(11) unsigned NOT NULL,
69
  `stub_interface_id` int(10) unsigned NOT NULL,
70
  `object_name` varchar(100) NOT NULL,
71
  `object_id` int(11) unsigned DEFAULT '0',
72
  `public` int(11) unsigned NOT NULL DEFAULT '0',
73
  `original_id` int(11) unsigned NOT NULL DEFAULT '0',
74
  `original_deployment_id` int(11) NOT NULL DEFAULT '0',
75
  PRIMARY KEY (`Id`),
76
  KEY `FK_custum_stub_deployments` (`deploy_id`),
77
  KEY `FK_custum_stub_stub_interface_object` (`stub_interface_id`,`object_name`),
78
  CONSTRAINT `FK_custum_stub_deployments` FOREIGN KEY (`deploy_id`) REFERENCES `deployments` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
79
  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
80
) ENGINE=InnoDB AUTO_INCREMENT=1401 DEFAULT CHARSET=utf8;
81

    
82
-- 테이블 데이터 nerv_icde_test.custum_stub:~0 rows (대략적) 내보내기
83
DELETE FROM `custum_stub`;
84
/*!40000 ALTER TABLE `custum_stub` DISABLE KEYS */;
85
/*!40000 ALTER TABLE `custum_stub` ENABLE KEYS */;
86

    
87
-- 테이블 nerv_icde_test.data 구조 내보내기
88
DROP TABLE IF EXISTS `data`;
89
CREATE TABLE IF NOT EXISTS `data` (
90
  `data_auto_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
91
  `domain_id` int(10) unsigned NOT NULL,
92
  `name` varchar(100) NOT NULL,
93
  `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,
94
  `real_data_auto_id` int(10) unsigned DEFAULT NULL,
95
  `scmin` varchar(100) NOT NULL DEFAULT '',
96
  `scmax` varchar(100) NOT NULL DEFAULT '',
97
  `seq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
98
  `description` mediumtext NOT NULL,
99
  `user_id` varchar(45) NOT NULL,
100
  `depth` int(10) unsigned NOT NULL DEFAULT '0',
101
  PRIMARY KEY (`data_auto_id`),
102
  UNIQUE KEY `domain_id_name` (`domain_id`,`name`),
103
  KEY `FK_data_data` (`real_data_auto_id`),
104
  KEY `type` (`type`),
105
  CONSTRAINT `FK_data_data` FOREIGN KEY (`real_data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE SET NULL ON UPDATE CASCADE,
106
  CONSTRAINT `FK_data_domain_data` FOREIGN KEY (`domain_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
107
) ENGINE=InnoDB AUTO_INCREMENT=528 DEFAULT CHARSET=utf8;
108

    
109
-- 테이블 데이터 nerv_icde_test.data:~0 rows (대략적) 내보내기
110
DELETE FROM `data`;
111
/*!40000 ALTER TABLE `data` DISABLE KEYS */;
112
/*!40000 ALTER TABLE `data` ENABLE KEYS */;
113

    
114
-- 테이블 nerv_icde_test.data_field 구조 내보내기
115
DROP TABLE IF EXISTS `data_field`;
116
CREATE TABLE IF NOT EXISTS `data_field` (
117
  `data_auto_id` int(10) unsigned NOT NULL DEFAULT '0',
118
  `member_name` varchar(100) NOT NULL,
119
  `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,
120
  `real_data_auto_id` int(10) unsigned DEFAULT NULL,
121
  `user_id` varchar(45) NOT NULL,
122
  `bitsize` int(10) unsigned DEFAULT '0',
123
  `scimin` varchar(100) DEFAULT '''''',
124
  `scimax` varchar(100) DEFAULT '''''',
125
  `arraytype` enum('NO','FIX','VARIABLE') NOT NULL DEFAULT 'NO',
126
  `arraysize` int(11) unsigned NOT NULL DEFAULT '0',
127
  `seq` int(11) NOT NULL AUTO_INCREMENT,
128
  `description` mediumtext NOT NULL,
129
  PRIMARY KEY (`data_auto_id`,`member_name`),
130
  KEY `FK_data_field_data_2` (`real_data_auto_id`),
131
  KEY `type` (`type`),
132
  KEY `seq` (`seq`),
133
  CONSTRAINT `FK_data_field_data` FOREIGN KEY (`data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE CASCADE ON UPDATE CASCADE,
134
  CONSTRAINT `FK_data_field_data_2` FOREIGN KEY (`real_data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE SET NULL ON UPDATE CASCADE
135
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
136

    
137
-- 테이블 데이터 nerv_icde_test.data_field:~0 rows (대략적) 내보내기
138
DELETE FROM `data_field`;
139
/*!40000 ALTER TABLE `data_field` DISABLE KEYS */;
140
/*!40000 ALTER TABLE `data_field` ENABLE KEYS */;
141

    
142
-- 테이블 nerv_icde_test.deployments 구조 내보내기
143
DROP TABLE IF EXISTS `deployments`;
144
CREATE TABLE IF NOT EXISTS `deployments` (
145
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT,
146
  `node_id` int(11) unsigned NOT NULL,
147
  `component_id` int(11) unsigned NOT NULL,
148
  `systemdomain_id` int(11) unsigned NOT NULL DEFAULT '0',
149
  `original_id` int(11) unsigned DEFAULT NULL,
150
  PRIMARY KEY (`Id`),
151
  KEY `FK_deployments_1` (`node_id`),
152
  KEY `FK_deployments_2` (`component_id`),
153
  KEY `deployments_ibfk_1` (`systemdomain_id`),
154
  KEY `Id_node_id` (`Id`,`node_id`),
155
  KEY `FK_deployments_deployments` (`original_id`),
156
  CONSTRAINT `deployments_ibfk_1` FOREIGN KEY (`systemdomain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
157
  CONSTRAINT `deployments_ibfk_2` FOREIGN KEY (`node_id`) REFERENCES `node` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
158
  CONSTRAINT `FK_deployments_1` FOREIGN KEY (`node_id`) REFERENCES `node` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
159
  CONSTRAINT `FK_deployments_2` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
160
  CONSTRAINT `FK_deployments_deployments` FOREIGN KEY (`original_id`) REFERENCES `deployments` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
161
) ENGINE=InnoDB AUTO_INCREMENT=723 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
162

    
163
-- 테이블 데이터 nerv_icde_test.deployments:~0 rows (대략적) 내보내기
164
DELETE FROM `deployments`;
165
/*!40000 ALTER TABLE `deployments` DISABLE KEYS */;
166
/*!40000 ALTER TABLE `deployments` ENABLE KEYS */;
167

    
168
-- 테이블 nerv_icde_test.deployments_bind 구조 내보내기
169
DROP TABLE IF EXISTS `deployments_bind`;
170
CREATE TABLE IF NOT EXISTS `deployments_bind` (
171
  `deployment_id` int(11) unsigned NOT NULL,
172
  `node_id` int(11) unsigned NOT NULL,
173
  `port` int(11) unsigned NOT NULL,
174
  `ip` varchar(255) NOT NULL DEFAULT '0',
175
  PRIMARY KEY (`deployment_id`,`node_id`,`port`,`ip`),
176
  KEY `FK_deployments_bind_network` (`node_id`,`port`,`ip`),
177
  CONSTRAINT `FK_deployments_bind_deployments` FOREIGN KEY (`deployment_id`, `node_id`) REFERENCES `deployments` (`Id`, `node_id`) ON DELETE CASCADE ON UPDATE CASCADE,
178
  CONSTRAINT `FK_deployments_bind_network` FOREIGN KEY (`node_id`, `port`, `ip`) REFERENCES `network` (`node_id`, `port`, `ip`) ON DELETE CASCADE ON UPDATE CASCADE
179
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
180

    
181
-- 테이블 데이터 nerv_icde_test.deployments_bind:~0 rows (대략적) 내보내기
182
DELETE FROM `deployments_bind`;
183
/*!40000 ALTER TABLE `deployments_bind` DISABLE KEYS */;
184
/*!40000 ALTER TABLE `deployments_bind` ENABLE KEYS */;
185

    
186
-- 테이블 nerv_icde_test.diagrame 구조 내보내기
187
DROP TABLE IF EXISTS `diagrame`;
188
CREATE TABLE IF NOT EXISTS `diagrame` (
189
  `Id` int(11) NOT NULL AUTO_INCREMENT,
190
  `domain_id` int(11) unsigned NOT NULL DEFAULT '0',
191
  `type` int(11) unsigned NOT NULL DEFAULT '0',
192
  `name` varchar(255) NOT NULL DEFAULT '',
193
  `description` mediumtext,
194
  PRIMARY KEY (`Id`),
195
  KEY `diagrame_ibfk_1` (`domain_id`),
196
  CONSTRAINT `diagrame_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
197
  CONSTRAINT `FK_diagrame_domainid` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
198
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
199

    
200
-- 테이블 데이터 nerv_icde_test.diagrame:~0 rows (대략적) 내보내기
201
DELETE FROM `diagrame`;
202
/*!40000 ALTER TABLE `diagrame` DISABLE KEYS */;
203
/*!40000 ALTER TABLE `diagrame` ENABLE KEYS */;
204

    
205
-- 테이블 nerv_icde_test.domain_data 구조 내보내기
206
DROP TABLE IF EXISTS `domain_data`;
207
CREATE TABLE IF NOT EXISTS `domain_data` (
208
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
209
  `uuid` char(36) NOT NULL,
210
  `upper_id` int(10) unsigned DEFAULT '0',
211
  `name` varchar(100) NOT NULL DEFAULT '',
212
  `user_id` varchar(45) NOT NULL,
213
  `public` tinyint(1) unsigned NOT NULL,
214
  `create_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
215
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
216
  `description` mediumtext,
217
  PRIMARY KEY (`id`),
218
  KEY `FK_upper_id` (`upper_id`) USING BTREE,
219
  KEY `FK_user_id` (`user_id`),
220
  CONSTRAINT `FK_domain_data_upper_id` FOREIGN KEY (`upper_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
221
  CONSTRAINT `FK_domain_data_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
222
) ENGINE=InnoDB AUTO_INCREMENT=190 DEFAULT CHARSET=utf8;
223

    
224
-- 테이블 데이터 nerv_icde_test.domain_data:~1 rows (대략적) 내보내기
225
DELETE FROM `domain_data`;
226
/*!40000 ALTER TABLE `domain_data` DISABLE KEYS */;
227
INSERT INTO `domain_data` (`id`, `uuid`, `upper_id`, `name`, `user_id`, `public`, `create_date`, `last_update`, `description`) VALUES
228
	(0, '', 0, '', 'root', 0, '0000-00-00 00:00:00', '2017-11-06 09:46:30', NULL);
229
/*!40000 ALTER TABLE `domain_data` ENABLE KEYS */;
230

    
231
-- 테이블 nerv_icde_test.domain_method 구조 내보내기
232
DROP TABLE IF EXISTS `domain_method`;
233
CREATE TABLE IF NOT EXISTS `domain_method` (
234
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
235
  `uuid` char(36) NOT NULL,
236
  `upper_id` int(10) unsigned DEFAULT '0',
237
  `name` varchar(100) NOT NULL,
238
  `user_id` varchar(45) NOT NULL,
239
  `public` tinyint(1) unsigned NOT NULL,
240
  `standard_port` smallint(5) unsigned NOT NULL,
241
  `description` mediumtext NOT NULL,
242
  `create_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
243
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
244
  PRIMARY KEY (`id`),
245
  KEY `FK_upper_id` (`upper_id`),
246
  KEY `FK_user_id` (`user_id`),
247
  CONSTRAINT `FK_domain_method_upper_id` FOREIGN KEY (`upper_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
248
  CONSTRAINT `FK_domain_method_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
249
) ENGINE=InnoDB AUTO_INCREMENT=224 DEFAULT CHARSET=utf8;
250

    
251
-- 테이블 데이터 nerv_icde_test.domain_method:~1 rows (대략적) 내보내기
252
DELETE FROM `domain_method`;
253
/*!40000 ALTER TABLE `domain_method` DISABLE KEYS */;
254
INSERT INTO `domain_method` (`id`, `uuid`, `upper_id`, `name`, `user_id`, `public`, `standard_port`, `description`, `create_date`, `last_update`) VALUES
255
	(0, '', NULL, '', 'root', 0, 0, '', '0000-00-00 00:00:00', '2017-11-06 09:47:11');
256
/*!40000 ALTER TABLE `domain_method` ENABLE KEYS */;
257

    
258
-- 테이블 nerv_icde_test.domain_system 구조 내보내기
259
DROP TABLE IF EXISTS `domain_system`;
260
CREATE TABLE IF NOT EXISTS `domain_system` (
261
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
262
  `uuid` char(36) NOT NULL DEFAULT '',
263
  `upper_id` int(10) unsigned DEFAULT NULL,
264
  `name` varchar(100) NOT NULL,
265
  `user_id` varchar(45) NOT NULL,
266
  `type` enum('router','switch','computer','sensor','system') NOT NULL,
267
  `public` tinyint(1) unsigned NOT NULL,
268
  `create_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
269
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
270
  `description` mediumtext NOT NULL,
271
  PRIMARY KEY (`id`),
272
  KEY `FK_upper_id` (`upper_id`),
273
  KEY `FK_user_id` (`user_id`),
274
  CONSTRAINT `FK_domain_system_2` FOREIGN KEY (`upper_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
275
  CONSTRAINT `FK_domain_system_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
276
) ENGINE=InnoDB AUTO_INCREMENT=341 DEFAULT CHARSET=utf8;
277

    
278
-- 테이블 데이터 nerv_icde_test.domain_system:~1 rows (대략적) 내보내기
279
DELETE FROM `domain_system`;
280
/*!40000 ALTER TABLE `domain_system` DISABLE KEYS */;
281
INSERT INTO `domain_system` (`id`, `uuid`, `upper_id`, `name`, `user_id`, `type`, `public`, `create_date`, `last_update`, `description`) VALUES
282
	(0, '', NULL, '', 'root', 'router', 0, '0000-00-00 00:00:00', '2017-11-06 09:47:42', '');
283
/*!40000 ALTER TABLE `domain_system` ENABLE KEYS */;
284

    
285
-- 테이블 nerv_icde_test.domain_system_logical_port 구조 내보내기
286
DROP TABLE IF EXISTS `domain_system_logical_port`;
287
CREATE TABLE IF NOT EXISTS `domain_system_logical_port` (
288
  `domain_system_id` int(11) unsigned NOT NULL DEFAULT '0',
289
  `port_group` int(11) unsigned NOT NULL DEFAULT '0',
290
  PRIMARY KEY (`domain_system_id`,`port_group`) USING BTREE,
291
  CONSTRAINT `domain_system_logical_port_ibfk_1` FOREIGN KEY (`domain_system_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
292
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
293

    
294
-- 테이블 데이터 nerv_icde_test.domain_system_logical_port:~1 rows (대략적) 내보내기
295
DELETE FROM `domain_system_logical_port`;
296
/*!40000 ALTER TABLE `domain_system_logical_port` DISABLE KEYS */;
297
INSERT INTO `domain_system_logical_port` (`domain_system_id`, `port_group`) VALUES
298
	(0, 0);
299
/*!40000 ALTER TABLE `domain_system_logical_port` ENABLE KEYS */;
300

    
301
-- 테이블 nerv_icde_test.domain_system_port 구조 내보내기
302
DROP TABLE IF EXISTS `domain_system_port`;
303
CREATE TABLE IF NOT EXISTS `domain_system_port` (
304
  `domain_system_id` int(11) unsigned NOT NULL DEFAULT '0',
305
  `port_num` int(11) unsigned NOT NULL DEFAULT '0',
306
  `port_group` int(11) unsigned NOT NULL DEFAULT '0',
307
  `description` text,
308
  PRIMARY KEY (`domain_system_id`,`port_num`,`port_group`) USING BTREE,
309
  KEY `FK_domain_system_port_1` (`domain_system_id`,`port_group`),
310
  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
311
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
312

    
313
-- 테이블 데이터 nerv_icde_test.domain_system_port:~0 rows (대략적) 내보내기
314
DELETE FROM `domain_system_port`;
315
/*!40000 ALTER TABLE `domain_system_port` DISABLE KEYS */;
316
/*!40000 ALTER TABLE `domain_system_port` ENABLE KEYS */;
317

    
318
-- 테이블 nerv_icde_test.inheritance_data_data 구조 내보내기
319
DROP TABLE IF EXISTS `inheritance_data_data`;
320
CREATE TABLE IF NOT EXISTS `inheritance_data_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_data_data_2` (`parent_domain_id`),
325
  CONSTRAINT `FK_inheritance_data_data_1` FOREIGN KEY (`domain_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
326
  CONSTRAINT `FK_inheritance_data_data_2` 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_test.inheritance_data_data:~1 rows (대략적) 내보내기
330
DELETE FROM `inheritance_data_data`;
331
/*!40000 ALTER TABLE `inheritance_data_data` DISABLE KEYS */;
332
INSERT INTO `inheritance_data_data` (`domain_id`, `parent_domain_id`) VALUES
333
	(0, 0);
334
/*!40000 ALTER TABLE `inheritance_data_data` ENABLE KEYS */;
335

    
336
-- 테이블 nerv_icde_test.inheritance_method_data 구조 내보내기
337
DROP TABLE IF EXISTS `inheritance_method_data`;
338
CREATE TABLE IF NOT EXISTS `inheritance_method_data` (
339
  `domain_id` int(10) unsigned NOT NULL,
340
  `parent_domain_id` int(10) unsigned NOT NULL,
341
  PRIMARY KEY (`domain_id`,`parent_domain_id`),
342
  KEY `FK_inheritance_method_data_parent_domain_in` (`parent_domain_id`),
343
  CONSTRAINT `FK_inheritance_method_data_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
344
  CONSTRAINT `FK_inheritance_method_data_parent_domain_in` FOREIGN KEY (`parent_domain_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
345
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
346

    
347
-- 테이블 데이터 nerv_icde_test.inheritance_method_data:~0 rows (대략적) 내보내기
348
DELETE FROM `inheritance_method_data`;
349
/*!40000 ALTER TABLE `inheritance_method_data` DISABLE KEYS */;
350
/*!40000 ALTER TABLE `inheritance_method_data` ENABLE KEYS */;
351

    
352
-- 테이블 nerv_icde_test.inheritance_method_method 구조 내보내기
353
DROP TABLE IF EXISTS `inheritance_method_method`;
354
CREATE TABLE IF NOT EXISTS `inheritance_method_method` (
355
  `domain_id` int(10) unsigned NOT NULL,
356
  `parent_domain_id` int(10) unsigned NOT NULL,
357
  PRIMARY KEY (`domain_id`,`parent_domain_id`),
358
  KEY `FK_inheritance_method_method_parent_domain_id` (`parent_domain_id`),
359
  CONSTRAINT `FK_inheritance_method_method_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
360
  CONSTRAINT `FK_inheritance_method_method_parent_domain_id` FOREIGN KEY (`parent_domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
361
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
362

    
363
-- 테이블 데이터 nerv_icde_test.inheritance_method_method:~0 rows (대략적) 내보내기
364
DELETE FROM `inheritance_method_method`;
365
/*!40000 ALTER TABLE `inheritance_method_method` DISABLE KEYS */;
366
/*!40000 ALTER TABLE `inheritance_method_method` ENABLE KEYS */;
367

    
368
-- 테이블 nerv_icde_test.inheritance_system_method 구조 내보내기
369
DROP TABLE IF EXISTS `inheritance_system_method`;
370
CREATE TABLE IF NOT EXISTS `inheritance_system_method` (
371
  `domain_id` int(10) unsigned NOT NULL,
372
  `parent_domain_id` int(10) unsigned NOT NULL,
373
  PRIMARY KEY (`domain_id`,`parent_domain_id`),
374
  KEY `FK_inheritance_system_method_parent_domain_id` (`parent_domain_id`),
375
  CONSTRAINT `FK_inheritance_system_method_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
376
  CONSTRAINT `FK_inheritance_system_method_parent_domain_id` FOREIGN KEY (`parent_domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
377
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
378

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

    
384
-- 테이블 nerv_icde_test.interface 구조 내보내기
385
DROP TABLE IF EXISTS `interface`;
386
CREATE TABLE IF NOT EXISTS `interface` (
387
  `domain_id` int(10) unsigned NOT NULL DEFAULT '0',
388
  `name` varchar(100) NOT NULL,
389
  `user_id` varchar(45) NOT NULL,
390
  `seq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
391
  `description` mediumtext NOT NULL,
392
  PRIMARY KEY (`domain_id`,`name`),
393
  KEY `FK_user_id` (`user_id`),
394
  CONSTRAINT `FK_interface_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
395
  CONSTRAINT `FK_interface_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
396
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
397

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

    
403
-- 테이블 nerv_icde_test.interface_member 구조 내보내기
404
DROP TABLE IF EXISTS `interface_member`;
405
CREATE TABLE IF NOT EXISTS `interface_member` (
406
  `domain_id` int(10) unsigned NOT NULL DEFAULT '0',
407
  `interface` varchar(100) NOT NULL,
408
  `method_domain_id` int(10) unsigned NOT NULL,
409
  `method_name` varchar(45) NOT NULL,
410
  `description` mediumtext NOT NULL,
411
  PRIMARY KEY (`domain_id`,`interface`,`method_domain_id`,`method_name`),
412
  KEY `FK_interface_member_method` (`domain_id`,`method_name`),
413
  KEY `interface_member_ibfk_1` (`method_domain_id`,`method_name`),
414
  CONSTRAINT `FK_interface_member_interface` FOREIGN KEY (`domain_id`, `interface`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE,
415
  CONSTRAINT `interface_member_ibfk_1` FOREIGN KEY (`method_domain_id`, `method_name`) REFERENCES `method` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE
416
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
417

    
418
-- 테이블 데이터 nerv_icde_test.interface_member:~0 rows (대략적) 내보내기
419
DELETE FROM `interface_member`;
420
/*!40000 ALTER TABLE `interface_member` DISABLE KEYS */;
421
/*!40000 ALTER TABLE `interface_member` ENABLE KEYS */;
422

    
423
-- 테이블 nerv_icde_test.interface_parent 구조 내보내기
424
DROP TABLE IF EXISTS `interface_parent`;
425
CREATE TABLE IF NOT EXISTS `interface_parent` (
426
  `domain_id` int(10) unsigned NOT NULL,
427
  `interface` varchar(100) NOT NULL,
428
  `parent_domain_id` int(10) unsigned NOT NULL,
429
  `parent_interface` varchar(100) NOT NULL,
430
  PRIMARY KEY (`domain_id`,`interface`,`parent_domain_id`,`parent_interface`),
431
  KEY `FK_interface_parent_parent` (`parent_domain_id`,`parent_interface`),
432
  CONSTRAINT `FK_interface_parent_interface` FOREIGN KEY (`domain_id`, `interface`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE,
433
  CONSTRAINT `FK_interface_parent_parent` FOREIGN KEY (`parent_domain_id`, `parent_interface`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE
434
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
435

    
436
-- 테이블 데이터 nerv_icde_test.interface_parent:~0 rows (대략적) 내보내기
437
DELETE FROM `interface_parent`;
438
/*!40000 ALTER TABLE `interface_parent` DISABLE KEYS */;
439
/*!40000 ALTER TABLE `interface_parent` ENABLE KEYS */;
440

    
441
-- 테이블 nerv_icde_test.members_domain_data 구조 내보내기
442
DROP TABLE IF EXISTS `members_domain_data`;
443
CREATE TABLE IF NOT EXISTS `members_domain_data` (
444
  `domain_id` int(10) unsigned NOT NULL DEFAULT '0',
445
  `user_id` varchar(45) NOT NULL,
446
  `member_type` enum('manager','member','guest') NOT NULL,
447
  PRIMARY KEY (`domain_id`,`user_id`),
448
  KEY `FK_user_id` (`user_id`),
449
  CONSTRAINT `FK_members_domain_data_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_data` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
450
  CONSTRAINT `FK_members_domain_data_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
451
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
452

    
453
-- 테이블 데이터 nerv_icde_test.members_domain_data:~0 rows (대략적) 내보내기
454
DELETE FROM `members_domain_data`;
455
/*!40000 ALTER TABLE `members_domain_data` DISABLE KEYS */;
456
/*!40000 ALTER TABLE `members_domain_data` ENABLE KEYS */;
457

    
458
-- 테이블 nerv_icde_test.members_domain_method 구조 내보내기
459
DROP TABLE IF EXISTS `members_domain_method`;
460
CREATE TABLE IF NOT EXISTS `members_domain_method` (
461
  `domain_id` int(10) unsigned NOT NULL,
462
  `user_id` varchar(45) NOT NULL,
463
  `member_type` enum('manager','member','guest') NOT NULL,
464
  PRIMARY KEY (`domain_id`,`user_id`),
465
  KEY `FK_user_id` (`user_id`),
466
  CONSTRAINT `FK_members_domain_method_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
467
  CONSTRAINT `FK_members_domain_method_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
468
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
469

    
470
-- 테이블 데이터 nerv_icde_test.members_domain_method:~0 rows (대략적) 내보내기
471
DELETE FROM `members_domain_method`;
472
/*!40000 ALTER TABLE `members_domain_method` DISABLE KEYS */;
473
/*!40000 ALTER TABLE `members_domain_method` ENABLE KEYS */;
474

    
475
-- 테이블 nerv_icde_test.members_domain_system 구조 내보내기
476
DROP TABLE IF EXISTS `members_domain_system`;
477
CREATE TABLE IF NOT EXISTS `members_domain_system` (
478
  `domain_id` int(10) unsigned NOT NULL,
479
  `user_id` varchar(45) NOT NULL,
480
  `member_type` enum('manager','member','guest') NOT NULL,
481
  PRIMARY KEY (`domain_id`,`user_id`),
482
  KEY `FK_user_id` (`user_id`),
483
  CONSTRAINT `FK_members_domain_system_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
484
  CONSTRAINT `FK_members_domain_system_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
485
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
486

    
487
-- 테이블 데이터 nerv_icde_test.members_domain_system:~0 rows (대략적) 내보내기
488
DELETE FROM `members_domain_system`;
489
/*!40000 ALTER TABLE `members_domain_system` DISABLE KEYS */;
490
/*!40000 ALTER TABLE `members_domain_system` ENABLE KEYS */;
491

    
492
-- 테이블 nerv_icde_test.member_system 구조 내보내기
493
DROP TABLE IF EXISTS `member_system`;
494
CREATE TABLE IF NOT EXISTS `member_system` (
495
  `domain_id` int(10) unsigned NOT NULL,
496
  `member_domain_id` int(10) unsigned NOT NULL,
497
  PRIMARY KEY (`domain_id`,`member_domain_id`),
498
  KEY `FK_member_system_member` (`member_domain_id`),
499
  CONSTRAINT `FK_member_system_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
500
  CONSTRAINT `FK_member_system_member` FOREIGN KEY (`member_domain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
501
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
502

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

    
508
-- 테이블 nerv_icde_test.method 구조 내보내기
509
DROP TABLE IF EXISTS `method`;
510
CREATE TABLE IF NOT EXISTS `method` (
511
  `domain_id` int(10) unsigned NOT NULL DEFAULT '0',
512
  `name` varchar(100) NOT NULL,
513
  `type` varchar(50) NOT NULL DEFAULT '',
514
  `code` smallint(5) unsigned NOT NULL DEFAULT '0',
515
  `in_data_auto_id` int(10) unsigned DEFAULT NULL,
516
  `out_data_auto_id` int(10) unsigned DEFAULT NULL,
517
  `user_id` varchar(45) NOT NULL,
518
  `description` mediumtext NOT NULL,
519
  PRIMARY KEY (`domain_id`,`name`),
520
  KEY `UQ_method` (`domain_id`,`type`,`code`),
521
  KEY `FK_method_user` (`user_id`),
522
  KEY `FK_method_in_data` (`in_data_auto_id`),
523
  KEY `FK_method_out_data` (`out_data_auto_id`),
524
  CONSTRAINT `FK_method_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
525
  CONSTRAINT `FK_method_in_data` FOREIGN KEY (`in_data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE SET NULL ON UPDATE CASCADE,
526
  CONSTRAINT `FK_method_out_data` FOREIGN KEY (`out_data_auto_id`) REFERENCES `data` (`data_auto_id`) ON DELETE SET NULL ON UPDATE CASCADE,
527
  CONSTRAINT `FK_method_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE CASCADE
528
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
529

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

    
535
-- 테이블 nerv_icde_test.network 구조 내보내기
536
DROP TABLE IF EXISTS `network`;
537
CREATE TABLE IF NOT EXISTS `network` (
538
  `node_id` int(10) unsigned NOT NULL DEFAULT '0',
539
  `port` int(11) unsigned NOT NULL DEFAULT '0',
540
  `ip` varchar(255) NOT NULL DEFAULT '',
541
  `mask` varchar(255) DEFAULT '',
542
  `net` varchar(50) NOT NULL DEFAULT '',
543
  `gateway` varchar(255) DEFAULT NULL,
544
  `dns` varchar(255) NOT NULL DEFAULT '',
545
  `description` varchar(255) DEFAULT NULL,
546
  `collision` tinyint(3) unsigned NOT NULL DEFAULT '0',
547
  `original_node_id` int(10) unsigned DEFAULT '0',
548
  `original_node_port` int(11) unsigned DEFAULT '0',
549
  `original_node_ip` varchar(255) DEFAULT '',
550
  PRIMARY KEY (`node_id`,`port`,`ip`),
551
  KEY `network_ibfk_3` (`original_node_id`,`original_node_port`,`original_node_ip`),
552
  CONSTRAINT `network_ibfk_1` FOREIGN KEY (`node_id`, `port`) REFERENCES `node_port` (`Id`, `port_group`) ON DELETE CASCADE ON UPDATE CASCADE,
553
  CONSTRAINT `network_ibfk_2` FOREIGN KEY (`node_id`) REFERENCES `node_port` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
554
  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
555
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
556

    
557
-- 테이블 데이터 nerv_icde_test.network:~0 rows (대략적) 내보내기
558
DELETE FROM `network`;
559
/*!40000 ALTER TABLE `network` DISABLE KEYS */;
560
/*!40000 ALTER TABLE `network` ENABLE KEYS */;
561

    
562
-- 테이블 nerv_icde_test.network_link 구조 내보내기
563
DROP TABLE IF EXISTS `network_link`;
564
CREATE TABLE IF NOT EXISTS `network_link` (
565
  `s_node_id` int(11) unsigned NOT NULL DEFAULT '0',
566
  `s_sub_system_id` int(11) unsigned NOT NULL DEFAULT '0',
567
  `s_port_id` int(11) unsigned NOT NULL DEFAULT '0',
568
  `d_node_id` int(11) unsigned DEFAULT NULL,
569
  `d_sub_system_id` int(11) unsigned NOT NULL DEFAULT '0',
570
  `d_port_id` int(11) unsigned NOT NULL DEFAULT '0',
571
  PRIMARY KEY (`s_node_id`,`s_sub_system_id`,`s_port_id`),
572
  UNIQUE KEY `d_node_id` (`d_node_id`,`d_sub_system_id`,`d_port_id`),
573
  KEY `s_sub_system_id` (`s_sub_system_id`,`s_port_id`),
574
  KEY `d_sub_system_id` (`d_sub_system_id`,`d_port_id`),
575
  CONSTRAINT `FK_network_link_4` FOREIGN KEY (`d_node_id`) REFERENCES `node` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
576
  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,
577
  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,
578
  CONSTRAINT `network_link_ibfk_3` FOREIGN KEY (`s_node_id`) REFERENCES `node` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
579
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
580

    
581
-- 테이블 데이터 nerv_icde_test.network_link:~0 rows (대략적) 내보내기
582
DELETE FROM `network_link`;
583
/*!40000 ALTER TABLE `network_link` DISABLE KEYS */;
584
/*!40000 ALTER TABLE `network_link` ENABLE KEYS */;
585

    
586
-- 테이블 nerv_icde_test.network_temp 구조 내보내기
587
DROP TABLE IF EXISTS `network_temp`;
588
CREATE TABLE IF NOT EXISTS `network_temp` (
589
  `node_id` int(10) unsigned NOT NULL DEFAULT '0',
590
  `port` int(11) unsigned NOT NULL DEFAULT '0',
591
  `ip` varchar(255) NOT NULL DEFAULT '',
592
  `mask` varchar(255) DEFAULT '',
593
  `net` varchar(50) NOT NULL DEFAULT '',
594
  `gateway` varchar(255) DEFAULT NULL,
595
  `dns` varchar(255) NOT NULL DEFAULT '',
596
  `description` varchar(255) DEFAULT NULL,
597
  `collision` tinyint(3) unsigned NOT NULL DEFAULT '0',
598
  `original_node_id` int(10) unsigned DEFAULT '0',
599
  `original_node_port` int(11) unsigned DEFAULT '0',
600
  `original_node_ip` varchar(255) DEFAULT ''
601
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
602

    
603
-- 테이블 데이터 nerv_icde_test.network_temp:~0 rows (대략적) 내보내기
604
DELETE FROM `network_temp`;
605
/*!40000 ALTER TABLE `network_temp` DISABLE KEYS */;
606
/*!40000 ALTER TABLE `network_temp` ENABLE KEYS */;
607

    
608
-- 테이블 nerv_icde_test.node 구조 내보내기
609
DROP TABLE IF EXISTS `node`;
610
CREATE TABLE IF NOT EXISTS `node` (
611
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
612
  `systemdomain_id` int(10) unsigned NOT NULL,
613
  `sub_system_domain_id` int(11) unsigned DEFAULT '0',
614
  `name` varchar(255) NOT NULL DEFAULT '',
615
  `type` varchar(45) NOT NULL DEFAULT '',
616
  `description` varchar(255) DEFAULT NULL,
617
  `complete` enum('Y','N') NOT NULL DEFAULT 'N',
618
  PRIMARY KEY (`Id`),
619
  KEY `FK_node_1` (`systemdomain_id`),
620
  KEY `package_domain_id` (`sub_system_domain_id`),
621
  KEY `Id_systemdomain_id` (`Id`,`systemdomain_id`),
622
  CONSTRAINT `node_ibfk_1` FOREIGN KEY (`systemdomain_id`) REFERENCES `domain_system` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
623
  CONSTRAINT `node_ibfk_2` FOREIGN KEY (`sub_system_domain_id`) REFERENCES `domain_system` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
624
) ENGINE=InnoDB AUTO_INCREMENT=1199 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
625

    
626
-- 테이블 데이터 nerv_icde_test.node:~1 rows (대략적) 내보내기
627
DELETE FROM `node`;
628
/*!40000 ALTER TABLE `node` DISABLE KEYS */;
629
INSERT INTO `node` (`Id`, `systemdomain_id`, `sub_system_domain_id`, `name`, `type`, `description`, `complete`) VALUES
630
	(0, 0, 0, '', 'sub_system', NULL, 'N');
631
/*!40000 ALTER TABLE `node` ENABLE KEYS */;
632

    
633
-- 테이블 nerv_icde_test.node_port 구조 내보내기
634
DROP TABLE IF EXISTS `node_port`;
635
CREATE TABLE IF NOT EXISTS `node_port` (
636
  `Id` int(10) unsigned NOT NULL,
637
  `systemdomain_id` int(10) unsigned NOT NULL,
638
  `sub_system_domain_id` int(11) unsigned NOT NULL DEFAULT '0',
639
  `port_group` int(11) unsigned NOT NULL DEFAULT '0',
640
  PRIMARY KEY (`Id`,`systemdomain_id`,`sub_system_domain_id`,`port_group`),
641
  KEY `Id_port_group` (`Id`,`port_group`),
642
  KEY `FK_node_port_domain_system_logical_port` (`sub_system_domain_id`,`port_group`),
643
  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,
644
  CONSTRAINT `FK_node_port_node` FOREIGN KEY (`Id`, `systemdomain_id`) REFERENCES `node` (`Id`, `systemdomain_id`) ON DELETE CASCADE ON UPDATE CASCADE
645
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
646

    
647
-- 테이블 데이터 nerv_icde_test.node_port:~0 rows (대략적) 내보내기
648
DELETE FROM `node_port`;
649
/*!40000 ALTER TABLE `node_port` DISABLE KEYS */;
650
/*!40000 ALTER TABLE `node_port` ENABLE KEYS */;
651

    
652
-- 테이블 nerv_icde_test.protocol_standard_port 구조 내보내기
653
DROP TABLE IF EXISTS `protocol_standard_port`;
654
CREATE TABLE IF NOT EXISTS `protocol_standard_port` (
655
  `Id` int(11) NOT NULL AUTO_INCREMENT,
656
  `title` varchar(255) DEFAULT NULL,
657
  `port` varchar(255) DEFAULT NULL,
658
  `discription` text,
659
  PRIMARY KEY (`Id`)
660
) ENGINE=InnoDB AUTO_INCREMENT=10746 DEFAULT CHARSET=utf8;
661

    
662
-- 테이블 데이터 nerv_icde_test.protocol_standard_port:~0 rows (대략적) 내보내기
663
DELETE FROM `protocol_standard_port`;
664
/*!40000 ALTER TABLE `protocol_standard_port` DISABLE KEYS */;
665
/*!40000 ALTER TABLE `protocol_standard_port` ENABLE KEYS */;
666

    
667
-- 테이블 nerv_icde_test.proxy_interface_object 구조 내보내기
668
DROP TABLE IF EXISTS `proxy_interface_object`;
669
CREATE TABLE IF NOT EXISTS `proxy_interface_object` (
670
  `proxy_interface_id` int(10) unsigned NOT NULL,
671
  `object_name` varchar(100) NOT NULL,
672
  `component_id` int(10) unsigned NOT NULL,
673
  PRIMARY KEY (`proxy_interface_id`,`object_name`),
674
  UNIQUE KEY `object_name_component_id` (`object_name`,`component_id`),
675
  KEY `FK_proxy_interface_object_proxy_interface_relation` (`proxy_interface_id`,`component_id`),
676
  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
677
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
678

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

    
684
-- 테이블 nerv_icde_test.proxy_interface_relation 구조 내보내기
685
DROP TABLE IF EXISTS `proxy_interface_relation`;
686
CREATE TABLE IF NOT EXISTS `proxy_interface_relation` (
687
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
688
  `component_id` int(10) unsigned NOT NULL DEFAULT '0',
689
  `method_domain_id` int(10) unsigned NOT NULL DEFAULT '0',
690
  `interface_name` varchar(100) NOT NULL DEFAULT '',
691
  `class_name` varchar(255) DEFAULT '',
692
  PRIMARY KEY (`id`),
693
  UNIQUE KEY `unique_key` (`component_id`,`method_domain_id`,`interface_name`,`class_name`),
694
  KEY `FK_proxy_interface_relation_1` (`component_id`),
695
  KEY `FK_proxy_interface_relation_2` (`method_domain_id`,`interface_name`),
696
  KEY `id_component_id` (`id`,`component_id`),
697
  CONSTRAINT `FK_proxy_interface_relation_1` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
698
  CONSTRAINT `FK_proxy_interface_relation_2` FOREIGN KEY (`method_domain_id`, `interface_name`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE
699
) ENGINE=InnoDB AUTO_INCREMENT=1099 DEFAULT CHARSET=utf8;
700

    
701
-- 테이블 데이터 nerv_icde_test.proxy_interface_relation:~0 rows (대략적) 내보내기
702
DELETE FROM `proxy_interface_relation`;
703
/*!40000 ALTER TABLE `proxy_interface_relation` DISABLE KEYS */;
704
/*!40000 ALTER TABLE `proxy_interface_relation` ENABLE KEYS */;
705

    
706
-- 테이블 nerv_icde_test.server_information 구조 내보내기
707
DROP TABLE IF EXISTS `server_information`;
708
CREATE TABLE IF NOT EXISTS `server_information` (
709
  `field_name` varchar(100) NOT NULL,
710
  `description` mediumtext NOT NULL,
711
  `seq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
712
  PRIMARY KEY (`field_name`)
713
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
714

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

    
720
-- 테이블 nerv_icde_test.stub_interface_object 구조 내보내기
721
DROP TABLE IF EXISTS `stub_interface_object`;
722
CREATE TABLE IF NOT EXISTS `stub_interface_object` (
723
  `stub_interface_id` int(10) unsigned NOT NULL,
724
  `object_name` varchar(100) NOT NULL,
725
  `component_id` int(10) unsigned NOT NULL,
726
  PRIMARY KEY (`stub_interface_id`,`object_name`),
727
  UNIQUE KEY `object_name_component_id` (`object_name`,`component_id`),
728
  KEY `FK_stub_interface_object_stub_interface_relation` (`stub_interface_id`,`component_id`),
729
  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
730
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
731

    
732
-- 테이블 데이터 nerv_icde_test.stub_interface_object:~0 rows (대략적) 내보내기
733
DELETE FROM `stub_interface_object`;
734
/*!40000 ALTER TABLE `stub_interface_object` DISABLE KEYS */;
735
/*!40000 ALTER TABLE `stub_interface_object` ENABLE KEYS */;
736

    
737
-- 테이블 nerv_icde_test.stub_interface_relation 구조 내보내기
738
DROP TABLE IF EXISTS `stub_interface_relation`;
739
CREATE TABLE IF NOT EXISTS `stub_interface_relation` (
740
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
741
  `component_id` int(10) unsigned NOT NULL DEFAULT '0',
742
  `method_domain_id` int(10) unsigned NOT NULL DEFAULT '0',
743
  `interface_name` varchar(100) NOT NULL DEFAULT '',
744
  `class_name` varchar(255) DEFAULT '',
745
  `domain_port` varchar(255) DEFAULT NULL,
746
  `text` text,
747
  PRIMARY KEY (`Id`),
748
  UNIQUE KEY `unique_key` (`component_id`,`method_domain_id`,`interface_name`,`class_name`),
749
  KEY `FK_stub_interface_ralation_1` (`component_id`),
750
  KEY `FK_stub_interface_ralation_2` (`method_domain_id`,`interface_name`),
751
  KEY `Id_component_id` (`Id`,`component_id`),
752
  CONSTRAINT `FK_stub_interface_ralation_1` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
753
  CONSTRAINT `FK_stub_interface_ralation_2` FOREIGN KEY (`method_domain_id`, `interface_name`) REFERENCES `interface` (`domain_id`, `name`) ON DELETE CASCADE ON UPDATE CASCADE
754
) ENGINE=InnoDB AUTO_INCREMENT=866 DEFAULT CHARSET=utf8;
755

    
756
-- 테이블 데이터 nerv_icde_test.stub_interface_relation:~0 rows (대략적) 내보내기
757
DELETE FROM `stub_interface_relation`;
758
/*!40000 ALTER TABLE `stub_interface_relation` DISABLE KEYS */;
759
/*!40000 ALTER TABLE `stub_interface_relation` ENABLE KEYS */;
760

    
761
-- 테이블 nerv_icde_test.temp_history 구조 내보내기
762
DROP TABLE IF EXISTS `temp_history`;
763
CREATE TABLE IF NOT EXISTS `temp_history` (
764
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
765
  `userid` varchar(45) NOT NULL,
766
  PRIMARY KEY (`timestamp`)
767
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
768

    
769
-- 테이블 데이터 nerv_icde_test.temp_history:~0 rows (대략적) 내보내기
770
DELETE FROM `temp_history`;
771
/*!40000 ALTER TABLE `temp_history` DISABLE KEYS */;
772
/*!40000 ALTER TABLE `temp_history` ENABLE KEYS */;
773

    
774
-- 테이블 nerv_icde_test.umlcomponent 구조 내보내기
775
DROP TABLE IF EXISTS `umlcomponent`;
776
CREATE TABLE IF NOT EXISTS `umlcomponent` (
777
  `Id` int(11) NOT NULL AUTO_INCREMENT,
778
  `diagrame_id` int(11) NOT NULL DEFAULT '0',
779
  `component_id` int(11) unsigned NOT NULL DEFAULT '0',
780
  `position_x` int(11) unsigned NOT NULL DEFAULT '0',
781
  `position_y` int(11) unsigned NOT NULL DEFAULT '0',
782
  `size` int(11) unsigned NOT NULL DEFAULT '0',
783
  PRIMARY KEY (`Id`),
784
  KEY `FK_umlcomponent_diagrame_id` (`diagrame_id`),
785
  KEY `component_id` (`component_id`),
786
  CONSTRAINT `FK_umlcomponent_component_id` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
787
  CONSTRAINT `FK_umlcomponent_diagrame_id` FOREIGN KEY (`diagrame_id`) REFERENCES `diagrame` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE,
788
  CONSTRAINT `umlcomponent_ibfk_1` FOREIGN KEY (`component_id`) REFERENCES `component` (`id`)
789
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
790

    
791
-- 테이블 데이터 nerv_icde_test.umlcomponent:~0 rows (대략적) 내보내기
792
DELETE FROM `umlcomponent`;
793
/*!40000 ALTER TABLE `umlcomponent` DISABLE KEYS */;
794
/*!40000 ALTER TABLE `umlcomponent` ENABLE KEYS */;
795

    
796
-- 테이블 nerv_icde_test.users 구조 내보내기
797
DROP TABLE IF EXISTS `users`;
798
CREATE TABLE IF NOT EXISTS `users` (
799
  `user_id` varchar(45) NOT NULL,
800
  `password` varchar(45) NOT NULL,
801
  `description` mediumtext NOT NULL,
802
  `supermanager` tinyint(1) unsigned NOT NULL,
803
  `newacount` tinyint(1) unsigned NOT NULL,
804
  `newdomain` tinyint(1) unsigned NOT NULL,
805
  PRIMARY KEY (`user_id`)
806
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
807

    
808
-- 테이블 데이터 nerv_icde_test.users:~2 rows (대략적) 내보내기
809
DELETE FROM `users`;
810
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
811
INSERT INTO `users` (`user_id`, `password`, `description`, `supermanager`, `newacount`, `newdomain`) VALUES
812
	('anonymous', '', '', 0, 1, 0),
813
	('root', '', '', 1, 1, 1);
814
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
815

    
816
-- 뷰 nerv_icde_test.view_a 구조 내보내기
817
DROP VIEW IF EXISTS `view_a`;
818
-- VIEW 종속성 오류를 극복하기 위해 임시 테이블을 생성합니다.
819
CREATE TABLE `view_a` (
820
	`s_node_id` INT(11) UNSIGNED NOT NULL,
821
	`s_sub_system_id` INT(11) UNSIGNED NOT NULL,
822
	`s_port_id` INT(11) UNSIGNED NOT NULL,
823
	`d_node_id` INT(11) UNSIGNED NULL,
824
	`d_sub_system_id` INT(11) UNSIGNED NOT NULL,
825
	`d_port_id` INT(11) UNSIGNED NOT NULL
826
) ENGINE=MyISAM;
827

    
828
-- 뷰 nerv_icde_test.view_b 구조 내보내기
829
DROP VIEW IF EXISTS `view_b`;
830
-- VIEW 종속성 오류를 극복하기 위해 임시 테이블을 생성합니다.
831
CREATE TABLE `view_b` (
832
	`s_node_id` INT(11) UNSIGNED NOT NULL,
833
	`s_sub_system_id` INT(11) UNSIGNED NOT NULL,
834
	`s_port_id` INT(11) UNSIGNED NOT NULL,
835
	`d_node_id` INT(11) UNSIGNED NULL,
836
	`d_sub_system_id` INT(11) UNSIGNED NOT NULL,
837
	`d_port_id` INT(11) UNSIGNED NOT NULL
838
) ENGINE=MyISAM;
839

    
840
-- 프로시저 nerv_icde_test.acountInfoAccessUser 구조 내보내기
841
DROP PROCEDURE IF EXISTS `acountInfoAccessUser`;
842
DELIMITER //
843
CREATE PROCEDURE `acountInfoAccessUser`()
844
BEGIN
845
        declare sm bool;
846
        if loginTest() then
847
                select 1 as test;
848
                       select user_id,supermanager,newacount,newdomain,description from users where user_id = @nervuser;
849
       else
850
                select 0 as test;
851
       end if;
852
END//
853
DELIMITER ;
854

    
855
-- 프로시저 nerv_icde_test.acountlistViewAcountList 구조 내보내기
856
DROP PROCEDURE IF EXISTS `acountlistViewAcountList`;
857
DELIMITER //
858
CREATE PROCEDURE `acountlistViewAcountList`(IN `userkey` varchar(100))
859
BEGIN
860
        declare sm bool;
861
        if loginTest() then
862
                select 1 as test;
863
                if( supermanagerTest(@nervuser) ) then
864
                        select user_id,supermanager,newacount,newdomain,description from users
865
								 where user_id like userkey;
866
                else
867
                        select user_id,supermanager,newacount,newdomain,description from users
868
								 where (user_id = 'anonymous' or user_id=@nervuser) and user_id like userkey;
869
                end if;
870
       else
871
                select 0 as test;
872
       end if;
873
END//
874
DELIMITER ;
875

    
876
-- 프로시저 nerv_icde_test.acountlistViewDeleteAcount 구조 내보내기
877
DROP PROCEDURE IF EXISTS `acountlistViewDeleteAcount`;
878
DELIMITER //
879
CREATE PROCEDURE `acountlistViewDeleteAcount`(IN `acountkey` varchar(100))
880
BEGIN
881
        declare targetsm bool;
882
        if acountkey != 'anonymous' and acountkey != 'root'
883
		  	and acountkey != @nervuser and loginTest()
884
			  and supermanagerTest(@nervuser) and !supermanagerTest(acountkey) then
885
                select 1 as test;
886
                delete from users where user_id=acountkey;
887
        else
888
                select 0 as test;
889
        end if;
890
END//
891
DELIMITER ;
892

    
893
-- 프로시저 nerv_icde_test.acountlistViewNewAcount 구조 내보내기
894
DROP PROCEDURE IF EXISTS `acountlistViewNewAcount`;
895
DELIMITER //
896
CREATE PROCEDURE `acountlistViewNewAcount`(acountidvalue varchar(100),passwordvalue varchar(100) ,descriptionvalue text)
897
BEGIN
898
        declare newacountpriv bool;
899
        declare anonymousnewacount bool;
900
        declare anonymousnewdomain bool;
901
        declare anonymoussupermanager bool;
902

    
903
        if loginTest() then
904
                select newacount into newacountpriv from users where user_id=@nervuser;
905
                if newacountpriv then
906
                        select 1 as test;
907
                        select supermanager into anonymoussupermanager from users where user_id='anonymous';
908
                        select newacount into anonymousnewacount from users where user_id='anonymous';
909
                        select newdomain into anonymousnewdomain from users where user_id='anonymous';
910
                        insert into users(user_id, password,supermanager,newacount,newdomain, description)
911
                                   values(acountidvalue,password(passwordvalue),anonymoussupermanager,anonymousnewacount,anonymousnewdomain,descriptionvalue);
912
                else
913
                        select 0 as test;
914
                end if;
915
        else
916
                select 0 as test;
917
        end if;
918
END//
919
DELIMITER ;
920

    
921
-- 프로시저 nerv_icde_test.acountlistViewToggleNewAcount 구조 내보내기
922
DROP PROCEDURE IF EXISTS `acountlistViewToggleNewAcount`;
923
DELIMITER //
924
CREATE PROCEDURE `acountlistViewToggleNewAcount`(acountkey varchar(100))
925
BEGIN
926
        if acountkey != 'root' and loginTest() and supermanagerTest(@nervuser) and !supermanagerTest(acountkey) then
927
                select 1 as test;
928
                update users set newacount = !newacount where user_id=acountkey;
929
        else
930
                select 0 as test;
931
        end if;
932
END//
933
DELIMITER ;
934

    
935
-- 프로시저 nerv_icde_test.acountlistViewToggleNewDomain 구조 내보내기
936
DROP PROCEDURE IF EXISTS `acountlistViewToggleNewDomain`;
937
DELIMITER //
938
CREATE PROCEDURE `acountlistViewToggleNewDomain`(acountkey varchar(100))
939
BEGIN
940
        if acountkey != 'root' and loginTest() and supermanagerTest(@nervuser) and !supermanagerTest(acountkey) then
941
                select 1 as test;
942
                update users set newdomain = !newdomain where user_id=acountkey;
943
        else
944
                select 0 as test;
945
        end if;
946
END//
947
DELIMITER ;
948

    
949
-- 프로시저 nerv_icde_test.acountlistViewToggleSupermanager 구조 내보내기
950
DROP PROCEDURE IF EXISTS `acountlistViewToggleSupermanager`;
951
DELIMITER //
952
CREATE PROCEDURE `acountlistViewToggleSupermanager`(acountkey varchar(100))
953
BEGIN
954
        if acountkey != 'root' and @nervuser = 'root' and loginTest() then
955
                select 1 as test;
956
                update users set supermanager = !supermanager where user_id=acountkey;
957
        else
958
                select 0 as test;
959
        end if;
960
END//
961
DELIMITER ;
962

    
963
-- 프로시저 nerv_icde_test.acountViewEditAcount 구조 내보내기
964
DROP PROCEDURE IF EXISTS `acountViewEditAcount`;
965
DELIMITER //
966
CREATE PROCEDURE `acountViewEditAcount`(IN `oldpasswordedit` varchar(100), IN `passwordedit` varchar(100), IN `descriptionedit` text)
967
BEGIN
968
        declare pwd varchar(100);
969
        if @nervuser != 'anonymous' then
970
                if loginTest() then
971
                        select users.password into pwd from users where user_id=@nervuser;
972
                        if pwd = password(oldpasswordedit) then
973
                                select 1 as test;
974
                                update users set password=password(passwordedit), description=descriptionedit
975
										   where user_id=@nervuser;
976
                                set @nervpassword = passwordedit;
977
                        else
978
                                select 0 as test;
979
                        end if;
980
                else
981
                        select 0 as test;
982
                end if;
983
        else
984
                select 0 as test;
985
        end if;
986
END//
987
DELIMITER ;
988

    
989
-- 프로시저 nerv_icde_test.acountViewSecedeAcount 구조 내보내기
990
DROP PROCEDURE IF EXISTS `acountViewSecedeAcount`;
991
DELIMITER //
992
CREATE PROCEDURE `acountViewSecedeAcount`()
993
BEGIN
994
        declare pwd varchar(100);
995
        if @nervuser != 'anonymous' then
996
                if loginTest() then
997
                        select 1 as test;
998
                        delete from users where user_id=@nervuser;
999
                else
1000
                        select 0 as test;
1001
                end if;
1002
        else
1003
                select 0 as test;
1004
        end if;
1005
END//
1006
DELIMITER ;
1007

    
1008
-- 프로시저 nerv_icde_test.acountViewUserinfo 구조 내보내기
1009
DROP PROCEDURE IF EXISTS `acountViewUserinfo`;
1010
DELIMITER //
1011
CREATE PROCEDURE `acountViewUserinfo`()
1012
BEGIN
1013
       if loginTest() then
1014
               select 1 as test;
1015
               select user_id,supermanager,newacount,newdomain,description from users where user_id=@nervuser;
1016
       else
1017
               select 0 as test;
1018
       end if;
1019
END//
1020
DELIMITER ;
1021

    
1022
-- 프로시저 nerv_icde_test.auto_update_data_field_path 구조 내보내기
1023
DROP PROCEDURE IF EXISTS `auto_update_data_field_path`;
1024
DELIMITER //
1025
CREATE PROCEDURE `auto_update_data_field_path`()
1026
BEGIN
1027
	declare my_data_id int;
1028
	declare my_real_data_auto_id int;
1029
	declare my_domain_id int;
1030
	declare my_real_domain_id int;
1031
	declare my_real_data_name varchar(50);
1032
	declare my_depth int;
1033
	declare my_real_data_path int;
1034
	declare no_more_rows bool default false;
1035

    
1036
		DECLARE my_list CURSOR FOR
1037
		select data_field.data_auto_id, data_field.real_data_auto_id  from data_field where data_field.`type`='alias';
1038
		declare continue handler for not found set no_more_rows := TRUE;
1039

    
1040
			open my_list;
1041
			my_loop : loop
1042
				fetch my_list into my_data_id, my_real_data_auto_id;
1043
				if no_more_rows then
1044
					close my_list;
1045
					leave my_loop;
1046
				end if;
1047
				   select  data.domain_id into my_domain_id from data where data.data_auto_id = my_data_id;
1048
        			select  data.domain_id into my_real_domain_id from data where data.data_auto_id = my_real_data_auto_id;
1049
        			select  data.name into my_real_data_name from data where data.data_auto_id = my_real_data_auto_id;
1050

    
1051

    
1052

    
1053
        			if my_domain_id=my_real_domain_id then
1054
               		select data.depth into my_depth from data where data.data_auto_id=my_data_id;
1055
               		select data.depth into my_real_data_path from data where data.data_auto_id=my_real_data_auto_id;
1056

    
1057

    
1058

    
1059
               		if my_depth <= my_real_data_path then
1060
               			set my_real_data_path = my_real_data_path + 1;
1061

    
1062
               			  update data set data.depth = my_real_data_path where data.data_auto_id = my_data_id;
1063
               			  call update_child_depth(my_real_data_auto_id,my_real_domain_id,my_real_data_path);
1064
               		end if;
1065
               	end if;
1066
   		end loop my_loop;
1067
END//
1068
DELIMITER ;
1069

    
1070
-- 프로시저 nerv_icde_test.auto_update_data_path 구조 내보내기
1071
DROP PROCEDURE IF EXISTS `auto_update_data_path`;
1072
DELIMITER //
1073
CREATE PROCEDURE `auto_update_data_path`()
1074
BEGIN
1075

    
1076
	declare my_data_id int;
1077
	declare my_domain_id int;
1078
	declare my_depth int;
1079
	declare my_real_data_auto_id int;
1080
	declare my_real_data_path int;
1081

    
1082
	declare no_more_rows bool default false;
1083

    
1084
		DECLARE my_list CURSOR FOR
1085
		select data.data_auto_id, data.domain_id, data.depth, data.real_data_auto_id  from data where data.`type`='alias';
1086

    
1087
		declare continue handler for not found set no_more_rows := TRUE;
1088

    
1089
			open my_list;
1090
			my_loop : loop
1091
				fetch my_list into my_data_id, my_domain_id, my_depth, my_real_data_auto_id;
1092
				if no_more_rows then
1093
					close my_list;
1094
					leave my_loop;
1095
				end if;
1096

    
1097
               		select data.depth into my_real_data_path from data where data.data_auto_id=my_real_data_auto_id;
1098
               		if my_depth <= my_real_data_path then
1099
								set my_depth = my_real_data_path +1;
1100

    
1101
               			call update_child_depth(my_data_id,my_domain_id,my_depth);
1102

    
1103
								 update data set data.depth = my_depth where data.data_auto_id=my_data_id;
1104
							end if;
1105
   		end loop my_loop;
1106

    
1107
END//
1108
DELIMITER ;
1109

    
1110
-- 프로시저 nerv_icde_test.check_child_depth_limit_loop 구조 내보내기
1111
DROP PROCEDURE IF EXISTS `check_child_depth_limit_loop`;
1112
DELIMITER //
1113
CREATE PROCEDURE `check_child_depth_limit_loop`(
1114
	IN `in_domain_id` INT,
1115
	IN `in_data_name` VARCHAR(100),
1116
	IN `in_real_auto_id` INT
1117
)
1118
BEGIN
1119
	declare no_more_rows bool default false;
1120
	declare data_type varchar(100);
1121
	declare data_domain_id int;
1122
	declare data_name varchar(100);
1123
	declare child_data_auto_id int;
1124
	declare limit_count int default 0;
1125
	declare check_data_auto_id int;
1126

    
1127
	DECLARE my_list CURSOR FOR
1128
	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
1129
 	union
1130
	select data.`type`, data.real_data_auto_id from data where data.domain_id=in_domain_id and data.data_auto_id in
1131
 		(select data_field.real_data_auto_id from data_field where  data_field.data_auto_id = in_real_auto_id);
1132

    
1133
	declare continue handler for not found set no_more_rows := TRUE;
1134

    
1135
	set max_sp_recursion_depth = 50;
1136

    
1137
	   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;
1138

    
1139
		open my_list;
1140
		my_loop : loop
1141

    
1142
			fetch my_list into data_type, child_data_auto_id;
1143

    
1144
			 if no_more_rows then
1145
				 close my_list;
1146
				 leave my_loop;
1147
			 end if;
1148
			if check_data_auto_id = child_data_auto_id then
1149
				   select 1 into limit_count;
1150
				   select child_data_auto_id;
1151
				 close my_list;
1152
				 leave my_loop;
1153
			end if;
1154
			 if data_type = 'alias' and limit_count = 0 then
1155
			 	   call check_child_depth_limit_loop( in_domain_id, in_data_name, child_data_auto_id);
1156
			 end if;
1157
		end loop my_loop;
1158
END//
1159
DELIMITER ;
1160

    
1161
-- 프로시저 nerv_icde_test.check_clone_component 구조 내보내기
1162
DROP PROCEDURE IF EXISTS `check_clone_component`;
1163
DELIMITER //
1164
CREATE PROCEDURE `check_clone_component`(IN `in_system_domain_id` INT, IN `in_component_id` INT)
1165
BEGIN
1166
select b.name, c.name from
1167
(
1168
	select * from deployments where id in
1169
		(select deploy_id from custum_proxy where id != original_id and original_id in
1170
			( select id from custum_proxy where deploy_id in
1171
				 (select id from deployments where component_id=in_component_id and systemdomain_id=in_system_domain_id)
1172
			)
1173
		)
1174
) as a
1175
join
1176
domain_system as b on b.id = a.systemdomain_id
1177
join
1178
node as c on c.Id = a.node_id;
1179
END//
1180
DELIMITER ;
1181

    
1182
-- 프로시저 nerv_icde_test.check_method_code 구조 내보내기
1183
DROP PROCEDURE IF EXISTS `check_method_code`;
1184
DELIMITER //
1185
CREATE PROCEDURE `check_method_code`(
1186
	IN `in_domain_id` INT,
1187
	IN `in_code` INT,
1188
	IN `in_type` ENUM('CALL','SIGNAL','EVENT','INFORMATION','COMMAND','BROADCAST'),
1189
	IN `in_method_name` VARCHAR(50)
1190

    
1191
)
1192
BEGIN
1193
	if logintest() then
1194
		select 1 as test;
1195
		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;
1196
	else
1197
	 	select 0 as test;
1198
	end if;
1199

    
1200
END//
1201
DELIMITER ;
1202

    
1203
-- 프로시저 nerv_icde_test.check_overlap_ip 구조 내보내기
1204
DROP PROCEDURE IF EXISTS `check_overlap_ip`;
1205
DELIMITER //
1206
CREATE PROCEDURE `check_overlap_ip`(IN `in_system_domain_id` INT, IN `in_node_id` INT, IN `in_port_id` INT)
1207
BEGIN
1208
	declare logical_port int;
1209
	declare sub_domain_id int;
1210
	declare lock_state int;
1211

    
1212
	delete from network_temp;
1213
	Select sub_system_domain_id into sub_domain_id from node where id = in_node_id;
1214
	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;
1215

    
1216
	call check_overlap_ip_recursion( in_node_id , logical_port , in_node_id , logical_port , 10 );
1217

    
1218
	update network set collision = 1 where (node_id , ip , port)
1219
	 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  ) );
1220
	update network set collision = 0 where (node_id , ip , port)
1221
	 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  ) );
1222

    
1223
	select node.name,  network.port, network.ip, network.mask, network.description from network
1224
	 join node on network.node_id = node.Id where collision = 1 and node.systemdomain_id = in_system_domain_id
1225
	 and (network.node_id , network.ip) in (select node_id , ip from network_temp);
1226
END//
1227
DELIMITER ;
1228

    
1229
-- 프로시저 nerv_icde_test.check_overlap_ip_recursion 구조 내보내기
1230
DROP PROCEDURE IF EXISTS `check_overlap_ip_recursion`;
1231
DELIMITER //
1232
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)
1233
BEGIN
1234
	declare domain_id int;
1235
	declare no_more_rows bool default false;
1236
	declare child_node_id int;
1237
	declare child_port_group int;
1238

    
1239
	DECLARE my_list CURSOR FOR select K.node_id , domain_system_port.port_group from
1240
		 		(
1241
				 	(
1242
					 	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
1243
						 							( d_node_id , d_port_id ) in ( select in_node_id, port_num from domain_system_port as A
1244
													 where A.domain_system_id = domain_id and A.port_group = in_port_group )
1245
					)
1246
						union
1247
				 	(
1248
					 	select d_node_id , d_sub_system_id , d_port_id  from network_link where
1249
						 							( s_node_id , s_port_id ) in ( select in_node_id, port_num from domain_system_port as A
1250
													  where A.domain_system_id = domain_id and A.port_group = in_port_group )
1251
					)
1252
				) as K
1253

    
1254
			join
1255
				domain_system_port on K.sub_system_id = domain_system_port.domain_system_id and K.port_id = domain_system_port.port_num
1256
	where
1257
			not ( K.node_id = in_parent_node_id and domain_system_port.port_group = in_parent_port_group );
1258

    
1259
	declare continue handler for not found set no_more_rows := TRUE;
1260
	set max_sp_recursion_depth = 50;
1261

    
1262
	insert into network_temp select * from network where node_id = in_node_id and port = in_port_group;
1263

    
1264
	if in_depth > 0 then
1265
		select node.sub_system_domain_id into domain_id from node where node.Id = in_node_id;
1266

    
1267
		open my_list;
1268
		my_loop : loop
1269
			fetch my_list into child_node_id , child_port_group;
1270
			if no_more_rows then
1271
				close my_list;
1272
				leave my_loop;
1273
			end if;
1274

    
1275
			call check_overlap_ip_recursion( in_node_id, in_port_group , child_node_id , child_port_group , in_depth - 1 );
1276

    
1277
		end loop my_loop;
1278
	end if;
1279
END//
1280
DELIMITER ;
1281

    
1282
-- 프로시저 nerv_icde_test.check_system_lock_component 구조 내보내기
1283
DROP PROCEDURE IF EXISTS `check_system_lock_component`;
1284
DELIMITER //
1285
CREATE PROCEDURE `check_system_lock_component`(IN `in_domain_id` INT, IN `in_component_id` INT)
1286
BEGIN
1287

    
1288
	if(check_system_lock_domain(in_domain_id)) then
1289
		if(check_system_lock_component_f(in_component_id)) then
1290
			select 1 as return_value;
1291
		else
1292
			select 0 as return_value;
1293
		end if;
1294
	else
1295
		select 0 as return_value;
1296
	end if;
1297

    
1298
END//
1299
DELIMITER ;
1300

    
1301
-- 프로시저 nerv_icde_test.check_system_lock_domain 구조 내보내기
1302
DROP PROCEDURE IF EXISTS `check_system_lock_domain`;
1303
DELIMITER //
1304
CREATE PROCEDURE `check_system_lock_domain`(IN `in_domain_id` INT)
1305
BEGIN
1306

    
1307
	if(check_system_lock_domain(in_domain_id)) then
1308
		select 1 as return_value;
1309
	else
1310
		select 0 as return_value;
1311
	end if;
1312
END//
1313
DELIMITER ;
1314

    
1315
-- 프로시저 nerv_icde_test.check_system_lock_interface 구조 내보내기
1316
DROP PROCEDURE IF EXISTS `check_system_lock_interface`;
1317
DELIMITER //
1318
CREATE PROCEDURE `check_system_lock_interface`(IN `in_domain_id` INT, IN `in_interface_name` VARCHAR(50))
1319
BEGIN
1320

    
1321
	if(check_system_lock_interface(in_domain_id, in_interface_name)) then
1322
		select 1 as return_value;
1323
	else
1324
		select 0 as return_value;
1325
	end if;
1326
END//
1327
DELIMITER ;
1328

    
1329
-- 프로시저 nerv_icde_test.check_system_lock_networklink 구조 내보내기
1330
DROP PROCEDURE IF EXISTS `check_system_lock_networklink`;
1331
DELIMITER //
1332
CREATE PROCEDURE `check_system_lock_networklink`(IN `in_node_id` INT, IN `in_port` INT, IN `in_domain_id` INT)
1333
BEGIN
1334

    
1335
declare sub_domain_id int default 0;
1336

    
1337
select node.sub_system_domain_id into sub_domain_id from node where node.Id=in_node_id;
1338

    
1339
	if(check_system_lock_domain(in_domain_id)) then
1340
		if(check_system_lock_domainport(in_node_id,sub_domain_id,in_port)) then
1341
			select 1 as return_value;
1342
		else
1343
			select 0 as return_value;
1344
		end if;
1345
	else
1346
		select 0 as return_value;
1347
	end if;
1348

    
1349
END//
1350
DELIMITER ;
1351

    
1352
-- 프로시저 nerv_icde_test.check_system_lock_node_port 구조 내보내기
1353
DROP PROCEDURE IF EXISTS `check_system_lock_node_port`;
1354
DELIMITER //
1355
CREATE PROCEDURE `check_system_lock_node_port`(IN `in_node_id` INT, IN `in_node_port` INT)
1356
BEGIN
1357

    
1358
	if(check_system_lock_node_port_f(in_node_id, in_node_port)) then
1359
		select 1 as return_value;
1360
	else
1361
		select 0 as return_value;
1362
	end if;
1363
END//
1364
DELIMITER ;
1365

    
1366
-- 프로시저 nerv_icde_test.check_system_lock_objct 구조 내보내기
1367
DROP PROCEDURE IF EXISTS `check_system_lock_objct`;
1368
DELIMITER //
1369
CREATE PROCEDURE `check_system_lock_objct`(IN `in_deploy_id` INT)
1370
BEGIN
1371

    
1372
	declare deploy_system_domain_id int default 0;
1373

    
1374
	select deployments.systemdomain_id into deploy_system_domain_id from deployments where id=in_deploy_id;
1375

    
1376
	if(check_system_lock_domain(deploy_system_domain_id)) then
1377
		select 1 as return_value;
1378
	else
1379
		select 0 as return_value;
1380
	end if;
1381

    
1382
END//
1383
DELIMITER ;
1384

    
1385
-- 프로시저 nerv_icde_test.check_system_lock_proxy_class 구조 내보내기
1386
DROP PROCEDURE IF EXISTS `check_system_lock_proxy_class`;
1387
DELIMITER //
1388
CREATE PROCEDURE `check_system_lock_proxy_class`(IN `in_proxy_id` INT)
1389
BEGIN
1390
	if(check_system_lock_proxy_class(in_proxy_id)) then
1391
			select 1 as return_value;
1392
	else
1393
		select 0 as return_value;
1394
	end if;
1395
END//
1396
DELIMITER ;
1397

    
1398
-- 프로시저 nerv_icde_test.check_system_lock_proxy_object 구조 내보내기
1399
DROP PROCEDURE IF EXISTS `check_system_lock_proxy_object`;
1400
DELIMITER //
1401
CREATE PROCEDURE `check_system_lock_proxy_object`(IN `in_proxy_id` INT, IN `in_proxy_object_name` VARCHAR(50))
1402
BEGIN
1403
	if(check_system_lock_proxy_object_f(in_proxy_id, in_proxy_object_name)) then
1404
			select 1 as return_value;
1405
	else
1406
		select 0 as return_value;
1407
	end if;
1408
END//
1409
DELIMITER ;
1410

    
1411
-- 프로시저 nerv_icde_test.check_system_lock_proxy_stub_ip 구조 내보내기
1412
DROP PROCEDURE IF EXISTS `check_system_lock_proxy_stub_ip`;
1413
DELIMITER //
1414
CREATE PROCEDURE `check_system_lock_proxy_stub_ip`(IN `in_custum_proxy_id` INT, IN `in_deploy_id` INT)
1415
BEGIN
1416

    
1417
	declare deploy_system_domain_id int default 0;
1418

    
1419
	select deployments.systemdomain_id into deploy_system_domain_id from deployments where id=in_deploy_id;
1420

    
1421
	if(check_system_lock_domain(deploy_system_domain_id)) then
1422
	  if(check_system_lock_proxy_public(in_custum_proxy_id)) then
1423
			select 1 as return_value;
1424
		else
1425
		 	select 0 as return_value;
1426
	   end if;
1427
	else
1428
		select 0 as return_value;
1429
	end if;
1430
END//
1431
DELIMITER ;
1432

    
1433
-- 프로시저 nerv_icde_test.check_system_lock_stub_class 구조 내보내기
1434
DROP PROCEDURE IF EXISTS `check_system_lock_stub_class`;
1435
DELIMITER //
1436
CREATE PROCEDURE `check_system_lock_stub_class`(IN `in_stub_id` INT)
1437
BEGIN
1438

    
1439
	if(check_system_lock_stub_class_f(in_stub_id)) then
1440
			select 1 as return_value;
1441
	else
1442
		select 0 as return_value;
1443
	end if;
1444

    
1445
END//
1446
DELIMITER ;
1447

    
1448
-- 프로시저 nerv_icde_test.check_system_lock_stub_object 구조 내보내기
1449
DROP PROCEDURE IF EXISTS `check_system_lock_stub_object`;
1450
DELIMITER //
1451
CREATE PROCEDURE `check_system_lock_stub_object`(IN `in_stub_id` INT, IN `in_stub_object_name` VARCHAR(50))
1452
BEGIN
1453
	if(check_system_lock_stub_object_f(in_stub_id, in_stub_object_name)) then
1454
			select 1 as return_value;
1455
	else
1456
		select 0 as return_value;
1457
	end if;
1458

    
1459
END//
1460
DELIMITER ;
1461

    
1462
-- 프로시저 nerv_icde_test.componentEntityViewcomponentinfoList 구조 내보내기
1463
DROP PROCEDURE IF EXISTS `componentEntityViewcomponentinfoList`;
1464
DELIMITER //
1465
CREATE PROCEDURE `componentEntityViewcomponentinfoList`(in_componentid int)
1466
BEGIN
1467

    
1468
     if loginTest() then
1469
         select 1 as test;
1470
         select id, systemdomain_id, name, seq, description  from component where id = in_componentid;
1471

    
1472
     else
1473
         select 0 as test;
1474
     end if;
1475

    
1476
End//
1477
DELIMITER ;
1478

    
1479
-- 프로시저 nerv_icde_test.componentEntityViewNewcomponentEntity 구조 내보내기
1480
DROP PROCEDURE IF EXISTS `componentEntityViewNewcomponentEntity`;
1481
DELIMITER //
1482
CREATE PROCEDURE `componentEntityViewNewcomponentEntity`(in_diagrame_id int,
1483
                                                                            in_component_id int,
1484
                                                                            in_position_x   int,
1485
                                                                            in_position_y   int,
1486
                                                                            in_size         int)
1487
BEGIN
1488
        if loginTest() then
1489
                select 1 as test;
1490

    
1491
                if componentEntityCheck(in_diagrame_id, in_component_id) then
1492
                  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;
1493
                else
1494
                  insert into umlcomponent(diagrame_id, component_id, position_x, position_y, size)
1495
                                  values(in_diagrame_id, in_component_id, in_position_x, in_position_y,in_size);
1496
                end if;
1497

    
1498
                select LAST_INSERT_ID();
1499
        else
1500
                select 0 as test;
1501
        end if;
1502
END//
1503
DELIMITER ;
1504

    
1505
-- 프로시저 nerv_icde_test.componentsNewcomponent 구조 내보내기
1506
DROP PROCEDURE IF EXISTS `componentsNewcomponent`;
1507
DELIMITER //
1508
CREATE PROCEDURE `componentsNewcomponent`(insystemdomainid int,
1509
                                                             inname varchar(50),
1510
                                                             indescription text)
1511
BEGIN
1512

    
1513

    
1514
     if loginTest() then
1515
         select 1 as test;
1516
         insert into component(systemdomain_id, name, description)
1517
                        values(insystemdomainid, inname, indescription);
1518
         select LAST_INSERT_ID();
1519

    
1520
     else
1521
         select 0 as test;
1522
     end if;
1523

    
1524

    
1525

    
1526
End//
1527
DELIMITER ;
1528

    
1529
-- 프로시저 nerv_icde_test.componentViewDeletecomponent 구조 내보내기
1530
DROP PROCEDURE IF EXISTS `componentViewDeletecomponent`;
1531
DELIMITER //
1532
CREATE PROCEDURE `componentViewDeletecomponent`(in_component_id int, in_systemdomain_id int)
1533
BEGIN
1534

    
1535

    
1536
        if loginTest() then
1537
                select 1 as test;
1538
                delete from component where
1539
                 id=in_component_id and systemdomain_id = in_systemdomain_id;
1540
        else
1541
                select 0 as test;
1542
        end if;
1543
END//
1544
DELIMITER ;
1545

    
1546
-- 프로시저 nerv_icde_test.ComponentViewEditComponent 구조 내보내기
1547
DROP PROCEDURE IF EXISTS `ComponentViewEditComponent`;
1548
DELIMITER //
1549
CREATE PROCEDURE `ComponentViewEditComponent`(in_component_id int,
1550
                                                                 in_systemdomain_id int,
1551
                                                                      in_name varchar(100),
1552
                                                                      in_description  varchar(100))
1553
BEGIN
1554

    
1555
        if loginTest() then
1556
                select 1 as test;
1557
                       update component set name=in_name, description=in_description
1558
                                    where id=in_component_id and systemdomain_id=in_systemdomain_id;
1559
        else
1560
                select 0 as test;
1561
        end if;
1562
END//
1563
DELIMITER ;
1564

    
1565
-- 프로시저 nerv_icde_test.componentViewList 구조 내보내기
1566
DROP PROCEDURE IF EXISTS `componentViewList`;
1567
DELIMITER //
1568
CREATE PROCEDURE `componentViewList`(indomainid int)
1569
BEGIN
1570

    
1571

    
1572

    
1573
     if loginTest() then
1574
         select 1 as test;
1575
         select Id, systemdomain_id, name, seq, description from component where systemdomain_id = indomainid;
1576

    
1577
     else
1578
         select 0 as test;
1579
     end if;
1580

    
1581

    
1582

    
1583
End//
1584
DELIMITER ;
1585

    
1586
-- 프로시저 nerv_icde_test.copy_node_port_talble 구조 내보내기
1587
DROP PROCEDURE IF EXISTS `copy_node_port_talble`;
1588
DELIMITER //
1589
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)
1590
BEGIN
1591

    
1592
	if logintest() then
1593
  		select 1 as test;
1594
		insert into node_port (node_port.id, node_port.systemdomain_id, node_port.sub_system_domain_id, node_port.port_group)
1595
   	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;
1596
  	else
1597
    	select 0 as test;
1598
   end if;
1599
END//
1600
DELIMITER ;
1601

    
1602
-- 프로시저 nerv_icde_test.coustim_proxyViewlistinfo 구조 내보내기
1603
DROP PROCEDURE IF EXISTS `coustim_proxyViewlistinfo`;
1604
DELIMITER //
1605
CREATE PROCEDURE `coustim_proxyViewlistinfo`(IN `in_node_id` int, IN `in_component_id` int)
1606
BEGIN
1607
        if loginTest() then
1608
                select 1 as test;
1609
                  select a.id, a.deploy_id, a.proxy_interface_id, b.interface_name, b.class_name,
1610
						       a.object_id, a.stub_object_id, a.stub_ip, c.name, c.id, c.standard_port,
1611
								 a.object_name, a.public, a.original_id from
1612
                    ((select id, deploy_id, proxy_interface_id, object_id, stub_object_id, stub_ip, object_name, public, original_id
1613
						   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
1614
                    join
1615
                    (select id, interface_name, class_name, method_domain_id from proxy_interface_relation) as b on b.id = a.proxy_interface_id)
1616
                    join
1617
                    (select id, name, standard_port from domain_method) as c on c.id = b.method_domain_id;
1618
        else
1619
                select 0 as test;
1620
        end if;
1621
END//
1622
DELIMITER ;
1623

    
1624
-- 프로시저 nerv_icde_test.coustim_stubViewlistinfo 구조 내보내기
1625
DROP PROCEDURE IF EXISTS `coustim_stubViewlistinfo`;
1626
DELIMITER //
1627
CREATE PROCEDURE `coustim_stubViewlistinfo`(IN `in_node_id` int, IN `in_component_id` int)
1628
BEGIN
1629
        if loginTest() then
1630
                select 1 as test;
1631
                  select a.id, a.deploy_id, a.stub_interface_id, a.object_id, b.interface_name, b.class_name,
1632
						 c.name, c.id, c.standard_port, a.object_name, a.public, a.original_id from
1633
                    (select id, deploy_id, stub_interface_id, object_id, object_name, public, original_id FROM custum_stub
1634
						   where deploy_id in (select Id from deployments where node_id = in_node_id and component_id =in_component_id)) as a
1635
                    join
1636
                    (select id, interface_name, class_name, method_domain_id from stub_interface_relation) as b on b.id = a.stub_interface_id
1637
                    join
1638
                    (select id, name, standard_port from domain_method) as c on c.id = b.method_domain_id;
1639
        else
1640
                select 0 as test;
1641
        end if;
1642
END//
1643
DELIMITER ;
1644

    
1645
-- 프로시저 nerv_icde_test.coustum_proxyViewDeleteInterface 구조 내보내기
1646
DROP PROCEDURE IF EXISTS `coustum_proxyViewDeleteInterface`;
1647
DELIMITER //
1648
CREATE PROCEDURE `coustum_proxyViewDeleteInterface`(in_deploy_id int,
1649
                                                              in_interface_id int)
1650
BEGIN
1651
        if loginTest() then
1652
                select 1 as test;
1653
                delete from custum_proxy where deploy_id = in_deploy_id and proxy_interface_id = in_interface_id;
1654
        else
1655
                select 0 as test;
1656
        end if;
1657
END//
1658
DELIMITER ;
1659

    
1660
-- 프로시저 nerv_icde_test.coustum_proxyViewNewobjectid 구조 내보내기
1661
DROP PROCEDURE IF EXISTS `coustum_proxyViewNewobjectid`;
1662
DELIMITER //
1663
CREATE PROCEDURE `coustum_proxyViewNewobjectid`(in_deploy_id int,
1664
                                                                  in_interface_id int,
1665
                                                                  in_object_id int,
1666
                                                                  in_object_name varchar(100))
1667
BEGIN
1668
        if loginTest() then
1669
                select 1 as test;
1670
                insert into custum_proxy (deploy_id, proxy_interface_id, object_id, object_name)
1671
                                values(in_deploy_id, in_interface_id, in_object_id, in_object_name);
1672
        else
1673
                select 0 as test;
1674
        end if;
1675
END//
1676
DELIMITER ;
1677

    
1678
-- 프로시저 nerv_icde_test.coustum_stubViewDeleteInterface 구조 내보내기
1679
DROP PROCEDURE IF EXISTS `coustum_stubViewDeleteInterface`;
1680
DELIMITER //
1681
CREATE PROCEDURE `coustum_stubViewDeleteInterface`(in_deploy_id int,
1682
                                                              in_interface_id int)
1683
BEGIN
1684
        if loginTest() then
1685
                select 1 as test;
1686
                delete from custum_stub where deploy_id = in_deploy_id and proxy_interface_id = in_interface_id;
1687
        else
1688
                select 0 as test;
1689
        end if;
1690
END//
1691
DELIMITER ;
1692

    
1693
-- 프로시저 nerv_icde_test.coustum_stubViewNewobjectid 구조 내보내기
1694
DROP PROCEDURE IF EXISTS `coustum_stubViewNewobjectid`;
1695
DELIMITER //
1696
CREATE PROCEDURE `coustum_stubViewNewobjectid`(in_deploy_id int,
1697
                                                                  in_interface_id int,
1698
                                                                  in_object_id int,
1699
                                                                  in_object_name varchar(100))
1700
BEGIN
1701
        if loginTest() then
1702
                select 1 as test;
1703
                insert into custum_stub (deploy_id, stub_interface_id, object_id, object_name)
1704
                                values(in_deploy_id, in_interface_id, in_object_id, in_object_name);
1705
        else
1706
                select 0 as test;
1707
        end if;
1708
END//
1709
DELIMITER ;
1710

    
1711
-- 프로시저 nerv_icde_test.coustum_ViewEditobjectid 구조 내보내기
1712
DROP PROCEDURE IF EXISTS `coustum_ViewEditobjectid`;
1713
DELIMITER //
1714
CREATE PROCEDURE `coustum_ViewEditobjectid`(IN `in_id` int, IN `in_object_id` int, IN `in_type` int, IN `in_public` int)
1715
BEGIN
1716
        if loginTest() then
1717
                select 1 as test;
1718
               if (in_type = 0) then
1719
                   update custum_proxy set object_id=in_object_id, public=in_public where id = in_id;
1720
               else
1721
                   update custum_stub set object_id=in_object_id, public=in_public where id = in_id;
1722
               end if;
1723
        else
1724
                select 0 as test;
1725
        end if;
1726
END//
1727
DELIMITER ;
1728

    
1729
-- 프로시저 nerv_icde_test.data_field_auto_seq 구조 내보내기
1730
DROP PROCEDURE IF EXISTS `data_field_auto_seq`;
1731
DELIMITER //
1732
CREATE PROCEDURE `data_field_auto_seq`()
1733
BEGIN
1734

    
1735
	declare no_more_rows bool default false;
1736
	declare find_data_auto_id int;
1737
	declare find_membername varchar(50);
1738
	declare find_seq timestamp;
1739

    
1740
	DECLARE my_list CURSOR FOR
1741
	select data_field.data_auto_id, data_field.member_name, data_field.seq from data_field;
1742

    
1743
	declare continue handler for not found set no_more_rows := TRUE;
1744

    
1745
	set max_sp_recursion_depth = 50;
1746

    
1747
		open my_list;
1748
		my_loop : loop
1749
			fetch my_list into find_data_auto_id, find_membername, find_seq;
1750

    
1751
			 if no_more_rows then
1752
				 close my_list;
1753
				 leave my_loop;
1754
			 end if;
1755

    
1756
			 	    call data_field_auto_seq_update(find_data_auto_id, find_membername, find_seq);
1757

    
1758
		end loop my_loop;
1759
END//
1760
DELIMITER ;
1761

    
1762
-- 프로시저 nerv_icde_test.data_field_auto_seq_update 구조 내보내기
1763
DROP PROCEDURE IF EXISTS `data_field_auto_seq_update`;
1764
DELIMITER //
1765
CREATE PROCEDURE `data_field_auto_seq_update`(IN `in_data_auto_id` INT, IN `in_member_name` VARCHAR(50), IN `in_seq` TIMESTAMP)
1766
BEGIN
1767
	declare seq_count int default 0;
1768

    
1769
	select count(data_field.seq) into seq_count from data_field
1770
	 where data_field.data_auto_id = in_data_auto_id and data_field.seq = in_seq;
1771

    
1772
   if seq_count > 1 then
1773
      select seq_count;
1774
		 update data_field set data_field.seq = DATE_ADD(in_seq, INTERVAL -seq_count second)
1775
		  where data_field.data_auto_id = in_data_auto_id and data_field.member_name=in_member_name;
1776
	end if;
1777
END//
1778
DELIMITER ;
1779

    
1780
-- 프로시저 nerv_icde_test.delete_subsystem_object 구조 내보내기
1781
DROP PROCEDURE IF EXISTS `delete_subsystem_object`;
1782
DELIMITER //
1783
CREATE PROCEDURE `delete_subsystem_object`(IN `in_custum_id` INT, IN `in_custum_deploy_id` INT, IN `in_type` INT)
1784
BEGIN
1785
   declare subsystem_deploy_id int;
1786
	declare subsystem_proxy_count int;
1787
	declare subsystem_stub_count int;
1788
	declare subsystem_component_id int;
1789
	declare no_more_rows bool default false;
1790
	DECLARE my_list CURSOR FOR
1791
			select deployments.id from deployments where deployments.node_id in (
1792
			select node.id from node where node.sub_system_domain_id in(
1793
			 select deployments.systemdomain_id from deployments where deployments.Id=in_custum_deploy_id));
1794
	declare continue handler for not found set no_more_rows := TRUE;
1795

    
1796
	 if in_type = 0 then
1797
  		select 1 as test;
1798
		 delete from custum_proxy where custum_proxy.original_id=in_custum_id
1799
		  and custum_proxy.original_deployment_id=in_custum_deploy_id
1800
		   and custum_proxy.Id !=in_custum_id and custum_proxy.deploy_id != in_custum_deploy_id;
1801
 else
1802
  	select 1 as test;
1803
 		 delete from custum_stub where custum_stub.original_id=in_custum_id
1804
		   and custum_stub.original_deployment_id=in_custum_deploy_id
1805
			 and custum_stub.Id !=in_custum_id and custum_stub.deploy_id != in_custum_deploy_id;
1806
 end if;
1807

    
1808
set max_sp_recursion_depth = 50;
1809

    
1810
	open my_list;
1811
			my_loop : loop
1812
				fetch my_list into subsystem_deploy_id;
1813
				if no_more_rows then
1814
					close my_list;
1815
					leave my_loop;
1816
				end if;
1817

    
1818
				select count(custum_proxy.deploy_id) into subsystem_proxy_count from custum_proxy
1819
				 where custum_proxy.deploy_id = subsystem_deploy_id;
1820
 				select count(custum_stub.deploy_id) into subsystem_stub_count from custum_stub
1821
				  where custum_stub.deploy_id =subsystem_deploy_id;
1822

    
1823
 				if subsystem_proxy_count = 0 and subsystem_stub_count=0 then
1824
				 	select deployments.component_id into subsystem_component_id from deployments
1825
					  where deployments.Id = 	subsystem_deploy_id;
1826
 	 				  delete from component where component.id = subsystem_component_id;
1827
 	 			end if;
1828
	end loop my_loop;
1829
END//
1830
DELIMITER ;
1831

    
1832
-- 프로시저 nerv_icde_test.deployComponentViewInterfaceinfo 구조 내보내기
1833
DROP PROCEDURE IF EXISTS `deployComponentViewInterfaceinfo`;
1834
DELIMITER //
1835
CREATE PROCEDURE `deployComponentViewInterfaceinfo`(IN `in_component_id` INT)
1836
BEGIN
1837

    
1838
 	if logintest() then
1839
 		select 1 as test;
1840

    
1841
 		select a.id, a.method_domain_id, a.component_id, a.interface_name, b.name, a.class_name from
1842
  		(select stub_interface_relation.Id, stub_interface_relation.method_domain_id, stub_interface_relation.component_id
1843
		  , stub_interface_relation.interface_name, stub_interface_relation.class_name from stub_interface_relation where id in
1844
			(select stub_interface_id from custum_stub where deploy_id in
1845
			 (select id from deployments where component_id = in_component_id))) as a
1846
		join domain_method as b on a.method_domain_id = b.id;
1847
   else
1848
   	select 0 as test;
1849
   end if;
1850
END//
1851
DELIMITER ;
1852

    
1853
-- 프로시저 nerv_icde_test.deploymentsViewDeploymentslist 구조 내보내기
1854
DROP PROCEDURE IF EXISTS `deploymentsViewDeploymentslist`;
1855
DELIMITER //
1856
CREATE PROCEDURE `deploymentsViewDeploymentslist`(
1857
	IN `in_systemdomainid` int,
1858
	IN `in_componentid` int
1859

    
1860
)
1861
BEGIN
1862
     if loginTest() then
1863
    select 1 as test;
1864
         select Id, node_id, component_id, systemdomain_id from deployments
1865
                     where systemdomain_id = in_systemdomainid and component_id = in_componentid;
1866

    
1867
     else
1868
         select 0 as test;
1869
     end if;
1870
End//
1871
DELIMITER ;
1872

    
1873
-- 프로시저 nerv_icde_test.deploymentsViewIdInfo 구조 내보내기
1874
DROP PROCEDURE IF EXISTS `deploymentsViewIdInfo`;
1875
DELIMITER //
1876
CREATE PROCEDURE `deploymentsViewIdInfo`(in_nodeid int,
1877
                                                            in_componentid int)
1878
BEGIN
1879

    
1880
     if loginTest() then
1881
    select 1 as test;
1882
         select Id from deployments where node_id = in_nodeid and component_id = in_componentid;
1883

    
1884
     else
1885
         select 0 as test;
1886
     end if;
1887

    
1888

    
1889

    
1890
End//
1891
DELIMITER ;
1892

    
1893
-- 프로시저 nerv_icde_test.deployments_bindTableNewBind 구조 내보내기
1894
DROP PROCEDURE IF EXISTS `deployments_bindTableNewBind`;
1895
DELIMITER //
1896
CREATE PROCEDURE `deployments_bindTableNewBind`(IN `in_deployment_id` INT, IN `in_node_id` INT, IN `in_port` INT, IN `in_ip` VARCHAR(255))
1897
BEGIN
1898

    
1899
declare total_num int;
1900

    
1901
set total_num = 0;
1902

    
1903
	if logintest() then
1904
		select 1 as test;
1905
		select count(*) into total_num from deployments_bind where deployments_bind.deployment_id = in_deployment_id;
1906

    
1907
		if total_num = 0 then
1908
			insert into deployments_bind (deployments_bind.deployment_id, deployments_bind.node_id, deployments_bind.port, deployments_bind.ip)
1909
			       values(in_deployment_id,in_node_id,in_port,in_ip);
1910
		else
1911
			update deployments_bind set deployments_bind.port = in_port, deployments_bind.ip = in_ip
1912
			 where deployments_bind.deployment_id = in_deployment_id;
1913
		end if;
1914
   else
1915
      select 0 as test;
1916
   end if;
1917
END//
1918
DELIMITER ;
1919

    
1920
-- 프로시저 nerv_icde_test.deployments_bind_table_info 구조 내보내기
1921
DROP PROCEDURE IF EXISTS `deployments_bind_table_info`;
1922
DELIMITER //
1923
CREATE PROCEDURE `deployments_bind_table_info`(IN `in_deployment_id` INT)
1924
BEGIN
1925
	if logintest() then
1926
		select 1 as test;
1927
		select deployments_bind.node_id, deployments_bind.port, deployments_bind.ip from deployments_bind
1928
		 where deployments_bind.deployment_id = in_deployment_id;
1929
	else
1930
		select 0 as test;
1931
	end if;
1932
END//
1933
DELIMITER ;
1934

    
1935
-- 프로시저 nerv_icde_test.diagramViewList 구조 내보내기
1936
DROP PROCEDURE IF EXISTS `diagramViewList`;
1937
DELIMITER //
1938
CREATE PROCEDURE `diagramViewList`(IN `indomainid` int)
1939
BEGIN
1940
     if loginTest() then
1941
         select 1 as test;
1942
         select Id, domain_id, type, name, description
1943
          from diagrame where domain_id = indomainid;
1944
     else
1945
         select 0 as test;
1946
     end if;
1947
End//
1948
DELIMITER ;
1949

    
1950
-- 프로시저 nerv_icde_test.diagramViewNewDiagram 구조 내보내기
1951
DROP PROCEDURE IF EXISTS `diagramViewNewDiagram`;
1952
DELIMITER //
1953
CREATE PROCEDURE `diagramViewNewDiagram`(in_domainid int,
1954
                                                            in_type  int,
1955
                                                            in_name  varchar(100),
1956
                                                            in_description  text)
1957
BEGIN
1958
        if loginTest() then
1959
                select 1 as test;
1960
                insert into diagrame(domain_id, type, name, description )
1961
                                 values(in_domainid, in_type, in_name, in_description);
1962
                select LAST_INSERT_ID();
1963
        else
1964
                select 0 as test;
1965
        end if;
1966
END//
1967
DELIMITER ;
1968

    
1969
-- 프로시저 nerv_icde_test.domainAccountViewJoinPrivateDomain 구조 내보내기
1970
DROP PROCEDURE IF EXISTS `domainAccountViewJoinPrivateDomain`;
1971
DELIMITER //
1972
CREATE PROCEDURE `domainAccountViewJoinPrivateDomain`(IN `in_domainname` varchar(100), IN `in_domainupperid` int, IN `in_domaintype` varchar(100))
1973
BEGIN
1974
     DECLARE domain_id int;
1975
     DECLARE flag tinyint;
1976
     set domain_id = 0;
1977
     set flag =0;
1978

    
1979
        if loginTest() then
1980
           select 1 as test;
1981
           select exitDomainId(in_domainname, in_domainupperid, in_domaintype) into domain_id;
1982
           select existMemberDomain(domain_id, @nervuser, in_domaintype) into flag;
1983

    
1984
           if(flag <= 0) then
1985
                   if(in_domaintype ='data') then
1986
                     insert into members_domain_data(domain_id, user_id, member_type) values(domain_id,@nervuser,'guest');
1987
                   end if;
1988
                   if(in_domaintype ='method') then
1989
                      insert into members_domain_method(domain_id, user_id, member_type) values(domain_id,@nervuser,'guest');
1990
                   end if;
1991
                   if(in_domaintype ='system') then
1992
                       insert into members_domain_system(domain_id, user_id, member_type) values(domain_id,@nervuser,'guest');
1993
                   end if;
1994
           end if;
1995
           select domain_id as test;
1996
        else
1997
                select 0 as test;
1998
        end if;
1999
END//
2000
DELIMITER ;
2001

    
2002
-- 프로시저 nerv_icde_test.domainDataInfo 구조 내보내기
2003
DROP PROCEDURE IF EXISTS `domainDataInfo`;
2004
DELIMITER //
2005
CREATE PROCEDURE `domainDataInfo`(domain_idkey int, domaintype varchar(50))
2006
BEGIN
2007
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
2008
                select 1 as test;
2009
                  select id , upper_id, name , user_id, public, create_date, last_update, description
2010
                    from domain_data where id=domain_idkey;
2011
        else
2012
                select 0 as test;
2013
        end if;
2014
END//
2015
DELIMITER ;
2016

    
2017
-- 프로시저 nerv_icde_test.domainId 구조 내보내기
2018
DROP PROCEDURE IF EXISTS `domainId`;
2019
DELIMITER //
2020
CREATE PROCEDURE `domainId`(domainnamekey varchar(100), domaintype varchar(100))
2021
BEGIN
2022

    
2023
        if loginTest() then
2024
                select 1 as test;
2025

    
2026
                       if(domaintype='data') then
2027
                        select id from domain_data where name = domainnamekey;
2028
                       end if;
2029
                       if(domaintype='method') then
2030
                        select id from domain_method where name = domainnamekey;
2031
                       end if;
2032
                       if(domaintype='system') then
2033
                        select id from domain_system where name = domainnamekey;
2034
                       end if;
2035

    
2036
       else
2037
               select 0 as test;
2038
       end if;
2039
END//
2040
DELIMITER ;
2041

    
2042
-- 프로시저 nerv_icde_test.domainLogicalPortViewDeletePort 구조 내보내기
2043
DROP PROCEDURE IF EXISTS `domainLogicalPortViewDeletePort`;
2044
DELIMITER //
2045
CREATE PROCEDURE `domainLogicalPortViewDeletePort`(IN `in_system_domain_id` int, IN `in_port_group` int)
2046
BEGIN
2047
     if loginTest() and logical_port_group_count(in_system_domain_id, in_port_group)=0 then
2048
         select 1 as test;
2049
         delete from domain_system_logical_port where domain_system_id = in_system_domain_id and port_group = in_port_group;
2050
     else
2051
         select 2 as test;
2052
     end if;
2053
End//
2054
DELIMITER ;
2055

    
2056
-- 프로시저 nerv_icde_test.domainLogicalPortViewNewPortGroup 구조 내보내기
2057
DROP PROCEDURE IF EXISTS `domainLogicalPortViewNewPortGroup`;
2058
DELIMITER //
2059
CREATE PROCEDURE `domainLogicalPortViewNewPortGroup`(in_domain_id int, in_group int)
2060
BEGIN
2061
     if loginTest() and logical_port_group_count(in_domain_id, in_group)=0 then
2062
         select 1 as test;
2063
         insert into domain_system_logical_port(domain_system_id, port_group)
2064
                           values(in_domain_id, in_group);
2065
     else
2066
         select 0 as test;
2067
     end if;
2068
End//
2069
DELIMITER ;
2070

    
2071
-- 프로시저 nerv_icde_test.domainLogicalViewlist 구조 내보내기
2072
DROP PROCEDURE IF EXISTS `domainLogicalViewlist`;
2073
DELIMITER //
2074
CREATE PROCEDURE `domainLogicalViewlist`(IN `in_domain_id` INT)
2075
BEGIN
2076

    
2077
  if logintest() then
2078
  select 1 as test;
2079
  	select port_group from domain_system_logical_port where domain_system_id = in_domain_id;
2080
  else
2081
    select 0 as test;
2082
  end if;
2083
END//
2084
DELIMITER ;
2085

    
2086
-- 프로시저 nerv_icde_test.domainMethodInfo 구조 내보내기
2087
DROP PROCEDURE IF EXISTS `domainMethodInfo`;
2088
DELIMITER //
2089
CREATE PROCEDURE `domainMethodInfo`(domain_idkey int, domaintype varchar(50))
2090
BEGIN
2091
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
2092
                select 1 as test;
2093
                  select id , upper_id, name , user_id, public, standard_port, create_date, last_update, description
2094
                    from domain_method where id=domain_idkey;
2095
        else
2096
                select 0 as test;
2097
        end if;
2098
END//
2099
DELIMITER ;
2100

    
2101
-- 프로시저 nerv_icde_test.domainName 구조 내보내기
2102
DROP PROCEDURE IF EXISTS `domainName`;
2103
DELIMITER //
2104
CREATE PROCEDURE `domainName`(idkey varchar(100), domaintype varchar(100))
2105
BEGIN
2106

    
2107
        if loginTest() then
2108
                select 1 as test;
2109
                       if(domaintype='data') then
2110
                        select name from domain_data where id = idkey;
2111
                       end if;
2112
                       if(domaintype='method') then
2113
                        select name from domain_method where id = idkey;
2114
                       end if;
2115
                       if(domaintype='system') then
2116
                        select name from domain_system where id = idkey;
2117
                       end if;
2118

    
2119
       else
2120
               select 0 as test;
2121
       end if;
2122
END//
2123
DELIMITER ;
2124

    
2125
-- 프로시저 nerv_icde_test.domainnametoid 구조 내보내기
2126
DROP PROCEDURE IF EXISTS `domainnametoid`;
2127
DELIMITER //
2128
CREATE PROCEDURE `domainnametoid`(domain_name varchar(100), domaintype varchar(100))
2129
BEGIN
2130

    
2131
        if loginTest() then
2132
                select 1 as test;
2133
                       if(domaintype='data') then
2134
                        select id from domain_data where name = domain_name;
2135
                       end if;
2136
                       if(domaintype='method') then
2137
                        select id from domain_method where name = domain_name;
2138
                       end if;
2139
                       if(domaintype='system') then
2140
                        select id from domain_system where name = domain_name;
2141
                       end if;
2142

    
2143
       else
2144
               select 0 as test;
2145
       end if;
2146
END//
2147
DELIMITER ;
2148

    
2149
-- 프로시저 nerv_icde_test.domainPortViewDeletePort 구조 내보내기
2150
DROP PROCEDURE IF EXISTS `domainPortViewDeletePort`;
2151
DELIMITER //
2152
CREATE PROCEDURE `domainPortViewDeletePort`(in_system_domain_id int, in_port_num int)
2153
BEGIN
2154
     if loginTest() then
2155
         select 1 as test;
2156
         delete from domain_system_port where domain_system_id = in_system_domain_id and port_num = in_port_num;
2157
     else
2158
         select 0 as test;
2159
     end if;
2160
End//
2161
DELIMITER ;
2162

    
2163
-- 프로시저 nerv_icde_test.domainPortViewEditPort 구조 내보내기
2164
DROP PROCEDURE IF EXISTS `domainPortViewEditPort`;
2165
DELIMITER //
2166
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))
2167
BEGIN
2168
     if loginTest() then
2169
         select 1 as test;
2170
         UPDATE domain_system_port set port_num=in_port_edit, port_group=in_port_group, description=in_description_edit
2171
			 where domain_system_id = in_system_domain_id and port_num = in_port_key;
2172
     else
2173
         select 0 as test;
2174
     end if;
2175
End//
2176
DELIMITER ;
2177

    
2178
-- 프로시저 nerv_icde_test.domainPortViewNewPort 구조 내보내기
2179
DROP PROCEDURE IF EXISTS `domainPortViewNewPort`;
2180
DELIMITER //
2181
CREATE PROCEDURE `domainPortViewNewPort`(in_domain_id int, in_port int, in_port_group int, in_description varchar(100))
2182
BEGIN
2183
     if loginTest() then
2184
         select 1 as test;
2185
         insert into domain_system_port(domain_system_id, port_num, port_group, description)
2186
                           values(in_domain_id, in_port, in_port_group, in_description);
2187
     else
2188
         select 0 as test;
2189
     end if;
2190
End//
2191
DELIMITER ;
2192

    
2193
-- 프로시저 nerv_icde_test.domainviewCheckOverlapDomainName 구조 내보내기
2194
DROP PROCEDURE IF EXISTS `domainviewCheckOverlapDomainName`;
2195
DELIMITER //
2196
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))
2197
BEGIN
2198
  if loginTest() then
2199
     select 1 as test;
2200
     if in_domain_type='data' then
2201
     		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;
2202
     end if;
2203

    
2204
     if in_domain_type='method' then
2205
     	   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;
2206
     end if;
2207

    
2208
     if in_domain_type='system' then
2209
         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;
2210
     end if;
2211
  else
2212
  		select 0 as test;
2213
  end if;
2214
END//
2215
DELIMITER ;
2216

    
2217
-- 프로시저 nerv_icde_test.domainViewDeleteDomain 구조 내보내기
2218
DROP PROCEDURE IF EXISTS `domainViewDeleteDomain`;
2219
DELIMITER //
2220
CREATE PROCEDURE `domainViewDeleteDomain`(domain_id int, domain_type varchar(50) )
2221
BEGIN
2222
        if loginTest() and domainWriteTest(domain_id, domain_type) then
2223
                select 1 as test;
2224

    
2225
                if(domain_type = 'method') then
2226
                        delete from domain_method where id=domain_id;
2227
               end if;
2228

    
2229
                if (domain_type = 'data') then
2230
                        delete from domain_data where id=domain_id;
2231
               end if;
2232

    
2233
                if (domain_type = 'system') then
2234
                        delete from domain_system where id=domain_id;
2235
                end if;
2236

    
2237
        else
2238
                select 0 as test;
2239
        end if;
2240
END//
2241
DELIMITER ;
2242

    
2243
-- 프로시저 nerv_icde_test.domainViewDeleteParentDomain 구조 내보내기
2244
DROP PROCEDURE IF EXISTS `domainViewDeleteParentDomain`;
2245
DELIMITER //
2246
CREATE PROCEDURE `domainViewDeleteParentDomain`(domain_idvalue int, domaintype varchar(100), parentdomain_idvalue int, parentdomain_type int)
2247
BEGIN
2248

    
2249
        if loginTest() and domainWriteTest(domain_idvalue, domaintype) then
2250
                select 1 as test;
2251
                if parentdomain_type = 0 then
2252
                   delete from inheritance_data_data where domain_id = domain_idvalue and parent_domain_id = parentdomain_idvalue;
2253
               end if;
2254
                if parentdomain_type = 1 then
2255
                   delete from inheritance_method_data where domain_id = domain_idvalue and parent_domain_id = parentdomain_idvalue;
2256
               end if;
2257
                if parentdomain_type = 2 then
2258
                   delete from inheritance_method_method where domain_id = domain_idvalue and parent_domain_id = parentdomain_idvalue;
2259
               end if;
2260
                if parentdomain_type = 3 then
2261
                   delete from inheritance_system_method where domain_id = domain_idvalue and parent_domain_id = parentdomain_idvalue;
2262
               end if;
2263
         else
2264
                select 0 as test;
2265
        end if;
2266
END//
2267
DELIMITER ;
2268

    
2269
-- 프로시저 nerv_icde_test.domainViewDomainInfo 구조 내보내기
2270
DROP PROCEDURE IF EXISTS `domainViewDomainInfo`;
2271
DELIMITER //
2272
CREATE PROCEDURE `domainViewDomainInfo`(domain_idkey int, domaintype varchar(50))
2273
BEGIN
2274
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
2275
                select 1 as test;
2276

    
2277
                if(domaintype = 'data') then
2278
                   select a.name , u.user_id, u.userdesc , b.* , c.mcnt, d.*, a.public, a.description, a.create_date, a.last_update  from
2279
                                ( select * from domain_data where id=domain_idkey) as a
2280
                   join        ( select user_id,description as userdesc from users ) as u on a.user_id = u.user_id
2281
                   join        ( select count(name) as scnt from data where domain_id=domain_idkey ) as b
2282
                   join        ( select count(domain_id) as mcnt from inheritance_method_data where parent_domain_id=domain_idkey ) as c
2283
                   join        ( select count(name) as icnt from interface where domain_id=domain_idkey ) as d;
2284
                end if;
2285
                if(domaintype = 'method') then
2286
                   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
2287
                                 ( select * from domain_method where id=domain_idkey) as a
2288
                   join        ( select user_id,description as userdesc from users ) as u on a.user_id = u.user_id
2289
                   join        ( select count(domain_id) as scnt from inheritance_method_data where domain_id=domain_idkey ) as b
2290
                   join        ( select count(name) as mcnt from method where domain_id=domain_idkey ) as c
2291
                   join        ( select count(domain_id) as icnt from interface where domain_id=domain_idkey ) as d;
2292
                end if;
2293
                if(domaintype = 'system') then
2294
                   select a.name , u.user_id, u.userdesc , b.* , c.mcnt,d.*, a.public, a.description,a.create_date, a.last_update  from
2295
                                ( select * from domain_system where id=domain_idkey) as a
2296
                   join        ( select user_id,description as userdesc from users ) as u on a.user_id = u.user_id
2297
                   join        ( select count(name) as scnt from data where domain_id=domain_idkey ) as b
2298
                   join        ( select count(name) as mcnt from method where domain_id=domain_idkey ) as c
2299
                   join        ( select count(name) as icnt from interface where domain_id=domain_idkey ) as d;
2300
                end if;
2301

    
2302
        else
2303
                select 0 as test;
2304
        end if;
2305
END//
2306
DELIMITER ;
2307

    
2308
-- 프로시저 nerv_icde_test.domainViewEditDomain 구조 내보내기
2309
DROP PROCEDURE IF EXISTS `domainViewEditDomain`;
2310
DELIMITER //
2311
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)
2312
BEGIN
2313
        declare cnt int;
2314
        set cnt = 0;
2315

    
2316
        if loginTest() and domainWriteTest(domain_idkey, domaintypevalue) then
2317
                select 1 as test;
2318
                if (domaintypevalue='data') then
2319
                        update domain_data set name=edit_domain_name, public=publicvalue,description=descriptionvalue where id=domain_idkey;
2320
                end if;
2321
                if (domaintypevalue='method') then
2322
                        update domain_method set  name=edit_domain_name, standard_port=standardportvalue, public=publicvalue,description=descriptionvalue
2323
								 where id=domain_idkey;
2324
                end if;
2325
                if (domaintypevalue='system') then
2326
                        update domain_system set  name=edit_domain_name, public=publicvalue,description=descriptionvalue where id=domain_idkey;
2327
                end if;
2328

    
2329
        else
2330
                select 0 as test;
2331
        end if;
2332
END//
2333
DELIMITER ;
2334

    
2335
-- 프로시저 nerv_icde_test.domainViewEditDomainName 구조 내보내기
2336
DROP PROCEDURE IF EXISTS `domainViewEditDomainName`;
2337
DELIMITER //
2338
CREATE PROCEDURE `domainViewEditDomainName`(domain_idkey int,
2339
                                                               domaintypevalue varchar(50),
2340
                                                               edit_domain_name varchar(100))
2341
BEGIN
2342
        declare cnt int;
2343
        set cnt = 0;
2344

    
2345
        if loginTest() and domainWriteTest(domain_idkey, domaintypevalue) then
2346
                select 1 as test;
2347
                if (domaintypevalue='data') then
2348
                        update domain_data set name=edit_domain_name where id=domain_idkey;
2349
                end if;
2350
                if (domaintypevalue='method') then
2351
                        update domain_method set  name=edit_domain_name where id=domain_idkey;
2352
                end if;
2353
                if (domaintypevalue='system') then
2354
                        update domain_system set  name=edit_domain_name where id=domain_idkey;
2355
                end if;
2356
        else
2357
                select 0 as test;
2358
        end if;
2359
END//
2360
DELIMITER ;
2361

    
2362
-- 프로시저 nerv_icde_test.domainViewEditUpperIDDomain 구조 내보내기
2363
DROP PROCEDURE IF EXISTS `domainViewEditUpperIDDomain`;
2364
DELIMITER //
2365
CREATE PROCEDURE `domainViewEditUpperIDDomain`(in_domain_id_key int, in_edit_upper_id int, in_domain_type varchar(50))
2366
BEGIN
2367
       if loginTest() and domainWriteTest(in_domain_id_key, in_domain_type) then
2368
                select 1 as test;
2369
                if (in_domain_type='data') then
2370
                        update domain_data set upper_id=in_edit_upper_id where id=in_domain_id_key;
2371
                end if;
2372
                if (in_domain_type='method') then
2373
                        update domain_method set  upper_id=in_edit_upper_id where id=in_domain_id_key;
2374
                end if;
2375
                if (in_domain_type='system') then
2376
                        update domain_system set  upper_id=in_edit_upper_id where id=in_domain_id_key;
2377
                end if;
2378

    
2379
        else
2380
                select 0 as test;
2381
        end if;
2382
END//
2383
DELIMITER ;
2384

    
2385
-- 프로시저 nerv_icde_test.domainViewNewDomain 구조 내보내기
2386
DROP PROCEDURE IF EXISTS `domainViewNewDomain`;
2387
DELIMITER //
2388
CREATE PROCEDURE `domainViewNewDomain`(domaintype varchar(50),
2389
                                                          upper_idvalue  int,
2390
                                                           namevalue varchar(100),
2391
                                                           standardportvalue int,
2392
                                                           publicvalue bool,
2393
                                                           descriptionvalue text)
2394
BEGIN
2395
        declare nd bool;
2396
        declare cnt int default 0;
2397

    
2398
        set nd = false;
2399
        set @logdate = DATE_FORMAT(DATE_ADD(SYSDATE(), INTERVAL 0 DAY), '%Y%m%d%H%i%s');
2400

    
2401

    
2402
        if loginTest() and newDomainTest() then
2403
                select 1 as test;
2404
                if (domaintype='data') then
2405
                insert into domain_data(upper_id, name, user_id, public, create_date, last_update,description )
2406
                                 values(upper_idvalue, namevalue, @nervuser, publicvalue, @logdate, @logdate,descriptionvalue);
2407
                select LAST_INSERT_ID();
2408
                end if;
2409
                if (domaintype='method') then
2410
                insert into domain_method(upper_id, name, user_id, public,  standard_port, create_date, last_update,description )
2411
                                 values(upper_idvalue, namevalue, @nervuser, publicvalue, standardportvalue, @logdate, @logdate,descriptionvalue);
2412
                select LAST_INSERT_ID();
2413
                end if;
2414
                if (domaintype='system') then
2415
                 select count(name) into cnt from domain_system where name=namevalue and upper_id = upper_idvalue;
2416
                 if cnt > 0 then
2417
                        select 0 as test;
2418
                else
2419
                       insert into domain_system(upper_id, name, user_id, public, create_date, last_update,description )
2420
                                          values(upper_idvalue, namevalue, @nervuser, publicvalue, @logdate, @logdate,descriptionvalue);
2421
                       select LAST_INSERT_ID();
2422
                end if;
2423
               end if;
2424
        else
2425
                select 0 as test;
2426
        end if;
2427
END//
2428
DELIMITER ;
2429

    
2430
-- 프로시저 nerv_icde_test.domainViewNewParentCandidateList 구조 내보내기
2431
DROP PROCEDURE IF EXISTS `domainViewNewParentCandidateList`;
2432
DELIMITER //
2433
CREATE PROCEDURE `domainViewNewParentCandidateList`(IN `domain_idkey` int, IN `domaintype` varchar(50), IN `parentdomain_type` int)
2434
BEGIN
2435
        if loginTest() and domainWriteTest(domain_idkey, domaintype) then
2436
                select 1 as test;
2437
                if( supermanagerTest(@nervuser) ) then
2438
                       if(parentdomain_type=0) then
2439
                                select * from domain_data where id not in
2440
                                 (select parent_domain_id from inheritance_data_data where domain_id=domain_idkey) order by id desc;
2441
                        end if;
2442
                           if(parentdomain_type=1) then
2443
                                select * from domain_data where id not in
2444
                                 (select parent_domain_id from inheritance_method_data where domain_id=domain_idkey) order by id desc;
2445
                        end if;
2446
                           if(parentdomain_type=2) then
2447
                                select * from domain_method where id not in
2448
                                 (select parent_domain_id from inheritance_method_method where domain_id=domain_idkey) order by id desc;
2449
                        end if;
2450
                           if(parentdomain_type=3) then
2451
                                select * from domain_system where id not in
2452
                                 (select parent_domain_id from inheritance_system_method where domain_id=domain_idkey) order by id desc;
2453
                        end if;
2454
                else
2455
                        if(parentdomain_type=0) then
2456
                         select * from domain_data where (user_id=@nervuser or public =1)
2457
                                                     and (id not in (select parent_domain_id FROM inheritance_data_data where domain_id= domain_idkey))
2458
                                                     and (id != 0);
2459
                        end if;
2460
                        if(parentdomain_type=1) then
2461
                          select * from domain_data where (user_id=@nervuser or public =1)
2462
                                                     and (id not in (select parent_domain_id FROM inheritance_method_data where domain_id= domain_idkey))
2463
                                                     and (id != 0);
2464
                        end if;
2465
                        if(parentdomain_type=2) then
2466
                          select * from domain_method where (user_id=@nervuser or public =1)
2467
                                                     and (id not in (select parent_domain_id FROM inheritance_method_method where domain_id= domain_idkey));
2468
                        end if;
2469
                        if(parentdomain_type=3) then
2470
                                select * from
2471
                                (
2472
                                        (
2473
                                          select domain_id from members_domain_system where user_id=@nervuser
2474
														and (member_type='manager' or member_type='member')
2475
                                        )
2476
                                        union distinct
2477
                                        (
2478
                                                select domain_id from domain_system where (user_id=@nervuser or public=true )
2479
                                        ) order by domain_id desc
2480
                                ) as a
2481
                                where  domain_id not in
2482
                                        (select parent_domain_id from inheritance_system_method where domain_id=domain_idkey);
2483
                        end if;
2484
                end if;
2485
       else
2486
               select 0 as test;
2487
       end if;
2488
END//
2489
DELIMITER ;
2490

    
2491
-- 프로시저 nerv_icde_test.domainViewNewParentDomain 구조 내보내기
2492
DROP PROCEDURE IF EXISTS `domainViewNewParentDomain`;
2493
DELIMITER //
2494
CREATE PROCEDURE `domainViewNewParentDomain`(IN `domain_idkey` int, IN `domaintype` varchar(50), IN `parent_domain_idkey` int, IN `parentdomaintype` int)
2495
BEGIN
2496
        declare uid varchar(100);
2497

    
2498
        if loginTest() and domainWriteTest(domain_idkey, domaintype)
2499
                       and existDomain(domain_idkey, domaintype) then
2500
            select 1 as test;
2501
                if parentdomaintype=0 then
2502
                   if(domain_idkey != parent_domain_idkey and existDomain(parent_domain_idkey, domaintype)) then
2503
                          insert into inheritance_data_data(domain_id,parent_domain_id) values(domain_idkey,parent_domain_idkey);
2504
                   else
2505
                       select 0;
2506
                   end if;
2507
                end if;
2508
                if parentdomaintype=1 then
2509
                   if(existDomain(parent_domain_idkey, 'data')) then
2510
                          insert into inheritance_method_data(domain_id,parent_domain_id) values(domain_idkey,parent_domain_idkey);
2511
                    else
2512
                       select 0;
2513
                   end if;
2514
                end if;
2515
                if parentdomaintype=2 then
2516
                   if (method_domainCompatibleTest(domain_idkey,parent_domain_idkey, parentdomaintype)
2517
						  and domain_idkey != parent_domain_idkey and existDomain(parent_domain_idkey, domaintype)) then
2518
                      insert into inheritance_method_method(domain_id,parent_domain_id) values(domain_idkey,parent_domain_idkey);
2519
                   else
2520
                        select 2 as test;
2521
                   end if;
2522
                end if;
2523
                if parentdomaintype=3 then
2524
                if(domain_idkey != parent_domain_idkey and existDomain(parent_domain_idkey, domaintype)) then
2525
                   insert into inheritance_system_method(domain_id,parent_domain_id) values(domain_idkey,parent_domain_idkey);
2526
                 else
2527
                       select 0;
2528
                 end if;
2529
                end if;
2530

    
2531
        else
2532
                select 0 as test;
2533
        end if;
2534
END//
2535
DELIMITER ;
2536

    
2537
-- 프로시저 nerv_icde_test.domainViewUpperList 구조 내보내기
2538
DROP PROCEDURE IF EXISTS `domainViewUpperList`;
2539
DELIMITER //
2540
CREATE PROCEDURE `domainViewUpperList`(in_upper_idkey varchar(100), domaintype varchar(100))
2541
BEGIN
2542

    
2543
        if loginTest() then
2544
                select 1 as test;
2545
                       if(domaintype='data') then
2546
                        select id,name, upper_id, user_id,create_date, last_update, description from domain_data where upper_id = in_upper_idkey;
2547
                       end if;
2548
                       if(domaintype='method') then
2549
                        select id, name, upper_id, user_id, public, create_date, last_update, description from domain_method where upper_id = in_upper_idkey;
2550
                       end if;
2551
                       if(domaintype='system') then
2552
                        select id,name, upper_id, user_id, create_date, last_update, description from domain_system where upper_id = in_upper_idkey;
2553
                       end if;
2554

    
2555
       else
2556
               select 0 as test;
2557
       end if;
2558
END//
2559
DELIMITER ;
2560

    
2561
-- 프로시저 nerv_icde_test.domain_table_Info 구조 내보내기
2562
DROP PROCEDURE IF EXISTS `domain_table_Info`;
2563
DELIMITER //
2564
CREATE PROCEDURE `domain_table_Info`(domain_idkey int, domaintype varchar(50))
2565
BEGIN
2566
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
2567
                select 1 as test;
2568

    
2569
                if(domaintype = 'data') then
2570
                   select id , upper_id, name , user_id, public, create_date, last_update, description  from domain_data where id=domain_idkey;
2571
                end if;
2572
                if(domaintype = 'method') then
2573
                 select id , upper_id, name , user_id, public, standard_port, create_date, last_update, description  from domain_method where id=domain_idkey;
2574
                end if;
2575
                if(domaintype = 'system') then
2576
                                 select id , upper_id, name , user_id, public, create_date, last_update, description  from domain_system where id=domain_idkey;
2577
                end if;
2578

    
2579
        else
2580
                select 0 as test;
2581
        end if;
2582
END//
2583
DELIMITER ;
2584

    
2585
-- 프로시저 nerv_icde_test.draw_deployComponentProxyInterfaceList 구조 내보내기
2586
DROP PROCEDURE IF EXISTS `draw_deployComponentProxyInterfaceList`;
2587
DELIMITER //
2588
CREATE PROCEDURE `draw_deployComponentProxyInterfaceList`(IN `in_systemdomain_id` INT, IN `in_node_id` INT, IN `in_component_id` INT)
2589
BEGIN
2590

    
2591
        if loginTest() then
2592
                select 1 as test;
2593
                 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,
2594
					   c.name, c.id, c.standard_port, a.object_name, a.public, a.original_id, g.component_id from
2595
						(
2596
    						((select id, deploy_id, proxy_interface_id, object_id, stub_object_id, stub_ip, object_name, public, original_id FROM custum_proxy
2597
							  where deploy_id in(select Id from deployments where node_id = in_node_id and component_id = in_component_id)) as a
2598
       						join
2599
       					(select id, interface_name, class_name, method_domain_id from proxy_interface_relation) as b on b.id = a.proxy_interface_id)
2600
       						join
2601
       					(select id, name, standard_port from domain_method) as c on c.id = b.method_domain_id
2602
       						join
2603
							(select deployments_bind.deployment_id, deployments_bind.ip from deployments_bind) as d on d.ip = a.stub_ip
2604
					       	join
2605
					      (select id, node_id, systemdomain_id from deployments) as e on e.id = d.deployment_id and e.systemdomain_id = in_systemdomain_id
2606
					       	join
2607
					      (select deploy_id, object_id from custum_stub) as f on f.object_id = a.stub_object_id and f.deploy_id = e.id
2608
					       	join
2609
					      (select id, component_id from deployments) as g on g.id = f.deploy_id
2610
						) group by g.component_id, a.id,a.deploy_id,a.proxy_interface_id;
2611

    
2612
        else
2613
                select 0 as test;
2614
        end if;
2615

    
2616

    
2617

    
2618
END//
2619
DELIMITER ;
2620

    
2621
-- 프로시저 nerv_icde_test.ExposedInterfaceViewInterfaceList 구조 내보내기
2622
DROP PROCEDURE IF EXISTS `ExposedInterfaceViewInterfaceList`;
2623
DELIMITER //
2624
CREATE PROCEDURE `ExposedInterfaceViewInterfaceList`(in_component_id int)
2625
BEGIN
2626
        if loginTest() then
2627
                select 1 as test;
2628
                select method_domain_id, interface_name from proxy_interface_relation where component_id = in_component_id
2629
                UNION
2630
                SELECT method_domain_id, interface_name from stub_interface_relation where component_id = in_component_id;
2631
        else
2632
                select 0 as test;
2633
        end if;
2634
END//
2635
DELIMITER ;
2636

    
2637
-- 프로시저 nerv_icde_test.get_domain_path 구조 내보내기
2638
DROP PROCEDURE IF EXISTS `get_domain_path`;
2639
DELIMITER //
2640
CREATE PROCEDURE `get_domain_path`(IN `in_domain_id_key` INT, IN `in_domain_type` VARCHAR(50))
2641
BEGIN
2642

    
2643
	if in_domain_type = 'method' then
2644
		select 1 as test;
2645
		select(domainMethodPath(in_domain_id_key,''))  As path;
2646
	end if;
2647

    
2648
	if in_domain_type = 'data' then
2649
		select 1 as test;
2650
		select(domainDataPath(in_domain_id_key,''))  As path;
2651
	end if;
2652

    
2653
		if in_domain_type = 'system' then
2654
   	select 1 as test;
2655
		select(domainSystemPath(in_domain_id_key,''))  As path;
2656
	end if;
2657
END//
2658
DELIMITER ;
2659

    
2660
-- 프로시저 nerv_icde_test.inheritanceSystemMethodViewDeleteparent 구조 내보내기
2661
DROP PROCEDURE IF EXISTS `inheritanceSystemMethodViewDeleteparent`;
2662
DELIMITER //
2663
CREATE PROCEDURE `inheritanceSystemMethodViewDeleteparent`(in_domain_id int,
2664
                                                                              in_parent_domain_id int)
2665
BEGIN
2666
        if loginTest() then
2667
                select 1 as test;
2668
                delete from inheritance_system_method where domain_id = in_domain_id and parent_domain_id = in_parent_domain_id;
2669
        else
2670
                select 0 as test;
2671
        end if;
2672
END//
2673
DELIMITER ;
2674

    
2675
-- 프로시저 nerv_icde_test.inheritanceSystemMethodViewNewparent 구조 내보내기
2676
DROP PROCEDURE IF EXISTS `inheritanceSystemMethodViewNewparent`;
2677
DELIMITER //
2678
CREATE PROCEDURE `inheritanceSystemMethodViewNewparent`(in_domain_id int,
2679
                                                                           in_parent_domain_id int)
2680
BEGIN
2681
        if loginTest() and inheritanceSystemMehtodParentOverlapCheck(in_domain_id, in_parent_domain_id) then
2682
                select 1 as test;
2683
                insert into inheritance_system_method(domain_id, parent_domain_id)
2684
                                      values(in_domain_id, in_parent_domain_id);
2685
        else
2686
                select 0 as test;
2687
        end if;
2688
END//
2689
DELIMITER ;
2690

    
2691
-- 프로시저 nerv_icde_test.inheritance_data_dataViewDomainList 구조 내보내기
2692
DROP PROCEDURE IF EXISTS `inheritance_data_dataViewDomainList`;
2693
DELIMITER //
2694
CREATE PROCEDURE `inheritance_data_dataViewDomainList`(IN `domain_idkey` int)
2695
BEGIN
2696

    
2697
        if loginTest() and domainReadTest(domain_idkey, 'data') then
2698
           select 1 as test;
2699

    
2700

    
2701
				select d.* from
2702
				(
2703
					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')
2704
					union
2705
					select domain_id from data where data.data_auto_id in(select data_field.real_data_auto_id from data_field
2706
					 where data_field.`type`='alias' and data_field.data_auto_id in
2707
					  (select data.data_auto_id from data where data.domain_id=domain_idkey))
2708
				)as m join domain_data as d on m.domain_id=d.id and d.id != domain_idkey;
2709

    
2710
        else
2711
                select 0 as test;
2712
        end if;
2713
END//
2714
DELIMITER ;
2715

    
2716
-- 프로시저 nerv_icde_test.inheritance_method_dataViewDomainList 구조 내보내기
2717
DROP PROCEDURE IF EXISTS `inheritance_method_dataViewDomainList`;
2718
DELIMITER //
2719
CREATE PROCEDURE `inheritance_method_dataViewDomainList`(IN `domain_idkey` int)
2720
BEGIN
2721

    
2722
        if loginTest() and domainReadTest(domain_idkey, 'method') then
2723
           select 1 as test;
2724
           select d.* from
2725
			  (
2726
					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)
2727
					union
2728
					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)
2729
				)as m join domain_data as d on m.domain_id=d.id;
2730

    
2731

    
2732

    
2733
        else
2734
                select 0 as test;
2735
        end if;
2736
END//
2737
DELIMITER ;
2738

    
2739
-- 프로시저 nerv_icde_test.inheritance_method_methodViewDomainList 구조 내보내기
2740
DROP PROCEDURE IF EXISTS `inheritance_method_methodViewDomainList`;
2741
DELIMITER //
2742
CREATE PROCEDURE `inheritance_method_methodViewDomainList`(domain_idkey int)
2743
BEGIN
2744

    
2745
        if loginTest() and domainReadTest(domain_idkey, 'method') then
2746
           select 1 as test;
2747

    
2748
            SELECT b.* from
2749
            (select * from inheritance_method_method where domain_id=domain_idkey) as a
2750
             join
2751
            (select * from domain_method ) as b on a.parent_domain_id = b.id ;
2752

    
2753
        else
2754
                select 0 as test;
2755
        end if;
2756
END//
2757
DELIMITER ;
2758

    
2759
-- 프로시저 nerv_icde_test.inheritance_system_methodViewDomainList 구조 내보내기
2760
DROP PROCEDURE IF EXISTS `inheritance_system_methodViewDomainList`;
2761
DELIMITER //
2762
CREATE PROCEDURE `inheritance_system_methodViewDomainList`(domain_idkey int)
2763
BEGIN
2764

    
2765
        if loginTest() and domainReadTest(domain_idkey, 'method') then
2766
           select 1 as test;
2767

    
2768
            SELECT b.* from
2769
            (select * from inheritance_system_method where domain_id=domain_idkey) as a
2770
             join
2771
            (select * from domain_method ) as b on a.parent_domain_id = b.id ;
2772

    
2773
        else
2774
                select 0 as test;
2775
        end if;
2776
END//
2777
DELIMITER ;
2778

    
2779
-- 프로시저 nerv_icde_test.insertProxyInserfaceRelation 구조 내보내기
2780
DROP PROCEDURE IF EXISTS `insertProxyInserfaceRelation`;
2781
DELIMITER //
2782
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))
2783
BEGIN
2784
 declare select_interface_realation_id_key int;
2785
 declare new_proxy_interface_realation_id int;
2786
 set select_interface_realation_id_key=0;
2787

    
2788
		  select id into select_interface_realation_id_key from proxy_interface_relation
2789
		 		 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;
2790

    
2791
		  if select_interface_realation_id_key = 0 then
2792
 			select 1 as check_count;
2793
 			insert into proxy_interface_relation (component_id, method_domain_id, interface_name, class_name)
2794
                                values(in_component_id, in_method_domain_id, in_interface_name, in_class_name);
2795

    
2796
         select last_insert_id() into new_proxy_interface_realation_id;
2797

    
2798
          insert into proxy_interface_object (proxy_interface_id, object_name, component_id)
2799
                                values(new_proxy_interface_realation_id, in_object_name, in_component_id);
2800

    
2801
          insert into custum_proxy (deploy_id, proxy_interface_id, object_name)
2802
                     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;
2803
 		  else
2804
 		   select 2 as check_count;
2805
 		   insert into proxy_interface_object (proxy_interface_id, object_name, component_id)
2806
                                values( select_interface_realation_id_key, in_object_name, in_component_id);
2807

    
2808
			insert into custum_proxy (deploy_id, proxy_interface_id, object_name)
2809
                     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;
2810
		  end if;
2811
END//
2812
DELIMITER ;
2813

    
2814
-- 프로시저 nerv_icde_test.insertStubInserfaceRelation 구조 내보내기
2815
DROP PROCEDURE IF EXISTS `insertStubInserfaceRelation`;
2816
DELIMITER //
2817
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))
2818
BEGIN
2819
 declare select_interface_realation_id_key int;
2820
 declare new_stub_interface_realation_id int;
2821

    
2822
 set select_interface_realation_id_key=0;
2823

    
2824
		  select id into select_interface_realation_id_key from stub_interface_relation
2825
		 		 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;
2826

    
2827
		  if select_interface_realation_id_key = 0 then
2828
 			select 1 as check_count;
2829
 			insert into stub_interface_relation (component_id, method_domain_id, interface_name, class_name)
2830
                                values(in_component_id, in_method_domain_id, in_interface_name, in_class_name);
2831

    
2832
         select last_insert_id() into new_stub_interface_realation_id;
2833

    
2834
          insert into stub_interface_object (stub_interface_id, object_name, component_id)
2835
                                values(new_stub_interface_realation_id, in_object_name, in_component_id);
2836

    
2837
          insert into custum_stub (deploy_id, stub_interface_id, object_name)
2838
                     select id, new_stub_interface_realation_id, in_object_name from deployments
2839
							 where systemdomain_id = in_system_domain_id and component_id = in_component_id;
2840
 		  else
2841
 		   select 2 as check_count;
2842
 		   insert into stub_interface_object (stub_interface_id, object_name, component_id)
2843
                                values( select_interface_realation_id_key, in_object_name, in_component_id);
2844

    
2845
			insert into custum_stub (deploy_id, stub_interface_id, object_name)
2846
                     select id, select_interface_realation_id_key, in_object_name from deployments
2847
							 where systemdomain_id = in_system_domain_id and component_id = in_component_id;
2848
		  end if;
2849
END//
2850
DELIMITER ;
2851

    
2852
-- 프로시저 nerv_icde_test.insert_component_deployments_custum 구조 내보내기
2853
DROP PROCEDURE IF EXISTS `insert_component_deployments_custum`;
2854
DELIMITER //
2855
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)
2856
BEGIN
2857
declare new_component_id int;
2858
declare new_deployment_id int;
2859
declare proxy_object_count int;
2860
declare stub_object_count int;
2861
declare computer_node_id int;
2862

    
2863
select count(id) into proxy_object_count from custum_proxy where custum_proxy.public=1 and custum_proxy.deploy_id = in_deployment_id;
2864
select count(id) into stub_object_count from custum_stub where custum_stub.public=1 and custum_stub.deploy_id = in_deployment_id;
2865

    
2866
if (proxy_object_count !=0 or stub_object_count !=0) then
2867
	insert into component (systemdomain_id, name, description)
2868
	values (in_subsystem_domain_id, in_component_name, in_component_description);
2869
	select Last_INSERT_ID() into new_component_id;
2870

    
2871
	insert into deployments (node_id, component_id, systemdomain_id, original_id)
2872
	values(in_node_id, new_component_id, in_subsystem_domain_id, in_deployment_id);
2873
	select Last_INSERT_ID() into new_deployment_id;
2874

    
2875
	insert into custum_proxy (deploy_id, proxy_interface_id, object_name, object_id, stub_object_id, stub_ip, original_id, original_deployment_id)
2876
 	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
2877
 	(select id from deployments where component_id = in_component_id and systemdomain_id = in_systemdomain_id);
2878

    
2879
 	insert into custum_stub (deploy_id, stub_interface_id, object_name, object_id, original_id, original_deployment_id)
2880
 	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
2881
 	(select id from deployments where component_id = in_component_id and systemdomain_id = in_systemdomain_id);
2882

    
2883
	 	insert into deployments_bind (deployments_bind.deployment_id, deployments_bind.node_id, deployments_bind.port, deployments_bind.ip)
2884
			select new_deployment_id, b.node_id, b.port, b.ip from
2885
			(
2886
				(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
2887
				join
2888
				(select network.node_id, network.port, network.ip from network where node_id =in_node_id) as b on b.ip = a.ip
2889
			) where b.node_id is not NULL;
2890

    
2891
end if;
2892
END//
2893
DELIMITER ;
2894

    
2895
-- 프로시저 nerv_icde_test.insert_subsystem_component 구조 내보내기
2896
DROP PROCEDURE IF EXISTS `insert_subsystem_component`;
2897
DELIMITER //
2898
CREATE PROCEDURE `insert_subsystem_component`(IN `in_node_id` int)
2899
BEGIN
2900
	declare domain_id int;
2901
 	declare sub_domain_id int;
2902
 	declare depth int;
2903
	declare no_more_rows bool default false;
2904
	declare deployment_id int;
2905
	declare component_id int;
2906
 	declare component_system_domain_id int;
2907
   declare component_name varchar(100);
2908
   declare component_description varchar(100);
2909

    
2910
	DECLARE my_list CURSOR FOR select a.id, c.id, c.systemdomain_id, c.name, c.description from
2911

    
2912
  (select deployments.Id, deployments.component_id from deployments where (node_id,systemdomain_id)
2913
   in (select id,systemdomain_id from node where systemdomain_id=sub_domain_id)) as a
2914
  join
2915
  (select * from component) as c on c.id = a.component_id group by c.id;
2916

    
2917
	declare continue handler for not found set no_more_rows := TRUE;
2918

    
2919
	set max_sp_recursion_depth = 50;
2920
	set depth=10;
2921

    
2922
	if depth > 0 then
2923
	Select node.systemdomain_id into domain_id from node where node.id = in_node_id;
2924
   Select node.sub_system_domain_id into sub_domain_id from node where node.id = in_node_id;
2925

    
2926
		open my_list;
2927
			my_loop : loop
2928
			fetch my_list into deployment_id, component_id, component_system_domain_id, component_name, component_description;
2929
			if no_more_rows then
2930
				close my_list;
2931
				leave my_loop;
2932
			end if;
2933

    
2934
	  call insert_component_deployments_custum(deployment_id, domain_id, in_node_id, component_id, component_system_domain_id, component_name, component_description);
2935

    
2936
			set depth = depth -1;
2937
		end loop my_loop;
2938
	 end if;
2939
END//
2940
DELIMITER ;
2941

    
2942
-- 프로시저 nerv_icde_test.insert_subsystem_custum_interface 구조 내보내기
2943
DROP PROCEDURE IF EXISTS `insert_subsystem_custum_interface`;
2944
DELIMITER //
2945
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)
2946
BEGIN
2947
 if(in_object_type = 0) then
2948
	 insert into custum_proxy (custum_proxy.deploy_id, custum_proxy.proxy_interface_id, custum_proxy.object_name,
2949
	 									 custum_proxy.object_id, custum_proxy.stub_object_id, custum_proxy.stub_ip, custum_proxy.public,
2950
										  custum_proxy.original_id, custum_proxy.original_deployment_id)
2951
 	  select in_subsystem_deployment_id, custum_proxy.proxy_interface_id, custum_proxy.object_name, custum_proxy.object_id,
2952
		 custum_proxy.stub_object_id, custum_proxy.stub_ip, 0, in_original_custum_id, in_original_custum_deployment_id
2953
     from custum_proxy where custum_proxy.Id = in_original_custum_id and custum_proxy.deploy_id = in_original_custum_deployment_id;
2954
 else
2955
	 insert into custum_stub (custum_stub.deploy_id, custum_stub.stub_interface_id, custum_stub.object_name,
2956
	 									 custum_stub.object_id, custum_stub.public, custum_stub.original_id,
2957
										   custum_stub.original_deployment_id)
2958
 	  select in_subsystem_deployment_id, custum_stub.stub_interface_id, custum_stub.object_name,
2959
		 custum_stub.object_id, 0, in_original_custum_id, in_original_custum_deployment_id
2960
     from custum_stub where custum_stub.Id = in_original_custum_id and custum_stub.deploy_id = in_original_custum_deployment_id;
2961
 end if;
2962

    
2963
END//
2964
DELIMITER ;
2965

    
2966
-- 프로시저 nerv_icde_test.insert_subsystem_custum_interface_loop 구조 내보내기
2967
DROP PROCEDURE IF EXISTS `insert_subsystem_custum_interface_loop`;
2968
DELIMITER //
2969
CREATE PROCEDURE `insert_subsystem_custum_interface_loop`(IN `in_custum_id` INT, IN `in_deployments_id` INT, IN `in_object_type` INT)
2970
BEGIN
2971
	declare sub_system_deploy_id int;
2972
	declare subsystem_node_id int;
2973
	declare no_more_rows bool default false;
2974
	declare deploy_sub_component int default 0;
2975
	declare 	orginal_domain_id int;
2976
	declare 	orginal_component_id int;
2977
	declare 	orginal_node_id int;
2978
   declare subsystem_domain_id int;
2979
   declare component_id int;
2980
   declare component_system_domain_id int;
2981
   declare component_name varchar(100);
2982
   declare component_description varchar(100);
2983

    
2984
		DECLARE my_list CURSOR FOR
2985
			select node.id from node where node.sub_system_domain_id in( select deployments.systemdomain_id from deployments where deployments.Id=in_deployments_id);
2986
		declare continue handler for not found set no_more_rows := TRUE;
2987

    
2988
		set max_sp_recursion_depth = 50;
2989

    
2990
			open my_list;
2991
			my_loop : loop
2992
				fetch my_list into subsystem_node_id;
2993
				if no_more_rows then
2994
					close my_list;
2995
					leave my_loop;
2996
				end if;
2997

    
2998
				select count(deployments.Id) into deploy_sub_component from deployments where deployments.node_id = subsystem_node_id and deployments.original_id = in_deployments_id;
2999

    
3000
	      	if deploy_sub_component = 0 then
3001
					 select deployments.systemdomain_id into orginal_domain_id from deployments where deployments.Id=in_deployments_id;
3002
					 select deployments.component_id into orginal_component_id from deployments where deployments.Id=in_deployments_id;
3003
					 select deployments.node_id into orginal_node_id from deployments where deployments.Id=in_deployments_id;
3004
					 select systemdomain_id into subsystem_domain_id  from node where node.Id = subsystem_node_id;
3005
			 		 select component.id into component_id from component where id = orginal_component_id;
3006
			 		 select component.systemdomain_id into component_system_domain_id from component where id = orginal_component_id;
3007
			 		 select component.name into component_name from component where id = orginal_component_id;
3008
					 select component.description into component_description from component where id = orginal_component_id;
3009

    
3010
 					 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);
3011

    
3012
 				else
3013
 				   select deployments.Id into sub_system_deploy_id from deployments where deployments.node_id = subsystem_node_id and deployments.original_id = in_deployments_id;
3014

    
3015
					call insert_subsystem_custum_interface( sub_system_deploy_id, in_custum_id, in_deployments_id, in_object_type);
3016
				end if;
3017

    
3018
			end loop my_loop;
3019
END//
3020
DELIMITER ;
3021

    
3022
-- 프로시저 nerv_icde_test.insert_subsystem_custum_interface_loop_new_subsystem 구조 내보내기
3023
DROP PROCEDURE IF EXISTS `insert_subsystem_custum_interface_loop_new_subsystem`;
3024
DELIMITER //
3025
CREATE PROCEDURE `insert_subsystem_custum_interface_loop_new_subsystem`(IN `in_custum_id` INT, IN `in_deployments_id` INT, IN `in_object_type` INT)
3026
BEGIN
3027
	declare sub_system_deploy_id int;
3028
	declare subsystem_node_id int;
3029
	declare no_more_rows bool default false;
3030
	declare deploy_sub_component int default 0;
3031
	declare 	orginal_domain_id int;
3032
	declare 	orginal_component_id int;
3033
	declare 	orginal_node_id int;
3034
   declare subsystem_domain_id int;
3035
   declare component_id int;
3036
   declare component_system_domain_id int;
3037
   declare component_name varchar(100);
3038
   declare component_description varchar(100);
3039

    
3040
		DECLARE my_list CURSOR FOR
3041
			select node.id from node where node.sub_system_domain_id in
3042
			( select deployments.systemdomain_id from deployments where deployments.Id=in_deployments_id);
3043
		declare continue handler for not found set no_more_rows := TRUE;
3044

    
3045
		set max_sp_recursion_depth = 50;
3046
			open my_list;
3047
			my_loop : loop
3048
				fetch my_list into subsystem_node_id;
3049
				if no_more_rows then
3050
					close my_list;
3051
					leave my_loop;
3052
				end if;
3053

    
3054
				select count(deployments.Id) into deploy_sub_component from deployments where deployments.node_id = subsystem_node_id and deployments.original_id = in_deployments_id;
3055

    
3056
	      	if deploy_sub_component = 0 then
3057
					 select deployments.systemdomain_id into orginal_domain_id from deployments where deployments.Id=in_deployments_id;
3058
					 select deployments.component_id into orginal_component_id from deployments where deployments.Id=in_deployments_id;
3059
					 select deployments.node_id into orginal_node_id from deployments where deployments.Id=in_deployments_id;
3060
					 select systemdomain_id into subsystem_domain_id  from node where node.Id = subsystem_node_id;
3061
			 		 select component.id into component_id from component where id = orginal_component_id;
3062
			 		 select component.systemdomain_id into component_system_domain_id from component where id = orginal_component_id;
3063
			 		 select component.name into component_name from component where id = orginal_component_id;
3064
					 select component.description into component_description from component where id = orginal_component_id;
3065

    
3066
 					 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);
3067
				end if;
3068

    
3069
			end loop my_loop;
3070
END//
3071
DELIMITER ;
3072

    
3073
-- 프로시저 nerv_icde_test.insert_subsystem_public_proxy_interface_loop 구조 내보내기
3074
DROP PROCEDURE IF EXISTS `insert_subsystem_public_proxy_interface_loop`;
3075
DELIMITER //
3076
CREATE PROCEDURE `insert_subsystem_public_proxy_interface_loop`(IN `in_subsystem_domain_id` INT)
3077
BEGIN
3078

    
3079
	declare in_custum_id int;
3080
	declare in_deploy_id int;
3081
	declare no_more_rows bool default false;
3082

    
3083
		DECLARE my_list CURSOR FOR
3084
		select custum_proxy.Id, custum_proxy.deploy_id from custum_proxy where custum_proxy.public=1 and custum_proxy.deploy_id in (
3085
		select id from deployments where deployments.systemdomain_id=in_subsystem_domain_id);
3086

    
3087
		declare continue handler for not found set no_more_rows := TRUE;
3088
		select 1 as test;
3089
			open my_list;
3090
			my_loop : loop
3091
				fetch my_list into in_custum_id, in_deploy_id;
3092
				if no_more_rows then
3093
					close my_list;
3094
					leave my_loop;
3095
				end if;
3096

    
3097
  				call insert_subsystem_custum_interface_loop_new_subsystem(in_custum_id, in_deploy_id, 0);
3098
			end loop my_loop;
3099
END//
3100
DELIMITER ;
3101

    
3102
-- 프로시저 nerv_icde_test.insert_subsystem_public_stub_interface_loop 구조 내보내기
3103
DROP PROCEDURE IF EXISTS `insert_subsystem_public_stub_interface_loop`;
3104
DELIMITER //
3105
CREATE PROCEDURE `insert_subsystem_public_stub_interface_loop`(IN `in_subsystem_domain_id` INT)
3106
BEGIN
3107

    
3108
	declare in_custum_id int;
3109
	declare in_deploy_id int;
3110
	declare no_more_rows bool default false;
3111

    
3112
	DECLARE my_list_stub CURSOR FOR
3113
	select custum_stub.Id, custum_stub.deploy_id from custum_stub where custum_stub.public=1 and custum_stub.deploy_id in (
3114
		select id from deployments where deployments.systemdomain_id=in_subsystem_domain_id);
3115

    
3116
	declare continue handler for not found set no_more_rows := TRUE;
3117
					select 1 as test;
3118
			open my_list_stub;
3119
			my_loop : loop
3120
				fetch my_list_stub into in_custum_id, in_deploy_id;
3121
				if no_more_rows then
3122
					close my_list_stub;
3123
					leave my_loop;
3124
				end if;
3125

    
3126
 				call insert_subsystem_custum_interface_loop_new_subsystem(in_custum_id, in_deploy_id, 1);
3127
			end loop my_loop;
3128

    
3129
END//
3130
DELIMITER ;
3131

    
3132
-- 프로시저 nerv_icde_test.interfaceViewDeleteInterface 구조 내보내기
3133
DROP PROCEDURE IF EXISTS `interfaceViewDeleteInterface`;
3134
DELIMITER //
3135
CREATE PROCEDURE `interfaceViewDeleteInterface`(domain_idkey int,interface_name varchar(100))
3136
BEGIN
3137
        if loginTest() and domainManageTest(domain_idkey) then
3138
                select 1 as test;
3139
                delete from interface where domain_id=domain_idkey and name=interface_name;
3140

    
3141
        else
3142
                select 0 as test;
3143
        end if;
3144
END//
3145
DELIMITER ;
3146

    
3147
-- 프로시저 nerv_icde_test.interfaceViewDeleteMemberMethod 구조 내보내기
3148
DROP PROCEDURE IF EXISTS `interfaceViewDeleteMemberMethod`;
3149
DELIMITER //
3150
CREATE PROCEDURE `interfaceViewDeleteMemberMethod`(IN `domain_idkey` int, IN `interfacename` varchar(100), IN `methoddomain_id` int, IN `methodname` varchar(100))
3151
BEGIN
3152
        if loginTest() and domainManageTest(domain_idkey) then
3153
                select 1 as test;
3154
                delete from interface_member where domain_id=domain_idkey
3155
					  and interface=interfacename and method_domain_id=methoddomain_id and method_name=methodname;
3156
        else
3157
                select 0 as test;
3158
        end if;
3159
END//
3160
DELIMITER ;
3161

    
3162
-- 프로시저 nerv_icde_test.interfaceViewDeleteParentInterface 구조 내보내기
3163
DROP PROCEDURE IF EXISTS `interfaceViewDeleteParentInterface`;
3164
DELIMITER //
3165
CREATE PROCEDURE `interfaceViewDeleteParentInterface`(domain_idkey int,
3166
                                                                        interface_name varchar(100),
3167
                                                                        parentdomain_idkey int,
3168
                                                                        parentinterface_name varchar(100))
3169
BEGIN
3170

    
3171
        if loginTest() and domainManageTest(domain_idkey) then
3172
                select 1 as test;
3173
                delete from interface_parent where domain_id=domain_idkey and interface=interface_name and parent_domain_id=parentdomain_idkey and parent_interface=parentinterface_name;
3174
        else
3175
                select 0 as test;
3176
        end if;
3177
END//
3178
DELIMITER ;
3179

    
3180
-- 프로시저 nerv_icde_test.interfaceViewEditInterface 구조 내보내기
3181
DROP PROCEDURE IF EXISTS `interfaceViewEditInterface`;
3182
DELIMITER //
3183
CREATE PROCEDURE `interfaceViewEditInterface`(domain_idkey int, interface_name varchar(100),interfacevalue varchar(100),descriptionvalue varchar(100))
3184
BEGIN
3185

    
3186
        if loginTest() and domainManageTest(domain_idkey) then
3187
                select 1 as test;
3188
                       update interface set name=interfacevalue,description=descriptionvalue where domain_id=domain_idkey and name=interface_name;
3189
        else
3190
                select 0 as test;
3191
        end if;
3192
END//
3193
DELIMITER ;
3194

    
3195
-- 프로시저 nerv_icde_test.interfaceViewEditInterfaceSeq 구조 내보내기
3196
DROP PROCEDURE IF EXISTS `interfaceViewEditInterfaceSeq`;
3197
DELIMITER //
3198
CREATE PROCEDURE `interfaceViewEditInterfaceSeq`(domain_idkey int, domaintype varchar(50),
3199
                                                                        interfacekey1 varchar(100),
3200
                                                                        interfacekey2 varchar(100))
3201
BEGIN
3202
        declare t1 timestamp;
3203
        declare t2 timestamp;
3204

    
3205
        if loginTest() and domainManageTest(domain_idkey, domaintype) then
3206
                select 1 as test;
3207
                       select seq into t1 from interface where domain_id=domain_idkey and name=interfacekey1;
3208
                       select seq into t2 from interface where domain_id=domain_idkey and name=interfacekey2;
3209
                update interface set seq = t2 where domain_id=domain_idkey and name=interfacekey1;
3210
                update interface set seq = t1 where domain_id=domain_idkey and name=interfacekey2;
3211
        else
3212
                select 0 as test;
3213
        end if;
3214
END//
3215
DELIMITER ;
3216

    
3217
-- 프로시저 nerv_icde_test.interfaceViewEditMemberMethod 구조 내보내기
3218
DROP PROCEDURE IF EXISTS `interfaceViewEditMemberMethod`;
3219
DELIMITER //
3220
CREATE PROCEDURE `interfaceViewEditMemberMethod`(domain_idkey int,
3221
                                                                     interfacekey varchar(100),
3222
                                                                     method_domain_idkey int,
3223
                                                                     method_namekey varchar(100),
3224
                                                                     method_domain_idvalue int,
3225
                                                                     methodvalue varchar(100),
3226
                                                                     descriptionvalue text)
3227
BEGIN
3228
        if loginTest() and domainManageTest(domain_idkey) and existMethod(method_domain_idvalue,methodvalue) then
3229
                select 1 as test;
3230
                update interface_member set method_domain_id=method_domain_idvalue,
3231
                                            method_name=methodvalue,
3232
                                            description=descriptionvalue
3233
                                        where domain_id=domain_idkey
3234
                                         and  interface=interfacekey
3235
                                         and  method_domain_id=method_domain_idkey
3236
                                         and  method_name=method_namekey;
3237
        else
3238
                select 0 as test;
3239
        end if;
3240
END//
3241
DELIMITER ;
3242

    
3243
-- 프로시저 nerv_icde_test.interfaceViewEditMemberMethodRealdomainList 구조 내보내기
3244
DROP PROCEDURE IF EXISTS `interfaceViewEditMemberMethodRealdomainList`;
3245
DELIMITER //
3246
CREATE PROCEDURE `interfaceViewEditMemberMethodRealdomainList`(domain_idkey int)
3247
BEGIN
3248
        declare sm bool;
3249
        declare sa varchar(100);
3250
        declare acount varchar(100);
3251
        declare pbc bool;
3252

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

    
3260
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3261
                        select 1 as test;
3262
                        (select id, name from domain_method where id in (select parent_domain_id from inheritance_method_method where domain_id=domain_idkey))
3263
                         union
3264
                        (select id, name from domain_method where id=domain_idkey);
3265

    
3266
                    else
3267
                        select 0 as test;
3268
                     end if;
3269
               else
3270
                 select 0 as test;
3271
        end if;
3272
END//
3273
DELIMITER ;
3274

    
3275
-- 프로시저 nerv_icde_test.interfaceViewEditMemberMethodRealmethodList 구조 내보내기
3276
DROP PROCEDURE IF EXISTS `interfaceViewEditMemberMethodRealmethodList`;
3277
DELIMITER //
3278
CREATE PROCEDURE `interfaceViewEditMemberMethodRealmethodList`(domain_idkey int, interfacekey varchar(100))
3279
BEGIN
3280
       declare sm bool;
3281
        declare sa varchar(100);
3282
        declare acount varchar(100);
3283
        declare pbc bool;
3284

    
3285
        set sa = '';
3286
        if loginTest() then
3287
                     select supermanager into sm from users where user_id = @nervuser;
3288
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
3289
                     select user_id into acount from domain_method where id = domain_idkey;
3290
                     select public into pbc from domain_method where id = domain_idkey;
3291

    
3292

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

    
3304
END//
3305
DELIMITER ;
3306

    
3307
-- 프로시저 nerv_icde_test.interfaceViewInterfaceList 구조 내보내기
3308
DROP PROCEDURE IF EXISTS `interfaceViewInterfaceList`;
3309
DELIMITER //
3310
CREATE PROCEDURE `interfaceViewInterfaceList`(domain_idkey int, domaintype varchar(100), interface_namekey varchar(100))
3311
BEGIN
3312

    
3313

    
3314
       if loginTest() and domainReadTest(domain_idkey, domaintype) then
3315
               select 1 as test;
3316
               select name,user_id,description, domain_id, seq from interface where domain_id=domain_idkey and name like interface_namekey order by seq asc;
3317
       else
3318
               select 0 as test;
3319
       end if;
3320
END//
3321
DELIMITER ;
3322

    
3323
-- 프로시저 nerv_icde_test.interfaceViewMemberMethodList 구조 내보내기
3324
DROP PROCEDURE IF EXISTS `interfaceViewMemberMethodList`;
3325
DELIMITER //
3326
CREATE PROCEDURE `interfaceViewMemberMethodList`(
3327
	IN `domain_idkey` int,
3328
	IN `domaintype` varchar(50),
3329
	IN `interface_namekey` VARCHAR(100)
3330

    
3331
)
3332
BEGIN
3333

    
3334
       if loginTest() and domainReadTest(domain_idkey, domaintype) then
3335
               select 1 as test;
3336
               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
3337
               (select id, name from domain_method) as c
3338
               	join
3339
               ( select * from method ) as a
3340
                    left outer join
3341
  					(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
3342
     					left outer join
3343
  					(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id
3344
              		left outer join
3345
               (select id, name from domain_data) as d on i.domain_id = d.id
3346
              		left outer join
3347
            	(select id, name from domain_data) as e on o.domain_id = e.id
3348
             		 join
3349
              ( select method_domain_id, method_name , description from interface_member where domain_id=domain_idkey and interface=interface_namekey) as b
3350
                                                      on a.domain_id=b.method_domain_id and a.name = b.method_name  and a.domain_id = c.id order by type desc;
3351
       else
3352
               select 0 as test;
3353
       end if;
3354
END//
3355
DELIMITER ;
3356

    
3357
-- 프로시저 nerv_icde_test.interfaceViewNewInterface 구조 내보내기
3358
DROP PROCEDURE IF EXISTS `interfaceViewNewInterface`;
3359
DELIMITER //
3360
CREATE PROCEDURE `interfaceViewNewInterface`(domain_idkey int, domaintype varchar (100),interface_namekey varchar(100),descriptionvalue text)
3361
BEGIN
3362
        if loginTest() and domainManageTest(domain_idkey) and existDomain(domain_idkey, domaintype) then
3363
                select 1 as test;
3364
                insert into interface (domain_id,                name,  user_id, description)
3365
                                values(domain_idkey, interface_namekey, @nervuser, descriptionvalue );
3366
        else
3367
                select 0 as test;
3368
        end if;
3369
END//
3370
DELIMITER ;
3371

    
3372
-- 프로시저 nerv_icde_test.interfaceViewNewMemberMethod 구조 내보내기
3373
DROP PROCEDURE IF EXISTS `interfaceViewNewMemberMethod`;
3374
DELIMITER //
3375
CREATE PROCEDURE `interfaceViewNewMemberMethod`(domain_idkey int,
3376
                                                                   interface_namekey varchar(100),
3377
                                                                   methoddomain_idvalue int,
3378
                                                                   method_namevalue varchar(100),
3379
                                                                   descriptionvalue text)
3380
BEGIN
3381
        if loginTest() and domainManageTest(domain_idkey) and existMethod(methoddomain_idvalue,method_namevalue) then
3382
                select 1 as test;
3383
                insert into interface_member(domain_id,        interface,     method_domain_id,   method_name, description)
3384
                                    values(domain_idkey,interface_namekey,methoddomain_idvalue,method_namevalue,descriptionvalue);
3385
        else
3386
                select 0 as test;
3387
        end if;
3388
END//
3389
DELIMITER ;
3390

    
3391
-- 프로시저 nerv_icde_test.interfaceViewNewMemberMethodRealdomainList 구조 내보내기
3392
DROP PROCEDURE IF EXISTS `interfaceViewNewMemberMethodRealdomainList`;
3393
DELIMITER //
3394
CREATE PROCEDURE `interfaceViewNewMemberMethodRealdomainList`(domain_idkey int)
3395
BEGIN
3396
        declare sm bool;
3397
        declare sa varchar(100);
3398
        declare acount varchar(100);
3399
        declare pbc bool;
3400

    
3401
        set sa = '';
3402
        if loginTest() then
3403
                    select supermanager into sm from users where user_id=@nervuser;
3404
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
3405
                    select user_id into acount from domain_method where id=domain_idkey;
3406
                    select public into pbc from domain_method where id=domain_idkey;
3407

    
3408
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3409
                        select 1 as test;
3410
                        (select id, name from domain_method where id in
3411
                                 (select parent_domain_id from inheritance_method_method where domain_id=domain_idkey))
3412
                         union
3413
                        (select id, name from domain_method where id=domain_idkey);
3414

    
3415
                   else
3416
                        select 0 as test;
3417
                     end if;
3418
               else
3419
                 select 0 as test;
3420
        end if;
3421
End//
3422
DELIMITER ;
3423

    
3424
-- 프로시저 nerv_icde_test.interfaceViewNewMemberMethodRealmethodList 구조 내보내기
3425
DROP PROCEDURE IF EXISTS `interfaceViewNewMemberMethodRealmethodList`;
3426
DELIMITER //
3427
CREATE PROCEDURE `interfaceViewNewMemberMethodRealmethodList`(in_interface_domain_idkey int, in_method_domain_idkey int,interfacekey varchar(100))
3428
BEGIN
3429
        declare sm bool;
3430
        declare sa varchar(100);
3431
        declare acount varchar(100);
3432
        declare pbc bool;
3433

    
3434
        set sa = '';
3435
        if loginTest() then
3436
                     select supermanager into sm from users where user_id = @nervuser;
3437
                     select member_type into sa from members_domain_method where domain_id=in_method_domain_idkey and user_id=@nervuser;
3438
                     select user_id into acount from domain_method where id = in_method_domain_idkey;
3439
                     select public into pbc from domain_method where id = in_method_domain_idkey;
3440

    
3441

    
3442
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3443
                        select 1 as test;
3444
                        select domain_id, name,type from method where domain_id=in_method_domain_idkey and name not in
3445
                                        (select method_name from interface_member where domain_id = in_interface_domain_idkey and interface=interfacekey);
3446
                     else
3447
                        select 0 as test;
3448
                     end if;
3449
       else
3450
                select 0 as test;
3451
       end if;
3452

    
3453

    
3454
END//
3455
DELIMITER ;
3456

    
3457
-- 프로시저 nerv_icde_test.interfaceViewNewParentInterface 구조 내보내기
3458
DROP PROCEDURE IF EXISTS `interfaceViewNewParentInterface`;
3459
DELIMITER //
3460
CREATE PROCEDURE `interfaceViewNewParentInterface`(domain_idkey int,
3461
                                                                        interface_namekey varchar(100),
3462
                                                                        parentdomain_id int,
3463
                                                                        parent_namevalue varchar(100))
3464
BEGIN
3465
        if loginTest() and domainManageTest(domain_idkey) and existInterface(parentdomain_id,parent_namevalue) then
3466
                select 1 as test;
3467
                insert into interface_parent(domain_id,          interface,parent_domain_id,parent_interface)
3468
                                      values(domain_idkey,interface_namekey,parentdomain_id,parent_namevalue);
3469
        else
3470
                select 0 as test;
3471
        end if;
3472
END//
3473
DELIMITER ;
3474

    
3475
-- 프로시저 nerv_icde_test.interfaceViewNewParentInterfaceRealdomainList 구조 내보내기
3476
DROP PROCEDURE IF EXISTS `interfaceViewNewParentInterfaceRealdomainList`;
3477
DELIMITER //
3478
CREATE PROCEDURE `interfaceViewNewParentInterfaceRealdomainList`(domain_idkey int)
3479
BEGIN
3480
         declare sm bool;
3481
        declare sa varchar(100);
3482
        declare acount varchar(100);
3483
        declare pbc bool;
3484

    
3485
        set sa = '';
3486
        if loginTest() then
3487

    
3488
                    select supermanager into sm from users where user_id=@nervuser;
3489
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
3490
                    select user_id into acount from domain_method where id=domain_idkey;
3491
                    select public into pbc from domain_method where id=domain_idkey;
3492

    
3493
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3494
                        select 1 as test;
3495
                        (select id, name from domain_method where id in (select parent_domain_id from inheritance_method_method where domain_id=domain_idkey))
3496
                         union
3497
                        (select id, name from domain_method where id=domain_idkey);
3498

    
3499
                    else
3500
                        select 0 as test;
3501
                     end if;
3502
               else
3503
                 select 0 as test;
3504
        end if;
3505
End//
3506
DELIMITER ;
3507

    
3508
-- 프로시저 nerv_icde_test.interfaceViewNewParentInterfaceRealinterfaceList 구조 내보내기
3509
DROP PROCEDURE IF EXISTS `interfaceViewNewParentInterfaceRealinterfaceList`;
3510
DELIMITER //
3511
CREATE PROCEDURE `interfaceViewNewParentInterfaceRealinterfaceList`(domain_idkey int, interfacekey varchar(100))
3512
BEGIN
3513
        declare sm bool;
3514
        declare sa varchar(100);
3515
        declare acount varchar(100);
3516
        declare pbc bool;
3517

    
3518
        set sa = '';
3519
        if loginTest() then
3520
                     select supermanager into sm from users where user_id=@nervuser;
3521
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
3522
                     select user_id into acount from domain_method where id=domain_idkey;
3523
                     select public into pbc from domain_method where id=domain_idkey;
3524

    
3525
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3526
                        select 1 as test;
3527
                        select domain_id, name, user_id, seq, description from interface where domain_id=domain_idkey and name != interfacekey and name not in
3528
                                        (select parent_interface from interface_parent where parent_domain_id=domain_idkey and interface=interfacekey);
3529
                     else
3530
                        select 0 as test;
3531
                     end if;
3532

    
3533
        else
3534
                select 0 as test;
3535
        end if;
3536
END//
3537
DELIMITER ;
3538

    
3539
-- 프로시저 nerv_icde_test.interfaceViewParentInterfaceList 구조 내보내기
3540
DROP PROCEDURE IF EXISTS `interfaceViewParentInterfaceList`;
3541
DELIMITER //
3542
CREATE PROCEDURE `interfaceViewParentInterfaceList`(domain_idkey int, domaintype varchar(100), interface_namekey varchar(100 ) )
3543
BEGIN
3544

    
3545

    
3546
       if loginTest() and domainReadTest(domain_idkey, domaintype) then
3547
               select 1 as test;
3548
               select b.name, a.parent_interface, a.parent_domain_id from
3549
               (select parent_domain_id,parent_interface from interface_parent where domain_id=domain_idkey and interface = interface_namekey) As a
3550
               join
3551
               (select id, name from domain_method) as b on a.parent_domain_id = b.id;
3552
       else
3553
               select 0 as test;
3554
       end if;
3555
END//
3556
DELIMITER ;
3557

    
3558
-- 프로시저 nerv_icde_test.loginResult 구조 내보내기
3559
DROP PROCEDURE IF EXISTS `loginResult`;
3560
DELIMITER //
3561
CREATE PROCEDURE `loginResult`()
3562
BEGIN
3563
       select loginTest() as test;
3564
END//
3565
DELIMITER ;
3566

    
3567
-- 프로시저 nerv_icde_test.mainViewDomainAllList 구조 내보내기
3568
DROP PROCEDURE IF EXISTS `mainViewDomainAllList`;
3569
DELIMITER //
3570
CREATE PROCEDURE `mainViewDomainAllList`(
3571
	IN `idkey` VARCHAR(50),
3572
	IN `domaintype` VARCHAR(50)
3573
)
3574
BEGIN
3575

    
3576
        declare sm bool;
3577

    
3578

    
3579
        if loginTest() then
3580
                select 1 as test;
3581
                if( supermanagerTest(@nervuser) ) then
3582
                       if(domaintype='data') then
3583
                       	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;
3584
                       end if;
3585

    
3586
                       if(domaintype='method') then
3587
                        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;
3588
                       end if;
3589

    
3590
                       if(domaintype='system') then
3591
                        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;
3592
                       end if;
3593
                else
3594
                      if(domaintype='data') then
3595
                         select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_data where id in
3596
                         (select domain_id from members_domain_data where user_id=@nervuser and (member_type='manager' or member_type='member'))
3597
                         union distinct
3598
                         select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_data where (user_id=@nervuser or public = 1);
3599
                      end if;
3600

    
3601
                        if(domaintype='method') then
3602
                        select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description  FROM domain_method where id in
3603
                        (select domain_id from members_domain_method where user_id=@nervuser and (member_type='manager' or member_type='member'))
3604
                        union distinct
3605
                        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);
3606

    
3607
                        end if;
3608
                        if(domaintype='system') then
3609
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_system where id in
3610
                        (select domain_id from members_domain_system where user_id=@nervuser and (member_type='manager' or member_type='member'))
3611
                        union distinct
3612
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_system where (user_id=@nervuser or public = 1);
3613
                        end if;
3614
                end if;
3615
       else
3616
               select 0 as test;
3617
       end if;
3618

    
3619
END//
3620
DELIMITER ;
3621

    
3622
-- 프로시저 nerv_icde_test.mainViewDomainList 구조 내보내기
3623
DROP PROCEDURE IF EXISTS `mainViewDomainList`;
3624
DELIMITER //
3625
CREATE PROCEDURE `mainViewDomainList`(
3626
	IN `idkey` varchar(100),
3627
	IN `domaintype` varchar(100)
3628
)
3629
BEGIN
3630
        declare sm bool;
3631
        if loginTest() then
3632
                select 1 as test;
3633
                if( supermanagerTest(@nervuser) ) then
3634
                       if(domaintype='data') then
3635
                        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
3636
								union
3637
								select id, name, upper_id, user_id, public, 0, create_date, last_update, description from domain_data where domain_data.upper_id in
3638
																(select domain_data.id from domain_data where domain_data.upper_id=idkey)
3639
								) as uuu order by name desc;
3640
                       end if;
3641
                       if(domaintype='method') then
3642
                        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
3643
								 union
3644
								 select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description from domain_method where domain_method.upper_id in
3645
																(select domain_method.id from domain_method where domain_method.upper_id=idkey)
3646
								) as uuu order by name desc;
3647
                       end if;
3648
                       if(domaintype='system') then
3649
                        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
3650
								union
3651
								select id, name, upper_id, user_id, public, 0, create_date, last_update, description from domain_system where domain_system.upper_id in
3652
																(select domain_system.id from domain_system where domain_system.upper_id=idkey)
3653
								) as uuu order by name desc;
3654
                       end if;
3655
                else
3656
                      if(domaintype='data') then
3657
                        select * from (
3658
						      select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_data where id in
3659
                         (select domain_id from members_domain_data where user_id=@nervuser and (member_type='manager' or member_type='member'))
3660
                        union distinct
3661
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_data where (user_id=@nervuser or public = 1)
3662
                        ) as uuu order by name desc;
3663
                      end if;
3664
                      if(domaintype='method') then
3665
                        select * from (
3666
                        select id,name, upper_id, user_id, public, standard_port, create_date, last_update, description  FROM domain_method where id in
3667
                        (select domain_id from members_domain_method where user_id=@nervuser and (member_type='manager' or member_type='member'))
3668
                        union distinct
3669
                        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)
3670
                        ) as uuu order by name desc;
3671
                      end if;
3672
                      if(domaintype='system') then
3673
                        select * from (
3674
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_system where id in
3675
                        (select domain_id from members_domain_system where user_id=@nervuser and (member_type='manager' or member_type='member'))
3676
                        union distinct
3677
                        select id, name, upper_id, user_id, public, 0, create_date, last_update, description FROM domain_system where (user_id=@nervuser or public = 1)
3678
                        ) as uuu order by name desc;
3679
                      end if;
3680
                end if;
3681
       else
3682
               select 0 as test;
3683
       end if;
3684
END//
3685
DELIMITER ;
3686

    
3687
-- 프로시저 nerv_icde_test.metadataViewCopyData 구조 내보내기
3688
DROP PROCEDURE IF EXISTS `metadataViewCopyData`;
3689
DELIMITER //
3690
CREATE PROCEDURE `metadataViewCopyData`(IN `copy_data_auto_id` INT, IN `paste_domain_id` INT)
3691
BEGIN
3692

    
3693
	declare new_data_auto_id int default null;
3694

    
3695
   if loginTest() and newDomainTest() then
3696
      select 1 as test;
3697

    
3698
	   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)
3699
		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;
3700

    
3701
	   select LAST_INSERT_ID() into new_data_auto_id;
3702

    
3703
		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 )
3704
		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
3705
				 where data_field.data_auto_id=copy_data_auto_id;
3706
	else
3707
      select 0 as test;
3708
	end if;
3709
END//
3710
DELIMITER ;
3711

    
3712
-- 프로시저 nerv_icde_test.metadataViewDeleteMetadata 구조 내보내기
3713
DROP PROCEDURE IF EXISTS `metadataViewDeleteMetadata`;
3714
DELIMITER //
3715
CREATE PROCEDURE `metadataViewDeleteMetadata`(domain_idkey int,metadata_namekey varchar(100))
3716
BEGIN
3717
        if loginTest() and domainManageTest(domain_idkey) then
3718
                select 1 as test;
3719
                delete from data where domain_id=domain_idkey and name=metadata_namekey;
3720

    
3721
        else
3722
                select 0 as test;
3723
        end if;
3724
END//
3725
DELIMITER ;
3726

    
3727
-- 프로시저 nerv_icde_test.metadataViewDeleteMetafield 구조 내보내기
3728
DROP PROCEDURE IF EXISTS `metadataViewDeleteMetafield`;
3729
DELIMITER //
3730
CREATE PROCEDURE `metadataViewDeleteMetafield`(IN `domain_idkey` int, IN `metadata_namekey` varchar(100), IN `member_namekey` varchar(100))
3731
BEGIN
3732

    
3733
	declare datakey_auto_id int default 0;
3734

    
3735
        if loginTest() and domainManageTest(domain_idkey) then
3736
                select 1 as test;
3737

    
3738
                delete from data_field where member_name=member_namekey and data_field.data_auto_id in
3739
					  (select data.data_auto_id from data where data.domain_id=domain_idkey and data.name=metadata_namekey);
3740
        else
3741
                select 0 as test;
3742
        end if;
3743
END//
3744
DELIMITER ;
3745

    
3746
-- 프로시저 nerv_icde_test.metadataViewEditMetadata 구조 내보내기
3747
DROP PROCEDURE IF EXISTS `metadataViewEditMetadata`;
3748
DELIMITER //
3749
CREATE PROCEDURE `metadataViewEditMetadata`(
3750
	IN `domain_idkey` int,
3751
	IN `metadatakey` varchar(100),
3752
	IN `data_namevalue` varchar(100),
3753
	IN `typevalue` varchar(100),
3754
	IN `in_real_data_auto_id` varchar(100),
3755
	IN `scminvalue` varchar(100),
3756
	IN `scmaxvalue` varchar(100),
3757
	IN `descriptionvalue` TEXT
3758
)
3759
BEGIN
3760
       declare data_depth int default 0;
3761
       declare real_data_domain_id int default 0;
3762
       declare data_id int;
3763
       declare real_data_path int;
3764

    
3765
        if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(in_real_data_auto_id) )then
3766
                if typevalue='alias' then
3767
					 	select data.domain_id into real_data_domain_id from data where data.data_auto_id=in_real_data_auto_id;
3768
					 else
3769
                	set in_real_data_auto_id=null;
3770
                end if;
3771

    
3772
               select data.data_auto_id into data_id from data where data.domain_id=domain_idkey and data.name=metadatakey;
3773
               select data.depth into data_depth from data where data.data_auto_id=data_id;
3774

    
3775
               if domain_idkey=real_data_domain_id then
3776
               	if typevalue ='alias' then
3777
               		select data.depth into real_data_path from data where data.data_auto_id=in_real_data_auto_id;
3778
               		if data_depth <= real_data_path then
3779
								set data_depth = real_data_path +1;
3780
               			call update_child_depth(data_id,domain_idkey,data_depth);
3781

    
3782
							end if;
3783
               	end if;
3784
               end if;
3785

    
3786
                select 1 as test;
3787

    
3788
                update data set name=data_namevalue,
3789
                                type=typevalue,
3790
                                data.real_data_auto_id=in_real_data_auto_id,
3791
                                scmin=scminvalue,
3792
                                scmax=scmaxvalue,
3793
                                description=descriptionvalue,
3794
                                data.depth = data_depth
3795
                                where data.data_auto_id=data_id;
3796

    
3797
        else
3798
                select 0 as test;
3799
        end if;
3800
END//
3801
DELIMITER ;
3802

    
3803
-- 프로시저 nerv_icde_test.metadataViewEditMetadataRealdomainList 구조 내보내기
3804
DROP PROCEDURE IF EXISTS `metadataViewEditMetadataRealdomainList`;
3805
DELIMITER //
3806
CREATE PROCEDURE `metadataViewEditMetadataRealdomainList`(domain_idkey int)
3807
BEGIN
3808
        declare sm bool;
3809
        declare sa varchar(100);
3810
        declare acount varchar(100);
3811
        declare pbc bool;
3812

    
3813
        set sa = '';
3814
        if loginTest() then
3815
                    select supermanager into sm from users where user_id=@nervuser;
3816
                    select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
3817
                    select user_id into acount from domain_data where id=domain_idkey;
3818
                    select public into pbc from domain_data where id=domain_idkey;
3819

    
3820
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3821
                        select 1 as test;
3822
                         (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))
3823
                           union
3824
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id=domain_idkey);
3825

    
3826

    
3827
                     else
3828
                        select 0 as test;
3829
                     end if;
3830

    
3831
        else
3832
                select 0 as test;
3833
        end if;
3834
End//
3835
DELIMITER ;
3836

    
3837
-- 프로시저 nerv_icde_test.metadataViewEditMetadataRealmetadataList 구조 내보내기
3838
DROP PROCEDURE IF EXISTS `metadataViewEditMetadataRealmetadataList`;
3839
DELIMITER //
3840
CREATE PROCEDURE `metadataViewEditMetadataRealmetadataList`(domain_idkey int)
3841
BEGIN
3842
        declare sm bool;
3843
        declare sa varchar(100);
3844
        declare acount varchar(100);
3845
        declare pbc bool;
3846

    
3847
        set sa = '';
3848
        if loginTest() then
3849
                     select supermanager into sm from users where user_id=@nervuser;
3850
                     select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
3851
                     select user_id into acount from domain_data where id=domain_idkey;
3852
                     select public into pbc from domain_data where id=domain_idkey;
3853

    
3854
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3855
                        select 1 as test;
3856
                         select * from data where domain_id=domain_idkey order by seq asc;
3857
                     else
3858
                        select 0 as test;
3859
                     end if;
3860
        else
3861
                select 0 as test;
3862
        end if;
3863
END//
3864
DELIMITER ;
3865

    
3866
-- 프로시저 nerv_icde_test.metadataViewEditMetadataSeq 구조 내보내기
3867
DROP PROCEDURE IF EXISTS `metadataViewEditMetadataSeq`;
3868
DELIMITER //
3869
CREATE PROCEDURE `metadataViewEditMetadataSeq`(IN `domain_idkey` int, IN `metadatakey1` varchar(100), IN `metadatakey2` varchar(100))
3870
BEGIN
3871
        declare t1 timestamp;
3872
        declare t2 timestamp;
3873

    
3874

    
3875

    
3876
        if loginTest() and domainManageTest(domain_idkey) then
3877
                select 1 as test;
3878
                       select seq into t1 from data where domain_id=domain_idkey and name=metadatakey1;
3879
                       select seq into t2 from data where domain_id=domain_idkey and name=metadatakey2;
3880
                       update data set seq = t2 where domain_id=domain_idkey and name=metadatakey1;
3881
                       update data set seq = t1 where domain_id=domain_idkey and name=metadatakey2;
3882
        else
3883
                select 0 as test;
3884
        end if;
3885
END//
3886
DELIMITER ;
3887

    
3888
-- 프로시저 nerv_icde_test.metadataViewEditMetafield 구조 내보내기
3889
DROP PROCEDURE IF EXISTS `metadataViewEditMetafield`;
3890
DELIMITER //
3891
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)
3892
BEGIN
3893
		 declare data_depth int default 0;
3894
		 declare data_field_depth int default 0;
3895
 		 declare datakey_auto_id int default 0;
3896
 		 declare real_data_auto_id int default 0;
3897

    
3898
		 if typevalue!='alias' then
3899
       	set real_data_auto_id=null;
3900
       else
3901
       	select data.data_auto_id into real_data_auto_id from data where data.domain_id=realdomainvalue and data.name=realmetadatavalue;
3902
       end if;
3903

    
3904
       if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(real_data_auto_id) ) then
3905

    
3906
           	 select 1 as test;
3907
       			select data.data_auto_id into datakey_auto_id from data where data.domain_id=domain_idkey and data.name=metadatakey;
3908

    
3909
            	if typevalue ='alias' then
3910
  						if domain_idkey=realdomainvalue then
3911
               		select data.depth into data_depth from data where data.data_auto_id=datakey_auto_id;
3912
               		select data.depth into data_field_depth from data where data.data_auto_id=real_data_auto_id;
3913

    
3914
               		if data_depth <= data_field_depth then
3915
               			set data_field_depth = data_field_depth + 1;
3916

    
3917
               			update data set data.depth = data_field_depth where data.domain_id=domain_idkey and data.name=metadatakey;
3918

    
3919
               			call update_child_depth(real_data_auto_id,realdomainvalue,data_field_depth);
3920
               		end if;
3921
               	end if;
3922
               end if;
3923
                update data_field set member_name=metafieldvalue,
3924
                                      bitsize=bitsizevalue,
3925
                                      type=typevalue,
3926
                                      data_field.real_data_auto_id=real_data_auto_id,
3927
                                      scimin=minvalue,
3928
                                      scimax=in_maxvalue,
3929
                                      arraytype=arraytypevalue,
3930
                                      arraysize=arraysizevalue,
3931
                                      description=descriptionvalue,
3932
                                      seq=seq
3933
                                 where data_field.data_auto_id=datakey_auto_id and data_field.member_name=metafieldkey;
3934
        else
3935
                select 0 as test;
3936
        end if;
3937
END//
3938
DELIMITER ;
3939

    
3940
-- 프로시저 nerv_icde_test.metadataViewEditMetafieldRealdomainList 구조 내보내기
3941
DROP PROCEDURE IF EXISTS `metadataViewEditMetafieldRealdomainList`;
3942
DELIMITER //
3943
CREATE PROCEDURE `metadataViewEditMetafieldRealdomainList`(IN `domain_idkey` int )
3944
BEGIN
3945
        declare sm bool;
3946
        declare sa varchar(100);
3947
        declare acount varchar(100);
3948
        declare pbc bool;
3949

    
3950
        set sa = '';
3951
        if loginTest() then
3952
                    select supermanager into sm from users where user_id=@nervuser;
3953
                    select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
3954
                    select user_id into acount from domain_data where id=domain_idkey;
3955
                    select public into pbc from domain_data where id=domain_idkey;
3956

    
3957
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3958
                        select 1 as test;
3959
                         (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id in
3960
								  (select parent_domain_id from inheritance_data_data where domain_id=domain_idkey))
3961
                           union
3962
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id=domain_idkey);
3963

    
3964

    
3965
                     else
3966
                        select 0 as test;
3967
                     end if;
3968

    
3969
        else
3970
                select 0 as test;
3971
        end if;
3972
End//
3973
DELIMITER ;
3974

    
3975
-- 프로시저 nerv_icde_test.metadataViewEditMetafieldRealmetadataList 구조 내보내기
3976
DROP PROCEDURE IF EXISTS `metadataViewEditMetafieldRealmetadataList`;
3977
DELIMITER //
3978
CREATE PROCEDURE `metadataViewEditMetafieldRealmetadataList`(domain_idkey int)
3979
BEGIN
3980
        declare sm bool;
3981
        declare sa varchar(100);
3982
        declare acount varchar(100);
3983
        declare pbc bool;
3984

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

    
3992
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
3993
                        select 1 as test;
3994
                         select * from data where domain_id=domain_idkey order by domain_id asc;
3995

    
3996
                     else
3997
                        select 0 as test;
3998
                     end if;
3999
        else
4000
                select 0 as test;
4001
        end if;
4002
END//
4003
DELIMITER ;
4004

    
4005
-- 프로시저 nerv_icde_test.metadataViewEditMetafieldSeq 구조 내보내기
4006
DROP PROCEDURE IF EXISTS `metadataViewEditMetafieldSeq`;
4007
DELIMITER //
4008
CREATE PROCEDURE `metadataViewEditMetafieldSeq`(IN `domain_idkey` int, IN `domaintype` varchar(50), IN `metadatakey` varchar(100), IN `metadatakey1` varchar(100), IN `metadatakey2` varchar(100))
4009
BEGIN
4010
        declare t1 bigint;
4011
        declare t2 bigint;
4012

    
4013
        declare data_auto_id_key int default null;
4014
        
4015
        if loginTest() and domainManageTest(domain_idkey) then
4016
                select 1 as test;
4017
                select data.data_auto_id into data_auto_id_key from data where data.domain_id=domain_idkey and data.name=metadatakey;
4018
                
4019
                  select seq into t1 from data_field where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey1;
4020
                  select seq into t2 from data_field where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey2;
4021
                update data_field set seq = t2 where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey1;
4022
                update data_field set seq = t1 where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey2;
4023
        else
4024
                select 0 as test;
4025
        end if;
4026

    
4027
END//
4028
DELIMITER ;
4029

    
4030
-- 프로시저 nerv_icde_test.metadataViewMetadataList 구조 내보내기
4031
DROP PROCEDURE IF EXISTS `metadataViewMetadataList`;
4032
DELIMITER //
4033
CREATE PROCEDURE `metadataViewMetadataList`(
4034
	IN `domain_idkey` int,
4035
	IN `metadatakey` varchar(100),
4036
	IN `domain_idtype` varchar(50)
4037

    
4038
)
4039
BEGIN
4040

    
4041
        if loginTest() and domainReadTest(domain_idkey, domain_idtype) then
4042
                select 1 as test;
4043

    
4044

    
4045
                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
4046

    
4047
    					(select * from data where domain_id=domain_idkey and name like metadatakey order by depth asc) as a
4048
    						left join
4049
    					(select data.data_auto_id, data.domain_id, data.name from data) as b on a.real_data_auto_id = b.data_auto_id
4050
        					left join
4051
    					(select id, name from domain_data) as c on b.domain_id = c.id;
4052
        else
4053
                select 0 as test;
4054
        end if;
4055
END//
4056
DELIMITER ;
4057

    
4058
-- 프로시저 nerv_icde_test.metadataViewMetadataListByTypeSort 구조 내보내기
4059
DROP PROCEDURE IF EXISTS `metadataViewMetadataListByTypeSort`;
4060
DELIMITER //
4061
CREATE PROCEDURE `metadataViewMetadataListByTypeSort`(IN `domain_idkey` int, IN `metadatakey` varchar(100), IN `domain_idtype` varchar(50))
4062
BEGIN
4063

    
4064
        if loginTest() and domainReadTest(domain_idkey, domain_idtype) then
4065
                select 1 as test;
4066
                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
4067
    					(select * from data where domain_id=domain_idkey and name like metadatakey order by type asc) as a
4068
    						left join
4069
    					(select data.data_auto_id, data.domain_id, data.name from data) as b on a.real_data_auto_id = b.data_auto_id
4070
        					left join
4071
    					(select id, name from domain_data) as c on b.domain_id = c.id;
4072
        else
4073
                select 0 as test;
4074
        end if;
4075
END//
4076
DELIMITER ;
4077

    
4078
-- 프로시저 nerv_icde_test.metadataViewMetafieldList 구조 내보내기
4079
DROP PROCEDURE IF EXISTS `metadataViewMetafieldList`;
4080
DELIMITER //
4081
CREATE PROCEDURE `metadataViewMetafieldList`(
4082
	IN `domain_idkey` int,
4083
	IN `metadatakey` varchar(100 ),
4084
	IN `domain_idtype` varchar(100)
4085
)
4086
BEGIN
4087

    
4088
        if loginTest() and domainReadTest(domain_idkey, domain_idtype) then
4089
                select 1 as test;
4090

    
4091
                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
4092
					(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
4093
						left outer join
4094
					(select data.data_auto_id, data.domain_id, data.name from data) as o on o.data_auto_id=a.data_auto_id
4095
						left outer join
4096
					(select data.data_auto_id, data.domain_id, data.name from data) as i on a.real_data_auto_id=i.data_auto_id
4097
					  left outer join
4098
               (select id, name from domain_data) as b on i.domain_id = b.id order by seq asc;
4099
        else
4100
                select 0 as test;
4101
        end if;
4102
END//
4103
DELIMITER ;
4104

    
4105
-- 프로시저 nerv_icde_test.metadataViewNewMetadata 구조 내보내기
4106
DROP PROCEDURE IF EXISTS `metadataViewNewMetadata`;
4107
DELIMITER //
4108
CREATE PROCEDURE `metadataViewNewMetadata`(
4109
	IN `domain_idkey` int,
4110
	IN `metadatakey` varchar(100),
4111
	IN `typevalue` varchar(100),
4112
	IN `real_data_auto_id` int,
4113
	IN `scminvalue` varchar(100),
4114
	IN `scmaxvalue` varchar(100),
4115
	IN `descriptionvalue` text
4116
)
4117
BEGIN
4118
       declare cnt int default 0;
4119
       declare depth int default 0;
4120
       declare real_data_domain_id int default null;
4121
       declare real_data_name varchar(100) default null;
4122

    
4123
       if typevalue ='alias' then
4124
       	select data.domain_id into real_data_domain_id from data where data.data_auto_id=real_data_auto_id;
4125
       	select data.name into real_data_name from data where data.data_auto_id=real_data_auto_id;
4126
      else
4127
      	set real_data_auto_id = NULL;
4128
       end if;
4129

    
4130
        if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(real_data_auto_id) )then
4131

    
4132

    
4133

    
4134
               if domain_idkey=real_data_domain_id then
4135
               	if typevalue ='alias' then
4136
               		select data.depth into depth from data where data.data_auto_id=real_data_auto_id;
4137
               		set depth = depth +1;
4138
               	end if;
4139
               end if;
4140

    
4141
                select 1 as test;
4142
                insert into data (domain_id   ,name       ,user_id     ,type     , real_data_auto_id     , scmin     ,scmax     ,description, depth)
4143
                              values(domain_idkey,metadatakey,@nervuser,typevalue, real_data_auto_id, scminvalue,scmaxvalue,descriptionvalue, depth);
4144

    
4145
        else
4146
                select 0 as test;
4147
        end if;
4148
END//
4149
DELIMITER ;
4150

    
4151
-- 프로시저 nerv_icde_test.metadataViewNewMetadataRealdomainList 구조 내보내기
4152
DROP PROCEDURE IF EXISTS `metadataViewNewMetadataRealdomainList`;
4153
DELIMITER //
4154
CREATE PROCEDURE `metadataViewNewMetadataRealdomainList`(IN `domain_idkey` int)
4155
BEGIN
4156
        declare sm bool;
4157
        declare sa varchar(100);
4158
        declare acount varchar(100);
4159
        declare pbc bool;
4160

    
4161
        set sa = '';
4162

    
4163
        if loginTest() then
4164
                    select supermanager into sm from users where user_id=@nervuser;
4165
                    select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
4166
                    select user_id into acount from domain_data where id=domain_idkey;
4167
                    select public into pbc from domain_data where id=domain_idkey;
4168

    
4169
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4170
                        select 1 as test;
4171
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data
4172
								 where id in (select parent_domain_id from inheritance_data_data where domain_id=domain_idkey))
4173
                         union
4174
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data
4175
								 where id=domain_idkey);
4176
                    else
4177
                        select 0 as test;
4178
                     end if;
4179
               else
4180
                 select 0 as test;
4181
        end if;
4182
End//
4183
DELIMITER ;
4184

    
4185
-- 프로시저 nerv_icde_test.metadataViewNewMetadataRealmetadataList 구조 내보내기
4186
DROP PROCEDURE IF EXISTS `metadataViewNewMetadataRealmetadataList`;
4187
DELIMITER //
4188
CREATE PROCEDURE `metadataViewNewMetadataRealmetadataList`(domain_idkey int)
4189
BEGIN
4190
        declare sm bool;
4191
        declare sa varchar(100);
4192
        declare acount varchar(100);
4193
        declare pbc bool;
4194

    
4195
        set sa = '';
4196
        if loginTest() then
4197
                     select supermanager into sm from users where user_id=@nervuser;
4198
                     select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
4199
                     select user_id into acount from domain_data where id=domain_idkey;
4200
                     select public into pbc from domain_data where id=domain_idkey;
4201

    
4202
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4203
                        select 1 as test;
4204
                         select * from data where domain_id=domain_idkey order by domain_id asc;
4205
                     else
4206
                        select 0 as test;
4207
                     end if;
4208
        else
4209
                select 0 as test;
4210
        end if;
4211
END//
4212
DELIMITER ;
4213

    
4214
-- 프로시저 nerv_icde_test.metadataViewNewMetafield 구조 내보내기
4215
DROP PROCEDURE IF EXISTS `metadataViewNewMetafield`;
4216
DELIMITER //
4217
CREATE PROCEDURE `metadataViewNewMetafield`(
4218
	IN `domain_idkey` int,
4219
	IN `metadatakey` varchar(100),
4220
	IN `metafieldkey` varchar(100),
4221
	IN `bitsizevalue` int unsigned,
4222
	IN `typevalue` varchar(100),
4223
	IN `real_domain_id_value` INT,
4224
	IN `real_data_value` VARCHAR(100),
4225
	IN `minvalue` varchar(100),
4226
	IN `in_maxvalue` varchar(100),
4227
	IN `arraytypevalue` varchar(100),
4228
	IN `arraysizevalue` int unsigned,
4229
	IN `descriptionvalue` text
4230

    
4231

    
4232

    
4233

    
4234
)
4235
BEGIN
4236
		 declare datakey_auto_id int default 0;
4237
		 declare real_data_auto_id int default 0;
4238
		 declare data_depth int default 0;
4239
		 declare data_field_depth int default 0;
4240

    
4241
		 if typevalue!='alias' then
4242
       	set real_data_auto_id=null;
4243
       else
4244
       	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;
4245
       end if;
4246

    
4247
        if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(real_data_auto_id) ) then
4248

    
4249
        			select data.data_auto_id into datakey_auto_id from data where data.domain_id=domain_idkey and data.name=metadatakey;
4250

    
4251
               if typevalue ='alias' then
4252
                  if real_data_auto_id != datakey_auto_id then
4253
							if domain_idkey=real_domain_id_value then
4254
	               		select data.depth into data_depth from data where data.domain_id=domain_idkey and data.name=metadatakey;
4255
	               		select data.depth into data_field_depth from data where data.data_auto_id=real_data_auto_id;
4256

    
4257
	               		 if data_depth <= data_field_depth then
4258
	               			set data_depth = data_field_depth + 1;
4259

    
4260
									update data set data.depth = data_depth where data.data_auto_id=datakey_auto_id;
4261

    
4262
	               			call update_child_depth(datakey_auto_id, domain_idkey, data_depth);
4263
	               		 end if;
4264
							end if;
4265
                     select 1 as test;
4266
							insert into data_field( data_auto_id, member_name,       bitsize,      type, real_data_auto_id,   user_id,scimin,  scimax,      arraytype,     arraysize, description)
4267
											values(datakey_auto_id, metafieldkey, bitsizevalue, typevalue, real_data_auto_id, @nervuser,minvalue,in_maxvalue,arraytypevalue,arraysizevalue,descriptionvalue);
4268

    
4269
						else
4270
							select 0 as test;
4271
                  end if;
4272
               else
4273
                 select 1 as test;
4274
                 insert into data_field( data_auto_id, member_name,       bitsize,      type, real_data_auto_id,   user_id,scimin,  scimax,      arraytype,     arraysize, description)
4275
                               values(datakey_auto_id, metafieldkey, bitsizevalue, typevalue, real_data_auto_id, @nervuser,minvalue,in_maxvalue,arraytypevalue,arraysizevalue,descriptionvalue);
4276
               end if;
4277

    
4278
        else
4279
                select 0 as test;
4280
        end if;
4281
END//
4282
DELIMITER ;
4283

    
4284
-- 프로시저 nerv_icde_test.metadataViewNewMetafieldRealdomainList 구조 내보내기
4285
DROP PROCEDURE IF EXISTS `metadataViewNewMetafieldRealdomainList`;
4286
DELIMITER //
4287
CREATE PROCEDURE `metadataViewNewMetafieldRealdomainList`(domain_idkey int)
4288
BEGIN
4289
        declare sm bool;
4290
        declare sa varchar(100);
4291
        declare acount varchar(100);
4292
        declare pbc bool;
4293

    
4294
        set sa = '';
4295
        if loginTest() then
4296
                    select supermanager into sm from users where user_id=@nervuser;
4297
                    select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
4298
                    select user_id into acount from domain_data where id=domain_idkey;
4299
                    select public into pbc from domain_data where id=domain_idkey;
4300

    
4301
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4302
                        select 1 as test;
4303
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id
4304
                                in (select parent_domain_id from inheritance_data_data where domain_id=domain_idkey))
4305
                         union
4306
                        (select id, upper_id, name, user_id, public, create_date, last_update, description from domain_data where id=domain_idkey);
4307
                    else
4308
                        select 0 as test;
4309
                     end if;
4310
               else
4311
                 select 0 as test;
4312
        end if;
4313
End//
4314
DELIMITER ;
4315

    
4316
-- 프로시저 nerv_icde_test.metadataViewNewMetafieldRealmetadataList 구조 내보내기
4317
DROP PROCEDURE IF EXISTS `metadataViewNewMetafieldRealmetadataList`;
4318
DELIMITER //
4319
CREATE PROCEDURE `metadataViewNewMetafieldRealmetadataList`(IN `domain_idkey` int, IN `domain_name` varchar(100))
4320
BEGIN
4321
        declare sm bool;
4322
        declare sa varchar(100);
4323
        declare acount varchar(100);
4324
        declare pbc bool;
4325

    
4326
        set sa = '';
4327
        if loginTest() then
4328
                     select supermanager into sm from users where user_id=@nervuser;
4329
                     select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
4330
                     select user_id into acount from domain_data where id=domain_idkey;
4331
                     select public into pbc from domain_data where id=domain_idkey;
4332

    
4333
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4334
                        select 1 as test;
4335
                        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;
4336

    
4337
                     else
4338
                        select 0 as test;
4339
                     end if;
4340
        else
4341
                select 0 as test;
4342
        end if;
4343
END//
4344
DELIMITER ;
4345

    
4346
-- 프로시저 nerv_icde_test.methodInfoList 구조 내보내기
4347
DROP PROCEDURE IF EXISTS `methodInfoList`;
4348
DELIMITER //
4349
CREATE PROCEDURE `methodInfoList`(domain_idkey int, methodkey varchar(100))
4350
BEGIN
4351

    
4352
        if loginTest() then
4353
                select 1 as test;
4354
                       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
4355
                           (select type,code,name,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4356
                              where domain_id=domain_idkey && name=methodkey) as a
4357
                             left outer join
4358
                              (select id, name from domain_data) as b on a.in_domain_id = b.id
4359
                              left outer join
4360
                              (select id, name from domain_data) as c on a.out_domain_id = c.id;
4361
        else
4362
                select 0 as test;
4363

    
4364
         end if;
4365

    
4366

    
4367
END//
4368
DELIMITER ;
4369

    
4370
-- 프로시저 nerv_icde_test.methodViewDeleteMethod 구조 내보내기
4371
DROP PROCEDURE IF EXISTS `methodViewDeleteMethod`;
4372
DELIMITER //
4373
CREATE PROCEDURE `methodViewDeleteMethod`(domain_idkey int, methodkey varchar(100))
4374
BEGIN
4375
        if loginTest() and domainManageTest(domain_idkey) then
4376
                select 1 as test;
4377
                delete from method where domain_id=domain_idkey and name=methodkey;
4378

    
4379
        else
4380
                select 0 as test;
4381
        end if;
4382
END//
4383
DELIMITER ;
4384

    
4385
-- 프로시저 nerv_icde_test.methodViewEditMethod 구조 내보내기
4386
DROP PROCEDURE IF EXISTS `methodViewEditMethod`;
4387
DELIMITER //
4388
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)
4389
BEGIN
4390

    
4391
	declare in_real_data_auto_id int default null;
4392
	declare out_real_data_auto_id int default null;
4393

    
4394
	if inputdomainvalue!=0 then
4395
      select data.data_auto_id into in_real_data_auto_id  from data where data.domain_id=inputdomainvalue and data.name=inputmetadatavalue;
4396
	end if;
4397
	if outputdomainvalue!=0 then
4398
      select data.data_auto_id into out_real_data_auto_id  from data where data.domain_id=outputdomainvalue and data.name=outputmetadatavalue;
4399
	end if;
4400

    
4401
     if loginTest() and domainManageTest(domain_idkey) and (in_real_data_auto_id is NULL or existMetadata(in_real_data_auto_id) )
4402
                                                       and (out_real_data_auto_id is NULL or existMetadata(out_real_data_auto_id)) then
4403
                select 1 as test;
4404
                update method set       code=codevalue,
4405
                                        type=typevalue,
4406
                                        name=methodvalue,
4407
                                        method.in_data_auto_id=in_real_data_auto_id,
4408
                                        method.out_data_auto_id=out_real_data_auto_id,
4409
                                        description=descriptionvalue
4410
                              where     domain_id=domain_idkey and name=methodkey;
4411

    
4412

    
4413

    
4414

    
4415

    
4416

    
4417

    
4418
        else
4419
                select 0 as test;
4420
        end if;
4421
END//
4422
DELIMITER ;
4423

    
4424
-- 프로시저 nerv_icde_test.methodViewEditMethodRealdomainList 구조 내보내기
4425
DROP PROCEDURE IF EXISTS `methodViewEditMethodRealdomainList`;
4426
DELIMITER //
4427
CREATE PROCEDURE `methodViewEditMethodRealdomainList`(domain_idkey int)
4428
BEGIN
4429
        declare sm bool;
4430
        declare sa varchar(100);
4431
        declare acount varchar(100);
4432
        declare pbc bool;
4433

    
4434
        set sa = '';
4435
        if loginTest() then
4436
                    select supermanager into sm from users where user_id=@nervuser;
4437
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
4438
                    select user_id into acount from domain_method where id=domain_idkey;
4439
                    select public into pbc from domain_method where id=domain_idkey;
4440

    
4441
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4442
                        select 1 as test;
4443
                        (select name from domain_data where id in (select parent_domain_id from inheritance_method_data where domain_id=domain_idkey))
4444
                         union
4445
                        (select name from domain_method where id=domain_idkey);
4446

    
4447

    
4448

    
4449
                    else
4450
                        select 0 as test;
4451
                     end if;
4452
               else
4453
                 select 0 as test;
4454
        end if;
4455
End//
4456
DELIMITER ;
4457

    
4458
-- 프로시저 nerv_icde_test.methodViewEditMethodRealmetadataList 구조 내보내기
4459
DROP PROCEDURE IF EXISTS `methodViewEditMethodRealmetadataList`;
4460
DELIMITER //
4461
CREATE PROCEDURE `methodViewEditMethodRealmetadataList`(domain_idkey int, domainkey varchar(100))
4462
BEGIN
4463
        declare sm bool;
4464
        declare sa varchar(100);
4465
        declare acount varchar(100);
4466
        declare pbc bool;
4467

    
4468
        set sa = '';
4469
        if loginTest() then
4470

    
4471
                     select supermanager into sm from users where user_id = @nervuser;
4472
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
4473
                     select user_id into acount from domain_method where id = domain_idkey;
4474
                     select public into pbc from domain_method where id = domain_idkey;
4475

    
4476

    
4477
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4478
                        select 1 as test;
4479

    
4480
                        select name from data where domain_id in (select id from domain_data where name = domainkey);
4481

    
4482
                     else
4483
                        select 0 as test;
4484
                     end if;
4485
       else
4486
                select 0 as test;
4487
       end if;
4488
END//
4489
DELIMITER ;
4490

    
4491
-- 프로시저 nerv_icde_test.methodViewMethodList 구조 내보내기
4492
DROP PROCEDURE IF EXISTS `methodViewMethodList`;
4493
DELIMITER //
4494
CREATE PROCEDURE `methodViewMethodList`(
4495
	IN `domain_idkey` int,
4496
	IN `in_domaintype` varchar(100),
4497
	IN `typekey` varchar(100),
4498
	IN `codekey` varchar(100),
4499
	IN `methodkey` varchar(100)
4500

    
4501
)
4502
BEGIN
4503
	declare domaintype varchar(20);
4504
	set domaintype = 'method';
4505

    
4506
	if codekey='' then
4507
      set codekey = null;
4508
	end if;
4509
         if loginTest() and domainReadTest(domain_idkey, domaintype) then
4510
                select 1 as test;
4511
                if typekey = 'ALL' then
4512
                     if codekey is null then
4513
                     	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
4514
                      	(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
4515
                        	left outer join
4516
                      	(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
4517
                        	left outer join
4518
                       	(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id
4519
									left outer join
4520
                        (select id, name from domain_data) as b on i.domain_id = b.id
4521
                           left outer join
4522
                        (select id, name from domain_data) as c on o.domain_id = c.id;
4523
                     else
4524
                     	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
4525
                         (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
4526
								   left outer join
4527
                      	(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
4528
                        	left outer join
4529
                       	(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id
4530
                           left outer join
4531
                         (select id, name from domain_data) as b on i.domain_id = b.id
4532
                           left outer join
4533
                         (select id, name from domain_data) as c on o.domain_id = c.id;
4534
                     end if;
4535
                else
4536
                     if codekey is null then
4537
                     	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
4538
                         (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
4539
                         left outer join
4540
                      	(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
4541
                        	left outer join
4542
                       	(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id
4543
                           left outer join
4544
                        (select id, name from domain_data) as b on i.in_domain_id = b.id
4545
                           left outer join
4546
                        (select id, name from domain_data) as c on o.out_domain_id = c.id;
4547
                     else
4548
                     	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
4549
                         (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
4550
                             left outer join
4551
                      	(select data.data_auto_id, data.domain_id, data.name from data) as i on a.in_data_auto_id=i.data_auto_id
4552
                        	left outer join
4553
                       	(select data.data_auto_id, data.domain_id, data.name from data) as o on a.out_data_auto_id=o.data_auto_id
4554
                           left outer join
4555
                        (select id, name from domain_data) as b on i.in_domain_id = b.id
4556
                           left outer join
4557
                        (select id, name from domain_data) as c on o.out_domain_id = c.id;
4558
                     end if;
4559
                end if;
4560
        else
4561
          select 0 as test;
4562
        end if;
4563
END//
4564
DELIMITER ;
4565

    
4566
-- 프로시저 nerv_icde_test.methodViewNewMethod 구조 내보내기
4567
DROP PROCEDURE IF EXISTS `methodViewNewMethod`;
4568
DELIMITER //
4569
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)
4570
BEGIN
4571

    
4572
	declare in_real_data_auto_id int default null;
4573
	declare out_real_data_auto_id int default null;
4574

    
4575
	if inputdomainvalue!=0 then
4576
      select data.data_auto_id into in_real_data_auto_id  from data where data.domain_id=inputdomainvalue and data.name=inputmetadatavalue;
4577
	end if;
4578
	if outputdomainvalue!=0 then
4579
      select data.data_auto_id into out_real_data_auto_id  from data where data.domain_id=outputdomainvalue and data.name=outputmetadatavalue;
4580
	end if;
4581

    
4582
	if  loginTest() and domainManageTest(domain_idkey) and (in_real_data_auto_id is NULL or existMetadata(in_real_data_auto_id) )
4583
		 and (out_real_data_auto_id is NULL or existMetadata(out_real_data_auto_id)) then
4584
                select 1 as test;
4585

    
4586
                insert into method(    domain_id,    code,      type,      name,     method.in_data_auto_id,     method.out_data_auto_id,   user_id, description)
4587
                            values( domain_idkey, codekey, typevalue, methodkey, in_real_data_auto_id, out_real_data_auto_id, @nervuser, descriptionvalue);
4588
        else
4589
                select 0 as test;
4590
        end if;
4591

    
4592
END//
4593
DELIMITER ;
4594

    
4595
-- 프로시저 nerv_icde_test.methodViewNewMethodRealdomainList 구조 내보내기
4596
DROP PROCEDURE IF EXISTS `methodViewNewMethodRealdomainList`;
4597
DELIMITER //
4598
CREATE PROCEDURE `methodViewNewMethodRealdomainList`(IN `domain_idkey` int)
4599
BEGIN
4600
        declare sm bool;
4601
        declare sa varchar(100);
4602
        declare acount varchar(100);
4603
        declare pbc bool;
4604

    
4605

    
4606
        set sa = '';
4607
        if loginTest() then
4608

    
4609
                    select supermanager into sm from users where user_id=@nervuser;
4610
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
4611
                    select user_id into acount from domain_method where id=domain_idkey;
4612
                    select public into pbc from domain_method where id=domain_idkey;
4613

    
4614
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4615
                        select 1 as test;
4616
                        select d.* from
4617
								(
4618
									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)
4619
									union
4620
									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)
4621
								)as m join domain_data as d on m.domain_id=d.id;
4622

    
4623
                    else
4624
                        select 0 as test;
4625
                     end if;
4626
               else
4627
                 select 0 as test;
4628
        end if;
4629
End//
4630
DELIMITER ;
4631

    
4632
-- 프로시저 nerv_icde_test.methodViewNewMethodRealmetadataList 구조 내보내기
4633
DROP PROCEDURE IF EXISTS `methodViewNewMethodRealmetadataList`;
4634
DELIMITER //
4635
CREATE PROCEDURE `methodViewNewMethodRealmetadataList`(IN `domain_idkey` int)
4636
BEGIN
4637
        declare sm bool;
4638
        declare sa varchar(100);
4639
        declare acount varchar(100);
4640
        declare pbc bool;
4641

    
4642

    
4643

    
4644

    
4645
        set sa = '';
4646

    
4647

    
4648

    
4649
        if loginTest() then
4650

    
4651
							select supermanager into sm from users where user_id = @nervuser;
4652
       					select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
4653
       					select user_id into acount from domain_data where id = domain_idkey;
4654
       					select public into pbc from domain_data where id = domain_idkey;
4655

    
4656
                       if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
4657
                          select 1 as test;
4658
                          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
4659
                                 from data where domain_id=domain_idkey order by domain_id asc;
4660

    
4661
                       else
4662
                          select 0 as test;
4663
                       end if;
4664
       else
4665
                select 0 as test;
4666
       end if;
4667
END//
4668
DELIMITER ;
4669

    
4670
-- 프로시저 nerv_icde_test.methodViewTreeList 구조 내보내기
4671
DROP PROCEDURE IF EXISTS `methodViewTreeList`;
4672
DELIMITER //
4673
CREATE PROCEDURE `methodViewTreeList`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `typekey` varchar(100), IN `codekey` varchar(100), IN `methodkey` varchar(100))
4674
BEGIN
4675
        if loginTest() and domainReadTest(domain_idkey, domaintype) then
4676
                select 1 as test;
4677
                if typekey = 'ALL' then
4678
                        if codekey = ' ' then
4679
                                select domain_id, name, type,code,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4680
										   where domain_id=domain_idkey and method like methodkey order by code  asc;
4681
                        else
4682
                                select domain_id, name, type,code,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4683
										   where domain_id=domain_idkey and code like codekey and method like methodkey order by code  asc;
4684
                        end if;
4685
                else
4686
                        if codekey = ' ' then
4687
                                select domain_id, name, type,code,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4688
										   where domain_id=domain_idkey and type=typekey and method like methodkey order by code asc;
4689
                        else
4690
                                select domain_id, name, type,code,in_domain_id,in_data,out_domain_id,out_data,user_id,description from method
4691
										   where domain_id=domain_idkey and type=typekey and code like codekey and method like methodkey order by code asc;
4692
                        end if;
4693
                end if;
4694
        else
4695
                select 0 as test;
4696
        end if;
4697
END//
4698
DELIMITER ;
4699

    
4700
-- 프로시저 nerv_icde_test.networkLinkViewConnectSwitch 구조 내보내기
4701
DROP PROCEDURE IF EXISTS `networkLinkViewConnectSwitch`;
4702
DELIMITER //
4703
CREATE PROCEDURE `networkLinkViewConnectSwitch`(in_node_id int)
4704
BEGIN
4705
     if loginTest() then
4706
         select 1 as test;
4707
         select b.node_id, b.ip, b.mask, b.port, b.net from
4708
         (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
4709
         join
4710
         (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;
4711

    
4712

    
4713
     else
4714
         select 0 as test;
4715
     end if;
4716

    
4717
End//
4718
DELIMITER ;
4719

    
4720
-- 프로시저 nerv_icde_test.netWorkLinkViewDeleteNetWorkLink 구조 내보내기
4721
DROP PROCEDURE IF EXISTS `netWorkLinkViewDeleteNetWorkLink`;
4722
DELIMITER //
4723
CREATE PROCEDURE `netWorkLinkViewDeleteNetWorkLink`(in_s_node_id_key int, in_s_port_id_key int)
4724
BEGIN
4725
     if loginTest() then
4726
         select 1 as test;
4727
         delete from network_link where s_node_id = in_s_node_id_key and s_port_id = in_s_port_id_key;
4728
     else
4729
         select 0 as test;
4730
     end if;
4731
End//
4732
DELIMITER ;
4733

    
4734
-- 프로시저 nerv_icde_test.NetworklinkViewEditNetworkink 구조 내보내기
4735
DROP PROCEDURE IF EXISTS `NetworklinkViewEditNetworkink`;
4736
DELIMITER //
4737
CREATE PROCEDURE `NetworklinkViewEditNetworkink`(in_s_node_id_key int, in_s_node_port_key int,
4738
                                                                    in_s_node_id_edit int, in_s_node_sub_system_domain_id int, in_s_node_port_edit int,
4739
                                                                    in_d_node_id_edit int, in_d_node_sub_system_domain_id int, in_d_node_port_edit int)
4740
BEGIN
4741
     if loginTest() then
4742
         select 1 as test;
4743
         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,
4744
                                 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
4745
                             where s_node_id = in_s_node_id_key and s_port_id=in_s_node_port_key;
4746

    
4747
     else
4748
         select 0 as test;
4749
     end if;
4750
End//
4751
DELIMITER ;
4752

    
4753
-- 프로시저 nerv_icde_test.NetworklinkViewNetworkinkList 구조 내보내기
4754
DROP PROCEDURE IF EXISTS `NetworklinkViewNetworkinkList`;
4755
DELIMITER //
4756
CREATE PROCEDURE `NetworklinkViewNetworkinkList`(
4757
	IN `in_system_domain_id` int
4758
)
4759
BEGIN
4760
     if loginTest() then
4761
         select 1 as test;
4762

    
4763
			select * from
4764
				(
4765
		         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
4766
		         ((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
4767
   		      join
4768
      		   (select id, name, node.type  from node) as b on b.id = a.s_node_id
4769
         		join
4770
		         (select id, name from node) as c on c.id = a.d_node_id) order by b.type
4771
	         ) as x order by sname, s_port_id asc;
4772

    
4773

    
4774
        else
4775
         select 0 as test;
4776
     end if;
4777
End//
4778
DELIMITER ;
4779

    
4780
-- 프로시저 nerv_icde_test.NetworklinkViewNewNetworkink 구조 내보내기
4781
DROP PROCEDURE IF EXISTS `NetworklinkViewNewNetworkink`;
4782
DELIMITER //
4783
CREATE PROCEDURE `NetworklinkViewNewNetworkink`(in_s_node_id int, in_s_sub_system_id int, in_s_port_id int,
4784
                                                                   in_d_node_id int, in_d_sub_system_id int, in_d_port_id int)
4785
BEGIN
4786
     if loginTest() then
4787
         select 1 as test;
4788
         insert into network_link(s_node_id, s_sub_system_id, s_port_id, d_node_id, d_sub_system_id, d_port_id)
4789
                           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);
4790
     else
4791
         select 0 as test;
4792
     end if;
4793
End//
4794
DELIMITER ;
4795

    
4796
-- 프로시저 nerv_icde_test.networkNewip 구조 내보내기
4797
DROP PROCEDURE IF EXISTS `networkNewip`;
4798
DELIMITER //
4799
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))
4800
BEGIN
4801
     if loginTest() then
4802
     		select 1 as test;
4803
          insert into network (node_id,  ip,   mask,    net,   gateway,    dns,   port,   description, collision, original_node_id, original_node_port, original_node_ip)
4804
                      values(innodeid, inip, intmask, innet, intgateway, indns, inport, indescription, 0, NULL, NULL, NULL);
4805
		    insert into deployments_bind(deployments_bind.deployment_id, deployments_bind.node_id, deployments_bind.port, deployments_bind.ip)
4806
		    select deployments.Id, innodeid, inport, inip from deployments where deployments.node_id = innodeid;
4807
     else
4808
         select 0 as test;
4809
     end if;
4810

    
4811
End//
4812
DELIMITER ;
4813

    
4814
-- 프로시저 nerv_icde_test.networkViewDeleteip 구조 내보내기
4815
DROP PROCEDURE IF EXISTS `networkViewDeleteip`;
4816
DELIMITER //
4817
CREATE PROCEDURE `networkViewDeleteip`(in_node_id int,
4818
                                                          in_ip varchar(100))
4819
BEGIN
4820
        if loginTest() then
4821
                select 1 as test;
4822
                delete from network where node_id=in_node_id and ip=in_ip;
4823
        else
4824
                select 0 as test;
4825
        end if;
4826
END//
4827
DELIMITER ;
4828

    
4829
-- 프로시저 nerv_icde_test.networkViewEditip 구조 내보내기
4830
DROP PROCEDURE IF EXISTS `networkViewEditip`;
4831
DELIMITER //
4832
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))
4833
BEGIN
4834
        if loginTest() then
4835
                select 1 as test;
4836
                       update network set ip=in_edit_ip, mask=in_edit_mask, net=in_edit_net, gateway=in_edit_gateway, dns=in_edit_dns,
4837
                                       port=in_edit_port, description=in_edit_description
4838
                                    where node_id=in_node_idkey and ip=in_ipkey;
4839

    
4840
								if in_ipkey != in_edit_ip then
4841
								  	update network set network.ip = in_edit_ip
4842
							 			where network.original_node_id=in_node_idkey and network.original_node_port=in_edit_port and network.original_node_ip=in_ipkey;
4843

    
4844
									update deployments_bind a, (select * from deployments_bind where deployments_bind.deployment_id in
4845
									(select deployments_bind.deployment_id from deployments_bind where deployments_bind.ip = in_ipkey and deployments_bind.node_id in(
4846
																							select node_id from network where network.original_node_id = in_node_idkey and
4847
																							 network.original_node_port=in_port_key and network.original_node_ip=in_ipkey))) b
4848
									 set a.ip=in_edit_ip
4849
									 where a.deployment_id = b.deployment_id;
4850

    
4851
                     		update network set network.original_node_ip=in_edit_ip
4852
							 			where network.original_node_id=in_node_idkey and network.original_node_port=in_edit_port and network.original_node_ip=in_ipkey;
4853
							 	end if;
4854

    
4855
        else
4856
                select 0 as test;
4857
        end if;
4858
END//
4859
DELIMITER ;
4860

    
4861
-- 프로시저 nerv_icde_test.networkViewList 구조 내보내기
4862
DROP PROCEDURE IF EXISTS `networkViewList`;
4863
DELIMITER //
4864
CREATE PROCEDURE `networkViewList`(IN `innode_id` int)
4865
BEGIN
4866
     if loginTest() then
4867
         select 1 as test;
4868

    
4869
     	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
4870
     	(select * from network where node_id = innode_id) as a
4871

    
4872
      join
4873
      (select id, name  from node) as b on b.id = innode_id
4874
		left join
4875
		(select id, name  from node) as c on c.id = a.original_node_id;
4876
     else
4877
         select 0 as test;
4878
     end if;
4879
End//
4880
DELIMITER ;
4881

    
4882
-- 프로시저 nerv_icde_test.networkViewSubsystemList 구조 내보내기
4883
DROP PROCEDURE IF EXISTS `networkViewSubsystemList`;
4884
DELIMITER //
4885
CREATE PROCEDURE `networkViewSubsystemList`(in_sub_system_id int)
4886
BEGIN
4887
     if loginTest() then
4888
         select 1 as test;
4889

    
4890
         SELECT a.d_port_id , b.name, b.type, a.s_port_id, d.ip, d.mask, d.gateway, d.dns, d.description from
4891
         (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
4892
         join
4893
         (select id, name, type from node) as b on b.id = a.s_node_id
4894
         join
4895
         (select id, name from domain_system) as c on c.id = a.d_sub_system_id
4896
         left join
4897
         (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;
4898

    
4899
         else
4900
         select 0 as test;
4901
     end if;
4902
End//
4903
DELIMITER ;
4904

    
4905
-- 프로시저 nerv_icde_test.network_table_node_Ip_ist 구조 내보내기
4906
DROP PROCEDURE IF EXISTS `network_table_node_Ip_ist`;
4907
DELIMITER //
4908
CREATE PROCEDURE `network_table_node_Ip_ist`(IN `in_deploy_id` INT)
4909
BEGIN
4910
     if loginTest() then
4911
         select 1 as test;
4912
			select * from network where network.node_id in(select node_id from deployments where deployments.Id = in_deploy_id);
4913
	  else
4914
	  		select 0 as test;
4915
	  end if;
4916
END//
4917
DELIMITER ;
4918

    
4919
-- 프로시저 nerv_icde_test.nodeComponentViewProxyComponentList 구조 내보내기
4920
DROP PROCEDURE IF EXISTS `nodeComponentViewProxyComponentList`;
4921
DELIMITER //
4922
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)
4923
BEGIN
4924
     if loginTest() then
4925
     select 1 as test;
4926

    
4927
      	select d.*, a.stub_ip, a.stub_object_id, e.name, b.id from
4928
		(
4929
			select * from custum_proxy where stub_object_id=in_objectid and stub_ip in(
4930
				select ip from deployments_bind where deployments_bind.deployment_id in (select id from deployments where deployments.component_id = in_component_id))
4931
		) as a
4932
		join
4933
		(select * from proxy_interface_relation) as c on c.id = a.proxy_interface_id and c.interface_name=in_interface_name
4934
	   join
4935
	  	(select * from deployments) as b on b.id = a.deploy_id and systemdomain_id=in_domain_id
4936
	  	join
4937
	  	(select * from component) as d on d.id = b.component_id
4938
	  	join
4939
	  	(select * from node) as e on e.id = b.node_id
4940
	  ;
4941

    
4942
     else
4943
         select 0 as test;
4944
     end if;
4945
 End//
4946
DELIMITER ;
4947

    
4948
-- 프로시저 nerv_icde_test.nodecomponentViewstubcomponentlist 구조 내보내기
4949
DROP PROCEDURE IF EXISTS `nodecomponentViewstubcomponentlist`;
4950
DELIMITER //
4951
CREATE PROCEDURE `nodecomponentViewstubcomponentlist`(IN `in_objectid` int, IN `in_networkip` varchar(255), IN `in_domain_id` int)
4952
BEGIN
4953
     if loginTest() then
4954
     select 1 as test;
4955
      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
4956
      	(select id, deploy_id, stub_interface_id, object_id FROM custum_stub where object_id = in_objectid and deploy_id in
4957
         	(select deployments_bind.deployment_id from deployments_bind where deployments_bind.ip=in_networkip and  deployments_bind.deployment_id in
4958
					(select id from deployments where deployments.systemdomain_id=in_domain_id and deployments.node_id in
4959
						(select node_id from network where ip = in_networkip)))) as a
4960
		     join
4961
          (select id, component_id, interface_name, class_name from stub_interface_relation) as b on b.id = a.stub_interface_id
4962
           join
4963
          (select id, systemdomain_id, name, seq, description from component) as c on c.id = b.component_id
4964
			  join
4965
			 (select Id, name from node where node.Id in
4966
				 (select node_id from deployments where deployments.systemdomain_id=in_domain_id and deployments.node_id in
4967
					(select node_id from network where ip = in_networkip)
4968
				 )
4969
			  ) as d ;
4970

    
4971
      else
4972
         select 0 as test;
4973
     end if;
4974
 End//
4975
DELIMITER ;
4976

    
4977
-- 프로시저 nerv_icde_test.nodeDeleteNodes 구조 내보내기
4978
DROP PROCEDURE IF EXISTS `nodeDeleteNodes`;
4979
DELIMITER //
4980
CREATE PROCEDURE `nodeDeleteNodes`(IN `inidkey` int)
4981
BEGIN
4982

    
4983
 declare node_type varchar(100);
4984

    
4985
        if loginTest() and domainManageTest(inidkey) then
4986
                select 1 as test;
4987
                select node.`type` into node_type from node where id=inidkey;
4988

    
4989
                if node_type='sub_system' then
4990
   	             delete from component where component.id in(select deployments.component_id from deployments where deployments.node_id=inidkey);
4991
                end if;
4992

    
4993
                delete from node where id=inidkey;
4994
        else
4995
                select 0 as test;
4996
        end if;
4997
END//
4998
DELIMITER ;
4999

    
5000
-- 프로시저 nerv_icde_test.nodeDeploymentViewComponentList 구조 내보내기
5001
DROP PROCEDURE IF EXISTS `nodeDeploymentViewComponentList`;
5002
DELIMITER //
5003
CREATE PROCEDURE `nodeDeploymentViewComponentList`(IN `in_systemdomain_id` int, IN `in_node_id` int)
5004
BEGIN
5005

    
5006
     if loginTest() then
5007
         select 1 as test;
5008

    
5009
         select Id, systemdomain_id, name, seq, description from component where systemdomain_id = in_systemdomain_id;
5010

    
5011
     else
5012
         select 0 as test;
5013
     end if;
5014

    
5015

    
5016

    
5017
End//
5018
DELIMITER ;
5019

    
5020
-- 프로시저 nerv_icde_test.nodeDeploymentViewDeleteComponent 구조 내보내기
5021
DROP PROCEDURE IF EXISTS `nodeDeploymentViewDeleteComponent`;
5022
DELIMITER //
5023
CREATE PROCEDURE `nodeDeploymentViewDeleteComponent`(IN `in_id` int)
5024
BEGIN
5025

    
5026

    
5027
        if loginTest() then
5028
                select 1 as test;
5029

    
5030
                delete from deployments where deployments.Id = in_id;
5031
        else
5032
                select 0 as test;
5033
        end if;
5034
END//
5035
DELIMITER ;
5036

    
5037
-- 프로시저 nerv_icde_test.nodeDeploymentViewInstallList 구조 내보내기
5038
DROP PROCEDURE IF EXISTS `nodeDeploymentViewInstallList`;
5039
DELIMITER //
5040
CREATE PROCEDURE `nodeDeploymentViewInstallList`(
5041
	IN `in_systemdomain_id` int,
5042
	IN `in_node_id` int
5043
)
5044
BEGIN
5045

    
5046
     if loginTest() then
5047
         select 1 as test;
5048

    
5049

    
5050
         select B.ID as process_id , A.Id as component_id, A.systemdomain_id, A.name, A.seq, A.description from
5051

    
5052
--			( select Id, systemdomain_id, name, seq, description from component  where systemdomain_id = in_systemdomain_id ) as A
5053
			( select Id, systemdomain_id, name, seq, description from component ) as A
5054

    
5055
         join deployments as B
5056
             on A.Id = B.component_id
5057
             where node_id = in_node_id;
5058

    
5059

    
5060
     else
5061
         select 0 as test;
5062
     end if;
5063

    
5064

    
5065

    
5066
End//
5067
DELIMITER ;
5068

    
5069
-- 프로시저 nerv_icde_test.nodeDeploymentViewNewcomponent 구조 내보내기
5070
DROP PROCEDURE IF EXISTS `nodeDeploymentViewNewcomponent`;
5071
DELIMITER //
5072
CREATE PROCEDURE `nodeDeploymentViewNewcomponent`(IN `in_node_id` int, IN `in_component_id` int, IN `in_systemdomain_id` int, IN `in_copy_deploy_id` INT)
5073
BEGIN
5074

    
5075
	  declare new_deployment_id int;
5076

    
5077

    
5078
     if loginTest() then
5079
     		select 1 as test;
5080

    
5081
	   	insert into deployments(node_id, component_id, systemdomain_id) values(in_node_id, in_component_id, in_systemdomain_id);
5082
			select Last_INSERT_ID() into new_deployment_id;
5083

    
5084
			insert into custum_proxy (deploy_id, proxy_interface_id, object_name)
5085
			select new_deployment_id, proxy_interface_object.proxy_interface_id, proxy_interface_object.object_name from proxy_interface_object where proxy_interface_id in
5086
			(select id from proxy_interface_relation where component_id = in_component_id);
5087

    
5088
			insert into custum_stub (deploy_id, stub_interface_id, object_name)
5089
			select new_deployment_id, stub_interface_object.stub_interface_id, stub_interface_object.object_name from stub_interface_object where stub_interface_id in
5090
			(select id from stub_interface_relation where component_id = in_component_id);
5091

    
5092
			update custum_proxy set original_id=custum_proxy.Id where custum_proxy.deploy_id = new_deployment_id;
5093
			update custum_stub set original_id=custum_stub.Id where custum_stub.deploy_id = new_deployment_id;
5094

    
5095
			update custum_proxy set original_deployment_id=custum_proxy.deploy_id where custum_proxy.deploy_id = new_deployment_id;
5096
			update custum_stub set original_deployment_id=custum_stub.deploy_id where custum_stub.deploy_id = new_deployment_id;
5097

    
5098
			insert into deployments_bind (deployments_bind.deployment_id, deployments_bind.node_id, deployments_bind.port, deployments_bind.ip)
5099
			select new_deployment_id, network.node_id, network.port, network.ip from network where network.node_id = in_node_id;
5100

    
5101

    
5102
			if in_copy_deploy_id > 0 then
5103
				update custum_proxy as a,
5104
      		(select custum_proxy.object_name, custum_proxy.object_id, custum_proxy.stub_object_id, custum_proxy.stub_ip, custum_proxy.public from custum_proxy
5105
				 where deploy_id = in_copy_deploy_id) as b
5106
      			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
5107
      			where a.deploy_id = new_deployment_id and a.object_name=b.object_name;
5108

    
5109
				update custum_stub as a,
5110
      		(select custum_stub.object_name, custum_stub.object_id, custum_stub.public from custum_stub where deploy_id = in_copy_deploy_id) as b
5111
      			set a.object_id = b.object_id, a.public=b.public
5112
      			where a.deploy_id = new_deployment_id and a.object_name=b.object_name;
5113
      	end if;
5114

    
5115
       else
5116
         select 0 as test;
5117
     end if;
5118

    
5119
End//
5120
DELIMITER ;
5121

    
5122
-- 프로시저 nerv_icde_test.nodeDeploymentViewUpdateCustumTable 구조 내보내기
5123
DROP PROCEDURE IF EXISTS `nodeDeploymentViewUpdateCustumTable`;
5124
DELIMITER //
5125
CREATE PROCEDURE `nodeDeploymentViewUpdateCustumTable`(IN `in_copy_deploy_id` INT, IN `in_new_component_id` INT)
5126
BEGIN
5127

    
5128
	declare in_new_deploy_id int;
5129
   declare new_custum_id int;
5130
  	declare check_public int;
5131

    
5132
	if logintest() then
5133
		select 1 as test;
5134
		select id into in_new_deploy_id from deployments where deployments.component_id = in_new_component_id;
5135

    
5136
		update custum_proxy as a,
5137
      	(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
5138
      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
5139
      where a.deploy_id = in_new_deploy_id and a.object_name=b.object_name;
5140

    
5141

    
5142
		update custum_stub as a,
5143
      	(select custum_stub.object_name, custum_stub.object_id, custum_stub.public from custum_stub where deploy_id = in_copy_deploy_id) as b
5144
      set a.object_id = b.object_id, a.public=b.public
5145
      where a.deploy_id = in_new_deploy_id and a.object_name=b.object_name;
5146

    
5147
   else
5148
   			select 0 as test;
5149
   end if;
5150
END//
5151
DELIMITER ;
5152

    
5153
-- 프로시저 nerv_icde_test.nodeNewNodes 구조 내보내기
5154
DROP PROCEDURE IF EXISTS `nodeNewNodes`;
5155
DELIMITER //
5156
CREATE PROCEDURE `nodeNewNodes`(IN `insystemdomainid` int, IN `inname` varchar(50), IN `intype` varchar(50), IN `indescription` text, IN `in_sub_system_domain_id` int)
5157
BEGIN
5158

    
5159
     if loginTest() then
5160
     		select 1 as test;
5161

    
5162
			  if intype = 'router' then
5163
     			set intype = 'urouter';
5164
     		end if;
5165

    
5166
			insert into node(systemdomain_id, name, type, description, sub_system_domain_id)
5167
                      values(insystemdomainid, inname, intype, indescription, in_sub_system_domain_id);
5168

    
5169
			select LAST_INSERT_ID();
5170

    
5171
     else
5172
         select 0 as test;
5173
     end if;
5174

    
5175

    
5176

    
5177
End//
5178
DELIMITER ;
5179

    
5180
-- 프로시저 nerv_icde_test.nodeportViewNewNode 구조 내보내기
5181
DROP PROCEDURE IF EXISTS `nodeportViewNewNode`;
5182
DELIMITER //
5183
CREATE PROCEDURE `nodeportViewNewNode`(in_node_id int, in_domain_system_id int, in_sub_system_domain_id int)
5184
BEGIN
5185
     if loginTest() then
5186
         select 1 as test;
5187
         insert node_port (id, systemdomain_id, sub_system_domain_id, port_group)
5188
         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;
5189

    
5190
     else
5191
         select 0 as test;
5192
     end if;
5193
End//
5194
DELIMITER ;
5195

    
5196
-- 프로시저 nerv_icde_test.nodeportViewNewPortGroup 구조 내보내기
5197
DROP PROCEDURE IF EXISTS `nodeportViewNewPortGroup`;
5198
DELIMITER //
5199
CREATE PROCEDURE `nodeportViewNewPortGroup`(in_sub_system_domain_id int, in_port_group int)
5200
BEGIN
5201
     if loginTest() then
5202
         select 1 as test;
5203
         insert into node_port (id, systemdomain_id, sub_system_domain_id, port_group)
5204
          select id, systemdomain_id, sub_system_domain_id, in_port_group from node where sub_system_domain_id = in_sub_system_domain_id;
5205

    
5206
     else
5207
         select 0 as test;
5208
     end if;
5209
End//
5210
DELIMITER ;
5211

    
5212
-- 프로시저 nerv_icde_test.nodeportViewNodeportInfo 구조 내보내기
5213
DROP PROCEDURE IF EXISTS `nodeportViewNodeportInfo`;
5214
DELIMITER //
5215
CREATE PROCEDURE `nodeportViewNodeportInfo`(in_node_id int)
5216
BEGIN
5217
     if loginTest() then
5218
         select 1 as test;
5219
        select  id, systemdomain_id, sub_system_domain_id, port_group from node_port where id =in_node_id;
5220

    
5221
     else
5222
         select 0 as test;
5223
     end if;
5224
End//
5225
DELIMITER ;
5226

    
5227
-- 프로시저 nerv_icde_test.nodeproxyViewNewstubinfo 구조 내보내기
5228
DROP PROCEDURE IF EXISTS `nodeproxyViewNewstubinfo`;
5229
DELIMITER //
5230
CREATE PROCEDURE `nodeproxyViewNewstubinfo`(in_nodeid int,
5231
                                                   in_stub_objectid       varchar(50),
5232
                                                   in_stub_ip     varchar(255))
5233
BEGIN
5234
     if loginTest() then
5235
     select 1 as test;
5236
         update custum_proxy set stub_object_id=in_stub_objectid, stub_ip=in_stub_ip
5237
          where id=in_nodeid;
5238
     else
5239
         select 0 as test;
5240
     end if;
5241

    
5242
End//
5243
DELIMITER ;
5244

    
5245
-- 프로시저 nerv_icde_test.nodesNewSwitch 구조 내보내기
5246
DROP PROCEDURE IF EXISTS `nodesNewSwitch`;
5247
DELIMITER //
5248
CREATE PROCEDURE `nodesNewSwitch`(insystemdomainid int,
5249
                                                     inip varchar(50),
5250
                                                     insubnetmask varchar(50),
5251
                                                     indescription text)
5252
BEGIN
5253
     if loginTest() then
5254
         insert into network(systemdomain_id, ip, subnetmask, description)
5255
                      values(insystemdomainid, inip, insubnetmask, indescription);
5256
         select 1 as test;
5257
     else
5258
         select 0 as test;
5259
     end if;
5260

    
5261

    
5262

    
5263
End//
5264
DELIMITER ;
5265

    
5266
-- 프로시저 nerv_icde_test.nodeViewConnectSwitch 구조 내보내기
5267
DROP PROCEDURE IF EXISTS `nodeViewConnectSwitch`;
5268
DELIMITER //
5269
CREATE PROCEDURE `nodeViewConnectSwitch`(in_node_id int)
5270
BEGIN
5271
     if loginTest() then
5272
         select 1 as test;
5273
                select a.node_id, a.ip, a.mask, a.mac, b. name, a.net from
5274
                (select node_id, ip, mask, port, net from network where connect_node_id = in_node_id) as a
5275
                join
5276
                (select id, name from node )as b on b.id=a.node_id;
5277
     else
5278
         select 0 as test;
5279
     end if;
5280

    
5281
End//
5282
DELIMITER ;
5283

    
5284
-- 프로시저 nerv_icde_test.NodeViewEditNode 구조 내보내기
5285
DROP PROCEDURE IF EXISTS `NodeViewEditNode`;
5286
DELIMITER //
5287
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)
5288
BEGIN
5289
declare cnt int;
5290

    
5291
declare enum_lock varchar(10) default 'N';
5292
set cnt=0;
5293

    
5294
        if loginTest() then
5295
          select 1 as test;
5296

    
5297
         if in_type = 'router' then
5298
     			set in_type = 'urouter';
5299
     		end if;
5300

    
5301
			if in_lock_state = 1 then
5302
     			set enum_lock = 'Y';
5303
     		end if;
5304

    
5305
			  update node set name=in_name, type=in_type, description=in_description, sub_system_domain_id=in_sub_system_domain_id, complete=enum_lock
5306
                     where id=in_node_idkey and systemdomain_id=in_systemdomain_id;
5307

    
5308
			   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);
5309

    
5310
           if cnt=0 then
5311
	           delete from node_port where id=in_node_idkey;
5312
              call nodeportViewNewNode(in_node_idkey, in_systemdomain_id, in_sub_system_domain_id);
5313
           end if;
5314

    
5315

    
5316
        else
5317
                select 0 as test;
5318
        end if;
5319
END//
5320
DELIMITER ;
5321

    
5322
-- 프로시저 nerv_icde_test.nodeViewList 구조 내보내기
5323
DROP PROCEDURE IF EXISTS `nodeViewList`;
5324
DELIMITER //
5325
CREATE PROCEDURE `nodeViewList`(
5326
	IN `indomainid` int
5327
)
5328
BEGIN
5329
     if loginTest() then
5330
         select 1 as test;
5331

    
5332
         select * from
5333
				(
5334
		         select a.Id, a.systemdomain_id, a.name as aname, a.type, a.description, a.sub_system_domain_id,  b.name, a.complete from
5335
      		   (select Id, systemdomain_id, name, type, description, sub_system_domain_id, complete from node where systemdomain_id=indomainid) as a
5336
		         left outer join
5337
		         (select id, name from domain_system ) as b on b.id=a.sub_system_domain_id
5338
		      ) as xxx order by aname asc;
5339

    
5340
     else
5341
         select 0 as test;
5342
     end if;
5343

    
5344
End//
5345
DELIMITER ;
5346

    
5347
-- 프로시저 nerv_icde_test.nodeViewListnodeKey 구조 내보내기
5348
DROP PROCEDURE IF EXISTS `nodeViewListnodeKey`;
5349
DELIMITER //
5350
CREATE PROCEDURE `nodeViewListnodeKey`(IN `in_node_id` INT)
5351
BEGIN
5352

    
5353
     if loginTest() then
5354
         select 1 as test;
5355
         select a.Id, a.systemdomain_id, a.name, a.type, a.description, a.sub_system_domain_id,  b.name from
5356
         (select Id, systemdomain_id, name, type, description, sub_system_domain_id from node where node.Id=in_node_id) as a
5357
         left outer join
5358
         (select id, name from domain_system ) as b on b.id=a.sub_system_domain_id;
5359
     else
5360
         select 0 as test;
5361
     end if;
5362

    
5363
END//
5364
DELIMITER ;
5365

    
5366
-- 프로시저 nerv_icde_test.nodeViewNetworkPort 구조 내보내기
5367
DROP PROCEDURE IF EXISTS `nodeViewNetworkPort`;
5368
DELIMITER //
5369
CREATE PROCEDURE `nodeViewNetworkPort`(in_sub_domain_system_id int, in_node_id int)
5370
BEGIN
5371
        if loginTest() then
5372
           select 1 as test;
5373

    
5374
             select port_num, description from domain_system_port where domain_system_id=in_sub_domain_system_id and
5375
                  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)
5376
            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);
5377
        else
5378
            select 0 as test;
5379
        end if;
5380
END//
5381
DELIMITER ;
5382

    
5383
-- 프로시저 nerv_icde_test.nodeViewnodeinfo 구조 내보내기
5384
DROP PROCEDURE IF EXISTS `nodeViewnodeinfo`;
5385
DELIMITER //
5386
CREATE PROCEDURE `nodeViewnodeinfo`(IN `in_deploy_id` int)
5387
BEGIN
5388
     if loginTest() then
5389
         select 1 as test;
5390
         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);
5391

    
5392

    
5393
     else
5394
         select 0 as test;
5395
     end if;
5396

    
5397
End//
5398
DELIMITER ;
5399

    
5400
-- 프로시저 nerv_icde_test.node_table_node_info 구조 내보내기
5401
DROP PROCEDURE IF EXISTS `node_table_node_info`;
5402
DELIMITER //
5403
CREATE PROCEDURE `node_table_node_info`(IN `in_deploy_id` INT)
5404
BEGIN
5405

    
5406
	if logintest() then
5407
		select 1 as test;
5408
		select node.Id, node.systemdomain_id, node.name, node.`type`, node.description from node where node.systemdomain_id in(select systemdomain_id from deployments
5409
		 where id = in_deploy_id);
5410
	else
5411
		select 0 as test;
5412
	end if;
5413

    
5414
END//
5415
DELIMITER ;
5416

    
5417
-- 프로시저 nerv_icde_test.proxyComponentViewParentInterfaceRealdomainList 구조 내보내기
5418
DROP PROCEDURE IF EXISTS `proxyComponentViewParentInterfaceRealdomainList`;
5419
DELIMITER //
5420
CREATE PROCEDURE `proxyComponentViewParentInterfaceRealdomainList`(domain_idkey int)
5421
BEGIN
5422
         declare sm bool;
5423
        declare sa varchar(100);
5424
        declare acount varchar(100);
5425
        declare pbc bool;
5426

    
5427
        set sa = '';
5428
        if loginTest() then
5429

    
5430
                    select supermanager into sm from users where user_id=@nervuser;
5431
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
5432
                    select user_id into acount from domain_method where id=domain_idkey;
5433
                    select public into pbc from domain_method where id=domain_idkey;
5434

    
5435
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
5436
                        select 1 as test;
5437
                        (select id, name from domain_method where id in (select parent_domain_id from inheritance_system_method where domain_id=domain_idkey))
5438
                         union
5439
                        (select id, name from domain_method where id=domain_idkey);
5440

    
5441
                    else
5442
                        select 0 as test;
5443
                     end if;
5444
               else
5445
                 select 0 as test;
5446
        end if;
5447
End//
5448
DELIMITER ;
5449

    
5450
-- 프로시저 nerv_icde_test.proxyComponentViewParentInterfaceRealinterfaceList 구조 내보내기
5451
DROP PROCEDURE IF EXISTS `proxyComponentViewParentInterfaceRealinterfaceList`;
5452
DELIMITER //
5453
CREATE PROCEDURE `proxyComponentViewParentInterfaceRealinterfaceList`(domain_idkey int,in_component_idkey int)
5454
BEGIN
5455
        declare sm bool;
5456
        declare sa varchar(100);
5457
        declare acount varchar(100);
5458
        declare pbc bool;
5459

    
5460
        set sa = '';
5461
        if loginTest() then
5462
                     select supermanager into sm from users where user_id=@nervuser;
5463
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
5464
                     select user_id into acount from domain_method where id=domain_idkey;
5465
                     select public into pbc from domain_method where id=domain_idkey;
5466

    
5467
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
5468
                        select 1 as test;
5469
                        select domain_id, name, user_id, seq, description from interface where domain_id=domain_idkey and name not in
5470
                                        (select interface_name from proxy_interface_relation where component_id=in_component_idkey);
5471
                     else
5472
                        select 0 as test;
5473
                     end if;
5474

    
5475
        else
5476
                select 0 as test;
5477
        end if;
5478
END//
5479
DELIMITER ;
5480

    
5481
-- 프로시저 nerv_icde_test.proxyInterfaceObjectViewDelete 구조 내보내기
5482
DROP PROCEDURE IF EXISTS `proxyInterfaceObjectViewDelete`;
5483
DELIMITER //
5484
CREATE PROCEDURE `proxyInterfaceObjectViewDelete`(in_interface_object_id int, in_object_name varchar(100), in_component_id int)
5485
BEGIN
5486
        if loginTest()then
5487
                select 1 as test;
5488
                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;
5489
        else
5490
                select 0 as test;
5491
        end if;
5492
END//
5493
DELIMITER ;
5494

    
5495
-- 프로시저 nerv_icde_test.proxyInterfaceObjectViewEditObjectName 구조 내보내기
5496
DROP PROCEDURE IF EXISTS `proxyInterfaceObjectViewEditObjectName`;
5497
DELIMITER //
5498
CREATE PROCEDURE `proxyInterfaceObjectViewEditObjectName`(in_proxy_interface_id int, in_object_name varchar (100), in_component_id int, in_edit_object_name varchar(100))
5499
BEGIN
5500
        if loginTest() then
5501
                select 1 as test;
5502
                UPDATE proxy_interface_object Set object_name=in_edit_object_name
5503
                                where proxy_interface_id=in_proxy_interface_id and component_id=in_component_id and object_name=in_object_name;
5504
        else
5505
                select 0 as test;
5506
        end if;
5507
END//
5508
DELIMITER ;
5509

    
5510
-- 프로시저 nerv_icde_test.proxyInterfaceObjectViewList 구조 내보내기
5511
DROP PROCEDURE IF EXISTS `proxyInterfaceObjectViewList`;
5512
DELIMITER //
5513
CREATE PROCEDURE `proxyInterfaceObjectViewList`(in_proxy_interface_relation_id int)
5514
BEGIN
5515
     if loginTest() then
5516
         select 1 as test;
5517
         select * from proxy_interface_object where proxy_interface_id=in_proxy_interface_relation_id;
5518
     else
5519
         select 0 as test;
5520
     end if;
5521
End//
5522
DELIMITER ;
5523

    
5524
-- 프로시저 nerv_icde_test.proxyInterfaceObjectViewNewObjectName 구조 내보내기
5525
DROP PROCEDURE IF EXISTS `proxyInterfaceObjectViewNewObjectName`;
5526
DELIMITER //
5527
CREATE PROCEDURE `proxyInterfaceObjectViewNewObjectName`(in_proxy_interface_id int, in_object_name varchar (100), in_component_id int)
5528
BEGIN
5529
        if loginTest() then
5530
                select 1 as test;
5531
                insert into proxy_interface_object (proxy_interface_id, object_name, component_id)
5532
                                values(in_proxy_interface_id, in_object_name, in_component_id);
5533
        else
5534
                select 0 as test;
5535
        end if;
5536
END//
5537
DELIMITER ;
5538

    
5539
-- 프로시저 nerv_icde_test.proxyInterfaceRalationDeleteInterface 구조 내보내기
5540
DROP PROCEDURE IF EXISTS `proxyInterfaceRalationDeleteInterface`;
5541
DELIMITER //
5542
CREATE PROCEDURE `proxyInterfaceRalationDeleteInterface`(inidkey int)
5543
BEGIN
5544
        if loginTest()then
5545
                select 1 as test;
5546
                delete from proxy_interface_relation where id=inidkey;
5547
        else
5548
                select 0 as test;
5549
        end if;
5550
END//
5551
DELIMITER ;
5552

    
5553
-- 프로시저 nerv_icde_test.proxyInterfaceRalationViewEditInterface 구조 내보내기
5554
DROP PROCEDURE IF EXISTS `proxyInterfaceRalationViewEditInterface`;
5555
DELIMITER //
5556
CREATE PROCEDURE `proxyInterfaceRalationViewEditInterface`(in_idkey int,
5557
                                                                              in_method_domain_id int,
5558
                                                                              in_interface_name varchar(100),
5559
                                                                              in_class_name varchar(255))
5560
BEGIN
5561
        if loginTest() then
5562
                select 1 as test;
5563
                update proxy_interface_relation set  method_domain_id = in_method_domain_id,
5564
                                                     interface_name = in_interface_name,
5565
                                                     class_name = in_class_name where id = in_idkey;
5566

    
5567

    
5568
        else
5569
                select 0 as test;
5570
        end if;
5571
END//
5572
DELIMITER ;
5573

    
5574
-- 프로시저 nerv_icde_test.proxyInterfaceRalationViewNewInterface 구조 내보내기
5575
DROP PROCEDURE IF EXISTS `proxyInterfaceRalationViewNewInterface`;
5576
DELIMITER //
5577
CREATE PROCEDURE `proxyInterfaceRalationViewNewInterface`(in_component_id int,
5578
                                                                             in_method_domain_id int,
5579
                                                                             in_interface_name varchar(100),
5580
                                                                             in_class_name varchar(255))
5581
BEGIN
5582
        if loginTest() then
5583
                select 1 as test;
5584
                    insert into proxy_interface_relation (component_id, method_domain_id, interface_name, class_name)
5585
                                values(in_component_id, in_method_domain_id, in_interface_name, in_class_name);
5586
                    select LAST_INSERT_ID();
5587
        else
5588
                select 0 as test;
5589

    
5590
        end if;
5591
END//
5592
DELIMITER ;
5593

    
5594
-- 프로시저 nerv_icde_test.proxyInterfaceRelationViewClassNameList 구조 내보내기
5595
DROP PROCEDURE IF EXISTS `proxyInterfaceRelationViewClassNameList`;
5596
DELIMITER //
5597
CREATE PROCEDURE `proxyInterfaceRelationViewClassNameList`(in_component_id int, in_method_domain_id int, in_interface_name varchar(100))
5598
BEGIN
5599
     if loginTest() then
5600
         select 1 as test;
5601
         select class_name from proxy_interface_relation where
5602
                component_id=in_component_id and method_domain_id=in_method_domain_id and interface_name=in_interface_name;
5603
     else
5604
         select 0 as test;
5605
     end if;
5606
End//
5607
DELIMITER ;
5608

    
5609
-- 프로시저 nerv_icde_test.proxyInterfaceRelationViewSearchList 구조 내보내기
5610
DROP PROCEDURE IF EXISTS `proxyInterfaceRelationViewSearchList`;
5611
DELIMITER //
5612
CREATE PROCEDURE `proxyInterfaceRelationViewSearchList`(in_component_id int, in_method_domain_id int, in_interface_name varchar(100), in_class_name varchar(255))
5613
BEGIN
5614
     if loginTest() then
5615
         select 1 as test;
5616
         select id from proxy_interface_relation where
5617
                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;
5618
     else
5619
         select 0 as test;
5620
     end if;
5621
End//
5622
DELIMITER ;
5623

    
5624
-- 프로시저 nerv_icde_test.proxyInterfaceViewList 구조 내보내기
5625
DROP PROCEDURE IF EXISTS `proxyInterfaceViewList`;
5626
DELIMITER //
5627
CREATE PROCEDURE `proxyInterfaceViewList`(
5628
	IN `incomponent_id` int
5629
)
5630
BEGIN
5631
     if loginTest() then
5632
         select 1 as test;
5633

    
5634
        select a.id,  a.method_domain_id, a.component_id, a.interface_name, b.name as method_domain_name, a.class_name from
5635

    
5636
         (select id, component_id, method_domain_id, interface_name, class_name from proxy_interface_relation where component_id = incomponent_id) as a
5637
         join
5638
         (select id,name from domain_method) as b on a.method_domain_id = b.id;
5639

    
5640
     else
5641
         select 0 as test;
5642
     end if;
5643

    
5644
End//
5645
DELIMITER ;
5646

    
5647
-- 프로시저 nerv_icde_test.SelectinterfaceViewInterfaceList 구조 내보내기
5648
DROP PROCEDURE IF EXISTS `SelectinterfaceViewInterfaceList`;
5649
DELIMITER //
5650
CREATE PROCEDURE `SelectinterfaceViewInterfaceList`()
5651
BEGIN
5652
   if loginTest() then
5653
     select 1 as test;
5654
     select b.id, b.name, b.upper_id, a.name, a.user_id, a.seq from
5655
     (select  domain_id, name, user_id, seq, description from interface) As a
5656
     join
5657
     (select id, name, upper_id from domain_method) As b on a.domain_id = b.id;
5658
   else
5659
      select 0 as test;
5660
   end if;
5661
END//
5662
DELIMITER ;
5663

    
5664
-- 프로시저 nerv_icde_test.select_all_deploy_component_only_proxy 구조 내보내기
5665
DROP PROCEDURE IF EXISTS `select_all_deploy_component_only_proxy`;
5666
DELIMITER //
5667
CREATE PROCEDURE `select_all_deploy_component_only_proxy`(IN `in_domain_id` INT)
5668
BEGIN
5669

    
5670
	if logintest() then
5671
		select 1 as test;
5672
select n.id, m.* from
5673
(
5674
select * from component WHERE id in (
5675
SELECT component_id from deployments where systemdomain_id = in_domain_id and component_id not in (
5676
select id from component where id in (
5677
select component_id from deployments where id in (
5678
select k.original_deployment_id from
5679

    
5680
(
5681
   select a_f.original_deployment_id, b_f.interface_name, a_f.object_id, c_f.ip from
5682
          (select * from custum_stub where deploy_id in (select id from deployments where deployments.systemdomain_id=in_domain_id)) as a_f
5683
          join
5684
          (select * from stub_interface_relation) as b_f on b_f.id = a_f.stub_interface_id
5685
          join
5686
          (select * from deployments_bind) as c_f on a_f.deploy_id = c_f.deployment_id
5687
 ) as k
5688
 join
5689

    
5690
(
5691
   select a.original_deployment_id, b.interface_name, a.stub_object_id, a.stub_ip from
5692
   (
5693
	        (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
5694
 	        join
5695
	        (select * from proxy_interface_relation) as b on b.id = a.proxy_interface_id
5696
   )
5697
) as i
5698
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
5699
))))) as m
5700
 join deployments as n on n.component_id = m.id;
5701

    
5702

    
5703

    
5704
	else
5705
	   select 0 as test;
5706
	end if;
5707

    
5708
END//
5709
DELIMITER ;
5710

    
5711
-- 프로시저 nerv_icde_test.select_all_deploy_stub_component 구조 내보내기
5712
DROP PROCEDURE IF EXISTS `select_all_deploy_stub_component`;
5713
DELIMITER //
5714
CREATE PROCEDURE `select_all_deploy_stub_component`(IN `in_domain_id` INT, IN `in_component_id` INT)
5715
BEGIN
5716

    
5717
   if logintest() then
5718
      select 1 as test;
5719
      select d.id, c.* from
5720
		(select * from component where component.id != in_component_id and component.id in
5721
			(select component_id from deployments where deployments.id in
5722
				(select b.deploy_id from
5723
					(select * from deployments where deployments.systemdomain_id = in_domain_id and id in
5724
						(select deployment_id from deployments_bind where deployments_bind.ip in
5725
							(select stub_ip from custum_proxy where custum_proxy.stub_object_id !=0 and custum_proxy.deploy_id in
5726
								(select id from deployments where deployments.component_id = in_component_id)))) as a
5727
				join custum_stub as b on b.deploy_id = a.id and b.object_id in
5728
		 			(select stub_object_id from custum_proxy where custum_proxy.stub_object_id !=0 and custum_proxy.deploy_id in
5729
		  				(select id from deployments where deployments.component_id = in_component_id))))) as c
5730
		  join deployments as d on d.component_id=c.id;
5731

    
5732

    
5733

    
5734
	else
5735
		select 0 as test;
5736
	end if;
5737

    
5738
END//
5739
DELIMITER ;
5740

    
5741
-- 프로시저 nerv_icde_test.select_deploy_all_components 구조 내보내기
5742
DROP PROCEDURE IF EXISTS `select_deploy_all_components`;
5743
DELIMITER //
5744
CREATE PROCEDURE `select_deploy_all_components`(IN `in_domain_id` INT)
5745
BEGIN
5746

    
5747
   if logintest() then
5748
   	select 1 as test;
5749
   	select a.*, b.node_id from
5750
		(
5751
			(select * from component where id in(select component_id from deployments where deployments.systemdomain_id = in_domain_id)) as a
5752
			join
5753
			(select * from deployments) as b on b.systemdomain_id = in_domain_id
5754
		);
5755
	else
5756
		select 0 as test;
5757
	end if;
5758
END//
5759
DELIMITER ;
5760

    
5761
-- 프로시저 nerv_icde_test.select_group 구조 내보내기
5762
DROP PROCEDURE IF EXISTS `select_group`;
5763
DELIMITER //
5764
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)
5765
BEGIN
5766

    
5767

    
5768

    
5769
	declare logical_port int;
5770
	declare sub_domain_id int;
5771

    
5772
	Select sub_system_domain_id into sub_domain_id from node where id = in_s_node_id;
5773
	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;
5774

    
5775
	call select_group_recursion( in_d_subsystem_id , in_d_port_id , 0 , in_d_port_id , in_s_node_id , logical_port , 10 );
5776

    
5777
END//
5778
DELIMITER ;
5779

    
5780
-- 프로시저 nerv_icde_test.select_group_recursion 구조 내보내기
5781
DROP PROCEDURE IF EXISTS `select_group_recursion`;
5782
DELIMITER //
5783
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)
5784
BEGIN
5785
	declare domain_id int;
5786
	declare no_more_rows bool default false;
5787
	declare child_node_id int;
5788
	declare child_port_group int;
5789
	declare node_port_count int;
5790

    
5791
	DECLARE my_list CURSOR FOR select K.node_id , domain_system_port.port_group from
5792
		 		(
5793
				 	(
5794
					 	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
5795
						 							( 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 )
5796
					)
5797
						union
5798
				 	(
5799
					 	select d_node_id , d_sub_system_id , d_port_id  from network_link where
5800
						 							 ( 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 )
5801
					)
5802
				) as K
5803
			join
5804
				domain_system_port on K.sub_system_id = domain_system_port.domain_system_id and K.port_id = domain_system_port.port_num
5805
	where
5806
			not ( K.node_id = in_parent_node_id and domain_system_port.port_group = in_parent_port_group );
5807

    
5808
	declare continue handler for not found set no_more_rows := TRUE;
5809
		set max_sp_recursion_depth = 50;
5810

    
5811
	if in_node_id = 0 then
5812

    
5813
		 set node_port_count = 0;
5814
		 select count(*) into node_port_count from node_port where sub_system_domain_id = in_domain_system_id and port_group = in_port_group;
5815

    
5816
		 if node_port_count = 0 then
5817
		 	 update node_port set port_group = in_port_group where sub_system_domain_id = in_domain_system_id and port_group = in_export_num;
5818
		 end if;
5819
	end if;
5820

    
5821
	if in_depth > 0 then
5822
		select node.sub_system_domain_id into domain_id from node where node.Id = in_node_id;
5823
		open my_list;
5824
		my_loop : loop
5825

    
5826
			fetch my_list into child_node_id , child_port_group;
5827
			if no_more_rows then
5828
				close my_list;
5829
				leave my_loop;
5830
			end if;
5831
			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 );
5832
		end loop my_loop;
5833
	end if;
5834
END//
5835
DELIMITER ;
5836

    
5837
-- 프로시저 nerv_icde_test.select_network 구조 내보내기
5838
DROP PROCEDURE IF EXISTS `select_network`;
5839
DELIMITER //
5840
CREATE PROCEDURE `select_network`(IN `in_node_id` INT)
5841
BEGIN
5842
	declare sub_domain_id int;
5843
	declare export_group int;
5844
	declare inner_node_id int;
5845
	declare  inner_port_group int;
5846
	declare no_more_rows bool default false;
5847

    
5848
	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
5849
		(
5850
			select s_node_id , sub_system_domain_id, type, s_port_id , port_group  from
5851
				(
5852
					 select s_node_id , s_port_id , port_group from
5853
					 	(
5854
						 	select * from network_link where d_node_id = 0 and d_sub_system_id = sub_domain_id
5855
						) as A
5856
							join
5857
						(
5858
							select * from domain_system_port where domain_system_id = sub_domain_id
5859
						) as B
5860
							on  A.d_port_id = B.port_num group by port_group
5861
				) as C
5862
					join node on C.s_node_id = node.id
5863
		) as D
5864
			join domain_system_port as E on D.sub_system_domain_id = E.domain_system_id and D.s_port_id = E.port_num;
5865

    
5866
	declare continue handler for not found set no_more_rows := TRUE;
5867

    
5868
	set max_sp_recursion_depth = 50;
5869
	select sub_system_domain_id into sub_domain_id from node where id = in_node_id;
5870

    
5871
	open my_list;
5872
	my_loop : loop
5873
		fetch my_list into export_group , inner_node_id , inner_port_group;
5874
		if no_more_rows then
5875
			close my_list;
5876
			leave my_loop;
5877
		end if;
5878
		 call select_network_recursion( in_node_id, export_group, 0 , export_group , inner_node_id , inner_port_group , 10 );
5879
	end loop my_loop;
5880
END//
5881
DELIMITER ;
5882

    
5883
-- 프로시저 nerv_icde_test.select_network_recursion 구조 내보내기
5884
DROP PROCEDURE IF EXISTS `select_network_recursion`;
5885
DELIMITER //
5886
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)
5887
BEGIN
5888
	declare domain_id int;
5889
	declare no_more_rows bool default false;
5890
	declare child_node_id int;
5891
	declare child_port_group int;
5892
	declare network_count int;
5893

    
5894
	DECLARE my_list CURSOR FOR select K.node_id , domain_system_port.port_group from
5895
		 		(
5896
				 	(
5897
					 	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
5898
						  ( 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 )
5899
					)
5900
						union
5901
				 	(
5902
					 	select d_node_id , d_sub_system_id , d_port_id  from network_link where	( s_node_id , s_port_id ) in
5903
						  ( 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 )
5904
					)
5905
				) as K
5906

    
5907
			join domain_system_port	on K.sub_system_id = domain_system_port.domain_system_id and K.port_id = domain_system_port.port_num
5908
	where	not ( K.node_id = in_parent_node_id and domain_system_port.port_group = in_parent_port_group );
5909

    
5910
	declare continue handler for not found set no_more_rows := TRUE;
5911

    
5912
	select count(*) into network_count from network where node_id = in_insert_node and
5913
	 (original_node_id, original_node_port, original_node_ip) in
5914
	  (select node_id, port, ip from network where node_id = in_node_id and port = in_port_group);
5915

    
5916
	  if network_count=0  then
5917
	       insert into network ( node_id, port , ip, mask , net , gateway , dns, description, original_node_id, original_node_port, original_node_ip )
5918
	            select in_insert_node , in_insert_port_group , ip, mask , net , gateway , dns, description, node_id, port, ip from network
5919
					 where node_id = in_node_id and port = in_port_group;
5920
	  end if;
5921

    
5922
	if in_depth > 0 then
5923
		select node.sub_system_domain_id into domain_id from node where node.Id = in_node_id;
5924
		open my_list;
5925
		my_loop : loop
5926
			fetch my_list into child_node_id , child_port_group;
5927

    
5928
			if no_more_rows then
5929
				close my_list;
5930
				leave my_loop;
5931
			end if;
5932
			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 );
5933
		end loop my_loop;
5934
	end if;
5935
END//
5936
DELIMITER ;
5937

    
5938
-- 프로시저 nerv_icde_test.select_search_data_name 구조 내보내기
5939
DROP PROCEDURE IF EXISTS `select_search_data_name`;
5940
DELIMITER //
5941
CREATE PROCEDURE `select_search_data_name`(IN `in_search_name` VARCHAR(50))
5942
BEGIN
5943
	if loginTest() then
5944
			select 1 as test;
5945
		  select id,('domain') as type, name, (select `domainDataPath`(domain_data.id, ''))as path from domain_data where name like in_search_name
5946
				union all
5947
			select domain_id,('data') as type, name, (select `domainDataPath`(data.domain_id, ''))as path from data where data.name like in_search_name
5948
				union all
5949
			select b.domain_id,('data_field') as type, a.member_name as name, concat((select `domainDataPath`(b.domain_id, '')),b.name) as path from
5950
	 		(select data_field.data_auto_id, data_field.member_name from data_field where member_name like in_search_name) as a
5951
	 		   join
5952
	 		(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;
5953
	else
5954
		select 0 as test;
5955
	end if;
5956
END//
5957
DELIMITER ;
5958

    
5959
-- 프로시저 nerv_icde_test.select_search_method_name 구조 내보내기
5960
DROP PROCEDURE IF EXISTS `select_search_method_name`;
5961
DELIMITER //
5962
CREATE PROCEDURE `select_search_method_name`(IN `in_search_name` VARCHAR(50))
5963
BEGIN
5964

    
5965
	if loginTest() then
5966
		select 1 as test;
5967

    
5968
		select id,('domain') as type, name, (select `domainMethodPath`(domain_method.id, ''))as path from domain_method where name like in_search_name
5969
			  union all
5970
		select domain_id,('method') as type, name, (select `domainMethodPath`(method.domain_id, ''))as path from method where method.name like in_search_name
5971
			 union all
5972
		select domain_id,('interface') as type, name, (select `domainMethodPath`(interface.domain_id, ''))as path from interface where interface.name like in_search_name;
5973
	else
5974
		select 0 as test;
5975
	end if;
5976

    
5977
END//
5978
DELIMITER ;
5979

    
5980
-- 프로시저 nerv_icde_test.select_search_system_name 구조 내보내기
5981
DROP PROCEDURE IF EXISTS `select_search_system_name`;
5982
DELIMITER //
5983
CREATE PROCEDURE `select_search_system_name`(IN `in_search_name` VARCHAR(50))
5984
BEGIN
5985

    
5986
	if loginTest() then
5987
		select 1 as test;
5988

    
5989
		 select id,('domain') as type, name, (select `domainSystemPath`(domain_system.id, ''))as path from domain_system where name like in_search_name
5990
  			union all
5991
		 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
5992
  			union all
5993
		 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
5994
 		 	union all
5995

    
5996
 		 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
5997
			(select * from proxy_interface_relation where proxy_interface_relation.class_name like in_search_name) as a
5998
				join
5999
			(select component.id, component.systemdomain_id, concat('Components\\',component.name)as name from component)as b on a.component_id=b.id
6000

    
6001
			union all
6002

    
6003
	   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
6004
				(select * from stub_interface_relation where stub_interface_relation.class_name like in_search_name) as a
6005
					join
6006
				(select component.id, component.systemdomain_id, concat('Components\\',component.name)as name from component)as b on a.component_id=b.id
6007
			union all
6008

    
6009
		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
6010
				(select * from proxy_interface_object where proxy_interface_object.object_name like in_search_name) as a
6011
					join
6012
				(select component.id, component.systemdomain_id, concat('Components\\',component.name)as name from component)as b on a.component_id=b.id
6013
					join
6014
				(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
6015
		  union all
6016

    
6017
	  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
6018
			(select * from stub_interface_object where stub_interface_object.object_name like in_search_name) as a
6019
				join
6020
			(select component.id, component.systemdomain_id, concat('Components\\',component.name)as name from component)as b on a.component_id=b.id
6021
				join
6022
			(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;
6023

    
6024
	else
6025
		select 0 as test;
6026
	end if;
6027

    
6028

    
6029
END//
6030
DELIMITER ;
6031

    
6032
-- 프로시저 nerv_icde_test.serverViewDeleteField 구조 내보내기
6033
DROP PROCEDURE IF EXISTS `serverViewDeleteField`;
6034
DELIMITER //
6035
CREATE PROCEDURE `serverViewDeleteField`(fieldvalue varchar(100))
6036
BEGIN
6037
        if loginTest() and supermanagerTest(@nervuser) then
6038
                select 1 as test;
6039
                delete from server_information where field_name=fieldvalue;
6040
        else
6041
                select 0 as test;
6042
        end if;
6043
END//
6044
DELIMITER ;
6045

    
6046
-- 프로시저 nerv_icde_test.serverViewEditField 구조 내보내기
6047
DROP PROCEDURE IF EXISTS `serverViewEditField`;
6048
DELIMITER //
6049
CREATE PROCEDURE `serverViewEditField`(fieldvalue varchar(100), fieldedit varchar(100), descriptionedit text)
6050
BEGIN
6051

    
6052
END//
6053
DELIMITER ;
6054

    
6055
-- 프로시저 nerv_icde_test.serverViewEditFieldSeq 구조 내보내기
6056
DROP PROCEDURE IF EXISTS `serverViewEditFieldSeq`;
6057
DELIMITER //
6058
CREATE PROCEDURE `serverViewEditFieldSeq`(fieldkey1 varchar(100), fieldkey2 varchar(100))
6059
BEGIN
6060
        declare t1 timestamp;
6061
        declare t2 timestamp;
6062
        if loginTest() and supermanagerTest(@nervuser) then
6063
                select 1 as test;
6064
                select seq into t1 from server_information where field_name=fieldkey1;
6065
                select seq into t2 from server_information where field_name=fieldkey2;
6066
                update server_information set seq = t2 where field_name=fieldkey1;
6067
                update server_information set seq = t1 where field_name=fieldkey2;
6068
        else
6069
                select 0 as test;
6070
        end if;
6071
END//
6072
DELIMITER ;
6073

    
6074
-- 프로시저 nerv_icde_test.serverViewNewField 구조 내보내기
6075
DROP PROCEDURE IF EXISTS `serverViewNewField`;
6076
DELIMITER //
6077
CREATE PROCEDURE `serverViewNewField`(fieldvalue varchar(100), seqvalue int, descriptionvalue text)
6078
BEGIN
6079
        if loginTest() and supermanagerTest(@nervuser) then
6080
                select 1 as test;
6081
                insert into server_information(field_name,seq, description) values(fieldvalue,seqvalue, descriptionvalue);
6082
        else
6083
                select 0 as test;
6084
        end if;
6085

    
6086

    
6087
END//
6088
DELIMITER ;
6089

    
6090
-- 프로시저 nerv_icde_test.serverViewServerInfo 구조 내보내기
6091
DROP PROCEDURE IF EXISTS `serverViewServerInfo`;
6092
DELIMITER //
6093
CREATE PROCEDURE `serverViewServerInfo`()
6094
BEGIN
6095
       if loginTest() then
6096
               select 1 as test;
6097
               select * from server_information order by seq asc;
6098
       else
6099
               select 0 as test;
6100
       end if;
6101
END//
6102
DELIMITER ;
6103

    
6104
-- 프로시저 nerv_icde_test.setup_public_interface_to_subsystem 구조 내보내기
6105
DROP PROCEDURE IF EXISTS `setup_public_interface_to_subsystem`;
6106
DELIMITER //
6107
CREATE PROCEDURE `setup_public_interface_to_subsystem`(IN `in_node_id` INT, IN `in_type` INT)
6108
BEGIN
6109
	 if loginTest() then
6110
          select 1 as test;
6111

    
6112
          if in_type = 0 then
6113
          		select custum_proxy.Id, custum_proxy.deploy_id,custum_proxy.public from custum_proxy where public=1 and deploy_id in
6114
					(select id from deployments where node_id=in_node_id);
6115
			else
6116
			 		select custum_stub.Id, custum_stub.deploy_id,custum_stub.public from custum_stub where public=1 and deploy_id in
6117
					(select id from deployments where node_id=in_node_id);
6118
			end if;
6119

    
6120
	 else
6121
			 select 0 as test;
6122
	 end if;
6123

    
6124
END//
6125
DELIMITER ;
6126

    
6127
-- 프로시저 nerv_icde_test.standard_port 구조 내보내기
6128
DROP PROCEDURE IF EXISTS `standard_port`;
6129
DELIMITER //
6130
CREATE PROCEDURE `standard_port`(in_port varchar(100), in_idkey int)
6131
BEGIN
6132
        if loginTest() then
6133
              select 1 as test;
6134
               update protocol_standard_port set discription=in_port where id=in_idkey;
6135
         else
6136
                         select 0 as test;
6137
         end if;
6138
END//
6139
DELIMITER ;
6140

    
6141
-- 프로시저 nerv_icde_test.standard_portViewCheckPort 구조 내보내기
6142
DROP PROCEDURE IF EXISTS `standard_portViewCheckPort`;
6143
DELIMITER //
6144
CREATE PROCEDURE `standard_portViewCheckPort`(in_port varchar(100))
6145
BEGIN
6146
        if loginTest() then
6147
           select 1 as test;
6148
           select * from protocol_standard_port where port like in_port;
6149
         else
6150
           select 0 as test;
6151
         end if;
6152
END//
6153
DELIMITER ;
6154

    
6155
-- 프로시저 nerv_icde_test.stubComponentViewParentInterfaceRealdomainList 구조 내보내기
6156
DROP PROCEDURE IF EXISTS `stubComponentViewParentInterfaceRealdomainList`;
6157
DELIMITER //
6158
CREATE PROCEDURE `stubComponentViewParentInterfaceRealdomainList`(domain_idkey int)
6159
BEGIN
6160
         declare sm bool;
6161
        declare sa varchar(100);
6162
        declare acount varchar(100);
6163
        declare pbc bool;
6164

    
6165
        set sa = '';
6166
        if loginTest() then
6167

    
6168
                    select supermanager into sm from users where user_id=@nervuser;
6169
                    select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6170
                    select user_id into acount from domain_method where id=domain_idkey;
6171
                    select public into pbc from domain_method where id=domain_idkey;
6172

    
6173
                    if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
6174
                        select 1 as test;
6175
                        (select id, name from domain_method where id in (select parent_domain_id from inheritance_system_method where domain_id=domain_idkey))
6176
                         union
6177
                        (select id, name from domain_method where id=domain_idkey);
6178

    
6179
                    else
6180
                        select 0 as test;
6181
                     end if;
6182
               else
6183
                 select 0 as test;
6184
        end if;
6185
End//
6186
DELIMITER ;
6187

    
6188
-- 프로시저 nerv_icde_test.stubComponentViewParentInterfaceRealinterfaceList 구조 내보내기
6189
DROP PROCEDURE IF EXISTS `stubComponentViewParentInterfaceRealinterfaceList`;
6190
DELIMITER //
6191
CREATE PROCEDURE `stubComponentViewParentInterfaceRealinterfaceList`(domain_idkey int,in_component_idkey int)
6192
BEGIN
6193
        declare sm bool;
6194
        declare sa varchar(100);
6195
        declare acount varchar(100);
6196
        declare pbc bool;
6197

    
6198
        set sa = '';
6199
        if loginTest() then
6200
                     select supermanager into sm from users where user_id=@nervuser;
6201
                     select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6202
                     select user_id into acount from domain_method where id=domain_idkey;
6203
                     select public into pbc from domain_method where id=domain_idkey;
6204

    
6205
                     if( pbc or sm or sa='member' or sa='manager' or acount = @nervuser ) then
6206
                        select 1 as test;
6207
                        select domain_id, name, user_id, seq, description from interface where domain_id=domain_idkey and name not in
6208
                                        (select interface_name from stub_interface_relation where component_id=in_component_idkey);
6209
                     else
6210
                        select 0 as test;
6211
                     end if;
6212

    
6213
        else
6214
                select 0 as test;
6215
        end if;
6216
END//
6217
DELIMITER ;
6218

    
6219
-- 프로시저 nerv_icde_test.stubInterfaceObjectViewDelete 구조 내보내기
6220
DROP PROCEDURE IF EXISTS `stubInterfaceObjectViewDelete`;
6221
DELIMITER //
6222
CREATE PROCEDURE `stubInterfaceObjectViewDelete`(in_interface_object_id int, in_object_name varchar(100), in_component_id int)
6223
BEGIN
6224
        if loginTest()then
6225
                select 1 as test;
6226
                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;
6227
        else
6228
                select 0 as test;
6229
        end if;
6230
END//
6231
DELIMITER ;
6232

    
6233
-- 프로시저 nerv_icde_test.stubInterfaceObjectViewEditObjectName 구조 내보내기
6234
DROP PROCEDURE IF EXISTS `stubInterfaceObjectViewEditObjectName`;
6235
DELIMITER //
6236
CREATE PROCEDURE `stubInterfaceObjectViewEditObjectName`(in_stub_interface_id int, in_object_name varchar (100), in_component_id int, in_edit_object_name varchar(100))
6237
BEGIN
6238
        if loginTest() then
6239
                select 1 as test;
6240
                UPDATE stub_interface_object Set object_name=in_edit_object_name
6241
                                where stub_interface_id=in_stub_interface_id and component_id=in_component_id and object_name=in_object_name;
6242
        else
6243
                select 0 as test;
6244
        end if;
6245
END//
6246
DELIMITER ;
6247

    
6248
-- 프로시저 nerv_icde_test.stubInterfaceObjectViewList 구조 내보내기
6249
DROP PROCEDURE IF EXISTS `stubInterfaceObjectViewList`;
6250
DELIMITER //
6251
CREATE PROCEDURE `stubInterfaceObjectViewList`(in_stub_interface_relation_id int)
6252
BEGIN
6253
     if loginTest() then
6254
         select 1 as test;
6255
         select * from stub_interface_object where stub_interface_id=in_stub_interface_relation_id;
6256
     else
6257
         select 0 as test;
6258
     end if;
6259
End//
6260
DELIMITER ;
6261

    
6262
-- 프로시저 nerv_icde_test.stubInterfaceObjectViewNewObjectName 구조 내보내기
6263
DROP PROCEDURE IF EXISTS `stubInterfaceObjectViewNewObjectName`;
6264
DELIMITER //
6265
CREATE PROCEDURE `stubInterfaceObjectViewNewObjectName`(in_stub_interface_id int, in_object_name varchar (100), in_component_id int)
6266
BEGIN
6267
        if loginTest() then
6268
                select 1 as test;
6269
                insert into stub_interface_object (stub_interface_id, object_name, component_id)
6270
                                values(in_stub_interface_id, in_object_name, in_component_id);
6271
        else
6272
                select 0 as test;
6273
        end if;
6274
END//
6275
DELIMITER ;
6276

    
6277
-- 프로시저 nerv_icde_test.stubInterfaceRalationDeleteInterface 구조 내보내기
6278
DROP PROCEDURE IF EXISTS `stubInterfaceRalationDeleteInterface`;
6279
DELIMITER //
6280
CREATE PROCEDURE `stubInterfaceRalationDeleteInterface`(inidkey int)
6281
BEGIN
6282

    
6283

    
6284
        if loginTest()then
6285
                select 1 as test;
6286
                delete from stub_interface_relation where id=inidkey;
6287
        else
6288
                select 0 as test;
6289
        end if;
6290
END//
6291
DELIMITER ;
6292

    
6293
-- 프로시저 nerv_icde_test.stubInterfaceRalationViewEditInterface 구조 내보내기
6294
DROP PROCEDURE IF EXISTS `stubInterfaceRalationViewEditInterface`;
6295
DELIMITER //
6296
CREATE PROCEDURE `stubInterfaceRalationViewEditInterface`(in_idkey int,
6297
                                                                              in_method_domain_id int,
6298
                                                                              in_interface_name varchar(100),
6299
                                                                              in_class_name varchar(255))
6300
BEGIN
6301
        if loginTest() then
6302
                select 1 as test;
6303
                update stub_interface_relation set  method_domain_id = in_method_domain_id,
6304
                                                     interface_name = in_interface_name,
6305
                                                     class_name = in_class_name
6306
                                               where id = in_idkey;
6307

    
6308

    
6309
        else
6310
                select 0 as test;
6311
        end if;
6312
END//
6313
DELIMITER ;
6314

    
6315
-- 프로시저 nerv_icde_test.stubInterfaceRalationViewNewInterface 구조 내보내기
6316
DROP PROCEDURE IF EXISTS `stubInterfaceRalationViewNewInterface`;
6317
DELIMITER //
6318
CREATE PROCEDURE `stubInterfaceRalationViewNewInterface`(in_component_id int,
6319
                                                                             in_method_domain_id int,
6320
                                                                             in_interface_name varchar(100),
6321
                                                                             in_class_name varchar(255))
6322
BEGIN
6323
        if loginTest() then
6324
                select 1 as test;
6325
                insert into stub_interface_relation (component_id, method_domain_id, interface_name, class_name)
6326
                                values(in_component_id, in_method_domain_id, in_interface_name, in_class_name);
6327

    
6328
                select LAST_INSERT_ID();
6329
        else
6330
                select 0 as test;
6331
        end if;
6332
END//
6333
DELIMITER ;
6334

    
6335
-- 프로시저 nerv_icde_test.stubInterfaceRelationViewClassNameList 구조 내보내기
6336
DROP PROCEDURE IF EXISTS `stubInterfaceRelationViewClassNameList`;
6337
DELIMITER //
6338
CREATE PROCEDURE `stubInterfaceRelationViewClassNameList`(in_component_id int, in_method_domain_id int, in_interface_name varchar(100))
6339
BEGIN
6340
     if loginTest() then
6341
         select 1 as test;
6342
         select class_name from stub_interface_relation where
6343
                component_id=in_component_id and method_domain_id=in_method_domain_id and interface_name=in_interface_name;
6344
     else
6345
         select 0 as test;
6346
     end if;
6347
End//
6348
DELIMITER ;
6349

    
6350
-- 프로시저 nerv_icde_test.stubInterfaceRelationViewSearchList 구조 내보내기
6351
DROP PROCEDURE IF EXISTS `stubInterfaceRelationViewSearchList`;
6352
DELIMITER //
6353
CREATE PROCEDURE `stubInterfaceRelationViewSearchList`(in_component_id int, in_method_domain_id int, in_interface_name varchar(100), in_class_name varchar(255))
6354
BEGIN
6355
     if loginTest() then
6356
         select 1 as test;
6357
         select id from stub_interface_relation where
6358
                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;
6359
     else
6360
         select 0 as test;
6361
     end if;
6362
End//
6363
DELIMITER ;
6364

    
6365
-- 프로시저 nerv_icde_test.stubInterfaceViewList 구조 내보내기
6366
DROP PROCEDURE IF EXISTS `stubInterfaceViewList`;
6367
DELIMITER //
6368
CREATE PROCEDURE `stubInterfaceViewList`(
6369
	IN `incomponent_id` int
6370
)
6371
BEGIN
6372
     if loginTest() then
6373
         select 1 as test;
6374

    
6375
         select a.id,  a.method_domain_id, a.component_id, a.interface_name, b.name as method_domain_name , a.class_name from
6376

    
6377
         (select id, component_id, method_domain_id, interface_name, class_name from stub_interface_relation where component_id = incomponent_id) as a
6378
         join
6379
         (select id,name from domain_method) as b on a.method_domain_id = b.id ;
6380

    
6381

    
6382
     else
6383
         select 0 as test;
6384
     end if;
6385

    
6386

    
6387

    
6388
End//
6389
DELIMITER ;
6390

    
6391
-- 프로시저 nerv_icde_test.switchSubComponentInfo 구조 내보내기
6392
DROP PROCEDURE IF EXISTS `switchSubComponentInfo`;
6393
DELIMITER //
6394
CREATE PROCEDURE `switchSubComponentInfo`(in_node_id int)
6395
BEGIN
6396

    
6397
     if loginTest() then
6398
     select 1 as test;
6399
        select component_id from stub_interface_relation where component_id in (select component_id from deployments where node_id=in_node_id);
6400
     else
6401
         select 0 as test;
6402
     end if;
6403
End//
6404
DELIMITER ;
6405

    
6406
-- 프로시저 nerv_icde_test.systemDomainPortViewList 구조 내보내기
6407
DROP PROCEDURE IF EXISTS `systemDomainPortViewList`;
6408
DELIMITER //
6409
CREATE PROCEDURE `systemDomainPortViewList`(in_system_domain_id int)
6410
BEGIN
6411
     if loginTest() then
6412
         select 1 as test;
6413
         select domain_system_id, port_num, port_group, description from domain_system_port where domain_system_id=in_system_domain_id;
6414
     else
6415
         select 0 as test;
6416
     end if;
6417
End//
6418
DELIMITER ;
6419

    
6420
-- 프로시저 nerv_icde_test.ten_pro 구조 내보내기
6421
DROP PROCEDURE IF EXISTS `ten_pro`;
6422
DELIMITER //
6423
CREATE PROCEDURE `ten_pro`()
6424
BEGIN
6425
	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
6426
	 (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;
6427
END//
6428
DELIMITER ;
6429

    
6430
-- 프로시저 nerv_icde_test.testpro 구조 내보내기
6431
DROP PROCEDURE IF EXISTS `testpro`;
6432
DELIMITER //
6433
CREATE PROCEDURE `testpro`(IN `idkey` int , IN `domaintype` varchar(100))
6434
BEGIN
6435
     if( idkey != 0 ) then
6436
         select id, upper_id, name from domain_method  where id = idkey;
6437

    
6438

    
6439
         call testpro(upper_id, 'method');
6440
     else
6441

    
6442
         select 0 as test;
6443
     end if;
6444
END//
6445
DELIMITER ;
6446

    
6447
-- 프로시저 nerv_icde_test.TreeDomainChildViewList 구조 내보내기
6448
DROP PROCEDURE IF EXISTS `TreeDomainChildViewList`;
6449
DELIMITER //
6450
CREATE PROCEDURE `TreeDomainChildViewList`(
6451
	IN `idkey` int,
6452
	IN `domaintype` varchar(100)
6453

    
6454
)
6455
BEGIN
6456
        declare sm bool;
6457
        if loginTest() then
6458
                select 1 as test;
6459
                if( supermanagerTest(@nervuser) ) then
6460
                       if(domaintype='data') then
6461
                        select id, name , upper_id from domain_data where upper_id = idkey order by name desc;
6462
                       end if;
6463
                       if(domaintype='method') then
6464
                        select id, name, upper_id from domain_method where upper_id = idkey order by name desc;
6465
                       end if;
6466
                       if(domaintype='system') then
6467
                        select id, name, upper_id from domain_system where upper_id = idkey order by name desc;
6468
                       end if;
6469
                 end if;
6470
       else
6471
               select 0 as test;
6472
       end if;
6473
END//
6474
DELIMITER ;
6475

    
6476
-- 프로시저 nerv_icde_test.treeViewEditItemName 구조 내보내기
6477
DROP PROCEDURE IF EXISTS `treeViewEditItemName`;
6478
DELIMITER //
6479
CREATE PROCEDURE `treeViewEditItemName`(in_idkey int,
6480
                                                            in_typevalue int,
6481
                                                            in_orignalnamekey varchar(100),
6482
                                                            in_editname varchar(100))
6483
BEGIN
6484

    
6485
        if loginTest() then
6486

    
6487

    
6488
                if (in_typevalue=0) then
6489
                        update domain_system set  name=in_editname where id=in_idkey;
6490
                        select 1 as test;
6491
                end if;
6492

    
6493
                if (in_typevalue=1) then
6494
                        update domain_method set  name=in_editname where id=in_idkey;
6495
                        select 1 as test;
6496
                end if;
6497

    
6498
                if (in_typevalue=2) then
6499
                        update domain_data set name=in_editname where id=in_idkey;
6500
                        select 1 as test;
6501
                end if;
6502

    
6503
                if (in_typevalue=3) then
6504
                        update data set  name=in_editname where domain_id=in_idkey and name = in_orignalnamekey;
6505
                        select 1 as test;
6506
                end if;
6507

    
6508
                if (in_typevalue=4) then
6509
                        update method set  name=in_editname where domain_id=in_idkey and name = in_orignalnamekey;
6510
                        select 1 as test;
6511
                end if;
6512

    
6513
                if (in_typevalue=6) then
6514
                        update interface set name=in_editname where domain_id=in_idkey and name = in_orignalnamekey;
6515
                        select 1 as test;
6516
                end if;
6517

    
6518
                if (in_typevalue=7) then
6519
                        update node set name=in_editname where id=in_idkey and name = in_orignalnamekey;
6520
                        select 1 as test;
6521
                end if;
6522
                if (in_typevalue=8) then
6523
                        update component set name=in_editname where id=in_idkey and name = in_orignalnamekey;
6524
                        select 1 as test;
6525
                end if;
6526

    
6527

    
6528
        else
6529
                select 0 as test;
6530
        end if;
6531
END//
6532
DELIMITER ;
6533

    
6534
-- 프로시저 nerv_icde_test.umlcomponententityViewList 구조 내보내기
6535
DROP PROCEDURE IF EXISTS `umlcomponententityViewList`;
6536
DELIMITER //
6537
CREATE PROCEDURE `umlcomponententityViewList`(in_diagramid int)
6538
BEGIN
6539
     if loginTest() then
6540
         select 1 as test;
6541
         select id, diagrame_id, component_id, position_x, position_y, size from umlcomponent where diagrame_id = in_diagramid;
6542

    
6543
     else
6544
         select 0 as test;
6545
     end if;
6546

    
6547

    
6548

    
6549
End//
6550
DELIMITER ;
6551

    
6552
-- 프로시저 nerv_icde_test.update_child_depth 구조 내보내기
6553
DROP PROCEDURE IF EXISTS `update_child_depth`;
6554
DELIMITER //
6555
CREATE PROCEDURE `update_child_depth`(IN `in_data_auto_id` INT, IN `in_data_domain_id` INT, IN `in_data_depth` INT)
6556
BEGIN
6557

    
6558

    
6559
	declare no_more_rows bool default false;
6560

    
6561
	declare child_data_auto_id int;
6562
	declare child_domain_id int;
6563
	declare child_depth int;
6564

    
6565
	DECLARE my_list CURSOR FOR
6566

    
6567
		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'
6568
		union
6569
		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
6570
		(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);
6571

    
6572
	declare continue handler for not found set no_more_rows := TRUE;
6573

    
6574
	set max_sp_recursion_depth = 50;
6575

    
6576
		open my_list;
6577
		my_loop : loop
6578

    
6579
			fetch my_list into child_data_auto_id, child_domain_id, child_depth;
6580
			if no_more_rows then
6581
				close my_list;
6582
				leave my_loop;
6583
			end if;
6584

    
6585
			if child_depth <= in_data_depth then
6586
			 	update data set data.depth=(in_data_depth+1) where data.data_auto_id=child_data_auto_id;
6587
			 	call update_child_depth( child_data_auto_id, child_domain_id , in_data_depth+1);
6588
			end if;
6589

    
6590
		end loop my_loop;
6591

    
6592

    
6593

    
6594
END//
6595
DELIMITER ;
6596

    
6597
-- 프로시저 nerv_icde_test.userViewEditDomainUserGuest 구조 내보내기
6598
DROP PROCEDURE IF EXISTS `userViewEditDomainUserGuest`;
6599
DELIMITER //
6600
CREATE PROCEDURE `userViewEditDomainUserGuest`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `acountkey` varchar(100))
6601
BEGIN
6602
        declare domaincreator varchar(100);
6603
        declare mb varchar(100);
6604
        declare targetmb varchar(100);
6605

    
6606
        if(domaintype='data') then
6607
              select user_id into domaincreator from domain_data where id=domain_idkey;
6608
              if acountkey != domaincreator then
6609
                  select member_type into mb from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
6610
                  select member_type into targetmb from members_domain_data where domain_id=domain_idkey and user_id=acountkey;
6611
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6612
                        if loginTest() then
6613
                                select 1 as test;
6614
                                update members_domain_data set member_type = 'guest' where domain_id=domain_idkey and user_id=acountkey;
6615
                        else
6616
                                select 0 as test;
6617
                        end if;
6618
                  else
6619
                        select 0 as test;
6620
                  end if;
6621
              else
6622
                select 0 as test;
6623
              end if;
6624
        end if;
6625

    
6626
        if(domaintype='method') then
6627
              select user_id into domaincreator from domain_method where id=domain_idkey;
6628
              if acountkey != domaincreator then
6629
                  select member_type into mb from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6630
                  select member_type into targetmb from members_domain_method where domain_id=domain_idkey and user_id=acountkey;
6631
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6632
                        if loginTest() then
6633
                                select 1 as test;
6634
                                update members_domain_method set member_type = 'guest' where domain_id=domain_idkey and user_id=acountkey;
6635
                        else
6636
                                select 0 as test;
6637
                        end if;
6638
                  else
6639
                        select 0 as test;
6640
                  end if;
6641
              else
6642
                select 2 as test;
6643
              end if;
6644
        end if;
6645

    
6646
        if(domaintype='system') then
6647
              select user_id into domaincreator from domain_system where id=domain_idkey;
6648
              if acountkey != domaincreator then
6649
                  select member_type into mb from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
6650
                  select member_type into targetmb from members_domain_system where domain_id=domain_idkey and user_id=acountkey;
6651
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6652
                        if loginTest() then
6653
                                select 1 as test;
6654
                                update members_domain_system set member_type = 'guest' where domain_id=domain_idkey and user_id=acountkey;
6655
                        else
6656
                                select 0 as test;
6657
                        end if;
6658
                  else
6659
                        select 0 as test;
6660
                  end if;
6661
              else
6662
                select 0 as test;
6663
              end if;
6664
        end if;
6665
END//
6666
DELIMITER ;
6667

    
6668
-- 프로시저 nerv_icde_test.userViewEditDomainUserManager 구조 내보내기
6669
DROP PROCEDURE IF EXISTS `userViewEditDomainUserManager`;
6670
DELIMITER //
6671
CREATE PROCEDURE `userViewEditDomainUserManager`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `acountkey` varchar(100))
6672
BEGIN
6673
        declare domaincreator varchar(100);
6674

    
6675
        if(domaintype='data') then
6676
                    select user_id into domaincreator from domain_data where id=domain_idkey;
6677

    
6678
                    if acountkey != domaincreator and @nervuser = domaincreator or supermanagerTest(@nervuser) then
6679
                       if loginTest() then
6680
                           select 1 as test;
6681
                           update members_domain_data set member_type = 'manager' where domain_id=domain_idkey and user_id=acountkey;
6682
                       else
6683
                           select 0 as test;
6684
                       end if;
6685
                    else
6686
                       select 0 as test;
6687
                    end if;
6688
         end if;
6689

    
6690
         if(domaintype='method') then
6691
                    select user_id into domaincreator from domain_method where id=domain_idkey;
6692

    
6693
                    if acountkey != domaincreator and @nervuser = domaincreator or supermanagerTest(@nervuser) then
6694
                       if loginTest() then
6695
                           select 1 as test;
6696
                           update members_domain_method set member_type = 'manager' where domain_id=domain_idkey and user_id=acountkey;
6697
                       else
6698
                           select 0 as test;
6699
                       end if;
6700
                    else
6701
                       select 0 as test;
6702
                    end if;
6703
         end if;
6704

    
6705
         if(domaintype='system') then
6706
                    select user_id into domaincreator from domain_system where id=domain_idkey;
6707

    
6708
                    if acountkey != domaincreator and @nervuser = domaincreator or supermanagerTest(@nervuser) then
6709
                       if loginTest() then
6710
                           select 1 as test;
6711
                           update members_domain_system set member_type = 'manager' where domain_id=domain_idkey and user_id=acountkey;
6712
                       else
6713
                           select 0 as test;
6714
                       end if;
6715
                    else
6716
                       select 0 as test;
6717
                    end if;
6718
         end if;
6719
END//
6720
DELIMITER ;
6721

    
6722
-- 프로시저 nerv_icde_test.userViewEditDomainUserMember 구조 내보내기
6723
DROP PROCEDURE IF EXISTS `userViewEditDomainUserMember`;
6724
DELIMITER //
6725
CREATE PROCEDURE `userViewEditDomainUserMember`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `acountkey` varchar(100))
6726
BEGIN
6727
        declare domaincreator varchar(100);
6728
        declare mb varchar(100);
6729
        declare targetmb varchar(100);
6730

    
6731
        if(domaintype='data') then
6732
                     select user_id into domaincreator from domain_data where id=domain_idkey;
6733
                     if acountkey != domaincreator then
6734
                        select member_type into mb from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
6735
                        select member_type into targetmb from members_domain_data where domain_id=domain_idkey and user_id=acountkey;
6736
                        if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6737
                           if loginTest() then
6738
                                select 1 as test;
6739
                                update members_domain_data set member_type = 'member' where  domain_id=domain_idkey and user_id=acountkey;
6740
                           else
6741
                                select 0 as test;
6742
                           end if;
6743
                        else
6744
                           select 0 as test;
6745
                        end if;
6746
                      else
6747
                         select 0 as test;
6748
                      end if;
6749
          end if;
6750

    
6751
          if(domaintype='method') then
6752
                     select user_id into domaincreator from domain_method where id=domain_idkey;
6753
                     if acountkey != domaincreator then
6754
                        select member_type into mb from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6755
                        select member_type into targetmb from members_domain_method where domain_id=domain_idkey and user_id=acountkey;
6756
                        if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6757
                           if loginTest() then
6758
                                select 1 as test;
6759
                                update members_domain_method set member_type = 'member' where  domain_id=domain_idkey and user_id=acountkey;
6760
                           else
6761
                                select 0 as test;
6762
                           end if;
6763
                        else
6764
                           select 2 as test;
6765
                        end if;
6766
                      else
6767
                         select -1 as test;
6768
                      end if;
6769
          end if;
6770
          if(domaintype='system') then
6771
                     select user_id into domaincreator from domain_system where id=domain_idkey;
6772

    
6773
                     if acountkey != domaincreator then
6774
                        select member_type into mb from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
6775
                        select member_type into targetmb from members_domain_system where domain_id=domain_idkey and user_id=acountkey;
6776
                        if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6777
                           if loginTest() then
6778
                                select 1 as test;
6779
                                update members_domain_system set member_type = 'member' where  domain_id=domain_idkey and user_id=acountkey;
6780
                           else
6781
                                select 0 as test;
6782
                           end if;
6783
                        else
6784
                           select 0 as test;
6785
                        end if;
6786
                      else
6787
                         select 0 as test;
6788
                      end if;
6789
          end if;
6790

    
6791
END//
6792
DELIMITER ;
6793

    
6794
-- 프로시저 nerv_icde_test.userViewEditDomainUserPurge 구조 내보내기
6795
DROP PROCEDURE IF EXISTS `userViewEditDomainUserPurge`;
6796
DELIMITER //
6797
CREATE PROCEDURE `userViewEditDomainUserPurge`(IN `domain_idkey` int, IN `domaintype` varchar(100), IN `acountkey` varchar(100))
6798
BEGIN
6799
        declare domaincreator varchar(100);
6800
        declare mb varchar(100);
6801
        declare targetmb varchar(100);
6802

    
6803
        if(domaintype='data') then
6804
              select user_id into domaincreator from domain_data where id=domain_idkey;
6805
              if acountkey != domaincreator then
6806
                  select member_type into mb from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
6807
                  select member_type into targetmb from members_domain_data where domain_id=domain_idkey and user_id=acountkey;
6808
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6809
                        if loginTest() then
6810
                                select 1 as test;
6811
                                 delete from members_domain_data where domain_id=domain_idkey and user_id=acountkey;
6812

    
6813
                        else
6814
                                select 0 as test;
6815
                        end if;
6816
                  else
6817
                        select 0 as test;
6818
                  end if;
6819
              else
6820
                select 0 as test;
6821
              end if;
6822
        end if;
6823

    
6824
        if(domaintype='method') then
6825
              select user_id into domaincreator from domain_method where id=domain_idkey;
6826
              if acountkey != domaincreator then
6827
                  select member_type into mb from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6828
                  select member_type into targetmb from members_domain_method where domain_id=domain_idkey and user_id=acountkey;
6829
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6830
                        if loginTest() then
6831
                                select 1 as test;
6832
                                 delete from members_domain_method where domain_id=domain_idkey and user_id=acountkey;
6833
                        else
6834
                                select 0 as test;
6835
                        end if;
6836
                  else
6837
                        select 0 as test;
6838
                  end if;
6839
              else
6840
                select 0 as test;
6841
              end if;
6842
        end if;
6843

    
6844
        if(domaintype='system') then
6845
              select user_id into domaincreator from domain_system where id=domain_idkey;
6846
              if acountkey != domaincreator then
6847
                  select member_type into mb from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
6848
                  select member_type into targetmb from members_domain_system where domain_id=domain_idkey and user_id=acountkey;
6849
                  if @nervuser = domaincreator or (mb='manager' and targetmb!='manager') or supermanagerTest(@nervuser) then
6850
                        if loginTest() then
6851
                                select 1 as test;
6852
                                 delete from members_domain_system where domain_id=domain_idkey and user_id=acountkey;
6853
                        else
6854
                                select 0 as test;
6855
                        end if;
6856
                  else
6857
                        select 0 as test;
6858
                  end if;
6859
              else
6860
                select 0 as test;
6861
              end if;
6862
        end if;
6863
END//
6864
DELIMITER ;
6865

    
6866
-- 프로시저 nerv_icde_test.userViewJoinDomain 구조 내보내기
6867
DROP PROCEDURE IF EXISTS `userViewJoinDomain`;
6868
DELIMITER //
6869
CREATE PROCEDURE `userViewJoinDomain`(domain_idkey int, domaintype varchar(100))
6870
BEGIN
6871
        if loginTest() then
6872
                if (domaintype ='data') then
6873
                   select 1 as test;
6874
                   insert into members_domain_data(domain_id,user_id,member_type) values(domain_idkey,@nervuser,'guest');
6875
                end if;
6876
                if (domaintype ='method') then
6877
                   select 1 as test;
6878
                   insert into members_domain_method(domain_id,user_id,member_type) values(domain_idkey,@nervuser,'guest');
6879
                end if;
6880
                if (domaintype ='system') then
6881
                   select 1 as test;
6882
                   insert into members_domain_system(domain_id,user_id,member_type) values(domain_idkey,@nervuser,'guest');
6883
                end if;
6884
        else
6885
                select 0 as test;
6886
        end if;
6887
END//
6888
DELIMITER ;
6889

    
6890
-- 프로시저 nerv_icde_test.userViewSecessionDomain 구조 내보내기
6891
DROP PROCEDURE IF EXISTS `userViewSecessionDomain`;
6892
DELIMITER //
6893
CREATE PROCEDURE `userViewSecessionDomain`(domain_idkey int, domaintype varchar(100))
6894
BEGIN
6895
        if loginTest() then
6896
                if (domaintype ='data') then
6897
                   select 1 as test;
6898
                   delete from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
6899
                end if;
6900
                if (domaintype ='method') then
6901
                   select 1 as test;
6902
                   delete from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
6903
                end if;
6904
                if (domaintype ='system') then
6905
                   select 1 as test;
6906
                   delete from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
6907
                end if;
6908

    
6909

    
6910
        else
6911
                select 0 as test;
6912
        end if;
6913
END//
6914
DELIMITER ;
6915

    
6916
-- 프로시저 nerv_icde_test.userViewUserList 구조 내보내기
6917
DROP PROCEDURE IF EXISTS `userViewUserList`;
6918
DELIMITER //
6919
CREATE PROCEDURE `userViewUserList`(domain_idkey int, domaintype varchar(100), userkey varchar(100),memberkey varchar(100))
6920
BEGIN
6921
        if loginTest() then
6922
                select 1 as test;
6923
                if domainReadTest(domain_idkey, domaintype) then
6924
                   if (domaintype ='data') then
6925
                        if memberkey='all' then
6926
                                select a.user_id,member_type, description from
6927
                                        (select * from members_domain_data where domain_id=domain_idkey and user_id like userkey) as a
6928
                                                join
6929
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6930
                        else
6931
                                select a.user_id,member_type, description from
6932
                                        (select * from members_domain_data where domain_id=domain_idkey and user_id like userkey and member_type=memberkey) as a
6933
                                                join
6934
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6935
                        end if;
6936
                   end if;
6937

    
6938
                   if (domaintype ='method') then
6939
                        if memberkey='all' then
6940
                                select a.user_id,member_type, description from
6941
                                        (select * from members_domain_method where domain_id=domain_idkey and user_id like userkey) as a
6942
                                                join
6943
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6944
                        else
6945
                                select a.user_id,member_type, description from
6946
                                        (select * from members_domain_method where domain_id=domain_idkey and user_id like userkey and member_type=memberkey) as a
6947
                                                join
6948
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6949
                        end if;
6950
                   end if;
6951

    
6952
                   if (domaintype ='system') then
6953
                        if memberkey='all' then
6954
                                select a.user_id,member_type, description from
6955
                                        (select * from members_domain_system where domain_id=domain_idkey and user_id like userkey) as a
6956
                                                join
6957
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6958
                        else
6959
                                select a.user_id,member_type, description from
6960
                                        (select * from members_domain_system where domain_id=domain_idkey and user_id like userkey and member_type=memberkey) as a
6961
                                                join
6962
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6963
                        end if;
6964
                   end if;
6965

    
6966
                else
6967
                     if (domaintype ='data') then
6968
                        if memberkey='all' then
6969
                                select a.user_id,member_type, description from
6970
                                        (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
6971
                                                join
6972
                                        (select user_id,description from users where userid like userkey ) as b on a.user_id=b.user_id;
6973
                        else
6974
                                select a.user_id,member_type, description from
6975
                                        (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
6976
                                                join
6977
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6978
                        end if;
6979
                     end if;
6980

    
6981
                     if (domaintype ='method') then
6982
                        if memberkey='all' then
6983
                                select a.user_id,member_type, description from
6984
                                        (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
6985
                                                join
6986
                                        (select user_id,description from users where userid like userkey ) as b on a.user_id=b.user_id;
6987
                        else
6988
                                select a.user_id,member_type, description from
6989
                                        (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
6990
                                                join
6991
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
6992
                        end if;
6993
                     end if;
6994

    
6995
                     if (domaintype ='system') then
6996
                        if memberkey='all' then
6997
                                select a.user_id,member_type, description from
6998
                                        (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
6999
                                                join
7000
                                        (select user_id,description from users where userid like userkey ) as b on a.user_id=b.user_id;
7001
                        else
7002
                                select a.user_id,member_type, description from
7003
                                        (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
7004
                                                join
7005
                                        (select user_id,description from users where user_id like userkey ) as b on a.user_id=b.user_id;
7006
                        end if;
7007
                     end if;
7008
                end if;
7009
       else
7010
               select 0 as test;
7011
       end if;
7012
END//
7013
DELIMITER ;
7014

    
7015
-- 프로시저 nerv_icde_test.xmldocumentViewimportData 구조 내보내기
7016
DROP PROCEDURE IF EXISTS `xmldocumentViewimportData`;
7017
DELIMITER //
7018
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))
7019
BEGIN
7020

    
7021
	declare in_data_auto_id int default null;
7022
	declare in_real_data_auto_id int default null;
7023

    
7024
        if typevalue ='alias' and realdomain_idvalue != 0 then
7025
               select data.data_auto_id into in_real_data_auto_id from data where data.domain_id=realdomain_idvalue and data.name=realmetadatavalue;
7026
         end if;
7027

    
7028
        if loginTest() and domainManageTest(domain_idkey) and ( typevalue!='alias' or existMetadata(in_real_data_auto_id) )then
7029

    
7030
        			select data.data_auto_id into in_data_auto_id from data where data.domain_id=domain_idkey and data.name=data_namevalue;
7031

    
7032

    
7033
                select 1 as test;
7034
                if existMetadata(in_data_auto_id) then
7035

    
7036
                update data set name=data_namevalue,
7037
                                type=typevalue,
7038
                                real_data_auto_id=in_real_data_auto_id,
7039
                                scmin=scminvalue,
7040
                                scmax=scmaxvalue,
7041
                                description=descriptionvalue
7042
                                where data.data_auto_id=in_data_auto_id;
7043
                else
7044
                   insert into data (domain_id   ,name       ,type     , real_data_auto_id,       scmin     ,scmax     , description, user_id)
7045
                              values(domain_idkey,data_namevalue, typevalue, in_real_data_auto_id,scminvalue,scmaxvalue,descriptionvalue, @nervuser );
7046
                end if;
7047

    
7048
        else
7049
                select 0 as test;
7050
        end if;
7051
END//
7052
DELIMITER ;
7053

    
7054
-- 프로시저 nerv_icde_test.xmldocumentViewimportDatafield 구조 내보내기
7055
DROP PROCEDURE IF EXISTS `xmldocumentViewimportDatafield`;
7056
DELIMITER //
7057
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)
7058
BEGIN
7059

    
7060
	declare data_auto_id_key int default null;
7061
	declare in_real_data_auto_id int default null;
7062

    
7063
	select data.data_auto_id into data_auto_id_key from data where data.domain_id=domain_idkey and data.name=metadatakey;
7064

    
7065
      if typevalue ='alias' and realdomainvalue !=0 then
7066
	      select data.data_auto_id into in_real_data_auto_id from data where data.domain_id=realdomainvalue and data.name=realmetadatavalue;
7067
      end if;
7068

    
7069
      if loginTest() and domainManageTest(domain_idkey) and (typevalue!='alias' or existMetadata(in_real_data_auto_id)) then
7070
                select 1 as test;
7071
                if existMetadatafield(domain_idkey, metadatakey, metafieldvalue) then
7072

    
7073
                update data_field set member_name=metafieldvalue,
7074
                                      type=typevalue,
7075
                                      real_data_auto_id=in_real_data_auto_id,
7076
                                      bitsize=bitsizevalue,
7077
                                      scimin=minvalue,
7078
                                      scimax=in_maxvalue,
7079
                                      arraytype=arraytypevalue,
7080
                                      arraysize=arraysizevalue,
7081
                                      description=descriptionvalue
7082
                                 where data_field.data_auto_id=data_auto_id_key and member_name=metafieldvalue;
7083
                else
7084
                     insert into data_field( data_auto_id, member_name, type, real_data_auto_id, bitsize, user_id, scimin, scimax, arraytype, arraysize, description)
7085
          values(data_auto_id_key, metafieldvalue, typevalue, in_real_data_auto_id, bitsizevalue, @nervuser, minvalue, in_maxvalue, arraytypevalue, arraysizevalue, descriptionvalue);
7086
                end if;
7087

    
7088
        else
7089
                select 0 as test;
7090
        end if;
7091
END//
7092
DELIMITER ;
7093

    
7094
-- 프로시저 nerv_icde_test.xmldocumentViewimportDomain 구조 내보내기
7095
DROP PROCEDURE IF EXISTS `xmldocumentViewimportDomain`;
7096
DELIMITER //
7097
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)
7098
BEGIN
7099

    
7100

    
7101
        if loginTest() and newDomainTest() then
7102
                select 1 as test;
7103

    
7104
					 if (domaintype='data') then
7105
					 	if existDomain(in_id,domaintype) then
7106
                		update domain_data set upper_id=upper_idvalue, name=namevalue,  public=publicvalue  where domain_data.id=in_id;
7107
                	else
7108
                		insert into domain_data(id, upper_id, name, user_id, public, create_date, last_update,description )
7109
                                 values(in_id, upper_idvalue, namevalue, @nervuser, publicvalue, @logdate, @logdate,descriptionvalue);
7110
               	end if;
7111
                end if;
7112

    
7113
					 if (domaintype='method') then
7114
                	if existDomain(in_id,domaintype) then
7115
                		update domain_method set upper_id=upper_idvalue, name=namevalue,  public=publicvalue,  standard_port=standardportvalue where domain_method.id=in_id;
7116
                	else
7117
		                insert into domain_method(id, upper_id, name, user_id, public,  standard_port, create_date, last_update,description )
7118
                                 values(in_id, upper_idvalue, namevalue, @nervuser, publicvalue, standardportvalue, @logdate, @logdate,descriptionvalue);
7119
                  end if;
7120
                end if;
7121

    
7122
			else
7123
                select 0 as test;
7124
        end if;
7125

    
7126
END//
7127
DELIMITER ;
7128

    
7129
-- 프로시저 nerv_icde_test.xmldocumentViewimportInterface 구조 내보내기
7130
DROP PROCEDURE IF EXISTS `xmldocumentViewimportInterface`;
7131
DELIMITER //
7132
CREATE PROCEDURE `xmldocumentViewimportInterface`(domain_idkey int,
7133
                                                                     interfacevalue varchar(100),
7134
                                                                     descriptionvalue varchar(100))
7135
BEGIN
7136

    
7137
        if loginTest() and domainManageTest(domain_idkey) then
7138
                select 1 as test;
7139
                if existInterface(domain_idkey,interfacevalue) then
7140
                       update interface set name=interfacevalue,description=descriptionvalue where domain_id=domain_idkey and name=interfacevalue;
7141
                else
7142
                insert into interface (domain_id,                name,  user_id, description)
7143
                                values(domain_idkey, interfacevalue, @nervuser, descriptionvalue );
7144
                end if;
7145
        else
7146
                select 0 as test;
7147
        end if;
7148
END//
7149
DELIMITER ;
7150

    
7151
-- 프로시저 nerv_icde_test.xmldocumentViewimportInterfacemembermethod 구조 내보내기
7152
DROP PROCEDURE IF EXISTS `xmldocumentViewimportInterfacemembermethod`;
7153
DELIMITER //
7154
CREATE PROCEDURE `xmldocumentViewimportInterfacemembermethod`(domain_idkey int,
7155
                                                                                interfacekey varchar(100),
7156
                                                                                methodvalue varchar(100),
7157
                                                                                descriptionvalue varchar(100))
7158
BEGIN
7159
        if loginTest() and domainManageTest(domain_idkey) and existMethod(domain_idkey, methodvalue) and !existInterfaceMemberMethod(domain_idkey,interfacekey,methodvalue)then
7160
                select 1 as test;
7161
                insert into interface_member(domain_id,        interface,     method_domain_id,   method_name, description)
7162
                                    values(domain_idkey, interfacekey, domain_idkey, methodvalue, descriptionvalue);
7163
        else
7164
                select 0 as test;
7165
        end if;
7166
END//
7167
DELIMITER ;
7168

    
7169
-- 프로시저 nerv_icde_test.xmldocumentViewimportMethod 구조 내보내기
7170
DROP PROCEDURE IF EXISTS `xmldocumentViewimportMethod`;
7171
DELIMITER //
7172
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)
7173
BEGIN
7174

    
7175
	declare in_real_data_auto_id int default null;
7176
	declare out_real_data_auto_id int default null;
7177

    
7178

    
7179
     if inputdomainvalue!=0 then
7180
     		select data.data_auto_id into in_real_data_auto_id from data where data.domain_id=inputdomainvalue and data.name=inputmetadatavalue;
7181
     end if;
7182

    
7183
     if outputdomainvalue!=0 then
7184
	     select data.data_auto_id into out_real_data_auto_id from data where data.domain_id=outputdomainvalue and data.name=outputmetadatavalue;
7185
     end if;
7186

    
7187
     if loginTest() and domainManageTest(in_domain_id) and (in_real_data_auto_id is NULL or existMetadata(in_real_data_auto_id) )
7188
                                                       and (out_real_data_auto_id is NULL or existMetadata(out_real_data_auto_id)) then
7189
                select 1 as test;
7190
                if existMethod(in_domain_id, in_methodvalue) then
7191

    
7192
                update method set       code=in_codevalue,
7193
                                        type=in_typevalue,
7194
                                        name=in_methodvalue,
7195
                                        in_data_auto_id=in_real_data_auto_id,
7196
													 out_data_auto_id=out_real_data_auto_id,
7197
                                        description=descriptionvalue
7198
                              where     domain_id=in_domain_id and name=in_methodvalue;
7199
                else
7200
                insert into method(    domain_id,           name,         type,         code,      in_data_auto_id,  out_data_auto_id,  user_id, description)
7201
                            values( in_domain_id, in_methodvalue, in_typevalue, in_codevalue, in_real_data_auto_id, out_data_auto_id, @nervuser, descriptionvalue);
7202
                end if;
7203

    
7204
        else
7205
                select 0 as test;
7206
        end if;
7207
END//
7208
DELIMITER ;
7209

    
7210
-- 함수 nerv_icde_test.check_system_lock_component_f 구조 내보내기
7211
DROP FUNCTION IF EXISTS `check_system_lock_component_f`;
7212
DELIMITER //
7213
CREATE FUNCTION `check_system_lock_component_f`(
7214
	`in_component_id` INT
7215
) RETURNS tinyint(1)
7216
BEGIN
7217

    
7218
	declare deploy_id int default 0;
7219
	declare proxy_cnt int default 0;
7220
	declare stub_cnt int default 0;
7221

    
7222

    
7223
	select deployments.Id into deploy_id from deployments where component_id=in_component_id;
7224
	select count(*) into proxy_cnt from custum_proxy where custum_proxy.deploy_id=deploy_id and public=1;
7225
	select count(*) into stub_cnt  from custum_stub where custum_stub.deploy_id=deploy_id and public=1;
7226

    
7227

    
7228
	if proxy_cnt > 0  or stub_cnt > 0 then
7229
		return 0;
7230
	else
7231
		return 0;
7232
	end if;
7233
END//
7234
DELIMITER ;
7235

    
7236
-- 함수 nerv_icde_test.check_system_lock_domain 구조 내보내기
7237
DROP FUNCTION IF EXISTS `check_system_lock_domain`;
7238
DELIMITER //
7239
CREATE FUNCTION `check_system_lock_domain`(
7240
	`in_domain_id` INT
7241
) RETURNS tinyint(1)
7242
BEGIN
7243
	declare cnt int default 0;
7244

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

    
7247
	if cnt > 0 then
7248
		return 0;
7249
	else
7250
		return 0;
7251
	end if;
7252
END//
7253
DELIMITER ;
7254

    
7255
-- 함수 nerv_icde_test.check_system_lock_domainport 구조 내보내기
7256
DROP FUNCTION IF EXISTS `check_system_lock_domainport`;
7257
DELIMITER //
7258
CREATE FUNCTION `check_system_lock_domainport`(
7259
	`in_node_id` INT,
7260
	`in_domain_id` INT,
7261
	`in_port_num` INT
7262
) RETURNS tinyint(1)
7263
BEGIN
7264

    
7265
	declare cnt int default 0;
7266

    
7267
	select count(b.d_node_id) into cnt from
7268
	(select * from domain_system_port where domain_system_port.domain_system_id=in_domain_id and domain_system_port.port_group in
7269
		(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
7270
	join
7271
	(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;
7272

    
7273
	if cnt > 0 then
7274
		return 0;
7275
	else
7276
		return 0;
7277
	end if;
7278

    
7279
END//
7280
DELIMITER ;
7281

    
7282
-- 함수 nerv_icde_test.check_system_lock_interface 구조 내보내기
7283
DROP FUNCTION IF EXISTS `check_system_lock_interface`;
7284
DELIMITER //
7285
CREATE FUNCTION `check_system_lock_interface`(
7286
	`in_domain_id` INT,
7287
	`in_interface_name` VARCHAR(50)
7288

    
7289
) RETURNS tinyint(1)
7290
BEGIN
7291

    
7292
		declare proxy_cnt int default 0;
7293
		declare stub_cnt int default 0;
7294

    
7295
		select count(id) into proxy_cnt from custum_proxy where custum_proxy.public=1 and custum_proxy.proxy_interface_id in (
7296
			select id from proxy_interface_relation where proxy_interface_relation.method_domain_id=in_domain_id
7297
																 and proxy_interface_relation.interface_name =in_interface_name);
7298

    
7299
	  select count(id) into stub_cnt from custum_stub where custum_stub.public=1 and custum_stub.stub_interface_id in (
7300
			select id from stub_interface_relation where stub_interface_relation.method_domain_id=in_domain_id
7301
																 and stub_interface_relation.interface_name =in_interface_name);
7302

    
7303

    
7304
	if proxy_cnt > 0 or stub_cnt > 0 then
7305
		return 0;
7306
	else
7307
		return 0;
7308
	end if;
7309

    
7310
END//
7311
DELIMITER ;
7312

    
7313
-- 함수 nerv_icde_test.check_system_lock_node_port_f 구조 내보내기
7314
DROP FUNCTION IF EXISTS `check_system_lock_node_port_f`;
7315
DELIMITER //
7316
CREATE FUNCTION `check_system_lock_node_port_f`(
7317
	`in_node_id` INT,
7318
	`in_node_port` INT
7319
) RETURNS tinyint(1)
7320
BEGIN
7321

    
7322
	declare cnt int default 0;
7323
	select count(*) into cnt from node where node.complete='Y' and node.id in (
7324
		select node_id from network where network.original_node_id=in_node_id and network.original_node_port=in_node_port);
7325

    
7326
	if cnt > 0 then
7327
		return 0;
7328
	else
7329
		return 0;
7330
	end if;
7331

    
7332
END//
7333
DELIMITER ;
7334

    
7335
-- 함수 nerv_icde_test.check_system_lock_proxy_class 구조 내보내기
7336
DROP FUNCTION IF EXISTS `check_system_lock_proxy_class`;
7337
DELIMITER //
7338
CREATE FUNCTION `check_system_lock_proxy_class`(
7339
	`in_proxy_id` INT
7340
) RETURNS tinyint(1)
7341
BEGIN
7342

    
7343
	declare cnt int default 0;
7344

    
7345

    
7346
	select count(*) into cnt from node where node.complete='y' and node.sub_system_domain_id in
7347
		(select systemdomain_id from deployments where deployments.id in
7348
			(select deploy_id from custum_proxy where custum_proxy.proxy_interface_id = in_proxy_id and custum_proxy.public=1));
7349

    
7350

    
7351
		if cnt > 0 then
7352
		return 0;
7353
	else
7354
		return 0;
7355
	end if;
7356
END//
7357
DELIMITER ;
7358

    
7359
-- 함수 nerv_icde_test.check_system_lock_proxy_object_f 구조 내보내기
7360
DROP FUNCTION IF EXISTS `check_system_lock_proxy_object_f`;
7361
DELIMITER //
7362
CREATE FUNCTION `check_system_lock_proxy_object_f`(
7363
	`in_proxy_id` INT,
7364
	`in_proxy_object_name` VARCHAR(50)
7365
) RETURNS tinyint(1)
7366
BEGIN
7367

    
7368
declare cnt int default 0;
7369

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

    
7372
if cnt > 0 then
7373
		return 0;
7374
	else
7375
		return 0;
7376
	end if;
7377
END//
7378
DELIMITER ;
7379

    
7380
-- 함수 nerv_icde_test.check_system_lock_proxy_public 구조 내보내기
7381
DROP FUNCTION IF EXISTS `check_system_lock_proxy_public`;
7382
DELIMITER //
7383
CREATE FUNCTION `check_system_lock_proxy_public`(
7384
	`in_custum_id` INT
7385
) RETURNS tinyint(1)
7386
BEGIN
7387
		declare cnt int default 0;
7388
		select count(id) into cnt from custum_proxy where custum_proxy.Id = in_custum_id and custum_proxy.public=1;
7389

    
7390
	if cnt > 0 then
7391
		return 0;
7392
	else
7393
		return 0;
7394
	end if;
7395
END//
7396
DELIMITER ;
7397

    
7398
-- 함수 nerv_icde_test.check_system_lock_stub_class_f 구조 내보내기
7399
DROP FUNCTION IF EXISTS `check_system_lock_stub_class_f`;
7400
DELIMITER //
7401
CREATE FUNCTION `check_system_lock_stub_class_f`(
7402
	`in_stub_id` INT
7403
) RETURNS tinyint(1)
7404
BEGIN
7405
	declare cnt int default 0;
7406

    
7407

    
7408
	select count(*) into cnt from node where node.complete='y' and node.sub_system_domain_id in
7409
		(select systemdomain_id from deployments where deployments.id in
7410
			(select deploy_id from custum_stub where custum_stub.stub_interface_id = in_stub_id and custum_stub.public=1));
7411

    
7412

    
7413
		if cnt > 0 then
7414
		return 0;
7415
	else
7416
		return 0;
7417
	end if;
7418
END//
7419
DELIMITER ;
7420

    
7421
-- 함수 nerv_icde_test.check_system_lock_stub_object_f 구조 내보내기
7422
DROP FUNCTION IF EXISTS `check_system_lock_stub_object_f`;
7423
DELIMITER //
7424
CREATE FUNCTION `check_system_lock_stub_object_f`(
7425
	`in_stub_id` INT,
7426
	`in_stub_object_name` VARCHAR(50)
7427
) RETURNS tinyint(1)
7428
BEGIN
7429

    
7430
declare cnt int default 0;
7431

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

    
7434
if cnt > 0 then
7435
		return 0;
7436
	else
7437
		return 0;
7438
	end if;
7439

    
7440
END//
7441
DELIMITER ;
7442

    
7443
-- 함수 nerv_icde_test.componentEntityCheck 구조 내보내기
7444
DROP FUNCTION IF EXISTS `componentEntityCheck`;
7445
DELIMITER //
7446
CREATE FUNCTION `componentEntityCheck`(in_diagrameid int, in_component_id int) RETURNS tinyint(1)
7447
BEGIN
7448
        declare cnt int default 0;
7449
        select count(id) into cnt from umlcomponent where diagrame_id=in_diagrameid and component_id=in_component_id;
7450
        if cnt > 0 then
7451
                return 1;
7452
        else
7453
                return 0;
7454
        end if;
7455
END//
7456
DELIMITER ;
7457

    
7458
-- 함수 nerv_icde_test.domainDataPath 구조 내보내기
7459
DROP FUNCTION IF EXISTS `domainDataPath`;
7460
DELIMITER //
7461
CREATE FUNCTION `domainDataPath`(`in_domain_idkey` INT, `in_path` TEXT) RETURNS text CHARSET utf8
7462
BEGIN
7463

    
7464
	declare path varchar(50);
7465
	declare in_upper_id int default null;
7466
	declare in_name varchar(50) default null;
7467

    
7468
	 loop
7469
		select domain_data.upper_id into in_upper_id from domain_data where domain_data.id=in_domain_idkey;
7470
		select name into path from domain_data where id=in_domain_idkey;
7471

    
7472

    
7473
		 select (concat_WS('\\',path,in_path)) into in_path;
7474

    
7475
		 if in_upper_id=0 then
7476
		 	return in_path;
7477
		 end if;
7478

    
7479
		set in_domain_idkey=in_upper_id;
7480
	 end loop;
7481

    
7482

    
7483

    
7484
END//
7485
DELIMITER ;
7486

    
7487
-- 함수 nerv_icde_test.domainManageTest 구조 내보내기
7488
DROP FUNCTION IF EXISTS `domainManageTest`;
7489
DELIMITER //
7490
CREATE FUNCTION `domainManageTest`(domain_idkey int) RETURNS tinyint(1)
7491
BEGIN
7492
        declare sa varchar(100);
7493
        declare acount varchar(100);
7494
        declare pbc bool;
7495

    
7496
        set sa = '';
7497

    
7498
        if( supermanagerTest(@nervuser) ) then
7499
            return 1;
7500
        end if;
7501

    
7502
              select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
7503
               if( sa='manager' ) then
7504
                   return 1;
7505
               end if;
7506

    
7507
               select user_id into acount from domain_data where id=domain_idkey;
7508
               if(acount = @nervuser) then
7509
                    return 1;
7510
               end if;
7511

    
7512
               select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
7513
               if( sa='manager' ) then
7514
                   return 1;
7515
               end if;
7516
               select user_id into acount from domain_method where id=domain_idkey;
7517
               if(acount = @nervuser) then
7518
                    return 1;
7519
               end if;
7520

    
7521
               select member_type into sa from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
7522
               if( sa='manager' ) then
7523
                   return 1;
7524
               end if;
7525
               select user_id into acount from domain_system where id=domain_idkey;
7526
               if(acount = @nervuser) then
7527
                    return 1;
7528
               end if;
7529

    
7530

    
7531
        return 0;
7532
END//
7533
DELIMITER ;
7534

    
7535
-- 함수 nerv_icde_test.domainMethodPath 구조 내보내기
7536
DROP FUNCTION IF EXISTS `domainMethodPath`;
7537
DELIMITER //
7538
CREATE FUNCTION `domainMethodPath`(`in_domain_idkey` INT, `in_path` TEXT) RETURNS text CHARSET utf8
7539
BEGIN
7540
	declare path varchar(50);
7541
	declare in_upper_id int default null;
7542
	declare in_name varchar(50) default null;
7543

    
7544
	 loop
7545
		select domain_method.upper_id into in_upper_id from domain_method where domain_method.id=in_domain_idkey;
7546
		select name into path from domain_method where id=in_domain_idkey;
7547

    
7548

    
7549
		 select (concat_WS('\\',path,in_path)) into in_path;
7550

    
7551
		 if in_upper_id=0 then
7552
		 	return in_path;
7553
		 end if;
7554

    
7555
		set in_domain_idkey=in_upper_id;
7556
	 end loop;
7557

    
7558
END//
7559
DELIMITER ;
7560

    
7561
-- 함수 nerv_icde_test.domainReadTest 구조 내보내기
7562
DROP FUNCTION IF EXISTS `domainReadTest`;
7563
DELIMITER //
7564
CREATE FUNCTION `domainReadTest`(domain_idkey int, domaintype varchar(50)) RETURNS tinyint(1)
7565
BEGIN
7566
        declare sa varchar(100);
7567
        declare acount varchar(100);
7568
        declare pbc bool;
7569
        set sa = '';
7570

    
7571

    
7572

    
7573
        if( supermanagerTest(@nervuser) ) then
7574
             return 1;
7575
        end if;
7576

    
7577
        if (domaintype = 'system') then
7578
           select member_type into sa from members_domain_system where domain_id=domain_idkey and user_id=@nervuser;
7579
        end if;
7580
        if (domaintype = 'method') then
7581
           select member_type into sa from members_domain_method where domain_id=domain_idkey and user_id=@nervuser;
7582
        end if;
7583
        if (domaintype = 'data') then
7584
           select member_type into sa from members_domain_data where domain_id=domain_idkey and user_id=@nervuser;
7585
        end if;
7586

    
7587
        if( sa='member' or sa='manager' ) then
7588
           return 1;
7589
        end if;
7590

    
7591

    
7592

    
7593
        if (domaintype = 'system') then
7594
           select user_id into acount from domain_system where id=domain_idkey;
7595
        end if;
7596
        if (domaintype = 'method') then
7597
           select user_id into acount from domain_method where id=domain_idkey;
7598
        end if;
7599
        if (domaintype = 'data') then
7600
           select user_id into acount from domain_data where id=domain_idkey;
7601
        end if;
7602

    
7603
        if(acount = @nervuser) then
7604
           return 1;
7605
        end if;
7606

    
7607

    
7608

    
7609
        if (domaintype = 'system') then
7610
           select public into pbc from domain_system where id=domain_idkey;
7611
        end if;
7612
        if (domaintype = 'method') then
7613
           select public into pbc from domain_method where id=domain_idkey;
7614
        end if;
7615
        if (domaintype = 'data') then
7616
           select public into pbc from domain_data where id=domain_idkey;
7617
        end if;
7618

    
7619
        if(pbc) then
7620
         return 1;
7621
        end if;
7622
        return 0;
7623
END//
7624
DELIMITER ;
7625

    
7626
-- 함수 nerv_icde_test.domainSystemPath 구조 내보내기
7627
DROP FUNCTION IF EXISTS `domainSystemPath`;
7628
DELIMITER //
7629
CREATE FUNCTION `domainSystemPath`(`in_domain_idkey` INT, `in_path` TEXT) RETURNS text CHARSET utf8
7630
BEGIN
7631
	declare path varchar(50);
7632
	declare in_upper_id int default null;
7633
	declare in_name varchar(50) default null;
7634

    
7635
	 loop
7636
		select domain_system.upper_id into in_upper_id from domain_system where domain_system.id=in_domain_idkey;
7637
		select name into path from domain_system where id=in_domain_idkey;
7638

    
7639
		select (concat_WS('\\',path,in_path)) into in_path;
7640

    
7641
		 if in_upper_id=0 then
7642
		 	return in_path;
7643
		 end if;
7644

    
7645
		set in_domain_idkey=in_upper_id;
7646
	 end loop;
7647

    
7648
END//
7649
DELIMITER ;
7650

    
7651
-- 함수 nerv_icde_test.domainWriteTest 구조 내보내기
7652
DROP FUNCTION IF EXISTS `domainWriteTest`;
7653
DELIMITER //
7654
CREATE FUNCTION `domainWriteTest`(domain_idkey int, domaintypevalue varchar(100)) RETURNS tinyint(1)
7655
BEGIN
7656
        declare sa varchar(100);
7657
        declare acount varchar(100);
7658

    
7659
           if( supermanagerTest(@nervuser) ) then
7660
             return 1;
7661
        end if;
7662

    
7663
        if domaintypevalue = 'data' then
7664
          select user_id into acount from members_domain_data where domain_id=domain_idkey;
7665
          if(acount = @nervuser) then
7666
              return 1;
7667
          end if;
7668
            select user_id into acount from domain_data where id = domain_idkey;
7669

    
7670

    
7671
        end if;
7672

    
7673
        if domaintypevalue = 'method' then
7674
          select user_id into acount from members_domain_method where domain_id=domain_idkey;
7675
          if(acount = @nervuser) then
7676
              return 1;
7677
          end if;
7678
          select user_id into acount from domain_method where id = domain_idkey;
7679
        end if;
7680

    
7681
        if domaintypevalue = 'system' then
7682
          select user_id into acount from members_domain_system where domain_id=domain_idkey;
7683
          if(acount = @nervuser) then
7684
              return 1;
7685
          end if;
7686
          select user_id into acount from domain_system where id = domain_idkey;
7687
        end if;
7688

    
7689
        if(acount = @nervuser) then
7690
              return 1;
7691
        end if;
7692
        return 0;
7693
END//
7694
DELIMITER ;
7695

    
7696
-- 함수 nerv_icde_test.existDomain 구조 내보내기
7697
DROP FUNCTION IF EXISTS `existDomain`;
7698
DELIMITER //
7699
CREATE FUNCTION `existDomain`(`domainkey` int, `domaintypevalue` varchar(100)) RETURNS tinyint(1)
7700
BEGIN
7701
        declare cnt tinyint(1);
7702
        declare cnt_2 tinyint(1);
7703
        set cnt = 0;
7704

    
7705
        if(domaintypevalue = 'data') then
7706
             select count(*) into cnt from domain_data where id=domainkey;
7707
             return cnt;
7708
        end if;
7709
        if(domaintypevalue = 'method') then
7710
             select count(*) into cnt from domain_method where id=domainkey;
7711
             return cnt;
7712

    
7713

    
7714
        end if;
7715
        if(domaintypevalue = 'system') then
7716
             select count(*) into cnt from domain_system where id=domainkey;
7717
             return cnt;
7718
        end if;
7719
END//
7720
DELIMITER ;
7721

    
7722
-- 함수 nerv_icde_test.existInterface 구조 내보내기
7723
DROP FUNCTION IF EXISTS `existInterface`;
7724
DELIMITER //
7725
CREATE FUNCTION `existInterface`(domain_idkey int, interface_name varchar(100)) RETURNS tinyint(1)
7726
BEGIN
7727
        declare cnt tinyint(1);
7728
        set cnt = 0;
7729

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

    
7732
        return cnt;
7733
END//
7734
DELIMITER ;
7735

    
7736
-- 함수 nerv_icde_test.existInterfaceMemberMethod 구조 내보내기
7737
DROP FUNCTION IF EXISTS `existInterfaceMemberMethod`;
7738
DELIMITER //
7739
CREATE FUNCTION `existInterfaceMemberMethod`(domain_idkey int ,
7740
                                                                interfacekey varchar(100),
7741
                                                                methodnamekey varchar(100) ) RETURNS tinyint(1)
7742
BEGIN
7743
        declare cnt tinyint(1);
7744
        set cnt = 0;
7745

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

    
7748
        return cnt;
7749
END//
7750
DELIMITER ;
7751

    
7752
-- 함수 nerv_icde_test.existMemberDomain 구조 내보내기
7753
DROP FUNCTION IF EXISTS `existMemberDomain`;
7754
DELIMITER //
7755
CREATE FUNCTION `existMemberDomain`(in_domainid int, in_userid varchar(100), in_domaintype varchar(100) ) RETURNS tinyint(1)
7756
BEGIN
7757
        declare cnt tinyint(1);
7758
        set cnt = 0;
7759
        if(in_domaintype='data')then
7760
            select count(*) into cnt from members_domain_data where domain_id=in_domainid and user_id=in_userid;
7761
        end if;
7762
        if(in_domaintype='method')then
7763
            select count(*) into cnt from members_domain_method where domain_id=in_domainid and user_id=in_userid;
7764
        end if;
7765
        if(in_domaintype='system')then
7766
            select count(*) into cnt from members_domain_system where domain_id=in_domainid and user_id=in_userid;
7767
        end if;
7768

    
7769
        return cnt;
7770
END//
7771
DELIMITER ;
7772

    
7773
-- 함수 nerv_icde_test.existMetadata 구조 내보내기
7774
DROP FUNCTION IF EXISTS `existMetadata`;
7775
DELIMITER //
7776
CREATE FUNCTION `existMetadata`(`in_data_auto_id_key` int) RETURNS tinyint(1)
7777
BEGIN
7778
        declare cnt tinyint(1);
7779
        set cnt = 0;
7780
        select count(*) into cnt from data where data.data_auto_id=in_data_auto_id_key;
7781

    
7782
        return cnt;
7783
END//
7784
DELIMITER ;
7785

    
7786
-- 함수 nerv_icde_test.existMetadatafield 구조 내보내기
7787
DROP FUNCTION IF EXISTS `existMetadatafield`;
7788
DELIMITER //
7789
CREATE FUNCTION `existMetadatafield`(`domain_idkey` int, `metadata_name` varchar(100), `metadatafield_name` varchar(100) ) RETURNS tinyint(1)
7790
BEGIN
7791
        declare cnt tinyint(1);
7792
        declare data_auto_id_key int default null;
7793

    
7794
		  select data.data_auto_id into data_auto_id_key from data where data.domain_id=domain_idkey and data.name=metadata_name;
7795

    
7796
        set cnt = 0;
7797
        select count(*) into cnt from data_field where data_field.data_auto_id=data_auto_id_key and member_name=metadatafield_name;
7798

    
7799
        return cnt;
7800
END//
7801
DELIMITER ;
7802

    
7803
-- 함수 nerv_icde_test.existMethod 구조 내보내기
7804
DROP FUNCTION IF EXISTS `existMethod`;
7805
DELIMITER //
7806
CREATE FUNCTION `existMethod`(domain_idkey int , method_name varchar(100) ) RETURNS tinyint(1)
7807
BEGIN
7808
        declare cnt tinyint(1);
7809
        set cnt = 0;
7810

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

    
7813
        return cnt;
7814
END//
7815
DELIMITER ;
7816

    
7817
-- 함수 nerv_icde_test.exitDomainId 구조 내보내기
7818
DROP FUNCTION IF EXISTS `exitDomainId`;
7819
DELIMITER //
7820
CREATE FUNCTION `exitDomainId`(in_domainname varchar(100), in_upperid varchar(100), in_domaintype varchar(100) ) RETURNS int(10) unsigned
7821
BEGIN
7822
        declare domain_id int unsigned;
7823
        set domain_id = 0;
7824

    
7825
        if(in_domaintype='data')then
7826
            select id into domain_id from domain_data where name=in_domainname and upper_id=in_upperid;
7827
        end if;
7828
        if(in_domaintype='method')then
7829
            select id into domain_id from domain_method where name=in_domainname and upper_id=in_upperid;
7830
        end if;
7831
        if(in_domaintype='system')then
7832
            select id into domain_id from domain_system where name=in_domainname and upper_id=in_upperid;
7833
        end if;
7834

    
7835
        return domain_id;
7836
END//
7837
DELIMITER ;
7838

    
7839
-- 함수 nerv_icde_test.inheritanceSystemMehtodParentOverlapCheck 구조 내보내기
7840
DROP FUNCTION IF EXISTS `inheritanceSystemMehtodParentOverlapCheck`;
7841
DELIMITER //
7842
CREATE FUNCTION `inheritanceSystemMehtodParentOverlapCheck`(domainkey int, parentdomainidkey int) RETURNS tinyint(1)
7843
BEGIN
7844
        declare cnt tinyint(1);
7845

    
7846
        set cnt = 0;
7847

    
7848
        select count(*) into cnt from inheritance_system_method where domain_id=domainkey and parent_domain_id=parentdomainidkey;
7849

    
7850
        if(cnt = 0) then
7851
            return 1;
7852
        end if;
7853

    
7854
         return 0;
7855

    
7856
END//
7857
DELIMITER ;
7858

    
7859
-- 함수 nerv_icde_test.logical_port_group_count 구조 내보내기
7860
DROP FUNCTION IF EXISTS `logical_port_group_count`;
7861
DELIMITER //
7862
CREATE FUNCTION `logical_port_group_count`(in_system_domain_id int, in_port_group int) RETURNS tinyint(1)
7863
BEGIN
7864
        declare cnt tinyint(1);
7865
        set cnt=0;
7866

    
7867
        select count(*) into cnt from domain_system_port where domain_system_id=in_system_domain_id and port_group=in_port_group;
7868
        return cnt;
7869
END//
7870
DELIMITER ;
7871

    
7872
-- 함수 nerv_icde_test.loginTest 구조 내보내기
7873
DROP FUNCTION IF EXISTS `loginTest`;
7874
DELIMITER //
7875
CREATE FUNCTION `loginTest`() RETURNS tinyint(1)
7876
BEGIN
7877
        declare cnt int default 0;
7878
        select count(user_id) into cnt from users where user_id=@nervuser and password = password(@nervpassword);
7879
        if cnt > 0 then
7880
                return 1;
7881
        else
7882
                return 0;
7883
        end if;
7884
END//
7885
DELIMITER ;
7886

    
7887
-- 함수 nerv_icde_test.method_domainCompatibleTest 구조 내보내기
7888
DROP FUNCTION IF EXISTS `method_domainCompatibleTest`;
7889
DELIMITER //
7890
CREATE FUNCTION `method_domainCompatibleTest`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7891
BEGIN
7892
        declare cnt int;
7893
        declare itor int default 0;
7894
        declare pdomain int;
7895

    
7896
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7897
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7898

    
7899

    
7900
        if( domain_idkey = parent_domain_idkey) then
7901
            return 1;
7902
        end if;
7903

    
7904
        open cur1;
7905
        set itor = 0;
7906
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7907
        while itor < cnt do
7908
            fetch cur1 into pdomain;
7909
            if( !method_domainCompatibleTest_depth_0( parent_domain_idkey , pdomain,depth+1) ) then
7910
                 close cur1;
7911
                 return 0;
7912
            end if;
7913
            set itor = itor + 1;
7914
        end while;
7915
        close cur1;
7916

    
7917
        open cur2;
7918
        set itor = 0;
7919
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7920
        while itor < cnt do
7921
            fetch cur2 into pdomain;
7922
            if( !method_domainCompatibleTest_depth_0( domain_idkey , pdomain,depth+1) ) then
7923
                    close cur2;
7924
                    return 0;
7925
            end if;
7926
            set itor = itor + 1;
7927
        end while;
7928
        close cur2;
7929

    
7930
        select count(*) into cnt from
7931
            (select type,code from method where domain_id=domain_idkey) as a
7932
            join
7933
            (select type,code from method where domain_id=parent_domain_idkey) as b
7934
            on a.type=b.type and a.code = b.code;
7935

    
7936
         if( cnt > 0) then
7937
            return 0;
7938
         end if;
7939

    
7940
         return 1;
7941
END//
7942
DELIMITER ;
7943

    
7944
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_0 구조 내보내기
7945
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_0`;
7946
DELIMITER //
7947
CREATE FUNCTION `method_domainCompatibleTest_depth_0`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
7948
BEGIN
7949
        declare cnt int;
7950
        declare itor int default 0;
7951
        declare pdomain int;
7952

    
7953
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
7954
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
7955

    
7956

    
7957
        if( domain_idkey = parent_domain_idkey) then
7958
            return 1;
7959
        end if;
7960

    
7961
        open cur1;
7962
        set itor = 0;
7963
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
7964
        while itor < cnt do
7965
            fetch cur1 into pdomain;
7966
            if( !method_domainCompatibleTest_depth_1( parent_domain_idkey , pdomain,depth+1) ) then
7967
                 close cur1;
7968
                 return 0;
7969
            end if;
7970
            set itor = itor + 1;
7971
        end while;
7972
        close cur1;
7973

    
7974
        open cur2;
7975
        set itor = 0;
7976
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
7977
        while itor < cnt do
7978
            fetch cur2 into pdomain;
7979
            if( !method_domainCompatibleTest_depth_1( domain_idkey , pdomain,depth+1) ) then
7980
                    close cur2;
7981
                    return 0;
7982
            end if;
7983
            set itor = itor + 1;
7984
        end while;
7985
        close cur2;
7986

    
7987
        select count(*) into cnt from
7988
            (select type,code from method where domain_id=domain_idkey) as a
7989
            join
7990
            (select type,code from method where domain_id=parent_domain_idkey) as b
7991
            on a.type=b.type and a.code = b.code;
7992

    
7993
         if( cnt > 0) then
7994
            return 0;
7995
         end if;
7996

    
7997
         return 1;
7998
END//
7999
DELIMITER ;
8000

    
8001
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_1 구조 내보내기
8002
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_1`;
8003
DELIMITER //
8004
CREATE FUNCTION `method_domainCompatibleTest_depth_1`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8005
BEGIN
8006
        declare cnt int;
8007
        declare itor int default 0;
8008
        declare pdomain int;
8009

    
8010
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8011
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8012

    
8013

    
8014
        if( domain_idkey = parent_domain_idkey) then
8015
            return 1;
8016
        end if;
8017

    
8018
        open cur1;
8019
        set itor = 0;
8020
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8021
        while itor < cnt do
8022
            fetch cur1 into pdomain;
8023
            if( !method_domainCompatibleTest_depth_2( parent_domain_idkey , pdomain,depth+1) ) then
8024
                 close cur1;
8025
                 return 0;
8026
            end if;
8027
            set itor = itor + 1;
8028
        end while;
8029
        close cur1;
8030

    
8031
        open cur2;
8032
        set itor = 0;
8033
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8034
        while itor < cnt do
8035
            fetch cur2 into pdomain;
8036
            if( !method_domainCompatibleTest_depth_2( domain_idkey , pdomain,depth+1) ) then
8037
                    close cur2;
8038
                    return 0;
8039
            end if;
8040
            set itor = itor + 1;
8041
        end while;
8042
        close cur2;
8043

    
8044
        select count(*) into cnt from
8045
            (select type,code from method where domain_id=domain_idkey) as a
8046
            join
8047
            (select type,code from method where domain_id=parent_domain_idkey) as b
8048
            on a.type=b.type and a.code = b.code;
8049

    
8050
         if( cnt > 0) then
8051
            return 0;
8052
         end if;
8053

    
8054
         return 1;
8055
END//
8056
DELIMITER ;
8057

    
8058
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_10 구조 내보내기
8059
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_10`;
8060
DELIMITER //
8061
CREATE FUNCTION `method_domainCompatibleTest_depth_10`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8062
BEGIN
8063
        declare cnt int;
8064
        declare itor int default 0;
8065
        declare pdomain int;
8066

    
8067
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8068
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8069

    
8070

    
8071
        if( domain_idkey = parent_domain_idkey) then
8072
            return 1;
8073
        end if;
8074

    
8075
        open cur1;
8076
        set itor = 0;
8077
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8078
        while itor < cnt do
8079
            fetch cur1 into pdomain;
8080
            if( !method_domainCompatibleTest_depth_1( parent_domain_idkey , pdomain,depth+1) ) then
8081
                 close cur1;
8082
                 return 0;
8083
            end if;
8084
            set itor = itor + 1;
8085
        end while;
8086
        close cur1;
8087

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

    
8101
        select count(*) into cnt from
8102
            (select type,code from method where domain_id=domain_idkey) as a
8103
            join
8104
            (select type,code from method where domain_id=parent_domain_idkey) as b
8105
            on a.type=b.type and a.code = b.code;
8106

    
8107
         if( cnt > 0) then
8108
            return 0;
8109
         end if;
8110

    
8111
         return 1;
8112
END//
8113
DELIMITER ;
8114

    
8115
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_2 구조 내보내기
8116
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_2`;
8117
DELIMITER //
8118
CREATE FUNCTION `method_domainCompatibleTest_depth_2`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8119
BEGIN
8120
        declare cnt int;
8121
        declare itor int default 0;
8122
        declare pdomain int;
8123

    
8124
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8125
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8126

    
8127

    
8128
        if( domain_idkey = parent_domain_idkey) then
8129
            return 1;
8130
        end if;
8131

    
8132
        open cur1;
8133
        set itor = 0;
8134
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8135
        while itor < cnt do
8136
            fetch cur1 into pdomain;
8137
            if( !method_domainCompatibleTest_depth_3( parent_domain_idkey , pdomain,depth+1) ) then
8138
                 close cur1;
8139
                 return 0;
8140
            end if;
8141
            set itor = itor + 1;
8142
        end while;
8143
        close cur1;
8144

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

    
8158
        select count(*) into cnt from
8159
            (select type,code from method where domain_id=domain_idkey) as a
8160
            join
8161
            (select type,code from method where domain_id=parent_domain_idkey) as b
8162
            on a.type=b.type and a.code = b.code;
8163

    
8164
         if( cnt > 0) then
8165
            return 0;
8166
         end if;
8167

    
8168
         return 1;
8169
END//
8170
DELIMITER ;
8171

    
8172
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_3 구조 내보내기
8173
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_3`;
8174
DELIMITER //
8175
CREATE FUNCTION `method_domainCompatibleTest_depth_3`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8176
BEGIN
8177
        declare cnt int;
8178
        declare itor int default 0;
8179
        declare pdomain int;
8180

    
8181
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8182
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8183

    
8184

    
8185
        if( domain_idkey = parent_domain_idkey) then
8186
            return 1;
8187
        end if;
8188

    
8189
        open cur1;
8190
        set itor = 0;
8191
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8192
        while itor < cnt do
8193
            fetch cur1 into pdomain;
8194
            if( !method_domainCompatibleTest_depth_4( parent_domain_idkey , pdomain,depth+1) ) then
8195
                 close cur1;
8196
                 return 0;
8197
            end if;
8198
            set itor = itor + 1;
8199
        end while;
8200
        close cur1;
8201

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

    
8215
        select count(*) into cnt from
8216
            (select type,code from method where domain_id=domain_idkey) as a
8217
            join
8218
            (select type,code from method where domain_id=parent_domain_idkey) as b
8219
            on a.type=b.type and a.code = b.code;
8220

    
8221
         if( cnt > 0) then
8222
            return 0;
8223
         end if;
8224

    
8225
         return 1;
8226
END//
8227
DELIMITER ;
8228

    
8229
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_4 구조 내보내기
8230
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_4`;
8231
DELIMITER //
8232
CREATE FUNCTION `method_domainCompatibleTest_depth_4`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8233
BEGIN
8234
        declare cnt int;
8235
        declare itor int default 0;
8236
        declare pdomain int;
8237

    
8238
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8239
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8240

    
8241

    
8242
        if( domain_idkey = parent_domain_idkey) then
8243
            return 1;
8244
        end if;
8245

    
8246
        open cur1;
8247
        set itor = 0;
8248
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8249
        while itor < cnt do
8250
            fetch cur1 into pdomain;
8251
            if( !method_domainCompatibleTest_depth_5( parent_domain_idkey , pdomain,depth+1) ) then
8252
                 close cur1;
8253
                 return 0;
8254
            end if;
8255
            set itor = itor + 1;
8256
        end while;
8257
        close cur1;
8258

    
8259
        open cur2;
8260
        set itor = 0;
8261
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8262
        while itor < cnt do
8263
            fetch cur2 into pdomain;
8264
            if( !method_domainCompatibleTest_depth_5( domain_idkey , pdomain,depth+1) ) then
8265
                    close cur2;
8266
                    return 0;
8267
            end if;
8268
            set itor = itor + 1;
8269
        end while;
8270
        close cur2;
8271

    
8272
        select count(*) into cnt from
8273
            (select type,code from method where domain_id=domain_idkey) as a
8274
            join
8275
            (select type,code from method where domain_id=parent_domain_idkey) as b
8276
            on a.type=b.type and a.code = b.code;
8277

    
8278
         if( cnt > 0) then
8279
            return 0;
8280
         end if;
8281

    
8282
         return 1;
8283
END//
8284
DELIMITER ;
8285

    
8286
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_5 구조 내보내기
8287
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_5`;
8288
DELIMITER //
8289
CREATE FUNCTION `method_domainCompatibleTest_depth_5`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8290
BEGIN
8291
        declare cnt int;
8292
        declare itor int default 0;
8293
        declare pdomain int;
8294

    
8295
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8296
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8297

    
8298

    
8299
        if( domain_idkey = parent_domain_idkey) then
8300
            return 1;
8301
        end if;
8302

    
8303
        open cur1;
8304
        set itor = 0;
8305
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8306
        while itor < cnt do
8307
            fetch cur1 into pdomain;
8308
            if( !method_domainCompatibleTest_depth_6( parent_domain_idkey , pdomain,depth+1) ) then
8309
                 close cur1;
8310
                 return 0;
8311
            end if;
8312
            set itor = itor + 1;
8313
        end while;
8314
        close cur1;
8315

    
8316
        open cur2;
8317
        set itor = 0;
8318
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8319
        while itor < cnt do
8320
            fetch cur2 into pdomain;
8321
            if( !method_domainCompatibleTest_depth_6( domain_idkey , pdomain,depth+1) ) then
8322
                    close cur2;
8323
                    return 0;
8324
            end if;
8325
            set itor = itor + 1;
8326
        end while;
8327
        close cur2;
8328

    
8329
        select count(*) into cnt from
8330
            (select type,code from method where domain_id=domain_idkey) as a
8331
            join
8332
            (select type,code from method where domain_id=parent_domain_idkey) as b
8333
            on a.type=b.type and a.code = b.code;
8334

    
8335
         if( cnt > 0) then
8336
            return 0;
8337
         end if;
8338

    
8339
         return 1;
8340
END//
8341
DELIMITER ;
8342

    
8343
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_6 구조 내보내기
8344
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_6`;
8345
DELIMITER //
8346
CREATE FUNCTION `method_domainCompatibleTest_depth_6`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8347
BEGIN
8348
        declare cnt int;
8349
        declare itor int default 0;
8350
        declare pdomain int;
8351

    
8352
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8353
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8354

    
8355

    
8356
        if( domain_idkey = parent_domain_idkey) then
8357
            return 1;
8358
        end if;
8359

    
8360
        open cur1;
8361
        set itor = 0;
8362
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8363
        while itor < cnt do
8364
            fetch cur1 into pdomain;
8365
            if( !method_domainCompatibleTest_depth_7( parent_domain_idkey , pdomain,depth+1) ) then
8366
                 close cur1;
8367
                 return 0;
8368
            end if;
8369
            set itor = itor + 1;
8370
        end while;
8371
        close cur1;
8372

    
8373
        open cur2;
8374
        set itor = 0;
8375
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8376
        while itor < cnt do
8377
            fetch cur2 into pdomain;
8378
            if( !method_domainCompatibleTest_depth_7( domain_idkey , pdomain,depth+1) ) then
8379
                    close cur2;
8380
                    return 0;
8381
            end if;
8382
            set itor = itor + 1;
8383
        end while;
8384
        close cur2;
8385

    
8386
        select count(*) into cnt from
8387
            (select type,code from method where domain_id=domain_idkey) as a
8388
            join
8389
            (select type,code from method where domain_id=parent_domain_idkey) as b
8390
            on a.type=b.type and a.code = b.code;
8391

    
8392
         if( cnt > 0) then
8393
            return 0;
8394
         end if;
8395

    
8396
         return 1;
8397
END//
8398
DELIMITER ;
8399

    
8400
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_7 구조 내보내기
8401
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_7`;
8402
DELIMITER //
8403
CREATE FUNCTION `method_domainCompatibleTest_depth_7`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8404
BEGIN
8405
        declare cnt int;
8406
        declare itor int default 0;
8407
        declare pdomain int;
8408

    
8409
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8410
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8411

    
8412

    
8413
        if( domain_idkey = parent_domain_idkey) then
8414
            return 1;
8415
        end if;
8416

    
8417
        open cur1;
8418
        set itor = 0;
8419
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8420
        while itor < cnt do
8421
            fetch cur1 into pdomain;
8422
            if( !method_domainCompatibleTest_depth_8( parent_domain_idkey , pdomain,depth+1) ) then
8423
                 close cur1;
8424
                 return 0;
8425
            end if;
8426
            set itor = itor + 1;
8427
        end while;
8428
        close cur1;
8429

    
8430
        open cur2;
8431
        set itor = 0;
8432
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8433
        while itor < cnt do
8434
            fetch cur2 into pdomain;
8435
            if( !method_domainCompatibleTest_depth_8( domain_idkey , pdomain,depth+1) ) then
8436
                    close cur2;
8437
                    return 0;
8438
            end if;
8439
            set itor = itor + 1;
8440
        end while;
8441
        close cur2;
8442

    
8443
        select count(*) into cnt from
8444
            (select type,code from method where domain_id=domain_idkey) as a
8445
            join
8446
            (select type,code from method where domain_id=parent_domain_idkey) as b
8447
            on a.type=b.type and a.code = b.code;
8448

    
8449
         if( cnt > 0) then
8450
            return 0;
8451
         end if;
8452

    
8453
         return 1;
8454
END//
8455
DELIMITER ;
8456

    
8457
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_8 구조 내보내기
8458
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_8`;
8459
DELIMITER //
8460
CREATE FUNCTION `method_domainCompatibleTest_depth_8`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8461
BEGIN
8462
        declare cnt int;
8463
        declare itor int default 0;
8464
        declare pdomain int;
8465

    
8466
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8467
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8468

    
8469

    
8470
        if( domain_idkey = parent_domain_idkey) then
8471
            return 1;
8472
        end if;
8473

    
8474
        open cur1;
8475
        set itor = 0;
8476
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8477
        while itor < cnt do
8478
            fetch cur1 into pdomain;
8479
            if( !method_domainCompatibleTest_depth_9( parent_domain_idkey , pdomain,depth+1) ) then
8480
                 close cur1;
8481
                 return 0;
8482
            end if;
8483
            set itor = itor + 1;
8484
        end while;
8485
        close cur1;
8486

    
8487
        open cur2;
8488
        set itor = 0;
8489
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8490
        while itor < cnt do
8491
            fetch cur2 into pdomain;
8492
            if( !method_domainCompatibleTest_depth_9( domain_idkey , pdomain,depth+1) ) then
8493
                    close cur2;
8494
                    return 0;
8495
            end if;
8496
            set itor = itor + 1;
8497
        end while;
8498
        close cur2;
8499

    
8500
        select count(*) into cnt from
8501
            (select type,code from method where domain_id=domain_idkey) as a
8502
            join
8503
            (select type,code from method where domain_id=parent_domain_idkey) as b
8504
            on a.type=b.type and a.code = b.code;
8505

    
8506
         if( cnt > 0) then
8507
            return 0;
8508
         end if;
8509

    
8510
         return 1;
8511
END//
8512
DELIMITER ;
8513

    
8514
-- 함수 nerv_icde_test.method_domainCompatibleTest_depth_9 구조 내보내기
8515
DROP FUNCTION IF EXISTS `method_domainCompatibleTest_depth_9`;
8516
DELIMITER //
8517
CREATE FUNCTION `method_domainCompatibleTest_depth_9`(domain_idkey int, parent_domain_idkey int , depth int ) RETURNS tinyint(1)
8518
BEGIN
8519
        declare cnt int;
8520
        declare itor int default 0;
8521
        declare pdomain int;
8522

    
8523
        DECLARE cur1 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=domain_idkey;
8524
        DECLARE cur2 CURSOR FOR SELECT parent_domain_id FROM inheritance_method_method where domain_id=parent_domain_idkey;
8525

    
8526

    
8527
        if( domain_idkey = parent_domain_idkey) then
8528
            return 1;
8529
        end if;
8530

    
8531
        open cur1;
8532
        set itor = 0;
8533
        select count(*) into cnt from inheritance_method_method where domain_id=domain_idkey;
8534
        while itor < cnt do
8535
            fetch cur1 into pdomain;
8536
            if( !method_domainCompatibleTest_depth_10( parent_domain_idkey , pdomain,depth+1) ) then
8537
                 close cur1;
8538
                 return 0;
8539
            end if;
8540
            set itor = itor + 1;
8541
        end while;
8542
        close cur1;
8543

    
8544
        open cur2;
8545
        set itor = 0;
8546
        select count(*) into cnt from inheritance_method_method where domain_id=parent_domain_idkey;
8547
        while itor < cnt do
8548
            fetch cur2 into pdomain;
8549
            if( !method_domainCompatibleTest_depth_10( domain_idkey , pdomain,depth+1) ) then
8550
                    close cur2;
8551
                    return 0;
8552
            end if;
8553
            set itor = itor + 1;
8554
        end while;
8555
        close cur2;
8556

    
8557
        select count(*) into cnt from
8558
            (select type,code from method where domain_id=domain_idkey) as a
8559
            join
8560
            (select type,code from method where domain_id=parent_domain_idkey) as b
8561
            on a.type=b.type and a.code = b.code;
8562

    
8563
         if( cnt > 0) then
8564
            return 0;
8565
         end if;
8566

    
8567
         return 1;
8568
END//
8569
DELIMITER ;
8570

    
8571
-- 함수 nerv_icde_test.newDomainTest 구조 내보내기
8572
DROP FUNCTION IF EXISTS `newDomainTest`;
8573
DELIMITER //
8574
CREATE FUNCTION `newDomainTest`() RETURNS tinyint(1)
8575
BEGIN
8576
        declare nd bool;
8577
        set nd = false;
8578
        select newdomain into nd from users where user_id=@nervuser;
8579
        return nd;
8580
END//
8581
DELIMITER ;
8582

    
8583
-- 함수 nerv_icde_test.return_domainid 구조 내보내기
8584
DROP FUNCTION IF EXISTS `return_domainid`;
8585
DELIMITER //
8586
CREATE FUNCTION `return_domainid`(in_domainname int, in_upperid int, in_domaintype varchar(100)) RETURNS int(1)
8587
BEGIN
8588
        declare cnt int(1);
8589
        set cnt = 0;
8590

    
8591
        if(in_domaintype ='data') then
8592
                         select id into cnt from domain_data where name=in_domainname and upper_id=in_upperid;
8593
        end if;
8594
        if(in_domaintype ='method') then
8595
                         select id into cnt from domain_method where name=in_domainname and upper_id=in_upperid;
8596
        end if;
8597
                if(in_domaintype ='system') then
8598
                         select id into cnt from domain_system where name=in_domainname and upper_id=in_upperid;
8599
        end if;
8600

    
8601
        return cnt;
8602
END//
8603
DELIMITER ;
8604

    
8605
-- 함수 nerv_icde_test.return_proxy_interface id 구조 내보내기
8606
DROP FUNCTION IF EXISTS `return_proxy_interface id`;
8607
DELIMITER //
8608
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
8609
BEGIN
8610
        declare interface_key_id int unsigned;
8611
        set interface_key_id=0;
8612

    
8613
        select count(*) into interface_key_id from proxy_interface_relation
8614
         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;
8615

    
8616
      if interface_key_id>0 then
8617
        return 1;
8618
      else
8619
          return 0;
8620
      end if;
8621
END//
8622
DELIMITER ;
8623

    
8624
-- 함수 nerv_icde_test.supermanagerTest 구조 내보내기
8625
DROP FUNCTION IF EXISTS `supermanagerTest`;
8626
DELIMITER //
8627
CREATE FUNCTION `supermanagerTest`(useridkey varchar(100)) RETURNS tinyint(1)
8628
BEGIN
8629
        declare sm bool;
8630
        select supermanager into sm from users where user_id=useridkey;
8631
        return sm;
8632
END//
8633
DELIMITER ;
8634

    
8635
-- 함수 nerv_icde_test.updata_data_real_data_auto_id 구조 내보내기
8636
DROP FUNCTION IF EXISTS `updata_data_real_data_auto_id`;
8637
DELIMITER //
8638
CREATE FUNCTION `updata_data_real_data_auto_id`() RETURNS int(11)
8639
BEGIN
8640

    
8641
update data d,
8642
(select a.data_auto_id as auto_id, b.data_auto_id from
8643
	(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
8644
	join
8645
	(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
8646
)as f
8647
set d.real_data_auto_id = f.data_auto_id
8648
where d.data_auto_id = f.auto_id;
8649

    
8650
return 0;
8651
END//
8652
DELIMITER ;
8653

    
8654
-- 함수 nerv_icde_test.update_data_field_table_data_auto_id 구조 내보내기
8655
DROP FUNCTION IF EXISTS `update_data_field_table_data_auto_id`;
8656
DELIMITER //
8657
CREATE FUNCTION `update_data_field_table_data_auto_id`() RETURNS int(11)
8658
BEGIN
8659
update data_field d,
8660
(select a.domain_id, a.data_name as name, b.data_auto_id as data_id from
8661
	(select * from data_field) as a
8662
	join
8663
	(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
8664
)as f
8665
set d.data_auto_id=f.data_id
8666
where d.domain_id=f.domain_id and d.data_name=f.name;
8667

    
8668
return 0;
8669
END//
8670
DELIMITER ;
8671

    
8672
-- 함수 nerv_icde_test.update_data_field_table_real_data_id 구조 내보내기
8673
DROP FUNCTION IF EXISTS `update_data_field_table_real_data_id`;
8674
DELIMITER //
8675
CREATE FUNCTION `update_data_field_table_real_data_id`() RETURNS int(11)
8676
BEGIN
8677

    
8678
 update data_field d,
8679
 (
8680
	select a.data_auto_id, a.member_name,b.data_auto_id as data_id from
8681
	(select * from data_field) as a
8682
	join
8683
	(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
8684
 )as f
8685
 	set d.real_data_auto_id=f.data_id
8686
 	where d.data_auto_id=f.data_auto_id and d.member_name=f.member_name;
8687

    
8688
 	return 0;
8689
END//
8690
DELIMITER ;
8691

    
8692
-- 함수 nerv_icde_test.update_method_table_data_auto_id 구조 내보내기
8693
DROP FUNCTION IF EXISTS `update_method_table_data_auto_id`;
8694
DELIMITER //
8695
CREATE FUNCTION `update_method_table_data_auto_id`() RETURNS int(11)
8696
BEGIN
8697

    
8698
update method c,
8699
 (
8700
	select a.domain_id as method_domain_id,a.name as method_name, a.in_domain_id, a.in_data, b.* from
8701
	(select * from method) as a
8702
	join
8703
	(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
8704
 )as f
8705
 set c.in_data_auto_id=f.data_auto_id
8706
 where c.domain_id=f.method_domain_id and c.name=f.method_name ;
8707

    
8708

    
8709
 update method c,
8710
 (
8711
	select a.domain_id as method_domain_id,a.name as method_name, a.out_domain_id, a.out_data, b.* from
8712
	(select * from method) as a
8713
	join
8714
	(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
8715
 )as f
8716
 set c.out_data_auto_id=f.data_auto_id
8717
 where c.domain_id=f.method_domain_id and c.name=f.method_name ;
8718

    
8719
 return 0;
8720

    
8721
END//
8722
DELIMITER ;
8723

    
8724
-- 뷰 nerv_icde_test.view_a 구조 내보내기
8725
DROP VIEW IF EXISTS `view_a`;
8726
-- 임시 테이블을 제거하고 최종 VIEW 구조를 생성
8727
DROP TABLE IF EXISTS `view_a`;
8728
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));
8729

    
8730
-- 뷰 nerv_icde_test.view_b 구조 내보내기
8731
DROP VIEW IF EXISTS `view_b`;
8732
-- 임시 테이블을 제거하고 최종 VIEW 구조를 생성
8733
DROP TABLE IF EXISTS `view_b`;
8734
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));
8735

    
8736
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
8737
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
8738
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
8739
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
(2-2/8)