use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.
the class PartySubscriptions method on.
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.DeleteEvent ev) {
Party sourceParty = (Party) ev.getSource();
Party replacementParty = ev.getReplacement();
List<AgreementRole> agreementRoles;
switch(ev.getEventPhase()) {
case VALIDATE:
agreementRoles = agreementRoleRepository.findByParty(sourceParty);
if (replacementParty == null && agreementRoles.size() > 0) {
ev.invalidate("Party is being used in an agreement role: remove roles or provide a replacement");
} else {
scratchpad.put(onPartyRemoveScratchpadKey = UUID.randomUUID(), agreementRoles);
}
break;
case EXECUTING:
agreementRoles = (List<AgreementRole>) scratchpad.get(onPartyRemoveScratchpadKey);
for (AgreementRole agreementRole : agreementRoles) {
agreementRole.setParty(replacementParty);
}
break;
default:
break;
}
}
use of org.estatio.module.agreement.dom.AgreementRole 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.AgreementRole in project estatio by estatio.
the class Lease method disableNewMandate.
public String disableNewMandate() {
final AgreementRole tenantRole = getSecondaryAgreementRole();
if (tenantRole == null || !tenantRole.isCurrent()) {
return "Could not determine the tenant (secondary party) of this lease";
}
final List<? extends FinancialAccount> validBankAccounts = existingBankAccountsForTenant();
if (validBankAccounts.isEmpty()) {
return "There are no bank accounts available for this tenant";
}
return null;
}
use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.
the class Lease method existingBankMandatesForTenant.
@SuppressWarnings({ "unchecked", "rawtypes" })
private List<BankMandate> existingBankMandatesForTenant() {
final AgreementRole tenantRole = getSecondaryAgreementRole();
if (tenantRole == null || !tenantRole.isCurrent()) {
return Collections.emptyList();
}
final Party tenant = partyOf(tenantRole);
final AgreementType bankMandateAgreementType = bankMandateAgreementType();
final AgreementRoleType debtorRoleType = debtorRoleType();
return (List) agreementRepository.findByAgreementTypeAndRoleTypeAndParty(bankMandateAgreementType, debtorRoleType, tenant);
}
use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.
the class PartyBankAccountsAndMandatesDtoFactory method newDto.
@Programmatic
public BankAccountsAndMandatesDto newDto(final Party party) {
final BankAccountsAndMandatesDto dto = new BankAccountsAndMandatesDto();
final List<FinancialAccount> financialAccountList = financialAccountRepository.findAccountsByTypeOwner(FinancialAccountType.BANK_ACCOUNT, party);
final List<BankAccountDto> bankAccountDtos = financialAccountList.stream().map(x -> bankAccountDtoFactory.newDto((BankAccount) x)).collect(Collectors.toList());
dto.setBankAccounts(bankAccountDtos);
final AgreementType bankMandateAt = agreementTypeRepository.find(BankMandateAgreementTypeEnum.MANDATE);
final AgreementRoleType debtorOfMandate = agreementRoleTypeRepository.findByAgreementTypeAndTitle(bankMandateAt, BankMandateAgreementRoleTypeEnum.DEBTOR.getTitle());
final List<AgreementRole> agreementRoles = agreementRoleRepository.findByPartyAndType(party, debtorOfMandate);
final List<BankMandateDto> mandateDtos = agreementRoles.stream().map(x -> x.getAgreement()).map(x -> bankMandateDtoFactory.newDto((BankMandate) x)).collect(Collectors.toList());
dto.setBankMandates(mandateDtos);
return dto;
}
Aggregations