Adding transaction_tester.php file see BT#4882 + reverting latest changes of soap_call function

skala
Julio Montoya 12 years ago
parent 04acba30bf
commit 20620a6fdb
  1. 40
      tests/migrate/migration.class.php
  2. 22
      tests/migrate/migration.custom.class.php
  3. 45
      tests/migrate/transaction_tester.php

@ -181,8 +181,9 @@ class Migration {
* @param array Variables to be passed as params to the function
* @return array Results as returned by the SOAP call
*/
function soap_call($function_name, $params = array()) {
$web_service_params = $this->web_service_connection_info;
function soap_call($web_service_params, $function_name, $params = array()) {
//$web_service_params = $this->web_service_connection_info;
// Create the client instance
$url = $web_service_params['url'];
@ -666,24 +667,24 @@ class Migration {
$web_service_params = $this->web_service_connection_info;
/*$result = $this->soap_call('usuarioDetalles', array('uididpersona' => 'D236776B-D7A5-47FF-8328-55EBE9A59015'));
$result = $this->soap_call('programaDetalles', array('uididprograma' => 'C3671999-095E-4018-9826-678BAFF595DF'));
$result = $this->soap_call('cursoDetalles', array('uididcurso' => 'E2334974-9D55-4BB4-8B57-FCEFBE2510DC'));
$result = $this->soap_call('faseDetalles', array('uididfase' => 'EBF63F1C-FBD7-46A5-B039-80B5AF064929'));
$result = $this->soap_call('frecuenciaDetalles', array('uididfrecuencia' => '0091CD3B-F042-11D7-B338-0050DAB14015'));
$result = $this->soap_call('intensidadDetalles', array('uididintensidad' => '0091CD3C-F042-11D7-B338-0050DAB14015'));
$result = $this->soap_call('mesesDetalles', array('uididfase' => 'EBF63F1C-FBD7-46A5-B039-80B5AF064929'));
$result = $this->soap_call('sedeDetalles', array('uididsede' => '7379A7D3-6DC5-42CA-9ED4-97367519F1D9'));
$result = $this->soap_call('horarioDetalles', array('uididhorario' => 'E395895A-B480-456F-87F2-36B3A1EBB81C'));
$result = $this->soap_call('transacciones', array('ultimo' => 354911, 'cantidad' => 2));
/*$result = $this->soap_call($web_service_params,'usuarioDetalles', array('uididpersona' => 'D236776B-D7A5-47FF-8328-55EBE9A59015'));
$result = $this->soap_call($web_service_params,'programaDetalles', array('uididprograma' => 'C3671999-095E-4018-9826-678BAFF595DF'));
$result = $this->soap_call($web_service_params,'cursoDetalles', array('uididcurso' => 'E2334974-9D55-4BB4-8B57-FCEFBE2510DC'));
$result = $this->soap_call($web_service_params,'faseDetalles', array('uididfase' => 'EBF63F1C-FBD7-46A5-B039-80B5AF064929'));
$result = $this->soap_call($web_service_params,'frecuenciaDetalles', array('uididfrecuencia' => '0091CD3B-F042-11D7-B338-0050DAB14015'));
$result = $this->soap_call($web_service_params,'intensidadDetalles', array('uididintensidad' => '0091CD3C-F042-11D7-B338-0050DAB14015'));
$result = $this->soap_call($web_service_params,'mesesDetalles', array('uididfase' => 'EBF63F1C-FBD7-46A5-B039-80B5AF064929'));
$result = $this->soap_call($web_service_params,'sedeDetalles', array('uididsede' => '7379A7D3-6DC5-42CA-9ED4-97367519F1D9'));
$result = $this->soap_call($web_service_params,'horarioDetalles', array('uididhorario' => 'E395895A-B480-456F-87F2-36B3A1EBB81C'));
$result = $this->soap_call($web_service_params,'transacciones', array('ultimo' => 354911, 'cantidad' => 2));
*/
$branches = self::get_branches();
foreach ($branches as $branch) {
error_log('Treating transactions for branch '.$branch['branch_id']);
$last = self::get_latest_transaction_by_branch($branch['branch_id']);
$result = self::soap_call('transacciones', array('ultimo' => $last, 'cantidad' => 1));
$result = self::soap_call($this->web_service_connection_info,'transacciones', array('ultimo' => $last, 'cantidad' => 1));
//Calling a process to save transactions
MigrationCustom::process_transactions(array('ultimo' => $last, 'cantidad' => 1));
MigrationCustom::process_transactions($web_service_params, array('ultimo' => $last, 'cantidad' => 1));
}
}
@ -766,16 +767,17 @@ class Migration {
error_log("\n-----------------------------------------------------------------------");
error_log("\nCalling function MigrationCustom::$function_to_call");
$result = MigrationCustom::$function_to_call($transaction_info, $this->web_service_connection_info);
error_log('Reponse: '.$result['message']);
$result = MigrationCustom::$function_to_call($transaction_info, $this->web_service_connection_info);
$result['message'] = "Funcion called: MigrationCustom::$function_to_call() \n Function reponse: ".$result['message'];
error_log('Reponse: '.$result['message']);
if (!empty($transaction_info['id'])) {
self::update_transaction(array('id' => $transaction_info['id'] , 'status_id' => $result['status_id']));
}
return $result;
} else {
// method does not exist
$error_message = "Function does $function_to_call not exists";
$error_message = "Function $function_to_call does not exists";
error_log($error_message);
//Failed
@ -792,14 +794,14 @@ class Migration {
*
*/
function load_transaction_by_third_party_id($transaction_external_id) {
$result = self::soap_call('transacciones', array('ultimo' => $transaction_external_id, 'cantidad' => 2));
$result = self::soap_call($this->web_service_connection_info,'transacciones', array('ultimo' => $transaction_external_id, 'cantidad' => 2));
if ($result && isset($result[0])) {
//Getting 1 transaction
$result = $result[0];
//Hacking webservice
$transaction_external_id++;
if ($result['idt'] == $transaction_external_id) {
$message = Display::return_message('Transaction id found in third party', 'success');
$message = Display::return_message('Transaction id found in third party', 'info');
//Adding third party transaction to Chamilo not sure about this
$chamilo_transaction_id = MigrationCustom::process_transaction($result);

@ -794,7 +794,7 @@ class MigrationCustom {
}
} else {
return array(
'message' => "User was not found : $uidIdPersonaId",
'message' => "User was not found with uidIdPersona: $uidIdPersonaId",
'status_id' => self::TRANSACTION_STATUS_FAILED
);
}
@ -1183,8 +1183,8 @@ class MigrationCustom {
$extra_field_info = $extra_field->get_handler_field_info_by_field_variable($extra_field_variable);
if (empty($extra_field_info)) {
return array(
'message' => "Extra field can't be edited extra field does not exists: extra_field_variable: ".$extra_field_variable,
'status_id' => self::TRANSACTION_STATUS_FAILED
'message' => "Extra field can't be edited extra field does not exists: extra_field_variable: ".$extra_field_variable,
'status_id' => self::TRANSACTION_STATUS_FAILED
);
}
@ -1209,11 +1209,11 @@ class MigrationCustom {
$options_updated = array();
foreach($extra_field_option_info as $option) {
$extra_field_option_info = array(
'id' => $option['id'],
'field_id' => $extra_field_info['id'],
'option_value' => $original_data['item_id'],
'id' => $option['id'],
'field_id' => $extra_field_info['id'],
'option_value' => $original_data['item_id'],
'option_display_text' => $data['name'],
'option_order' => null
'option_order' => null
);
$extra_field_option->update($extra_field_option_info);
$options_updated [] = $option['id'];
@ -1402,8 +1402,8 @@ class MigrationCustom {
string(12) "AAAAATbYxkg="
}
*/
function process_transactions($params) {
$transactions = Migration::soap_call('transacciones', $params);
function process_transactions($params, $web_service_details) {
$transactions = Migration::soap_call($web_service_details, 'transacciones', $params);
if (!empty($transactions)) {
foreach ($transactions as $transaction_info) {
/*
@ -1430,10 +1430,10 @@ class MigrationCustom {
if ($transaction_info) {
$params = array(
'action' => $transaction_info['ida'],
'item_id' => $transaction_info['idt'],
'item_id' => $transaction_info['id'],
'orig_id' => $transaction_info['id'],
'branch_id' => $transaction_info['idsede'],
'dest_id' => $transaction_info['idt'],
'dest_id' => $transaction_info['id'],
'status_id' => 0
);
if (!$save_to_db) {

@ -0,0 +1,45 @@
<?php
require_once dirname(__FILE__).'/../../main/inc/global.inc.php';
require_once 'config.php';
Display::display_header();
$form = new FormValidator('transaction_tester');
$form->addElement('header', 'Transaction tester');
$form->addElement('text', 'transaction_id', get_lang('TransactionId'));
$form->addRule('transaction_id',get_lang('ThisFieldShouldBeNumeric'),'numeric');
$form->addElement('button', 'submit', get_lang('Send'));
$response = null;
if ($form->validate()) {
$values = $form->getSubmitValues();
$transaction_id = $values['transaction_id'];
$response = Display::page_subheader2("Testing transaction #$transaction_id");
require_once 'migration.class.php';
require_once 'migration.custom.class.php';
//harcoded db_matches
require_once 'db_matches.php';
$migration = new Migration();
$migration->set_web_service_connection_info($matches);
//This is the fault of the webservice
$transaction_id--;
$result = $migration->load_transaction_by_third_party_id($transaction_id);
$response .= $result['message'];
if (isset($result['raw_reponse'])) {
$response .= $result['raw_reponse'];
}
}
$form->setDefaults(array('transaction_id' => '376012'));
$form->display();
if (!empty($response)) {
echo $response;
}
Loading…
Cancel
Save