use of org.olat.ims.cp.objects.CPMetadata in project OpenOLAT by OpenOLAT.
the class CPCore method removeElement.
/**
* removes an element with identifier "identifier" from the manifest
*
* @param identifier the identifier if the element to remove
* @param booleanFlag indicates whether to remove linked resources as well...!
* (needed for moving elements)
*/
public void removeElement(String identifier, boolean resourceFlag) {
DefaultElement el = rootNode.getElementByIdentifier(identifier);
if (el != null) {
if (el instanceof CPItem) {
// element is CPItem
CPItem item = (CPItem) el;
// first remove resources
if (resourceFlag) {
// Delete children (depth first search)
removeChildElements(item, resourceFlag);
// remove referenced resource
CPResource res = (CPResource) rootNode.getElementByIdentifier(item.getIdentifierRef());
if (res != null && referencesCount(res) == 1) {
res.removeFromManifest();
}
}
// then remove item
item.removeFromManifest();
} else if (el instanceof CPOrganization) {
// element is organization
CPOrganization org = (CPOrganization) el;
org.removeFromManifest(resourceFlag);
} else if (el instanceof CPMetadata) {
// element is <metadata>
CPMetadata md = (CPMetadata) el;
md.removeFromManifest();
}
} else {
throw new OLATRuntimeException(CPOrganizations.class, "couldn't remove element with id \"" + identifier + "\"! Element not found in manifest ", new Exception());
}
}
use of org.olat.ims.cp.objects.CPMetadata in project openolat by klemens.
the class CPCore method removeElement.
/**
* removes an element with identifier "identifier" from the manifest
*
* @param identifier the identifier if the element to remove
* @param booleanFlag indicates whether to remove linked resources as well...!
* (needed for moving elements)
*/
public void removeElement(String identifier, boolean resourceFlag) {
DefaultElement el = rootNode.getElementByIdentifier(identifier);
if (el != null) {
if (el instanceof CPItem) {
// element is CPItem
CPItem item = (CPItem) el;
// first remove resources
if (resourceFlag) {
// Delete children (depth first search)
removeChildElements(item, resourceFlag);
// remove referenced resource
CPResource res = (CPResource) rootNode.getElementByIdentifier(item.getIdentifierRef());
if (res != null && referencesCount(res) == 1) {
res.removeFromManifest();
}
}
// then remove item
item.removeFromManifest();
} else if (el instanceof CPOrganization) {
// element is organization
CPOrganization org = (CPOrganization) el;
org.removeFromManifest(resourceFlag);
} else if (el instanceof CPMetadata) {
// element is <metadata>
CPMetadata md = (CPMetadata) el;
md.removeFromManifest();
}
} else {
throw new OLATRuntimeException(CPOrganizations.class, "couldn't remove element with id \"" + identifier + "\"! Element not found in manifest ", new Exception());
}
}
Aggregations