@Atomic public static ActionError run(String selectedGroupProposalOID) throws FenixServiceException { final GroupProposal groupProposal = FenixFramework.getDomainObject(selectedGroupProposalOID); if (groupProposal != null) { final Proposal proposal = groupProposal.getFinalDegreeWorkProposal(); final FinalDegreeWorkGroup group = groupProposal.getFinalDegreeDegreeWorkGroup(); if (proposal != null && group != null) { final Proposal proposalAttributedToGroup = group.getProposalAttributedByTeacher(); if (proposalAttributedToGroup != null && proposalAttributedToGroup != proposal) { return new ActionError( "error.message.GroupAlreadyAttributed", proposalAttributedToGroup.getProposalNumber()); } if (proposal.getGroupAttributedByTeacher() == null || proposal.getGroupAttributedByTeacher() != group) { proposal.setGroupAttributedByTeacher(group); for (GroupProposal otherGroupProposal : group.getGroupProposalsSet()) { Proposal otherProposal = otherGroupProposal.getFinalDegreeWorkProposal(); if (otherProposal != proposal && group == otherProposal.getGroupAttributedByTeacher()) { otherProposal.setGroupAttributedByTeacher(null); } } } else { proposal.setGroupAttributedByTeacher(null); } } } return null; }
@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; }