Skip to content

Commit 2187f85

Browse files
authored
Merge pull request #16682 from nextcloud/enh/12790/workflow-backend
workflow overhaul
2 parents 0cc780e + 228cb24 commit 2187f85

File tree

95 files changed

+5533
-2145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+5533
-2145
lines changed

apps/workflowengine/appinfo/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121

2222
$application = new \OCA\WorkflowEngine\AppInfo\Application();
2323
$application->registerHooksAndListeners();
24+
$application->registerRuleListeners();

apps/workflowengine/appinfo/database.xml

Lines changed: 0 additions & 90 deletions
This file was deleted.

apps/workflowengine/appinfo/info.xml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
44
<id>workflowengine</id>
5-
<name>Files workflow engine</name>
6-
<summary>Files workflow engine</summary>
7-
<description>Files workflow engine</description>
8-
<version>1.8.0</version>
5+
<name>Nextcloud workflow engine</name>
6+
<summary>Nextcloud workflow engine</summary>
7+
<description>Nextcloud workflow engine</description>
8+
<version>2.0.0</version>
99
<licence>agpl</licence>
10+
<author>Arthur Schiwon</author>
11+
<author>Julius Härtl</author>
1012
<author>Morris Jobke</author>
1113
<namespace>WorkflowEngine</namespace>
1214

@@ -23,7 +25,20 @@
2325
<nextcloud min-version="18" max-version="18"/>
2426
</dependencies>
2527

28+
<repair-steps>
29+
<post-migration>
30+
<step>OCA\WorkflowEngine\Migration\PopulateNewlyIntroducedDatabaseFields</step>
31+
</post-migration>
32+
</repair-steps>
33+
34+
<commands>
35+
<command>OCA\WorkflowEngine\Command\Index</command>
36+
</commands>
37+
2638
<settings>
39+
<admin>OCA\WorkflowEngine\Settings\Admin</admin>
2740
<admin-section>OCA\WorkflowEngine\Settings\Section</admin-section>
41+
<personal>OCA\WorkflowEngine\Settings\Personal</personal>
42+
<personal-section>OCA\WorkflowEngine\Settings\Section</personal-section>
2843
</settings>
2944
</info>

apps/workflowengine/appinfo/routes.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121

2222
return [
2323
'routes' => [
24-
['name' => 'flowOperations#getOperations', 'url' => '/operations', 'verb' => 'GET'],
25-
['name' => 'flowOperations#addOperation', 'url' => '/operations', 'verb' => 'POST'],
26-
['name' => 'flowOperations#updateOperation', 'url' => '/operations/{id}', 'verb' => 'PUT'],
27-
['name' => 'flowOperations#deleteOperation', 'url' => '/operations/{id}', 'verb' => 'DELETE'],
2824
['name' => 'requestTime#getTimezones', 'url' => '/timezones', 'verb' => 'GET'],
29-
]
25+
],
26+
'ocs-resources' => [
27+
'global_workflows' => ['url' => '/api/v1/workflows/global'],
28+
],
3029
];

apps/workflowengine/composer/composer/autoload_classmap.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,21 @@
1616
'OCA\\WorkflowEngine\\Check\\RequestTime' => $baseDir . '/../lib/Check/RequestTime.php',
1717
'OCA\\WorkflowEngine\\Check\\RequestURL' => $baseDir . '/../lib/Check/RequestURL.php',
1818
'OCA\\WorkflowEngine\\Check\\RequestUserAgent' => $baseDir . '/../lib/Check/RequestUserAgent.php',
19+
'OCA\\WorkflowEngine\\Check\\TFileCheck' => $baseDir . '/../lib/Check/TFileCheck.php',
1920
'OCA\\WorkflowEngine\\Check\\UserGroupMembership' => $baseDir . '/../lib/Check/UserGroupMembership.php',
20-
'OCA\\WorkflowEngine\\Controller\\FlowOperations' => $baseDir . '/../lib/Controller/FlowOperations.php',
21+
'OCA\\WorkflowEngine\\Command\\Index' => $baseDir . '/../lib/Command/Index.php',
22+
'OCA\\WorkflowEngine\\Controller\\AWorkflowController' => $baseDir . '/../lib/Controller/AWorkflowController.php',
23+
'OCA\\WorkflowEngine\\Controller\\GlobalWorkflowsController' => $baseDir . '/../lib/Controller/GlobalWorkflowsController.php',
2124
'OCA\\WorkflowEngine\\Controller\\RequestTime' => $baseDir . '/../lib/Controller/RequestTime.php',
25+
'OCA\\WorkflowEngine\\Controller\\UserWorkflowsController' => $baseDir . '/../lib/Controller/UserWorkflowsController.php',
26+
'OCA\\WorkflowEngine\\Entity\\File' => $baseDir . '/../lib/Entity/File.php',
27+
'OCA\\WorkflowEngine\\Helper\\ScopeContext' => $baseDir . '/../lib/Helper/ScopeContext.php',
2228
'OCA\\WorkflowEngine\\Manager' => $baseDir . '/../lib/Manager.php',
29+
'OCA\\WorkflowEngine\\Migration\\PopulateNewlyIntroducedDatabaseFields' => $baseDir . '/../lib/Migration/PopulateNewlyIntroducedDatabaseFields.php',
30+
'OCA\\WorkflowEngine\\Migration\\Version2019Date20190808074233' => $baseDir . '/../lib/Migration/Version2019Date20190808074233.php',
31+
'OCA\\WorkflowEngine\\Service\\RuleMatcher' => $baseDir . '/../lib/Service/RuleMatcher.php',
32+
'OCA\\WorkflowEngine\\Settings\\ASettings' => $baseDir . '/../lib/Settings/ASettings.php',
33+
'OCA\\WorkflowEngine\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
34+
'OCA\\WorkflowEngine\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php',
2335
'OCA\\WorkflowEngine\\Settings\\Section' => $baseDir . '/../lib/Settings/Section.php',
2436
);

