Search in sources :

Example 6 with RepositoryEntryShort

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);
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) BusinessGroupSelectionEvent(org.olat.group.model.BusinessGroupSelectionEvent) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) BusinessGroupShort(org.olat.group.BusinessGroupShort) BusinessGroupRow(org.olat.group.model.BusinessGroupRow)

Example 7 with RepositoryEntryShort

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);
}
Also used : RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) BusinessGroup(org.olat.group.BusinessGroup)

Example 8 with RepositoryEntryShort

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;
}
Also used : ACResourceInfoImpl(org.olat.resource.accesscontrol.model.ACResourceInfoImpl) RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) HashMap(java.util.HashMap) BusinessGroup(org.olat.group.BusinessGroup) ACResourceInfo(org.olat.resource.accesscontrol.model.ACResourceInfo) ArrayList(java.util.ArrayList) OLATResource(org.olat.resource.OLATResource)

Example 9 with RepositoryEntryShort

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);
}
Also used : RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 10 with RepositoryEntryShort

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>");
        }
    }
}
Also used : RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

RepositoryEntryShort (org.olat.repository.RepositoryEntryShort)20 RepositoryEntry (org.olat.repository.RepositoryEntry)10 BusinessGroup (org.olat.group.BusinessGroup)8 ArrayList (java.util.ArrayList)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 BusinessGroupShort (org.olat.group.BusinessGroupShort)4 HashMap (java.util.HashMap)2 Locale (java.util.Locale)2 VelocityContext (org.apache.velocity.VelocityContext)2 Test (org.junit.Test)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 Translator (org.olat.core.gui.translator.Translator)2 Identity (org.olat.core.id.Identity)2 User (org.olat.core.id.User)2 MailTemplate (org.olat.core.util.mail.MailTemplate)2 BusinessGroupRef (org.olat.group.BusinessGroupRef)2 BusinessGroupService (org.olat.group.BusinessGroupService)2 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)2 BusinessGroupSelectionEvent (org.olat.group.model.BusinessGroupSelectionEvent)2