use of org.olat.portfolio.model.structel.PortfolioStructure 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.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class GroupPortfolioIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
if (!(businessObj instanceof BusinessGroup))
throw new AssertException("businessObj must be BusinessGroup");
BusinessGroup businessGroup = (BusinessGroup) businessObj;
NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(businessGroup);
Property mapKeyProperty = npm.findProperty(null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_PORTFOLIO);
// Check if portfolio map property exist
if (mapKeyProperty != null) {
Long mapKey = mapKeyProperty.getLongValue();
String version = mapKeyProperty.getStringValue();
if (version == null || !version.equals("2")) {
PortfolioStructure map = frontendManager.loadPortfolioStructureByKey(mapKey);
if (map != null) {
SearchResourceContext resourceContext = new SearchResourceContext(parentResourceContext);
resourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLPORTFOLIO);
resourceContext.setDocumentType(TYPE);
resourceContext.setParentContextType(GroupDocument.TYPE);
resourceContext.setParentContextName(businessGroup.getName());
Document document = PortfolioMapDocument.createDocument(resourceContext, map);
indexerWriter.addDocument(document);
}
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class PortfolioRepositoryIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext resourceContext, Object object, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
if (isLogDebugEnabled())
logDebug("Index portfolio templates...");
RepositoryEntry repositoryEntry = (RepositoryEntry) object;
OLATResource ores = repositoryEntry.getOlatResource();
PortfolioStructure element = structureManager.loadPortfolioStructure(ores);
// only index templates
if (element instanceof EPStructuredMapTemplate) {
resourceContext.setDocumentType(TYPE);
resourceContext.setParentContextType(TYPE);
resourceContext.setParentContextName(repositoryEntry.getDisplayname());
resourceContext.setFilePath(element.getKey().toString());
Document document = PortfolioMapDocument.createDocument(resourceContext, element);
indexWriter.addDocument(document);
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class PortfolioCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(searchResourceContext, courseNode, NODE_TYPE);
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(document);
PortfolioCourseNode portfolioNode = (PortfolioCourseNode) courseNode;
RepositoryEntry repoEntry = portfolioNode.getReferencedRepositoryEntry();
if (repoEntry != null) {
OLATResource ores = repoEntry.getOlatResource();
PortfolioStructure element = structureManager.loadPortfolioStructure(ores);
if (element != null) {
Document pDocument = PortfolioMapDocument.createDocument(courseNodeResourceContext, element);
indexWriter.addDocument(pDocument);
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure 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();
}
Aggregations