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

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

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

Variables.byteArrayValue介绍

[英]Creates a new BytesValue that encapsulates the given bytes
[中]创建一个新字节值,该字节值封装给定的bytes

代码示例

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

/**
 * Creates a new {@link BytesValue} that encapsulates the given <code>bytes</code>
 */
public static BytesValue byteArrayValue(byte[] bytes) {
 return byteArrayValue(bytes, false);
}

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

public BytesValue createValue(Object value, Map<String, Object> valueInfo) {
 return Variables.byteArrayValue((byte[]) value, isTransient(valueInfo));
}

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

public BytesValue readValue(ValueFields valueFields) {
 return Variables.byteArrayValue(valueFields.getByteArrayValue());
}

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

public BytesValue readValue(ValueFields valueFields) {
 return Variables.byteArrayValue(valueFields.getByteArrayValue());
}

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

public BytesValue convertToTypedValue(UntypedValueImpl untypedValue) {
 Object value = untypedValue.getValue();
 if (value instanceof byte[]) {
  return Variables.byteArrayValue((byte[]) value, untypedValue.isTransient());
 } else {
  byte[] data = IoUtil.readInputStream((InputStream) value, null);
  return Variables.byteArrayValue(data, untypedValue.isTransient());
 }
}

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

public BytesValue convertToTypedValue(UntypedValueImpl untypedValue) {
 Object value = untypedValue.getValue();
 if (value instanceof byte[]) {
  return Variables.byteArrayValue((byte[]) value, untypedValue.isTransient());
 } else {
  byte[] data = IoUtil.readInputStream((InputStream) value, null);
  return Variables.byteArrayValue(data, untypedValue.isTransient());
 }
}

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

public Void execute(CommandContext commandContext) {
 commandContext.getDbEntityManager()
  .selectById(ByteArrayEntity.class, historicByteArrayId); // cache
 monitor.sync();
 runtimeService.setVariable(processInstanceId, VARIABLE_NAME,
  Variables.byteArrayValue(ANOTHER_VARIABLE_VALUE.getBytes()));
 return null;
}

代码示例来源:origin: org.camunda.commons/camunda-commons-typed-values

/**
 * Creates a new {@link BytesValue} that encapsulates the given <code>bytes</code>
 */
public static BytesValue byteArrayValue(byte[] bytes) {
 return byteArrayValue(bytes, false);
}

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

@Test
public void testGetSingleVariableInstanceForBinaryVariable() {
 MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance();
 HistoricVariableInstance variableInstanceMock = builder
  .typedValue(Variables.byteArrayValue(null))
  .build();
 when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
 given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID)
 .then().expect().statusCode(Status.OK.getStatusCode())
 .and()
  .body("type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.BYTES)))
  .body("value", nullValue())
 .when().get(VARIABLE_INSTANCE_URL);
 verify(variableInstanceQueryMock, times(1)).disableBinaryFetching();
}

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

@Test
public void testGetSingleVariableInstanceForBinaryVariable() {
 MockVariableInstanceBuilder builder = MockProvider.mockVariableInstance();
 VariableInstance variableInstanceMock =
   builder
    .typedValue(Variables.byteArrayValue(null))
    .build();
 when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
 given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID)
 .then().expect().statusCode(Status.OK.getStatusCode())
 .and()
  .body("type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.BYTES)))
  .body("value", nullValue())
 .when().get(VARIABLE_INSTANCE_URL);
 verify(variableInstanceQueryMock, times(1)).disableBinaryFetching();
}

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

@Test
public void testBinaryDataForBinaryVariable() {
 final byte[] byteContent = "some bytes".getBytes();
 HistoricVariableInstance variableInstanceMock = MockProvider.mockHistoricVariableInstance()
   .typedValue(Variables.byteArrayValue(byteContent))
   .build();
 when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
 Response response = given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
  .contentType(ContentType.BINARY.toString())
 .when().get(VARIABLE_INSTANCE_BINARY_DATA_URL);
 byte[] responseBytes = response.getBody().asByteArray();
 Assert.assertEquals(new String(byteContent), new String(responseBytes));
 verify(variableInstanceQueryMock, never()).disableBinaryFetching();
}

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

