Search in sources :

Example 1 with AgreementRoleCommunicationChannel

use of org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel 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 2 with AgreementRoleCommunicationChannel

use of org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel 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)

Aggregations

Programmatic (org.apache.isis.applib.annotation.Programmatic)2 AgreementRoleCommunicationChannel (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel)2 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)2 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)1 AgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType)1 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)1