forked from opensourceautomation/Open-Source-Automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
osae_038.sql
3741 lines (3580 loc) · 198 KB
/
osae_038.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Script was generated by Devart dbForge Studio for MySQL, Version 5.0.67.0
-- Product home page: http://www.devart.com/dbforge/mysql/studio
-- Script date 5/30/2012 6:21:05 PM
-- Server version: 5.1.61-community
-- Client version: 4.1
--
-- Disable foreign keys
--
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
--
-- Set character set the client will use to send SQL statements to the server
--
SET NAMES 'utf8';
--
-- Definition for database osae
--
DROP DATABASE IF EXISTS osae;
CREATE DATABASE osae
CHARACTER SET latin1
COLLATE latin1_swedish_ci;
--
-- Set default database
--
USE osae;
--
-- Definition for table osae_debug_log
--
CREATE TABLE osae_debug_log (
log_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
log_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
entry VARCHAR(255) NOT NULL,
debug_trace VARCHAR(2000) DEFAULT NULL,
PRIMARY KEY (log_id)
)
ENGINE = INNODB
AUTO_INCREMENT = 3984370
AVG_ROW_LENGTH = 91
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_pattern
--
CREATE TABLE osae_object_pattern (
object_pattern_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
object_id INT(10) UNSIGNED DEFAULT NULL,
pattern_id INT(10) UNSIGNED DEFAULT NULL,
PRIMARY KEY (object_pattern_id)
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_type
--
CREATE TABLE osae_object_type (
object_type_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
object_type VARCHAR(100) NOT NULL,
object_type_description VARCHAR(200) DEFAULT NULL,
plugin_object_id INT(10) UNSIGNED ZEROFILL DEFAULT NULL,
system_hidden TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
object_type_owner TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
base_type_id INT(10) UNSIGNED ZEROFILL DEFAULT NULL,
container TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
hide_redundant_events TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY (object_type_id),
UNIQUE INDEX osae_object_types_unq_type (object_type)
)
ENGINE = INNODB
AUTO_INCREMENT = 100
AVG_ROW_LENGTH = 315
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_pattern
--
CREATE TABLE osae_pattern (
pattern_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
pattern VARCHAR(400) DEFAULT NULL,
script TEXT DEFAULT NULL,
PRIMARY KEY (pattern_id)
)
ENGINE = INNODB
AUTO_INCREMENT = 19
AVG_ROW_LENGTH = 910
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_pattern_match
--
CREATE TABLE osae_pattern_match (
match_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
pattern_id INT(10) UNSIGNED NOT NULL,
`match` VARCHAR(400) NOT NULL,
PRIMARY KEY (match_id)
)
ENGINE = INNODB
AUTO_INCREMENT = 54
AVG_ROW_LENGTH = 327
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_type_event
--
CREATE TABLE osae_object_type_event (
event_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
event_name VARCHAR(200) NOT NULL,
event_label VARCHAR(200) DEFAULT NULL,
object_type_id INT(10) UNSIGNED ZEROFILL NOT NULL,
PRIMARY KEY (event_id),
INDEX osae_fk_events_to_object_type (object_type_id),
UNIQUE INDEX osae_object_type_events_unq (event_name, object_type_id),
CONSTRAINT osae_fk_events_to_object_type FOREIGN KEY (object_type_id)
REFERENCES osae_object_type(object_type_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 133
AVG_ROW_LENGTH = 202
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_type_method
--
CREATE TABLE osae_object_type_method (
method_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
method_name VARCHAR(200) DEFAULT NULL,
method_label VARCHAR(200) NOT NULL,
object_type_id INT(10) UNSIGNED ZEROFILL NOT NULL,
param_1_label VARCHAR(100) DEFAULT NULL,
param_2_label VARCHAR(200) DEFAULT NULL,
param_1_default VARCHAR(512) DEFAULT NULL,
param_2_default VARCHAR(512) DEFAULT NULL,
PRIMARY KEY (method_id),
INDEX osae_fk_methods_to_object_type (object_type_id),
UNIQUE INDEX osae_object_type_methods_unq (method_name, object_type_id),
CONSTRAINT osae_fk_methods_to_object_type FOREIGN KEY (object_type_id)
REFERENCES osae_object_type(object_type_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 193
AVG_ROW_LENGTH = 156
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_type_property
--
CREATE TABLE osae_object_type_property (
property_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
property_name VARCHAR(200) NOT NULL,
property_datatype VARCHAR(50) NOT NULL,
property_default VARCHAR(255) DEFAULT NULL,
object_type_id INT(10) UNSIGNED ZEROFILL NOT NULL,
track_history TINYINT(1) NOT NULL DEFAULT 1,
PRIMARY KEY (property_id),
INDEX oase_fk_properties_to_object_type (object_type_id),
UNIQUE INDEX osae_object_type_properties_unq (property_name, object_type_id),
CONSTRAINT oase_fk_properties_to_object_type FOREIGN KEY (object_type_id)
REFERENCES osae_object_type(object_type_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 693
AVG_ROW_LENGTH = 53
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_type_state
--
CREATE TABLE osae_object_type_state (
state_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
state_name VARCHAR(20) NOT NULL,
state_label VARCHAR(50) DEFAULT NULL,
object_type_id INT(10) UNSIGNED ZEROFILL NOT NULL,
PRIMARY KEY (state_id),
INDEX osae_fk_states_to_object_type (object_type_id),
UNIQUE INDEX osae_object_type_states_unq (state_name, object_type_id),
CONSTRAINT osae_fk_states_to_object_type FOREIGN KEY (object_type_id)
REFERENCES osae_object_type(object_type_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 124
AVG_ROW_LENGTH = 224
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object
--
CREATE TABLE osae_object (
object_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
object_name VARCHAR(100) NOT NULL,
object_description VARCHAR(200) DEFAULT NULL,
state_id INT(10) UNSIGNED ZEROFILL DEFAULT NULL,
object_type_id INT(10) UNSIGNED ZEROFILL NOT NULL,
object_value VARCHAR(50) DEFAULT NULL,
address VARCHAR(300) DEFAULT NULL,
container_id INT(10) UNSIGNED ZEROFILL DEFAULT NULL,
enabled TINYINT(1) UNSIGNED DEFAULT 1,
last_updated DATETIME DEFAULT NULL,
last_state_change DATETIME DEFAULT NULL,
PRIMARY KEY (object_id),
INDEX osae_fk_objects_to_container (container_id),
INDEX osae_fk_objects_to_object_types (object_type_id),
INDEX osae_fk_objects_to_type_state (state_id),
UNIQUE INDEX osae_object_unq (object_name),
CONSTRAINT osae_fk_objects_to_container FOREIGN KEY (container_id)
REFERENCES osae_object(object_id) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT osae_fk_objects_to_object_types FOREIGN KEY (object_type_id)
REFERENCES osae_object_type(object_type_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_objects_to_type_state FOREIGN KEY (state_id)
REFERENCES osae_object_type_state(state_id) ON DELETE SET NULL ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 1115
AVG_ROW_LENGTH = 2048
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_type_property_option
--
CREATE TABLE osae_object_type_property_option (
option_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
option_name VARCHAR(200) NOT NULL,
property_id INT(10) UNSIGNED ZEROFILL NOT NULL,
PRIMARY KEY (option_id),
INDEX oase_fk_options_to_object_type_property (property_id),
UNIQUE INDEX osae_object_type_property_options_unq (option_name, property_id),
CONSTRAINT oase_fk_options_to_object_type_property FOREIGN KEY (property_id)
REFERENCES osae_object_type_property(property_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 7
AVG_ROW_LENGTH = 2730
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_event_log
--
CREATE TABLE osae_event_log (
event_log_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
object_id INT(10) UNSIGNED ZEROFILL NOT NULL,
event_id INT(10) UNSIGNED ZEROFILL NOT NULL,
log_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
from_object_id INT(10) UNSIGNED DEFAULT NULL,
debug_trace VARCHAR(2000) DEFAULT NULL,
PRIMARY KEY (event_log_id),
INDEX osae_fk_events_log_to_events (event_id),
INDEX osae_fk_events_log_to_objects (object_id),
CONSTRAINT osae_fk_events_log_to_events FOREIGN KEY (event_id)
REFERENCES osae_object_type_event(event_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_events_log_to_objects FOREIGN KEY (object_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_method_log
--
CREATE TABLE osae_method_log (
method_log_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
entry_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
object_id INT(10) UNSIGNED ZEROFILL NOT NULL,
method_id INT(10) UNSIGNED ZEROFILL NOT NULL,
parameter_1 VARCHAR(1024) DEFAULT NULL,
parameter_2 VARCHAR(1024) DEFAULT NULL,
from_object_id INT(10) UNSIGNED DEFAULT NULL,
debug_trace VARCHAR(2000) DEFAULT NULL,
PRIMARY KEY (method_log_id),
INDEX osae_method_log_index02 (method_id),
INDEX osae_method_log_index03 (object_id),
CONSTRAINT osae_fk_method_log_to_method FOREIGN KEY (method_id)
REFERENCES osae_object_type_method(method_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_method_log_to_object FOREIGN KEY (object_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_method_queue
--
CREATE TABLE osae_method_queue (
method_queue_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
entry_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
object_id INT(10) UNSIGNED ZEROFILL NOT NULL,
method_id INT(10) UNSIGNED ZEROFILL NOT NULL,
parameter_1 VARCHAR(1024) DEFAULT NULL,
parameter_2 VARCHAR(1024) DEFAULT NULL,
from_object_id INT(10) UNSIGNED DEFAULT NULL,
debug_trace VARCHAR(2000) DEFAULT NULL,
PRIMARY KEY (method_queue_id),
INDEX osae_fk_methods_queue_to_methods (method_id),
INDEX osae_fk_methods_queue_to_objects (object_id),
CONSTRAINT osae_fk_methods_queue_to_methods FOREIGN KEY (method_id)
REFERENCES osae_object_type_method(method_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_methods_queue_to_objects FOREIGN KEY (object_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_event_script
--
CREATE TABLE osae_object_event_script (
event_script_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
object_id INT(10) UNSIGNED ZEROFILL NOT NULL,
event_id INT(10) UNSIGNED ZEROFILL NOT NULL,
event_script TEXT NOT NULL,
PRIMARY KEY (event_script_id),
INDEX osae_fk_object_script_to_events (event_id),
INDEX osae_fk_object_script_to_object (object_id),
UNIQUE INDEX osae_object_event_script_unq (object_id, event_id),
CONSTRAINT osae_fk_object_script_to_events FOREIGN KEY (event_id)
REFERENCES osae_object_type_event(event_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_object_script_to_object FOREIGN KEY (object_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 24
AVG_ROW_LENGTH = 4096
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_property
--
CREATE TABLE osae_object_property (
object_property_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
object_id INT(10) UNSIGNED ZEROFILL NOT NULL,
object_type_property_id INT(10) UNSIGNED ZEROFILL NOT NULL,
property_value VARCHAR(255) DEFAULT NULL,
last_updated DATETIME DEFAULT NULL,
property_image MEDIUMBLOB DEFAULT NULL,
PRIMARY KEY (object_property_id),
INDEX osae_fk_object_property_to_object_type (object_type_property_id),
UNIQUE INDEX osae_object_property_index_unq (object_id, object_type_property_id),
CONSTRAINT osae_fk_object_property_to_object FOREIGN KEY (object_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_object_property_to_object_type FOREIGN KEY (object_type_property_id)
REFERENCES osae_object_type_property(property_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 2615
AVG_ROW_LENGTH = 341
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_state_history
--
CREATE TABLE osae_object_state_history (
object_id INT(10) UNSIGNED NOT NULL,
state_id INT(10) UNSIGNED NOT NULL,
times_this_hour INT(10) UNSIGNED NOT NULL DEFAULT 0,
times_this_day INT(10) UNSIGNED NOT NULL DEFAULT 0,
times_this_month INT(10) UNSIGNED NOT NULL DEFAULT 0,
times_this_year INT(10) UNSIGNED NOT NULL DEFAULT 0,
times_ever INT(10) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (object_id, state_id),
INDEX osae_fk_object_state_to_state (state_id),
CONSTRAINT osae_fk_object_state_to_object FOREIGN KEY (object_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_object_state_to_state FOREIGN KEY (state_id)
REFERENCES osae_object_type_state(state_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AVG_ROW_LENGTH = 2048
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_schedule_queue
--
CREATE TABLE osae_schedule_queue (
schedule_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
queue_datetime DATETIME DEFAULT NULL,
object_id INT(10) UNSIGNED DEFAULT NULL,
method_id INT(10) UNSIGNED DEFAULT NULL,
parameter_1 VARCHAR(200) DEFAULT NULL,
parameter_2 VARCHAR(200) DEFAULT NULL,
recurring_id INT(10) UNSIGNED DEFAULT NULL,
pattern_id INT(10) UNSIGNED DEFAULT NULL,
PRIMARY KEY (schedule_id),
INDEX osae_fk_schedule_pattern_to_pattern_id (pattern_id),
INDEX schedule_queue_Index02 (method_id),
INDEX schedule_queue_Index03 (object_id),
INDEX schedule_queue_Index04 (recurring_id),
CONSTRAINT osae_fk_schedule_method_to_method_id FOREIGN KEY (method_id)
REFERENCES osae_object_type_method(method_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_schedule_object_to_object FOREIGN KEY (object_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_schedule_pattern_to_pattern_id FOREIGN KEY (pattern_id)
REFERENCES osae_pattern(pattern_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_schedule_recurring
--
CREATE TABLE osae_schedule_recurring (
recurring_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
object_id INT(10) UNSIGNED DEFAULT NULL,
method_id INT(10) UNSIGNED DEFAULT NULL,
parameter_1 VARCHAR(200) DEFAULT NULL,
parameter_2 VARCHAR(200) DEFAULT NULL,
recurring_time TIME NOT NULL DEFAULT '00:00:01',
monday TINYINT(1) UNSIGNED DEFAULT NULL,
tuesday TINYINT(1) UNSIGNED DEFAULT NULL,
wednesday TINYINT(1) UNSIGNED DEFAULT NULL,
thursday TINYINT(1) UNSIGNED DEFAULT NULL,
friday TINYINT(1) UNSIGNED DEFAULT NULL,
saturday TINYINT(1) UNSIGNED DEFAULT NULL,
sunday TINYINT(1) UNSIGNED DEFAULT NULL,
interval_unit CHAR(1) NOT NULL DEFAULT 'W',
recurring_minutes INT(8) UNSIGNED DEFAULT NULL,
recurring_day INT(4) UNSIGNED DEFAULT NULL,
recurring_date DATE DEFAULT NULL,
pattern_id INT(10) UNSIGNED DEFAULT NULL,
schedule_name VARCHAR(100) DEFAULT NULL,
PRIMARY KEY (recurring_id),
INDEX osa_fk_recurring_object_to_object_id (object_id),
INDEX osae_fk_recurring_method_to_method_id (method_id),
INDEX osae_fk_recurring_pattern_to_pattern_id (pattern_id),
UNIQUE INDEX osae_schedule_recurring_unq (schedule_name),
CONSTRAINT osa_fk_recurring_object_to_object_id FOREIGN KEY (object_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_recurring_method_to_method_id FOREIGN KEY (method_id)
REFERENCES osae_object_type_method(method_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_recurring_pattern_to_pattern_id FOREIGN KEY (pattern_id)
REFERENCES osae_pattern(pattern_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_screen_object
--
CREATE TABLE osae_screen_object (
screen_object_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
screen_id INT(10) UNSIGNED ZEROFILL NOT NULL,
object_id INT(10) UNSIGNED ZEROFILL NOT NULL,
control_id INT(10) UNSIGNED ZEROFILL NOT NULL,
PRIMARY KEY (screen_object_id),
INDEX osae_fk_screen_object_to_object (object_id),
INDEX osae_fk_screen_object_to_object_type (control_id),
INDEX osae_fk_screen_screen_to_object (screen_id),
CONSTRAINT osae_fk_screen_control_to_object FOREIGN KEY (control_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_screen_object_to_object FOREIGN KEY (object_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT osae_fk_screen_screen_to_object FOREIGN KEY (screen_id)
REFERENCES osae_object(object_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_property_array
--
CREATE TABLE osae_object_property_array (
property_array_id INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
object_property_id INT(10) UNSIGNED ZEROFILL NOT NULL,
item_name VARCHAR(2000) NOT NULL,
item_label VARCHAR(400) DEFAULT NULL,
PRIMARY KEY (property_array_id),
INDEX osae_fk_property_array_to_object_property (object_property_id),
CONSTRAINT osae_fk_property_array_to_object_property FOREIGN KEY (object_property_id)
REFERENCES osae_object_property(object_property_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 277
AVG_ROW_LENGTH = 134
CHARACTER SET utf8
COLLATE utf8_general_ci;
--
-- Definition for table osae_object_property_history
--
CREATE TABLE osae_object_property_history (
history_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
history_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
object_property_id INT(10) UNSIGNED NOT NULL,
property_value VARCHAR(4000) NOT NULL,
PRIMARY KEY (history_id),
INDEX osae_fk_object_property_history_to_object_property (object_property_id),
CONSTRAINT osae_fk_object_property_history_to_object_property FOREIGN KEY (object_property_id)
REFERENCES osae_object_property(object_property_id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
DELIMITER $$
--
-- Definition for procedure osae_object_name_get_by_address
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_object_name_get_by_address(
IN paddress varchar(400)
)
BEGIN
SELECT object_name FROM osae_object WHERE address=paddress;
END
$$
--
-- Definition for procedure osae_sp_debug_log_add
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_debug_log_add(IN pentry varchar(200), IN pdebugtrace varchar(200))
BEGIN
IF ISNULL(pentry) = FALSE THEN
INSERT INTO osae_debug_log(entry,debug_trace) VALUES(pentry,pdebugtrace);
END IF;
END
$$
--
-- Definition for procedure osae_sp_event_log_add
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_event_log_add(
IN pobject varchar(200),
IN pevent varchar(200),
IN pfromobject varchar(200),
IN pdebuginfo varchar(1000)
)
BEGIN
DECLARE vObjectCount INT;
DECLARE vObjectID INT;
DECLARE vObjectTypeID INT;
DECLARE vEventCount INT;
DECLARE vEventID INT;
DECLARE vFromObjectID INT DEFAULT NULL;
DECLARE vFromObjectCount INT;
DECLARE vDebugTrace VARCHAR(2000);
SET vDebugTrace = CONCAT(COALESCE(pdebuginfo,''),' -> osae_sp_event_log_add');
SELECT object_id INTO vFromObjectID FROM osae_object WHERE UPPER(object_name)=UPPER(pfromobject);
SELECT COUNT(object_id) INTO vObjectCount FROM osae_object WHERE UPPER(object_name)=UPPER(pobject);
IF vObjectCount > 0 THEN
SELECT object_id,object_type_id INTO vObjectID,vObjectTypeID FROM osae_object WHERE UPPER(object_name)=UPPER(pobject);
SELECT COUNT(event_id) INTO vEventCount FROM osae_object_type_event WHERE object_type_id=vObjectTypeID AND UPPER(event_name)=UPPER(pevent);
IF vEventCount = 1 THEN
CALL osae_sp_debug_log_add(CONCAT('Event_Log_add (',pobject,' ',pevent,') ',pfromobject,' vFromObjectID ',COALESCE(vFromObjectID,'NULL')),vDebugTrace);
SELECT event_id INTO vEventID FROM osae_object_type_event WHERE object_type_id=vObjectTypeID AND UPPER(event_name)=UPPER(pevent);
INSERT INTO osae_event_log (object_id,event_id,from_object_id,debug_trace) VALUES(vObjectID,vEventID,vFromObjectID,vDebugTrace);
END IF;
END IF;
END
$$
--
-- Definition for procedure osae_sp_event_log_clear
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_event_log_clear()
BEGIN
DELETE FROM osae_event_log;
DELETE FROM osae_debug_log;
DELETE FROM osae_method_log;
END
$$
--
-- Definition for procedure osae_sp_method_queue_add
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_method_queue_add(
IN pobject varchar(200),
IN pmethod varchar(200),
IN pparameter1 varchar(1024),
IN pparameter2 varchar(1024),
IN pfromobject varchar(200),
IN pdebuginfo varchar(1000)
)
BEGIN
DECLARE vObjectCount INT;
DECLARE vObjectID INT;
DECLARE vObjectTypeID INT;
DECLARE vMethodCount INT;
DECLARE vMethodID INT;
DECLARE vSystemCount INT;
DECLARE vObjectName VARCHAR(200);
DECLARE vObjectType VARCHAR(200);
DECLARE vBaseType VARCHAR(200);
DECLARE vFromObjectID INT DEFAULT NULL;
DECLARE vFromObjectCount INT;
DECLARE vStateCount INT;
DECLARE vDebugTrace VARCHAR(1000);
DECLARE vPropertyCount INT;
DECLARE vMethod VARCHAR(200);
SET max_sp_recursion_depth = 10;
SET vDebugTrace = CONCAT(pdebuginfo,' -> osae_sp_method_queue_add');
SELECT object_id INTO vFromObjectID FROM osae_object WHERE UPPER(object_name)=UPPER(pfromobject);
SELECT COUNT(object_id) INTO vObjectCount FROM osae_object WHERE UPPER(object_name)=UPPER(pobject);
IF vObjectCount = 1 THEN
SELECT object_id,object_type_id INTO vObjectID,vObjectTypeID FROM osae_object WHERE UPPER(object_name)=UPPER(pobject);
SELECT COUNT(method_id) INTO vMethodCount FROM osae_object_type_method WHERE object_type_id=vObjectTypeID AND (UPPER(method_name)=UPPER(pmethod) OR UPPER(method_label)=UPPER(pmethod));
IF vMethodCount > 0 THEN
SELECT method_id INTO vMethodID FROM osae_object_type_method WHERE object_type_id=vObjectTypeID AND (UPPER(method_name)=UPPER(pmethod) OR UPPER(method_label)=UPPER(pmethod));
# Check to see if an app owns this, or SYSTEM, if system owns we will have to handle events....
SELECT count(object_id) INTO vSystemCount FROM osae_v_object WHERE object_id=vObjectID AND owned_by='SYSTEM';
IF vSystemCount = 1 THEN
SELECT object_name,object_type,base_type INTO vObjectName,vObjectType,vBaseType FROM osae_v_object WHERE object_id=vObjectID;
SELECT method_name INTO vMethod FROM osae_object_type_method WHERE method_id=vMethodID;
# Here is the magic, if the Method Name matches a State, then the Method's Job is to Set that State, so look up the state
SELECT count(state_name) INTO vStateCount FROM osae_v_object_type_state WHERE UPPER(state_name)=UPPER(vMethod) AND object_type=vObjectType;
IF vStateCount = 1 THEN
CALL osae_sp_object_state_set (vObjectName,vMethod,pfromobject,vDebugTrace);
ELSE
SELECT count(property_name) INTO vPropertyCount FROM osae_v_object_type_property WHERE UPPER(property_name)=UPPER(vMethod) AND object_type=vObjectType;
IF vPropertyCount = 1 THEN
CALL osae_sp_object_property_set (vObjectName,vMethod,pparameter1,pfromobject,vDebugTrace);
END IF;
END IF;
ELSE
INSERT INTO osae_method_queue (object_id,method_id,parameter_1,parameter_2,from_object_id,debug_trace) VALUES(vObjectID,vMethodID,pparameter1,pparameter2,vFromObjectID,vDebugTrace);
END IF;
END IF;
END IF;
END
$$
--
-- Definition for procedure osae_sp_method_queue_delete
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_method_queue_delete(
IN pmethodid int
)
BEGIN
DELETE FROM osae_method_queue WHERE method_queue_id=pmethodid;
END
$$
--
-- Definition for procedure osae_sp_object_add
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_add(IN pname VARCHAR(200),
IN pdescription VARCHAR(200),
IN pobjecttype VARCHAR(200),
IN paddress VARCHAR(200),
IN pcontainer VARCHAR(200),
IN penabled TINYINT(1),
OUT results INTEGER
)
BEGIN
DECLARE vObjectCount INT;
DECLARE vObjectTypeCount INT;
DECLARE iContainer INT;
DECLARE iObjectID INT;
DECLARE vObjectTypeID INT;
DECLARE vContainerCount INT;
DECLARE vContainerID INT DEFAULT NULL;
SET results = 1;
SELECT count(object_type_id) INTO vObjectTypeCount FROM osae_object_type WHERE object_type = pobjecttype;
IF vObjectTypeCount > 0 THEN
SELECT object_type_id, container INTO vObjectTypeID, iContainer FROM osae_object_type WHERE object_type = pobjecttype;
SELECT count(object_id) INTO vContainerCount FROM osae_v_object WHERE object_name = pcontainer AND container = 1;
IF vContainerCount = 1 THEN
SELECT object_id INTO vContainerID FROM osae_v_object WHERE object_name = pcontainer AND container = 1;
END IF;
SELECT count(object_id) INTO vObjectCount FROM osae_object WHERE upper(object_name) = upper(pname) OR (upper(address) = upper(paddress) AND address IS NOT NULL AND address <> '');
IF vObjectCount = 0 THEN
INSERT INTO osae_object (object_name, object_description, object_type_id, address, container_id, enabled) VALUES (pname, pdescription, vObjectTypeID, paddress, vContainerID, penabled);
ELSE
CALL osae_sp_debug_log_add(concat('Object_Add Failed to Add ', pname, ' due to duplicate data.'), 'SYSTEM');
SET results = 3;
END IF;
IF iContainer = 1 THEN
SELECT object_id INTO iObjectID FROM osae_object WHERE object_name = pname;
UPDATE osae_object SET container_id = iObjectID WHERE object_id = iObjectID;
END IF;
ELSE
SET results = 2;
END IF;
END
$$
--
-- Definition for procedure osae_sp_object_delete
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_delete(
IN pname varchar(200)
)
BEGIN
DELETE FROM osae_object WHERE object_name=pname;
END
$$
--
-- Definition for procedure osae_sp_object_event_script_add
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_event_script_add(
IN pobject varchar(200),
IN pevent varchar(200),
IN ptext text
)
BEGIN
DECLARE vObjectCount INT;
DECLARE vObjectID INT;
DECLARE vObjectTypeID INT;
DECLARE vEventCount INT;
DECLARE vEventID INT;
SELECT COUNT(object_id) INTO vObjectCount FROM osae_object WHERE object_name=pobject;
IF vObjectCount > 0 THEN
SELECT object_id,object_type_id INTO vObjectID,vObjectTypeID FROM osae_object WHERE object_name=pobject;
SELECT COUNT(event_id) INTO vEventCount FROM osae_object_type_event WHERE object_type_id=vObjectTypeID AND (event_name=pevent OR event_label=pevent);
IF vEventCount = 1 THEN
SELECT event_id INTO vEventID FROM osae_object_type_event WHERE object_type_id=vObjectTypeID AND (event_name=pevent OR event_label=pevent);
INSERT INTO osae_object_event_script (object_id,event_id,event_script) VALUES(vObjectID,vEventID,ptext);
END IF;
END IF;
END
$$
--
-- Definition for procedure osae_sp_object_event_script_update
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_event_script_update(IN pobject varchar(200), IN pevent varchar(200), IN ptext text)
BEGIN
DECLARE vObjectCount INT;
DECLARE vObjectID INT;
DECLARE vObjectTypeID INT;
DECLARE vEventCount INT;
DECLARE vEventID INT;
SELECT COUNT(object_id) INTO vObjectCount FROM osae_object WHERE UPPER(object_name)=UPPER(pobject);
IF vObjectCount > 0 THEN
SELECT object_id,object_type_id INTO vObjectID,vObjectTypeID FROM osae_object WHERE UPPER(object_name)=UPPER(pobject);
SELECT COUNT(event_id) INTO vEventCount FROM osae_object_type_event WHERE object_type_id=vObjectTypeID AND (UPPER(event_name)=UPPER(pevent) OR UPPER(event_label)=UPPER(pevent));
IF vEventCount = 1 THEN
SELECT event_id INTO vEventID FROM osae_object_type_event WHERE object_type_id=vObjectTypeID AND (UPPER(event_name)=UPPER(pevent) OR UPPER(event_label)=UPPER(pevent));
UPDATE osae_object_event_script SET event_script=ptext WHERE object_id=vObjectID AND event_id=vEventID;
-- CALL osae_sp_debug_log_add(CONCAT('Updated ',vObjectID,' - ',vEventID,ptext),'');
END IF;
END IF;
END
$$
--
-- Definition for procedure osae_sp_object_property_array_add
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_property_array_add(
IN pobject varchar(200),
IN pproperty varchar(200),
IN pvalue varchar(1000),
IN plabel varchar(200)
)
BEGIN
DECLARE vObjectID INT;
DECLARE vObjectTypeID INT;
DECLARE vObjectPropertyID INT;
SELECT object_property_id INTO vObjectPropertyID FROM osae_v_object_property WHERE UPPER(object_name)=UPPER(pobject) AND UPPER(property_name)=UPPER(pproperty);
IF vObjectPropertyID IS NOT NULL Then
INSERT INTO osae_object_property_array (object_property_id,item_name,item_label) VALUES(vObjectPropertyID,pvalue,plabel);
END IF;
END
$$
--
-- Definition for procedure osae_sp_object_property_array_delete
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_property_array_delete(
IN pobject varchar(400),
IN pproperty varchar(400),
IN pvalue varchar(2000)
)
BEGIN
DECLARE vPropertyArrayID INT;
SELECT property_array_id INTO vPropertyArrayID FROM osae_v_object_property_array WHERE object_name=pobject AND property_name=pproperty AND item_name=pvalue;
DELETE FROM osae_object_property_array WHERE object_property_array_id=vPropertyArrayID;
END
$$
--
-- Definition for procedure osae_sp_object_property_array_delete_all
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_property_array_delete_all(
IN pobject varchar(400),
IN pproperty varchar(400)
)
BEGIN
DECLARE vPropertyID INT;
SELECT object_property_id INTO vPropertyID FROM osae_v_object_property WHERE object_name=pobject AND property_name=pproperty;
DELETE FROM osae_object_property_array WHERE object_property_id=vPropertyID;
END
$$
--
-- Definition for procedure osae_sp_object_property_array_get_all
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_property_array_get_all(IN pobject VARCHAR(255), IN pproperty VARCHAR(255))
BEGIN
SELECT item_name FROM osae_v_object_property_array WHERE object_name=pobject AND property_name=pproperty;
END
$$
--
-- Definition for procedure osae_sp_object_property_array_get_random
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_property_array_get_random(
IN pobject varchar(200),
IN pproperty varchar(200)
)
BEGIN
SELECT item_name FROM osae_v_object_property_array WHERE object_name=pobject AND property_name=pproperty ORDER BY RAND() LIMIT 1;
END
$$
--
-- Definition for procedure osae_sp_object_property_array_update
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_property_array_update(
IN pobject varchar(200),
IN pproperty varchar(200),
IN poldvalue varchar(2000),
IN pnewvalue varchar(2000),
IN pnewlabel varchar(200)
)
BEGIN
DECLARE vObjectID INT;
DECLARE vObjectTypeID INT;
DECLARE vObjectPropertyID INT;
SELECT object_property_id INTO vObjectPropertyID FROM osae_v_object_property WHERE UPPER(object_name)=UPPER(pobject) AND UPPER(property_name)=UPPER(pproperty);
IF vObjectPropertyID IS NOT NULL Then
UPDATE osae_object_property_array SET item_name=pnewvalue,item_label=pnewlabel WHERE object_property_id=vObjectPropertyID AND item_name=poldvalue;
END IF;
END
$$
--
-- Definition for procedure osae_sp_object_property_get
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_property_get(
IN pname varchar(200),
IN pproperty varchar(200)
)
BEGIN
SELECT property_value FROM osae_v_object_property WHERE object_name=pname AND property_name=pproperty;
END
$$
--
-- Definition for procedure osae_sp_object_property_set
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_property_set(
IN pname varchar(200),
IN pproperty varchar(200),
IN pvalue varchar(255),
IN pfromobject varchar(200),
IN pdebuginfo varchar(2000)
)
BEGIN
DECLARE vObjectID INT DEFAULT 0;
DECLARE vObjectCount INT DEFAULT 0;
DECLARE vObjectTypeID INT DEFAULT 0;
DECLARE vPropertyID INT DEFAULT 0;
DECLARE vPropertyValue VARCHAR(2000);
DECLARE vPropertyCount INT DEFAULT 0;
DECLARE vEventCount INT;
DECLARE vDebugTrace VARCHAR(2000) DEFAULT '';
SET vDebugTrace = CONCAT(pdebuginfo,' -> osae_sp_object_property_set');
SELECT COUNT(object_id) INTO vObjectCount FROM osae_object WHERE UPPER(object_name)=UPPER(pname);
IF vObjectCount > 0 THEN
SELECT object_id,object_type_id INTO vObjectID,vObjectTypeID FROM osae_object WHERE UPPER(object_name)=UPPER(pname);
SELECT COUNT(property_id) INTO vPropertyCount FROM osae_v_object_property WHERE UPPER(object_name)=UPPER(pname) AND UPPER(property_name)=UPPER(pproperty) AND (property_value IS NULL OR property_value != pvalue);
IF vPropertyCount > 0 THEN
SELECT property_id,COALESCE(property_value,'') INTO vPropertyID, vPropertyValue FROM osae_v_object_property WHERE UPPER(object_name)=UPPER(pname) AND UPPER(property_name)=UPPER(pproperty) AND (property_value IS NULL OR property_value != pvalue);
UPDATE osae_object_property SET property_value=pvalue WHERE object_id=vObjectID AND object_type_property_id=vPropertyID;
UPDATE osae_object SET last_updated=NOW() WHERE object_id=vObjectID;
SELECT COUNT(event_id) INTO vEventCount FROM osae_object_type_event WHERE object_type_id=vObjectTypeID AND UPPER(event_name)=UPPER(pproperty);
IF vEventCount > 0 THEN
CALL osae_sp_event_log_add(pname,pproperty,pfromobject,vDebugTrace);
END IF;
END IF;
END IF;
END
$$
--
-- Definition for procedure osae_sp_object_state_set
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_state_set(
IN pname varchar(200),
IN pstate varchar(50),
IN pfromobject varchar(200),
IN pdebuginfo varchar(2000)
)
BEGIN
DECLARE vObjectCount INT;
DECLARE vObjectID INT;
DECLARE vObjectTypeID INT;
DECLARE vStateCount INT;
DECLARE vOldStateID INT;
DECLARE vStateID INT;
DECLARE vEventCount INT;
DECLARE vHideRedundantEvents INT;
DECLARE vDebugTrace VARCHAR(2000) DEFAULT '';
SET vDebugTrace = CONCAT(pdebuginfo,' -> osae_sp_object_state_set');
SELECT COUNT(object_id) INTO vObjectCount FROM osae_object WHERE UPPER(object_name)=UPPER(pname);
IF vObjectCount = 1 THEN
SELECT object_id,object_type_id,state_id INTO vObjectID,vObjectTypeID,vOldStateID FROM osae_object WHERE UPPER(object_name)=UPPER(pname) LIMIT 1;
SELECT COUNT(state_id) INTO vStateCount FROM osae_object_type_state WHERE object_type_id=vObjectTypeID AND (UPPER(state_name)=UPPER(pstate) OR UPPER(state_label)=UPPER(pstate));
IF vStateCount = 1 THEN
SELECT state_id INTO vStateID FROM osae_object_type_state WHERE object_type_id=vObjectTypeID AND (UPPER(state_name)=UPPER(pstate) OR UPPER(state_label)=UPPER(pstate)) LIMIT 1;
UPDATE osae_object SET state_id=vStateID,last_updated=NOW() WHERE object_id=vObjectID;
SELECT COUNT(event_id) INTO vEventCount FROM osae_v_object_type_event WHERE object_type_id=vObjectTypeID AND UPPER(event_name)=UPPER(pstate) LIMIT 1;
IF vEventCount = 1 THEN
SELECT hide_redundant_events INTO vHideRedundantEvents FROM osae_v_object_type_event WHERE object_type_id=vObjectTypeID AND UPPER(event_name)=UPPER(pstate) LIMIT 1;
IF vOldStateID <> vStateID OR vHideRedundantEvents = 0 Then
CALL osae_sp_event_log_add(pname,pstate,pfromobject,vDebugTrace);
END IF;
END IF;
END IF;
END IF;
END
$$
--
-- Definition for procedure osae_sp_object_state_set_by_address
--
CREATE DEFINER = 'osae'@'%'
PROCEDURE osae_sp_object_state_set_by_address(
IN paddress varchar(400),
IN pstate varchar(50),
IN pfromobject varchar(200),
IN pdebuginfo varchar(2000)
)
BEGIN
DECLARE vObjectCount INT;
DECLARE vObjectID INT;
DECLARE vObjectTypeID INT;
DECLARE vStateCount INT;
DECLARE vOldStateID INT;
DECLARE vStateID INT;
DECLARE vEventCount INT;
DECLARE vHideRedundantEvents INT;
DECLARE vDebugTrace VARCHAR(2000) DEFAULT '';
SET vDebugTrace = CONCAT(pdebuginfo,' -> osae_sp_object_state_set');
SELECT COUNT(object_id) INTO vObjectCount FROM osae_object WHERE UPPER(address)=UPPER(paddress);
IF vObjectCount = 1 THEN
SELECT object_id,object_type_id,state_id INTO vObjectID,vObjectTypeID,vOldStateID FROM osae_object WHERE UPPER(address)=UPPER(paddress) AND paddress != '' LIMIT 1;
SELECT COUNT(state_id) INTO vStateCount FROM osae_object_type_state WHERE object_type_id=vObjectTypeID AND (UPPER(state_name)=UPPER(pstate) OR UPPER(state_label)=UPPER(pstate));
IF vStateCount = 1 THEN
SELECT state_id INTO vStateID FROM osae_object_type_state WHERE object_type_id=vObjectTypeID AND (UPPER(state_name)=UPPER(pstate) OR UPPER(state_label)=UPPER(pstate)) LIMIT 1;
UPDATE osae_object SET state_id=vStateID,last_updated=NOW() WHERE object_id=vObjectID;
SELECT COUNT(event_id),hide_redundant_events INTO vEventCount,vHideRedundantEvents FROM osae_v_object_type_event WHERE object_type_id=vObjectTypeID AND UPPER(event_name)=UPPER(pstate) LIMIT 1;
IF vOldStateID <> vStateID OR vHideRedundantEvents = 0 Then
IF vEventCount = 1 THEN
CALL osae_sp_event_log_add(pname,pstate,pfromobject,vDebugTrace);
END IF;
END IF;
END IF;
END IF;
END