private GlobalContext globalContext;
public ExpBldrWorkflow getWorkflowFromRegistry(String workflowTemplateName, ApplicationGlobalContext context){
Workflow xBayaWorkflow = null;
ExpBldrWorkflow expBldrWorkflow = new ExpBldrWorkflow();
GSSCredential cred = null;
try {
FileInputStream fis = new FileInputStream(context.getProperties().getProperty("ssl.hostcertsKeyFile"));
GlobusCredential globusCred = new GlobusCredential(fis);
cred = new GlobusGSSCredentialImpl(globusCred, GSSCredential.INITIATE_AND_ACCEPT);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ODEClient xbayaRegistryClient = new ODEClient();
// if (workflowTemplateName.startsWith("http://extreme.indiana.edu/lead/workflow/")){
// QName workflowQName = new QName(workflowTemplateName);
// xBayaWorkflow = xbayaRegistryClient.getWorkflow(URI.create(xRegistryUrl), credential, workflowQName);
// } else {
// xBayaWorkflow = xbayaRegistryClient.getWorkflow(URI.create(xRegistryUrl), credential, workflowTemplateName);
// }
if (workflowTemplateName.startsWith("http://extreme.indiana.edu/lead/workflow/")){
String[] tokens = workflowTemplateName.split("/");
workflowTemplateName = tokens[tokens.length - 1];
}
//Fetch the required elements and load into to lighter experiment builder workflow model
try {
xBayaWorkflow = xbayaRegistryClient.getWorkflow(URI.create(context.getXRegistryUrl()), cred, workflowTemplateName);
if (xBayaWorkflow != null){
expBldrWorkflow.setId(xBayaWorkflow.getUniqueWorkflowName().toString());
expBldrWorkflow.setName(xBayaWorkflow.getName());
expBldrWorkflow.setDescription(xBayaWorkflow.getDescription());
expBldrWorkflow.setWorkflowImage(xBayaWorkflow.getImage());
// for (WSComponentPort wsComponentPort : inputs) {
// wsComponentPort.setDefaultValue("<whateverxml/>");
// wsComponentPort.getDescription();
// }
// Fetch All Workflow Inputs
List<WSComponentPort> workflowInputs = xbayaRegistryClient.getInputs(xBayaWorkflow);
LinkedList<Pair<WSComponentPort, String>> workflowInputExtensionPairs = new LinkedList<Pair<WSComponentPort, String>>();
//Iterate through all inputs and determine extensions and stuff them into experiment builder workflow object
for (WSComponentPort workflowInput : workflowInputs) {
String inputExtension = null;
if (workflowInput.getType().equals(ExperimentBuilderConstants.CROSSCUT_PARAMS_QNAME)) {
inputExtension = ExperimentBuilderConstants.EXT_GEO_SPATIAL_TEMPORAL;
} else if ((workflowInput.getType().getLocalPart().equals(ExperimentBuilderConstants.LEAD_FILE_ID_ARRAY_TYPE))) {
inputExtension = ExperimentBuilderConstants.EXT_LEAD_QM_DATASEARCH;
}
workflowInputExtensionPairs.add(new Pair<WSComponentPort, String>(workflowInput,inputExtension));
}
expBldrWorkflow.setWorkflowInputExtensionPairs(workflowInputExtensionPairs);
}
} catch (Exception e) {
log.error("Error Loading Workflow Object", e);
}