Search in sources :

Example 6 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<AgreementRoleCommunicationChannel> communicationChannels;
    switch(ev.getEventPhase()) {
        case VALIDATE:
            communicationChannels = agreementRoleCommunicationChannelRepository.findByCommunicationChannel(sourceCommunicationChannel);
            if (communicationChannels.size() > 0 && replacementCommunicationChannel == null) {
                ev.invalidate("Communication channel is being used: provide a replacement");
            } else {
                scratchpad.put(onCommunicationChannelRemoveScratchpadKey = UUID.randomUUID(), communicationChannels);
            }
            break;
        case EXECUTING:
            communicationChannels = (List<AgreementRoleCommunicationChannel>) scratchpad.get(onCommunicationChannelRemoveScratchpadKey);
            for (AgreementRoleCommunicationChannel arcc : communicationChannels) {
                arcc.setCommunicationChannel(replacementCommunicationChannel);
            }
            break;
        default:
            break;
    }
}
Also used : AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 7 with CommunicationChannel

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

the class PartyDtoFactory method newDto.

@Programmatic
public PartyDto newDto(final Party party) {
    PartyDto dto = new PartyDto();
    dto.setSelf(mappingHelper.oidDtoFor(party));
    dto.setName(party.getName());
    dto.setReference(party.getReference());
    final SortedSet<CommunicationChannel> postalAddresses = communicationChannelRepository.findByOwnerAndType(party, CommunicationChannelType.POSTAL_ADDRESS);
    final Optional<CommunicationChannel> postalAddressIfAny = postalAddresses.stream().filter(x -> x.isLegal()).findFirst();
    if (postalAddressIfAny.isPresent()) {
        dto.setLegalPostalAddress(mappingHelper.oidDtoFor(postalAddressIfAny.get()));
    }
    return dto;
}
Also used : Inject(javax.inject.Inject) NatureOfService(org.apache.isis.applib.annotation.NatureOfService) Party(org.estatio.module.party.dom.Party) SortedSet(java.util.SortedSet) DtoMappingHelper(org.apache.isis.applib.services.dto.DtoMappingHelper) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) CommunicationChannelType(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType) Optional(java.util.Optional) PartyDto(org.estatio.canonical.party.v1.PartyDto) DomainService(org.apache.isis.applib.annotation.DomainService) CommunicationChannelRepository(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelRepository) Programmatic(org.apache.isis.applib.annotation.Programmatic) PartyDto(org.estatio.canonical.party.v1.PartyDto) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 8 with CommunicationChannel

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

the class CommunicationChannelSubscriptions method on.

@Subscribe
public void on(final CommunicationChannel.RemoveEvent ev) {
    CommunicationChannel sourceCommunicationChannel = ev.getSource();
    CommunicationChannel replacementCommunicationChannel = ev.getReplacement();
    switch(ev.getEventPhase()) {
        case VALIDATE:
            final List<Communication> communications = communicationRepository.findByCommunicationChannel(sourceCommunicationChannel);
            if (communications.size() > 0 && replacementCommunicationChannel == null) {
                ev.invalidate("Communication channel is being used in a communication: provide a replacement");
            }
            break;
        case EXECUTING:
            for (Communication comm : communicationRepository.findByCommunicationChannel(sourceCommunicationChannel)) {
                for (CommChannelRole commChannelRole : comm.getCorrespondents()) {
                    if (commChannelRole.getChannel().equals(sourceCommunicationChannel)) {
                        commChannelRole.setChannel(replacementCommunicationChannel);
                    }
                }
            }
            break;
        default:
            break;
    }
}
Also used : CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Subscribe(com.google.common.eventbus.Subscribe)

Example 9 with CommunicationChannel

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

the class AgreementCommunicationChannelLocator method current.

@Programmatic
public List<CommunicationChannel> current(final Agreement agreement, final String art, final String arcct, final List<CommunicationChannelType> communicationChannelTypes) {
    final List<CommunicationChannel> communicationChannels = Lists.newArrayList();
    final AgreementRoleType partyInRoleOf = agreementRoleTypeRepository.findByTitle(art);
    final AgreementRoleCommunicationChannelType commChannelInRoleOf = agreementRoleCommunicationChannelTypeRepository.findByTitle(arcct);
    final SortedSet<AgreementRole> agreementRoles = agreement.getRoles();
    for (final AgreementRole role : agreementRoles) {
        if (role.getType() == partyInRoleOf) {
            final SortedSet<AgreementRoleCommunicationChannel> rolesOfChannels = role.getCommunicationChannels();
            for (AgreementRoleCommunicationChannel roleOfChannel : rolesOfChannels) {
                if (roleOfChannel.getType() == commChannelInRoleOf) {
                    final CommunicationChannel communicationChannel = roleOfChannel.getCommunicationChannel();
                    if (roleOfChannel.isCurrent() && communicationChannelTypes.contains(communicationChannel.getType())) {
                        communicationChannels.add(communicationChannel);
                    }
                }
            }
        }
    }
    return communicationChannels;
}
Also used : AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 10 with CommunicationChannel

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

the class DocumentCommunicationSupportForDocumentsAttachedToInvoiceForLease method addTo.

private <T extends CommunicationChannel> void addTo(final InvoiceForLease invoice, final CommHeaderAbstract<T> header, final CommunicationChannelType channelType) {
    final Lease lease = invoice.getLease();
    // current choice(s) and default
    final List current = locator.current(lease, LeaseAgreementRoleTypeEnum.TENANT.getTitle(), AgreementRoleCommunicationChannelTypeEnum.INVOICE_ADDRESS.getTitle(), channelType);
    header.getToChoices().addAll(current);
    final CommunicationChannel sendTo = invoice.getSendTo();
    if (sendTo != null && sendTo.getType() == channelType) {
        header.setToDefault((T) sendTo);
    } else {
        header.setToDefault((T) firstIfAny(current));
    }
    // additional choices (those on file)
    final List onFile = locator.onFile(lease, LeaseAgreementRoleTypeEnum.TENANT.getTitle(), channelType);
    header.getToChoices().addAll(onFile);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) List(java.util.List) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

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