Project

General

Profile

« Previous | Next » 

Revision 12224

validation/aggregating/*/*.sql, schemas/vegbien.sql, lib/runscripts/validations.pg.sql.run, inputs/bien2_traits/validations.sql: added _ to beginning of each view name so the validation views would sort at the top in the datasource's tables list. this will also make the validation result sets easily distinguishable from the data tables.

View differences:

trunk/inputs/bien2_traits/validations.sql
12 12
SET search_path = bien2_traits, pg_catalog;
13 13

  
14 14
--
15
-- Name: traits_01_count_records; Type: VIEW; Schema: bien2_traits; Owner: -
15
-- Name: _traits_01_count_records; Type: VIEW; Schema: bien2_traits; Owner: -
16 16
--
17 17

  
18
CREATE VIEW traits_01_count_records AS
18
CREATE VIEW _traits_01_count_records AS
19 19
 SELECT count(*) AS totalrecords
20 20
   FROM "TraitObservation"
21 21
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text));
22 22

  
23 23

  
24 24
--
25
-- Name: traits_02_count_trait_names; Type: VIEW; Schema: bien2_traits; Owner: -
25
-- Name: _traits_02_count_trait_names; Type: VIEW; Schema: bien2_traits; Owner: -
26 26
--
27 27

  
28
CREATE VIEW traits_02_count_trait_names AS
28
CREATE VIEW _traits_02_count_trait_names AS
29 29
 SELECT count(DISTINCT "TraitObservation"."measurementName") AS traits
30 30
   FROM "TraitObservation"
31 31
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text));
32 32

  
33 33

  
34 34
--
35
-- Name: traits_03_list_trait_names; Type: VIEW; Schema: bien2_traits; Owner: -
35
-- Name: _traits_03_list_trait_names; Type: VIEW; Schema: bien2_traits; Owner: -
36 36
--
37 37

  
38
CREATE VIEW traits_03_list_trait_names AS
38
CREATE VIEW _traits_03_list_trait_names AS
39 39
 SELECT DISTINCT "TraitObservation"."measurementName" AS trait
40 40
   FROM "TraitObservation"
41 41
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text))
......
43 43

  
44 44

  
45 45
--
46
-- Name: traits_04_count_records_per_trait; Type: VIEW; Schema: bien2_traits; Owner: -
46
-- Name: _traits_04_count_records_per_trait; Type: VIEW; Schema: bien2_traits; Owner: -
47 47
--
48 48

  
49
CREATE VIEW traits_04_count_records_per_trait AS
49
CREATE VIEW _traits_04_count_records_per_trait AS
50 50
 SELECT "TraitObservation"."measurementName" AS trait, 
51 51
    count(*) AS measurements
52 52
   FROM "TraitObservation"
......
56 56

  
57 57

  
58 58
--
59
-- Name: traits_05_count_taxa; Type: VIEW; Schema: bien2_traits; Owner: -
59
-- Name: _traits_05_count_taxa; Type: VIEW; Schema: bien2_traits; Owner: -
60 60
--
61 61

  
62
CREATE VIEW traits_05_count_taxa AS
62
CREATE VIEW _traits_05_count_taxa AS
63 63
 SELECT count(DISTINCT btrim(concat_ws(' '::text, util.ifnull("TraitObservation"."taxonName", ''::text), util.ifnull("TraitObservation"."scientificNameAuthorship", ''::text)))) AS taxa
64 64
   FROM "TraitObservation"
65 65
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text));
66 66

  
67 67

  
68 68
--
69
-- Name: traits_06_list_distinct_taxa; Type: VIEW; Schema: bien2_traits; Owner: -
69
-- Name: _traits_06_list_distinct_taxa; Type: VIEW; Schema: bien2_traits; Owner: -
70 70
--
71 71

  
72
CREATE VIEW traits_06_list_distinct_taxa AS
72
CREATE VIEW _traits_06_list_distinct_taxa AS
73 73
 SELECT DISTINCT btrim(concat_ws(' '::text, util.ifnull("TraitObservation"."taxonName", ''::text), util.ifnull("TraitObservation"."scientificNameAuthorship", ''::text))) AS taxonwithauthor
74 74
   FROM "TraitObservation"
75 75
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text))
......
77 77

  
78 78

  
79 79
--
80
-- Name: traits_07_trait_value_and_units; Type: VIEW; Schema: bien2_traits; Owner: -
80
-- Name: _traits_07_trait_value_and_units; Type: VIEW; Schema: bien2_traits; Owner: -
81 81
--
82 82

  
83
CREATE VIEW traits_07_trait_value_and_units AS
83
CREATE VIEW _traits_07_trait_value_and_units AS
84 84
 SELECT "TraitObservation"."measurementName" AS trait, 
85 85
    "TraitObservation"."measurementValue" AS value, 
86 86
    "TraitObservation"."measurementUnit" AS units
......
90 90

  
91 91

  
92 92
--
93
-- Name: traits_08_taxonname_trait_and_value_for_first_5000_records; Type: VIEW; Schema: bien2_traits; Owner: -
93
-- Name: _traits_08_taxonname_trait_and_value_for_first_5000_records; Type: VIEW; Schema: bien2_traits; Owner: -
94 94
--
95 95

  
96
CREATE VIEW traits_08_taxonname_trait_and_value_for_first_5000_records AS
96
CREATE VIEW _traits_08_taxonname_trait_and_value_for_first_5000_records AS
97 97
 SELECT btrim(concat_ws(' '::text, util.ifnull("TraitObservation"."taxonName", ''::text), util.ifnull("TraitObservation"."scientificNameAuthorship", ''::text))) AS taxonwithauthor, 
98 98
    "TraitObservation"."measurementName" AS trait, 
99 99
    "TraitObservation"."measurementValue" AS value
trunk/schemas/vegbien.my.sql
3428 3428

  
3429 3429

  
3430 3430
--
3431
-- Name: plots_01_count_of_projects; Type: VIEW; Schema: public_validations; Owner: -
3431
-- Name: _plots_01_count_of_projects; Type: VIEW; Schema: public_validations; Owner: -
3432 3432
--
3433 3433

  
3434 3434

  
3435 3435

  
3436 3436

  
3437 3437
--
3438
-- Name: plots_02_list_of_project_names; Type: VIEW; Schema: public_validations; Owner: -
3438
-- Name: _plots_02_list_of_project_names; Type: VIEW; Schema: public_validations; Owner: -
3439 3439
--
3440 3440

  
3441 3441

  
3442 3442

  
3443 3443

  
3444 3444
--
3445
-- Name: plots_03_count_of_all_plots_in_this_source; Type: VIEW; Schema: public_validations; Owner: -
3445
-- Name: _plots_03_count_of_all_plots_in_this_source; Type: VIEW; Schema: public_validations; Owner: -
3446 3446
--
3447 3447

  
3448 3448

  
3449 3449

  
3450 3450

  
3451 3451
--
3452
-- Name: plots_04_count_of_plots_in_each_project_in_this_source; Type: VIEW; Schema: public_validations; Owner: -
3452
-- Name: _plots_04_count_of_plots_in_each_project_in_this_source; Type: VIEW; Schema: public_validations; Owner: -
3453 3453
--
3454 3454

  
3455 3455

  
3456 3456

  
3457 3457

  
3458 3458
--
3459
-- Name: plots_05_list_of_plot_codes_by_project; Type: VIEW; Schema: public_validations; Owner: -
3459
-- Name: _plots_05_list_of_plot_codes_by_project; Type: VIEW; Schema: public_validations; Owner: -
3460 3460
--
3461 3461

  
3462 3462

  
3463 3463

  
3464 3464

  
3465 3465
--
3466
-- Name: plots_06_list_of_plots_with_stem_measurements; Type: VIEW; Schema: public_validations; Owner: -
3466
-- Name: _plots_06_list_of_plots_with_stem_measurements; Type: VIEW; Schema: public_validations; Owner: -
3467 3467
--
3468 3468

  
3469 3469

  
3470 3470

  
3471 3471

  
3472 3472
--
3473
-- Name: plots_10_count_of_individuals_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
3473
-- Name: _plots_10_count_of_individuals_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
3474 3474
--
3475 3475

  
3476 3476

  
3477 3477

  
3478 3478

  
3479 3479
--
3480
-- Name: VIEW plots_10_count_of_individuals_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
3480
-- Name: VIEW _plots_10_count_of_individuals_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
3481 3481
--
3482 3482

  
3483 3483

  
3484 3484

  
3485 3485

  
3486 3486
--
3487
-- Name: plots_11_count_of_stems_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
3487
-- Name: _plots_11_count_of_stems_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
3488 3488
--
3489 3489

  
3490 3490

  
3491 3491

  
3492 3492

  
3493 3493
--
3494
-- Name: VIEW plots_11_count_of_stems_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
3494
-- Name: VIEW _plots_11_count_of_stems_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
3495 3495
--
3496 3496

  
3497 3497

  
3498 3498

  
3499 3499

  
3500 3500
--
3501
-- Name: plots_12_count_of_verbatim_taxa_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
3501
-- Name: _plots_12_count_of_verbatim_taxa_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
3502 3502
--
3503 3503

  
3504 3504

  
3505 3505

  
3506 3506

  
3507 3507
--
3508
-- Name: VIEW plots_12_count_of_verbatim_taxa_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
3508
-- Name: VIEW _plots_12_count_of_verbatim_taxa_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
3509 3509
--
3510 3510

  
3511 3511

  
3512 3512

  
3513 3513

  
3514 3514
--
3515
-- Name: plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_pr; Type: VIEW; Schema: public_validations; Owner: -
3515
-- Name: _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_p; Type: VIEW; Schema: public_validations; Owner: -
3516 3516
--
3517 3517

  
3518 3518

  
3519 3519

  
3520 3520

  
3521 3521
--
3522
-- Name: VIEW plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_pr; Type: COMMENT; Schema: public_validations; Owner: -
3522
-- Name: VIEW _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_p; Type: COMMENT; Schema: public_validations; Owner: -
3523 3523
--
3524 3524

  
3525 3525

  
3526 3526

  
3527 3527

  
3528 3528
--
3529
-- Name: plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pro; Type: VIEW; Schema: public_validations; Owner: -
3529
-- Name: _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pr; Type: VIEW; Schema: public_validations; Owner: -
3530 3530
--
3531 3531

  
3532 3532

  
3533 3533

  
3534 3534

  
3535 3535
--
3536
-- Name: VIEW plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pro; Type: COMMENT; Schema: public_validations; Owner: -
3536
-- Name: VIEW _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pr; Type: COMMENT; Schema: public_validations; Owner: -
3537 3537
--
3538 3538

  
3539 3539

  
3540 3540

  
3541 3541

  
3542 3542
--
3543
-- Name: plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_proj; Type: VIEW; Schema: public_validations; Owner: -
3543
-- Name: _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_pro; Type: VIEW; Schema: public_validations; Owner: -
3544 3544
--
3545 3545

  
3546 3546

  
3547 3547

  
3548 3548

  
3549 3549
--
3550
-- Name: VIEW plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_proj; Type: COMMENT; Schema: public_validations; Owner: -
3550
-- Name: VIEW _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_pro; Type: COMMENT; Schema: public_validations; Owner: -
3551 3551
--
3552 3552

  
3553 3553

  
3554 3554

  
3555 3555

  
3556 3556
--
3557
-- Name: plots_17_count_of_subplots_per_plot_for_each_project; Type: VIEW; Schema: public_validations; Owner: -
3557
-- Name: _plots_17_count_of_subplots_per_plot_for_each_project; Type: VIEW; Schema: public_validations; Owner: -
3558 3558
--
3559 3559

  
3560 3560

  
3561 3561

  
3562 3562

  
3563 3563
--
3564
-- Name: plots_18_list_of_subplots_codes_for_each_plot_for_each_project; Type: VIEW; Schema: public_validations; Owner: -
3564
-- Name: _plots_18_list_of_subplots_codes_for_each_plot_for_each_project; Type: VIEW; Schema: public_validations; Owner: -
3565 3565
--
3566 3566

  
3567 3567

  
3568 3568

  
3569 3569

  
3570 3570
--
3571
-- Name: VIEW plots_18_list_of_subplots_codes_for_each_plot_for_each_project; Type: COMMENT; Schema: public_validations; Owner: -
3571
-- Name: VIEW _plots_18_list_of_subplots_codes_for_each_plot_for_each_project; Type: COMMENT; Schema: public_validations; Owner: -
3572 3572
--
3573 3573

  
3574 3574

  
3575 3575

  
3576 3576

  
3577 3577
--
3578
-- Name: traits_01_count_records; Type: VIEW; Schema: public_validations; Owner: -
3578
-- Name: _traits_01_count_records; Type: VIEW; Schema: public_validations; Owner: -
3579 3579
--
3580 3580

  
3581 3581

  
3582 3582

  
3583 3583

  
3584 3584
--
3585
-- Name: traits_02_count_trait_names; Type: VIEW; Schema: public_validations; Owner: -
3585
-- Name: _traits_02_count_trait_names; Type: VIEW; Schema: public_validations; Owner: -
3586 3586
--
3587 3587

  
3588 3588

  
3589 3589

  
3590 3590

  
3591 3591
--
3592
-- Name: traits_03_list_trait_names; Type: VIEW; Schema: public_validations; Owner: -
3592
-- Name: _traits_03_list_trait_names; Type: VIEW; Schema: public_validations; Owner: -
3593 3593
--
3594 3594

  
3595 3595

  
3596 3596

  
3597 3597

  
3598 3598
--
3599
-- Name: traits_04_count_records_per_trait; Type: VIEW; Schema: public_validations; Owner: -
3599
-- Name: _traits_04_count_records_per_trait; Type: VIEW; Schema: public_validations; Owner: -
3600 3600
--
3601 3601

  
3602 3602

  
3603 3603

  
3604 3604

  
3605 3605
--
3606
-- Name: traits_05_count_taxa; Type: VIEW; Schema: public_validations; Owner: -
3606
-- Name: _traits_05_count_taxa; Type: VIEW; Schema: public_validations; Owner: -
3607 3607
--
3608 3608

  
3609 3609

  
3610 3610

  
3611 3611

  
3612 3612
--
3613
-- Name: VIEW traits_05_count_taxa; Type: COMMENT; Schema: public_validations; Owner: -
3613
-- Name: VIEW _traits_05_count_taxa; Type: COMMENT; Schema: public_validations; Owner: -
3614 3614
--
3615 3615

  
3616 3616

  
3617 3617

  
3618 3618

  
3619 3619
--
3620
-- Name: traits_06_list_taxa; Type: VIEW; Schema: public_validations; Owner: -
3620
-- Name: _traits_06_list_taxa; Type: VIEW; Schema: public_validations; Owner: -
3621 3621
--
3622 3622

  
3623 3623

  
3624 3624

  
3625 3625

  
3626 3626
--
3627
-- Name: VIEW traits_06_list_taxa; Type: COMMENT; Schema: public_validations; Owner: -
3627
-- Name: VIEW _traits_06_list_taxa; Type: COMMENT; Schema: public_validations; Owner: -
3628 3628
--
3629 3629

  
3630 3630

  
3631 3631

  
3632 3632

  
3633 3633
--
3634
-- Name: traits_07_trait_value_and_units_for_first_5000_records; Type: VIEW; Schema: public_validations; Owner: -
3634
-- Name: _traits_07_trait_value_and_units_for_first_5000_records; Type: VIEW; Schema: public_validations; Owner: -
3635 3635
--
3636 3636

  
3637 3637

  
3638 3638

  
3639 3639

  
3640 3640
--
3641
-- Name: traits_08_taxon_trait_and_value_for_first_5000_records; Type: VIEW; Schema: public_validations; Owner: -
3641
-- Name: _traits_08_taxon_trait_and_value_for_first_5000_records; Type: VIEW; Schema: public_validations; Owner: -
3642 3642
--
3643 3643

  
3644 3644

  
trunk/schemas/vegbien.sql
5154 5154
SET search_path = public_validations, pg_catalog;
5155 5155

  
5156 5156
--
5157
-- Name: plots_01_count_of_projects; Type: VIEW; Schema: public_validations; Owner: -
5157
-- Name: _plots_01_count_of_projects; Type: VIEW; Schema: public_validations; Owner: -
5158 5158
--
5159 5159

  
5160
CREATE VIEW plots_01_count_of_projects AS
5160
CREATE VIEW _plots_01_count_of_projects AS
5161 5161
 SELECT count(*) AS projects
5162 5162
   FROM (public.project p
5163 5163
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
5165 5165

  
5166 5166

  
5167 5167
--
5168
-- Name: plots_02_list_of_project_names; Type: VIEW; Schema: public_validations; Owner: -
5168
-- Name: _plots_02_list_of_project_names; Type: VIEW; Schema: public_validations; Owner: -
5169 5169
--
5170 5170

  
5171
CREATE VIEW plots_02_list_of_project_names AS
5171
CREATE VIEW _plots_02_list_of_project_names AS
5172 5172
 SELECT p.projectname
5173 5173
   FROM (public.project p
5174 5174
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
5176 5176

  
5177 5177

  
5178 5178
--
5179
-- Name: plots_03_count_of_all_plots_in_this_source; Type: VIEW; Schema: public_validations; Owner: -
5179
-- Name: _plots_03_count_of_all_plots_in_this_source; Type: VIEW; Schema: public_validations; Owner: -
5180 5180
--
5181 5181

  
5182
CREATE VIEW plots_03_count_of_all_plots_in_this_source AS
5182
CREATE VIEW _plots_03_count_of_all_plots_in_this_source AS
5183 5183
 SELECT count(*) AS plots
5184 5184
   FROM (((public.location l
5185 5185
   JOIN public.locationevent le ON ((l.location_id = le.location_id)))
......
5189 5189

  
5190 5190

  
5191 5191
--
5192
-- Name: plots_04_count_of_plots_in_each_project_in_this_source; Type: VIEW; Schema: public_validations; Owner: -
5192
-- Name: _plots_04_count_of_plots_in_each_project_in_this_source; Type: VIEW; Schema: public_validations; Owner: -
5193 5193
--
5194 5194

  
5195
CREATE VIEW plots_04_count_of_plots_in_each_project_in_this_source AS
5195
CREATE VIEW _plots_04_count_of_plots_in_each_project_in_this_source AS
5196 5196
 SELECT p.projectname, 
5197 5197
    count(DISTINCT l.location_id) AS plots
5198 5198
   FROM (((public.location l
......
5204 5204

  
5205 5205

  
5206 5206
--
5207
-- Name: plots_05_list_of_plot_codes_by_project; Type: VIEW; Schema: public_validations; Owner: -
5207
-- Name: _plots_05_list_of_plot_codes_by_project; Type: VIEW; Schema: public_validations; Owner: -
5208 5208
--
5209 5209

  
5210
CREATE VIEW plots_05_list_of_plot_codes_by_project AS
5210
CREATE VIEW _plots_05_list_of_plot_codes_by_project AS
5211 5211
 SELECT p.projectname, 
5212 5212
    l.authorlocationcode AS "plotCode"
5213 5213
   FROM (((public.location l
......
5218 5218

  
5219 5219

  
5220 5220
--
5221
-- Name: plots_06_list_of_plots_with_stem_measurements; Type: VIEW; Schema: public_validations; Owner: -
5221
-- Name: _plots_06_list_of_plots_with_stem_measurements; Type: VIEW; Schema: public_validations; Owner: -
5222 5222
--
5223 5223

  
5224
CREATE VIEW plots_06_list_of_plots_with_stem_measurements AS
5224
CREATE VIEW _plots_06_list_of_plots_with_stem_measurements AS
5225 5225
 SELECT top_plot.authorlocationcode
5226 5226
   FROM public.top_plot
5227 5227
  WHERE ((top_plot.source_id = public.source_by_shortname(("current_schema"())::text)) AND (EXISTS ( SELECT NULL::unknown AS unknown
......
5237 5237

  
5238 5238

  
5239 5239
--
5240
-- Name: plots_10_count_of_individuals_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
5240
-- Name: _plots_10_count_of_individuals_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
5241 5241
--
5242 5242

  
5243
CREATE VIEW plots_10_count_of_individuals_per_plot_in_each_project AS
5243
CREATE VIEW _plots_10_count_of_individuals_per_plot_in_each_project AS
5244 5244
 SELECT p.projectname, 
5245 5245
    l.authorlocationcode AS plotcode, 
5246 5246
    sum(ao.count) AS individuals
......
5257 5257

  
5258 5258

  
5259 5259
--
5260
-- Name: VIEW plots_10_count_of_individuals_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
5260
-- Name: VIEW _plots_10_count_of_individuals_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
5261 5261
--
5262 5262

  
5263
COMMENT ON VIEW plots_10_count_of_individuals_per_plot_in_each_project IS 'Method: count taxonObservations
5263
COMMENT ON VIEW _plots_10_count_of_individuals_per_plot_in_each_project IS 'Method: count taxonObservations
5264 5264
Note 1: `individuals` should be NULL for plots which use percent cover or line-intercept methods.
5265 5265
Note 2: Does this method requires that plots have 2-level nesting of subplots within plots?
5266 5266
';
5267 5267

  
5268 5268

  
5269 5269
--
5270
-- Name: plots_11_count_of_stems_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
5270
-- Name: _plots_11_count_of_stems_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
5271 5271
--
5272 5272

  
5273
CREATE VIEW plots_11_count_of_stems_per_plot_in_each_project AS
5273
CREATE VIEW _plots_11_count_of_stems_per_plot_in_each_project AS
5274 5274
 SELECT p.projectname, 
5275 5275
    l.authorlocationcode AS plotcode, 
5276 5276
    count(DISTINCT so.stemobservation_id) AS stems
......
5289 5289

  
5290 5290

  
5291 5291
--
5292
-- Name: VIEW plots_11_count_of_stems_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
5292
-- Name: VIEW _plots_11_count_of_stems_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
5293 5293
--
5294 5294

  
5295
COMMENT ON VIEW plots_11_count_of_stems_per_plot_in_each_project IS 'Method: count records in stemobservation table
5295
COMMENT ON VIEW _plots_11_count_of_stems_per_plot_in_each_project IS 'Method: count records in stemobservation table
5296 5296
';
5297 5297

  
5298 5298

  
5299 5299
--
5300
-- Name: plots_12_count_of_verbatim_taxa_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
5300
-- Name: _plots_12_count_of_verbatim_taxa_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: -
5301 5301
--
5302 5302

  
5303
CREATE VIEW plots_12_count_of_verbatim_taxa_per_plot_in_each_project AS
5303
CREATE VIEW _plots_12_count_of_verbatim_taxa_per_plot_in_each_project AS
5304 5304
 SELECT p.projectname, 
5305 5305
    l.authorlocationcode AS plotcode, 
5306 5306
    count(DISTINCT btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text)))) AS taxa
......
5318 5318

  
5319 5319

  
5320 5320
--
5321
-- Name: VIEW plots_12_count_of_verbatim_taxa_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
5321
-- Name: VIEW _plots_12_count_of_verbatim_taxa_per_plot_in_each_project; Type: COMMENT; Schema: public_validations; Owner: -
5322 5322
--
5323 5323

  
5324
COMMENT ON VIEW plots_12_count_of_verbatim_taxa_per_plot_in_each_project IS 'Check: join to source db by all columns, returns same number of rows
5324
COMMENT ON VIEW _plots_12_count_of_verbatim_taxa_per_plot_in_each_project IS 'Check: join to source db by all columns, returns same number of rows
5325 5325
Note: Must perform equivalent concatenation of taxonomic field in source db.
5326 5326
NOT YET READY, NEED TO INCLUDE SUBSPECIES, IF ANY
5327 5327
';
5328 5328

  
5329 5329

  
5330 5330
--
5331
-- Name: plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_pr; Type: VIEW; Schema: public_validations; Owner: -
5331
-- Name: _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_p; Type: VIEW; Schema: public_validations; Owner: -
5332 5332
--
5333 5333

  
5334
CREATE VIEW plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_pr AS
5334
CREATE VIEW _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_p AS
5335 5335
 SELECT DISTINCT p.projectname, 
5336 5336
    l.authorlocationcode AS plotcode, 
5337 5337
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon
......
5348 5348

  
5349 5349

  
5350 5350
--
5351
-- Name: VIEW plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_pr; Type: COMMENT; Schema: public_validations; Owner: -
5351
-- Name: VIEW _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_p; Type: COMMENT; Schema: public_validations; Owner: -
5352 5352
--
5353 5353

  
5354
COMMENT ON VIEW plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_pr IS 'Note: Must perform equivalent concatenation of taxonomic field in source db.
5354
COMMENT ON VIEW _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_p IS 'Note: Must perform equivalent concatenation of taxonomic field in source db.
5355 5355
';
5356 5356

  
5357 5357

  
5358 5358
--
5359
-- Name: plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pro; Type: VIEW; Schema: public_validations; Owner: -
5359
-- Name: _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pr; Type: VIEW; Schema: public_validations; Owner: -
5360 5360
--
5361 5361

  
5362
CREATE VIEW plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pro AS
5362
CREATE VIEW _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pr AS
5363 5363
 SELECT DISTINCT p.projectname, 
5364 5364
    l.authorlocationcode AS plotcode, 
5365 5365
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon, 
......
5379 5379

  
5380 5380

  
5381 5381
--
5382
-- Name: VIEW plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pro; Type: COMMENT; Schema: public_validations; Owner: -
5382
-- Name: VIEW _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pr; Type: COMMENT; Schema: public_validations; Owner: -
5383 5383
--
5384 5384

  
5385
COMMENT ON VIEW plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pro IS 'Note: Must do equivalent concatenation of taxonomic field in source db.
5385
COMMENT ON VIEW _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pr IS 'Note: Must do equivalent concatenation of taxonomic field in source db.
5386 5386
';
5387 5387

  
5388 5388

  
5389 5389
--
5390
-- Name: plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_proj; Type: VIEW; Schema: public_validations; Owner: -
5390
-- Name: _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_pro; Type: VIEW; Schema: public_validations; Owner: -
5391 5391
--
5392 5392

  
5393
CREATE VIEW plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_proj AS
5393
CREATE VIEW _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_pro AS
5394 5394
 SELECT DISTINCT p.projectname, 
5395 5395
    l.authorlocationcode AS plotcode, 
5396 5396
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon, 
......
5411 5411

  
5412 5412

  
5413 5413
--
5414
-- Name: VIEW plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_proj; Type: COMMENT; Schema: public_validations; Owner: -
5414
-- Name: VIEW _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_pro; Type: COMMENT; Schema: public_validations; Owner: -
5415 5415
--
5416 5416

  
5417
COMMENT ON VIEW plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_proj IS 'Applies to: aggregate-cover plots only
5417
COMMENT ON VIEW _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_pro IS 'Applies to: aggregate-cover plots only
5418 5418
Method: sums percent cover in aggregateoccurrence (as recorded in coverindex)
5419 5419
Check: join to source db by all columns, returns same number of rows
5420 5420
Note: Must do equivalent concatenation of taxonomic field in source db.
......
5422 5422

  
5423 5423

  
5424 5424
--
5425
-- Name: plots_17_count_of_subplots_per_plot_for_each_project; Type: VIEW; Schema: public_validations; Owner: -
5425
-- Name: _plots_17_count_of_subplots_per_plot_for_each_project; Type: VIEW; Schema: public_validations; Owner: -
5426 5426
--
5427 5427

  
5428
CREATE VIEW plots_17_count_of_subplots_per_plot_for_each_project AS
5428
CREATE VIEW _plots_17_count_of_subplots_per_plot_for_each_project AS
5429 5429
 SELECT p.projectname, 
5430 5430
    l.authorlocationcode AS plotcode, 
5431 5431
    count(DISTINCT sub_locationevent.locationevent_id) AS subplots
......
5440 5440

  
5441 5441

  
5442 5442
--
5443
-- Name: plots_18_list_of_subplots_codes_for_each_plot_for_each_project; Type: VIEW; Schema: public_validations; Owner: -
5443
-- Name: _plots_18_list_of_subplots_codes_for_each_plot_for_each_project; Type: VIEW; Schema: public_validations; Owner: -
5444 5444
--
5445 5445

  
5446
CREATE VIEW plots_18_list_of_subplots_codes_for_each_plot_for_each_project AS
5446
CREATE VIEW _plots_18_list_of_subplots_codes_for_each_plot_for_each_project AS
5447 5447
 SELECT p.projectname, 
5448 5448
    l.authorlocationcode AS plotcode, 
5449 5449
    sub_locationevent.authoreventcode AS "subplotCode"
......
5457 5457

  
5458 5458

  
5459 5459
--
5460
-- Name: VIEW plots_18_list_of_subplots_codes_for_each_plot_for_each_project; Type: COMMENT; Schema: public_validations; Owner: -
5460
-- Name: VIEW _plots_18_list_of_subplots_codes_for_each_plot_for_each_project; Type: COMMENT; Schema: public_validations; Owner: -
5461 5461
--
5462 5462

  
5463
COMMENT ON VIEW plots_18_list_of_subplots_codes_for_each_plot_for_each_project IS 'DOESN''T YET WORK PROPERLY
5463
COMMENT ON VIEW _plots_18_list_of_subplots_codes_for_each_plot_for_each_project IS 'DOESN''T YET WORK PROPERLY
5464 5464
';
5465 5465

  
5466 5466

  
5467 5467
--
5468
-- Name: traits_01_count_records; Type: VIEW; Schema: public_validations; Owner: -
5468
-- Name: _traits_01_count_records; Type: VIEW; Schema: public_validations; Owner: -
5469 5469
--
5470 5470

  
5471
CREATE VIEW traits_01_count_records AS
5471
CREATE VIEW _traits_01_count_records AS
5472 5472
 SELECT count(*) AS "totalRecords"
5473 5473
   FROM (public.trait
5474 5474
   JOIN public.taxonoccurrence USING (taxonoccurrence_id))
......
5476 5476

  
5477 5477

  
5478 5478
--
5479
-- Name: traits_02_count_trait_names; Type: VIEW; Schema: public_validations; Owner: -
5479
-- Name: _traits_02_count_trait_names; Type: VIEW; Schema: public_validations; Owner: -
5480 5480
--
5481 5481

  
5482
CREATE VIEW traits_02_count_trait_names AS
5482
CREATE VIEW _traits_02_count_trait_names AS
5483 5483
 SELECT count(DISTINCT trait.name) AS traits
5484 5484
   FROM (public.trait
5485 5485
   JOIN public.taxonoccurrence USING (taxonoccurrence_id))
......
5487 5487

  
5488 5488

  
5489 5489
--
5490
-- Name: traits_03_list_trait_names; Type: VIEW; Schema: public_validations; Owner: -
5490
-- Name: _traits_03_list_trait_names; Type: VIEW; Schema: public_validations; Owner: -
5491 5491
--
5492 5492

  
5493
CREATE VIEW traits_03_list_trait_names AS
5493
CREATE VIEW _traits_03_list_trait_names AS
5494 5494
 SELECT DISTINCT trait.name AS trait
5495 5495
   FROM (public.trait
5496 5496
   JOIN public.taxonoccurrence USING (taxonoccurrence_id))
......
5499 5499

  
5500 5500

  
5501 5501
--
5502
-- Name: traits_04_count_records_per_trait; Type: VIEW; Schema: public_validations; Owner: -
5502
-- Name: _traits_04_count_records_per_trait; Type: VIEW; Schema: public_validations; Owner: -
5503 5503
--
5504 5504

  
5505
CREATE VIEW traits_04_count_records_per_trait AS
5505
CREATE VIEW _traits_04_count_records_per_trait AS
5506 5506
 SELECT trait.name AS trait, 
5507 5507
    count(*) AS measurements
5508 5508
   FROM (public.trait
......
5513 5513

  
5514 5514

  
5515 5515
--
5516
-- Name: traits_05_count_taxa; Type: VIEW; Schema: public_validations; Owner: -
5516
-- Name: _traits_05_count_taxa; Type: VIEW; Schema: public_validations; Owner: -
5517 5517
--
5518 5518

  
5519
CREATE VIEW traits_05_count_taxa AS
5519
CREATE VIEW _traits_05_count_taxa AS
5520 5520
 SELECT count(DISTINCT ROW(taxonverbatim.taxonname, taxonverbatim.author)) AS taxa
5521 5521
   FROM public.taxonverbatim
5522 5522
  WHERE (taxonverbatim.source_id = public.source_by_shortname(("current_schema"())::text));
5523 5523

  
5524 5524

  
5525 5525
--
5526
-- Name: VIEW traits_05_count_taxa; Type: COMMENT; Schema: public_validations; Owner: -
5526
-- Name: VIEW _traits_05_count_taxa; Type: COMMENT; Schema: public_validations; Owner: -
5527 5527
--
5528 5528

  
5529
COMMENT ON VIEW traits_05_count_taxa IS 'Note: No morphospecies in trait table, therefore count taxon + authority only
5529
COMMENT ON VIEW _traits_05_count_taxa IS 'Note: No morphospecies in trait table, therefore count taxon + authority only
5530 5530
';
5531 5531

  
5532 5532

  
5533 5533
--
5534
-- Name: traits_06_list_taxa; Type: VIEW; Schema: public_validations; Owner: -
5534
-- Name: _traits_06_list_taxa; Type: VIEW; Schema: public_validations; Owner: -
5535 5535
--
5536 5536

  
5537
CREATE VIEW traits_06_list_taxa AS
5537
CREATE VIEW _traits_06_list_taxa AS
5538 5538
 SELECT DISTINCT concat_ws(' '::text, taxonverbatim.taxonname, taxonverbatim.author) AS taxonwithauthor
5539 5539
   FROM public.taxonverbatim
5540 5540
  WHERE (taxonverbatim.source_id = public.source_by_shortname(("current_schema"())::text))
......
5542 5542

  
5543 5543

  
5544 5544
--
5545
-- Name: VIEW traits_06_list_taxa; Type: COMMENT; Schema: public_validations; Owner: -
5545
-- Name: VIEW _traits_06_list_taxa; Type: COMMENT; Schema: public_validations; Owner: -
5546 5546
--
5547 5547

  
5548
COMMENT ON VIEW traits_06_list_taxa IS 'Note 1: No morphospecies in trait table, use taxon + authority 
5548
COMMENT ON VIEW _traits_06_list_taxa IS 'Note 1: No morphospecies in trait table, use taxon + authority 
5549 5549
Note 2: Note formation of taxonCorrected: includes family ONLY if taxon is not determined at least to genus
5550 5550
';
5551 5551

  
5552 5552

  
5553 5553
--
5554
-- Name: traits_07_trait_value_and_units_for_first_5000_records; Type: VIEW; Schema: public_validations; Owner: -
5554
-- Name: _traits_07_trait_value_and_units_for_first_5000_records; Type: VIEW; Schema: public_validations; Owner: -
5555 5555
--
5556 5556

  
5557
CREATE VIEW traits_07_trait_value_and_units_for_first_5000_records AS
5557
CREATE VIEW _traits_07_trait_value_and_units_for_first_5000_records AS
5558 5558
 SELECT trait.name AS trait, 
5559 5559
    trait.value, 
5560 5560
    trait.units
......
5566 5566

  
5567 5567

  
5568 5568
--
5569
-- Name: traits_08_taxon_trait_and_value_for_first_5000_records; Type: VIEW; Schema: public_validations; Owner: -
5569
-- Name: _traits_08_taxon_trait_and_value_for_first_5000_records; Type: VIEW; Schema: public_validations; Owner: -
5570 5570
--
5571 5571

  
5572
CREATE VIEW traits_08_taxon_trait_and_value_for_first_5000_records AS
5572
CREATE VIEW _traits_08_taxon_trait_and_value_for_first_5000_records AS
5573 5573
 SELECT concat_ws(' '::text, taxonverbatim.taxonname, taxonverbatim.author) AS taxonwithauthor, 
5574 5574
    trait.name AS trait, 
5575 5575
    trait.value
trunk/validation/aggregating/plots/bien3_validations_salvias_vegbien.sql
24 24
-- 1. Count of projects
25 25
-- Check: identical count in source db
26 26
-- ------------------
27
CREATE OR REPLACE VIEW plots_01_count_of_projects AS
27
CREATE OR REPLACE VIEW _plots_01_count_of_projects AS
28 28
SELECT COUNT(*) AS projects
29 29
FROM project p JOIN source s 
30 30
ON p.source_id=s.source_id
......
34 34
-- 2. List of project names
35 35
-- Check: join to source db returns same number of rows
36 36
-- ------------------
37
CREATE OR REPLACE VIEW plots_02_list_of_project_names AS
37
CREATE OR REPLACE VIEW _plots_02_list_of_project_names AS
38 38
SELECT p.projectname
39 39
FROM project p JOIN source s 
40 40
ON p.source_id=s.source_id
......
44 44
-- 3. Count of all plots in this source
45 45
-- Check: identical count in source db
46 46
-- ------------------
47
CREATE OR REPLACE VIEW plots_03_count_of_all_plots_in_this_source AS
47
CREATE OR REPLACE VIEW _plots_03_count_of_all_plots_in_this_source AS
48 48
SELECT COUNT(*) AS plots
49 49
FROM location l JOIN locationevent le
50 50
ON l.location_id=le.location_id
......
57 57
-- ------------------
58 58
-- 4. Count of plots in each project in this source
59 59
-- ------------------
60
CREATE OR REPLACE VIEW plots_04_count_of_plots_in_each_project_in_this_source AS
60
CREATE OR REPLACE VIEW _plots_04_count_of_plots_in_each_project_in_this_source AS
61 61
SELECT p.projectname, COUNT(DISTINCT l.location_id) AS plots
62 62
FROM location l JOIN locationevent le
63 63
ON l.location_id=le.location_id
......
72 72
-- 5.List of plot codes by project
73 73
-- Check: join to source db by all columns returns same number of rows
74 74
-- ------------------
75
CREATE OR REPLACE VIEW plots_05_list_of_plot_codes_by_project AS
75
CREATE OR REPLACE VIEW _plots_05_list_of_plot_codes_by_project AS
76 76
SELECT p.projectname, l.authorlocationcode AS "plotCode"
77 77
FROM location l JOIN locationevent le
78 78
ON l.location_id=le.location_id
......
85 85
-- ------------------
86 86
-- 6. List of plots with stem measurements
87 87
-- ------------------
88
CREATE OR REPLACE VIEW plots_06_list_of_plots_with_stem_measurements AS
88
CREATE OR REPLACE VIEW _plots_06_list_of_plots_with_stem_measurements AS
89 89

  
90 90
SELECT authorlocationcode
91 91
FROM top_plot
......
107 107
-- ------------------
108 108
-- 7.List of plots with counts of individuals per species
109 109
-- ------------------
110
CREATE OR REPLACE VIEW plots_07_list_of_plots_with_counts_of_individuals_per_species AS
110
CREATE OR REPLACE VIEW _plots_07_list_of_plots_with_counts_of_individuals_per_species AS
111 111

  
112 112

  
113 113

  
114 114
-- ------------------
115 115
-- 8.List of plots which use percent cover
116 116
-- ------------------
117
CREATE OR REPLACE VIEW plots_08_list_of_plots_which_use_percent_cover AS
117
CREATE OR REPLACE VIEW _plots_08_list_of_plots_which_use_percent_cover AS
118 118

  
119 119

  
120 120

  
......
122 122
-- ------------------
123 123
-- 9.List of plots which use line-intercept
124 124
-- ------------------
125
CREATE OR REPLACE VIEW plots_09_list_of_plots_which_use_line_intercept AS
125
CREATE OR REPLACE VIEW _plots_09_list_of_plots_which_use_line_intercept AS
126 126

  
127 127

  
128 128
-- ------------------
......
134 134
-- Note 2: Does this method requires that plots have 2-level nesting of
135 135
--       subplots within plots?
136 136
-- ------------------
137
CREATE OR REPLACE VIEW plots_10_count_of_individuals_per_plot_in_each_project AS
137
CREATE OR REPLACE VIEW _plots_10_count_of_individuals_per_plot_in_each_project AS
138 138
select p.projectname, l.authorlocationcode as plotcode, sum(ao.count) as individuals
139 139
from project p join source s 
140 140
on p.source_id=s.source_id
......
152 152
-- 
153 153
-- Method: count records in stemobservation table
154 154
-- ------------------
155
CREATE OR REPLACE VIEW plots_11_count_of_stems_per_plot_in_each_project AS
155
CREATE OR REPLACE VIEW _plots_11_count_of_stems_per_plot_in_each_project AS
156 156
select p.projectname, l.authorlocationcode as plotcode, count(distinct stemobservation_id) as stems
157 157
from project p join source s 
158 158
on p.source_id=s.source_id
......
173 173
-- Note: Must perform equivalent concatenation of taxonomic field in source db.
174 174
-- NOT YET READY, NEED TO INCLUDE SUBSPECIES, IF ANY
175 175
-- ------------------
176
CREATE OR REPLACE VIEW plots_12_count_of_verbatim_taxa_per_plot_in_each_project AS
176
CREATE OR REPLACE VIEW _plots_12_count_of_verbatim_taxa_per_plot_in_each_project AS
177 177
select p.projectname, l.authorlocationcode as plotcode, 
178 178
count(distinct trim('' || coalesce(family::text,'') || ' ' || coalesce(genus::text,'') || ' ' || coalesce(specific_epithet::text,'') || ' ' ||  coalesce(morphospecies::text,'')))
179 179
as taxa
......
194 194
-- 
195 195
-- Note: Must perform equivalent concatenation of taxonomic field in source db.
196 196
-- ------------------
197
CREATE OR REPLACE VIEW plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_project AS
197
CREATE OR REPLACE VIEW _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_project AS
198 198
select distinct p.projectname, l.authorlocationcode as plotcode, 
199 199
trim('' || coalesce(family::text,'') || ' ' || coalesce(genus::text,'') || ' ' || coalesce(specific_epithet::text,'') || ' ' ||  coalesce(morphospecies::text,'')) as taxon
200 200
from project p join source s 
......
213 213
-- 
214 214
-- Note: Must do equivalent concatenation of taxonomic field in source db.
215 215
-- ------------------
216
CREATE OR REPLACE VIEW plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_project AS
216
CREATE OR REPLACE VIEW _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_project AS
217 217
select distinct p.projectname, l.authorlocationcode as plotcode, 
218 218
trim('' || coalesce(family::text,'') || ' ' || coalesce(genus::text,'') || ' ' || coalesce(specific_epithet::text,'') || ' ' ||  coalesce(morphospecies::text,'')) as taxon,
219 219
sum(ao.count) as individuals
......
237 237
-- Check: join to source db by all columns, returns same number of rows
238 238
-- Note: Must do equivalent concatenation of taxonomic field in source db.
239 239
-- ------------------
240
CREATE OR REPLACE VIEW plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_project AS
240
CREATE OR REPLACE VIEW _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_project AS
241 241
select distinct p.projectname, l.authorlocationcode as plotcode, 
242 242
trim('' || coalesce(family::text,'') || ' ' || coalesce(genus::text,'') || ' ' || coalesce(specific_epithet::text,'') || ' ' ||  coalesce(morphospecies::text,'')) as taxon,
243 243
sum(ci.coverpercent) as totalpercentcover
......
268 268
--       stratum) with plots without subplots or strata (one cover measure 
269 269
--       per species per plot.
270 270
-- ------------------
271
CREATE OR REPLACE VIEW plots_16_intercepts_for_each_verb_taxon_in_each_plot_in_each_project AS
271
CREATE OR REPLACE VIEW _plots_16_intercepts_for_each_verb_taxon_in_each_plot_in_each_project AS
272 272

  
273 273

  
274 274

  
......
278 278
-- ------------------
279 279
-- 17. Count of subplots per plot, for each project
280 280
-- ------------------
281
CREATE OR REPLACE VIEW plots_17_count_of_subplots_per_plot_for_each_project AS
281
CREATE OR REPLACE VIEW _plots_17_count_of_subplots_per_plot_for_each_project AS
282 282
select p.projectname, l.authorlocationcode as plotcode, 
283 283
count(distinct sub_locationevent.locationevent_id) as subplots
284 284
from project p join source s 
......
294 294
-- 18. List of subplots codes for each plot for each project
295 295
-- DOESN'T YET WORK PROPERLY
296 296
-- ------------------
297
CREATE OR REPLACE VIEW plots_18_list_of_subplots_codes_for_each_plot_for_each_project AS
297
CREATE OR REPLACE VIEW _plots_18_list_of_subplots_codes_for_each_plot_for_each_project AS
298 298
select p.projectname, 
299 299
l.authorlocationcode as plotcode, 
300 300
sub_locationevent.authoreventcode as "subplotCode"
trunk/validation/aggregating/specimens/qualitative_validations_specimens.sql
13 13
-- 1. Count of total records (specimens) in source db
14 14
-- Check: full join against equivalent query on BIEN3 db should return 1 row
15 15
-- -------------------------------
16
CREATE OR REPLACE VIEW specimens_01_count_of_total_records_specimens_in_source_db AS
16
CREATE OR REPLACE VIEW _specimens_01_count_of_total_records_specimens_in_source_db AS
17 17

  
18 18
-- -------------------------------
19 19
-- 2. Count of unique (verbatim) non-null families
20 20
-- Check: Full inner join to equivalent query on BIEN3 db should return 1 row
21 21
-- -------------------------------
22
CREATE OR REPLACE VIEW specimens_02_count_of_unique_verbatim_non_null_families AS
22
CREATE OR REPLACE VIEW _specimens_02_count_of_unique_verbatim_non_null_families AS
23 23

  
24 24
-- -------------------------------
25 25
-- 3. List of verbatim families
26 26
-- Check: Full inner join to equivalent query on BIEN3 db should return same number of rows
27 27
-- -------------------------------
28
CREATE OR REPLACE VIEW specimens_03_list_of_verbatim_families AS
28
CREATE OR REPLACE VIEW _specimens_03_list_of_verbatim_families AS
29 29

  
30 30
-- -------------------------------
31 31
-- 4. Count of unique (verbatim) non-null species, without author
32 32
-- Check: Full inner join to equivalent query on BIEN3 db should return 1 row
33 33
-- -------------------------------
34
CREATE OR REPLACE VIEW specimens_04_count_of_unique_verbatim_non_null_species_without_author AS
34
CREATE OR REPLACE VIEW _specimens_04_count_of_unique_verbatim_non_null_species_without_author AS
35 35

  
36 36
-- -------------------------------
37 37
-- 5. List of verbatim species, excluding author
38 38
-- Check: Full inner join to equivalent query on BIEN3 db should return 3335 rows
39 39
-- -------------------------------
40
CREATE OR REPLACE VIEW specimens_05_list_of_verbatim_species_excluding_author AS
40
CREATE OR REPLACE VIEW _specimens_05_list_of_verbatim_species_excluding_author AS
41 41

  
42 42
-- -------------------------------
43 43
-- 6. Count of unique (verbatim) non-null subspecific taxa, without author
44 44
-- Check: Full inner join to equivalent query on BIEN3 db should return 1 row
45 45
-- -------------------------------
46
CREATE OR REPLACE VIEW specimens_06_count_of_unique_verbatim_non_null_subspecific_taxa_without_author AS
46
CREATE OR REPLACE VIEW _specimens_06_count_of_unique_verbatim_non_null_subspecific_taxa_without_author AS
47 47

  
48 48
-- -------------------------------
49 49
-- 7. List of verbatim subspecific taxa, without author
50 50
-- Check: Full inner join to equivalent query on BIEN3 db should return 40145 rows
51 51
-- -------------------------------
52
CREATE OR REPLACE VIEW specimens_07_list_of_verbatim_subspecific_taxa_without_author AS
52
CREATE OR REPLACE VIEW _specimens_07_list_of_verbatim_subspecific_taxa_without_author AS
53 53

  
54 54
-- -------------------------------
55 55
-- 8. Count of unique (verbatim) taxa including author, for all taxa identified at least to genus
56 56
-- Check: Full inner join to equivalent query on BIEN3 db should return 1 row
57 57
-- -------------------------------
58
CREATE OR REPLACE VIEW specimens_08_count_of_unique_verbatim_taxa_including_author_for_all_taxa_identified_at_least_to_genus AS
58
CREATE OR REPLACE VIEW _specimens_08_count_of_unique_verbatim_taxa_including_author_for_all_taxa_identified_at_least_to_genus AS
59 59

  
60 60
-- -------------------------------
61 61
-- 9. List of unique (verbatim) taxa including author, for all taxa identified at least to genus
62 62
-- Check: Full inner join to equivalent query on BIEN3 db should return 45997 rows
63 63
-- -------------------------------
64
CREATE OR REPLACE VIEW specimens_09_list_of_unique_verbatim_taxa_including_author_for_all_taxa_identified_at_least_to_genus AS
64
CREATE OR REPLACE VIEW _specimens_09_list_of_unique_verbatim_taxa_including_author_for_all_taxa_identified_at_least_to_genus AS
65 65

  
66 66
-- -------------------------------
67 67
-- 10. Count number of records by institution
68 68
-- Check: Full inner join to equivalent query on BIEN3 db should return 6 rows
69 69
-- Note: Majority should be from 'NY'; these are standard herbarium acronyms
70 70
-- -------------------------------
71
CREATE OR REPLACE VIEW specimens_10_count_number_of_records_by_institution AS
71
CREATE OR REPLACE VIEW _specimens_10_count_number_of_records_by_institution AS
72 72

  
73 73
-- -------------------------------
74 74
-- 11. List of three standard political divisions
......
76 76
-- Note: character set issues may cause mis-matches. This query is a good way to reveal
77 77
-- character set issues, either in source db or in BIEN
78 78
-- -------------------------------
79
CREATE OR REPLACE VIEW specimens_11_list_of_three_standard_political_divisions AS
79
CREATE OR REPLACE VIEW _specimens_11_list_of_three_standard_political_divisions AS
80 80

  
81 81
-- -------------------------------
82 82
-- 12. Check distinct Collector names + collection numbers + collection dates, 
83 83
-- plus total records
84 84
-- Check: Full inner join to equivalent query on BIEN3 db should return 309396 rows
85 85
-- -------------------------------
86
CREATE OR REPLACE VIEW specimens_12_check_distinct_collector_names_collection_numbers_collection_dates AS
86
CREATE OR REPLACE VIEW _specimens_12_check_distinct_collector_names_collection_numbers_collection_dates AS
87 87

  
88 88
-- -------------------------------
89 89
-- 13. Count of all  verbatim Latitude and Longitude values, as well as all 
90 90
-- latitude and longitude values that are decimals numbers
91 91
-- Check: full join to equivalent query against BIEN3 should return 1 row
92 92
-- -------------------------------
93
CREATE OR REPLACE VIEW specimens_13_count_of_all_verbatim_latitude_and_longitude_values_as_well_as_all AS
93
CREATE OR REPLACE VIEW _specimens_13_count_of_all_verbatim_latitude_and_longitude_values_as_well_as_all AS
94 94

  
95 95
-- -------------------------------
96 96
-- 14. Count of all verbatim Latitude and Longitude values that are not valid values
97 97
-- of decimal latitude or decimal longitude
98 98
-- Check: full join to equivalent query against BIEN3 should return 1 row
99 99
-- -------------------------------
100
CREATE OR REPLACE VIEW specimens_14_count_of_all_verbatim_latitude_and_longitude_values_that_are_not_valid_values AS
100
CREATE OR REPLACE VIEW _specimens_14_count_of_all_verbatim_latitude_and_longitude_values_that_are_not_valid_values AS
101 101

  
102 102
-- -------------------------------
103 103
-- 15. List distinct non-null locality descriptions
104 104
-- Check: full join to equivalent query against BIEN3 should return 125592 records
105 105
-- -------------------------------
106
CREATE OR REPLACE VIEW specimens_15_list_distinct_non_null_locality_descriptions AS
106
CREATE OR REPLACE VIEW _specimens_15_list_distinct_non_null_locality_descriptions AS
107 107

  
108 108
-- -------------------------------
109 109
-- 16. List distinct non-null specimen descriptions
110 110
-- Check: full join to equivalent query against BIEN3 should return 158460 records
111 111
-- Note: specimens descriptions in nybg extract is in column PlantFungusDescription
112 112
-- -------------------------------
113
CREATE OR REPLACE VIEW specimens_16_list_distinct_non_null_specimen_descriptions AS
113
CREATE OR REPLACE VIEW _specimens_16_list_distinct_non_null_specimen_descriptions AS
trunk/validation/aggregating/traits/bien3_validations_traits_bien3.sql
10 10
-- ------------------
11 11
-- 1. Count records
12 12
-- ------------------
13
CREATE OR REPLACE VIEW traits_01_count_records AS
13
CREATE OR REPLACE VIEW _traits_01_count_records AS
14 14
SELECT COUNT(*) AS "totalRecords"
15 15
FROM trait
16 16
JOIN taxonoccurrence USING (taxonoccurrence_id)
......
20 20
-- ------------------
21 21
-- 2. Count trait names
22 22
-- ------------------
23
CREATE OR REPLACE VIEW traits_02_count_trait_names AS
23
CREATE OR REPLACE VIEW _traits_02_count_trait_names AS
24 24
SELECT COUNT(DISTINCT name) AS traits
25 25
FROM trait
26 26
JOIN taxonoccurrence USING (taxonoccurrence_id)
......
29 29
-- ------------------
30 30
-- 3. List trait names
31 31
-- ------------------
32
CREATE OR REPLACE VIEW traits_03_list_trait_names AS
32
CREATE OR REPLACE VIEW _traits_03_list_trait_names AS
33 33
SELECT DISTINCT name AS trait
34 34
FROM trait
35 35
JOIN taxonoccurrence USING (taxonoccurrence_id)
......
40 40
-- ------------------
41 41
-- 4. Count records per trait
42 42
-- ------------------
43
CREATE OR REPLACE VIEW traits_04_count_records_per_trait AS
43
CREATE OR REPLACE VIEW _traits_04_count_records_per_trait AS
44 44
SELECT name AS trait, COUNT(*) AS measurements
45 45
FROM trait
46 46
JOIN taxonoccurrence USING (taxonoccurrence_id)
......
55 55
-- Note: No morphospecies in trait table, therefore count
56 56
-- 		taxon + authority only
57 57
-- ------------------
58
CREATE OR REPLACE VIEW traits_05_count_taxa AS
58
CREATE OR REPLACE VIEW _traits_05_count_taxa AS
59 59
SELECT COUNT(DISTINCT (taxonname, author)) AS taxa
60 60
FROM taxonverbatim
61 61
WHERE source_id = source_by_shortname(current_schema)
......
68 68
-- Note 2: Note formation of taxonCorrected: includes family ONLY if
69 69
-- taxon is not determined at least to genus
70 70
-- ------------------
71
CREATE OR REPLACE VIEW traits_06_list_taxa AS
71
CREATE OR REPLACE VIEW _traits_06_list_taxa AS
72 72
SELECT DISTINCT concat_ws(' ', taxonname, author) AS taxonwithauthor
73 73
FROM taxonverbatim
74 74
WHERE source_id = source_by_shortname(current_schema)
......
78 78
-- ------------------
79 79
-- 7. Trait, value and units for first 5000 records 
80 80
-- ------------------
81
CREATE OR REPLACE VIEW traits_07_trait_value_and_units_for_first_5000_records AS
81
CREATE OR REPLACE VIEW _traits_07_trait_value_and_units_for_first_5000_records AS
82 82
SELECT name AS trait, value, units
83 83
FROM trait
84 84
JOIN taxonoccurrence USING (taxonoccurrence_id)
......
90 90
-- ------------------
91 91
-- 8. Taxon, trait and value for first 5000 records 
92 92
-- ------------------
93
CREATE OR REPLACE VIEW traits_08_taxon_trait_and_value_for_first_5000_records AS
93
CREATE OR REPLACE VIEW _traits_08_taxon_trait_and_value_for_first_5000_records AS
94 94
SELECT concat_ws(' ', taxonname, author) AS taxonwithauthor, name AS trait, value
95 95
FROM taxonverbatim
96 96
JOIN taxondetermination ON taxondetermination.taxonverbatim_id = taxonverbatim.taxonverbatim_id AND taxondetermination.iscurrent
trunk/validation/aggregating/traits/BIEN2_traits/bien3_validations_traits_original_mysql.VegCore.sql
10 10
-- ------------------
11 11
-- 1. Count records
12 12
-- ------------------
13
CREATE OR REPLACE VIEW traits_01_count_records AS
13
CREATE OR REPLACE VIEW _traits_01_count_records AS
14 14
SELECT COUNT(*) AS totalrecords
15 15
FROM "TraitObservation"
16 16
WHERE "taxonName" IS NOT NULL AND "taxonName"<>'' AND "measurementName" IS NOT NULL AND "measurementName"<>''
......
19 19
-- ------------------
20 20
-- 2. Count trait names
21 21
-- ------------------
22
CREATE OR REPLACE VIEW traits_02_count_trait_names AS
22
CREATE OR REPLACE VIEW _traits_02_count_trait_names AS
23 23
SELECT COUNT(DISTINCT "measurementName") AS traits
24 24
FROM "TraitObservation"
25 25
WHERE "taxonName" IS NOT NULL AND "taxonName"<>'' AND "measurementName" IS NOT NULL AND "measurementName"<>''
......
28 28
-- ------------------
29 29
-- 3. List trait names
30 30
-- ------------------
31
CREATE OR REPLACE VIEW traits_03_list_trait_names AS
31
CREATE OR REPLACE VIEW _traits_03_list_trait_names AS
32 32
SELECT DISTINCT "measurementName" AS trait
33 33
FROM "TraitObservation"
34 34
WHERE "taxonName" IS NOT NULL AND "taxonName"<>'' AND "measurementName" IS NOT NULL AND "measurementName"<>''
......
38 38
-- ------------------
39 39
-- 4. Count records per trait
40 40
-- ------------------
41
CREATE OR REPLACE VIEW traits_04_count_records_per_trait AS
41
CREATE OR REPLACE VIEW _traits_04_count_records_per_trait AS
42 42
SELECT "measurementName" AS trait, COUNT(*) AS measurements
43 43
FROM "TraitObservation"
44 44
WHERE "taxonName" IS NOT NULL AND "taxonName"<>'' AND "measurementName" IS NOT NULL AND "measurementName"<>''
......
49 49
-- ------------------
50 50
-- 5. Count taxa
51 51
-- ------------------
52
CREATE OR REPLACE VIEW traits_05_count_taxa AS
52
CREATE OR REPLACE VIEW _traits_05_count_taxa AS
53 53
SELECT COUNT(DISTINCT
54 54
TRIM(CONCAT_WS(' ',IFNULL("taxonName",''),IFNULL("scientificNameAuthorship",'')))
55 55
) AS taxa
......
60 60
-- ------------------
61 61
-- 6. List distinct taxa
62 62
-- ------------------
63
CREATE OR REPLACE VIEW traits_06_list_distinct_taxa AS
63
CREATE OR REPLACE VIEW _traits_06_list_distinct_taxa AS
64 64
SELECT DISTINCT
65 65
TRIM(CONCAT_WS(' ',IFNULL("taxonName",''),IFNULL("scientificNameAuthorship",'')))
66 66
AS taxonwithauthor
......
72 72
-- ------------------
73 73
-- 7. Trait, value and units
74 74
-- ------------------
75
CREATE OR REPLACE VIEW traits_07_trait_value_and_units AS
75
CREATE OR REPLACE VIEW _traits_07_trait_value_and_units AS
76 76
SELECT "measurementName" AS trait, "measurementValue" AS value, "measurementUnit" AS units
77 77
FROM "TraitObservation"
78 78
WHERE "taxonName" IS NOT NULL AND "taxonName"<>'' AND "measurementName" IS NOT NULL AND "measurementName"<>''
......
82 82
-- ------------------
83 83
-- 8. "taxonName", trait and value for first 5000 records
84 84
-- ------------------
85
CREATE OR REPLACE VIEW traits_08_taxonname_trait_and_value_for_first_5000_records AS
85
CREATE OR REPLACE VIEW _traits_08_taxonname_trait_and_value_for_first_5000_records AS
86 86
SELECT
87 87
TRIM(CONCAT_WS(' ',IFNULL("taxonName",''),IFNULL("scientificNameAuthorship",'')))
88 88
AS taxonwithauthor,
trunk/lib/runscripts/validations.pg.sql.run
9 9
{
10 10
	echo_func
11 11
	#need explicit schema so matching tables from other schemas are not included
12
	export___schema.pg.sql.run --table="\"$schema\".[[:alpha:]]+_\d*" "$@"
12
	export___schema.pg.sql.run --table="\"$schema\"._[[:alpha:]]+_\d*" "$@"
13 13
}
14 14

  
15 15
fi

Also available in: Unified diff