@@ -57,6 +57,10 @@ public class ROBundle {
57
57
private GithubDetails githubInfo ;
58
58
private String commitSha ;
59
59
60
+ // Pattern for extracting version from a cwl file
61
+ private final String CWL_VERSION_REGEX = "cwlVersion:\\ s*\" ?(?:cwl:)?([^\\ s\" ]+)\" ?" ;
62
+ private final Pattern cwlVersionPattern = Pattern .compile (CWL_VERSION_REGEX );
63
+
60
64
/**
61
65
* Creates a new research object bundle for a workflow from a Github repository
62
66
* @param githubInfo The information necessary to access the Github directory associated with the RO
@@ -145,7 +149,7 @@ private void addFiles(List<RepositoryContents> repoContents, Path path,
145
149
// Add the files in the subdirectory to this new folder
146
150
addFiles (subdirectory , subdirPath , manifest );
147
151
148
- // Otherwise this is a file so add to the bundle
152
+ // Otherwise this is a file so add to the bundle
149
153
} else if (repoContent .getType ().equals ("file" )) {
150
154
151
155
// Get the content of this file from Github
@@ -165,6 +169,13 @@ private void addFiles(List<RepositoryContents> repoContents, Path path,
165
169
if (FilenameUtils .getExtension (repoContent .getName ()).equals ("cwl" )) {
166
170
// Correct mime type (no official standard for yaml)
167
171
aggregation .setMediatype ("text/x-yaml" );
172
+
173
+ // Add conformsTo for version extracted from regex
174
+ // Lower overhead vs parsing entire file
175
+ Matcher m = cwlVersionPattern .matcher (fileContent );
176
+ if (m .find ()) {
177
+ aggregation .setConformsTo (new URI ("https://w3id.org/cwl/" + m .group (1 )));
178
+ }
168
179
}
169
180
170
181
// Set retrievedFrom information for this file in the manifest
0 commit comments