use of org.olat.ims.cp.objects.CPItem in project OpenOLAT by OpenOLAT.
the class CPTreeDataModel method addElementToPath.
/**
* @param identifier
* @param path
* @param slash
* @param elem
*/
private void addElementToPath(DefaultElement elem, StringBuffer path) {
final String slash = "/";
if (elem instanceof CPItem) {
CPItem item = (CPItem) elem;
path.insert(0, slash).insert(1, getNodeIDForIdentifier(item.getIdentifier()));
DefaultElement parent = item.getParentElement();
if (parent != null)
addElementToPath(parent, path);
} else if (elem instanceof CPOrganization) {
CPOrganization item = (CPOrganization) elem;
path.insert(0, slash).insert(1, getNodeIDForIdentifier(item.getIdentifier()));
}
}
use of org.olat.ims.cp.objects.CPItem in project OpenOLAT by OpenOLAT.
the class ContentPackage method addBlankPage.
String addBlankPage(String parentID, String title) {
CPItem newPage = new CPItem();
newPage.setTitle(title);
cpcore.addElement(newPage, parentID, 0);
return newPage.getIdentifier();
}
use of org.olat.ims.cp.objects.CPItem in project OpenOLAT by OpenOLAT.
the class CPCore method copyElement.
/**
* duplicates an element and inserts it after targetID
*
* @param sourceID
* @param targetID
*/
public String copyElement(String sourceID, String targetID) {
DefaultElement elementToCopy = rootNode.getElementByIdentifier(sourceID);
if (elementToCopy == null) {
throw new OLATRuntimeException(CPOrganizations.class, "element with identifier \"" + sourceID + "\" not found..!", new Exception());
}
if (elementToCopy instanceof CPItem) {
CPItem newItem = (CPItem) elementToCopy.clone();
cloneResourceOfItemAndSubitems(newItem);
addElementAfter(newItem, targetID);
return newItem.getIdentifier();
} else {
// not yet supported
throw new OLATRuntimeException(CPOrganizations.class, "You can only copy <item>-elements...!", new Exception());
}
}
use of org.olat.ims.cp.objects.CPItem in project OpenOLAT by OpenOLAT.
the class CPCore method moveElement.
public void moveElement(String nodeID, String newParentID, int position) {
DefaultElement elementToMove = rootNode.getElementByIdentifier(nodeID);
if (elementToMove != null) {
if (elementToMove instanceof CPItem) {
removeElement(nodeID, false);
addElement(elementToMove, newParentID, position);
} else if (elementToMove instanceof CPOrganization) {
// not yet supported
} else {
throw new OLATRuntimeException(CPOrganizations.class, "Only <item>-elements are moveable...!", new Exception());
}
}
}
use of org.olat.ims.cp.objects.CPItem in project OpenOLAT by OpenOLAT.
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;
}
Aggregations