Reputation: 3848
I need to iterate over users list in groups list and if users list has the group(from group list) I need remove that from users list. I tried the following but its not working
def groupsList = entity.companyContainer.groups
groupsList.each { g ->
g.users.each { u ->
if( u.groups.find( g ) ) {
u.groups.remove( g )
entityService.update( u )
}
}
entityService.delete(g)
}
Exception:
ERROR | com.core.common.controller.impl.BaseMultiActionController | groovy.lang.MissingMethodException:
No signature of method:
com.core.configuration.persistence.ListWithPersistentSetPropertyAccessor$ListWithPersistentSet.find()
is applicable for argument types: (com.core.security.model.impl.Group) values: [LFO Super Users_Lawfirm]
Possible solutions: find(groovy.lang.Closure),
find(groovy.lang.Closure),
min(),
min(groovy.lang.Closure),
min(java.util.Comparator),
size()
Upvotes: 0
Views: 1061
Reputation: 50245
Although I am not clear about the full context of the logic but you can get what you need using find{}
as a closure operation as below:
def groupsList = entity.companyContainer.groups
groupsList.each{ g ->
g.users.each {u ->
if(u.groups.find{it.id == g.id}) {
u.groups.remove(g)
entityService.update(u)
}
}
entityService.delete(g)
}
Upvotes: 1