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<Invoice> notYetInvoiced;
List<Invoice> alreadyInvoiced;
switch(ev.getEventPhase()) {
case VALIDATE:
List<Invoice> invoices = invoiceRepository.findBySendTo(sourceCommunicationChannel);
notYetInvoiced = invoices.stream().filter(invoice -> invoice.getInvoiceNumber() == null).collect(Collectors.toList());
alreadyInvoiced = invoices.stream().filter(invoice -> invoice.getInvoiceNumber() != null).collect(Collectors.toList());
scratchpad.put("notYetInvoiced", notYetInvoiced);
scratchpad.put("alreadyInvoiced", alreadyInvoiced);
// (it doesn't matter if no replacement was provided only for already-invoiced invoices)
if (replacementCommunicationChannel == null && !notYetInvoiced.isEmpty()) {
ev.invalidate(TranslatableString.tr("Communication channel is being used (as the 'sendTo' channel for {num} invoice(s); " + "provide a replacement", "num", notYetInvoiced.size()));
}
break;
case EXECUTING:
notYetInvoiced = (List<Invoice>) scratchpad.get("notYetInvoiced");
alreadyInvoiced = (List<Invoice>) scratchpad.get("alreadyInvoiced");
for (Invoice invoice : notYetInvoiced) {
invoice.setSendTo(replacementCommunicationChannel);
}
for (Invoice invoice : alreadyInvoiced) {
if (invoice.getInvoiceNumber() != null) {
// just blank out
invoice.setSendTo(null);
}
}
break;
default:
break;
}
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class CommunicationChannelContributions_NewEmail_IntegTest method happyCase.
@Test
public void happyCase() throws Exception {
final Party party = fs.getObject();
// given
final SortedSet<CommunicationChannel> before = communicationChannelContributions.communicationChannels(party);
Assertions.assertThat(before).isEmpty();
// when
final String emailAddress = "bar@foo.com";
wrap(communicationChannelContributions).newEmail(party, CommunicationChannelType.EMAIL_ADDRESS, emailAddress);
// then
final SortedSet<CommunicationChannel> after = communicationChannelContributions.communicationChannels(party);
Assertions.assertThat(after).hasSize(1);
final CommunicationChannel communicationChannel = after.first();
Assertions.assertThat(communicationChannel).isInstanceOf(EmailAddress.class);
Assertions.assertThat(((EmailAddress) communicationChannel).getEmailAddress()).isEqualTo(emailAddress);
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class DocumentCommunicationSupportForDocumentsAttachedToDemoInvoice method addTo.
private <T extends CommunicationChannel> void addTo(final DemoInvoice invoice, final CommHeaderAbstract<T> header, final CommunicationChannelType channelType) {
final DemoObjectWithNotes customer = invoice.getCustomer();
final List<CommunicationChannelOwnerLink> links = communicationChannelOwnerLinkRepository.findByOwner(customer);
final List channels = links.stream().map(CommunicationChannelOwnerLink::getCommunicationChannel).filter(cc -> cc.getType() == channelType).collect(Collectors.toList());
header.getToChoices().addAll(channels);
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class PhoneOrFaxNumberRepository_IntegTest method setUp.
@Before
public void setUp() throws Exception {
party = OrganisationAndComms_enum.TopModelGb.findUsing(serviceRegistry);
SortedSet<CommunicationChannel> results = communicationChannelRepository.findByOwner(party);
Iterator<CommunicationChannel> it = results.iterator();
while (it.hasNext()) {
CommunicationChannel next = it.next();
if (next.getType() == CommunicationChannelType.PHONE_NUMBER) {
phoneOrFaxNumber = (PhoneOrFaxNumber) next;
}
}
Assert.assertThat(phoneOrFaxNumber.getPhoneNumber(), is("+31202211333"));
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class PostalAddressRepository_IntegTest method setUp.
@Before
public void setUp() throws Exception {
party = OrganisationAndComms_enum.TopModelGb.findUsing(serviceRegistry);
SortedSet<CommunicationChannel> results = communicationChannelRepository.findByOwner(party);
Iterator<CommunicationChannel> it = results.iterator();
while (it.hasNext()) {
CommunicationChannel next = it.next();
if (next.getType() == CommunicationChannelType.POSTAL_ADDRESS) {
postalAddress = (PostalAddress) next;
}
}
Assert.assertThat(postalAddress.getAddress1(), is("1 Circle Square"));
Assert.assertThat(postalAddress.getPostalCode(), is("W2AXXX"));
}
Aggregations