use of org.olat.modules.portfolio.Category in project openolat by klemens.
the class MyPageListController method loadModel.
@Override
protected void loadModel(UserRequest ureq, String searchString) {
Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfCommentsOnOwnedPage(getIdentity());
List<CategoryToElement> categorizedElements = portfolioService.getCategorizedOwnedPages(getIdentity());
Map<OLATResourceable, List<Category>> categorizedElementMap = new HashMap<>();
for (CategoryToElement categorizedElement : categorizedElements) {
List<Category> categories = categorizedElementMap.get(categorizedElement.getCategorizedResource());
if (categories == null) {
categories = new ArrayList<>();
categorizedElementMap.put(categorizedElement.getCategorizedResource(), categories);
}
categories.add(categorizedElement.getCategory());
}
List<Assignment> assignments = portfolioService.searchOwnedAssignments(getIdentity());
Map<Page, List<Assignment>> pageToAssignments = new HashMap<>();
for (Assignment assignment : assignments) {
Page page = assignment.getPage();
List<Assignment> assignmentList;
if (pageToAssignments.containsKey(page)) {
assignmentList = pageToAssignments.get(page);
} else {
assignmentList = new ArrayList<>();
pageToAssignments.put(page, assignmentList);
}
assignmentList.add(assignment);
}
FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
newEntryButton.setCustomEnabledLinkCSS("btn btn-primary");
List<Page> pages = portfolioService.searchOwnedPages(getIdentity(), searchString);
List<PortfolioElementRow> rows = new ArrayList<>(pages.size());
List<TimelinePoint> points = new ArrayList<>(pages.size());
for (Page page : pages) {
if (page.getPageStatus() == PageStatus.deleted) {
continue;
}
List<Assignment> assignmentList = pageToAssignments.get(page);
PortfolioElementRow row = forgePageRow(ureq, page, null, assignmentList, categorizedElementMap, numberOfCommentsMap, true);
rows.add(row);
if (page.getSection() != null) {
Section section = page.getSection();
row.setMetaSectionTitle(section.getTitle());
if (section.getBinder() != null) {
row.setMetaBinderTitle(section.getBinder().getTitle());
}
}
row.setNewFloatingEntryLink(newEntryButton);
String s = page.getPageStatus() == null ? "draft" : page.getPageStatus().name();
points.add(new TimelinePoint(page.getKey().toString(), page.getTitle(), page.getCreationDate(), s));
}
timelineEl.setPoints(points);
// clean up the posters
disposeRows();
model.setObjects(rows);
tableEl.reset();
tableEl.reloadData();
}
use of org.olat.modules.portfolio.Category in project OpenOLAT by OpenOLAT.
the class CategoryDAOTest method getMediaCategoriesStatistics.
@Test
public void getMediaCategoriesStatistics() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-media-1");
Media media = mediaDao.createMedia("Media to categorize", "Media category", "Media content", "text", "[Media:0]", null, 10, id);
dbInstance.commit();
Category category = categoryDao.createAndPersistCategory("Cool");
OLATResourceable ores = OresHelper.createOLATResourceableInstance(Media.class, media.getKey());
categoryDao.appendRelation(ores, category);
dbInstance.commitAndCloseSession();
// load medias
List<CategoryStatistics> catStatistics = categoryDao.getMediaCategoriesStatistics(id);
Assert.assertNotNull(catStatistics);
Assert.assertEquals(1, catStatistics.size());
Assert.assertEquals(category.getName(), catStatistics.get(0).getName());
Assert.assertTrue(1 <= catStatistics.get(0).getCount());
}
use of org.olat.modules.portfolio.Category in project OpenOLAT by OpenOLAT.
the class CategoryDAOTest method getMediaCategories.
@Test
public void getMediaCategories() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-media-1");
Media media = mediaDao.createMedia("Media to categorize", "Media category", "Media content", "text", "[Media:0]", null, 10, id);
dbInstance.commit();
Category category = categoryDao.createAndPersistCategory("Cool");
OLATResourceable ores = OresHelper.createOLATResourceableInstance(Media.class, media.getKey());
categoryDao.appendRelation(ores, category);
dbInstance.commitAndCloseSession();
// load medias
List<CategoryLight> categories = categoryDao.getMediaCategories(id);
Assert.assertNotNull(categories);
Assert.assertEquals(1, categories.size());
Assert.assertEquals(category.getName(), categories.get(0).getCategory());
}
use of org.olat.modules.portfolio.Category in project OpenOLAT by OpenOLAT.
the class AbstractPageListController method forgeSectionRow.
protected PortfolioElementRow forgeSectionRow(Section section, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap) {
PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, config.isAssessable(), (assignments != null && assignments.size() > 0));
String openLinkId = "open_" + (++counter);
FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL);
openLink.setIconRightCSS("o_icon o_icon_start");
openLink.setPrimary(true);
row.setOpenFormLink(openLink);
openLink.setUserObject(row);
addCategoriesToRow(row, categorizedElementMap);
if (assignments != null && secCallback.canViewPendingAssignments(section) && secCallback.canInstantiateAssignment()) {
List<Assignment> startableAssignments = assignments.stream().filter(ass -> ass.getAssignmentStatus() == AssignmentStatus.notStarted).filter(ass -> ass.getPage() == null).collect(Collectors.toList());
if (!startableAssignments.isEmpty()) {
String[] keys = new String[startableAssignments.size() + 1];
String[] values = new String[startableAssignments.size() + 1];
keys[0] = "start.assignment.hint";
values[0] = translate("start.assignment.hint");
int count = 1;
for (Assignment assignment : startableAssignments) {
keys[count] = Long.toString(assignment.getKey());
values[count] = assignment.getTitle();
count++;
}
SingleSelection startEl = uifactory.addDropdownSingleselect("assignments_" + (++counter), "", flc, keys, values, null);
startEl.setDomReplacementWrapperRequired(false);
startEl.addActionListener(FormEvent.ONCHANGE);
row.setStartSelection(startEl);
}
}
return row;
}
use of org.olat.modules.portfolio.Category in project OpenOLAT by OpenOLAT.
the class DeletedPageListController method loadModel.
@Override
protected void loadModel(UserRequest ureq, String searchString) {
Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfCommentsOnOwnedPage(getIdentity());
List<CategoryToElement> categorizedElements = portfolioService.getCategorizedOwnedPages(getIdentity());
Map<OLATResourceable, List<Category>> categorizedElementMap = new HashMap<>();
for (CategoryToElement categorizedElement : categorizedElements) {
List<Category> categories = categorizedElementMap.get(categorizedElement.getCategorizedResource());
if (categories == null) {
categories = new ArrayList<>();
categorizedElementMap.put(categorizedElement.getCategorizedResource(), categories);
}
categories.add(categorizedElement.getCategory());
}
List<Page> pages = portfolioService.searchDeletedPages(getIdentity(), searchString);
List<PortfolioElementRow> rows = new ArrayList<>(pages.size());
for (Page page : pages) {
rows.add(forgePageRow(ureq, page, null, null, categorizedElementMap, numberOfCommentsMap, true));
}
// clean up the posters
disposeRows();
model.setObjects(rows);
tableEl.reset();
tableEl.reloadData();
deleteButton.setVisible(tableEl.getRendererType() == FlexiTableRendererType.classic && model.getRowCount() > 0);
}
Aggregations