use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPStructureManager method loadStructureChildren.
/**
* @param structure
* @param firstResult
* @param maxResults
* @return
*/
protected List<PortfolioStructure> loadStructureChildren(PortfolioStructure structure, int firstResult, int maxResults) {
if (structure == null)
throw new NullPointerException();
StringBuilder sb = new StringBuilder();
sb.append("select link.child from ").append(EPStructureToStructureLink.class.getName()).append(" link").append(" where link.parent=:structureEl order by link.order");
DBQuery query = dbInstance.createQuery(sb.toString());
if (firstResult > 0) {
query.setFirstResult(firstResult);
}
if (maxResults > 0) {
query.setMaxResults(maxResults);
}
query.setEntity("structureEl", structure);
@SuppressWarnings("unchecked") List<PortfolioStructure> resources = query.list();
return resources;
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPXStreamHandler method copy.
public static final PortfolioStructure copy(PortfolioStructure structure) {
String stringuified = myStream.toXML(structure);
PortfolioStructure newStructure = (PortfolioStructure) myStream.fromXML(stringuified);
return newStructure;
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
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 klemens.
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 klemens.
the class AbstractPortfolioMapIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
SearchResourceContext resourceContext = new SearchResourceContext();
int firstResult = 0;
List<PortfolioStructure> structures = null;
do {
structures = frontendManager.getStructureElements(firstResult, 500, getElementType());
for (PortfolioStructure structure : structures) {
if (structure instanceof PortfolioStructureMap) {
PortfolioStructureMap map = (PortfolioStructureMap) structure;
if (accept(map)) {
resourceContext.setDocumentType(getDocumentType());
resourceContext.setBusinessControlFor(map.getOlatResource());
Document document = PortfolioMapDocument.createDocument(resourceContext, map);
indexerWriter.addDocument(document);
}
}
}
firstResult += structures.size();
} while (structures != null && structures.size() == BATCH_SIZE);
}
Aggregations