Changeset 5757
- Timestamp:
- Nov 26, 2019, 9:25:39 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/branches/4.24-stable/src/net/sf/basedb/reggie/plugins/AliquotImporter.java
r5663 r5757 23 23 import net.sf.basedb.core.query.Restrictions; 24 24 import net.sf.basedb.reggie.Reggie; 25 import net.sf.basedb.reggie.converter.ValueConverter; 25 26 import net.sf.basedb.reggie.dao.Annotationtype; 26 27 import net.sf.basedb.reggie.dao.BioplateType; … … 190 191 Mapper patientIdMapper = getOptionalMapper(ffp, "PatientID", fileAndLine); 191 192 Mapper provnummerMapper = getOptionalMapper(ffp, "Provnummer", fileAndLine); 193 194 ValueConverter<String, String> normalTumorConverter = new TranslationConverter("TUMOR", "T", "NA", null); 195 ValueConverter<String, String> variantConverter = new TranslationConverter("0", null); 192 196 193 197 while (ffp.hasMoreData()) … … 211 215 a.poolVolume = poolVolumeMapper.getString(data); 212 216 if (commentMapper != null) a.comment = commentMapper.getString(data); 213 if (normalTumorMapper != null) a.normalTumor = normalTumor Mapper.getString(data);217 if (normalTumorMapper != null) a.normalTumor = normalTumorConverter.convert(normalTumorMapper.getString(data)); 214 218 if (formMapper != null) a.form = formMapper.getString(data); 215 if (variantMapper != null) a.variant = variant Mapper.getString(data);219 if (variantMapper != null) a.variant = variantConverter.convert(variantMapper.getString(data)); 216 220 if (variantListMapper != null) a.variantList = variantListMapper.getString(data); 217 221 if (screeningMapper != null) a.screening = screeningMapper.getString(data); … … 664 668 665 669 } 670 671 /** 672 A simple converter for string values. If a value is found in the 673 translation map the translation is returned. Otherwise the original 674 value is returned unmodified. 675 */ 676 public static class TranslationConverter 677 implements ValueConverter<String, String> 678 { 679 680 private final Map<String, String> translation; 681 682 /** 683 Create a new translation. Key and values are provided 684 as a single array with pair-wise entries. Eg. 685 mapping[0] translates to mapping[1], mapping[2] translates to 686 mapping[3], and so on. 687 */ 688 public TranslationConverter(String... mapping) 689 { 690 this.translation = new HashMap<>(); 691 for (int i = 1; i < mapping.length; i+=2) 692 { 693 translation.put(mapping[i-1], mapping[i]); 694 } 695 } 696 697 @Override 698 public String convert(String key) 699 { 700 return translation.containsKey(key) ? translation.get(key) : key; 701 } 702 } 666 703 }
Note: See TracChangeset
for help on using the changeset viewer.