Search in sources :

Example 81 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.

the class TaxonomyLevelOverviewController method doMove.

private void doMove(UserRequest ureq) {
    if (moveLevelCtrl != null)
        return;
    taxonomyLevel = taxonomyService.getTaxonomyLevel(taxonomyLevel);
    Taxonomy taxonomy = taxonomyLevel.getTaxonomy();
    List<TaxonomyLevel> levelsToMove = Collections.singletonList(taxonomyLevel);
    moveLevelCtrl = new MoveTaxonomyLevelController(ureq, getWindowControl(), levelsToMove, taxonomy);
    listenTo(moveLevelCtrl);
    String title = translate("move.taxonomy.level.title", new String[] { StringHelper.escapeHtml(taxonomyLevel.getDisplayName()) });
    cmc = new CloseableModalController(getWindowControl(), "close", moveLevelCtrl.getInitialComponent(), true, title);
    listenTo(cmc);
    cmc.activate();
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 82 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.

the class TaxonomyListAdminController method doOpenTaxonomy.

private TaxonomyOverviewController doOpenTaxonomy(UserRequest ureq, TaxonomyRow row) {
    removeAsListenerAndDispose(taxonomyCtrl);
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("Taxonomy", row.getKey());
    WindowControl bwControl = addToHistory(ureq, ores, null);
    Taxonomy taxonomy = taxonomyService.getTaxonomy(row);
    taxonomyCtrl = new TaxonomyOverviewController(ureq, bwControl, taxonomy);
    taxonomyCtrl.setBreadcrumbPanel(stackPanel);
    listenTo(taxonomyCtrl);
    stackPanel.changeDisplayname(translate("admin.menu.title"));
    stackPanel.pushController(row.getDisplayName(), taxonomyCtrl);
    return taxonomyCtrl;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) Taxonomy(org.olat.modules.taxonomy.Taxonomy) WindowControl(org.olat.core.gui.control.WindowControl)

Example 83 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.

the class SearchControllerFactory method getBusinessPathLabel.

@Override
public String getBusinessPathLabel(String token, List<String> allTokens, Locale locale) {
    try {
        String[] splitted = token.split("[:]");
        if (splitted != null && splitted.length == 2) {
            String tokenType = splitted[0];
            String tokenKey = splitted[1];
            if ("RepositoryEntry".equals(tokenType)) {
                RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(Long.parseLong(tokenKey));
                return re.getDisplayname();
            }
            if ("CourseNode".equals(tokenType)) {
                String repoKey = allTokens.get(0).split("[:]")[1];
                RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(Long.parseLong(repoKey));
                if (re != null) {
                    ICourse course = CourseFactory.loadCourse(re);
                    CourseNode courseNode = course.getRunStructure().getNode(tokenKey);
                    return courseNode.getShortTitle();
                }
            }
            if ("Identity".equals(tokenType)) {
                IdentityShort identity = BaseSecurityManager.getInstance().loadIdentityShortByKey(Long.parseLong(tokenKey));
                return UserManager.getInstance().getUserDisplayName(identity);
            }
            if ("BusinessGroup".equals(tokenType)) {
                BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(Long.parseLong(tokenKey));
                return bg == null ? "" : bg.getName();
            }
            if ("Taxonomy".equals(tokenType)) {
                Taxonomy taxonomy = CoreSpringFactory.getImpl(TaxonomyService.class).getTaxonomy(new TaxonomyRefImpl(Long.parseLong(tokenKey)));
                return taxonomy == null ? "" : taxonomy.getDisplayName();
            }
            if ("TaxonomyLevel".equals(tokenType)) {
                TaxonomyLevel level = CoreSpringFactory.getImpl(TaxonomyService.class).getTaxonomyLevel(new TaxonomyLevelRefImpl(Long.parseLong(tokenKey)));
                return level == null ? "" : level.getDisplayName();
            }
            Translator translator = Util.createPackageTranslator(this.getClass(), locale);
            if ("DocumentPool".equals(tokenType)) {
                return translator.translate("DocumentPool");
            }
            if ("Templates".equals(tokenType)) {
                return translator.translate("Templates");
            }
            if ("userfolder".equals(tokenType)) {
                return translator.translate("type.identity.publicfolder");
            }
            String translated = translator.translate(tokenType);
            if (translated == null || translated.length() > 64) {
                // no translation, translator return an error
                return token;
            }
            return translated;
        }
    } catch (Exception ex) {
        log.warn("Problem to decipher business path token: " + token, ex);
    }
    return token;
}
Also used : TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) BusinessGroup(org.olat.group.BusinessGroup) Taxonomy(org.olat.modules.taxonomy.Taxonomy) IdentityShort(org.olat.basesecurity.IdentityShort) TaxonomyLevelRefImpl(org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) BusinessGroupService(org.olat.group.BusinessGroupService) Translator(org.olat.core.gui.translator.Translator) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) CourseNode(org.olat.course.nodes.CourseNode)

