Query the eveseat/resources repository for SDE
related information.

@throws \Seat\Services\Exceptions\SettingException
164793
public function handle()
    {

        // Start by warning the user about the command that will be run
        $this->comment('Warning! This Laravel command uses exec() to execute a ');
        $this->comment('mysql shell command to import an extracted dump. Due');
        $this->comment('to the way the command is constructed, should someone ');
        $this->comment('view the current running processes of your server, they ');
        $this->comment('will be able to see your SeAT database users password.');
        $this->line('');
        $this->line('Ensure that you understand this before continuing.');

        // Test that we have valid Database details. An exception
        // will be thrown if this fails.
        DB::connection()->getDatabaseName();

        if (! $this->confirm('Are you sure you want to update to the latest EVE SDE?', true)) {

            $this->warn('Exiting');

            return;
        }

        // Request the json from eveseat/resources
        $this->json = $this->getJsonResource();

        // Ensure we got a response, else fail.
        if (! $this->json) {

            $this->warn('Unable to reach the resources endpoint.');

            return;
        }

        // Check if we should attempt getting the
        // version string locally
        if ($this->option('local')) {

            $version_number = env('SDE_VERSION', null);

            if (! is_null($version_number)) {

                $this->comment('Using locally sourced version number of: ' . $version_number);
                $this->json->version = env('SDE_VERSION');

            } else {

                $this->warn('Unable to determine the version number override. ' .
                    'Using remote version: ' . $this->json->version);
            }
        }

        // Avoid an existing SDE to be accidentally installed again
        // except if the user explicitly ask for it
        if ($this->json->version == Seat::get('installed_sde') &&
            $this->option('force') == false
        ) {

            $this->warn('You are already running the latest SDE version.');
            $this->warn('If you want to install it again, run this command with --force argument.');

            return;
        }

        // Ask for a confirmation before installing an existing SDE version
        if ($this->option('force') == true) {

            $this->warn('You will re-download and install the current SDE version.');

            if (! $this->confirm('Are you sure ?', true)) {

                $this->info('Nothing has been updated.');

                return;
            }
        }

        //TODO: Allow for tables to be specified in config file

        // Show a final confirmation with some info on what
        // we are going to be doing.
        $this->info('The local SDE data will be updated to ' . $this->json->version);
        $this->info(count($this->json->tables) . ' tables will be updated: ' .
            implode(', ', $this->json->tables));
        $this->info('Download format will be: ' . $this->json->format);
        $this->line('');
        $this->info('The SDE will be imported to mysql://' .
            config('database.connections.mysql.username') . '@' .
            config('database.connections.mysql.host') . ':' .
            config('database.connections.mysql.port') . '/' .
            config('database.connections.mysql.database'));

        if (! $this->confirm('Does the above look OK?', true)) {

            $this->warn('Exiting');

            return;
        }

        if (! $this->isStorageOk()) {

            $this->error('Storage path is not OK. Please check permissions');

            return;
        }

        // Download the SDE's
        $this->getSde();

        $this->importSde();

        Seat::set('installed_sde', $this->json->version);

        $this->line('SDE Update Command Complete');

        // Analytics
        dispatch((new Analytics((new AnalyticsContainer)
            ->set('type', 'event')
            ->set('ec', 'queues')
            ->set('ea', 'update_sde')
            ->set('el', 'console')
            ->set('ev', $this->json->version)))
            ->onQueue('medium'));

    }
787011
protected function setCurrentResultStorageToRdsStorage()
    {
        if ($this->isDryrun()) {
            return;
        }
        /** @var ResultServerService $resultService */
        $resultService = $this->getServiceLocator()->get(ResultServerService::SERVICE_ID);
        $resultService->setOption(ResultServerService::OPTION_RESULT_STORAGE, RdsResultStorage::SERVICE_ID);
        $this->registerService(ResultServerService::SERVICE_ID, $resultService);
        $this->report->add(\common_report_Report::createSuccess('Storage type successfully updated to RDS Storage'));
    }
569293
protected function setRequestQueryString()
    {
        $query = $this->request->getQuery();

        foreach ($this->queryStrings as $key => $value) {
            $query->set($key, $value);
        }
    }
564069
public function getDatasourceService()
    {
        if ($this->datasourceService == null) {
            $this->datasourceService = $this->newService('AppserverIo\Appserver\Core\Api\DatasourceService');
        }
        return $this->datasourceService;
    }
830311
public static function getRepository() {
		if(self::$entity_manager == null)
			self::initialize();

		return call_user_func_array(array(self::$entity_manager, "getRepository"), func_get_args());
	}
