Package org.activiti.bpmn.model

Examples of org.activiti.bpmn.model.Message


  public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception {
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
      String messageId = model.getTargetNamespace() + ":" + xtr.getAttributeValue(null, ATTRIBUTE_ID);
      String messageName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
      String itemRef = parseItemRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_REF), model);
      Message message = new Message(messageId, messageName, itemRef);
      BpmnXMLUtil.addXMLLocation(message, xtr);
      BpmnXMLUtil.parseChildElements(ELEMENT_MESSAGE, message, xtr, model);
      model.addMessage(message);
    }
  }
View Full Code Here


            }

          } else if (eventDefinition instanceof MessageEventDefinition) {
            MessageEventDefinition messageEvent = (MessageEventDefinition) eventDefinition;
            if (model.containsMessageId(messageEvent.getMessageRef()) == false) {
              Message message = new Message(messageEvent.getMessageRef(), messageEvent.getMessageRef(), null);
              model.addMessage(message);
            }
          }
        }
      }
    }
   
    for (Signal signal : model.getSignals()) {
      xtw.writeStartElement(ELEMENT_SIGNAL);
      xtw.writeAttribute(ATTRIBUTE_ID, signal.getId());
      xtw.writeAttribute(ATTRIBUTE_NAME, signal.getName());
      if (signal.getScope() != null) {
        xtw.writeAttribute(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_SCOPE, signal.getScope());
      }
      xtw.writeEndElement();
    }
   
    for (Message message : model.getMessages()) {
      xtw.writeStartElement(ELEMENT_MESSAGE);
      String messageId = message.getId();
      // remove the namespace from the message id if set
      if (model.getTargetNamespace() != null && messageId.startsWith(model.getTargetNamespace())) {
        messageId = messageId.replace(model.getTargetNamespace(), "");
        messageId = messageId.replaceFirst(":", "");
      } else {
        for (String prefix : model.getNamespaces().keySet()) {
          String namespace = model.getNamespace(prefix);
          if (messageId.startsWith(namespace)) {
            messageId = messageId.replace(model.getTargetNamespace(), "");
            messageId = prefix + messageId;
          }
        }
      }
      xtw.writeAttribute(ATTRIBUTE_ID, messageId);
      if (StringUtils.isNotEmpty(message.getName())) {
        xtw.writeAttribute(ATTRIBUTE_NAME, message.getName());
      }
      if (StringUtils.isNotEmpty(message.getItemRef())) {
        xtw.writeAttribute(ATTRIBUTE_ITEM_REF, message.getItemRef());
      }
      xtw.writeEndElement();
    }
  }
View Full Code Here

  protected void executeParse(BpmnParse bpmnParse, MessageEventDefinition messageDefinition) {
   
    BpmnModel bpmnModel = bpmnParse.getBpmnModel();
    String messageRef = messageDefinition.getMessageRef();
    if (bpmnModel.containsMessageId(messageRef)) {
      Message message = bpmnModel.getMessage(messageRef);
      messageDefinition.setMessageRef(message.getName());
      messageDefinition.setExtensionElements(message.getExtensionElements());
    }
   
    EventSubscriptionDeclaration eventSubscription = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");

    ScopeImpl scope = bpmnParse.getCurrentScope();
View Full Code Here

  @Test
  public void testParseMessagedDefinitionWithExtension() {
    BpmnParse bpmnParseMock = Mockito.mock(BpmnParse.class);
    MessageEventDefinition messageEventDefinitionMock = Mockito.mock(MessageEventDefinition.class);
    BpmnModel bpmnModelMock = Mockito.mock(BpmnModel.class);
    Message messageMock = Mockito.mock(Message.class);
    @SuppressWarnings("unchecked")
    Map<String,List<ExtensionElement>> extensionElementMap = Mockito.mock(Map.class);
   
    Mockito.when(bpmnParseMock.getBpmnModel()).thenReturn(bpmnModelMock);
    Mockito.when(messageEventDefinitionMock.getMessageRef()).thenReturn("messageId");
    Mockito.when(bpmnModelMock.containsMessageId("messageId")).thenReturn(true);
    Mockito.when(bpmnModelMock.getMessage("messageId")).thenReturn(messageMock);
    Mockito.when(messageMock.getName()).thenReturn("MessageWithExtensionElements");
    Mockito.when(messageMock.getExtensionElements()).thenReturn(extensionElementMap);
   
    MessageEventDefinitionParseHandler handler = new MessageEventDefinitionParseHandler();
    handler.parse(bpmnParseMock, messageEventDefinitionMock);

    Mockito.verify(messageEventDefinitionMock).setMessageRef("MessageWithExtensionElements");
View Full Code Here

        for (TableItem item : getItems()) {
          String id = item.getText(0);
          String name = item.getText(1);
          if(StringUtils.isNotEmpty(id) && StringUtils.isNotEmpty(name)) {
           
            Message newMessage = new Message();
            newMessage.setId(id);
            newMessage.setName(name);
            newMessageList.add(newMessage);
          }
        }
        model.getBpmnModel().setMessages(newMessageList);
      }
View Full Code Here

TOP

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

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.