Example 84 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.

the class DocumentPoolAdminConfigurationController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormDescription("admin.description");
    String[] onValues = new String[] { translate("on") };
    enableEl = uifactory.addCheckboxesHorizontal("document.pool.admin.enabled", formLayout, onKeys, onValues);
    enableEl.addActionListener(FormEvent.ONCHANGE);
    if (docPoolModule.isEnabled()) {
        enableEl.select(onKeys[0], true);
    }
    String mountPoint = docPoolModule.getWebDAVMountPoint();
    webDAVMountPointEl = uifactory.addTextElement("mount.point", "document.pool.webdav.mount.point", 32, mountPoint, formLayout);
    webDAVMountPointEl.setMandatory(true);
    String selectedTaxonomyTreeKey = docPoolModule.getTaxonomyTreeKey();
    List<Taxonomy> taxonomyList = taxonomyService.getTaxonomyList();
    String[] taxonomyKeys = new String[taxonomyList.size() + 1];
    String[] taxonomyValues = new String[taxonomyList.size() + 1];
    taxonomyKeys[0] = "";
    taxonomyValues[0] = "-";
    for (int i = taxonomyList.size(); i-- > 0; ) {
        Taxonomy taxonomy = taxonomyList.get(i);
        taxonomyKeys[i + 1] = taxonomy.getKey().toString();
        taxonomyValues[i + 1] = taxonomy.getDisplayName();
    }
    taxonomyTreeEl = uifactory.addDropdownSingleselect("selected.taxonomy.tree", formLayout, taxonomyKeys, taxonomyValues, null);
    taxonomyTreeEl.setMandatory(true);
    boolean found = false;
    if (StringHelper.containsNonWhitespace(selectedTaxonomyTreeKey)) {
        for (String taxonomyKey : taxonomyKeys) {
            if (taxonomyKey.equals(selectedTaxonomyTreeKey)) {
                taxonomyTreeEl.select(taxonomyKey, true);
                found = true;
            }
        }
    }
    if (!found && taxonomyKeys.length > 0) {
        taxonomyTreeEl.select(taxonomyKeys[0], true);
    }
    templatesDirectoryEl = uifactory.addCheckboxesHorizontal("document.pool.templates.directory", formLayout, onKeys, onValues);
    if (docPoolModule.isTemplatesDirectoryEnabled()) {
        templatesDirectoryEl.select(onKeys[0], true);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormSubmitButton("save", buttonsCont);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 85 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.

the class DocumentPoolNotificationsHandler method createSubscriptionInfo.

@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();
    try {
        SubscriptionInfo si;
        String taxonomyKey = documentPoolModule.getTaxonomyTreeKey();
        if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews) && StringHelper.isLong(taxonomyKey)) {
            Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(taxonomyKey)));
            if (taxonomy == null) {
                return notificationsManager.getNoSubscriptionInfo();
            }
            Identity identity = subscriber.getIdentity();
            Roles roles = securityManager.getRoles(identity);
            boolean isTaxonomyAdmin = roles.isOLATAdmin();
            Translator translator = Util.createPackageTranslator(DocumentPoolMainController.class, locale);
            String templates = translator.translate("document.pool.templates");
            TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(taxonomy, identity, null, isTaxonomyAdmin, documentPoolModule.isTemplatesDirectoryEnabled(), templates, locale);
            TreeModel model = builder.buildTreeModel();
            si = new SubscriptionInfo(subscriber.getKey(), p.getType(), getTitleItemForPublisher(), null);
            new TreeVisitor(node -> {
                TaxonomyTreeNode tNode = (TaxonomyTreeNode) node;
                if (tNode.getTaxonomyLevel() != null && tNode.isDocumentsLibraryEnabled() && tNode.isCanRead()) {
                    VFSContainer container = taxonomyService.getDocumentsLibrary(tNode.getTaxonomyLevel());
                    String prefixBusinessPath = "[DocumentPool:" + taxonomy.getKey() + "][TaxonomyLevel:" + tNode.getTaxonomyLevel().getKey() + "][path=";
                    createSubscriptionInfo(container, prefixBusinessPath, compareDate, si, p, translator);
                } else if (tNode.getType() == TaxonomyTreeNodeType.templates) {
                    VFSContainer container = taxonomyService.getDocumentsLibrary(taxonomy);
                    String prefixBusinessPath = "[DocumentPool:" + taxonomy.getKey() + "][Templates:0s][path=";
                    createSubscriptionInfo(container, prefixBusinessPath, compareDate, si, p, translator);
                }
            }, model.getRootNode(), false).visitAll();
        } else {
            si = NotificationsManager.getInstance().getNoSubscriptionInfo();
        }
        return si;
    } catch (Exception e) {
        log.error("Cannot create document pool notifications for subscriber: " + subscriber.getKey(), e);
        return notificationsManager.getNoSubscriptionInfo();
    }
}
Also used : TitleItem(org.olat.core.commons.services.notifications.model.TitleItem) Util(org.olat.core.util.Util) TreeVisitor(org.olat.core.util.tree.TreeVisitor) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) NotificationHelper(org.olat.core.commons.services.notifications.NotificationHelper) OlatRelPathImpl(org.olat.core.util.vfs.OlatRelPathImpl) Date(java.util.Date) FileInfo(org.olat.core.commons.modules.bc.FileInfo) DocumentPoolModule(org.olat.modules.docpool.DocumentPoolModule) Autowired(org.springframework.beans.factory.annotation.Autowired) TaxonomyTreeNodeType(org.olat.modules.taxonomy.model.TaxonomyTreeNodeType) NotificationsHandler(org.olat.core.commons.services.notifications.NotificationsHandler) Locale(java.util.Locale) TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) Service(org.springframework.stereotype.Service) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) FileUtils(org.olat.core.util.FileUtils) FolderManager(org.olat.core.commons.modules.bc.FolderManager) StringHelper(org.olat.core.util.StringHelper) OLog(org.olat.core.logging.OLog) Taxonomy(org.olat.modules.taxonomy.Taxonomy) Translator(org.olat.core.gui.translator.Translator) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) TaxonomyTreeBuilder(org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder) TreeModel(org.olat.core.gui.components.tree.TreeModel) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Publisher(org.olat.core.commons.services.notifications.Publisher) VFSContainer(org.olat.core.util.vfs.VFSContainer) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) DocumentPoolMainController(org.olat.modules.docpool.ui.DocumentPoolMainController) List(java.util.List) Subscriber(org.olat.core.commons.services.notifications.Subscriber) Identity(org.olat.core.id.Identity) PublisherData(org.olat.core.commons.services.notifications.PublisherData) NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) BaseSecurity(org.olat.basesecurity.BaseSecurity) Tracing(org.olat.core.logging.Tracing) Roles(org.olat.core.id.Roles) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) Taxonomy(org.olat.modules.taxonomy.Taxonomy) VFSContainer(org.olat.core.util.vfs.VFSContainer) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Roles(org.olat.core.id.Roles) Publisher(org.olat.core.commons.services.notifications.Publisher) Date(java.util.Date) TreeVisitor(org.olat.core.util.tree.TreeVisitor) TreeModel(org.olat.core.gui.components.tree.TreeModel) Translator(org.olat.core.gui.translator.Translator) Identity(org.olat.core.id.Identity) TaxonomyTreeBuilder(org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)

Aggregations

Taxonomy (org.olat.modules.taxonomy.Taxonomy)194 Test (org.junit.Test)132 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)122 Identity (org.olat.core.id.Identity)56 URI (java.net.URI)36 HttpResponse (org.apache.http.HttpResponse)36 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)36 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)22 HttpGet (org.apache.http.client.methods.HttpGet)16 ArrayList (java.util.ArrayList)14 TaxonomyService (org.olat.modules.taxonomy.TaxonomyService)14 TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)14 HttpPut (org.apache.http.client.methods.HttpPut)12 HashMap (java.util.HashMap)10 List (java.util.List)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)10 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)10