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

E13403-08

oracle.javatools.db
Class CascadeManager

java.lang.Object
  extended by oracle.javatools.db.CascadeManager
Direct Known Subclasses:
SchemaObjectManager

public abstract class CascadeManager
extends java.lang.Object

Provides facilities for listing references between DBObjects in a DBObjectProvider, and provides cascade logic for cascading delete of an object.

The cascade manager interface supports the concept of "unresolved references" which are references in the model that don't resolve to a real object.

Since:
11.1.2.0.0
See Also:
DBObjectProvider.getCascadeManager()

Nested Class Summary
static class CascadeManager.NoCascadeRequiredException
          Exception thrown when a cascade is requested for an object that has no referers.
 
Constructor Summary
protected CascadeManager(DBObjectProvider pro)
           
 
Method Summary
 SystemObject cascadeDelete(DBObject deleted, SystemObject referer)
          Cascades the delete of the given object to the given referer by taking a copy of the referer and performing any necessary updates.
 SystemObject cascadeDelete(DBObject deleted, SystemObject referer, boolean copyIfCascadeRequired)
          Cascades the delete of the given object to the given referer by taking a copy of the referer and performing any necessary updates.
 void doCascadeDelete(SystemObject deleted, SystemObject referer)
           
protected  DBObjectProvider getProvider()
           
 boolean isUnresolvedReference(DBObjectID id)
          Returns true if the given id is an "unresolved reference".
 java.util.Collection<SystemObject> listReferencedObjects(SystemObject obj, boolean recurse)
          Returns the SystemObjects that this SystemObject, or any of its children, are dependent on (reference).
abstract  java.util.Collection<DBObjectID> listReferers(DBObject obj)
          Gets the ids of the DBObjects who directly reference the given object.
abstract  java.util.Collection<DBObjectID> listTopLevelReferers(SystemObject obj, boolean deep)
          Gets the ids for the SystemObjects who reference (either directly or via their children) the given SystemObject (or one of its children).
 java.util.Collection<Difference> resolveUnresolvedReferences(SystemObject obj)
          If this manager supports unresolved references and the given object could potentially fix those references then this method finds any objects that have an unresolved reference and looks to resolve it.
protected  void updateObjects(java.util.List<SystemObject> originals, java.util.List<SystemObject> updates, boolean bulkOperation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CascadeManager

protected CascadeManager(DBObjectProvider pro)
Method Detail

getProvider

protected DBObjectProvider getProvider()

listReferers

public abstract java.util.Collection<DBObjectID> listReferers(DBObject obj)
Gets the ids of the DBObjects who directly reference the given object. (e.g for a UK this would return any FKs that reference it). Any references to children of this object are automatically included.

Parameters:
obj - the object being referenced (e.g. a PK)
Returns:
the ids of any objects directly referencing the given object

listTopLevelReferers

public abstract java.util.Collection<DBObjectID> listTopLevelReferers(SystemObject obj,
                                                                      boolean deep)
Gets the ids for the SystemObjects who reference (either directly or via their children) the given SystemObject (or one of its children).

For example for a Table this would return any Tables, Views or Synonyms (etc) that reference it via FKs, ColumnUsages or Object references).

The referers will not contain the given object, even if it has internal references (e.g. a PK referencing its own Columns). The references are all external.

Parameters:
obj - the object to search for references to
deep - whether to traverse references to the referers etc.
Returns:
the ids of top level objects that reference the given object

cascadeDelete

public SystemObject cascadeDelete(DBObject deleted,
                                  SystemObject referer)
                           throws CascadeManager.NoCascadeRequiredException
Cascades the delete of the given object to the given referer by taking a copy of the referer and performing any necessary updates. The updated object is returned (if any updates were necessary).

Parameters:
deleted - the object that's being deleted. if this is not a SystemObject, it must still be currently parented by its SystemObject.
referer - the object that we want to cascade the delete to
Returns:
a copy of the referer with the delete cascaded. If the referer should be deleted in order to complete the cascade, null is returned.
Throws:
CascadeManager.NoCascadeRequiredException - if there is nothing to cascade and no changes are required.

cascadeDelete

public SystemObject cascadeDelete(DBObject deleted,
                                  SystemObject referer,
                                  boolean copyIfCascadeRequired)
                           throws CascadeManager.NoCascadeRequiredException
Cascades the delete of the given object to the given referer by taking a copy of the referer and performing any necessary updates. The updated object is returned (if any updates were necessary).

Parameters:
deleted - the object that's being deleted. if this is not a SystemObject, it must still be currently parented by its SystemObject.
referer - the object that we want to cascade the delete to
if - there is a change to cascade, optionally take a copy of referer and make the changes to that, or make them to the referer object directly.
Returns:
a copy of the referer with the delete cascaded. If the referer should be deleted in order to complete the cascade, null is returned.
Throws:
CascadeManager.NoCascadeRequiredException - if there is nothing to cascade and no changes are required.

updateObjects

protected void updateObjects(java.util.List<SystemObject> originals,
                             java.util.List<SystemObject> updates,
                             boolean bulkOperation)
                      throws DBException
Throws:
DBException

doCascadeDelete

public void doCascadeDelete(SystemObject deleted,
                            SystemObject referer)
                     throws DBException
Throws:
DBException

listReferencedObjects

public java.util.Collection<SystemObject> listReferencedObjects(SystemObject obj,
                                                                boolean recurse)
Returns the SystemObjects that this SystemObject, or any of its children, are dependent on (reference). Optionally recurses to include the dependencies of the dependencies, and so on.


isUnresolvedReference

public boolean isUnresolvedReference(DBObjectID id)
Returns true if the given id is an "unresolved reference". Subclasses should override as appropriate if they support unresolved references, the default implementation doesn't and will always return false.

See Also:
#supportsUnresolvedReferences()

resolveUnresolvedReferences

public java.util.Collection<Difference> resolveUnresolvedReferences(SystemObject obj)
If this manager supports unresolved references and the given object could potentially fix those references then this method finds any objects that have an unresolved reference and looks to resolve it. Any objects that are can have their unresolved references resolved are copied, updated and differenced.

Parameters:
obj - the object that is being created and could potentially resolve unresolved references.
Returns:
a collection containing Differences for each object that has unresolved references resolved by the incoming object. The collection might be empty, but will not be null.

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

E13403-08

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