Project

General

Profile

« Previous | Next » 

Revision 13800

schemas/public_.sql, inputs/.TNRS/schema.sql: upgraded to Postgres 9.3.4 format, which removes trailing " "

View differences:

trunk/inputs/.TNRS/schema.sql
363 363
--
364 364

  
365 365
CREATE VIEW "MatchedTaxon" AS
366
 SELECT s."*Name_matched.batch", 
367
    s."concatenatedScientificName", 
368
    s."matchedTaxonName", 
369
    s."matchedTaxonRank", 
370
    s."*Name_matched.Name_score", 
371
    s."matchedScientificNameAuthorship", 
372
    s."matchedScientificNameID", 
373
    s."*Name_matched.Author_score", 
374
    s."matchedFamilyConfidence_fraction", 
375
    s."matchedFamily", 
376
    s."matchedGenus", 
377
    s."matchedGenusConfidence_fraction", 
378
    s."matchedSpecificEpithet", 
379
    s."matchedSpeciesConfidence_fraction", 
380
    s."matchedInfraspecificEpithet", 
381
    s."*Name_matched.Infraspecific_epithet_score", 
382
    s."identificationQualifier", 
383
    s."morphospeciesSuffix", 
384
    s."taxonomicStatus", 
385
    s.accepted_taxon_name_no_author, 
386
    s.accepted_author, 
387
    s.accepted_taxon_rank, 
388
    s."acceptedScientificNameID", 
389
    s.accepted_species_binomial, 
390
    s.accepted_family, 
391
    s."*Name_matched.Selected", 
392
    s."*Name_matched.Source", 
393
    s."*Name_matched.Warnings", 
394
    s."*Name_matched.Accepted_name_lsid", 
395
    s.taxon_scrub__is_valid_match, 
396
    s.scrubbed_unique_taxon_name, 
366
 SELECT s."*Name_matched.batch",
367
    s."concatenatedScientificName",
368
    s."matchedTaxonName",
369
    s."matchedTaxonRank",
370
    s."*Name_matched.Name_score",
371
    s."matchedScientificNameAuthorship",
372
    s."matchedScientificNameID",
373
    s."*Name_matched.Author_score",
374
    s."matchedFamilyConfidence_fraction",
375
    s."matchedFamily",
376
    s."matchedGenus",
377
    s."matchedGenusConfidence_fraction",
378
    s."matchedSpecificEpithet",
379
    s."matchedSpeciesConfidence_fraction",
380
    s."matchedInfraspecificEpithet",
381
    s."*Name_matched.Infraspecific_epithet_score",
382
    s."identificationQualifier",
383
    s."morphospeciesSuffix",
384
    s."taxonomicStatus",
385
    s.accepted_taxon_name_no_author,
386
    s.accepted_author,
387
    s.accepted_taxon_rank,
388
    s."acceptedScientificNameID",
389
    s.accepted_species_binomial,
390
    s.accepted_family,
391
    s."*Name_matched.Selected",
392
    s."*Name_matched.Source",
393
    s."*Name_matched.Warnings",
394
    s."*Name_matched.Accepted_name_lsid",
395
    s.taxon_scrub__is_valid_match,
396
    s.scrubbed_unique_taxon_name,
397 397
        CASE
398 398
            WHEN (s.accepted_taxon_rank = 'family'::text) THEN concat_ws(' '::text, s.accepted_family, s."morphospeciesSuffix")
399 399
            WHEN (s.accepted_taxon_rank = 'genus'::text) THEN concat_ws(' '::text, s.accepted_taxon_name_no_author, s."morphospeciesSuffix")
400 400
            ELSE s.accepted_species_binomial
401 401
        END AS accepted_morphospecies_binomial
