Search in sources :

Example 26 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project jbpm by kiegroup.

the class MessageDescImplTest method testNotEqualsHashCode.

@Test
public void testNotEqualsHashCode() {
    Message message1 = new Message("id");
    Message message2 = new Message("id");
    message2.setName("name");
    message2.setName("type");
    MessageDesc messageDesc1 = MessageDescImpl.from(message1);
    MessageDesc messageDesc2 = MessageDescImpl.from(message2);
    assertNotEquals(messageDesc1.hashCode(), messageDesc2.hashCode());
    assertNotEquals(messageDesc1, messageDesc2);
}
Also used : Message(org.jbpm.bpmn2.core.Message) MessageDesc(org.jbpm.services.api.model.MessageDesc) Test(org.junit.Test)

Example 27 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project jbpm by kiegroup.

the class SignalDescImplTest method testSignalIsNotMessage.

@Test
public void testSignalIsNotMessage() {
    SignalDescBase signalDesc1 = SignalDescImpl.from(new Signal("id", "id"));
    SignalDescBase signalDesc2 = MessageDescImpl.from(new Message("id"));
    assertEquals(signalDesc1.getId(), signalDesc2.getId());
    assertEquals(signalDesc1.getName(), signalDesc2.getName());
    assertNotEquals(signalDesc1, signalDesc2);
}
Also used : Signal(org.jbpm.bpmn2.core.Signal) Message(org.jbpm.bpmn2.core.Message) SignalDescBase(org.jbpm.services.api.model.SignalDescBase) Test(org.junit.Test)

Example 28 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project droolsjbpm-integration by kiegroup.

the class KafkaServerRegistrationTest method testVersionedDeployment.

@Test
public void testVersionedDeployment() {
    KafkaServerRegistration register = new KafkaServerRegistration();
    DeployedUnitImpl du1 = new DeployedUnitImpl(new KModuleDeploymentUnit("individuo", "pepe", "1.0"));
    DeployedUnitImpl du2 = new DeployedUnitImpl(new KModuleDeploymentUnit("individuo", "pepe", "2.0"));
    Message message = new Message("pepe");
    message.setName("pepe");
    Node node = mock(Node.class);
    message.addIncomingNode(node);
    MessageDesc signal = MessageDescImpl.from(message);
    ProcessAssetDesc processDesc = new ProcessAssetDesc();
    processDesc.setMessagesDesc(Collections.singletonList(signal));
    du1.addAssetLocation("pepe", processDesc);
    du2.addAssetLocation("pepe", processDesc);
    DeploymentEvent event1 = new DeploymentEvent(du1.getDeploymentUnit().getIdentifier(), du1);
    DeploymentEvent event2 = new DeploymentEvent(du2.getDeploymentUnit().getIdentifier(), du2);
    register.addRegistration(event1);
    register.addRegistration(event2);
    ConsumerRecord<String, byte[]> record = mock(ConsumerRecord.class);
    when(record.topic()).thenReturn("pepe");
    KafkaServerEventProcessor<MessageDesc> processor = mock(KafkaServerEventProcessor.class);
    register.forEachMessage(record, processor);
    verify(processor).accept(record, event1.getDeploymentId(), signal);
    verify(processor).accept(record, event2.getDeploymentId(), signal);
    reset(processor);
    message.addIncomingNode(mock(StartNode.class));
    register.forEachMessage(record, processor);
    verify(processor, times(0)).accept(record, event1.getDeploymentId(), signal);
    verify(processor).accept(record, event2.getDeploymentId(), signal);
}
Also used : StartNode(org.jbpm.workflow.core.node.StartNode) ProcessAssetDesc(org.jbpm.kie.services.impl.model.ProcessAssetDesc) Message(org.jbpm.bpmn2.core.Message) StartNode(org.jbpm.workflow.core.node.StartNode) Node(org.kie.api.definition.process.Node) DeployedUnitImpl(org.jbpm.kie.services.impl.DeployedUnitImpl) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) MessageDesc(org.jbpm.services.api.model.MessageDesc) DeploymentEvent(org.jbpm.services.api.DeploymentEvent) Test(org.junit.Test)

Example 29 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project kogito-runtimes by kiegroup.

the class ProcessHandler method postProcessCollaborations.

