Package com.evernote.edam.type

Examples of com.evernote.edam.type.Tag


        note.setCreated(datetimeValue());
      if (reader.name().equalsIgnoreCase("Content"))
        note.setContent(textValue());
      if (reader.name().equalsIgnoreCase("tag") && createNewTags) {
        String tag = textValue();
        Tag noteTag = null;
        boolean found=false;
        for (int i=0; i<tags.size(); i++) {
          if (tags.get(i).getName().equalsIgnoreCase(tag)) {
            found=true;
            noteTag = tags.get(i);
            i=tags.size();
          }
        }
       
        if (!found) {
          noteTag = new Tag();
          noteTag.setName(tag);
          String tagGuid = QUuid.createUuid().toString().replace("{", "").replace("}", "");
          noteTag.setGuid(tagGuid);
          noteTag.setName(tag);
          tags.add(noteTag);
          conn.getTagTable().addTag(noteTag, true);
        }
        note.addToTagNames(noteTag.getName());
        note.addToTagGuids(noteTag.getGuid());
      }
      if (reader.name().equalsIgnoreCase("note-attributes"))
        note.setAttributes(processNoteAttributes());
      if (reader.name().equalsIgnoreCase("resource")) {
        note.getResources().add(processResource());
View Full Code Here


    if (badTagSync == null)
      badTagSync = new HashMap<String,String>();
    else
      badTagSync.clear();
   
    Tag enTag = findNextTag();
   
    // This is a hack.  Sometimes this function goes flookey and goes into a
    // perpetual loop.  This causes  NeverNote to flood Evernote's servers.
    // This is a safety valve to prevent unlimited loops.
    int maxCount = conn.getTagTable().getDirty().size()+10;
    int loopCount = 0;
   
    while(enTag!=null && loopCount < maxCount) {
      loopCount++;
//      if (authRefreshNeeded)
//        if (!refreshConnection())
//          return;

      try {
        if (enTag.getUpdateSequenceNum() > 0) {
          logger.log(logger.EXTREME, "Updating tag");
          sequence = noteStore.updateTag(authToken, enTag);
        } else {
         
          // Look for a tag with the same name.  If one is found, we don't need
          // to create another one
          logger.log(logger.EXTREME, "New tag.  Comparing with remote names");
          boolean found = false;
          String oldGuid = enTag.getGuid();
          for (int k=0; k<remoteList.size() && !found && keepRunning; k++) {
            if (remoteList.get(k).getName().equalsIgnoreCase(enTag.getName())) {
              conn.getTagTable().updateTagGuid(enTag.getGuid(), remoteList.get(k).getGuid());
              enTag = remoteList.get(k);
              logger.log(logger.EXTREME, "Matching tag name found");
              found = true;
            }
          }
          if (!found)
            enTag = noteStore.createTag(authToken, enTag);
          else
            enTag.setUpdateSequenceNum(noteStore.updateTag(authToken,enTag));
          sequence = enTag.getUpdateSequenceNum();
          if (!oldGuid.equals(enTag.getGuid())) {
            logger.log(logger.EXTREME, "Updating tag guid");
            conn.getTagTable().updateTagGuid(oldGuid, enTag.getGuid());
          }
        }
        logger.log(logger.EXTREME, "Updating tag sequence number");
        conn.getTagTable().updateTagSequence(enTag.getGuid(), sequence);
        logger.log(logger.EXTREME, "Resetting tag dirty flag");
        conn.getTagTable().resetDirtyFlag(enTag.getGuid());
        logger.log(logger.EXTREME, "Emitting sequence number to the main thread.");
        updateSequenceNumber = sequence;
        conn.getSyncTable().setUpdateSequenceNumber(updateSequenceNumber);
      } catch (EDAMUserException e) {
        logger.log(logger.LOW, "*** EDAM User Excepton syncLocalTags: " +enTag.getName());
        logger.log(logger.LOW, e.toString());
        badTagSync.put(enTag.getGuid(),null);
        error = true;
      } catch (EDAMSystemException e) {
        logger.log(logger.LOW, "** EDAM System Excepton syncLocalTags: " +enTag.getName());
        logger.log(logger.LOW, e.toString())
        badTagSync.put(enTag.getGuid(),null);
        error = true;
      } catch (EDAMNotFoundException e) {
        logger.log(logger.LOW, "*** EDAM Not Found Excepton syncLocalTags: " +enTag.getName());
        logger.log(logger.LOW, e.toString());
        badTagSync.put(enTag.getGuid(),null);
        error = true;
      } catch (TException e) {
        logger.log(logger.LOW, "*** EDAM TExcepton syncLocalTags: " +enTag.getName());
        logger.log(logger.LOW, e.toString());
        badTagSync.put(enTag.getGuid(),null);
        error = true;
     
     
      // Find the next tag
      logger.log(logger.EXTREME, "Finding next tag");
View Full Code Here

  //*******************************************************
  //* Find dirty tags, which do not have newly created parents
  //*******************************************************
  private Tag findNextTag() {
    logger.log(logger.HIGH, "Entering SyncRunner.findNextTag");
    Tag nextTag = null;
    List<Tag> tags = conn.getTagTable().getDirty();
   
    // Find the parent.  If the parent has a sequence > 0 then it is a good
    // parent.
    for (int i=0; i<tags.size() && keepRunning; i++) {
      if (!badTagSync.containsKey(tags.get(i).getGuid())) {
        if (tags.get(i).getParentGuid() == null) {
          logger.log(logger.HIGH, "Leaving SyncRunner.findNextTag - tag found without parent");
          return tags.get(i);
        }
        Tag parentTag = conn.getTagTable().getTag(tags.get(i).getParentGuid());
        if (parentTag.getUpdateSequenceNum() > 0) {
          logger.log(logger.HIGH, "Leaving SyncRunner.findNextTag - tag found");
          return tags.get(i);
        }
      }
    }
View Full Code Here

    for (int i=0; i<newNotes.size(); i++) {
      Note n = newNotes.get(i);
      for (int j=0; j<n.getTagGuidsSize(); j++) {
        String tag = n.getTagGuids().get(j);
        if (!conn.getTagTable().exists(tag)) {
          Tag newTag;
          try {
            newTag = noteStore.getTag(token, tag);
            conn.getTagTable().addTag(newTag, false);
          } catch (EDAMUserException e) {
            e.printStackTrace();
View Full Code Here

      }
    }
  }
 
  public void load(List<Tag> tags) {
      Tag tag;
      List<NTreeWidgetItem> index = new ArrayList<NTreeWidgetItem>();
      NTreeWidgetItem child;
              
      /* First, let's find out which stacks are expanded */
      QTreeWidgetItem root =   invisibleRootItem();
      List<String> expandedTags = findExpandedTags(root);


     
      //Clear out the tree & reload
      clear();
      String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
    QIcon icon = new QIcon(iconPath+"tag.png");
     
    Qt.Alignment ra = new Qt.Alignment(Qt.AlignmentFlag.AlignRight);
 
    // Create a copy.  We delete them out as they are found
    List<Tag> tempList = new ArrayList<Tag>();
    for (int i=0; i<tags.size(); i++) {
      tempList.add(tags.get(i));
    }
   
      while (tempList.size() > 0) {
        for (int i=0; i<tempList.size(); i++) {
          tag = tempList.get(i);
          if (tag.getParentGuid()==null || tag.getParentGuid().equals("")) {
            child = new NTreeWidgetItem();
            child.setText(0, tag.getName());
               if (icons != null && !icons.containsKey(tag.getGuid())) {
                 child.setIcon(0, findDefaultIcon(tag.getGuid()));
               } else {
                 child.setIcon(0, icons.get(tag.getGuid()));
               }

            child.setText(2, tag.getGuid());
            child.setTextAlignment(1, ra.value());
            index.add(child);
            addTopLevelItem(child);
            tempList.remove(i);
          } else {
            // We need to find the parent
            for (int j=0; j<index.size(); j++) {
              if (index.get(j).text(2).equals(tag.getParentGuid())) {
                  child = new NTreeWidgetItem();
                  child.setText(0, tag.getName());
                  child.setIcon(0, icon);
                  child.setText(2, tag.getGuid());
                  child.setTextAlignment(1, ra.value());
                     if (icons != null && !icons.containsKey(tag.getGuid())) {
                       child.setIcon(0, findDefaultIcon(tag.getGuid()));
                     } else {
                       child.setIcon(0, icons.get(tag.getGuid()));
                     }
                  tempList.remove(i);
                  index.add(child);               
                  index.get(j).addChild(child);
              }
View Full Code Here

          j=tagIndex.size()+1;
          found = true;
        }
      }
      if (!found) {
        Tag nTag = new Tag();
        nTag.setName(tagName);
        Calendar currentTime = new GregorianCalendar();
        Long l = new Long(currentTime.getTimeInMillis());
        long prevTime = l;
        while (l==prevTime) {
          currentTime = new GregorianCalendar();
          l=currentTime.getTimeInMillis();
        }
        String randint = new String(Long.toString(l));
     
        nTag.setUpdateSequenceNum(0);
        nTag.setGuid(randint);
        conn.getTagTable().addTag(nTag, true);
        getTagIndex().add(nTag);
        conn.getNoteTable().noteTagsTable.saveNoteTag(noteGuid, nTag.getGuid(), isDirty);
        tagGuids.add(nTag.getGuid());
        newTagCreated = true;
      }
    }
   
    for (int i=0; i<getNoteIndex().size(); i++) {
View Full Code Here

  }

 
 
  private void processTagNode() {
    tag = new Tag();
    tagIsDirty = false;
    boolean atEnd = false;
    while(!atEnd) {
      if (backup || importTags) {
        if (reader.isStartElement()) {     
View Full Code Here

       
    Calendar currentTime = new GregorianCalendar();
    Long l = new Long(currentTime.getTimeInMillis());
    String randint = new String(Long.toString(l));
 
    Tag newTag = new Tag();
    newTag.setUpdateSequenceNum(0);
    newTag.setGuid(randint);
    newTag.setName(edit.getTag());
    if (edit.getParentTag().isChecked()) {
      newTag.setParentGuid(currentSelection.text(2));
      newTag.setParentGuidIsSet(true);
      currentSelection.setExpanded(true);
    }
    conn.getTagTable().addTag(newTag, true);
    listManager.getTagIndex().add(newTag);
    reloadTagTree(true);
View Full Code Here

  @SuppressWarnings("unused")
  private void mergeTags() {
    List<Tag> tags = new ArrayList<Tag>();
    List<QTreeWidgetItem> selections = tagTree.selectedItems();
    for (int i=0; i<selections.size(); i++) {
      Tag record = new Tag();
      record.setGuid(selections.get(i).text(2));
      record.setName(selections.get(i).text(0));
      tags.add(record);
    }

    TagMerge mergeDialog = new TagMerge(tags);
    mergeDialog.exec();
View Full Code Here

    List<String> newTags = new ArrayList<String>();
    for (int i=ignore.getIgnoredTagList().count()-1; i>=0; i--) {
      String text = ignore.getIgnoredTagList().takeItem(i).text();
      for (int j=0; j<tags.size(); j++) {
        if (tags.get(j).getName().equalsIgnoreCase(text)) {
          Tag t = tags.get(j);
          conn.getSyncTable().addRecord("IGNORETAG-"+t.getGuid(), t.getGuid());
          newTags.add(t.getGuid());
          j=tags.size();
        }
      }
    }
   
    // Clear out old tags & add new ones
    List<String> oldIgnoreLinkedNotebooks = conn.getSyncTable().getIgnoreRecords("LINKEDNOTEBOOK");
    for (int i=0; i<oldIgnoreLinkedNotebooks.size(); i++) {
      conn.getSyncTable().deleteRecord("IGNORELINKEDNOTEBOOK-"+oldIgnoreLinkedNotebooks.get(i));
    }
   
    List<String> newLinked = new ArrayList<String>();
    for (int i=ignore.getIgnoredLinkedNotebookList().count()-1; i>=0; i--) {
      String text = ignore.getIgnoredLinkedNotebookList().takeItem(i).text();
      for (int j=0; j<linkedNotebooks.size(); j++) {
        if (linkedNotebooks.get(j).getShareName().equalsIgnoreCase(text)) {
          LinkedNotebook t = linkedNotebooks.get(j);
          conn.getSyncTable().addRecord("IGNORELINKEDNOTEBOOK-"+t.getGuid(), t.getGuid());
          newLinked.add(t.getGuid());
          j=linkedNotebooks.size();
        }
      }
    }
   
View Full Code Here

TOP

Related Classes of com.evernote.edam.type.Tag

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.