Example #1
0
 /**
  * @param string           $DatabaseName
  * @param null|TblAccount  $tblAccount
  * @param null|TblConsumer $tblConsumer
  * @param null|Element     $FromEntity
  * @param null|Element     $ToEntity
  *
  * @return false|TblProtocol
  */
 public function createProtocolEntry($DatabaseName, TblAccount $tblAccount = null, TblConsumer $tblConsumer = null, Element $FromEntity = null, Element $ToEntity = null)
 {
     // Skip if nothing changed
     if (null !== $FromEntity && null !== $ToEntity) {
         $From = $FromEntity->__toArray();
         sort($From);
         $To = $ToEntity->__toArray();
         sort($To);
         if ($From === $To) {
             return false;
         }
     }
     $Manager = $this->Connection->getEntityManager();
     $Entity = new TblProtocol();
     $Entity->setProtocolDatabase($DatabaseName);
     $Entity->setProtocolTimestamp(time());
     if ($tblAccount) {
         $Entity->setServiceTblAccount($tblAccount);
         $Entity->setAccountUsername($tblAccount->getUsername());
     }
     if ($tblConsumer) {
         $Entity->setServiceTblConsumer($tblConsumer);
         $Entity->setConsumerName($tblConsumer->getName());
         $Entity->setConsumerAcronym($tblConsumer->getAcronym());
     }
     $Entity->setEntityFrom($FromEntity ? serialize($FromEntity) : null);
     $Entity->setEntityTo($ToEntity ? serialize($ToEntity) : null);
     $Manager->saveEntity($Entity);
     return $Entity;
 }
Example #2
0
 /**
  * @param integer $Id
  *
  * @return bool|TblCompany
  */
 public function getCompanyById($Id)
 {
     /** @var IApiInterface $Cache */
     $Cache = (new Cache(new Memcached()))->getCache();
     if (!($Entity = $Cache->getValue(__METHOD__ . '::' . $Id))) {
         $Entity = $this->Connection->getEntityManager()->getEntityById('TblCompany', $Id);
         $Cache->setValue(__METHOD__ . '::' . $Id, null === $Entity ? false : $Entity, 500);
     }
     return null === $Entity ? false : $Entity;
 }
Example #3
0
 /**
  * @param TblResponsibility $tblResponsibility
  *
  * @return bool
  */
 public function removeResponsibility(TblResponsibility $tblResponsibility)
 {
     $Manager = $this->Connection->getEntityManager();
     /** @var TblResponsibility $Entity */
     $Entity = $Manager->getEntityById('TblResponsibility', $tblResponsibility->getId());
     if (null !== $Entity) {
         Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
         $Manager->killEntity($Entity);
         return true;
     }
     return false;
 }
Example #4
0
 /**
  * @param \SPHERE\Application\Platform\Gatekeeper\Authorization\Token\Service\Entity\TblToken $tblToken
  */
 public function destroyToken(TblToken $tblToken)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Manager->getEntityById('TblToken', $tblToken->getId());
     if (null !== $Entity) {
         $Manager->killEntity($Entity);
         Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
     }
 }
Example #5
0
 /**
  *
  * @param TblRole $tblRole
  *
  * @return bool|TblRoleLevel[]
  */
 public function getLevelAllByRole(TblRole $tblRole)
 {
     /** @var TblRoleLevel[] $EntityList */
     $EntityList = $this->Connection->getEntityManager()->getEntity('TblRoleLevel')->findBy(array(TblRoleLevel::ATTR_TBL_ROLE => $tblRole->getId()));
     array_walk($EntityList, function (TblRoleLevel &$V) {
         $V = $V->getTblLevel();
     });
     return null === $EntityList ? false : $EntityList;
 }
Example #6
0
 /**
  *
  * @param TblRole $tblRole
  *
  * @return bool|TblRoleLevel[]
  */
 public function getLevelAllByRole(TblRole $tblRole)
 {
     $EntityList = $this->getCachedEntityListBy(__METHOD__, $this->Connection->getEntityManager(), 'TblRoleLevel', array(TblRoleLevel::ATTR_TBL_ROLE => $tblRole->getId()));
     if ($EntityList) {
         array_walk($EntityList, function (TblRoleLevel &$V) {
             $V = $V->getTblLevel();
         });
     }
     return $EntityList;
 }
