use of org.estatio.module.agreement.dom.role.AgreementRoleType 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.estatio.module.agreement.dom.role.AgreementRoleType in project estatio by estatio.
the class LeaseRepository method newLease.
@Programmatic
public Lease newLease(final ApplicationTenancy applicationTenancy, final String reference, final String name, final LeaseType leaseType, final LocalDate startDate, final LocalDate endDate, final LocalDate tenancyStartDate, final LocalDate tenancyEndDate, final Party landlord, final Party tenant) {
Lease lease = newTransientInstance();
final AgreementType at = agreementTypeRepository.find(LeaseAgreementTypeEnum.LEASE.getTitle());
lease.setType(at);
lease.setApplicationTenancyPath(applicationTenancy.getPath());
lease.setReference(reference);
lease.setName(name);
lease.setStartDate(startDate);
lease.setEndDate(endDate);
lease.setTenancyStartDate(tenancyStartDate);
lease.setTenancyEndDate(tenancyEndDate);
lease.setLeaseType(leaseType);
persistIfNotAlready(lease);
if (tenant != null) {
final AgreementRoleType artTenant = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
lease.newRole(artTenant, tenant, null, null);
}
if (landlord != null) {
final AgreementRoleType artLandlord = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.LANDLORD);
lease.newRole(artLandlord, landlord, null, null);
}
return lease;
}
use of org.estatio.module.agreement.dom.role.AgreementRoleType 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