Changeset 4269
- Timestamp:
- Dec 22, 2011, 4:50:55 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/api/core/src/org/proteios/core/Hit.java
r4252 r4269 266 266 { 267 267 getData().setFractionId(fractionId); 268 } 269 270 /** 271 * The maximum length of the replicate ID that can be stored in the database. 272 * 273 * @see #setReplicateId(String) 274 */ 275 public static final int MAX_RELICATE_ID_LENGTH = HitData.MAX_REPLICATE_ID_LENGTH; 276 277 278 public String getReplicateId() 279 { 280 return getData().getReplicateId(); 281 } 282 283 284 public void setReplicateId(String replicateId) 285 { 286 getData().setReplicateId(replicateId); 268 287 } 269 288 -
trunk/api/core/src/org/proteios/core/data/HitData.java
r3532 r4269 48 48 private String localSampleId = null; 49 49 private String fractionId = null; 50 private String replicateId = null; 50 51 private Boolean microPlate = null; 51 52 private Date searchDate = null; … … 222 223 } 223 224 225 /** 226 * The maximum length of the replicate ID that can be stored in the database. 227 * 228 * @see #setFractionId(String) 229 */ 230 public static final int MAX_REPLICATE_ID_LENGTH = 10; 231 232 233 /** 234 * A replicate id, e.g. a serial number like 01. Constrained to 10 characters. 235 * 236 * @hibernate.property column="`replicateId`" length="16" type="string" 237 * not-null="false" 238 */ 239 public String getReplicateId() 240 { 241 return replicateId; 242 } 243 244 245 public void setReplicateId(String replicateId) 246 { 247 this.replicateId = replicateId; 248 } 249 224 250 225 251 /** -
trunk/client/servlet/src/locale/en/dictionary
r4239 r4269 742 742 Remaining=Remaining 743 743 RemainingSampleQuantityInMicroLiters=Remaining Sample Quantity (µl) 744 ReplicateId=Replicate ID 744 745 Removed=Removed 745 746 Reports=Reports -
trunk/client/servlet/src/org/proteios/action/file/InfoFileHandler.java
r4125 r4269 298 298 annotationName = "fraction"; 299 299 } 300 // To make sure replicate annotation is always lower case 301 else if (annotationName.equalsIgnoreCase("replicate")) 302 { 303 annotationName = "replicate"; 304 } 300 305 AnnotationType at = annotator.getAnnotationType(annotationName, 301 306 Type.STRING, file.getType()); -
trunk/plugin/src/org/proteios/plugins/PeakListToHitNonGelPlugin.java
r4126 r4269 44 44 import org.proteios.core.Project; 45 45 import org.proteios.core.SessionControl; 46 import org.proteios.core.Type; 46 47 import org.proteios.core.plugin.About; 47 48 import org.proteios.core.plugin.AboutImpl; … … 55 56 import org.proteios.io.FilenameParseUtil; 56 57 import org.proteios.io.PeakListFileValidationFactory; 58 57 59 import java.util.ArrayList; 58 60 import java.util.Collections; 61 import java.util.Iterator; 59 62 import java.util.List; 60 63 import java.util.Set; … … 116 119 // Directory d = (Directory) job.getValue("dir"); 117 120 ArrayList<Throwable> err = new ArrayList<Throwable>(1); 118 String localSampleIdEntryMode = (String) job.getValue("localSampleIdEntryMode"); 119 log.debug("localSampleIdEntryMode = \"" + localSampleIdEntryMode + "\""); 121 String localSampleIdEntryMode = (String) job 122 .getValue("localSampleIdEntryMode"); 123 log 124 .debug("localSampleIdEntryMode = \"" + localSampleIdEntryMode + "\""); 120 125 String localSampleId = (String) job.getValue("localSampleId"); 121 String fractionIdEntryMode = (String) job.getValue("fractionIdEntryMode"); 126 String fractionIdEntryMode = (String) job 127 .getValue("fractionIdEntryMode"); 122 128 log.debug("fractionIdEntryMode = \"" + fractionIdEntryMode + "\""); 123 129 String regexPattern = (String) job.getValue("regexPattern"); … … 128 134 DbControl dc = sc.newDbControl(); 129 135 Project project = Project.getById(dc, sc.getActiveProjectId()); 130 List<FileType> fts = PeakListFileValidationFactory.getPossibleFileTypes(dc); 136 List<FileType> fts = PeakListFileValidationFactory 137 .getPossibleFileTypes(dc); 131 138 dc.reattachItem(f); 132 139 // 133 140 List<String> localSampleIdStringList = new ArrayList<String>(); 134 141 Set<BioMaterial> fileBioMaterialSet = f.getBioMaterials(); 135 for (BioMaterial fileBioMaterial : fileBioMaterialSet)142 for (BioMaterial fileBioMaterial : fileBioMaterialSet) 136 143 { 137 144 String fileBioMaterialName = fileBioMaterial.getName(); … … 142 149 localSampleIdStringList.add(fileBioMaterialName); 143 150 } 144 else if (fileBioMaterialName2 != null && !fileBioMaterialName2.equals("")) 151 else if (fileBioMaterialName2 != null && !fileBioMaterialName2 152 .equals("")) 145 153 { 146 154 // Add name to local sample id string list … … 148 156 } 149 157 } 150 if (localSampleIdEntryMode.equals(GET_LOCAL_SAMPLE_ID_FROM_FILE_BIOMATERIAL)) 151 { 152 if (localSampleIdStringList != null && localSampleIdStringList.size() != 0) 158 if (localSampleIdEntryMode 159 .equals(GET_LOCAL_SAMPLE_ID_FROM_FILE_BIOMATERIAL)) 160 { 161 if (localSampleIdStringList != null && localSampleIdStringList 162 .size() != 0) 153 163 { 154 164 // Sort combined list 155 165 Collections.sort(localSampleIdStringList); 156 166 String tmpLocalSampleId = new String(""); 157 for (String partStr : localSampleIdStringList)167 for (String partStr : localSampleIdStringList) 158 168 { 159 169 if (partStr != null && !partStr.equals("")) … … 190 200 if (ft != null && (fts.contains(ft))) 191 201 { 202 // Retrieve replicate ID 203 String replicate = fetchReplicateIdFromFileAnnotation(dc, f); 192 204 // Attempt to obtain fraction ID from file annotation "fraction". 193 String fractionIdFromAnnotation = fetchFractionIdFromFileAnnotation(dc, f); 205 String fractionIdFromAnnotation = fetchFractionIdFromFileAnnotation( 206 dc, f); 194 207 // Use regex pattern to parse fraction ID from filename 195 208 String fractionIdFromFilename = null; … … 197 210 { 198 211 // Use regex pattern to parse fraction ID from filename 199 fractionIdFromFilename = fpu.fetchRegexResult(f.getName(), regexPattern); 200 } 201 log.debug("fraction id from file annotation = \"" + fractionIdFromAnnotation + "\""); 202 log.debug("fraction id from file name = \"" + fractionIdFromFilename + "\""); 212 fractionIdFromFilename = fpu.fetchRegexResult(f.getName(), 213 regexPattern); 214 } 215 log 216 .debug("fraction id from file annotation = \"" + fractionIdFromAnnotation + "\""); 217 log 218 .debug("fraction id from file name = \"" + fractionIdFromFilename + "\""); 203 219 // Get fraction id, if any 204 220 String fractionId = new String(""); 205 if (fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION) 206 || fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION_OR_NAME)) 221 if (fractionIdEntryMode 222 .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION) || fractionIdEntryMode 223 .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION_OR_NAME)) 207 224 { 208 225 if (fractionIdFromAnnotation != null) 209 226 { 210 // First choice, fraction id from annotation for peaklist file 227 // First choice, fraction id from annotation for peaklist 228 // file 211 229 fractionId = fractionIdFromAnnotation; 212 230 } 213 else if (fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION_OR_NAME)) 231 else if (fractionIdEntryMode 232 .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION_OR_NAME)) 214 233 { 215 234 if (fractionIdFromFilename != null) … … 220 239 } 221 240 } 222 else if (fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME) 223 || fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME_OR_ANNOTATION)) 241 else if (fractionIdEntryMode 242 .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME) || fractionIdEntryMode 243 .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME_OR_ANNOTATION)) 224 244 { 225 245 if (fractionIdFromFilename != null) … … 228 248 fractionId = fractionIdFromFilename; 229 249 } 230 else if (fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME_OR_ANNOTATION)) 250 else if (fractionIdEntryMode 251 .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME_OR_ANNOTATION)) 231 252 { 232 253 if (fractionIdFromAnnotation != null) 233 254 { 234 // Second choice, fraction id from annotation for peaklist file 255 // Second choice, fraction id from annotation for 256 // peaklist file 235 257 fractionId = fractionIdFromAnnotation; 236 258 } … … 242 264 if (fractionId != null && fractionId.length() > Hit.MAX_FRACTION_ID_LENGTH) 243 265 { 244 log.debug("Fraction ID = \"" + fractionId + "\" is too long (" + fractionId.length() + " characters, " + Hit.MAX_FRACTION_ID_LENGTH + " allowed)."); 245 err.add(new BaseException( 246 "Fraction ID = \"" + fractionId + "\" is too long (" + fractionId.length() + " characters, " + Hit.MAX_FRACTION_ID_LENGTH + " allowed).")); 266 log 267 .debug("Fraction ID = \"" + fractionId + "\" is too long (" + fractionId 268 .length() + " characters, " + Hit.MAX_FRACTION_ID_LENGTH + " allowed)."); 269 err 270 .add(new BaseException( 271 "Fraction ID = \"" + fractionId + "\" is too long (" + fractionId 272 .length() + " characters, " + Hit.MAX_FRACTION_ID_LENGTH + " allowed).")); 247 273 response.setError("Nothing imported", err); 248 274 return; … … 281 307 newhit.setLocalSampleId(localSampleId); 282 308 newhit.setFractionId(fractionId); 309 if (replicate !=null) 310 { 311 newhit.setReplicateId(replicate); 312 } 283 313 dc.saveItem(newhit); 284 314 dc.reattachItem(newhit); … … 325 355 326 356 /* 357 * Attempts to obtain replicate id from file annotation "replicate". 358 * @param DbControl dc The DbControl to use. 359 * @param File file The file to get the annotation for. 360 * @return String The found fraction id, or null if none found. 361 */ 362 private String fetchReplicateIdFromFileAnnotation(DbControl dc, File file) 363 { 364 String replicateId = null; 365 Annotator annotator = new Annotator(new ItemFactory(dc)); 366 AnnotationType at = annotator.getAnnotationType(file, "replicate", Type.STRING); 367 Annotation annotation = annotator.getAnnotation(file, at); 368 Iterator<?> it = annotation.getValues().iterator(); 369 while (it.hasNext()) 370 { 371 replicateId = (String) it.next(); 372 } 373 return replicateId; 374 } 375 376 377 /* 327 378 * Attempts to obtain fraction id from file annotation "fraction". 328 *329 379 * @param DbControl dc The DbControl to use. 330 380 * @param File file The file to get the anntation for. … … 336 386 // Try to get fraction id from file annotation "fraction" 337 387 Annotator annotator = new Annotator(new ItemFactory(dc)); 338 ItemQuery<Annotation> annotationQuery = annotator.getAnnotationSet(file).getAnnotations(); 388 ItemQuery<Annotation> annotationQuery = annotator 389 .getAnnotationSet(file).getAnnotations(); 339 390 ItemResultList<Annotation> annotationList = annotationQuery.list(dc); 340 391 if (annotationList != null && annotationList.size() > 0) 341 392 { 342 for (Annotation annotation : annotationList)393 for (Annotation annotation : annotationList) 343 394 { 344 395 if (annotation != null) 345 396 { 346 397 // Get annotation type 347 AnnotationType annotationType = annotation.getAnnotationType(); 398 AnnotationType annotationType = annotation 399 .getAnnotationType(); 348 400 if (annotationType != null) 349 401 { 350 402 String annotationTypeName = annotationType.getName(); 351 if (annotationTypeName != null && annotationTypeName.equals("fraction")) 403 if (annotationTypeName != null && annotationTypeName 404 .equals("fraction")) 352 405 { 353 List<String> tmpFractionIdList = (List<String>) annotation.getValues(); 354 if (tmpFractionIdList != null && tmpFractionIdList.size() > 0) 406 List<String> tmpFractionIdList = (List<String>) annotation 407 .getValues(); 408 if (tmpFractionIdList != null && tmpFractionIdList 409 .size() > 0) 355 410 { 356 String tmpFractionId = (String) tmpFractionIdList.get(0); 357 if (tmpFractionId != null && !tmpFractionId.equals("")) 411 String tmpFractionId = (String) tmpFractionIdList 412 .get(0); 413 if (tmpFractionId != null && !tmpFractionId 414 .equals("")) 358 415 { 359 416 fractionId = tmpFractionId; -
trunk/plugin/src/org/proteios/plugins/SearchResultsImporter.java
r4261 r4269 221 221 hit.setLocalSampleId(emptyHit.getLocalSampleId()); 222 222 hit.setFractionId(emptyHit.getFractionId()); 223 hit.setReplicateId(emptyHit.getReplicateId()); 223 224 hit.setPeakListFile(emptyHit.getPeakListFile()); 224 225 dc.saveItem(hit);
Note: See TracChangeset
for help on using the changeset viewer.