Search in sources :

Example 1 with Communication

use of org.incode.module.communications.dom.impl.comms.Communication in project estatio by estatio.

the class CommunicationChannelSubscription_Integtest method replacement_provided.

@Test
public void replacement_provided() throws Exception {
    // Given
    final DemoObjectWithNotes owner = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.FRED_HAS_EMAIL_AND_PHONE).get(0);
    final PostalAddress postalAddress = communicationChannelRepository.newPostal(owner, CommunicationChannelType.POSTAL_ADDRESS, "Some address", null, null, null, null, null, null);
    final PostalAddress replaceWith = communicationChannelRepository.newPostal(owner, CommunicationChannelType.POSTAL_ADDRESS, "Replacement Address", null, null, null, null, null, null);
    final Communication communication = communicationRepository.createPostal("Subject", "/", postalAddress);
    final int size = communicationChannelRepository.findByOwner(owner).size();
    // When
    wrapperFactory.wrap(postalAddress).remove(replaceWith);
    // Then
    Assertions.assertThat(communicationChannelRepository.findByOwner(owner).size()).isEqualTo(size - 1);
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes) Communication(org.incode.module.communications.dom.impl.comms.Communication) Test(org.junit.Test)

Example 2 with Communication

use of org.incode.module.communications.dom.impl.comms.Communication in project estatio by estatio.

the class CommunicationChannelSubscription_Integtest method validate_fails_when_no_replacement_is_provided.

@Test
public void validate_fails_when_no_replacement_is_provided() throws Exception {
    // Given
    final DemoObjectWithNotes owner = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.FRED_HAS_EMAIL_AND_PHONE).get(0);
    final PostalAddress postalAddress = communicationChannelRepository.newPostal(owner, CommunicationChannelType.POSTAL_ADDRESS, "Some address", null, null, null, null, null, null);
    final Communication communication = communicationRepository.createPostal("Subject", "/", postalAddress);
    // Expect
    expectedExceptions.expectMessage("Communication channel is being used");
    // When
    wrap(postalAddress).remove(null);
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes) Communication(org.incode.module.communications.dom.impl.comms.Communication) Test(org.junit.Test)

Example 3 with Communication

use of org.incode.module.communications.dom.impl.comms.Communication in project estatio by estatio.

the class Invoice_DocumentManagement_IntegTest method sendToFor.

<T extends CommunicationChannel> T sendToFor(final Invoice invoice, final Class<T> communicationChannelClass) {
    final CommunicationChannel sendTo = invoice.getSendTo();
    if (communicationChannelClass.isAssignableFrom(sendTo.getClass())) {
        return communicationChannelClass.cast(sendTo);
    }
    final List<CommunicationChannel> communicationChannels = mixin(InvoiceForLease_overrideSendTo.class, invoice).choices0$$();
    final Optional<CommunicationChannel> commChannelIfAny = communicationChannels.stream().filter(x -> communicationChannelClass.isAssignableFrom(x.getClass())).findFirst();
    if (!commChannelIfAny.isPresent()) {
        throw new IllegalStateException("could not locate communication channel of type " + communicationChannelClass.getSimpleName());
    }
    final CommunicationChannel communicationChannel = commChannelIfAny.get();
    wrap(mixin(InvoiceForLease_overrideSendTo.class, invoice)).$$(communicationChannel);
    return communicationChannelClass.cast(communicationChannel);
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) DocumentAbstract(org.incode.module.document.dom.impl.docs.DocumentAbstract) Invoice(org.estatio.module.invoice.dom.Invoice) URL(java.net.URL) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Percentage(org.assertj.core.data.Percentage) DocAndCommForInvoiceDoc(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) Assertions(org.assertj.core.api.Assertions) HiddenException(org.apache.isis.applib.services.wrapper.HiddenException) CommunicationState(org.incode.module.communications.dom.impl.comms.CommunicationState) InvoiceForLease_attachSupportingDocument(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_attachSupportingDocument) BookmarkService2(org.apache.isis.applib.services.bookmark.BookmarkService2) Blob(org.apache.isis.applib.value.Blob) DocumentTypeData(org.estatio.module.invoice.dom.DocumentTypeData) DocAndCommForPrelimLetter_communicationState(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter_communicationState) PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Party(org.estatio.module.party.dom.Party) DocumentSort(org.incode.module.document.dom.impl.docs.DocumentSort) DocAndCommForInvoiceDoc_document(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc_document) InvoiceForLease_overrideSendTo(org.estatio.module.lease.dom.invoicing.InvoiceForLease_overrideSendTo) DocAndCommForInvoiceDoc_communicationState(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc_communicationState) Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Communication(org.incode.module.communications.dom.impl.comms.Communication) InvoiceStatus(org.estatio.module.invoice.dom.InvoiceStatus) Invoice_ForLease_preliminaryLetters(org.estatio.module.lease.dom.invoicing.summary.comms.Invoice_ForLease_preliminaryLetters) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) Paperclip_changeRole(org.incode.module.document.dom.impl.paperclips.Paperclip_changeRole) Invoice_invoiceDocs(org.estatio.module.lease.dom.invoicing.summary.comms.Invoice_invoiceDocs) LeaseRepository(org.estatio.module.lease.dom.LeaseRepository) DocAndCommForPrelimLetter_document(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter_document) List(java.util.List) TransactionService(org.apache.isis.applib.services.xactn.TransactionService) InvoiceForLease_enum(org.estatio.module.lease.fixtures.invoice.enums.InvoiceForLease_enum) LeaseModuleIntegTestAbstract(org.estatio.module.lease.integtests.LeaseModuleIntegTestAbstract) InvoiceForLease_sendByPost(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByPost) Optional(java.util.Optional) DocAndCommForPrelimLetter(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter) FixtureScript(org.apache.isis.applib.fixturescripts.FixtureScript) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) Document(org.incode.module.document.dom.impl.docs.Document) Lease(org.estatio.module.lease.dom.Lease) EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress) DocumentState(org.incode.module.document.dom.impl.docs.DocumentState) InvoiceForLease_prepare(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_prepare) Inject(javax.inject.Inject) DocumentTemplateRepository(org.incode.module.document.dom.impl.docs.DocumentTemplateRepository) InvoiceRepository(org.estatio.module.invoice.dom.InvoiceRepository) InvoiceForLeaseRepository(org.estatio.module.lease.dom.invoicing.InvoiceForLeaseRepository) Document_delete(org.incode.module.document.dom.impl.docs.Document_delete) PaperclipRoleNames(org.estatio.module.lease.dom.invoicing.comms.PaperclipRoleNames) Before(org.junit.Before) PartyRepository(org.estatio.module.party.dom.PartyRepository) InvoiceForLease_sendByEmail(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByEmail) ClockService(org.apache.isis.applib.services.clock.ClockService) PaperclipRepository(org.incode.module.document.dom.impl.paperclips.PaperclipRepository) Resources(com.google.common.io.Resources) DocumentTypesAndTemplatesForLeaseFixture(org.estatio.module.lease.seed.DocumentTypesAndTemplatesForLeaseFixture) DocumentTypeRepository(org.incode.module.document.dom.impl.types.DocumentTypeRepository) DocAndCommForPrelimLetter_documentState(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter_documentState) IOException(java.io.IOException) Test(org.junit.Test) DocAndCommForInvoiceDoc_documentState(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc_documentState) LocalDate(org.joda.time.LocalDate) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) DocAndCommForPrelimLetter_communication(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForPrelimLetter_communication) Ignore(org.junit.Ignore) DocAndCommForInvoiceDoc_communication(org.estatio.module.lease.dom.invoicing.summary.comms.DocAndCommForInvoiceDoc_communication) InvoiceForLease_overrideSendTo(org.estatio.module.lease.dom.invoicing.InvoiceForLease_overrideSendTo) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Example 4 with Communication

