added new method for users statistics
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@120563 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1f4f753fa8
commit
10518c9d51
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>social-networking-library</artifactId>
|
<artifactId>social-networking-library</artifactId>
|
||||||
<version>1.8.1-SNAPSHOT</version>
|
<version>1.8.2-SNAPSHOT</version>
|
||||||
<name>gCube Social Networking Library</name>
|
<name>gCube Social Networking Library</name>
|
||||||
<description>
|
<description>
|
||||||
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.
|
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.
|
||||||
|
|
|
@ -449,6 +449,44 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
public List<Feed> getRecentFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException {
|
||||||
|
Date now = new Date();
|
||||||
|
if (timeInMillis > now.getTime())
|
||||||
|
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||||
|
|
||||||
|
OperationResult<Rows<String, String>> result = null;
|
||||||
|
try {
|
||||||
|
result = conn.getKeyspace().prepareQuery(cf_UserTline)
|
||||||
|
.getKeySlice(userid)
|
||||||
|
.execute();
|
||||||
|
} catch (ConnectionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
List<Feed> toReturn = new ArrayList<Feed>();
|
||||||
|
// Iterate rows and their columns
|
||||||
|
for (Row<String, String> row : result.getResult()) {
|
||||||
|
for (Column<String> column : row.getColumns()) {
|
||||||
|
long feedTime = Long.parseLong(column.getName());
|
||||||
|
if (feedTime > timeInMillis) {
|
||||||
|
try {
|
||||||
|
Feed toCheck = readFeed(column.getStringValue());
|
||||||
|
if (toCheck.getType() != FeedType.DISABLED)
|
||||||
|
toReturn.add(toCheck);
|
||||||
|
} catch (PrivacyLevelTypeNotFoundException
|
||||||
|
| FeedTypeNotFoundException
|
||||||
|
| FeedIDNotFoundException
|
||||||
|
| ColumnNameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public boolean deleteFeed(String feedId) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
|
public boolean deleteFeed(String feedId) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
|
||||||
Feed toDelete = readFeed(feedId);
|
Feed toDelete = readFeed(feedId);
|
||||||
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
|
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
|
||||||
|
@ -2130,4 +2168,5 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
package org.gcube.portal.databook.server;
|
package org.gcube.portal.databook.server;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.Invite;
|
|
||||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
|
||||||
import org.gcube.portal.databook.shared.InviteStatus;
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -26,31 +22,42 @@ public class DatabookCassandraTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvites() {
|
public void testFeedNumberPerUser() {
|
||||||
String controlCode = UUID.randomUUID().toString();
|
String userid = "massimiliano.assante";
|
||||||
String vreid = "/gcube/devsec/devVRE";
|
//String userid = "costantino.perciante";
|
||||||
String email = "ciccio@gmail.com";
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.add(Calendar.YEAR, -1);
|
||||||
InviteStatus statusToLookfor = InviteStatus.ACCEPTED;
|
Date now = new Date();
|
||||||
|
System.out.println(store.getRecentFeedsByUserAndDate(userid, cal.getTimeInMillis()).size());
|
||||||
Invite invite = new Invite(UUID.randomUUID().toString(), "andrea.rossi", vreid, email, controlCode, InviteStatus.PENDING, new Date(), "Andrea Rossi");
|
System.out.println(new Date().getTime() - now.getTime()+"ms");
|
||||||
try {
|
|
||||||
InviteOperationResult result = store.saveInvite(invite);
|
|
||||||
System.out.println(result);
|
|
||||||
String inviteid = store.isExistingInvite(vreid, email);
|
|
||||||
// System.out.println(store.readInvite(inviteid));
|
|
||||||
// store.setInviteStatus(vreid, email, InviteStatus.ACCEPTED);
|
|
||||||
// System.out.println(store.readInvite(inviteid));
|
|
||||||
System.out.println("Looking for all invites in " + vreid + " with status " + statusToLookfor);
|
|
||||||
List<Invite> invites = store.getInvitedEmailsByVRE(vreid, statusToLookfor, InviteStatus.PENDING);
|
|
||||||
for (Invite invite2 : invites) {
|
|
||||||
System.out.println(invite2);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// @Test
|
||||||
|
// public void testInvites() {
|
||||||
|
// String controlCode = UUID.randomUUID().toString();
|
||||||
|
// String vreid = "/gcube/devsec/devVRE";
|
||||||
|
// String email = "ciccio@gmail.com";
|
||||||
|
//
|
||||||
|
// InviteStatus statusToLookfor = InviteStatus.ACCEPTED;
|
||||||
|
//
|
||||||
|
// Invite invite = new Invite(UUID.randomUUID().toString(), "andrea.rossi", vreid, email, controlCode, InviteStatus.PENDING, new Date(), "Andrea Rossi");
|
||||||
|
// try {
|
||||||
|
// InviteOperationResult result = store.saveInvite(invite);
|
||||||
|
// System.out.println(result);
|
||||||
|
// String inviteid = store.isExistingInvite(vreid, email);
|
||||||
|
//// System.out.println(store.readInvite(inviteid));
|
||||||
|
//// store.setInviteStatus(vreid, email, InviteStatus.ACCEPTED);
|
||||||
|
//// System.out.println(store.readInvite(inviteid));
|
||||||
|
// System.out.println("Looking for all invites in " + vreid + " with status " + statusToLookfor);
|
||||||
|
// List<Invite> invites = store.getInvitedEmailsByVRE(vreid, statusToLookfor, InviteStatus.PENDING);
|
||||||
|
// for (Invite invite2 : invites) {
|
||||||
|
// System.out.println(invite2);
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
// public void testHashTag() {
|
// public void testHashTag() {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.portal.databook.server;
|
package org.gcube.portal.databook.server;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -158,6 +159,12 @@ public interface DatabookStore {
|
||||||
* @throws ColumnNameNotFoundException
|
* @throws ColumnNameNotFoundException
|
||||||
*/
|
*/
|
||||||
RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||||
|
/**
|
||||||
|
* @param userid user identifier
|
||||||
|
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
|
||||||
|
* @return the number of feeds in the range from: today to: timeInMillis
|
||||||
|
*/
|
||||||
|
List<Feed> getRecentFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
|
||||||
/**
|
/**
|
||||||
* save a Notification instance in the store
|
* save a Notification instance in the store
|
||||||
* @return true if everything went fine
|
* @return true if everything went fine
|
||||||
|
|
Loading…
Reference in New Issue