use of org.olat.repository.RepositoryEntryShort in project openolat by klemens.
the class AbstractBusinessGroupListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (createButton == source) {
doCreate(ureq, getWindowControl(), null);
} else if (deleteButton == source) {
confirmDelete(ureq, getSelectedItems());
} else if (duplicateButton == source) {
doCopy(ureq, getSelectedItems());
} else if (configButton == source) {
doConfiguration(ureq, getSelectedItems());
} else if (emailButton == source) {
doEmails(ureq, getSelectedItems());
} else if (usersButton == source) {
doUserManagement(ureq, getSelectedItems());
} else if (mergeButton == source) {
doMerge(ureq, getSelectedItems());
} else if (selectButton == source) {
doSelect(ureq, getSelectedItems());
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("mark".equals(cmd)) {
BusinessGroupRow row = (BusinessGroupRow) link.getUserObject();
boolean marked = toogleMark(row);
link.setIconLeftCSS(marked ? "o_icon o_icon_bookmark o_icon-lg" : "o_icon o_icon_bookmark_add o_icon-lg");
link.getComponent().setDirty(true);
} else if ("allresources".equals(cmd)) {
BusinessGroupShort bg = (BusinessGroupShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[BusinessGroup:" + bg.getKey() + "][toolresources:0]", ureq, getWindowControl());
} else if ("resource".equals(cmd)) {
RepositoryEntryShort re = (RepositoryEntryShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[RepositoryEntry:" + re.getKey() + "]", ureq, getWindowControl());
} else if (link.getUserObject() instanceof BusinessGroupRef) {
BusinessGroupRef item = (BusinessGroupRef) link.getUserObject();
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
}
}
} else if (source == tableEl) {
String cmd = event.getCommand();
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if (se.getIndex() >= 0 && se.getIndex() < groupTableModel.getRowCount()) {
BusinessGroupRef item = groupTableModel.getObject(se.getIndex());
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
// prevent rs after a group is deleted by someone else
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_DELETE.equals(cmd)) {
confirmDelete(ureq, Collections.singletonList(item));
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_EDIT.equals(cmd)) {
doEdit(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_SELECT.equals(cmd)) {
doSelect(ureq, businessGroup);
}
}
} else if (event instanceof FlexiTableSearchEvent) {
doSearch((FlexiTableSearchEvent) event);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.repository.RepositoryEntryShort in project openolat by klemens.
the class BGMailHelper method getTemplateInfos.
public static BGMailTemplateInfos getTemplateInfos(BusinessGroupShort group, List<RepositoryEntryShort> repoEntries) {
StringBuilder learningResources = new StringBuilder();
if (repoEntries != null && repoEntries.size() > 0) {
for (RepositoryEntryShort entry : repoEntries) {
String title = entry.getDisplayname();
String url = BusinessControlFactory.getInstance().getURLFromBusinessPathString("[RepositoryEntry:" + entry.getKey() + "]");
learningResources.append(title);
learningResources.append(" (");
learningResources.append(url);
learningResources.append(")\n");
}
}
String courseList = null;
if (learningResources.length() > 0) {
courseList = learningResources.toString();
}
String groupNameWithUrl = null;
String groupDescription = null;
if (group != null) {
// get group name and description
StringBuilder sb = new StringBuilder();
sb.append(group.getName() == null ? "" : group.getName()).append(" (").append(BusinessControlFactory.getInstance().getURLFromBusinessPathString("[BusinessGroup:" + group.getKey() + "]")).append(")\n");
groupNameWithUrl = sb.toString();
String description;
if (group instanceof BusinessGroup) {
description = ((BusinessGroup) group).getDescription();
} else {
description = CoreSpringFactory.getImpl(BusinessGroupDAO.class).loadDescription(group.getKey());
}
groupDescription = FilterFactory.getHtmlTagAndDescapingFilter().filter(description);
}
return new BGMailTemplateInfos(group.getName(), groupNameWithUrl, groupDescription, courseList);
}
use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.
the class ACFrontendManager method getResourceInfos.
@Override
public List<ACResourceInfo> getResourceInfos(List<OLATResource> resources) {
if (resources == null || resources.isEmpty()) {
return Collections.emptyList();
}
List<OLATResource> groupResources = new ArrayList<OLATResource>(resources.size());
List<OLATResource> repositoryResources = new ArrayList<OLATResource>(resources.size());
for (OLATResource resource : resources) {
String resourceType = resource.getResourceableTypeName();
if ("BusinessGroup".equals(resourceType)) {
groupResources.add(resource);
} else {
repositoryResources.add(resource);
}
}
List<ACResourceInfo> resourceInfos = new ArrayList<ACResourceInfo>(resources.size());
if (!groupResources.isEmpty()) {
List<Long> groupKeys = new ArrayList<Long>(groupResources.size());
Map<Long, OLATResource> groupMapKeys = new HashMap<Long, OLATResource>(groupResources.size() * 2 + 1);
for (OLATResource groupResource : groupResources) {
groupKeys.add(groupResource.getResourceableId());
}
List<BusinessGroup> groups = businessGroupService.loadBusinessGroups(groupKeys);
for (BusinessGroup group : groups) {
ACResourceInfoImpl info = new ACResourceInfoImpl();
info.setResource(groupMapKeys.get(group.getKey()));
info.setName(group.getName());
info.setDescription(group.getDescription());
info.setResource(group.getResource());
resourceInfos.add(info);
}
}
if (!repositoryResources.isEmpty()) {
List<RepositoryEntryShort> repoEntries = repositoryManager.loadRepositoryEntryShorts(repositoryResources);
for (RepositoryEntryShort repoEntry : repoEntries) {
ACResourceInfoImpl info = new ACResourceInfoImpl();
info.setName(repoEntry.getDisplayname());
info.setDescription(((RepositoryEntryShortImpl) repoEntry).getDescription());
info.setResource(((RepositoryEntryShortImpl) repoEntry).getOlatResource());
resourceInfos.add(info);
}
}
return resourceInfos;
}
use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAOTest method findShortRepositoryEntries.
@Test
public void findShortRepositoryEntries() {
// create 3 entries and 1 group
RepositoryEntry re1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry re2 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry re3 = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupDao.createAndPersist(null, "rel-repo", "rel-repo-desc", 0, 10, true, false, false, false, false);
dbInstance.commitAndCloseSession();
businessGroupRelationDao.addRelationToResource(group, re1);
businessGroupRelationDao.addRelationToResource(group, re2);
businessGroupRelationDao.addRelationToResource(group, re3);
dbInstance.commitAndCloseSession();
// check with empty list of groups
List<RepositoryEntryShort> emptyRelations = businessGroupRelationDao.findShortRepositoryEntries(Collections.<BusinessGroupShort>emptyList(), 0, -1);
Assert.assertNotNull(emptyRelations);
Assert.assertEquals(0, emptyRelations.size());
List<RepositoryEntryShort> repoEntries = businessGroupRelationDao.findShortRepositoryEntries(Collections.<BusinessGroupShort>singletonList(group), 0, -1);
Assert.assertNotNull(repoEntries);
Assert.assertEquals(3, repoEntries.size());
int count = 0;
for (RepositoryEntryShort repoEntry : repoEntries) {
if (repoEntry.getKey().equals(re1.getKey()) || repoEntry.getKey().equals(re2.getKey()) || repoEntry.getKey().equals(re3.getKey())) {
count++;
}
}
Assert.assertEquals(3, count);
}
use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.
the class RepositoryEntryIconRenderer method render.
@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
if (renderer == null) {
// render for export
} else {
String type = "";
String cssClass = "";
boolean managed = false;
if (val instanceof RepositoryEntryShort) {
RepositoryEntryShort re = (RepositoryEntryShort) val;
cssClass = RepositoyUIFactory.getIconCssClass(re);
String typeName = re.getResourceType();
type = NewControllerFactory.translateResourceableTypeName(typeName, locale);
} else if (val instanceof RepositoryEntry) {
RepositoryEntry re = (RepositoryEntry) val;
cssClass = RepositoyUIFactory.getIconCssClass(re);
managed = StringHelper.containsNonWhitespace(re.getManagedFlagsString());
String typeName = re.getOlatResource().getResourceableTypeName();
type = NewControllerFactory.translateResourceableTypeName(typeName, locale);
}
sb.append("<i class='o_icon ").append(cssClass).append("'");
if (StringHelper.containsNonWhitespace(type)) {
sb.append(" title=\"");
sb.append(StringEscapeUtils.escapeHtml(type));
}
sb.append("\"> </i>");
if (managed) {
sb.append(" <i class='o_icon o_icon_managed'> </i>");
}
}
}
Aggregations