org.camunda.bpm.engine.variable.Variables.objectValue()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(13.0k)|赞(0)|评价(0)|浏览(180)

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

Variables.objectValue介绍

[英]Returns a builder to create a new ObjectValue that encapsulates the given value.
[中]返回一个生成器,以创建封装给定值的新ObjectValue。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Returns a builder to create a new {@link ObjectValue} that encapsulates
 * the given {@code value}.
 */
public static ObjectValueBuilder objectValue(Object value, boolean isTransient) {
 return (ObjectValueBuilder) objectValue(value).setTransient(isTransient);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public TypedValue createValue(Object value, Map<String, Object> valueInfo) {
 ObjectValueBuilder builder = Variables.objectValue(value);
 if(valueInfo != null) {
  applyValueInfo(builder, valueInfo);
 }
 return builder.create();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public ObjectValue convertToTypedValue(UntypedValueImpl untypedValue) {
 // untyped values are always deserialized
 return Variables.objectValue(untypedValue.getValue(), untypedValue.isTransient()).create();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public ObjectValue convertToTypedValue(UntypedValueImpl untypedValue) {
 // untyped values are always deserialized
 return Variables.objectValue(untypedValue.getValue(), untypedValue.isTransient()).create();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public ObjectValue convertToTypedValue(UntypedValueImpl untypedValue) {
 return Variables.objectValue(untypedValue.getValue(), untypedValue.isTransient()).create();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public ObjectValue convertToTypedValue(UntypedValueImpl untypedValue) {
 return Variables.objectValue(untypedValue.getValue(), untypedValue.isTransient()).create();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public ObjectValue readValue(ValueFields valueFields, boolean deserializeObjectValue) {
 if(valueFields.getTextValue() != null && valueFields.getTextValue2() != null) {
  Object jpaEntity = mappings.getJPAEntity(valueFields.getTextValue(), valueFields.getTextValue2());
  return Variables.objectValue(jpaEntity).create();
 }
 return Variables.objectValue(null).create();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public ObjectValue readValue(ValueFields valueFields, boolean deserializeObjectValue) {
 if(valueFields.getTextValue() != null && valueFields.getTextValue2() != null) {
  Object jpaEntity = mappings.getJPAEntity(valueFields.getTextValue(), valueFields.getTextValue2());
  return Variables.objectValue(jpaEntity).create();
 }
 return Variables.objectValue(null).create();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void execute(DelegateExecution execution) throws Exception {
 RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
 ObjectValue jsonSerializeable = Variables
   .objectValue(createJsonSerializable())
   .serializationDataFormat(SerializationDataFormats.JSON)
   .create();
 // this should be executed in the context of the current process application
 runtimeService.setVariable(execution.getProcessInstanceId(), VARIABLE_NAME, jsonSerializeable);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public ProcessInstance call() throws Exception {
 final XmlSerializable var = new XmlSerializable();
 var.setProperty("jonny");
 return runtimeService.startProcessInstanceByKey("processWithTimer", Variables.createVariables()
  .putValueTyped("testObject", Variables.objectValue(var).serializationDataFormat(DataFormats.JSON_DATAFORMAT_NAME).create()));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetTypedNullForExistingVariable() throws Exception {
 ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
 // initially the variable has a value
 JavaSerializable javaSerializable = new JavaSerializable("foo");
 runtimeService.setVariable(instance.getId(), "varName",
   objectValue(javaSerializable)
   .serializationDataFormat(JAVA_DATA_FORMAT)
   .create());
 // get value via untyped api
 assertEquals(javaSerializable, runtimeService.getVariable(instance.getId(), "varName"));
 // set the variable to null via typed Api
 runtimeService.setVariable(instance.getId(), "varName", objectValue(null));
 // variable is still of type object
 ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "varName");
 assertObjectValueDeserializedNull(typedValue);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment
@Test
public void testGetVariableInstancesFromVariableScope() {
 VariableMap variables = createVariables()
  .putValue("anIntegerVariable", 1234)
  .putValue("anObjectValue", objectValue(new SimpleSerializableBean(10)).serializationDataFormat(Variables.SerializationDataFormats.JAVA))
  .putValue("anUntypedObjectValue", new SimpleSerializableBean(30));
 runtimeService.startProcessInstanceByKey("testProcess", variables);
 // assertions are part of the java delegate AssertVariableInstancesDelegate
 // only there we can access the VariableScope methods
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"})
@Test
public void testSubmitTaskFormForCmmnHumanTask() {
 caseService.createCaseInstanceByKey("oneTaskCase");
 Task task = taskService.createTaskQuery().singleResult();
 String stringValue = "some string";
 String serializedValue = "some value";
 formService.submitTaskForm(task.getId(), createVariables()
   .putValueTyped("boolean", booleanValue(null))
   .putValueTyped("string", stringValue(stringValue))
   .putValueTyped("serializedObject", serializedObjectValue(serializedValue)
     .objectTypeName(String.class.getName())
     .serializationDataFormat(Variables.SerializationDataFormats.JAVA)
     .create())
   .putValueTyped("object", objectValue(serializedValue).create()));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetJavaObjectNullDeserialized() throws Exception {
 ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
 // set null value as "deserialized" object
 runtimeService.setVariable(instance.getId(), "nullObject",
   objectValue(null)
   .serializationDataFormat(JAVA_DATA_FORMAT)
   .create());
 // get null value via untyped api
 assertNull(runtimeService.getVariable(instance.getId(), "nullObject"));
 // get null via typed api
 ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "nullObject");
 assertObjectValueDeserializedNull(typedValue);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetJavaObject() throws Exception {
 ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
 JavaSerializable javaSerializable = new JavaSerializable("foo");
 runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(javaSerializable).serializationDataFormat(JAVA_DATA_FORMAT).create());
 // validate untyped value
 JavaSerializable value = (JavaSerializable) runtimeService.getVariable(instance.getId(), "simpleBean");
 assertEquals(javaSerializable, value);
 // validate typed value
 ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean");
 assertObjectValueDeserialized(typedValue, javaSerializable);
 assertObjectValueSerializedJava(typedValue, javaSerializable);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSerializationAsJava() throws Exception {
 ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
 JavaSerializable javaSerializable = new JavaSerializable("foo");
 runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(javaSerializable).serializationDataFormat(JAVA_DATA_FORMAT).create());
 // validate untyped value
 JavaSerializable value = (JavaSerializable) runtimeService.getVariable(instance.getId(), "simpleBean");
 assertEquals(javaSerializable, value);
 // validate typed value
 ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean");
 assertObjectValueDeserialized(typedValue, javaSerializable);
 assertObjectValueSerializedJava(typedValue, javaSerializable);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetUntypedNullForExistingVariable() throws Exception {
 ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
 // initially the variable has a value
 JavaSerializable javaSerializable = new JavaSerializable("foo");
 runtimeService.setVariable(instance.getId(), "varName",
   objectValue(javaSerializable)
   .serializationDataFormat(JAVA_DATA_FORMAT)
   .create());
 // get value via untyped api
 assertEquals(javaSerializable, runtimeService.getVariable(instance.getId(), "varName"));
 // set the variable to null via untyped Api
 runtimeService.setVariable(instance.getId(), "varName", null);
 // variable is now untyped null
 TypedValue nullValue = runtimeService.getVariableTyped(instance.getId(), "varName");
 assertUntypedNullValue(nullValue);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testFallbackSerializerDoesNotOverrideRegularSerializer() {
 // given
 // that the process engine is configured with a serializer for a certain format
 // and a fallback serializer factory for the same format
  ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration()
   .setJdbcUrl("jdbc:h2:mem:camunda-forceclose")
   .setProcessEngineName("engine-forceclose");
  engineConfiguration.setCustomPreVariableSerializers(Arrays.<TypedValueSerializer>asList(new ExampleConstantSerializer()));
  engineConfiguration.setFallbackSerializerFactory(new ExampleSerializerFactory());
  processEngine = engineConfiguration.buildProcessEngine();
  deployOneTaskProcess(processEngine);
  // when setting a variable that no regular serializer can handle
  ObjectValue objectValue = Variables.objectValue("foo").serializationDataFormat(ExampleSerializer.FORMAT).create();
  ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess",
    Variables.createVariables().putValueTyped("var", objectValue));
  ObjectValue fetchedValue = processEngine.getRuntimeService().getVariableTyped(pi.getId(), "var", true);
  // then the fallback serializer is used
  Assert.assertNotNull(fetchedValue);
  Assert.assertEquals(ExampleSerializer.FORMAT, fetchedValue.getSerializationDataFormat());
  Assert.assertEquals(ExampleConstantSerializer.DESERIALIZED_VALUE, fetchedValue.getValue());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = {"org/camunda/bpm/engine/test/api/form/FormsProcess.bpmn20.xml"})
@Test
public void testSubmitStartFormDataTypedVariables() {
 String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
 String stringValue = "some string";
 String serializedValue = "some value";
 ProcessInstance processInstance = formService.submitStartForm(procDefId,
   createVariables()
    .putValueTyped("boolean", booleanValue(null))
    .putValueTyped("string", stringValue(stringValue))
    .putValueTyped("serializedObject", serializedObjectValue(serializedValue)
      .objectTypeName(String.class.getName())
      .serializationDataFormat(Variables.SerializationDataFormats.JAVA)
      .create())
    .putValueTyped("object", objectValue(serializedValue).create()));
 VariableMap variables = runtimeService.getVariablesTyped(processInstance.getId(), false);
 assertEquals(booleanValue(null), variables.getValueTyped("boolean"));
 assertEquals(stringValue(stringValue), variables.getValueTyped("string"));
 assertNotNull(variables.<ObjectValue>getValueTyped("serializedObject").getValueSerialized());
 assertNotNull(variables.<ObjectValue>getValueTyped("object").getValueSerialized());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testFallbackSerializer() {
 // given
 // that the process engine is configured with a fallback serializer factory
  ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration()
   .setJdbcUrl("jdbc:h2:mem:camunda-forceclose")
   .setProcessEngineName("engine-forceclose");
  engineConfiguration.setFallbackSerializerFactory(new ExampleSerializerFactory());
  processEngine = engineConfiguration.buildProcessEngine();
  deployOneTaskProcess(processEngine);
  // when setting a variable that no regular serializer can handle
  ObjectValue objectValue = Variables.objectValue("foo").serializationDataFormat(ExampleSerializer.FORMAT).create();
  ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess",
    Variables.createVariables().putValueTyped("var", objectValue));
  ObjectValue fetchedValue = processEngine.getRuntimeService().getVariableTyped(pi.getId(), "var", true);
  // then the fallback serializer is used
  Assert.assertNotNull(fetchedValue);
  Assert.assertEquals(ExampleSerializer.FORMAT, fetchedValue.getSerializationDataFormat());
  Assert.assertEquals("foo", fetchedValue.getValue());
}

相关文章