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);
}
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);
}
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);
}
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();
}
}
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;
}
Aggregations