Search in sources :

Example 1 with CommunicationChannelType

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

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

use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType 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)

Aggregations

CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)3 CommunicationChannelType (org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType)3 List (java.util.List)2 Inject (javax.inject.Inject)2 CommunicationChannelOwnerLink (org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink)2 CommunicationChannelOwnerLinkRepository (org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLinkRepository)2 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Optional (java.util.Optional)1 SortedSet (java.util.SortedSet)1 Collectors (java.util.stream.Collectors)1 AllArgsConstructor (lombok.AllArgsConstructor)1 Data (lombok.Data)1 EqualsAndHashCode (lombok.EqualsAndHashCode)1 Getter (lombok.Getter)1 Setter (lombok.Setter)1 ToString (lombok.ToString)1 Accessors (lombok.experimental.Accessors)1 DomainService (org.apache.isis.applib.annotation.DomainService)1 NatureOfService (org.apache.isis.applib.annotation.NatureOfService)1