Skip to content

Commit 770171e

Browse files
author
Mark Robinson
committed
Add conformsTo information for CWL files
1 parent 3864445 commit 770171e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/java/org/commonwl/viewer/domain/ROBundle.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public class ROBundle {
5757
private GithubDetails githubInfo;
5858
private String commitSha;
5959

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+
6064
/**
6165
* Creates a new research object bundle for a workflow from a Github repository
6266
* @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,
145149
// Add the files in the subdirectory to this new folder
146150
addFiles(subdirectory, subdirPath, manifest);
147151

148-
// Otherwise this is a file so add to the bundle
152+
// Otherwise this is a file so add to the bundle
149153
} else if (repoContent.getType().equals("file")) {
150154

151155
// Get the content of this file from Github
@@ -165,6 +169,13 @@ private void addFiles(List<RepositoryContents> repoContents, Path path,
165169
if (FilenameUtils.getExtension(repoContent.getName()).equals("cwl")) {
166170
// Correct mime type (no official standard for yaml)
167171
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+
}
168179
}
169180

170181
// Set retrievedFrom information for this file in the manifest

0 commit comments

Comments
 (0)