public void normalize(ArtResourceFrequency f) { Query query = entityManager.createNamedQuery("artResource.taggingCount"); query.setParameter("resid", f.getResource().getId()); query.setParameter("lang", localeSelector.getLanguage()); double taggings = ((Long) query.getSingleResult()).doubleValue(); f.setCount(f.getCount() / taggings); }
public Collection<SelectItem> getLanguagesAsSelectItems() { try { if (languagesAsSelectItems.isEmpty()) { // No select item found for locale. // Create select item list from language taxonomy List<Topic> languageTopics = retrieveAllLanguageTopics(); if (CollectionUtils.isEmpty(languageTopics)) { // No topics found for taxonomy. Load locale selector return localeSelector.getSupportedLocales(); } else { logger.error("Creating select items"); if (topicComparator == null) { topicComparator = new TopicComparator("en", OrderByProperty.LABEL); } Collections.sort(languageTopics, topicComparator); for (Topic language : languageTopics) { SelectItem selectItem = new SelectItem(); selectItem.setLabel(language.getLocalizedLabelForLocale("en")); selectItem.setValue(language.getName()); languagesAsSelectItems.put(language.getName(), selectItem); } } } return languagesAsSelectItems.values(); } catch (Exception e) { logger.error("", e); return localeSelector.getSupportedLocales(); } }