sergiogonzalez/liferay-portal — pull request #332 by matethurzo (2012-08-30 12:02:01+00:00)
Title: LPS-23964 Polls portlet fix for vote user ids

Hey Sergio,

This is the polls portlet fix we were discussing. After some consideration I've concluded in this solution for the following reasons.

There are four scenarios when importing a vote:

- The user id in the vote represents a valid user
- we are using the CURRENT_USER_ID strategy. This means that the correct id will be used for that specific user - the vote will be imported correctly
- we are using the ALWAYS_CURRENT_USER_ID strategy. This means that no matter what the current user's id will be used which will always cause data loss if there are more then one votes due to the duplicate votes
- The user id in the vote is either anonymous or belongs to a user that is no more present in the system
- with CURRENT_USER_ID strategy this will fall back to the current user's id, due to duplicates we will lose data
- with the ALWAYS_CURRENT_USER_ID strategy is effectively is the same: it will use the current user's id, we will lose data

So after all from this 4 scenario the only valid scenario is the first, in every other case we will lose data. So after all I've decided that no matter of the user id strategy the user id in the vote should be used to create the new polls vote record. If the user is valid then a user name will be displayed to that id when checking the vote results, if it's just an id then an id will be shown anyway.

We could not eliminate the user id strategy for the polls portlet though since we use the user id strategy for creating the question for example. Now the user id strategy won't be effective for the PollsVote entity itself.

Thanks,

Mate