@Test
public void testBinaryDataForBinaryVariable() {
 final byte[] byteContent = "some bytes".getBytes();
 MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate();
 HistoricVariableUpdate detailMock = builder
   .typedValue(Variables.byteArrayValue(byteContent))
   .build();
 when(historicDetailQueryMock.detailId(detailMock.getId())).thenReturn(historicDetailQueryMock);
 when(historicDetailQueryMock.disableCustomObjectDeserialization()).thenReturn(historicDetailQueryMock);
 when(historicDetailQueryMock.singleResult()).thenReturn(detailMock);
 Response response = given().pathParam("id", MockProvider.EXAMPLE_HISTORIC_VAR_UPDATE_ID)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
  .contentType(ContentType.BINARY.toString())
 .when().get(VARIABLE_INSTANCE_BINARY_DATA_URL);
 byte[] responseBytes = response.getBody().asByteArray();
 Assert.assertEquals(new String(byteContent), new String(responseBytes));
 verify(historicDetailQueryMock, never()).disableBinaryFetching();
}

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

@Test
public void testBinaryDataForBinaryVariable() {
 final byte[] byteContent = "some bytes".getBytes();
 VariableInstance variableInstanceMock =
   MockProvider.mockVariableInstance()
    .typedValue(Variables.byteArrayValue(byteContent))
    .build();
 when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
 when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
 Response response = given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
  .contentType(ContentType.BINARY.toString())
 .when().get(VARIABLE_INSTANCE_BINARY_DATA_URL);
 byte[] responseBytes = response.getBody().asByteArray();
 Assert.assertEquals(new String(byteContent), new String(responseBytes));
 verify(variableInstanceQueryMock, never()).disableBinaryFetching();
 verify(variableInstanceQueryMock).disableCustomObjectDeserialization();
}

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

@Override
 public Void execute(CommandContext commandContext) {
  //create a variable
  VariableInstanceEntity variable = VariableInstanceEntity.createAndInsert("aVariable", Variables.byteArrayValue(new byte[0]));
  String byteArrayId = variable.getByteArrayValueId();
  //delete the variable
  variable.delete();
  //check if the variable is deleted transient
  //-> no insert and delete stmt will be flushed
  DbEntityManager dbEntityManager = commandContext.getDbEntityManager();
  CachedDbEntity cachedEntity = dbEntityManager.getDbEntityCache().getCachedEntity(ByteArrayEntity.class, byteArrayId);
  DbEntityState entityState = cachedEntity.getEntityState();
  assertEquals(DbEntityState.DELETED_TRANSIENT, entityState);
  return null;
 }
});

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

.typedValue(Variables.byteArrayValue(null))
.build();

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

Variables.byteArrayValue(VARIABLE_VALUE.getBytes())))
.getId();

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

Variables.createVariables().putValue("a", Variables.stringValue("bar", true))
.putValue("b", Variables.booleanValue(true, true))
.putValue("c", Variables.byteArrayValue("test".getBytes(), true))
.putValue("d", Variables.dateValue(new Date(), true))
.putValue("e", Variables.doubleValue(20., true))

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

.putValueTyped("a", Variables.stringValue("bar", true))
.putValueTyped("b", Variables.booleanValue(true, true))
.putValueTyped("c", Variables.byteArrayValue("test".getBytes(), true))
.putValueTyped("d", Variables.dateValue(new Date(), true))
.putValueTyped("e", Variables.doubleValue(20., true))

代码示例来源:origin: org.camunda.bpm/camunda-engine

public BytesValue convertToTypedValue(UntypedValueImpl untypedValue) {
 Object value = untypedValue.getValue();
 if (value instanceof byte[]) {
  return Variables.byteArrayValue((byte[]) value, untypedValue.isTransient());
 } else {
  byte[] data = IoUtil.readInputStream((InputStream) value, null);
  return Variables.byteArrayValue(data, untypedValue.isTransient());
 }
}

代码示例来源:origin: org.camunda.bpm/camunda-engine

public Void execute(CommandContext commandContext) {
 commandContext.getDbEntityManager()
  .selectById(ByteArrayEntity.class, historicByteArrayId); // cache
 monitor.sync();
 runtimeService.setVariable(processInstanceId, VARIABLE_NAME,
  Variables.byteArrayValue(ANOTHER_VARIABLE_VALUE.getBytes()));
 return null;
}

相关文章