Skip to content

OBGM-493 Unable to assign user's role for specific location manually#4111

Merged
kchelstowski merged 1 commit intofeature/upgrade-to-grails-3.3.10from
OBGM-493
Jun 19, 2023
Merged

OBGM-493 Unable to assign user's role for specific location manually#4111
kchelstowski merged 1 commit intofeature/upgrade-to-grails-3.3.10from
OBGM-493

Conversation

@alannadolny
Copy link
Collaborator

No description provided.

import javax.imageio.ImageIO as IIO
import javax.swing.*
import grails.gorm.transactions.Transactional
import java.util.List
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error
GroovyCastException: Cannot cast object '[Requestor]' with class 'java.util.ArrayList' to class 'java.awt.List' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.awt.List(org.pih.warehouse.core.Role)
was caused by the fact that we used List from java.awt instead of java.util

Copy link
Collaborator

@awalkowiak awalkowiak Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alannadolny You should remove the import java.awt.* instead of adding import java.util.List

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there's no reason for us to have the wildcard imports (javax.swing.* and java.awt.*). Looks like it was from the original migration.

@kchelstowski This should not have been merged without removing that import. So please make sure there are at least two approvals (or @awalkowiak or @jmiranda has a chance to review before merging).

Copy link
Collaborator

@kchelstowski kchelstowski Jun 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmiranda I have not noticed this has not been removed. The reason I merged it alone, was that in the morning Katarzyna had problem with obdev3 not working and we thought a merge could help, before Artur is online (he starts work later than us). I wouldn't have merged it if it hadn't been the case. Sorry about that.

@kchelstowski kchelstowski merged commit 9698080 into feature/upgrade-to-grails-3.3.10 Jun 19, 2023
@kchelstowski kchelstowski deleted the OBGM-493 branch June 19, 2023 06:43
Copy link
Member

@jmiranda jmiranda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not have been merged.

import javax.imageio.ImageIO as IIO
import javax.swing.*
import grails.gorm.transactions.Transactional
import java.util.List
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there's no reason for us to have the wildcard imports (javax.swing.* and java.awt.*). Looks like it was from the original migration.

@kchelstowski This should not have been merged without removing that import. So please make sure there are at least two approvals (or @awalkowiak or @jmiranda has a chance to review before merging).

List<Role> roles = params.list("role.id").collect { roleId -> Role.get(roleId) }

// Update existing role
LocationRole locationRole = LocationRole.get(params.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably ok for now, but we should be careful about how we refactor these actions. I don't actually know what the original code is trying to do (I'm to blame as the original author) so adding a method with a bunch of arguments might not be the right solution.

In order to refactor properly

  1. We need to be very thoughtful about what the interface / API is supposed to be doing here. For example, are we trying to do multiple actions? If so, maybe we need multiple methods.
  2. Maybe think about passing each param separately and loading objects in the service that way we're doing all reading / writing in the same Hibernate session.

cc @awalkowiak @alannadolny @kchelstowski

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to consider the return value for new service methods. Again this is why I'd prefer to leave controllers alone unless we have very straightforward refactorings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import was removed in the PR mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants