Package org.olat.core.commons.modules.bc.meta

Examples of org.olat.core.commons.modules.bc.meta.MetaInfo


   *
   * @param item
   */
  private GenericTreeNode createNode(OlatRelPathImpl item) {
    GenericTreeNode node = new GenericTreeNode();
    MetaInfo meta = MetaInfoFactory.createMetaInfoFor(item);
    if (meta != null) {
      String title = meta.getTitle();
      if (StringHelper.containsNonWhitespace(title)) {
        node.setTitle(title);
      } else {
        node.setTitle(meta.getName());
      }
    } else {
      // TODO:GW log warning that
      // "metadate couldn't be loaded for folder relpath: " +
      // folder.getRelPath();
View Full Code Here


    else if (col.equals(SORT_LOCK)) {                                              // sort after modification date (if same, then name)
      comparator = new Comparator<VFSItem>() {
        public int compare(VFSItem o1, VFSItem o2) {
          boolean l1 = false;
          if(o1 instanceof MetaTagged) {
            MetaInfo meta = ((MetaTagged)o1).getMetaInfo();
            l1 = meta == null ? false : meta.isLocked();
          }
         
          boolean l2 = false;
          if(o2 instanceof MetaTagged) {
            MetaInfo meta = ((MetaTagged)o2).getMetaInfo();
            l2 = meta == null ? false : meta.isLocked();
          }
         
          if(l1 && !l2) return sortAsc ? -1 : 1;
          if(!l1 && l2) return sortAsc ? 1 : -1;
         
View Full Code Here

    if (child instanceof VFSLeaf) {
      leaf = (VFSLeaf)child;
    }
    boolean isContainer = (leaf == null); // if not a leaf, it must be a container...
   
    MetaInfo metaInfo = null;
    if(child instanceof OlatRelPathImpl) {
      metaInfo = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)child);
    }
    boolean lockedForUser = MetaInfoHelper.isLocked(metaInfo, fc.getIdentityEnvironnement());
   
    String name = child.getName();
    String pathAndName = currentContainerPath;
    if (pathAndName.length() > 0 && !pathAndName.endsWith("/"))
      pathAndName = pathAndName + "/";
    pathAndName = pathAndName + name;
    String type = FolderHelper.extractFileType(child.getName(), translator.getLocale());
       
    // tr begin, set alternating bgcolor
    sb.append("<tr");
    bgFlag = !bgFlag;
    if (bgFlag) { sb.append(" class=\"b_table_odd\""); }
    sb.append("><td class=\"b_first_child\">");

    // add checkbox for actions if user can write or delete to this directory
    if (canWrite || canDelete) {
      sb.append("<input type=\"checkbox\" class=\"b_checkbox\" name=\"");
      sb.append(FileSelection.FORM_ID);
      sb.append("\" value=\"");
      sb.append(StringEscapeUtils.escapeHtml(name));
      sb.append("\" />");
    }   
   
    // browse link pre
    sb.append("<a href=\"");
    if (isContainer) { // for directories... normal module URIs
      ubu.buildURI(sb, null, null, pathAndName, iframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
      sb.append("\"");
      if (iframePostEnabled) { // add ajax iframe target
        StringOutput so = new StringOutput();
        ubu.appendTarget(so);
        sb.append(so.toString());
      }
    } else { // for files, add PARAM_SERV command
      ubu.buildURI(sb, new String[] { PARAM_SERV }, new String[] { "x" }, pathAndName, AJAXFlags.MODE_NORMAL);
      sb.append("\" target=\"_blank\"");
    }
    // icon css
    sb.append(" class=\"b_with_small_icon_left ");
    if (isContainer) sb.append(CSSHelper.CSS_CLASS_FILETYPE_FOLDER);
    else sb.append(CSSHelper.createFiletypeIconCssClassFor(name));
    sb.append("\"");
    // file metadata
    if (metaInfo != null) {
      sb.append(" ext:qtip=\"<div class='b_ext_tooltip_wrapper b_briefcase_meta'>");
      if (StringHelper.containsNonWhitespace(metaInfo.getTitle())) {       
        sb.append("<h5>").append(Formatter.escapeDoubleQuotes(metaInfo.getTitle())).append("</h5>");   
      }
      if (StringHelper.containsNonWhitespace(metaInfo.getComment())) {
        sb.append(Formatter.escapeDoubleQuotes(metaInfo.getComment()));     
      }
      String author = metaInfo.getAuthor();
      if (StringHelper.containsNonWhitespace(author)) {
        sb.append("<p>").append(Formatter.escapeDoubleQuotes(translator.translate("mf.author")));
        sb.append(": ").append(Formatter.escapeDoubleQuotes(author)).append("</p>");     
      }
      sb.append("</div>\"");
    }
    sb.append(">");
    // name
    if (isAbstract) sb.append("<i>");
    sb.append(name);
    if (isAbstract) sb.append("</i>");
    sb.append("</a></td><td>");
   
    // filesize
    if (!isContainer) {
      // append filesize
      sb.append(StringHelper.formatMemory(leaf.getSize()));
    }
    sb.append("</td><td>");

    // type
    if (isContainer) {
      sb.append(translator.translate("Directory"));
    }
    else {
      if (type.equals(TYPE_FILE)) {
        sb.append(translator.translate("UnknownFile"));
      }
      else {
        sb.append(type.toUpperCase());
        sb.append(" ").append(translator.translate(TYPE_FILE));
      }
    }
    sb.append("</td><td>");
   
    if(canContainerVersion) {
      if (canVersion)
        sb.append(versions.getRevisionNr());
      sb.append("</td><td>");
    }
   
    // last modified
    long lastModified = child.getLastModified();
    if (lastModified != VFSConstants.UNDEFINED)
      sb.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, translator.getLocale()).format(new Date(lastModified)));
    else
      sb.append("-");
    sb.append("</td><td>");
   
    //locked
    if(metaInfo != null) {
      if(metaInfo.isLocked()) {
        Identity lockedBy = identityMap.get(metaInfo.getLockedBy());
        if(lockedBy == null) {
          lockedBy = metaInfo.getLockedByIdentity();
          if(lockedBy != null) {
            identityMap.put(lockedBy.getKey(), lockedBy);
          }
        }
       
        sb.append("<span class=\"b_small_icon b_briefcase_locked_file_icon\" ext:qtip=\"");
        if(lockedBy != null) {
          String firstName = lockedBy.getUser().getProperty(UserConstants.FIRSTNAME, translator.getLocale());
          String lastName = lockedBy.getUser().getProperty(UserConstants.LASTNAME, translator.getLocale());
          String date = "";
          if(metaInfo.getLockedDate() != null) {
            date = fc.getDateTimeFormat().format(metaInfo.getLockedDate());
          }
          sb.append(translator.translate("Locked", new String[]{firstName, lastName, date}));
        }
        sb.append("\">&#160;</span>");
      }
View Full Code Here

    String uuid = UUID.randomUUID().toString() + "_" + name;
    String versionNr = getNextRevisionNr(versions);
    String currentAuthor = versions.getAuthor();
    long lastModifiedDate = 0;
    if (currentFile instanceof MetaTagged) {
      MetaInfo metaInfo = ((MetaTagged) currentFile).getMetaInfo();
      if(currentAuthor == null) {
        currentAuthor = metaInfo.getAuthor();
      }
      lastModifiedDate = metaInfo.getLastModified();
    }
   
    if(lastModifiedDate <= 0) {
      Calendar cal = Calendar.getInstance();
      cal.setTime(new Date());
View Full Code Here

    VFSLeaf childLeaf = ((VFSContainer)folder).createChildLeaf(newName);
    if (childLeaf == null)
      throw new NamingException(smgr.getString("resources.bindFailed", name));
    copyVFS(childLeaf, name, obj, attrs);
    if(childLeaf instanceof MetaTagged) {
      MetaInfo infos = ((MetaTagged)childLeaf).getMetaInfo();
      if(infos != null && infos.getAuthorIdentity() == null) {
        infos.setAuthor(userSession.getIdentity().getName());
        infos.write();
      }
    }
   
    //used by move operations
    if(obj instanceof VFSResource) {
View Full Code Here

      VersionsManager.getInstance().addToRevisions((Versionable)file, identity, "");
    }
   
    copyVFS(file, name, obj, attrs);
    if(file instanceof MetaTagged) {
      MetaInfo infos = ((MetaTagged)file).getMetaInfo();
      if(infos != null && infos.getAuthorIdentity() == null) {
        infos.setAuthor(userSession.getIdentity().getName());
        infos.write();
      }
    }
   
    //used by move operations
    if(obj instanceof VFSResource) {
View Full Code Here

  public TitleComparator(Locale locale) {
    this.collator = Collator.getInstance(locale);
  }

  public int compare(MetaTagged one, MetaTagged two) {
    MetaInfo that = one.getMetaInfo();
    MetaInfo other = two.getMetaInfo();
    // Delegate!
    MetaTitleComparator comparator = new MetaTitleComparator(collator);
    return comparator.compare(that, other);
  }
View Full Code Here

  private static void getFileInfosRecursively(OlatRelPathImpl relPath, List<FileInfo> fileInfos, long newerThan, int basePathlen) {
    if (relPath instanceof VFSLeaf) {
      // is a file
      long lastModified = ((VFSLeaf)relPath).getLastModified();
      if (lastModified > newerThan) {
        MetaInfo meta = MetaInfoFactory.createMetaInfoFor(relPath);
        String bcrootPath = relPath.getRelPath();
        String bcRelPath = bcrootPath.substring(basePathlen);
        fileInfos.add(new FileInfo(bcRelPath, meta, new Date(lastModified)));
      }
    } else {
View Full Code Here

      }
    } else if (source == lockedFiledCtr) {
      fireEvent(ureq, FOLDERCOMMAND_FINISHED);
    } else if (source == unlockCtr) {
      if(!unlockCtr.keepLocked()) {
        MetaInfo info = ((MetaTagged)currentItem).getMetaInfo();
        info.setLocked(false);
        info.write();
      }
      cleanUpUnlockDialog();
      fireEvent(ureq, FOLDERCOMMAND_FINISHED);
    }
  }
View Full Code Here

        this.fireEvent(ureq, Event.FAILED_EVENT);
        return;
      }
      if (item instanceof OlatRelPathImpl) {
        // update meta data
        MetaInfo meta = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)item);
        meta.setAuthor(ureq.getIdentity().getName());
        meta.write();
      }   
      fireEvent(ureq, Event.DONE_EVENT);             
    }
View Full Code Here

TOP

Related Classes of org.olat.core.commons.modules.bc.meta.MetaInfo

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.