minor fixes, moved to version 2.0.2

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/top-topics@133752 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-10-31 10:46:35 +00:00
parent 0107f8843f
commit 7e601bef24
6 changed files with 93 additions and 127 deletions

View File

@ -1,19 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/top-topics-2.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/top-topics-2.0.2-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/> <classpathentry excluding="**" kind="src" output="target/top-topics-2.0.2-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> <classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
@ -30,5 +38,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/top-topics-2.0.1-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/top-topics-2.0.2-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -4,6 +4,7 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/> <property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="top-topics"/> <property name="context-root" value="top-topics"/>
</wb-module> </wb-module>

View File

@ -1,4 +1,8 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlet.user.toptopics.2-0-2"
date="2016-12-01">
<Change>Minor fixes</Change>
</Changeset>
<Changeset component="org.gcube.portlet.user.toptopics.2-0-1" <Changeset component="org.gcube.portlet.user.toptopics.2-0-1"
date="2016-10-01"> date="2016-10-01">
<Change>Minor fixes</Change> <Change>Minor fixes</Change>

View File

@ -13,10 +13,10 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>top-topics</artifactId> <artifactId>top-topics</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>2.0.1-SNAPSHOT</version> <version>2.0.2-SNAPSHOT</version>
<name>Top Topics Portlet</name> <name>Top Topics Portlet</name>
<description> <description>
Top Topics Portle shows the top 10 topics in the scope where is deployed. Top Topics Portlet shows the top topics in the scope where is deployed.
</description> </description>
<scm> <scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection> <connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection>
@ -53,6 +53,7 @@
<groupId>com.google.gwt</groupId> <groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId> <artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version> <version>${gwtVersion}</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.gwt</groupId> <groupId>com.google.gwt</groupId>
@ -75,19 +76,23 @@
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId> <artifactId>custom-portal-handler</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId> <artifactId>aslcore</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId> <artifactId>social-networking-library</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.dvos</groupId> <groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId> <artifactId>usermanagement-core</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google</groupId> <groupId>com.google</groupId>

View File