Example #7
0
 /**
  * @param string           $DatabaseName
  * @param null|TblAccount  $tblAccount
  * @param null|TblConsumer $tblConsumer
  * @param null|Element     $Entity
  * @param int              $Type
  *
  * @return false|TblArchive
  */
 public function createArchiveEntry($DatabaseName, TblAccount $tblAccount = null, TblConsumer $tblConsumer = null, Element $Entity = null, $Type = TblArchive::ARCHIVE_TYPE_CREATE)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Entity ? serialize($this->persistData($Entity)) : null;
     $Archive = new TblArchive($Type);
     $Archive->setArchiveDatabase($DatabaseName);
     $Archive->setArchiveTimestamp(time());
     if ($tblAccount) {
         $Archive->setServiceTblAccount($tblAccount);
         $Archive->setAccountUsername($tblAccount->getUsername());
     }
     if ($tblConsumer) {
         $Archive->setServiceTblConsumer($tblConsumer);
         $Archive->setConsumerName($tblConsumer->getName());
         $Archive->setConsumerAcronym($tblConsumer->getAcronym());
     }
     $Archive->setEntity($Entity);
     $Manager->saveEntity($Archive);
     return $Archive;
 }
Example #8
0
 /**
  * @param $Name
  *
  * @return TblCommodityType
  */
 public function actionCreateCommodityType($Name)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Manager->getEntity('TblCommodityType')->findOneBy(array('Name' => $Name));
     if (null === $Entity) {
         $Entity = new TblCommodityType();
         $Entity->setName($Name);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
     }
     return $Entity;
 }
Example #9
0
 /**
  * @param TblGroup $tblGroup
  *
  * @return bool
  */
 public function destroyGroup(TblGroup $tblGroup)
 {
     $Manager = $this->Connection->getEntityManager();
     /** @var TblMember $Entity */
     $Entity = $Manager->getEntityById('TblGroup', $tblGroup->getId());
     if (null !== $Entity) {
         Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
         $Manager->killEntity($Entity);
         return true;
     }
     return false;
 }
Example #10
0
 /**
  * @param TblAccount $tblAccount
  * @param TblPerson  $tblPerson
  *
  * @return bool
  */
 public function removeAccountPerson(TblAccount $tblAccount, TblPerson $tblPerson)
 {
     $Manager = $this->Connection->getEntityManager();
     /** @var TblUser $Entity */
     $Entity = $Manager->getEntity('TblUser')->findOneBy(array(TblUser::ATTR_TBL_ACCOUNT => $tblAccount->getId(), TblUser::SERVICE_TBL_PERSON => $tblPerson->getId()));
     if (null !== $Entity) {
         Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
         $Manager->killEntity($Entity);
         return true;
     }
     return false;
 }
Example #11
0
 /**
  * @param TblItemAccount $tblItemAccount
  *
  * @return bool
  */
 public function actionRemoveItemAccount(TblItemAccount $tblItemAccount)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Manager->getEntity('TblItemAccount')->findOneBy(array('Id' => $tblItemAccount->getId()));
     if (null !== $Entity) {
         /** @var Element $Entity */
         Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
         $Manager->killEntity($Entity);
         return true;
     }
     return false;
 }
Example #12
0
 /**
  * @param TblCompany $tblCompany
  * @param TblPerson  $tblPerson
  * @param TblType    $tblType
  * @param string     $Remark
  *
  * @return TblToCompany
  */
 public function addCompanyRelationshipToPerson(TblCompany $tblCompany, TblPerson $tblPerson, TblType $tblType, $Remark)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = new TblToCompany();
     $Entity->setServiceTblCompany($tblCompany);
     $Entity->setServiceTblPerson($tblPerson);
     $Entity->setTblType($tblType);
     $Entity->setRemark($Remark);
     $Manager->saveEntity($Entity);
     Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
     return $Entity;
 }
