Esempio n. 1
0
 /**
  * Validates join by id attribute.
  * @param string[][] $resultSetArray
  * @param ReportDefinition $reportDefinitionObject
  * @param SimpleXMLElement $join
  * @throws ReportException
  */
 private function validateJoinById($resultSetArray, $reportDefinitionObject, $join)
 {
     $numberJoinBy = 0;
     $reportDefinitionObject->resetJoinBy();
     $joinBy = $reportDefinitionObject->getCurrentJoinBy($join);
     if (is_null($joinBy)) {
         throw new ReportException("Invalid XML Definition!!! ( At least two Join Bys should be defined )");
     }
     $numberJoinBy++;
     while (!is_null($joinBy)) {
         $subReportName = $reportDefinitionObject->getJoinBySubReport($joinBy);
         if (is_null($subReportName) || empty($subReportName)) {
             throw new ReportException("Invalid XML Definition!!! ( Join By Attribute 'sub_report' should be defined )");
         }
         $joinById = $reportDefinitionObject->getJoinById($joinBy);
         if (is_null($joinById) || empty($joinById)) {
             throw new ReportException("Invalid XML Definition!!! ( Join By Attribute 'id' should be defined )");
         }
         if (count($resultSetArray[$subReportName]) > 0 && !array_key_exists($joinById, $resultSetArray[$subReportName][0])) {
             $message = "The id field - " . $joinById . ' - is not a field in the report "' . $subReportName . '"';
             throw new ReportException($message);
         }
         $joinBy = $reportDefinitionObject->getNextJoinBy($join);
         $numberJoinBy++;
         if (is_null($joinBy) && $numberJoinBy <= 2) {
             throw new ReportException("Invalid XML Definition!!! ( At least two Join Bys should be defined )");
         }
     }
     $reportDefinitionObject->resetJoinBy();
 }