Ejemplo n.º 1
0
 public boolean isChildOf(Keyword word) {
   Iterator parents = getParentIterator();
   while (parents.hasNext()) {
     Keyword par = (Keyword) parents.next();
     if (par == null) return (false);
     else if (par.equals(word)) return (true);
     else return (par.isChildOf(word));
   }
   return false;
 }
Ejemplo n.º 2
0
 public static EnumDefinition dropKeywordCreateEnum(
     EnumDefinition enumDefinition, Keyword keyword, boolean saveEnum) {
   if (enumDefinition == null) {
     enumDefinition = new EnumDefinition(keyword.toString(), saveEnum);
   }
   enumDefinition.setKeyword(keyword);
   return enumDefinition;
 }
Ejemplo n.º 3
0
  public static Vector extractKeywordFromText(String text) {
    // see if there are any existing keywords represented
    // in this text
    // Get all keywords

    Vector extractedKeywords = new Vector();
    Iterator keywords = allKeywords.iterator();
    while (keywords.hasNext()) {
      Keyword keyword = (Keyword) keywords.next();
      if (text != null
          && keyword.toString() != null
          && text.toLowerCase().indexOf(keyword.toString().toLowerCase()) > -1) {
        extractedKeywords.addElement(keyword);
      }
    }
    return extractedKeywords;
  }
Ejemplo n.º 4
0
 private Vector getChildren(Keyword keyword, Vector allKids) {
   allKids.addElement(keyword);
   // 			System.out.println("Addtoallkids " + keyword + "  " + allKids );
   Vector children = keyword.getChildren();
   if (children != null) {
     Iterator i = children.iterator();
     while (i.hasNext()) {
       Keyword child = (Keyword) i.next();
       getChildren(child, allKids);
     }
   }
   return allKids;
 }
Ejemplo n.º 5
0
  public boolean dropOn(Object dropOnObject) {
    if (dropOnObject instanceof Keyword) {
      Keyword parentKeyword = null;
      Keyword newParentKeyword = (Keyword) dropOnObject;
      // Add child to new parent
      newParentKeyword.addChild(this);
      // Add new parent to child
      setPar(newParentKeyword);
      update();
      newParentKeyword.update();
      return true;
    } else if (dropOnObject instanceof PersistibleWithKeywords) {
      // 						System.out.println("droping a keyword on " + dropOnObject);
      // THis seems to cause a duplicate entry
      addDescribedInstance((PersistibleWithKeywords) dropOnObject);
      update();

      ((PersistibleWithKeywords) dropOnObject).link(this);
      ((PersistibleWithKeywords) dropOnObject).update();
      return true;
    }
    return false;
  }
Ejemplo n.º 6
0
  private void addKeyword(Hashtable table, Keyword word, Keyword parent) {
    boolean recurse = true;

    if (table.containsKey(word)) recurse = false;

    if (parent == null) table.put(word, String.valueOf(-1));
    else table.put(word, parent);

    if (recurse) {
      Iterator it = word.getChildren().iterator();
      while (it.hasNext()) {
        addKeyword(table, (Keyword) it.next(), word);
      }
    }
  }
Ejemplo n.º 7
0
 public static EnumDefinition dropKeywordCreateEnum(Keyword keyword, boolean saveEnum) {
   EnumDefinition enumDefinition = new EnumDefinition(keyword.toString(), saveEnum);
   enumDefinition.setKeyword(keyword);
   return enumDefinition;
 }
Ejemplo n.º 8
0
 public static void main(String[] args) {
   Keyword t = new Keyword("TEST KEYWORD");
   t.update();
   oncotcap.Oncotcap.getDataSource().commit();
 }