@@ -110,6 +110,51 @@ public CWLService(RDFService rdfService,
110
110
this .singleFileSizeLimit = singleFileSizeLimit ;
111
111
}
112
112
113
+ /**
114
+ * Gets whether a file is packed using schema salad
115
+ * @param workflowFile The file to be parsed
116
+ * @return Whether the file is packed
117
+ */
118
+ public boolean isPacked (File workflowFile ) throws IOException {
119
+ if (workflowFile .length () > singleFileSizeLimit ) {
120
+ return false ;
121
+ }
122
+ String fileContent = readFileToString (workflowFile );
123
+ return fileContent .contains ("$graph" );
124
+ }
125
+
126
+ /**
127
+ * Gets a list of workflows from a packed CWL file
128
+ * @param packedFile The packed CWL file
129
+ * @return The list of workflow overviews
130
+ */
131
+ public List <WorkflowOverview > getWorkflowOverviewsFromPacked (File packedFile ) throws IOException {
132
+ if (packedFile .length () <= singleFileSizeLimit ) {
133
+ List <WorkflowOverview > overviews = new ArrayList <>();
134
+
135
+ JsonNode packedJson = yamlStringToJson (readFileToString (packedFile ));
136
+
137
+ if (packedJson .has (DOC_GRAPH )) {
138
+ for (JsonNode jsonNode : packedJson .get (DOC_GRAPH )) {
139
+ if (extractProcess (jsonNode ) == CWLProcess .WORKFLOW ) {
140
+ WorkflowOverview overview = new WorkflowOverview (jsonNode .get (ID ).asText (),
141
+ extractLabel (jsonNode ), extractDoc (jsonNode ));
142
+ overviews .add (overview );
143
+ }
144
+ }
145
+ } else {
146
+ throw new IOException ("The file given was not recognised as a packed CWL file" );
147
+ }
148
+
149
+ return overviews ;
150
+
151
+ } else {
152
+ throw new IOException ("File '" + packedFile .getName () + "' is over singleFileSizeLimit - " +
153
+ FileUtils .byteCountToDisplaySize (packedFile .length ()) + "/" +
154
+ FileUtils .byteCountToDisplaySize (singleFileSizeLimit ));
155
+ }
156
+ }
157
+
113
158
/**
114
159
* Gets the Workflow object from internal parsing
115
160
* @param workflowFile The workflow file to be parsed
0 commit comments