if (itemsArrayNode != null) {
for (JsonNode itemNode : itemsArrayNode) {
JsonNode typeNode = itemNode.get(PROPERTY_EXECUTION_LISTENER_EVENT);
if (typeNode != null && StringUtils.isNotEmpty(typeNode.asText())) {
ActivitiListener listener = new ActivitiListener();
listener.setEvent(typeNode.asText());
if (StringUtils.isNotEmpty(itemNode.get(PROPERTY_EXECUTION_LISTENER_CLASS).asText())) {
listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
listener.setImplementation(itemNode.get(PROPERTY_EXECUTION_LISTENER_CLASS).asText());
} else if (StringUtils.isNotEmpty(itemNode.get(PROPERTY_EXECUTION_LISTENER_EXPRESSION).asText())) {
listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
listener.setImplementation(itemNode.get(PROPERTY_EXECUTION_LISTENER_EXPRESSION).asText());
} else if (StringUtils.isNotEmpty(itemNode.get(PROPERTY_EXECUTION_LISTENER_DELEGATEEXPRESSION).asText())) {
listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
listener.setImplementation(itemNode.get(PROPERTY_EXECUTION_LISTENER_DELEGATEEXPRESSION).asText());
}
// resolve the listener feild
JsonNode listenerFieldsNode = null;
JsonNode listenerFieldsArrayNode = null;
listenerFieldsNode = itemNode.get(PROPERTY_EXECUTION_LISTENER_FIELDS);
if (listenerFieldsNode != null && StringUtils.isNotEmpty(listenerFieldsNode.asText()) && !("undefined".equals(listenerFieldsNode.asText()))){
if(listenerFieldsNode.isValueNode()){
try{
listenerFieldsNode = objectMapper.readTree(listenerFieldsNode.asText());
} catch(Exception e){
LOGGER.info("Listener fields node can not be read", e);
}
}
}
if (listenerFieldsNode != null) {
listenerFieldsArrayNode = listenerFieldsNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
List<FieldExtension> fields = new ArrayList<FieldExtension>();
if (listenerFieldsArrayNode != null) {
for (JsonNode fieldNode : listenerFieldsArrayNode){
JsonNode fieldNameNode = fieldNode.get(PROPERTY_EXECUTION_LISTENER_FIELD_NAME);
if (fieldNameNode != null && StringUtils.isNotEmpty(fieldNameNode.asText())){
FieldExtension field = new FieldExtension();
field.setFieldName(fieldNameNode.asText());
field.setStringValue(getValueAsString(PROPERTY_EXECUTION_LISTENER_FIELD_VALUE, fieldNode));
field.setExpression(getValueAsString(PROPERTY_EXECUTION_LISTENER_EXPRESSION, fieldNode));
fields.add(field);
}
}
}
listener.setFieldExtensions(fields);
}
executionListeners.add(listener);
}
}