Skip to content

Commit

Permalink
issue #909: fix dynamic propeties
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriim committed Nov 15, 2024
1 parent 261108b commit db53bee
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 6 deletions.
10 changes: 10 additions & 0 deletions classes/local/execution/iterators/dataflow_iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ class dataflow_iterator implements iterator {
/** @var int */
protected $iterationcount = 0;

/**
* @var \tool_dataflows\local\variables\var_step|null
*/
protected $stepvars = null;

/**
* @var null
*/
protected $pulled = null;

/**
* Create an instance of this class.
*
Expand Down
6 changes: 6 additions & 0 deletions classes/local/step/flow_cap.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
*/
final class flow_cap extends flow_step {

/**
* Upstream interator.
* @var
*/
protected $upstream;

/**
* Generates an engine step for this type.
*
Expand Down
18 changes: 12 additions & 6 deletions classes/step.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class step extends persistent {
/** @var array array for lazy loading step dependants */
private $dependents = null;

/** @var dataflow Dataflow */
protected $dataflow = null;

/** @var base_step step type */
protected $steptype;

/**
* Return the definition of the properties of this model.
*
Expand Down Expand Up @@ -495,7 +501,7 @@ public function upsert() {
// Update the local dependencies to the database.
$this->update_depends_on();

$this->steptype->on_save();
$this->get_steptype()->on_save();
$this->get_dataflow()->on_steps_save();

return $this;
Expand Down Expand Up @@ -628,7 +634,7 @@ protected function before_delete() {
$DB->delete_records('tool_dataflows_step_depends', ['stepid' => $this->id]);
$DB->delete_records('tool_dataflows_step_depends', ['dependson' => $this->id]);

$steptype = $this->steptype;
$steptype = $this->get_steptype();
if (isset($steptype)) {
$steptype->on_delete();
}
Expand Down Expand Up @@ -728,7 +734,7 @@ protected function validate_config() {
return new \lang_string('invalidyaml', 'tool_dataflows');
}

$validation = $this->steptype->validate_config($yaml);
$validation = $this->get_steptype()->validate_config($yaml);
if ($validation !== true) {
// NOTE: This will only return the first error as the persistent
// class expects the return value to be an instance of lang_string.
Expand All @@ -748,7 +754,7 @@ protected function validate_config() {
*/
protected function validate_link_count(int $count, string $inputoutput, string $flowconnector) {
$fn = "get_number_of_{$inputoutput}_{$flowconnector}s";
$steptype = $this->steptype;
$steptype = $this->get_steptype();
[$min, $max] = $steptype->$fn();
if ($inputoutput === 'output') {
$min = max($min, count($steptype->get_output_labels()));
Expand Down Expand Up @@ -778,7 +784,7 @@ protected function validate_links(array $deps, string $inputoutput) {
$count = count($deps);
$errors = [];

$steptype = $this->steptype;
$steptype = $this->get_steptype();

if ($count != 0) {
$dep = array_shift($deps);
Expand Down Expand Up @@ -877,7 +883,7 @@ public function has_side_effect(): bool {
if ($typevalidation !== true) {
return false;
}
return $this->steptype->has_side_effect();
return $this->get_steptype()->has_side_effect();
}

/**
Expand Down
31 changes: 31 additions & 0 deletions tests/tool_dataflows_event_processor_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,37 @@
*/
class tool_dataflows_event_processor_test extends \advanced_testcase {

/**
* Test workflow.
* @var \tool_dataflows\dataflow
*/
protected $dataflow;

/**
* Test writer.
* @var
*/
protected $writer;

/**
* Test reader.
* @var
*/
protected $reader;

/**
* Test course.
*
* @var \stdClass
*/
protected $course;

/**
* Test output path.
* @var
*/
protected $outputpath;

/**
* Set up before each test
*/
Expand Down
35 changes: 35 additions & 0 deletions tests/tool_dataflows_flow_sql_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,41 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataflows_flow_sql_test extends \advanced_testcase {
/**
* Test workflow.
* @var \tool_dataflows\dataflow
*/
protected $dataflow;

/**
* Test writer.
* @var
*/
protected $writer;

/**
* Test reader.
* @var
*/
protected $reader;

/**
* Test input path.
* @var false|string
*/
protected $inputpath;

/**
* Test output path.
* @var
*/
protected $outputpath;

/**
* Test flow step.
* @var \tool_dataflows\step
*/
protected $flow;

/**
* Set up before each test
Expand Down
36 changes: 36 additions & 0 deletions tests/tool_dataflows_json_reader_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,42 @@
*/
class tool_dataflows_json_reader_test extends \advanced_testcase {

/**
* Test workflow.
* @var \tool_dataflows\dataflow
*/
protected $dataflow;

/**
* Test writer.
* @var
*/
protected $writer;

/**
* Test reader.
* @var
*/
protected $reader;

/**
* Test input path.
* @var false|string
*/
protected $inputpath;

/**
* Test output path.
* @var
*/
protected $outputpath;

/**
* Test users.
* @var
*/
protected $users;

/**
* Set up before each test
*/
Expand Down
11 changes: 11 additions & 0 deletions tests/tool_dataflows_reader_csv_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataflows_reader_csv_test extends \advanced_testcase {
/**
* Test writer.
* @var
*/
protected $writer;

/**
* Test reader.
* @var
*/
protected $reader;

/**
* Set up before each test
Expand Down

0 comments on commit db53bee

Please sign in to comment.