Search in sources :

Example 71 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class CollaborationManagerImpl method lookupCalendarAccess.

@Override
public Map<Long, Long> lookupCalendarAccess(List<BusinessGroup> groups) {
    if (groups == null || groups.isEmpty()) {
        return new HashMap<Long, Long>();
    }
    StringBuilder query = new StringBuilder();
    query.append("select prop from ").append(Property.class.getName()).append(" as prop where ").append(" prop.category='").append(PROP_CAT_BG_COLLABTOOLS).append("'").append(" and prop.resourceTypeName='BusinessGroup'").append(" and prop.resourceTypeId in (:groupKeys)").append(" and prop.name='").append(KEY_CALENDAR_ACCESS).append("'").append(" and prop.identity is null and prop.grp is null");
    TypedQuery<Property> dbquery = dbInstance.getCurrentEntityManager().createQuery(query.toString(), Property.class);
    Map<Long, Long> groupKeyToAccess = new HashMap<Long, Long>();
    int count = 0;
    int batch = 200;
    do {
        int toIndex = Math.min(count + batch, groups.size());
        List<BusinessGroup> toLoad = groups.subList(count, toIndex);
        List<Long> groupKeys = PersistenceHelper.toKeys(toLoad);
        List<Property> props = dbquery.setFirstResult(count).setMaxResults(batch).setParameter("groupKeys", groupKeys).getResultList();
        for (Property prop : props) {
            groupKeyToAccess.put(prop.getResourceTypeId(), prop.getLongValue());
        }
        count += batch;
    } while (count < groups.size());
    return groupKeyToAccess;
}
Also used : HashMap(java.util.HashMap) BusinessGroup(org.olat.group.BusinessGroup) Property(org.olat.properties.Property)

Example 72 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class CollaborationTools method saveCalendarAccess.

public void saveCalendarAccess(Long calendarAccess) {
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property property = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_CALENDAR_ACCESS);
    if (property == null) {
        // create a new one
        Property nP = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_CALENDAR_ACCESS, null, calendarAccess, null, null);
        npm.saveProperty(nP);
    } else {
        // modify the existing one
        property.setLongValue(calendarAccess);
        npm.updateProperty(property);
    }
}
Also used : NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Example 73 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class CollaborationTools method lookupNews.

/**
 * @return the news; if there is no news yet: return null;
 */
public String lookupNews() {
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property property = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_NEWS);
    if (property == null) {
        // no entry
        return null;
    }
    // read the text value of the existing property
    String text = property.getTextValue();
    return text;
}
Also used : NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Example 74 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class CollaborationTools method archiveForum.

private void archiveForum(String archivFilePath) {
    Property forumKeyProperty = NarrowedPropertyManager.getInstance(ores).findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
    if (forumKeyProperty != null) {
        VFSContainer archiveContainer = new LocalFolderImpl(new File(archivFilePath));
        String archiveForumName = "del_forum_" + forumKeyProperty.getLongValue();
        VFSContainer archiveForumContainer = archiveContainer.createChildContainer(archiveForumName);
        ForumFormatter ff = new ForumRTFFormatter(archiveForumContainer, false, I18nModule.getDefaultLocale());
        ForumArchiveManager.getInstance().applyFormatter(ff, forumKeyProperty.getLongValue(), null);
    }
}
Also used : ForumFormatter(org.olat.modules.fo.archiver.formatters.ForumFormatter) ForumRTFFormatter(org.olat.modules.fo.archiver.formatters.ForumRTFFormatter) VFSContainer(org.olat.core.util.vfs.VFSContainer) Property(org.olat.properties.Property) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 75 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class CollaborationTools method createPortfolioController.

/**
 * return an controller for the wiki tool
 * @param ureq
 * @param wControl
 * @return
 */
