Beispiel #1
0
 public function update(\Archive\Port\Adaptor\Data\School\Persons\Person $person)
 {
     $app = \App::getInstance();
     $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 \School\Port\Adaptor\Persistence\QueryBuilder($params);
         $query = $qb->update()->t("resources")->set()->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())->where()->c("id")->eq()->val($person->getID())->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->update()->t("persons_keys")->set()->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)->where()->c("id")->eq()->val($person->getID())->fi();
         $sth = $conn->prepare($query);
         $sth->execute($params);
         return $person;
     }
 }
Beispiel #2
0
 public function update(\Archive\Port\Adaptor\Data\Archive\Events\Event $old, \Archive\Port\Adaptor\Data\Archive\Events\Event $event)
 {
     $app = \App::getInstance();
     $handler = new \Happymeal\Port\Adaptor\Data\ValidationHandler();
     $event->setID($old->getID());
     $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->update()->t("resources")->set()->c("uniqueId")->eq()->val($this->getUniqueId($event), $qb::NOT_NULL)->c("xmlview")->eq()->val($event->toXmlStr())->where()->c("id")->eq()->val($event->getID())->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->update()->t("events_keys")->set()->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)->where()->c("eventId")->eq()->val($event->getID())->fi();
         $sth1 = $conn->prepare($query);
         $sth1->execute($params);
         return $event;
     }
 }
 public function patch(\Archive\Port\Adaptor\Data\Archive\Documents\Document $doc, \Archive\Port\Adaptor\Data\Archive\Documents\Document $old)
 {
     $app = \App::getInstance();
     $handler = new \Happymeal\Port\Adaptor\Data\ValidationHandler();
     $doc->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;
         $old->setYear($doc->getYear());
         $old->setType($doc->getType());
         $old->setPublished($doc->getPublished());
         $old->setComments($doc->getComments());
         $params = array();
         $qb = new \Archive\Port\Adaptor\Persistence\QueryBuilder($params);
         $query = $qb->update()->t("resources")->set()->c("xmlview")->eq()->val($old->toXmlStr())->where()->c("id")->eq()->val($old->getID())->fi();
         $sth1 = $conn->prepare($query);
         $sth1->execute($params);
         $params = [];
         $qb = new \Archive\Port\Adaptor\Persistence\QueryBuilder($params);
         $query = $qb->update()->t("documents_keys")->set()->c("type")->eq()->val($old->getType(), $qb::NOT_NULL)->c("year")->eq()->val($old->getYear(), $qb::NOT_NULL)->c("published")->eq()->val($old->getPublished(), $qb::NOT_NULL)->where()->c("documentId")->eq()->val($old->getID())->fi();
         $sth2 = $conn->prepare($query);
         $sth2->execute($params);
         return $old;
     }
 }
Beispiel #4
0
 public function patch(\School\Port\Adaptor\Data\Archive\Links\Link $link, \Archive\Port\Adaptor\Data\Archive\Links\Link $old)
 {
     $app = \App::getInstance();
     if ($link->getSource() !== null) {
         $old->setSource($link->getSource());
     }
     if ($link->getDestination() !== null) {
         $old->setDestination($link->getDestination());
     }
     if ($link->getType() !== null) {
         $old->setType($link->getType());
     }
     if ($link->getDtStart() !== null) {
         $old->setDtStart($link->getDtStart());
     }
     if ($link->getDtEnd() !== null) {
         $old->setDtEnd($link->getDtEnd());
     }
     if ($link->getComments() !== null) {
         $old->setComments($link->getComments());
     }
     // check linked resources
     if (!$this->checkRefs($old)) {
         throw new \Exception("Link references not found", 450);
     }
     $handler = new \Happymeal\Port\Adaptor\Data\ValidationHandler();
     $old->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->update()->t("links")->set()->c("type")->eq()->val($old->getType(), $qb::NOT_NULL)->c("source")->eq()->val($old->getSource(), $qb::NOT_NULL)->c("destination")->eq()->val($old->getDestination(), $qb::NOT_NULL)->c("dt_start")->eq()->val($old->getDtStart(), $qb::NOT_NULL)->c("dt_end")->eq()->val($old->getDtEnd(), $qb::NOT_NULL)->c("xmlview")->eq()->val($old->toXmlStr())->where()->c("id")->eq()->val($old->getID())->fi();
         //print($query);print_r($params);exit;
         $sth = $conn->prepare($query);
         $sth->execute($params);
         return $old;
     }
 }