Beispiel #1
0
 /**
  * Gets the task signature.
  *
  * @param inputPortMap the input port map
  * @param outputPortMap the output port map
  * @return the task signature
  */
 public void getTaskSignature(
     HashMap<String, InputPort> inputPortMap, HashMap<String, OutputPort> outputPortMap) {
   TaskSignature signature = concreteBundle.getPrimaryConcreteTask().getSignature();
   for (ReferableResource referableResource : signature.getPorts()) {
     if (referableResource instanceof InputPort) {
       InputPort inputPort = (InputPort) referableResource;
       //                Class dataClass = XSDDataType.getClass(inputPort.getDataType());
       //                if (dataClass != null) {
       //                    inputDataTypes.add(dataClass.getCanonicalName());
       //                }
       inputPortMap.put(referableResource.getTitle(), inputPort);
     }
     if (referableResource instanceof OutputPort) {
       OutputPort outputPort = (OutputPort) referableResource;
       //                Class dataClass = XSDDataType.getClass(outputPort.getDataType());
       //                if (dataClass != null) {
       //                    outputDataTypes.add(dataClass.getCanonicalName());
       //                }
       outputPortMap.put(referableResource.getTitle(), outputPort);
     }
   }
 }
Beispiel #2
0
  /**
   * 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;
  }