866275
public function tenant() {
		// see if we have a tenant in a __token
		$input = \Request::input();
		if (!empty($input['__token'])) {
			$crypt_model = new \Crypt();
			$crypt_result = $crypt_model->tokenValidate($input['__token']);
		}
		$tenant_datasource_settings = \Object\ACL\Resources::getStatic('application_structure', 'tenant');
		if (!empty($tenant_datasource_settings['tenant_datasource'])) {
			// prepare to query tenant
			$tenant_input = \Application::get('application.structure.settings.tenant');
			// see if we have tenant override from __token
			if (!empty($crypt_result['id'])) {
				$tenant_input = ['id' => (int) $crypt_result['id']];
			}
			if (!empty($tenant_input)) {
				if (!empty($tenant_datasource_settings['column_prefix'])) {
					array_key_prefix_and_suffix($tenant_input, $tenant_datasource_settings['column_prefix']);
				}
				// find tenant
				$class = $tenant_datasource_settings['tenant_datasource'];
				$datasource = new $class();
				$tenant_result = $datasource->get(['where' => $tenant_input, 'single_row' => true]);
				if (empty($tenant_result)) {
					$structure = \Application::get('application.structure') ?? [];
					if (!empty($structure['tenant_not_found_url'])) {
						\Request::redirect($structure['tenant_not_found_url']);
					} else {
						Throw new \Exception('Invalid URL!', -1);
					}
				} else {
					if (!empty($tenant_datasource_settings['column_prefix'])) {
						array_key_prefix_and_suffix($tenant_result, $tenant_datasource_settings['column_prefix'], null, true);
					}
					\Application::set('application.structure.settings.tenant', $tenant_result);
				}
			}
		}
	}
408402
public function search()
    {
        $params = $this->getRequestParameter('params');
        $query = $params['query'];
        $class = $this->getClass($params['rootNode']);

        $rows = $this->hasRequestParameter('rows') ? (int)$this->getRequestParameter('rows') : null;
        $page = $this->hasRequestParameter('page') ? (int)$this->getRequestParameter('page') : 1;
        $startRow = is_null($rows) ? 0 : $rows * ($page - 1);

        try {
            $results = [];

            // if it is an URI
            if (strpos($query, LOCAL_NAMESPACE) === 0) {
                $resource = $this->getResource($query);
                if ($resource->exists() && $resource->isInstanceOf($class)) {
                    $results = new ResultSet([$resource->getUri()], 1);
                }
            }

            //  if there is no results based on considering the query as URI
            if (empty($results)) {
                $results = $this->getServiceLocator()->get(Search::SERVICE_ID)->query($query, $class->getUri(), $startRow, $rows);
            }

            $totalPages = is_null($rows) ? 1 : ceil( $results->getTotalCount() / $rows );

            $response = new StdClass();
            if(count($results) > 0 ){

                foreach($results as $uri) {
                    $instance = $this->getResource($uri);
                    $instanceProperties = array(
                        'id' => $instance->getUri(),
                        OntologyRdfs::RDFS_LABEL => $instance->getLabel()
                    );

                    $response->data[] = $instanceProperties;
                }
            }
    		$response->success = true;
            $response->page = empty($response->data) ? 0 : $page;
    		$response->total = $totalPages;
    		$response->records = count($results);

    		$this->returnJson($response, 200);
        } catch (SyntaxException $e) {
            $this->returnJson(array(
                'success' => false,
                'msg' => $e->getUserMessage()
            ));
        }
    }
1085301
private void processResources() throws SQLException
   {
      List<Row> rows = getRows("select * from zresource where zproject=? order by zorderinproject", m_projectID);
      for (Row row : rows)
      {
         Resource resource = m_project.addResource();
         resource.setUniqueID(row.getInteger("Z_PK"));
         resource.setEmailAddress(row.getString("ZEMAIL"));
         resource.setInitials(row.getString("ZINITIALS"));
         resource.setName(row.getString("ZTITLE_"));
         resource.setGUID(row.getUUID("ZUNIQUEID"));
         resource.setType(row.getResourceType("ZTYPE"));
         resource.setMaterialLabel(row.getString("ZMATERIALUNIT"));

         if (resource.getType() == ResourceType.WORK)
         {
            resource.setMaxUnits(Double.valueOf(NumberHelper.getDouble(row.getDouble("ZAVAILABLEUNITS_")) * 100.0));
         }

         Integer calendarID = row.getInteger("ZRESOURCECALENDAR");
         if (calendarID != null)
         {
            ProjectCalendar calendar = m_project.getCalendarByUniqueID(calendarID);
            if (calendar != null)
            {
               calendar.setName(resource.getName());
               resource.setResourceCalendar(calendar);
            }
         }

         m_eventManager.fireResourceReadEvent(resource);
      }
   }
