-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.sql
1436 lines (1051 loc) · 34.8 KB
/
dashboard.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
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.5.3
-- Dumped by pg_dump version 9.5.3
-- Started on 2016-06-28 13:59:22 WEST
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 8 (class 2615 OID 23716)
-- Name: activenglabs; Type: SCHEMA; Schema: -; Owner: geobox
--
CREATE SCHEMA activenglabs;
ALTER SCHEMA activenglabs OWNER TO geobox;
--
-- TOC entry 12 (class 2615 OID 51437)
-- Name: edificios; Type: SCHEMA; Schema: -; Owner: geobox
--
CREATE SCHEMA edificios;
ALTER SCHEMA edificios OWNER TO geobox;
--
-- TOC entry 9 (class 2615 OID 23718)
-- Name: plantas; Type: SCHEMA; Schema: -; Owner: geobox
--
CREATE SCHEMA plantas;
ALTER SCHEMA plantas OWNER TO geobox;
--
-- TOC entry 10 (class 2615 OID 23719)
-- Name: users; Type: SCHEMA; Schema: -; Owner: geobox
--
CREATE SCHEMA users;
ALTER SCHEMA users OWNER TO geobox;
--
-- TOC entry 1 (class 3079 OID 12397)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- TOC entry 3669 (class 0 OID 0)
-- Dependencies: 1
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- TOC entry 2 (class 3079 OID 22227)
-- Name: postgis; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
--
-- TOC entry 3670 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial types and functions';
SET search_path = edificios, pg_catalog;
--
-- TOC entry 1355 (class 1255 OID 51513)
-- Name: countimages(); Type: FUNCTION; Schema: edificios; Owner: geobox
--
CREATE FUNCTION countimages() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF TG_OP != 'DELETE' THEN
UPDATE edificios.edificado_vti2 e
set fotografias = (
select count(*) from edificios.fotografia f
where f.id_edifica = e.id_edifica)
WHERE e.id_edifica = NEW.id_edifica;
RETURN NEW;
END IF;
IF TG_OP != 'INSERT' THEN
UPDATE edificios.edificado_vti2 e
set fotografias = (
select count(*) from edificios.fotografia f
where f.id_edifica = e.id_edifica)
WHERE e.id_edifica = OLD.id_edifica;
RETURN OLD;
END IF;
END;
$$;
ALTER FUNCTION edificios.countimages() OWNER TO geobox;
SET search_path = public, pg_catalog;
--
-- TOC entry 1356 (class 1255 OID 51512)
-- Name: countimages(); Type: FUNCTION; Schema: public; Owner: geobox
--
CREATE FUNCTION countimages() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
UPDATE edificios.edificado_vti2 e
set fotografias = (
select count(*) from edificios.fotografia f
where f.id_edifica = e.id_difica)
WHERE e.id_edifica = NEW.id_edifica;
RETURN NEW;
END;
$$;
ALTER FUNCTION public.countimages() OWNER TO geobox;
--
-- TOC entry 1353 (class 1255 OID 23720)
-- Name: randompointsinpolygon(geometry, integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION randompointsinpolygon(geom geometry, num_points integer) RETURNS SETOF geometry
LANGUAGE plpgsql
AS $$DECLARE
target_proportion numeric;
n_ret integer := 0;
loops integer := 0;
x_min float8;
y_min float8;
x_max float8;
y_max float8;
srid integer;
rpoint geometry;
BEGIN
-- Get envelope and SRID of source polygon
SELECT ST_XMin(geom), ST_YMin(geom), ST_XMax(geom), ST_YMax(geom), ST_SRID(geom)
INTO x_min, y_min, x_max, y_max, srid;
-- Get the area proportion of envelope size to determine if a
-- result can be returned in a reasonable amount of time
SELECT ST_Area(geom)/ST_Area(ST_Envelope(geom)) INTO target_proportion;
RAISE DEBUG 'geom: SRID %, NumGeometries %, NPoints %, area proportion within envelope %',
srid, ST_NumGeometries(geom), ST_NPoints(geom),
round(100.0*target_proportion, 2) || '%';
IF target_proportion < 0.0001 THEN
RAISE EXCEPTION 'Target area proportion of geometry is too low (%)',
100.0*target_proportion || '%';
END IF;
RAISE DEBUG 'bounds: % % % %', x_min, y_min, x_max, y_max;
WHILE n_ret < num_points LOOP
loops := loops + 1;
SELECT ST_SetSRID(ST_MakePoint(random()*(x_max - x_min) + x_min,
random()*(y_max - y_min) + y_min),
srid) INTO rpoint;
IF ST_Contains(geom, rpoint) THEN
n_ret := n_ret + 1;
RETURN NEXT rpoint;
END IF;
END LOOP;
RAISE DEBUG 'determined in % loops (% efficiency)', loops, round(100.0*num_points/loops, 2) || '%';
END$$;
ALTER FUNCTION public.randompointsinpolygon(geom geometry, num_points integer) OWNER TO postgres;
SET search_path = users, pg_catalog;
--
-- TOC entry 1354 (class 1255 OID 23721)
-- Name: isleaf(); Type: FUNCTION; Schema: users; Owner: geobox
--
CREATE FUNCTION isleaf() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF NEW.leaf IS NULL THEN
NEW.leaf := NOT EXISTS (select * from users.menu inm where idparent = NEW.id);
END IF;
-- fazer um update ao pai para ser calculado...
IF NEW.idparent IS NOT NULL THEN
UPDATE users.menu SET leaf = false where id = NEW.idparent;
END IF;
RETURN NEW;
END;
$$;
ALTER FUNCTION users.isleaf() OWNER TO geobox;
SET search_path = activenglabs, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 225 (class 1259 OID 51391)
-- Name: alarm; Type: TABLE; Schema: activenglabs; Owner: geobox
--
CREATE TABLE alarm (
id integer NOT NULL,
sensorid integer NOT NULL,
address character varying(40) NOT NULL,
created timestamp with time zone DEFAULT now() NOT NULL,
value double precision NOT NULL,
within double precision NOT NULL,
compare integer NOT NULL,
sound integer,
email integer,
sms integer,
active integer DEFAULT 1 NOT NULL
);
ALTER TABLE alarm OWNER TO geobox;
--
-- TOC entry 224 (class 1259 OID 51389)
-- Name: alarm_id_seq; Type: SEQUENCE; Schema: activenglabs; Owner: geobox
--
CREATE SEQUENCE alarm_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE alarm_id_seq OWNER TO geobox;
--
-- TOC entry 3672 (class 0 OID 0)
-- Dependencies: 224
-- Name: alarm_id_seq; Type: SEQUENCE OWNED BY; Schema: activenglabs; Owner: geobox
--
ALTER SEQUENCE alarm_id_seq OWNED BY alarm.id;
--
-- TOC entry 201 (class 1259 OID 23722)
-- Name: calibration; Type: TABLE; Schema: activenglabs; Owner: geobox
--
CREATE TABLE calibration (
id integer NOT NULL,
sensorid integer NOT NULL,
address character varying(40) NOT NULL,
created timestamp with time zone DEFAULT now() NOT NULL,
cal_a_old double precision NOT NULL,
cal_b_old double precision NOT NULL,
cal_a_new double precision NOT NULL,
cal_b_new double precision NOT NULL,
ref_value_high double precision NOT NULL,
ref_value_low double precision NOT NULL,
read_value_high double precision NOT NULL,
read_value_low double precision NOT NULL
);
ALTER TABLE calibration OWNER TO geobox;
--
-- TOC entry 202 (class 1259 OID 23726)
-- Name: calibration_id_seq; Type: SEQUENCE; Schema: activenglabs; Owner: geobox
--
CREATE SEQUENCE calibration_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE calibration_id_seq OWNER TO geobox;
--
-- TOC entry 3673 (class 0 OID 0)
-- Dependencies: 202
-- Name: calibration_id_seq; Type: SEQUENCE OWNED BY; Schema: activenglabs; Owner: geobox
--
ALTER SEQUENCE calibration_id_seq OWNED BY calibration.id;
--
-- TOC entry 203 (class 1259 OID 23728)
-- Name: sensor; Type: TABLE; Schema: activenglabs; Owner: geobox
--
CREATE TABLE sensor (
sensorid integer NOT NULL,
address character varying(40) NOT NULL,
location character varying(80) NOT NULL,
installdate timestamp with time zone DEFAULT now() NOT NULL,
sensortype character varying(40) NOT NULL,
metric integer DEFAULT 1 NOT NULL,
calibrated integer DEFAULT 0 NOT NULL,
quantity character(1) DEFAULT 'T'::bpchar NOT NULL,
decimalplaces integer DEFAULT 3 NOT NULL,
cal_a double precision DEFAULT 0 NOT NULL,
cal_b double precision DEFAULT 1 NOT NULL,
read_interval integer DEFAULT 2000 NOT NULL,
record_sample integer DEFAULT 1 NOT NULL,
id integer NOT NULL
);
ALTER TABLE sensor OWNER TO geobox;
--
-- TOC entry 204 (class 1259 OID 23740)
-- Name: sensor_id_seq; Type: SEQUENCE; Schema: activenglabs; Owner: geobox
--
CREATE SEQUENCE sensor_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE sensor_id_seq OWNER TO geobox;
--
-- TOC entry 3674 (class 0 OID 0)
-- Dependencies: 204
-- Name: sensor_id_seq; Type: SEQUENCE OWNED BY; Schema: activenglabs; Owner: geobox
--
ALTER SEQUENCE sensor_id_seq OWNED BY sensor.id;
--
-- TOC entry 205 (class 1259 OID 23742)
-- Name: temperature; Type: TABLE; Schema: activenglabs; Owner: geobox
--
CREATE TABLE temperature (
id integer NOT NULL,
sensorid integer NOT NULL,
address character varying(40) NOT NULL,
created timestamp with time zone DEFAULT now() NOT NULL,
value double precision NOT NULL,
metric integer DEFAULT 1 NOT NULL,
calibrated integer DEFAULT 0 NOT NULL
);
ALTER TABLE temperature OWNER TO geobox;
--
-- TOC entry 206 (class 1259 OID 23748)
-- Name: temperature_id_seq; Type: SEQUENCE; Schema: activenglabs; Owner: geobox
--
CREATE SEQUENCE temperature_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE temperature_id_seq OWNER TO geobox;
--
-- TOC entry 3675 (class 0 OID 0)
-- Dependencies: 206
-- Name: temperature_id_seq; Type: SEQUENCE OWNED BY; Schema: activenglabs; Owner: geobox
--
ALTER SEQUENCE temperature_id_seq OWNED BY temperature.id;
SET search_path = edificios, pg_catalog;
--
-- TOC entry 226 (class 1259 OID 51441)
-- Name: edificado_vti2_gid_seq; Type: SEQUENCE; Schema: edificios; Owner: geobox
--
CREATE SEQUENCE edificado_vti2_gid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE edificado_vti2_gid_seq OWNER TO geobox;
--
-- TOC entry 227 (class 1259 OID 51443)
-- Name: edificado_vti2; Type: TABLE; Schema: edificios; Owner: geobox
--
CREATE TABLE edificado_vti2 (
gid integer DEFAULT nextval('edificado_vti2_gid_seq'::regclass) NOT NULL,
the_geom public.geometry,
id_edifica character varying(21),
data_inser character varying(80),
data_sub character varying(80),
estado character varying(80),
data_const character varying(80),
data_renov character varying(80),
refer_elev character varying(80),
v_crsi character varying(80),
valor_elev numeric,
cota_p_a numeric,
cota_solei numeric,
ref_altura character varying(80),
valor_altu numeric,
altura_max numeric,
nome character varying(80),
tipo character varying(50),
uso character varying(254),
uso_corren character varying(100),
percent numeric,
num_fogos character varying(21),
habitantes character varying(21),
n_servicos character varying(21),
n_comercio character varying(21),
n_entradas character varying(21),
n_fracoes character varying(21),
n_pisos_ac character varying(21),
n_pisos_ab character varying(21),
n_proc character varying(10),
n_alvara character varying(10),
id_lev numeric,
siou character varying(254),
fonte_vect character varying(80),
fonte_alfa character varying(80),
fonte_var character varying(254),
ref_extern character varying(80),
r_ext_nome character varying(80),
perimetro numeric,
area numeric,
obs text,
u_insere character varying(254),
d_insere character varying(254),
u_actualiz character varying(254),
d_actualiz character varying(254),
fotografias smallint,
CONSTRAINT enforce_dims_the_geom CHECK ((public.st_ndims(the_geom) = 2)),
CONSTRAINT enforce_geotype_the_geom CHECK (((public.geometrytype(the_geom) = 'POLYGON'::text) OR (the_geom IS NULL))),
CONSTRAINT enforce_srid_the_geom CHECK ((public.st_srid(the_geom) = 3763))
);
ALTER TABLE edificado_vti2 OWNER TO geobox;
--
-- TOC entry 228 (class 1259 OID 51479)
-- Name: fotografia; Type: TABLE; Schema: edificios; Owner: geobox
--
CREATE TABLE fotografia (
id integer NOT NULL,
id_edifica character varying(21) NOT NULL,
pasta character varying(255),
caminho character varying(255) NOT NULL,
observacoes text,
idutilizador integer NOT NULL,
tamanho integer,
largura integer,
altura integer,
inapropriada boolean DEFAULT false NOT NULL,
datacriacao timestamp with time zone DEFAULT now(),
datamodificacao timestamp with time zone DEFAULT now(),
apagado boolean DEFAULT false NOT NULL,
name character varying(255)
);
ALTER TABLE fotografia OWNER TO geobox;
--
-- TOC entry 229 (class 1259 OID 51489)
-- Name: fotografia_id_seq; Type: SEQUENCE; Schema: edificios; Owner: geobox
--
CREATE SEQUENCE fotografia_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE fotografia_id_seq OWNER TO geobox;
--
-- TOC entry 3678 (class 0 OID 0)
-- Dependencies: 229
-- Name: fotografia_id_seq; Type: SEQUENCE OWNED BY; Schema: edificios; Owner: geobox
--
ALTER SEQUENCE fotografia_id_seq OWNED BY fotografia.id;
SET search_path = plantas, pg_catalog;
--
-- TOC entry 207 (class 1259 OID 23784)
-- Name: pedido; Type: TABLE; Schema: plantas; Owner: geobox
--
CREATE TABLE pedido (
gid integer NOT NULL,
nome character varying(100),
pretensao public.geometry,
pdf character varying(250),
tipo integer,
obs character varying(250),
datahora timestamp with time zone DEFAULT now(),
utilizador character varying(100) NOT NULL,
coord_x double precision,
coord_y double precision,
nif character varying(12),
fs character(150),
download_cod character varying,
userid integer,
CONSTRAINT enforce_dims_the_geom CHECK ((public.st_ndims(pretensao) = 2)),
CONSTRAINT enforce_srid_the_geom CHECK ((public.st_srid(pretensao) = 3763))
);
ALTER TABLE pedido OWNER TO geobox;
--
-- TOC entry 208 (class 1259 OID 23793)
-- Name: pedidoold; Type: TABLE; Schema: plantas; Owner: geobox
--
CREATE TABLE pedidoold (
gid integer NOT NULL,
nome character varying(100),
pretencao public.geometry,
pdf character varying(250),
tipo integer,
obs character varying(250),
datahora timestamp with time zone DEFAULT now(),
utilizador character varying(24) NOT NULL,
coord_x double precision,
coord_y double precision,
nif character varying(12),
fs character(150),
download_cod character varying,
CONSTRAINT enforce_dims_pretencao CHECK ((public.st_ndims(pretencao) = 2)),
CONSTRAINT enforce_srid_pedido CHECK ((public.st_srid(pretencao) = 27492))
);
ALTER TABLE pedidoold OWNER TO geobox;
--
-- TOC entry 209 (class 1259 OID 23802)
-- Name: pedido_gid_seq; Type: SEQUENCE; Schema: plantas; Owner: geobox
--
CREATE SEQUENCE pedido_gid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE pedido_gid_seq OWNER TO geobox;
--
-- TOC entry 3679 (class 0 OID 0)
-- Dependencies: 209
-- Name: pedido_gid_seq; Type: SEQUENCE OWNED BY; Schema: plantas; Owner: geobox
--
ALTER SEQUENCE pedido_gid_seq OWNED BY pedidoold.gid;
--
-- TOC entry 210 (class 1259 OID 23804)
-- Name: pedido_gid_seq1; Type: SEQUENCE; Schema: plantas; Owner: geobox
--
CREATE SEQUENCE pedido_gid_seq1
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE pedido_gid_seq1 OWNER TO geobox;
--
-- TOC entry 3680 (class 0 OID 0)
-- Dependencies: 210
-- Name: pedido_gid_seq1; Type: SEQUENCE OWNED BY; Schema: plantas; Owner: geobox
--
ALTER SEQUENCE pedido_gid_seq1 OWNED BY pedido.gid;
--
-- TOC entry 211 (class 1259 OID 23806)
-- Name: pedidodetail; Type: TABLE; Schema: plantas; Owner: geobox
--
CREATE TABLE pedidodetail (
id integer NOT NULL,
gid integer NOT NULL,
userid integer,
sessionid character varying(36),
createdate timestamp with time zone DEFAULT now(),
pretensao public.geometry,
CONSTRAINT enforce_dims_the_geom CHECK ((public.st_ndims(pretensao) = 2)),
CONSTRAINT enforce_srid_the_geom CHECK ((public.st_srid(pretensao) = 3763))
);
ALTER TABLE pedidodetail OWNER TO geobox;
--
-- TOC entry 212 (class 1259 OID 23815)
-- Name: pedidodetail_id_seq; Type: SEQUENCE; Schema: plantas; Owner: geobox
--
CREATE SEQUENCE pedidodetail_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE pedidodetail_id_seq OWNER TO geobox;
--
-- TOC entry 3681 (class 0 OID 0)
-- Dependencies: 212
-- Name: pedidodetail_id_seq; Type: SEQUENCE OWNED BY; Schema: plantas; Owner: geobox
--
ALTER SEQUENCE pedidodetail_id_seq OWNED BY pedidodetail.id;
SET search_path = users, pg_catalog;
--
-- TOC entry 213 (class 1259 OID 24018)
-- Name: grupo; Type: TABLE; Schema: users; Owner: geobox
--
CREATE TABLE grupo (
id integer NOT NULL,
nome character varying(45) NOT NULL,
datacriacao timestamp with time zone DEFAULT now(),
datamodificacao timestamp with time zone,
idutilizador integer,
omissao boolean DEFAULT false NOT NULL
);
ALTER TABLE grupo OWNER TO geobox;
--
-- TOC entry 214 (class 1259 OID 24023)
-- Name: grupo_id_seq; Type: SEQUENCE; Schema: users; Owner: geobox
--
CREATE SEQUENCE grupo_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE grupo_id_seq OWNER TO geobox;
--
-- TOC entry 3682 (class 0 OID 0)
-- Dependencies: 214
-- Name: grupo_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: geobox
--
ALTER SEQUENCE grupo_id_seq OWNED BY grupo.id;
--
-- TOC entry 215 (class 1259 OID 24025)
-- Name: layer; Type: TABLE; Schema: users; Owner: geobox
--
CREATE TABLE layer (
id integer NOT NULL,
ord bigint,
title character varying(120),
layer character varying(76),
layergroup character varying(120),
url character varying(512),
service character varying(48),
srid bigint,
style character varying(255),
qtip character varying(255),
baselayer boolean DEFAULT false,
singletile boolean,
active boolean,
visible boolean,
attribution character varying(255),
notes character varying(255),
create_date timestamp with time zone DEFAULT now() NOT NULL,
modify_date timestamp with time zone DEFAULT now() NOT NULL,
userid integer,
viewid integer,
opacity real,
legendurl character varying(512),
getfeatureinfo boolean DEFAULT true NOT NULL,
gficolumns character varying(2048)
);
ALTER TABLE layer OWNER TO geobox;
--
-- TOC entry 216 (class 1259 OID 24035)
-- Name: layer_id_seq; Type: SEQUENCE; Schema: users; Owner: geobox
--
CREATE SEQUENCE layer_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE layer_id_seq OWNER TO geobox;
--
-- TOC entry 3683 (class 0 OID 0)
-- Dependencies: 216
-- Name: layer_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: geobox
--
ALTER SEQUENCE layer_id_seq OWNED BY layer.id;
--
-- TOC entry 217 (class 1259 OID 24037)
-- Name: menu; Type: TABLE; Schema: users; Owner: geobox
--
CREATE TABLE menu (
id integer NOT NULL,
text character varying(45) NOT NULL,
"iconCls" character varying(45),
idparent integer,
extjsview character varying(45),
"routeId" character varying(45)
);
ALTER TABLE menu OWNER TO geobox;
--
-- TOC entry 218 (class 1259 OID 24040)
-- Name: menu_id_seq; Type: SEQUENCE; Schema: users; Owner: geobox
--
CREATE SEQUENCE menu_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE menu_id_seq OWNER TO geobox;
--
-- TOC entry 3684 (class 0 OID 0)
-- Dependencies: 218
-- Name: menu_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: geobox
--
ALTER SEQUENCE menu_id_seq OWNED BY menu.id;
--
-- TOC entry 219 (class 1259 OID 24042)
-- Name: permissao; Type: TABLE; Schema: users; Owner: geobox
--
CREATE TABLE permissao (
idmenu integer NOT NULL,
idgrupo integer NOT NULL
);
ALTER TABLE permissao OWNER TO geobox;
--
-- TOC entry 220 (class 1259 OID 24045)
-- Name: sessao; Type: TABLE; Schema: users; Owner: geobox
--
CREATE TABLE sessao (
id integer NOT NULL,
userid integer NOT NULL,
sessionid character varying(36),
datalogin timestamp with time zone DEFAULT now(),
datalogout timestamp with time zone,
ativo boolean DEFAULT true,
ip character varying(45),
hostname character varying(45),
dataultimaatividade timestamp with time zone DEFAULT now(),
browser character varying(120),
reaproveitada integer DEFAULT 0,
socialid integer
);
ALTER TABLE sessao OWNER TO geobox;
--
-- TOC entry 221 (class 1259 OID 24052)
-- Name: sessao_id_seq; Type: SEQUENCE; Schema: users; Owner: geobox
--
CREATE SEQUENCE sessao_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE sessao_id_seq OWNER TO geobox;
--
-- TOC entry 3685 (class 0 OID 0)
-- Dependencies: 221
-- Name: sessao_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: geobox
--
ALTER SEQUENCE sessao_id_seq OWNED BY sessao.id;
--
-- TOC entry 222 (class 1259 OID 24054)
-- Name: utilizador; Type: TABLE; Schema: users; Owner: geobox
--
CREATE TABLE utilizador (
id integer NOT NULL,
login character varying(20),
password character varying(100),
idgrupo integer,
email character varying(100),
fotografia character varying(1024),
nome character varying(120) NOT NULL,
morada character varying(80),
localidade character varying(80),
codpostal character varying(8),
despostal character varying(80),
nif character varying(9),
nic character varying(9),
masculino boolean,
pessoacoletiva boolean,
telemovel character varying(15),
telefone character varying(15),
observacoes text,
dicofre character varying(6),
ponto public.geometry(Point,3763),
datacriacao timestamp with time zone DEFAULT now(),
datamodificacao timestamp with time zone DEFAULT now(),
ultimologin timestamp with time zone,
ativo boolean DEFAULT true,
emailconfirmacao boolean DEFAULT false,
token character varying(64),
preferencias text,
CONSTRAINT enforce_dims_geometria CHECK ((public.st_ndims(ponto) = 2)),
CONSTRAINT enforce_geotype_geometria CHECK (((public.geometrytype(ponto) = 'POINT'::text) OR (ponto IS NULL))),
CONSTRAINT enforce_srid_geometria CHECK ((public.st_srid(ponto) = 3763))
);
ALTER TABLE utilizador OWNER TO geobox;
--
-- TOC entry 223 (class 1259 OID 24067)
-- Name: utilizador_id_seq; Type: SEQUENCE; Schema: users; Owner: geobox
--
CREATE SEQUENCE utilizador_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE utilizador_id_seq OWNER TO geobox;
--
-- TOC entry 3686 (class 0 OID 0)
-- Dependencies: 223
-- Name: utilizador_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: geobox
--
ALTER SEQUENCE utilizador_id_seq OWNED BY utilizador.id;
SET search_path = activenglabs, pg_catalog;
--
-- TOC entry 3480 (class 2604 OID 51394)
-- Name: id; Type: DEFAULT; Schema: activenglabs; Owner: geobox
--
ALTER TABLE ONLY alarm ALTER COLUMN id SET DEFAULT nextval('alarm_id_seq'::regclass);
--
-- TOC entry 3431 (class 2604 OID 24069)
-- Name: id; Type: DEFAULT; Schema: activenglabs; Owner: geobox
--
ALTER TABLE ONLY calibration ALTER COLUMN id SET DEFAULT nextval('calibration_id_seq'::regclass);
--
-- TOC entry 3441 (class 2604 OID 24070)
-- Name: id; Type: DEFAULT; Schema: activenglabs; Owner: geobox
--
ALTER TABLE ONLY sensor ALTER COLUMN id SET DEFAULT nextval('sensor_id_seq'::regclass);
--
-- TOC entry 3445 (class 2604 OID 24071)
-- Name: id; Type: DEFAULT; Schema: activenglabs; Owner: geobox
--
ALTER TABLE ONLY temperature ALTER COLUMN id SET DEFAULT nextval('temperature_id_seq'::regclass);
SET search_path = edificios, pg_catalog;
--
-- TOC entry 3491 (class 2604 OID 51491)
-- Name: id; Type: DEFAULT; Schema: edificios; Owner: geobox
--
ALTER TABLE ONLY fotografia ALTER COLUMN id SET DEFAULT nextval('fotografia_id_seq'::regclass);
SET search_path = plantas, pg_catalog;