apps/workflowengine/composer/composer/autoload_static.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,22 @@ class ComposerStaticInitWorkflowEngine
3131
'OCA\\WorkflowEngine\\Check\\RequestTime' => __DIR__ . '/..' . '/../lib/Check/RequestTime.php',
3232
'OCA\\WorkflowEngine\\Check\\RequestURL' => __DIR__ . '/..' . '/../lib/Check/RequestURL.php',
3333
'OCA\\WorkflowEngine\\Check\\RequestUserAgent' => __DIR__ . '/..' . '/../lib/Check/RequestUserAgent.php',
34+
'OCA\\WorkflowEngine\\Check\\TFileCheck' => __DIR__ . '/..' . '/../lib/Check/TFileCheck.php',
3435
'OCA\\WorkflowEngine\\Check\\UserGroupMembership' => __DIR__ . '/..' . '/../lib/Check/UserGroupMembership.php',
35-
'OCA\\WorkflowEngine\\Controller\\FlowOperations' => __DIR__ . '/..' . '/../lib/Controller/FlowOperations.php',
36+
'OCA\\WorkflowEngine\\Command\\Index' => __DIR__ . '/..' . '/../lib/Command/Index.php',
37+
'OCA\\WorkflowEngine\\Controller\\AWorkflowController' => __DIR__ . '/..' . '/../lib/Controller/AWorkflowController.php',
38+
'OCA\\WorkflowEngine\\Controller\\GlobalWorkflowsController' => __DIR__ . '/..' . '/../lib/Controller/GlobalWorkflowsController.php',
3639
'OCA\\WorkflowEngine\\Controller\\RequestTime' => __DIR__ . '/..' . '/../lib/Controller/RequestTime.php',
40+
'OCA\\WorkflowEngine\\Controller\\UserWorkflowsController' => __DIR__ . '/..' . '/../lib/Controller/UserWorkflowsController.php',
41+
'OCA\\WorkflowEngine\\Entity\\File' => __DIR__ . '/..' . '/../lib/Entity/File.php',
42+
'OCA\\WorkflowEngine\\Helper\\ScopeContext' => __DIR__ . '/..' . '/../lib/Helper/ScopeContext.php',
3743
'OCA\\WorkflowEngine\\Manager' => __DIR__ . '/..' . '/../lib/Manager.php',
44+
'OCA\\WorkflowEngine\\Migration\\PopulateNewlyIntroducedDatabaseFields' => __DIR__ . '/..' . '/../lib/Migration/PopulateNewlyIntroducedDatabaseFields.php',
45+
'OCA\\WorkflowEngine\\Migration\\Version2019Date20190808074233' => __DIR__ . '/..' . '/../lib/Migration/Version2019Date20190808074233.php',
46+
'OCA\\WorkflowEngine\\Service\\RuleMatcher' => __DIR__ . '/..' . '/../lib/Service/RuleMatcher.php',
47+
'OCA\\WorkflowEngine\\Settings\\ASettings' => __DIR__ . '/..' . '/../lib/Settings/ASettings.php',
48+
'OCA\\WorkflowEngine\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
49+
'OCA\\WorkflowEngine\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php',
3850
'OCA\\WorkflowEngine\\Settings\\Section' => __DIR__ . '/..' . '/../lib/Settings/Section.php',
3951
);
4052

