6025 |
26 Oct 20 |
nicklas |
1 |
package net.sf.basedb.reggie.autoconfirm; |
6025 |
26 Oct 20 |
nicklas |
2 |
|
6025 |
26 Oct 20 |
nicklas |
3 |
import java.util.HashMap; |
6025 |
26 Oct 20 |
nicklas |
4 |
import java.util.List; |
6025 |
26 Oct 20 |
nicklas |
5 |
import java.util.Map; |
6025 |
26 Oct 20 |
nicklas |
6 |
|
6025 |
26 Oct 20 |
nicklas |
7 |
import net.sf.basedb.core.DbControl; |
6025 |
26 Oct 20 |
nicklas |
8 |
import net.sf.basedb.core.ItemList; |
6025 |
26 Oct 20 |
nicklas |
9 |
import net.sf.basedb.core.Job; |
6025 |
26 Oct 20 |
nicklas |
10 |
import net.sf.basedb.core.RawBioAssay; |
6025 |
26 Oct 20 |
nicklas |
11 |
import net.sf.basedb.core.SessionControl; |
6025 |
26 Oct 20 |
nicklas |
12 |
import net.sf.basedb.core.Software; |
6025 |
26 Oct 20 |
nicklas |
13 |
import net.sf.basedb.reggie.dao.Annotationtype; |
6025 |
26 Oct 20 |
nicklas |
14 |
import net.sf.basedb.reggie.dao.BiomaterialList; |
6025 |
26 Oct 20 |
nicklas |
15 |
import net.sf.basedb.reggie.dao.Subtype; |
6025 |
26 Oct 20 |
nicklas |
16 |
import net.sf.basedb.reggie.plugins.GeneReportPlugin; |
6025 |
26 Oct 20 |
nicklas |
17 |
|
6025 |
26 Oct 20 |
nicklas |
18 |
/** |
6025 |
26 Oct 20 |
nicklas |
Auto-confirm implementation for raw bioassays after running SSP analysis plug-in. |
6025 |
26 Oct 20 |
nicklas |
If the calculations succeeded the rawbioassays are scheduled for SCAN-B report |
6025 |
26 Oct 20 |
nicklas |
generation. In case of a failure, the raw bioassays are marked for re-processing |
6025 |
26 Oct 20 |
nicklas |
and added to the SSP list. |
6025 |
26 Oct 20 |
nicklas |
23 |
|
6025 |
26 Oct 20 |
nicklas |
@author nicklas |
6025 |
26 Oct 20 |
nicklas |
@since 4.28 |
6025 |
26 Oct 20 |
nicklas |
26 |
*/ |
6025 |
26 Oct 20 |
nicklas |
27 |
public class SspAutoConfirmer |
6025 |
26 Oct 20 |
nicklas |
28 |
extends AutoConfirmer<Job> |
6025 |
26 Oct 20 |
nicklas |
29 |
{ |
6025 |
26 Oct 20 |
nicklas |
30 |
public SspAutoConfirmer(Job job) |
6025 |
26 Oct 20 |
nicklas |
31 |
{ |
6025 |
26 Oct 20 |
nicklas |
32 |
super(job, job); |
6025 |
26 Oct 20 |
nicklas |
33 |
} |
6025 |
26 Oct 20 |
nicklas |
34 |
|
6025 |
26 Oct 20 |
nicklas |
35 |
/** |
6025 |
26 Oct 20 |
nicklas |
Always TRUE. |
6025 |
26 Oct 20 |
nicklas |
37 |
*/ |
6025 |
26 Oct 20 |
nicklas |
38 |
@Override |
6025 |
26 Oct 20 |
nicklas |
39 |
public boolean checkRules(DbControl dc, AutoConfirmManager manager) |
6025 |
26 Oct 20 |
nicklas |
40 |
{ |
6025 |
26 Oct 20 |
nicklas |
41 |
return true; |
6025 |
26 Oct 20 |
nicklas |
42 |
} |
6025 |
26 Oct 20 |
nicklas |
43 |
|
6025 |
26 Oct 20 |
nicklas |
44 |
/** |
6025 |
26 Oct 20 |
nicklas |
Set AutoProcessing to ReProcess on the raw bioassays and add |
6025 |
26 Oct 20 |
nicklas |
them to the correct item list for reporting. |
6025 |
26 Oct 20 |
nicklas |
47 |
*/ |
6025 |
26 Oct 20 |
nicklas |
48 |
@Override |
6025 |
26 Oct 20 |
nicklas |
49 |
public boolean autoConfirm(DbControl dc, AutoConfirmManager manager) |
6025 |
26 Oct 20 |
nicklas |
50 |
{ |
6025 |
26 Oct 20 |
nicklas |
51 |
Job job = job(dc); |
6025 |
26 Oct 20 |
nicklas |
52 |
List<RawBioAssay> rawBioAssays = job.getParameterValues("rawBioAssays"); |
6025 |
26 Oct 20 |
nicklas |
53 |
|
6025 |
26 Oct 20 |
nicklas |
54 |
if (job.getStatus() == Job.Status.ERROR) |
6025 |
26 Oct 20 |
nicklas |
55 |
{ |
6025 |
26 Oct 20 |
nicklas |
56 |
ItemList sspList = BiomaterialList.SSP_PIPELINE.get(dc); |
6025 |
26 Oct 20 |
nicklas |
57 |
for (RawBioAssay raw : rawBioAssays) |
6025 |
26 Oct 20 |
nicklas |
58 |
{ |
6025 |
26 Oct 20 |
nicklas |
59 |
Annotationtype.AUTO_PROCESSING.setAnnotationValue(dc, raw, "ReProcess"); |
6025 |
26 Oct 20 |
nicklas |
60 |
sspList.add(raw); |
6025 |
26 Oct 20 |
nicklas |
61 |
} |
6025 |
26 Oct 20 |
nicklas |
62 |
return false; // No next step |
6025 |
26 Oct 20 |
nicklas |
63 |
} |
6025 |
26 Oct 20 |
nicklas |
64 |
|
6025 |
26 Oct 20 |
nicklas |
65 |
ItemList scanbReportList = BiomaterialList.SCANB_REPORT_CREATE.get(dc); |
6025 |
26 Oct 20 |
nicklas |
66 |
scanbReportList.add(rawBioAssays.iterator()); |
6025 |
26 Oct 20 |
nicklas |
67 |
|
6025 |
26 Oct 20 |
nicklas |
68 |
return true; |
6025 |
26 Oct 20 |
nicklas |
69 |
} |
6025 |
26 Oct 20 |
nicklas |
70 |
|
6025 |
26 Oct 20 |
nicklas |
71 |
/** |
6025 |
26 Oct 20 |
nicklas |
Create SCAN-B reports. |
6025 |
26 Oct 20 |
nicklas |
73 |
*/ |
6025 |
26 Oct 20 |
nicklas |
74 |
@Override |
6025 |
26 Oct 20 |
nicklas |
75 |
public boolean startNextStep(SessionControl sc, AutoConfirmManager manager) |
6025 |
26 Oct 20 |
nicklas |
76 |
{ |
6025 |
26 Oct 20 |
nicklas |
77 |
DbControl dc = null; |
6025 |
26 Oct 20 |
nicklas |
78 |
try |
6025 |
26 Oct 20 |
nicklas |
79 |
{ |
6599 |
22 Feb 22 |
nicklas |
80 |
dc = sc.newDbControl("Reggie: Auto-confirm SSP - start report"); |
6025 |
26 Oct 20 |
nicklas |
81 |
Job job = job(dc); |
6025 |
26 Oct 20 |
nicklas |
82 |
|
6025 |
26 Oct 20 |
nicklas |
// Pipelines for further processing |
6025 |
26 Oct 20 |
nicklas |
84 |
ItemList scanbReportList = BiomaterialList.SCANB_REPORT_CREATE.load(dc); |
6025 |
26 Oct 20 |
nicklas |
85 |
boolean scanbReportpDisabled = "Disable".equals(Annotationtype.AUTO_PROCESSING.getAnnotationValue(dc, scanbReportList)); |
6025 |
26 Oct 20 |
nicklas |
86 |
|
6025 |
26 Oct 20 |
nicklas |
87 |
if (scanbReportpDisabled) return false; |
6025 |
26 Oct 20 |
nicklas |
88 |
|
6025 |
26 Oct 20 |
nicklas |
89 |
List<RawBioAssay> rawBioAssays = job.getParameterValues("rawBioAssays"); |
6025 |
26 Oct 20 |
nicklas |
90 |
Map<String, Software> reports = new HashMap<String, Software>(); |
6025 |
26 Oct 20 |
nicklas |
91 |
Software scanbReport = Subtype.REPORT_SOFTWARE.getLatestProjectDefault(dc, Annotationtype.REPORT_TEMPLATE.createFilter("SCANB_REPORT")); |
6025 |
26 Oct 20 |
nicklas |
92 |
if (!scanbReportpDisabled) reports.put("SCANB_REPORT", scanbReport); |
6025 |
26 Oct 20 |
nicklas |
93 |
|
6025 |
26 Oct 20 |
nicklas |
94 |
GeneReportPlugin.createReportJob(dc, rawBioAssays, reports, true); |
6025 |
26 Oct 20 |
nicklas |
95 |
dc.commit(); |
6025 |
26 Oct 20 |
nicklas |
96 |
} |
6025 |
26 Oct 20 |
nicklas |
97 |
finally |
6025 |
26 Oct 20 |
nicklas |
98 |
{ |
6025 |
26 Oct 20 |
nicklas |
99 |
if (dc != null) dc.close(); |
6025 |
26 Oct 20 |
nicklas |
100 |
} |
6025 |
26 Oct 20 |
nicklas |
101 |
return true; |
6025 |
26 Oct 20 |
nicklas |
102 |
|
6025 |
26 Oct 20 |
nicklas |
103 |
} |
6025 |
26 Oct 20 |
nicklas |
104 |
|
6025 |
26 Oct 20 |
nicklas |
105 |
} |