use of org.olat.core.util.nodes.INode in project OpenOLAT by OpenOLAT.
the class PublishProcessTest method testPublishNewNodeButNotMarkedAsSuch.
/**
* Publish a course with a node marked as not new but the
* node dosn't exist in the run structure.
*
* @throws URISyntaxException
*/
@Test
public void testPublishNewNodeButNotMarkedAsSuch() throws URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAdmin("publisher-" + UUID.randomUUID().toString());
RepositoryEntry re = deployTestCourse("simple_course_err3_not_new.zip");
// change node 1
ICourse course = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
CourseEditorTreeModel cetm = course.getEditorTreeModel();
CourseEditorTreeNode node1 = (CourseEditorTreeNode) cetm.getRootNode().getChildAt(0);
// publish the course and must survive this without exception
// as the course has no changes but we try to publish it
List<String> nodeIds = Collections.singletonList(node1.getIdent());
publishCourse(nodeIds, re, author);
// check the change
ICourse reloadedCourse = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
Assert.assertEquals(3, reloadedCourse.getRunStructure().getRootNode().getChildCount());
INode runNode1 = reloadedCourse.getRunStructure().getRootNode().getChildAt(0);
Assert.assertNotNull(runNode1);
CourseNode runNode1Impl = (CourseNode) runNode1;
Assert.assertEquals("Node 1 from hell", runNode1Impl.getShortTitle());
}
use of org.olat.core.util.nodes.INode in project OpenOLAT by OpenOLAT.
the class PublishProcessTest method testPublishNewNodeNotMarkedAsSuchAndNotPublished.
/**
* Publish a course with a node marked as not new but
* the node doesn't exist in the run structure. The node
* itself is not published.
*
* @throws URISyntaxException
*/
@Test
public void testPublishNewNodeNotMarkedAsSuchAndNotPublished() throws URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAdmin("publisher-" + UUID.randomUUID().toString());
RepositoryEntry re = deployTestCourse("simple_course_err5_not_new_or_published.zip");
// change node 1
ICourse course = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
CourseEditorTreeModel cetm = course.getEditorTreeModel();
// publish the course and must survive this without exception
// as the course has no changes but we try to publish it
List<String> nodeIds = Collections.singletonList(cetm.getRootNode().getIdent());
publishCourse(nodeIds, re, author);
// check the change
ICourse reloadedCourse = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
Assert.assertEquals(2, reloadedCourse.getRunStructure().getRootNode().getChildCount());
INode runNode1 = reloadedCourse.getRunStructure().getRootNode().getChildAt(0);
Assert.assertNotNull(runNode1);
CourseNode runNode1Impl = (CourseNode) runNode1;
Assert.assertEquals("Node 2", runNode1Impl.getShortTitle());
}
use of org.olat.core.util.nodes.INode in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method getGTACourseNode.
private GTACourseNode getGTACourseNode(RepositoryEntry courseEntry) {
ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode rootNode = course.getRunStructure().getRootNode();
for (int i = rootNode.getChildCount(); i-- > 0; ) {
INode child = rootNode.getChildAt(i);
if (child instanceof GTACourseNode) {
return ((GTACourseNode) child);
}
}
return null;
}
use of org.olat.core.util.nodes.INode in project OpenOLAT by OpenOLAT.
the class EditorMainController method doCreateAlternateBuildingBlock.
/**
* The following operation are done:
* <ul>
* <li>create a new instance of the replacement type
* <li>add the new element below the original element
* <li>copy the element title, description and the generic configuration options
* <li>copy the access, visibility and scoring rules (easy and expert)
* <li>optionally copy some other configuration if this is possible at all
* <li>move all child elements from the original to the replacement element
* <li>mark the original element as deleted
* </ul>
*
* @param chosenNode
* @param selectAlternative
*/
private void doCreateAlternateBuildingBlock(UserRequest ureq, ICourse course, CourseNode chosenNode, String selectAlternative) {
if (!StringHelper.containsNonWhitespace(selectAlternative))
return;
// create the alternative node
CourseNodeConfiguration newConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(selectAlternative);
CourseNode newNode = newConfig.getInstance();
// copy configurations
chosenNode.copyConfigurationTo(newNode, course);
// insert the node
CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(chosenNode.getIdent());
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) cetn.getParent();
int position = cetn.getPosition() + 1;
CourseEditorTreeNode newCetn = course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode.getCourseNode(), position);
doInsert(ureq, newNode);
// copy the children
while (cetn.getChildCount() > 0) {
CourseEditorTreeNode childNode = (CourseEditorTreeNode) cetn.getChildAt(0);
newCetn.addChild(childNode);
}
// set all dirty
TreeVisitor tv = new TreeVisitor(new Visitor() {
public void visit(INode node) {
((CourseEditorTreeNode) node).setDirty(true);
}
}, newCetn, true);
tv.visitAll();
// mark as deleted
doDelete(course, chosenNode.getIdent());
// save
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
}
use of org.olat.core.util.nodes.INode in project OpenOLAT by OpenOLAT.
the class CourseEditorEnvImpl method checkFolderNodes.
private List<StatusDescription> checkFolderNodes(INode rootNode, ICourse course, List<StatusDescription> descriptions) {
List<StatusDescription> descriptionsI = descriptions;
Visitor visitor = new Visitor() {
@Override
public void visit(INode node) {
CourseEditorTreeNode courseNode = (CourseEditorTreeNode) course.getEditorTreeModel().getNodeById(node.getIdent());
if (!courseNode.isDeleted() && courseNode.getCourseNode() instanceof BCCourseNode) {
BCCourseNode bcNode = (BCCourseNode) courseNode.getCourseNode();
if (bcNode.isSharedFolder()) {
String translPackage = Util.getPackageName(BCCourseNodeEditController.class);
StatusDescription status = new StatusDescription(StatusDescription.ERROR, "warning.no.sharedfolder", "warning.no.sharedfolder", null, translPackage);
status.setDescriptionForUnit(bcNode.getIdent());
// set which pane is affected by error
status.setActivateableViewIdentifier(BCCourseNodeEditController.PANE_TAB_FOLDER);
descriptionsI.add(status);
}
}
}
};
TreeVisitor v = new TreeVisitor(visitor, rootNode, false);
v.visitAll();
return descriptionsI;
}
Aggregations