use of org.incode.module.communications.dom.impl.comms.Communication in project estatio by estatio.

the class SuppressContributionsForCoverNoteDocument method hideIfCoverNote.

private void hideIfCoverNote(final org.apache.isis.applib.services.eventbus.ActionDomainEvent<?> ev) {
    if (ev.getEventPhase() != AbstractDomainEvent.Phase.HIDE) {
        return;
    }
    final Object mixedIn = ev.getMixedIn();
    if (!(mixedIn instanceof Document)) {
        return;
    }
    final Document document = (Document) mixedIn;
    final Communication communication = evaluator.coverNoteFor(document);
    if (communication != null) {
        ev.hide();
    }
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) Communication(org.incode.module.communications.dom.impl.comms.Communication)

Example 5 with Communication

use of org.incode.module.communications.dom.impl.comms.Communication in project estatio by estatio.

the class CommunicationChannelOwner_findCommunications method act.

@Action(semantics = SemanticsOf.SAFE, domainEvent = ActionDomainEvent.class)
public List<Communication> act(final LocalDate from, final LocalDate to) {
    final DateTime fromDateTime = toDateTime(from);
    final DateTime toDateTime = toDateTime(to).plusDays(1);
    final List<CommunicationChannelOwnerLink> channelLinks = communicationChannelRepository.findByOwner(communicationChannelOwner);
    final List<Communication> communications = Lists.newArrayList();
    for (final CommunicationChannelOwnerLink link : channelLinks) {
        final List<Communication> comms = communicationRepository.findByCommunicationChannelAndPendingOrCreatedAtBetween(link.getCommunicationChannel(), fromDateTime, toDateTime);
        communications.addAll(comms);
    }
    communications.sort(Communication.Orderings.createdAtDescending);
    return communications;
}
Also used : DateTime(org.joda.time.DateTime) Communication(org.incode.module.communications.dom.impl.comms.Communication) Action(org.apache.isis.applib.annotation.Action)

Aggregations

Communication (org.incode.module.communications.dom.impl.comms.Communication)11 Test (org.junit.Test)5 PostalAddress (org.incode.module.communications.dom.impl.commchannel.PostalAddress)4 Document (org.incode.module.document.dom.impl.docs.Document)4 DemoObjectWithNotes (org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes)4 Action (org.apache.isis.applib.annotation.Action)3 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)2 CommChannelRole (org.incode.module.communications.dom.impl.comms.CommChannelRole)2 DocumentAbstract (org.incode.module.document.dom.impl.docs.DocumentAbstract)2 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)2 DemoInvoice (org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice)2 Resources (com.google.common.io.Resources)1 IOException (java.io.IOException)1 URL (java.net.URL)1 List (java.util.List)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 FixtureScript (org.apache.isis.applib.fixturescripts.FixtureScript)1