Пример #1
0
  /**
   * Write configuration resource to file.
   *
   * @param configurationResource the configuration resource
   * @param file the file
   * @param outputLocation the output location
   * @return the file
   * @throws IOException Signals that an I/O exception has occurred.
   */
  public static File writeConfigurationResourceToFile(
      ConfigurationResource configurationResource, File file, File outputLocation)
      throws IOException {
    String longName = configurationResource.getBundleFile().getFilename();
    if (file == null) {
      file = new File(outputLocation, longName.substring(longName.lastIndexOf("/") + 1));
    }
    System.out.println("   >> Made : " + file.getAbsolutePath());

    return DataUtils.extractToFile(configurationResource, file);
  }
Пример #2
0
  /**
   * Creates the configuration.
   *
   * @param list the list
   * @return the mapping
   */
  public Mapping createConfiguration(List list) {
    if (list.size() > 0) {

      int inputObjectNo = 0;
      Mapping config = new DataMapping();

      for (ReferableResource referableResource :
          concreteBundle.getPrimaryConcreteTask().getSignature().getPorts()) {
        if (referableResource instanceof InputPort) {
          ConfigurationResource configurationResource =
              new ConfigurationResource(referableResource);
          // TODO serialize

          Object inputObject = list.get(inputObjectNo);

          if (inputObject instanceof File) {
            try {
              configurationResource.setRefType(ConfigurationResource.RefTypes.FILE_REF);
              BundleFile bf = DataUtils.createBundleFile((File) inputObject, config.getId() + "/");
              bf.setType(BundleFile.FileType.DATA_FILE);
              config.getBundleFiles().add(bf);
              configurationResource.setBundleFile(bf);
            } catch (SHIWADesktopIOException e) {
              e.printStackTrace();
            }
          } else {
            configurationResource.setValue(inputObject.toString());
            configurationResource.setRefType(ConfigurationResource.RefTypes.INLINE_REF);
          }
          inputObjectNo++;
          config.addResourceRef(configurationResource);
        }
      }
      getWorkflowImplementation().getAggregatedResources().add(config);
      return config;
    }
    return null;
  }
Пример #3
0
 /**
  * Bundle.
  *
  * @param temp the temp
  * @throws SHIWADesktopIOException the sHIWA desktop io exception
  */
 public void bundle(File temp) throws SHIWADesktopIOException {
   DataUtils.bundle(temp, getWorkflowImplementation());
 }
Пример #4
0
 /**
  * Save bundle.
  *
  * @param file the file
  * @return the file
  * @throws SHIWADesktopIOException the sHIWA desktop io exception
  */
 public File saveBundle(File file) throws SHIWADesktopIOException {
   return DataUtils.bundle(file, concreteBundle.getAggregatedResource());
 }
Пример #5
0
 /**
  * Extract to file.
  *
  * @param relativePath the relative path
  * @param file the file
  * @return the file
  * @throws IOException Signals that an I/O exception has occurred.
  */
 public File extractToFile(String relativePath, File file) throws IOException {
   return DataUtils.inputStreamToFile(concreteBundle.getEntry(relativePath), file);
 }
Пример #6
0
 /**
  * Gets the temp entry.
  *
  * @param relativePath the relative path
  * @return the temp entry
  * @throws IOException Signals that an I/O exception has occurred.
  */
 public File getTempEntry(String relativePath) throws IOException {
   return DataUtils.inputStreamToFile(
       concreteBundle.getEntry(relativePath),
       Locations.getTempFile(relativePath.replaceAll("/", ".")));
 }