Ejemplo n.º 1
0
  private static void exportFieldToKeywords(
      SpecialField e, String newValue, BibtexEntry be, NamedCompound ce) {
    if (!SpecialFieldsUtils.keywordSyncEnabled()) {
      return;
    }
    ArrayList<String> keywordList = Util.getSeparatedKeywords(be);
    List<String> values = e.getKeyWords();

    int foundPos = -1;

    // cleanup keywords
    for (Object value : values) {
      int pos = keywordList.indexOf(value);
      if (pos >= 0) {
        foundPos = pos;
        keywordList.remove(pos);
      }
    }

    if (newValue != null) {
      if (foundPos == -1) {
        keywordList.add(newValue);
      } else {
        keywordList.add(foundPos, newValue);
      }
    }
    Util.putKeywords(be, keywordList, ce);
  }
Ejemplo n.º 2
0
 /**
  * updates field values according to keywords
  *
  * @param ce indicates the undo named compound. May be null
  */
 public static void syncSpecialFieldsFromKeywords(BibtexEntry be, NamedCompound ce) {
   if (be.getField("keywords") == null) {
     return;
   }
   ArrayList<String> keywordList = Util.getSeparatedKeywords(be.getField("keywords"));
   SpecialFieldsUtils.importKeywordsForField(keywordList, Priority.getInstance(), be, ce);
   SpecialFieldsUtils.importKeywordsForField(keywordList, Rank.getInstance(), be, ce);
   SpecialFieldsUtils.importKeywordsForField(keywordList, Quality.getInstance(), be, ce);
   SpecialFieldsUtils.importKeywordsForField(keywordList, Relevance.getInstance(), be, ce);
   SpecialFieldsUtils.importKeywordsForField(keywordList, ReadStatus.getInstance(), be, ce);
   SpecialFieldsUtils.importKeywordsForField(keywordList, Printed.getInstance(), be, ce);
 }