use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class LeaseBuilder method createAddress.
private void createAddress(Lease lease, IAgreementRoleCommunicationChannelType addressType) {
final AgreementRoleType agreementRoleType = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
final AgreementRole agreementRole = lease.findRoleWithType(agreementRoleType, ld(2010, 7, 15));
AgreementRoleCommunicationChannelType agreementRoleCommunicationChannelType = agreementRoleCommunicationChannelTypeRepository.find(addressType);
final SortedSet<CommunicationChannel> channels = communicationChannelRepository.findByOwnerAndType(lease.getSecondaryParty(), CommunicationChannelType.POSTAL_ADDRESS);
final CommunicationChannel postalAddress = channels.first();
agreementRole.addCommunicationChannel(agreementRoleCommunicationChannelType, postalAddress, null);
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel 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);
}
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel 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);
}
use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel 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.commchannel.CommunicationChannel in project estatio by estatio.
the class EmailAddressRepository_IntegTest method setUp.
@Before
public void setUp() throws Exception {
party = OrganisationAndComms_enum.TopModelGb.findUsing(serviceRegistry);
SortedSet<CommunicationChannel> results = communicationChannelRepository.findByOwner(party);
Iterator<CommunicationChannel> it = results.iterator();
while (it.hasNext()) {
CommunicationChannel next = it.next();
if (next.getType() == CommunicationChannelType.EMAIL_ADDRESS) {
emailAddress = (EmailAddress) next;
}
}
Assert.assertThat(emailAddress.getEmailAddress(), is("info@topmodel.example.com"));
}
Aggregations