Skip to content

Updating feature branch FOUR-11378 with last changes in develop #5728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions ProcessMaker/Console/Commands/OptimizeClearCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace ProcessMaker\Console\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'optimize:clear')]
class OptimizeClearCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'optimize:clear';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Remove the cached bootstrap files';

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->components->info('Clearing cached bootstrap files.');

collect([
'events' => fn () => $this->callSilent('event:clear') == 0,
'views' => fn () => $this->callSilent('view:clear') == 0,
'route' => fn () => $this->callSilent('route:clear') == 0,
])->each(fn ($task, $description) => $this->components->task($description, $task));

$this->newLine();
}
}
25 changes: 20 additions & 5 deletions ProcessMaker/Nayra/Managers/WorkflowManagerDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use ProcessMaker\Nayra\Contracts\Bpmn\ThrowEventInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;
use ProcessMaker\Repositories\DefinitionsRepository;

class WorkflowManagerDefault implements WorkflowManagerInterface
{
Expand Down Expand Up @@ -265,12 +264,28 @@ public function throwSignalEventDefinition(EventDefinitionInterface $sourceEvent
}

$excludeProcesses = [$token->getInstance()->getModel()->process_id];
$excludeRequests = [];
$instances = $token->getInstance()->getProcess()->getEngine()->getExecutionInstances();

$excludeRequests = $this->getCollaboratingInstanceIds($token->getInstance());
ThrowSignalEvent::dispatch($signalRef, $data, $excludeProcesses, $excludeRequests)->onQueue('bpmn');
}

/**
* Retrieves IDs of all instances collaborating with the given instance.
*
* This function compiles a list of IDs from execution instances associated
* with the same process as the input instance, including the instance itself.
*
* @param ProcessRequest $instance The instance to find collaborators for.
* @return int[] Array of collaborating instance IDs.
*/
protected function getCollaboratingInstanceIds($instance)
{
$ids = [];
$instances = $instance->getProcess()->getEngine()->getExecutionInstances();
foreach ($instances as $instance) {
$excludeRequests[] = $instance->getId();
$ids[] = $instance->getId();
}
ThrowSignalEvent::dispatch($signalRef, $data, $excludeProcesses, $excludeRequests)->onQueue('bpmn');
return $ids;
}

/**
Expand Down
18 changes: 18 additions & 0 deletions ProcessMaker/Nayra/Managers/WorkflowManagerRabbitMq.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,24 @@ public function throwSignalEventRequest(ProcessRequest $request, $signalRef, arr
]);
}

/**
* Retrieves IDs of all instances collaborating with the given instance.
*
* This function compiles a list of IDs from execution instances associated
* with the same process as the input instance, including the instance itself.
*
* @param ProcessRequest $instance The instance to find collaborators for.
* @return int[] Array of collaborating instance IDs.
*/
protected function getCollaboratingInstanceIds($instance)
{
$ids = ProcessRequest::
where('process_collaboration_id', $instance->process_collaboration_id)
->pluck('id')
->toArray();
return $ids;
}

/**
* Build a state object.
*
Expand Down
3 changes: 3 additions & 0 deletions ProcessMaker/Nayra/Repositories/PersistenceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public function save(array $transaction)
case 'start_event_triggered':
$this->persistStartEventTriggered($transaction);
break;
case 'throw_global_signal_event':
$this->throwGlobalSignalEvent($transaction);
break;
case 'event_based_gateway_activated':
$this->persistEventBasedGatewayActivated($transaction);
break;
Expand Down
22 changes: 20 additions & 2 deletions ProcessMaker/Nayra/Repositories/PersistenceTokenTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace ProcessMaker\Nayra\Repositories;

use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use ProcessMaker\Facades\WorkflowManager;
use ProcessMaker\Listeners\BpmnSubscriber;
use ProcessMaker\Listeners\CommentsSubscriber;
use ProcessMaker\Nayra\Bpmn\Events\ActivityActivatedEvent;
Expand Down Expand Up @@ -165,9 +167,17 @@ public function persistGatewayTokenConsumed(array $transaction)
public function persistGatewayTokenPassed(array $transaction)
{
$gateway = $this->deserializer->unserializeEntity($transaction['gateway']);
$transition = $this->deserializer->unserializeEntity($transaction['transition']);
if (!is_numeric($transaction['transition'])) {
Log::info('Invalid transition id for gateway token passed. ' . json_encode($transaction));
return;
}
$transition = $gateway->getTransitions()[$transaction['transition']] ?? null;
if (empty($transition)) {
Log::info('Invalid transition for gateway token passed. ' . json_encode($transaction));
return;
}
$tokens = $this->deserializer->unserializeTokensCollection($transaction['tokens']);
$this->tokenRepository->persistGatewayTokenPassed($gateway, $tokens[0]);
$this->tokenRepository->persistGatewayTokenPassed($gateway, $tokens->item(0));

// Comments
$subscriber = new CommentsSubscriber();
Expand Down Expand Up @@ -298,4 +308,12 @@ public function persistAbout(array $aboutInfo)
error_log("Microservice $name version $version is running.");
Cache::put(self::$aboutCacheKey, $aboutInfo, 60);
}

public function throwGlobalSignalEvent(array $transaction)
{
$throwElement = $this->deserializer->unserializeEntity($transaction['throw_element']);
$token = $transaction['token'] ? $this->deserializer->unserializeToken($transaction['token']) : null;
$eventDefinition = $throwElement->getEventDefinitions()->item(0);
WorkflowManager::throwSignalEventDefinition($eventDefinition, $token);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"Gmail"
],
"processmaker": {
"build": "e24a3c60",
"build": "aa23ed0e",
"custom": {
"package-ellucian-ethos": "1.14.1",
"package-plaid": "1.3.1",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.