AnsweredAssumed Answered

Problem with Rest API to get BpmnModel of such processDefinition

Question asked by saeidrastak on May 25, 2014
Latest reply on May 25, 2014 by trademak
Hi Community,

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@558930e2; line: 1, column: 670] (through reference chain: org.activiti.bpmn.model.BpmnModel["processes"]->org.activiti.bpmn.model.Process["flowElements"]->org.activiti.bpmn.model.FlowElement["incomingFlows"])
   at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79)
   at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:555)
   at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:708)
   at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1159)
   at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:315)
   at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
   at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:230)
   at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:23)
   at com.fasterxml.jackson.databind.deser.impl.SetterlessProperty.deserializeAndSet(SetterlessProperty.java:116)
   at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:295)
   at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
   at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:230)
   at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:207)
   at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:23)
   at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:449)
   at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:107)
   at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:295)
   at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
   at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)
   at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
   …


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.


Best Regards.



Outcomes