Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

oracle.jdeveloper.offlinedb
Class OfflineDBObjectProvider

java.lang.Object
  extended by oracle.javatools.db.AbstractDBObjectProvider
      extended by oracle.jdeveloper.offlinedb.OfflineDBObjectProvider
All Implemented Interfaces:
DBObjectProvider

public abstract class OfflineDBObjectProvider
extends AbstractDBObjectProvider

Extension of DBObjectProvider for the offline projects. Instead of the object definitions being stored in a Database Dictionary they are stored as XML files in a Project.

See DBObjectProvider for a full list of the methods available. Where the offline database has specific behaviour for a method it will have doc included (overriden) for this class.

For more information on using the offlinedb read the package documentation.

See Also:
oracle.jdeveloper.offlinedb

Field Summary
 
Fields inherited from class oracle.javatools.db.AbstractDBObjectProvider
CASE_SENSITIVE_NAME_POLICY, EMPTY_LIST, LOWER_CASE_NAME_POLICY, MIXED_CASE_NAME_POLICY, NEW_FROM_TEMPLATE_TYPE, TIMESTAMP_PROPERTY, UPPER_CASE_NAME_POLICY
 
Fields inherited from interface oracle.javatools.db.DBObjectProvider
CREATE_PRIVILEDGE, DELETE_PRIVILEDGE, MODIFY_PRIVILEDGE
 
Constructor Summary
protected OfflineDBObjectProvider(ProviderSettings settings, java.net.URL url)
           
 
Method Summary
abstract  boolean canCreate(SystemObject object, boolean replace)
          Returns true if the schema for this object exists, and the file representing this object can be saved.
protected  SystemObject createObjectImpl(java.lang.String type, Schema schema, java.lang.String name)
          Creates a schema object by looking on the filesystem (using listAllObjects) for the appropriate filename.
 void createObjects(SystemObject[] objects, boolean replace)
          Used to create (or replace) the given SystemObjects.
 void deleteObjects(SystemObject[] objects, boolean cascade)
          Deletes a set of objects together.
protected  DBObject findByID(DBObjectID id)
          Finds a given object by ID.
 DBObject findGeneratedObject(DBObjectID id)
          Deprecated. 
 DBObject findImportedObject(DBObjectID id)
          Deprecated. 
static OfflineDBObjectProvider findProvider(Project project, BaseObjectID objID)
          Iterates through the project's providers, and see if any contain a matching object id.
static OfflineDBObjectProvider findProvider(Project p, java.lang.String id)
          Deprecated. replaced by #findProviderByID(Project,String}.
static OfflineDBObjectProvider findProviderByID(Project p, java.lang.String id)
          Finds a provider by its ID in the given Project.
static OfflineDBObjectProvider findProviderByName(Context c, java.lang.String name)
          Finds an Offline Database with the given name in the given Context.
static OfflineDBObjectProvider findProviderByName(Project p, java.lang.String name)
          Finds an Offline Database with the given name in the context of the given Project.
static OfflineDBObjectProvider getDBObjectProvider(Context c)
          Returns the provider for the given ide context.
abstract  Schema getDefaultSchema()
          Returns the default schema for this provider - this schema may not (yet) exist in the provider.
