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()); }
/** @brief Construct helper with pager and current query. * * @param $pager [in] pager retrieved from reply. * @param $meta [in] meta data of the replyset. * @param $query [in] current @a AfsQuery which will be used to generate * appropriate queries (see bellow @a get_pages, @a get_previous and * @a get_next). * @param $config [in] helper ocnfiguration object. * * @exception InvalidArgumentException @a pager is invalid. */ public function __construct($pager, AfsMetaHelper $meta, AfsQuery $query, AfsHelperConfiguration $config) { if (!property_exists($pager, AfsPagerHelper::CURRENT_NAME)) { throw new InvalidArgumentException('Pager is of the wrong type.'); } $this->pager = $pager; $this->query = $query; $this->config = $config; $this->feed_name = $meta->get_feed(); $this->initialize_last_page($meta); }
/** @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; }