Exemple #1
0
 /**
  * Converts the given course PDO to a bean object.
  * This includes the conversion from nested lists
  * of PDO objects to usable lists of oids/names to be used
  * by the page renderer.
  *
  * @access private
  * @param pdo $pdo Course
  * @return bean Course
  */
 private function coursePdoToBean($pdo)
 {
     require_once WEB_INF . '/beans/Seminar.php';
     global $logger;
     $logger->debug(get_class($this) . "::coursePdoToBean({$pdo})");
     $copyOption = new CopyBeanOption();
     $copyOption->setUseTargetVars(true);
     $copyOption->setScalarsOnly(true);
     $bean = new Course($pdo->epGetVars());
     // primaryGenre to bean
     $genre = $pdo->getPrimaryGenre();
     $ga = $genre != null ? $genre->epGetVars() : null;
     $bean->setPrimaryGenre(new Genre($ga));
     // pubState to a string
     $ps = '';
     if ($pdo->getPubState() != null) {
         $ps = $pdo->getPubState()->getValue();
     }
     $bean->setPubState($ps);
     // eventStatus to a string
     $es = '';
     if ($pdo->getEventStatus() != null) {
         $es = $pdo->getEventStatus()->getValue();
     }
     $bean->setEventStatus($es);
     // default venue from pdo to bean
     $dven = $pdo->getDefaultVenue();
     $logger->debug("Getting default venue from the course pdo: " . $pdo->getDefaultVenue());
     $dv = $dven != null ? $dven->epGetVars() : null;
     $bean->setDefaultVenue(new Venue($dv));
     $logger->debug("Setting default venue in the course bean: " . $bean->getDefaultVenue()->getName());
     // venues from array of pdos to array of venue bean
     $vens = array();
     if ($pdo->getVenues() != null) {
         foreach ($pdo->getVenues() as $ven) {
             $vens[] = new Venue($ven->epGetVars());
         }
     }
     $bean->setVenues($vens);
     // categories from array of pdos to keyed array of oids
     $cats = array();
     if ($pdo->getCategories() != null) {
         foreach ($pdo->getCategories() as $cat) {
             $scope = $cat->getScope();
             $cats[$scope][] = new $scope($cat->epGetVars());
         }
     }
     $bean->setCategories($cats);
     // related exhibitions from array of pdos to keyed array of oids
     $exhibitions = $pdo->getExhibitions();
     if ($exhibitions != null) {
         $related = array();
         foreach ($exhibitions as $event) {
             $related[] = new Exhibition($event->epGetVars());
         }
         $bean->setExhibitions($related);
     }
     // related programs from array of pdos to keyed array of oids
     $programs = $pdo->getPrograms();
     if ($programs != null) {
         $related = array();
         foreach ($programs as $event) {
             $related[] = new Program($event->epGetVars());
         }
         $bean->setPrograms($related);
     }
     // related performances from array of pdos to array of activities
     $children = $pdo->getChildren();
     if ($children != null) {
         $activities = array();
         foreach ($children as $activity) {
             $scope = $activity->getScope();
             $perf = new $scope($activity->epGetVars());
             $perf->setActivityStatus(new EventStatus($activity->getActivityStatus()->epGetVars()));
             $perf->setSchedule(new Schedule($activity->getSchedule()->epGetVars()));
             if ($activity->getVenue()) {
                 $perf->setVenue(new Venue($activity->getVenue()->epGetVars()));
             }
             $activities[] = $perf;
         }
         $bean->setChildren($activities);
     }
     return $bean;
 }
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;
 }