mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-19 13:09:27 +00:00
Plausichecks: added run method to IssueProducer_Controller for producing plausicheck issues
This commit is contained in:
@@ -3,38 +3,120 @@
|
||||
/**
|
||||
* Job for producing Plausicheck issues
|
||||
*/
|
||||
class PlausiIssueProducer extends IssueProducer_Controller
|
||||
class PlausiIssueProducer extends JOB_Controller
|
||||
{
|
||||
const PLAUSI_ISSUES_FOLDER = 'issues/plausichecks';
|
||||
const EXECUTE_PLAUSI_CHECK_METHOD_NAME = 'executePlausiCheck'
|
||||
|
||||
private _fehlerLibMappings;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// set fehler codes which can be produced by the job
|
||||
// structure: fehlercode => class (library) name for resolving
|
||||
// set fehler which can be produced by the job
|
||||
// structure: fehler_kurzbz => class (library) name for resolving
|
||||
$this->_fehlerLibMappings = array(
|
||||
'zgvDatumInZukunft' => 'ZgvDatumInZukunft',
|
||||
'zgvDatumVorGeburtsdatum' => 'ZgvDatumVorGeburtsdatum',
|
||||
'zgvMasterDatumInZukunft' => 'ZgvMasterDatumInZukunft',
|
||||
'zgvMasterDatumVorZgvdatum' => 'ZgvMasterDatumVorZgvdatum',
|
||||
'zgvMasterDatumVorGeburtsdatum' => 'ZgvMasterDatumVorGeburtsdatum',
|
||||
'keinAufenthaltszweckPlausi' => 'KeinAufenthaltszweckPlausi',
|
||||
'zuVieleZweckeIncomingPlausi' => 'ZuVieleZweckeIncomingPlausi',
|
||||
'falscherIncomingZweckPlausi' => 'FalscherIncomingZweckPlausi',
|
||||
'outgoingAufenthaltfoerderungfehltPlausi' => 'OutgoingAufenthaltfoerderungfehltPlausi',
|
||||
'outgoingAngerechneteEctsFehlenPlausi' => 'OutgoingAngerechneteEctsFehlenPlausi',
|
||||
'outgoingErworbeneEctsFehlenPlausi' => 'OutgoingErworbeneEctsFehlenPlausi'
|
||||
'' => ''
|
||||
//'zgvDatumInZukunft' => 'ZgvDatumInZukunft',
|
||||
//'zgvDatumVorGeburtsdatum' => 'ZgvDatumVorGeburtsdatum',
|
||||
//'zgvMasterDatumInZukunft' => 'ZgvMasterDatumInZukunft',
|
||||
//'zgvMasterDatumVorZgvdatum' => 'ZgvMasterDatumVorZgvdatum',
|
||||
//'zgvMasterDatumVorGeburtsdatum' => 'ZgvMasterDatumVorGeburtsdatum',
|
||||
//'keinAufenthaltszweckPlausi' => 'KeinAufenthaltszweckPlausi',
|
||||
//'zuVieleZweckeIncomingPlausi' => 'ZuVieleZweckeIncomingPlausi',
|
||||
//'falscherIncomingZweckPlausi' => 'FalscherIncomingZweckPlausi',
|
||||
//'outgoingAufenthaltfoerderungfehltPlausi' => 'OutgoingAufenthaltfoerderungfehltPlausi',
|
||||
//'outgoingAngerechneteEctsFehlenPlausi' => 'OutgoingAngerechneteEctsFehlenPlausi',
|
||||
//'outgoingErworbeneEctsFehlenPlausi' => 'OutgoingErworbeneEctsFehlenPlausi'
|
||||
);
|
||||
|
||||
$this->load->model('organisation/studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->load->model('studiensemester_model', 'StudiensemesterModel');
|
||||
$this->load->library('IssuesLib');
|
||||
}
|
||||
|
||||
public function run()
|
||||
/**
|
||||
* Initializes issue production.
|
||||
*/
|
||||
public function run($studiensemester_kurzbz = null)
|
||||
{
|
||||
$semRes = $this->StudiensemesterModel->getAkt();
|
||||
|
||||
if (hasData($semRes))
|
||||
if (isEmptyString($studiensemester_kurzbz))
|
||||
{
|
||||
$studiensemester_kurzbz = getData($semRes)[0]->studiensemester_kurzbz;
|
||||
$studiensemesterRes = $this->StudiensemesterModel->getAkt();
|
||||
|
||||
if (isError($studiensemesterRes)) $this->logError(getError($studiensemesterRes));
|
||||
|
||||
if (hasData($studiensemesterRes))
|
||||
{
|
||||
$studiensemester_kurzbz = getData($studiensemesterRes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->logInfo("Plausicheck issue producer job started");
|
||||
|
||||
foreach ($this->_fehlerLibMappings as $fehler_kurzbz => $libName)
|
||||
{
|
||||
// get path of library for issue to be produced
|
||||
$issuesLibPath = DOC_ROOT . 'application/libraries' . self::PLAUSI_ISSUES_FOLDER;
|
||||
$issuesLibFilePath = $issuesLibPath . '/' . $libName . '.php';
|
||||
|
||||
// check if library file exists
|
||||
if (!file_exists($issuesLibFilePath))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$this->logError("Issue library file " . $issuesLibFilePath . " does not exist");
|
||||
continue;
|
||||
}
|
||||
|
||||
// load library connected to fehlercode
|
||||
$this->load->library($issuesLibPath . $libName);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
// check if method is defined in library class
|
||||
if (!is_callable(array($this->{$lowercaseLibName}, self::EXECUTE_PLAUSI_CHECK_METHOD_NAME)))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$this->logError("Method " . self::EXECUTE_PLAUSI_CHECK_METHOD_NAME . " is not defined in library $lowercaseLibName");
|
||||
continue;
|
||||
}
|
||||
|
||||
// call the function for checking for issue production
|
||||
$executePlausiRes = $this->{$lowercaseLibName}->{self::EXECUTE_PLAUSI_CHECK_METHOD_NAME}();
|
||||
|
||||
if (isError($executePlausiRes))
|
||||
{
|
||||
$this->logError(getError($executePlausiRes));
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the data returned by Plausicheck
|
||||
$executePlausiData = getData($executePlausiRes);
|
||||
|
||||
if (is_array($executePlausiData))
|
||||
{
|
||||
foreach ($executePlausiData as $plausiData)
|
||||
{
|
||||
// get the data needed for issue production
|
||||
$person_id = isset($plausiData['person_id']) ? $plausiData['person_id'] : null;
|
||||
$oe_kurzbz = isset($plausiData['oe_kurzbz']) ? $plausiData['oe_kurzbz'] : null;
|
||||
$fehlertext_params = isset($plausiData['fehlertext_params']) ? $plausiData['fehlertext_params'] : null;
|
||||
$resolution_params = isset($plausiData['resolution_params']) ? $plausiData['resolution_params'] : null;
|
||||
|
||||
// write the issue
|
||||
$addIssueRes = $this->IssuesLib->addFhcIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params);
|
||||
|
||||
if (isError($addIssueRes))
|
||||
$this->logError(getError($behobenRes));
|
||||
else
|
||||
$this->logInfo("Plausicheck issue " . $fehler_kurzbz . " successfully produced");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->logInfo("Plausicheck issue producer job stopped");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ interface IIssueExistsChecker
|
||||
* @param array $params parameters needed for issue detection
|
||||
* @return object with success(true) if issue exists, success(false) otherwise
|
||||
*/
|
||||
public function produceIssue($person_id, $oe_kurzbz, $paramsForProducing);
|
||||
//public function produceIssue($person_id, $oe_kurzbz, $paramsForProducing);
|
||||
}
|
||||
|
||||
@@ -23,49 +23,53 @@ abstract class IssueProducer_Controller extends JOB_Controller
|
||||
/**
|
||||
* Initializes issue production.
|
||||
*/
|
||||
public function produceIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $paramsForChecking, $paramsForProduction)
|
||||
{
|
||||
// get libname from fehler_kurzbz
|
||||
$libName = $this->_fehlerLibMappings[$fehler_kurzbz];
|
||||
//public function produceIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $paramsForChecking, $paramsForProduction)
|
||||
//{
|
||||
//// get libname from fehler_kurzbz
|
||||
//$libName = $this->_fehlerLibMappings[$fehler_kurzbz];
|
||||
|
||||
// if called from extension (extension name set), path includes extension names, otherwise it is the core library folder
|
||||
$libRootPath = isset($this->_extensionName) ? 'extensions/' . $this->_extensionName . '/' : '';
|
||||
$issuesLibPath = $libRootPath . self::ISSUES_FOLDER . '/';
|
||||
$issuesLibFilePath = DOC_ROOT . 'application/' . $libRootPath . 'libraries/' . self::ISSUES_FOLDER . '/' . $libName . '.php';
|
||||
//// if called from extension (extension name set), path includes extension names, otherwise it is the core library folder
|
||||
//$libRootPath = isset($this->_extensionName) ? 'extensions/' . $this->_extensionName . '/' : '';
|
||||
//$issuesLibPath = $libRootPath . self::ISSUES_FOLDER . '/';
|
||||
//$issuesLibFilePath = DOC_ROOT . 'application/' . $libRootPath . 'libraries/' . self::ISSUES_FOLDER . '/' . $libName . '.php';
|
||||
|
||||
// check if library file exists
|
||||
if (!file_exists($issuesLibFilePath)) return error("Issue library file " . $issuesLibFilePath . " does not exist");
|
||||
//// check if library file exists
|
||||
//if (!file_exists($issuesLibFilePath)) return error("Issue library file " . $issuesLibFilePath . " does not exist");
|
||||
|
||||
// load library connected to fehler_kurzbz
|
||||
$this->load->library($issuesLibPath . $libName);
|
||||
//// load library connected to fehler_kurzbz
|
||||
//$this->load->library($issuesLibPath . $libName);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
//$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
// check if method is defined in library class
|
||||
if (!is_callable(array($this->{$lowercaseLibName}, self::CHECK_ISSUE_EXISTS_METHOD_NAME)))
|
||||
return error("Method " . self::CHECK_ISSUE_EXISTS_METHOD_NAME . " is not defined in library $lowercaseLibName");
|
||||
//// check if method is defined in library class
|
||||
//if (!is_callable(array($this->{$lowercaseLibName}, self::CHECK_ISSUE_EXISTS_METHOD_NAME)))
|
||||
//return error("Method " . self::CHECK_ISSUE_EXISTS_METHOD_NAME . " is not defined in library $lowercaseLibName");
|
||||
|
||||
// call the function for checking for issue resolution
|
||||
$issueExistsRes = $this->{$lowercaseLibName}->{self::CHECK_ISSUE_EXISTS_METHOD_NAME}($paramsForChecking);
|
||||
//// call the function for checking for issue resolution
|
||||
//$issueExistsRes = $this->{$lowercaseLibName}->{self::CHECK_ISSUE_EXISTS_METHOD_NAME}($paramsForChecking);
|
||||
|
||||
if (isError($issueExistsRes)) return $issueExistsRes;
|
||||
//if (isError($issueExistsRes)) return $issueExistsRes;
|
||||
|
||||
$issueExistsData = getData($issueExistsRes);
|
||||
//$issueExistsData = getData($issueExistsRes);
|
||||
|
||||
if ($issueExistsData === true)
|
||||
{
|
||||
// write issue if it was detected
|
||||
$produceRes = $this->{$lowercaseLibName}->{self::PRODUCE_ISSUE_METHOD_NAME}(
|
||||
$fehler_kurzbz,
|
||||
isset($params['person_id']) ? $params['person_id'] : null,
|
||||
isset($params['oe_kurzbz']) ? $params['oe_kurzbz'] : null,
|
||||
$paramsForProduction
|
||||
);
|
||||
//if ($issueExistsData === true)
|
||||
//{
|
||||
//// write issue if it was detected
|
||||
////$produceRes = $this->{$lowercaseLibName}->{self::PRODUCE_ISSUE_METHOD_NAME}(
|
||||
////$fehler_kurzbz,
|
||||
////isset($params['person_id']) ? $params['person_id'] : null,
|
||||
////isset($params['oe_kurzbz']) ? $params['oe_kurzbz'] : null,
|
||||
////$paramsForProduction
|
||||
////);
|
||||
|
||||
if (isError($produceRes))
|
||||
return $produceRes;
|
||||
////if (isError($produceRes))
|
||||
////return $produceRes;
|
||||
|
||||
return success("Issue " . $issue->issue_id . " successfully written");
|
||||
}
|
||||
}
|
||||
//$addIssueres = $this->IssuesLib->addFhcIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params);
|
||||
|
||||
//if (isError())
|
||||
|
||||
//return success("Issue " . $issue->issue_id . " successfully written");
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ abstract class IssueResolver_Controller extends JOB_Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$openIssues = getData($openIssuesRes);
|
||||
|
||||
foreach ($openIssues as $issue)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Lib
|
||||
class PlausicheckLib
|
||||
{
|
||||
private $_ci; // Code igniter instance
|
||||
|
||||
@@ -15,11 +15,4 @@ class Lib
|
||||
|
||||
$this->_ci->load->model('', '');
|
||||
}
|
||||
|
||||
public function getStudents()
|
||||
{
|
||||
$qry = '
|
||||
|
||||
';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Interface defining method to implement for issue producer (from core and extensions)
|
||||
*/
|
||||
interface IPlausiChecker
|
||||
{
|
||||
/**
|
||||
* Executes a plausi check.
|
||||
* @param array $params parameters needed for executing the check
|
||||
* @return array with objects which failed the plausi check
|
||||
*/
|
||||
public function executePlausiCheck($paramsForChecking);
|
||||
}
|
||||
Reference in New Issue
Block a user