support for invites invites management alpha version is complete
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@115627 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d211f7f879
commit
004e2cec2b
|
@ -1,9 +1,12 @@
|
|||
#Tue Dec 04 18:04:58 CET 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
|
|
|
@ -1660,6 +1660,20 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* helper method that retrieve all the Invites belonging to a list of Ids
|
||||
* @param inviteIds the lisf of invites UUID
|
||||
* @return all the invites belonging to a list of Ids
|
||||
* @throws InviteIDNotFoundException
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
private List<Invite> getInvitesById(List<String> inviteIds) throws InviteIDNotFoundException, InviteStatusNotFoundException {
|
||||
ArrayList<Invite> toReturn = new ArrayList<Invite>();
|
||||
for (String inviteid : inviteIds)
|
||||
toReturn.add(readInvite(inviteid));
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws InviteStatusNotFoundException
|
||||
|
@ -1689,24 +1703,39 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Invite> getAllInvitedEmailsByVRE(String vreid) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public List<Invite> getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException{
|
||||
OperationResult<Rows<String, String>> result = null;
|
||||
try {
|
||||
result = conn.getKeyspace().prepareQuery(cf_VREInvites)
|
||||
.getKeySlice(vreid)
|
||||
.execute();
|
||||
} catch (ConnectionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Invite> getPendingInvitedEmailsByVRE(String vreid) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
ArrayList<String> invitesIds = new ArrayList<String>();
|
||||
// Iterate rows and their columns
|
||||
for (Row<String, String> row : result.getResult()) {
|
||||
if (status != null) {
|
||||
for (Column<String> column : row.getColumns()) {
|
||||
for (int i = 0; i < status.length; i++) {
|
||||
if (column.getStringValue().compareTo(status[i].toString())==0)
|
||||
invitesIds.add(column.getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Column<String> column : row.getColumns())
|
||||
invitesIds.add(column.getName());
|
||||
}
|
||||
}
|
||||
return getInvitesById(invitesIds);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
/*
|
||||
*
|
||||
|
@ -1790,19 +1819,21 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
* @throws TypeNotFoundException .
|
||||
*/
|
||||
private InviteStatus getInviteStatusType(String type) throws InviteStatusNotFoundException {
|
||||
if (type.compareTo("PENDING") == 0) {
|
||||
switch (type) {
|
||||
case "PENDING":
|
||||
return InviteStatus.PENDING;
|
||||
}
|
||||
else if (type.compareTo("ACCEPTED") == 0) {
|
||||
case "ACCEPTED":
|
||||
return InviteStatus.ACCEPTED;
|
||||
}
|
||||
else if (type.compareTo("REJECTED") == 0) {
|
||||
case "REJECTED":
|
||||
return InviteStatus.REJECTED;
|
||||
}
|
||||
else
|
||||
case "RETRACTED":
|
||||
return InviteStatus.RETRACTED;
|
||||
default:
|
||||
throw new InviteStatusNotFoundException("The Invite Status was not recognized should be one of " + InviteStatus.values() + " asked for: " + type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* simply return an enum representing the feed type
|
||||
* @param type .
|
||||
|
|
|
@ -58,15 +58,23 @@ public class DatabookCassandraTest {
|
|||
public void testInvites() {
|
||||
String controlCode = UUID.randomUUID().toString();
|
||||
String vreid = "/gcube/devsec/devVRE";
|
||||
String email = "m.assante@gmail.com";
|
||||
Invite invite = new Invite(UUID.randomUUID().toString(), "massimiliano.assante", vreid, email, controlCode, InviteStatus.PENDING, new Date(), "Massimiliano Assante");
|
||||
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(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();
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ public interface DatabookStore {
|
|||
/**
|
||||
* read an invite from a given id
|
||||
* @throws InviteIDNotFoundException
|
||||
* @throws InviteIDNotFoundException
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
|
@ -385,13 +385,14 @@ public interface DatabookStore {
|
|||
*/
|
||||
boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
* return the list of invites
|
||||
* @param vreid
|
||||
* @return
|
||||
* Use to get the list of invites per VRE
|
||||
* @param vreid the vre id
|
||||
* @param status optional, if you want to restict on the status, e.g. all pending invites
|
||||
* @return return the list of invites
|
||||
* @throws InviteIDNotFoundException
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
List<Invite> getAllInvitedEmailsByVRE(String vreid);
|
||||
|
||||
List<Invite> getPendingInvitedEmailsByVRE(String vreid);
|
||||
List<Invite> getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
* close the connection to the underlying database
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
public enum InviteStatus {
|
||||
/**
|
||||
* First status of anyh invite
|
||||
*/
|
||||
PENDING,
|
||||
/**
|
||||
* User accepted the invite
|
||||
*/
|
||||
ACCEPTED,
|
||||
REJECTED;
|
||||
/**
|
||||
* User rejected the invite
|
||||
*/
|
||||
REJECTED,
|
||||
/**
|
||||
* Manager withdrawed the invite
|
||||
*/
|
||||
RETRACTED;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue