Search in sources :

Example 11 with AgreementRoleType

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;
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Party(org.estatio.module.party.dom.Party) ApplicationException(org.apache.isis.applib.ApplicationException) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) Lease(org.estatio.module.lease.dom.Lease) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) ArrayList(java.util.ArrayList) Country(org.incode.module.country.dom.impl.Country) DomainObject(org.apache.isis.applib.annotation.DomainObject) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 12 with AgreementRoleType

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;
}
Also used : AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 13 with AgreementRoleType

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;
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)13 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)7 Party (org.estatio.module.party.dom.Party)7 Programmatic (org.apache.isis.applib.annotation.Programmatic)6 AgreementType (org.estatio.module.agreement.dom.type.AgreementType)5 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)5 List (java.util.List)4 AgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType)4 ArrayList (java.util.ArrayList)2 Inject (javax.inject.Inject)2 AgreementRoleCommunicationChannel (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel)2 IAgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType)2 AgreementRoleTypeRepository (org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository)2 BankMandate (org.estatio.module.bankmandate.dom.BankMandate)2 FinancialAccount (org.estatio.module.financial.dom.FinancialAccount)2 FinancialAccountType (org.estatio.module.financial.dom.FinancialAccountType)2 Lease (org.estatio.module.lease.dom.Lease)2 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Optional (java.util.Optional)1