Search in sources :

Example 1 with CommunicationChannel

use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.

the class LeaseBuilder method createAddress.

private void createAddress(Lease lease, IAgreementRoleCommunicationChannelType addressType) {
    final AgreementRoleType agreementRoleType = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
    final AgreementRole agreementRole = lease.findRoleWithType(agreementRoleType, ld(2010, 7, 15));
    AgreementRoleCommunicationChannelType agreementRoleCommunicationChannelType = agreementRoleCommunicationChannelTypeRepository.find(addressType);
    final SortedSet<CommunicationChannel> channels = communicationChannelRepository.findByOwnerAndType(lease.getSecondaryParty(), CommunicationChannelType.POSTAL_ADDRESS);
    final CommunicationChannel postalAddress = channels.first();
    agreementRole.addCommunicationChannel(agreementRoleCommunicationChannelType, postalAddress, null);
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) IAgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Example 2 with CommunicationChannel

use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.

the class LeaseBuilder method addInvoiceAddressForTenant.

private void addInvoiceAddressForTenant(final Lease lease, final Party tenant, final CommunicationChannelType channelType) {
    final AgreementRoleType inRoleOfTenant = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
    final AgreementRoleCommunicationChannelType inRoleOfInvoiceAddress = agreementRoleCommunicationChannelTypeRepository.find(AgreementRoleCommunicationChannelTypeEnum.INVOICE_ADDRESS);
    final List<CommunicationChannelOwnerLink> addressLinks = communicationChannelOwnerLinkRepository.findByOwnerAndCommunicationChannelType(tenant, channelType);
    final Optional<CommunicationChannel> communicationChannelIfAny = addressLinks.stream().map(CommunicationChannelOwnerLink::getCommunicationChannel).findFirst();
    final SortedSet<AgreementRole> roles = lease.getRoles();
    final Optional<AgreementRole> agreementRoleIfAny = Lists.newArrayList(roles).stream().filter(x -> x.getType() == inRoleOfTenant).findFirst();
    if (agreementRoleIfAny.isPresent() && communicationChannelIfAny.isPresent()) {
        final AgreementRole agreementRole = agreementRoleIfAny.get();
        if (!Sets.filter(agreementRole.getCommunicationChannels(), inRoleOfInvoiceAddress.matchingCommunicationChannel()).isEmpty()) {
            // already one set up
            return;
        }
        final CommunicationChannel communicationChannel = communicationChannelIfAny.get();
        agreementRole.addCommunicationChannel(inRoleOfInvoiceAddress, communicationChannel, null, null);
    }
}
Also used : Setter(lombok.Setter) Accessors(lombok.experimental.Accessors) SortedSet(java.util.SortedSet) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) Getter(lombok.Getter) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Lease(org.estatio.module.lease.dom.Lease) BuilderScriptAbstract(org.apache.isis.applib.fixturescripts.BuilderScriptAbstract) VT.ld(org.incode.module.base.integtests.VT.ld) Inject(javax.inject.Inject) AgreementRoleCommunicationChannelTypeEnum(org.estatio.module.lease.dom.AgreementRoleCommunicationChannelTypeEnum) Lists(com.google.common.collect.Lists) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) ToString(lombok.ToString) CommunicationChannelOwnerLink(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink) LeaseAgreementRoleTypeEnum(org.estatio.module.lease.dom.LeaseAgreementRoleTypeEnum) Unit(org.estatio.module.asset.dom.Unit) OccupancyRepository(org.estatio.module.lease.dom.occupancy.OccupancyRepository) CommunicationChannelOwnerLinkRepository(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLinkRepository) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) AgreementRoleCommunicationChannelTypeRepository(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelTypeRepository) Party(org.estatio.module.party.dom.Party) CommunicationChannelType(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType) ApplicationTenancy_enum(org.incode.module.apptenancy.fixtures.enums.ApplicationTenancy_enum) LeaseType(org.estatio.module.lease.dom.LeaseType) AgreementRoleTypeRepository(org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository) Property(org.estatio.module.asset.dom.Property) EqualsAndHashCode(lombok.EqualsAndHashCode) CommunicationChannelRepository(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelRepository) Sets(com.google.common.collect.Sets) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseRepository(org.estatio.module.lease.dom.LeaseRepository) LocalDate(org.joda.time.LocalDate) List(java.util.List) LeaseRoleTypeEnum(org.estatio.module.lease.dom.LeaseRoleTypeEnum) BrandCoverage(org.estatio.module.lease.dom.occupancy.tags.BrandCoverage) Data(lombok.Data) Optional(java.util.Optional) IAgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType) Country(org.incode.module.country.dom.impl.Country) AllArgsConstructor(lombok.AllArgsConstructor) LeaseTypeRepository(org.estatio.module.lease.dom.LeaseTypeRepository) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) IAgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) CommunicationChannelOwnerLink(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Example 3 with CommunicationChannel

use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.

the class InvoiceSummaryForPropertyDueDateStatus_sendAbstract method appendTuplesToSend.

private void appendTuplesToSend(final Invoice invoice, final Predicate<InvoiceAndDocument> filter, final List<InvoiceAndDocument> invoiceAndDocuments) {
    final CommunicationChannel sendTo = invoice.getSendTo();
    if (sendTo == null) {
        return;
    }
    final CommunicationChannelType channelType = sendTo.getType();
    if (channelType != communicationChannelType) {
        return;
    }
    final Document document = findMostRecentAttachedTo(invoice, getDocumentType());
    if (document == null) {
        return;
    }
    if (document.getState() == DocumentState.NOT_RENDERED) {
        return;
    }
    if (invoiceDocAndCommService.findFirstCommunication(document) != null) {
        return;
    }
    final InvoiceAndDocument invoiceAndDocument = new InvoiceAndDocument(invoice, document);
    if (!filter.apply(invoiceAndDocument)) {
        return;
    }
    invoiceAndDocuments.add(invoiceAndDocument);
}
Also used : CommunicationChannelType(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType) Document(org.incode.module.document.dom.impl.docs.Document) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Example 4 with CommunicationChannel

use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel 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 5 with CommunicationChannel

use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.

the class EmailAddressRepository_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.EMAIL_ADDRESS) {
            emailAddress = (EmailAddress) next;
        }
    }
    Assert.assertThat(emailAddress.getEmailAddress(), is("info@topmodel.example.com"));
}
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