use of ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowLoadException in project irida by phac-nml.
the class IridaWorkflowLoaderService method loadWorkflowDescription.
/**
* Loads up the workflow description from the given file.
*
* @param descriptionFile
* The file to load up a workflow description.
* @return An IridaWorkflowDescription object.
* @throws IOException
* If there was an issue reading the passed file.
* @throws IridaWorkflowLoadException
* If there was an issue loading up the workflow description.
*/
public IridaWorkflowDescription loadWorkflowDescription(Path descriptionFile) throws IOException, IridaWorkflowLoadException {
checkNotNull(descriptionFile, "descriptionFile is null");
if (!Files.exists(descriptionFile)) {
throw new FileNotFoundException(descriptionFile.toAbsolutePath().toString());
}
Source source = new StreamSource(Files.newInputStream(descriptionFile));
IridaWorkflowDescription workflowDescription = (IridaWorkflowDescription) workflowDescriptionUnmarshaller.unmarshal(source);
if (workflowDescription.getId() == null) {
throw new IridaWorkflowLoadException("No id for workflow description from file " + descriptionFile);
} else if (workflowDescription.getAnalysisType() == null) {
throw new IridaWorkflowLoadException("Invalid analysisType for workflow description from file " + descriptionFile);
} else {
if (workflowDescription.acceptsParameters()) {
for (IridaWorkflowParameter workflowParameter : workflowDescription.getParameters()) {
if (workflowParameter.getDefaultValue() == null && !workflowParameter.isRequired()) {
throw new IridaWorkflowLoadException("Parameters with no default value must set the \"required\" attribute to \"true\"." + descriptionFile);
}
if (workflowParameter.hasDynamicSource() && !workflowParameter.isRequired()) {
throw new IridaWorkflowLoadException("Parameters loaded from Dynamic Sources must set the \"required\" attribute to \"true\"." + descriptionFile);
}
if (workflowParameter.isRequired() && workflowParameter.getDefaultValue() != null) {
throw new IridaWorkflowLoadException("Required parameters should not have a default value." + descriptionFile);
}
try {
workflowParameter.getDynamicSource();
} catch (IridaWorkflowParameterException e) {
throw new IridaWorkflowLoadException("Parameters may have no more than one Dynamic Source." + descriptionFile);
}
}
}
return workflowDescription;
}
}
Aggregations