Package org.corrib.s3b.sscf.tools.sscf2js

Examples of org.corrib.s3b.sscf.tools.sscf2js.NodeContainer


    //TODO: checking credit.
    //boolean reachable = checkCredit(viewer, resource);

    level++;
   
    NodeContainer nc = new NodeContainer();
   
    //** selected link/filtering **
    Set<List<String>> newPathsToUri = pathsToUri;
   
    if(pathsToUri!=null)
    {
      //check if node is on one of the paths in pathsToUri - if yes cut off this path
      for(List<String> path:pathsToUri)
      {
        if(!path.isEmpty())
          if(path.get(0).equals(resource.getStringURI()))
          {
            onPath = true;
            break;
          }
      }
     
      //if the current node is on some path - rewrite the list, and remove current node from it.
      if(onPath)
      {
        newPathsToUri = new HashSet<List<String>>();
        for(List<String> path:pathsToUri)
        {
          if(!path.isEmpty())
            if(path.get(0).equals(resource.getStringURI()))
            {
              path.remove(0);
            }
         
          if(!path.isEmpty())
          {
            newPathsToUri.add(path);
          }
        }
      }
    } 
   
    //need to think some more wise way to tell when script should stop go deeper
    if(level>=maxAbsoluteLevel&&hasContent&&!onPath) {
      isDyn = true;
    }
    nc.setDyn(isDyn);
   
    //set dynamic load
    //nc.setDyn(false);
   
    if (resource instanceof SiocPostResource) {
      SiocPostResource spr = SiocPostResource.getInstance(resource.getStringURI());
     
      owner = spr.getMaker();
      isOwner = viewer.equals(owner);
     
      nc.setType("siocPost");
   
      BookmarkNode bn = new BookmarkNode();
      bn.setId(spr.getStringURI());
     
      if(spr.getTitle()!=null&&!"".equals(spr.getTitle().trim()))
        bn.setLabel("Post:"+spr.getTitle());
      else
        bn.setLabel("Post:"+spr.getStringURI());
       
      //check if this bookmark is selected this directory        
      if(resource.getStringURI().equals(selectedUri))
      {
        bn.setSelected(true);
      }
      else bn.setSelected(false);
     
      bn.setLevel(level);
      bn.setOwn(parentIsOwner)
      bn.setStandalone(standalone);
      nc.setContent(bn);
    }
    else if (resource instanceof SiocForumResource) {
      SiocForumResource sfr = SiocForumResource.getInstance(resource.getStringURI());
     
      hasContent = sfr.hasContent();
   
      nc.setType("siocForum");
     
      DirectoryNode dn = new DirectoryNode();
      dn.setId(sfr.getStringURI());
      dn.setLevel(level);
     
      if(sfr.getName()!=null&&!"".equals(sfr.getName()))
        dn.setLabel("Forum: "+sfr.getName());
      else if(sfr.getTitle()!=null&&!"".equals(sfr.getTitle()))
        dn.setLabel("Forum: "+sfr.getTitle());
      else dn.setLabel("Forum: "+sfr.getStringURI());
      dn.setOwn(isOwner);
      //TODO - get owner from this tags
      //dn.setOwnerMbox((owner != null) ? (owner.getMbox().toString()) : "");
      //dn.setOwnerName((owner != null) ? (owner.getName()) : "");
      dn.setOwnerMbox("");
      dn.setOwnerName("");
      dn.setRemovable(!hasContent);
      dn.setLinkedIn(parentIsOwner&!isOwner);
     
      //check if user select this directory - we can get id or whole uri.
      if(selectedUri!=null&&!"".equals(selectedUri.trim())&&selectedUri.length()>=40)
      {
        if(resource.getStringURI().equals(selectedUri)||
            resource.getStringURI().endsWith(selectedUri.substring(selectedUri.length()-40,selectedUri.length())))
        {
          dn.setSelected(true);
          dn.setOpened(false);
        }
        else dn.setSelected(false);
      }
     
      dn.setStandalone(standalone);
      nc.setContent(dn);

    }
    else if (resource instanceof SiocSiteResource) {
      SiocSiteResource ssr = SiocSiteResource.getInstance(resource.getStringURI());
     
      hasContent = ssr.hasContent();

      nc.setType("siocSite");
   
      DirectoryNode dn = new DirectoryNode();
      dn.setId(resource.getResource().toString());
      dn.setLevel(level);
      dn.setLabel("Site: "+ssr.getTitle());
      dn.setOwn(isOwner);
      //TODO - get owner from this tags
      //dn.setOwnerMbox((owner != null) ? (owner.getMbox().toString()) : "");
      //dn.setOwnerName((owner != null) ? (owner.getName()) : "");
      dn.setOwnerMbox("");
      dn.setOwnerName("");   
      dn.setRemovable(!hasContent);
      dn.setLinkedIn(parentIsOwner&!isOwner);
     
      //check if user select this directory - we can get id or whole uri.
      if(selectedUri!=null&&!"".equals(selectedUri.trim())&&selectedUri.length()>=40)
      {
        if(resource.getStringURI().equals(selectedUri)||
            resource.getStringURI().endsWith(selectedUri.substring(selectedUri.length()-40,selectedUri.length())))
        {
          dn.setSelected(true);
          dn.setOpened(false);
        }
        else dn.setSelected(false);
      }
     
      dn.setStandalone(standalone);
      nc.setContent(dn);
    }
   
    //add created nodes to the buffer
    nc.toJSON(buffer);
   
    //proceed the content of this resource

    if (hasContent&&!isDyn) {
      //parentIsOwner = isOwner;
View Full Code Here


   */
  protected void bookmarksTreeWebResource(WebBookmarkResource resource,   
      Person viewer, StringBuilder buffer,int level,
      boolean parentIsOwner,boolean standalone,boolean inOwn,String selectedUri)
  { 
    NodeContainer nc = new NodeContainer();
    //set dynamic load
    nc.setDyn(false);
 
    //Web bookmark
    nc.setType("webBookmark");
    BookmarkNode bn = new BookmarkNode();
   
    bn.setId(resource.getResource().toString());
   
    bn.setLabel((resource.getLabel()!=null&&!"".equals(resource.getLabel())) ? escapeForJs(resource.getLabel()) : resource.getStringURI().toString() );
    bn.setHits(resource.getResourceHits());
   
    int savedBy = resource.getSavedByNumber();
    if(savedBy>1)
    {
      bn.setSavedBy(savedBy);
    }
   
    //check if this bookmark is selected this directory        
    if(resource.getStringURI().toString().equals(selectedUri))
    {
      bn.setSelected(true);
    }
    else bn.setSelected(false);
     
    bn.setLevel(level+1);
    bn.setOwn(parentIsOwner)
    bn.setStandalone(standalone);
    bn.setHref(resource.getSeeAlso()!=null?resource.getSeeAlso().toString():resource.getStringURI());
    nc.setContent(bn);
   
    //add created nodes to the buffer
    nc.toJSON(buffer)
  }
View Full Code Here

  protected void bookmarksTreeHexResource(WebBookmarkResource resource,
      Person viewer, StringBuilder buffer,int level,
      boolean parentIsOwner,boolean standalone,boolean inOwn,
      String selectedUri)
  { 
    NodeContainer nc = new NodeContainer();
    //set dynamic load
    nc.setDyn(false);
 
    //Web bookmark
    nc.setType("hexBookmark");
    BookmarkNode bn = new BookmarkNode();
   
    bn.setId(resource.getResource().toString());
   
    bn.setLabel((resource.getLabel()!=null&&!"".equals(resource.getLabel())) ? resource.getLabel() : resource.getStringURI().toString() );
    bn.setHits(resource.getResourceHits());
   
    int savedBy = resource.getSavedByNumber();
    if(savedBy>1)
    {
      bn.setSavedBy(savedBy);
    }
   
    //check if this bookmark is selected this directory        
    if(resource.getStringURI().toString().equals(selectedUri))
    {
      bn.setSelected(true);
    }
    else bn.setSelected(false);
     
    bn.setLevel(level+1);
    bn.setOwn(parentIsOwner)
    bn.setStandalone(standalone);
    bn.setHref(resource.getSeeAlso().toString());
    nc.setContent(bn);
   
    //add created nodes to the buffer
    nc.toJSON(buffer)
  }
View Full Code Here

   
    if(reachable)
    {
      level++;
     
      NodeContainer nc = new NodeContainer();
     
      //** selected link/filtering **
      Set<List<String>> newPathsToUri = pathsToUri;
     
      if(pathsToUri!=null)
      {
        //check if node is on one of the paths in pathsToUri - if yes cut off this path
        for(List<String> path:pathsToUri)
        {
          if(!path.isEmpty())
            if(path.get(0).equals(resource.getStringURI()))
            {
              onPath = true;
              break;
            }
        }
       
        //if the current node is on some path - rewrite the list, and remove current node from it.
        if(onPath)
        {
          newPathsToUri = new HashSet<List<String>>();
          for(List<String> path:pathsToUri)
          {
            if(!path.isEmpty())
              if(path.get(0).equals(resource.getStringURI()))
              {
                path.remove(0);
              }
           
            if(!path.isEmpty())
            {
              newPathsToUri.add(path);
            }
          }
        }
      } 
     
      //need to think some more wise way to tell when script should stop go deeper
      //FIXME: del.icio.us would be always dynamic!
      if(level>=maxAbsoluteLevel&&hasContent&&!onPath) {
        isDyn = true;
      }
      nc.setDyn(isDyn);
     
      //special case for filtering and user's own directory. there is no need to generate elements
      //that has been already generated.
      //maxAbsoluteLevel==0 means that there is filtering mode enabled
      boolean isSelected = false;
      if(selectedUri!=null&&!"".equals(selectedUri.trim())) {
        isSelected = (resource.getStringURI().equals(selectedUri));
        if(!isSelected&&selectedUri.length()>40)
          isSelected = resource.getStringURI().endsWith(selectedUri.substring(selectedUri.length()-40,selectedUri.length()));
      }
     
      if(maxAbsoluteLevel!=0||onPath||isSelected||!isOwner)
      {
        if(isDiu)
        {
          nc.setType("diuDirectory");
         
          if(onPath)
          {
            isDyn = false;
            nc.setDyn(isDyn);
          }
         
          DirectoryNode dn = new DirectoryNode();
          dn.setId(resource.getResource().toString());
         
          dn.setLevel(level);
         
          String label = resource.getStringURI();
          if(label.length()>9)
            label = label.substring(0,label.length()-9);
          dn.setLabel(label+" bookmarks");
               
          dn.setOwn(isOwner);
          dn.setOwnerMbox((issuer != null) ? (issuer.getId()) : "");
          dn.setOwnerName((issuer != null) ? (issuer.getName()) : "");
          dn.setRemovable(!hasContent);
          dn.setLinkedIn(parentIsOwner&!isOwner);
         
          dn.setOpened(onPath);
         
          dn.setStandalone(standalone);
          nc.setContent(dn);
        }
        //normal directory
        else if(isDir&&!isSuggested)
        {
          nc.setType("directory");
          DirectoryNode dn = new DirectoryNode();
          dn.setId(resource.getResource().toString());
         
          dn.setLevel(level);
         
          if(resource.getLabel().contains("\"")||resource.getLabel().contains("'"))
          {
            dn.setLabel("bleble "+resource.getLabel().replace("\"", "\\\"").replace("'","\\'"));
          }
          else if(resource.getLabel().trim().equals(""))
          {
            dn.setLabel(resource.getStringURI());
          }
          else
          {
            dn.setLabel(resource.getLabel());
          }
               
          dn.setOwn(isOwner);
          dn.setOwnerMbox((issuer != null) ? (issuer.getId()) : "");
          dn.setOwnerName((issuer != null) ? (issuer.getName()) : "");
          dn.setRemovable(!hasContent);
          dn.setLinkedIn(parentIsOwner&!isOwner);
         
          dn.setOpened(onPath);
         
          //check if user select this directory - we can get id or whole uri.
          if(isSelected)
          {
            dn.setSelected(true);
            dn.setOpened(false);
          }
          else dn.setSelected(false);
         
         
          dn.setStandalone(standalone);
          nc.setContent(dn);
        }
        //suggested directory
        else if(isDir&&isSuggested)
        {
          nc.setType("sugDirectory");
          SugDirectoryNode sdn = new SugDirectoryNode();
          sdn.setId(resource.getResource().toString());
          sdn.setLevel(level);
          sdn.setLabel(resource.getLabel());
          sdn.setOwnerMbox((issuer != null) ? (issuer.getId()) : "");
          sdn.setOwnerName((issuer != null) ? (issuer.getName()) : "");
         
          sdn.setOpened(onPath);
         
          //check if user select this directory - we can get id or whole uri.
          if(isSelected)
          {
            sdn.setSelected(true);
            sdn.setOpened(false);
          }
          else sdn.setSelected(false);
         
          sdn.setStandalone(standalone);
          nc.setContent(sdn);
        }
        //bookmark
        else
        {
          nc.setType("bookmark");
          BookmarkNode bn = new BookmarkNode();
          ResourceWrapper bookRes = new ResourceWrapper(resource,serviceAddr,true);
          bn.setId(resource.getResource().toString());
 
          if (bookRes.getAuthors() != null && bookRes.getTitle() != null) {
            bn.setLabel("<i>[" + bookRes.getAuthors() + "]</i> " + bookRes.getTitle());
          } else {
          //TODO: temporarly switched of to get some efficiency - will be substituted with - "fetch details" button
           
            if(resource.getLabel().contains("\"")||resource.getLabel().contains("'"))
              bn.setLabel(resource.getLabel().replace("\"", "\\\"").replace("'", "\\'"));
            else
              bn.setLabel(resource.getLabel()!=null&&!"".equals(resource.getLabel())?resource.getLabel(): resource.getResource().toString());
          }
         
          //check if this bookmark is selected this directory        
          if(isSelected)
          {
            bn.setSelected(true);
          }
          else bn.setSelected(false);
         
          bn.setHits(resource.getResourceHits());
          bn.setLevel(level);
          bn.setOwn(parentIsOwner)
          bn.setStandalone(standalone);
          nc.setContent(bn);
        }
       
        //add created nodes to the buffer
        if(reachable)
          nc.toJSON(buffer);
      }
     
      //proceed the content of this resource
      if (hasContent&&reachable&&!isDyn) {
        //parentIsOwner = isOwner;
View Full Code Here

     
        boolean hasCont = xsscf.hasContent();
       
        level++;
       
        NodeContainer nc = new NodeContainer();
        nc.setDyn(hasCont&!own);
       
        if(maxAbsoluteLevel==0&&onPath) nc.setDyn(false);
       
        if(person.equals(viewer))
          nc.setType("person");
        else
          nc.setType("friend");
     
        Node n = new Node();
        n.setLabel(person.getName());
        n.setId(person.getId());
        n.setStandalone(standalone);
        n.setLevel(level);
       
        nc.setContent(n);
       
        //append the node to the buffer
        nc.toJSON(buffer);
       
        //proceed the content
        if (hasCont&&(own||onPath)) {
          //parentIsOwner = own;
         
View Full Code Here

        XfoafSscfResource xfr = XfoafSscfResource.getXfoafSscfResource(resource.getStringURI());
        Iterator<? extends XResource> it2 = xfr.listSuggestedContent();
        //create the virtual node - "additional suggested directory"
        if(it2!=null&&it2.hasNext()&&afterTheOwner)
        {
          NodeContainer nc = new NodeContainer();
          nc.setType("addDirectory");
          SugDirectoryNode sdn = new SugDirectoryNode();
          sdn.setId(resource.getResource().toString());
          sdn.setLevel(++level);
          sdn.setStandalone(standalone);
          nc.setContent(sdn);
          nc.toJSON(buffer);
        }
        this.bookmarksTree(it2, buffer, viewer, depth, session, level, parentIsOwner, standalone,true,inOwn,serviceAddr,selectedUri,pathsToUri);
       
        //if we were created virtual directory, we should decrement the level.
        if(it2!=null&&it2.hasNext()&&afterTheOwner)
View Full Code Here

        return jsonArray;
      for(List<String> path : paths){
       
        //first element is the import directory for bookmarking source, second element is the first directory in the tree
        String dirUri = path.get(1);
        NodeContainer nc = new NodeContainer();


        WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResource(dirUri);
        //set dynamic load
        nc.setDyn(true);

        //Web bookmark
        nc.setType("directory");
        DirectoryNode dn = new DirectoryNode();

        dn.setId(wbr.getResource().toString());

        dn.setLabel((wbr.getLabel()!=null&&!"".equals(wbr.getLabel())) ? escapeForJs(wbr.getLabel()) : wbr.getStringURI().toString() );

        int level = 3;
        dn.setLevel(level);
        dn.setOwn(true)
        dn.setStandalone(false);
        nc.setContent(dn);

        //add created nodes to the buffer
       
        jsonArray.add(nc.toJSONObject());
      }
    }
    return jsonArray;
  }
View Full Code Here

TOP

Related Classes of org.corrib.s3b.sscf.tools.sscf2js.NodeContainer

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.