@ -4,10 +4,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -22,7 +19,7 @@ import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore; import org.gcube.portal.databook.server.DatabookStore;
import org.gcube.portal.databook.shared.Feed; import org.gcube.portal.databook.shared.Feed;
import org.gcube.portlets.user.topics.client.TopicService; import org.gcube.portlets.user.topics.client.TopicService;
import org.gcube.portlets.user.topics.shared.HashTagAndOccurrence; import org.gcube.portlets.user.topics.shared.HashTagOccAndWeight;
import org.gcube.portlets.user.topics.shared.HashtagsWrapper; import org.gcube.portlets.user.topics.shared.HashtagsWrapper;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
@ -36,7 +33,9 @@ import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/** /**
* TopicServiceImpl server side implementation for top-topics class
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR
* @author Costantino Perciante, ISTI-CNR
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class TopicServiceImpl extends RemoteServiceServlet implements TopicService { public class TopicServiceImpl extends RemoteServiceServlet implements TopicService {
@ -45,17 +44,20 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
public static final String TEST_USER = "test.user"; public static final String TEST_USER = "test.user";
private static final String TEST_SCOPE = "/gcube/devsec/devVRE"; private static final String TEST_SCOPE = "/gcube/devsec/devVRE";
private static final int WINDOW_SIZE_IN_MONTHS = 6; // it must not exceed 12 private static final int WINDOW_SIZE_IN_MONTHS = 6; // it must not exceed 12
private static final double FRESHNESS_FACTOR = 0.4;
private static final double NORMALIZED_SCORE_FACTOR = 0.6;
/**
* The Cassandra store interface
*/
private DatabookStore store; private DatabookStore store;
private GroupManager gm;
private UserManager um;
/** /**
* connect to cassandra at startup * connect to cassandra at startup
*/ */
public void init() { public void init() {
store = new DBCassandraAstyanaxImpl(); store = new DBCassandraAstyanaxImpl();
gm = new LiferayGroupManager();
um = new LiferayUserManager();
} }
/** /**
@ -78,7 +80,7 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
} }
return SessionManager.getInstance().getASLSession(sessionID, user); return SessionManager.getInstance().getASLSession(sessionID, user);
} }
/** /**
* when packaging test will fail if the user is not set to test.user * when packaging test will fail if the user is not set to test.user
* @return . * @return .
@ -94,52 +96,40 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
*/ */
@Override @Override
public HashtagsWrapper getHashtags() { public HashtagsWrapper getHashtags() {
ArrayList<String> hashtagsChart = new ArrayList<String>();
ASLSession session = getASLSession(); ASLSession session = getASLSession();
String userName = session.getUsername(); String userName = session.getUsername();
String currentScope = session.getScope();
boolean isInfrastructure = isInfrastructureScope();
//in case the portal is restarted and you have the social home open it will get test.user (no callback to set session info)
//this check just return nothing if that happens
if (userName.compareTo(TEST_USER) == 0) { if (userName.compareTo(TEST_USER) == 0) {
logger.debug("Found " + userName + " returning nothing"); logger.debug("Found " + userName + " returning nothing");
return null; return null;
} }
long timestampStart = System.currentTimeMillis(); String currentScope = session.getScope();
boolean isInfrastructure = isInfrastructureScope(currentScope);
// get the reference time // get the reference time
Calendar referenceTime = Calendar.getInstance(); Calendar referenceTime = Calendar.getInstance();
int currentMonth = referenceTime.get(Calendar.MONTH); // jan = 0, ..... dec = 11 int currentMonth = referenceTime.get(Calendar.MONTH); // jan = 0, ..... dec = 11
referenceTime.set(Calendar.MONTH, currentMonth - WINDOW_SIZE_IN_MONTHS); // the year is automatically decreased if needed referenceTime.set(Calendar.MONTH, currentMonth - WINDOW_SIZE_IN_MONTHS); // the year is automatically decreased if needed
// print it
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
logger.debug("Reference time for trending topics is " + format.format(referenceTime.getTime())); logger.debug("Reference time for trending topics is " + format.format(referenceTime.getTime()));
ArrayList<HashTagOccAndWeight> toSort = new ArrayList<HashTagOccAndWeight>();
ArrayList<String> hashtagsChart = new ArrayList<String>();
Map<String, List<String>> hashtagsInVres = null;
try { try {
ArrayList<HashTagAndOccurrence> toSort = new ArrayList<HashTagAndOccurrence>(); Map<String, Integer> hashtagsAndOccurrences = new HashMap<String, Integer>();
if (isInfrastructure) { if (isInfrastructure) {
logger.debug("****** retrieving hashtags for user VREs and site"); logger.debug("****** retrieving hashtags for user VREs and site");
// different vres could have a same hashtag, we need to merge them
Map<String, Integer> hashtags = new HashMap<String, Integer>();
// we need a map for the couple <hashtag, vre in which it is present>
// it is needed because later we need to retrieve the most recent feed among the ones
// containing the hashtag itself
Map<String, List<String>> hashtagsInVres = new HashMap<String, List<String>>();
GroupManager gm = new LiferayGroupManager();
UserManager um = new LiferayUserManager();
GCubeUser user = um.getUserByUsername(userName); GCubeUser user = um.getUserByUsername(userName);
Set<GCubeGroup> vresInPortal = gm.listGroupsByUserAndSite(user.getUserId(), getThreadLocalRequest().getServerName()); Set<GCubeGroup> vresInPortal = gm.listGroupsByUserAndSite(user.getUserId(), getThreadLocalRequest().getServerName());
logger.debug("Contexts in this site are per user " + vresInPortal); logger.debug("Contexts in this site per user are " + vresInPortal);
List<String> contexts = new ArrayList<String>(); List<String> contexts = new ArrayList<String>();
// get the scopes associated with such groups // get the scopes associated with such groups
@ -147,91 +137,77 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
contexts.add(gm.getInfrastructureScope(gCubeGroup.getGroupId())); contexts.add(gm.getInfrastructureScope(gCubeGroup.getGroupId()));
} }
for (String context : contexts) { hashtagsInVres = new HashMap<String, List<String>>();
Map<String, Integer> map = store.getVREHashtagsWithOccurrenceFilteredByTime(context, referenceTime.getTimeInMillis());
for (String context : contexts) {
Map<String, Integer> hashtagsAndOccurrenceInScope = store.getVREHashtagsWithOccurrenceFilteredByTime(context, referenceTime.getTimeInMillis());
// merge the values if needed // merge the values if needed
for (String hashtag : map.keySet()) { for (String hashtag : hashtagsAndOccurrenceInScope.keySet()) {
if(hashtags.containsKey(hashtag)){ int newValue;
List<String> vres = new ArrayList<String>();
int currentValue = hashtags.get(hashtag); if(hashtagsAndOccurrences.containsKey(hashtag)){
int newValue = currentValue + map.get(hashtag);
// remove and re-add newValue = hashtagsAndOccurrences.get(hashtag) + hashtagsAndOccurrenceInScope.get(hashtag);
hashtags.remove(hashtag); vres = hashtagsInVres.get(hashtag);
hashtags.put(hashtag, newValue);
// get the current list of vres in which the hashtag is present and add this new one
List<String> vres = hashtagsInVres.get(hashtag);
vres.add(context);
hashtagsInVres.put(hashtag, vres);
}else{ }else{
hashtags.put(hashtag, map.get(hashtag)); newValue = hashtagsAndOccurrenceInScope.get(hashtag);
// put in the hashmap hashtagsInVres too
List<String> vres = new ArrayList<String>();
vres.add(context);
hashtagsInVres.put(hashtag, vres);
} }
hashtagsAndOccurrences.put(hashtag, newValue);
vres.add(context);
hashtagsInVres.put(hashtag, vres);
} }
} }
// now we need to evaluate score for each element
Map<String, Double> weights = evaluateWeight(hashtags, WINDOW_SIZE_IN_MONTHS, currentMonth, referenceTime, null, hashtagsInVres);
// at the end build the list
for (String hashtag : hashtags.keySet()) {
toSort.add(new HashTagAndOccurrence(hashtag, hashtags.get(hashtag), weights.get(hashtag)));
}
} }
else { else {
logger.debug("****** retrieving hashtags for scope " + currentScope); logger.debug("****** retrieving hashtags for scope " + currentScope);
Map<String, Integer> hashtags = store.getVREHashtagsWithOccurrenceFilteredByTime(currentScope, referenceTime.getTimeInMillis()); hashtagsAndOccurrences = store.getVREHashtagsWithOccurrenceFilteredByTime(currentScope, referenceTime.getTimeInMillis());
// now we need to evaluate the weight for each element
Map<String, Double> weights = evaluateWeight(hashtags, WINDOW_SIZE_IN_MONTHS, currentMonth, referenceTime, currentScope, null);
for (String hashtag : hashtags.keySet()) {
toSort.add(new HashTagAndOccurrence(hashtag, hashtags.get(hashtag), weights.get(hashtag)));
}
} }
logger.debug("Number of topics retrieved is " + toSort.size()); // now we need to evaluate score for each element
Map<String, Double> weights = evaluateWeights(hashtagsAndOccurrences, WINDOW_SIZE_IN_MONTHS, currentMonth, referenceTime, currentScope, hashtagsInVres);
Collections.sort(toSort); // sort for weight // at the end build the list
for (String hashtag : hashtagsAndOccurrences.keySet()) {
toSort.add(new HashTagOccAndWeight(hashtag, hashtagsAndOccurrences.get(hashtag), weights.get(hashtag)));
}
for (HashTagAndOccurrence wrapper : toSort) { // sort for weights
Collections.sort(toSort);
// build the list of hashtags to display
for (HashTagOccAndWeight wrapper : toSort) {
logger.debug("Entry is " + wrapper.toString() + " with weight " + wrapper.getWeight()); logger.debug("Entry is " + wrapper.toString() + " with weight " + wrapper.getWeight());
String hashtag = wrapper.getHashtag(); String hashtag = wrapper.getHashtag();
String href="\"?"+ String href="\"?"+
new String(Base64.encodeBase64(GCubeSocialNetworking.HASHTAG_OID.getBytes()))+"="+ new String(Base64.encodeBase64(GCubeSocialNetworking.HASHTAG_OID.getBytes()))+"="+
new String(Base64.encodeBase64(hashtag.getBytes()))+"\""; new String(Base64.encodeBase64(hashtag.getBytes()))+"\"";
String hashtagLink = "<a class=\"topiclink\" href=" + href + ">"+hashtag+"</a>"; String hashtagLink = "<a class=\"topiclink\" href=" + href + ">"+hashtag+"</a>";
hashtagsChart.add(hashtagLink); hashtagsChart.add(hashtagLink);
} }
return new HashtagsWrapper(isInfrastructure, hashtagsChart);
} }
catch (Exception e) { catch (Exception e) {
logger.error("Error while retrieving hashtags ", e); logger.error("Error while retrieving hashtags ", e);
return null; return null;
} }
long timestampEnd = System.currentTimeMillis() - timestampStart;
logger.debug("Overall time to retrieve hastags is " + timestampEnd + "ms");
return new HashtagsWrapper(isInfrastructure, hashtagsChart);
} }
/** /**
* Evaluate the weight for each element as w = 0.6 * s + 0.4 * f * Evaluate the weight for each element as w = 0.6 * s + 0.4 * f
* where s is the score: a normalized value given by counter_i / counter_max * where s is the score: a normalized value given by counter_i / counter_max
* f is the freshness: evaluated taking into account the most recent feed containing that hashtag into the window w (that is, * f is the freshness: evaluated taking into account the most recent feed containing that hashtag into the window w (that is, the period taken into account)
* the period taken into account)
* @param hashtags * @param hashtags
* @param hashtagsInVres (present if vreid is null) * @param hashtagsInVres (present if vreid is null)
* @param window size * @param window size
@ -240,7 +216,13 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
* @param vreid (present if hashtagsInVres is null) * @param vreid (present if hashtagsInVres is null)
* @return a Map of weight for each hashtag * @return a Map of weight for each hashtag
*/ */
private Map<String, Double> evaluateWeight(Map<String, Integer> hashtags, int windowSize, int currentMonth, Calendar referenceTime, String vreId, Map<String, List<String>> hashtagsInVres) { private Map<String, Double> evaluateWeights(
Map<String, Integer> hashtags,
int windowSize,
int currentMonth,
Calendar referenceTime,
String vreId,
Map<String, List<String>> hashtagsInVres) {
Map<String, Double> weights = new HashMap<String, Double>(); Map<String, Double> weights = new HashMap<String, Double>();
@ -261,17 +243,17 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
} }
// create the weight for each entry as: // create the weight for each entry as:
// w = 0.6 * normalized_score + 0.4 * freshness // w = NORMALIZED_SCORE_FACTOR * normalized_score + FRESHNESS_FACTOR * freshness
// freshness is evaluated as (window_size - latest_feed_for_hashtag_in_window_month)/window_size // freshness is evaluated as (window_size - latest_feed_for_hashtag_in_window_month)/window_size
for(Entry<String, Integer> entry : hashtags.entrySet()){ for(Entry<String, Integer> entry : hashtags.entrySet()){
// first part of the weight // first part of the weight
double weight = 0.6 * normalized.get(entry.getKey()); double weight = NORMALIZED_SCORE_FACTOR * normalized.get(entry.getKey());
List<Feed> mostRecentFeedForHashtag = null; List<Feed> mostRecentFeedForHashtag = null;
// we are in the simplest case.. the hashtag belongs (or the request comes) from a single vre // we are in the simplest case.. the hashtag belongs (or the request comes) from a single vre
if(vreId != null){ if(hashtagsInVres == null){
try{ try{
@ -329,58 +311,24 @@ public class TopicServiceImpl extends RemoteServiceServlet implements TopicServi
" because the last feed has month " + monstRecentFeedForHashTagTime.get(Calendar.MONTH)); " because the last feed has month " + monstRecentFeedForHashTagTime.get(Calendar.MONTH));
// update the weight // update the weight
weight += 0.4 * freshness; weight += FRESHNESS_FACTOR * freshness;
// put it into the hashmap // put it into the hashmap
weights.put(entry.getKey(), weight); weights.put(entry.getKey(), weight);
} }
// print sorted
Map<String, Double> scoredListSorted = sortByWeight(weights);
for(Entry<String, Double> entry : scoredListSorted.entrySet()){
logger.debug("[hashtag=" + entry.getKey() + " , weight=" + entry.getValue() + "]");
}
return weights; return weights;
} }
/**
* Sort a map by its values
* @param map
* @return
*/
private static <K, V extends Comparable<? super V>> Map<K, V>
sortByWeight( Map<K, V> map )
{
List<Map.Entry<K, V>> list =
new LinkedList<Map.Entry<K, V>>( map.entrySet() );
Collections.sort( list, new Comparator<Map.Entry<K, V>>()
{
public int compare( Map.Entry<K, V> o1, Map.Entry<K, V> o2 )
{
return (o2.getValue()).compareTo( o1.getValue() );
}
});
Map<K, V> result = new LinkedHashMap<K, V>();
for (Map.Entry<K, V> entry : list)
{
result.put( entry.getKey(), entry.getValue() );
}
return result;
}
/** /**
* Indicates whether the scope is the whole infrastructure. * Indicates whether the scope is the whole infrastructure.
* @return <code>true</code> if it is, <code>false</code> otherwise. * @return <code>true</code> if it is, <code>false</code> otherwise.
*/ */
private boolean isInfrastructureScope() { private boolean isInfrastructureScope(String currentScope) {
boolean toReturn = false; boolean toReturn = false;
try { try {
GroupManager manager = new LiferayGroupManager(); long groupId = gm.getGroupIdFromInfrastructureScope(currentScope);
long groupId = manager.getGroupIdFromInfrastructureScope(getASLSession().getScope()); toReturn = !gm.isVRE(groupId);
toReturn = !manager.isVRE(groupId);
return toReturn; return toReturn;
} }
catch (Exception e) { catch (Exception e) {

View File

@ -4,16 +4,16 @@ package org.gcube.portlets.user.topics.shared;
* Bean class for hashtag and its occurrence number * Bean class for hashtag and its occurrence number
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class HashTagAndOccurrence implements Comparable<HashTagAndOccurrence>{ public class HashTagOccAndWeight implements Comparable<HashTagOccAndWeight>{
private String hashtag; private String hashtag;
private Integer occurrence; private Integer occurrence;
private double weight; private double weight;
public HashTagAndOccurrence(String hashtag, Integer occurrence) { public HashTagOccAndWeight(String hashtag, Integer occurrence) {
super(); super();
this.hashtag = hashtag; this.hashtag = hashtag;
this.occurrence = occurrence; this.occurrence = occurrence;
} }
public HashTagAndOccurrence(String hashtag, Integer occurrence, double weight) { public HashTagOccAndWeight(String hashtag, Integer occurrence, double weight) {
super(); super();
this.hashtag = hashtag; this.hashtag = hashtag;
this.occurrence = occurrence; this.occurrence = occurrence;
@ -44,7 +44,7 @@ public class HashTagAndOccurrence implements Comparable<HashTagAndOccurrence>{
+ occurrence + ", weight=" + weight + "]"; + occurrence + ", weight=" + weight + "]";
} }
@Override @Override
public int compareTo(HashTagAndOccurrence o) { public int compareTo(HashTagOccAndWeight o) {
return Double.compare(o.getWeight(), this.weight); return Double.compare(o.getWeight(), this.weight);
} }
} }