@inheritdoc

@throws RepositoryException
12448
public function readScopeIdentifiers(int $identifier): array
    {
        try {
            $schema = $this->getDatabaseSchema();
            return $this->readBelongsToManyRelationshipIdentifiers(
                $identifier,
                $schema->getTokensScopesTable(),
                $schema->getTokensScopesTokenIdentityColumn(),
                $schema->getTokensScopesScopeIdentityColumn()
            );
        } catch (RepositoryException $exception) {
            $message = 'Reading scopes for a token failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
45613
@Override
    public <E extends Exception> void add(Iteration<? extends Statement, E> statements, Resource... contexts) throws RepositoryException, E {
        while(statements.hasNext()){
            Statement st = statements.next();
            add(st.getSubject(), st.getPredicate(), st.getObject(), mergeResource(st.getContext(), contexts));
        }
    }
341041
protected void resetExecutor() throws RepositoryException {
        if (mExecutor != null) {
            mExecutor = executorFactory().executor(mFilter, mOrdering, null);
        }
    }
893038
private function generateRepository($className) {
		$table = EntityReflexion::getTable($className);
		if ($table === NULL) {
			throw new RepositoryException("Entity \"" . $className . " has no annotation \"table\"");
		} else {
			$genClassName = $this->generateRepositoryName($className);
			if (!class_exists($genClassName)) {
				$class = $this->cache->load($genClassName);
				if ($class) {
					$repository = $class;
				} else {
					$repository = new ClassType($genClassName);
					$repository->addExtend('\slimORM\BaseRepository');
					$repository->setFinal(TRUE);
					$repository->addComment($genClassName);
					$repository->addComment("@generated");
					$repository->addProperty("connection")
						->setVisibility("protected")
						->addComment('@var \Nette\Database\Context');
					$repository->addProperty("entityManager")
						->setVisibility("protected")
						->addComment('@var \slimORM\EntityManager');
					$parameter = new Parameter("connection");
					$parameter->setTypeHint('\Nette\Database\Context');
					$parameter2 = new Parameter("entityManager");
					$parameter2->setTypeHint('\slimORM\EntityManager');
					$entity = EntityManager::PREFIX . str_replace("\\", "", $className) . "Entity";
					$repository->addMethod("__construct")
						->addComment($genClassName . " constructor")
						->addComment('@param \Nette\Database\Context $connection')
						->addComment('@param \slimORM\EntityManager $entityManager')
						->setParameters(array($parameter, $parameter2))
						->setBody("\$this->connection = \$connection;\n\$this->entityManager = \$entityManager;\nparent::__construct(\$connection, \"$table\", \"$entity\");");
					$parameter = new Parameter("key");
					$repository->addMethod("get")
						->addComment("Find item by primary key")
						->addComment("@param int \$key")
						->addComment("@return $entity|null")
						->setParameters(array($parameter))
						->setBody("return parent::get(\$key);");

					//FileSystem::write(WWW_DIR . '/temp/' . $genClassName . ".php", "<?php\n" . $repository);
					$this->cache->save($genClassName, $repository, array(
						Cache::FILES => EntityReflexion::getFile($className), // lze uvést i pole souborů
					));
				}
				$res = eval('?><?php ' . $repository);
				if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) {
					throw new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
				}
				$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
			} else if (!isset($this->repositories[$genClassName])) {
				$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
			}
		}
	}
345882
protected void removeRepository(RepositoryService repositoryService, String repositoryName)
      throws RepositoryException,
      RepositoryConfigurationException
   {
      ManageableRepository mr = null;

      try
      {
         mr = repositoryService.getRepository(repositoryName);
      }
      catch (RepositoryException e)
      {
         // The repository not exist.
         if (LOG.isTraceEnabled())
         {
            LOG.trace("An exception occurred: " + e.getMessage());
         }
      }

      if (mr != null)
      {
         closeAllSession(mr);
         repositoryService.removeRepository(repositoryName);
         repositoryService.getConfig().retain(); // save configuration to persistence (file or persister)
      }
   }
867054
protected function execute( InputInterface $input, OutputInterface $output ) {
		Log::instance()->setOutput( $output );

		$repository = RepositoryManager::instance()->setup( $input->getOption( 'repository' ) );

		if ( ! $repository ) {
			Log::instance()->write( 'Could not setup repository.', 0, 'error' );
			return 1;
		}

		$instances = $repository->getDB()->search( $input->getArgument( 'search_text' ) );

		if ( ! $instances ) {
			Log::instance()->write( 'An error occured while searching.', 0, 'success' );
		}

		if ( empty( $instances ) ) {
			Log::instance()->write( 'No snapshots found.', 0, 'warning' );
			return;
		}

		$table = new Table( $output );
		$table->setHeaders( [ 'ID', 'Project', 'Description', 'Author', 'Size', 'Multisite', 'Created' ] );

		$rows = [];

		foreach ( $instances as $instance ) {
			if ( empty( $instance['time'] ) ) {
				$instance['time'] = time();
			}

			$rows[ $instance['time'] ] = [
				'id'          => ( ! empty( $instance['id'] ) ) ? $instance['id'] : '',
				'project'     => ( ! empty( $instance['project'] ) ) ? $instance['project'] : '',
				'description' => ( ! empty( $instance['description'] ) ) ? $instance['description'] : '',
				'author'      => ( ! empty( $instance['author']['name'] ) ) ? $instance['author']['name'] : '',
				'size'        => ( ! empty( $instance['size'] ) ) ? Utils\format_bytes( (int) $instance['size'] ) : '',
				'multisite'   => ( ! empty( $instance['multisite'] ) ) ? 'Yes' : 'No',
				'created'     => ( ! empty( $instance['time'] ) ) ? date( 'F j, Y, g:i a', $instance['time'] ) : '',
			];
		}

		ksort( $rows );

		$table->setRows( $rows );

		$table->render();
	}
969997
protected function getQueryBuilder($repositoryMethod)
    {
        $repository = $this
            ->getDriver()
            ->getDoctrineOrmEm()
            ->getRepository($this->getDriver()->getEntityFqn())
        ;

        $repositoryMethods = $this->getDriver()->getEntityRepositorySearchableMethods();

        if (!method_exists($repository, $repositoryMethods[$repositoryMethod])) {
            return $repository->createQueryBuilder($this->getDriver()->getEntityAlias());
        }

        $queryBuilder = $repository->{$repositoryMethods[$repositoryMethod]}();

        if (!$queryBuilder instanceof QueryBuilder) {
            throw new ResourceException(sprintf(
                'The method "%s" of repository class must be return a %s instance',
                $repositoryMethods[$repositoryMethod],
                '\Doctrine\ORM\QueryBuilder'
            ));
        }

        return $queryBuilder;
    }
560473
public function read()
    {
        if (empty($this->filename)) {
            Throw new RepositoryException(sprintf('There is no filename set for %s', __CLASS__));
        }

        if (! file_exists($this->filename)) {
            Throw new RepositoryException(sprintf('Config file $s is does not exists', $this->filename));
        }

        if (! is_readable($this->filename)) {
            Throw new RepositoryException(sprintf('Config file $s is not readable', $this->filename));
        }

        $array = include ($this->filename);
    }
474695
private function validate()
    {
        if ($this->name === null && $this->attributeName === null) {
            throw MappingException::missingPropertyName($this->className);
        }

        if ($this->collectionClass !== null) {
            $rColl = new \ReflectionClass($this->collectionClass);
            if (!$rColl->implementsInterface('Doctrine\\Common\\Collections\\Collection')) {
                throw MappingException::collectionClassDoesNotImplementCommonInterface($this->className, $this->attributeName, $this->collectionClass);
            }
        }

        if ($this->reference !== null && empty($this->targetDocument) && empty($this->discriminatorMap) &&
            ($this->mappedBy !== null || $this->inversedBy !== null)) {
            throw MappingException::owningAndInverseReferencesRequireTargetDocument($this->className, $this->name);
        }

        if (!empty($this->prime) && ($this->association !== self::ASSOCIATION_TYPE_REFERENCE_MANY || !$this->isInverseSide === true)) {
            throw MappingException::referencePrimersOnlySupportedForInverseReferenceMany($this->className, $this->name);
        }

        if ($this->repositoryMethod !== null && $this->limit !== null) {
            throw MappingException::repositoryMethodCanNotBeCombinedWithLimit($this->className, $this->name);
        }
    }
665069
protected function doCanFilterWithRepository(
        Collection $collection,
        Repository $repository
    ){
        /**
         * @var Filter[] $filters
         */
        $filters = $this->getFilters();

        foreach ($filters as $filter) {
            if (!$filter->canFilterWithRepository($collection, $repository)){
                return false;
            }
        }

        return true;
    }
35668
public function find(array $filter = [], array $orderBy = [], $limit = 0,
        $offset = 0, array $associate = []
    ) {
        try {

            $query = $this->query()
                ->select()
                ->associate($associate)
                ->setFilter($filter);

            foreach ($orderBy as $orderByRule) {
                $query->orderBy($orderByRule[0], $orderByRule[1]);
            }

            return $query->limit($limit)->offset($offset)->run($this->connection);
        } catch (Exception\QueryException $e) {
            throw new Exception\RepositoryException($e->getMessage());
        }
    }
988177
@SuppressWarnings("unchecked")
    void fetchFromRepository(Collection<ProductDefinition> installDefinition) throws RepositoryException {
        Collection<ResourceType> interestingTypes = new HashSet<ResourceType>();
        interestingTypes.add(ResourceType.FEATURE);
        interestingTypes.add(ResourceType.OPENSOURCE);
        interestingTypes.add(ResourceType.PRODUCTSAMPLE);
        Map<ResourceType, Collection<? extends RepositoryResource>> resources = repoConnections.getResources(installDefinition, interestingTypes, null);

        Collection<EsaResource> features = (Collection<EsaResource>) resources.get(ResourceType.FEATURE);
        if (features != null) {
            repoFeatures = features;
        } else {
            repoFeatures = Collections.emptySet();
        }

        repoSamples = new ArrayList<>();
        Collection<SampleResource> samples = (Collection<SampleResource>) resources.get(ResourceType.PRODUCTSAMPLE);
        if (samples != null) {
            repoSamples.addAll(samples);
        }

        Collection<SampleResource> osiSamples = (Collection<SampleResource>) resources.get(ResourceType.OPENSOURCE);
        if (osiSamples != null) {
            repoSamples.addAll(osiSamples);
        }
    }
485802
void migrate() throws RepositoryException
   {
      try
      {
         LOG.info("Migration started.");

         moveOldStructure();
         service.createStructure();

         //Migration order is important due to removal of nodes.
         migrateGroups();
         migrateMembershipTypes();
         migrateUsers();
         migrateProfiles();
         migrateMemberships();

         removeOldStructure();

         LOG.info("Migration completed.");
      }
      catch (Exception e)//NOSONAR
      {
         throw new RepositoryException("Migration failed", e);
      }
   }
724701
public function process(ContainerBuilder $container)
    {
        $repositoryConfigurations = $container->getParameter('apisearch.repository_configuration');
        foreach ($repositoryConfigurations as $name => $repositoryConfiguration) {
            $this->createAppRepositories(
                $container,
                $name,
                $repositoryConfiguration
            );

            foreach ($repositoryConfiguration['indices'] as $indexName => $indexId) {
                $indexId = (string) $indexId;
                $this->createIndexRepositories(
                    $container,
                    $name,
                    $repositoryConfiguration,
                    $indexId,
                    $indexName
                );
            }
        }
    }
236390
public function read(int $identifier): ?TokenInterface
    {
        try {
            return $this->readResource($identifier);
        } catch (RepositoryException $exception) {
            $message = 'Token reading failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
656157
private void init() throws RepositoryException, RepositoryConfigurationException
   {
      List<WorkspaceEntry> wsEntries = config.getWorkspaceEntries();

      NodeTypeDataManager typeManager = (NodeTypeDataManager)this.getComponentInstanceOfType(NodeTypeDataManager.class);
      NamespaceRegistryImpl namespaceRegistry =
         (NamespaceRegistryImpl)this.getComponentInstanceOfType(NamespaceRegistry.class);

      for (WorkspaceEntry ws : wsEntries)
      {
         initWorkspace(ws);
         WorkspaceContainer workspaceContainer = getWorkspaceContainer(ws.getName());
         SearchManager searchManager =
            (SearchManager)workspaceContainer.getComponentInstanceOfType(SearchManager.class);
         //         if (searchManager != null)
         //         {
         //            typeManager.addQueryHandler(searchManager.getHandler());
         //            namespaceRegistry.addQueryHandler(searchManager.getHandler());
         //         }
         //         else
         //         {
         //            log.warn("Search manager not configured for " + ws.getName());
         //         }
      }

      SystemSearchManagerHolder searchManager =
         (SystemSearchManagerHolder)this.getComponentInstanceOfType(SystemSearchManagerHolder.class);
      //      if (searchManager != null)
      //      {
      //         typeManager.addQueryHandler(searchManager.get().getHandler());
      //         namespaceRegistry.addQueryHandler(searchManager.get().getHandler());
      //      }
      //      else
      //      {
      //         log.warn("System search manager not configured ");
      //      }

   }
469776
public function insert(Repository $repository = null)
    {
        if (!$repository) {
            $repository = $this->getRepository();
        }

        $repository = $repository->aliased('write');

        $insert = $this->getQuery()->transformToInsert();

        $prepare = $repository->prepareQuery($insert);

        return $repository->executePrepared($prepare);
    }