コード例 #1
0
  private static Entry infoToSeedForField(Entry entry, String value, EntryField field) {
    if (!entry.getRecordType().equalsIgnoreCase(EntryType.ARABIDOPSIS.toString())) return entry;

    ArabidopsisSeed seed = (ArabidopsisSeed) entry;

    switch (field) {
      case HOMOZYGOSITY:
        seed.setHomozygosity(value);
        return seed;

      case ECOTYPE:
        seed.setEcotype(value);
        return seed;

      case HARVEST_DATE:
        if (value != null && !value.isEmpty()) {
          try {
            Date date = SimpleDateFormat.getDateInstance(DateFormat.SHORT).parse(value);
            seed.setHarvestDate(date);
          } catch (ParseException ia) {
            Logger.error(ia);
          }
        }
        return seed;

      case GENERATION:
        seed.setGeneration(Generation.fromString(value));
        return seed;

      case SENT_TO_ABRC:
        seed.setSentToABRC("yes".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value));
        return seed;

      case PLANT_TYPE:
        seed.setPlantType(PlantType.fromString(value));
        return seed;

      case PARENTS:
        seed.setParents(value);
        return seed;

      default:
        return seed;
    }
  }
コード例 #2
0
  protected static Entry setSeedFields(ArabidopsisSeedData seedData, Entry entry) {
    ArabidopsisSeed seed = (ArabidopsisSeed) entry;
    if (seedData == null) return entry;

    if (seedData.getHomozygosity() != null) seed.setHomozygosity(seedData.getHomozygosity());

    if (StringUtils.isNotEmpty(seedData.getHarvestDate())) {
      DateFormat format = new SimpleDateFormat("MM/dd/YYYY");
      try {
        Date date = format.parse(seedData.getHarvestDate());
        seed.setHarvestDate(date);
      } catch (ParseException e) {
        Logger.error("Could not parse date " + seedData.getHarvestDate());
        return null;
      }
    }

    String ecoType = seedData.getEcotype() == null ? "" : seedData.getEcotype();
    seed.setEcotype(ecoType);
    String parents = seedData.getSeedParents() == null ? "" : seedData.getSeedParents();

    seed.setParents(parents);

    if (seedData.getGeneration() != null) {
      Generation generation = Generation.fromString(seedData.getGeneration().name());
      seed.setGeneration(generation);
    } else {
      seed.setGeneration(Generation.UNKNOWN);
    }

    if (seedData.getPlantType() != null) {
      PlantType plantType = PlantType.fromString(seedData.getPlantType().name());
      seed.setPlantType(plantType);
    } else {
      seed.setPlantType(PlantType.NULL);
    }
    seed.setSentToABRC(seedData.isSentToAbrc());
    return entry;
  }