Exemple #1
0
 /**
  * Converts the incoming exhibition bean object to PDO instances.
  * This includes the conversion from nested list of
  * linked elements stored as arrays of oids to their
  * PDO instances.
  *
  * @access private
  * @param bean $bean an Exhibition bean
  * @param bean $copyOption an optional CopyOptionBean (for ignore null values)
  */
 private function exhibitionBeanToPdo($bean, $copyOption = null)
 {
     global $logger;
     $logger->debug(get_class($this) . "::exhibitionBeanToPdo({$bean},{$copyOption})");
     if (get_class($bean) != 'Exhibition') {
         trigger_error("Incoming object is not a valid Event", E_USER_ERROR);
         return;
     }
     if ($copyOption == null) {
         $copyOption = new CopyBeanOption();
         $copyOption->setScalarsOnly(true);
     }
     // Check to see if there is a event OID
     if ($bean->getOid() > 0) {
         $pdo = $this->fetchEventById('Exhibition', $bean->getOid());
     } else {
         // Get a new event PDO
         $epm = epManager::instance();
         $pdo = $epm->create('Exhibition');
     }
     // Copy the bean values over the top of the PDO values
     BeanUtil::copyBean($bean, $pdo, $copyOption);
     // schedule pdo
     $schedule = $this->fetchSchedule($bean->getSchedule(), 'Exhibition');
     //print_r($schedule);
     //print_r($bean->getSchedule());
     $bean->getSchedule()->setScope('Exhibition');
     BeanUtil::copyBean($bean->getSchedule(), $schedule, $copyOption);
     //print_r($schedule);
     $pdo->setSchedule($schedule);
     //print_r($pdo->getSchedule());
     // pubState from string to pdo
     $pubState = $this->fetchPubState($bean->getPubState());
     $pdo->setPubState($pubState);
     // eventStatus from string to pdo
     $eventStatus = $this->fetchEventStatus($bean->getEventStatus());
     $pdo->setEventStatus($eventStatus);
     // venues from array of oids to array of pdos
     $venues = $bean->getVenues();
     if ($venues != null) {
         $vpdos = array();
         foreach ($venues as $venue) {
             if ($venue->getOid() == 0) {
                 continue;
             }
             $vpdos[] = $this->fetchVenueById($venue->getOid());
         }
         $pdo->getVenues()->removeAll();
         $pdo->setVenues($vpdos);
     }
     // categories from keyed array of oids to array of pdos
     $cats = $bean->getCategories();
     if ($cats != null) {
         $cpdos = array();
         foreach ($cats as $key => $value) {
             foreach ($value as $cat) {
                 if ($cat->getOid() == 0) {
                     continue;
                 }
                 $cpdos[] = $this->fetchCategoryById(ucfirst($key), $cat->getOid());
             }
         }
         $pdo->getCategories()->removeAll();
         $pdo->setCategories($cpdos);
     }
     // related programs from keyed array of oids to array of pdos
     $programs = $bean->getPrograms();
     if ($programs != null) {
         $epdos = array();
         foreach ($programs as $program) {
             if ($program->getOid() == 0) {
                 continue;
             }
             $epdos[] = $this->fetchEventById('Program', $program->getOid());
         }
         $pdo->getPrograms()->removeAll();
         $pdo->setPrograms($epdos);
     }
     // related courses from keyed array of oids to array of pdos
     $courses = $bean->getCourses();
     if ($courses != null) {
         $epdos = array();
         foreach ($courses as $course) {
             if ($course->getOid() == 0) {
                 continue;
             }
             $epdos[] = $this->fetchEventById('Course', $course->getOid());
         }
         $pdo->getCourses()->removeAll();
         $pdo->setCourses($epdos);
     }
     // related artists
     $artists = $bean->getArtists();
     if ($artists != null) {
         $ps = $this->getPersonService();
         $epdos = array();
         foreach ($artists as $artist) {
             if ($artist->getOid() == 0) {
                 continue;
             }
             $epdos[] = $ps->fetchPersonById('Artist', $artist->getOid());
         }
         $pdo->getArtists()->removeAll();
         $pdo->setArtists($epdos);
     }
     return $pdo;
 }
