Search in sources :

Example 6 with BinderPageUsage

use of org.olat.modules.portfolio.model.BinderPageUsage in project OpenOLAT by OpenOLAT.

the class MediaDAO method usedInBinders.

public List<BinderPageUsage> usedInBinders(MediaLight media) {
    StringBuilder sb = new StringBuilder();
    sb.append("select binder.key, binder.title, page.key, page.title, page.status").append(" from pfpage as page").append(" inner join page.body as pageBody").append(" inner join pageBody.parts as bodyPart").append(" left join page.section as section").append(" left join section.binder as binder").append(" where bodyPart.media.key=:mediaKey");
    List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("mediaKey", media.getKey()).getResultList();
    List<BinderPageUsage> usage = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        Long binderKey = (Long) object[0];
        String binderTitle = (String) object[1];
        Long pageKey = (Long) object[2];
        String pageTitle = (String) object[3];
        String pageStatus = (String) object[4];
        usage.add(new BinderPageUsage(binderKey, binderTitle, pageKey, pageTitle, pageStatus));
    }
    return usage;
}
Also used : BinderPageUsage(org.olat.modules.portfolio.model.BinderPageUsage) ArrayList(java.util.ArrayList) PersistenceHelper.makeFuzzyQueryString(org.olat.core.commons.persistence.PersistenceHelper.makeFuzzyQueryString)

Example 7 with BinderPageUsage

use of org.olat.modules.portfolio.model.BinderPageUsage in project openolat by klemens.

the class MediaDAO method usedInBinders.

public List<BinderPageUsage> usedInBinders(MediaLight media) {
    StringBuilder sb = new StringBuilder();
    sb.append("select binder.key, binder.title, page.key, page.title, page.status").append(" from pfpage as page").append(" inner join page.body as pageBody").append(" inner join pageBody.parts as bodyPart").append(" left join page.section as section").append(" left join section.binder as binder").append(" where bodyPart.media.key=:mediaKey");
    List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("mediaKey", media.getKey()).getResultList();
    List<BinderPageUsage> usage = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        Long binderKey = (Long) object[0];
        String binderTitle = (String) object[1];
        Long pageKey = (Long) object[2];
        String pageTitle = (String) object[3];
        String pageStatus = (String) object[4];
        usage.add(new BinderPageUsage(binderKey, binderTitle, pageKey, pageTitle, pageStatus));
    }
    return usage;
}
Also used : BinderPageUsage(org.olat.modules.portfolio.model.BinderPageUsage) ArrayList(java.util.ArrayList) PersistenceHelper.makeFuzzyQueryString(org.olat.core.commons.persistence.PersistenceHelper.makeFuzzyQueryString)

Example 8 with BinderPageUsage

use of org.olat.modules.portfolio.model.BinderPageUsage in project openolat by klemens.

the class MediaDetailsController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        Object uobject = link.getUserObject();
        if ("binder".equals(cmd)) {
            if (uobject instanceof BinderPageUsage) {
                String businessPath = "[Binder:" + ((BinderPageUsage) uobject).getBinderKey() + "]";
                NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
            }
        } else if ("page".equals(cmd)) {
            if (uobject instanceof BinderPageUsage) {
                // http://localhost:8081/auth/HomeSite/720898/PortfolioV2/0/MyPages/0/Entry/89
                String businessPath = "[HomeSite:" + getIdentity().getKey() + "][PortfolioV2:0][MyPages:0][Entry:" + ((BinderPageUsage) uobject).getPageKey() + "]";
                NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : BinderPageUsage(org.olat.modules.portfolio.model.BinderPageUsage) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

BinderPageUsage (org.olat.modules.portfolio.model.BinderPageUsage)8 ArrayList (java.util.ArrayList)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 Media (org.olat.modules.portfolio.Media)4 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Test (org.junit.Test)2 NewControllerFactory (org.olat.NewControllerFactory)2 PersistenceHelper.makeFuzzyQueryString (org.olat.core.commons.persistence.PersistenceHelper.makeFuzzyQueryString)2 UserRequest (org.olat.core.gui.UserRequest)2 Component (org.olat.core.gui.components.Component)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 FormItemContainer (org.olat.core.gui.components.form.flexible.FormItemContainer)2 TextBoxListElement (org.olat.core.gui.components.form.flexible.elements.TextBoxListElement)2 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)2 FormEvent (org.olat.core.gui.components.form.flexible.impl.FormEvent)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2