extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/autoconfirm/GeneReportAutoConfirmer.java

Code
Comments
Other
Rev Date Author Line
3051 17 Dec 14 nicklas 1 package net.sf.basedb.reggie.autoconfirm;
3051 17 Dec 14 nicklas 2
6023 26 Oct 20 nicklas 3 import java.util.ArrayList;
6023 26 Oct 20 nicklas 4 import java.util.List;
6023 26 Oct 20 nicklas 5
3051 17 Dec 14 nicklas 6 import net.sf.basedb.core.DbControl;
6023 26 Oct 20 nicklas 7 import net.sf.basedb.core.ItemList;
3051 17 Dec 14 nicklas 8 import net.sf.basedb.core.Job;
3051 17 Dec 14 nicklas 9 import net.sf.basedb.core.RawBioAssay;
3055 19 Dec 14 nicklas 10 import net.sf.basedb.core.SessionControl;
3051 17 Dec 14 nicklas 11 import net.sf.basedb.reggie.dao.Annotationtype;
6023 26 Oct 20 nicklas 12 import net.sf.basedb.reggie.pdf.PdfReportTemplate;
3051 17 Dec 14 nicklas 13
3051 17 Dec 14 nicklas 14 /**
6023 26 Oct 20 nicklas 15   Auto-confirm implementation for raw bioassays after generating gene/pilot/scan-b report.
3051 17 Dec 14 nicklas 16   This auto-confirmer is needed to handle the case when the gene report
6023 26 Oct 20 nicklas 17   plug-in fails to create the report. 
3051 17 Dec 14 nicklas 18   
6023 26 Oct 20 nicklas 19   If the auto-confirmer finds a failed job, it will set the {@link Annotationtype#AUTO_PROCESSING} 
6023 26 Oct 20 nicklas 20   to ReProcess and add the raw bioassay to the item list for the corresponding report.
3051 17 Dec 14 nicklas 21   
3051 17 Dec 14 nicklas 22   @author nicklas
3051 17 Dec 14 nicklas 23   @since 3.0
3051 17 Dec 14 nicklas 24 */
3051 17 Dec 14 nicklas 25 public class GeneReportAutoConfirmer 
6023 26 Oct 20 nicklas 26   extends AutoConfirmer<Job> 
3051 17 Dec 14 nicklas 27 {
6023 26 Oct 20 nicklas 28   public GeneReportAutoConfirmer(Job job)
3051 17 Dec 14 nicklas 29   {
6023 26 Oct 20 nicklas 30     super(job, job);
3051 17 Dec 14 nicklas 31   }
3051 17 Dec 14 nicklas 32
3055 19 Dec 14 nicklas 33   /**
3055 19 Dec 14 nicklas 34     Jobs that has failed passes so that we can flag raw bioassay with ReProcess
3055 19 Dec 14 nicklas 35     in {@link #autoConfirm(DbControl, AutoConfirmManager)}
3055 19 Dec 14 nicklas 36   */
3051 17 Dec 14 nicklas 37   @Override
3051 17 Dec 14 nicklas 38   public boolean checkRules(DbControl dc, AutoConfirmManager manager) 
3051 17 Dec 14 nicklas 39   {
6023 26 Oct 20 nicklas 40     Job job = job(dc);
6023 26 Oct 20 nicklas 41
3051 17 Dec 14 nicklas 42     // We need to fix failed jobs and just don't care about the reset
3051 17 Dec 14 nicklas 43     return job.getStatus() == Job.Status.ERROR;
3051 17 Dec 14 nicklas 44   }
3055 19 Dec 14 nicklas 45   
3055 19 Dec 14 nicklas 46   /**
6023 26 Oct 20 nicklas 47     Set AutoProcessing to ReProcess on the raw bioassays and add 
6023 26 Oct 20 nicklas 48     them to the correct item list for reporting.
3055 19 Dec 14 nicklas 49   */
3051 17 Dec 14 nicklas 50   @Override
3051 17 Dec 14 nicklas 51   public boolean autoConfirm(DbControl dc, AutoConfirmManager manager) 
3051 17 Dec 14 nicklas 52   {
6023 26 Oct 20 nicklas 53     Job job = job(dc);
6023 26 Oct 20 nicklas 54     
6023 26 Oct 20 nicklas 55     List<RawBioAssay> rawBioAssays = job.getParameterValues("rawBioAssays");
6023 26 Oct 20 nicklas 56     List<String> reports = job.getParameterValues("reports");
6023 26 Oct 20 nicklas 57     
6023 26 Oct 20 nicklas 58     List<ItemList> itemLists = new ArrayList<>();
6023 26 Oct 20 nicklas 59     for (String report : reports)
6023 26 Oct 20 nicklas 60     {
6023 26 Oct 20 nicklas 61       PdfReportTemplate template = PdfReportTemplate.getByCName(report, null);
6023 26 Oct 20 nicklas 62       if (template != null && template.getItemList() != null)
6023 26 Oct 20 nicklas 63       {
6023 26 Oct 20 nicklas 64         itemLists.add(template.getItemList().get(dc));
6023 26 Oct 20 nicklas 65       }
6023 26 Oct 20 nicklas 66     }
6023 26 Oct 20 nicklas 67     for (RawBioAssay raw : rawBioAssays)
6023 26 Oct 20 nicklas 68     {
6023 26 Oct 20 nicklas 69       Annotationtype.AUTO_PROCESSING.setAnnotationValue(dc, raw, "ReProcess");
6023 26 Oct 20 nicklas 70       for (ItemList list : itemLists)
6023 26 Oct 20 nicklas 71       {
6023 26 Oct 20 nicklas 72         list.add(raw);
6023 26 Oct 20 nicklas 73       }
6023 26 Oct 20 nicklas 74     }
6023 26 Oct 20 nicklas 75
3051 17 Dec 14 nicklas 76     return false; // No next step
3051 17 Dec 14 nicklas 77   }
3051 17 Dec 14 nicklas 78
3055 19 Dec 14 nicklas 79   /**
3055 19 Dec 14 nicklas 80     Nothing to do.
3055 19 Dec 14 nicklas 81   */
3055 19 Dec 14 nicklas 82   @Override
3055 19 Dec 14 nicklas 83   public boolean startNextStep(SessionControl sc, AutoConfirmManager manager) 
3055 19 Dec 14 nicklas 84   {
3055 19 Dec 14 nicklas 85     return false;
3055 19 Dec 14 nicklas 86   }
3051 17 Dec 14 nicklas 87
3051 17 Dec 14 nicklas 88 }