Exemple #2
0
 /**
  * A convenience method to copy attributes from the PDO
  * to the Bean. Will automatically set the useTargetVars 
  * attribute of the CopyBeanOption.
  * 
  * @access private
  * @param pdo The HomePage PDO object (source)
  * @return bean The HomePage bean
  */
 private function pdoToBean($pdo)
 {
     global $logger;
     $logger->debug(get_class($this) . "::pdoToBean({$pdo})");
     $copyOption = new CopyBeanOption();
     $copyOption->setUseTargetVars(true);
     $copyOption->setScalarsOnly(true);
     $bean = new HomePage();
     $bean = BeanUtil::copyBean($pdo, $bean, $copyOption);
     // Convert the pubState to a string
     $ps = '';
     if ($pdo->getPubState() != null) {
         $ps = $pdo->getPubState()->getValue();
     }
     $bean->setPubState($ps);
     return $bean;
 }
Exemple #3
0
 /**
  * A convenience method to copy attributes from the PDO
  * to the Bean. Will automatically set the useTargetVars 
  * attribute of the CopyBeanOption.
  * 
  * @access private
  * @param pdo The Venue PDO object (source)
  * @return bean The Venue bean
  */
 private function pdoToBean($pdo)
 {
     global $logger;
     $logger->debug(get_class($this) . "::pdoToBean({$pdo})");
     $copyOption = new CopyBeanOption();
     $copyOption->setUseTargetVars(true);
     $copyOption->setScalarsOnly(true);
     $bean = new Venue();
     $bean = BeanUtil::copyBean($pdo, $bean, $copyOption);
     // Convert the pubState to a string
     $ps = '';
     if ($pdo->getPubState() != null) {
         $ps = $pdo->getPubState()->getValue();
     }
     $bean->setPubState($ps);
     $logger->debug("pubstate: " . $bean->getPubState());
     // Convert the Address to bean
     $addrBean = new Address();
     if ($pdo->getAddress() != null) {
         $addrBean = BeanUtil::copyBean($pdo->getAddress(), $addrBean, $copyOption);
     }
     $bean->setAddress($addrBean);
     $logger->debug("address: " . $bean->getAddress());
     // related events from array of pdos to keyed array of oids
     $events = $pdo->getEvents();
     $logger->debug("events: " . count($events));
     if (!empty($events) && '' != get_class($events[0])) {
         $es = new EventService();
         $related = array();
         foreach ($events as $event) {
             $logger->debug("event: " . $event);
             $related[] = $es->getEventById($event->getScope(), $event->getOid());
         }
         $bean->setEvents($related);
     }
     return $bean;
 }
Exemple #4
0
 /**
  * A convenience method to copy attributes from the PDO
  * to the Bean. Will automatically set the useTargetVars 
  * attribute of the CopyBeanOption.
  * 
  * @access private
  * @param pdo The Venue PDO object (source)
  * @return bean The Venue bean
  */
 private function pdoToBean($pdo)
 {
     global $logger;
     $logger->debug(get_class($this) . "::pdoToBean({$pdo})");
     $copyOption = new CopyBeanOption();
     $copyOption->setUseTargetVars(true);
     $copyOption->setScalarsOnly(true);
     $bean = new $pdo->scope();
     $bean = BeanUtil::copyBean($pdo, $bean, $copyOption);
     // pubState to a string
     $ps = '';
     if ($pdo->getPubState() != null) {
         $ps = $pdo->getPubState()->getValue();
     }
     $bean->setPubState($ps);
     // related events from array of pdos to keyed array of oids
     $events = $pdo->getEvents();
     if (!empty($events)) {
         $es = new EventService();
         $related = array();
         foreach ($events as $event) {
             $related[] = $es->getEventById($event->getScope(), $event->getOid());
         }
         $bean->setEvents($related);
     }
     return $bean;
 }