当前位置: 首页>>代码示例>>Java>>正文


Java Variables类代码示例

本文整理汇总了Java中org.camunda.bpm.engine.variable.Variables的典型用法代码示例。如果您正苦于以下问题:Java Variables类的具体用法?Java Variables怎么用?Java Variables使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Variables类属于org.camunda.bpm.engine.variable包,在下文中一共展示了Variables类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toTypedValue

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
private static TypedValue toTypedValue(Object value) {
    if (value instanceof Integer) {
        return Variables.integerValue((Integer) value);
    } else if (value instanceof String) {
        return Variables.stringValue((String) value);
    } else if (value instanceof Boolean) {
        return Variables.booleanValue((Boolean) value);
    } else if (value instanceof byte[]) {
        return Variables.byteArrayValue((byte[]) value);
    } else if (value instanceof Date) {
        return Variables.dateValue((Date) value);
    } else if (value instanceof Long) {
        return Variables.longValue((Long) value);
    } else if (value instanceof Short) {
        return Variables.shortValue((Short) value);
    } else if (value instanceof Double) {
        return Variables.doubleValue((Double) value);
    } else if (value instanceof Number) {
        return Variables.numberValue((Number) value);
    }
    return Variables.untypedValue(value);
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:23,代码来源:ExternalTaskManagerImpl.java

示例2: main

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
public static void main(String... args) throws Exception {
  SpringApplication.run(Application.class, args);

  // do default setup of platform (everything is only applied if not yet there)
  ProcessEngine engine = BpmPlatform.getDefaultProcessEngine();
  
  // start a Saga right away
  engine.getRuntimeService().startProcessInstanceByKey(
      "trip", 
      Variables.putValue("someVariableToPass", "someValue"));
  
  // and add default users to Camunda to be ready-to-go
  UserGenerator.createDefaultUsers(engine);
  LicenseHelper.setLicense(engine);    
  
  // Start H2 server to be able to connect to database from the outside
  Server.createTcpServer(new String[] { "-tcpPort", "8092", "-tcpAllowOthers" }).start();
}
 
开发者ID:flowing,项目名称:flowing-trip-booking-saga,代码行数:19,代码来源:Application.java

示例3: handleEvent

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Override
public boolean handleEvent(String type, String name, String transactionId, JsonObject event) {
  if ("Command".equals(type) && "RetrievePayment".equals(name)) {
    String refId = event.getString("refId");
    String reason = event.getString("reason");
    long amount = event.getJsonNumber("amount").longValue();

    Map<String, Object> variables = Variables.createVariables() //
        .putValue("refId", refId) //
        .putValue("transactionId", transactionId) //
        .putValue("reason", reason) //
        .putValue("amount", amount);

    engine.getRuntimeService().startProcessInstanceByKey("Payment", transactionId, variables);
    return true;
  } else {
    return false;
  }
}
 
开发者ID:flowing,项目名称:flowing-retail-old,代码行数:20,代码来源:CamundaPaymentEventHandler.java

示例4: sendMailWithFileName

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Test
@Deployment(resources = "processes/mail-send-file.bpmn")
public void sendMailWithFileName() throws Exception {
  File attachment = new File(getClass().getResource("/attachment.txt").toURI());
  assertThat(attachment.exists()).isTrue();

  engineRule.getRuntimeService().startProcessInstanceByKey("send-mail",
      Variables.createVariables().putValue("file", attachment.getPath()));

  MimeMessage[] mails = greenMail.getReceivedMessages();
  assertThat(mails).hasSize(1);

  MimeMessage mail = mails[0];

  assertThat(mail.getContent()).isInstanceOf(MimeMultipart.class);
  MimeMultipart multiPart = (MimeMultipart) mail.getContent();

  assertThat(multiPart.getCount()).isEqualTo(1);
  assertThat(GreenMailUtil.getBody(multiPart.getBodyPart(0))).isEqualTo("plain text");
}
 
开发者ID:camunda,项目名称:camunda-bpm-mail,代码行数:21,代码来源:SendMailConnectorProcessTest.java

示例5: startService

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@PostDeploy
public void startService(ProcessEngine processEngine) throws Exception {
  RuntimeService runtimeService = processEngine.getRuntimeService();

  configuration = MailConfigurationFactory.getConfiguration();
  notificationService = new MailNotificationService(configuration);

  notificationService.registerMailHandler(mail -> {
    runtimeService.startProcessInstanceByKey("printProcess",
        Variables.createVariables()
          .putValue("mail", mail)
          .putValue("invoice", getInvoicePath()));
  });

  notificationService.start();
}
 
开发者ID:camunda,项目名称:camunda-bpm-mail,代码行数:17,代码来源:PrintServiceProcessApplication.java

示例6: testYellowScenario

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Test
public void testYellowScenario() {

  variables = Variables.createVariables()
    .putValue("applicantAge", 30)
    .putValue("carManufacturer", "Porsche")
    .putValue("carType", "911");

  Scenario scenario = Scenario.run(insuranceApplication)
    .startBy(() -> { // ... or define your own starter function
      return rule.getRuntimeService().startProcessInstanceByKey("InsuranceApplication", variables);
    })
    .execute();

  assertThat(scenario.instance(insuranceApplication)).variables().containsEntry("riskAssessment", "yellow");
  verify(insuranceApplication).hasCompleted("SubProcessManualCheck");
  verify(insuranceApplication).hasFinished("EndEventApplicationAccepted");

}
 
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:20,代码来源:InsuranceApplicationProcessTest.java

示例7: testRedScenario

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Test
public void testRedScenario() {

  variables = Variables.createVariables()
    .putValue("applicantAge", 20)
    .putValue("carManufacturer", "Porsche")
    .putValue("carType", "911");

  Scenario scenario = Scenario.run(insuranceApplication)
      .startByKey("InsuranceApplication", variables)
      .execute();

  assertThat(scenario.instance(insuranceApplication)).variables().containsEntry("riskAssessment", "red");

  verify(insuranceApplication, never()).hasStarted("SubProcessManualCheck");
  verify(insuranceApplication).hasFinished("EndEventApplicationRejected");

}
 
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:19,代码来源:InsuranceApplicationProcessTest.java

示例8: testManualApprovalScenario

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Test
public void testManualApprovalScenario() {

  variables = Variables.createVariables()
    .putValue("applicantAge", 30)
    .putValue("carManufacturer", "Porsche")
    .putValue("carType", "911");

  Scenario scenario = Scenario.run(insuranceApplication)
      .startByKey("InsuranceApplication", variables)
      .execute();

  assertThat(scenario.instance(insuranceApplication)).variables()
    .containsEntry("riskAssessment", "yellow")
    .containsEntry("approved", true);

  verify(insuranceApplication).hasCompleted("SubProcessManualCheck");
  verify(insuranceApplication).hasFinished("EndEventApplicationAccepted");

}
 
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:21,代码来源:InsuranceApplicationProcessTest.java

示例9: testManualRejectionScenario

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Test
public void testManualRejectionScenario() {

  variables = Variables.createVariables()
    .putValue("applicantAge", 30)
    .putValue("carManufacturer", "Porsche")
    .putValue("carType", "911");

  when(insuranceApplication.waitsAtUserTask("UserTaskDecideAboutApplication")).thenReturn((task) -> {
    task.complete(withVariables("approved", false));
  });

  Scenario scenario = Scenario.run(insuranceApplication)
      .startByKey("InsuranceApplication", variables)
      .execute();

  assertThat(scenario.instance(insuranceApplication)).variables()
    .containsEntry("riskAssessment", "yellow")
    .containsEntry("approved", false);

  verify(insuranceApplication).hasCompleted("SubProcessManualCheck");
  verify(insuranceApplication).hasFinished("EndEventApplicationRejected");

}
 
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:25,代码来源:InsuranceApplicationProcessTest.java

示例10: testDocumentRequestScenario

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Test
public void testDocumentRequestScenario() {

  variables = Variables.createVariables()
      .putValue("applicantAge", 30)
      .putValue("carManufacturer", "Porsche")
      .putValue("carType", "911");

  when(insuranceApplication.waitsAtUserTask("UserTaskDecideAboutApplication")).thenReturn((task) -> {
    runtimeService().correlateMessage("msgDocumentNecessary");
    task.complete(withVariables("approved", true));
  });

  Scenario.run(insuranceApplication)
      .startByKey("InsuranceApplication", variables)
      .execute();

  verify(insuranceApplication).hasCompleted("CallActivityDocumentRequest");

}
 
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:21,代码来源:InsuranceApplicationProcessTest.java

示例11: changeVariableType

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
public void changeVariableType() {
  ReadStrategy readStrategy = null;
  WriteStrategy writeStrategy = null;
  String sourceVariableName = null;

  Conversion conversionFunction = (TypedValue originalTypedValue) -> {
    String invoiceNumberWithoutDelimiters = originalTypedValue.getValue().toString().replace("-", "");
    return Variables.longValue(Long.valueOf(invoiceNumberWithoutDelimiters));
  };

  VariableStep variableStep = VariableStep.builder()
    .readStrategy(readStrategy)
    .writeStrategy(writeStrategy)
    .sourceVariableName(sourceVariableName)
    .conversion(conversionFunction)
    .build();
}
 
开发者ID:camunda,项目名称:camunda-bpm-migration,代码行数:18,代码来源:Snippets.java

示例12: uses_provided_conversion

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Test
public void uses_provided_conversion() {
  //Given a variable with originalValue
  TypedValue originalValue = prepareOriginalValue();
  //And a conversion function that converts originalValue to convertedValue
  TypedValue convertedValue = Variables.booleanValue(Boolean.TRUE);
  @SuppressWarnings("unchecked")
  Conversion conversion = mock(Conversion.class);
  when(conversion.apply(originalValue)).thenReturn(convertedValue);
  //And a variableStep with that conversion function
  variableStep.setConversion(conversion);

  //When performing the variable step
  variableStep.perform(stepExecutionContext);

  //then the conversion function is called with the originalValue
  verify(conversion).apply(originalValue);
  //and the writerStrategy is called with the convertedValue
  verify(writeStrategy).write(stepExecutionContext, VARIABLE, convertedValue);
}
 
开发者ID:camunda,项目名称:camunda-bpm-migration,代码行数:21,代码来源:VariableStepTest.java

示例13: leistungenErfassen

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
private void leistungenErfassen(ProcessInstance processInstance, String user, String produkt, String status, Set<String> leistungsNamen) {
  Task task = claimTask(processInstance, user);

  List<Leistung> leistungen = Lists.newArrayList();
  for (String leistungsName : leistungsNamen) {
    Leistung leistung = new Leistung();
    leistung.setBezeichnung(leistungsName);
    leistungen.add(leistung);
  }

  taskService.complete(task.getId(), Variables
    .putValue(VARIABLES.KUNDENSTATUS, status)
    .putValue(VARIABLES.PRODUKT, produkt)
    .putValueTyped(VARIABLES.LEISTUNGEN, Variables.objectValue(leistungen).create())
  );
}
 
开发者ID:holisticon,项目名称:skill-based-routing,代码行数:17,代码来源:ShowcaseSetupServlet.java

示例14: testSingleOutputUntypedValue

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testSingleOutputUntypedValue() {
  DmnDecisionResult decisionResult = evaluateWithMatchingRules(SINGLE_OUTPUT_VALUE);
  assertThat(decisionResult).hasSize(1);

  DmnDecisionResultEntries ruleResult = decisionResult.getFirstResult();

  TypedValue typedEntry = ruleResult.getEntryTyped("firstOutput");
  assertThat(typedEntry).isEqualTo(Variables.untypedValue("singleValue"));

  typedEntry = ruleResult.getEntryTyped("secondOutput");
  assertThat(typedEntry).isNull();

  typedEntry = ruleResult.getFirstEntryTyped();
  assertThat(typedEntry).isEqualTo(Variables.untypedValue("singleValue"));

  typedEntry = ruleResult.getSingleEntryTyped();
  assertThat(typedEntry).isEqualTo(Variables.untypedValue("singleValue"));
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:21,代码来源:DmnDecisionResultTest.java

示例15: testSingleOutputTypedValue

import org.camunda.bpm.engine.variable.Variables; //导入依赖的package包/类
@Test
@DecisionResource(resource = RESULT_TEST_WITH_TYPES_DMN)
public void testSingleOutputTypedValue() {
  DmnDecisionResult decisionResult = evaluateWithMatchingRules(SINGLE_OUTPUT_VALUE);
  assertThat(decisionResult).hasSize(1);

  DmnDecisionResultEntries ruleResult = decisionResult.getFirstResult();

  TypedValue typedValue = ruleResult.getEntryTyped("firstOutput");
  assertThat(typedValue).isEqualTo(Variables.stringValue("singleValue"));

  typedValue = ruleResult.getEntryTyped("secondOutput");
  assertThat(typedValue).isNull();

  typedValue = ruleResult.getFirstEntryTyped();
  assertThat(typedValue).isEqualTo(Variables.stringValue("singleValue"));

  typedValue = ruleResult.getSingleEntryTyped();
  assertThat(typedValue).isEqualTo(Variables.stringValue("singleValue"));
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:21,代码来源:DmnDecisionResultTest.java


注:本文中的org.camunda.bpm.engine.variable.Variables类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。