Esempio n. 1
0
 public function create(\Archive\Port\Adaptor\Data\Archive\Events\Event $event)
 {
     $app = \App::getInstance();
     $event->setID(\Archive\Infrastructure\Helpers\UUID::generate());
     $handler = new \Happymeal\Port\Adaptor\Data\ValidationHandler();
     $event->validateType($handler);
     if ($handler->hasErrors()) {
         $errors = $handler->getErrors();
         foreach ($errors as $code => $err) {
             $app->throwError(new \Exception(implode(";", $err), $code));
         }
     } else {
         $conn = $app->DB_CONNECT;
         $params = array();
         $qb = new \Archive\Port\Adaptor\Persistence\QueryBuilder($params);
         $query = $qb->insert()->t("resources")->set()->c("id")->eq()->val($event->getID(), $qb::NOT_NULL)->c("type")->eq()->val("event")->c("uniqueId")->eq()->val($this->getUniqueId($event), $qb::NOT_NULL)->c("xmlview")->eq()->val($event->toXmlStr())->fi();
         //print($query);print_r($params);exit;
         $sth = $conn->prepare($query);
         $sth->execute($params);
         $params = array();
         $qb = new \Archive\Port\Adaptor\Persistence\QueryBuilder($params);
         $query = $qb->insert()->t("events_keys")->set()->c("eventId")->eq()->val($event->getID(), $qb::NOT_NULL)->c("name")->eq()->val($event->getName(), $qb::NOT_NULL)->c("dt")->eq()->val($event->getDt(), $qb::NOT_NULL)->c("type")->eq()->val($event->getType(), $qb::NOT_NULL)->fi();
         $sth1 = $conn->prepare($query);
         $sth1->execute($params);
         return $event;
     }
 }
Esempio n. 2
0
 public function create(\Archive\Port\Adaptor\Data\Archive\Persons\Person $person)
 {
     $app = \App::getInstance();
     $person->setID(\Archive\Infrastructure\Helpers\UUID::generate());
     $handler = new \Happymeal\Port\Adaptor\Data\ValidationHandler();
     $person->validateType($handler);
     if ($handler->hasErrors()) {
         $errors = $handler->getErrors();
         foreach ($errors as $code => $err) {
             $app->throwError(new \Exception(implode(";", $err), $code));
         }
     } else {
         $conn = $app->DB_CONNECT;
         $params = array();
         $qb = new \Archive\Port\Adaptor\Persistence\QueryBuilder($params);
         $query = $qb->insert()->t("resources")->set()->c("id")->eq()->val($person->getID(), $qb::NOT_NULL)->c("type")->eq()->val("person")->c("key1")->eq()->val($person->getLastName(), $qb::NOT_NULL)->c("key2")->eq()->val($person->getDOB(), $qb::NOT_NULL)->c("key3")->eq()->val($person->getRollNo(), $qb::NOT_NULL)->c("xmlview")->eq()->val($person->toXmlStr())->fi();
         //print($query);print_r($params);exit;
         $sth = $conn->prepare($query);
         $sth->execute($params);
         $params = array();
         $qb = new \Archive\Port\Adaptor\Persistence\QueryBuilder($params);
         $query = $qb->insert()->t("persons_keys")->set()->c("id")->eq()->val($person->getID(), $qb::NOT_NULL)->c("dob")->eq()->val($person->getDOB(), $qb::NOT_NULL)->c("fullName")->eq()->val($person->getFullName(), $qb::NOT_NULL)->c("middleName")->eq()->val($person->getMiddleName(), $qb::NOT_NULL)->c("lastName")->eq()->val($person->getLastName(), $qb::NOT_NULL)->c("firstName")->eq()->val($person->getFirstName(), $qb::NOT_NULL)->c("initials")->eq()->val($person->getInitials(), $qb::NOT_NULL)->c("esq")->eq()->val($person->getEsq(), $qb::NOT_NULL)->c("deceased")->eq()->val($person->getDeceased(), $qb::NOT_NULL)->c("rollNo")->eq()->val($person->getRollNo(), $qb::NOT_NULL)->c("no")->eq()->val($person->getNo(), $qb::NOT_NULL)->c("league")->eq()->val($person->getLeague(), $qb::NOT_NULL)->fi();
         $sth = $conn->prepare($query);
         $sth->execute($params);
         return $person;
     }
 }
Esempio n. 3
0
 public function create(\Archive\Port\Adaptor\Data\Archive\Links\Link $link)
 {
     $app = \App::getInstance();
     // check linked resources
     $this->checkRefs($link);
     $link->setID(\Archive\Infrastructure\Helpers\UUID::generate());
     $handler = new \Happymeal\Port\Adaptor\Data\ValidationHandler();
     $link->validateType($handler);
     if ($handler->hasErrors()) {
         $errors = $handler->getErrors();
         foreach ($errors as $code => $err) {
             $app->throwError(new \Exception(implode(";", $err), $code));
         }
     } else {
         $conn = $app->DB_CONNECT;
         $params = array();
         $qb = new \Archive\Port\Adaptor\Persistence\QueryBuilder($params);
         $query = $qb->insert()->t("links")->set()->c("id")->eq()->val($link->getID(), $qb::NOT_NULL)->c("type")->eq()->val($link->getType(), $qb::NOT_NULL)->c("source")->eq()->val($link->getSource(), $qb::NOT_NULL)->c("destination")->eq()->val($link->getDestination(), $qb::NOT_NULL)->c("dt_start")->eq()->val($link->getDtStart(), $qb::NOT_NULL)->c("dt_end")->eq()->val($link->getDtEnd(), $qb::NOT_NULL)->c("xmlview")->eq()->val($link->toXmlStr())->fi();
         //print($query);print_r($params);exit;
         $sth = $conn->prepare($query);
         $sth->execute($params);
         return $link;
     }
 }