Skip to content

Commit

Permalink
Merge pull request #3916 from devgateway/hotfix/v3.5.4.1
Browse files Browse the repository at this point in the history
AMP-30298 fix delete team member
  • Loading branch information
jdeanquin-dg authored Aug 26, 2021
2 parents 9560752 + 127ac4d commit f3261b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions amp/WEB-INF/src/org/digijava/module/aim/util/TeamMemberUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class TeamMemberUtil {
public static User getUserEntityByTMId(Long teamMemberId) {
return getAmpTeamMember(teamMemberId).getUser();
}

public static AmpTeamMember getAmpTeamMemberByUserId(Long userId) {
return (AmpTeamMember) PersistenceManager.getSession()
.createCriteria(AmpTeamMember.class)
Expand All @@ -77,7 +77,7 @@ public static AmpTeamMember getAmpTeamMemberByUserId(Long userId) {
.setMaxResults(1)
.uniqueResult();
}

public static AmpTeamMember getAmpTeamMember(Long id) {
return (AmpTeamMember) PersistenceManager.getSession()
.createCriteria(AmpTeamMember.class)
Expand All @@ -88,7 +88,7 @@ public static AmpTeamMember getAmpTeamMember(Long id) {
.setMaxResults(1)
.uniqueResult();
}

private static LogicalExpression getNotDeletedTeamMemberRestriction() {
return Restrictions.or(Restrictions.eq("deleted", false), Restrictions.isNull("deleted"));
}
Expand Down Expand Up @@ -274,7 +274,7 @@ public static Collection getMembersUsingRole(Long roleId) {

public static List<TeamMember> getAllTeamMembers(Long teamId) {
try {

Session session = PersistenceManager.getSession();
String queryString = "select distinct tm from " + AmpTeamMember.class.getName() + " tm "
+ "where (tm.deleted is null or tm.deleted = false) ";
Expand All @@ -293,7 +293,7 @@ public static List<TeamMember> getAllTeamMembers(Long teamId) {
List<TeamMember> members = new ArrayList<>();
for (AmpTeamMember atm : atms) {
members.add(new TeamMember(atm));

}
Collections.sort((List<TeamMember>) members, new TeamMemberUtil.TeamMemberComparator());

Expand All @@ -302,7 +302,7 @@ public static List<TeamMember> getAllTeamMembers(Long teamId) {
throw new RuntimeException(e);
}
}

public static List<TeamMemberMail> getAllTeamMembersMail(Long teamId) {
try {

Expand Down Expand Up @@ -1164,9 +1164,9 @@ public static void removeTeamMembers(Long id[]) {

Session session = PersistenceManager.getSession();

for (Long anId : id) {
if (anId != null) {
AmpTeamMember ampMember = (AmpTeamMember) session.load(AmpTeamMember.class, anId);
for (Long amId : id) {
if (amId != null) {
AmpTeamMember ampMember = (AmpTeamMember) session.load(AmpTeamMember.class, amId);
if (isTeamLead(ampMember)) {
AmpTeam team = ampMember.getAmpTeam();
team.setTeamLead(null);
Expand All @@ -1175,7 +1175,7 @@ public static void removeTeamMembers(Long id[]) {

String qryStr = "select com from " + AmpComments.class.getName()
+ " com where (com.memberId.ampTeamMemId=:memberId)";
Query qry = session.createQuery(qryStr).setParameter("memberId", anId, LongType.INSTANCE);
Query qry = session.createQuery(qryStr).setParameter("memberId", amId, LongType.INSTANCE);
List<AmpComments> memComments = qry.list();
for (AmpComments comm : memComments) {
comm.setMemberId(null);
Expand All @@ -1184,14 +1184,16 @@ public static void removeTeamMembers(Long id[]) {

qryStr = "select atr from " + AmpAnalyticalReport.class.getName() + " atr "
+ " where (atr.owner=:memberId) ";
qry = session.createQuery(qryStr).setLong("memberId", anId);
qry = session.createQuery(qryStr).setLong("memberId", amId);
List<AmpAnalyticalReport> ampAnalyticalReports = qry.list();
if (ampAnalyticalReports != null && ampAnalyticalReports.size() > 0) {
for (AmpAnalyticalReport ampAnRep : ampAnalyticalReports) {
session.delete(ampAnRep);
}
}

qryStr = "delete AmpDesktopTabSelection dts where dts.owner=:memberId";
qry = session.createQuery(qryStr).setLong("memberId", amId);
qry.executeUpdate();
deleteTeamMember(ampMember);

}
Expand Down
2 changes: 1 addition & 1 deletion amp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.devgateway</groupId>
<artifactId>amp</artifactId>
<version>3.5.4</version>
<version>3.5.4.1</version>
<packaging>war</packaging>
<name>Aid Management Platform</name>
<properties>
Expand Down

0 comments on commit f3261b1

Please sign in to comment.