Search in sources :

Example 1 with NarrowedPropertyManager

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

the class GroupPortfolioIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
    if (!portfolioModule.isEnabled())
        return;
    if (!(businessObj instanceof BusinessGroup))
        throw new AssertException("businessObj must be BusinessGroup");
    BusinessGroup businessGroup = (BusinessGroup) businessObj;
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(businessGroup);
    Property mapKeyProperty = npm.findProperty(null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_PORTFOLIO);
    // Check if portfolio map property exist
    if (mapKeyProperty != null) {
        Long mapKey = mapKeyProperty.getLongValue();
        String version = mapKeyProperty.getStringValue();
        if (version == null || !version.equals("2")) {
            PortfolioStructure map = frontendManager.loadPortfolioStructureByKey(mapKey);
            if (map != null) {
                SearchResourceContext resourceContext = new SearchResourceContext(parentResourceContext);
                resourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLPORTFOLIO);
                resourceContext.setDocumentType(TYPE);
                resourceContext.setParentContextType(GroupDocument.TYPE);
                resourceContext.setParentContextName(businessGroup.getName());
                Document document = PortfolioMapDocument.createDocument(resourceContext, map);
                indexerWriter.addDocument(document);
            }
        }
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) SearchResourceContext(org.olat.search.service.SearchResourceContext) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) PortfolioMapDocument(org.olat.search.service.document.PortfolioMapDocument) Document(org.apache.lucene.document.Document) GroupDocument(org.olat.search.service.document.GroupDocument) Property(org.olat.properties.Property)

Example 2 with NarrowedPropertyManager

use of org.olat.properties.NarrowedPropertyManager in project openolat by klemens.

the class CollaborationTools method lookupFolderAccess.

public Long lookupFolderAccess() {
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property property = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FOLDER_ACCESS);
    if (property == null) {
        // no entry
        return null;
    }
    // read the long value of the existing property
    return property.getLongValue();
}
Also used : NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Example 3 with NarrowedPropertyManager

use of org.olat.properties.NarrowedPropertyManager in project openolat by klemens.

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 4 with NarrowedPropertyManager

use of org.olat.properties.NarrowedPropertyManager in project openolat by klemens.

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)

Example 5 with NarrowedPropertyManager

use of org.olat.properties.NarrowedPropertyManager 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)

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