int layoutId = profile.getLayoutId();
Set incorrectIds = new HashSet();
Set correctIds = new HashSet();
Connection con = RDBMServices.getConnection();
try {
IGroupMember groupPerson = null;
String query1 = "SELECT ULS.FRAGMENT_ID,ULS.NODE_ID,UGF.GROUP_KEY FROM UP_LAYOUT_STRUCT_AGGR ULS,UP_OWNER_FRAGMENT UOF,UP_GROUP_FRAGMENT UGF WHERE "+
"UOF.PUSHED_FRAGMENT='Y' AND ULS.USER_ID="+userId+" AND ULS.LAYOUT_ID="+layoutId+" AND ULS.FRAGMENT_ID=UOF.FRAGMENT_ID AND ULS.FRAGMENT_ID=UGF.FRAGMENT_ID";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query1);
Set groupKeys = new HashSet();
while ( rs.next() ) {
if ( groupPerson == null ) {
EntityIdentifier personIdentifier = person.getEntityIdentifier();
groupPerson = GroupService.getGroupMember(personIdentifier);
}
String nodeId = rs.getInt(2)+"";
String groupKey = rs.getString(3);
if ( !correctIds.contains(nodeId) ) {
boolean isGroupKey = groupKeys.contains(groupKey);
if( !isGroupKey ) {
IEntityGroup group = GroupService.findGroup(groupKey);
if ( group == null || !groupPerson.isDeepMemberOf(group) ) {
if ( !incorrectIds.contains(nodeId) )
incorrectIds.add(nodeId);
groupKeys.add(groupKey);
} else {
correctIds.add(nodeId);