private void postProcessCollaborations(RuleFlowProcess process, ExtensibleXmlParser parser) {
    // now we wire correlation process subscriptions
    CorrelationManager correlationManager = process.getCorrelationManager();
    for (Message message : HandlerUtil.messages(parser).values()) {
        correlationManager.newMessage(message.getId(), message.getName(), message.getType());
    }
    // only the ones this process is member of
    List<Collaboration> collaborations = HandlerUtil.collaborations(parser).values().stream().filter(c -> c.getProcessesRef().contains(process.getId())).collect(Collectors.toList());
    for (Collaboration collaboration : collaborations) {
        for (CorrelationKey key : collaboration.getCorrelationKeys()) {
            correlationManager.newCorrelation(key.getId(), key.getName());
            List<CorrelationProperty> properties = key.getPropertiesRef().stream().map(k -> HandlerUtil.correlationProperties(parser).get(k)).collect(Collectors.toList());
            for (CorrelationProperty correlationProperty : properties) {
                correlationProperty.getMessageRefs().forEach(messageRef -> {
                    // for now only MVEL expressions
                    MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(correlationProperty.getRetrievalExpression(messageRef).getScript());
                    correlationManager.addMessagePropertyExpression(key.getId(), messageRef, correlationProperty.getId(), evaluator);
                });
            }
        }
    }
    // we create the correlations
    for (CorrelationSubscription subscription : HandlerUtil.correlationSubscription(process).values()) {
        correlationManager.subscribeTo(subscription.getCorrelationKeyRef());
        for (Map.Entry<String, Expression> binding : subscription.getPropertyExpressions().entrySet()) {
            MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(binding.getValue().getScript());
            correlationManager.addProcessSubscriptionPropertyExpression(subscription.getCorrelationKeyRef(), binding.getKey(), evaluator);
        }
    }
}
Also used : EventFilter(org.jbpm.process.core.event.EventFilter) ConstraintTrigger(org.jbpm.workflow.core.node.ConstraintTrigger) CorrelationManager(org.jbpm.process.core.correlation.CorrelationManager) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) LoggerFactory(org.slf4j.LoggerFactory) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) StartNode(org.jbpm.workflow.core.node.StartNode) CorrelationProperty(org.jbpm.bpmn2.core.CorrelationProperty) RuleFlowProcessValidator(org.jbpm.ruleflow.core.validation.RuleFlowProcessValidator) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition) Constraint(org.jbpm.workflow.core.Constraint) ExtensibleXmlParser(org.drools.core.xml.ExtensibleXmlParser) Association(org.jbpm.bpmn2.core.Association) Connection(org.jbpm.workflow.core.Connection) StateNode(org.jbpm.workflow.core.node.StateNode) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) RuleSetNode(org.jbpm.workflow.core.node.RuleSetNode) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Signal(org.jbpm.bpmn2.core.Signal) CancelNodeInstanceAction(org.jbpm.process.instance.impl.actions.CancelNodeInstanceAction) SubProcessNode(org.jbpm.workflow.core.node.SubProcessNode) EventTrigger(org.jbpm.workflow.core.node.EventTrigger) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) Collaboration(org.jbpm.bpmn2.core.Collaboration) Collection(java.util.Collection) Process(org.kie.api.definition.process.Process) VariableScope(org.jbpm.process.core.context.variable.VariableScope) KogitoNode(org.kie.kogito.internal.process.runtime.KogitoNode) Collectors(java.util.stream.Collectors) IntermediateLink(org.jbpm.bpmn2.core.IntermediateLink) ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler) Message(org.jbpm.bpmn2.core.Message) List(java.util.List) Error(org.jbpm.bpmn2.core.Error) Stream(java.util.stream.Stream) ContextContainer(org.jbpm.process.core.ContextContainer) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) SAXException(org.xml.sax.SAXException) CorrelationKey(org.jbpm.bpmn2.core.CorrelationKey) ProcessInstanceCompensationAction(org.jbpm.process.instance.impl.actions.ProcessInstanceCompensationAction) Trigger(org.jbpm.workflow.core.node.Trigger) NodeContainer(org.kie.api.definition.process.NodeContainer) DataStore(org.jbpm.bpmn2.core.DataStore) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) SignalProcessInstanceAction(org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) CompensationScope(org.jbpm.process.core.context.exception.CompensationScope) Escalation(org.jbpm.bpmn2.core.Escalation) Split(org.jbpm.workflow.core.node.Split) HashMap(java.util.HashMap) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) ArrayList(java.util.ArrayList) Lane(org.jbpm.bpmn2.core.Lane) Timer(org.jbpm.process.core.timer.Timer) HashSet(java.util.HashSet) Expression(org.jbpm.bpmn2.core.Expression) Swimlane(org.jbpm.process.core.context.swimlane.Swimlane) Attributes(org.xml.sax.Attributes) BaseAbstractHandler(org.drools.core.xml.BaseAbstractHandler) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) FaultNode(org.jbpm.workflow.core.node.FaultNode) DroolsAction(org.jbpm.workflow.core.DroolsAction) LinkedHashSet(java.util.LinkedHashSet) CorrelationSubscription(org.jbpm.bpmn2.core.CorrelationSubscription) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) Interface(org.jbpm.bpmn2.core.Interface) ConnectionRef(org.jbpm.workflow.core.impl.ConnectionRef) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) Logger(org.slf4j.Logger) Metadata(org.jbpm.ruleflow.core.Metadata) EventNode(org.jbpm.workflow.core.node.EventNode) ConstraintImpl(org.jbpm.workflow.core.impl.ConstraintImpl) Handler(org.drools.core.xml.Handler) MVELMessageExpressionEvaluator(org.jbpm.process.core.event.MVELMessageExpressionEvaluator) Node(org.kie.api.definition.process.Node) CompensationHandler(org.jbpm.process.core.context.exception.CompensationHandler) Definitions(org.jbpm.bpmn2.core.Definitions) Action(org.jbpm.process.instance.impl.Action) KogitoWorkflowProcess(org.kie.kogito.internal.process.runtime.KogitoWorkflowProcess) ExtendedNodeImpl(org.jbpm.workflow.core.impl.ExtendedNodeImpl) MVELMessageExpressionEvaluator(org.jbpm.process.core.event.MVELMessageExpressionEvaluator) Message(org.jbpm.bpmn2.core.Message) CorrelationSubscription(org.jbpm.bpmn2.core.CorrelationSubscription) CorrelationManager(org.jbpm.process.core.correlation.CorrelationManager) CorrelationKey(org.jbpm.bpmn2.core.CorrelationKey) Expression(org.jbpm.bpmn2.core.Expression) Collaboration(org.jbpm.bpmn2.core.Collaboration) CorrelationProperty(org.jbpm.bpmn2.core.CorrelationProperty) Map(java.util.Map) HashMap(java.util.HashMap)

