added hashtag support, missing delete operation

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@100332 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-10-01 15:08:38 +00:00
parent 79ea470f94
commit fdcd091f84
7 changed files with 689 additions and 337 deletions

View File

@ -102252,3 +102252,146 @@ Compiling...
Compilation completed in 0.01 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
[WARN] Error processing classpath URL 'file:/Applications/eclipse 4.3/plugins/com.google.gdt.eclipse.designer.hosted.2_2_3.1.2.r43x201303061525/gwt-dev-designtime.jar'
java.net.URISyntaxException: Illegal character in path at index 26: file:/Applications/eclipse 4.3/plugins/com.google.gdt.eclipse.designer.hosted.2_2_3.1.2.r43x201303061525/gwt-dev-designtime.jar
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parseHierarchical(URI.java:3086)
at java.net.URI$Parser.parse(URI.java:3034)
at java.net.URI.<init>(URI.java:595)
at java.net.URL.toURI(URL.java:938)
at com.google.gwt.dev.resource.impl.ResourceOracleImpl.addAllClassPathEntries(ResourceOracleImpl.java:323)
at com.google.gwt.dev.resource.impl.ResourceOracleImpl.getAllClassPathEntries(ResourceOracleImpl.java:358)
at com.google.gwt.dev.resource.impl.ResourceOracleImpl.<init>(ResourceOracleImpl.java:402)
at com.google.gwt.dev.cfg.ModuleDef.normalize(ModuleDef.java:545)
at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:199)
at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromResources(ModuleDefLoader.java:169)
at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:141)
at com.google.gwt.dev.shell.designtime.HostedModeSupportImpl.loadModule(HostedModeSupportImpl.java:85)
at com.google.gwt.dev.shell.designtime.HostedModeSupportImpl.createModuleSpaceHost(HostedModeSupportImpl.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.invokeMethod(ReflectionUtils.java:869)
at com.google.gdt.eclipse.designer.hosted.tdt.HostedModeSupport.createModuleSpaceHost(HostedModeSupport.java:447)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.invokeMethod(ReflectionUtils.java:869)
at com.google.gdt.eclipse.designer.WarmUpSupport.warmUpHostedMode(WarmUpSupport.java:125)
at com.google.gdt.eclipse.designer.WarmUpSupport.warmUpHostedMode(WarmUpSupport.java:103)
at com.google.gdt.eclipse.designer.WarmUpSupport.doWarmUp(WarmUpSupport.java:84)
at com.google.gdt.eclipse.designer.Activator.earlyStartup(Activator.java:190)
at org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup(EarlyStartupRunnable.java:87)
at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:73)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.Workbench$55.run(Workbench.java:2552)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Translatable source found in...
Found 0 cached/archived units. Used 0 / 2719 units from cache.
Compiling...
0% complete (ETR: 68 seconds)
10% complete (ETR: 69 seconds)
20% complete (ETR: 58 seconds)
30% complete (ETR: 39 seconds)
40% complete (ETR: 30 seconds)
50% complete (ETR: 24 seconds)
60% complete (ETR: 17 seconds)
70% complete (ETR: 12 seconds)
80% complete (ETR: 8 seconds)
90% complete (ETR: 3 seconds)
100% complete (ETR: 0 seconds)
Compilation completed in 40.04 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
[WARN] Error processing classpath URL 'file:/Applications/eclipse 4.3/plugins/com.google.gdt.eclipse.designer.hosted.2_2_3.1.2.r43x201303061525/gwt-dev-designtime.jar'
java.net.URISyntaxException: Illegal character in path at index 26: file:/Applications/eclipse 4.3/plugins/com.google.gdt.eclipse.designer.hosted.2_2_3.1.2.r43x201303061525/gwt-dev-designtime.jar
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parseHierarchical(URI.java:3086)
at java.net.URI$Parser.parse(URI.java:3034)
at java.net.URI.<init>(URI.java:595)
at java.net.URL.toURI(URL.java:938)
at com.google.gwt.dev.resource.impl.ResourceOracleImpl.addAllClassPathEntries(ResourceOracleImpl.java:323)
at com.google.gwt.dev.resource.impl.ResourceOracleImpl.getAllClassPathEntries(ResourceOracleImpl.java:358)
at com.google.gwt.dev.resource.impl.ResourceOracleImpl.<init>(ResourceOracleImpl.java:402)
at com.google.gwt.dev.cfg.ModuleDef.normalize(ModuleDef.java:545)
at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:199)
at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromResources(ModuleDefLoader.java:169)
at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:141)
at com.google.gwt.dev.shell.designtime.HostedModeSupportImpl.loadModule(HostedModeSupportImpl.java:85)
at com.google.gwt.dev.shell.designtime.HostedModeSupportImpl.createModuleSpaceHost(HostedModeSupportImpl.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.invokeMethod(ReflectionUtils.java:869)
at com.google.gdt.eclipse.designer.hosted.tdt.HostedModeSupport.createModuleSpaceHost(HostedModeSupport.java:447)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.invokeMethod(ReflectionUtils.java:869)
at com.google.gdt.eclipse.designer.WarmUpSupport.warmUpHostedMode(WarmUpSupport.java:125)
at com.google.gdt.eclipse.designer.WarmUpSupport.warmUpHostedMode(WarmUpSupport.java:104)
at com.google.gdt.eclipse.designer.WarmUpSupport.doWarmUp(WarmUpSupport.java:84)
at com.google.gdt.eclipse.designer.Activator.earlyStartup(Activator.java:190)
at org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup(EarlyStartupRunnable.java:87)
at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:73)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.Workbench$55.run(Workbench.java:2552)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Translatable source found in...
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
[WARN] Error processing classpath URL 'file:/Applications/eclipse 4.3/plugins/com.google.gdt.eclipse.designer.hosted.2_2_3.1.2.r43x201303061525/gwt-dev-designtime.jar'
java.net.URISyntaxException: Illegal character in path at index 26: file:/Applications/eclipse 4.3/plugins/com.google.gdt.eclipse.designer.hosted.2_2_3.1.2.r43x201303061525/gwt-dev-designtime.jar
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parseHierarchical(URI.java:3086)
at java.net.URI$Parser.parse(URI.java:3034)
at java.net.URI.<init>(URI.java:595)
at java.net.URL.toURI(URL.java:938)
at com.google.gwt.dev.resource.impl.ResourceOracleImpl.addAllClassPathEntries(ResourceOracleImpl.java:323)
at com.google.gwt.dev.resource.impl.ResourceOracleImpl.getAllClassPathEntries(ResourceOracleImpl.java:358)
at com.google.gwt.dev.resource.impl.ResourceOracleImpl.<init>(ResourceOracleImpl.java:402)
at com.google.gwt.dev.cfg.ModuleDef.normalize(ModuleDef.java:545)
at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:199)
at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromResources(ModuleDefLoader.java:169)
at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:141)
at com.google.gwt.dev.shell.designtime.HostedModeSupportImpl.loadModule(HostedModeSupportImpl.java:85)
at com.google.gwt.dev.shell.designtime.HostedModeSupportImpl.createModuleSpaceHost(HostedModeSupportImpl.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.invokeMethod(ReflectionUtils.java:869)
at com.google.gdt.eclipse.designer.hosted.tdt.HostedModeSupport.createModuleSpaceHost(HostedModeSupport.java:447)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.invokeMethod(ReflectionUtils.java:869)
at com.google.gdt.eclipse.designer.WarmUpSupport.warmUpHostedMode(WarmUpSupport.java:125)
at com.google.gdt.eclipse.designer.WarmUpSupport.warmUpHostedMode(WarmUpSupport.java:105)
at com.google.gdt.eclipse.designer.WarmUpSupport.doWarmUp(WarmUpSupport.java:84)
at com.google.gdt.eclipse.designer.Activator.earlyStartup(Activator.java:190)
at org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup(EarlyStartupRunnable.java:87)
at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:73)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.Workbench$55.run(Workbench.java:2552)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Translatable source found in...
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes

