use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class PortfolioMapDocument method getContent.
private static String getContent(PortfolioStructure map, SearchResourceContext resourceContext, StringBuilder sb, Filter filter) {
sb.append(' ').append(map.getTitle());
if (StringHelper.containsNonWhitespace(map.getDescription())) {
sb.append(' ').append(filter.filter(map.getDescription()));
}
for (PortfolioStructure child : ePFMgr.loadStructureChildren(map)) {
getContent(child, resourceContext, sb, filter);
}
for (AbstractArtefact artefact : ePFMgr.getArtefacts(map)) {
String reflexion = artefact.getReflexion();
if (StringHelper.containsNonWhitespace(reflexion)) {
sb.append(' ').append(filter.filter(reflexion));
}
OLATResourceable ores = OresHelper.createOLATResourceableInstance(AbstractArtefact.class.getSimpleName(), artefact.getKey());
EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
SearchResourceContext artefactResourceContext = new SearchResourceContext(resourceContext);
artefactResourceContext.setBusinessControlFor(ores);
OlatDocument doc = handler.getIndexerDocument(artefactResourceContext, artefact, ePFMgr);
sb.append(' ').append(doc.getContent());
}
return sb.toString();
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method testCopyMap.
@Test
public void testCopyMap() {
// create two artefacts
AbstractArtefact artefact1 = epFrontendManager.createAndPersistArtefact(ident1, "text");
assertNotNull(artefact1);
AbstractArtefact artefact2 = epFrontendManager.createAndPersistArtefact(ident1, "bc");
assertNotNull(artefact2);
dbInstance.commitAndCloseSession();
// create a map with a page and the page has two artefacts
PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
PortfolioStructure newPage = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
boolean successfullLink1 = epFrontendManager.addArtefactToStructure(ident1, artefact1, newPage);
assertTrue(successfullLink1);
boolean successfullLink2 = epFrontendManager.addArtefactToStructure(ident1, artefact2, newPage);
assertTrue(successfullLink2);
dbInstance.commitAndCloseSession();
// 1 test: copy the map one shoot
PortfolioStructureMap copyMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title copy", "Description copy");
epFrontendManager.copyStructureRecursively(originalMap, copyMap, true);
assertNotNull(copyMap.getKey());
dbInstance.commitAndCloseSession();
// 2 test: copy the map two shoota
PortfolioStructureMap copyMap2 = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title copy 2", "Description copy 2");
dbInstance.commitAndCloseSession();
assertNotNull(copyMap2.getKey());
epFrontendManager.copyStructureRecursively(originalMap, copyMap2, true);
dbInstance.commitAndCloseSession();
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method closedArtefacts.
@Test
public void closedArtefacts() {
// create two artefacts
AbstractArtefact artefact1 = epFrontendManager.createAndPersistArtefact(ident1, "text");
assertNotNull(artefact1);
AbstractArtefact artefact2 = epFrontendManager.createAndPersistArtefact(ident1, "bc");
assertNotNull(artefact2);
dbInstance.commitAndCloseSession();
// create a map with a page and the page has two artefacts
PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
PortfolioStructure newPage = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
boolean successfullLink1 = epFrontendManager.addArtefactToStructure(ident1, artefact1, newPage);
assertTrue(successfullLink1);
boolean successfullLink2 = epFrontendManager.addArtefactToStructure(ident1, artefact2, newPage);
assertTrue(successfullLink2);
dbInstance.commitAndCloseSession();
// check if the artefact is in a closed map
assertFalse(epFrontendManager.isArtefactClosed(artefact1));
assertFalse(epFrontendManager.isArtefactClosed(artefact2));
// closed the map artificially
((EPDefaultMap) originalMap).setStatus(StructureStatusEnum.CLOSED);
dbInstance.updateObject(originalMap);
dbInstance.commitAndCloseSession();
// check if the artefact is in a closed map
assertTrue(epFrontendManager.isArtefactClosed(artefact1));
assertTrue(epFrontendManager.isArtefactClosed(artefact2));
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method isArtefactsInStructure.
@Test
public void isArtefactsInStructure() {
// create two artefacts
AbstractArtefact artefact1 = epFrontendManager.createAndPersistArtefact(ident1, "text");
assertNotNull(artefact1);
AbstractArtefact artefact2 = epFrontendManager.createAndPersistArtefact(ident1, "bc");
assertNotNull(artefact2);
dbInstance.commitAndCloseSession();
// create a map with a page and the page has two artefacts
PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
PortfolioStructure page2 = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
boolean successfullLink1 = epFrontendManager.addArtefactToStructure(ident1, artefact1, page1);
assertTrue(successfullLink1);
boolean successfullLink2 = epFrontendManager.addArtefactToStructure(ident1, artefact2, page2);
assertTrue(successfullLink2);
dbInstance.commitAndCloseSession();
assertTrue(epFrontendManager.isArtefactInStructure(artefact1, page1));
assertFalse(epFrontendManager.isArtefactInStructure(artefact1, page2));
assertFalse(epFrontendManager.isArtefactInStructure(artefact2, page1));
assertTrue(epFrontendManager.isArtefactInStructure(artefact2, page2));
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManager method getArtefactsAndTagCloud.
/**
* This is an optimized method to filter a list of artefact by tags and return
* the tags of this list of artefacts. This prevent to search two times or more the list
* of tags of an artefact.
* @param identity
* @param tags
* @return the filtered artefacts and their tags
*/
protected EPArtefactTagCloud getArtefactsAndTagCloud(Identity identity, List<String> tags) {
List<AbstractArtefact> artefacts = getArtefactPoolForUser(identity);
EPFilterSettings filterSettings = new EPFilterSettings();
filterSettings.setTagFilter(tags);
Set<String> newTags = new HashSet<String>();
filterArtefactsByTags(artefacts, filterSettings, newTags);
return new EPArtefactTagCloud(artefacts, newTags);
}
Aggregations