Example #1
0
  /**
   * Fills the copyObj with the contents of this object. If deepcopy is true, The associated objects
   * are also copied and treated as new objects.
   *
   * @param copyObj the object to fill.
   * @param deepcopy whether the associated objects should be copied.
   */
  protected Synonym copyInto(Synonym copyObj, boolean deepcopy) throws TorqueException {
    copyObj.setId(id);
    copyObj.setKeywords(keywords);
    copyObj.setState(state);

    copyObj.setId(0);

    if (deepcopy) {}
    return copyObj;
  }
  /** For annotations, try to find the appropriate identifier to add to the base URL. */
  protected String generateAnnotURL(AnnotatedFeatureI g, String baseAnnotURL) {
    if (baseAnnotURL == null || baseAnnotURL.equals("")) return null;

    Hashtable id_hash = new Hashtable();

    String id;
    for (int i = 0; i < g.getDbXrefs().size(); i++) {
      DbXref ref = (DbXref) g.getDbXrefs().elementAt(i);
      id = ref.getIdValue();
      // Apparently, if the id starts with FBan we want to replace "FBan" with "CG".
      if (id.startsWith("FBan")) {
        id = id.substring("FBan".length());
        try {
          int cg_num = Integer.parseInt(id);
          id = "CG" + cg_num;
          id_hash.put(id, id);
        } catch (Exception e) {
        }
      } else if (id.startsWith("FB")) { // FBgn, FBab, etc.
        id_hash.put(id, id);
      } else if (id.startsWith("TE")) { // FBgn, FBab, etc.
        id_hash.put(id, id);
      }
    }

    id = getCG(g.getId(), "CG");
    if (id != null) id_hash.put(id, id);
    else {
      id = getCG(g.getId(), "CR");
      if (id != null) id_hash.put(id, id);
      else {
        id = getCG(g.getId(), "FB");
        if (id != null) id_hash.put(id, id);
      }
    }

    id = getCG(g.getName(), "CG");
    if (id != null) id_hash.put(id, id);
    else {
      id = getCG(g.getName(), "CR");
      if (id != null) id_hash.put(id, id);
    }

    for (int i = 0; i < g.getSynonyms().size(); i++) {
      Synonym syn = (Synonym) (g.getSynonyms().elementAt(i));
      id = getCG(syn.getName(), "CG");
      if (id != null) id_hash.put(id, id);
      else {
        id = getCG(syn.getName(), "CR");
        if (id != null) id_hash.put(id, id);
        else {
          id = getCG(g.getId(), "FB");
          if (id != null) id_hash.put(id, id);
        }
      }
    }

    // The code here was glomming together all the elements into one
    // big |ed string, but that's not what the FlyBase annotation report CGI wants.
    // An FB or CG or CR identifier should be sufficient.
    StringBuffer query_str = new StringBuffer();
    for (Enumeration e = id_hash.elements(); e.hasMoreElements(); ) {
      String namepart = (String) e.nextElement();
      //      System.out.println("Considering namepart " + namepart); // DEL
      if (namepart.indexOf("FB") == 0
          || namepart.indexOf("CG") == 0
          || namepart.indexOf("CR") == 0) {
        if (query_str.length() > 0) query_str.replace(0, query_str.length(), namepart);
        else query_str.append(namepart);
        break;
      }
      if (query_str.length() > 0) query_str.append('|');
      query_str.append(namepart);
    }

    // if not FlyBase ID, use the annotation's regular ID
    if (query_str.length() == 0) {
      query_str.append(g.getId());
    }

    String url = null;
    //    System.out.println("generateAnnotUrl: query = " + query_str); // DEL
    if (query_str.length() > 0) {
      // if a custom URL is setup for this type in the tiers file, use that - otherwise use the
      // global
      // one setup in the style file
      FeatureProperty fp = Config.getPropertyScheme().getFeatureProperty(g.getTopLevelType());
      if (fp.getURLString() != null && fp.getURLString().length() > 0) {
        url = fp.getURLString() + g.getId();
      } else {
        url = baseAnnotURL + query_str.toString();
      }
    }

    return url;
  }