Add support for Json mapping in Rest API (for converting BpmnModel class)



i wrote this method to get BpmnModel of such ProcessDefinition:

1 @Override
2 public BpmnModel getBpmnModelResource(String processDefinitionId) {
3 ObjectMapper mapper = new ObjectMapper();
4 String path = serverConfig.getServicePath() + "repository/process-definitions/{processDefinitionId}/model";
5 UriComponents uriComponents = UriComponentsBuilder.newInstance().scheme("http").host(serverConfig.getServerIP()).
6 port(serverConfig.getServerPort()).path(path).build().expand(processDefinitionId);
7 String json = restTemplate.getForObject(uriComponents.toUri(), String.class);
8 try {
9 return mapper.readValue(json, BpmnModel.class);
10 } catch (IOException e) {
11 e.printStackTrace();
12 }
13 return null;
14 }

i got this exception in line 9:

INFO: XML driver implementation: com.thoughtworks.xstream.io.xml.StaxDriver
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "incomingFlows" (class org.activiti.bpmn.model.FlowElement), not marked as ignorable (8 known properties: , "xmlColumnNumber", "extensionElements", "attributes", "executionListeners", "documentation", "id", "name", "xmlRowNumber"])
at Source: java.io.StringReader@558930e; line: 1, column: 670
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79)
....

after that i copy the BpmnModel, FlowElement,... and related class from bpmn model project to my source and refactor them.
then add @JsonIgnoreProperties(ignoreUnknown = true) annotation to BpmnModel and FlowElement:

@JsonIgnoreProperties(ignoreUnknown = true)
public class BpmnModel {
...


@JsonIgnoreProperties(ignoreUnknown = true)
public class FlowElement extends BaseElement implements HasExecutionListeners {
...

and then everything is ok.

The changes made are correct?
If possible, be placed in the project source code.