Search in sources :

Example 6 with CPDependency

use of org.olat.ims.cp.objects.CPDependency in project openolat by klemens.

the class CPCore method findReferencesToResource.

/**
 * Searches for <item>-elements or <dependency>-elements which references to
 * the resource with id "resourceIdentifier"
 *
 * if an element is found, search is aborted and the found element is returned
 *
 * @param resourceIdentifier
 * @return the found element or null
 */
public DefaultElement findReferencesToResource(String resourceIdentifier) {
    // search for <item identifierref="resourceIdentifier" >
    for (Iterator<CPOrganization> it = rootNode.getOrganizations().getOrganizationIterator(); it.hasNext(); ) {
        CPOrganization org = it.next();
        for (Iterator<CPItem> itO = org.getItems().iterator(); itO.hasNext(); ) {
            CPItem item = itO.next();
            CPItem found = _findReferencesToRes(item, resourceIdentifier);
            if (found != null)
                return found;
        }
    }
    // search for <dependency identifierref="resourceIdentifier" >
    for (Iterator<CPResource> itRes = rootNode.getResources().getResourceIterator(); itRes.hasNext(); ) {
        CPResource res = itRes.next();
        for (Iterator<CPDependency> itDep = res.getDependencyIterator(); itDep.hasNext(); ) {
            CPDependency dep = itDep.next();
            if (dep.getIdentifierRef().equals(resourceIdentifier))
                return dep;
        }
    }
    return null;
}
Also used : CPResource(org.olat.ims.cp.objects.CPResource) CPOrganization(org.olat.ims.cp.objects.CPOrganization) CPItem(org.olat.ims.cp.objects.CPItem) CPDependency(org.olat.ims.cp.objects.CPDependency)

Aggregations

CPDependency (org.olat.ims.cp.objects.CPDependency)6 CPItem (org.olat.ims.cp.objects.CPItem)6 CPOrganization (org.olat.ims.cp.objects.CPOrganization)6 CPResource (org.olat.ims.cp.objects.CPResource)4 Vector (java.util.Vector)2 DefaultElement (org.dom4j.tree.DefaultElement)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 CPFile (org.olat.ims.cp.objects.CPFile)2 CPOrganizations (org.olat.ims.cp.objects.CPOrganizations)2 CPResources (org.olat.ims.cp.objects.CPResources)2