Skip to content

Commit

Permalink
fixed gap in conflict check. close #2179
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Nov 5, 2023
1 parent ea73a2b commit c1fa9e3
Showing 1 changed file with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ You should also get your employer (if you work as a programmer) or school,
import java.awt.Window;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.List;
import javax.swing.JDialog;
import javax.swing.JFrame;
Expand All @@ -691,9 +691,9 @@ public class ConflictOfInterestUtils {

private static final Logger log=Logger.getLogger(ConflictOfInterestUtils.class.getName());

public static void checkForConflicts(AddressBean address, PartyTypeBean selectedType, Window parent) {
public static void checkForConflicts(AddressBean address, PartyTypeBean requestedType, String requestedCaseId, Window parent) {

if(address==null || selectedType==null || parent==null) {
if(address==null || requestedType==null || parent==null) {

return;
}
Expand All @@ -703,11 +703,11 @@ public static void checkForConflicts(AddressBean address, PartyTypeBean selected
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
ArchiveFileServiceRemote afRem = locator.lookupArchiveFileServiceRemote();
Collection col = afRem.getArchiveFileAddressesForAddress(address.getId());
Hashtable<PartyTypeBean, List<ArchiveFileBean>> casesWithDifferentPartyType=new Hashtable<>();
HashMap<PartyTypeBean, List<ArchiveFileBean>> casesWithDifferentPartyType=new HashMap<>();
ArrayList<String> caseIds=new ArrayList<>();
for (Object o : col) {
ArchiveFileAddressesBean afb = (ArchiveFileAddressesBean) o;
if (!(afb.getReferenceType().getId().equals(selectedType.getId()))) {
if (!(afb.getReferenceType().getId().equals(requestedType.getId()))) {
if(!(casesWithDifferentPartyType.containsKey(afb.getReferenceType())))
casesWithDifferentPartyType.put(afb.getReferenceType(), new ArrayList<>());

Expand All @@ -719,22 +719,34 @@ public static void checkForConflicts(AddressBean address, PartyTypeBean selected
}
}

boolean conflict=false;

// if caseIds.size = 1 that is okay - the person is in different roles, but within the same case
if(casesWithDifferentPartyType.size()>0 && caseIds.size()>1) {
if(!casesWithDifferentPartyType.isEmpty() && caseIds.size()>1) {
conflict=true;
} else if(caseIds.size()==1 && !caseIds.contains(requestedCaseId)) {
// party requested for different case and party only present in one case currently - check whether it is requested for a different type
for(PartyTypeBean p: casesWithDifferentPartyType.keySet()) {
if(!(p.equals(requestedType))) {
conflict=true;
break;
}
}
}

if(conflict) {
ConflictOfInterestDialog dlg=null;
if(parent instanceof JDialog) {
dlg=new ConflictOfInterestDialog((JDialog)parent, true, address, selectedType, casesWithDifferentPartyType);
dlg=new ConflictOfInterestDialog((JDialog)parent, true, address, requestedType, casesWithDifferentPartyType);
} else if(parent instanceof JFrame) {
dlg=new ConflictOfInterestDialog((JFrame)parent, true, address, selectedType, casesWithDifferentPartyType);
dlg=new ConflictOfInterestDialog((JFrame)parent, true, address, requestedType, casesWithDifferentPartyType);
}
if(dlg != null) {
FrameUtils.centerDialog(dlg, parent);
dlg.setVisible(true);
} else {
log.error("unknown parent type for ConflictOfInterestDialog");
}

}

} catch (Exception ex) {
Expand Down

0 comments on commit c1fa9e3

Please sign in to comment.