private void reportOnWorkflow( String workflowAccession, WorkflowRunStatus status, Date earlyDate, Date lateDate) throws IOException { String title = ""; if (workflowAccession != null) { title = "workflow_" + workflowAccession; } if (status != null) { title += "status_" + status.name(); } if (earlyDate != null) { title += "from" + dateFormat.format(earlyDate); } if (lateDate != null) { title += "to" + dateFormat.format(lateDate); } initWriter(title); String report; try { Integer workflowParameter = null; if (workflowAccession != null) { workflowParameter = Integer.parseInt(workflowAccession); } report = metadata.getWorkflowRunReport(workflowParameter, status, earlyDate, lateDate); } catch (RuntimeException e) { Log.fatal("Workflow not found", e); ret = new ReturnValue(ReturnValue.INVALIDPARAMETERS); return; } if (options.has("human")) { writer.write(TabExpansionUtil.expansion(report)); return; } writer.write(report); }
/** Constructor for WorkflowRunReporter. */ public WorkflowRunReporter() { super(); parser .acceptsAll(Arrays.asList("workflow-run-accession", "wra"), "The SWID of the workflow run") .withRequiredArg(); parser .acceptsAll( Arrays.asList("workflow-accession", "wa"), "The SWID of " + "a workflow. All the workflow runs for that workflow will be " + "retrieved.") .withRequiredArg(); parser .acceptsAll( Arrays.asList("time-period", "t"), "Dates to check for " + "workflow runs. Dates are in format YYYY-MM-DD. If one date is " + "provided, from that point to the present is checked. If two, " + "separated by hyphen YYYY-MM-DDL:YYYY-MM-DD then it checks " + "that range") .withRequiredArg(); parser .acceptsAll(Arrays.asList("output-filename", "o"), "Optional: The output filename") .withRequiredArg(); parser.acceptsAll(Arrays.asList("stdout"), "Prints to standard out instead of to a file"); parser.acceptsAll( Arrays.asList(WRSTDOUT), "Optional: will print the stdout of the workflow run, must specify the --workflow-run-accession"); parser.acceptsAll( Arrays.asList(WRSTDERR), "Optional: will print the stderr of the workflow run, must specify the --workflow-run-accession"); this.statusSpec = parser .accepts( "status", "Optional: Specify a particular status to restrict workflow runs that will be returned, status is one of " + Arrays.toString(WorkflowRunStatus.values())) .withRequiredArg() .ofType(WorkflowRunStatus.class); parser.acceptsAll( Arrays.asList("human"), "Optional: will print output in expanded human friendly format"); ret.setExitStatus(ReturnValue.SUCCESS); }