use of org.wso2.carbon.bpmn.rest.model.form.FormPropertyResponseCollection 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