Package com.gnizr.db.dao

Examples of com.gnizr.db.dao.MachineTag


import junit.framework.TestCase;

public class TestMachineTag extends TestCase {

  public void testToString() throws Exception{
    MachineTag mt = new MachineTag();
    assertEquals("",mt.toString());
   
    mt = new MachineTag("ns","predicate","value");
    assertEquals("ns:predicate=value",mt.toString());
   
    mt = new MachineTag(null,"predicate","value");
    assertEquals("gn:predicate=value",mt.toString());
   
    mt = new MachineTag(null,"predicate","\"value value\"");
    assertEquals("gn:predicate=\"value value\"",mt.toString());
   
    mt = new MachineTag("ns","predicate","\"value value\"");
    assertEquals("ns:predicate=\"value value\"",mt.toString());
  }
View Full Code Here


    mt = new MachineTag("ns","predicate","\"value value\"");
    assertEquals("ns:predicate=\"value value\"",mt.toString());
  }
 
  public void testEquals() throws Exception{
    MachineTag m1 = new MachineTag(null,"pred","value");
    MachineTag m2 = new MachineTag("gn","pred","value");
    MachineTag m3 = new MachineTag(null,"ppp","value");
   
    assertTrue(m1.equals(m2));
    assertFalse(m1.equals(m3));
    assertFalse(m2.equals(m3));
  }
View Full Code Here

    List<String> tags = tagParser.getTags();
    assertTrue(tags.contains("tag:geonames:united_states"));
    assertTrue(tags.contains("gn:tag=geonames:21045,md"));
   
    List<MachineTag> mtags = tagParser.getMachineTags();
    MachineTag m1 = mtags.get(0);
    assertEquals("geonames:united_states",m1.getValue());
    MachineTag m2 = mtags.get(1);
    assertEquals("geonames:21045,md",m2.getValue());
  }
View Full Code Here

  public static boolean isPrefixedUserTag(String tag){
    if(tag == null) throw new NullPointerException("tag is null");
    TagsParser parse = new TagsParser(tag);
    List<MachineTag> result = parse.getMachineTags();
    if(result != null && result.size() == 1){
      MachineTag mt = result.get(0);
      String ns = mt.getNsPrefix();
      String pred = mt.getPredicate();
      if(ns == null || ns.equals(MachineTags.NS_GNIZR)){
        if(MachineTags.TAG_PRED.equals(pred)){
          return true;
        }
      }   
View Full Code Here

      return null;
    }
    TagsParser parse = new TagsParser(tag);
    List<MachineTag> result = parse.getMachineTags();
    if(result != null && result.size() == 1){
      MachineTag mt = result.get(0);
      String value = mt.getValue();
      String[] parseResult = value.split("/");
      if(parseResult != null){
        if(parseResult.length == 2){   
          return new UserTag(parseResult[0],parseResult[1]);
        }else if(parseResult.length == 1){
View Full Code Here

  public String doRemoveTag() throws Exception{
    resolveUser();
    if (feedUrl != null && tag != null) {     
      String safeTagStr = TagUtil.makeSafeTagString(tag);
      if (safeTagStr.length() > 0) {
        MachineTag mt = MachineTags.GN_TAG(safeTagStr);
        String fullSynx = mt.toString();
        String shrtSynx = mt.getPredicate()+":"+mt.getValue();
        FeedSubscription feed = feedSubscriptionManager.getSubscription(getUser(),feedUrl);
        if(feed != null){
          String tagline = feed.getBookmark().getTags();
          if(tagline.contains(fullSynx) == true){
            tagline = tagline.replace(fullSynx," ");
View Full Code Here

      throws MissingIdException, NoSuchUserException,
      NoSuchLinkException, NoSuchBookmarkException {
    if (tag != null) {
      String safeTagStr = TagUtil.makeSafeTagString(tag);
      if (safeTagStr.length() > 0) {
        MachineTag newTag = MachineTags.GN_TAG(safeTagStr);
        List<MachineTag> mtags = bm.getMachineTagList();
        for (MachineTag mt : mtags) {
          if (mt.equals(newTag) == true) {
            return;
          }
        }
        if (bm.getTags() != null) {
          bm.setTags(bm.getTags() + " " + newTag.toString());
        } else {
          bm.setTags(newTag.toString());
        }
        bookmarkManager.updateBookmark(bm);
      }
    }
  }
View Full Code Here

public class MachineTags {

 
  public static final MachineTag GN_FOLDER(String folder){
    String f = folder.replaceAll("\\s+","_");
    return new MachineTag(NS_GNIZR,FOLDER_PRED,f);
  };
View Full Code Here

    String f = folder.replaceAll("\\s+","_");
    return new MachineTag(NS_GNIZR,FOLDER_PRED,f);
  };
 
  public static final MachineTag GN_FOR(String username){
    return new MachineTag(NS_GNIZR,FOR_PRED,username);
  }
View Full Code Here

  public static final MachineTag GN_FOR(String username){
    return new MachineTag(NS_GNIZR,FOR_PRED,username);
  }
 
  public static final MachineTag GN_TAG(String tag){
    return new MachineTag(NS_GNIZR,TAG_PRED,tag);
  }
View Full Code Here

TOP

Related Classes of com.gnizr.db.dao.MachineTag

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.