示例#1
0
 /** @brief Constructs new cluster helper instance.
  *
  * @param $cluster [in] One cluster reply.
  * @param $meta [in] Reply set meta data.
  * @param $facet_helper [in] Facet helper (used to retrieve value label).
  * @param $query [in] AfsQuery object previously initialized. It is used to
  *        generate new query to filter on this cluster reply.
  * @param $config [in] Helper configuration.
  */
 public function __construct($cluster, AfsMetaHelper $meta, $facet_helper, AfsQuery $query, AfsHelperConfiguration $config)
 {
     $formatter = AfsFacetHelperRetriever::get_formatter($meta->get_cluster_id(), $query);
     $this->id = $formatter->format($cluster->id);
     $this->initialize_label($facet_helper);
     $this->total_replies = $cluster->totalItems;
     $factory = new AfsReplyHelperFactory($config->get_reply_text_visitor());
     $this->replies = $factory->create_replies($meta->get_feed(), $cluster);
     $this->query = $query->auto_set_from()->unset_cluster()->add_filter($meta->get_cluster_id(), $this->id);
     $this->config = $config;
 }
示例#2
0
 public function testValuesWithCluster()
 {
     $input = json_decode('{
         "uri": "Catalog",
         "totalItems": 61,
         "totalItemsIsExact": true,
         "pageItems": 20,
         "firstPageItem": 1,
         "lastPageItem": 20,
         "durationMs": 6,
         "cluster": "marketing",
         "firstPaFId": 1,
         "lastPaFId": 1,
         "producer": "SEARCH",
         "totalItemsInClusters": 2,
         "nbClusters": 2
     }');
     $meta = new AfsMetaHelper($input);
     $this->assertEquals('Catalog', $meta->get_feed());
     $this->assertEquals(61, $meta->get_total_replies());
     $this->assertEquals($meta->get_replies_per_page(), 20);
     $this->assertEquals(6, $meta->get_duration());
     $this->assertEquals('SEARCH', $meta->get_producer());
     $this->assertTrue($meta->has_cluster());
     $this->assertEquals('marketing', $meta->get_cluster_id());
     $this->assertEquals('marketing', $meta->get_cluster_label());
     $meta->set_cluster_label('My label');
     $this->assertEquals('My label', $meta->get_cluster_label());
 }