本文整理汇总了Java中org.activiti.engine.form.StartFormData.getFormProperties方法的典型用法代码示例。如果您正苦于以下问题:Java StartFormData.getFormProperties方法的具体用法?Java StartFormData.getFormProperties怎么用?Java StartFormData.getFormProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.form.StartFormData
的用法示例。
在下文中一共展示了StartFormData.getFormProperties方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buttonClick
import org.activiti.engine.form.StartFormData; //导入方法依赖的package包/类
public void buttonClick(ClickEvent event) {
// Check if process-definition defines a start-form
StartFormData startFormData = formService.getStartFormData(processDefinition.getId());
if(startFormData != null && ((startFormData.getFormProperties() != null && startFormData.getFormProperties().size() > 0) || startFormData.getFormKey() != null)) {
parentPage.showStartForm(processDefinition, startFormData);
} else {
// Just start the process-instance since it has no form.
// TODO: Error handling
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
// Show notification of success
notificationManager.showInformationNotification(Messages.PROCESS_STARTED_NOTIFICATION, getProcessDisplayName(processDefinition));
// Switch to inbox page in case a task of this process was created
List<Task> loggedInUsersTasks = taskService.createTaskQuery()
.taskAssignee(ExplorerApp.get().getLoggedInUser().getId())
.processInstanceId(processInstance.getId())
.list();
if (loggedInUsersTasks.size() > 0) {
ExplorerApp.get().getViewManager().showInboxPage(loggedInUsersTasks.get(0).getId());
}
}
}
示例2: testJavascriptFormType
import org.activiti.engine.form.StartFormData; //导入方法依赖的package包/类
@Test
@Deployment(resources = "chapter6/dynamic-form/leave.bpmn")
public void testJavascriptFormType() throws Exception {
// 验证是否部署成功
long count = repositoryService.createProcessDefinitionQuery().count();
assertEquals(1, count);
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult();
StartFormData startFormData = formService.getStartFormData(processDefinition.getId());
List<FormProperty> formProperties = startFormData.getFormProperties();
for (FormProperty formProperty : formProperties) {
System.out.println(formProperty.getId() + ",value=" + formProperty.getValue());
}
}
示例3: testStartFormDefaultValue
import org.activiti.engine.form.StartFormData; //导入方法依赖的package包/类
@Deployment
public void testStartFormDefaultValue() throws Exception {
String processDefinitionId = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey("FormPropertyDefaultValueTest.testDefaultValue")
.latestVersion()
.singleResult()
.getId();
StartFormData startForm = formService.getStartFormData(processDefinitionId);
List<FormProperty> formProperties = startForm.getFormProperties();
assertEquals(4, formProperties.size());
for (FormProperty prop : formProperties) {
if ("booleanProperty".equals(prop.getId())) {
assertEquals("true", prop.getValue());
} else if ("stringProperty".equals(prop.getId())) {
assertEquals("someString", prop.getValue());
} else if ("longProperty".equals(prop.getId())) {
assertEquals("42", prop.getValue());
} else if ("longExpressionProperty".equals(prop.getId())) {
assertEquals("23", prop.getValue());
} else {
assertTrue("Invalid form property: " + prop.getId(), false);
}
}
// Override 2 properties. The others should pe posted as the default-value
Map<String, String> formDataUpdate = new HashMap<String, String>();
formDataUpdate.put("longExpressionProperty", "1");
formDataUpdate.put("booleanProperty", "false");
ProcessInstance processInstance = formService.submitStartFormData(processDefinitionId, formDataUpdate);
assertEquals(false, runtimeService.getVariable(processInstance.getId(), "booleanProperty"));
assertEquals("someString", runtimeService.getVariable(processInstance.getId(), "stringProperty"));
assertEquals(42L, runtimeService.getVariable(processInstance.getId(), "longProperty"));
assertEquals(1L, runtimeService.getVariable(processInstance.getId(), "longExpressionProperty"));
}
示例4: startProcessInstanceByKey
import org.activiti.engine.form.StartFormData; //导入方法依赖的package包/类
/**
* 启动流程
*
* @param processDefinitionKey 流程定义编号
* @param name 流程实例名称
* @param variables 流程变量
* @param userId
* @param businessKey 业务ID
* @return 是否启动成功 success=true是第二个参数为流程实例ID
*/
@Override
public Result startProcessInstanceByKey(String processDefinitionKey, String name, Map<String, Object> variables,
String userId, String businessKey) {
//校验流程定义是否存在
final ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery()
.processDefinitionKey(processDefinitionKey).latestVersion().active().singleResult();
if (processDefinitionEntity == null)
return new Result(false, "启动失败", "流程启动失败key='" + processDefinitionKey + "'的流程定义不存在");
//设置流程启动人
identityService.setAuthenticatedUserId(userId);
//启动流程, 根据key获取最新版本的流程定义
ProcessInstance processInstance = null;
try {
//---------------------解决在初始化时,表单变量取不到默认值的问题-------------------------------------
Object retObj = ((FormServiceImpl) formService).getCommandExecutor().execute(new Command<Object>() {
@Override
public Object execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext
.getProcessEngineConfiguration()
.getDeploymentManager()
.findDeployedProcessDefinitionById(processDefinitionEntity.getId());
DefaultStartFormHandler startFormHandler = (DefaultStartFormHandler) processDefinition.getStartFormHandler();
for (FormPropertyHandler formPropertyHandler : startFormHandler.getFormPropertyHandlers()) {
//默认值
formPropertyHandler.setDefaultExpression(formPropertyHandler.getVariableExpression());
}
return startFormHandler.createStartFormData(processDefinition);
}
});
//StartFormData startFormData1 = formService.getStartFormData(processDefinitionEntity.getId());
StartFormData startFormData = (StartFormData) retObj;
//--------------------------------------------------------------------------------------------
if (startFormData != null) {
List<FormProperty> properties = startFormData.getFormProperties();
for (FormProperty property : properties) {
if (!variables.containsKey(property.getId())) {
variables.put(property.getId(), this.getVariable(property, property.getValue()));
}
}
}
processInstance = runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey, variables);
} catch (Exception ex) {
return new Result(false, "启动异常", "流程启动异常,异常原因:" + ex.getMessage());
}
runtimeService.setProcessInstanceName(processInstance.getId(), name);
return new Result(true, processInstance.getId(), "启动成功");
}
示例5: getStartFormProperties
import org.activiti.engine.form.StartFormData; //导入方法依赖的package包/类
@GET
@Path("/{processDefinitionId}/properties")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public Response getStartFormProperties(@PathParam("processDefinitionId") String processDefinitionId) {
FormService formService = BPMNOSGIService.getFormService();
StartFormData startFormData = formService.getStartFormData(processDefinitionId);
FormPropertyResponseCollection formPropertyResponseCollection = new FormPropertyResponseCollection();
if(startFormData != null) {
List<FormProperty> properties = startFormData.getFormProperties();
List<FormPropertyResponse> formPropertyResponseList = new ArrayList<>();
for (FormProperty property : properties) {
// ObjectNode propertyJSON = objectMapper.createObjectNode();
FormPropertyResponse formPropertyResponse = new FormPropertyResponse();
formPropertyResponse.setId(property.getId());
formPropertyResponse.setName(property.getName());
if (property.getValue() != null) {
formPropertyResponse.setValue(property.getValue());
} else {
formPropertyResponse.setValue(null);
}
if(property.getType() != null) {
formPropertyResponse.setType(property.getType().getName());
if (property.getType() instanceof EnumFormType) {
@SuppressWarnings("unchecked")
Map<String, String> valuesMap = (Map<String, String>) property.getType().getInformation("values");
if (valuesMap != null) {
List<FormPropertyEnumDataHolder> formPropertyEnumDataHoldersList = new ArrayList<>();
for (String key : valuesMap.keySet()) {
FormPropertyEnumDataHolder formPropertyEnumDataHolder = new
FormPropertyEnumDataHolder();
formPropertyEnumDataHolder.setId(key);
formPropertyEnumDataHolder.setName(valuesMap.get(key));
formPropertyEnumDataHoldersList.add(formPropertyEnumDataHolder);
}
formPropertyResponse.setEnumValues(formPropertyEnumDataHoldersList);
}
}
} else {
formPropertyResponse.setType("String");
}
formPropertyResponse.setRequired(property.isRequired());
formPropertyResponse.setReadable(property.isReadable());
formPropertyResponse.setWritable(property.isWritable());
formPropertyResponseList.add(formPropertyResponse);
}
formPropertyResponseCollection.setData(formPropertyResponseList);
}
return Response.ok().entity(formPropertyResponseCollection).build();
}
示例6: getStartFormProperties
import org.activiti.engine.form.StartFormData; //导入方法依赖的package包/类
@Get
public ObjectNode getStartFormProperties() {
if(authenticate() == false) return null;
String processDefinitionId = (String) getRequest().getAttributes().get("processDefinitionId");
StartFormData startFormData = ActivitiUtil.getFormService().getStartFormData(processDefinitionId);
ObjectNode responseJSON = new ObjectMapper().createObjectNode();
ArrayNode propertiesJSON = new ObjectMapper().createArrayNode();
if(startFormData != null) {
List<FormProperty> properties = startFormData.getFormProperties();
for (FormProperty property : properties) {
ObjectNode propertyJSON = new ObjectMapper().createObjectNode();
propertyJSON.put("id", property.getId());
propertyJSON.put("name", property.getName());
if(property.getValue() != null) {
propertyJSON.put("value", property.getValue());
} else {
propertyJSON.put("value", "null");
}
if(property.getType() != null) {
propertyJSON.put("type", property.getType().getName());
if(property.getType() instanceof EnumFormType) {
@SuppressWarnings("unchecked")
Map<String, String> valuesMap = (Map<String, String>) property.getType().getInformation("values");
if(valuesMap != null) {
ArrayNode valuesArray = new ObjectMapper().createArrayNode();
propertyJSON.put("enumValues", valuesArray);
for (String key : valuesMap.keySet()) {
ObjectNode valueJSON = new ObjectMapper().createObjectNode();
valueJSON.put("id", key);
valueJSON.put("name", valuesMap.get(key));
valuesArray.add(valueJSON);
}
}
}
} else {
propertyJSON.put("type", "String");
}
propertyJSON.put("required", property.isRequired());
propertyJSON.put("readable", property.isReadable());
propertyJSON.put("writable", property.isWritable());
propertiesJSON.add(propertyJSON);
}
}
responseJSON.put("data", propertiesJSON);
return responseJSON;
}