Package org.olat.modules.fo

Examples of org.olat.modules.fo.ForumManager


   * @param userCourseEnv
   * @return the loaded forum
   */
  private Forum loadOrCreateForum(final UserCourseEnvironment userCourseEnv) {
    updateModuleConfigDefaults(false);       
    final ForumManager fom = ForumManager.getInstance();
    final CoursePropertyManager cpm = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    final CourseNode thisCourseNode = this;
    Forum theForum = null;
   
    Codepoint.codepoint(FOCourseNode.class, "findCourseNodeProperty")
    Property forumKeyProp = cpm.findCourseNodeProperty(thisCourseNode, null, null, FORUM_KEY);
    //System.out.println("System.out.println - findCourseNodeProperty");
    if(forumKeyProp!=null) {
      // Forum does already exist, load forum with key from properties
      Long forumKey = forumKeyProp.getLongValue();
      theForum = fom.loadForum(forumKey);
      if (theForum == null) { throw new OLATRuntimeException(FOCourseNode.class, "Tried to load forum with key " + forumKey.longValue() + " in course "
        + userCourseEnv.getCourseEnvironment().getCourseResourceableId() + " for node " + thisCourseNode.getIdent()
        + " as defined in course node property but forum manager could not load forum.", null); }
    } else {
      //creates resourceable from FOCourseNode.class and the current node id as key
      OLATResourceable courseNodeResourceable = OresHelper.createOLATResourceableInstance(FOCourseNode.class, new Long(this.getIdent()));
      Codepoint.codepoint(FOCourseNode.class, "beforeDoInSync");   
      //System.out.println("System.out.println - beforeDoInSync");
      //o_clusterOK by:ld
      theForum = CoordinatorManager.getCoordinator().getSyncer().doInSync(courseNodeResourceable, new SyncerCallback<Forum>(){
        public Forum execute() {
        Forum forum = null;
        Long forumKey;             
        Codepoint.codepoint(FOCourseNode.class,"doInSync");
        //System.out.println("Codepoint - doInSync");
        Property forumKeyProperty = cpm.findCourseNodeProperty(thisCourseNode, null, null, FORUM_KEY);       
        if (forumKeyProperty == null) {
          // First call of forum, create new forum and save forum key as property         
          forum = fom.addAForum();
          forumKey = forum.getKey();
          forumKeyProperty = cpm.createCourseNodePropertyInstance(thisCourseNode, null, null, FORUM_KEY, null, forumKey, null, null);
          cpm.saveProperty(forumKeyProperty)
          //System.out.println("Forum added");
        } else {
          // Forum does already exist, load forum with key from properties
          forumKey = forumKeyProperty.getLongValue();
          forum = fom.loadForum(forumKey);
          if (forum == null) { throw new OLATRuntimeException(FOCourseNode.class, "Tried to load forum with key " + forumKey.longValue() + " in course "
              + userCourseEnv.getCourseEnvironment().getCourseResourceableId() + " for node " + thisCourseNode.getIdent()
              + " as defined in course node property but forum manager could not load forum.", null); }
          }
        //System.out.println("Forum already exists");
View Full Code Here


   * @return all top message nodes together with their children in a list
   */
  private List convertToThreadTrees(long forumId, ForumCallback forumCallback){
    List messages;
    List topNodeList = new ArrayList();
    ForumManager fm = ForumManager.getInstance();
    Long l = new Long(forumId);
    Forum f = fm.loadForum(l);
    messages = fm.getMessagesByForum(f);
   
    for (Iterator iterTop = messages.iterator(); iterTop.hasNext();) {
      Message msg = (Message) iterTop.next();
      if (msg.getParent() == null) {
        iterTop.remove();
View Full Code Here

   * @return the top message node with all its children
   */
  private MessageNode convertToThreadTree(long topMessageId){
    List messages;
    MessageNode topNode = null;
    ForumManager fm = ForumManager.getInstance();
    Long l = new Long(topMessageId);
    messages = fm.getThread(l);
    for (Iterator iterTop = messages.iterator(); iterTop.hasNext();) {
      Message msg = (Message) iterTop.next();
      if (msg.getParent() == null) {
        iterTop.remove();
        topNode = new MessageNode(msg);
View Full Code Here

    if (!(businessObj instanceof BusinessGroup) )
      throw new AssertException("businessObj must be BusinessGroup");
    BusinessGroup businessGroup = (BusinessGroup)businessObj;
   
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(businessGroup);
    ForumManager fom = ForumManager.getInstance();

    Property forumKeyProperty = npm.findProperty(null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_FORUM);
    // Check if forum-property exist
    if (forumKeyProperty != null) {
      Long forumKey = forumKeyProperty.getLongValue();
      Forum forum = fom.loadForum(forumKey);
      SearchResourceContext forumSearchResourceContext = new SearchResourceContext(parentResourceContext);
      forumSearchResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLFORUM);
      forumSearchResourceContext.setDocumentType(TYPE);
      forumSearchResourceContext.setDocumentContext(businessGroup.getKey() + " " + forumKey);
      forumSearchResourceContext.setParentContextType(GroupDocument.TYPE);
View Full Code Here

   * @param indexWriter
   * @throws IOException
   */
  private void doIndexForum(SearchResourceContext parentResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException,InterruptedException  {
    if (log.isDebug()) log.debug("Index Course Forum...");
    ForumManager fom = ForumManager.getInstance();
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();

    Property forumKeyProperty = cpm.findCourseNodeProperty(courseNode, null, null, FOCourseNode.FORUM_KEY);
    // Check if forum-property exist
    if (forumKeyProperty != null) {
      Long forumKey = forumKeyProperty.getLongValue();
      Forum forum = fom.loadForum(forumKey);
//      SearchResourceContext forumSearchResourceContext = new SearchResourceContext(parentResourceContext);
//      forumSearchResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLFORUM); // TODO:chg: Must be an other Class e.g. CourseRunMainController
      parentResourceContext.setDocumentType(TYPE);
      parentResourceContext.setDocumentContext(course.getResourceableId() + " " + courseNode.getIdent() + " " + forumKey);
      doIndexAllMessages(parentResourceContext, forum, indexWriter );
View Full Code Here

    super(ureq, wControl, Util.createPackageTranslator(Forum.class, ureq.getLocale()));
    this.nodeId = nodeId;
 
    VelocityContainer peekviewVC = createVelocityContainer("peekview");
    // add items, only as many as configured
    ForumManager foMgr = ForumManager.getInstance();
    List<Message> allMessages = foMgr.getMessagesByForum(forum);
    // Sort messages by creation date
    Collections.sort(allMessages, dateSortingComparator);
    // only take the configured amount of messages
    List<Message> messages = new ArrayList<Message>();
    for (int i = 0; i < allMessages.size(); i++) {
View Full Code Here

  public Controller createForumController(UserRequest ureq, WindowControl wControl, boolean isAdmin, boolean isGuestOnly,
      final SubscriptionContext subsContext) {
    Codepoint.codepoint(CollaborationTools.class, "createForumController-init");
    final boolean isAdm = isAdmin;
    final boolean isGuest = isGuestOnly;
    final ForumManager fom = ForumManager.getInstance();
    final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
   
    // TODO: is there a nicer solution without setting an instance variable
    //final List<Forum> forumHolder = new ArrayList<Forum>();
   
    Codepoint.codepoint(CollaborationTools.class, "pre_sync_enter");

    Forum forum = CoordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Forum>(){
      public Forum execute() {
       
        Codepoint.codepoint(CollaborationTools.class, "sync_enter");
       
        //was: synchronized (CollaborationTools.class) {
        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());
View Full Code Here

  public void deleteTools(BusinessGroup businessGroupTodelete) {
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    /*
     * delete the forum, if existing
     */
    ForumManager fom = ForumManager.getInstance();
    Property forumKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
    if (forumKeyProperty != null) {
      // if there was a forum, delete it
      Long forumKey = forumKeyProperty.getLongValue();
      if (forumKey == null) throw new AssertException("property had no longValue, prop:" + forumKeyProperty);
      fom.deleteForum(forumKey);
    }
    /*
     * delete the folder, if existing
     */
    OlatRootFolderImpl vfsContainer = new OlatRootFolderImpl(getFolderRelPath(), null);
View Full Code Here

      archiveFolder(this.ores, archivFilePath);
    }
  }

  private void archiveForum(OLATResourceable ores, String archivFilePath) {
    ForumManager fom = ForumManager.getInstance();
    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);
View Full Code Here

      log.audit("+... Calcualating word and character count in existing forum posts         ...+");
      log.audit("+-----------------------------------------------------------------------------+");
      TextService languageService = new TextServiceImpl();
     
      int counter = 0;
      ForumManager fMgr = ForumManager.getInstance();
      List<Long> allForumKeys = fMgr.getAllForumKeys();
      if (log.isDebug()) log.info("Found " + allForumKeys.size() + " forums to migrate.");

      for(Long forumKey:allForumKeys) {
        List<Message> allMessages = fMgr.getMessagesByForumID(forumKey);
        for (Message message : allMessages) {
          try{
            String body = message.getBody();
            Locale locale = languageService.detectLocale(body);
            int characters = languageService.characterCount(body, locale);
View Full Code Here

TOP

Related Classes of org.olat.modules.fo.ForumManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.