/**
  * @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);
 }
 /**
  * @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;
 }
 /**
  * @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()));
 }
 /**
  * @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]);
 }
 public function checkUserRight(User $user, Collection $collection)
 {
     if (!$user->isManagerFor($collection->getCollectioncode())) {
         throw new AccessDeniedException($this->translator->trans('access.denied.wrongPermission', [], 'exceptions'));
     }
 }
 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+');
 }
Exemple #7
0
 /**
  * Remove createdProject
  *
  * @param \AppBundle\Entity\Project $createdProject
  */
 public function removeCreatedProject(\AppBundle\Entity\Project $createdProject)
 {
     $this->created_projects->removeElement($createdProject);
 }
Exemple #8
0
 /**
  * @param Item $item
  */
 public function removeItem(Scene $item)
 {
     $this->items->removeElement($item);
 }
Exemple #9
0
 /**
  * Remove mySchool
  *
  * @param \AppBundle\Entity\School $mySchool
  */
 public function removeMySchool(\AppBundle\Entity\School $mySchool)
 {
     $this->mySchools->removeElement($mySchool);
 }
 /**
  * @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;
 }