Package org.olat.ims.cp.objects

Examples of org.olat.ims.cp.objects.CPItem


    this.log = Logger.getLogger(CPPage.class.getName());
    this.identifier = identifier;
    CPManagerImpl cpMgm = (CPManagerImpl) CPManager.getInstance();
    DefaultElement ele = cpMgm.getElementByIdentifier(cp, identifier);
    if (ele instanceof CPItem) {
      CPItem pageItem = (CPItem) ele;
      this.cpRoot = false;
      this.idRef = pageItem.getIdentifierRef();
      this.title = pageItem.getTitle();
      this.rootDir = cp.getRootDir();
      this.metadata = pageItem.getMetadata();
      if (metadata != null) metadata.setTitle(title);
      this.cp = cp;
      String filePath = cpMgm.getPageByItemId(cp, identifier);
      if (filePath != null && filePath != "") {
        LocalFileImpl f = (LocalFileImpl) cp.getRootDir().resolve(filePath);
View Full Code Here


    // Get the parent node to be displayed after deletion.
    String parentIdentifier = null;
    if (currentElem instanceof CPItem) {
      Element parent = ((CPItem) currentElem).getParentElement();
      if (parent instanceof CPItem) {
        CPItem parentItem = (CPItem) parent;
        parentIdentifier = parentItem.getIdentifier();
      } else if (parent instanceof CPOrganization) {
        CPOrganization parentItem = (CPOrganization) parent;
        parentIdentifier = parentItem.getIdentifier();
      }
    }
    return parentIdentifier;
  }
View Full Code Here

  public void testLoad() {
    ContentPackage relodedCP = mgr.load(cp.getRootDir(), cp.getResourcable());
    assertNotNull(relodedCP);
    CPOrganization orga = relodedCP.getFirstOrganizationInManifest();
    assertNotNull(orga);
    CPItem item = orga.getFirstItem();
    assertEquals(PAGE_TITLE, item.getTitle());
  }
View Full Code Here

  public void testAddElement() {
  // TODO:GW impl
  }

  public void testAddElementAfter() {
    CPItem newItem = new CPItem();
    mgr.addElementAfter(cp, newItem, ITEM_ID);
    assertTrue("The new item wasn't inserted at the second position.", newItem.getPosition() == 1);
  }
View Full Code Here

    }
    try {
      if (el.getName().equals(CPCore.ORGANIZATION)) {
        CPOrganization org = (CPOrganization) el;
        for (Iterator<CPItem> it = org.getItemIterator(); it.hasNext();) {
          CPItem item = it.next();
          addItem(nodeList, item);
        }
      } else if (el.getName().equals(CPCore.ITEM)) {
        CPItem pItem = (CPItem) el;
        for (Iterator<CPItem> it = pItem.getItemIterator(); it.hasNext();) {
          CPItem item = it.next();
          addItem(nodeList, item);
        }
      } else {
        // element is not item nor orga -> ergo wrong element
        log.info("unknown element while building treemodel for gui (id: " + nodeId + ")");
View Full Code Here

   * @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()));
    }
  }
View Full Code Here

    if (parentElement instanceof CPItem) {
      // parent is a <item>
      if (newElement instanceof CPItem) {
        // only CPItems can be added to CPItems
        CPItem item = (CPItem) parentElement;
        item.addItemAt((CPItem) newElement, position);
        return true;
      } else {
        throw new OLATRuntimeException(CPOrganizations.class, "you can only add <item>  elements to an <item>-element", new Exception());
      }
View Full Code Here

    if (beforeElement == null) return false;

    if (beforeElement instanceof CPItem) {
      // beforeElement is a <item>
      // ==> newElement has to be an <item>
      CPItem beforeItem = (CPItem) beforeElement;
      DefaultElement parent = beforeItem.getParentElement();
      if (!(newElement instanceof CPItem)) { throw new OLATRuntimeException(CPOrganizations.class, "only <item> element allowed",
          new Exception()); }
      if (parent instanceof CPItem) {
        CPItem p = (CPItem) parent;
        p.addItemAt((CPItem) newElement, beforeItem.getPosition() + 1);
      } else if (parent instanceof CPOrganization) {
        CPOrganization o = (CPOrganization) parent;
        o.addItemAt((CPItem) newElement, beforeItem.getPosition() + 1);
      } else {
        throw new OLATRuntimeException(CPOrganizations.class, "you cannot add an <item> element to a " + parent.getName() + " element",
View Full Code Here

    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);
View Full Code Here

    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 {
      // if (elementToCopy.getClass().equals(CPOrganization.class)) {
      // not yet supported
      throw new OLATRuntimeException(CPOrganizations.class, "You can only copy <item>-elements...!", new Exception());
    }
View Full Code Here

TOP

Related Classes of org.olat.ims.cp.objects.CPItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.