コード例 #1
0
 /**
  * @return string
  */
 public function getCollectionPath()
 {
     $institutionPath = $this->getPath() . '/' . $this->collection->getInstitution()->getInstitutioncode() . '/';
     UtilityService::createDir($institutionPath, $this->userGroup);
     $collectionPath = $institutionPath . $this->collection->getCollectioncode();
     return UtilityService::createDir($collectionPath, $this->userGroup);
 }
コード例 #2
0
 /**
  * @param Collection   $collection
  * @param array|string $catalogNumbers
  * @return array
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function findBestTaxonsByCatalogNumbers(Collection $collection, $catalogNumbers)
 {
     if (!is_array($catalogNumbers)) {
         $catalogNumbers = [$catalogNumbers];
     }
     $rsm = new ResultSetMapping();
     $rsm->addScalarResult('scientificname', 'scientificname');
     $rsm->addScalarResult('scientificnameauthorship', 'scientificnameauthorship');
     $rsm->addScalarResult('catalognumber', 'catalognumber');
     $nativeSqlTaxon = '
     WITH FirstIDentified AS (
        SELECT First_Value(t.taxonid) OVER (PARTITION BY catalognumber ORDER BY identificationverifstatus) First,
        t.taxonid, t.scientificname, t.scientificnameauthorship,
        s.catalognumber
        FROM Taxons t
        JOIN Determinations d ON t.taxonid = d.taxonid
        JOIN Specimens s on d.occurrenceid = s.occurrenceid
        WHERE s.collectioncode = :collectionCode AND
        s.catalognumber IN (:catalogNumbers)
     )
     SELECT catalognumber, scientificname, scientificnameauthorship FROM FirstIdentified
     WHERE taxonid = First
     ';
     $this->getEntityManager()->getConnection()->setFetchMode(\PDO::FETCH_ASSOC);
     $results = $this->getEntityManager()->getConnection()->executeQuery($nativeSqlTaxon, ['collectionCode' => $collection->getCollectioncode(), 'catalogNumbers' => $catalogNumbers], ['catalogNumbers' => Connection::PARAM_STR_ARRAY])->fetchAll();
     $formattedResult = [];
     if (count($results)) {
         foreach ($results as $values) {
             $formattedResult[$values['CATALOGNUMBER']] = Taxon::toString($values['SCIENTIFICNAME'], $values['SCIENTIFICNAMEAUTHORSHIP']);
         }
     }
     return $formattedResult;
 }
コード例 #3
0
 /**
  * @param Specimen    $specimen
  * @param rCollection $collection
  * @return string
  */
 public function getLink(Specimen $specimen, rCollection $collection)
 {
     $type = null;
     switch (strtolower($collection->getType())) {
         case 'h':
         case 'b':
             $type = 'botanique';
             break;
         case 'z':
             $type = 'zoologie';
             break;
         case 'p':
             $type = 'paleontologie';
             break;
         case 'g':
             $type = 'geographie';
             break;
     }
     return sprintf('%s%s/%s', $this->urlRecolnat, $type, strtoupper($specimen->getOccurrenceid()));
 }
コード例 #4
0
 /**
  * @param Collection   $collection
  * @param QueryBuilder $qb
  * @param array        $catalogNumbers
  * @param string       $alias
  */
 protected function setSpecimenCodesWhereClause(Collection $collection, QueryBuilder &$qb, $catalogNumbers, $alias = 's')
 {
     $qb->andWhere(sprintf('%s.institutioncode = :institutionCode', $alias))->andWhere(sprintf('%s.collectioncode = :collectionCode', $alias))->andWhere($qb->expr()->in(sprintf('%s.catalognumber', $alias), ':catalogNumbers'))->setParameters(['institutionCode' => $collection->getInstitution()->getInstitutioncode(), 'collectionCode' => $collection->getCollectioncode(), 'catalogNumbers' => $catalogNumbers]);
 }
コード例 #5
0
 public function checkUserRight(User $user, Collection $collection)
 {
     if (!$user->isManagerFor($collection->getCollectioncode())) {
         throw new AccessDeniedException($this->translator->trans('access.denied.wrongPermission', [], 'exceptions'));
     }
 }
コード例 #6
0
 private function setLogFilePath()
 {
     $now = new \DateTime();
     $logFilePath = sprintf($this->getContainer()->getParameter('export_path') . '/' . $this->logFileTemplate, $this->collection->getInstitution()->getInstitutioncode(), $this->collection->getCollectioncode(), $now->format('d-m-Y-H-i-s'));
     $this->logFile = new \SplFileObject($logFilePath, 'w+');
 }
コード例 #7
0
ファイル: User.php プロジェクト: sirnec/tm
 /**
  * Remove createdProject
  *
  * @param \AppBundle\Entity\Project $createdProject
  */
 public function removeCreatedProject(\AppBundle\Entity\Project $createdProject)
 {
     $this->created_projects->removeElement($createdProject);
 }
コード例 #8
0
ファイル: Scene.php プロジェクト: szymach/talesweaver
 /**
  * @param Item $item
  */
 public function removeItem(Scene $item)
 {
     $this->items->removeElement($item);
 }
コード例 #9
0
ファイル: User.php プロジェクト: eduardoledo/schoolmanager
 /**
  * Remove mySchool
  *
  * @param \AppBundle\Entity\School $mySchool
  */
 public function removeMySchool(\AppBundle\Entity\School $mySchool)
 {
     $this->mySchools->removeElement($mySchool);
 }
コード例 #10
0
 /**
  * @param Collection $collection
  * @return $this
  * @throws \Exception
  */
 public function setCollection(Collection $collection)
 {
     $this->collection = $collection;
     $this->collectionCode = $collection->getCollectioncode();
     if (is_null($this->collection)) {
         throw new \Exception('Can\'t found the collection with collectionCode = ' . $this->collectionCode);
     } else {
         $this->diffHandler = new DiffHandler($this->user->getDataDirPath(), $this->collection, $this->userGroup);
         //if (!$this->getDiffHandler()->shouldSearchDiffs()) {
         $this->selectedSpecimensHandler = new SelectedSpecimensHandler($this->diffHandler->getCollectionPath(), $this->userGroup);
         $data = $this->getDiffHandler()->getDiffsFile()->getData();
         $data['selectedSpecimens'] = $this->selectedSpecimensHandler->getData();
         $this->sessionHandler = new SessionHandler($this->sessionManager, $this->genericEntityManager, $data);
         $this->getSessionHandler()->init($this->getDiffHandler(), $this->collectionCode);
         //}
     }
     return $this;
 }