Java Code Examples for org.activiti.engine.form.FormProperty#getType()
The following examples show how to use
org.activiti.engine.form.FormProperty#getType() .
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: RestResponseFactory.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public FormDataResponse createFormDataResponse(FormData formData) { FormDataResponse result = new FormDataResponse(); result.setDeploymentId(formData.getDeploymentId()); result.setFormKey(formData.getFormKey()); if (formData.getFormProperties() != null) { for (FormProperty formProp : formData.getFormProperties()) { RestFormProperty restFormProp = new RestFormProperty(); restFormProp.setId(formProp.getId()); restFormProp.setName(formProp.getName()); if (formProp.getType() != null) { restFormProp.setType(formProp.getType().getName()); } restFormProp.setValue(formProp.getValue()); restFormProp.setReadable(formProp.isReadable()); restFormProp.setRequired(formProp.isRequired()); restFormProp.setWritable(formProp.isWritable()); if ("enum".equals(restFormProp.getType())) { Object values = formProp.getType().getInformation("values"); if (values != null) { @SuppressWarnings("unchecked") Map<String, String> enumValues = (Map<String, String>) values; for (String enumId : enumValues.keySet()) { RestEnumFormProperty enumProperty = new RestEnumFormProperty(); enumProperty.setId(enumId); enumProperty.setName(enumValues.get(enumId)); restFormProp.addEnumValue(enumProperty); } } } else if ("date".equals(restFormProp.getType())) { restFormProp.setDatePattern((String) formProp.getType().getInformation("datePattern")); } result.addFormProperty(restFormProp); } } RestUrlBuilder urlBuilder = createUrlBuilder(); if (formData instanceof StartFormData) { StartFormData startFormData = (StartFormData) formData; if (startFormData.getProcessDefinition() != null) { result.setProcessDefinitionId(startFormData.getProcessDefinition().getId()); result.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, startFormData.getProcessDefinition().getId())); } } else if (formData instanceof TaskFormData) { TaskFormData taskFormData = (TaskFormData) formData; if (taskFormData.getTask() != null) { result.setTaskId(taskFormData.getTask().getId()); result.setTaskUrl(urlBuilder.buildUrl(RestUrls.URL_TASK, taskFormData.getTask().getId())); } } return result; }
Example 2
Source File: ProcessDefinitionPropertiesResource.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@RequestMapping(value = "/process-definition/{processDefinitionId}/properties", method = RequestMethod.GET, produces = "application/json") public ObjectNode getStartFormProperties(@ApiParam(name = "processDefinitionId") @PathVariable String processDefinitionId) { StartFormData startFormData = formService.getStartFormData(processDefinitionId); ObjectNode responseJSON = objectMapper.createObjectNode(); ArrayNode propertiesJSON = objectMapper.createArrayNode(); if (startFormData != null) { List<FormProperty> properties = startFormData.getFormProperties(); for (FormProperty property : properties) { ObjectNode propertyJSON = objectMapper.createObjectNode(); propertyJSON.put("id", property.getId()); propertyJSON.put("name", property.getName()); if (property.getValue() != null) { propertyJSON.put("value", property.getValue()); } else { propertyJSON.putNull("value"); } 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 = objectMapper.createArrayNode(); propertyJSON.put("enumValues", valuesArray); for (String key : valuesMap.keySet()) { ObjectNode valueJSON = 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; }