MINI MINI MANI MO
Rem
Rem $Header: sdo/admin/sdocsw.sql /main/15 2017/10/20 11:01:23 rjanders Exp $
Rem
Rem sdocsw.sql
Rem
Rem Copyright (c) 2014, 2017, Oracle and/or its affiliates.
Rem All rights reserved.
Rem
Rem NAME
Rem sdocsw.sql - <one-line expansion of the name>
Rem
Rem DESCRIPTION
Rem Header file for prvtcsw.sql.
Rem
Rem NOTES
Rem <other useful comments, qualifications, etc.>
Rem
Rem BEGIN SQL_FILE_METADATA
Rem SQL_SOURCE_FILE: sdo/admin/sdocsw.sql
Rem SQL_SHIPPED_FILE: md/admin/sdocsw.sql
Rem SQL_PHASE: SDOCSW
Rem SQL_STARTUP_MODE: NORMAL
Rem SQL_IGNORABLE_ERRORS: NONE
Rem SQL_CALLING_FILE: sdo/admin/sdowfscs.sql
Rem END SQL_FILE_METADATA
Rem
Rem MODIFIED (MM/DD/YY)
Rem rjanders 10/08/17 - Add MDSYS to spatial type
Rem bkazar 09/08/16 - extend generate_metadata_id to DCMI records
Rem bkazar 09/01/16 - Add Internal package sdo_csw_int
Rem bkazar 06/08/16 - Add parse_search function for PropertyIsLike
Rem Operator of GetRecords Request
Rem bkazar 03/29/16 - add record_extract, modify create_spatial_idx and add user table triggers
Rem bkazar 12/01/15 - XQFT-Text Index Tunes
Rem bgouslin 11/10/15 - Fix ID length issue per Siva R.
Rem bkazar 11/04/15 - Range query optimizations for XQFT index
Rem czechar 08/14/15 - add SQL file metadata
Rem bkazar 06/29/15 - Modify table_name to csw_table_name
Rem bkazar 06/26/15 - shorten insert_user_sdo_csw_service_info to
Rem insert_user_sdo_cswserviceinfo
Rem bkazar 06/17/15 - Renamings
Rem bkazar 03/25/15 - consistent formatting of procedure names etc.
Rem bkazar 02/25/15 - Use Metadata_Id (fileIdentifier) and
Rem add first generate_Metadata_Id procedure api.
Rem bkazar 12/04/14 - Created
Rem
@@?/rdbms/admin/sqlsessstart.sql
/* Move this package header to prvtcswih.sql for database version 13.1+. */
CREATE OR REPLACE PACKAGE MDSYS.SDO_CSW_INT AUTHID current_user AS
--------------------------------------------------------------------------------
-- Description:
-- This procedure optimizes the XML Query Full Text Index for Range Query by
-- first adding the prefix_ns_mapping, adding the sdata section, then setting the
-- sdata section to be opitimized for search.
-- Only the leaf XML elements (i.e., queryables/indexables) are listed.
-- These leaf XML elements (i.e., queryables/indexables) are for Summary mode and
-- they are listed in section 7.4.2 of OGC 07-045 document titled as
-- OpenGIS Catalogue Services Specification 2.0.2 - ISO Metadata Application Profile.
-- There is no limitation on the number of SDATA sections one can add. However,
-- if one XML element is only used for string equality comparison, there is no need
-- to add a SDATA section. The SDATA section is useful for range search like a > "foo", etc.
--------------------------------------------------------------------------------
procedure opt_rq_for_summary
(
csw_xsd_id IN NUMBER
);
--------------------------------------------------------------------------------
-- Populate in USER view of MDSYS.CSW_SERVICE_INFO (old name MDSYS.CSW_SCHEMANAME$)
--------------------------------------------------------------------------------
procedure insert_user_sdo_cswserviceinfo
(
owner IN VARCHAR2,
csw_version IN VARCHAR2,
csw_xsd_id IN NUMBER,
csw_table_name IN VARCHAR2
);
--------------------------------------------------------------------------------
-- Populate USER_SDO_GEOM_METADATA for USER CSW table if entry does not exist
--------------------------------------------------------------------------------
procedure insert_user_sdo_geom_metadata
(
owner IN VARCHAR2,
new_csw_table_name IN VARCHAR2,
new_column_name IN VARCHAR2,
diminfo IN mdsys.sdo_dim_array,
srid IN number
);
--------------------------------------------------------------------------------
-- Change USER_SDO_GEOM_METADATA for USER CSW table if entry exists
--------------------------------------------------------------------------------
procedure change_user_sdo_geom_metadata
(
owner IN VARCHAR2,
old_csw_table_name IN VARCHAR2,
old_column_name IN VARCHAR2,
new_csw_table_name IN VARCHAR2,
new_column_name IN VARCHAR2,
diminfo IN mdsys.sdo_dim_array,
srid IN number
);
--------------------------------------------------------------------------------
-- Description:
-- This procedure prints SDO_GEOMETRY
--------------------------------------------------------------------------------
procedure print_geom(geom MDSYS.SDO_GEOMETRY);
--------------------------------------------------------------------------------
-- Description:
-- Private function to find whether fileIdentifier Element exists within an XML instance
-- If neither of the XPATHs /MD_Metadata/fileIdentifier, /gmd:MD_Metadata/gmd:fileIdentifier exist,
-- this function returns 0; otherwise returns the number of times the XPATH appears.
--------------------------------------------------------------------------------
/*
function find_fileidentifier_element
(
xml_inst XMLType
)
RETURN NUMBER;
*/
--------------------------------------------------------------------------------
-- Description:
-- Private function to find whether an Element exists within an XML instance
-- If none of the XPATH(s) exist,
-- this function returns 0; otherwise returns the number of times the XPATH appears.
-- The lists have two elements: first without Namespace, the second with Namespace.
-- This is generic.
--------------------------------------------------------------------------------
function find_element
(
xml_inst XMLType,
xpath_list MDSYS.StringList,
name_space_list MDSYS.StringList
)
RETURN NUMBER;
--------------------------------------------------------------------------------
-- Description:
-- Private function to extract fileIdentifier Element from an XML instance
-- Due to calling sequence in generate_metadata_id procedure, it is guaranteed that
-- minimum 1 fileIdentifier element exists in the XML instance. However, this
-- function does not depend on such assumptions.
--------------------------------------------------------------------------------
/*
function extract_fileidentifier_element
(
xml_inst XMLType
)
RETURN MDSYS.StringList;
*/
--------------------------------------------------------------------------------
-- Description:
-- Private function to extract an Element from an XML instance
-- Due to calling sequence in generate_metadata_id procedure, it is guaranteed that
-- minimum 1 seeking element exists in the XML instance. However, this
-- function does not depend on such assumptions.
-- CSW_XSD_ID parameter can only be 1, 2, 3 respectively for DCMI, ISO19139 and INSPIRE.
-- The lists have two elements: first without Namespace, the second with Namespace.
-- This is generic.
--------------------------------------------------------------------------------
function extract_element
(
csw_xsd_id NUMBER,
xml_inst XMLType,
xpath_list MDSYS.StringList,
name_space_list MDSYS.StringList
)
RETURN MDSYS.StringList;
--------------------------------------------------------------------------------
-- Description:
-- Private function to get next value from MDSYS.MD_identifier_sq$ sequence.
--
--------------------------------------------------------------------------------
function generate_md_identifier_sq
RETURN VARCHAR2;
END SDO_CSW_INT;
/
show errors;
CREATE OR REPLACE PACKAGE MDSYS.SDO_CSW AUTHID current_user AS
--------------------------------------------------------------------------------
-- Description:
-- With all parameters it is aimed to create user tables, indexes and
-- to fill in the CSW 202+ metadata.
-- User can query the MDSYS.SDO_XSD_TABLE to see the available XSDs.
-- owner: database schema name for the user.
-- csw_version: the version of CSW ie, 202+ inclusive.
-- csw_xsd_id: ID of the XSD in MDSYS.SDO_XSD_TABLE.
-- csw_table_name: user's "preferred" table name for user CSW202+ data.
-- srid: SRID for the user CSW202+ data.
-- generate_index: is index desired to build- if > 0 build all indexes,
-- otherwise no indexes are built.
--
--
-- With only mandatory parameters (default functionality) where optional parameters are set as:
-- -- SRID parameter is NULL (default)
-- -- GENERATE_INDEX parameter is 0 (default)
-- -- OWNER.CSW_TABLE_NAME table exists
-- User creates tables and all indexes (ie, XQFT, Spatial indexes).
-- The CSW 202+ metadata is filled in here only and in this case it is equivalent to SDO_CSW.REGISTER_CSW procedure.
-- owner: database schema name
-- csw_version: the version of CSW ie, 202+ inclusive.
-- csw_xsd_id: ID of the XSD in MDSYS.SDO_XSD_TABLE.
-- csw_table_name: User CSW202+ table name for the data.
--
-- The csw_xsd_id parameter maps to the xsd_id column in MDSYS.SDO_XSD_TABLE table and also the csw_xsd_id column in MDSYS.CSW_SERVICE_INFO table.
--------------------------------------------------------------------------------
procedure initialize_csw
(
owner IN VARCHAR2,
csw_version IN VARCHAR2,
csw_xsd_id IN NUMBER,
csw_table_name IN VARCHAR2,
srid IN NUMBER DEFAULT NULL,
generate_index IN NUMBER DEFAULT 0
);
--------------------------------------------------------------------------------
-- Description:
-- Only does the population of ALL_SDO_CSW_SERVICE_INFO view.
-- The SDO_CSW.INITIALIZE_CSW procedure is equivalent to SDO_CSW.REGISTER_CSW procedure when:
-- -- SRID parameter is NULL (default)
-- -- GENERATE_INDEX parameter is 0 (default)
-- -- OWNER.CSW_TABLE_NAME table exists
-- and this procedure can be used in case User creates tables and all indexes
-- (ie, XQFT, Spatial indexes).
-- The CSW 202+ metadata is filled in here only.
-- owner: database schema name
-- csw_version: the version of CSW ie, 202+ inclusive.
-- csw_xsd_id: ID of the XSD in MDSYS.SDO_XSD_TABLE.
-- csw_table_name: User CSW202+ table name for the data.
--------------------------------------------------------------------------------
procedure register_csw
(
owner IN VARCHAR2,
csw_version IN VARCHAR2,
csw_xsd_id IN NUMBER,
csw_table_name IN VARCHAR2
);
--------------------------------------------------------------------------------
-- Description:
-- Executes as the Invoker and creates XQFT (XML Search-XPath Query Full Text) Index.
--------------------------------------------------------------------------------
procedure create_xqft_idx
(
owner IN VARCHAR2,
csw_table_name IN VARCHAR2
);
--------------------------------------------------------------------------------
-- Description:
-- Create Spatial index named as: CSW User Table Name appended by "IDX".
-- This procedure also extracts SDO_GEOMETRY from XMLType column of CSW User Table
-- and then creates Spatial Index if it does not exist.
--------------------------------------------------------------------------------
procedure create_spatial_idx
(
owner IN VARCHAR2,
csw_table_name IN VARCHAR2,
srid IN NUMBER
);
--------------------------------------------------------------------------------
-- Description:
-- Publishes the RecordType.
-- xsd_type could be DCMI, ISO19139 or INSPIRE.
-- This API is not publicly documented yet as of database version 12.2.0.1
-- as it is planned for some future public uses such as this: It is ok for now (12.2.0.1) but
-- for some future reason when the request can not be validated, this API may be needed
-- for GetRecords ResultType "validate" option.
--------------------------------------------------------------------------------
procedure publish_recordtype
(
record_type_name IN VARCHAR2,
record_type_namespace IN VARCHAR2,
xsd_type IN VARCHAR2
);
--------------------------------------------------------------------------------
-- Description:
-- Reads the DCMI identifier and the ISO19139 fileIdentifier (or MD_Identifier if fileIdentifier does not exist) element
-- from the Record_Instance_Xml XML column and inserts into Metadata_Id column of CSW user table; and
-- if fileIdentifier does not exist in the Record_Instance_Xml XML column doc or Record_Instance_Xml is NULL,
-- then we use sequence generator for Metadata_Id column.
-- Users will use this procedure while populating their data.
--
-- This procedure assumes USER/ALL_SDO_CSW_SERVICE_INFO view is already populated.
-- The SDO_CSW.REGISTER_CSW procedure only does the population of that view.
-- The SDO_CSW.INITIALIZE_CSW procedure is equivalent to SDO_CSW.REGISTER_CSW procedure when:
-- -- SRID parameter is NULL (default)
-- -- GENERATE_INDEX parameter is 0 (default)
-- -- OWNER.CSW_TABLE_NAME exists
--
-- This signature is for all rows of user table.
--------------------------------------------------------------------------------
procedure generate_metadata_id
(
owner IN VARCHAR2,
csw_table_name IN VARCHAR2
);
/*
--------------------------------------------------------------------------------
-- Description:
-- Reads the fileIdentifier element from the Record_Instance_Xml XML column and
-- inserts into Metadata_Id column of user table and if fileIdentifier does not
-- exist in the Record_Instance_Xml XML column doc or Record_Instance_Xml is NULL,
-- then we use sequence generator for Metadata_Id column. Users will use this
-- procedure while populating their data.
--
-- This signature is for a specific row of user table.
--------------------------------------------------------------------------------
procedure generate_metadata_id
(
owner IN VARCHAR2,
csw_table_name IN VARCHAR2,
rowId IN ROWID
);
*/
--------------------------------------------------------------------------------
-- Description:
-- This procedure sync's XML Query Full Text Index.
--------------------------------------------------------------------------------
procedure sync_index
(
owner VARCHAR2,
csw_table_name VARCHAR2
);
--------------------------------------------------------------------------------
-- Description:
-- This procedure first extracts the SDO_GEOMETRY object from a CSW Record and
-- then CS Transforms the SDO_GEOMETRY object if its SRID is different than the
-- to_srid parameter. This is called as MDSYS.SDO_CSW as SDO_CSW_INT is not public.
--------------------------------------------------------------------------------
function record_extract
(
record XMLType,
to_srid NUMBER,
csw_xsd_id NUMBER
)
RETURN MDSYS.SDO_GEOMETRY;
--------------------------------------------------------------------------------
-- Description:
-- This function prepares a String if it has any multi_wildcard (by default "%" character)
-- for the PropertyIsLike Operator of GetRecords Request.
-- Algorithm:
-- 1. Take out all the non-alphabetic(except escape and underscore) and non-wildcard characters, replacing them by spaces.
-- 2. Any multi-char wildcards surrounded by alphanumerics get replaced by "% ftAND %"
-- 3. Any other multi-char wildcards get replaced by %
-- 4. Each remaining word gets replaced with " ftAND "
-- This is called as MDSYS.SDO_CSW as SDO_CSW_INT is not public.
--------------------------------------------------------------------------------
function parse_search
(
input_string VARCHAR2,
multi_wildcard VARCHAR2 default '%'
)
RETURN VARCHAR2;
END SDO_CSW;
/
show errors;
create or replace public synonym SDO_CSW for mdsys.SDO_CSW;
show errors;
@?/rdbms/admin/sqlsessend.sql
OHA YOOOO