Package org.activiti.bpmn.model

Examples of org.activiti.bpmn.model.ActivitiListener


*/
public abstract class ActivitiListenerParser extends BaseChildElementParser {
 
  public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
   
    ActivitiListener listener = new ActivitiListener();
    BpmnXMLUtil.addXMLLocation(listener, xtr);
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS))) {
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS));
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
    } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EXPRESSION))) {
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EXPRESSION));
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
    } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION))) {
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION));
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
    }
    listener.setEvent(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EVENT));
    addListenerToParent(listener, parentElement);
    parseChildElements(xtr, listener, model, new FieldExtensionParser());
  }
View Full Code Here


    validateExtensionElements(extensionElementMap);
  }
 
  protected void validateExecutionListeners(List<ActivitiListener> listeners) {
    assertEquals(3, listeners.size());
    ActivitiListener listener = (ActivitiListener) listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
    assertEquals("org.test.TestClass", listener.getImplementation());
    assertEquals("start", listener.getEvent());
    listener = (ActivitiListener) listeners.get(1);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${testExpression}", listener.getImplementation());
    assertEquals("end", listener.getEvent());
    listener = (ActivitiListener) listeners.get(2);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${delegateExpression}", listener.getImplementation());
    assertEquals("start", listener.getEvent());
  }
View Full Code Here

    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);
        }
      }
View Full Code Here

    addScript(INCOMING_PRIORITY_TEMPLATE);
  }
 
  public ActivitiListener build() {
    if(listener == null) {
      listener = new ActivitiListener();
      listener.setEvent(event);
      listener.setImplementationType(BpmnXMLConstants.ATTRIBUTE_LISTENER_CLASS);
      listener.setImplementation(AlfrescoConversionConstants.CLASSNAME_SCRIPT_TASK_LISTENER);
     
      FieldExtension scriptFieldElement = new FieldExtension();
View Full Code Here

    StartEvent startEvent = new StartEvent();
    startEvent.setId("startEvent1");
    TimerEventDefinition timerDef = new TimerEventDefinition();
    timerDef.setTimeDuration("PT5M");
    startEvent.getEventDefinitions().add(timerDef);
    ActivitiListener listener = new ActivitiListener();
    listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
    listener.setImplementation("${test}");
    listener.setEvent("end");
    startEvent.getExecutionListeners().add(listener);
    process.addFlowElement(startEvent);
    UserTask task = new UserTask();
    task.setId("reviewTask");
    task.setAssignee("kermit");
View Full Code Here

    assertEquals("testField2", field.getFieldName());
    assertEquals("${test}", field.getExpression());
   
    List<ActivitiListener> listeners = serviceTask.getExecutionListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = (ActivitiListener) listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
    assertEquals("org.test.TestClass", listener.getImplementation());
    assertEquals("start", listener.getEvent());
    listener = (ActivitiListener) listeners.get(1);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${testExpression}", listener.getImplementation());
    assertEquals("end", listener.getEvent());
    listener = (ActivitiListener) listeners.get(2);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${delegateExpression}", listener.getImplementation());
    assertEquals("start", listener.getEvent());
  }
View Full Code Here

    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
   
    List<ActivitiListener> listeners = userTask.getTaskListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = (ActivitiListener) listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
    assertEquals("org.test.TestClass", listener.getImplementation());
    assertEquals("create", listener.getEvent());
    listener = (ActivitiListener) listeners.get(1);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someExpression}", listener.getImplementation());
    assertEquals("assignment", listener.getEvent());
    listener = (ActivitiListener) listeners.get(2);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someDelegateExpression}", listener.getImplementation());
    assertEquals("complete", listener.getEvent());
  }