402798
private function callRepository()
    {
        // check the config
        if (config('generators.settings.controller.repository_contract')) {
            if ($this->confirm("Create a reposity and contract for the $this->resource resource?")) {
                $name = $this->getModelName();

                $this->repositoryContract = true;

                $this->callCommandFile('contract', $name);
                $this->callCommandFile('repository', $name);

                //$contract = $name . config('generators.settings.contract.postfix');
                //$this->callCommandFile('repository', $name, ['--contract' => $contract]);
            }
        }
    }
1073131
public function load()
    {
        $contents = $this->repository->get($this->key);

        if (! is_null($contents)) {
            $this->setFromStorage($contents);
        }
    }
1309661
public function setDataSource($data)
    {
        if ($data instanceof DataSource\DataSourceInterface) {
            $this->dataSource = $data;
        } elseif (is_array($data)) {
            $this->dataSource = new DataSource\PhpArray($data);
        } elseif ($data instanceof QueryBuilder) {
            $this->dataSource = new DataSource\Doctrine2($data);
        } elseif ($data instanceof ZendSelect) {
            $args = func_get_args();
            if (count($args) === 1 ||
                (! $args[1] instanceof \Zend\Db\Adapter\Adapter && ! $args[1] instanceof \Zend\Db\Sql\Sql)
            ) {
                throw new \InvalidArgumentException(
                    'For "Zend\Db\Sql\Select" also a "Zend\Db\Adapter\Sql" or "Zend\Db\Sql\Sql" is needed.'
                );
            }
            $this->dataSource = new DataSource\ZendSelect($data);
            $this->dataSource->setAdapter($args[1]);
        } elseif ($data instanceof Collection) {
            $args = func_get_args();
            if (count($args) === 1 || ! $args[1] instanceof \Doctrine\ORM\EntityManager) {
                throw new \InvalidArgumentException(
                    'If providing a Collection, also the Doctrine\ORM\EntityManager is needed as a second parameter'
                );
            }
            $this->dataSource = new DataSource\Doctrine2Collection($data);
            $this->dataSource->setEntityManager($args[1]);
        } else {
            throw new \InvalidArgumentException(
                '$data must implement the interface ZfcDatagrid\DataSource\DataSourceInterface'
            );
        }
    }
1182493
private function setEntityRepository()
    {
        try {
            $this->_repository = $this->_em->getRepository(self::ENTITY_CLASSNAME);
        } catch (\Exception $e) {
            throw new CacheException('Enable to load the cache entity repository', null, $e);
        }

        return $this;
    }
1063374
public function index()
    {
        $roleGrid = new RoleDataGrid($this->repository->query());

        return view('avored-framework::system.role.index')->with('dataGrid', $roleGrid->dataGrid);
    }
347407
protected function loadServiceData() {
    if (!isset($this->serviceData)) {
      $this->serviceData = $this->environment->getStorage()->retrieve('services');
    }

    // Populate the keys, in case analysis crashed.
    $this->serviceData += [
      'primary' => [],
      'all' => [],
    ];

    return $this->serviceData;
  }
752120
private function checkQueryResourceId(array $parameters, string $type): void
    {
        if (!$this->resourceId && $parameters['resource_id']) {
            throw new \InvalidArgumentException(\sprintf(
                'Trying to query with a resource ID, but the repository %s does not provide support for them',
                $this->name
            ));
        }
        if (self::ENDPOINT_SINGLE === $type && !$parameters['resource_id']) {
            throw new \InvalidArgumentException(\sprintf(
                'Trying to query a single element without providing a resource ID for repository %s',
                $this->name
            ));
        }
        if (self::ENPOINT_COLLECTION === $type && $parameters['resource_id']) {
            throw new \InvalidArgumentException(\sprintf(
                'Trying to query a collection element by providing a resource ID for repository %s',
                $this->name
            ));
        }
    }
147698
protected DataSource getDataSource() throws RepositoryException
   {
      try
      {
         return containerConfig.dsProvider.getDataSource(containerConfig.dbSourceName);
      }
      catch (NamingException e)
      {
         throw new RepositoryException("Datasource '" + containerConfig.dbSourceName
            + "' is not bound in this context.", e);
      }
   }
1265273
def get_resource_relationships_by_search(self, resource_relationship_query, resource_relationship_search):
        """"""
        # Implemented from azosid template for -
        # osid.resource.ResourceSearchSession.get_resources_by_search_template
        if not self._can('search'):
            raise PermissionDenied()
        return self._provider_session.get_resource_relationships_by_search(resource_relationship_query, resource_relationship_search)