Search in sources :

Example 11 with CommunicationChannel

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;
    }
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 12 with CommunicationChannel

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);
}
Also used : Party(org.estatio.module.party.dom.Party) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress) Test(org.junit.Test)

Example 13 with CommunicationChannel

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);
}
Also used : NatureOfService(org.apache.isis.applib.annotation.NatureOfService) DocumentType(org.incode.module.document.dom.impl.types.DocumentType) PaperclipRepository(org.incode.module.document.dom.impl.paperclips.PaperclipRepository) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) CommunicationChannelType(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType) Document(org.incode.module.document.dom.impl.docs.Document) DocumentTypeRepository(org.incode.module.document.dom.impl.types.DocumentTypeRepository) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes) CommHeaderForEmail(org.incode.module.communications.dom.spi.CommHeaderForEmail) DomainService(org.apache.isis.applib.annotation.DomainService) CommHeaderAbstract(org.incode.module.communications.dom.spi.CommHeaderAbstract) Collectors(java.util.stream.Collectors) DocumentType_and_DocumentTemplates_createSome(org.incode.platform.dom.communications.integtests.dom.communications.fixture.data.doctypes.DocumentType_and_DocumentTemplates_createSome) Inject(javax.inject.Inject) List(java.util.List) DemoInvoice(org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice) CommunicationChannelOwnerLink(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink) DocumentCommunicationSupport(org.incode.module.communications.dom.spi.DocumentCommunicationSupport) CommunicationChannelOwnerLinkRepository(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLinkRepository) CommHeaderForPost(org.incode.module.communications.dom.spi.CommHeaderForPost) List(java.util.List) CommunicationChannelOwnerLink(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes)

Example 14 with CommunicationChannel

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"));
}
Also used : CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Before(org.junit.Before)

Example 15 with CommunicationChannel

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"));
}
Also used : CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Before(org.junit.Before)

Aggregations

CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)21 Programmatic (org.apache.isis.applib.annotation.Programmatic)8 Party (org.estatio.module.party.dom.Party)7 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)5 List (java.util.List)4 Inject (javax.inject.Inject)4 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)4 AgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType)4 Lease (org.estatio.module.lease.dom.Lease)4 CommunicationChannelType (org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType)4 Before (org.junit.Before)4 Optional (java.util.Optional)3 AgreementRoleCommunicationChannel (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel)3 Document (org.incode.module.document.dom.impl.docs.Document)3 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)3 DemoObjectWithNotes (org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes)3 DemoInvoice (org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice)3 Test (org.junit.Test)3 SortedSet (java.util.SortedSet)2 DomainService (org.apache.isis.applib.annotation.DomainService)2