Java Code Examples for org.camunda.bpm.model.bpmn.Bpmn#convertToString()

The following examples show how to use org.camunda.bpm.model.bpmn.Bpmn#convertToString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EngineRule.java    From camunda-external-task-client-java with Apache License 2.0 6 votes vote down vote up
protected HttpPost createDeploymentRequest(String tenantId, BpmnModelInstance... processes) {
  String uri = String.format(URI_DEPLOYMEN_CREATE, getEngineUrl());
  HttpPost post = new HttpPost(uri);

  MultipartEntityBuilder builder = MultipartEntityBuilder.create()
    .addTextBody("deployment-name", "deployment")
    .addTextBody("enable-duplicate-filtering", "false")
    .addTextBody("deployment-source", "process application");

  if (tenantId != null) {
    builder.addTextBody("tenant-id", tenantId);
  }

  for (int i = 0; i < processes.length; i++) {
    BpmnModelInstance process = processes[i];
    String processAsString = Bpmn.convertToString(process);
    builder.addBinaryBody(
        String.format("data %d", i),
        processAsString.getBytes(StandardCharsets.UTF_8), ContentType.APPLICATION_OCTET_STREAM,
        String.format("test%d.bpmn", i));
  }

  HttpEntity entity = builder.build();
  post.setEntity(entity);
  return post;
}
 
Example 2
Source File: BpmnProcessModelCustomizer.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
public String buildAsXml() {
    if (rootBpmnModelInstance == null) {
        performBuild();
    }

    if (rootBpmnModelInstance != null) {
        return Bpmn.convertToString(rootBpmnModelInstance);
    } else {
        throw new BpmnCustomizationException("Failed to build BPMN model instance.");
    }
}
 
Example 3
Source File: RepositoryServiceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testUTF8DeploymentMethod() throws IOException {
  //given utf8 charset
  Charset utf8Charset = Charset.forName("UTF-8");
  Charset defaultCharset = processEngineConfiguration.getDefaultCharset();
  processEngineConfiguration.setDefaultCharset(utf8Charset);

  //and model instance with umlauts
  String umlautsString = "äöüÄÖÜß";
  String resourceName = "deployment.bpmn";
  BpmnModelInstance instance = Bpmn.createExecutableProcess("umlautsProcess").startEvent(umlautsString).done();
  String instanceAsString = Bpmn.convertToString(instance);

  //when instance is deployed via addString method
  org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment()
                                                                             .addString(resourceName, instanceAsString)
                                                                             .deploy();

  //then bytes are saved in utf-8 format
  InputStream inputStream = repositoryService.getResourceAsStream(deployment.getId(), resourceName);
  byte[] utf8Bytes = instanceAsString.getBytes(utf8Charset);
  checkDeployedBytes(inputStream, utf8Bytes);
  repositoryService.deleteDeployment(deployment.getId());


  //when model instance is deployed via addModelInstance method
  deployment = repositoryService.createDeployment().addModelInstance(resourceName, instance).deploy();

  //then also the bytes are saved in utf-8 format
  inputStream = repositoryService.getResourceAsStream(deployment.getId(), resourceName);
  checkDeployedBytes(inputStream, utf8Bytes);

  repositoryService.deleteDeployment(deployment.getId());
  processEngineConfiguration.setDefaultCharset(defaultCharset);
}
 
Example 4
Source File: AbstractTemplateScriptEngineSupportTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText) {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID)
    .startEvent()
    .scriptTask()
      .scriptFormat(scriptFormat)
      .scriptText(scriptText)
      .camundaResultVariable(RESULT_VARIABLE)
    .userTask()
    .endEvent()
    .done();
  return new StringAsset(Bpmn.convertToString(modelInstance));
}
 
Example 5
Source File: AbstractPaLocalScriptEngineTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText) {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID)
    .startEvent()
    .scriptTask()
      .scriptFormat(scriptFormat)
      .scriptText(scriptText)
      .camundaResultVariable("scriptValue")
      .userTask()
    .endEvent()
    .done();
  return new StringAsset(Bpmn.convertToString(modelInstance));
}
 
Example 6
Source File: AbstractScriptEngineSupportTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText) {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID)
    .startEvent()
    .scriptTask()
      .scriptFormat(scriptFormat)
      .scriptText(scriptText)
      .userTask()
    .endEvent()
    .done();
  return new StringAsset(Bpmn.convertToString(modelInstance));
}
 
Example 7
Source File: PythonPaClassImportTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText, String pdk) {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(pdk)
    .startEvent()
    .scriptTask()
      .scriptFormat(scriptFormat)
      .scriptText(scriptText)
      .userTask()
    .endEvent()
    .done();
  return new StringAsset(Bpmn.convertToString(modelInstance));
}
 
Example 8
Source File: GroovyPaClassImportTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static StringAsset createScriptTaskProcess(String scriptFormat, String scriptText, String pdk) {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(pdk)
    .startEvent()
    .scriptTask()
      .scriptFormat(scriptFormat)
      .scriptText(scriptText)
      .userTask()
    .endEvent()
    .done();
  return new StringAsset(Bpmn.convertToString(modelInstance));
}
 
Example 9
Source File: DeploymentRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
private InputStream createMockDeploymentResourceBpmnDataNonExecutableProcess() {
  // do not close the input stream, will be done in implementation
  String model = Bpmn.convertToString(Bpmn.createProcess().startEvent().endEvent().done());
  InputStream inputStream = new ByteArrayInputStream(model.getBytes());
  return inputStream;
}