Search in sources :

Example 16 with NarrowedPropertyManager

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

the class CollaborationTools method getForum.

public Forum getForum() {
    final ForumManager fom = ForumManager.getInstance();
    final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property forumProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
    Forum forum;
    if (forumProperty != null) {
        forum = fom.loadForum(forumProperty.getLongValue());
    } else {
        forum = coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Forum>() {

            @Override
            public Forum execute() {
                Forum aforum;
                Long forumKey;
                Property forumKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
                if (forumKeyProperty == null) {
                    // First call of forum, create new forum and save
                    aforum = fom.addAForum();
                    forumKey = aforum.getKey();
                    if (log.isDebug()) {
                        log.debug("created new forum in collab tools: foid::" + forumKey.longValue() + " for ores::" + ores.getResourceableTypeName() + "/" + ores.getResourceableId());
                    }
                    forumKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM, null, forumKey, null, null);
                    npm.saveProperty(forumKeyProperty);
                } else {
                    // Forum does already exist, load forum with key from properties
                    forumKey = forumKeyProperty.getLongValue();
                    aforum = fom.loadForum(forumKey);
                    if (aforum == null) {
                        throw new AssertException("Unable to load forum with key " + forumKey.longValue() + " for ores " + ores.getResourceableTypeName() + " with key " + ores.getResourceableId());
                    }
                    if (log.isDebug()) {
                        log.debug("loading forum in collab tools from properties: foid::" + forumKey.longValue() + " for ores::" + ores.getResourceableTypeName() + "/" + ores.getResourceableId());
                    }
                }
                return aforum;
            }
        });
    }
    return forum;
}
Also used : AssertException(org.olat.core.logging.AssertException) ForumManager(org.olat.modules.fo.manager.ForumManager) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) SyncerCallback(org.olat.core.util.coordinate.SyncerCallback) Property(org.olat.properties.Property) Forum(org.olat.modules.fo.Forum)

Example 17 with NarrowedPropertyManager

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

the class CollaborationTools method saveFolderAccess.

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

Example 18 with NarrowedPropertyManager

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

the class CollaborationTools method getNewsAccessProperty.

/**
 * @return Gets the news access property
 */
public String getNewsAccessProperty() {
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property property = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_NEWS_ACCESS);
    if (property == null) {
        // no entry
        return null;
    }
    // read the text value of the existing property
    String text = property.getStringValue();
    return text;
}
Also used : NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Example 19 with NarrowedPropertyManager

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

the class CollaborationTools method saveNewsAccessProperty.

/**
 * @param Save news access property.
 */
public void saveNewsAccessProperty(String access) {
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property property = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_NEWS_ACCESS);
    if (property == null) {
        // create a new one
        Property nP = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_NEWS_ACCESS, null, null, access, null);
        npm.saveProperty(nP);
    } else {
        // modify the existing one
        property.setStringValue(access);
        npm.updateProperty(property);
    }
}
Also used : NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Example 20 with NarrowedPropertyManager

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

the class CollaborationTools method saveNews.

/**
 * @param news
 */
public void saveNews(String news) {
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property property = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_NEWS);
    if (property == null) {
        // create a new one
        Property nP = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_NEWS, null, null, null, news);
        npm.saveProperty(nP);
    } else {
        // modify the existing one
        property.setTextValue(news);
        npm.updateProperty(property);
    }
}
Also used : NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Aggregations

NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)32 Property (org.olat.properties.Property)32 AssertException (org.olat.core.logging.AssertException)8 ForumManager (org.olat.modules.fo.manager.ForumManager)8 Forum (org.olat.modules.fo.Forum)6 BusinessGroup (org.olat.group.BusinessGroup)4 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)4 SearchResourceContext (org.olat.search.service.SearchResourceContext)4 File (java.io.File)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Document (org.apache.lucene.document.Document)2 Before (org.junit.Before)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 CalendarManager (org.olat.commons.calendar.CalendarManager)2 ImportToCalendarManager (org.olat.commons.calendar.manager.ImportToCalendarManager)2 CalendarController (org.olat.commons.calendar.ui.CalendarController)2 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)2