Skip to content

Commit 28854f2

Browse files
committed
Debuging code
1 parent c29bf07 commit 28854f2

7 files changed

Lines changed: 36 additions & 17 deletions

File tree

‎ProcessMaker/BpmnEngine.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class BpmnEngine implements EngineInterface
3333
* Loaded versioned definitions
3434
*/
3535
private $definitions = [];
36+
public $uid;
3637

3738
/**
3839
* Test engine constructor.
@@ -42,6 +43,7 @@ class BpmnEngine implements EngineInterface
4243
*/
4344
public function __construct(RepositoryInterface $repository, $dispatcher)
4445
{
46+
$this->uid = uniqid();
4547
$this->repository = $repository;
4648
$this->dispatcher = $dispatcher;
4749
}

‎ProcessMaker/Jobs/CatchSignalEvent.php‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ class CatchSignalEvent implements ShouldQueue
4141
public function __construct(ThrowEventInterface $throwEvent, SignalEventDefinition $sourceEventDefinition, TokenInterface $token)
4242
{
4343
$this->eventDefinition = $sourceEventDefinition->getId();
44-
$this->payload = $token->getInstance()->data;
45-
$this->requestId = $token->getInstance()->getId();
44+
$this->payload = $token->processRequest->data;
45+
$this->requestId = $token->processRequest->getKey();
4646
$this->signalRef = $sourceEventDefinition->getProperty('signalRef');
4747
$this->throwEvent = $throwEvent->getId();
48-
$this->tokenId = $token->getId();
48+
$this->tokenId = $token->getKey();
4949
}
5050

5151
public function handle()
@@ -55,6 +55,7 @@ public function handle()
5555
->where('status', 'ACTIVE')
5656
->where('id', '!=', $this->requestId)
5757
->count();
58+
//dump(['requestId' => $this->requestId], ProcessRequest::all()->toArray(), $count);
5859
if ($count) {
5960
$perJob = ceil($count / self::maxJobs);
6061
$requests = ProcessRequest::select(['id'])
@@ -72,7 +73,8 @@ public function handle()
7273
$this->payload,
7374
$this->throwEvent,
7475
$this->eventDefinition,
75-
$this->tokenId
76+
$this->tokenId,
77+
$this->requestId
7678
);
7779
}
7880
}

‎ProcessMaker/Jobs/CatchSignalEventRequest.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,29 @@ class CatchSignalEventRequest implements ShouldQueue
3434
*
3535
* @return void
3636
*/
37-
public function __construct($chunck, $signalRef, $payload, $throwEvent, $eventDefinition, $tokenId)
37+
public function __construct($chunck, $signalRef, $payload, $throwEvent, $eventDefinition, $tokenId, $requestId)
3838
{
3939
$this->chunck = $chunck;
4040
$this->payload = $payload;
4141
$this->signalRef = $signalRef;
4242
$this->throwEvent = $throwEvent;
4343
$this->eventDefinition = $eventDefinition;
4444
$this->tokenId = $tokenId;
45+
$this->requestId = $requestId;
4546
}
4647

