Search in sources :

Example 11 with AgreementRole

use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.

the class LeaseBuilder method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    checkParam("reference", executionContext, String.class);
    checkParam("name", executionContext, String.class);
    checkParam("property", executionContext, Unit.class);
    checkParam("landlord", executionContext, Party.class);
    checkParam("tenant", executionContext, Party.class);
    checkParam("startDate", executionContext, LocalDate.class);
    checkParam("endDate", executionContext, LocalDate.class);
    defaultParam("invoiceAddressCreationPolicy", executionContext, InvoiceAddressCreationPolicy.DONT_CREATE);
    defaultParam("addressesCreationPolicy", executionContext, AddressesCreationPolicy.DONT_CREATE);
    landlord.addRole(LeaseRoleTypeEnum.LANDLORD);
    tenant.addRole(LeaseRoleTypeEnum.TENANT);
    final ApplicationTenancy atPath = ApplicationTenancy_enum.Global.findUsing(serviceRegistry);
    final LeaseType leaseType = leaseTypeRepository.findOrCreate("STD", "Standard", atPath);
    Lease lease = leaseRepository.newLease(property.getApplicationTenancy(), reference, name, leaseType, startDate, null, endDate, landlord, tenant);
    executionContext.addResult(this, lease.getReference(), lease);
    if (manager != null) {
        final AgreementRole role = lease.createRole(agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.MANAGER), manager, null, null);
        executionContext.addResult(this, role);
    }
    for (final OccupancySpec spec : occupancySpecs) {
        Occupancy occupancy = occupancyRepository.newOccupancy(lease, spec.unit, spec.startDate);
        occupancy.setEndDate(spec.endDate);
        occupancy.setBrandName(spec.brand, spec.brandCoverage, spec.countryOfOrigin);
        occupancy.setSectorName(spec.sector);
        occupancy.setActivityName(spec.activity);
        executionContext.addResult(this, occupancy);
    }
    if (invoiceAddressCreationPolicy == InvoiceAddressCreationPolicy.CREATE) {
        addInvoiceAddressForTenant(lease, tenant, CommunicationChannelType.EMAIL_ADDRESS);
    }
    if (addressesCreationPolicy == AddressesCreationPolicy.CREATE) {
        createAddress(lease, AgreementRoleCommunicationChannelTypeEnum.ADMINISTRATION_ADDRESS);
        createAddress(lease, AgreementRoleCommunicationChannelTypeEnum.INVOICE_ADDRESS);
    }
    if (leaseRepository.findLeaseByReference(reference) == null) {
        throw new RuntimeException("could not find lease reference='" + reference + "'");
    }
    object = lease;
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Lease(org.estatio.module.lease.dom.Lease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) LeaseType(org.estatio.module.lease.dom.LeaseType) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 12 with AgreementRole

use of org.estatio.module.agreement.dom.AgreementRole 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

AgreementRole (org.estatio.module.agreement.dom.AgreementRole)12 Party (org.estatio.module.party.dom.Party)8 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)7 Programmatic (org.apache.isis.applib.annotation.Programmatic)5 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)4 List (java.util.List)3 AgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType)3 Lease (org.estatio.module.lease.dom.Lease)3 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)3 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 AgreementType (org.estatio.module.agreement.dom.type.AgreementType)2 Unit (org.estatio.module.asset.dom.Unit)2 BankMandate (org.estatio.module.bankmandate.dom.BankMandate)2 LeaseType (org.estatio.module.lease.dom.LeaseType)2 Country (org.incode.module.country.dom.impl.Country)2 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1