public Controller createPortfolioController(final UserRequest ureq, final WindowControl wControl, final TooledStackedPanel stackPanel, final BusinessGroup group) {
    final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property mapProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO);
    if (mapProperty != null) {
        return createPortfolioController(ureq, wControl, stackPanel, mapProperty);
    } else {
        return coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Controller>() {

            @Override
            public Controller execute() {
                Controller ctrl;
                Property mapKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO);
                if (mapKeyProperty == null) {
                    PortfolioV2Module moduleV2 = CoreSpringFactory.getImpl(PortfolioV2Module.class);
                    if (moduleV2.isEnabled()) {
                        PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
                        Binder binder = portfolioService.createNewBinder(group.getName(), group.getDescription(), null, null);
                        CoreSpringFactory.getImpl(BinderUserInformationsDAO.class).updateBinderUserInformationsInSync(binder, ureq.getIdentity());
                        mapKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO, null, binder.getKey(), "2", null);
                        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForBusinessGroup();
                        BinderController binderCtrl = new BinderController(ureq, wControl, stackPanel, secCallback, binder, BinderConfiguration.createBusinessGroupConfig());
                        List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType("Toc");
                        binderCtrl.activate(ureq, entries, null);
                        ctrl = binderCtrl;
                        ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(binder));
                        ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_BINDER_CREATED, getClass());
                    } else {
                        EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
                        PortfolioStructureMap map = ePFMgr.createAndPersistPortfolioDefaultMap(group.getName(), group.getDescription());
                        Translator pT = Util.createPackageTranslator(EPCreateMapController.class, ureq.getLocale());
                        // add a page, as each map should have at least one per default!
                        ePFMgr.createAndPersistPortfolioPage(map, pT.translate("new.page.title"), pT.translate("new.page.desc"));
                        mapKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO, null, map.getKey(), null, null);
                        EPSecurityCallback secCallback = new EPSecurityCallbackImpl(true, true);
                        ctrl = EPUIFactory.createMapViewController(ureq, wControl, map, secCallback);
                    }
                    npm.saveProperty(mapKeyProperty);
                } else {
                    ctrl = createPortfolioController(ureq, wControl, stackPanel, mapProperty);
                }
                return ctrl;
            }
        });
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioV2Module(org.olat.modules.portfolio.PortfolioV2Module) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) EPCreateMapController(org.olat.portfolio.ui.structel.EPCreateMapController) OpenMeetingsRunController(org.olat.modules.openmeetings.ui.OpenMeetingsRunController) ChatToolController(org.olat.instantMessaging.ui.ChatToolController) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) BinderController(org.olat.modules.portfolio.ui.BinderController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) ContactFormController(org.olat.modules.co.ContactFormController) Controller(org.olat.core.gui.control.Controller) CalendarController(org.olat.commons.calendar.ui.CalendarController) InfoGroupRunController(org.olat.group.ui.run.InfoGroupRunController) EPSecurityCallbackImpl(org.olat.portfolio.EPSecurityCallbackImpl) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager) Binder(org.olat.modules.portfolio.Binder) PortfolioService(org.olat.modules.portfolio.PortfolioService) BinderController(org.olat.modules.portfolio.ui.BinderController) Translator(org.olat.core.gui.translator.Translator) EPCreateMapController(org.olat.portfolio.ui.structel.EPCreateMapController) EPSecurityCallback(org.olat.portfolio.EPSecurityCallback) ArrayList(java.util.ArrayList) List(java.util.List) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Aggregations

Property (org.olat.properties.Property)270 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)62 PropertyManager (org.olat.properties.PropertyManager)48 Identity (org.olat.core.id.Identity)36 NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)36 ArrayList (java.util.ArrayList)24 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)22 BusinessGroup (org.olat.group.BusinessGroup)18 File (java.io.File)16 ICourse (org.olat.course.ICourse)16 Translator (org.olat.core.gui.translator.Translator)14 AssertException (org.olat.core.logging.AssertException)14 CourseNode (org.olat.course.nodes.CourseNode)14 Forum (org.olat.modules.fo.Forum)14 ForumManager (org.olat.modules.fo.manager.ForumManager)14 Test (org.junit.Test)12 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)12 XStream (com.thoughtworks.xstream.XStream)10 HashMap (java.util.HashMap)10 List (java.util.List)10