/** * Gets the outputs. * * @param bundle the bundle * @return the outputs */ public static HashMap<String, ConfigurationResource> getOutputs(File bundle) { HashMap<String, ConfigurationResource> results = new HashMap<String, ConfigurationResource>(); try { // SHIWABundle shiwaBundle = new SHIWABundle(bundle); ConcreteBundle concreteBundle = new ConcreteBundle(bundle); // WorkflowController workflowController = new WorkflowController(shiwaBundle); for (Mapping configuration : concreteBundle.getPrimaryMappings()) { System.out.println("Config type : " + configuration.getClass().getCanonicalName()); if (configuration instanceof ExecutionMapping) { System.out.println("Received bundle has an exec config"); System.out.println( configuration.getAggregatedResources().size() + " aggregated resources"); System.out.println( "Exec config contains " + configuration.getResources().size() + " resources."); for (ConfigurationResource r : configuration.getResources()) { results.put(r.getReferableResource().getTitle(), r); } System.out.println(results.size() + " outputs found."); return results; } } } catch (SHIWADesktopIOException e) { System.out.println("Returned bundle was corrupt or null."); ErrorTracker.getErrorTracker() .broadcastError(new ErrorEvent(null, e, "Returned Bundle was corrupt or null")); } return null; }
/** * Gets the configuration resource for dependency. * * @param dependency the dependency * @return the configuration resource for dependency */ public ConfigurationResource getConfigurationResourceForDependency(Dependency dependency) { for (Mapping mapping : concreteBundle.getPrimaryMappings()) { for (ConfigurationResource configurationResource : mapping.getResources()) { if (dependency.getId().equals(configurationResource.getId())) { return configurationResource; } } } return null; }
/** * Creates the transfer signature. * * @param workflow the workflow * @param configuration the configuration * @return the transfer signature * @throws IOException Signals that an I/O exception has occurred. */ public TransferSignature createTransferSignature(ConcreteTask workflow, Mapping configuration) throws IOException { TransferSignature signature = new TransferSignature(); signature.setName(workflow.getDefinition().getFilename()); if (workflow.getLanguage() != null) { signature.setLanguage(workflow.getLanguage().toString()); } for (ReferableResource referableResource : workflow.getSignature().getPorts()) { if (referableResource instanceof InputPort) { String value = null; boolean isReference = false; if (configuration != null) { for (ConfigurationResource portRef : configuration.getResources()) { System.out.println( portRef.getReferableResource().getId() + " " + referableResource.getId()); if (portRef.getReferableResource().getId().equals(referableResource.getId())) { value = portRef.getValue(); isReference = (portRef.getRefType() == ConfigurationResource.RefTypes.FILE_REF); } } } if (value != null) { if (isReference) { signature.addInputReference( referableResource.getTitle(), referableResource.getDataType(), value); } else { signature.addInput( referableResource.getTitle(), referableResource.getDataType(), value); } } else { signature.addInput(referableResource.getTitle(), referableResource.getDataType()); } } else if (referableResource instanceof OutputPort) { signature.addOutput(referableResource.getTitle(), referableResource.getDataType()); } } // for (Dependency dependency : workflow.getDependencies()) { // String value = null; // TransferSignature.ValueType valueType = null; // // if (configuration != null) { // for (ConfigurationResource portRef : // getFirstConfigurationOfType(Configuration.ConfigType.ENVIRONMENT_CONFIGURATION).getResources()) { // if (portRef.getReferableResource().getId().equals(dependency.getId())) { // value = portRef.getValue(); // // ConfigurationResource.RefTypes refType = portRef.getRefType(); // System.out.println("Value for " + portRef.getId() + " : " + value); // // if(refType == ConfigurationResource.RefTypes.INLINE_REF){ // valueType = TransferSignature.ValueType.INLINE_STRING; // // } else if (refType == ConfigurationResource.RefTypes.URI_REF){ // File success = download(value, new File("."), null); // if(success.exists()){ // System.out.println("Fetched " + value + " to " + // success.getAbsolutePath()); // value = success.getAbsolutePath(); // } else { // System.out.println("Failed to fetch " + value); // } // // valueType = TransferSignature.ValueType.INLINE_URI; // } else if (refType == ConfigurationResource.RefTypes.FILE_REF){ // valueType = TransferSignature.ValueType.BUNDLED_FILE; //// File tempFile = DataUtils.extractToTempFile(portRef); // File tempFile = writeConfigurationResourceToFile(portRef, null); // value = tempFile.getAbsolutePath(); // } // } // } // } // signature.addOutput(dependency.getTitle(), // dependency.getDataType(), // dependency.getDescription(), // value, // valueType // ); // } if (configuration != null) { signature.setHasConfiguration(true); } return signature; }