Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 22 |
CRAP | |
0.00% |
0 / 215 |
| ReligionService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 22 |
2352.00 | |
0.00% |
0 / 215 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| getAllReligion | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getAllReligionForFilter | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| getReligionById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| saveReligion | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| getAllCasteOfReligion | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| getCasteByNameAndReligion | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
| createReligion | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| createCaste | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| getCasteById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| saveCaste | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| deleteReligion | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| getReligionByName | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| deleteCaste | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| getAllReligionReport | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getAllReligionForDataImport | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| saveSubCaste | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 15 |
|||
| getAllSubCastesByCasteId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
| deleteSubCaste | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| getAllCasteByReligionID | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use com\linways\core\ams\professional\dto\Religion; | |
| use com\linways\core\ams\professional\dto\Caste; | |
| class ReligionService extends BaseService | |
| { | |
| // /Condition 1 - Presence of a static member variable | |
| private static $_instance = null; | |
| private $mapper = []; | |
| // /Condition 2 - Locked down the constructor | |
| private function __construct() | |
| { | |
| } | |
| // Prevent any oustide instantiation of this class | |
| // /Condition 3 - Prevent any object or instance of that class to be cloned | |
| private function __clone() | |
| { | |
| } | |
| // Prevent any copy of this object | |
| // /Condition 4 - Have a single globally accessible static method | |
| public static function getInstance() | |
| { | |
| if (!is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
| self::$_instance = new self(); | |
| return self::$_instance; | |
| } | |
| /** | |
| * get all religion | |
| * | |
| * @return list of religion | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllReligion($sortBy = 'religionName', $sortOrder = 'ASC') | |
| { | |
| $query = "SELECT religionID AS religionId, religionName, religionDesc FROM religion ORDER BY " . $sortBy . " " . $sortOrder . ""; | |
| try { | |
| $response = $this->executeQueryForList($query); | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllReligionForFilter() | |
| { | |
| $query = "SELECT religionID AS id, religionName as name, religionDesc as description | |
| FROM religion ORDER BY religionName"; | |
| try { | |
| $response = $this->executeQueryForList($query); | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * get religion by religion ID | |
| * | |
| * @param unknown $religionId | |
| * @return unknown | |
| * @throws ProfessionalException | |
| */ | |
| public function getReligionById($religionId) | |
| { | |
| $religionId = $this->realEscapeString($religionId); | |
| $query = "SELECT religionID, religionName, religionDesc FROM religion WHERE religionID=\"$religionId\""; | |
| try { | |
| $response = $this->executeQueryForObject($query); | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * save relgion | |
| * @param unknown $religionObj | |
| * @return string | |
| * @throws ProfessionalException | |
| * @author Aswin | |
| * @deprecated use createReligion | |
| */ | |
| public function saveReligion($religionObj) | |
| { | |
| $religionObj = $this->realEscapeObject($religionObj); | |
| if (!$religionObj->religionID) { | |
| $query = "insert into religion (religionName,religionDesc) values (\"$religionObj->religionName\",\"$religionObj->religionDesc\")"; | |
| } else { | |
| $query = "update religion set religionName=\"$religionObj->religionName\",religionDesc=\"$religionObj->religionDesc\" where religionID=\"$religionObj->religionID\""; | |
| } | |
| try { | |
| $response = $this->executeQueryForList($query); | |
| return "saved"; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getAllCasteOfReligion($religionID) | |
| { | |
| $religionID = $this->realEscapeString($religionID); | |
| $query = "select casteID, casteName, religionID, student_specify, sub_caste_label, sub_caste_description from student_caste where religionID=\"$religionID\""; | |
| try { | |
| $response = $this->executeQueryForList($query); | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Get Cast by name and religion id | |
| * @param string $casteName | |
| * @param int $religionId | |
| * @return object|NULL|\com\linways\base\util\$objectList[] | |
| * @throws ProfessionalException | |
| */ | |
| public function getCasteByNameAndReligion($casteName, $religionId) | |
| { | |
| $caste = null; | |
| $casteName = $this->realEscapeString($casteName); | |
| $religionId = $this->realEscapeString($religionId); | |
| $query = "select * from student_caste where casteName='$casteName' and religionID = $religionId"; | |
| try { | |
| $caste = $this->executeQueryForObject($query); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $caste; | |
| } | |
| /** | |
| * Create religion | |
| * | |
| * @param Religion $religion | |
| * @return string | |
| * @throws ProfessionalException | |
| */ | |
| public function createReligion($religion) | |
| { | |
| $religion = $this->realEscapeObject($religion); | |
| $id = null; | |
| if (!empty($religion)) { | |
| try { | |
| $query = "INSERT INTO religion (religionName,religionDesc) | |
| VALUES ('$religion->religionName','$religion->religionDesc')"; | |
| $id = $this->executeQueryForObject($query, true); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| return $id; | |
| } | |
| /** | |
| * Create Caste | |
| * @param Caste $caste | |
| * @return string | |
| * @throws ProfessionalException | |
| */ | |
| public function createCaste($caste) | |
| { | |
| $caste = $this->realEscapeObject($caste); | |
| $id = null; | |
| if (!empty($caste)) { | |
| try { | |
| $query = "INSERT INTO student_caste (casteName,religionID) | |
| VALUES ('$caste->casteName','$caste->religionID')"; | |
| $id = $this->executeQueryForObject($query, true); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| return $id; | |
| } | |
| public function getCasteById($casteID) | |
| { | |
| $this->realEscapeString($casteID); | |
| $query = "select casteID, casteName, religionID, student_specify, sub_caste_label, sub_caste_description from student_caste where casteID=\"$casteID\""; | |
| try { | |
| $response = $this->executeQueryForObject($query); | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @param unknown $casteObj | |
| * @return string | |
| * @throws ProfessionalException | |
| * @deprecated use createCaste | |
| */ | |
| public function saveCaste($casteObj) | |
| { | |
| $casteObj = $this->realEscapeObject($casteObj); | |
| if (!$casteObj->casteID) { | |
| $query = "insert into student_caste (casteName,religionID) values (\"$casteObj->casteName\",\"$casteObj->religionID\")"; | |
| } else { | |
| $query = "update student_caste set casteName=\"$casteObj->casteName\" where casteID=\"$casteObj->casteID\""; | |
| } | |
| try { | |
| $response = $this->executeQueryForList($query); | |
| return "saved"; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function deleteReligion($religionID) | |
| { | |
| $religionID = $this->realEscapeString($religionID); | |
| $query = "delete from religion where religionID='$religionID'"; | |
| try { | |
| $response = $this->executeQueryForList($query); | |
| return "deleted"; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Get relgion by name | |
| * | |
| * @param string $religionName | |
| * @return string | |
| * @throws ProfessionalException | |
| */ | |
| public function getReligionByName($religionName) | |
| { | |
| $religionName = $this->realEscapeString($religionName); | |
| $religion = null; | |
| if (!empty($religionName)) { | |
| $query = "SELECT religionId as id ,religionName as name ,religionDesc as description from religion | |
| WHERE religionName='$religionName'"; | |
| try { | |
| $religion = $this->executeQueryForObject($query); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| return $religion; | |
| } | |
| public function deleteCaste($casteId) | |
| { | |
| $casteId = $this->realEscapeString($casteId); | |
| $query = "delete from student_caste where casteID='$casteId'"; | |
| try { | |
| $response = $this->executeQueryForList($query); | |
| return "deleted"; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * get all religion | |
| * | |
| * @return list of religion | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllReligionReport($sortBy = 'religionName', $sortOrder = 'ASC') | |
| { | |
| $query = "SELECT religionID AS id, religionName as name, religionDesc FROM religion ORDER BY " . $sortBy . " " . $sortOrder . ""; | |
| try { | |
| $response = $this->executeQueryForList($query); | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getAllReligionForDataImport() | |
| { | |
| $query = "SELECT religionID AS id, religionName as name, religionDesc FROM religion ORDER BY religionName ASC"; | |
| try { | |
| $response = $this->executeQueryForList($query); | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @param $subCasteRequest | |
| * @return $id | |
| * @throws ProfessionalException | |
| */ | |
| public function saveSubCaste($subCasteRequest){ | |
| $subCasteRequest = $this->realEscapeObject($subCasteRequest); | |
| if($subCasteRequest->id){ | |
| $sql = "INSERT INTO student_subcaste (subcaste_name, student_caste_id, student_reservation_id) values ('$subCasteRequest->subCasteName','$subCasteRequest->studentCasteId','$subCasteRequest->studentReservationId')"; | |
| } | |
| else{ | |
| $sql ="UPDATE student_subcaste set subcaste_name = '$subCasteRequest->subCasteName',student_reservation_id = '$subCasteRequest->studentReservationId' where id = '$subCasteRequest->id'"; | |
| } | |
| try{ | |
| $response = $this->executeQuery($sql,true); | |
| $id = $response->id; | |
| return $id; | |
| }catch(\Exception $e) { | |
| throw new AdmissionException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @param $subCasteRequest | |
| * @return Array SubCaste List | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllSubCastesByCasteId($studentCasteId){ | |
| $sql = "SELECT id, subcaste_name, student_caste_id, student_reservation_id,isHidden from student_subcaste where student_caste_id = '$studentCasteId' order by student_caste_id desc"; | |
| try{ | |
| return $this->executeQueryForList($sql); | |
| }catch(\Exception $e) { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @param $request | |
| * @throws ProfessionalException | |
| */ | |
| public function deleteSubCaste($request){ | |
| $sql ="DELETE from student_subcaste where id = '$request->id'"; | |
| try{ | |
| $this->executeQuery($sql); | |
| return; | |
| }catch(\Exception $e) { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @param $request | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllCasteByReligionID($religionID){ | |
| $sql = "SELECT casteID,casteName,religionID from student_caste sc where religionID ='$religionID'"; | |
| try{ | |
| return $this->executeQueryForList($sql); | |
| }catch(\Exception $e) { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| } | |