removal of local participants that is not available at remote system now works for opponents and active participations as well.
This commit is contained in:
parent
9bdd50215a
commit
186706136c
src/main/java/se/su/dsv/scipro
data
dao
dataobjects
io/facade
@ -5,6 +5,7 @@ package se.su.dsv.scipro.data.dao.interfaces;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarActiveParticipation;
|
import se.su.dsv.scipro.data.dataobjects.FinalSeminarActiveParticipation;
|
||||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||||
import se.su.dsv.scipro.data.dataobjects.User;
|
import se.su.dsv.scipro.data.dataobjects.User;
|
||||||
@ -18,6 +19,7 @@ import se.su.dsv.scipro.data.dataobjects.User;
|
|||||||
public interface FinalSeminarActiveParticipationDao extends Dao<FinalSeminarActiveParticipation>{
|
public interface FinalSeminarActiveParticipationDao extends Dao<FinalSeminarActiveParticipation>{
|
||||||
|
|
||||||
public List<FinalSeminarActiveParticipation> findParticipationsByUserAndProject(final User user, final Project project);
|
public List<FinalSeminarActiveParticipation> findParticipationsByUserAndProject(final User user, final Project project);
|
||||||
|
public List<FinalSeminarActiveParticipation> findParticipationsByUserAndProject(final User user, final Project project, final FinalSeminar fs);
|
||||||
public int countParticipationsByProjectAndStudent(final Project project, final User user);
|
public int countParticipationsByProjectAndStudent(final Project project, final User user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import org.springframework.stereotype.Repository;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarActiveParticipationDao;
|
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarActiveParticipationDao;
|
||||||
|
import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarActiveParticipation;
|
import se.su.dsv.scipro.data.dataobjects.FinalSeminarActiveParticipation;
|
||||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||||
import se.su.dsv.scipro.data.dataobjects.User;
|
import se.su.dsv.scipro.data.dataobjects.User;
|
||||||
@ -53,6 +54,31 @@ public class FinalSeminarActiveParticipationDaoJPAImp extends AbstractDaoJPAImp
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public List<FinalSeminarActiveParticipation> findParticipationsByUserAndProject(final User user, final Project project, final FinalSeminar finalSeminar){
|
||||||
|
return getJpaTemplate().execute(new JpaCallback<List<FinalSeminarActiveParticipation>>() {
|
||||||
|
public List<FinalSeminarActiveParticipation> doInJpa(EntityManager em)
|
||||||
|
throws PersistenceException {
|
||||||
|
String q = "select ap " +
|
||||||
|
"from FinalSeminarActiveParticipation ap " +
|
||||||
|
"where ap.user = :user " +
|
||||||
|
"and ap.project = :project " +
|
||||||
|
"and ap.finalSeminar = :finalSeminar";
|
||||||
|
|
||||||
|
TypedQuery<FinalSeminarActiveParticipation> query = em.createQuery(q, FinalSeminarActiveParticipation.class);
|
||||||
|
query.setParameter("user", user);
|
||||||
|
query.setParameter("project", project);
|
||||||
|
query.setParameter("finalSeminar", finalSeminar);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return query.getResultList();
|
||||||
|
} catch (NoResultException e) {
|
||||||
|
return new ArrayList<FinalSeminarActiveParticipation>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public int countParticipationsByProjectAndStudent(final Project project, final User user){
|
public int countParticipationsByProjectAndStudent(final Project project, final User user){
|
||||||
return getJpaTemplate().execute(new JpaCallback<Integer>() {
|
return getJpaTemplate().execute(new JpaCallback<Integer>() {
|
||||||
|
@ -35,7 +35,18 @@ public class Member implements Serializable {
|
|||||||
return "Co-Supervisor";
|
return "Co-Supervisor";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
OPPONENT {
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Opponent";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ACTIVE_PARTICIPANT {
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Active Participant";
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
public Member(User user, Type type) {
|
public Member(User user, Type type) {
|
||||||
|
@ -212,7 +212,20 @@ public class ImporterFacade {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void checkForRemovedMembers(final Project project, final Set<ProjectParticipantDTO> participants) {
|
private void checkForRemovedMembers(final Project project, final Set<ProjectParticipantDTO> participants) {
|
||||||
final List<Member> currentMembers = project.getMembers();
|
//Get project team members.
|
||||||
|
final Set<Member> currentMembers = new HashSet<Member>(project.getMembers());
|
||||||
|
final List<FinalSeminar> fsList = finalSeminarDao.findFinalSeminarsByProject(project);
|
||||||
|
//Get opponents and active participants as well.
|
||||||
|
if(!fsList.isEmpty()){
|
||||||
|
for(FinalSeminar fs : fsList) {
|
||||||
|
for(FinalSeminarOpposition opp : fs.getOppositions()){
|
||||||
|
currentMembers.add(new Member(opp.getUser(), Member.Type.OPPONENT));
|
||||||
|
}
|
||||||
|
for(FinalSeminarActiveParticipation ap : fs.getActiveParticipations()){
|
||||||
|
currentMembers.add(new Member(ap.getUser(), Member.Type.ACTIVE_PARTICIPANT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
final Set<ProjectParticipantDTO> remoteMembers = new HashSet<ProjectParticipantDTO>(participants);
|
final Set<ProjectParticipantDTO> remoteMembers = new HashSet<ProjectParticipantDTO>(participants);
|
||||||
final Set<Member> membersToRemove = new HashSet<Member>();
|
final Set<Member> membersToRemove = new HashSet<Member>();
|
||||||
//Check to see if some members of the projects have been removed from Daisy. If so, we need to remove from Scipro as well.
|
//Check to see if some members of the projects have been removed from Daisy. If so, we need to remove from Scipro as well.
|
||||||
@ -261,8 +274,31 @@ public class ImporterFacade {
|
|||||||
logger.debug("Can't find project follower to remove.");
|
logger.debug("Can't find project follower to remove.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OPPONENT: {
|
||||||
|
for (FinalSeminar fs : fsList) {
|
||||||
|
List<FinalSeminarOpposition> oppList = finalSeminarOppositionDao.findOppositionsByUserAndProject(m.getUser(), project, fs);
|
||||||
|
for (FinalSeminarOpposition opp : oppList) {
|
||||||
|
if(fs.getOppositions().contains(opp)){
|
||||||
|
finalSeminarOppositionDao.delete(opp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ACTIVE_PARTICIPANT: {
|
||||||
|
for (FinalSeminar fs : fsList) {
|
||||||
|
List<FinalSeminarActiveParticipation> apList = finalSeminarActiveParticipationDao.findParticipationsByUserAndProject(m.getUser(), project, fs);
|
||||||
|
for (FinalSeminarActiveParticipation ap: apList) {
|
||||||
|
if(fs.getActiveParticipations().contains(ap))
|
||||||
|
finalSeminarActiveParticipationDao.delete(ap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private ProjectParticipantDTO participantDtoFromMember(Member m) {
|
private ProjectParticipantDTO participantDtoFromMember(Member m) {
|
||||||
ProjectParticipantDTO dto = new ProjectParticipantDTO();
|
ProjectParticipantDTO dto = new ProjectParticipantDTO();
|
||||||
@ -289,6 +325,15 @@ public class ImporterFacade {
|
|||||||
dto.setRole(EXTERNAL_PROJECT_ROLE.ASSISTANT_SUPERVISOR.toLocal().name());
|
dto.setRole(EXTERNAL_PROJECT_ROLE.ASSISTANT_SUPERVISOR.toLocal().name());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OPPONENT:
|
||||||
|
{
|
||||||
|
dto.setRole(EXTERNAL_PROJECT_ROLE.OPPONENT.toLocal().name());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ACTIVE_PARTICIPANT:
|
||||||
|
{
|
||||||
|
dto.setRole(EXTERNAL_PROJECT_ROLE.ACTIVE_PARTICIPATION.name());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user