gpt4 book ai didi

org.apache.taverna.scufl2.api.io.WorkflowBundleIO.readBundle()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 09:29:05 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.taverna.scufl2.api.io.WorkflowBundleIO.readBundle()方法的一些代码示例,展示了WorkflowBundleIO.readBundle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkflowBundleIO.readBundle()方法的具体详情如下:
包路径:org.apache.taverna.scufl2.api.io.WorkflowBundleIO
类名称:WorkflowBundleIO
方法名:readBundle

WorkflowBundleIO.readBundle介绍

[英]Reads a file containing a workflow bundle in the specified media type and returns a WorkflowBundle.
[中]读取包含指定媒体类型的工作流包的文件,并返回WorkflowBundle

代码示例

代码示例来源:origin: org.apache.taverna.language/taverna-databundle

public static WorkflowBundle getWorkflowBundle(Bundle dataBundle)
    throws ReaderException, IOException {
  Path wf = getWorkflow(dataBundle);
  // String type = Files.probeContentType(wf);
  return getWfBundleIO().readBundle(newInputStream(wf), null);
}

代码示例来源:origin: org.apache.taverna.server/taverna-server-worker

@Override
public RemoteSingleRun make(byte[] workflow, String creator,
    UsageRecordReceiver urReceiver, UUID id) throws RemoteException {
  if (creator == null)
    throw new RemoteException("no creator");
  try {
    URI wfid = io.readBundle(new ByteArrayInputStream(workflow), null)
        .getMainWorkflow().getIdentifier();
    out.println("Creating run from workflow <" + wfid + "> for <"
        + creator + ">");
    return new LocalWorker(command, workflow, urReceiver, id,
        seedEnvironment, javaInitParams, this);
  } catch (RemoteException e) {
    throw e;
  } catch (Exception e) {
    throw new RemoteException("bad instance construction", e);
  }
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-api

return readBundle(url.openStream(), contentType);

代码示例来源:origin: org.apache.taverna.engine/taverna-run-impl

@Before
public void loadWf() throws ReaderException, IOException {
  wfBundle = workflowBundleIO.readBundle(getClass().getResource("/hello_anyone.wfbundle"), 
      "application/vnd.taverna.scufl2.workflow-bundle");
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-wfbundle

@Test
public void readStreamNoMediaType() throws ReaderException, IOException {
  workflowBundle = bundleIO.readBundle(getClass().getResourceAsStream(EXAMPLE_SCUFL2), null);
  assertNotNull(workflowBundle);
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-wfbundle

@Before
public void exampleBundle() throws ReaderException, IOException {
  String name = EXAMPLE_SCUFL2;
  exampleBundle = getClass().getResource(name);
  assertNotNull("Can't find example workflow bundle " + name,
      exampleBundle);
  workflowBundle = bundleIO.readBundle(exampleBundle,
      APPLICATION_VND_TAVERNA_SCUFL2_WORKFLOW_BUNDLE);
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-api

@Test
public void readToWriteRoundTrip() throws Exception {
  InputStream inputStream = new ByteArrayInputStream(
      getStructureFormatWorkflowBundle().getBytes("utf-8"));
  WorkflowBundle readBundle = bundleIO.readBundle(inputStream,
      TEXT_VND_TAVERNA_SCUFL2_STRUCTURE);
  ByteArrayOutputStream output = new ByteArrayOutputStream();
  bundleIO.writeBundle(readBundle, output, TEXT_VND_TAVERNA_SCUFL2_STRUCTURE);
  String bundleTxt = new String(output.toByteArray(), UTF_8);
      String getStructureFormatWorkflowBundle = getStructureFormatWorkflowBundle();
      bundleTxt = bundleTxt.replaceAll("\r", "").replaceAll("\n", "");
      getStructureFormatWorkflowBundle = getStructureFormatWorkflowBundle.replaceAll("\r", "").replaceAll("\n", "");
  assertEquals(getStructureFormatWorkflowBundle, bundleTxt);
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-api

@Test
public void readBundleFileNoMediaType() throws Exception {
  File bundleFile = tempFile();
  FileUtils.writeStringToFile(bundleFile,
      getStructureFormatWorkflowBundle(),
      UTF_8);
  WorkflowBundle wfBundle = bundleIO.readBundle(bundleFile,null);
  assertNotNull(wfBundle);
  File emptyFile = File.createTempFile("test", "txt");
  try {
    @SuppressWarnings("unused")
    WorkflowBundle none = bundleIO.readBundle(emptyFile,null);
    fail("Should throw IllegalArgumentException for unrecognized file");
  } catch (IllegalArgumentException ex) {
  }
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-api

@Test
public void readBundleStreamNoMediaType() throws Exception {
  InputStream inputStream = new ByteArrayInputStream(
      getStructureFormatWorkflowBundle().getBytes("utf-8"));
  WorkflowBundle wfBundle = bundleIO.readBundle(inputStream, null);
  assertNotNull(wfBundle);
  assertEquals("HelloWorld", wfBundle.getName());
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-t2flow

@Test
public void readSimpleWorkflow() throws Exception {
  URL wfResource = getClass().getResource(AS_T2FLOW);
  assertNotNull("Could not find workflow " + AS_T2FLOW, wfResource);
  WorkflowBundle wfBundle = io.readBundle(wfResource,
      APPLICATION_VND_TAVERNA_T2FLOW_XML);
  Profile profile = wfBundle.getMainProfile();
  assertEquals(1, wfBundle.getProfiles().size());
  assertEquals(profile,
      wfBundle.getProfiles().getByName("taverna-2.1.0"));
  
  String report = IOUtils.toString(getClass().getResourceAsStream("/as.txt"));
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  io.writeBundle(wfBundle, byteStream, StructureReader.TEXT_VND_TAVERNA_SCUFL2_STRUCTURE);
      String byteStreamTtoString = byteStream.toString("utf-8");
      report = report.replaceAll("\r", "").replaceAll("\n", "");
      byteStreamTtoString = byteStreamTtoString.replaceAll("\r", "").replaceAll("\n", "");
  assertEquals(report, byteStreamTtoString);
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-t2flow

@Test
public void preservedOriginalT2flow() throws Exception {
  URL wfResource = getClass().getResource(AS_T2FLOW);
  assertNotNull("Could not find workflow " + AS_T2FLOW, wfResource);
  WorkflowBundle wfBundle = io.readBundle(wfResource,
      APPLICATION_VND_TAVERNA_T2FLOW_XML);
  Map<String, ResourceEntry> history = wfBundle.getResources()
      .listResources("history");
  assertEquals(1, history.size());
  assertEquals(AS_UUID + ".t2flow", history.keySet().iterator().next());
  ResourceEntry r = history.get(AS_UUID + ".t2flow");
  assertEquals("application/vnd.taverna.t2flow+xml", r.getMediaType());
  String original = IOUtils.toString(getClass().getResourceAsStream(
      AS_T2FLOW));
  String shouldBeOriginal = wfBundle.getResources().getResourceAsString(
      "history/" + AS_UUID + ".t2flow");
  assertEquals(shouldBeOriginal, original);
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-api

@Test
  public void multiLineJson() throws Exception {
    String struct = getStructureFormatWorkflowBundle();
    // Make JSON multi-line by adding some whitespace
    struct = struct.replace("{", "{\n         ");
    struct = struct.replace("\":\"", "\":\n             \"");
    struct = struct.replace("}", "\n        }\n");
    // EG: 
//       {
//        "script":
//            "hello = \"Hello, \" + personName;\nJOptionPane.showMessageDialog(null, hello);"
//       }
    
//        System.out.println(struct);
    
    InputStream inputStream = new ByteArrayInputStream(
        struct.getBytes("utf-8"));
    WorkflowBundle readBundle = bundleIO.readBundle(inputStream,
        TEXT_VND_TAVERNA_SCUFL2_STRUCTURE);
    assertEquals(1, readBundle.getMainProfile().getConfigurations().size());
    
    Configuration config = readBundle.getMainProfile().getConfigurations().getByName("Hello");
    String script = config.getJson().get("script").asText();
    String expected = "hello = \"Hello, \" + personName;\n"
        + "JOptionPane.showMessageDialog(null, hello);";
    assertEquals(expected, script);        
  }

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-t2flow

@Before
public void readWorkflow() throws ReaderException, IOException {
  WorkflowBundleIO io = new WorkflowBundleIO();
  InputStream is = getClass().getResourceAsStream(ITERATIONSTRATEGIES_T2FLOW);
  wfBundle = io.readBundle(is, APPLICATION_VND_TAVERNA_T2FLOW_XML);
  wf = wfBundle.getMainWorkflow();
  coloursLisr = wf.getProcessors().getByName("ColoursLisr");
  concat = wf.getProcessors().getByName("Concatenate_two_strings");
  shape = wf.getProcessors().getByName("ShapeAnimals");
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-api

@Test
public void configurationReadTwice() throws Exception {
  InputStream inputStream = new ByteArrayInputStream(
      getStructureFormatWorkflowBundle().getBytes("utf-8"));
  WorkflowBundle readBundle = bundleIO.readBundle(inputStream,
      TEXT_VND_TAVERNA_SCUFL2_STRUCTURE);
  assertEquals(1, readBundle.getMainProfile().getConfigurations().size());
  new Scufl2Tools().setParents(readBundle);
  assertEquals(1, readBundle.getMainProfile().getConfigurations().size());
  ByteArrayOutputStream output = new ByteArrayOutputStream();
  bundleIO.writeBundle(readBundle, output, TEXT_VND_TAVERNA_SCUFL2_STRUCTURE);
  assertEquals(1, readBundle.getMainProfile().getConfigurations().size());
  String bundleTxt = new String(output.toByteArray(), UTF_8);
      String getStructureFormatWorkflowBundle = getStructureFormatWorkflowBundle();
      bundleTxt = bundleTxt.replaceAll("\r", "").replaceAll("\n", "");
      getStructureFormatWorkflowBundle = getStructureFormatWorkflowBundle.replaceAll("\r", "").replaceAll("\n", "");
  assertEquals(getStructureFormatWorkflowBundle, bundleTxt);
  
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-api

@Test
public void readBundleStream() throws Exception {
  InputStream inputStream = new ByteArrayInputStream(
      getStructureFormatWorkflowBundle().getBytes("utf-8"));
  WorkflowBundle wfBundle = bundleIO.readBundle(inputStream,
      TEXT_VND_TAVERNA_SCUFL2_STRUCTURE);
  assertEquals("HelloWorld", wfBundle.getName());
  assertEquals("HelloWorld", wfBundle.getMainWorkflow().getName());
  assertTrue(wfBundle.getMainWorkflow().getProcessors()
      .containsName("Hello"));
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-wfbundle

@Test
public void awkwardFilenames() throws Exception {
  workflowBundle.getProfiles().removeByName("tavernaServer");
  String funnyName = "Funny_%2f_characters_50%_of the time";
  workflowBundle.getMainProfile().setName(funnyName);        
  workflowBundle.getMainWorkflow().setName(funnyName);
  File bundleFile = tempFile();
  bundleIO.writeBundle(workflowBundle, bundleFile,
      APPLICATION_VND_TAVERNA_SCUFL2_WORKFLOW_BUNDLE);
  UCFPackage ucfPackage = new UCFPackage(bundleFile);
  Map<String, ResourceEntry> profiles = ucfPackage.listResources("profile");
  assertEquals(2, profiles.size());
  assertTrue(profiles.keySet().contains("Funny_%252f_characters_50%25_of%20the%20time.rdf"));
  assertTrue(profiles.keySet().contains("Funny_%252f_characters_50%25_of%20the%20time/"));
  
  Map<String, ResourceEntry> workflows = ucfPackage.listResources("workflow");
  assertEquals(1, workflows.size());
  assertEquals("Funny_%252f_characters_50%25_of%20the%20time.rdf", workflows.keySet().iterator().next());
  
  // and.. can we read it in again correctly?
  WorkflowBundle readBundle = bundleIO.readBundle(bundleFile, APPLICATION_VND_TAVERNA_SCUFL2_WORKFLOW_BUNDLE);
  assertEquals(funnyName, readBundle.getMainProfile().getName());
  assertEquals(funnyName, readBundle.getMainWorkflow().getName());
  // did the JSON parse back in?
  JsonNode oldJson = workflowBundle.getMainProfile().getConfigurations().getByName("Hello").getJson();
  assertTrue(oldJson.get("script").asText().startsWith("hello"));           
  JsonNode newJson = readBundle.getMainProfile().getConfigurations().getByName("Hello").getJson();
  assertTrue(newJson.get("script").asText().startsWith("hello"));        
  assertEquals(oldJson, newJson);
}

代码示例来源:origin: org.apache.taverna.language/taverna-scufl2-api

@Test
public void readBundleFile() throws Exception {
  File bundleFile = tempFile();
  FileUtils.writeStringToFile(bundleFile,
      getStructureFormatWorkflowBundle(),
      UTF_8);
  WorkflowBundle wfBundle = bundleIO.readBundle(bundleFile,
      TEXT_VND_TAVERNA_SCUFL2_STRUCTURE);
  assertEquals("HelloWorld", wfBundle.getName());
  assertEquals("HelloWorld", wfBundle.getMainWorkflow().getName());
  assertTrue(wfBundle.getMainWorkflow().getProcessors()
      .containsName("Hello"));
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com