Skip to content

Commit

Permalink
NC 18 Workflow integration #10
Browse files Browse the repository at this point in the history
  • Loading branch information
Rello committed Jan 9, 2020
1 parent 5f54962 commit e7d7598
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
6 changes: 3 additions & 3 deletions js/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
name: 'WorkflowScript',
items: [],
render: function (createElement) {
var self = this;
var items = [];
var selected;
let self = this;
let items = [];
let selected;
for (let navigation of Component.items) {
if (parseInt(navigation.type) === 2) {
if (parseInt(self.value) === navigation.id) {
Expand Down
3 changes: 2 additions & 1 deletion l10n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"<= less equal": "<= kleiner gleich",
">= greater equal": ">= größer gleich",
"!= not equal": "!= ungleich",
"Single value or *": "Einzelwert oder *"
"Single value or *": "Einzelwert oder *",
"Read file and add its data to an existing report": "Datei auslesen und den Inhalt einem bestehenden Report hinzufügen"
},
"pluralForm": ""
}
3 changes: 2 additions & 1 deletion l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"<= less equal": "<= kleiner gleich",
">= greater equal": ">= größer gleich",
"!= not equal": "!= ungleich",
"Single value or *": "Einzelwert oder *"
"Single value or *": "Einzelwert oder *",
"Read file and add its data to an existing report": "Datei auslesen und den Inhalt einem bestehenden Report hinzufügen"
},
"pluralForm": ""
}
45 changes: 20 additions & 25 deletions lib/Flow/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public static function register(IEventDispatcher $dispatcher): void

public function getDisplayName(): string
{
return $this->l->t('Add to Analytics');
return $this->l->t('Data Analytics');
}

public function getDescription(): string
{
return $this->l->t('Read a file and add its data to an existing report');
return $this->l->t('Read file and add its data to an existing report');
}

public function getIcon(): string
Expand All @@ -80,45 +80,40 @@ public function isAvailableForScope(int $scope): bool
}

/**
* Validates whether a configured workflow rule is valid. If it is not,
* an `\UnexpectedValueException` is supposed to be thrown.
*
* @param $name
* @param array $checks
* @param $operation
* @since 9.1
*/
public function validateOperation($name, array $checks, $operation): void
{
$this->logger->debug("validateOperation");
}

public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void
{
$flow = $ruleMatcher->getFlows(true);
$datasetId = (int)$flow['operation'];

try {
if ($eventName === '\OCP\Files::postRename') {
/** @var Node $oldNode */
list(, $node) = $event->getSubject();
} else {
$node = $event->getSubject();
}
if ($eventName === '\OCP\Files::postRename') {
/** @var Node $oldNode */
list(, $node) = $event->getSubject();
} else {
$node = $event->getSubject();
}

list(, , $folder, $file) = explode('/', $node->getPath(), 4);
if ($folder !== 'files' || $node instanceof Folder) {
return;
}
$file = '/' . $file;
list(, , $folder, $file) = explode('/', $node->getPath(), 4);
if ($folder !== 'files' || $node instanceof Folder) {
return;
}
$file = '/' . $file;

$this->logger->debug("Flow Operation 119: storing file '" . $file . "' in report " . $datasetId);
try {
$this->DataloadController->importFile($datasetId, $file);
} catch (NotFoundException $e) {
} catch (\Exception $e) {
}
} catch (\OCP\Files\NotFoundException $e) {
$this->logger->debug("Analytics Flow Operation 115: storing file '" . $file . "' in report " . $datasetId);
try {
$this->DataloadController->importFile($datasetId, $file);
} catch (NotFoundException $e) {
return;
} catch (\Exception $e) {
return;
}
}
}

0 comments on commit e7d7598

Please sign in to comment.