22
22
import io .seqware .common .model .ProcessingStatus ;
23
23
import io .seqware .common .model .SequencerRunStatus ;
24
24
import io .seqware .common .model .WorkflowRunStatus ;
25
+ import io .seqware .pipeline .SqwKeys ;
25
26
import java .io .Writer ;
26
27
import java .sql .SQLException ;
27
28
import java .util .ArrayList ;
43
44
import net .sourceforge .seqware .common .model .File ;
44
45
import net .sourceforge .seqware .common .model .FileAttribute ;
45
46
import net .sourceforge .seqware .common .model .FileProvenanceParam ;
47
+ import net .sourceforge .seqware .common .model .FirstTierModel ;
46
48
import net .sourceforge .seqware .common .model .IUS ;
47
49
import net .sourceforge .seqware .common .model .IUSAttribute ;
48
50
import net .sourceforge .seqware .common .model .Lane ;
69
71
import net .sourceforge .seqware .common .model .WorkflowRunAttribute ;
70
72
import net .sourceforge .seqware .common .module .ReturnValue ;
71
73
import net .sourceforge .seqware .common .util .Log ;
74
+ import net .sourceforge .seqware .common .util .configtools .ConfigTools ;
72
75
73
76
/**
74
77
* This stores some metadata in memory as an exploration of running workflows without a running database or web service.
@@ -82,14 +85,14 @@ public class MetadataInMemory implements Metadata {
82
85
/**
83
86
* Stores SWID/id -> Model object. Unlike the postgres database, we re-use the sw accession as the id
84
87
*/
85
- private static final Table <Integer , Class , Object > STORE = HashBasedTable .create ();
88
+ private static final Table <Integer , Class <?> , Object > STORE = HashBasedTable .create ();
86
89
87
90
/**
88
91
* Not really thread-safe, why does Guava not have a synchronized wrapper?
89
92
*
90
93
* @return the store
91
94
*/
92
- private static synchronized Table <Integer , Class , Object > getStore () {
95
+ private static synchronized Table <Integer , Class <?> , Object > getStore () {
93
96
return STORE ;
94
97
}
95
98
@@ -230,6 +233,7 @@ public int add_workflow_run(int workflowAccession) {
230
233
wr .setWorkflowRunId (wr .getSwAccession ());
231
234
wr .setCreateTimestamp (new Date ());
232
235
wr .setUpdateTimestamp (new Date ());
236
+ wr .setOwnerUserName (ConfigTools .getSettings ().get (SqwKeys .SW_REST_USER .getSettingKey ()));
233
237
Workflow workflow = (Workflow ) MetadataInMemory .getStore ().get (workflowAccession , Workflow .class );
234
238
wr .setWorkflow (workflow );
235
239
MetadataInMemory .getStore ().put (wr .getSwAccession (), WorkflowRun .class , wr );
@@ -334,11 +338,27 @@ public ReturnValue addWorkflow(String name, String version, String description,
334
338
return returnValue ;
335
339
}
336
340
341
+ private synchronized int getCurrentSwAccession () {
342
+ int currKey = MetadataInMemory .getStore ().rowKeySet ().size ();
343
+ return currKey ;
344
+ }
345
+
337
346
private synchronized int getNextSwAccession () {
338
347
int nextKey = MetadataInMemory .getStore ().rowKeySet ().size () + 1 ;
339
348
return nextKey ;
340
349
}
341
350
351
+ public void loadEntity (FirstTierModel model ) {
352
+ // populate store up to the desiredkey
353
+ int currSWID = getCurrentSwAccession ();
354
+ while (currSWID < model .getSwAccession ()) {
355
+ int swid = getNextSwAccession ();
356
+ MetadataInMemory .getStore ().put (swid , Integer .class , swid );
357
+ currSWID = getCurrentSwAccession ();
358
+ }
359
+ MetadataInMemory .getStore ().put (model .getSwAccession (), model .getClass (), model );
360
+ }
361
+
342
362
@ Override
343
363
public ReturnValue updateWorkflow (int workflowId , String permanentBundleLocation ) {
344
364
throw new UnsupportedOperationException ("Not supported yet." );
@@ -520,12 +540,14 @@ public String getWorkflowRunReport(int workflowRunSWID) {
520
540
521
541
@ Override
522
542
public String getWorkflowRunReportStdErr (int workflowRunSWID ) {
523
- throw new UnsupportedOperationException ("Not supported yet." );
543
+ WorkflowRun wr = (WorkflowRun ) MetadataInMemory .getStore ().get (workflowRunSWID , WorkflowRun .class );
544
+ return wr .getStdErr () == null ? "" : wr .getStdErr ();
524
545
}
525
546
526
547
@ Override
527
548
public String getWorkflowRunReportStdOut (int workflowRunSWID ) {
528
- throw new UnsupportedOperationException ("Not supported yet." );
549
+ WorkflowRun wr = (WorkflowRun ) MetadataInMemory .getStore ().get (workflowRunSWID , WorkflowRun .class );
550
+ return wr .getStdOut () == null ? "" : wr .getStdOut ();
529
551
}
530
552
531
553
@ Override
0 commit comments