use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPReflexionWrapperController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == reflexionCtrl && event instanceof EPReflexionChangeEvent) {
EPReflexionChangeEvent refEv = (EPReflexionChangeEvent) event;
if (struct != null) {
ePFMgr.setReflexionForArtefactToStructureLink(refEv.getRefArtefact(), struct, refEv.getReflexion());
reflexionBox.deactivate();
fireEvent(ureq, new EPStructureChangeEvent(EPStructureChangeEvent.ADDED, struct));
} else {
AbstractArtefact refArtefact = refEv.getRefArtefact();
refArtefact.setReflexion(refEv.getReflexion());
ePFMgr.updateArtefact(refArtefact);
reflexionBox.deactivate();
fireEvent(ureq, Event.DONE_EVENT);
}
removeAsListenerAndDispose(reflexionBox);
} else if (source == reflexionBox && event == CloseableCalloutWindowController.CLOSE_WINDOW_EVENT) {
removeAsListenerAndDispose(reflexionBox);
reflexionBox = null;
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManagerTest method testCreateForumArtefact.
@Test
public void testCreateForumArtefact() {
EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler("Forum");
AbstractArtefact artefact = handler.createArtefact();
artefact.setAuthor(ident1);
assertNotNull(artefact);
assertTrue(artefact instanceof ForumArtefact);
// update the artefact
AbstractArtefact persistedArtefact = epFrontendManager.updateArtefact(artefact);
assertNotNull(persistedArtefact);
assertTrue(persistedArtefact instanceof ForumArtefact);
dbInstance.commitAndCloseSession();
// reload the artefact
AbstractArtefact loadedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
assertNotNull(loadedArtefact);
assertTrue(loadedArtefact instanceof ForumArtefact);
// get the VFS container of the artefact
VFSContainer container = epFrontendManager.getArtefactContainer(loadedArtefact);
assertNotNull(container);
if (container instanceof LocalFolderImpl) {
LocalFolderImpl folder = (LocalFolderImpl) container;
assertNotNull(folder.getBasefile());
assertTrue(folder.getBasefile().exists());
assertTrue(folder.getBasefile().isDirectory());
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManagerTest method testDeleteArtefactVFSContainer.
@Test
public void testDeleteArtefactVFSContainer() {
// test deletion of vfs-artefactContainer
AbstractArtefact artefact3 = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
VFSContainer artCont = epFrontendManager.getArtefactContainer(artefact3);
artCont.createChildLeaf("testfile.txt");
assertEquals(1, artCont.getItems().size());
Long artKey3 = artefact3.getKey();
epFrontendManager.deleteArtefact(artefact3);
VFSItem item = epFrontendManager.getArtefactsRoot().resolve(artKey3.toString());
assertNull(item);
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPStructureToArtefactTest method saveArtefact.
/**
* Persist all properties and check them
*/
@Test
public void saveArtefact() {
// create artefact
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.MILLISECOND, 0);
Date collectionDate = cal.getTime();
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
artefact.setTitle("artefact-title");
artefact.setBusinessPath("business-path");
artefact.setCollectionDate(collectionDate);
artefact.setDescription("artefact-description");
artefact.setReflexion("artefact-reflexion");
artefact.setSignature(70);
artefact.setFulltextContent("fulltext-content");
artefact.setSource("artefact-source");
artefact = epFrontendManager.updateArtefact(artefact);
dbInstance.commitAndCloseSession();
// test if the link is persisted
AbstractArtefact retrievedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
assertNotNull(retrievedArtefact);
assertEquals(artefact.getKey(), retrievedArtefact.getKey());
assertEquals("artefact-title", retrievedArtefact.getTitle());
assertEquals("business-path", retrievedArtefact.getBusinessPath());
assertEquals("artefact-description", retrievedArtefact.getDescription());
assertEquals("artefact-reflexion", retrievedArtefact.getReflexion());
assertEquals(70, retrievedArtefact.getSignature());
assertEquals("fulltext-content", retrievedArtefact.getFulltextContent());
assertEquals("artefact-source", retrievedArtefact.getSource());
assertEquals(ident1.getKey(), retrievedArtefact.getAuthor().getKey());
// check date
assertNotNull(retrievedArtefact.getCollectionDate());
Calendar cal1 = Calendar.getInstance();
cal1.setTime(collectionDate);
Calendar cal2 = Calendar.getInstance();
cal2.setTime(retrievedArtefact.getCollectionDate());
assertTrue(cal1.compareTo(cal2) == 0);
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPStructureToArtefactTest method removeArtefactsToStructure.
@Test
public void removeArtefactsToStructure() {
// create structure element
PortfolioStructure structure = epFrontendManager.createAndPersistPortfolioStructureElement(null, "struc-to-art-el", "structure-to-artefact-element");
// create artefact
AbstractArtefact artefact1 = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
AbstractArtefact artefact2 = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
AbstractArtefact artefact3 = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
epFrontendManager.addArtefactToStructure(ident1, artefact1, structure);
epFrontendManager.addArtefactToStructure(ident1, artefact2, structure);
epFrontendManager.addArtefactToStructure(ident1, artefact3, structure);
dbInstance.commitAndCloseSession();
epFrontendManager.removeArtefactFromStructure(artefact2, structure);
dbInstance.commitAndCloseSession();
// test if the link is persisted
List<AbstractArtefact> linkedArtfeacts = epFrontendManager.getArtefacts(structure);
assertNotNull(linkedArtfeacts);
assertEquals(2, linkedArtfeacts.size());
assertEquals(artefact1.getKey(), linkedArtfeacts.get(0).getKey());
assertEquals(artefact3.getKey(), linkedArtfeacts.get(1).getKey());
}
Aggregations