use of org.olat.core.id.context.StateEntry in project OpenOLAT by OpenOLAT.
the class HomePageContextEntryControllerCreator method extractIdentity.
/**
* Helper to get the identity that is encoded into the context entry
*
* @param ce
* @return the identity or NULL if not found
*/
private Identity extractIdentity(ContextEntry ce) {
OLATResourceable resource = ce.getOLATResourceable();
Long key = resource.getResourceableId();
if (key == null || key.equals(0)) {
log.error("Can not load identity with key::" + key);
return null;
}
StateEntry state = ce.getTransientState();
if (state instanceof HomePageStateEntry) {
HomePageStateEntry homeState = (HomePageStateEntry) state;
if (homeState.same(key)) {
return homeState.getIdentity();
}
}
Identity identity = BaseSecurityManager.getInstance().loadIdentityByKey(key);
if (identity == null) {
log.error("Can not load identity with key::" + key);
}
ce.setTransientState(new HomePageStateEntry(identity));
return identity;
}
use of org.olat.core.id.context.StateEntry in project OpenOLAT by OpenOLAT.
the class BaseFullWebappController method back.
protected void back(UserRequest ureq, HistoryPoint cstate) {
List<ContextEntry> entries = cstate.getEntries();
if (entries.isEmpty())
return;
entries = new ArrayList<ContextEntry>(entries);
ContextEntry state = entries.remove(0);
// no red screen for this
if (state == null)
return;
OLATResourceable ores = state.getOLATResourceable();
if (ores != null && "HomeSite".equals(ores.getResourceableTypeName())) {
activateSite(userTools, ureq, entries, false);
} else {
DTab dt = getDTab(ores);
if (dt != null) {
doActivateDTab(dt);
if (dt.getController() instanceof Activateable2) {
((Activateable2) dt.getController()).activate(ureq, entries, null);
}
updateBusinessPath(ureq, dt);
} else {
StateEntry s = state.getTransientState();
if (s instanceof StateSite && ((StateSite) s).getSite() != null && sites != null) {
SiteInstance site = ((StateSite) s).getSite();
for (SiteInstance savedSite : sites) {
if (savedSite != null && site.getClass().equals(savedSite.getClass())) {
activateSite(savedSite, ureq, entries, false);
}
}
}
}
}
}
use of org.olat.core.id.context.StateEntry in project OpenOLAT by OpenOLAT.
the class AssessmentIdentityListCourseTreeController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
boolean emptyEntries = entries == null || entries.isEmpty();
if (emptyEntries) {
TreeNode rootNode = menuTree.getTreeModel().getRootNode();
if (rootNode.getUserObject() instanceof CourseNode) {
doSelectCourseNode(ureq, (CourseNode) rootNode.getUserObject());
}
} else {
String resourceTypeName = entries.get(0).getOLATResourceable().getResourceableTypeName();
if ("Node".equalsIgnoreCase(resourceTypeName)) {
Long nodeIdent = entries.get(0).getOLATResourceable().getResourceableId();
CourseNode courseNode = CourseFactory.loadCourse(courseEntry).getRunStructure().getNode(nodeIdent.toString());
TreeNode courseTreeNode = TreeHelper.findNodeByUserObject(courseNode, menuTree.getTreeModel().getRootNode());
if (courseNode != null && courseTreeNode != null) {
doSelectCourseNode(ureq, courseNode);
menuTree.setSelectedNode(courseTreeNode);
}
}
}
if (currentCtrl instanceof Activateable2) {
List<ContextEntry> subEntries = emptyEntries ? entries : entries.subList(1, entries.size());
StateEntry subState = emptyEntries ? state : entries.get(0).getTransientState();
((Activateable2) currentCtrl).activate(ureq, subEntries, subState);
}
}
use of org.olat.core.id.context.StateEntry in project openolat by klemens.
the class CatalogNodeManagerController 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 catEntry = ((CatalogStateEntry) stateEntry).getEntry();
CatalogNodeManagerController nextCtrl = selectCatalogEntry(ureq, catEntry);
if (nextCtrl != null && entries.size() > 1) {
nextCtrl.activate(ureq, entries.subList(1, entries.size()), null);
}
}
}
}
use of org.olat.core.id.context.StateEntry in project openolat by klemens.
the class HomePageContextEntryControllerCreator method extractIdentity.
/**
* Helper to get the identity that is encoded into the context entry
*
* @param ce
* @return the identity or NULL if not found
*/
private Identity extractIdentity(ContextEntry ce) {
OLATResourceable resource = ce.getOLATResourceable();
Long key = resource.getResourceableId();
if (key == null || key.equals(0)) {
log.error("Can not load identity with key::" + key);
return null;
}
StateEntry state = ce.getTransientState();
if (state instanceof HomePageStateEntry) {
HomePageStateEntry homeState = (HomePageStateEntry) state;
if (homeState.same(key)) {
return homeState.getIdentity();
}
}
Identity identity = BaseSecurityManager.getInstance().loadIdentityByKey(key);
if (identity == null) {
log.error("Can not load identity with key::" + key);
}
ce.setTransientState(new HomePageStateEntry(identity));
return identity;
}
Aggregations