935 |
935 |
|
936 |
936 |
|
937 |
937 |
--
|
938 |
|
-- Name: sync_darwin_core_to_view(); Type: FUNCTION; Schema: public; Owner: -
|
939 |
|
--
|
940 |
|
|
941 |
|
CREATE FUNCTION sync_darwin_core_to_view() RETURNS void
|
942 |
|
LANGUAGE sql
|
943 |
|
AS $$
|
944 |
|
DROP TABLE IF EXISTS darwin_core;
|
945 |
|
CREATE TABLE darwin_core AS SELECT * FROM darwin_core_view;
|
946 |
|
|
947 |
|
CREATE INDEX ON darwin_core ("institutionCode", "projectID", "plotName", "dateCollected" );
|
948 |
|
CREATE INDEX ON darwin_core ("institutionCode", "occurrenceID" );
|
949 |
|
CREATE INDEX ON darwin_core ("institutionCode", "subInstitutionCode", "collectionCode", "catalogNumber" );
|
950 |
|
CREATE INDEX ON darwin_core ("institutionCode", "catalogNumber" );
|
951 |
|
$$;
|
952 |
|
|
953 |
|
|
954 |
|
--
|
955 |
938 |
-- Name: sync_geoscrub_input_to_view(); Type: FUNCTION; Schema: public; Owner: -
|
956 |
939 |
--
|
957 |
940 |
|
... | ... | |
2825 |
2808 |
|
2826 |
2809 |
|
2827 |
2810 |
--
|
2828 |
|
-- Name: darwin_core; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
2829 |
|
--
|
2830 |
|
|
2831 |
|
CREATE TABLE darwin_core (
|
2832 |
|
"institutionCode" text,
|
2833 |
|
"subInstitutionCode" text,
|
2834 |
|
"collectionCode" text,
|
2835 |
|
"catalogNumber" text,
|
2836 |
|
"occurrenceID" text,
|
2837 |
|
country text,
|
2838 |
|
"stateProvince" text,
|
2839 |
|
county text,
|
2840 |
|
"decimalLatitude" double precision,
|
2841 |
|
"decimalLongitude" double precision,
|
2842 |
|
"coordinateUncertaintyInMeters" double precision,
|
2843 |
|
geovalid boolean,
|
2844 |
|
"isNewWorld" boolean,
|
2845 |
|
"projectID" integer,
|
2846 |
|
"plotName" text,
|
2847 |
|
"elevationInMeters" double precision,
|
2848 |
|
"plotArea_ha" double precision,
|
2849 |
|
"samplingProtocol" text,
|
2850 |
|
"dateCollected" date,
|
2851 |
|
"higherPlantGroup" higher_plant_group,
|
2852 |
|
family text,
|
2853 |
|
genus text,
|
2854 |
|
"speciesBinomial" text,
|
2855 |
|
"scientificName" text,
|
2856 |
|
"scientificNameAuthorship" text,
|
2857 |
|
"speciesBinomialWithMorphospecies" text,
|
2858 |
|
"scientificNameWithMorphospecies" text,
|
2859 |
|
threatened boolean,
|
2860 |
|
"identifiedBy" text,
|
2861 |
|
"growthForm" growthform,
|
2862 |
|
cultivated boolean,
|
2863 |
|
"cultivatedBasis" text,
|
2864 |
|
"recordedBy" text,
|
2865 |
|
"recordNumber" text,
|
2866 |
|
"coverPercent" double precision,
|
2867 |
|
"diameterBreastHeight_cm" double precision,
|
2868 |
|
height_m double precision,
|
2869 |
|
tag text,
|
2870 |
|
"organismX_m" double precision,
|
2871 |
|
"organismY_m" double precision,
|
2872 |
|
"taxonOccurrenceID" text,
|
2873 |
|
"authorTaxonCode" text,
|
2874 |
|
"individualID" text,
|
2875 |
|
"authorStemCode" text
|
2876 |
|
);
|
2877 |
|
|
2878 |
|
|
2879 |
|
--
|
2880 |
|
-- Name: darwin_core_view; Type: VIEW; Schema: public; Owner: -
|
2881 |
|
--
|
2882 |
|
|
2883 |
|
CREATE VIEW darwin_core_view AS
|
2884 |
|
SELECT source.shortname AS "institutionCode", sourcename.name AS "subInstitutionCode", specimenreplicate.collectioncode_dwc AS "collectionCode", specimenreplicate.catalognumber_dwc AS "catalogNumber", specimenreplicate.sourceaccessioncode AS "occurrenceID", canon_place.country, canon_place.stateprovince AS "stateProvince", datasource_place.county, coordinates.latitude_deg AS "decimalLatitude", coordinates.longitude_deg AS "decimalLongitude", coordinates.coordsaccuracy_m AS "coordinateUncertaintyInMeters", canon_place.geovalid, "newWorldCountries"."isNewWorld", locationevent.project_id AS "projectID", COALESCE(location.sourceaccessioncode, location.authorlocationcode) AS "plotName", location.elevation_m AS "elevationInMeters", _m2_to_ha(location.area_m2) AS "plotArea_ha", method.name AS "samplingProtocol", COALESCE(locationevent.obsstartdate, parent_plot_event.obsstartdate, aggregateoccurrence.collectiondate) AS "dateCollected", family_higher_plant_group.higher_plant_group AS "higherPlantGroup", accepted_taxonverbatim.family, accepted_taxonverbatim.genus, ((accepted_taxonverbatim.genus || ' '::text) || accepted_taxonverbatim.specific_epithet) AS "speciesBinomial", COALESCE(accepted_taxonverbatim.taxonomicname, accepted_taxonverbatim.taxonname) AS "scientificName", accepted_taxonverbatim.author AS "scientificNameAuthorship", NULLIF(array_to_string(ARRAY[COALESCE(accepted_taxonverbatim.genus, accepted_taxonverbatim.family), COALESCE(accepted_taxonverbatim.specific_epithet, parsed_taxonverbatim.morphospecies)], ' '::text), ''::text) AS "speciesBinomialWithMorphospecies", NULLIF(array_to_string(ARRAY[accepted_taxonverbatim.taxonomicname, parsed_taxonverbatim.morphospecies], ' '::text), ''::text) AS "scientificNameWithMorphospecies", (threatened_taxonlabel.taxonlabel_id IS NOT NULL) AS threatened, identifiedby.fullname AS "identifiedBy", taxonoccurrence.growthform AS "growthForm", ((cultivated_family_locations.country IS NOT NULL) OR _or(taxonoccurrence.iscultivated, location.iscultivated)) AS cultivated, CASE WHEN (taxonoccurrence.iscultivated IS NOT NULL) THEN taxonoccurrence.cultivatedbasis WHEN (location.iscultivated IS NOT NULL) THEN NULL::text ELSE NULL::text END AS "cultivatedBasis", collector.fullname AS "recordedBy", plantobservation.collectionnumber AS "recordNumber", _fraction_to_percent(aggregateoccurrence.cover_fraction) AS "coverPercent", _m_to_cm(stemobservation.diameterbreastheight_m) AS "diameterBreastHeight_cm", stemobservation.height_m, stemobservation.tag, stemobservation.xposition_m AS "organismX_m", stemobservation.yposition_m AS "organismY_m", taxonoccurrence.sourceaccessioncode AS "taxonOccurrenceID", taxonoccurrence.authortaxoncode AS "authorTaxonCode", plantobservation.sourceaccessioncode AS "individualID", stemobservation.authorstemcode AS "authorStemCode" FROM (((((((((((((((((((((((((((((source JOIN location USING (source_id)) LEFT JOIN locationplace USING (location_id)) LEFT JOIN place datasource_place USING (place_id)) LEFT JOIN place canon_place ON ((canon_place.place_id = datasource_place.canon_place_id))) LEFT JOIN coordinates ON ((coordinates.coordinates_id = canon_place.coordinates_id))) LEFT JOIN "newWorld".iso_code_gadm ON ((iso_code_gadm."GADM country" = canon_place.country))) LEFT JOIN "newWorld"."newWorldCountries" ON (("newWorldCountries"."isoCode" = iso_code_gadm."2-digit iso code"))) LEFT JOIN locationevent USING (location_id)) LEFT JOIN project USING (project_id)) LEFT JOIN method USING (method_id)) LEFT JOIN taxonoccurrence USING (locationevent_id)) LEFT JOIN locationevent parent_plot_event ON ((parent_plot_event.locationevent_id = locationevent.parent_id))) LEFT JOIN party collector ON ((collector.party_id = taxonoccurrence.collector_id))) LEFT JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) LEFT JOIN taxonverbatim datasource_taxonverbatim USING (taxonverbatim_id)) LEFT JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) LEFT JOIN taxonlabel parsed_taxonlabel ON ((parsed_taxonlabel.taxonlabel_id = datasource_taxonlabel.matched_label_id))) LEFT JOIN taxonverbatim parsed_taxonverbatim ON ((parsed_taxonverbatim.taxonlabel_id = parsed_taxonlabel.taxonlabel_id))) LEFT JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.canon_label_id))) LEFT JOIN taxonverbatim accepted_taxonverbatim ON ((accepted_taxonverbatim.taxonlabel_id = accepted_taxonlabel.taxonlabel_id))) LEFT JOIN threatened_taxonlabel ON ((threatened_taxonlabel.taxonlabel_id = accepted_taxonlabel.taxonlabel_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN family_higher_plant_group ON ((family_higher_plant_group.family = accepted_taxonverbatim.family))) LEFT JOIN cultivated_family_locations ON (((cultivated_family_locations.family = accepted_taxonverbatim.family) AND (cultivated_family_locations.country = canon_place.country)))) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN stemobservation USING (plantobservation_id)) LEFT JOIN specimenreplicate USING (plantobservation_id)) LEFT JOIN sourcename ON ((sourcename.sourcename_id = specimenreplicate.institution_id)));
|
2885 |
|
|
2886 |
|
|
2887 |
|
--
|
2888 |
2811 |
-- Name: dba_preassignacccode_dba_requestnumber_seq; Type: SEQUENCE; Schema: public; Owner: -
|
2889 |
2812 |
--
|
2890 |
2813 |
|
... | ... | |
5099 |
5022 |
|
5100 |
5023 |
|
5101 |
5024 |
--
|
5102 |
|
-- Data for Name: darwin_core; Type: TABLE DATA; Schema: public; Owner: -
|
5103 |
|
--
|
5104 |
|
|
5105 |
|
|
5106 |
|
|
5107 |
|
--
|
5108 |
5025 |
-- Data for Name: definedvalue; Type: TABLE DATA; Schema: public; Owner: -
|
5109 |
5026 |
--
|
5110 |
5027 |
|
... | ... | |
6109 |
6026 |
|
6110 |
6027 |
|
6111 |
6028 |
--
|
6112 |
|
-- Name: darwin_core_institutionCode_catalogNumber_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
6113 |
|
--
|
6114 |
|
|
6115 |
|
CREATE INDEX "darwin_core_institutionCode_catalogNumber_idx" ON darwin_core USING btree ("institutionCode", "catalogNumber");
|
6116 |
|
|
6117 |
|
|
6118 |
|
--
|
6119 |
|
-- Name: darwin_core_institutionCode_occurrenceID_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
6120 |
|
--
|
6121 |
|
|
6122 |
|
CREATE INDEX "darwin_core_institutionCode_occurrenceID_idx" ON darwin_core USING btree ("institutionCode", "occurrenceID");
|
6123 |
|
|
6124 |
|
|
6125 |
|
--
|
6126 |
|
-- Name: darwin_core_institutionCode_projectID_plotName_dateCollecte_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
6127 |
|
--
|
6128 |
|
|
6129 |
|
CREATE INDEX "darwin_core_institutionCode_projectID_plotName_dateCollecte_idx" ON darwin_core USING btree ("institutionCode", "projectID", "plotName", "dateCollected");
|
6130 |
|
|
6131 |
|
|
6132 |
|
--
|
6133 |
|
-- Name: darwin_core_institutionCode_subInstitutionCode_collectionCo_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
6134 |
|
--
|
6135 |
|
|
6136 |
|
CREATE INDEX "darwin_core_institutionCode_subInstitutionCode_collectionCo_idx" ON darwin_core USING btree ("institutionCode", "subInstitutionCode", "collectionCode", "catalogNumber");
|
6137 |
|
|
6138 |
|
|
6139 |
|
--
|
6140 |
6029 |
-- Name: graphic_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
6141 |
6030 |
--
|
6142 |
6031 |
|
schemas/vegbien.sql: Removed no longer needed darwin_core table. Use analytical_stem instead, which is now identical.