private function createSuggestions()
 {
     $suggestions = array();
     $this->useJsonResponseContentProcessor();
     if (isset($this->parameters['format'])) {
         $oldFormat = $this->parameters['format'];
     }
     $this->parameters['format'] = 'json';
     $suggestData = $this->getResponseContent();
     if (parent::isValidResponse($suggestData)) {
         if (isset($suggestData['suggestions'])) {
             $suggestData = $suggestData['suggestions'];
         }
         foreach ($suggestData as $suggestQueryData) {
             $suggestLink = $this->convertServerQueryToClientUrl($suggestQueryData['searchParams']);
             $suggestAttributes = null;
             if (isset($suggestQueryData['attributes']) && is_array($suggestQueryData['attributes'])) {
                 $suggestAttributes = $suggestQueryData['attributes'];
             } else {
                 $suggestAttributes = array();
             }
             $suggestions[] = FF::getInstance('Data\\SuggestQuery', $suggestQueryData['name'], $suggestLink, $suggestQueryData['hitCount'], $suggestQueryData['type'], $suggestQueryData['image'], $suggestAttributes);
         }
     }
     if (isset($oldFormat)) {
         $this->parameters['format'] = $oldFormat;
     }
     return $suggestions;
 }
예제 #2
0
 public function __construct($loggerClass, \FACTFinder\Core\ConfigurationInterface $configuration, \FACTFinder\Core\Server\Request $request, \FACTFinder\Core\Client\UrlBuilder $urlBuilder, \FACTFinder\Core\AbstractEncodingConverter $encodingConverter = null)
 {
     parent::__construct($loggerClass, $configuration, $request, $urlBuilder, $encodingConverter);
     $this->log = $loggerClass::getLogger(__CLASS__);
     $this->request->setAction('Search.ff');
     $this->parameters['format'] = 'json';
     $this->useJsonResponseContentProcessor();
 }
 public function __construct($loggerClass, \FACTFinder\Core\ConfigurationInterface $configuration, \FACTFinder\Core\Server\Request $request, \FACTFinder\Core\Client\UrlBuilder $urlBuilder)
 {
     parent::__construct($loggerClass, $configuration, $request, $urlBuilder);
     $this->log = $loggerClass::getLogger(__CLASS__);
     $this->request->setAction('Suggest.ff');
     $this->request->setConnectTimeout($configuration->getSuggestConnectTimeout());
     $this->request->setTimeout($configuration->getSuggestTimeout());
 }
 public function __construct($loggerClass, \FACTFinder\Core\ConfigurationInterface $configuration, \FACTFinder\Core\Server\Request $request, \FACTFinder\Core\Client\UrlBuilder $urlBuilder)
 {
     parent::__construct($loggerClass, $configuration, $request, $urlBuilder);
     $this->log = $loggerClass::getLogger(__CLASS__);
     $this->request->setAction('Recommender.ff');
     $this->parameters['do'] = 'getRecommendation';
     $this->parameters['format'] = 'json';
     $this->useJsonResponseContentProcessor();
 }
 public function __construct($loggerClass, \FACTFinder\Core\ConfigurationInterface $configuration, \FACTFinder\Core\Server\Request $request, \FACTFinder\Core\Client\UrlBuilder $urlBuilder, \FACTFinder\Core\AbstractEncodingConverter $encodingConverter = null)
 {
     parent::__construct($loggerClass, $configuration, $request, $urlBuilder, $encodingConverter);
     $this->log = $loggerClass::getLogger(__CLASS__);
     $this->request->setAction('Tracking.ff');
     $this->request->setConnectTimeout($configuration->getTrackingConnectTimeout());
     $this->request->setTimeout($configuration->getTrackingTimeout());
     // $this->usePassthroughResponseContentProcessor(); (default)
 }
 public function __construct($loggerClass, \FACTFinder\Core\ConfigurationInterface $configuration, \FACTFinder\Core\Server\Request $request, \FACTFinder\Core\Client\UrlBuilder $urlBuilder)
 {
     parent::__construct($loggerClass, $configuration, $request, $urlBuilder);
     $this->log = $loggerClass::getLogger(__CLASS__);
     // Don't set request action yet, because it depends on the kind of
     // import to be done.
     $this->parameters['format'] = 'xml';
     $this->request->setConnectTimeout($configuration->getImportConnectTimeout());
     $this->request->setTimeout($configuration->getImportTimeout());
     $this->useXmlResponseContentProcessor();
 }
 private function createTagCloud($requestQuery = null)
 {
     $tagCloud = array();
     $tagCloudData = $this->getResponseContent();
     if (parent::isValidResponse($tagCloudData)) {
         foreach ($tagCloudData as $tagQueryData) {
             $query = $tagQueryData['query'];
             // TODO: Once JIRA issue FF-5328 is fixed, retrieve the
             //       parameters from searchParams, like all other adapters
             //       do.
             $parameters = FF::getInstance('Util\\Parameters');
             $parameters['query'] = $query;
             $tagCloud[] = FF::getInstance('Data\\TagQuery', $query, $this->urlBuilder->generateUrl($parameters), $requestQuery == $query, $tagQueryData['weight'], $tagQueryData['searchCount']);
         }
     }
     return $tagCloud;
 }
 private function createComparedRecords()
 {
     $records = array();
     $parameters = $this->request->getParameters();
     if (!isset($parameters['ids'])) {
         $this->log->warn('Compared records cannot be loaded without product IDs. ' . 'Use setProductIDs() first.');
     } else {
         $position = 1;
         $jsonData = $this->getResponseContent();
         if (parent::isValidResponse($jsonData)) {
             foreach ($jsonData['records'] as $recordData) {
                 $records[] = FF::getInstance('Data\\Record', (string) $recordData['id'], $recordData['record'], 100.0, $position++);
             }
         }
     }
     return FF::getInstance('Data\\Result', $records, null, count($records));
 }
 private function createRecommendations()
 {
     $records = array();
     $parameters = $this->request->getParameters();
     if (!isset($parameters['id'])) {
         $this->log->warn('Recommendations cannot be loaded without a product ID. ' . 'Use setProductIDs() or addProductIDs() first.');
     } else {
         $recommenderData = $this->getResponseContent();
         if (parent::isValidResponse($recommenderData)) {
             if (isset($recommenderData['resultRecords'])) {
                 $recommenderData = $recommenderData['resultRecords'];
             }
             $position = 1;
             foreach ($recommenderData as $recordData) {
                 if ($this->idsOnly) {
                     $records[] = $this->createSparseRecord($recordData);
                 } else {
                     $records[] = $this->createRecord($recordData, $position++);
                 }
             }
         }
     }
     return FF::getInstance('Data\\Result', $records, null, count($records));
 }
 /**
  * @param string $loggerClass Class name of logger to use. The class should
  *        implement FACTFinder\Util\LoggerInterface.
  * @param \FACTFinder\Core\ConfigurationInterface $configuration
  *        Configuration object to use.
  * @param \FACTFinder\Core\Server\Request $request The request object from
  *        which to obtain the server data.
  * @param \FACTFinder\Core\Client\UrlBuilder $urlBuilder
  *        Client URL builder object to use.
  * @param \FACTFinder\Core\encodingConverter $encodingConverter
  *        Encoding converter object to use
  */
 public function __construct($loggerClass, \FACTFinder\Core\ConfigurationInterface $configuration, \FACTFinder\Core\Server\Request $request, \FACTFinder\Core\Client\UrlBuilder $urlBuilder, \FACTFinder\Core\AbstractEncodingConverter $encodingConverter = null)
 {
     parent::__construct($loggerClass, $configuration, $request, $urlBuilder, $encodingConverter);
 }