Search in sources :

Example 6 with StateEntry

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;
}
Also used : StateEntry(org.olat.core.id.context.StateEntry) OLATResourceable(org.olat.core.id.OLATResourceable) Identity(org.olat.core.id.Identity)

Example 7 with StateEntry

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);
                    }
                }
            }
        }
    }
}
Also used : DTab(org.olat.core.gui.control.generic.dtabs.DTab) StateEntry(org.olat.core.id.context.StateEntry) BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) SiteInstance(org.olat.core.gui.control.navigation.SiteInstance) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) OLATResourceable(org.olat.core.id.OLATResourceable) StateSite(org.olat.core.id.context.StateSite) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 8 with StateEntry

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);
    }
}
Also used : StateEntry(org.olat.core.id.context.StateEntry) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) TreeNode(org.olat.core.gui.components.tree.TreeNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 9 with StateEntry

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);
            }
        }
    }
}
Also used : StateEntry(org.olat.core.id.context.StateEntry) CatalogEntry(org.olat.repository.CatalogEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 10 with StateEntry

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;
}
Also used : StateEntry(org.olat.core.id.context.StateEntry) OLATResourceable(org.olat.core.id.OLATResourceable) Identity(org.olat.core.id.Identity)

Aggregations

StateEntry (org.olat.core.id.context.StateEntry)14 ContextEntry (org.olat.core.id.context.ContextEntry)10 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)6 OLATResourceable (org.olat.core.id.OLATResourceable)4 CatalogEntry (org.olat.repository.CatalogEntry)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 Controller (org.olat.core.gui.control.Controller)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 DTab (org.olat.core.gui.control.generic.dtabs.DTab)2 BornSiteInstance (org.olat.core.gui.control.navigation.BornSiteInstance)2 SiteInstance (org.olat.core.gui.control.navigation.SiteInstance)2 Identity (org.olat.core.id.Identity)2 StateSite (org.olat.core.id.context.StateSite)2 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)2 CourseNode (org.olat.course.nodes.CourseNode)2 GTACourseNode (org.olat.course.nodes.GTACourseNode)2