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();
}
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;
}
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;
}
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);
}
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();
}
}
Aggregations