@Override public String toString() { String result = String.format( "FacetTopic(facet: '%s' topic: '%s' count: '%s')", getFacetName(), getTopicName(), getCount()); return result; }
/** * Return topic count for the specified facet and topic name. If facet or * topic don't exist, return 0. * * @param facetName name of the wanted facet * @param topicName name of the wanted topic * @return topic count or 0 */ public int getTopicCount(String facetName, String topicName) { int result = 0; if (getFacetsAsMap() != null) { Map<String, FacetTopic> topics = getFacetsAsMap().get(facetName); if (topics != null) { FacetTopic topic = topics.get(topicName); if (topic != null) { result = topic.getCount(); } } } return result; }
@Override public void exportWriter(String securityToken, Writer writer, WikittyService ws, PagedResult<Wikitty> pagedResult) throws Exception { WikittyClient client = new WikittyClient(null, ws, securityToken); Map<String, List<FacetTopic>> facet = new HashMap<String, List<FacetTopic>>(); for (Map.Entry<String, List<org.nuiton.wikitty.search.FacetTopic>> e : pagedResult.getFacets().entrySet()) { String facetName = e.getKey(); List<FacetTopic> topics = new ArrayList<FacetTopic>(); // since 3.4, facet extension has changed of name if (org.nuiton.wikitty.search.operators.Element.ELT_EXTENSION.equals(facetName)) { facet.put(Element.EXTENSION.getValue(), topics); } else { facet.put(facetName, topics); } for (org.nuiton.wikitty.search.FacetTopic f : e.getValue()) { topics.add(new FacetTopic(f.getFacetName(), f.getTopicName(), f.getCount())); } } WikittyQueryResult<Wikitty> queryResult = new WikittyQueryResult( pagedResult.getCriteriaName(), pagedResult.getFirstIndice(), pagedResult.getNumFound(), null, pagedResult.getQueryString(), pagedResult.getAll(), null, null, facet, 0, 0); exportWriter(client, writer, queryResult); }
for (FacetTopic topic : topics) { String topicName = topic.getTopicName(); int topicCount = topic.getCount(); counts.put(topicName, topicCount);
for (org.nuiton.wikitty.search.FacetTopic topic : topics) { String topicName = topic.getTopicName(); int topicCount = topic.getCount(); counts.put(topicName, topicCount);