mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 08:34:29 +00:00
issues: changed logic to read producable issues from config file
This commit is contained in:
@@ -9,48 +9,40 @@ class PlausicheckDefinitionLib
|
||||
{
|
||||
// set fehler for core plausichecks
|
||||
// structure: fehler_kurzbz => class (library) name for resolving
|
||||
private $_fehlerLibMappings = array(
|
||||
'AbbrecherAktiv' => 'AbbrecherAktiv',
|
||||
'AbschlussstatusFehlt' => 'AbschlussstatusFehlt',
|
||||
'AktSemesterNull' => 'AktSemesterNull',
|
||||
'AktiverStudentOhneStatus' => 'AktiverStudentOhneStatus',
|
||||
'AusbildungssemPrestudentUngleichAusbildungssemStatus' => 'AusbildungssemPrestudentUngleichAusbildungssemStatus',
|
||||
'DatumAbschlusspruefungFehlt' => 'DatumAbschlusspruefungFehlt',
|
||||
'DatumSponsionFehlt' => 'DatumSponsionFehlt',
|
||||
'DatumStudiensemesterFalscheReihenfolge' => 'DatumStudiensemesterFalscheReihenfolge',
|
||||
'FalscheAnzahlAbschlusspruefungen' => 'FalscheAnzahlAbschlusspruefungen',
|
||||
'FalscheAnzahlHeimatadressen' => 'FalscheAnzahlHeimatadressen',
|
||||
'FalscheAnzahlZustelladressen' => 'FalscheAnzahlZustelladressen',
|
||||
'GbDatumWeitZurueck' => 'GbDatumWeitZurueck',
|
||||
'InaktiverStudentAktiverStatus' => 'InaktiverStudentAktiverStatus',
|
||||
'IncomingHeimatNationOesterreich' => 'IncomingHeimatNationOesterreich',
|
||||
'IncomingOhneIoDatensatz' => 'IncomingOhneIoDatensatz',
|
||||
'IncomingOrGsFoerderrelevant' => 'IncomingOrGsFoerderrelevant',
|
||||
'InskriptionVorLetzerBismeldung' => 'InskriptionVorLetzerBismeldung',
|
||||
'NationNichtOesterreichAberGemeinde' => 'NationNichtOesterreichAberGemeinde',
|
||||
'OrgformStgUngleichOrgformPrestudent' => 'OrgformStgUngleichOrgformPrestudent',
|
||||
'PrestudentMischformOhneOrgform' => 'PrestudentMischformOhneOrgform',
|
||||
'StgPrestudentUngleichStgStudienplan' => 'StgPrestudentUngleichStgStudienplan',
|
||||
'StgPrestudentUngleichStgStudent' => 'StgPrestudentUngleichStgStudent',
|
||||
'StudentstatusNachAbbrecher' => 'StudentstatusNachAbbrecher',
|
||||
private $_fehlerKurzbz = array(
|
||||
'AbbrecherAktiv',
|
||||
'AbschlussstatusFehlt',
|
||||
'AktSemesterNull',
|
||||
'AktiverStudentOhneStatus',
|
||||
'AusbildungssemPrestudentUngleichAusbildungssemStatus',
|
||||
'DatumAbschlusspruefungFehlt',
|
||||
'DatumSponsionFehlt',
|
||||
'DatumStudiensemesterFalscheReihenfolge',
|
||||
'FalscheAnzahlAbschlusspruefungen',
|
||||
'FalscheAnzahlHeimatadressen',
|
||||
'FalscheAnzahlZustelladressen',
|
||||
'GbDatumWeitZurueck',
|
||||
'InaktiverStudentAktiverStatus',
|
||||
'IncomingHeimatNationOesterreich',
|
||||
'IncomingOhneIoDatensatz',
|
||||
'IncomingOrGsFoerderrelevant',
|
||||
'InskriptionVorLetzerBismeldung',
|
||||
'NationNichtOesterreichAberGemeinde',
|
||||
'OrgformStgUngleichOrgformPrestudent',
|
||||
'PrestudentMischformOhneOrgform',
|
||||
'StgPrestudentUngleichStgStudienplan',
|
||||
'StgPrestudentUngleichStgStudent',
|
||||
'StudentstatusNachAbbrecher',
|
||||
'DualesStudiumOhneMarkierung' => 'DualesStudiumOhneMarkierung'
|
||||
//'StudienplanUngueltig' => 'StudienplanUngueltig'
|
||||
//'BewerberNichtZumRtAngetreten' => 'BewerberNichtZumRtAngetreten'
|
||||
//'StudienplanUngueltig',
|
||||
//'BewerberNichtZumRtAngetreten'
|
||||
);
|
||||
|
||||
/**
|
||||
* Gets all fehler_kurzbz-library mappings for fehler which need to be checked.
|
||||
*/
|
||||
public function getFehlerLibMappings()
|
||||
{
|
||||
return $this->_fehlerLibMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all fehler_kurzbz for fehler which need to be checked.
|
||||
*/
|
||||
public function getFehlerKurzbz()
|
||||
{
|
||||
return array_keys($this->_fehlerLibMappings);
|
||||
return $this->_fehlerKurzbz;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,33 +9,41 @@ class PlausicheckProducerLib
|
||||
const EXTENSIONS_FOLDER = 'extensions';
|
||||
const PLAUSI_ISSUES_FOLDER = 'issues/plausichecks';
|
||||
const EXECUTE_PLAUSI_CHECK_METHOD_NAME = 'executePlausiCheck';
|
||||
const CONFIG_FEHLER_FILENAME = 'fehler.php';
|
||||
const CONFIG_FEHLER_NAME = 'fehler';
|
||||
const FEHLER_KURZBZ_NAME = 'fehler_kurzbz';
|
||||
const PRODUCER_LIB_NAME = 'producerLibName';
|
||||
const EXTENSION_NAME = 'extensionName';
|
||||
|
||||
private $_ci; // ci instance
|
||||
private $_extensionName; // name of extension
|
||||
private $_konfiguration = []; // configuration parameters
|
||||
private $_fehlerKurzbz = []; // fehler to produce
|
||||
private $_fehlerLibMappings = []; // mappings of fehler and libraries for producing them
|
||||
private $_isForResolutionCheck = false; // mappings of fehler and libraries for producing them
|
||||
private $_apps = []; // apps of fehler to produce
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
// set extension name if called from extension
|
||||
if (isset($params['extensionName'])) $this->_extensionName = $params['extensionName'];
|
||||
if (isset($params['fehlerLibMappings'])) $this->_fehlerLibMappings = $params['fehlerLibMappings'];
|
||||
if (isset($params['isForResolutionCheck'])) $this->_isForResolutionCheck = $params['isForResolutionCheck'];
|
||||
|
||||
// set application
|
||||
$app = isset($params['app']) ? $params['app'] : null;
|
||||
// set application(s))
|
||||
if (isset($params['apps']))
|
||||
{
|
||||
if (is_string($params['apps'])) $params['apps'] = [$params['apps']];
|
||||
if (is_array($params['apps'])) $this->_apps = $params['apps'];
|
||||
}
|
||||
|
||||
$this->_ci =& get_instance(); // get ci instance
|
||||
|
||||
// load libraries
|
||||
$this->_ci->load->library('IssuesLib');
|
||||
$this->_ci->load->library('ExtensionsLib');
|
||||
|
||||
// load models
|
||||
$this->_ci->load->model('system/Fehler_model', 'FehlerModel');
|
||||
$this->_ci->load->model('system/Fehlerkonfiguration_model', 'FehlerkonfigurationModel');
|
||||
|
||||
// get all configuration parameters for the application
|
||||
$fehlerkonfigurationRes = $this->_ci->FehlerkonfigurationModel->getKonfiguration($app);
|
||||
$this->_ci->load->config('fehler');
|
||||
|
||||
// get all configuration parameters for the application(s))
|
||||
$fehlerkonfigurationRes = $this->_ci->FehlerkonfigurationModel->getKonfiguration($this->_apps);
|
||||
|
||||
if (hasData($fehlerkonfigurationRes))
|
||||
{
|
||||
@@ -46,10 +54,86 @@ class PlausicheckProducerLib
|
||||
$this->_konfiguration[$fk->fehler_kurzbz][$fk->konfigurationstyp_kurzbz] = $fk->konfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
// get all fehler to be produced (by kurzbz array or app)
|
||||
if (isset($params['fehlerKurzbz']) && !isEmptyArray($params['fehlerKurzbz']))
|
||||
{
|
||||
$this->_fehlerKurzbz = $params['fehlerKurzbz'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_ci->FehlerModel->addSelect('fehler_kurzbz');
|
||||
if (!isEmptyArray($this->_apps)) $this->_ci->FehlerModel->db->where_in('app', $this->_apps);
|
||||
$fehlerRes = $this->_ci->FehlerModel->load();
|
||||
|
||||
if (hasData($fehlerRes))
|
||||
{
|
||||
$this->_fehlerKurzbz = array_column(getData($fehlerRes), 'fehler_kurzbz');
|
||||
}
|
||||
}
|
||||
|
||||
// get producer file paths for the fehler
|
||||
|
||||
// Load Fehler Entries of Core
|
||||
$configArray = $this->_ci->config->item(self::CONFIG_FEHLER_NAME);
|
||||
|
||||
foreach ($configArray as $coreEntry)
|
||||
{
|
||||
if (!isset($coreEntry[self::FEHLER_KURZBZ_NAME])
|
||||
|| !isset($coreEntry[self::PRODUCER_LIB_NAME])
|
||||
|| !in_array($coreEntry[self::FEHLER_KURZBZ_NAME], $this->_fehlerKurzbz)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->_fehlerLibMappings[$coreEntry[self::FEHLER_KURZBZ_NAME]][self::PRODUCER_LIB_NAME] = $coreEntry[self::PRODUCER_LIB_NAME];
|
||||
}
|
||||
|
||||
// load fehler entries of extensions
|
||||
$extensions = $this->_ci->extensionslib->getInstalledExtensions();
|
||||
|
||||
if (hasData($extensions))
|
||||
{
|
||||
$extensionArray = array();
|
||||
|
||||
$extensionsData = getData($extensions);
|
||||
|
||||
|
||||
foreach ($extensionsData as $ext)
|
||||
{
|
||||
$configFilename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/'.self::CONFIG_FEHLER_FILENAME;
|
||||
|
||||
if (file_exists($configFilename))
|
||||
{
|
||||
$config = array(); // default value
|
||||
|
||||
include($configFilename);
|
||||
|
||||
if (isset($config[self::CONFIG_FEHLER_NAME]) && is_array($config[self::CONFIG_FEHLER_NAME]))
|
||||
{
|
||||
foreach ($config[self::CONFIG_FEHLER_NAME] as $extensionEntry)
|
||||
{
|
||||
if (
|
||||
!isset($extensionEntry[self::FEHLER_KURZBZ_NAME])
|
||||
|| !isset($extensionEntry[self::PRODUCER_LIB_NAME])
|
||||
|| !in_array($extensionEntry[self::FEHLER_KURZBZ_NAME], $this->_fehlerKurzbz)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fehler_kurzbz = $extensionEntry[self::FEHLER_KURZBZ_NAME];
|
||||
|
||||
$this->_fehlerLibMappings[$fehler_kurzbz][self::PRODUCER_LIB_NAME] = $extensionEntry[self::PRODUCER_LIB_NAME];
|
||||
$this->_fehlerLibMappings[$fehler_kurzbz][self::EXTENSION_NAME] = $ext->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces multiple plausicheck issues at once and saved them to db.
|
||||
* Produces multiple plausicheck issues at once, and saves them in the database.
|
||||
* @param array $params passed to each plausicheck
|
||||
* @return result object with occured error and info
|
||||
*/
|
||||
@@ -58,11 +142,17 @@ class PlausicheckProducerLib
|
||||
$result = new StdClass();
|
||||
$result->errors = [];
|
||||
$result->infos = [];
|
||||
$mappingFehlerKurbz = array_keys($this->_fehlerLibMappings);
|
||||
|
||||
foreach ($this->_fehlerLibMappings as $fehler_kurzbz => $libName)
|
||||
// check if all issues to produce could be found in database
|
||||
$notFoundFehlerKurzbz = array_diff($this->_fehlerKurzbz, $mappingFehlerKurbz);
|
||||
|
||||
if (!isEmptyArray($notFoundFehlerKurzbz))
|
||||
$result->errors[] = error('Fehler to produce not defined in config: '.implode(', ', $notFoundFehlerKurzbz));
|
||||
|
||||
foreach ($mappingFehlerKurbz as $fehler_kurzbz)
|
||||
{
|
||||
$plausicheckRes = $this->producePlausicheckIssue(
|
||||
$libName,
|
||||
$fehler_kurzbz,
|
||||
$params
|
||||
);
|
||||
@@ -96,14 +186,22 @@ class PlausicheckProducerLib
|
||||
|
||||
/**
|
||||
* Executes plausicheck using a given library, returns the result.
|
||||
* @param $libName string name of library producing the issue
|
||||
* @param $fehler_kurzbz string unique short name of fehler, for which issue is produced
|
||||
* @param $params parameters passed to issue production method
|
||||
*/
|
||||
public function producePlausicheckIssue($libName, $fehler_kurzbz, $params)
|
||||
public function producePlausicheckIssue($fehler_kurzbz, $params)
|
||||
{
|
||||
if (!isset($this->_fehlerLibMappings[$fehler_kurzbz])) return error("Mapping for Fehler " . $fehler_kurzbz . " was not found");
|
||||
|
||||
$mapping = $this->_fehlerLibMappings[$fehler_kurzbz];
|
||||
|
||||
if (!isset($mapping[self::PRODUCER_LIB_NAME]) || isEmptyString($mapping[self::PRODUCER_LIB_NAME]))
|
||||
return error("No producer lib name set for Fehler " . $fehler_kurzbz);
|
||||
|
||||
$libName = $mapping[self::PRODUCER_LIB_NAME];
|
||||
|
||||
// if called from extension (extension name set), path includes extension names
|
||||
$libRootPath = isset($this->_extensionName) ? self::EXTENSIONS_FOLDER . '/' . $this->_extensionName . '/' : '';
|
||||
$libRootPath = isset($mapping[self::EXTENSION_NAME]) ? self::EXTENSIONS_FOLDER . '/' . $mapping[self::EXTENSION_NAME] . '/' : '';
|
||||
|
||||
// path for loading issue library
|
||||
$issuesLibPath = $libRootPath . self::PLAUSI_ISSUES_FOLDER . '/';
|
||||
@@ -121,7 +219,7 @@ class PlausicheckProducerLib
|
||||
// load library connected to fehlercode
|
||||
$this->_ci->load->library(
|
||||
$issuesLibPath . $libName,
|
||||
['configurationParams' => $config, 'isForResolutionCheck' => $this->_isForResolutionCheck]
|
||||
['configurationParams' => $config]
|
||||
);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
@@ -9,28 +9,106 @@ class PlausicheckResolverLib
|
||||
const EXTENSIONS_FOLDER = 'extensions';
|
||||
const ISSUE_RESOLVERS_FOLDER = 'issues/resolvers';
|
||||
const CHECK_ISSUE_RESOLVED_METHOD_NAME = 'checkIfIssueIsResolved';
|
||||
const CONFIG_FEHLER_FILENAME = 'fehler.php';
|
||||
const CONFIG_FEHLER_NAME = 'fehler';
|
||||
const FEHLERCODE_NAME = 'fehlercode';
|
||||
const FEHLER_KURZBZ_NAME = 'fehler_kurzbz';
|
||||
const RESOLVER_LIB_NAME = 'resolverLibName';
|
||||
const PRODUCER_IS_RESOLVER_NAME = 'producerIsResolver';
|
||||
const EXTENSION_NAME = 'extensionName';
|
||||
|
||||
|
||||
private $_ci; // ci instance
|
||||
private $_extensionName; // name of extension
|
||||
private $_fehlercodes = []; // name of extension
|
||||
private $_codeLibMappings = []; // mappings for issues which explicitly defined resolver
|
||||
private $_codeProducerLibMappings = []; // mappings for issues which are resolved with the same check as they are produced
|
||||
private $_defaultIssueParams = ['issue_id' => 'issue_id', 'issue_person_id' => 'person_id', 'issue_oe_kurzbz' => 'oe_kurzbz'];
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
// set extension name if called from extension
|
||||
if (isset($params['extensionName'])) $this->_extensionName = $params['extensionName'];
|
||||
if (isset($params['codeLibMappings'])) $this->_codeLibMappings = $params['codeLibMappings'];
|
||||
if (isset($params['codeProducerLibMappings'])) $this->_codeProducerLibMappings = $params['codeProducerLibMappings'];
|
||||
// get all fehler to be produced (by kurzbz array or app)
|
||||
if (isset($params['fehlercodes']) && !isEmptyArray($params['fehlercodes']))
|
||||
{
|
||||
$this->_fehlercodes = $params['fehlercodes'];
|
||||
}
|
||||
|
||||
$this->_ci =& get_instance(); // get ci instance
|
||||
|
||||
$this->_ci->load->library('IssuesLib');
|
||||
$this->_ci->load->library('issues/PlausicheckProducerLib', ['extensionName' => $this->_extensionName, 'isForResolutionCheck' => true]);
|
||||
$this->_ci->load->library('ExtensionsLib');
|
||||
|
||||
$this->_ci->load->config('fehler');
|
||||
|
||||
// Load Fehler Entries of Core
|
||||
$configArray = $this->_ci->config->item(self::CONFIG_FEHLER_NAME);
|
||||
|
||||
$fehlerKurzbzArr = [];
|
||||
|
||||
foreach ($configArray as $coreEntry)
|
||||
{
|
||||
if (!isset($coreEntry[self::FEHLERCODE_NAME])
|
||||
|| !in_array($coreEntry[self::FEHLERCODE_NAME], $this->_fehlercodes)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($coreEntry[self::FEHLER_KURZBZ_NAME])) $fehlerKurzbzArr[] = $coreEntry[self::FEHLER_KURZBZ_NAME];
|
||||
|
||||
$this->_codeLibMappings[$coreEntry[self::FEHLERCODE_NAME]][self::RESOLVER_LIB_NAME] = $coreEntry[self::RESOLVER_LIB_NAME] ?? null;
|
||||
$this->_codeLibMappings[$coreEntry[self::FEHLERCODE_NAME]][self::PRODUCER_IS_RESOLVER_NAME]
|
||||
= $coreEntry[self::PRODUCER_IS_RESOLVER_NAME] ?? false;
|
||||
}
|
||||
|
||||
// load fehler entries of extensions
|
||||
$extensions = $this->_ci->extensionslib->getInstalledExtensions();
|
||||
|
||||
if (hasData($extensions))
|
||||
{
|
||||
$extensionArray = array();
|
||||
|
||||
$extensionsData = getData($extensions);
|
||||
|
||||
foreach ($extensionsData as $ext)
|
||||
{
|
||||
$configFilename = APPPATH.'config/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$ext->name.'/'.self::CONFIG_FEHLER_FILENAME;
|
||||
|
||||
if (file_exists($configFilename))
|
||||
{
|
||||
$config = array(); // default value
|
||||
|
||||
include($configFilename);
|
||||
|
||||
if (isset($config[self::CONFIG_FEHLER_NAME]) && is_array($config[self::CONFIG_FEHLER_NAME]))
|
||||
{
|
||||
foreach ($config[self::CONFIG_FEHLER_NAME] as $extensionEntry)
|
||||
{
|
||||
if (
|
||||
!isset($extensionEntry[self::FEHLERCODE_NAME])
|
||||
|| !in_array($extensionEntry[self::FEHLERCODE_NAME], $this->_fehlercodes)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fehlercode = $extensionEntry[self::FEHLERCODE_NAME];
|
||||
if (isset($extensionEntry[self::FEHLER_KURZBZ_NAME])) $fehlerKurzbzArr[] = $extensionEntry[self::FEHLER_KURZBZ_NAME];
|
||||
|
||||
$this->_codeLibMappings[$fehlercode][self::RESOLVER_LIB_NAME]
|
||||
= $extensionEntry[self::RESOLVER_LIB_NAME] ?? null;
|
||||
$this->_codeLibMappings[$fehlercode][self::EXTENSION_NAME] = $ext->name;
|
||||
$this->_codeLibMappings[$fehlercode][self::PRODUCER_IS_RESOLVER_NAME]
|
||||
= $extensionEntry[self::PRODUCER_IS_RESOLVER_NAME] ?? false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_ci->load->library('issues/PlausicheckProducerLib', ['fehlerKurzbz' => $fehlerKurzbzArr]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reseolves multiple plausicheck issues at once.
|
||||
* @param array $codeLibMappings contains fehler type to check and library responsible for check (fehlercode => libName)
|
||||
* @param array $openIssues passed issues to resolve
|
||||
* @return result object with occured error and info
|
||||
*/
|
||||
@@ -40,12 +118,25 @@ class PlausicheckResolverLib
|
||||
$result->errors = [];
|
||||
$result->infos = [];
|
||||
|
||||
// check if all issues to resolve could be found in database
|
||||
$mappingFehlerCodes = array_keys($this->_codeLibMappings);
|
||||
$notFoundFehlerCodes = array_diff($this->_fehlercodes, $mappingFehlerCodes);
|
||||
|
||||
if (!isEmptyArray($notFoundFehlerCodes))
|
||||
$result->errors[] = error('Fehler to resolve not defined in config: '.implode(', ', $notFoundFehlerCodes));
|
||||
|
||||
foreach ($openIssues as $issue)
|
||||
{
|
||||
$params = [];
|
||||
foreach ($this->_defaultIssueParams as $index => $propertyName)
|
||||
{
|
||||
$params[$index] = $issue->{$propertyName};
|
||||
}
|
||||
|
||||
// add person id and oe kurzbz automatically as params, merge it with additional params
|
||||
// decode bewerbung_parameter into assoc array
|
||||
$params = array_merge(
|
||||
array('issue_id' => $issue->issue_id, 'issue_person_id' => $issue->person_id, 'issue_oe_kurzbz' => $issue->oe_kurzbz),
|
||||
$params,
|
||||
isset($issue->behebung_parameter) ? json_decode($issue->behebung_parameter, true) : array()
|
||||
);
|
||||
|
||||
@@ -54,69 +145,72 @@ class PlausicheckResolverLib
|
||||
// ignore if Fehlercode is not in libmappings (shouldn't be checked)
|
||||
if (isset($this->_codeLibMappings[$issue->fehlercode]))
|
||||
{
|
||||
$libName = $this->_codeLibMappings[$issue->fehlercode];
|
||||
$codeLibMapping = $this->_codeLibMappings[$issue->fehlercode];
|
||||
$libName = $codeLibMapping[self::RESOLVER_LIB_NAME];
|
||||
$extensionName = $codeLibMapping[self::EXTENSION_NAME] ?? null;
|
||||
$producerIsResolver = $codeLibMapping[self::PRODUCER_IS_RESOLVER_NAME] ?? false;
|
||||
|
||||
// if called from extension (extension name set), path includes extension names
|
||||
$libRootPath = isset($this->_extensionName) ? self::EXTENSIONS_FOLDER . '/' . $this->_extensionName . '/' : '';
|
||||
|
||||
// path for loading issue library
|
||||
$issuesLibPath = $libRootPath . self::ISSUE_RESOLVERS_FOLDER . '/';
|
||||
|
||||
// file path of library for check if file exists
|
||||
$issuesLibFilePath = DOC_ROOT . self::CI_PATH
|
||||
. '/' . $libRootPath . self::CI_LIBRARY_FOLDER . '/' . self::ISSUE_RESOLVERS_FOLDER . '/' . $libName . '.php';
|
||||
|
||||
// check if library file exists
|
||||
if (!file_exists($issuesLibFilePath))
|
||||
if ($producerIsResolver)
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$result->errors[] = "Issue library file " . $issuesLibFilePath . " does not exist";
|
||||
continue;
|
||||
}
|
||||
// execute same check as used for issue production
|
||||
$issueResolvedRes = $this->_ci->plausicheckproducerlib->producePlausicheckIssue(
|
||||
$issue->fehler_kurzbz,
|
||||
$params
|
||||
);
|
||||
|
||||
// load library connected to fehlercode
|
||||
$this->_ci->load->library($issuesLibPath . $libName);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
// check if method is defined in library class
|
||||
if (!is_callable(array($this->_ci->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME)))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$result->errors[] = "Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName";
|
||||
continue;
|
||||
}
|
||||
|
||||
// call the function for checking for issue resolution
|
||||
$issueResolvedRes = $this->_ci->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params);
|
||||
|
||||
if (isError($issueResolvedRes))
|
||||
{
|
||||
$result->errors[] = getError($issueResolvedRes);
|
||||
if (isError($issueResolvedRes))
|
||||
{
|
||||
$result->errors[] = getError($issueResolvedRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
$issueResolved = !hasData($issueResolvedRes);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$issueResolved = getData($issueResolvedRes) === true;
|
||||
}
|
||||
}
|
||||
elseif (isset($this->_codeProducerLibMappings[$issue->fehlercode])) // check if it is an issue without explicit resolver, "self-resolving"
|
||||
{
|
||||
$libName = $this->_codeProducerLibMappings[$issue->fehlercode];
|
||||
// if called from extension (extension name set), path includes extension names
|
||||
$libRootPath = isset($extensionName) ? self::EXTENSIONS_FOLDER . '/' . $extensionName . '/' : '';
|
||||
|
||||
// execute same check as used for issue production
|
||||
$issueResolvedRes = $this->_ci->plausicheckproducerlib->producePlausicheckIssue(
|
||||
$libName,
|
||||
$issue->fehler_kurzbz,
|
||||
$params
|
||||
);
|
||||
// path for loading issue library
|
||||
$issuesLibPath = $libRootPath . self::ISSUE_RESOLVERS_FOLDER . '/';
|
||||
|
||||
if (isError($issueResolvedRes))
|
||||
{
|
||||
$result->errors[] = getError($issueResolvedRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
$issueResolved = !hasData($issueResolvedRes);
|
||||
// file path of library for check if file exists
|
||||
$issuesLibFilePath = DOC_ROOT . self::CI_PATH
|
||||
. '/' . $libRootPath . self::CI_LIBRARY_FOLDER . '/' . self::ISSUE_RESOLVERS_FOLDER . '/' . $libName . '.php';
|
||||
|
||||
// check if library file exists
|
||||
if (!file_exists($issuesLibFilePath))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$result->errors[] = "Issue library file " . $issuesLibFilePath . " does not exist";
|
||||
continue;
|
||||
}
|
||||
|
||||
// load library connected to fehlercode
|
||||
$this->_ci->load->library($issuesLibPath . $libName);
|
||||
|
||||
$lowercaseLibName = mb_strtolower($libName);
|
||||
|
||||
// check if method is defined in library class
|
||||
if (!is_callable(array($this->_ci->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME)))
|
||||
{
|
||||
// log error and continue with next issue if not
|
||||
$result->errors[] = "Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName";
|
||||
continue;
|
||||
}
|
||||
|
||||
// call the function for checking for issue resolution
|
||||
$issueResolvedRes = $this->_ci->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params);
|
||||
|
||||
if (isError($issueResolvedRes))
|
||||
{
|
||||
$result->errors[] = getError($issueResolvedRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
$issueResolved = getData($issueResolvedRes) === true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
*/
|
||||
abstract class PlausiChecker
|
||||
{
|
||||
const ISSUE_ID_NAME = 'issue_id';
|
||||
|
||||
protected $_ci; // code igniter instance
|
||||
protected $_config; // all applicable configuration parameters for this plausicheck
|
||||
protected $_db; // database for queries
|
||||
|
||||
protected $_isForResolutionCheck; // if true, additional parameters only needed for resolution are checked
|
||||
|
||||
protected $_config_params = []; // name of all config params which should be applied for this plausicheck, with sql [name] => [sql]
|
||||
protected $_params_for_checking = []; // name of all passed params for checking, with sql [name] => [sql]
|
||||
|
||||
@@ -24,8 +24,6 @@ abstract class PlausiChecker
|
||||
// set configuration
|
||||
$this->_config = $params['configurationParams'] ?? [];
|
||||
|
||||
$this->_isForResolutionCheck = $params['isForResolutionCheck'] ?? false;
|
||||
|
||||
// get database for queries
|
||||
$this->_db = new DB_Model();
|
||||
}
|
||||
@@ -41,15 +39,20 @@ abstract class PlausiChecker
|
||||
$params = [];
|
||||
$qry = $this->_base_sql;
|
||||
|
||||
if ($this->_isForResolutionCheck == true)
|
||||
// if issue id is set, issue is resolving - check if behebung parameter are present
|
||||
if (isset($paramsForChecking[self::ISSUE_ID_NAME]))
|
||||
{
|
||||
foreach ($this->_resolution_params as $resParam)
|
||||
{
|
||||
if (!isset($paramsForChecking[$resParam]))
|
||||
return error("$resParam missing".(isset($paramsForChecking['issue_id']) ? ", issue ID: ".$paramsForChecking['issue_id'] : ""));
|
||||
return error("$resParam missing"
|
||||
.(isset($paramsForChecking[self::ISSUE_ID_NAME]) ? ", issue ID: ".$paramsForChecking[self::ISSUE_ID_NAME] : ""));
|
||||
}
|
||||
}
|
||||
|
||||
// get fehlertext and resolution params
|
||||
|
||||
|
||||
// add config params to query
|
||||
if (isset($this->_config_params) && !isEmptyArray($this->_config_params))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user