Search in sources :

Example 76 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.

the class PublishProcess method checkRefs.

/**
 * Checks references of coursenodes.
 *
 * @param courseEditorTreeNodes
 * @return boolean
 */
private List<StatusDescription> checkRefs(List<CourseEditorTreeNode> courseEditorTreeNodes) {
    // course Editor Nodes With Damaged Reference
    List<StatusDescription> cetnDamaged = new ArrayList<StatusDescription>();
    for (Iterator<CourseEditorTreeNode> iter = courseEditorTreeNodes.iterator(); iter.hasNext(); ) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        /*
			 * for those coursenodes which need a reference to a repository entry to
			 * function properly, check that the reference is valid
			 */
        if (cn.needsReferenceToARepositoryEntry()) {
            RepositoryEntry referencedEntry = cn.getReferencedRepositoryEntry();
            if (referencedEntry == null) {
                cetnDamaged.add(new StatusDescription(ValidationStatus.ERROR, "pbl.error.refs", "pbl.error.refs", new String[] { cetn.getTitle() + "(id:" + cetn.getIdent() + " )" }, PACKAGE));
            }
        }
    }
    return cetnDamaged;
}
Also used : ArrayList(java.util.ArrayList) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 77 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.

the class PublishProcess method createPublishSetFor.

/**
 * first step in publishing course editor nodes.<br>
 * next step is testPublishSet, see method for more details.
 * @param nodeIdsToPublish
 */
public void createPublishSetFor(List<String> nodeIdsToPublish) {
    this.originalNodeIdsToPublish = nodeIdsToPublish;
    // append new nodes' subnodes
    int selectCount = nodeIdsToPublish.size();
    for (int i = 0; i < selectCount; i++) {
        // avoid using iterator here so we can modify the Collection
        String nodeId = nodeIdsToPublish.get(i);
        CourseEditorTreeNode cetn = editorTreeModel.getCourseEditorNodeById(nodeId);
        if (cetn.isNewnode() || cetn.isDeleted() || publishTreeModel.isMoved(cetn))
            appendPublishableSubnodeIds(cetn, nodeIdsToPublish);
    }
    /*
		 * generatePublishSet, testPublishSet, applyPublishSet
		 */
    /*
		 * several book keeping lists which are also used to modify the course
		 * editor model after the new runstructure is generated into ram.
		 */
    editorModelDeletedNodes = new ArrayList<CourseEditorTreeNode>();
    editorModelInsertedNodes = new ArrayList<CourseEditorTreeNode>();
    editorModelModifiedNodes = new ArrayList<CourseEditorTreeNode>();
    resultingCourseRun = new Structure();
    // has side effect on the above editorModelxxxNodes and the
    // resultingCourseRun;
    calculatePublishSet(nodeIdsToPublish);
}
Also used : CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) Structure(org.olat.course.Structure)

Example 78 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.

the class PublishProcess method convertInCourseEditorTreeNode.

/**
 * Convert all CourseNodes into CourseEditorTreeNode
 *
 * @param courseEditorTreeNode  Parent CourseEditorTreeNode
 * @param node                  Current course node which will be converted
 */
private void convertInCourseEditorTreeNode(CourseEditorTreeNode courseEditorTreeNode, CourseNode node) {
    int childCnt = node.getChildCount();
    for (int i = 0; i < childCnt; i++) {
        CourseNode childNode = (CourseNode) node.getChildAt(i);
        CourseEditorTreeNode newEditorNode = new CourseEditorTreeNode(childNode);
        courseEditorTreeNode.addChild(newEditorNode);
        convertInCourseEditorTreeNode(newEditorNode, childNode);
        // remove all children after calling convertInCourseEditorTreeNode
        childNode.removeAllChildren();
    }
}
Also used : CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CourseNode(org.olat.course.nodes.CourseNode)

Example 79 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.

the class PublishProcess method checkUpdates.

private List<StatusDescription> checkUpdates(List<CourseEditorTreeNode> courseEditorTreeNodes, CourseEditorEnv cev) {
    List<StatusDescription> notifications = new ArrayList<StatusDescription>();
    for (Iterator<CourseEditorTreeNode> iter = courseEditorTreeNodes.iterator(); iter.hasNext(); ) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        List<StatusDescription> nodeNotes = cn.publishUpdatesExplanations(cev);
        if (nodeNotes != null && nodeNotes.size() > 0) {
            notifications.addAll(nodeNotes);
        }
    }
    return notifications;
}
Also used : ArrayList(java.util.ArrayList) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CourseNode(org.olat.course.nodes.CourseNode)

Example 80 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project openolat by klemens.

the class PublishProcess method appendPublishableSubnodeIds.

/**
 * starting from each user selected to-publish node all also affected nodes
 * are added to the list of nodes to be published.
 *
 * @param cetn
 * @param nodesToPublish
 */
private void appendPublishableSubnodeIds(CourseEditorTreeNode cetn, List<String> nodesToPublish) {
    for (int i = 0; i < cetn.getChildCount(); i++) {
        CourseEditorTreeNode child = (CourseEditorTreeNode) cetn.getChildAt(i);
        if (child.hasPublishableChanges())
            nodesToPublish.add(child.getIdent());
        appendPublishableSubnodeIds(child, nodesToPublish);
    }
}
Also used : CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode)

Aggregations

CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)88 CourseNode (org.olat.course.nodes.CourseNode)54 ICourse (org.olat.course.ICourse)38 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)24 INode (org.olat.core.util.nodes.INode)22 Test (org.junit.Test)20 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Identity (org.olat.core.id.Identity)14 TreeVisitor (org.olat.core.util.tree.TreeVisitor)14 Visitor (org.olat.core.util.tree.Visitor)14 CourseNodeVO (org.olat.restapi.support.vo.CourseNodeVO)12 TreeNode (org.olat.core.gui.components.tree.TreeNode)10 STCourseNode (org.olat.course.nodes.STCourseNode)10 ArrayList (java.util.ArrayList)9 File (java.io.File)8 URI (java.net.URI)8 HttpResponse (org.apache.http.HttpResponse)8 HttpPut (org.apache.http.client.methods.HttpPut)8 Structure (org.olat.course.Structure)8 BCCourseNode (org.olat.course.nodes.BCCourseNode)8