use of org.activiti.engine.impl.form.EnumFormType in project Activiti by Activiti.
the class ProcessDefinitionPropertiesResource method getStartFormProperties.
@RequestMapping(value = "/process-definition/{processDefinitionId}/properties", method = RequestMethod.GET, produces = "application/json")
public ObjectNode getStartFormProperties(@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;
}
use of org.activiti.engine.impl.form.EnumFormType in project carbon-business-process by wso2.
the class ProcessDefinitionFormPropertyService method getStartFormProperties.
@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();
}
Aggregations