use of org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType 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.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType 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.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType 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;
}
use of org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType 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;
}
Aggregations