use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel 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.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class PartyDtoFactory method newDto.
@Programmatic
public PartyDto newDto(final Party party) {
PartyDto dto = new PartyDto();
dto.setSelf(mappingHelper.oidDtoFor(party));
dto.setName(party.getName());
dto.setReference(party.getReference());
final SortedSet<CommunicationChannel> postalAddresses = communicationChannelRepository.findByOwnerAndType(party, CommunicationChannelType.POSTAL_ADDRESS);
final Optional<CommunicationChannel> postalAddressIfAny = postalAddresses.stream().filter(x -> x.isLegal()).findFirst();
if (postalAddressIfAny.isPresent()) {
dto.setLegalPostalAddress(mappingHelper.oidDtoFor(postalAddressIfAny.get()));
}
return dto;
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class CommunicationChannelSubscriptions method on.
@Subscribe
public void on(final CommunicationChannel.RemoveEvent ev) {
CommunicationChannel sourceCommunicationChannel = ev.getSource();
CommunicationChannel replacementCommunicationChannel = ev.getReplacement();
switch(ev.getEventPhase()) {
case VALIDATE:
final List<Communication> communications = communicationRepository.findByCommunicationChannel(sourceCommunicationChannel);
if (communications.size() > 0 && replacementCommunicationChannel == null) {
ev.invalidate("Communication channel is being used in a communication: provide a replacement");
}
break;
case EXECUTING:
for (Communication comm : communicationRepository.findByCommunicationChannel(sourceCommunicationChannel)) {
for (CommChannelRole commChannelRole : comm.getCorrespondents()) {
if (commChannelRole.getChannel().equals(sourceCommunicationChannel)) {
commChannelRole.setChannel(replacementCommunicationChannel);
}
}
}
break;
default:
break;
}
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel 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;
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class DocumentCommunicationSupportForDocumentsAttachedToInvoiceForLease method addTo.
private <T extends CommunicationChannel> void addTo(final InvoiceForLease invoice, final CommHeaderAbstract<T> header, final CommunicationChannelType channelType) {
final Lease lease = invoice.getLease();
// current choice(s) and default
final List current = locator.current(lease, LeaseAgreementRoleTypeEnum.TENANT.getTitle(), AgreementRoleCommunicationChannelTypeEnum.INVOICE_ADDRESS.getTitle(), channelType);
header.getToChoices().addAll(current);
final CommunicationChannel sendTo = invoice.getSendTo();
if (sendTo != null && sendTo.getType() == channelType) {
header.setToDefault((T) sendTo);
} else {
header.setToDefault((T) firstIfAny(current));
}
// additional choices (those on file)
final List onFile = locator.onFile(lease, LeaseAgreementRoleTypeEnum.TENANT.getTitle(), channelType);
header.getToChoices().addAll(onFile);
}
Aggregations