public function execute(ezcWorkflowExecution $execution) { $qa_results_dir = "/var/qa"; // value will be the latest score of the package $value = $execution->getVariable('distilled_review'); // an integer // dump this value to a file in the filesystem $storage = new midgard_query_storage('com_meego_package_details'); // get the detailed package object $q = new midgard_query_select($storage); $q->set_constraint(new midgard_query_constraint(new midgard_query_property('packageguid'), '=', new midgard_query_value($execution->getVariable('package_instance')))); $q->execute(); $package = $q->list_objects(); if (count($package) && $value) { $project_name = $package[0]->repoprojectname; $package_name = $package[0]->packageparent; $qa_results_dir = $qa_results_dir . '/' . $project_name; if (!is_dir($qa_results_dir)) { $ret = mkdir($qa_results_dir, 0755, true); if (!$ret) { // do something return; } } $handle = fopen($qa_results_dir . '/' . $package_name . '.txt', "wb"); if ($handle) { $ret = fwrite($handle, $value); if (!$ret) { // do something } } fclose($handle); } return; }
/** * Executes this node and returns true. * * Expects the configuration parameters 'name' the name of the workflow * variable to work on and the parameter 'value' the value to operate with * or the name of the workflow variable containing the value. * * @param ezcWorkflowExecution $execution * @return boolean * @ignore */ public function execute(ezcWorkflowExecution $execution) { if (is_array($this->configuration)) { $variableName = $this->configuration['name']; } else { $variableName = $this->configuration; } $this->variable = $execution->getVariable($variableName); if (!is_numeric($this->variable)) { throw new ezcWorkflowExecutionException(sprintf('Variable "%s" is not a number.', $variableName)); } if (is_numeric($this->configuration['operand'])) { $this->operand = $this->configuration['operand']; } else { if (is_string($this->configuration['operand'])) { try { $operand = $execution->getVariable($this->configuration['operand']); if (is_numeric($operand)) { $this->operand = $operand; } } catch (ezcWorkflowExecutionException $e) { } } } if ($this->operand === null) { throw new ezcWorkflowExecutionException('Illegal operand.'); } $this->doExecute(); $execution->setVariable($variableName, $this->variable); $this->activateNode($execution, $this->outNodes[0]); return parent::execute($execution); }
/** * @todo: docs */ public function execute(ezcWorkflowExecution $execution) { $form = midgardmvc_ui_forms_generator::get_by_guid($execution->getVariable('review_form')); $instance = new midgardmvc_ui_forms_form_instance($execution->getVariable('review')); $review = midgardmvc_ui_forms_store::load_form($form, $instance); $items = $form->items; $boolean_count = 0; $positive = 0; $package = new com_meego_package($instance->relatedobject); foreach ($items as $key => $item) { if ($key == "redirect_link" || $key == "execution") { continue; } try { $field = new midgardmvc_ui_forms_form_field($key); } catch (Exception $e) { midgardmvc_core::get_instance()->log('Invalid field detected in distill review: ' . $key . ', value: ' . $item, 'warning'); } // todo: ugly hardcoded check, but what can we do.. if ($field->title == "Should the application be in this application catalog?") { // if the answer belongs to a certain field then we process // this field must be a boolean too if ($item instanceof midgardmvc_helper_forms_field_boolean) { if ($item->get_value()) { // add +1 to the package score $package->metadata->score++; } else { // oh yes, we do give -1 points too ;) $package->metadata->score--; } $res = $package->update(); if (!$res) { //update failed; do what? } } } else { // otherwise continue; } } // pass on the score $execution->setVariable('distilled_review', $package->metadata->score); }
public function execute(ezcWorkflowExecution $execution) { $package_instance = new com_meego_package($execution->getVariable('package_instance')); // We load the form from the package's repository $repository = new com_meego_repository($package_instance->repository); $list_of_forms = midgardmvc_ui_forms_generator::list_for_object($repository); if (empty($list_of_forms)) { return; } $execution->setVariable('review_form', $list_of_forms[0]->name); }
/** * Passes variables from one execution context to another. * * @param ezcWorkflowExecution $from The execution context the variables are passed from. * @param ezcWorkflowExecution $to The execution context the variables are passed to. * @param array $variables The names of the variables. * @throws ezcWorkflowExecutionException if a variable that is to be passed does not exist. * @ignore */ protected function passVariables(ezcWorkflowExecution $from, ezcWorkflowExecution $to, array $variables) { foreach ($variables as $fromName => $toName) { $to->setVariable($toName, $from->getVariable($fromName)); } }