public boolean addUserToTeam ( final UserPrincipal user , final Team team ) { List < Team > teams = user . getTeams ( ) ; boolean found = false ; if ( teams == null ) { teams = new ArrayList <> ( ) ; } for ( final Team t : teams ) { if ( team . getUuid ( ) . equals ( t . getUuid ( ) ) ) { found = true ; } } if ( ! found ) { pm . currentTransaction ( ) . begin ( ) ; teams . add ( team ) ; user . setTeams ( teams ) ; pm . currentTransaction ( ) . commit ( ) ; return true ; } return false ; }
Associates a UserPrincipal to a Team .