@Atomic public static Boolean run( FinalDegreeWorkGroup group, String groupProposalOID, Integer orderOfPreference) { check(RolePredicates.STUDENT_PREDICATE); GroupProposal groupProposal = FenixFramework.getDomainObject(groupProposalOID); if (group != null && groupProposal != null) { for (GroupProposal otherGroupProposal : group.getGroupProposalsSet()) { if (otherGroupProposal != null && !groupProposal.getExternalId().equals(otherGroupProposal.getExternalId())) { int otherOrderOfPreference = otherGroupProposal.getOrderOfPreference().intValue(); if (orderOfPreference.intValue() <= otherOrderOfPreference && groupProposal.getOrderOfPreference().intValue() > otherOrderOfPreference) { otherGroupProposal.setOrderOfPreference(new Integer(otherOrderOfPreference + 1)); } else if (orderOfPreference.intValue() >= otherOrderOfPreference && groupProposal.getOrderOfPreference().intValue() < otherOrderOfPreference) { otherGroupProposal.setOrderOfPreference(new Integer(otherOrderOfPreference - 1)); } } } groupProposal.setOrderOfPreference(orderOfPreference); } return true; }