use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogManagerController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
ContextEntry entry = entries.get(0);
String type = entry.getOLATResourceable().getResourceableTypeName();
if ("CatalogEntry".equalsIgnoreCase(type)) {
Long entryKey = entry.getOLATResourceable().getResourceableId();
if (entryKey != null && entryKey.longValue() > 0) {
List<ContextEntry> parentLine = new ArrayList<>();
for (CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node != null && 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);
toolbarPanel.popUpToRootController(ureq);
catalogCtrl.activate(ureq, parentLine, null);
}
}
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogNodeController method event.
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (source instanceof Link) {
Link link = (Link) source;
if ("select_node".equals(link.getCommand())) {
Long categoryNodeKey = (Long) link.getUserObject();
CatalogEntry entry = catalogManager.getCatalogNodeByKey(categoryNodeKey);
selectCatalogEntry(ureq, entry);
}
} else if ("img_select".equals(event.getCommand())) {
String node = ureq.getParameter("node");
if (StringHelper.isLong(node)) {
try {
Long categoryNodeKey = new Long(node);
CatalogEntry entry = catalogManager.getCatalogNodeByKey(categoryNodeKey);
selectCatalogEntry(ureq, entry);
} catch (NumberFormatException e) {
logWarn("Not a valid long: " + node, e);
}
}
}
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogNodeController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty()) {
return;
}
ContextEntry entry = entries.get(0);
String type = entry.getOLATResourceable().getResourceableTypeName();
if ("CatalogEntry".equalsIgnoreCase(type)) {
Long entryKey = entry.getOLATResourceable().getResourceableId();
if (entryKey != null && entryKey.longValue() > 0) {
activateRoot(ureq, entryKey);
}
} else if ("Node".equalsIgnoreCase(type)) {
// the "Node" is only for internal usage
StateEntry stateEntry = entry.getTransientState();
if (stateEntry instanceof CatalogStateEntry) {
CatalogEntry catalogEntry = ((CatalogStateEntry) stateEntry).getEntry();
CatalogNodeController nextCtrl = selectCatalogEntry(ureq, catalogEntry);
if (nextCtrl != null && entries.size() > 1) {
nextCtrl.activate(ureq, entries.subList(1, entries.size()), null);
}
}
}
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogNodeManagerController method doAddResource.
private void doAddResource(UserRequest ureq, RepositoryEntry selectedEntry) {
CatalogEntry newLinkNotPersistedYet = catalogManager.createCatalogEntry();
newLinkNotPersistedYet.setName(selectedEntry.getDisplayname());
newLinkNotPersistedYet.setDescription(selectedEntry.getDescription());
newLinkNotPersistedYet.setRepositoryEntry(selectedEntry);
newLinkNotPersistedYet.setType(CatalogEntry.TYPE_LEAF);
newLinkNotPersistedYet.setOwnerGroup(securityManager.createAndPersistSecurityGroup());
catalogManager.addCatalogEntry(catalogEntry, newLinkNotPersistedYet);
loadResources(ureq);
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogNodeManagerController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (addEntryCtrl == source) {
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
loadNodesChildren();
}
cmc.deactivate();
cleanUp();
fireEvent(ureq, Event.CHANGED_EVENT);
} else if (editEntryCtrl == source) {
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
catalogEntry = editEntryCtrl.getEditedCatalogEntry();
loadEntryInfos();
}
cmc.deactivate();
cleanUp();
fireEvent(ureq, Event.CHANGED_EVENT);
} else if (categoryMoveCtrl == source) {
cmc.deactivate();
CatalogEntry moveMe = null;
if (event.equals(Event.DONE_EVENT)) {
showInfo("tools.move.catalog.entry.success", catalogEntry.getName());
moveMe = categoryMoveCtrl.getMoveMe();
} else if (event.equals(Event.FAILED_EVENT)) {
showError("tools.move.catalog.entry.failed");
loadNodesChildren();
}
cleanUp();
// in any case, remove the lock
if (catModificationLock != null && catModificationLock.isSuccess()) {
CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(catModificationLock);
catModificationLock = null;
}
// only after jump to the moved entry
if (moveMe != null) {
launchCatalogEntry(ureq, moveMe);
}
} else if (dialogDeleteSubtree == source) {
// from remove subtree dialog -> yes or no
if (DialogBoxUIFactory.isYesEvent(event)) {
catalogManager.deleteCatalogEntry(catalogEntry);
fireEvent(ureq, Event.BACK_EVENT);
}
// in any case, remove the lock
if (catModificationLock != null && catModificationLock.isSuccess()) {
CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(catModificationLock);
catModificationLock = null;
}
} else if (childNodeCtrl == source) {
if (event == Event.BACK_EVENT) {
toolbarPanel.popUpToController(this);
removeAsListenerAndDispose(childNodeCtrl);
childNodeCtrl = null;
loadNodesChildren();
}
} else if (entrySearchCtrl == source) {
if (event.getCommand().equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
// successfully selected a repository entry which will be a link within
// the current Category
RepositoryEntry selectedEntry = entrySearchCtrl.getSelectedEntry();
doAddResource(ureq, selectedEntry);
fireEvent(ureq, Event.CHANGED_EVENT);
}
cmc.deactivate();
cleanUp();
} else if (groupCtrl == source) {
if (event instanceof IdentitiesAddEvent || event instanceof IdentitiesRemoveEvent) {
doAddRemoveOwners(event);
}
} else if (contactCtrl == source) {
cmc.deactivate();
cleanUp();
} else if (dialogDeleteLink == source) {
if (DialogBoxUIFactory.isYesEvent(event)) {
CatalogEntryRow row = (CatalogEntryRow) dialogDeleteLink.getUserObject();
catalogManager.deleteCatalogEntry(row, catalogEntry);
loadResources(ureq);
}
} else if (entryResourceMoveCtrl == source) {
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
CatalogEntry moveMe = entryResourceMoveCtrl.getMoveMe();
showInfo("tools.move.catalog.entry.success", moveMe.getName());
loadResources(ureq);
}
cmc.deactivate();
cleanUp();
} else if (cmc == source) {
cleanUp();
}
super.event(ureq, source, event);
}
Aggregations