Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
91e87f0
feat: add cases_started migration
Sep 9, 2024
794c160
feat: add cases started model
Sep 9, 2024
55d771c
feat: add new get_all_cases endpoint
Sep 11, 2024
a1ca7a7
Merge branch 'feature/FOUR-18078' into FOUR-18603
Sep 11, 2024
2fc73d7
fix cr observations
Sep 12, 2024
caa509c
Merge pull request #7357 from ProcessMaker/FOUR-18603
caleeli Sep 12, 2024
d1313a2
feat: add cases_participated migration
Sep 12, 2024
9d58af0
feat: add cases_participated model, factory
Sep 12, 2024
1b66edf
feat: add get_in_progress, get_completed endpoints
Sep 13, 2024
c2ee011
feat: add case repository
Sep 13, 2024
5e23427
feat: add validation exception
Sep 13, 2024
63de52c
Merge branch 'next' into feature/FOUR-18078
Sep 16, 2024
eecbdf7
Merge branch 'feature/FOUR-18078' into FOUR-18604
Sep 16, 2024
dfb39d4
Update enterprise package
ryancooley Sep 16, 2024
7b3b940
Version 4.11.2-RC3
ryancooley Sep 16, 2024
c2415e6
Version 4.11.2
ryancooley Sep 17, 2024
0936002
tests: case controller ep tests
Sep 16, 2024
20f8998
Merge pull request #7372 from ProcessMaker/FOUR-18604
caleeli Sep 17, 2024
840dd24
Set elementDestination to null for 'taskSource' case
eiresendez Sep 18, 2024
60831c9
Merge pull request #7382 from ProcessMaker/bug/FOUR-19210
ryancooley Sep 19, 2024
1763205
Version 4.11.3
ryancooley Sep 19, 2024
04ace5a
Merge branch 'next' into feature/FOUR-18078
Sep 19, 2024
4e7ee52
feat: populate case started main flow
Sep 19, 2024
8c47c45
feat: populate case participate main flow
Sep 20, 2024
e955c99
Merge pull request #7400 from ProcessMaker/FOUR-18599
caleeli Sep 20, 2024
88a0f4a
test: cases main flow
Sep 24, 2024
1031a8f
fix: handle null case started
Sep 25, 2024
387cf7d
fix: update cases migrations, fix CaseController test
Sep 25, 2024
ef64c8f
fix: handle null case number
Sep 25, 2024
52f3ac5
Merge pull request #7412 from ProcessMaker/FOUR-18600-B
caleeli Sep 25, 2024
2fbba85
feat: populate sub processes
Sep 25, 2024
fec23b4
Change PDF validation condition
danloa Sep 25, 2024
eeec1e6
feat: ref common functions
Sep 26, 2024
3c93fd4
test: populate case sub processes
Sep 26, 2024
143664c
test: fix CaseStartedSubProcessTest setup
Sep 26, 2024
1858009
fix: implement Last-Modified header with If-Modified-Since validation…
eiresendez Sep 26, 2024
64f71a0
Allow admin users to reassign any user task
nolanpro Sep 27, 2024
a168f7e
Revert "fix: implement Last-Modified header with If-Modified-Since va…
eiresendez Sep 27, 2024
d8186ea
feat: implement cache-busting with version parameter to ensure screen…
eiresendez Sep 27, 2024
e0638fd
Cast users and groups to array of strings
caleeli Sep 27, 2024
01dd406
Fix call to missing method
nolanpro Sep 27, 2024
319f16f
Merge pull request #7417 from ProcessMaker/bugfix/FOUR-19373
ryancooley Sep 29, 2024
d51708c
Merge pull request #7427 from ProcessMaker/bugfix/FOUR-19110
ryancooley Sep 29, 2024
e70586d
Merge pull request #7432 from ProcessMaker/bugfix/FOUR-19390
ryancooley Sep 29, 2024
7c1ff50
Merge pull request #7428 from ProcessMaker/bugix/FOUR-19002
ryancooley Sep 29, 2024
2196ed7
Merge pull request #7430 from ProcessMaker/FOUR-19402
ryancooley Sep 29, 2024
e9211d0
Update JS dependencies
ryancooley Sep 29, 2024
7e30220
Update enterprise package
ryancooley Sep 29, 2024
5d95bd9
Version 4.11.4-RC1
ryancooley Sep 29, 2024
fd3e202
fix: add cr suggestions
Sep 30, 2024
da20d16
Version 4.11.4
ryancooley Sep 30, 2024
c6848dc
Merge pull request #7421 from ProcessMaker/FOUR-18601
caleeli Oct 1, 2024
01c07e9
Merge branch 'next' into feature/FOUR-18078
Oct 1, 2024
eaf113b
feat: add cases sync artisan command
Sep 30, 2024
e6a3edc
feat: add custom exception logs
Sep 27, 2024
e92b52a
feat: add case sync repo
Oct 1, 2024
6df43f6
case repository refactor
Oct 1, 2024
c9572a6
test: case exception tests
Oct 1, 2024
7055d40
fix: case exception handling and logging
Oct 2, 2024
98b2610
FOUR-18605 Count the cases and requests by user and status (EP)
julceslauhub Oct 2, 2024
d7ea383
fix: use status active constant
Oct 2, 2024
dcebace
Merge pull request #7445 from ProcessMaker/FOUR-18602
caleeli Oct 2, 2024
d418885
Merge pull request #7449 from ProcessMaker/FOUR-18605
caleeli Oct 2, 2024
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
47 changes: 47 additions & 0 deletions ProcessMaker/Console/Commands/CasesSync.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace ProcessMaker\Console\Commands;

