use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
the class EPArtefactManager method filterArtefactsByString.
private void filterArtefactsByString(List<AbstractArtefact> artefacts, String textFilter) {
if (StringHelper.containsNonWhitespace(textFilter)) {
List<AbstractArtefact> toRemove = new ArrayList<AbstractArtefact>();
for (AbstractArtefact artefact : artefacts) {
String textCompare = artefact.getTitle() + artefact.getDescription() + artefact.getFulltextContent();
if (!textCompare.toLowerCase().contains(textFilter.toLowerCase())) {
toRemove.add(artefact);
}
}
artefacts.removeAll(toRemove);
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
the class EPArtefactManager method loadArtefactsByBusinessPath.
protected List<AbstractArtefact> loadArtefactsByBusinessPath(String businessPath, Identity author) {
if (!StringHelper.containsNonWhitespace(businessPath))
return null;
StringBuilder sb = new StringBuilder();
sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where artefact.businessPath=:bpath");
if (author != null) {
sb.append(" and artefact.author=:ident");
}
DBQuery query = dbInstance.createQuery(sb.toString());
query.setString("bpath", businessPath);
if (author != null) {
query.setEntity("ident", author);
}
@SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
// if not found, it is an empty list
if (artefacts.isEmpty())
return null;
return artefacts;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
the class EPArtefactManager method getArtefactPoolForUser.
protected List<AbstractArtefact> getArtefactPoolForUser(Identity ident) {
long start = System.currentTimeMillis();
StringBuilder sb = new StringBuilder();
sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where author=:author");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setEntity("author", ident);
@SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
if (artefacts.isEmpty())
return null;
long duration = System.currentTimeMillis() - start;
if (isLogDebugEnabled())
logDebug("loading the full artefact pool took " + duration + "ms");
return artefacts;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
the class EPArtefactManager method filterArtefactsByType.
private void filterArtefactsByType(List<AbstractArtefact> artefacts, List<String> type) {
if (type != null && type.size() != 0) {
List<AbstractArtefact> toRemove = new ArrayList<AbstractArtefact>();
for (AbstractArtefact artefact : artefacts) {
if (!type.contains(artefact.getResourceableTypeName())) {
toRemove.add(artefact);
}
}
artefacts.removeAll(toRemove);
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.
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