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 Party.DeleteEvent ev) {
Party sourceParty = ev.getSource();
Party replacementParty = ev.getReplacement();
switch(ev.getEventPhase()) {
case VALIDATE:
// We don't care if being deleted
break;
case EXECUTING:
for (CommunicationChannel communicationChannel : communicationChannelRepository.findByOwner(sourceParty)) {
if (replacementParty == null) {
communicationChannel.remove(null);
} else {
communicationChannel.setOwner(replacementParty);
}
}
break;
default:
break;
}
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class Smoke_IntegTest method can_send_email.
@Test
public void can_send_email() throws Exception {
// given
fixtureScripts.runFixtureScript(new CommandDomModule().getTeardownFixtureWillDelete(), null);
fixtureScripts.runFixtureScript(new DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_create(), null);
transactionService.nextTransaction();
// and so given customer with an email
final DemoObjectWithNotes fred = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.FRED_HAS_EMAIL_AND_PHONE).get(0);
final EmailAddress fredEmail = (EmailAddress) linkRepository.findByOwnerAndCommunicationChannelType(fred, CommunicationChannelType.EMAIL_ADDRESS).get(0).getCommunicationChannel();
// and with an invoice
final DemoInvoice fredInvoice = invoiceRepository.findByCustomer(fred).get(0);
// that has an attached document
final Paperclip paperclip = paperclipRepository.findByAttachedTo(fredInvoice).get(0);
final DocumentAbstract document = paperclip.getDocument();
// when
final Document_sendByEmail documentEmail = mixin(Document_sendByEmail.class, document);
final Set<EmailAddress> emailAddresses = documentEmail.choices0Act();
// then
assertThat(emailAddresses).contains(fredEmail);
// and when
// REVIEW: should be wrapped, however the DocumentCommunicationSupportForDocumentsAttachedToInvoiceForLease
// vetoes this, and there is current no way to exclude classes that are not part of the "effective" module
// final Communication comm = wrap(documentEmail).act(fredEmail, null, null, null, null, null);
final Communication comm = documentEmail.act(fredEmail, null, null, null, null, null);
// then
assertThat(comm).isNotNull();
assertThat(comm.getState()).isEqualTo(CommunicationState.PENDING);
assertThat(comm.getCreatedAt()).isNotNull();
assertThat(comm.getType()).isEqualTo(CommunicationChannelType.EMAIL_ADDRESS);
assertThat(comm.getSubject()).isNotNull();
assertThat(comm.getSentAt()).isNull();
final List<CommunicationChannel> correspondentChannels = Lists.newArrayList(comm.getCorrespondents()).stream().map(CommChannelRole::getChannel).filter(Objects::nonNull).collect(Collectors.toList());
assertThat(correspondentChannels).contains(fredEmail);
List<EmailMessage> emailMessages = fakeEmailService.listSentEmails();
assertThat(emailMessages).isEmpty();
List<CommandJdo> commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
assertThat(commands.size()).isEqualTo(1);
// when
fakeScheduler.runBackgroundCommands(5000);
// then
assertThat(comm.getState()).isEqualTo(CommunicationState.SENT);
assertThat(comm.getSentAt()).isNotNull();
emailMessages = fakeEmailService.listSentEmails();
assertThat(emailMessages).isNotEmpty();
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class Smoke_IntegTest method can_create_postal_address.
@Test
public void can_create_postal_address() throws Exception {
// given
fixtureScripts.runFixtureScript(new DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_recreate(), null);
transactionService.nextTransaction();
// and so given customer with an email
final DemoObjectWithNotes mary = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.MARY_HAS_PHONE_AND_POST).get(0);
final PostalAddress maryPost = (PostalAddress) linkRepository.findByOwnerAndCommunicationChannelType(mary, CommunicationChannelType.POSTAL_ADDRESS).get(0).getCommunicationChannel();
// and with an invoice
final DemoInvoice fredInvoice = invoiceRepository.findByCustomer(mary).get(0);
// that has an attached document
final Paperclip paperclip = paperclipRepository.findByAttachedTo(fredInvoice).get(0);
final DocumentAbstract document = paperclip.getDocument();
// when
final Document_sendByPost documentPrint = mixin(Document_sendByPost.class, document);
final Set<PostalAddress> postalAddresses = documentPrint.choices0Act();
// then
assertThat(postalAddresses).contains(maryPost);
// and when
final Communication comm = wrap(documentPrint).act(maryPost);
// then
assertThat(comm).isNotNull();
assertThat(comm.getState()).isEqualTo(CommunicationState.PENDING);
// same as emails
assertThat(comm.getCreatedAt()).isNotNull();
assertThat(comm.getType()).isEqualTo(CommunicationChannelType.POSTAL_ADDRESS);
assertThat(comm.getSubject()).isNotNull();
assertThat(comm.getSentAt()).isNull();
final List<CommunicationChannel> correspondentChannels = Lists.newArrayList(comm.getCorrespondents()).stream().map(CommChannelRole::getChannel).filter(Objects::nonNull).collect(Collectors.toList());
assertThat(correspondentChannels).contains(maryPost);
// when
final Communication_downloadPdfForPosting mixin = mixin(Communication_downloadPdfForPosting.class, comm);
wrap(mixin).act(mixin.default0Act());
// then
assertThat(comm.getState()).isEqualTo(CommunicationState.SENT);
assertThat(comm.getSentAt()).isNotNull();
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class CommunicationChannelImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
List<Object> results = new ArrayList<>();
// Party
final Party party = fetchParty(partyReference);
if (party == null)
throw new ApplicationException(String.format("Party with reference [%s] not found", partyReference));
// Address
if (address1 != null || address2 != null || address3 != null) {
final Country country = countryRepository.findCountry(countryCode);
PostalAddress comm = (PostalAddress) postalAddressRepository.findByAddress(party, address1, address2, address3, postalCode, city, country);
if (comm == null) {
comm = communicationChannelRepository.newPostal(party, CommunicationChannelType.POSTAL_ADDRESS, address1, address2, address3, postalCode, city, stateRepository.findState(stateCode), countryRepository.findCountry(countryCode));
}
if (legal != null && legal) {
comm.setLegal(true);
}
// attach to lease
if (leaseReference != null) {
Lease lease = fetchLease(leaseReference);
if (lease != null && addressType != null) {
final AgreementRoleType art = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
final AgreementRoleCommunicationChannelType arcct = agreementRoleCommunicationChannelTypeRepository.findByTitle(addressType);
lease.findRoleWithType(art, lease.getStartDate()).addCommunicationChannel(arcct, comm, lease.getStartDate());
}
}
}
// Phone
if (phoneNumber != null) {
CommunicationChannel comm = phoneOrFaxNumberRepository.findByPhoneOrFaxNumber(party, phoneNumber);
if (comm == null) {
comm = communicationChannelRepository.newPhoneOrFax(party, CommunicationChannelType.PHONE_NUMBER, phoneNumber);
comm.setReference(leaseReference);
}
}
// Fax
if (faxNumber != null) {
CommunicationChannel comm = phoneOrFaxNumberRepository.findByPhoneOrFaxNumber(party, faxNumber);
if (comm == null) {
comm = communicationChannelRepository.newPhoneOrFax(party, CommunicationChannelType.FAX_NUMBER, faxNumber);
comm.setReference(leaseReference);
}
}
// Email
if (emailAddress != null) {
CommunicationChannel comm = emailAddressRepository.findByEmailAddress(party, emailAddress);
if (comm == null) {
comm = communicationChannelRepository.newEmail(party, CommunicationChannelType.EMAIL_ADDRESS, emailAddress);
comm.setReference(leaseReference);
}
}
return results;
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class AgreementCommunicationChannelLocator method onFile.
@Programmatic
public List<CommunicationChannel> onFile(final Agreement agreement, final String art, final List<CommunicationChannelType> communicationChannelTypes) {
final List<CommunicationChannel> communicationChannels = Lists.newArrayList();
final AgreementRoleType partyInRoleOf = agreementRoleTypeRepository.findByTitle(art);
final SortedSet<AgreementRole> agreementRoles = agreement.getRoles();
for (final AgreementRole role : agreementRoles) {
if (role.getType() == partyInRoleOf) {
final Party party = role.getParty();
final SortedSet<CommunicationChannel> channels = communicationChannelRepository.findByOwner(party);
for (CommunicationChannel channel : channels) {
if (communicationChannelTypes.contains(channel.getType())) {
communicationChannels.add(channel);
}
}
break;
}
}
return communicationChannels;
}
Aggregations