use Illuminate\Console\Command;
use ProcessMaker\Repositories\CaseSyncRepository;

class CasesSync extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'cases:sync
{--request_ids= : Comma-separated list of request IDs to sync}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Sync requests with the cases tables';

/**
* Execute the console command.
*/
public function handle()
{
$requestIds = $this->option('request_ids');
$requestIds = $requestIds ? explode(',', $requestIds) : [];

if (count($requestIds) > 0) {
$data = CaseSyncRepository::syncCases($requestIds);

foreach ($data['successes'] as $value) {
$this->info('Case started synced ' . $value);
}

foreach ($data['errors'] as $value) {
$this->error('Error syncing case started ' . $value);
}
} else {
$this->error('Please specify a list of request IDs.');
}
}
}
62 changes: 62 additions & 0 deletions ProcessMaker/Contracts/CaseApiRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace ProcessMaker\Contracts;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;

interface CaseApiRepositoryInterface
{
/**
* Get all cases
*
* @param Request $request
*
* @return Builder
*/
public function getAllCases(Request $request): Builder;
/**
* Get all cases in progress
*
* @param Request $request
*
* @return Builder
*/
public function getInProgressCases(Request $request): Builder;
/**
* Get all completed cases
*
* @param Request $request
*
* @return Builder
*/
public function getCompletedCases(Request $request): Builder;
/**
* Search by case number or case title.

* @param Request $request: Query parameter format: search=keyword
* @param Builder $query
*
* @return void
*/
public function search(Request $request, Builder $query): void;
/**
* Filter the query.
*
* @param Request $request: Query parameter format: filterBy[field]=value&filterBy[field2]=value2&...
* @param Builder $query
* @param array $dateFields List of date fields in current model
*
* @return void
*/
public function filterBy(Request $request, Builder $query): void;
/**
* Sort the query.
*
* @param Request $request: Query parameter format: sortBy=field:asc,field2:desc,...
* @param Builder $query
*
* @return void
*/
public function sortBy(Request $request, Builder $query): void;
}
32 changes: 32 additions & 0 deletions ProcessMaker/Contracts/CaseRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace ProcessMaker\Contracts;

use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;

interface CaseRepositoryInterface
{
/**
* Store a new case started.
*
* @param ExecutionInstanceInterface $instance
* @return void
*/
public function create(ExecutionInstanceInterface $instance): void;
/**
* Update the case started.
*
* @param ExecutionInstanceInterface $instance
* @param TokenInterface $token
* @return void
*/
public function update(ExecutionInstanceInterface $instance, TokenInterface $token): void;
/**
* Update the status of a case started.
*
* @param ExecutionInstanceInterface $instance
* @return void
*/
public function updateStatus(ExecutionInstanceInterface $instance): void;
}
20 changes: 20 additions & 0 deletions ProcessMaker/Exception/CaseValidationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace ProcessMaker\Exception;