Example 30 with Message

use of io.automatiko.engine.workflow.bpmn2.core.Message in project kogito-runtimes by kiegroup.

the class ReceiveTaskHandler method handleNode.

@SuppressWarnings("unchecked")
protected Node handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    WorkItemNode workItemNode = (WorkItemNode) node;
    String messageRef = element.getAttribute("messageRef");
    Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
    if (messages == null) {
        throw new ProcessParsingValidationException("No messages found");
    }
    Message message = messages.get(messageRef);
    if (message == null) {
        throw new ProcessParsingValidationException("Could not find message " + messageRef);
    }
    workItemNode.getWork().setParameter("MessageId", message.getId());
    workItemNode.getWork().setParameter("MessageType", message.getType());
    return node;
}
Also used : Message(org.jbpm.bpmn2.core.Message) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) Map(java.util.Map)

Aggregations

Map (java.util.Map)28 Message (org.jbpm.bpmn2.core.Message)27 Element (org.w3c.dom.Element)16 ArrayList (java.util.ArrayList)14 Message (io.automatiko.engine.workflow.bpmn2.core.Message)9 Test (org.junit.Test)9 List (java.util.List)7 EventFilter (org.jbpm.process.core.event.EventFilter)7 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)7 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)6 Signal (org.jbpm.bpmn2.core.Signal)5 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)5 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)5 StartNode (org.jbpm.workflow.core.node.StartNode)5 HashMap (java.util.HashMap)4 Error (org.jbpm.bpmn2.core.Error)4 Escalation (org.jbpm.bpmn2.core.Escalation)4 ConstraintTrigger (org.jbpm.workflow.core.node.ConstraintTrigger)4 EventNode (org.jbpm.workflow.core.node.EventNode)4 Node (org.kie.api.definition.process.Node)4