402
   FROM ( SELECT tnrs.batch AS "*Name_matched.batch", 
403
            tnrs."Name_submitted" AS "concatenatedScientificName", 
404
            tnrs."Name_matched" AS "matchedTaxonName", 
405
            tnrs."Name_matched_rank" AS "matchedTaxonRank", 
406
            tnrs."Name_score" AS "*Name_matched.Name_score", 
407
            tnrs."Name_matched_author" AS "matchedScientificNameAuthorship", 
408
            tnrs."Name_matched_url" AS "matchedScientificNameID", 
409
            tnrs."Author_score" AS "*Name_matched.Author_score", 
410
            tnrs."Family_score" AS "matchedFamilyConfidence_fraction", 
411
            COALESCE(tnrs."Name_matched_accepted_family", tnrs."Accepted_name_family") AS "matchedFamily", 
412
            tnrs."Genus_matched" AS "matchedGenus", 
413
            tnrs."Genus_score" AS "matchedGenusConfidence_fraction", 
414
            tnrs."Specific_epithet_matched" AS "matchedSpecificEpithet", 
415
            tnrs."Specific_epithet_score" AS "matchedSpeciesConfidence_fraction", 
416
            tnrs."Infraspecific_epithet_matched" AS "matchedInfraspecificEpithet", 
417
            tnrs."Infraspecific_epithet_score" AS "*Name_matched.Infraspecific_epithet_score", 
418
            tnrs."Annotations" AS "identificationQualifier", 
419
            tnrs."Unmatched_terms" AS "morphospeciesSuffix", 
420
            map_taxonomic_status(tnrs."Taxonomic_status", tnrs."Accepted_name") AS "taxonomicStatus", 
421
            tnrs."Accepted_name" AS accepted_taxon_name_no_author, 
422
            tnrs."Accepted_name_author" AS accepted_author, 
423
            tnrs."Accepted_name_rank" AS accepted_taxon_rank, 
424
            tnrs."Accepted_name_url" AS "acceptedScientificNameID", 
425
            tnrs."Accepted_name_species" AS accepted_species_binomial, 
426
            tnrs."Accepted_name_family" AS accepted_family, 
427
            tnrs."Selected" AS "*Name_matched.Selected", 
428
            tnrs."Source" AS "*Name_matched.Source", 
429
            tnrs."Warnings" AS "*Name_matched.Warnings", 
430
            tnrs."Accepted_name_lsid" AS "*Name_matched.Accepted_name_lsid", 
431
            tnrs.is_valid_match AS taxon_scrub__is_valid_match, 
402
   FROM ( SELECT tnrs.batch AS "*Name_matched.batch",
403
            tnrs."Name_submitted" AS "concatenatedScientificName",
404
            tnrs."Name_matched" AS "matchedTaxonName",
405
            tnrs."Name_matched_rank" AS "matchedTaxonRank",
406
            tnrs."Name_score" AS "*Name_matched.Name_score",
407
            tnrs."Name_matched_author" AS "matchedScientificNameAuthorship",
408
            tnrs."Name_matched_url" AS "matchedScientificNameID",
409
            tnrs."Author_score" AS "*Name_matched.Author_score",
410
            tnrs."Family_score" AS "matchedFamilyConfidence_fraction",
411
            COALESCE(tnrs."Name_matched_accepted_family", tnrs."Accepted_name_family") AS "matchedFamily",
412
            tnrs."Genus_matched" AS "matchedGenus",
413
            tnrs."Genus_score" AS "matchedGenusConfidence_fraction",
414
            tnrs."Specific_epithet_matched" AS "matchedSpecificEpithet",
415
            tnrs."Specific_epithet_score" AS "matchedSpeciesConfidence_fraction",
416
            tnrs."Infraspecific_epithet_matched" AS "matchedInfraspecificEpithet",
417
            tnrs."Infraspecific_epithet_score" AS "*Name_matched.Infraspecific_epithet_score",
418
            tnrs."Annotations" AS "identificationQualifier",
419
            tnrs."Unmatched_terms" AS "morphospeciesSuffix",
420
            map_taxonomic_status(tnrs."Taxonomic_status", tnrs."Accepted_name") AS "taxonomicStatus",
421
            tnrs."Accepted_name" AS accepted_taxon_name_no_author,
422
            tnrs."Accepted_name_author" AS accepted_author,
423
            tnrs."Accepted_name_rank" AS accepted_taxon_rank,
424
            tnrs."Accepted_name_url" AS "acceptedScientificNameID",
425
            tnrs."Accepted_name_species" AS accepted_species_binomial,
426
            tnrs."Accepted_name_family" AS accepted_family,
427
            tnrs."Selected" AS "*Name_matched.Selected",
428
            tnrs."Source" AS "*Name_matched.Source",
429
            tnrs."Warnings" AS "*Name_matched.Warnings",
430
            tnrs."Accepted_name_lsid" AS "*Name_matched.Accepted_name_lsid",
431
            tnrs.is_valid_match AS taxon_scrub__is_valid_match,
432 432
            tnrs.scrubbed_unique_taxon_name
433 433
           FROM tnrs) s;
434 434

  
......
450 450
--
451 451

  
452 452
CREATE VIEW "ValidMatchedTaxon" AS
453
 SELECT "MatchedTaxon"."*Name_matched.batch", 
454
    "MatchedTaxon"."concatenatedScientificName", 
455
    "MatchedTaxon"."matchedTaxonName", 
456
    "MatchedTaxon"."matchedTaxonRank", 
457
    "MatchedTaxon"."*Name_matched.Name_score", 
458
    "MatchedTaxon"."matchedScientificNameAuthorship", 
459
    "MatchedTaxon"."matchedScientificNameID", 
460
    "MatchedTaxon"."*Name_matched.Author_score", 
461
    "MatchedTaxon"."matchedFamilyConfidence_fraction", 
462
    "MatchedTaxon"."matchedFamily", 
463
    "MatchedTaxon"."matchedGenus", 
464
    "MatchedTaxon"."matchedGenusConfidence_fraction", 
465
    "MatchedTaxon"."matchedSpecificEpithet", 
466
    "MatchedTaxon"."matchedSpeciesConfidence_fraction", 
467
    "MatchedTaxon"."matchedInfraspecificEpithet", 
468
    "MatchedTaxon"."*Name_matched.Infraspecific_epithet_score", 
469
    "MatchedTaxon"."identificationQualifier", 
470
    "MatchedTaxon"."morphospeciesSuffix", 
471
    "MatchedTaxon"."taxonomicStatus", 
472
    "MatchedTaxon".accepted_taxon_name_no_author, 
473
    "MatchedTaxon".accepted_author, 
474
    "MatchedTaxon".accepted_taxon_rank, 
475
    "MatchedTaxon"."acceptedScientificNameID", 
476
    "MatchedTaxon".accepted_species_binomial, 
477
    "MatchedTaxon".accepted_family, 
478
    "MatchedTaxon"."*Name_matched.Selected", 
479
    "MatchedTaxon"."*Name_matched.Source", 
480
    "MatchedTaxon"."*Name_matched.Warnings", 
481
    "MatchedTaxon"."*Name_matched.Accepted_name_lsid", 
482
    "MatchedTaxon".taxon_scrub__is_valid_match, 
483
    "MatchedTaxon".scrubbed_unique_taxon_name, 
453
 SELECT "MatchedTaxon"."*Name_matched.batch",
454
    "MatchedTaxon"."concatenatedScientificName",
455
    "MatchedTaxon"."matchedTaxonName",
456
    "MatchedTaxon"."matchedTaxonRank",
457
    "MatchedTaxon"."*Name_matched.Name_score",
458
    "MatchedTaxon"."matchedScientificNameAuthorship",
459
    "MatchedTaxon"."matchedScientificNameID",
460
    "MatchedTaxon"."*Name_matched.Author_score",
461
    "MatchedTaxon"."matchedFamilyConfidence_fraction",
462
    "MatchedTaxon"."matchedFamily",
463
    "MatchedTaxon"."matchedGenus",
464
    "MatchedTaxon"."matchedGenusConfidence_fraction",
465
    "MatchedTaxon"."matchedSpecificEpithet",
466
    "MatchedTaxon"."matchedSpeciesConfidence_fraction",
467
    "MatchedTaxon"."matchedInfraspecificEpithet",
468
    "MatchedTaxon"."*Name_matched.Infraspecific_epithet_score",
469
    "MatchedTaxon"."identificationQualifier",
470
    "MatchedTaxon"."morphospeciesSuffix",
471
    "MatchedTaxon"."taxonomicStatus",
472
    "MatchedTaxon".accepted_taxon_name_no_author,
473
    "MatchedTaxon".accepted_author,
474
    "MatchedTaxon".accepted_taxon_rank,
475
    "MatchedTaxon"."acceptedScientificNameID",
476
    "MatchedTaxon".accepted_species_binomial,
477
    "MatchedTaxon".accepted_family,
478
    "MatchedTaxon"."*Name_matched.Selected",
479
    "MatchedTaxon"."*Name_matched.Source",
480
    "MatchedTaxon"."*Name_matched.Warnings",
481
    "MatchedTaxon"."*Name_matched.Accepted_name_lsid",
482
    "MatchedTaxon".taxon_scrub__is_valid_match,
483
    "MatchedTaxon".scrubbed_unique_taxon_name,
484 484
    "MatchedTaxon".accepted_morphospecies_binomial
485 485
   FROM "MatchedTaxon"
486 486
  WHERE "MatchedTaxon".taxon_scrub__is_valid_match;
......
591 591
--
592 592

  
593 593
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
594
 SELECT tnrs."Name_submitted" AS scrubbed_unique_taxon_name, 
595
    tnrs."Name_matched_rank" AS scrubbed_taxon_rank, 
596
    COALESCE(tnrs."Name_matched_accepted_family", tnrs."Family_matched") AS scrubbed_family, 
597
    tnrs."Genus_matched" AS scrubbed_genus, 
598
    tnrs."Specific_epithet_matched" AS scrubbed_specific_epithet, 
599
    tnrs."Infraspecific_rank" AS scrubbed_infraspecific_rank, 
600
    tnrs."Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet, 
601
    tnrs."Name_matched_author" AS scrubbed_author, 
602
    tnrs."Name_matched" AS scrubbed_taxon_name_no_author, 
594
 SELECT tnrs."Name_submitted" AS scrubbed_unique_taxon_name,
595
    tnrs."Name_matched_rank" AS scrubbed_taxon_rank,
596
    COALESCE(tnrs."Name_matched_accepted_family", tnrs."Family_matched") AS scrubbed_family,
597
    tnrs."Genus_matched" AS scrubbed_genus,
598
    tnrs."Specific_epithet_matched" AS scrubbed_specific_epithet,
599
    tnrs."Infraspecific_rank" AS scrubbed_infraspecific_rank,
600
    tnrs."Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
601
    tnrs."Name_matched_author" AS scrubbed_author,
602
    tnrs."Name_matched" AS scrubbed_taxon_name_no_author,
603 603
    (tnrs."Name_matched" || COALESCE((' '::text || tnrs."Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
604 604
   FROM tnrs;
605 605

  
......
618 618
--
619 619

  
620 620
CREATE VIEW taxon_scrub AS
621
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name, 
622
    "ValidMatchedTaxon"."*Name_matched.batch", 
623
    "ValidMatchedTaxon"."concatenatedScientificName", 
624
    "ValidMatchedTaxon"."matchedTaxonName", 
625
    "ValidMatchedTaxon"."matchedTaxonRank", 
626
    "ValidMatchedTaxon"."*Name_matched.Name_score", 
627
    "ValidMatchedTaxon"."matchedScientificNameAuthorship", 
628
    "ValidMatchedTaxon"."matchedScientificNameID", 
629
    "ValidMatchedTaxon"."*Name_matched.Author_score", 
630
    "ValidMatchedTaxon"."matchedFamilyConfidence_fraction", 
631
    "ValidMatchedTaxon"."matchedFamily", 
632
    "ValidMatchedTaxon"."matchedGenus", 
633
    "ValidMatchedTaxon"."matchedGenusConfidence_fraction", 
634
    "ValidMatchedTaxon"."matchedSpecificEpithet", 
635
    "ValidMatchedTaxon"."matchedSpeciesConfidence_fraction", 
636
    "ValidMatchedTaxon"."matchedInfraspecificEpithet", 
637
    "ValidMatchedTaxon"."*Name_matched.Infraspecific_epithet_score", 
638
    "ValidMatchedTaxon"."identificationQualifier", 
639
    "ValidMatchedTaxon"."morphospeciesSuffix", 
640
    "ValidMatchedTaxon"."taxonomicStatus", 
641
    "ValidMatchedTaxon".accepted_taxon_name_no_author, 
642
    "ValidMatchedTaxon".accepted_author, 
643
    "ValidMatchedTaxon".accepted_taxon_rank, 
644
    "ValidMatchedTaxon"."acceptedScientificNameID", 
645
    "ValidMatchedTaxon".accepted_species_binomial, 
646
    "ValidMatchedTaxon".accepted_family, 
647
    "ValidMatchedTaxon"."*Name_matched.Selected", 
648
    "ValidMatchedTaxon"."*Name_matched.Source", 
649
    "ValidMatchedTaxon"."*Name_matched.Warnings", 
650
    "ValidMatchedTaxon"."*Name_matched.Accepted_name_lsid", 
651
    "ValidMatchedTaxon".taxon_scrub__is_valid_match, 
652
    "ValidMatchedTaxon".accepted_morphospecies_binomial, 
653
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank, 
654
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family, 
655
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus, 
656
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet, 
657
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank, 
658
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet, 
659
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author, 
660
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author, 
661
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author, 
621
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
622
    "ValidMatchedTaxon"."*Name_matched.batch",
623
    "ValidMatchedTaxon"."concatenatedScientificName",
624
    "ValidMatchedTaxon"."matchedTaxonName",
625
    "ValidMatchedTaxon"."matchedTaxonRank",
626
    "ValidMatchedTaxon"."*Name_matched.Name_score",
627
    "ValidMatchedTaxon"."matchedScientificNameAuthorship",
628
    "ValidMatchedTaxon"."matchedScientificNameID",
629
    "ValidMatchedTaxon"."*Name_matched.Author_score",
630
    "ValidMatchedTaxon"."matchedFamilyConfidence_fraction",
631
    "ValidMatchedTaxon"."matchedFamily",
632
    "ValidMatchedTaxon"."matchedGenus",
633
    "ValidMatchedTaxon"."matchedGenusConfidence_fraction",
634
    "ValidMatchedTaxon"."matchedSpecificEpithet",
635
    "ValidMatchedTaxon"."matchedSpeciesConfidence_fraction",
636
    "ValidMatchedTaxon"."matchedInfraspecificEpithet",
637
    "ValidMatchedTaxon"."*Name_matched.Infraspecific_epithet_score",
638
    "ValidMatchedTaxon"."identificationQualifier",
639
    "ValidMatchedTaxon"."morphospeciesSuffix",
640
    "ValidMatchedTaxon"."taxonomicStatus",
641
    "ValidMatchedTaxon".accepted_taxon_name_no_author,
642
    "ValidMatchedTaxon".accepted_author,
643
    "ValidMatchedTaxon".accepted_taxon_rank,
644
    "ValidMatchedTaxon"."acceptedScientificNameID",
645
    "ValidMatchedTaxon".accepted_species_binomial,
646
    "ValidMatchedTaxon".accepted_family,
647
    "ValidMatchedTaxon"."*Name_matched.Selected",
648
    "ValidMatchedTaxon"."*Name_matched.Source",
649
    "ValidMatchedTaxon"."*Name_matched.Warnings",
650
    "ValidMatchedTaxon"."*Name_matched.Accepted_name_lsid",
651
    "ValidMatchedTaxon".taxon_scrub__is_valid_match,
652
    "ValidMatchedTaxon".accepted_morphospecies_binomial,
653
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
654
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
655
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
656
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
657
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
658
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
659
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
660
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
661
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
662 662
        CASE
663 663
            WHEN ("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank = 'family'::text) THEN concat_ws(' '::text, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family, "ValidMatchedTaxon"."morphospeciesSuffix")
664 664
            WHEN ("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank = 'genus'::text) THEN concat_ws(' '::text, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author, "ValidMatchedTaxon"."morphospeciesSuffix")
trunk/schemas/public_.sql
5438 5438
--
5439 5439

  
5440 5440
CREATE VIEW "2013-10-18.Brian_Enquist.Canadensys" AS
5441
 SELECT analytical_stem.scrubbed_morphospecies_binomial AS species, 
5442
    analytical_stem."decimalLatitude" AS latitude__deg, 
5443
    analytical_stem."decimalLongitude" AS longitude__deg, 
5441
 SELECT analytical_stem.scrubbed_morphospecies_binomial AS species,
5442
    analytical_stem."decimalLatitude" AS latitude__deg,
5443
    analytical_stem."decimalLongitude" AS longitude__deg,
5444 5444
    analytical_stem."coordinateUncertaintyInMeters" AS coords__uncertainty__m
5445 5445
   FROM analytical_stem
5446 5446
  WHERE (((((analytical_stem.scrubbed_morphospecies_binomial = ANY (ARRAY['Juniperus scopulorum'::text, 'Picea engelmannii'::text, 'Pinus contorta'::text, 'Pinus edulis'::text, 'Pinus ponderosa'::text, 'Populus tremuloides'::text, 'Pseudotsuga menziesii'::text, 'Quercus gambelii'::text])) AND (NOT COALESCE((analytical_stem.cultivated_bien)::boolean, false))) AND COALESCE((analytical_stem.geovalid_bien)::boolean, true)) AND (analytical_stem."decimalLatitude" IS NOT NULL)) AND (analytical_stem."decimalLongitude" IS NOT NULL))
......
5452 5452
--
5453 5453

  
5454 5454
CREATE VIEW "2013-7-10.Naia.range_limiting_factors" AS
5455
 SELECT analytical_stem.taxon_occurrence__pkey AS occurrence_id, 
5456
    analytical_stem.scrubbed_morphospecies_binomial AS species, 
5457
    analytical_stem."decimalLatitude" AS latitude__deg, 
5455
 SELECT analytical_stem.taxon_occurrence__pkey AS occurrence_id,
5456
    analytical_stem.scrubbed_morphospecies_binomial AS species,
5457
    analytical_stem."decimalLatitude" AS latitude__deg,
5458 5458
    analytical_stem."decimalLongitude" AS longitude__deg
5459 5459
   FROM analytical_stem
5460 5460
  WHERE ((((((NOT COALESCE((analytical_stem.cultivated_bien)::boolean, false)) AND COALESCE((analytical_stem.geovalid_bien)::boolean, true)) AND (analytical_stem.scrubbed_morphospecies_binomial IS NOT NULL)) AND (analytical_stem."decimalLatitude" IS NOT NULL)) AND (analytical_stem."decimalLongitude" IS NOT NULL)) AND COALESCE((analytical_stem."coordinateUncertaintyInMeters" <= _km_to_m((10)::double precision)), true));
......
5465 5465
--
5466 5466

  
5467 5467
CREATE VIEW "2014-3-11.Jeff_Ott.climatic_range_determinants" AS
5468
 SELECT analytical_stem.datasource, 
5469
    analytical_stem."decimalLatitude", 
5470
    analytical_stem."decimalLongitude", 
5471
    analytical_stem."higherPlantGroup_bien" AS "higherPlantGroup", 
5472
    analytical_stem.scrubbed_family AS family, 
5473
    analytical_stem.scrubbed_genus AS genus, 
5474
    analytical_stem.scrubbed_species_binomial AS "speciesBinomial", 
5468
 SELECT analytical_stem.datasource,
5469
    analytical_stem."decimalLatitude",
5470
    analytical_stem."decimalLongitude",
5471
    analytical_stem."higherPlantGroup_bien" AS "higherPlantGroup",
5472
    analytical_stem.scrubbed_family AS family,
5473
    analytical_stem.scrubbed_genus AS genus,
5474
    analytical_stem.scrubbed_species_binomial AS "speciesBinomial",
5475 5475
    analytical_stem.scrubbed_taxon_name_with_author AS "scientificName"
5476 5476
   FROM analytical_stem
5477 5477
  WHERE (((((COALESCE((analytical_stem.geovalid_bien)::boolean, true) AND COALESCE((analytical_stem."isNewWorld_bien")::boolean, false)) AND (NOT COALESCE((analytical_stem.cultivated_bien)::boolean, false))) AND (analytical_stem.scrubbed_taxon_name_with_author IS NOT NULL)) AND (analytical_stem."decimalLatitude" IS NOT NULL)) AND (analytical_stem."decimalLongitude" IS NOT NULL));
......
5482 5482
--
5483 5483

  
5484 5484
CREATE VIEW "2014-6-12.Jeff_Ott.climatic_range_determinants" AS
5485
 SELECT analytical_stem.datasource, 
5486
    analytical_stem."decimalLatitude", 
5487
    analytical_stem."decimalLongitude", 
5488
    analytical_stem."coordinateUncertaintyInMeters", 
5489
    analytical_stem.geovalid_bien, 
5490
    analytical_stem."dateCollected", 
5491
    analytical_stem."higherPlantGroup_bien" AS "higherPlantGroup", 
5492
    analytical_stem.scrubbed_family AS family, 
5493
    analytical_stem.scrubbed_genus AS genus, 
5494
    analytical_stem.scrubbed_species_binomial AS "speciesBinomial", 
5485
 SELECT analytical_stem.datasource,
5486
    analytical_stem."decimalLatitude",
5487
    analytical_stem."decimalLongitude",
5488
    analytical_stem."coordinateUncertaintyInMeters",
5489
    analytical_stem.geovalid_bien,
5490
    analytical_stem."dateCollected",
5491
    analytical_stem."higherPlantGroup_bien" AS "higherPlantGroup",
5492
    analytical_stem.scrubbed_family AS family,
5493
    analytical_stem.scrubbed_genus AS genus,
5494
    analytical_stem.scrubbed_species_binomial AS "speciesBinomial",
5495 5495
    analytical_stem.scrubbed_taxon_name_with_author AS "scientificName"
5496 5496
   FROM analytical_stem
5497 5497
  WHERE ((((((COALESCE((analytical_stem.geovalid_bien)::boolean, true) AND COALESCE((analytical_stem."isNewWorld_bien")::boolean, false)) AND (NOT COALESCE((analytical_stem.cultivated_bien)::boolean, false))) AND (analytical_stem.scrubbed_family IS NOT NULL)) AND (analytical_stem."decimalLatitude" IS NOT NULL)) AND (analytical_stem."decimalLongitude" IS NOT NULL)) AND COALESCE((analytical_stem."coordinateUncertaintyInMeters" <= _km_to_m((10)::double precision)), true));
......
5613 5613
--
5614 5614

  
5615 5615
CREATE VIEW analytical_plot AS
5616
 SELECT analytical_stem.datasource, 
5617
    analytical_stem.country, 
5618
    analytical_stem."stateProvince", 
5619
    analytical_stem.county, 
5620
    analytical_stem.locality, 
5621
    analytical_stem."decimalLatitude", 
5622
    analytical_stem."decimalLongitude", 
5623
    analytical_stem."coordinateUncertaintyInMeters", 
5624
    analytical_stem."coordinateSource_bien", 
5625
    analytical_stem."georeferenceProtocol_bien", 
5626
    analytical_stem.geovalid_bien, 
5627
    analytical_stem."isNewWorld_bien", 
5628
    analytical_stem."projectID", 
5629
    analytical_stem.project_contributors, 
5630
    analytical_stem."locationID", 
5631
    analytical_stem."locationName", 
5632
    analytical_stem.subplot, 
5633
    analytical_stem.location__cultivated__bien, 
5634
    analytical_stem."eventDate", 
5635
    analytical_stem."elevationInMeters", 
5636
    analytical_stem."slopeAspect", 
5637
    analytical_stem."slopeGradient", 
5638
    analytical_stem."plotArea_ha", 
5639
    analytical_stem."samplingProtocol", 
5640
    analytical_stem."temperature_C", 
5641
    analytical_stem.precipitation_m, 
5642
    analytical_stem.stratum__name, 
5643
    analytical_stem.communities, 
5644
    analytical_stem.plot__collectors, 
5645
    analytical_stem."recordedBy", 
5646
    analytical_stem."recordNumber", 
5647
    analytical_stem."dateCollected", 
5648
    analytical_stem.family_verbatim, 
5649
    analytical_stem."scientificName_verbatim", 
5650
    analytical_stem."identifiedBy", 
5651
    analytical_stem."dateIdentified", 
5652
    analytical_stem."identificationRemarks", 
5653
    analytical_stem.family_matched, 
5654
    analytical_stem."taxonName_matched", 
5655
    analytical_stem."scientificNameAuthorship_matched", 
5656
    analytical_stem.scrubbed_family, 
5657
    analytical_stem.scrubbed_genus, 
5658
    analytical_stem.scrubbed_morphospecies_binomial, 
5659
    analytical_stem.scrubbed_taxon_name_no_author, 
5660
    analytical_stem.scrubbed_author, 
5661
    analytical_stem."growthForm", 
5662
    analytical_stem."reproductiveCondition", 
5663
    analytical_stem.cultivated_bien, 
5664
    analytical_stem."cultivatedBasis_bien", 
5665
    analytical_stem."occurrenceRemarks", 
5666
    analytical_stem."coverPercent", 
5667
    analytical_stem."diameterBreastHeight_cm", 
5668
    analytical_stem.height_m, 
5669
    analytical_stem.tag, 
5670
    analytical_stem."organismX_m", 
5671
    analytical_stem."organismY_m", 
5672
    analytical_stem."taxonOccurrenceID", 
5673
    analytical_stem."authorTaxonCode", 
5674
    analytical_stem."aggregateOrganismObservationID", 
5675
    analytical_stem."individualObservationID", 
5676
    analytical_stem."individualCode", 
5677
    analytical_stem."individualCount", 
5616
 SELECT analytical_stem.datasource,
5617
    analytical_stem.country,
5618
    analytical_stem."stateProvince",
5619
    analytical_stem.county,
5620
    analytical_stem.locality,
5621
    analytical_stem."decimalLatitude",
5622
    analytical_stem."decimalLongitude",
5623
    analytical_stem."coordinateUncertaintyInMeters",
5624
    analytical_stem."coordinateSource_bien",
5625
    analytical_stem."georeferenceProtocol_bien",
5626
    analytical_stem.geovalid_bien,
5627
    analytical_stem."isNewWorld_bien",
5628
    analytical_stem."projectID",
5629
    analytical_stem.project_contributors,
5630
    analytical_stem."locationID",
5631
    analytical_stem."locationName",
5632
    analytical_stem.subplot,
5633
    analytical_stem.location__cultivated__bien,
5634
    analytical_stem."eventDate",
5635
    analytical_stem."elevationInMeters",
5636
    analytical_stem."slopeAspect",
5637
    analytical_stem."slopeGradient",
5638
    analytical_stem."plotArea_ha",
5639
    analytical_stem."samplingProtocol",
5640
    analytical_stem."temperature_C",
5641
    analytical_stem.precipitation_m,
5642
    analytical_stem.stratum__name,
5643
    analytical_stem.communities,
5644
    analytical_stem.plot__collectors,
5645
    analytical_stem."recordedBy",
5646
    analytical_stem."recordNumber",
5647
    analytical_stem."dateCollected",
5648
    analytical_stem.family_verbatim,
5649
    analytical_stem."scientificName_verbatim",
5650
    analytical_stem."identifiedBy",
5651
    analytical_stem."dateIdentified",
5652
    analytical_stem."identificationRemarks",
5653
    analytical_stem.family_matched,
5654
    analytical_stem."taxonName_matched",
5655
    analytical_stem."scientificNameAuthorship_matched",
5656
    analytical_stem.scrubbed_family,
5657
    analytical_stem.scrubbed_genus,
5658
    analytical_stem.scrubbed_morphospecies_binomial,
5659
    analytical_stem.scrubbed_taxon_name_no_author,
5660
    analytical_stem.scrubbed_author,
5661
    analytical_stem."growthForm",
5662
    analytical_stem."reproductiveCondition",
5663
    analytical_stem.cultivated_bien,
5664
    analytical_stem."cultivatedBasis_bien",
5665
    analytical_stem."occurrenceRemarks",
5666
    analytical_stem."coverPercent",
5667
    analytical_stem."diameterBreastHeight_cm",
5668
    analytical_stem.height_m,
5669
    analytical_stem.tag,
5670
    analytical_stem."organismX_m",
5671
    analytical_stem."organismY_m",
5672
    analytical_stem."taxonOccurrenceID",
5673
    analytical_stem."authorTaxonCode",
5674
    analytical_stem."aggregateOrganismObservationID",
5675
    analytical_stem."individualObservationID",
5676
    analytical_stem."individualCode",
5677
    analytical_stem."individualCount",
5678 5678
    analytical_stem."authorStemCode"
5679 5679
   FROM analytical_stem;
5680 5680

  
......
5684 5684
--
5685 5685

  
5686 5686
CREATE VIEW analytical_specimen AS
5687
 SELECT analytical_stem.datasource, 
5688
    analytical_stem.country, 
5689
    analytical_stem."stateProvince", 
5690
    analytical_stem.county, 
5691
    analytical_stem.locality, 
5692
    analytical_stem."decimalLatitude", 
5693
    analytical_stem."decimalLongitude", 
5694
    analytical_stem."coordinateUncertaintyInMeters", 
5695
    analytical_stem."coordinateSource_bien", 
5696
    analytical_stem."georeferenceProtocol_bien", 
5697
    analytical_stem.geovalid_bien, 
5698
    analytical_stem."isNewWorld_bien", 
5699
    analytical_stem.location__cultivated__bien, 
5700
    analytical_stem."eventDate", 
5701
    analytical_stem."elevationInMeters", 
5702
    analytical_stem."temperature_C", 
5703
    analytical_stem.precipitation_m, 
5704
    analytical_stem."specimenHolderInstitutions", 
5705
    analytical_stem.collection, 
5706
    analytical_stem."accessionNumber", 
5707
    analytical_stem."occurrenceID", 
5708
    analytical_stem."recordedBy", 
5709
    analytical_stem."recordNumber", 
5710
    analytical_stem."dateCollected", 
5711
    analytical_stem.family_verbatim, 
5712
    analytical_stem."scientificName_verbatim", 
5713
    analytical_stem."identifiedBy", 
5714
    analytical_stem."dateIdentified", 
5715
    analytical_stem."identificationRemarks", 
5716
    analytical_stem.family_matched, 
5717
    analytical_stem."taxonName_matched", 
5718
    analytical_stem."scientificNameAuthorship_matched", 
5719
    analytical_stem.scrubbed_family, 
5720
    analytical_stem.scrubbed_genus, 
5721
    analytical_stem.scrubbed_taxon_name_no_author, 
5722
    analytical_stem.scrubbed_author, 
5723
    analytical_stem."growthForm", 
5724
    analytical_stem."reproductiveCondition", 
5725
    analytical_stem.cultivated_bien, 
5726
    analytical_stem."cultivatedBasis_bien", 
5727
    analytical_stem."occurrenceRemarks", 
5728
    analytical_stem."diameterBreastHeight_cm", 
5729
    analytical_stem.height_m, 
5687
 SELECT analytical_stem.datasource,
5688
    analytical_stem.country,
5689
    analytical_stem."stateProvince",
5690
    analytical_stem.county,
5691
    analytical_stem.locality,
5692
    analytical_stem."decimalLatitude",
5693
    analytical_stem."decimalLongitude",
5694
    analytical_stem."coordinateUncertaintyInMeters",
5695
    analytical_stem."coordinateSource_bien",
5696
    analytical_stem."georeferenceProtocol_bien",
5697
    analytical_stem.geovalid_bien,
5698
    analytical_stem."isNewWorld_bien",
5699
    analytical_stem.location__cultivated__bien,
5700
    analytical_stem."eventDate",
5701
    analytical_stem."elevationInMeters",
5702
    analytical_stem."temperature_C",
5703
    analytical_stem.precipitation_m,
5704
    analytical_stem."specimenHolderInstitutions",
5705
    analytical_stem.collection,
5706
    analytical_stem."accessionNumber",
5707
    analytical_stem."occurrenceID",
5708
    analytical_stem."recordedBy",
5709
    analytical_stem."recordNumber",
5710
    analytical_stem."dateCollected",
5711
    analytical_stem.family_verbatim,
5712
    analytical_stem."scientificName_verbatim",
5713
    analytical_stem."identifiedBy",
5714
    analytical_stem."dateIdentified",
5715
    analytical_stem."identificationRemarks",
5716
    analytical_stem.family_matched,
5717
    analytical_stem."taxonName_matched",
5718
    analytical_stem."scientificNameAuthorship_matched",
5719
    analytical_stem.scrubbed_family,
5720
    analytical_stem.scrubbed_genus,
5721
    analytical_stem.scrubbed_taxon_name_no_author,
5722
    analytical_stem.scrubbed_author,
5723
    analytical_stem."growthForm",
5724
    analytical_stem."reproductiveCondition",
5725
    analytical_stem.cultivated_bien,
5726
    analytical_stem."cultivatedBasis_bien",
5727
    analytical_stem."occurrenceRemarks",
5728
    analytical_stem."diameterBreastHeight_cm",
5729
    analytical_stem.height_m,
5730 5730
    analytical_stem.tag
5731 5731
   FROM analytical_stem;
5732 5732

  
......
6375 6375
--
6376 6376

  
6377 6377
CREATE VIEW "plot.**" AS
6378
 SELECT source.shortname AS datasource, 
6379
    COALESCE(geoscrub_output."acceptedCountry", place.country) AS country, 
6380
    COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince) AS "stateProvince", 
6381
    COALESCE(geoscrub_output."acceptedCounty", place.county) AS county, 
6382
    location.locationnarrative AS locality, 
6378
 SELECT source.shortname AS datasource,
6379
    COALESCE(geoscrub_output."acceptedCountry", place.country) AS country,
6380
    COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince) AS "stateProvince",
6381
    COALESCE(geoscrub_output."acceptedCounty", place.county) AS county,
6382
    location.locationnarrative AS locality,
6383 6383
        CASE
6384 6384
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.latitude_deg
6385 6385
            ELSE county_centroids."decimalLatitude"
6386
        END AS "decimalLatitude", 
6386
        END AS "decimalLatitude",
6387 6387
        CASE
6388 6388
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.longitude_deg
6389 6389
            ELSE county_centroids."decimalLongitude"
6390
        END AS "decimalLongitude", 
6390
        END AS "decimalLongitude",
6391 6391
        CASE
6392 6392
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.coordsaccuracy_m
6393 6393
            ELSE _km_to_m(county_centroids."*error_km")
6394
        END AS "coordinateUncertaintyInMeters", 
6394
        END AS "coordinateUncertaintyInMeters",
6395 6395
        CASE
6396 6396
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN 'source data'::coordinatesource
6397 6397
            WHEN (county_centroids."*row_num" IS NOT NULL) THEN 'georeferencing'::coordinatesource
6398 6398
            ELSE NULL::coordinatesource
6399
        END AS "coordinateSource_bien", 
6399
        END AS "coordinateSource_bien",
6400 6400
        CASE
6401 6401
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN NULL::text
6402 6402
            WHEN (county_centroids."*row_num" IS NOT NULL) THEN 'county centroid'::text
6403 6403
            ELSE NULL::text
6404
        END AS "georeferenceProtocol_bien", 
6405
    (geoscrub_output.geovalid)::integer AS geovalid_bien, 
6406
    ("newWorldCountries"."isNewWorld")::integer AS "isNewWorld_bien", 
6407
    COALESCE(project.sourceaccessioncode, project.projectname) AS "projectID", 
6408
    ARRAY( SELECT project_contributors(project.project_id) AS project_contributors) AS project_contributors, 
6409
    COALESCE(location.sourceaccessioncode, NULLIF(concat_ws('; '::text, COALESCE(parent_location.sourceaccessioncode, parent_location.authorlocationcode), location.authorlocationcode), ''::text)) AS "locationID", 
6410
    COALESCE(parent_location.authorlocationcode, location.authorlocationcode) AS "locationName", 
6404
        END AS "georeferenceProtocol_bien",
6405
    (geoscrub_output.geovalid)::integer AS geovalid_bien,
6406
    ("newWorldCountries"."isNewWorld")::integer AS "isNewWorld_bien",
6407
    COALESCE(project.sourceaccessioncode, project.projectname) AS "projectID",
6408
    ARRAY( SELECT project_contributors(project.project_id) AS project_contributors) AS project_contributors,
6409
    COALESCE(location.sourceaccessioncode, NULLIF(concat_ws('; '::text, COALESCE(parent_location.sourceaccessioncode, parent_location.authorlocationcode), location.authorlocationcode), ''::text)) AS "locationID",
6410
    COALESCE(parent_location.authorlocationcode, location.authorlocationcode) AS "locationName",
6411 6411
        CASE
6412 6412
            WHEN (parent_location.location_id IS NOT NULL) THEN location.authorlocationcode
6413 6413
            ELSE NULL::text
6414
        END AS subplot, 
6415
    location.iscultivated AS location__cultivated__bien, 
6416
    locationevent.locationevent_id AS locationevent__pkey, 
6417
    COALESCE(locationevent.obsstartdate, parent_event.obsstartdate) AS "eventDate", 
6418
    COALESCE(location.elevation_m, parent_location.elevation_m) AS "elevationInMeters", 
6419
    COALESCE(location.slopeaspect_deg, parent_location.slopeaspect_deg) AS "slopeAspect", 
6420
    COALESCE(location.slopegradient_fraction, parent_location.slopegradient_fraction) AS "slopeGradient", 
6421
    _m2_to_ha(COALESCE(location.area_m2, parent_location.area_m2)) AS "plotArea_ha", 
6422
    method.name AS "samplingProtocol", 
6423
    COALESCE(locationevent.temperature_c, parent_event.temperature_c) AS "temperature_C", 
6424
    COALESCE(locationevent.precipitation_m, parent_event.precipitation_m) AS precipitation_m, 
6425
    stratum.stratumname AS stratum__name, 
6426
    COALESCE(locationevent__communities__array(locationevent.locationevent_id), locationevent__communities__array(parent_event.locationevent_id)) AS communities, 
6414
        END AS subplot,
6415
    location.iscultivated AS location__cultivated__bien,
6416
    locationevent.locationevent_id AS locationevent__pkey,
6417
    COALESCE(locationevent.obsstartdate, parent_event.obsstartdate) AS "eventDate",
6418
    COALESCE(location.elevation_m, parent_location.elevation_m) AS "elevationInMeters",
6419
    COALESCE(location.slopeaspect_deg, parent_location.slopeaspect_deg) AS "slopeAspect",
6420
    COALESCE(location.slopegradient_fraction, parent_location.slopegradient_fraction) AS "slopeGradient",
6421
    _m2_to_ha(COALESCE(location.area_m2, parent_location.area_m2)) AS "plotArea_ha",
6422
    method.name AS "samplingProtocol",
6423
    COALESCE(locationevent.temperature_c, parent_event.temperature_c) AS "temperature_C",
6424
    COALESCE(locationevent.precipitation_m, parent_event.precipitation_m) AS precipitation_m,
6425
    stratum.stratumname AS stratum__name,
6426
    COALESCE(locationevent__communities__array(locationevent.locationevent_id), locationevent__communities__array(parent_event.locationevent_id)) AS communities,
6427 6427
    COALESCE(locationevent__contributors__array(locationevent.locationevent_id), locationevent__contributors__array(parent_event.locationevent_id)) AS plot__collectors
6428 6428
   FROM (((((((((((((source
6429 6429
   JOIN location USING (source_id))
......
6754 6754
--
6755 6755

  
6756 6756
CREATE VIEW analytical_stem_view AS
6757
 SELECT "plot.**".datasource, 
6758
    "plot.**".country AS "country__@DwC__@vegpath.org", 
6759
    "plot.**"."stateProvince" AS "stateProvince__@DwC__@vegpath.org", 
6760
    "plot.**".county AS "county__@DwC__@vegpath.org", 
6761
    "plot.**".locality AS "locality__@DwC__@vegpath.org", 
6762
    "plot.**"."decimalLatitude" AS "decimalLatitude__@DwC__@vegpath.org", 
6763
    "plot.**"."decimalLongitude" AS "decimalLongitude__@DwC__@vegpath.org", 
6764
    "plot.**"."coordinateUncertaintyInMeters" AS "coordinateUncertaintyInMeters__@DwC__@vegpath.org", 
6765
    "plot.**"."coordinateSource_bien" AS "georeferenceSources__@DwC__@vegpath.org", 
6766
    "plot.**"."georeferenceProtocol_bien" AS "georeferenceProtocol__@DwC__@vegpath.org", 
6767
    "plot.**".geovalid_bien, 
6768
    "plot.**"."isNewWorld_bien", 
6769
    "plot.**"."projectID" AS "projectID__@VegX__.plotObservation@vegpath.org", 
6770
    "plot.**".project_contributors AS "projectContributor[s]__@VegBank__@vegpath.org", 
6771
    "plot.**"."locationID" AS "locationID__@DwC__@vegpath.org", 
6772
    "plot.**"."locationName" AS "plotName__@VegX__.plot@vegpath.org", 
6773
    "plot.**".subplot AS "subplot__@SALVIAS__.Plot_data@vegpath.org", 
6774
    "plot.**".location__cultivated__bien, 
6775
    "plot.**".locationevent__pkey AS "locationevent.locationevent_id__@VegBIEN__.public@vegpath.org", 
6776
    "plot.**"."eventDate" AS "eventDate__@DwC__@vegpath.org", 
6777
    "plot.**"."elevationInMeters" AS "(-minimum-)ElevationInMeters__@DwC__@vegpath.org", 
6778
    "plot.**"."slopeAspect" AS "slopeAspect[_deg]__@VegX__.plot@vegpath.org", 
6779
    "plot.**"."slopeGradient" AS "slopeGradient[_deg]__@VegX__.plot@vegpath.org", 
6780
    "plot.**"."plotArea_ha" AS "area[_ha]__@VegX__.plot@vegpath.org", 
6781
    "plot.**"."samplingProtocol" AS "samplingProtocol__@DwC__@vegpath.org", 
6782
    "plot.**"."temperature_C" AS "temperature[_C]__@VegX__.plotObs.obsCond@vegpath.org", 
6783
    "plot.**".precipitation_m AS "precip_mm__@SALVIAS__.Plot_metadata@vegpath.org", 
6784
    "plot.**".stratum__name AS "stratumName__@VegX__.stratum@vegpath.org", 
6785
    "plot.**".communities AS "communityConcept.name__@VegX__.communityDet@vegpath.org", 
6786
    "plot.**".plot__collectors AS "observationContributor[s]__@VegBank__@vegpath.org", 
6787
    sourcelist.name AS "[custodial_]institutionCode[s]__@DwC__@vegpath.org", 
6788
    specimenreplicate.collectioncode_dwc AS "collectionCode__@DwC__@vegpath.org", 
6789
    specimenreplicate.catalognumber_dwc AS "catalogNumber__@DwC__@vegpath.org", 
6790
    specimenreplicate.sourceaccessioncode AS "occurrenceID__@DwC__@vegpath.org", 
6791
    collector.fullname AS "recordedBy__@DwC__@vegpath.org", 
6792
    plantobservation.authorplantcode AS "recordNumber__@DwC__@vegpath.org", 
6793
    COALESCE(aggregateoccurrence.collectiondate, "plot.**"."eventDate") AS "(-Earliest-)DateCollected__-2007-04-17__@DwC__.hist@vegpath.org", 
6794
    taxonverbatim.family AS "[verbatim_]family__@DwC__@vegpath.org", 
6795
    COALESCE(taxonverbatim.taxonomicname, (taxonverbatim.taxonname || COALESCE((' '::text || taxonverbatim.author), ''::text)), taxonlabel.taxonomicname) AS "[verbatim_]scientificName__@DwC__@vegpath.org", 
6796
    identifiedby.fullname AS "identifiedBy__@DwC__@vegpath.org", 
6797
    taxondetermination.determinationdate AS "dateIdentified__@DwC__@vegpath.org", 
6798
    taxondetermination.notes AS "identificationRemarks__@DwC__@vegpath.org", 
6799
    taxon_scrub."matchedFamily" AS "Family_matched__@TNRS__@vegpath.org", 
6800
    taxon_scrub."matchedTaxonName" AS "Name_matched__@TNRS__@vegpath.org", 
6801
    taxon_scrub."matchedScientificNameAuthorship" AS "Name_matched_author__@TNRS__@vegpath.org", 
6802
    family_higher_plant_group.higher_plant_group AS "[higher_plant_group~]higherClassification__@DwC__@vegpath.org", 
6803
    taxon_scrub."taxonomicStatus" AS "taxonomicStatus__@DwC__@vegpath.org", 
6804
    taxon_scrub.scrubbed_family, 
6805
    taxon_scrub.scrubbed_genus, 
6806
    taxon_scrub.scrubbed_specific_epithet, 
6807
    ((taxon_scrub.scrubbed_genus || ' '::text) || taxon_scrub.scrubbed_specific_epithet) AS scrubbed_species_binomial, 
6808
    taxon_scrub.scrubbed_taxon_name_no_author, 
6809
    taxon_scrub.scrubbed_author, 
6810
    taxon_scrub.scrubbed_taxon_name_with_author, 
6811
    taxon_scrub.scrubbed_morphospecies_binomial AS "speciesBinomialWithMorphospecies__@VegCore__@vegpath.org", 
6812
    taxonoccurrence.growthform AS "[growth_form=]habit__@SALVIAS__.Plot_data@vegpath.org", 
6813
    plantobservation.reproductivecondition AS "reproductiveCondition__@DwC__@vegpath.org", 
6814
    ((threatened_taxonlabel.taxonlabel_id IS NOT NULL))::integer AS threatened_bien, 
6815
    (((cultivated_family_locations.country IS NOT NULL) OR _or(taxonoccurrence.iscultivated, "plot.**".location__cultivated__bien)))::integer AS cultivated_bien, 
6757
 SELECT "plot.**".datasource,
6758
    "plot.**".country AS "country__@DwC__@vegpath.org",
6759
    "plot.**"."stateProvince" AS "stateProvince__@DwC__@vegpath.org",
6760
    "plot.**".county AS "county__@DwC__@vegpath.org",
6761
    "plot.**".locality AS "locality__@DwC__@vegpath.org",
6762
    "plot.**"."decimalLatitude" AS "decimalLatitude__@DwC__@vegpath.org",
6763
    "plot.**"."decimalLongitude" AS "decimalLongitude__@DwC__@vegpath.org",
6764
    "plot.**"."coordinateUncertaintyInMeters" AS "coordinateUncertaintyInMeters__@DwC__@vegpath.org",
6765
    "plot.**"."coordinateSource_bien" AS "georeferenceSources__@DwC__@vegpath.org",
6766
    "plot.**"."georeferenceProtocol_bien" AS "georeferenceProtocol__@DwC__@vegpath.org",
6767
    "plot.**".geovalid_bien,
6768
    "plot.**"."isNewWorld_bien",
6769
    "plot.**"."projectID" AS "projectID__@VegX__.plotObservation@vegpath.org",
6770
    "plot.**".project_contributors AS "projectContributor[s]__@VegBank__@vegpath.org",
6771
    "plot.**"."locationID" AS "locationID__@DwC__@vegpath.org",
6772
    "plot.**"."locationName" AS "plotName__@VegX__.plot@vegpath.org",
6773
    "plot.**".subplot AS "subplot__@SALVIAS__.Plot_data@vegpath.org",
6774
    "plot.**".location__cultivated__bien,
6775
    "plot.**".locationevent__pkey AS "locationevent.locationevent_id__@VegBIEN__.public@vegpath.org",
6776
    "plot.**"."eventDate" AS "eventDate__@DwC__@vegpath.org",
6777
    "plot.**"."elevationInMeters" AS "(-minimum-)ElevationInMeters__@DwC__@vegpath.org",
6778
    "plot.**"."slopeAspect" AS "slopeAspect[_deg]__@VegX__.plot@vegpath.org",
6779
    "plot.**"."slopeGradient" AS "slopeGradient[_deg]__@VegX__.plot@vegpath.org",
6780
    "plot.**"."plotArea_ha" AS "area[_ha]__@VegX__.plot@vegpath.org",
6781
    "plot.**"."samplingProtocol" AS "samplingProtocol__@DwC__@vegpath.org",
6782
    "plot.**"."temperature_C" AS "temperature[_C]__@VegX__.plotObs.obsCond@vegpath.org",
6783
    "plot.**".precipitation_m AS "precip_mm__@SALVIAS__.Plot_metadata@vegpath.org",
6784
    "plot.**".stratum__name AS "stratumName__@VegX__.stratum@vegpath.org",
6785
    "plot.**".communities AS "communityConcept.name__@VegX__.communityDet@vegpath.org",
6786
    "plot.**".plot__collectors AS "observationContributor[s]__@VegBank__@vegpath.org",
6787
    sourcelist.name AS "[custodial_]institutionCode[s]__@DwC__@vegpath.org",
6788
    specimenreplicate.collectioncode_dwc AS "collectionCode__@DwC__@vegpath.org",
6789
    specimenreplicate.catalognumber_dwc AS "catalogNumber__@DwC__@vegpath.org",
6790
    specimenreplicate.sourceaccessioncode AS "occurrenceID__@DwC__@vegpath.org",
6791
    collector.fullname AS "recordedBy__@DwC__@vegpath.org",
6792
    plantobservation.authorplantcode AS "recordNumber__@DwC__@vegpath.org",
6793
    COALESCE(aggregateoccurrence.collectiondate, "plot.**"."eventDate") AS "(-Earliest-)DateCollected__-2007-04-17__@DwC__.hist@vegpath.org",
6794
    taxonverbatim.family AS "[verbatim_]family__@DwC__@vegpath.org",
6795
    COALESCE(taxonverbatim.taxonomicname, (taxonverbatim.taxonname || COALESCE((' '::text || taxonverbatim.author), ''::text)), taxonlabel.taxonomicname) AS "[verbatim_]scientificName__@DwC__@vegpath.org",
6796
    identifiedby.fullname AS "identifiedBy__@DwC__@vegpath.org",
6797
    taxondetermination.determinationdate AS "dateIdentified__@DwC__@vegpath.org",
6798
    taxondetermination.notes AS "identificationRemarks__@DwC__@vegpath.org",
6799
    taxon_scrub."matchedFamily" AS "Family_matched__@TNRS__@vegpath.org",
6800
    taxon_scrub."matchedTaxonName" AS "Name_matched__@TNRS__@vegpath.org",
6801
    taxon_scrub."matchedScientificNameAuthorship" AS "Name_matched_author__@TNRS__@vegpath.org",
6802
    family_higher_plant_group.higher_plant_group AS "[higher_plant_group~]higherClassification__@DwC__@vegpath.org",
6803
    taxon_scrub."taxonomicStatus" AS "taxonomicStatus__@DwC__@vegpath.org",
6804
    taxon_scrub.scrubbed_family,
6805
    taxon_scrub.scrubbed_genus,
6806
    taxon_scrub.scrubbed_specific_epithet,
6807
    ((taxon_scrub.scrubbed_genus || ' '::text) || taxon_scrub.scrubbed_specific_epithet) AS scrubbed_species_binomial,
6808
    taxon_scrub.scrubbed_taxon_name_no_author,
6809
    taxon_scrub.scrubbed_author,
6810
    taxon_scrub.scrubbed_taxon_name_with_author,
6811
    taxon_scrub.scrubbed_morphospecies_binomial AS "speciesBinomialWithMorphospecies__@VegCore__@vegpath.org",
6812
    taxonoccurrence.growthform AS "[growth_form=]habit__@SALVIAS__.Plot_data@vegpath.org",
6813
    plantobservation.reproductivecondition AS "reproductiveCondition__@DwC__@vegpath.org",
6814
    ((threatened_taxonlabel.taxonlabel_id IS NOT NULL))::integer AS threatened_bien,
6815
    (((cultivated_family_locations.country IS NOT NULL) OR _or(taxonoccurrence.iscultivated, "plot.**".location__cultivated__bien)))::integer AS cultivated_bien,
6816 6816
        CASE
6817 6817
            WHEN (taxonoccurrence.iscultivated IS NOT NULL) THEN taxonoccurrence.cultivatedbasis
6818 6818
            WHEN ("plot.**".location__cultivated__bien IS NOT NULL) THEN NULL::text
6819 6819
            ELSE NULL::text
6820
        END AS "cultivatedBasis_bien", 
6821
    aggregateoccurrence.notes AS "occurrenceRemarks__@DwC__@vegpath.org", 
6822
    _fraction_to_percent(aggregateoccurrence.cover_fraction) AS "coverPercent__@VegX__.attribute.ordinal@vegpath.org", 
6823
    _m_to_cm(stemobservation.diameterbreastheight_m) AS "stem_dbh[_cm]__@SALVIAS__.Plot_data@vegpath.org", 
6824
    stemobservation.height_m AS "stemHeight[_m]__@VegBank__.stemCount@vegpath.org", 
6825
    stemobservation.tag AS "[tag=]identificationLabel__@VegX__.individual@vegpath.org", 
6826
    stemobservation.xposition_m AS "relativeX[_m]__@VegX__.individualOrganismObs@vegpath.org", 
6827
    stemobservation.yposition_m AS "relativeY[_m]__@VegX__.individualOrganismObs@vegpath.org", 
6828
    taxonoccurrence.sourceaccessioncode AS "taxonObservation[.id]__@VegBank__@vegpath.org", 
6829
    taxonoccurrence.authortaxoncode AS "authorTaxonCode", 
6830
    aggregateoccurrence.sourceaccessioncode AS "aggregateOrganismObservation.id__@VegX__@vegpath.org", 
6831
    plantobservation.sourceaccessioncode AS "individualOrganismObservation.id__@VegX__@vegpath.org", 
6832
    plantobservation.authorplantcode AS "individualID__@DwC__@vegpath.org", 
6833
    aggregateoccurrence.count AS "individualCount__@DwC__@vegpath.org", 
6820
        END AS "cultivatedBasis_bien",
6821
    aggregateoccurrence.notes AS "occurrenceRemarks__@DwC__@vegpath.org",
6822
    _fraction_to_percent(aggregateoccurrence.cover_fraction) AS "coverPercent__@VegX__.attribute.ordinal@vegpath.org",
6823
    _m_to_cm(stemobservation.diameterbreastheight_m) AS "stem_dbh[_cm]__@SALVIAS__.Plot_data@vegpath.org",
6824
    stemobservation.height_m AS "stemHeight[_m]__@VegBank__.stemCount@vegpath.org",
6825
    stemobservation.tag AS "[tag=]identificationLabel__@VegX__.individual@vegpath.org",
6826
    stemobservation.xposition_m AS "relativeX[_m]__@VegX__.individualOrganismObs@vegpath.org",
6827
    stemobservation.yposition_m AS "relativeY[_m]__@VegX__.individualOrganismObs@vegpath.org",
6828
    taxonoccurrence.sourceaccessioncode AS "taxonObservation[.id]__@VegBank__@vegpath.org",
6829
    taxonoccurrence.authortaxoncode AS "authorTaxonCode",
6830
    aggregateoccurrence.sourceaccessioncode AS "aggregateOrganismObservation.id__@VegX__@vegpath.org",
6831
    plantobservation.sourceaccessioncode AS "individualOrganismObservation.id__@VegX__@vegpath.org",
6832
    plantobservation.authorplantcode AS "individualID__@DwC__@vegpath.org",
6833
    aggregateoccurrence.count AS "individualCount__@DwC__@vegpath.org",
6834 6834
    stemobservation.authorstemcode AS "stemCode__@VegBank__.stemLocation@vegpath.org"
6835 6835
   FROM ((((((((((((((("plot.**"
6836 6836
   LEFT JOIN taxonoccurrence ON ((taxonoccurrence.locationevent_id = "plot.**".locationevent__pkey)))
......
7885 7885
--
7886 7886

  
7887 7887
CREATE VIEW geoscrub_input_new AS
7888
 SELECT geoscrub_input.country, 
7889
    geoscrub_input."stateProvince", 
7890
    geoscrub_input.county, 
7891
    geoscrub_input."decimalLatitude", 
7888
 SELECT geoscrub_input.country,
7889
    geoscrub_input."stateProvince",
7890
    geoscrub_input.county,
7891
    geoscrub_input."decimalLatitude",
7892 7892
    geoscrub_input."decimalLongitude"
7893 7893
   FROM (geoscrub_input
7894 7894
   LEFT JOIN geoscrub.geoscrub_output ON ((((((geoscrub_output."decimalLatitude" = geoscrub_input."decimalLatitude") AND (geoscrub_output."decimalLongitude" = geoscrub_input."decimalLongitude")) AND (geoscrub_output.country = geoscrub_input.country)) AND (geoscrub_output."stateProvince" = geoscrub_input."stateProvince")) AND (geoscrub_output.county = geoscrub_input.county))))
......
7900 7900
--
7901 7901

  
7902 7902
CREATE VIEW geoscrub_input_view AS
7903
 SELECT DISTINCT place.country, 
7904
    place.stateprovince AS "stateProvince", 
7905
    place.county, 
7906
    coordinates.latitude_deg AS "decimalLatitude", 
7903
 SELECT DISTINCT place.country,
7904
    place.stateprovince AS "stateProvince",
7905
    place.county,
7906
    coordinates.latitude_deg AS "decimalLatitude",
7907 7907
    coordinates.longitude_deg AS "decimalLongitude"
7908 7908
   FROM (place
7909 7909
   JOIN coordinates USING (coordinates_id))
......
8312 8312
--
8313 8313

  
8314 8314
CREATE VIEW place_visit AS
8315
 SELECT locationevent.locationevent_id, 
8316
    locationevent.source_id, 
8317
    locationevent.sourceaccessioncode, 
8318
    locationevent.accesslevel, 
8319
    locationevent.place_visit_id, 
8320
    locationevent.parent_id, 
8321
    locationevent.location_id, 
8322
    locationevent.project_id, 
8323
    locationevent.stratum_id, 
8324
    locationevent.authoreventcode, 
8325
    locationevent.previous_id, 
8326
    locationevent.obsstartdate, 
8327
    locationevent.obsenddate, 
8328
    locationevent.dateaccuracy, 
8329
    locationevent.method_id, 
8330
    locationevent.temperature_c, 
8331
    locationevent.precipitation_m, 
8332
    locationevent.autotaxoncover, 
8333
    locationevent.originaldata, 
8334
    locationevent.effortlevel, 
8335
    locationevent.floristicquality, 
8336
    locationevent.bryophytequality, 
8337
    locationevent.lichenquality, 
8338
    locationevent.locationeventnarrative, 
8339
    locationevent.landscapenarrative, 
8340
    locationevent.homogeneity, 
8341
    locationevent.phenologicaspect, 
8342
    locationevent.representativeness, 
8343
    locationevent.standmaturity, 
8344
    locationevent.successionalstatus, 
8345
    locationevent.basalarea, 
8346
    locationevent.hydrologicregime, 
8347
    locationevent.soilmoistureregime, 
8348
    locationevent.soildrainage, 
8349
    locationevent.watersalinity, 
8350
    locationevent.waterdepth_m, 
8351
    locationevent.shoredistance, 
8352
    locationevent.soildepth, 
8353
    locationevent.organicdepth, 
8354
    locationevent.soiltaxon_id, 
8355
    locationevent.soiltaxonsrc, 
8356
    locationevent.percentbedrock, 
8357
    locationevent.percentrockgravel, 
8358
    locationevent.percentwood, 
8359
    locationevent.percentlitter, 
8360
    locationevent.percentbaresoil, 
8361
    locationevent.percentwater, 
8362
    locationevent.percentother, 
8363
    locationevent.nameother, 
8364
    locationevent.treeht, 
8365
    locationevent.shrubht, 
8366
    locationevent.fieldht, 
8367
    locationevent.nonvascularht, 
8368
    locationevent.submergedht, 
8369
    locationevent.treecover, 
8370
    locationevent.shrubcover, 
8371
    locationevent.fieldcover, 
8372
    locationevent.nonvascularcover, 
8373
    locationevent.floatingcover, 
8374
    locationevent.submergedcover, 
8375
    locationevent.dominantstratum, 
8376
    locationevent.growthform1type, 
8377
    locationevent.growthform2type, 
8378
    locationevent.growthform3type, 
8379
    locationevent.growthform1cover, 
8380
    locationevent.growthform2cover, 
8381
    locationevent.growthform3cover, 
8382
    locationevent.totalcover, 
8383
    locationevent.notespublic, 
8384
    locationevent.notesmgt, 
8385
    locationevent.revisions, 
8386
    locationevent.dateentered, 
8387
    locationevent.toptaxon1name, 
8388
    locationevent.toptaxon2name, 
8389
    locationevent.toptaxon3name, 
8390
    locationevent.toptaxon4name, 
8391
    locationevent.toptaxon5name, 
8315
 SELECT locationevent.locationevent_id,
8316
    locationevent.source_id,
8317
    locationevent.sourceaccessioncode,
8318
    locationevent.accesslevel,
8319
    locationevent.place_visit_id,
8320
    locationevent.parent_id,
8321
    locationevent.location_id,
8322
    locationevent.project_id,
8323
    locationevent.stratum_id,
8324
    locationevent.authoreventcode,
8325
    locationevent.previous_id,
8326
    locationevent.obsstartdate,
8327
    locationevent.obsenddate,
8328
    locationevent.dateaccuracy,
8329
    locationevent.method_id,
8330
    locationevent.temperature_c,
8331
    locationevent.precipitation_m,
8332
    locationevent.autotaxoncover,
8333
    locationevent.originaldata,
8334
    locationevent.effortlevel,
8335
    locationevent.floristicquality,
8336
    locationevent.bryophytequality,
8337
    locationevent.lichenquality,
8338
    locationevent.locationeventnarrative,
8339
    locationevent.landscapenarrative,
8340
    locationevent.homogeneity,
8341
    locationevent.phenologicaspect,
8342
    locationevent.representativeness,
8343
    locationevent.standmaturity,
8344
    locationevent.successionalstatus,
8345
    locationevent.basalarea,
8346
    locationevent.hydrologicregime,
8347
    locationevent.soilmoistureregime,
8348
    locationevent.soildrainage,
8349
    locationevent.watersalinity,
8350
    locationevent.waterdepth_m,
8351
    locationevent.shoredistance,
8352
    locationevent.soildepth,
8353
    locationevent.organicdepth,
8354
    locationevent.soiltaxon_id,
8355
    locationevent.soiltaxonsrc,
8356
    locationevent.percentbedrock,
8357
    locationevent.percentrockgravel,
8358
    locationevent.percentwood,
8359
    locationevent.percentlitter,
8360
    locationevent.percentbaresoil,
8361
    locationevent.percentwater,
8362
    locationevent.percentother,
8363
    locationevent.nameother,
8364
    locationevent.treeht,
8365
    locationevent.shrubht,
8366
    locationevent.fieldht,
8367
    locationevent.nonvascularht,
8368
    locationevent.submergedht,
8369
    locationevent.treecover,
8370
    locationevent.shrubcover,
8371
    locationevent.fieldcover,
8372
    locationevent.nonvascularcover,
8373
    locationevent.floatingcover,
8374
    locationevent.submergedcover,
8375
    locationevent.dominantstratum,
8376
    locationevent.growthform1type,
8377
    locationevent.growthform2type,
8378
    locationevent.growthform3type,
8379
    locationevent.growthform1cover,
8380
    locationevent.growthform2cover,
8381
    locationevent.growthform3cover,
8382
    locationevent.totalcover,
8383
    locationevent.notespublic,
8384
    locationevent.notesmgt,
8385
    locationevent.revisions,
8386
    locationevent.dateentered,
8387
    locationevent.toptaxon1name,
8388
    locationevent.toptaxon2name,
8389
    locationevent.toptaxon3name,
8390
    locationevent.toptaxon4name,
8391
    locationevent.toptaxon5name,
8392 8392
    locationevent.numberoftaxa
8393 8393
   FROM locationevent
8394 8394
  WHERE (locationevent.parent_id IS NULL);
......
8556 8556
--
8557 8557

  
8558 8558
CREATE VIEW plot AS
8559
 SELECT location.location_id AS plot_id, 
8560
    location.source_id, 
8561
    location.sourceaccessioncode, 
8562
    location.plot_location_id AS plot, 
8563
    location.parent_id, 
8564
    location.authorlocationcode, 
8565
    location.place_id, 
8566
    location.accesslevel, 
8567
    location.accessconditions, 
8568
    location.sublocationxposition_m, 
8569
    location.sublocationyposition_m, 
8570
    location.iscultivated, 
8571
    location.authorzone, 
8572
    location.authordatum, 
8573
    location.authorlocation, 
8574
    location.locationnarrative, 
8575
    location.azimuth, 
8576
    location.shape, 
8577
    location.area_m2, 
8578
    location.standsize, 
8579
    location.placementmethod, 
8580
    location.permanence, 
8581
    location.layoutnarrative, 
8582
    location.elevation_m, 
8583
    location.elevationaccuracy_m, 
8584
    location.elevationrange_m, 
8585
    location.verbatimelevation, 
8586
    location.slopeaspect_deg, 
8587
    location.minslopeaspect_deg, 
8588
    location.maxslopeaspect_deg, 
8589
    location.slopegradient_fraction, 
8590
    location.minslopegradient_fraction, 
8591
    location.maxslopegradient_fraction, 
8592
    location.topoposition, 
8593
    location.landform, 
8594
    location.surficialdeposits, 
8595
    location.rocktype, 
8596
    location.submitter_surname, 
8597
    location.submitter_givenname, 
8598
    location.submitter_email, 
8599
    location.notespublic, 
8600
    location.notesmgt, 
8601
    location.revisions, 
8602
    location.dateentered, 
8559
 SELECT location.location_id AS plot_id,
8560
    location.source_id,
8561
    location.sourceaccessioncode,
8562
    location.plot_location_id AS plot,
8563
    location.parent_id,
8564
    location.authorlocationcode,
8565
    location.place_id,
8566
    location.accesslevel,
8567
    location.accessconditions,
8568
    location.sublocationxposition_m,
8569
    location.sublocationyposition_m,
8570
    location.iscultivated,
8571
    location.authorzone,
8572
    location.authordatum,
8573
    location.authorlocation,
8574
    location.locationnarrative,
8575
    location.azimuth,
8576
    location.shape,
8577
    location.area_m2,
8578
    location.standsize,
8579
    location.placementmethod,
8580
    location.permanence,
8581
    location.layoutnarrative,
8582
    location.elevation_m,
8583
    location.elevationaccuracy_m,
8584
    location.elevationrange_m,
8585
    location.verbatimelevation,
8586
    location.slopeaspect_deg,
8587
    location.minslopeaspect_deg,
8588
    location.maxslopeaspect_deg,
8589
    location.slopegradient_fraction,
8590
    location.minslopegradient_fraction,
8591
    location.maxslopegradient_fraction,
8592
    location.topoposition,
8593
    location.landform,
8594
    location.surficialdeposits,
8595
    location.rocktype,
8596
    location.submitter_surname,
8597
    location.submitter_givenname,
8598
    location.submitter_email,
8599
    location.notespublic,
8600
    location.notesmgt,
8601
    location.revisions,
8602
    location.dateentered,
8603 8603
    location.locationrationalenarrative
8604 8604
   FROM location
8605 8605
  WHERE (location.parent_id IS NULL);
......
8693 8693
--
8694 8694

  
8695 8695
CREATE VIEW provider_count_view AS
8696
        ( SELECT s.dataprovider, 
8697
            s.dataset, 
8698
            s.records, 
8699
            s.sourcetype, 
8696
        ( SELECT s.dataprovider,
8697
            s.dataset,
8698
            s.records,
8699
            s.sourcetype,
8700 8700
            s.observationtype
8701
           FROM ( SELECT source.shortname AS dataprovider, 
8702
                    '(total)'::text AS dataset, 
8701
           FROM ( SELECT source.shortname AS dataprovider,
8702
                    '(total)'::text AS dataset,
8703 8703
                    ( SELECT count(*) AS count
8704 8704
                           FROM taxonoccurrence
8705
                          WHERE (taxonoccurrence.source_id = source.source_id)) AS records, 
8706
                    source.sourcetype, 
8705
                          WHERE (taxonoccurrence.source_id = source.source_id)) AS records,
8706
                    source.sourcetype,
8707 8707
                    source.observationtype
8708 8708
                   FROM source
8709 8709
                  WHERE (EXISTS ( SELECT NULL::unknown AS unknown
......
8711 8711
                          WHERE (taxonoccurrence.source_id = source.source_id)
8712 8712
                         LIMIT 1))) s
8713 8713
          ORDER BY s.records DESC)
8714
UNION ALL 
8715
        ( SELECT dataprovider.shortname AS dataprovider, 
8716
            s.dataset, 
8717
            s.records, 
8718
            dataset.sourcetype, 
8714
UNION ALL
8715
        ( SELECT dataprovider.shortname AS dataprovider,
8716
            s.dataset,
8717
            s.records,
8718
            dataset.sourcetype,
8719 8719
            COALESCE(dataset.observationtype, dataprovider.observationtype) AS observationtype
8720
           FROM ((( SELECT specimenreplicate.source_id AS dataprovider_id, 
8721
                    sourcename.name AS dataset, 
8722
                    sourcename.matched_source_id AS dataset_id, 
8720
           FROM ((( SELECT specimenreplicate.source_id AS dataprovider_id,
8721
                    sourcename.name AS dataset,
8722
                    sourcename.matched_source_id AS dataset_id,
8723 8723
                    count(*) AS records
8724 8724
                   FROM ((specimenreplicate
8725 8725
              JOIN sourcelist ON ((sourcelist.sourcelist_id = specimenreplicate.duplicate_institutions_sourcelist_id)))
......
8735 8735
--
8736 8736

  
8737 8737
CREATE VIEW range_modeling_input AS
8738
 SELECT analytical_stem.datasource AS source, 
8739
    analytical_stem."specimenHolderInstitutions" AS first_publisher, 
8740
    analytical_stem."decimalLatitude" AS latitude_deg, 
8741
    analytical_stem."decimalLongitude" AS longitude_deg, 
8742
    analytical_stem.geovalid_bien AS geovalid, 
8743
    analytical_stem.scrubbed_morphospecies_binomial AS species_taxon_name, 
8738
 SELECT analytical_stem.datasource AS source,
8739
    analytical_stem."specimenHolderInstitutions" AS first_publisher,
8740
    analytical_stem."decimalLatitude" AS latitude_deg,
8741
    analytical_stem."decimalLongitude" AS longitude_deg,
8742
    analytical_stem.geovalid_bien AS geovalid,
8743
    analytical_stem.scrubbed_morphospecies_binomial AS species_taxon_name,
8744 8744
    analytical_stem."higherPlantGroup_bien" AS higher_plant_group
8745 8745
   FROM analytical_stem
8746 8746
  WHERE (analytical_stem."higherPlantGroup_bien" IS NOT NULL);
......
9070 9070
--
9071 9071

  
9072 9072
CREATE VIEW taxon_trait_view AS
9073
 SELECT taxon_scrub.scrubbed_taxon_name_no_author AS "scientificName", 
9074
    trait.name AS "measurementType", 
9075
    trait.value AS "measurementValue", 
9073
 SELECT taxon_scrub.scrubbed_taxon_name_no_author AS "scientificName",
9074
    trait.name AS "measurementType",
9075
    trait.value AS "measurementValue",
9076 9076
    trait.units AS "measurementUnit"
9077 9077
   FROM (((((trait
9078 9078
   LEFT JOIN taxonoccurrence USING (taxonoccurrence_id))
......
9547 9547
--
9548 9548

  
9549 9549
CREATE VIEW _plots_04_count_of_plots_in_each_project_in_this_source AS
9550
 SELECT p.projectname AS project_name, 
9550
 SELECT p.projectname AS project_name,
9551 9551
    count(DISTINCT l.plot_id) AS plots
9552 9552
   FROM (((public.plot l
9553 9553
   JOIN public.locationevent le ON ((l.plot_id = le.location_id)))
......
9562 9562
--
9563 9563

  
9564 9564
CREATE VIEW _plots_05_list_of_plot_codes_by_project AS
9565
 SELECT p.projectname AS project_name, 
9565
 SELECT p.projectname AS project_name,
9566 9566
    l.authorlocationcode AS plot_code
9567 9567
   FROM (((public.plot l
9568 9568
   JOIN public.locationevent le ON ((l.plot_id = le.location_id)))
......
9576 9576
--
9577 9577

  
9578 9578
CREATE VIEW _plots_06_list_of_plots_with_stem_measurements AS
9579
 SELECT DISTINCT project.projectname AS project_name, 
9579
 SELECT DISTINCT project.projectname AS project_name,
9580 9580
    plot.authorlocationcode AS plot_code
9581 9581
   FROM ((public.plot
9582 9582
   JOIN public.locationevent USING (plot_id))
......
9597 9597
--
9598 9598

  
9599 9599
CREATE VIEW _plots_06a_list_of_stems AS
9600
 SELECT project.projectname AS project_name, 
9601
    plot.authorlocationcode AS plot_code, 
9600
 SELECT project.projectname AS project_name,
9601
    plot.authorlocationcode AS plot_code,
9602 9602
    stemobservation.sourceaccessioncode AS stem_id
9603 9603
   FROM ((((((public.plot
9604 9604
   JOIN public.locationevent USING (plot_id))
......
9616 9616
--
9617 9617

  
9618 9618
CREATE VIEW _plots_07_list_of_plots_which_use_counts_of_indiv_per_species AS
9619
 SELECT DISTINCT project.projectname AS project_name, 
9619
 SELECT DISTINCT project.projectname AS project_name,
9620 9620
    plot.authorlocationcode AS plot_code
9621 9621
   FROM ((public.plot
9622 9622
   JOIN public.locationevent USING (plot_id))
......
9635 9635
--
9636 9636

  
9637 9637
CREATE VIEW _plots_08_list_of_plots_which_use_percent_cover AS
9638
 SELECT project.projectname AS project_name, 
9638
 SELECT project.projectname AS project_name,
9639 9639
    plot.authorlocationcode AS plot_code
9640 9640
   FROM ((public.plot
9641 9641
   JOIN public.locationevent USING (plot_id))
......
9654 9654
--
9655 9655

  
9656 9656
CREATE VIEW _plots_09_list_of_plots_which_use_line_intercept AS
9657
 SELECT DISTINCT project.projectname AS project_name, 
9657
 SELECT DISTINCT project.projectname AS project_name,
9658 9658
    plot.authorlocationcode AS plot_code
9659 9659
   FROM ((public.plot
9660 9660
   JOIN public.locationevent USING (plot_id))
......
9673 9673
--
9674 9674

  
9675 9675
CREATE VIEW _plots_10_count_of_individuals_per_plot_in_each_project AS
9676
 SELECT p.projectname AS project_name, 
9677
    l.authorlocationcode AS plot_code, 
9676
 SELECT p.projectname AS project_name,
9677
    l.authorlocationcode AS plot_code,
9678 9678
    sum(ao.count) AS individuals
9679 9679
   FROM ((((((public.project p
9680 9680
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9704 9704
--
9705 9705

  
9706 9706
CREATE VIEW _plots_10a_aggregate_observation_individual_counts AS
9707
 SELECT p.projectname AS project_name, 
9708
    l.authorlocationcode AS plot_code, 
9709
    o.sourceaccessioncode AS individual_id, 
9707
 SELECT p.projectname AS project_name,
9708
    l.authorlocationcode AS plot_code,
9709
    o.sourceaccessioncode AS individual_id,
9710 9710
    ao.count AS individuals
9711 9711
   FROM ((((((public.project p
9712 9712
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9733 9733
--
9734 9734

  
9735 9735
CREATE VIEW _plots_11_count_of_stems_per_plot_in_each_project AS
9736
 SELECT p.projectname AS project_name, 
9737
    l.authorlocationcode AS plot_code, 
9736
 SELECT p.projectname AS project_name,
9737
    l.authorlocationcode AS plot_code,
9738 9738
    count(DISTINCT so.stemobservation_id) AS stems
9739 9739
   FROM ((((((((public.project p
9740 9740
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9764 9764
--
9765 9765

  
9766 9766
CREATE VIEW _plots_12_count_of_verbatim_taxa_per_plot_in_each_project AS
9767
 SELECT p.projectname AS project_name, 
9768
    l.authorlocationcode AS plot_code, 
9767
 SELECT p.projectname AS project_name,
9768
    l.authorlocationcode AS plot_code,
9769 9769
    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
9770 9770
   FROM (((((((public.project p
9771 9771
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9796 9796
--
9797 9797

  
9798 9798
CREATE VIEW _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_p AS
9799
 SELECT DISTINCT p.projectname AS project_name, 
9800
    l.authorlocationcode AS plot_code, 
9799
 SELECT DISTINCT p.projectname AS project_name,
9800
    l.authorlocationcode AS plot_code,
9801 9801
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon
9802 9802
   FROM (((((((public.project p
9803 9803
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9825 9825
--
9826 9826

  
9827 9827
CREATE VIEW _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pr AS
9828
 SELECT DISTINCT p.projectname AS project_name, 
9829
    l.authorlocationcode AS plot_code, 
9830
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon, 
9828
 SELECT DISTINCT p.projectname AS project_name,
9829
    l.authorlocationcode AS plot_code,
9830
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon,
9831 9831
    sum(ao.count) AS individuals
9832 9832
   FROM ((((((((public.project p
9833 9833
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9857 9857
--
9858 9858

  
9859 9859
CREATE VIEW _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_pro AS
9860
 SELECT DISTINCT p.projectname AS project_name, 
9861
    l.authorlocationcode AS plot_code, 
9862
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon, 
9860
 SELECT DISTINCT p.projectname AS project_name,
9861
    l.authorlocationcode AS plot_code,
9862
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon,
9863 9863
    sum(ci.coverpercent) AS totalpercentcover
9864 9864
   FROM (((((((((public.project p
9865 9865
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9893 9893
--
9894 9894

  
9895 9895
CREATE VIEW _plots_16_intercepts_for_each_verb_taxon_in_each_plot_each_proj AS
9896
 SELECT DISTINCT p.projectname AS project_name, 
9897
    l.authorlocationcode AS plot_code, 
9898
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon, 
9896
 SELECT DISTINCT p.projectname AS project_name,
9897
    l.authorlocationcode AS plot_code,
9898
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon,
9899 9899
    sum(ao.linecover_m) AS intercept_cm
9900 9900
   FROM ((((((((public.project p
9901 9901
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9926 9926
--
9927 9927

  
9928 9928
CREATE VIEW _plots_17_count_of_subplots_per_plot_for_each_project AS
9929
 SELECT p.projectname AS project_name, 
9930
    l.authorlocationcode AS plot_code, 
9929
 SELECT p.projectname AS project_name,
9930
    l.authorlocationcode AS plot_code,
9931 9931
    count(DISTINCT sub_locationevent.locationevent_id) AS subplots
9932 9932
   FROM ((((public.project p
9933 9933
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9944 9944
--
9945 9945

  
9946 9946
CREATE VIEW _plots_18_list_of_subplots_codes_for_each_plot_for_each_project AS
9947
 SELECT p.projectname AS project_name, 
9948
    l.authorlocationcode AS plot_code, 
9947
 SELECT p.projectname AS project_name,
9948
    l.authorlocationcode AS plot_code,
9949 9949
    sub_locationevent.authoreventcode AS subplot_code
9950 9950
   FROM ((((public.project p
9951 9951
   JOIN public.source s ON ((p.source_id = s.source_id)))
......
9970 9970
--
9971 9971

  
9972 9972
CREATE VIEW _plots_19_count_of_censuses_per_plot_in_each_project AS
9973
 SELECT project.projectname AS project_name, 
9974
    plot.authorlocationcode AS plot_code, 
9973
 SELECT project.projectname AS project_name,
9974
    plot.authorlocationcode AS plot_code,
9975 9975
    count(*) AS inventories
9976 9976
   FROM ((public.plot plot(location_id, source_id, sourceaccessioncode, plot, parent_id, authorlocationcode, place_id, accesslevel, accessconditions, sublocationxposition_m, sublocationyposition_m, iscultivated, authorzone, authordatum, authorlocation, locationnarrative, azimuth, shape, area_m2, standsize, placementmethod, permanence, layoutnarrative, elevation_m, elevationaccuracy_m, elevationrange_m, verbatimelevation, slopeaspect_deg, minslopeaspect_deg, maxslopeaspect_deg, slopegradient_fraction, minslopegradient_fraction, maxslopegradient_fraction, topoposition, landform, surficialdeposits, rocktype, submitter_surname, submitter_givenname, submitter_email, notespublic, notesmgt, revisions, dateentered, locationrationalenarrative)
9977 9977
   JOIN public.locationevent USING (location_id))
......
9986 9986
--
9987 9987

  
9988 9988
CREATE VIEW _plots_20_tnrs_names AS
9989
 SELECT taxonverbatim.taxonomicname AS verbatim_name_with_author, 
9990
    taxonlabel.taxonomicname AS tnrs_input_name, 
9991
    taxon_scrub."taxonomicStatus" AS tnrs_taxonomic_status, 
9992
    taxon_scrub.accepted_family AS tnrs_accepted_name_family, 
9993
    taxon_scrub.accepted_taxon_name_no_author AS tnrs_accepted_name, 
9994
    taxon_scrub.accepted_author AS tnrs_accepted_name_author, 
9989
 SELECT taxonverbatim.taxonomicname AS verbatim_name_with_author,
9990
    taxonlabel.taxonomicname AS tnrs_input_name,
9991
    taxon_scrub."taxonomicStatus" AS tnrs_taxonomic_status,
9992
    taxon_scrub.accepted_family AS tnrs_accepted_name_family,
9993
    taxon_scrub.accepted_taxon_name_no_author AS tnrs_accepted_name,
9994
    taxon_scrub.accepted_author AS tnrs_accepted_name_author,
9995 9995
    taxon_scrub.accepted_morphospecies_binomial AS taxon_morphospecies
9996 9996
   FROM ((public.taxonverbatim
9997 9997
   JOIN public.taxonlabel USING (taxonlabel_id))
......
10141 10141
CREATE VIEW _specimens_10_count_number_of_records_by_institution AS
10142 10142
 SELECT ( SELECT sourcelist.name
10143 10143
           FROM public.sourcelist
10144
          WHERE (sourcelist.sourcelist_id = specimenreplicate.duplicate_institutions_sourcelist_id)) AS specimen_duplicate_institutions, 
10144
          WHERE (sourcelist.sourcelist_id = specimenreplicate.duplicate_institutions_sourcelist_id)) AS specimen_duplicate_institutions,
10145 10145
    count(*) AS records
10146 10146
   FROM public.specimenreplicate
10147 10147
  WHERE (specimenreplicate.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname))
......
10153 10153
--
10154 10154

  
10155 10155
CREATE VIEW _specimens_11_list_of_three_standard_political_divisions AS
10156
 SELECT DISTINCT place.country, 
10157
    place.stateprovince AS "stateProvince", 
10156
 SELECT DISTINCT place.country,
10157
    place.stateprovince AS "stateProvince",
10158 10158
    place.county
10159 10159
   FROM public.place
10160 10160
  WHERE (place.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname));
......
10176 10176
CREATE VIEW _specimens_12_distinct_collector_name_collect_num_date_w_count AS
10177 10177
 SELECT ( SELECT party.fullname
10178 10178
           FROM public.party
10179
          WHERE (party.party_id = taxonoccurrence.collector_id)) AS "collectorName", 
10180
    specimenreplicate.collectionnumber AS "collectionNumber", 
10181
    (aggregateoccurrence.collectiondate)::text AS "dateCollected", 
10179
          WHERE (party.party_id = taxonoccurrence.collector_id)) AS "collectorName",
10180
    specimenreplicate.collectionnumber AS "collectionNumber",
10181
    (aggregateoccurrence.collectiondate)::text AS "dateCollected",
10182 10182
    count(*) AS "specimenRecords"
10183 10183
   FROM (((public.taxonoccurrence
10184 10184
   JOIN public.aggregateoccurrence USING (taxonoccurrence_id))
......
10200 10200
CREATE VIEW _specimens_13_count_of_all_verbatim_and_decimal_lat_long AS
10201 10201
 SELECT ( SELECT count(DISTINCT ROW(coordinates.latitude_deg, coordinates.longitude_deg, coordinates.verbatimlatitude, coordinates.verbatimlongitude, coordinates.coordsaccuracy_m)) AS count
10202 10202
           FROM public.coordinates
10203
          WHERE ((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (((coordinates.verbatimlatitude IS NOT NULL) OR (coordinates.latitude_deg IS NOT NULL)) OR ((coordinates.verbatimlongitude IS NOT NULL) OR (coordinates.longitude_deg IS NOT NULL))))) AS "allLatLongs", 
10203
          WHERE ((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (((coordinates.verbatimlatitude IS NOT NULL) OR (coordinates.latitude_deg IS NOT NULL)) OR ((coordinates.verbatimlongitude IS NOT NULL) OR (coordinates.longitude_deg IS NOT NULL))))) AS "allLatLongs",
10204 10204
    ( SELECT count(DISTINCT ROW(coordinates.latitude_deg, coordinates.longitude_deg, coordinates.verbatimlatitude, coordinates.verbatimlongitude, coordinates.coordsaccuracy_m)) AS count
10205 10205
           FROM public.coordinates
10206 10206
          WHERE (((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (coordinates.latitude_deg IS NOT NULL)) AND (coordinates.longitude_deg IS NOT NULL))) AS "decimalLatLongs";
......
10211 10211
--
10212 10212

  
10213 10213
CREATE VIEW _specimens_13a_list_of_all_verbatim_lat_long AS
10214
 SELECT DISTINCT COALESCE(coordinates.verbatimlatitude, (coordinates.latitude_deg)::text) AS "verbatimLatitude", 
10214
 SELECT DISTINCT COALESCE(coordinates.verbatimlatitude, (coordinates.latitude_deg)::text) AS "verbatimLatitude",
10215 10215
    COALESCE(coordinates.verbatimlatitude, (coordinates.longitude_deg)::text) AS "verbatimLongitude"
10216 10216
   FROM public.coordinates
10217 10217
  WHERE ((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (((coordinates.verbatimlatitude IS NOT NULL) OR (coordinates.latitude_deg IS NOT NULL)) OR ((coordinates.verbatimlongitude IS NOT NULL) OR (coordinates.longitude_deg IS NOT NULL))));
......
10222 10222
--
10223 10223

  
10224 10224
CREATE VIEW _specimens_13b_list_of_all_decimal_lat_long AS
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff