Manager scrtMngr = ManagerFactory.getManager();
ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
// two named ContactLists, the new way using the contact form
// the same name as in the checkboxes are taken as contactlist names
ContactList ownerCntctLst;// = new ContactList(translate("sendtochooser.form.chckbx.owners"));
ContactList partipCntctLst;// = new ContactList(translate("sendtochooser.form.chckbx.partip"));
ContactList waitingListContactList;// = new ContactList(translate("sendtochooser.form.chckbx.waitingList"));
if (flags.isEnabled(BGConfigFlags.GROUP_OWNERS)) {
if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.all"));
SecurityGroup owners = businessGroup.getOwnerGroup();
List<Identity> ownerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
ownerCntctLst.addAllIdentites(ownerList);
cmsg.addEmailTo(ownerCntctLst);
} else {
if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.choose"));
SecurityGroup owners = businessGroup.getOwnerGroup();
List<Identity> ownerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
List<Identity> changeableOwnerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
for (Identity identity : ownerList) {
boolean keyIsSelected = false;
for (Long key : sendToChooserForm.getSelectedOwnerKeys()) {
if (key.equals(identity.getKey())) {
keyIsSelected = true;
break;
}
}
if (!keyIsSelected) {
changeableOwnerList.remove(changeableOwnerList.indexOf(identity));
}
}
ownerCntctLst.addAllIdentites(changeableOwnerList);
cmsg.addEmailTo(ownerCntctLst);
}
}
}
if (sendToChooserForm != null) {
if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
partipCntctLst = new ContactList(translate("sendtochooser.form.radio.partip.all"));
SecurityGroup participants = businessGroup.getPartipiciantGroup();
List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
partipCntctLst.addAllIdentites(participantsList);
cmsg.addEmailTo(partipCntctLst);
} else {
if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
partipCntctLst = new ContactList(translate("sendtochooser.form.radio.partip.choose"));
SecurityGroup participants = businessGroup.getPartipiciantGroup();
List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
List<Identity> changeableParticipantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
for (Identity identity : participantsList) {
boolean keyIsSelected = false;
for (Long key : sendToChooserForm.getSelectedPartipKeys()) {
if (key.equals(identity.getKey())) {
keyIsSelected = true;
break;
}
}
if (!keyIsSelected) {
changeableParticipantsList.remove(changeableParticipantsList.indexOf(identity));
}
}
partipCntctLst.addAllIdentites(changeableParticipantsList);
cmsg.addEmailTo(partipCntctLst);
}
}
}
if (sendToChooserForm != null && isAdmin && businessGroup.getWaitingListEnabled().booleanValue()) {
if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.all"));
SecurityGroup waitingList = businessGroup.getWaitingGroup();
List<Identity> waitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
waitingListContactList.addAllIdentites(waitingListIdentities);
cmsg.addEmailTo(waitingListContactList);
} else {
if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.choose"));
SecurityGroup waitingList = businessGroup.getWaitingGroup();
List<Identity> waitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
List<Identity> changeableWaitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
for (Identity indentity : waitingListIdentities) {
boolean keyIsSelected = false;
for (Long key : sendToChooserForm.getSelectedWaitingKeys()) {
if (key.equals(indentity.getKey())) {
keyIsSelected = true;
break;
}
}
if (!keyIsSelected) {
changeableWaitingListIdentities.remove(changeableWaitingListIdentities.indexOf(indentity));
}
}
waitingListContactList.addAllIdentites(changeableWaitingListIdentities);
cmsg.addEmailTo(waitingListContactList);
}
}
}