View Full Code Here

        return;
      }
      TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain();
      ActivitiUiUtil.runModelChange(new Runnable() {
        public void run() {
          ActivitiListener newListener = new ActivitiListener();
          newListener.setEvent(dialog.eventName);
          newListener.setImplementationType(dialog.implementationType);
          newListener.setImplementation(dialog.implementation);
          if(AlfrescoUserTask.ALFRESCO_SCRIPT_TASK_LISTENER.equalsIgnoreCase(dialog.implementation) ||
                  AlfrescoScriptTask.ALFRESCO_SCRIPT_EXECUTION_LISTENER.equalsIgnoreCase(dialog.implementation)) {
           
            FieldExtension scriptExtension = new FieldExtension();
            scriptExtension.setFieldName("script");
            scriptExtension.setStringValue(dialog.script);
            newListener.getFieldExtensions().add(scriptExtension);
           
            FieldExtension runAsExtension = new FieldExtension();
            runAsExtension.setFieldName("runAs");
            runAsExtension.setStringValue(dialog.runAs);
            newListener.getFieldExtensions().add(runAsExtension);
           
            FieldExtension scriptProcessorExtension = new FieldExtension();
            scriptProcessorExtension.setFieldName("scriptProcessor");
            scriptProcessorExtension.setStringValue(dialog.scriptProcessor);
            newListener.getFieldExtensions().add(scriptProcessorExtension);
           
          } else {
            setFieldsInListener(newListener, dialog.fieldExtensionList);
          }
          BpmnBOUtil.addListener(bo, newListener, diagram);
View Full Code Here

        return;
      }
      TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain();
      ActivitiUiUtil.runModelChange(new Runnable() {
        public void run() {
          ActivitiListener listener = listenerList.get(index);
          if(listener != null) {
            listener.setEvent(dialog.eventName);
            listener.setImplementation(dialog.implementation);
            listener.setImplementationType(dialog.implementationType);
            if(AlfrescoUserTask.ALFRESCO_SCRIPT_TASK_LISTENER.equalsIgnoreCase(dialog.implementation) ||
                    AlfrescoScriptTask.ALFRESCO_SCRIPT_EXECUTION_LISTENER.equalsIgnoreCase(dialog.implementation)) {
             
              List<FieldExtension> extensionList = listener.getFieldExtensions();
              FieldExtension scriptExtension = null;
              FieldExtension runAsExtension = null;
              FieldExtension scriptProcessorExtension = null;
              for (FieldExtension fieldExtension : extensionList) {
                if ("script".equalsIgnoreCase(fieldExtension.getFieldName())) {
                  scriptExtension = fieldExtension;
                } else if ("runAs".equalsIgnoreCase(fieldExtension.getFieldName())) {
                  runAsExtension = fieldExtension;
                } else if ("scriptProcessor".equalsIgnoreCase(fieldExtension.getFieldName())) {
                  scriptProcessorExtension = fieldExtension;
                }
              }
             
              if (scriptExtension != null) {
                scriptExtension.setStringValue(dialog.script);
              } else {
                scriptExtension = new FieldExtension();
                scriptExtension.setFieldName("script");
                scriptExtension.setStringValue(dialog.script);
                listener.getFieldExtensions().add(scriptExtension);
              }
             
              if (runAsExtension != null) {
                runAsExtension.setStringValue(dialog.runAs);
              } else {
                runAsExtension = new FieldExtension();
                runAsExtension.setFieldName("runAs");
                runAsExtension.setStringValue(dialog.runAs);
                listener.getFieldExtensions().add(runAsExtension);
              }
             
              if (scriptProcessorExtension != null) {
                scriptProcessorExtension.setStringValue(dialog.scriptProcessor);
              } else {
                scriptProcessorExtension = new FieldExtension();
                scriptProcessorExtension.setFieldName("scriptProcessor");
                scriptProcessorExtension.setStringValue(dialog.scriptProcessor);
                listener.getFieldExtensions().add(scriptProcessorExtension);
              }
             
            } else {
              setFieldsInListener(listener, dialog.fieldExtensionList);
            }
View Full Code Here

    final Object bo = BpmnBOUtil.getExecutionListenerBO(pictogramElement, diagram);
    if (bo != null) {
      TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain();
      ActivitiUiUtil.runModelChange(new Runnable() {
        public void run() {
          ActivitiListener listener = listenerList.remove(index);
          listenerList.add(index - 1, listener);
        }
      }, editingDomain, "Model Update");
    }
    super.upPressed();
View Full Code Here

TOP

Related Classes of org.activiti.bpmn.model.ActivitiListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.