示例#1
0
  private static Set<Link> getLinks(ArrayList<String> linkList, Entry entry) {
    Set<Link> existingLinks = entry.getLinks();
    Set<Link> links = new HashSet<>();

    if (existingLinks == null) existingLinks = new HashSet<>();

    if (linkList == null) return existingLinks;

    for (int i = 0; i < linkList.size(); i++) {
      String currentItem = linkList.get(i);
      Link link;

      if (existingLinks.size() > i) {
        link = (Link) existingLinks.toArray()[i];
      } else {
        link = new Link();
        existingLinks.add(link);
      }
      link.setLink(currentItem);
      link.setEntry(entry);
      links.add(link);
    }

    return links;
  }
示例#2
0
  /**
   * Updates the entry based on the field that is specified. Mainly created for use by the bulk
   * import auto update
   *
   * @param entry entry to be updated
   * @param plasmid should be set if updating strain with plasmid
   * @param value value to be set
   * @param field to set
   * @return updated entry array containing both entry and plasmid. if plasmid is null only entry is
   *     returned
   */
  public static Entry[] infoToEntryForField(
      Entry entry, Entry plasmid, String value, EntryField field) {
    switch (field) {
      case PI:
        {
          entry.setPrincipalInvestigator(value);
          if (plasmid != null) plasmid.setPrincipalInvestigator(value);
          break;
        }

      case PI_EMAIL:
        {
          entry.setPrincipalInvestigatorEmail(value);
          break;
        }

      case FUNDING_SOURCE:
        {
          entry.setFundingSource(value);
          if (plasmid != null) plasmid.setFundingSource(value);
          break;
        }

      case IP:
        entry.setIntellectualProperty(value);
        if (plasmid != null) plasmid.setIntellectualProperty(value);
        break;

      case BIO_SAFETY_LEVEL:
        Integer level = BioSafetyOption.intValue(value);
        if (level == null) {
          if (value.contains("1")) level = 1;
          else if (value.contains("2")) level = 2;
          else break;
        }
        entry.setBioSafetyLevel(level);
        if (plasmid != null) {
          plasmid.setBioSafetyLevel(level);
        }
        break;

      case NAME:
        entry.setName(value);
        break;

      case ALIAS:
        entry.setAlias(value);
        break;

      case KEYWORDS:
        entry.setKeywords(value);
        break;

      case SUMMARY:
        entry.setShortDescription(value);
        break;

      case NOTES:
        entry.setLongDescription(value);
        break;

      case REFERENCES:
        entry.setReferences(value);
        break;

      case LINKS:
        HashSet<Link> links = new HashSet<>();
        Link link = new Link();
        link.setLink(value);
        link.setEntry(entry);
        links.add(link);
        entry.setLinks(links);
        break;

      case STATUS:
        entry.setStatus(value);
        if (plasmid != null) plasmid.setStatus(value);
        break;

      case SELECTION_MARKERS:
        HashSet<SelectionMarker> markers = new HashSet<>();
        SelectionMarker marker = new SelectionMarker(value, entry);
        markers.add(marker);
        entry.setSelectionMarkers(markers);
        break;

      case PARENTAL_STRAIN:
      case GENOTYPE_OR_PHENOTYPE:
      case PLASMIDS:
        entry = infoToStrainForField(entry, value, field);
        break;

      case BACKBONE:
      case ORIGIN_OF_REPLICATION:
      case CIRCULAR:
      case PROMOTERS:
      case REPLICATES_IN:
        entry = infoToPlasmidForField(entry, value, field);
        break;

      case HOMOZYGOSITY:
      case ECOTYPE:
      case HARVEST_DATE:
      case GENERATION:
      case SENT_TO_ABRC:
      case PLANT_TYPE:
      case PARENTS:
        entry = infoToSeedForField(entry, value, field);
        break;
      default:
        break;
    }
    if (plasmid == null) return new Entry[] {entry};

    return new Entry[] {entry, plasmid};
  }