use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogNodeManagerController method loadNodesChildren.
protected void loadNodesChildren() {
List<CatalogEntry> childCe = catalogManager.getNodesChildrenOf(catalogEntry);
Collections.sort(childCe, new CatalogEntryComparator(getLocale()));
List<String> subCategories = new ArrayList<>();
int count = 0;
for (CatalogEntry entry : childCe) {
if (entry.getType() == CatalogEntry.TYPE_NODE) {
String cmpId = "cat_" + (++count);
VFSLeaf img = catalogManager.getImage(entry);
if (img != null) {
String imgId = "image_" + count;
flc.contextPut(imgId, img.getName());
}
flc.contextPut("k" + cmpId, entry.getKey());
String title = StringHelper.escapeHtml(entry.getName());
Link link = LinkFactory.createCustomLink(cmpId, "select_node", cmpId, Link.LINK + Link.NONTRANSLATED, flc.getFormItemComponent(), this);
link.setIconLeftCSS("o_icon o_icon_catalog_sub");
link.setCustomDisplayText(title);
link.setUserObject(entry.getKey());
subCategories.add(Integer.toString(count));
String titleId = "title_" + count;
flc.contextPut(titleId, title);
}
}
flc.contextPut("subCategories", subCategories);
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogNodeManagerController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// one mapper for all users
flc.contextPut("mapperThumbnailUrl", mapperThumbnailKey.getUrl());
int level = 0;
CatalogEntry parent = catalogEntry.getParent();
while (parent != null) {
level++;
parent = parent.getParent();
}
flc.contextPut("catalogLevel", level);
String url = Settings.getServerContextPathURI() + "/url/CatalogEntry/" + catalogEntry.getKey();
if (loginModule.isGuestLoginLinksEnabled()) {
flc.contextPut("guestExtLink", url + "?guest=true&lang=" + getLocale().getLanguage());
}
if (!isGuest) {
flc.contextPut("extLink", url);
}
FlexiTableColumnModel entriesColumnsModel = getCatalogFlexiTableColumnModel("opened-");
entriesModel = new CatalogEntryRowModel(entriesColumnsModel);
entriesEl = uifactory.addTableElement(getWindowControl(), "entries", entriesModel, getTranslator(), formLayout);
FlexiTableColumnModel closedEntriesColumnsModel = getCatalogFlexiTableColumnModel("closed-");
closedEntriesModel = new CatalogEntryRowModel(closedEntriesColumnsModel);
closedEntriesEl = uifactory.addTableElement(getWindowControl(), "closedEntries", closedEntriesModel, getTranslator(), formLayout);
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogNodeManagerController method activateRoot.
/**
* Build an internal business path made of "Node" with the category
* as state entry to prevent loading several times the same entries.
*
* @param ureq
* @param entryKey
*/
private void activateRoot(UserRequest ureq, Long entryKey) {
List<ContextEntry> parentLine = new ArrayList<>();
for (CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node.getParent() != null; node = node.getParent()) {
OLATResourceable nodeRes = OresHelper.createOLATResourceableInstance("Node", node.getKey());
ContextEntry ctxEntry = BusinessControlFactory.getInstance().createContextEntry(nodeRes);
ctxEntry.setTransientState(new CatalogStateEntry(node));
parentLine.add(ctxEntry);
}
Collections.reverse(parentLine);
activate(ureq, parentLine, null);
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogNodeManagerController method doMoveCategory.
private void doMoveCategory(UserRequest ureq, CatalogEntryRow row) {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(entryResourceMoveCtrl);
CatalogEntry moveMe = catalogManager.getCatalogEntryBy(row, catalogEntry);
if (moveMe != null) {
entryResourceMoveCtrl = new CatalogEntryMoveController(getWindowControl(), ureq, moveMe, getTranslator());
listenTo(entryResourceMoveCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", entryResourceMoveCtrl.getInitialComponent(), true, translate("tools.move.catalog.entry"));
listenTo(cmc);
cmc.activate();
}
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogEntryAddController method insertNode.
protected void insertNode(UserRequest ureq, Long newParentId) {
CatalogEntry newParent = catalogManager.loadCatalogEntry(newParentId);
// check first if this repo entry is already attached to this new parent
List<CatalogEntry> existingChildren = catalogManager.getChildrenOf(newParent);
for (CatalogEntry existingChild : existingChildren) {
RepositoryEntry existingRepoEntry = existingChild.getRepositoryEntry();
if (existingRepoEntry != null && existingRepoEntry.equalsByPersistableKey(toBeAddedEntry)) {
showError("catalog.tree.add.already.exists", toBeAddedEntry.getDisplayname());
return;
}
}
CatalogEntry newEntry = catalogManager.createCatalogEntry();
newEntry.setRepositoryEntry(toBeAddedEntry);
newEntry.setName(toBeAddedEntry.getDisplayname());
newEntry.setDescription(toBeAddedEntry.getDescription());
newEntry.setType(CatalogEntry.TYPE_LEAF);
newEntry.setOwnerGroup(BaseSecurityManager.getInstance().createAndPersistSecurityGroup());
// save entry
catalogManager.addCatalogEntry(newParent, newEntry);
fireEvent(ureq, Event.DONE_EVENT);
}
Aggregations