Example #13
0
 /**
  * @param TblProspect $tblProspect
  * @param string      $Remark
  *
  * @return TblProspect
  */
 public function updateProspect(TblProspect $tblProspect, $Remark)
 {
     $Manager = $this->Connection->getEntityManager();
     /** @var null|TblProspect $Entity */
     $Entity = $Manager->getEntityById('TblProspect', $tblProspect->getId());
     if (null !== $Entity) {
         $Protocol = clone $Entity;
         $Entity->setRemark($Remark);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createUpdateEntry($this->Connection->getDatabase(), $Protocol, $Entity);
         return true;
     }
     return false;
 }
Example #14
0
 /**
  * @param TblCompany $tblCompany
  * @param TblMail    $tblMail
  * @param TblType    $tblType
  * @param string     $Remark
  *
  * @return TblToCompany
  */
 public function addMailToCompany(TblCompany $tblCompany, TblMail $tblMail, TblType $tblType, $Remark)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Manager->getEntity('TblToCompany')->findOneBy(array(TblToCompany::SERVICE_TBL_COMPANY => $tblCompany->getId(), TblToCompany::ATT_TBL_MAIL => $tblMail->getId(), TblToCompany::ATT_TBL_TYPE => $tblType->getId()));
     if (null === $Entity) {
         $Entity = new TblToCompany();
         $Entity->setServiceTblCompany($tblCompany);
         $Entity->setTblMail($tblMail);
         $Entity->setTblType($tblType);
         $Entity->setRemark($Remark);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
     }
     return $Entity;
 }
Example #15
0
 /**
  * @param TblConsumer $tblConsumer
  * @param TblAccount  $tblAccount
  *
  * @return bool
  */
 public function changeConsumer(TblConsumer $tblConsumer, TblAccount $tblAccount = null)
 {
     if (null === $tblAccount) {
         $tblAccount = $this->getAccountBySession();
     }
     $Manager = $this->Connection->getEntityManager();
     /** @var TblAccount $Entity */
     $Entity = $Manager->getEntityById('TblAccount', $tblAccount->getId());
     $Protocol = clone $Entity;
     if (null !== $Entity) {
         $Entity->setServiceTblConsumer($tblConsumer);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createUpdateEntry($this->Connection->getDatabase(), $Protocol, $Entity);
         return true;
     }
     return false;
 }
Example #16
0
 /**
  * @param Entity\TblCommodity $tblCommodity
  *
  * @return bool
  */
 public function actionRemoveCommodity(TblCommodity $tblCommodity)
 {
     $Manager = $this->Connection->getEntityManager();
     $EntityItems = $Manager->getEntity('TblCommodityItem')->findBy(array(TblCommodityItem::ATTR_TBL_COMMODITY => $tblCommodity->getId()));
     if (null !== $EntityItems) {
         foreach ($EntityItems as $Entity) {
             Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
             $Manager->killEntity($Entity);
         }
     }
     $Entity = $Manager->getEntity('TblCommodity')->findOneBy(array('Id' => $tblCommodity->getId()));
     if (null !== $Entity) {
         /** @var Element $Entity */
         Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
         $Manager->killEntity($Entity);
         return true;
     }
     return false;
 }
Example #17
0
 /**
  * @param TblBasket $tblBasket
  *
  * @return bool
  */
 public function actionDestroyTempInvoice(TblBasket $tblBasket)
 {
     if ($tblBasket !== null) {
         $Manager = $this->Connection->getEntityManager();
         /** @var  TblTempInvoice[] $EntityList */
         $EntityList = $Manager->getEntity('TblTempInvoice')->findBy(array(TblTempInvoice::ATTR_SERVICE_BILLING_BASKET => $tblBasket->getId()));
         foreach ($EntityList as $Entity) {
             $EntitySubList = $Manager->getEntity('TblTempInvoiceCommodity')->findBy(array(TblTempInvoiceCommodity::ATTR_TBL_TEMP_INVOICE => $Entity->getId()));
             foreach ($EntitySubList as $SubEntity) {
                 Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $SubEntity);
                 $Manager->bulkKillEntity($SubEntity);
             }
             Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
             $Manager->bulkKillEntity($Entity);
         }
         $Manager->flushCache();
         return true;
     }
     return false;
 }