protected  java.util.logging.Logger getLogger()
          Gets the logger to use in this provider.
 java.lang.String getName()
          Returns the name of this provider (from the provider's settings).
abstract  NodeCache getNodeCache()
          Gets the cache that maps DBObjectIDs to the URLs of the files on disk the offline database objects are stored in.
 DBObject getObject(OfflineDBObjectNode node)
          Retrieves the object from the given node ensuring that the object's ID is correctly setup for this provider.
 SchemaObject getObject(SchemaObjectNode node)
          Retrieves the SchemaObject from the given node ensuring that the object's ID is correctly setup for this provider.
abstract  SystemObject getObject(java.net.URL url)
          Retrieves the SchemaObject from the given URL ensuring that the object's ID is correctly setup for this provider.
protected
<T extends SystemObject>
T
getObjectImpl(DBObjectCriteria<T> criteria)
           
static java.util.Iterator<OfflineDBObjectProvider> getProviderIterator(Project p)
          Returns an iterator over the providers in a project.
static java.util.Iterator<OfflineDBObjectProvider> getProviderIterator(Project p, boolean incProjDeps)
          Returns an iterator over the providers in a project.
 Schema getSchema(java.lang.String name, boolean incBuiltInSchemas)
          Offline specific method for retrieving the schema with a given name without looking through the built-in schemas.
 ProviderSettings getSettings()
          Returns the current settings for this offline provider.
static java.lang.String getUniqueProviderName(Project p, java.lang.String name)
          Returns a unique provier name for the given provider within the project based on the given base name.
abstract  java.lang.String getUniqueSchemaName(java.lang.String base)
          Returns a unique name for a schema within this provider given the base name.
 java.net.URL getURL()
          Returns the URL for this offline provider.
protected abstract  boolean isClosed()
          Tests whether this provider is closed, and therefore will not function.
 boolean isDependentProvider(OfflineDBObjectProvider provider)
          Determines whether the given provider is in the dependency chain for this provider, i.e.
protected abstract
<T extends SystemObject>
java.util.Collection<T>
listAllObjects(DBObjectCriteria<T> criteria)
          Lists the objects by type, schema and name (can include wildcard '%') from this provide only, not its dependencies.
static java.util.List<OfflineDBObjectProvider> listDBObjectProviders(Project p)
          Lists the providers that already exist on the given project's offline database source path.
static java.util.List<OfflineDBObjectProvider> listDBObjectProviders(Project p, boolean incProjDeps)
          Lists the providers that already exist on the given project's offline database source path.
protected
<T extends SystemObject>
java.util.Collection<T>
listObjectsImpl(DBObjectCriteria<T> criteria)
          Internal listObjects implementation.
protected  void setURL(java.net.URL newURL)
           
 void undeleteObject(SchemaObject object)
          This method is not currently supported in the offline provider.
 void undeleteObjects(SchemaObject[] objects)
          This method is not currently supported in the offline provider.
abstract  void updateObjects(Difference rs, boolean replace, boolean cascade)
          Updates the definition objects held in this provider.
 void validateObject(DBObject object)
          Validates the given object using the DBObjectValidator registered against that object's type.
 void validateObject(DBObject original, DBObject update)
          Validates the given object update using the DBObjectValidator registered against that object's type.
 void validateObjectProperty(DBObject original, DBObject update, java.lang.String property)
          Checks to see if the updated children of a given object are valid.
 void validateObjectProperty(DBObject object, java.lang.String property)
          Checks to see if the children of a given object are valid.
 
Methods inherited from class oracle.javatools.db.AbstractDBObjectProvider
addProviderListener, cacheObject, checkCachedObject, clearAllCaches, clearCache, convertObject, createByIDImpl, createObject, createObjectManager, createSchema, deleteObject, deleteSchema, destroyCache, findObject, findObject, findSchema, fireObjectsAdded, fireObjectsRemoved, fireProviderClosed, fireProviderDeleted, fireProviderOpened, fireProviderReloaded, fireSchemaAdded, fireSchemaObjectUpdated, fireSchemaRemoved, fireSchemaUpdated, getBuilderForType, getCachedTimestamp, getCascadeManager, getCasePolicy, getDataType, getDefaultTemplateForType, getDiffEngine, getExternalName, getExternalName, getExternalTimestamp, getExternalTimestampImpl, getIdentifierQuoteString, getInternalName, getInternalName, getObject, getObject, getObjectFactory, getObjectManager, getOrCreateDataType, getPropertyManager, getQuotedNameCasePolicy, getSchema, getSchemaObjectExpanders, getTimestamp, getTimestamp, getUniqueName, getValidatorForType, hasPriviledge, isEditable, isNewFromTemplateType, isRequestedObject, isValidName, isValidName, listObjects, listObjects, listObjects, listObjects, listObjects, listObjectsFromCache, listObjectsImpl, listObjectsImpl, listObjectTypes, listSchemas, listSchemas, listSupportedDataTypes, logEvent, markForLazyInit, markForLazyInit, normaliseType, putCachedTimestampKey, quoteIdentifier, registerBuilder, registerExpanders, registerSchemaObjectExpander, registerType, registerValidator, removeProviderListener, resetObject, resumeTimestampQueries, schemaUpdated, setDefaultTemplateForType, supportsObjectType, supportsTimestamps, supportsTimestamps, suspendTimestampQueries, uncacheObject, unregisterBuilder, unregisterValidator, updateObject, updateObjects, updateSchema, validateName, validateName, validateObject, validateObject, validateObjectProperty, validateObjectProperty, validateSchema, validateSchema, validateUniqueName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.javatools.db.DBObjectProvider
canDelete, getDescriptor
 

Constructor Detail

OfflineDBObjectProvider

protected OfflineDBObjectProvider(ProviderSettings settings,
                                  java.net.URL url)
Method Detail

getSettings

public final ProviderSettings getSettings()
Returns the current settings for this offline provider.


getURL

public final java.net.URL getURL()
Returns the URL for this offline provider.


setURL

protected final void setURL(java.net.URL newURL)

getName

public final java.lang.String getName()
Returns the name of this provider (from the provider's settings).

Specified by:
getName in class AbstractDBObjectProvider
See Also:
getSettings()

getObject

public final SchemaObject getObject(SchemaObjectNode node)
                             throws DBException
Retrieves the SchemaObject from the given node ensuring that the object's ID is correctly setup for this provider.

Throws:
DBException - is this is not possible - e.g. the given node is a duplicate on the database path for this provider.

getObject

public final DBObject getObject(OfflineDBObjectNode node)
                         throws DBException
Retrieves the object from the given node ensuring that the object's ID is correctly setup for this provider.

Throws:
DBException - is this is not possible - e.g. the given node is a duplicate on the database path for this provider.

getObject

public abstract SystemObject getObject(java.net.URL url)
                                throws DBException
Retrieves the SchemaObject from the given URL ensuring that the object's ID is correctly setup for this provider.

Throws:
DBException - is this is not possible.

findImportedObject

@Deprecated
public final DBObject findImportedObject(DBObjectID id)
Deprecated. 

Finds an object in this provider which has been imported from an object whose ID matches the given ID (uses an unstrict comparison).


findGeneratedObject

@Deprecated
public final DBObject findGeneratedObject(DBObjectID id)
Deprecated. 

Finds an object in this provider which has been generated to an object whose ID matches the given ID (uses an unstrict comparison).


canCreate

public abstract boolean canCreate(SystemObject object,
                                  boolean replace)
Returns true if the schema for this object exists, and the file representing this object can be saved. If the object already exists, true is only returned if replace is also true, and the object's file is writable.

Parameters:
object - the SystemObject describing the object to create
replace - whether to replace an existing object. If replace is false and the object exists, canCreate must return false.
Returns:
whether the create will succeed.

createObjects

public final void createObjects(SystemObject[] objects,
                                boolean replace)
                         throws DBException
Used to create (or replace) the given SystemObjects. If replacing - the name, Schema and type of each object must be identical to the original. To replace the object, updateObjects() is used to prevent observers losing their subjects.

Update messages are fired to any observers following the outcome of the operation.

Note: if you call this method with an object whose Schema hasn't explicitly been retrieved from the getSchema() method then one of two things will happen:

Parameters:
objects - the SystemObject[] describing the objects to create.
replace - whether to replace an existing objects. If replace is false and the object exists, createObjects will fail.
Throws:
DBException - if an error is encountered creating the objects.
See Also:
DBObjectProvider.createObjects(oracle.javatools.db.SystemObject[], boolean)

deleteObjects

public final void deleteObjects(SystemObject[] objects,
                                boolean cascade)
                         throws DBException
Deletes a set of objects together. Use to delete a number of inter-dependent objects. If an element in the array is null it is ignored.

Parameters:
objects - the objects to delete
cascade - whether to delete dependent objects
Throws:
DBException - if an error is encountered performing the delete

updateObjects

public abstract void updateObjects(Difference rs,
                                   boolean replace,
                                   boolean cascade)
                            throws DBException
Updates the definition objects held in this provider. Depending on the ResultSet contents this can also perform create or delete operations. To edit an object a user of the API should do the following:
  1. call getObject() to retrieve the SystemObject they wish to edit
  2. take a copy of that object using the
    copyTo( DBObject target, boolean includeID )
    method on oracle.javatools.db.DBUtil with true to include IDs) - e.g.
    Table copy = (Table)table.copyTo( null, true );
  3. perform any edit operation required on the copy
  4. Call this method with the old and new objects
This ensures that all observers of the original object are notified correctly of any changes made.

This method updates an old SystemObject with the properties of the given new object. If the "copy" is successful a message is sent to all observers of the old object.

  • Nothing is done if the objects are identical.
  • A DBException is thrown if an object already exists with the same type, schema and name of the new object
  • A DBException is thrown if the old object doesn't already exist.
  • A DBException is thrown if another incompatible object exists at the URL for the new object

Parameters:
rs - the changes described as a Difference - this should be a LIST Difference with the old objects as a() and the new objects as b().
replace - true if an existing object is to be replaced (when creating)
cascade - true if cascade delete should be used to replace an object (when deleting)
Throws:
DBException
See Also:
DBObjectProvider.updateObjects(oracle.javatools.db.diff.Difference, boolean, boolean), DBObject.copyTo(oracle.javatools.db.DBObject, boolean)

undeleteObject

public void undeleteObject(SchemaObject object)
                    throws DBException
This method is not currently supported in the offline provider.

Parameters:
object - the object to be undeleted
Throws:
DBException - if an error is encountered performing the undelete

undeleteObjects

public void undeleteObjects(SchemaObject[] objects)
                     throws DBException
This method is not currently supported in the offline provider.

Parameters:
objects - the objects to be undeleted
Throws:
DBException - if an error is encountered performing the undelete

validateObject

public void validateObject(DBObject object)
                    throws ValidationException
Validates the given object using the DBObjectValidator registered against that object's type. A ValidationException is thrown if the object fails to validate, or if no DBObjectValidator is registered for that object type.

Specified by:
validateObject in interface DBObjectProvider
Overrides:
validateObject in class AbstractDBObjectProvider
Parameters:
object - The object to validate
Throws:
ValidationException - if the object is not valid. The exception will describe the validation failure. A MissingValidatorException is thrown if the provider has no validator for the given object type.

validateObject

public void validateObject(DBObject original,
                           DBObject update)
                    throws ValidationException
Validates the given object update using the DBObjectValidator registered against that object's type. A ValidationException is thrown if the update fails to validate, or if no DBObjectValidator is registered for that object type.

Specified by:
validateObject in interface DBObjectProvider
Overrides:
validateObject in class AbstractDBObjectProvider
Throws:
ValidationException - if the updated object is not valid. The exception will describe the validation failure. A MissingValidatorException is thrown if the provider has no validator for the given object type.

validateObjectProperty

public void validateObjectProperty(DBObject original,
                                   DBObject update,
                                   java.lang.String property)
                            throws ValidationException
Description copied from interface: DBObjectProvider
Checks to see if the updated children of a given object are valid. If the object has no children of the given type a MissingValidatorException will be thrown. This is a convinience method to perform validation to a specific property on an object - all properties will be validated if DBObjectProvider.validateObject(DBObject,DBObject) is called.

Specified by:
validateObjectProperty in interface DBObjectProvider
Overrides:
validateObjectProperty in class AbstractDBObjectProvider
Parameters:
original - The original version of the edited object
update - The edited object to validate
property - An identifier for a specific property to validate
Throws:
ValidationException - if the object is not valid. The exception will describe the validation failure. A MissingValidatorException is thrown if the provider has no validator for the given object type, or property.

validateObjectProperty

public void validateObjectProperty(DBObject object,
                                   java.lang.String property)
                            throws ValidationException
Description copied from interface: DBObjectProvider
Checks to see if the children of a given object are valid. If the object has no children of the given type a MissingValidatorException will be thrown. This is a convinience method to perform validation to a specific property on an object - all properties will be validated if DBObjectProvider.validateObject(DBObject) is called.

Specified by:
validateObjectProperty in interface DBObjectProvider
Overrides:
validateObjectProperty in class AbstractDBObjectProvider
Parameters:
object - The object to validate
property - An identifier for a specific property to validate
Throws:
ValidationException - if the object is not valid. The exception will describe the validation failure. A MissingValidatorException is thrown if the provider has no validator for the given object type, or property.

isDependentProvider

public boolean isDependentProvider(OfflineDBObjectProvider provider)
Determines whether the given provider is in the dependency chain for this provider, i.e. whether objects in the given provider can be accessed by the current provider. For convenience, if the given provider is the same as the current provider, this method returns true. Given the dependency chain PARENT and CHILD, where CHILD lists PARENT as one of its dependencies, calling isDependentProvider on CHILD and passing in PARENT will return true. Calling it on PARENT and passing in CHILD will return false.

Parameters:
provider - the provider to compare with
Returns:
true if the given provider is the same as the current provider or if it somewhere in the dependency chain

getSchema

public final Schema getSchema(java.lang.String name,
                              boolean incBuiltInSchemas)
                       throws DBException
Offline specific method for retrieving the schema with a given name without looking through the built-in schemas.

Parameters:
name - the schema to search for
incBuiltInSchemas - whether to search the built-in schemas, e.g. complex type schemas, PUBLIC schema for synonyms etc.
Returns:
a schema if one is found.
Throws:
DBException
See Also:
AbstractDBObjectProvider.getSchema(java.lang.String)

getDefaultSchema

public abstract Schema getDefaultSchema()
Returns the default schema for this provider - this schema may not (yet) exist in the provider.


getUniqueSchemaName

public abstract java.lang.String getUniqueSchemaName(java.lang.String base)
Returns a unique name for a schema within this provider given the base name.


getNodeCache

public abstract NodeCache getNodeCache()
Gets the cache that maps DBObjectIDs to the URLs of the files on disk the offline database objects are stored in.

Returns:
the NodeCache instance for this Offline Database.

getObjectImpl

protected <T extends SystemObject> T getObjectImpl(DBObjectCriteria<T> criteria)
                                        throws DBException
Overrides:
getObjectImpl in class AbstractDBObjectProvider
Throws:
DBException

findByID

protected DBObject findByID(DBObjectID id)
                     throws DBException
Finds a given object by ID. API clients should use id.resolveID().

Overrides:
findByID in class AbstractDBObjectProvider
Throws:
DBException
See Also:
DBObjectID.resolveID()

createObjectImpl

protected SystemObject createObjectImpl(java.lang.String type,
                                        Schema schema,
                                        java.lang.String name)
                                 throws DBException
Creates a schema object by looking on the filesystem (using listAllObjects) for the appropriate filename.

Overrides:
createObjectImpl in class AbstractDBObjectProvider
Throws:
DBException

listObjectsImpl

protected <T extends SystemObject> java.util.Collection<T> listObjectsImpl(DBObjectCriteria<T> criteria)
                                                                throws DBException
Description copied from class: AbstractDBObjectProvider
Internal listObjects implementation. All listObjects methods call through to this.

Specified by:
listObjectsImpl in class AbstractDBObjectProvider
Throws:
DBException

listAllObjects

protected abstract <T extends SystemObject> java.util.Collection<T> listAllObjects(DBObjectCriteria<T> criteria)
Lists the objects by type, schema and name (can include wildcard '%') from this provide only, not its dependencies. Additionally built in object types etc are not included.

If the accepts parameter is not null then each object is tested using it once opened. If the object is aceepted then the iteration is stopped and just that object is returned in the Collection. This allows a "search" for an object to jump out and not load all the objects.

See Also:
AbstractDBObjectProvider.listObjects(java.lang.String, oracle.javatools.db.Schema)
For internal use only. Application developers should not use this

isClosed

protected abstract boolean isClosed()
Tests whether this provider is closed, and therefore will not function. A provider is closed when it is uncached from the DBObjectProviderFactory which happens as a result of its Project being closed. Listeners to a provider will have been notified.

Returns:
true if the provider has been closed.
For internal use only. Application developers should not use this

getLogger

protected java.util.logging.Logger getLogger()
Description copied from class: AbstractDBObjectProvider
Gets the logger to use in this provider.

Overrides:
getLogger in class AbstractDBObjectProvider

getDBObjectProvider

public static final OfflineDBObjectProvider getDBObjectProvider(Context c)
Returns the provider for the given ide context. The context must contain a node that is underneath a provider, or this will return null. If null is returned and a provider file is expected (e.g. you are requesting from a table node) then the user can be alerted by using ProviderWizard.showMissingProviderError(oracle.ide.Context, java.lang.String)


listDBObjectProviders

public static final java.util.List<OfflineDBObjectProvider> listDBObjectProviders(Project p)
Lists the providers that already exist on the given project's offline database source path. This will load all the providers, if you are searching for a specific provider then use getProviderIterator(Project) instead. Providers from dependent projects are included in the list.

See Also:
getProviderIterator(Project)

listDBObjectProviders

public static final java.util.List<OfflineDBObjectProvider> listDBObjectProviders(Project p,
                                                                                  boolean incProjDeps)
Lists the providers that already exist on the given project's offline database source path. This will load all the providers, if you are searching for a specific provider then use getProviderIterator(Project) instead.

Parameters:
p - the project to look in
incProjDeps - whether to search the project's dependencies as well.
See Also:
getProviderIterator(Project)

getProviderIterator

public static final java.util.Iterator<OfflineDBObjectProvider> getProviderIterator(Project p)
Returns an iterator over the providers in a project. This is faster than using listDBObjectProviders(Project) if you are searching because it doesn't load all the providers unless you keep iterating. Providers from dependent projects are included.

Returns:
an iterator of providers which could contain null elements if there is a problem loading a provider at a particular url.
See Also:
listDBObjectProviders(Project)

getProviderIterator

public static final java.util.Iterator<OfflineDBObjectProvider> getProviderIterator(Project p,
                                                                                    boolean incProjDeps)
Returns an iterator over the providers in a project. This is faster than using listDBObjectProviders(Project) if you are searching because it doesn't load all the providers unless you keep iterating. Providers from dependent projects are optionally included.

Parameters:
p - the project to look in
incProjDeps - whether to search the project's dependencies as well.
Returns:
an iterator of providers which could contain null elements if there is a problem loading a provider at a particular url.
See Also:
listDBObjectProviders(Project)

getUniqueProviderName

public static final java.lang.String getUniqueProviderName(Project p,
                                                           java.lang.String name)
Returns a unique provier name for the given provider within the project based on the given base name.


findProvider

@Deprecated
public static final OfflineDBObjectProvider findProvider(Project p,
                                                                    java.lang.String id)
Deprecated. replaced by #findProviderByID(Project,String}.


findProviderByName

public static final OfflineDBObjectProvider findProviderByName(Context c,
                                                               java.lang.String name)
Finds an Offline Database with the given name in the given Context.

Parameters:
c - the context to search
name - the name of the offline database to find
Returns:
an Offline Database, or null if one doesn't exist with the given name.

findProviderByName

public static final OfflineDBObjectProvider findProviderByName(Project p,
                                                               java.lang.String name)
Finds an Offline Database with the given name in the context of the given Project.

Parameters:
p - the project to search
name - the name of the offline database to find
Returns:
an Offline Database, or null if one doesn't exist with the given name.

findProviderByID

public static final OfflineDBObjectProvider findProviderByID(Project p,
                                                             java.lang.String id)
Finds a provider by its ID in the given Project. Once found it is cached (weakly) against the ID for quicker retrieval next time.

The ID isn't used by the DBObjectProviderFactory - because the URL is required to retrieve the provider succefully. The ID is provider as a mechanism to uniquely identify a provider within the context of a project.

Parameters:
p - the project to search in
id - the id of the provider
Returns:
a provider if one can be found, or null otherwise
See Also:
ProviderSettings.getID(), getProviderIterator(oracle.ide.model.Project)

findProvider

public static final OfflineDBObjectProvider findProvider(Project project,
                                                         BaseObjectID objID)
Iterates through the project's providers, and see if any contain a matching object id. This is potentially very time consuming and should be avoided if at all possible. Wherever possible cache provider's by their own id and look them up using the appropriate findProvider method.

Parameters:
p - the project to search in
objID - the id of an object you expect to find in your provider. This needs its type and guid set, but not the provider obviously.
Returns:
a provider that contains the given object id.
See Also:
findProvider(oracle.ide.model.Project, java.lang.String)

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

Copyright © 1997, 2009, Oracle. All rights reserved.