use of org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel in project estatio by estatio.
the class CommunicationChannelSubscriptions method on.
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final CommunicationChannel.RemoveEvent ev) {
CommunicationChannel sourceCommunicationChannel = ev.getSource();
CommunicationChannel replacementCommunicationChannel = ev.getReplacement();
List<AgreementRoleCommunicationChannel> communicationChannels;
switch(ev.getEventPhase()) {
case VALIDATE:
communicationChannels = agreementRoleCommunicationChannelRepository.findByCommunicationChannel(sourceCommunicationChannel);
if (communicationChannels.size() > 0 && replacementCommunicationChannel == null) {
ev.invalidate("Communication channel is being used: provide a replacement");
} else {
scratchpad.put(onCommunicationChannelRemoveScratchpadKey = UUID.randomUUID(), communicationChannels);
}
break;
case EXECUTING:
communicationChannels = (List<AgreementRoleCommunicationChannel>) scratchpad.get(onCommunicationChannelRemoveScratchpadKey);
for (AgreementRoleCommunicationChannel arcc : communicationChannels) {
arcc.setCommunicationChannel(replacementCommunicationChannel);
}
break;
default:
break;
}
}
use of org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel in project estatio by estatio.
the class AgreementCommunicationChannelLocator method current.
@Programmatic
public List<CommunicationChannel> current(final Agreement agreement, final String art, final String arcct, final List<CommunicationChannelType> communicationChannelTypes) {
final List<CommunicationChannel> communicationChannels = Lists.newArrayList();
final AgreementRoleType partyInRoleOf = agreementRoleTypeRepository.findByTitle(art);
final AgreementRoleCommunicationChannelType commChannelInRoleOf = agreementRoleCommunicationChannelTypeRepository.findByTitle(arcct);
final SortedSet<AgreementRole> agreementRoles = agreement.getRoles();
for (final AgreementRole role : agreementRoles) {
if (role.getType() == partyInRoleOf) {
final SortedSet<AgreementRoleCommunicationChannel> rolesOfChannels = role.getCommunicationChannels();
for (AgreementRoleCommunicationChannel roleOfChannel : rolesOfChannels) {
if (roleOfChannel.getType() == commChannelInRoleOf) {
final CommunicationChannel communicationChannel = roleOfChannel.getCommunicationChannel();
if (roleOfChannel.isCurrent() && communicationChannelTypes.contains(communicationChannel.getType())) {
communicationChannels.add(communicationChannel);
}
}
}
}
}
return communicationChannels;
}
Aggregations