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 |
Auto-confirm implementation for raw bioassays after generating gene/pilot/scan-b report. |
3051 |
17 Dec 14 |
nicklas |
This auto-confirmer is needed to handle the case when the gene report |
6023 |
26 Oct 20 |
nicklas |
plug-in fails to create the report. |
3051 |
17 Dec 14 |
nicklas |
18 |
|
6023 |
26 Oct 20 |
nicklas |
If the auto-confirmer finds a failed job, it will set the {@link Annotationtype#AUTO_PROCESSING} |
6023 |
26 Oct 20 |
nicklas |
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 |
@author nicklas |
3051 |
17 Dec 14 |
nicklas |
@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 |
Jobs that has failed passes so that we can flag raw bioassay with ReProcess |
3055 |
19 Dec 14 |
nicklas |
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 |
// 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 |
Set AutoProcessing to ReProcess on the raw bioassays and add |
6023 |
26 Oct 20 |
nicklas |
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 |
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 |
} |