Package oracle.soda.rdbms
Interface OracleRDBMSMetadataBuilder
-
public interface OracleRDBMSMetadataBuilder
Builds custom collection metadata, expressed as a JSONOracleDocument
. The resultingOracleDocument
must be supplied toOracleDatabaseAdmin.createCollection(String, OracleDocument)
method to create a collection with the provided metadata. Custom collection metadata is needed when you want to specify, for example, how the collection is stored, or that the collection is read-only, or remove some of the optional (e.g. version, created-on timestamp, last modified timestamp) columns from the underlying table storing the collection. Custom collection metadata can also be used to map a pre-existing SQL table to a new SODA collection.The builder is created as follows:
OracleRDBMSClient client = ... OracleRDBMSMetadataBuilder builder = client.createMetadataBuilder();
The resulting builder is initialized with default metadata settings. These settings can be modified using variousOracleRDBMSMetadataBuilder
methods. For example, to change the key assignment method to client-assigned, and to change the content column type toVARCHAR2
, invokekeyColumnAssignmentMethod(String)
andcontentColumnType(String)
as follows:
builder.keyColumnAssignmentMethod("CLIENT").contentColumnType("VARCHAR2");
Once the desired changes to the default metadata settings are made, theOracleDocument
representing collection metadata in JSON should be created as follows:
OracleDocument metadata = builder.build();
This metadata document is supplied to theOracleDatabaseAdmin.createCollection(String, OracleDocument)
method to create a collection with the specified custom metadata:
OracleDatabase db = ... OracleCollection collection = db.admin().createCollection("myCollection", metadata);
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description OracleDocument
build()
Builds a JSON object containing the collection metadata.OracleRDBMSMetadataBuilder
contentColumnCache(boolean cache)
Sets the SecureFiles LOB cache setting for the content column.OracleRDBMSMetadataBuilder
contentColumnCompress(String compress)
Sets the SecureFiles LOB compress setting for the content column.OracleRDBMSMetadataBuilder
contentColumnEncrypt(String encrypt)
Sets the SecureFiles LOB encryption setting for the content column.OracleRDBMSMetadataBuilder
contentColumnMaxLength(int maxLength)
Sets the maximum length of the content column.OracleRDBMSMetadataBuilder
contentColumnName(String name)
Sets the name of the content column.OracleRDBMSMetadataBuilder
contentColumnType(String sqlType)
Sets the SQL type of the content column.OracleRDBMSMetadataBuilder
contentColumnValidation(String validation)
Sets the validation mode for the content column.OracleRDBMSMetadataBuilder
creationTimeColumnName(String name)
Sets the optional creation time column name.OracleRDBMSMetadataBuilder
dualityViewName(String dualityViewName)
OracleRDBMSMetadataBuilder
keyColumnAssignmentMethod(String assignmentMethod)
Sets the key column assignment method.OracleRDBMSMetadataBuilder
keyColumnMaxLength(int maxLength)
Sets the maximum size of the key column.OracleRDBMSMetadataBuilder
keyColumnName(String name)
Sets the name of the key column.OracleRDBMSMetadataBuilder
keyColumnSequenceName(String sequenceName)
Sets the sequence name for sequence-based keys.OracleRDBMSMetadataBuilder
keyColumnType(String sqlType)
Sets the key column type.OracleRDBMSMetadataBuilder
lastModifiedColumnIndex(String index)
Sets the last-modified column index name.OracleRDBMSMetadataBuilder
lastModifiedColumnName(String name)
Sets the optional last-modified timestamp column name.OracleRDBMSMetadataBuilder
mediaTypeColumnName(String name)
Sets the media type column name.OracleRDBMSMetadataBuilder
readOnly(boolean readOnly)
Sets the read/write policy.OracleRDBMSMetadataBuilder
removeOptionalColumns()
Removes the optional metadata columns.OracleRDBMSMetadataBuilder
schemaName(String schemaName)
Sets the SQL schema name for the underlying database object.OracleRDBMSMetadataBuilder
tableName(String tableName)
Sets the SQL table name.OracleRDBMSMetadataBuilder
versionColumnMethod(String method)
Sets version column method.OracleRDBMSMetadataBuilder
versionColumnName(String name)
Sets the version (ETag) column name.OracleRDBMSMetadataBuilder
viewName(String viewName)
Sets the SQL view name.
-
-
-
Method Detail
-
build
OracleDocument build() throws OracleException
Builds a JSON object containing the collection metadata. AnOracleException
will be raised if an invalid configuration is detected. The specific validation errors that may occur are documented throughout this interface.- Returns:
- The JSON collection metadata encoded as UTF-8
- Throws:
OracleException
- if an invalid combination is detected- See Also:
OracleDatabaseAdmin.createCollection(String, OracleDocument)
-
schemaName
OracleRDBMSMetadataBuilder schemaName(String schemaName)
Sets the SQL schema name for the underlying database object. IfschemaName
isnull
, the schema associated with the connection will be used.- Parameters:
schemaName
- the name of the schema ornull
- Returns:
- a reference to this object
-
tableName
OracleRDBMSMetadataBuilder tableName(String tableName)
Sets the SQL table name. A collection is based off of a table or a view. Calling this method will override the view name if previously set usingviewName(String)
. IftableName
isnull
, the collection will be created using a table name based on the name of the collection name.- Parameters:
tableName
- the name of the table. May benull
- Returns:
- a reference to this object
- See Also:
viewName(String)
-
viewName
OracleRDBMSMetadataBuilder viewName(String viewName)
Sets the SQL view name. A collection is based off of a table or a view. Calling this method will override the table name if previously set usingtableName(String)
IfviewName
isnull
, the collection will be created using a table name based on the name of the collection name.- Parameters:
viewName
- the name of the view. May benull
- Returns:
- a reference to this object
- See Also:
tableName(String)
-
dualityViewName
OracleRDBMSMetadataBuilder dualityViewName(String dualityViewName)
-
contentColumnName
OracleRDBMSMetadataBuilder contentColumnName(String name)
Sets the name of the content column. Ifname
isnull
, the default value"JSON_DOCUMENT"
is used.- Parameters:
name
- the name of the column. May benull
- Returns:
- a reference to this object
-
contentColumnType
OracleRDBMSMetadataBuilder contentColumnType(String sqlType) throws OracleException
Sets the SQL type of the content column. The value must be either"VARCHAR2"
,"NVARCHAR2"
,"RAW"
,"BLOB"
,"CLOB"
, or"NCLOB"
. IfsqlType
isnull
, the default value"BLOB"
is used.Changing the content column type may automatically remove other related settings:
- Setting to LOB type will remove the content column maximum length.
- Setting to a non-LOB type will remove all SecureFile LOB settings.
- Parameters:
sqlType
- the type of the content column. May benull
- Returns:
- a reference to this object
- Throws:
OracleException
- ifsqlType
is not one of the expected values
-
contentColumnMaxLength
OracleRDBMSMetadataBuilder contentColumnMaxLength(int maxLength) throws OracleException
Sets the maximum length of the content column. IfmaxLength
is 0, then the maximum is unspecified and the default value of 2000 will be used, if applicable. If the content column type is a LOB type and a maximum length is specified, an error will be raised whenbuild()
is called.- Parameters:
maxLength
- the maximum size- Returns:
- a reference to this object
- Throws:
OracleException
- ifmaxLength
is negative- See Also:
contentColumnType(String)
-
contentColumnValidation
OracleRDBMSMetadataBuilder contentColumnValidation(String validation) throws OracleException
Sets the validation mode for the content column. The value ofvalidation
must be one of"STANDARD"
,"STRICT"
, or"LAX"
. Ifvalidation
isnull
, the default"STANDARD"
mode is used.- Parameters:
validation
- the validation mode. May benull
- Returns:
- a reference to this object.
- Throws:
OracleException
- ifvalidation
is notnull
,"STANDARD"
,"STRICT"
, or"LAX"
-
contentColumnCompress
OracleRDBMSMetadataBuilder contentColumnCompress(String compress) throws OracleException
Sets the SecureFiles LOB compress setting for the content column. The value ofcompress
must be one of"NONE"
,"HIGH"
,"MEDIUM"
, or"LOW"
. This setting is not applicable if thecontent column type
is not a LOB type. Ifcompress
isnull
, the default value"NONE"
is used.If the compression is set to something other than
"NONE"
and the column is not a LOB type, an error will be raised whenbuild()
is called.- Parameters:
compress
- the compression mode. May benull
- Returns:
- a reference to this object
- Throws:
OracleException
- ifcompress
is not one of the expected values- See Also:
contentColumnType(String)
-
contentColumnCache
OracleRDBMSMetadataBuilder contentColumnCache(boolean cache)
Sets the SecureFiles LOB cache setting for the content column. This setting is not applicable if thecontent column type
is not a LOB type. The default value istrue
.If the
cache
istrue
and the column is not a LOB type, an error will be raised whenbuild()
is called.- Parameters:
cache
- specifies if caching is used- Returns:
- a reference to this object
- See Also:
contentColumnType(String)
-
contentColumnEncrypt
OracleRDBMSMetadataBuilder contentColumnEncrypt(String encrypt) throws OracleException
Sets the SecureFiles LOB encryption setting for the content column. The value ofencrypt
must be"NONE"
,"3DES168"
,"AES128"
,"AES192"
,"AES256"
. Ifencrypt
is null, the default value"NONE"
is used. This setting is not applicable if thecontent column type
is not a LOB type. Ifencrypt
is anything other than"NONE"
and the column is not a LOB type, an error will be raised whenbuild()
is called.- Parameters:
encrypt
- the encryption type. May benull
- Returns:
- a reference to this object
- Throws:
OracleException
- ifencrypt
is not one of the expected values- See Also:
contentColumnType(String)
-
keyColumnName
OracleRDBMSMetadataBuilder keyColumnName(String name)
Sets the name of the key column. Ifname
is null, they default value"ID"
is used.- Parameters:
name
- the name of the key column. May benull
- Returns:
- a reference to this object
-
keyColumnType
OracleRDBMSMetadataBuilder keyColumnType(String sqlType) throws OracleException
Sets the key column type. The value ofsqlType
must be one of"VARCHAR2"
,"NVARCHAR2"
,"NUMBER"
, or"RAW"
. IfsqlType
isnull
, the default value"VARCHAR2"
will be used. Setting the key column type to"NUMBER"
or"RAW"
automatically removes the maximum size of the key column.- Parameters:
sqlType
- the key column type. May benull
- Returns:
- a reference to this object
- Throws:
OracleException
- ifsqlType
is not one of the expected values.
-
keyColumnMaxLength
OracleRDBMSMetadataBuilder keyColumnMaxLength(int maxLength) throws OracleException
Sets the maximum size of the key column. IfmaxLength
is 0, then the maximum is unspecified and the default value of 255 will be used, if applicable. If the key column type isNUMBER
orRAW
and a maximum length is specified, an error will be raised whenbuild()
is called.- Parameters:
maxLength
- the maximum size- Returns:
- a reference to this object
- Throws:
OracleException
- ifmaxLength
is negative- See Also:
keyColumnType(String)
-
keyColumnAssignmentMethod
OracleRDBMSMetadataBuilder keyColumnAssignmentMethod(String assignmentMethod) throws OracleException
Sets the key column assignment method. The value ofassignmentMethod
must be one of"SEQUENCE"
,"GUID"
,"UUID"
, or"CLIENT"
. IfassignmentMethod
isnull
, the default value"UUID"
will be used. IfassignmentMethod
is anything other than"SEQUENCE"
, the key column sequence name will be automatically removed. If the assignment method is"SEQUENCE"
but no key column sequence name is specified, an error will be raised whenbuild()
is called.- Parameters:
assignmentMethod
- the key column assignment method. May benull
- Returns:
- a reference to this object
- Throws:
OracleException
- ifassignmentMethod
is not one of the expected values- See Also:
keyColumnSequenceName(String)
-
keyColumnSequenceName
OracleRDBMSMetadataBuilder keyColumnSequenceName(String sequenceName)
Sets the sequence name for sequence-based keys. IfsequenceName
isnull
, the sequence name is unspecified. Specifying a sequence name automatically changes the key column assignment method to"SEQUENCE"
.- Parameters:
sequenceName
- the name of the sequence. May benull
- Returns:
- a reference to this object
- See Also:
keyColumnAssignmentMethod(String)
-
creationTimeColumnName
OracleRDBMSMetadataBuilder creationTimeColumnName(String name)
Sets the optional creation time column name. Ifname
isnull
, no creation time column will be used. The default value is"CREATED_ON"
.- Parameters:
name
- the name of the column. May benull
- Returns:
- a reference to this object
-
lastModifiedColumnName
OracleRDBMSMetadataBuilder lastModifiedColumnName(String name)
Sets the optional last-modified timestamp column name. Ifname
isnull
, no last-modified column will be used and the last-modified column index will automatically be removed. The default value is"LAST_MODIFIED"
.- Parameters:
name
- the name of the column. May benull
- Returns:
- a reference to this object
- See Also:
lastModifiedColumnIndex(String)
-
lastModifiedColumnIndex
OracleRDBMSMetadataBuilder lastModifiedColumnIndex(String index)
Sets the last-modified column index name. Ifindex
isnull
, the index name is unspecified. If the last-modified index name is specified but the last-modified column name is not set, an error will be raised whenbuild()
is called.- Parameters:
index
- the name of the index. May benull
- Returns:
- a reference to this object
- See Also:
lastModifiedColumnName(String)
-
versionColumnName
OracleRDBMSMetadataBuilder versionColumnName(String name)
Sets the version (ETag) column name. Ifname
isnull
, the version column will not be used and the version column method will automatically set to"NONE"
. The default value is"VERSION"
.- Parameters:
name
- the name of the column. May benull
- Returns:
- a reference to this object
- See Also:
versionColumnMethod(String)
-
versionColumnMethod
OracleRDBMSMetadataBuilder versionColumnMethod(String method) throws OracleException
Sets version column method. The value ofmethod
must be"SEQUENTIAL"
,"TIMESTAMP"
,"UUID"
,"SHA256"
,"MD5"
, or"NONE"
. Ifmethod
isnull
, the default value"NONE"
is used. If the version column method is not"NONE"
and the version column name is not specified, an error will be raised whenbuild()
is called.- Parameters:
method
- the version method. May benull
- Returns:
- a reference to this object
- Throws:
OracleException
- ifmethod
is not one of the expected values
-
mediaTypeColumnName
OracleRDBMSMetadataBuilder mediaTypeColumnName(String name)
Sets the media type column name. Ifname
isnull
, the media type column is unspecified and a media type column will not be used. If thecontent column type
is not"BLOB"
and the media type column is specified, an error will be raised whenbuild()
is called. By default, the media type column is unspecified.- Parameters:
name
- the name of the media type column. May benull
- Returns:
- a reference to this object
-
readOnly
OracleRDBMSMetadataBuilder readOnly(boolean readOnly)
Sets the read/write policy. The default value isfalse
.- Parameters:
readOnly
- when true, specifies the collection is read only- Returns:
- a reference to this object
-
removeOptionalColumns
OracleRDBMSMetadataBuilder removeOptionalColumns()
Removes the optional metadata columns. This method is useful when creating a collection over an existing table where these columns may not exist.Calling this method is equivalent to the following:
this .creationTimeColumnName(null) .lastModifiedColumnName(null) .versionColumnName(null) .mediaTypeColumnName(null);
- Returns:
- a reference to this object
-
-