Binary file not shown.

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>1.6.2-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
<name>gCube Social Networking Library</name>
<description>
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.
@ -46,7 +46,6 @@
<dependency>
<groupId>com.netflix.astyanax</groupId>
<artifactId>astyanax</artifactId>
<version>1.56.21</version>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
@ -55,12 +54,10 @@
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<version>[0.1.0-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>com.google</groupId>
<artifactId>gwt-jsonmaker</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>

View File

@ -187,6 +187,8 @@ public class CassandraClusterConnection {
ColumnFamilyDefinition cfDefUserNotifications = getDynamicCFDef(DBCassandraAstyanaxImpl.USER_NOTIFICATIONS);
ColumnFamilyDefinition cfDefUserMessagesNotifications = getDynamicCFDef(DBCassandraAstyanaxImpl.USER_MESSAGES_NOTIFICATIONS);
ColumnFamilyDefinition cfDefUserNotificationsPreferences = getDynamicCFDef(DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES);
ColumnFamilyDefinition cfDefHashtagsCounter = getDynamicCFDef(DBCassandraAstyanaxImpl.HASHTAGS_COUNTER);
ColumnFamilyDefinition cfDefHashtagTimeline = getDynamicCFDef(DBCassandraAstyanaxImpl.HASHTAGGED_FEEDS);
ksDef.setName(keyspaceName)
@ -204,7 +206,9 @@ public class CassandraClusterConnection {
.addColumnFamily(cfDefUserNotifications)
.addColumnFamily(cfDefUserMessagesNotifications)
.addColumnFamily(cfDefUserNotificationsPreferences)
.addColumnFamily(cfDefUserLikedFeeds);
.addColumnFamily(cfDefUserLikedFeeds)
.addColumnFamily(cfDefHashtagsCounter)
.addColumnFamily(cfDefHashtagTimeline);
cluster.addKeyspace(ksDef);
}

View File

@ -70,6 +70,9 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
public static final String USER_NOTIFICATIONS = "USERNotifications"; // regular user notifications timeline
public static final String USER_MESSAGES_NOTIFICATIONS = "USERMessagesNotifications"; // user messages notifications timeline
public static final String USER_NOTIFICATIONS_PREFERENCES = "USERNotificationsPreferences"; // preferences for notifications
public static final String HASHTAGS_COUNTER = "HashtagsCounter"; // count the hashtags per group and type
public static final String HASHTAGGED_FEEDS = "HashtaggedFeeds"; // contains hashtags per type associated with vre and feed
private static ColumnFamily<String, String> cf_Connections = new ColumnFamily<String, String>(
CONNECTIONS, // Column Family Name
@ -126,6 +129,14 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
StringSerializer.get(), // Key Serializer
StringSerializer.get()); // Column Serializer
private static ColumnFamily<String, String> cf_HashtagsCounter = new ColumnFamily<String, String>(
HASHTAGS_COUNTER, // Column Family Name
StringSerializer.get(), // Key Serializer
StringSerializer.get()); // Column Serializer
protected static ColumnFamily<String, String> cf_HashtagTimeline = new ColumnFamily<String, String>(
HASHTAGGED_FEEDS, // Column Family Name
StringSerializer.get(), // Key Serializer
StringSerializer.get()); // Column Serializer
@ -133,7 +144,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
* connection instance
*/
private CassandraClusterConnection conn;
protected CassandraClusterConnection getConnection() {
return conn;
}
@ -737,6 +748,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return execute(m);
}
/**
* {@inheritDoc}
*/
@ -1408,7 +1420,6 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
toReturn.add(toAdd);
}
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return toReturn;
@ -1417,6 +1428,74 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
* {@inheritDoc}
*/
@Override
public boolean saveHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException {
// Inserting data
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
for (String hashtag : hashtags) {
m.withRow(cf_HashtagTimeline, hashtag).putColumn(feedid, vreid, null);
boolean firstInsert = execute(m);
boolean secondInsert = updateVREHashtagCount(vreid, hashtag, true);
if (! (firstInsert && secondInsert)) {
_log.error("saveHashTag: Could not save the hashtag(s)");
return false;
}
}
return true;
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, Integer> getVREHashtagsWithOccurrence(String vreid) {
OperationResult<Rows<String, String>> result = null;
try {
result = conn.getKeyspace().prepareQuery(cf_HashtagsCounter)
.getKeySlice(vreid)
.execute();
} catch (ConnectionException e) {
e.printStackTrace();
}
HashMap<String, Integer> toReturn = new HashMap<String, Integer> ();
// Iterate rows and their columns
for (Row<String, String> row : result.getResult()) {
for (Column<String> column : row.getColumns()) {
int curValue = Integer.parseInt(column.getStringValue());
toReturn.put(column.getName(), curValue);
}
}
return toReturn;
}
/**
* {@inheritDoc}
*/
@Override
public List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
List<Feed> toReturn = new ArrayList<Feed>();
OperationResult<Rows<String, String>> result = null;
try {
result = conn.getKeyspace().prepareQuery(cf_HashtagTimeline)
.getKeySlice(hashtag)
.execute();
} catch (ConnectionException e) {
e.printStackTrace();
}
ArrayList<String> feedIds = new ArrayList<String>();
// Iterate rows and their columns
for (Row<String, String> row : result.getResult()) {
for (Column<String> column : row.getColumns()) {
if (column.getStringValue().compareTo(vreid)==0)
feedIds.add(column.getName());
}
}
toReturn = getFeedsByIds(feedIds);
return toReturn;
}
/**
* {@inheritDoc}
*/
@Override
public void closeConnection() {
// TODO Auto-generated method stub
}
@ -1675,6 +1754,43 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return true;
}
/**
* update the hashtag count by incrementing or decrementing it by (1)
* used when adding or removing a hashtag in a feed
* @param vreid the vreid
* @param hashtag the hashtag
* @param increment set true if you want to add 1, false to subtract 1.
*/
private boolean updateVREHashtagCount(String vreid, String hashtag, boolean increment) {
Map<String, Integer> vreHashtags = getVREHashtagsWithOccurrence(vreid);
//if the hashtag not yet exist
int newCount = 0;
if (!vreHashtags.containsKey(hashtag)) {
newCount = 1;
}
else {
try {
int current = vreHashtags.get(hashtag);
newCount = increment ? current+1 : current-1;
}
catch (NumberFormatException e) {
_log.error("Hashtag Number found is not a number: " + newCount);
}
}
_log.info("Updating counter for " + hashtag + " to " + newCount);
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
m.withRow(cf_HashtagsCounter, vreid).putColumn(hashtag, ""+newCount, null);
try {
m.execute();
} catch (ConnectionException e) {
_log.error("Hashtag Count update NOT OK ");
return false;
}
_log.info("Hashtag Count update OK to: " + newCount);
return true;
}

