Ignore:
Timestamp:
Jul 19, 2011, 6:20:58 PM (14 years ago)
Author:
cla
Message:

rdfint

  • optimized Data::query, now testing properties before creating Projections
File:
1 edited

Legend:

Unmodified
Added
Removed
  • php/trunk/classes/rdfa_Data.php

    r36 r63  
    952952
    953953  // --------------------------------------------------------
    954  
     954
    955955  /**
    956956   * Retrieves a list of Projections based on a set of selection criteria.
     
    995995      return false;
    996996
    997     // create projections for examination
     997    // examine properties
    998998    $aprojection_test = array();
    999999    $count = count( $asubjects);
    1000     if ($fLogMessages) $this->debugger->sendMessage( "Getting $count projections for filter test",
     1000    if ($fLogMessages) $this->debugger->sendMessage( "Testing $count subjects",
    10011001                                                     self::debugcontext);
     1002    $aFilteredSubjects = array();
    10021003    foreach ($asubjects as $subject) {
    1003       $aprojection_test[] = new \rdfa\Projection( $this, $subject, $template);
    10041004      $debugmessage .= "$subject\n";
    1005     }
    1006 
    1007     // determine which projections have to be filtered out
    1008     $aFilteredSubjects = array();
    1009     foreach ($aprojection_test as $projection) {
    1010       $subject = $projection->getSubject();
    10111005      foreach ($query as $property => $value) {
    1012         $avalues = $projection->getAll( $property);
     1006        $avalues = $this->getValues( $subject, $property);
    10131007        if ($avalues == false) {
    1014           // filter this projection: property not found
     1008          // filter this subject: property not found
    10151009          $aFilteredSubjects[ $subject] = "Property $property not found";
    10161010          break;
     
    10241018      }
    10251019    }
     1020
    10261021    $count = count( $aFilteredSubjects);
    10271022    if ($count == 0) {
    10281023      $debugmessage = "No projections filtered\n";
    10291024    } else {
    1030       $debugmessage = "Filtering $count projections\n";
     1025      $debugmessage = "Filtering $count subjects\n";
    10311026      foreach ( $aFilteredSubjects as $subject => $reason) {
    10321027        $debugmessage .= "$subject: $reason\n";
     
    10391034    // take over unfiltered projections
    10401035    $aprojection = array();
    1041     foreach ($aprojection_test as $projection) {
    1042       if (array_key_exists( $projection->getSubject(), $aFilteredSubjects) === false) {
    1043         $aprojection[] = $projection;
    1044       } else {
    1045         unset( $projection);
    1046       }
    1047     }
    1048 
    1049     // create log output
     1036    foreach ($asubjects as $subject) {
     1037      if (array_key_exists( $subject, $aFilteredSubjects) === false)
     1038        $aprojection[] = new \rdfa\Projection( $this, $subject, $template);
     1039    }
     1040
     1041    // create projections on unfiltered subjects
     1042    foreach ($aprojection as $projection) {
     1043      $debugmessage .= "{$projection->getSubject()}\n";
     1044    }
    10501045    $count = count( $aprojection);
    10511046    $debugmessage =  "Returning $count projections \n";
    1052     foreach ($aprojection as $projection) {
    1053       $debugmessage .= "{$projection->getSubject()}\n";
    1054     }
     1047
    10551048    if ($fLogMessages) $this->debugger->sendMessage( "$debugmessage",
    10561049                                                self::debugcontext);
Note: See TracChangeset for help on using the changeset viewer.