use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class CaseValidationException extends Exception
{
/**
* Render the exception as an HTTP response.
*/
public function render(Request $request): JsonResponse
{
return response()->json([
'message' => $this->getMessage(),
], JsonResponse::HTTP_UNPROCESSABLE_ENTITY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ private function validatePDFFile(UploadedFile $file, &$errors)
{
$text = $file->get();

$jsKeywords = ['/JavaScript', '/JS', '<< /S /JavaScript'];
$jsKeywords = ['/JavaScript', '<< /S /JavaScript'];

foreach ($jsKeywords as $keyword) {
if (strpos($text, $keyword) !== false) {
Expand Down
7 changes: 6 additions & 1 deletion ProcessMaker/Http/Controllers/Api/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use ProcessMaker\Http\Resources\ApiResource;
use ProcessMaker\Http\Resources\Task as Resource;
use ProcessMaker\Http\Resources\TaskCollection;
use ProcessMaker\Jobs\CaseUpdate;
use ProcessMaker\Listeners\HandleRedirectListener;
use ProcessMaker\Models\Process;
use ProcessMaker\Models\ProcessRequest;
Expand Down Expand Up @@ -253,7 +254,11 @@ public function update(Request $request, ProcessRequestToken $task)
$userToAssign = $request->input('user_id');
$task->reassign($userToAssign, $request->user());

return new Resource($task->refresh());
$taskRefreshed = $task->refresh();

CaseUpdate::dispatch($task->processRequest, $taskRefreshed);

return new Resource($taskRefreshed);
} else {
return abort(422);
}
Expand Down
178 changes: 178 additions & 0 deletions ProcessMaker/Http/Controllers/Api/V1_1/CaseController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<?php

namespace ProcessMaker\Http\Controllers\Api\V1_1;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use ProcessMaker\Http\Controllers\Api\ProcessRequestController;
use ProcessMaker\Http\Controllers\Controller;
use ProcessMaker\Http\Requests\CaseListRequest;
use ProcessMaker\Http\Resources\V1_1\CaseResource;
use ProcessMaker\Models\User;
use ProcessMaker\Repositories\CaseApiRepository;

class CaseController extends Controller
{
protected $caseRepository;

const DEFAULT_PAGE_SIZE = 15;

public function __construct(private Request $request, CaseApiRepository $caseRepository) {
$this->caseRepository = $caseRepository;
}

/* The comment block you provided is a PHPDoc block. It is used to document the purpose and usage of a method in PHP
code. In this specific block: */
/**
* Get a list of all started cases.
*
* @param Request $request
*
* @queryParam userId int Filter by user ID.
* @queryParam status string Filter by case status.
* @queryParam sortBy string Sort by field:asc,field2:desc,...
* @queryParam filterBy array Filter by field=value&field2=value2&...
* @queryParam search string Search by case number or case title.
* @queryParam pageSize int Number of items per page.
* @queryParam page int Page number.
*
* @return array
*/
public function getAllCases(CaseListRequest $request): JSonResponse
{
$query = $this->caseRepository->getAllCases($request);
return $this->paginateResponse($query);
}

/**
* Get a list of all started cases.
*
* @param Request $request
*
* @queryParam userId int Filter by user ID.
* @queryParam sortBy string Sort by field:asc,field2:desc,...
* @queryParam filterBy array Filter by field=value&field2=value2&...
* @queryParam search string Search by case number or case title.
* @queryParam pageSize int Number of items per page.
* @queryParam page int Page number.
*
* @return array
*/
public function getInProgress(CaseListRequest $request): JSonResponse
{
$query = $this->caseRepository->getInProgressCases($request);
return $this->paginateResponse($query);
}

/**
* Get a list of all started cases.
*
* @param Request $request
*
* @queryParam userId int Filter by user ID.
* @queryParam sortBy string Sort by field:asc,field2:desc,...
* @queryParam filterBy array Filter by field=value&field2=value2&...
* @queryParam search string Search by case number or case title.
* @queryParam pageSize int Number of items per page.
* @queryParam page int Page number.
*
* @return array
*/
public function getCompleted(CaseListRequest $request): JSonResponse
{
$query = $this->caseRepository->getCompletedCases($request);
return $this->paginateResponse($query);
}

/**
* Get "my cases" counters
*
* @param CaseListRequest $request
*
* @return JsonResponse
*/
public function getMyCasesCounters(CaseListRequest $request): JsonResponse
{
// Load user object
if ($request->filled('userId')) {
$userId = $request->get('userId');
$user = User::find($userId);
} else {
$user = Auth::user();
}

// Initializing variables
$totalAllCases = null;
$totalMyCases = null;
$totalInProgress = null;
$totalCompleted = null;
$totalMyRequest = null;

// Check permission
if ($user->hasPermission('view-all_cases')) {
// The total number of cases recorded in the platform. User Id send is overridden.
$request->merge(['userId' => null]);
$queryAllCases = $this->caseRepository->getAllCases($request);
$totalAllCases = $queryAllCases->count();
}

// Restore user id
$request->merge(['userId' => $user->id]);

// The total number of cases recorded by the user making the request.
$queryMyCases = $this->caseRepository->getAllCases($request);
$totalMyCases = $queryMyCases->count();

// The number of In Progress cases started by the user making the request.
$queryInProgressCases = $this->caseRepository->getInProgressCases($request);
$totalInProgress = $queryInProgressCases->count();

// The number of Completed cases started by the user making the request.
$queryCompletedCases = $this->caseRepository->getCompletedCases($request);
$totalCompleted = $queryCompletedCases->count();

// Check permission
if ($user->hasPermission('view-my_requests')) {
// Only in progress requests
$requestAux = new Request();
$requestAux->replace(['type' => 'in_progress']);

// The number of requests for user making the request.
$totalMyRequest = (new ProcessRequestController)->index($requestAux, true, $user);
}

// Build response
return response()->json([
'totalAllCases' => $totalAllCases,
'totalMyCases' => $totalMyCases,
'totalInProgress' => $totalInProgress,
'totalCompleted' => $totalCompleted,
'totalMyRequest' => $totalMyRequest,
]);
}

/**
* Handle pagination and return JSON response.
*
* @param Builder $query
*
* @return JsonResponse
*/
private function paginateResponse(Builder $query): JsonResponse
{
$pageSize = $this->request->get('pageSize', self::DEFAULT_PAGE_SIZE);
$pagination = CaseResource::collection($query->paginate($pageSize));

return response()->json([
'data' => $pagination->items(),
'meta' => [
'total' => $pagination->total(),
'perPage' => $pagination->perPage(),
'currentPage' => $pagination->currentPage(),
'lastPage' => $pagination->lastPage(),
],
]);
}
}
Loading