View File

@ -1,24 +1,20 @@
package org.gcube.portal.databook.server;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import java.sql.Savepoint;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Map;
import java.util.UUID;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.PrivacyLevel;
import org.gcube.portal.databook.shared.RangeFeeds;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
@ -26,10 +22,15 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import com.google.common.collect.ImmutableMap;
import com.netflix.astyanax.connectionpool.OperationResult;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
import com.netflix.astyanax.ddl.ColumnFamilyDefinition;
import com.netflix.astyanax.model.ColumnFamily;
import com.netflix.astyanax.model.Row;
import com.netflix.astyanax.model.Rows;
import com.netflix.astyanax.serializers.StringSerializer;
import com.netflix.astyanax.thrift.ddl.ThriftColumnFamilyDefinitionImpl;
public class DatabookCassandraTest {
private static DBCassandraAstyanaxImpl store;
@ -44,340 +45,406 @@ public class DatabookCassandraTest {
store.closeConnection();
System.out.println("End");
}
private List<String> getKeys() {
List<String> toReturn = new ArrayList<String>();
try {
OperationResult<Rows<String, String>> rows = store.getConnection().getKeyspace().prepareQuery(DBCassandraAstyanaxImpl.cf_UserNotificationsPreferences)
.getAllRows()
.setRowLimit(1000) // This is the page size
.execute();
int i = 1;
for (Row<String, String> row : rows.getResult()) {
System.out.println(i+" ROW: " + row.getKey() + " " + row.getColumns().size());
toReturn.add(row.getKey());
i++;
}
} catch (ConnectionException e) {
e.printStackTrace();
}
return toReturn;
}
@Test
public void testUserNotificationPreferences() {
System.out.println("Notification type" + NotificationType.POST_ALERT.toString() +" OFF for:");
try {
for (String user : getKeys()) {
List<NotificationChannelType> channels = store.getUserNotificationChannels(user, NotificationType.POST_ALERT);
if (channels.isEmpty()) {
System.out.println(user);
}
else if (! channels.contains(NotificationChannelType.EMAIL)) {
System.out.println(user + "->" + channels.toString());
}
public void testHashTag() {
try {
final String VREID = "/gcube/devsec/devVRE5";
final String HASHTAG1 = "#anotherHashTag";
final String HASHTAG2 = "#yetAnotherHashTag";
List<String> hashtags = new LinkedList<String>();
hashtags.add(HASHTAG1);
hashtags.add(HASHTAG2);
Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "massimiliano.assante", new Date(), VREID,
"www.d4science.org/monitor", "thumbUri", "This is a feed with " + HASHTAG1 + " and " + HASHTAG2, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
assertTrue(store.saveUserFeed(feed));
assertTrue(store.saveHashTags(feed.getKey(), VREID, hashtags));
System.out.println(feed);
System.out.println("\ngetting getVREHashtagsWithOccurrence for " + VREID);
Map<String, Integer> hashtagsWithOcc = store.getVREHashtagsWithOccurrence(VREID);
for (String hashtag : hashtagsWithOcc.keySet()) {
System.out.println(hashtag + ":" + hashtagsWithOcc.get(hashtag));
}
System.out.println("\ngetting getVREFeedsByHashtag for " + VREID + " and " + HASHTAG1);
for (Feed theFeed : store.getVREFeedsByHashtag(VREID, HASHTAG1)) {
System.out.println(theFeed);
}
// for (NotificationChannelType channel : store.getUserNotificationChannels("roberto.trasarti", NotificationType.POST_ALERT)) {
// System.out.println(channel);
// }
} catch (NotificationChannelTypeNotFoundException e) {
} catch (Exception e) {
e.printStackTrace();
} catch (NotificationTypeNotFoundException e) {
e.printStackTrace();
};
}
}
// @Test
// public void testLikes() {
// int count = 10;
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "http://www.d4science.org/monitor", "thumbUri", "This feed is Liked ", PrivacyLevel.PUBLIC,
// "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
// Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
// new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
//
// try {
// assertTrue(store.like(toUnlike));
// for (int i = 0; i < count; i++)
// assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
// new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
//
// System.out.println("massimiliano.assante liked the following feeds: ");
// for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
// System.out.println(feedid);
// }
//
// for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
// System.out.println(like);
// }
// System.out.println("massimiliano.assante trying unlike the following feed: " + toUnlike);
// store.unlike("massimiliano.assante", toUnlike.getKey(), toUnlike.getFeedid());
//
// } catch (Exception e) {
// System.out.println("Exception feed id not found");
// }
// }
// /**
// * use exclusively to add a new CF to a keyspace
// * use exclusively to add a new (Dynamic) CF to a keyspace
// */
// @Test
// public void addNotifPreferencesColumnFamily() {
// // ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>(
// // DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
// // StringSerializer.get(), // Key Serializer
// // StringSerializer.get()); // Column Serializer
// //
// // try {
// // new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsPreferences, ImmutableMap.<String, Object>builder()
// // .put("default_validation_class", "UTF8Type")
// // .put("key_validation_class", "UTF8Type")
// // .put("comparator_type", "UTF8Type")
// // .build());
// // } catch (ConnectionException e) {
// // e.printStackTrace();
// // }
// }
// public void addHashtagsColumnFamilies() {
// ColumnFamily<String, String> cf_HashtagsCounter = new ColumnFamily<String, String>(
// DBCassandraAstyanaxImpl.HASHTAGS_COUNTER, // Column Family Name
// StringSerializer.get(), // Key Serializer
// StringSerializer.get()); // Column Serializer
// ColumnFamily<String, String> cf_HashtagTimeline = new ColumnFamily<String, String>(
// DBCassandraAstyanaxImpl.HASHTAGGED_FEEDS, // Column Family Name
// StringSerializer.get(), // Key Serializer
// StringSerializer.get()); // Column Serializer
//
// @Test
// public void testFriendships() {
// assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
// assertTrue(store.requestFriendship("massimiliano.assante", "ermit"));
// assertTrue(store.requestFriendship("massimiliano.assante", "giorgino"));
// assertTrue(store.requestFriendship("barabba", "massimiliano.assante"));
//
// assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante"));
// assertTrue(store.approveFriendship("ermit", "massimiliano.assante"));
//
// assertTrue(store.denyFriendship("giorgino", "massimiliano.assante"));
// System.out.println("Pending Connections for massimiliano.assante:");
// for (String userid: store.getPendingFriendRequests("massimiliano.assante")) {
// System.out.println(userid);
// }
//
// System.out.println("Connections for massimiliano.assante:");
// for (String userid: store.getFriends("massimiliano.assante")) {
// System.out.println(userid);
// }
//
// }
// @Test
// public void testLikedFeedsRetrieval() {
// try {
// for (Feed feed : store.getAllLikedFeedsByUser("luca.frosini", 10)) {
// System.out.println(feed);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
//
//
//
// @Test
// public void testSingleNotification() {
// Notification not = new Notification(
// UUID.randomUUID().toString(),
// NotificationType.LIKE,
// "leonardo.candela",
// "MESSAGEID",
// new Date(),
// "uri",
// "This is notification about a like",
// false,
// "leonardo.candela", "Leonardo Candela",
// "thumburl");
// assertTrue(store.saveNotification(not));
//
// not = new Notification(
// UUID.randomUUID().toString(),
// NotificationType.MESSAGE,
// "massimiliano.assante",
// "MESSAGEID",
// new Date(),
// "uri",
// "This is notification about a like",
// false,
// "antonio.gioia", "Antonio Gioia",
// "thumburl");
// assertTrue(store.saveNotification(not));
// System.out.println("Writing one Notification " + not);
// }
//
// @Test
// public void testNotifications() {
// Notification not = null;
// System.out.println("Writing 18 Notifications");
// int count = 18;
// for (int i = 0; i < count; i++) {
// if (i % 2 != 0) {
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK,
// "leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl");
// } else {
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK,
// "massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl");
// }
// assertTrue(store.saveNotification(not));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// Notification rNot= null;
// try {
//
// //read
// rNot = store.readNotification(not.getKey().toString());
// assertNotNull(rNot);
// System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
//
// //set Read
// assertTrue(store.setNotificationRead(rNot.getKey().toString()));
//
// System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
//
// not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
// "leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl");
// assertTrue(store.saveNotification(not));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// rNot = store.readNotification(not.getKey().toString());
// System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead());
// // //set Read
// // assertTrue(store.setNotificationRead(rNot.getKey().toString()));
// // System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid());
// //
// Random randomGenerator = new Random();
//
// System.out.println("leonardo.candela Notifications: ");
// List<Notification> recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50));
// assertNotNull(recentNots);
// for (Notification notif :recentNots)
// System.out.println(notif);
//
//
// System.out.println("massimiliano.assante Notifications: ");
// recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
// assertNotNull(recentNots);
// for (Notification notif :recentNots)
// System.out.println(notif);
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// System.out.println("getRangeNotificationsByUser massimiliano.assante: ");
// try {
// int from = 0;
// for (int i = 0; i < 5; i++) {
// System.out.println("\nFROM="+from);
// List<Notification> range = store.getRangeNotificationsByUser("massimiliano.assante", from, 50);
// for (Notification notification : range) {
// System.out.println(notification.getDescription());
// from = 1+i * 50;
// }
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
//
// @Test
// public void testFeeds() {
// int count = 18;
// Feed feed = null;
// for (int i = 0; i < count; i++) {
// if (i % 2 != 0) {
// feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
// } else {
// feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "",
// "www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
// }
// assertTrue(store.saveUserFeed(feed));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// Feed rFeed = null;
// try {
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// assertNotNull(rFeed);
//
// String feedIdToDelete = UUID.randomUUID().toString();
// feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
// try {
// Thread.sleep(250);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// System.out.println("Test Delete Feed ");
// assertTrue(store.deleteFeed(feedIdToDelete));
//
// System.out.println("massimiliano.assante ALL FEEDS: ");
// for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante"))
// System.out.println(recFeed);
// }
// catch (Exception e) {
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_HashtagsCounter, ImmutableMap.<String, Object>builder()
// .put("default_validation_class", "UTF8Type")
// .put("key_validation_class", "UTF8Type")
// .put("comparator_type", "UTF8Type")
// .build());
//
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_HashtagTimeline, ImmutableMap.<String, Object>builder()
// .put("default_validation_class", "UTF8Type")
// .put("key_validation_class", "UTF8Type")
// .put("comparator_type", "UTF8Type")
// .build());
//
// } catch (ConnectionException e) {
// e.printStackTrace();
// }
// }
//
//
//
// @Test
// public void testComments() {
// int count = 10;
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante",
// "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
//
// Comment toDelete = null;
// for (int i = 0; i < count; i++) {
// try {
// toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
// new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
// assertTrue(store.addComment(toDelete));
//
// } catch (FeedIDNotFoundException e) {
// System.out.println("Exception feed id not found");
// }
// }
// System.out.println("GetAllCOmmentsByFeed ");
// for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
// System.out.println(cm.getText());
// };
//
// try {
// assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
// } catch (Exception e) {
// System.out.println("Exception feed id not found");
// }
// }
// private List<String> getKeys() {
// List<String> toReturn = new ArrayList<String>();
// try {
//
// OperationResult<Rows<String, String>> rows = store.getConnection().getKeyspace().prepareQuery(DBCassandraAstyanaxImpl.cf_UserNotificationsPreferences)
// .getAllRows()
// .setRowLimit(1000) // This is the page size
// .execute();
// int i = 1;
// for (Row<String, String> row : rows.getResult()) {
// System.out.println(i+" ROW: " + row.getKey() + " " + row.getColumns().size());
// toReturn.add(row.getKey());
// i++;
// }
// } catch (ConnectionException e) {
// e.printStackTrace();
// }
// return toReturn;
// }
//
// @Test
// public void testUserNotificationPreferences() {
// System.out.println("Notification type" + NotificationType.POST_ALERT.toString() +" OFF for:");
// try {
// for (String user : getKeys()) {
// List<NotificationChannelType> channels = store.getUserNotificationChannels(user, NotificationType.POST_ALERT);
// if (channels.isEmpty()) {
// System.out.println(user);
// }
// else if (! channels.contains(NotificationChannelType.EMAIL)) {
// System.out.println(user + "->" + channels.toString());
// }
// }
// for (NotificationChannelType channel : store.getUserNotificationChannels("roberto.trasarti", NotificationType.POST_ALERT)) {
// System.out.println(channel);
// }
// } catch (NotificationChannelTypeNotFoundException e) {
// e.printStackTrace();
// } catch (NotificationTypeNotFoundException e) {
// e.printStackTrace();
// };
//
// }
// @Test
// public void testLikes() {
// int count = 10;
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "http://www.d4science.org/monitor", "thumbUri", "This feed is Liked ", PrivacyLevel.PUBLIC,
// "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
// Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
// new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
//
// try {
// assertTrue(store.like(toUnlike));
// for (int i = 0; i < count; i++)
// assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
// new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
//
// System.out.println("massimiliano.assante liked the following feeds: ");
// for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
// System.out.println(feedid);
// }
//
// for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
// System.out.println(like);
// }
// System.out.println("massimiliano.assante trying unlike the following feed: " + toUnlike);
// store.unlike("massimiliano.assante", toUnlike.getKey(), toUnlike.getFeedid());
//
// } catch (Exception e) {
// System.out.println("Exception feed id not found");
// }
// }
// /**
// * use exclusively to add a new CF to a keyspace
// */
// @Test
// public void addNotifPreferencesColumnFamily() {
// // ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>(
// // DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
// // StringSerializer.get(), // Key Serializer
// // StringSerializer.get()); // Column Serializer
// //
// // try {
// // new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsPreferences, ImmutableMap.<String, Object>builder()
// // .put("default_validation_class", "UTF8Type")
// // .put("key_validation_class", "UTF8Type")
// // .put("comparator_type", "UTF8Type")
// // .build());
// // } catch (ConnectionException e) {
// // e.printStackTrace();
// // }
// }
//
// @Test
// public void testFriendships() {
// assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
// assertTrue(store.requestFriendship("massimiliano.assante", "ermit"));
// assertTrue(store.requestFriendship("massimiliano.assante", "giorgino"));
// assertTrue(store.requestFriendship("barabba", "massimiliano.assante"));
//
// assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante"));
// assertTrue(store.approveFriendship("ermit", "massimiliano.assante"));
//
// assertTrue(store.denyFriendship("giorgino", "massimiliano.assante"));
// System.out.println("Pending Connections for massimiliano.assante:");
// for (String userid: store.getPendingFriendRequests("massimiliano.assante")) {
// System.out.println(userid);
// }
//
// System.out.println("Connections for massimiliano.assante:");
// for (String userid: store.getFriends("massimiliano.assante")) {
// System.out.println(userid);
// }
//
// }
// @Test
// public void testLikedFeedsRetrieval() {
// try {
// for (Feed feed : store.getAllLikedFeedsByUser("luca.frosini", 10)) {
// System.out.println(feed);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
//
//
//
// @Test
// public void testSingleNotification() {
// Notification not = new Notification(
// UUID.randomUUID().toString(),
// NotificationType.LIKE,
// "leonardo.candela",
// "MESSAGEID",
// new Date(),
// "uri",
// "This is notification about a like",
// false,
// "leonardo.candela", "Leonardo Candela",
// "thumburl");
// assertTrue(store.saveNotification(not));
//
// not = new Notification(
// UUID.randomUUID().toString(),
// NotificationType.MESSAGE,
// "massimiliano.assante",
// "MESSAGEID",
// new Date(),
// "uri",
// "This is notification about a like",
// false,
// "antonio.gioia", "Antonio Gioia",
// "thumburl");
// assertTrue(store.saveNotification(not));
// System.out.println("Writing one Notification " + not);
// }
//
// @Test
// public void testNotifications() {
// Notification not = null;
// System.out.println("Writing 18 Notifications");
// int count = 18;
// for (int i = 0; i < count; i++) {
// if (i % 2 != 0) {
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK,
// "leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl");
// } else {
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK,
// "massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl");
// }
// assertTrue(store.saveNotification(not));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// Notification rNot= null;
// try {
//
// //read
// rNot = store.readNotification(not.getKey().toString());
// assertNotNull(rNot);
// System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
//
// //set Read
// assertTrue(store.setNotificationRead(rNot.getKey().toString()));
//
// System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
//
// not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
// "leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl");
// assertTrue(store.saveNotification(not));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// rNot = store.readNotification(not.getKey().toString());
// System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead());
// // //set Read
// // assertTrue(store.setNotificationRead(rNot.getKey().toString()));
// // System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid());
// //
// Random randomGenerator = new Random();
//
// System.out.println("leonardo.candela Notifications: ");
// List<Notification> recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50));
// assertNotNull(recentNots);
// for (Notification notif :recentNots)
// System.out.println(notif);
//
//
// System.out.println("massimiliano.assante Notifications: ");
// recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
// assertNotNull(recentNots);
// for (Notification notif :recentNots)
// System.out.println(notif);
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// System.out.println("getRangeNotificationsByUser massimiliano.assante: ");
// try {
// int from = 0;
// for (int i = 0; i < 5; i++) {
// System.out.println("\nFROM="+from);
// List<Notification> range = store.getRangeNotificationsByUser("massimiliano.assante", from, 50);
// for (Notification notification : range) {
// System.out.println(notification.getDescription());
// from = 1+i * 50;
// }
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
//
// @Test
// public void testFeeds() {
// int count = 18;
// Feed feed = null;
// for (int i = 0; i < count; i++) {
// if (i % 2 != 0) {
// feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
// } else {
// feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "",
// "www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
// }
// assertTrue(store.saveUserFeed(feed));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// Feed rFeed = null;
// try {
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// assertNotNull(rFeed);
//
// String feedIdToDelete = UUID.randomUUID().toString();
// feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
// try {
// Thread.sleep(250);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// System.out.println("Test Delete Feed ");
// assertTrue(store.deleteFeed(feedIdToDelete));
//
// System.out.println("massimiliano.assante ALL FEEDS: ");
// for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante"))
// System.out.println(recFeed);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
//
//
//
// @Test
// public void testComments() {
// int count = 10;
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante",
// "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
//
// Comment toDelete = null;
// for (int i = 0; i < count; i++) {
// try {
// toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
// new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
// assertTrue(store.addComment(toDelete));
//
// } catch (FeedIDNotFoundException e) {
// System.out.println("Exception feed id not found");
// }
// }
// System.out.println("GetAllCOmmentsByFeed ");
// for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
// System.out.println(cm.getText());
// };
//
// try {
// assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
// } catch (Exception e) {
// System.out.println("Exception feed id not found");
// }
// }
}

View File

@ -23,7 +23,6 @@ import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
/**
* @author Massimiliano Assante ISTI-CNR
*
* @version 1.0 Feb 2013
* <class>DatabookStore</class> is the high level interface for querying and adding data to DatabookStore
*/
public interface DatabookStore {
@ -278,7 +277,7 @@ public interface DatabookStore {
/**
* delete a comment
* @param commentid the comment identifier to delete
* @parma feedid the feedid to shich the comment is associated
* @parma feedid the feedid to which the comment is associated
* @return true if success, false otherwise
*/
boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
@ -292,7 +291,7 @@ public interface DatabookStore {
* unlike a feed
* @param userid user identifier
* @param likeid the like identifier to delete
* @param feedid the feedid to shich the comment is associated
* @param feedid the feedid to which the comment is associated
* @return true if success, false otherwise
*/
boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
@ -317,7 +316,33 @@ public interface DatabookStore {
* return all the likes belonging to the feedid
*/
List<Like> getAllLikesByFeed(String feedid);
/**
*
* @param hashtags the hashtag including the '#'
* @param feedid the feedid to which the hashtag is associated
* @param vreid VRE identifier
* @return true if success, false otherwise
* @throws FeedIDNotFoundException
*/
boolean saveHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
/**
* get a map of vre hashtags where the key is the hashtag and the value is the occurrence of the hashtag in the VRE
* @param vreid vre identifier (scope)
* @return a HashMap<String, Integer> of vre Hashtags associated with their occurrence
*/
Map<String, Integer> getVREHashtagsWithOccurrence(String vreid);
/**
*
* @param vreid VRE identifier
* @param hashtag the hashtag to look for including the '#'
* @throws ColumnNameNotFoundException .
* @throws FeedIDNotFoundException .
* @throws FeedTypeNotFoundException .
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedIDNotFoundException .
* @return all the feeds having the hashtag passed as parameter
*/
List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* close the connection to the underlying database
*/