4748
public function handle()
4849
{
50+
dump("++++++++++++++++++++++handle");
4951
$mainRequest = ProcessRequest::find($this->requestId);
5052
$definitions = ($mainRequest->processVersion ?? $mainRequest->process)->getDefinitions(true);
5153
$throwEvent = $definitions->findElementById($this->throwEvent)->getBpmnElementInstance();
5254
$eventDefinition = $definitions->findElementById($this->eventDefinition)->getBpmnElementInstance();
5355
$token = ProcessRequestToken::find($this->tokenId);
5456
foreach ($this->chunck as $requestId) {
57+
dump("==============================");
5558
$request = ProcessRequest::find($requestId);
56-
$definitions = ($request->processVersion ?? $request->process)->getDefinitions(true);
59+
$definitions = ($request->processVersion ?? $request->process)->getDefinitions(true, null, false);
5760
$engine = $definitions->getEngine();
5861
$instance = $engine->loadProcessRequest($request);
5962
$engine->getEventDefinitionBus()->dispatchEventDefinition(

‎ProcessMaker/Models/ProcessRequest.php‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
use Illuminate\Database\Eloquent\Model;
77
use Illuminate\Validation\Rule;
88
use Log;
9+
use ProcessMaker\Nayra\Bpmn\Models\IntermediateCatchEvent;
910
use ProcessMaker\Nayra\Contracts\Bpmn\FlowElementInterface;
11+
use ProcessMaker\Nayra\Contracts\Bpmn\IntermediateCatchEventInterface;
1012
use ProcessMaker\Nayra\Contracts\Bpmn\SignalEventDefinitionInterface;
1113
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
1214
use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;
@@ -595,9 +597,13 @@ public function updateCatchEvents()
595597
{
596598
$signalEvents = [];
597599
foreach ($this->tokens as $token) {
598-
$element = $token->getDefinition();
599-
if ($element instanceof SignalEventDefinitionInterface) {
600-
$signalEvents[]= $element->getSignalRef();
600+
$element = $token->getDefinition(true);
601+
if ($element instanceof IntermediateCatchEventInterface) {
602+
foreach ($element->getEventDefinitions() as $eventDefinition) {
603+
if ($eventDefinition instanceof SignalEventDefinitionInterface) {
604+
$signalEvents[]= $eventDefinition->getProperty('signalRef');
605+
}
606+
}
601607
}
602608
}
603609
$this->signal_events = $signalEvents;

‎ProcessMaker/Providers/WorkflowServiceProvider.php‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,20 @@ public function register()
6161
$eventBus = app('events');
6262

6363
//Initialize the BpmnEngine
64-
$engine = empty($params['engine']) ? new BpmnEngine($repository, $eventBus) : $params['engine'];
64+
//$engine = empty($params['engine']) ? new BpmnEngine($repository, $eventBus) : $params['engine'];
65+
$engine = new BpmnEngine($repository, $eventBus);
6566
$eventDefinitionBus = new EventDefinitionBus;
6667
$engine->setEventDefinitionBus($eventDefinitionBus);
6768

6869
// Catch the signal events
69-
$eventDefinitionBus->attachEvent(
70-
SignalEventDefinition::class,
71-
function (ThrowEventInterface $source, EventDefinitionInterface $sourceEventDefinition, TokenInterface $token) {
72-
WorkflowManagerFacade::catchSignalEvent($source, $sourceEventDefinition, $token);
73-
}
74-
);
70+
if ($params['globalEvents']) {
71+
$eventDefinitionBus->attachEvent(
72+
SignalEventDefinition::class,
73+
function (ThrowEventInterface $source, EventDefinitionInterface $sourceEventDefinition, TokenInterface $token) {
74+
WorkflowManagerFacade::catchSignalEvent($source, $sourceEventDefinition, $token);
75+
}
76+
);
77+
}
7578

7679
$engine->setJobManager(new TaskSchedulerManager());
7780

‎ProcessMaker/Repositories/TokenRepository.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public function persistCatchEventTokenArrives(CatchEventInterface $intermediateC
215215
$token->saveOrFail();
216216
$token->setId($token->getKey());
217217
$token->getInstance()->updateCatchEvents();
218+
dump("persistCatchEventTokenArrives " . $token->getInstance()->id);
218219
}
219220

220221
public function persistCatchEventTokenConsumed(CatchEventInterface $intermediateCatchEvent, TokenInterface $token)
@@ -243,6 +244,7 @@ public function persistCatchEventMessageArrives(CatchEventInterface $intermediat
243244
$token->riskchanges_at = null;
244245
$token->saveOrFail();
245246
$token->setId($token->getKey());
247+
dump("persistCatchEventMessageArrives " . $token->getInstance()->id);
246248
}
247249

248250
public function persistCatchEventMessageConsumed(CatchEventInterface $intermediateCatchEvent, TokenInterface $token)

‎ProcessMaker/Traits/ProcessTrait.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ trait ProcessTrait
2222
*
2323
* @return \ProcessMaker\Nayra\Contracts\Storage\BpmnDocumentInterface
2424
*/
25-
public function getDefinitions($forceParse = false, $engine = null)
25+
public function getDefinitions($forceParse = false, $engine = null, $globalEvents = true)
2626
{
2727
if ($forceParse || empty($this->bpmnDefinitions)) {
2828
$options = ['process' => $this instanceof ProcessVersion ? $this->process : $this];
2929
!$engine ?: $options['engine'] = $engine;
30+
$options['globalEvents'] = $globalEvents;
3031
$this->bpmnDefinitions = app(BpmnDocumentInterface::class, $options);
3132
if ($this->bpmn) {
3233
$this->bpmnDefinitions->loadXML($this->bpmn);

0 commit comments

Comments
 (0)