Search in sources :

Example 6 with Dependency

use of org.apache.derby.iapi.sql.depend.Dependency in project derby by apache.

the class BasicDependencyManager method getDependencyDescriptorList.

/**
 * Turn a list of DependencyDescriptors into a list of Dependencies.
 *
 * @param storedList	The List of DependencyDescriptors representing
 *						stored dependencies.
 * @param providerForList The provider if this list is being created
 *                        for a list of dependents. Null otherwise.
 *
 * @return List		The converted List
 *
 * @exception StandardException thrown if something goes wrong
 */
private List<Dependency> getDependencyDescriptorList(List<DependencyDescriptor> storedList, Provider providerForList) throws StandardException {
    List<Dependency> retval = new ArrayList<Dependency>();
    if (!storedList.isEmpty()) {
        /* For each DependencyDescriptor, we need to instantiate
			 * object descriptors of the appropriate type for both
			 * the dependent and provider, create a Dependency with
			 * that Dependent and Provider and substitute the Dependency
			 * back into the same place in the List
			 * so that the call gets an enumerations of Dependencys.
			 */
        for (DependencyDescriptor depDesc : storedList) {
            Dependent tempD;
            Provider tempP;
            DependableFinder finder = depDesc.getDependentFinder();
            tempD = (Dependent) finder.getDependable(dd, depDesc.getUUID());
            if (providerForList != null) {
                // Use the provider being passed in.
                tempP = providerForList;
                // Sanity check the object identifiers match.
                if (SanityManager.DEBUG) {
                    if (!tempP.getObjectID().equals(depDesc.getProviderID())) {
                        SanityManager.THROWASSERT("mismatch providers");
                    }
                }
            } else {
                finder = depDesc.getProviderFinder();
                tempP = (Provider) finder.getDependable(dd, depDesc.getProviderID());
            }
            retval.add(new BasicDependency(tempD, tempP));
        }
    }
    return retval;
}
Also used : DependableFinder(org.apache.derby.catalog.DependableFinder) DependencyDescriptor(org.apache.derby.iapi.sql.dictionary.DependencyDescriptor) ArrayList(java.util.ArrayList) Dependency(org.apache.derby.iapi.sql.depend.Dependency) Dependent(org.apache.derby.iapi.sql.depend.Dependent) Provider(org.apache.derby.iapi.sql.depend.Provider)

Example 7 with Dependency

use of org.apache.derby.iapi.sql.depend.Dependency in project derby by apache.

the class BasicDependencyManager method getProviders.

/**
 * Returns a list of all providers that this dependent has (even invalid
 * ones). Includes all dependency types.
 *
 * @param d the dependent
 * @return A list of providers (possibly empty).
 * @throws StandardException thrown if something goes wrong
 */
private List<Provider> getProviders(Dependent d) throws StandardException {
    List<Provider> provs = new ArrayList<Provider>();
    synchronized (this) {
        List deps = (List) dependents.get(d.getObjectID());
        if (deps != null) {
            Iterator depsIter = deps.iterator();
            while (depsIter.hasNext()) {
                provs.add(((Dependency) depsIter.next()).getProvider());
            }
        }
    }
    // into consideration as well.
    if (d.isPersistent()) {
        List<Dependency> storedList = getDependencyDescriptorList(dd.getDependentsDescriptorList(d.getObjectID().toString()), (Provider) null);
        Iterator<Dependency> depIter = storedList.iterator();
        while (depIter.hasNext()) {
            provs.add((depIter.next()).getProvider());
        }
    }
    return provs;
}
Also used : ArrayList(java.util.ArrayList) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ProviderList(org.apache.derby.iapi.sql.depend.ProviderList) Dependency(org.apache.derby.iapi.sql.depend.Dependency) Provider(org.apache.derby.iapi.sql.depend.Provider)

Aggregations

Dependency (org.apache.derby.iapi.sql.depend.Dependency)7 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)2 List (java.util.List)2 ListIterator (java.util.ListIterator)2 UUID (org.apache.derby.catalog.UUID)2 Dependent (org.apache.derby.iapi.sql.depend.Dependent)2 Provider (org.apache.derby.iapi.sql.depend.Provider)2 ProviderList (org.apache.derby.iapi.sql.depend.ProviderList)2 StandardException (org.apache.derby.shared.common.error.StandardException)2 DependableFinder (org.apache.derby.catalog.DependableFinder)1 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)1 StatementContext (org.apache.derby.iapi.sql.conn.StatementContext)1 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)1 DependencyDescriptor (org.apache.derby.iapi.sql.dictionary.DependencyDescriptor)1 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)1 ViewDescriptor (org.apache.derby.iapi.sql.dictionary.ViewDescriptor)1