on 06-11-2014 6:48 PM
Hello, I'm trying to get the users (and their emails) of a collaborator inside a Master Agreement that is type group.
I've tried the following methods:
1- Using a IBeanHomeLocator to get the GroupIBeanHomeIfc (with the static variable of sHOME_NAME) and then trying to get the Group with the DocumentId that the colaborator's method (getDocumentId()) returns and the GroupIBeanHome method findGroup().
The result was null
2 - Using exactly the same method as before, but instead of using the DocumentId, I did a query, in order to get the field USER_GROUP_OBJECT_ID, to get the Id of the group.
The result is still null.
I'm not sure if there is a direct way to get it, or if i'm misusing the GroupIBeanHomeIfc.
Thanks in advance!
Hi Oscar,
In the document collaborator class there is a method getCollaboratorType() which returns CollaboratorTypeEnumType and there are certain values assigned to them.
So, hashcode of 2 returns the group.
Please have a look in to the below code.
collaborators = doc.getCollaborators();
if(collaborators.size() > 0)
{
collabIter = collaborators.iterator();
while (collabIter.hasNext())
{
member = collabIter.next();
collabType= member.getCollaboratorType();
hashValue= collabType.hashCode();
if(hashValue==2)
{
collabName= member.getDisplayName();
throw new ApplicationException("collabName:" +collabName);
}
}
}
In the above code collabName returns the name of the group, with this you can search for the specified group using IbeanHomeLocator for group and then you can get the members in it and their mail Id's
Hope it helps you and let me know if you need any assistance.
Thanks,
Raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Thanks for the answer!
Actually that second part is the one I'm having trouble with (I forgot to mention I already had separated Groups from Users).
Can I get the Group with IBeanHomeLocator with the group's name and not the group's Id?
If so, I'm guessing the code will be something like this?
//Out of Context being collab a collaborator inside the iterator.
if(collab.getCollaboratorType().toString().equals("group")){
GroupIBeanHomeIfc groupHome = IBeanHomeLocator(session,GroupIBeanHomeIfc.sHOME_NAME);
groupName = collab.getDisplayName();
group = groupHome.findGroup(groupName);
}
is that the way to get it using IBeanHomeLocator?
I think that's the part I'm having trouble with.
Thanks in Advance!
Hi oscar,
First you have to get the group name by iterating the collaborators in MA and then you have to go to respective group home, then you have to iterate the members in the group and then you have to create user home and there you will be getting the Email Id's of respective users.
Please see the below code.
collaborators = doc.getCollaborators();
if(collaborators.size() > 0)
{
collabIter = collaborators.iterator();
while (collabIter.hasNext())
{
member = collabIter.next();
collabType= member.getCollaboratorType();
hashValue= collabType.hashCode();
if(hashValue==2)
{
collabName= member.getDisplayName();
groupHome= IBeanHomeLocator.lookup(session,GroupIBeanHomeIfc.sHOME_NAME);
groupBean= groupHome.findGroup(collabName);
groupMemList= groupBean.findGroupMembers();
groupMemItr= groupMemList.iterator();
while(groupMemItr.hasNext())
{
groupMember = groupMemItr.next();
userBeanHome= IBeanHomeLocator.lookup(session, NewUserAccountIBeanHomeIfc.sHOME_NAME);
userBean= userBeanHome.find(groupMember);
userEmail = userBean.getEmail();
//throw new ApplicationException("groupMember:" +userEmail);
}
Please let me know if you need any further assistance.
Thanks,
Raj.
Hello Waldemar,
The below method in group home takes Group ID( String) as input.
GroupIBeanIfc.findGroup(java.lang.String sSearchString)
Find a group using a groupId.
You have to create groups in such a way that Display name equals the External ID
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.