apps/workflowengine/js/workflowengine.js

Lines changed: 425 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/workflowengine/js/workflowengine.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/workflowengine/lib/AppInfo/Application.php

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,45 @@
2121

2222
namespace OCA\WorkflowEngine\AppInfo;
2323

24+
use OCA\WorkflowEngine\Manager;
2425
use OCP\Template;
2526
use OCA\WorkflowEngine\Controller\RequestTime;
26-
use OCA\WorkflowEngine\Controller\FlowOperations;
27+
use OCP\WorkflowEngine\IEntity;
28+
use OCP\WorkflowEngine\IOperation;
29+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
30+
use Symfony\Component\EventDispatcher\GenericEvent;
2731

2832
class Application extends \OCP\AppFramework\App {
2933

34+
const APP_ID = 'workflowengine';
35+
36+
/** @var EventDispatcherInterface */
37+
protected $dispatcher;
38+
/** @var Manager */
39+
protected $manager;
40+
3041
public function __construct() {
31-
parent::__construct('workflowengine');
42+
parent::__construct(self::APP_ID);
3243

33-
$this->getContainer()->registerAlias('FlowOperationsController', FlowOperations::class);
3444
$this->getContainer()->registerAlias('RequestTimeController', RequestTime::class);
45+
46+
$this->dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
47+
$this->manager = $this->getContainer()->query(Manager::class);
3548
}
3649

3750
/**
3851
* Register all hooks and listeners
3952
*/
4053
public function registerHooksAndListeners() {
41-
$dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
42-
$dispatcher->addListener(
54+
$this->dispatcher->addListener(
4355
'OCP\WorkflowEngine::loadAdditionalSettingScripts',
4456
function() {
4557
if (!function_exists('style')) {
4658
// This is hacky, but we need to load the template class
4759
class_exists(Template::class, true);
4860
}
4961

50-
style('workflowengine', [
62+
style(self::APP_ID, [
5163
'admin',
5264
]);
5365

@@ -59,11 +71,34 @@ class_exists(Template::class, true);
5971
'systemtags/systemtagscollection',
6072
]);
6173

62-
script('workflowengine', [
74+
script(self::APP_ID, [
6375
'workflowengine',
6476
]);
6577
},
6678
-100
6779
);
6880
}
81+
82+
public function registerRuleListeners() {
83+
$configuredEvents = $this->manager->getAllConfiguredEvents();
84+
85+
foreach ($configuredEvents as $operationClass => $events) {
86+
foreach ($events as $entityClass => $eventNames) {
87+
array_map(function (string $eventName) use ($operationClass, $entityClass) {
88+
$this->dispatcher->addListener(
89+
$eventName,
90+
function (GenericEvent $event) use ($eventName, $operationClass, $entityClass) {
91+
$ruleMatcher = $this->manager->getRuleMatcher();
92+
/** @var IEntity $entity */
93+
$entity = $this->getContainer()->query($entityClass);
94+
$entity->prepareRuleMatcher($ruleMatcher, $eventName, $event);
95+
/** @var IOperation $operation */
96+
$operation = $this->getContainer()->query($operationClass);
97+
$operation->onEvent($eventName, $event, $ruleMatcher);
98+
}
99+
);
100+
}, $eventNames);
101+
}
102+
}
103+
}
69104
}

apps/workflowengine/lib/Check/AbstractStringCheck.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
namespace OCA\WorkflowEngine\Check;
2323

2424

25-
use OCP\Files\Storage\IStorage;
2625
use OCP\IL10N;
2726
use OCP\WorkflowEngine\ICheck;
27+
use OCP\WorkflowEngine\IManager;
2828

2929
abstract class AbstractStringCheck implements ICheck {
3030

@@ -41,14 +41,6 @@ public function __construct(IL10N $l) {
4141
$this->l = $l;
4242
}
4343

44-
/**
45-
* @param IStorage $storage
46-
* @param string $path
47-
*/
48-
public function setFileInfo(IStorage $storage, $path) {
49-
// Nothing changes here with a different path
50-
}
51-
5244
/**
5345
* @return string
5446
*/
@@ -101,6 +93,16 @@ public function validateCheck($operator, $value) {
10193
}
10294
}
10395

96+
public function supportedEntities(): array {
97+
// universal by default
98+
return [];
99+
}
100+
101+
public function isAvailableForScope(int $scope): bool {
102+
// admin only by default
103+
return $scope === IManager::SCOPE_ADMIN;
104+
}
105+
104106
/**
105107
* @param string $pattern
106108
* @param string $subject

0 commit comments

Comments
 (0)