Ejemplo n.º 1
0
 public function __construct($source = null)
 {
     if (is_object($source)) {
         BeanUtil::copyBean($source, $this);
     } else {
         if (is_array($source)) {
             foreach ($source as $key => $value) {
                 if (property_exists($this, $key)) {
                     $setter = 'set_' . $key;
                     $this->{$setter}($value);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 /** 
  * A convenience method to convert the incoming bean
  * to the corresponding PDO.  This includes all translations
  * such as the nested PublicationSate.
  * If the bean has an oid, then it will fetch the person,
  * if the person id is null, a new pdo object will be returned.
  * 
  * @access private
  * @param bean Person bean
  * @return pdo Person PDO
  */
 private function beanToPdo($bean)
 {
     global $logger;
     $logger->debug(get_class($this) . "::beanToPdo({$bean})");
     // Check to see if there is a valid OID
     if ($bean->getOid() > 0) {
         $pdo = $this->fetchPersonById(get_class($bean), $bean->getOid());
     } else {
         // Get a new event PDO
         $epm = epManager::instance();
         $pdo = $epm->create(get_class($bean));
     }
     // Copy the bean values over the top of the PDO values
     BeanUtil::copyBean($bean, $pdo);
     // Translate the pubState from string to object instance;
     $pubState = $this->fetchPubState($bean->getPubState());
     $pdo->setPubState($pubState);
     // Get the Exhibitions if an Artist
     if (get_class($bean) == Person::ARTIST) {
         $es = $this->getEventService();
         $exhibitions = $bean->getExhibitions();
         if ($exhibitions != null) {
             $epdos = array();
             foreach ($exhibitions as $event) {
                 $epdos[] = $es->fetchEventById('Exhibition', $event->getOid());
             }
             $pdo->getExhibitions()->removeAll();
             $pdo->setExhibitions($epdos);
         }
     }
     return $pdo;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 /**
  * A sample detail bean for use in rendering the template.
  * If a course is supplied, it will copy thevalues of the
  * given bean over the top of the demo bean.
  * @return
  */
 private function getDemoCourseDetail($crse)
 {
     require_once WEB_INF . '/beans/Performance.php';
     require_once WEB_INF . '/beans/Schedule.php';
     require_once WEB_INF . '/beans/Venue.php';
     global $logger;
     $logger->debug(get_class($this) . "::getDemoCourseDetail({$crse})");
     $bean = new Course();
     $bean->setTitle("Demo Course Detail Bean");
     $desc = "<p>This is a description of the course. Malian Grammy Award nominee Mamadou Diabate is a virtuoso kora player descended from a long line of Manding musician-storytellers. Dolor dignissim exerci feugiat. Lobortis ut, luptatum facilisis. Augue volutpat facilisis at, eum consequat adipiscing accumsan blandit molestie. </p>\n\t\t\t\t <p>Lobortis eros at hendrerit luptatum consequat feugiat ut facilisi commodo esse autem consequat at ex ullamcorper hendrerit wisi, commodo nostrud nisl wisi eum autem eu esse eu iriure. Tation, magna ad nibh at eum, ea praesent eum lorem eu erat enim commodo dolore?</p>\n \t\t\t\t <p>Crisare enim sed ex eros hendrerit blandit illum qui sciurus autem nulla enim luptatum. Quis enim eum feugait elit blandit, hendrerit consequat, velit ut luptatum nostrud wisi ea. Dignissim consequat dolore aliquam eum volutpat, wisi dolore et exerci nisl veniam luptatum ut ullamcorper consequatvel nulla delenit.</p>\n\t\t\t\t";
     $bean->setDescription($desc);
     $bean->setPrimaryGenre("Music");
     // Performances
     $perf = new Performance();
     $schd = new Schedule();
     $schd->setStartTime(time());
     $perf->setSchedule($schd);
     $logger->debug("Performance time: " . $perf->getSchedule()->getStartTime());
     $perf->setTicketCode("21");
     $bean->setChildren(array($perf));
     $logger->debug("Number of set performaces: " . count($bean->getChildren()));
     // Venues
     $v1 = new Venue();
     $v1->setName('Hurd Gallery');
     $bean->setDefaultVenue($v1);
     if (get_class($crse) == 'Course') {
         $crse->setPerformances(null);
         $option = new CopyBeanOption();
         $option->setIgnoreNullValues(true);
         BeanUtil::copyBean($crse, $bean, $option);
     }
     return $bean;
 }
Ejemplo n.º 5
0
 /**
  * Copies the updated values of the bean to the pdo
  * object, then commits the pdo object to update the 
  * address.
  * 
  * @access private
  * @param bean Address Bean
  * @return pdo updated Address PDO
  */
 private function updateAddress($bean)
 {
     global $logger;
     $logger->debug(get_class($this) . "::updateAddress({$bean})");
     $logger->debug("Address is of class: " . get_class($bean));
     $logger->debug("Before update the address id: " . $bean->getOid());
     $epm = epManager::instance();
     $pdo = null;
     if ($bean->getOid() > 0) {
         $pdo = $this->fetchAddressById($bean->getOid());
         $logger->debug("Oid > 0: " . $pdo->getOid());
     } else {
         if (trim($bean->getStreet()) != NULL) {
             $pdo = $epm->create('Address');
             $logger->debug("No oid, but valid street: " . $bean->getStreet());
         } else {
             return null;
             // This is not a valid address
         }
     }
     $pdo = BeanUtil::copyBean($bean, $pdo);
     $pdo = $epm->commit($pdo);
     $logger->debug("After update the address id: " . $pdo->getOid());
     return $pdo;
 }
Ejemplo n.º 6
0
 /** 
  * A convenience method to convert the incoming bean
  * to the corresponding PDO.  This includes all translations
  * such as the nested PublicationSate and Address objects.  
  * If the bean has an oid, then it will fetch the home_page,
  * if the home_page id is null, a new pdo object will be returned.
  * 
  * @access private
  * @param bean HomePage bean
  * @return pdo HomePage PDO
  */
 private function beanToPdo($bean)
 {
     global $logger;
     $logger->debug(get_class($this) . "::beanToPdo({$bean})");
     // Check to see if there is a valid HomePage OID
     if ($bean->getOid() > 0) {
         $pdo = $this->fetchHomePageById($bean->getOid());
     } else {
         // Get a new event PDO
         $epm = epManager::instance();
         $pdo = $epm->create('HomePage');
     }
     // Copy the bean values over the top of the PDO values
     BeanUtil::copyBean($bean, $pdo);
     // Translate the pubState from string to object instance
     $pubState = $this->fetchPubState($bean->getPubState());
     $pdo->setPubState($pubState);
     return $pdo;
 }
Ejemplo n.º 7
0
 /** 
  * A convenience method to convert the incoming bean
  * to the corresponding PDO.  This includes all translations
  * such as the nested PublicationSate.
  * If the bean has an oid, then it will fetch the category,
  * if the category id is null, a new pdo object will be returned.
  * 
  * @access private
  * @param bean Category bean
  * @return pdo Category PDO
  */
 private function beanToPdo($bean)
 {
     global $logger;
     $logger->debug(get_class($this) . "::beanToPdo({$bean})");
     // Check to see if there is a valid OID
     if ($bean->getOid() > 0) {
         $pdo = $this->fetchCategoryById($bean->getOid());
     } else {
         // Get a new event PDO
         $epm = epManager::instance();
         $pdo = $epm->create('Category');
     }
     // Copy the bean values over the top of the PDO values
     BeanUtil::copyBean($bean, $pdo);
     // Set the scope
     $pdo->setScope(get_class($bean));
     // Translate the pubState from string to object instance
     $pubState = $this->fetchPubState($bean->getPubState());
     $pdo->setPubState($pubState);
     // Translate the events from array of oids to array of PDOs
     $eventAssoc = $bean->getEvents();
     if ($eventAssoc != null) {
         $es = new EventService();
         $eventPdo = array();
         foreach ($eventAssoc as $key => $value) {
             $type = ucfirst($key);
             $logger->debug("The event type is: " . $type);
             foreach ($value as $evoid) {
                 $eventPdo[] = $es->fetchEventById($type, $evoid);
             }
         }
         $pdo->setEvents($eventPdo);
     }
     return $pdo;
 }