예제 #1
0
 /**
  * Gets the dependency for type.
  *
  * @param type the type
  * @return the dependency for type
  */
 public ArrayList<Dependency> getDependencyForType(String type) {
   ArrayList<Dependency> dependencies = new ArrayList<Dependency>();
   for (Dependency dependency : concreteBundle.getPrimaryConcreteTask().getDependencies()) {
     if (dependency.getDataType().equals(type)) {
       dependencies.add(dependency);
     }
   }
   return dependencies;
 }
예제 #2
0
  /**
   * Write config resources to disk.
   *
   * @param dependency the dependency
   * @param config the config
   * @param outputLocation the output location
   * @throws IOException Signals that an I/O exception has occurred.
   */
  public static void writeConfigResourcesToDisk(
      Dependency dependency, List<ConfigurationResource> config, File outputLocation)
      throws IOException {
    String value = null;
    TransferSignature.ValueType valueType = null;
    for (ConfigurationResource portRef : config) {
      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, outputLocation);
          value = tempFile.getAbsolutePath();
        }
      }
    }
  }
예제 #3
0
 /**
  * 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;
 }