Example #18
0
 /**
  * @param TblBasket $tblBasket
  *
  * @return bool
  */
 public function actionDestroyBasketCommodity(TblBasket $tblBasket)
 {
     if ($tblBasket !== null) {
         $Manager = $this->Connection->getEntityManager();
         /** @var  TblBasketCommodity[] $EntityList */
         $EntityList = $Manager->getEntity('TblBasketCommodity')->findBy(array(TblBasketCommodity::ATTR_TBL_BASKET => $tblBasket->getId()));
         foreach ($EntityList as $Entity) {
             $EntitySubList = $Manager->getEntity('TblBasketCommodityDebtor')->findBy(array(TblBasketCommodityDebtor::ATTR_TBL_BASKET_COMMODITY => $Entity->getId()));
             foreach ($EntitySubList as $SubEntity) {
                 Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $SubEntity);
                 $Manager->bulkKillEntity($SubEntity);
             }
             Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
             $Manager->bulkKillEntity($Entity);
         }
         $Manager->flushCache();
         return true;
     }
     return false;
 }
Example #19
0
 /**
  *
  * @param TblPerson $tblPerson
  *
  * @return bool|TblCommon
  */
 public function getCommonByPerson(TblPerson $tblPerson)
 {
     /** @var TblCommon $Entity */
     $Entity = $this->Connection->getEntityManager()->getEntity('TblCommon')->findOneBy(array(TblCommon::SERVICE_TBL_PERSON => $tblPerson->getId()));
     return null === $Entity ? false : $Entity;
 }
Example #20
0
 /**
  * @return TblConsumer[]|bool
  */
 public function getConsumerAll()
 {
     return $this->getCachedEntityList(__METHOD__, $this->Connection->getEntityManager(), 'TblConsumer');
 }
Example #21
0
 /**
  * @param int $Id
  *
  * @return bool|TblStudentTransferProcess
  */
 public function getStudentTransferProcessById($Id)
 {
     return $this->getCachedEntityById(__METHOD__, $this->Connection->getEntityManager(), 'TblStudentTransferProcess', $Id);
 }
Example #22
0
 /**
  * @return array|bool|TblAccountType[]
  */
 public function entityAccountTypeAll()
 {
     $Entity = $this->Connection->getEntityManager()->getEntity('TblAccountType')->findAll();
     return null === $Entity ? false : $Entity;
 }
Example #23
0
 /**
  * @return bool|TblTestPicture[]
  */
 public function getTestPictureAll()
 {
     $EntityList = $this->Connection->getEntityManager()->getEntity('TblTestPicture')->findAll();
     return empty($EntityList) ? false : $EntityList;
 }
Example #24
0
 /**
  * @return bool|TblScoreType[]
  */
 public function getScoreTypeAll()
 {
     $EntityList = $this->Connection->getEntityManager()->getEntity('TblScoreType')->findAll();
     return empty($EntityList) ? false : $EntityList;
 }
Example #25
0
 /**
  * @param integer $Id
  *
  * @return bool|TblSalutation
  */
 public function getSalutationById($Id)
 {
     return $this->getCachedEntityById(__METHOD__, $this->Connection->getEntityManager(), 'TblSalutation', $Id);
 }
Example #26
0
 /**
  * @param int $Id
  *
  * @return bool|TblCustody
  */
 public function getCustodyById($Id)
 {
     return $this->getCachedEntityById(__METHOD__, $this->Connection->getEntityManager(), 'TblCustody', $Id);
 }
Example #27
0
 /**
  * @param integer $Id
  *
  * @return bool|TblCompany
  */
 public function getCompanyById($Id)
 {
     $Entity = $this->Connection->getEntityManager()->getEntityById('TblCompany', $Id);
     return null === $Entity ? false : $Entity;
 }
Example #28
0
 /**
  * @param $Id
  *
  * @return bool|TblPaymentType
  */
 public function entityPaymentTypeById($Id)
 {
     $Entity = $this->Connection->getEntityManager()->getEntityById('TblPaymentType', $Id);
     return null === $Entity ? false : $Entity;
 }
Example #29
0
 /**
  * @return \SPHERE\Application\Platform\Gatekeeper\Authorization\Consumer\Service\Entity\TblConsumer[]|bool
  */
 public function getConsumerAll()
 {
     $EntityList = $this->Connection->getEntityManager()->getEntity('TblConsumer')->findAll();
     return empty($EntityList) ? false : $EntityList;
 }